@upstash/qstash 2.7.18 → 2.7.20

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-WXLHIS4A.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-WXLHIS4A.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);
@@ -585,6 +587,9 @@ var LLMProvider = class extends BaseProvider {
585
587
  if (this.owner === "openai" && this.organization) {
586
588
  headers["OpenAI-Organization"] = this.organization;
587
589
  }
590
+ if (this.owner === "anthropic") {
591
+ headers["anthropic-version"] = "2023-06-01";
592
+ }
588
593
  return headers;
589
594
  }
590
595
  /**
@@ -722,6 +727,16 @@ function prefixHeaders(headers) {
722
727
  }
723
728
  return headers;
724
729
  }
730
+ function wrapWithGlobalHeaders(headers, globalHeaders) {
731
+ if (!globalHeaders) {
732
+ return headers;
733
+ }
734
+ const finalHeaders = new Headers(globalHeaders);
735
+ headers.forEach((value, key) => {
736
+ finalHeaders.set(key, value);
737
+ });
738
+ return finalHeaders;
739
+ }
725
740
  function processHeaders(request) {
726
741
  const headers = prefixHeaders(new Headers(request.headers));
727
742
  headers.set("Upstash-Method", request.method ?? "POST");
@@ -868,7 +883,10 @@ var Queue = class {
868
883
  if (!this.queueName) {
869
884
  throw new Error("Please provide a queue name to the Queue constructor");
870
885
  }
871
- const headers = processHeaders(request);
886
+ const headers = wrapWithGlobalHeaders(
887
+ processHeaders(request),
888
+ this.http.headers
889
+ );
872
890
  const destination = getRequestPath(request);
873
891
  const response = await this.http.request({
874
892
  path: ["v2", "enqueue", this.queueName, destination],
@@ -888,8 +906,7 @@ var Queue = class {
888
906
  const nonApiRequest = processApi(request, headers, upstashToken);
889
907
  const response = await this.enqueue({
890
908
  ...nonApiRequest,
891
- body: JSON.stringify(nonApiRequest.body),
892
- headers
909
+ body: JSON.stringify(nonApiRequest.body)
893
910
  });
894
911
  return response;
895
912
  }
@@ -973,7 +990,7 @@ var Schedules = class {
973
990
  }
974
991
  return await this.http.request({
975
992
  method: "POST",
976
- headers,
993
+ headers: wrapWithGlobalHeaders(headers, this.http.headers),
977
994
  path: ["v2", "schedules", request.destination],
978
995
  body: request.body
979
996
  });
@@ -1099,7 +1116,9 @@ var Client = class {
1099
1116
  this.http = new HttpClient({
1100
1117
  retry: config.retry,
1101
1118
  baseUrl: config.baseUrl ? config.baseUrl.replace(/\/$/, "") : "https://qstash.upstash.io",
1102
- authorization: `Bearer ${config.token}`
1119
+ authorization: `Bearer ${config.token}`,
1120
+ //@ts-expect-error caused by undici and bunjs type overlap
1121
+ headers: prefixHeaders(new Headers(config.headers))
1103
1122
  });
1104
1123
  this.token = config.token;
1105
1124
  }
@@ -1174,7 +1193,10 @@ var Client = class {
1174
1193
  return new Chat(this.http, this.token);
1175
1194
  }
1176
1195
  async publish(request) {
1177
- const headers = processHeaders(request);
1196
+ const headers = wrapWithGlobalHeaders(
1197
+ processHeaders(request),
1198
+ this.http.headers
1199
+ );
1178
1200
  const response = await this.http.request({
1179
1201
  path: ["v2", "publish", getRequestPath(request)],
1180
1202
  body: request.body,
@@ -1204,7 +1226,7 @@ var Client = class {
1204
1226
  async batch(request) {
1205
1227
  const messages = [];
1206
1228
  for (const message of request) {
1207
- const headers = processHeaders(message);
1229
+ const headers = wrapWithGlobalHeaders(processHeaders(message), this.http.headers);
1208
1230
  const headerEntries = Object.fromEntries(headers.entries());
1209
1231
  messages.push({
1210
1232
  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);
@@ -621,6 +623,9 @@ var LLMProvider = class extends BaseProvider {
621
623
  if (this.owner === "openai" && this.organization) {
622
624
  headers["OpenAI-Organization"] = this.organization;
623
625
  }
626
+ if (this.owner === "anthropic") {
627
+ headers["anthropic-version"] = "2023-06-01";
628
+ }
624
629
  return headers;
625
630
  }
626
631
  /**
@@ -742,6 +747,16 @@ function prefixHeaders(headers) {
742
747
  }
743
748
  return headers;
744
749
  }
750
+ function wrapWithGlobalHeaders(headers, globalHeaders) {
751
+ if (!globalHeaders) {
752
+ return headers;
753
+ }
754
+ const finalHeaders = new Headers(globalHeaders);
755
+ headers.forEach((value, key) => {
756
+ finalHeaders.set(key, value);
757
+ });
758
+ return finalHeaders;
759
+ }
745
760
  function processHeaders(request) {
746
761
  const headers = prefixHeaders(new Headers(request.headers));
747
762
  headers.set("Upstash-Method", request.method ?? "POST");
@@ -888,7 +903,10 @@ var Queue = class {
888
903
  if (!this.queueName) {
889
904
  throw new Error("Please provide a queue name to the Queue constructor");
890
905
  }
891
- const headers = processHeaders(request);
906
+ const headers = wrapWithGlobalHeaders(
907
+ processHeaders(request),
908
+ this.http.headers
909
+ );
892
910
  const destination = getRequestPath(request);
893
911
  const response = await this.http.request({
894
912
  path: ["v2", "enqueue", this.queueName, destination],
@@ -908,8 +926,7 @@ var Queue = class {
908
926
  const nonApiRequest = processApi(request, headers, upstashToken);
909
927
  const response = await this.enqueue({
910
928
  ...nonApiRequest,
911
- body: JSON.stringify(nonApiRequest.body),
912
- headers
929
+ body: JSON.stringify(nonApiRequest.body)
913
930
  });
914
931
  return response;
915
932
  }
@@ -993,7 +1010,7 @@ var Schedules = class {
993
1010
  }
994
1011
  return await this.http.request({
995
1012
  method: "POST",
996
- headers,
1013
+ headers: wrapWithGlobalHeaders(headers, this.http.headers),
997
1014
  path: ["v2", "schedules", request.destination],
998
1015
  body: request.body
999
1016
  });
@@ -1119,7 +1136,9 @@ var Client = class {
1119
1136
  this.http = new HttpClient({
1120
1137
  retry: config.retry,
1121
1138
  baseUrl: config.baseUrl ? config.baseUrl.replace(/\/$/, "") : "https://qstash.upstash.io",
1122
- authorization: `Bearer ${config.token}`
1139
+ authorization: `Bearer ${config.token}`,
1140
+ //@ts-expect-error caused by undici and bunjs type overlap
1141
+ headers: prefixHeaders(new Headers(config.headers))
1123
1142
  });
1124
1143
  this.token = config.token;
1125
1144
  }
@@ -1194,7 +1213,10 @@ var Client = class {
1194
1213
  return new Chat(this.http, this.token);
1195
1214
  }
1196
1215
  async publish(request) {
1197
- const headers = processHeaders(request);
1216
+ const headers = wrapWithGlobalHeaders(
1217
+ processHeaders(request),
1218
+ this.http.headers
1219
+ );
1198
1220
  const response = await this.http.request({
1199
1221
  path: ["v2", "publish", getRequestPath(request)],
1200
1222
  body: request.body,
@@ -1224,7 +1246,7 @@ var Client = class {
1224
1246
  async batch(request) {
1225
1247
  const messages = [];
1226
1248
  for (const message of request) {
1227
- const headers = processHeaders(message);
1249
+ const headers = wrapWithGlobalHeaders(processHeaders(message), this.http.headers);
1228
1250
  const headerEntries = Object.fromEntries(headers.entries());
1229
1251
  messages.push({
1230
1252
  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-WXLHIS4A.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);
@@ -945,6 +947,9 @@ var LLMProvider = class extends BaseProvider {
945
947
  if (this.owner === "openai" && this.organization) {
946
948
  headers["OpenAI-Organization"] = this.organization;
947
949
  }
950
+ if (this.owner === "anthropic") {
951
+ headers["anthropic-version"] = "2023-06-01";
952
+ }
948
953
  return headers;
949
954
  }
950
955
  /**
@@ -1066,6 +1071,16 @@ function prefixHeaders(headers) {
1066
1071
  }
1067
1072
  return headers;
1068
1073
  }
1074
+ function wrapWithGlobalHeaders(headers, globalHeaders) {
1075
+ if (!globalHeaders) {
1076
+ return headers;
1077
+ }
1078
+ const finalHeaders = new Headers(globalHeaders);
1079
+ headers.forEach((value, key) => {
1080
+ finalHeaders.set(key, value);
1081
+ });
1082
+ return finalHeaders;
1083
+ }
1069
1084
  function processHeaders(request) {
1070
1085
  const headers = prefixHeaders(new Headers(request.headers));
1071
1086
  headers.set("Upstash-Method", request.method ?? "POST");
@@ -1212,7 +1227,10 @@ var Queue = class {
1212
1227
  if (!this.queueName) {
1213
1228
  throw new Error("Please provide a queue name to the Queue constructor");
1214
1229
  }
1215
- const headers = processHeaders(request);
1230
+ const headers = wrapWithGlobalHeaders(
1231
+ processHeaders(request),
1232
+ this.http.headers
1233
+ );
1216
1234
  const destination = getRequestPath(request);
1217
1235
  const response = await this.http.request({
1218
1236
  path: ["v2", "enqueue", this.queueName, destination],
@@ -1232,8 +1250,7 @@ var Queue = class {
1232
1250
  const nonApiRequest = processApi(request, headers, upstashToken);
1233
1251
  const response = await this.enqueue({
1234
1252
  ...nonApiRequest,
1235
- body: JSON.stringify(nonApiRequest.body),
1236
- headers
1253
+ body: JSON.stringify(nonApiRequest.body)
1237
1254
  });
1238
1255
  return response;
1239
1256
  }
@@ -1317,7 +1334,7 @@ var Schedules = class {
1317
1334
  }
1318
1335
  return await this.http.request({
1319
1336
  method: "POST",
1320
- headers,
1337
+ headers: wrapWithGlobalHeaders(headers, this.http.headers),
1321
1338
  path: ["v2", "schedules", request.destination],
1322
1339
  body: request.body
1323
1340
  });
@@ -2829,7 +2846,9 @@ var Client = class {
2829
2846
  this.http = new HttpClient({
2830
2847
  retry: config.retry,
2831
2848
  baseUrl: config.baseUrl ? config.baseUrl.replace(/\/$/, "") : "https://qstash.upstash.io",
2832
- authorization: `Bearer ${config.token}`
2849
+ authorization: `Bearer ${config.token}`,
2850
+ //@ts-expect-error caused by undici and bunjs type overlap
2851
+ headers: prefixHeaders(new Headers(config.headers))
2833
2852
  });
2834
2853
  this.token = config.token;
2835
2854
  }
@@ -2904,7 +2923,10 @@ var Client = class {
2904
2923
  return new Chat(this.http, this.token);
2905
2924
  }
2906
2925
  async publish(request) {
2907
- const headers = processHeaders(request);
2926
+ const headers = wrapWithGlobalHeaders(
2927
+ processHeaders(request),
2928
+ this.http.headers
2929
+ );
2908
2930
  const response = await this.http.request({
2909
2931
  path: ["v2", "publish", getRequestPath(request)],
2910
2932
  body: request.body,
@@ -2934,7 +2956,7 @@ var Client = class {
2934
2956
  async batch(request) {
2935
2957
  const messages = [];
2936
2958
  for (const message of request) {
2937
- const headers = processHeaders(message);
2959
+ const headers = wrapWithGlobalHeaders(processHeaders(message), this.http.headers);
2938
2960
  const headerEntries = Object.fromEntries(headers.entries());
2939
2961
  messages.push({
2940
2962
  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-3XWIKEL6.mjs";
5
+ import "./chunk-JSD5ZIXP.mjs";
6
+ import "./chunk-WXLHIS4A.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);
@@ -621,6 +623,9 @@ var LLMProvider = class extends BaseProvider {
621
623
  if (this.owner === "openai" && this.organization) {
622
624
  headers["OpenAI-Organization"] = this.organization;
623
625
  }
626
+ if (this.owner === "anthropic") {
627
+ headers["anthropic-version"] = "2023-06-01";
628
+ }
624
629
  return headers;
625
630
  }
626
631
  /**
@@ -742,6 +747,16 @@ function prefixHeaders(headers) {
742
747
  }
743
748
  return headers;
744
749
  }
750
+ function wrapWithGlobalHeaders(headers, globalHeaders) {
751
+ if (!globalHeaders) {
752
+ return headers;
753
+ }
754
+ const finalHeaders = new Headers(globalHeaders);
755
+ headers.forEach((value, key) => {
756
+ finalHeaders.set(key, value);
757
+ });
758
+ return finalHeaders;
759
+ }
745
760
  function processHeaders(request) {
746
761
  const headers = prefixHeaders(new Headers(request.headers));
747
762
  headers.set("Upstash-Method", request.method ?? "POST");
@@ -888,7 +903,10 @@ var Queue = class {
888
903
  if (!this.queueName) {
889
904
  throw new Error("Please provide a queue name to the Queue constructor");
890
905
  }
891
- const headers = processHeaders(request);
906
+ const headers = wrapWithGlobalHeaders(
907
+ processHeaders(request),
908
+ this.http.headers
909
+ );
892
910
  const destination = getRequestPath(request);
893
911
  const response = await this.http.request({
894
912
  path: ["v2", "enqueue", this.queueName, destination],
@@ -908,8 +926,7 @@ var Queue = class {
908
926
  const nonApiRequest = processApi(request, headers, upstashToken);
909
927
  const response = await this.enqueue({
910
928
  ...nonApiRequest,
911
- body: JSON.stringify(nonApiRequest.body),
912
- headers
929
+ body: JSON.stringify(nonApiRequest.body)
913
930
  });
914
931
  return response;
915
932
  }
@@ -993,7 +1010,7 @@ var Schedules = class {
993
1010
  }
994
1011
  return await this.http.request({
995
1012
  method: "POST",
996
- headers,
1013
+ headers: wrapWithGlobalHeaders(headers, this.http.headers),
997
1014
  path: ["v2", "schedules", request.destination],
998
1015
  body: request.body
999
1016
  });
@@ -1119,7 +1136,9 @@ var Client = class {
1119
1136
  this.http = new HttpClient({
1120
1137
  retry: config.retry,
1121
1138
  baseUrl: config.baseUrl ? config.baseUrl.replace(/\/$/, "") : "https://qstash.upstash.io",
1122
- authorization: `Bearer ${config.token}`
1139
+ authorization: `Bearer ${config.token}`,
1140
+ //@ts-expect-error caused by undici and bunjs type overlap
1141
+ headers: prefixHeaders(new Headers(config.headers))
1123
1142
  });
1124
1143
  this.token = config.token;
1125
1144
  }
@@ -1194,7 +1213,10 @@ var Client = class {
1194
1213
  return new Chat(this.http, this.token);
1195
1214
  }
1196
1215
  async publish(request) {
1197
- const headers = processHeaders(request);
1216
+ const headers = wrapWithGlobalHeaders(
1217
+ processHeaders(request),
1218
+ this.http.headers
1219
+ );
1198
1220
  const response = await this.http.request({
1199
1221
  path: ["v2", "publish", getRequestPath(request)],
1200
1222
  body: request.body,
@@ -1224,7 +1246,7 @@ var Client = class {
1224
1246
  async batch(request) {
1225
1247
  const messages = [];
1226
1248
  for (const message of request) {
1227
- const headers = processHeaders(message);
1249
+ const headers = wrapWithGlobalHeaders(processHeaders(message), this.http.headers);
1228
1250
  const headerEntries = Object.fromEntries(headers.entries());
1229
1251
  messages.push({
1230
1252
  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-WXLHIS4A.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);
@@ -641,6 +643,9 @@ var LLMProvider = class extends BaseProvider {
641
643
  if (this.owner === "openai" && this.organization) {
642
644
  headers["OpenAI-Organization"] = this.organization;
643
645
  }
646
+ if (this.owner === "anthropic") {
647
+ headers["anthropic-version"] = "2023-06-01";
648
+ }
644
649
  return headers;
645
650
  }
646
651
  /**
@@ -778,6 +783,16 @@ function prefixHeaders(headers) {
778
783
  }
779
784
  return headers;
780
785
  }
786
+ function wrapWithGlobalHeaders(headers, globalHeaders) {
787
+ if (!globalHeaders) {
788
+ return headers;
789
+ }
790
+ const finalHeaders = new Headers(globalHeaders);
791
+ headers.forEach((value, key) => {
792
+ finalHeaders.set(key, value);
793
+ });
794
+ return finalHeaders;
795
+ }
781
796
  function processHeaders(request) {
782
797
  const headers = prefixHeaders(new Headers(request.headers));
783
798
  headers.set("Upstash-Method", request.method ?? "POST");
@@ -919,7 +934,10 @@ var Queue = class {
919
934
  if (!this.queueName) {
920
935
  throw new Error("Please provide a queue name to the Queue constructor");
921
936
  }
922
- const headers = processHeaders(request);
937
+ const headers = wrapWithGlobalHeaders(
938
+ processHeaders(request),
939
+ this.http.headers
940
+ );
923
941
  const destination = getRequestPath(request);
924
942
  const response = await this.http.request({
925
943
  path: ["v2", "enqueue", this.queueName, destination],
@@ -939,8 +957,7 @@ var Queue = class {
939
957
  const nonApiRequest = processApi(request, headers, upstashToken);
940
958
  const response = await this.enqueue({
941
959
  ...nonApiRequest,
942
- body: JSON.stringify(nonApiRequest.body),
943
- headers
960
+ body: JSON.stringify(nonApiRequest.body)
944
961
  });
945
962
  return response;
946
963
  }
@@ -1024,7 +1041,7 @@ var Schedules = class {
1024
1041
  }
1025
1042
  return await this.http.request({
1026
1043
  method: "POST",
1027
- headers,
1044
+ headers: wrapWithGlobalHeaders(headers, this.http.headers),
1028
1045
  path: ["v2", "schedules", request.destination],
1029
1046
  body: request.body
1030
1047
  });
@@ -1181,7 +1198,9 @@ var Client = class {
1181
1198
  this.http = new HttpClient({
1182
1199
  retry: config.retry,
1183
1200
  baseUrl: config.baseUrl ? config.baseUrl.replace(/\/$/, "") : "https://qstash.upstash.io",
1184
- authorization: `Bearer ${config.token}`
1201
+ authorization: `Bearer ${config.token}`,
1202
+ //@ts-expect-error caused by undici and bunjs type overlap
1203
+ headers: prefixHeaders(new Headers(config.headers))
1185
1204
  });
1186
1205
  this.token = config.token;
1187
1206
  }
@@ -1256,7 +1275,10 @@ var Client = class {
1256
1275
  return new Chat(this.http, this.token);
1257
1276
  }
1258
1277
  async publish(request) {
1259
- const headers = processHeaders(request);
1278
+ const headers = wrapWithGlobalHeaders(
1279
+ processHeaders(request),
1280
+ this.http.headers
1281
+ );
1260
1282
  const response = await this.http.request({
1261
1283
  path: ["v2", "publish", getRequestPath(request)],
1262
1284
  body: request.body,
@@ -1286,7 +1308,7 @@ var Client = class {
1286
1308
  async batch(request) {
1287
1309
  const messages = [];
1288
1310
  for (const message of request) {
1289
- const headers = processHeaders(message);
1311
+ const headers = wrapWithGlobalHeaders(processHeaders(message), this.http.headers);
1290
1312
  const headerEntries = Object.fromEntries(headers.entries());
1291
1313
  messages.push({
1292
1314
  destination: getRequestPath(message),
@@ -1389,7 +1411,7 @@ var EmailProvider = class extends BaseProvider {
1389
1411
  }
1390
1412
  getHeaders(_options) {
1391
1413
  return {
1392
- "upstash-forward-authorization": `Bearer ${this.token}`
1414
+ authorization: `Bearer ${this.token}`
1393
1415
  };
1394
1416
  }
1395
1417
  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-JSD5ZIXP.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-WXLHIS4A.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);
@@ -625,6 +627,9 @@ var LLMProvider = class extends BaseProvider {
625
627
  if (this.owner === "openai" && this.organization) {
626
628
  headers["OpenAI-Organization"] = this.organization;
627
629
  }
630
+ if (this.owner === "anthropic") {
631
+ headers["anthropic-version"] = "2023-06-01";
632
+ }
628
633
  return headers;
629
634
  }
630
635
  /**
@@ -746,6 +751,16 @@ function prefixHeaders(headers) {
746
751
  }
747
752
  return headers;
748
753
  }
754
+ function wrapWithGlobalHeaders(headers, globalHeaders) {
755
+ if (!globalHeaders) {
756
+ return headers;
757
+ }
758
+ const finalHeaders = new Headers(globalHeaders);
759
+ headers.forEach((value, key) => {
760
+ finalHeaders.set(key, value);
761
+ });
762
+ return finalHeaders;
763
+ }
749
764
  function processHeaders(request) {
750
765
  const headers = prefixHeaders(new Headers(request.headers));
751
766
  headers.set("Upstash-Method", request.method ?? "POST");
@@ -892,7 +907,10 @@ var Queue = class {
892
907
  if (!this.queueName) {
893
908
  throw new Error("Please provide a queue name to the Queue constructor");
894
909
  }
895
- const headers = processHeaders(request);
910
+ const headers = wrapWithGlobalHeaders(
911
+ processHeaders(request),
912
+ this.http.headers
913
+ );
896
914
  const destination = getRequestPath(request);
897
915
  const response = await this.http.request({
898
916
  path: ["v2", "enqueue", this.queueName, destination],
@@ -912,8 +930,7 @@ var Queue = class {
912
930
  const nonApiRequest = processApi(request, headers, upstashToken);
913
931
  const response = await this.enqueue({
914
932
  ...nonApiRequest,
915
- body: JSON.stringify(nonApiRequest.body),
916
- headers
933
+ body: JSON.stringify(nonApiRequest.body)
917
934
  });
918
935
  return response;
919
936
  }
@@ -997,7 +1014,7 @@ var Schedules = class {
997
1014
  }
998
1015
  return await this.http.request({
999
1016
  method: "POST",
1000
- headers,
1017
+ headers: wrapWithGlobalHeaders(headers, this.http.headers),
1001
1018
  path: ["v2", "schedules", request.destination],
1002
1019
  body: request.body
1003
1020
  });
@@ -1123,7 +1140,9 @@ var Client = class {
1123
1140
  this.http = new HttpClient({
1124
1141
  retry: config.retry,
1125
1142
  baseUrl: config.baseUrl ? config.baseUrl.replace(/\/$/, "") : "https://qstash.upstash.io",
1126
- authorization: `Bearer ${config.token}`
1143
+ authorization: `Bearer ${config.token}`,
1144
+ //@ts-expect-error caused by undici and bunjs type overlap
1145
+ headers: prefixHeaders(new Headers(config.headers))
1127
1146
  });
1128
1147
  this.token = config.token;
1129
1148
  }
@@ -1198,7 +1217,10 @@ var Client = class {
1198
1217
  return new Chat(this.http, this.token);
1199
1218
  }
1200
1219
  async publish(request) {
1201
- const headers = processHeaders(request);
1220
+ const headers = wrapWithGlobalHeaders(
1221
+ processHeaders(request),
1222
+ this.http.headers
1223
+ );
1202
1224
  const response = await this.http.request({
1203
1225
  path: ["v2", "publish", getRequestPath(request)],
1204
1226
  body: request.body,
@@ -1228,7 +1250,7 @@ var Client = class {
1228
1250
  async batch(request) {
1229
1251
  const messages = [];
1230
1252
  for (const message of request) {
1231
- const headers = processHeaders(message);
1253
+ const headers = wrapWithGlobalHeaders(processHeaders(message), this.http.headers);
1232
1254
  const headerEntries = Object.fromEntries(headers.entries());
1233
1255
  messages.push({
1234
1256
  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-WXLHIS4A.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-3XWIKEL6.mjs";
4
+ import "./chunk-JSD5ZIXP.mjs";
5
+ import "./chunk-WXLHIS4A.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.20","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);
@@ -622,6 +624,9 @@ var LLMProvider = class extends BaseProvider {
622
624
  if (this.owner === "openai" && this.organization) {
623
625
  headers["OpenAI-Organization"] = this.organization;
624
626
  }
627
+ if (this.owner === "anthropic") {
628
+ headers["anthropic-version"] = "2023-06-01";
629
+ }
625
630
  return headers;
626
631
  }
627
632
  /**
@@ -743,6 +748,16 @@ function prefixHeaders(headers) {
743
748
  }
744
749
  return headers;
745
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
+ }
746
761
  function processHeaders(request) {
747
762
  const headers = prefixHeaders(new Headers(request.headers));
748
763
  headers.set("Upstash-Method", request.method ?? "POST");
@@ -889,7 +904,10 @@ var Queue = class {
889
904
  if (!this.queueName) {
890
905
  throw new Error("Please provide a queue name to the Queue constructor");
891
906
  }
892
- const headers = processHeaders(request);
907
+ const headers = wrapWithGlobalHeaders(
908
+ processHeaders(request),
909
+ this.http.headers
910
+ );
893
911
  const destination = getRequestPath(request);
894
912
  const response = await this.http.request({
895
913
  path: ["v2", "enqueue", this.queueName, destination],
@@ -909,8 +927,7 @@ var Queue = class {
909
927
  const nonApiRequest = processApi(request, headers, upstashToken);
910
928
  const response = await this.enqueue({
911
929
  ...nonApiRequest,
912
- body: JSON.stringify(nonApiRequest.body),
913
- headers
930
+ body: JSON.stringify(nonApiRequest.body)
914
931
  });
915
932
  return response;
916
933
  }
@@ -994,7 +1011,7 @@ var Schedules = class {
994
1011
  }
995
1012
  return await this.http.request({
996
1013
  method: "POST",
997
- headers,
1014
+ headers: wrapWithGlobalHeaders(headers, this.http.headers),
998
1015
  path: ["v2", "schedules", request.destination],
999
1016
  body: request.body
1000
1017
  });
@@ -2506,7 +2523,9 @@ var Client = class {
2506
2523
  this.http = new HttpClient({
2507
2524
  retry: config.retry,
2508
2525
  baseUrl: config.baseUrl ? config.baseUrl.replace(/\/$/, "") : "https://qstash.upstash.io",
2509
- authorization: `Bearer ${config.token}`
2526
+ authorization: `Bearer ${config.token}`,
2527
+ //@ts-expect-error caused by undici and bunjs type overlap
2528
+ headers: prefixHeaders(new Headers(config.headers))
2510
2529
  });
2511
2530
  this.token = config.token;
2512
2531
  }
@@ -2581,7 +2600,10 @@ var Client = class {
2581
2600
  return new Chat(this.http, this.token);
2582
2601
  }
2583
2602
  async publish(request) {
2584
- const headers = processHeaders(request);
2603
+ const headers = wrapWithGlobalHeaders(
2604
+ processHeaders(request),
2605
+ this.http.headers
2606
+ );
2585
2607
  const response = await this.http.request({
2586
2608
  path: ["v2", "publish", getRequestPath(request)],
2587
2609
  body: request.body,
@@ -2611,7 +2633,7 @@ var Client = class {
2611
2633
  async batch(request) {
2612
2634
  const messages = [];
2613
2635
  for (const message of request) {
2614
- const headers = processHeaders(message);
2636
+ const headers = wrapWithGlobalHeaders(processHeaders(message), this.http.headers);
2615
2637
  const headerEntries = Object.fromEntries(headers.entries());
2616
2638
  messages.push({
2617
2639
  destination: getRequestPath(message),
package/solidjs.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import "./chunk-K2ZUMNWA.mjs";
1
+ import "./chunk-JSD5ZIXP.mjs";
2
2
  import {
3
3
  Receiver,
4
4
  serve
5
- } from "./chunk-A3H5A6JL.mjs";
5
+ } from "./chunk-WXLHIS4A.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);
@@ -622,6 +624,9 @@ var LLMProvider = class extends BaseProvider {
622
624
  if (this.owner === "openai" && this.organization) {
623
625
  headers["OpenAI-Organization"] = this.organization;
624
626
  }
627
+ if (this.owner === "anthropic") {
628
+ headers["anthropic-version"] = "2023-06-01";
629
+ }
625
630
  return headers;
626
631
  }
627
632
  /**
@@ -743,6 +748,16 @@ function prefixHeaders(headers) {
743
748
  }
744
749
  return headers;
745
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
+ }
746
761
  function processHeaders(request) {
747
762
  const headers = prefixHeaders(new Headers(request.headers));
748
763
  headers.set("Upstash-Method", request.method ?? "POST");
@@ -889,7 +904,10 @@ var Queue = class {
889
904
  if (!this.queueName) {
890
905
  throw new Error("Please provide a queue name to the Queue constructor");
891
906
  }
892
- const headers = processHeaders(request);
907
+ const headers = wrapWithGlobalHeaders(
908
+ processHeaders(request),
909
+ this.http.headers
910
+ );
893
911
  const destination = getRequestPath(request);
894
912
  const response = await this.http.request({
895
913
  path: ["v2", "enqueue", this.queueName, destination],
@@ -909,8 +927,7 @@ var Queue = class {
909
927
  const nonApiRequest = processApi(request, headers, upstashToken);
910
928
  const response = await this.enqueue({
911
929
  ...nonApiRequest,
912
- body: JSON.stringify(nonApiRequest.body),
913
- headers
930
+ body: JSON.stringify(nonApiRequest.body)
914
931
  });
915
932
  return response;
916
933
  }
@@ -994,7 +1011,7 @@ var Schedules = class {
994
1011
  }
995
1012
  return await this.http.request({
996
1013
  method: "POST",
997
- headers,
1014
+ headers: wrapWithGlobalHeaders(headers, this.http.headers),
998
1015
  path: ["v2", "schedules", request.destination],
999
1016
  body: request.body
1000
1017
  });
@@ -2506,7 +2523,9 @@ var Client = class {
2506
2523
  this.http = new HttpClient({
2507
2524
  retry: config.retry,
2508
2525
  baseUrl: config.baseUrl ? config.baseUrl.replace(/\/$/, "") : "https://qstash.upstash.io",
2509
- authorization: `Bearer ${config.token}`
2526
+ authorization: `Bearer ${config.token}`,
2527
+ //@ts-expect-error caused by undici and bunjs type overlap
2528
+ headers: prefixHeaders(new Headers(config.headers))
2510
2529
  });
2511
2530
  this.token = config.token;
2512
2531
  }
@@ -2581,7 +2600,10 @@ var Client = class {
2581
2600
  return new Chat(this.http, this.token);
2582
2601
  }
2583
2602
  async publish(request) {
2584
- const headers = processHeaders(request);
2603
+ const headers = wrapWithGlobalHeaders(
2604
+ processHeaders(request),
2605
+ this.http.headers
2606
+ );
2585
2607
  const response = await this.http.request({
2586
2608
  path: ["v2", "publish", getRequestPath(request)],
2587
2609
  body: request.body,
@@ -2611,7 +2633,7 @@ var Client = class {
2611
2633
  async batch(request) {
2612
2634
  const messages = [];
2613
2635
  for (const message of request) {
2614
- const headers = processHeaders(message);
2636
+ const headers = wrapWithGlobalHeaders(processHeaders(message), this.http.headers);
2615
2637
  const headerEntries = Object.fromEntries(headers.entries());
2616
2638
  messages.push({
2617
2639
  destination: getRequestPath(message),
package/svelte.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import "./chunk-K2ZUMNWA.mjs";
1
+ import "./chunk-JSD5ZIXP.mjs";
2
2
  import {
3
3
  Receiver,
4
4
  serve
5
- } from "./chunk-A3H5A6JL.mjs";
5
+ } from "./chunk-WXLHIS4A.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);
@@ -627,6 +629,9 @@ var LLMProvider = class extends BaseProvider {
627
629
  if (this.owner === "openai" && this.organization) {
628
630
  headers["OpenAI-Organization"] = this.organization;
629
631
  }
632
+ if (this.owner === "anthropic") {
633
+ headers["anthropic-version"] = "2023-06-01";
634
+ }
630
635
  return headers;
631
636
  }
632
637
  /**
@@ -748,6 +753,16 @@ function prefixHeaders(headers) {
748
753
  }
749
754
  return headers;
750
755
  }
756
+ function wrapWithGlobalHeaders(headers, globalHeaders) {
757
+ if (!globalHeaders) {
758
+ return headers;
759
+ }
760
+ const finalHeaders = new Headers(globalHeaders);
761
+ headers.forEach((value, key) => {
762
+ finalHeaders.set(key, value);
763
+ });
764
+ return finalHeaders;
765
+ }
751
766
  function processHeaders(request) {
752
767
  const headers = prefixHeaders(new Headers(request.headers));
753
768
  headers.set("Upstash-Method", request.method ?? "POST");
@@ -894,7 +909,10 @@ var Queue = class {
894
909
  if (!this.queueName) {
895
910
  throw new Error("Please provide a queue name to the Queue constructor");
896
911
  }
897
- const headers = processHeaders(request);
912
+ const headers = wrapWithGlobalHeaders(
913
+ processHeaders(request),
914
+ this.http.headers
915
+ );
898
916
  const destination = getRequestPath(request);
899
917
  const response = await this.http.request({
900
918
  path: ["v2", "enqueue", this.queueName, destination],
@@ -914,8 +932,7 @@ var Queue = class {
914
932
  const nonApiRequest = processApi(request, headers, upstashToken);
915
933
  const response = await this.enqueue({
916
934
  ...nonApiRequest,
917
- body: JSON.stringify(nonApiRequest.body),
918
- headers
935
+ body: JSON.stringify(nonApiRequest.body)
919
936
  });
920
937
  return response;
921
938
  }
@@ -999,7 +1016,7 @@ var Schedules = class {
999
1016
  }
1000
1017
  return await this.http.request({
1001
1018
  method: "POST",
1002
- headers,
1019
+ headers: wrapWithGlobalHeaders(headers, this.http.headers),
1003
1020
  path: ["v2", "schedules", request.destination],
1004
1021
  body: request.body
1005
1022
  });
@@ -1125,7 +1142,9 @@ var Client = class {
1125
1142
  this.http = new HttpClient({
1126
1143
  retry: config.retry,
1127
1144
  baseUrl: config.baseUrl ? config.baseUrl.replace(/\/$/, "") : "https://qstash.upstash.io",
1128
- authorization: `Bearer ${config.token}`
1145
+ authorization: `Bearer ${config.token}`,
1146
+ //@ts-expect-error caused by undici and bunjs type overlap
1147
+ headers: prefixHeaders(new Headers(config.headers))
1129
1148
  });
1130
1149
  this.token = config.token;
1131
1150
  }
@@ -1200,7 +1219,10 @@ var Client = class {
1200
1219
  return new Chat(this.http, this.token);
1201
1220
  }
1202
1221
  async publish(request) {
1203
- const headers = processHeaders(request);
1222
+ const headers = wrapWithGlobalHeaders(
1223
+ processHeaders(request),
1224
+ this.http.headers
1225
+ );
1204
1226
  const response = await this.http.request({
1205
1227
  path: ["v2", "publish", getRequestPath(request)],
1206
1228
  body: request.body,
@@ -1230,7 +1252,7 @@ var Client = class {
1230
1252
  async batch(request) {
1231
1253
  const messages = [];
1232
1254
  for (const message of request) {
1233
- const headers = processHeaders(message);
1255
+ const headers = wrapWithGlobalHeaders(processHeaders(message), this.http.headers);
1234
1256
  const headerEntries = Object.fromEntries(headers.entries());
1235
1257
  messages.push({
1236
1258
  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-WXLHIS4A.mjs";
10
10
  export {
11
11
  DisabledWorkflowContext,
12
12
  StepTypes,