@upstash/qstash 2.7.18 → 2.7.19

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.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Receiver,
3
3
  serve
4
- } from "./chunk-A3H5A6JL.mjs";
4
+ } from "./chunk-S5ODGXCI.mjs";
5
5
 
6
6
  // node_modules/defu/dist/defu.mjs
7
7
  function isPlainObject(value) {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  BaseProvider
3
- } from "./chunk-A3H5A6JL.mjs";
3
+ } from "./chunk-S5ODGXCI.mjs";
4
4
 
5
5
  // src/client/api/email.ts
6
6
  var EmailProvider = class extends BaseProvider {
@@ -16,7 +16,7 @@ var EmailProvider = class extends BaseProvider {
16
16
  }
17
17
  getHeaders(_options) {
18
18
  return {
19
- "upstash-forward-authorization": `Bearer ${this.token}`
19
+ authorization: `Bearer ${this.token}`
20
20
  };
21
21
  }
22
22
  onFinish(providerInfo, _options) {
@@ -201,6 +201,7 @@ var HttpClient = class {
201
201
  authorization;
202
202
  options;
203
203
  retry;
204
+ headers;
204
205
  constructor(config) {
205
206
  this.baseUrl = config.baseUrl.replace(/\/$/, "");
206
207
  this.authorization = config.authorization;
@@ -212,6 +213,7 @@ var HttpClient = class {
212
213
  attempts: config.retry?.retries ?? 5,
213
214
  backoff: config.retry?.backoff ?? ((retryCount) => Math.exp(retryCount) * 50)
214
215
  };
216
+ this.headers = config.headers;
215
217
  }
216
218
  async request(request) {
217
219
  const { response } = await this.requestWithBackoff(request);
@@ -722,6 +724,16 @@ function prefixHeaders(headers) {
722
724
  }
723
725
  return headers;
724
726
  }
727
+ function wrapWithGlobalHeaders(headers, globalHeaders) {
728
+ if (!globalHeaders) {
729
+ return headers;
730
+ }
731
+ const finalHeaders = new Headers(globalHeaders);
732
+ headers.forEach((value, key) => {
733
+ finalHeaders.set(key, value);
734
+ });
735
+ return finalHeaders;
736
+ }
725
737
  function processHeaders(request) {
726
738
  const headers = prefixHeaders(new Headers(request.headers));
727
739
  headers.set("Upstash-Method", request.method ?? "POST");
@@ -868,7 +880,10 @@ var Queue = class {
868
880
  if (!this.queueName) {
869
881
  throw new Error("Please provide a queue name to the Queue constructor");
870
882
  }
871
- const headers = processHeaders(request);
883
+ const headers = wrapWithGlobalHeaders(
884
+ processHeaders(request),
885
+ this.http.headers
886
+ );
872
887
  const destination = getRequestPath(request);
873
888
  const response = await this.http.request({
874
889
  path: ["v2", "enqueue", this.queueName, destination],
@@ -888,8 +903,7 @@ var Queue = class {
888
903
  const nonApiRequest = processApi(request, headers, upstashToken);
889
904
  const response = await this.enqueue({
890
905
  ...nonApiRequest,
891
- body: JSON.stringify(nonApiRequest.body),
892
- headers
906
+ body: JSON.stringify(nonApiRequest.body)
893
907
  });
894
908
  return response;
895
909
  }
@@ -973,7 +987,7 @@ var Schedules = class {
973
987
  }
974
988
  return await this.http.request({
975
989
  method: "POST",
976
- headers,
990
+ headers: wrapWithGlobalHeaders(headers, this.http.headers),
977
991
  path: ["v2", "schedules", request.destination],
978
992
  body: request.body
979
993
  });
@@ -1099,7 +1113,9 @@ var Client = class {
1099
1113
  this.http = new HttpClient({
1100
1114
  retry: config.retry,
1101
1115
  baseUrl: config.baseUrl ? config.baseUrl.replace(/\/$/, "") : "https://qstash.upstash.io",
1102
- authorization: `Bearer ${config.token}`
1116
+ authorization: `Bearer ${config.token}`,
1117
+ //@ts-expect-error caused by undici and bunjs type overlap
1118
+ headers: prefixHeaders(new Headers(config.headers))
1103
1119
  });
1104
1120
  this.token = config.token;
1105
1121
  }
@@ -1174,7 +1190,10 @@ var Client = class {
1174
1190
  return new Chat(this.http, this.token);
1175
1191
  }
1176
1192
  async publish(request) {
1177
- const headers = processHeaders(request);
1193
+ const headers = wrapWithGlobalHeaders(
1194
+ processHeaders(request),
1195
+ this.http.headers
1196
+ );
1178
1197
  const response = await this.http.request({
1179
1198
  path: ["v2", "publish", getRequestPath(request)],
1180
1199
  body: request.body,
@@ -1204,7 +1223,7 @@ var Client = class {
1204
1223
  async batch(request) {
1205
1224
  const messages = [];
1206
1225
  for (const message of request) {
1207
- const headers = processHeaders(message);
1226
+ const headers = wrapWithGlobalHeaders(processHeaders(message), this.http.headers);
1208
1227
  const headerEntries = Object.fromEntries(headers.entries());
1209
1228
  messages.push({
1210
1229
  destination: getRequestPath(message),
@@ -362,6 +362,7 @@ type UpstashResponse<TResult> = TResult & {
362
362
  type Requester = {
363
363
  request: <TResult = unknown>(request: UpstashRequest) => Promise<UpstashResponse<TResult>>;
364
364
  requestStream: (request: UpstashRequest) => AsyncIterable<ChatCompletionChunk>;
365
+ headers?: Headers;
365
366
  };
366
367
  type RetryConfig = false | {
367
368
  /**
@@ -1574,6 +1575,11 @@ type ClientConfig = {
1574
1575
  * Configure how the client should retry requests.
1575
1576
  */
1576
1577
  retry?: RetryConfig;
1578
+ /**
1579
+ * Global headers to send with each request.
1580
+ * These can be overridden by the headers in the request.
1581
+ */
1582
+ headers?: HeadersInit;
1577
1583
  };
1578
1584
  type PublishBatchRequest<TBody = BodyInit> = PublishRequest<TBody> & {
1579
1585
  queueName?: string;
@@ -362,6 +362,7 @@ type UpstashResponse<TResult> = TResult & {
362
362
  type Requester = {
363
363
  request: <TResult = unknown>(request: UpstashRequest) => Promise<UpstashResponse<TResult>>;
364
364
  requestStream: (request: UpstashRequest) => AsyncIterable<ChatCompletionChunk>;
365
+ headers?: Headers;
365
366
  };
366
367
  type RetryConfig = false | {
367
368
  /**
@@ -1574,6 +1575,11 @@ type ClientConfig = {
1574
1575
  * Configure how the client should retry requests.
1575
1576
  */
1576
1577
  retry?: RetryConfig;
1578
+ /**
1579
+ * Global headers to send with each request.
1580
+ * These can be overridden by the headers in the request.
1581
+ */
1582
+ headers?: HeadersInit;
1577
1583
  };
1578
1584
  type PublishBatchRequest<TBody = BodyInit> = PublishRequest<TBody> & {
1579
1585
  queueName?: string;
package/cloudflare.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-B0bFJMw6.mjs';
1
+ import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-CdYtp0E1.mjs';
2
2
  import 'neverthrow';
3
3
 
4
4
  type WorkflowBindings = {
package/cloudflare.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-B0bFJMw6.js';
1
+ import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-CdYtp0E1.js';
2
2
  import 'neverthrow';
3
3
 
4
4
  type WorkflowBindings = {
package/cloudflare.js CHANGED
@@ -237,6 +237,7 @@ var HttpClient = class {
237
237
  authorization;
238
238
  options;
239
239
  retry;
240
+ headers;
240
241
  constructor(config) {
241
242
  this.baseUrl = config.baseUrl.replace(/\/$/, "");
242
243
  this.authorization = config.authorization;
@@ -248,6 +249,7 @@ var HttpClient = class {
248
249
  attempts: config.retry?.retries ?? 5,
249
250
  backoff: config.retry?.backoff ?? ((retryCount) => Math.exp(retryCount) * 50)
250
251
  };
252
+ this.headers = config.headers;
251
253
  }
252
254
  async request(request) {
253
255
  const { response } = await this.requestWithBackoff(request);
@@ -742,6 +744,16 @@ function prefixHeaders(headers) {
742
744
  }
743
745
  return headers;
744
746
  }
747
+ function wrapWithGlobalHeaders(headers, globalHeaders) {
748
+ if (!globalHeaders) {
749
+ return headers;
750
+ }
751
+ const finalHeaders = new Headers(globalHeaders);
752
+ headers.forEach((value, key) => {
753
+ finalHeaders.set(key, value);
754
+ });
755
+ return finalHeaders;
756
+ }
745
757
  function processHeaders(request) {
746
758
  const headers = prefixHeaders(new Headers(request.headers));
747
759
  headers.set("Upstash-Method", request.method ?? "POST");
@@ -888,7 +900,10 @@ var Queue = class {
888
900
  if (!this.queueName) {
889
901
  throw new Error("Please provide a queue name to the Queue constructor");
890
902
  }
891
- const headers = processHeaders(request);
903
+ const headers = wrapWithGlobalHeaders(
904
+ processHeaders(request),
905
+ this.http.headers
906
+ );
892
907
  const destination = getRequestPath(request);
893
908
  const response = await this.http.request({
894
909
  path: ["v2", "enqueue", this.queueName, destination],
@@ -908,8 +923,7 @@ var Queue = class {
908
923
  const nonApiRequest = processApi(request, headers, upstashToken);
909
924
  const response = await this.enqueue({
910
925
  ...nonApiRequest,
911
- body: JSON.stringify(nonApiRequest.body),
912
- headers
926
+ body: JSON.stringify(nonApiRequest.body)
913
927
  });
914
928
  return response;
915
929
  }
@@ -993,7 +1007,7 @@ var Schedules = class {
993
1007
  }
994
1008
  return await this.http.request({
995
1009
  method: "POST",
996
- headers,
1010
+ headers: wrapWithGlobalHeaders(headers, this.http.headers),
997
1011
  path: ["v2", "schedules", request.destination],
998
1012
  body: request.body
999
1013
  });
@@ -1119,7 +1133,9 @@ var Client = class {
1119
1133
  this.http = new HttpClient({
1120
1134
  retry: config.retry,
1121
1135
  baseUrl: config.baseUrl ? config.baseUrl.replace(/\/$/, "") : "https://qstash.upstash.io",
1122
- authorization: `Bearer ${config.token}`
1136
+ authorization: `Bearer ${config.token}`,
1137
+ //@ts-expect-error caused by undici and bunjs type overlap
1138
+ headers: prefixHeaders(new Headers(config.headers))
1123
1139
  });
1124
1140
  this.token = config.token;
1125
1141
  }
@@ -1194,7 +1210,10 @@ var Client = class {
1194
1210
  return new Chat(this.http, this.token);
1195
1211
  }
1196
1212
  async publish(request) {
1197
- const headers = processHeaders(request);
1213
+ const headers = wrapWithGlobalHeaders(
1214
+ processHeaders(request),
1215
+ this.http.headers
1216
+ );
1198
1217
  const response = await this.http.request({
1199
1218
  path: ["v2", "publish", getRequestPath(request)],
1200
1219
  body: request.body,
@@ -1224,7 +1243,7 @@ var Client = class {
1224
1243
  async batch(request) {
1225
1244
  const messages = [];
1226
1245
  for (const message of request) {
1227
- const headers = processHeaders(message);
1246
+ const headers = wrapWithGlobalHeaders(processHeaders(message), this.http.headers);
1228
1247
  const headerEntries = Object.fromEntries(headers.entries());
1229
1248
  messages.push({
1230
1249
  destination: getRequestPath(message),
package/cloudflare.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  serve
3
- } from "./chunk-A3H5A6JL.mjs";
3
+ } from "./chunk-S5ODGXCI.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-B0bFJMw6.mjs';
3
+ import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-CdYtp0E1.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 { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-B0bFJMw6.js';
3
+ import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-CdYtp0E1.js';
4
4
  import 'neverthrow';
5
5
 
6
6
  type VerifySignatureConfig = {
package/h3.js CHANGED
@@ -561,6 +561,7 @@ var HttpClient = class {
561
561
  authorization;
562
562
  options;
563
563
  retry;
564
+ headers;
564
565
  constructor(config) {
565
566
  this.baseUrl = config.baseUrl.replace(/\/$/, "");
566
567
  this.authorization = config.authorization;
@@ -572,6 +573,7 @@ var HttpClient = class {
572
573
  attempts: config.retry?.retries ?? 5,
573
574
  backoff: config.retry?.backoff ?? ((retryCount) => Math.exp(retryCount) * 50)
574
575
  };
576
+ this.headers = config.headers;
575
577
  }
576
578
  async request(request) {
577
579
  const { response } = await this.requestWithBackoff(request);
@@ -1066,6 +1068,16 @@ function prefixHeaders(headers) {
1066
1068
  }
1067
1069
  return headers;
1068
1070
  }
1071
+ function wrapWithGlobalHeaders(headers, globalHeaders) {
1072
+ if (!globalHeaders) {
1073
+ return headers;
1074
+ }
1075
+ const finalHeaders = new Headers(globalHeaders);
1076
+ headers.forEach((value, key) => {
1077
+ finalHeaders.set(key, value);
1078
+ });
1079
+ return finalHeaders;
1080
+ }
1069
1081
  function processHeaders(request) {
1070
1082
  const headers = prefixHeaders(new Headers(request.headers));
1071
1083
  headers.set("Upstash-Method", request.method ?? "POST");
@@ -1212,7 +1224,10 @@ var Queue = class {
1212
1224
  if (!this.queueName) {
1213
1225
  throw new Error("Please provide a queue name to the Queue constructor");
1214
1226
  }
1215
- const headers = processHeaders(request);
1227
+ const headers = wrapWithGlobalHeaders(
1228
+ processHeaders(request),
1229
+ this.http.headers
1230
+ );
1216
1231
  const destination = getRequestPath(request);
1217
1232
  const response = await this.http.request({
1218
1233
  path: ["v2", "enqueue", this.queueName, destination],
@@ -1232,8 +1247,7 @@ var Queue = class {
1232
1247
  const nonApiRequest = processApi(request, headers, upstashToken);
1233
1248
  const response = await this.enqueue({
1234
1249
  ...nonApiRequest,
1235
- body: JSON.stringify(nonApiRequest.body),
1236
- headers
1250
+ body: JSON.stringify(nonApiRequest.body)
1237
1251
  });
1238
1252
  return response;
1239
1253
  }
@@ -1317,7 +1331,7 @@ var Schedules = class {
1317
1331
  }
1318
1332
  return await this.http.request({
1319
1333
  method: "POST",
1320
- headers,
1334
+ headers: wrapWithGlobalHeaders(headers, this.http.headers),
1321
1335
  path: ["v2", "schedules", request.destination],
1322
1336
  body: request.body
1323
1337
  });
@@ -2829,7 +2843,9 @@ var Client = class {
2829
2843
  this.http = new HttpClient({
2830
2844
  retry: config.retry,
2831
2845
  baseUrl: config.baseUrl ? config.baseUrl.replace(/\/$/, "") : "https://qstash.upstash.io",
2832
- authorization: `Bearer ${config.token}`
2846
+ authorization: `Bearer ${config.token}`,
2847
+ //@ts-expect-error caused by undici and bunjs type overlap
2848
+ headers: prefixHeaders(new Headers(config.headers))
2833
2849
  });
2834
2850
  this.token = config.token;
2835
2851
  }
@@ -2904,7 +2920,10 @@ var Client = class {
2904
2920
  return new Chat(this.http, this.token);
2905
2921
  }
2906
2922
  async publish(request) {
2907
- const headers = processHeaders(request);
2923
+ const headers = wrapWithGlobalHeaders(
2924
+ processHeaders(request),
2925
+ this.http.headers
2926
+ );
2908
2927
  const response = await this.http.request({
2909
2928
  path: ["v2", "publish", getRequestPath(request)],
2910
2929
  body: request.body,
@@ -2934,7 +2953,7 @@ var Client = class {
2934
2953
  async batch(request) {
2935
2954
  const messages = [];
2936
2955
  for (const message of request) {
2937
- const headers = processHeaders(message);
2956
+ const headers = wrapWithGlobalHeaders(processHeaders(message), this.http.headers);
2938
2957
  const headerEntries = Object.fromEntries(headers.entries());
2939
2958
  messages.push({
2940
2959
  destination: getRequestPath(message),
package/h3.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  serve,
3
3
  verifySignatureH3
4
- } from "./chunk-A5VKSI7H.mjs";
5
- import "./chunk-K2ZUMNWA.mjs";
6
- import "./chunk-A3H5A6JL.mjs";
4
+ } from "./chunk-L2DZYBAR.mjs";
5
+ import "./chunk-RNFKMAEP.mjs";
6
+ import "./chunk-S5ODGXCI.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-B0bFJMw6.mjs';
2
+ import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-CdYtp0E1.mjs';
3
3
  import 'neverthrow';
4
4
 
5
5
  type WorkflowBindings = {
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-B0bFJMw6.js';
2
+ import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-CdYtp0E1.js';
3
3
  import 'neverthrow';
4
4
 
5
5
  type WorkflowBindings = {
package/hono.js CHANGED
@@ -237,6 +237,7 @@ var HttpClient = class {
237
237
  authorization;
238
238
  options;
239
239
  retry;
240
+ headers;
240
241
  constructor(config) {
241
242
  this.baseUrl = config.baseUrl.replace(/\/$/, "");
242
243
  this.authorization = config.authorization;
@@ -248,6 +249,7 @@ var HttpClient = class {
248
249
  attempts: config.retry?.retries ?? 5,
249
250
  backoff: config.retry?.backoff ?? ((retryCount) => Math.exp(retryCount) * 50)
250
251
  };
252
+ this.headers = config.headers;
251
253
  }
252
254
  async request(request) {
253
255
  const { response } = await this.requestWithBackoff(request);
@@ -742,6 +744,16 @@ function prefixHeaders(headers) {
742
744
  }
743
745
  return headers;
744
746
  }
747
+ function wrapWithGlobalHeaders(headers, globalHeaders) {
748
+ if (!globalHeaders) {
749
+ return headers;
750
+ }
751
+ const finalHeaders = new Headers(globalHeaders);
752
+ headers.forEach((value, key) => {
753
+ finalHeaders.set(key, value);
754
+ });
755
+ return finalHeaders;
756
+ }
745
757
  function processHeaders(request) {
746
758
  const headers = prefixHeaders(new Headers(request.headers));
747
759
  headers.set("Upstash-Method", request.method ?? "POST");
@@ -888,7 +900,10 @@ var Queue = class {
888
900
  if (!this.queueName) {
889
901
  throw new Error("Please provide a queue name to the Queue constructor");
890
902
  }
891
- const headers = processHeaders(request);
903
+ const headers = wrapWithGlobalHeaders(
904
+ processHeaders(request),
905
+ this.http.headers
906
+ );
892
907
  const destination = getRequestPath(request);
893
908
  const response = await this.http.request({
894
909
  path: ["v2", "enqueue", this.queueName, destination],
@@ -908,8 +923,7 @@ var Queue = class {
908
923
  const nonApiRequest = processApi(request, headers, upstashToken);
909
924
  const response = await this.enqueue({
910
925
  ...nonApiRequest,
911
- body: JSON.stringify(nonApiRequest.body),
912
- headers
926
+ body: JSON.stringify(nonApiRequest.body)
913
927
  });
914
928
  return response;
915
929
  }
@@ -993,7 +1007,7 @@ var Schedules = class {
993
1007
  }
994
1008
  return await this.http.request({
995
1009
  method: "POST",
996
- headers,
1010
+ headers: wrapWithGlobalHeaders(headers, this.http.headers),
997
1011
  path: ["v2", "schedules", request.destination],
998
1012
  body: request.body
999
1013
  });
@@ -1119,7 +1133,9 @@ var Client = class {
1119
1133
  this.http = new HttpClient({
1120
1134
  retry: config.retry,
1121
1135
  baseUrl: config.baseUrl ? config.baseUrl.replace(/\/$/, "") : "https://qstash.upstash.io",
1122
- authorization: `Bearer ${config.token}`
1136
+ authorization: `Bearer ${config.token}`,
1137
+ //@ts-expect-error caused by undici and bunjs type overlap
1138
+ headers: prefixHeaders(new Headers(config.headers))
1123
1139
  });
1124
1140
  this.token = config.token;
1125
1141
  }
@@ -1194,7 +1210,10 @@ var Client = class {
1194
1210
  return new Chat(this.http, this.token);
1195
1211
  }
1196
1212
  async publish(request) {
1197
- const headers = processHeaders(request);
1213
+ const headers = wrapWithGlobalHeaders(
1214
+ processHeaders(request),
1215
+ this.http.headers
1216
+ );
1198
1217
  const response = await this.http.request({
1199
1218
  path: ["v2", "publish", getRequestPath(request)],
1200
1219
  body: request.body,
@@ -1224,7 +1243,7 @@ var Client = class {
1224
1243
  async batch(request) {
1225
1244
  const messages = [];
1226
1245
  for (const message of request) {
1227
- const headers = processHeaders(message);
1246
+ const headers = wrapWithGlobalHeaders(processHeaders(message), this.http.headers);
1228
1247
  const headerEntries = Object.fromEntries(headers.entries());
1229
1248
  messages.push({
1230
1249
  destination: getRequestPath(message),
package/hono.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  serve
3
- } from "./chunk-A3H5A6JL.mjs";
3
+ } from "./chunk-S5ODGXCI.mjs";
4
4
 
5
5
  // platforms/hono.ts
6
6
  var serve2 = (routeFunction, options) => {
package/index.d.mts CHANGED
@@ -1,5 +1,5 @@
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';
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-CdYtp0E1.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-CdYtp0E1.mjs';
3
3
  import 'neverthrow';
4
4
 
5
5
  /**
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
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';
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-CdYtp0E1.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-CdYtp0E1.js';
3
3
  import 'neverthrow';
4
4
 
5
5
  /**
package/index.js CHANGED
@@ -257,6 +257,7 @@ var HttpClient = class {
257
257
  authorization;
258
258
  options;
259
259
  retry;
260
+ headers;
260
261
  constructor(config) {
261
262
  this.baseUrl = config.baseUrl.replace(/\/$/, "");
262
263
  this.authorization = config.authorization;
@@ -268,6 +269,7 @@ var HttpClient = class {
268
269
  attempts: config.retry?.retries ?? 5,
269
270
  backoff: config.retry?.backoff ?? ((retryCount) => Math.exp(retryCount) * 50)
270
271
  };
272
+ this.headers = config.headers;
271
273
  }
272
274
  async request(request) {
273
275
  const { response } = await this.requestWithBackoff(request);
@@ -778,6 +780,16 @@ function prefixHeaders(headers) {
778
780
  }
779
781
  return headers;
780
782
  }
783
+ function wrapWithGlobalHeaders(headers, globalHeaders) {
784
+ if (!globalHeaders) {
785
+ return headers;
786
+ }
787
+ const finalHeaders = new Headers(globalHeaders);
788
+ headers.forEach((value, key) => {
789
+ finalHeaders.set(key, value);
790
+ });
791
+ return finalHeaders;
792
+ }
781
793
  function processHeaders(request) {
782
794
  const headers = prefixHeaders(new Headers(request.headers));
783
795
  headers.set("Upstash-Method", request.method ?? "POST");
@@ -919,7 +931,10 @@ var Queue = class {
919
931
  if (!this.queueName) {
920
932
  throw new Error("Please provide a queue name to the Queue constructor");
921
933
  }
922
- const headers = processHeaders(request);
934
+ const headers = wrapWithGlobalHeaders(
935
+ processHeaders(request),
936
+ this.http.headers
937
+ );
923
938
  const destination = getRequestPath(request);
924
939
  const response = await this.http.request({
925
940
  path: ["v2", "enqueue", this.queueName, destination],
@@ -939,8 +954,7 @@ var Queue = class {
939
954
  const nonApiRequest = processApi(request, headers, upstashToken);
940
955
  const response = await this.enqueue({
941
956
  ...nonApiRequest,
942
- body: JSON.stringify(nonApiRequest.body),
943
- headers
957
+ body: JSON.stringify(nonApiRequest.body)
944
958
  });
945
959
  return response;
946
960
  }
@@ -1024,7 +1038,7 @@ var Schedules = class {
1024
1038
  }
1025
1039
  return await this.http.request({
1026
1040
  method: "POST",
1027
- headers,
1041
+ headers: wrapWithGlobalHeaders(headers, this.http.headers),
1028
1042
  path: ["v2", "schedules", request.destination],
1029
1043
  body: request.body
1030
1044
  });
@@ -1181,7 +1195,9 @@ var Client = class {
1181
1195
  this.http = new HttpClient({
1182
1196
  retry: config.retry,
1183
1197
  baseUrl: config.baseUrl ? config.baseUrl.replace(/\/$/, "") : "https://qstash.upstash.io",
1184
- authorization: `Bearer ${config.token}`
1198
+ authorization: `Bearer ${config.token}`,
1199
+ //@ts-expect-error caused by undici and bunjs type overlap
1200
+ headers: prefixHeaders(new Headers(config.headers))
1185
1201
  });
1186
1202
  this.token = config.token;
1187
1203
  }
@@ -1256,7 +1272,10 @@ var Client = class {
1256
1272
  return new Chat(this.http, this.token);
1257
1273
  }
1258
1274
  async publish(request) {
1259
- const headers = processHeaders(request);
1275
+ const headers = wrapWithGlobalHeaders(
1276
+ processHeaders(request),
1277
+ this.http.headers
1278
+ );
1260
1279
  const response = await this.http.request({
1261
1280
  path: ["v2", "publish", getRequestPath(request)],
1262
1281
  body: request.body,
@@ -1286,7 +1305,7 @@ var Client = class {
1286
1305
  async batch(request) {
1287
1306
  const messages = [];
1288
1307
  for (const message of request) {
1289
- const headers = processHeaders(message);
1308
+ const headers = wrapWithGlobalHeaders(processHeaders(message), this.http.headers);
1290
1309
  const headerEntries = Object.fromEntries(headers.entries());
1291
1310
  messages.push({
1292
1311
  destination: getRequestPath(message),
@@ -1389,7 +1408,7 @@ var EmailProvider = class extends BaseProvider {
1389
1408
  }
1390
1409
  getHeaders(_options) {
1391
1410
  return {
1392
- "upstash-forward-authorization": `Bearer ${this.token}`
1411
+ authorization: `Bearer ${this.token}`
1393
1412
  };
1394
1413
  }
1395
1414
  onFinish(providerInfo, _options) {
package/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  resend
3
- } from "./chunk-K2ZUMNWA.mjs";
3
+ } from "./chunk-RNFKMAEP.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-A3H5A6JL.mjs";
25
+ } from "./chunk-S5ODGXCI.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-B0bFJMw6.mjs';
3
+ import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-CdYtp0E1.mjs';
4
4
  import 'neverthrow';
5
5
 
6
6
  type VerifySignatureConfig = {
package/nextjs.d.ts 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-B0bFJMw6.js';
3
+ import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-CdYtp0E1.js';
4
4
  import 'neverthrow';
5
5
 
6
6
  type VerifySignatureConfig = {
package/nextjs.js CHANGED
@@ -241,6 +241,7 @@ var HttpClient = class {
241
241
  authorization;
242
242
  options;
243
243
  retry;
244
+ headers;
244
245
  constructor(config) {
245
246
  this.baseUrl = config.baseUrl.replace(/\/$/, "");
246
247
  this.authorization = config.authorization;
@@ -252,6 +253,7 @@ var HttpClient = class {
252
253
  attempts: config.retry?.retries ?? 5,
253
254
  backoff: config.retry?.backoff ?? ((retryCount) => Math.exp(retryCount) * 50)
254
255
  };
256
+ this.headers = config.headers;
255
257
  }
256
258
  async request(request) {
257
259
  const { response } = await this.requestWithBackoff(request);
@@ -746,6 +748,16 @@ function prefixHeaders(headers) {
746
748
  }
747
749
  return headers;
748
750
  }
751
+ function wrapWithGlobalHeaders(headers, globalHeaders) {
752
+ if (!globalHeaders) {
753
+ return headers;
754
+ }
755
+ const finalHeaders = new Headers(globalHeaders);
756
+ headers.forEach((value, key) => {
757
+ finalHeaders.set(key, value);
758
+ });
759
+ return finalHeaders;
760
+ }
749
761
  function processHeaders(request) {
750
762
  const headers = prefixHeaders(new Headers(request.headers));
751
763
  headers.set("Upstash-Method", request.method ?? "POST");
@@ -892,7 +904,10 @@ var Queue = class {
892
904
  if (!this.queueName) {
893
905
  throw new Error("Please provide a queue name to the Queue constructor");
894
906
  }
895
- const headers = processHeaders(request);
907
+ const headers = wrapWithGlobalHeaders(
908
+ processHeaders(request),
909
+ this.http.headers
910
+ );
896
911
  const destination = getRequestPath(request);
897
912
  const response = await this.http.request({
898
913
  path: ["v2", "enqueue", this.queueName, destination],
@@ -912,8 +927,7 @@ var Queue = class {
912
927
  const nonApiRequest = processApi(request, headers, upstashToken);
913
928
  const response = await this.enqueue({
914
929
  ...nonApiRequest,
915
- body: JSON.stringify(nonApiRequest.body),
916
- headers
930
+ body: JSON.stringify(nonApiRequest.body)
917
931
  });
918
932
  return response;
919
933
  }
@@ -997,7 +1011,7 @@ var Schedules = class {
997
1011
  }
998
1012
  return await this.http.request({
999
1013
  method: "POST",
1000
- headers,
1014
+ headers: wrapWithGlobalHeaders(headers, this.http.headers),
1001
1015
  path: ["v2", "schedules", request.destination],
1002
1016
  body: request.body
1003
1017
  });
@@ -1123,7 +1137,9 @@ var Client = class {
1123
1137
  this.http = new HttpClient({
1124
1138
  retry: config.retry,
1125
1139
  baseUrl: config.baseUrl ? config.baseUrl.replace(/\/$/, "") : "https://qstash.upstash.io",
1126
- authorization: `Bearer ${config.token}`
1140
+ authorization: `Bearer ${config.token}`,
1141
+ //@ts-expect-error caused by undici and bunjs type overlap
1142
+ headers: prefixHeaders(new Headers(config.headers))
1127
1143
  });
1128
1144
  this.token = config.token;
1129
1145
  }
@@ -1198,7 +1214,10 @@ var Client = class {
1198
1214
  return new Chat(this.http, this.token);
1199
1215
  }
1200
1216
  async publish(request) {
1201
- const headers = processHeaders(request);
1217
+ const headers = wrapWithGlobalHeaders(
1218
+ processHeaders(request),
1219
+ this.http.headers
1220
+ );
1202
1221
  const response = await this.http.request({
1203
1222
  path: ["v2", "publish", getRequestPath(request)],
1204
1223
  body: request.body,
@@ -1228,7 +1247,7 @@ var Client = class {
1228
1247
  async batch(request) {
1229
1248
  const messages = [];
1230
1249
  for (const message of request) {
1231
- const headers = processHeaders(message);
1250
+ const headers = wrapWithGlobalHeaders(processHeaders(message), this.http.headers);
1232
1251
  const headerEntries = Object.fromEntries(headers.entries());
1233
1252
  messages.push({
1234
1253
  destination: getRequestPath(message),
package/nextjs.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Receiver,
3
3
  serve
4
- } from "./chunk-A3H5A6JL.mjs";
4
+ } from "./chunk-S5ODGXCI.mjs";
5
5
 
6
6
  // platforms/nextjs.ts
7
7
  var BAD_REQUEST = 400;
package/nuxt.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  verifySignatureH3
3
- } from "./chunk-A5VKSI7H.mjs";
4
- import "./chunk-K2ZUMNWA.mjs";
5
- import "./chunk-A3H5A6JL.mjs";
3
+ } from "./chunk-L2DZYBAR.mjs";
4
+ import "./chunk-RNFKMAEP.mjs";
5
+ import "./chunk-S5ODGXCI.mjs";
6
6
 
7
7
  // platforms/nuxt.ts
8
8
  var verifySignatureNuxt = verifySignatureH3;
package/package.json CHANGED
@@ -1 +1 @@
1
- {"version":"v2.7.18","name":"@upstash/qstash","description":"Official Typescript client for QStash","author":"Andreas Thomas <dev@chronark.com>","license":"MIT","homepage":"https://github.com/upstash/sdk-qstash-ts#readme","repository":{"type":"git","url":"git+https://github.com/upstash/sdk-qstash-ts.git"},"bugs":{"url":"https://github.com/upstash/sdk-qstash-ts/issues"},"main":"./index.js","module":"./index.mjs","types":"./index.d.ts","files":["./*"],"exports":{".":{"import":"./index.mjs","require":"./index.js"},"./dist/nextjs":{"import":"./nextjs.mjs","require":"./nextjs.js"},"./nextjs":{"import":"./nextjs.mjs","require":"./nextjs.js"},"./h3":{"import":"./h3.mjs","require":"./h3.js"},"./nuxt":{"import":"./nuxt.mjs","require":"./nuxt.js"},"./svelte":{"import":"./svelte.mjs","require":"./svelte.js"},"./solidjs":{"import":"./solidjs.mjs","require":"./solidjs.js"},"./workflow":{"import":"./workflow.mjs","require":"./workflow.js"},"./hono":{"import":"./hono.mjs","require":"./hono.js"},"./cloudflare":{"import":"./cloudflare.mjs","require":"./cloudflare.js"}},"keywords":["qstash","queue","events","serverless","upstash"],"scripts":{"build":"tsup && cp README.md ./dist/ && cp package.json ./dist/ && cp LICENSE ./dist/","test":"bun test src","fmt":"prettier --write .","lint":"tsc && eslint \"{src,platforms}/**/*.{js,ts,tsx}\" --quiet --fix","check-exports":"bun run build && cd dist && attw -P"},"devDependencies":{"@commitlint/cli":"^19.2.2","@commitlint/config-conventional":"^19.2.2","@eslint/eslintrc":"^3.1.0","@eslint/js":"^9.10.0","@solidjs/start":"^1.0.6","@sveltejs/kit":"^2.5.18","@types/bun":"^1.1.1","@types/crypto-js":"^4.2.0","@typescript-eslint/eslint-plugin":"^8.4.0","@typescript-eslint/parser":"^8.4.0","ai":"^3.1.28","bun-types":"^1.1.7","eslint":"^9.10.0","eslint-plugin-unicorn":"^51.0.1","h3":"^1.12.0","hono":"^4.5.8","husky":"^9.0.10","next":"^14.0.2","prettier":"^3.2.5","tsup":"latest","typescript":"^5.4.5","undici-types":"^6.16.0","vitest":"latest"},"dependencies":{"crypto-js":">=4.2.0","jose":"^5.2.3","neverthrow":"^7.0.1"}}
1
+ {"version":"v2.7.19","name":"@upstash/qstash","description":"Official Typescript client for QStash","author":"Andreas Thomas <dev@chronark.com>","license":"MIT","homepage":"https://github.com/upstash/sdk-qstash-ts#readme","repository":{"type":"git","url":"git+https://github.com/upstash/sdk-qstash-ts.git"},"bugs":{"url":"https://github.com/upstash/sdk-qstash-ts/issues"},"main":"./index.js","module":"./index.mjs","types":"./index.d.ts","files":["./*"],"exports":{".":{"import":"./index.mjs","require":"./index.js"},"./dist/nextjs":{"import":"./nextjs.mjs","require":"./nextjs.js"},"./nextjs":{"import":"./nextjs.mjs","require":"./nextjs.js"},"./h3":{"import":"./h3.mjs","require":"./h3.js"},"./nuxt":{"import":"./nuxt.mjs","require":"./nuxt.js"},"./svelte":{"import":"./svelte.mjs","require":"./svelte.js"},"./solidjs":{"import":"./solidjs.mjs","require":"./solidjs.js"},"./workflow":{"import":"./workflow.mjs","require":"./workflow.js"},"./hono":{"import":"./hono.mjs","require":"./hono.js"},"./cloudflare":{"import":"./cloudflare.mjs","require":"./cloudflare.js"}},"keywords":["qstash","queue","events","serverless","upstash"],"scripts":{"build":"tsup && cp README.md ./dist/ && cp package.json ./dist/ && cp LICENSE ./dist/","test":"bun test src","fmt":"prettier --write .","lint":"tsc && eslint \"{src,platforms}/**/*.{js,ts,tsx}\" --quiet --fix","check-exports":"bun run build && cd dist && attw -P"},"devDependencies":{"@commitlint/cli":"^19.2.2","@commitlint/config-conventional":"^19.2.2","@eslint/eslintrc":"^3.1.0","@eslint/js":"^9.10.0","@solidjs/start":"^1.0.6","@sveltejs/kit":"^2.5.18","@types/bun":"^1.1.1","@types/crypto-js":"^4.2.0","@typescript-eslint/eslint-plugin":"^8.4.0","@typescript-eslint/parser":"^8.4.0","ai":"^3.1.28","bun-types":"^1.1.7","eslint":"^9.10.0","eslint-plugin-unicorn":"^51.0.1","h3":"^1.12.0","hono":"^4.5.8","husky":"^9.0.10","next":"^14.0.2","prettier":"^3.2.5","tsup":"latest","typescript":"^5.4.5","undici-types":"^6.16.0","vitest":"latest"},"dependencies":{"crypto-js":">=4.2.0","jose":"^5.2.3","neverthrow":"^7.0.1"}}
package/solidjs.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { APIHandler, APIEvent } from '@solidjs/start/server';
2
- import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-B0bFJMw6.mjs';
2
+ import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-CdYtp0E1.mjs';
3
3
  import 'neverthrow';
4
4
 
5
5
  type VerifySignatureConfig = {
package/solidjs.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { APIHandler, APIEvent } from '@solidjs/start/server';
2
- import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-B0bFJMw6.js';
2
+ import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-CdYtp0E1.js';
3
3
  import 'neverthrow';
4
4
 
5
5
  type VerifySignatureConfig = {
package/solidjs.js CHANGED
@@ -238,6 +238,7 @@ var HttpClient = class {
238
238
  authorization;
239
239
  options;
240
240
  retry;
241
+ headers;
241
242
  constructor(config) {
242
243
  this.baseUrl = config.baseUrl.replace(/\/$/, "");
243
244
  this.authorization = config.authorization;
@@ -249,6 +250,7 @@ var HttpClient = class {
249
250
  attempts: config.retry?.retries ?? 5,
250
251
  backoff: config.retry?.backoff ?? ((retryCount) => Math.exp(retryCount) * 50)
251
252
  };
253
+ this.headers = config.headers;
252
254
  }
253
255
  async request(request) {
254
256
  const { response } = await this.requestWithBackoff(request);
@@ -743,6 +745,16 @@ function prefixHeaders(headers) {
743
745
  }
744
746
  return headers;
745
747
  }
748
+ function wrapWithGlobalHeaders(headers, globalHeaders) {
749
+ if (!globalHeaders) {
750
+ return headers;
751
+ }
752
+ const finalHeaders = new Headers(globalHeaders);
753
+ headers.forEach((value, key) => {
754
+ finalHeaders.set(key, value);
755
+ });
756
+ return finalHeaders;
757
+ }
746
758
  function processHeaders(request) {
747
759
  const headers = prefixHeaders(new Headers(request.headers));
748
760
  headers.set("Upstash-Method", request.method ?? "POST");
@@ -889,7 +901,10 @@ var Queue = class {
889
901
  if (!this.queueName) {
890
902
  throw new Error("Please provide a queue name to the Queue constructor");
891
903
  }
892
- const headers = processHeaders(request);
904
+ const headers = wrapWithGlobalHeaders(
905
+ processHeaders(request),
906
+ this.http.headers
907
+ );
893
908
  const destination = getRequestPath(request);
894
909
  const response = await this.http.request({
895
910
  path: ["v2", "enqueue", this.queueName, destination],
@@ -909,8 +924,7 @@ var Queue = class {
909
924
  const nonApiRequest = processApi(request, headers, upstashToken);
910
925
  const response = await this.enqueue({
911
926
  ...nonApiRequest,
912
- body: JSON.stringify(nonApiRequest.body),
913
- headers
927
+ body: JSON.stringify(nonApiRequest.body)
914
928
  });
915
929
  return response;
916
930
  }
@@ -994,7 +1008,7 @@ var Schedules = class {
994
1008
  }
995
1009
  return await this.http.request({
996
1010
  method: "POST",
997
- headers,
1011
+ headers: wrapWithGlobalHeaders(headers, this.http.headers),
998
1012
  path: ["v2", "schedules", request.destination],
999
1013
  body: request.body
1000
1014
  });
@@ -2506,7 +2520,9 @@ var Client = class {
2506
2520
  this.http = new HttpClient({
2507
2521
  retry: config.retry,
2508
2522
  baseUrl: config.baseUrl ? config.baseUrl.replace(/\/$/, "") : "https://qstash.upstash.io",
2509
- authorization: `Bearer ${config.token}`
2523
+ authorization: `Bearer ${config.token}`,
2524
+ //@ts-expect-error caused by undici and bunjs type overlap
2525
+ headers: prefixHeaders(new Headers(config.headers))
2510
2526
  });
2511
2527
  this.token = config.token;
2512
2528
  }
@@ -2581,7 +2597,10 @@ var Client = class {
2581
2597
  return new Chat(this.http, this.token);
2582
2598
  }
2583
2599
  async publish(request) {
2584
- const headers = processHeaders(request);
2600
+ const headers = wrapWithGlobalHeaders(
2601
+ processHeaders(request),
2602
+ this.http.headers
2603
+ );
2585
2604
  const response = await this.http.request({
2586
2605
  path: ["v2", "publish", getRequestPath(request)],
2587
2606
  body: request.body,
@@ -2611,7 +2630,7 @@ var Client = class {
2611
2630
  async batch(request) {
2612
2631
  const messages = [];
2613
2632
  for (const message of request) {
2614
- const headers = processHeaders(message);
2633
+ const headers = wrapWithGlobalHeaders(processHeaders(message), this.http.headers);
2615
2634
  const headerEntries = Object.fromEntries(headers.entries());
2616
2635
  messages.push({
2617
2636
  destination: getRequestPath(message),
package/solidjs.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import "./chunk-K2ZUMNWA.mjs";
1
+ import "./chunk-RNFKMAEP.mjs";
2
2
  import {
3
3
  Receiver,
4
4
  serve
5
- } from "./chunk-A3H5A6JL.mjs";
5
+ } from "./chunk-S5ODGXCI.mjs";
6
6
 
7
7
  // platforms/solidjs.ts
8
8
  var verifySignatureSolidjs = (handler, config) => {
package/svelte.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { RequestHandler } from '@sveltejs/kit';
2
- import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-B0bFJMw6.mjs';
2
+ import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-CdYtp0E1.mjs';
3
3
  import 'neverthrow';
4
4
 
5
5
  type VerifySignatureConfig = {
package/svelte.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { RequestHandler } from '@sveltejs/kit';
2
- import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-B0bFJMw6.js';
2
+ import { a3 as RouteFunction, a4 as WorkflowServeOptions } from './client-CdYtp0E1.js';
3
3
  import 'neverthrow';
4
4
 
5
5
  type VerifySignatureConfig = {
package/svelte.js CHANGED
@@ -238,6 +238,7 @@ var HttpClient = class {
238
238
  authorization;
239
239
  options;
240
240
  retry;
241
+ headers;
241
242
  constructor(config) {
242
243
  this.baseUrl = config.baseUrl.replace(/\/$/, "");
243
244
  this.authorization = config.authorization;
@@ -249,6 +250,7 @@ var HttpClient = class {
249
250
  attempts: config.retry?.retries ?? 5,
250
251
  backoff: config.retry?.backoff ?? ((retryCount) => Math.exp(retryCount) * 50)
251
252
  };
253
+ this.headers = config.headers;
252
254
  }
253
255
  async request(request) {
254
256
  const { response } = await this.requestWithBackoff(request);
@@ -743,6 +745,16 @@ function prefixHeaders(headers) {
743
745
  }
744
746
  return headers;
745
747
  }
748
+ function wrapWithGlobalHeaders(headers, globalHeaders) {
749
+ if (!globalHeaders) {
750
+ return headers;
751
+ }
752
+ const finalHeaders = new Headers(globalHeaders);
753
+ headers.forEach((value, key) => {
754
+ finalHeaders.set(key, value);
755
+ });
756
+ return finalHeaders;
757
+ }
746
758
  function processHeaders(request) {
747
759
  const headers = prefixHeaders(new Headers(request.headers));
748
760
  headers.set("Upstash-Method", request.method ?? "POST");
@@ -889,7 +901,10 @@ var Queue = class {
889
901
  if (!this.queueName) {
890
902
  throw new Error("Please provide a queue name to the Queue constructor");
891
903
  }
892
- const headers = processHeaders(request);
904
+ const headers = wrapWithGlobalHeaders(
905
+ processHeaders(request),
906
+ this.http.headers
907
+ );
893
908
  const destination = getRequestPath(request);
894
909
  const response = await this.http.request({
895
910
  path: ["v2", "enqueue", this.queueName, destination],
@@ -909,8 +924,7 @@ var Queue = class {
909
924
  const nonApiRequest = processApi(request, headers, upstashToken);
910
925
  const response = await this.enqueue({
911
926
  ...nonApiRequest,
912
- body: JSON.stringify(nonApiRequest.body),
913
- headers
927
+ body: JSON.stringify(nonApiRequest.body)
914
928
  });
915
929
  return response;
916
930
  }
@@ -994,7 +1008,7 @@ var Schedules = class {
994
1008
  }
995
1009
  return await this.http.request({
996
1010
  method: "POST",
997
- headers,
1011
+ headers: wrapWithGlobalHeaders(headers, this.http.headers),
998
1012
  path: ["v2", "schedules", request.destination],
999
1013
  body: request.body
1000
1014
  });
@@ -2506,7 +2520,9 @@ var Client = class {
2506
2520
  this.http = new HttpClient({
2507
2521
  retry: config.retry,
2508
2522
  baseUrl: config.baseUrl ? config.baseUrl.replace(/\/$/, "") : "https://qstash.upstash.io",
2509
- authorization: `Bearer ${config.token}`
2523
+ authorization: `Bearer ${config.token}`,
2524
+ //@ts-expect-error caused by undici and bunjs type overlap
2525
+ headers: prefixHeaders(new Headers(config.headers))
2510
2526
  });
2511
2527
  this.token = config.token;
2512
2528
  }
@@ -2581,7 +2597,10 @@ var Client = class {
2581
2597
  return new Chat(this.http, this.token);
2582
2598
  }
2583
2599
  async publish(request) {
2584
- const headers = processHeaders(request);
2600
+ const headers = wrapWithGlobalHeaders(
2601
+ processHeaders(request),
2602
+ this.http.headers
2603
+ );
2585
2604
  const response = await this.http.request({
2586
2605
  path: ["v2", "publish", getRequestPath(request)],
2587
2606
  body: request.body,
@@ -2611,7 +2630,7 @@ var Client = class {
2611
2630
  async batch(request) {
2612
2631
  const messages = [];
2613
2632
  for (const message of request) {
2614
- const headers = processHeaders(message);
2633
+ const headers = wrapWithGlobalHeaders(processHeaders(message), this.http.headers);
2615
2634
  const headerEntries = Object.fromEntries(headers.entries());
2616
2635
  messages.push({
2617
2636
  destination: getRequestPath(message),
package/svelte.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import "./chunk-K2ZUMNWA.mjs";
1
+ import "./chunk-RNFKMAEP.mjs";
2
2
  import {
3
3
  Receiver,
4
4
  serve
5
- } from "./chunk-A3H5A6JL.mjs";
5
+ } from "./chunk-S5ODGXCI.mjs";
6
6
 
7
7
  // platforms/svelte.ts
8
8
  var verifySignatureSvelte = (handler, config) => {
package/workflow.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export { ag as AsyncStepFunction, a9 as DisabledWorkflowContext, F as FailureFunctionPayload, aj as FinishCondition, al as LogLevel, ai as ParallelCallState, ae as RawStep, ak as RequiredExceptFields, a3 as RouteFunction, S as Step, ah as StepFunction, ad as StepType, ac as StepTypes, af as SyncStepFunction, a5 as Workflow, aa as WorkflowClient, a8 as WorkflowContext, an as WorkflowLogger, am as WorkflowLoggerOptions, ab as WorkflowReceiver, a4 as WorkflowServeOptions, a6 as processOptions, a7 as serve } from './client-B0bFJMw6.mjs';
1
+ export { ag as AsyncStepFunction, a9 as DisabledWorkflowContext, F as FailureFunctionPayload, aj as FinishCondition, al as LogLevel, ai as ParallelCallState, ae as RawStep, ak as RequiredExceptFields, a3 as RouteFunction, S as Step, ah as StepFunction, ad as StepType, ac as StepTypes, af as SyncStepFunction, a5 as Workflow, aa as WorkflowClient, a8 as WorkflowContext, an as WorkflowLogger, am as WorkflowLoggerOptions, ab as WorkflowReceiver, a4 as WorkflowServeOptions, a6 as processOptions, a7 as serve } from './client-CdYtp0E1.mjs';
2
2
  import 'neverthrow';
package/workflow.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { ag as AsyncStepFunction, a9 as DisabledWorkflowContext, F as FailureFunctionPayload, aj as FinishCondition, al as LogLevel, ai as ParallelCallState, ae as RawStep, ak as RequiredExceptFields, a3 as RouteFunction, S as Step, ah as StepFunction, ad as StepType, ac as StepTypes, af as SyncStepFunction, a5 as Workflow, aa as WorkflowClient, a8 as WorkflowContext, an as WorkflowLogger, am as WorkflowLoggerOptions, ab as WorkflowReceiver, a4 as WorkflowServeOptions, a6 as processOptions, a7 as serve } from './client-B0bFJMw6.js';
1
+ export { ag as AsyncStepFunction, a9 as DisabledWorkflowContext, F as FailureFunctionPayload, aj as FinishCondition, al as LogLevel, ai as ParallelCallState, ae as RawStep, ak as RequiredExceptFields, a3 as RouteFunction, S as Step, ah as StepFunction, ad as StepType, ac as StepTypes, af as SyncStepFunction, a5 as Workflow, aa as WorkflowClient, a8 as WorkflowContext, an as WorkflowLogger, am as WorkflowLoggerOptions, ab as WorkflowReceiver, a4 as WorkflowServeOptions, a6 as processOptions, a7 as serve } from './client-CdYtp0E1.js';
2
2
  import 'neverthrow';
package/workflow.js CHANGED
@@ -243,6 +243,7 @@ var HttpClient = class {
243
243
  authorization;
244
244
  options;
245
245
  retry;
246
+ headers;
246
247
  constructor(config) {
247
248
  this.baseUrl = config.baseUrl.replace(/\/$/, "");
248
249
  this.authorization = config.authorization;
@@ -254,6 +255,7 @@ var HttpClient = class {
254
255
  attempts: config.retry?.retries ?? 5,
255
256
  backoff: config.retry?.backoff ?? ((retryCount) => Math.exp(retryCount) * 50)
256
257
  };
258
+ this.headers = config.headers;
257
259
  }
258
260
  async request(request) {
259
261
  const { response } = await this.requestWithBackoff(request);
@@ -748,6 +750,16 @@ function prefixHeaders(headers) {
748
750
  }
749
751
  return headers;
750
752
  }
753
+ function wrapWithGlobalHeaders(headers, globalHeaders) {
754
+ if (!globalHeaders) {
755
+ return headers;
756
+ }
757
+ const finalHeaders = new Headers(globalHeaders);
758
+ headers.forEach((value, key) => {
759
+ finalHeaders.set(key, value);
760
+ });
761
+ return finalHeaders;
762
+ }
751
763
  function processHeaders(request) {
752
764
  const headers = prefixHeaders(new Headers(request.headers));
753
765
  headers.set("Upstash-Method", request.method ?? "POST");
@@ -894,7 +906,10 @@ var Queue = class {
894
906
  if (!this.queueName) {
895
907
  throw new Error("Please provide a queue name to the Queue constructor");
896
908
  }
897
- const headers = processHeaders(request);
909
+ const headers = wrapWithGlobalHeaders(
910
+ processHeaders(request),
911
+ this.http.headers
912
+ );
898
913
  const destination = getRequestPath(request);
899
914
  const response = await this.http.request({
900
915
  path: ["v2", "enqueue", this.queueName, destination],
@@ -914,8 +929,7 @@ var Queue = class {
914
929
  const nonApiRequest = processApi(request, headers, upstashToken);
915
930
  const response = await this.enqueue({
916
931
  ...nonApiRequest,
917
- body: JSON.stringify(nonApiRequest.body),
918
- headers
932
+ body: JSON.stringify(nonApiRequest.body)
919
933
  });
920
934
  return response;
921
935
  }
@@ -999,7 +1013,7 @@ var Schedules = class {
999
1013
  }
1000
1014
  return await this.http.request({
1001
1015
  method: "POST",
1002
- headers,
1016
+ headers: wrapWithGlobalHeaders(headers, this.http.headers),
1003
1017
  path: ["v2", "schedules", request.destination],
1004
1018
  body: request.body
1005
1019
  });
@@ -1125,7 +1139,9 @@ var Client = class {
1125
1139
  this.http = new HttpClient({
1126
1140
  retry: config.retry,
1127
1141
  baseUrl: config.baseUrl ? config.baseUrl.replace(/\/$/, "") : "https://qstash.upstash.io",
1128
- authorization: `Bearer ${config.token}`
1142
+ authorization: `Bearer ${config.token}`,
1143
+ //@ts-expect-error caused by undici and bunjs type overlap
1144
+ headers: prefixHeaders(new Headers(config.headers))
1129
1145
  });
1130
1146
  this.token = config.token;
1131
1147
  }
@@ -1200,7 +1216,10 @@ var Client = class {
1200
1216
  return new Chat(this.http, this.token);
1201
1217
  }
1202
1218
  async publish(request) {
1203
- const headers = processHeaders(request);
1219
+ const headers = wrapWithGlobalHeaders(
1220
+ processHeaders(request),
1221
+ this.http.headers
1222
+ );
1204
1223
  const response = await this.http.request({
1205
1224
  path: ["v2", "publish", getRequestPath(request)],
1206
1225
  body: request.body,
@@ -1230,7 +1249,7 @@ var Client = class {
1230
1249
  async batch(request) {
1231
1250
  const messages = [];
1232
1251
  for (const message of request) {
1233
- const headers = processHeaders(message);
1252
+ const headers = wrapWithGlobalHeaders(processHeaders(message), this.http.headers);
1234
1253
  const headerEntries = Object.fromEntries(headers.entries());
1235
1254
  messages.push({
1236
1255
  destination: getRequestPath(message),
package/workflow.mjs CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  WorkflowLogger,
7
7
  processOptions,
8
8
  serve
9
- } from "./chunk-A3H5A6JL.mjs";
9
+ } from "./chunk-S5ODGXCI.mjs";
10
10
  export {
11
11
  DisabledWorkflowContext,
12
12
  StepTypes,