@upstash/qstash 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -152,6 +152,25 @@ var Messages = class {
152
152
  }
153
153
  };
154
154
 
155
+ // src/client/utils.ts
156
+ function prefixHeaders(headers) {
157
+ const isIgnoredHeader = (header) => {
158
+ const lowerCaseHeader = header.toLowerCase();
159
+ return lowerCaseHeader.startsWith("content-type") || lowerCaseHeader.startsWith("upstash-");
160
+ };
161
+ const keysToBePrefixed = Array.from(headers.keys()).filter(
162
+ (key) => !isIgnoredHeader(key)
163
+ );
164
+ for (const key of keysToBePrefixed) {
165
+ const value = headers.get(key);
166
+ if (value !== null) {
167
+ headers.set(`Upstash-Forward-${key}`, value);
168
+ }
169
+ headers.delete(key);
170
+ }
171
+ return headers;
172
+ }
173
+
155
174
  // src/client/schedules.ts
156
175
  var Schedules = class {
157
176
  constructor(http) {
@@ -162,7 +181,7 @@ var Schedules = class {
162
181
  */
163
182
  create(req) {
164
183
  return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
165
- const headers = new Headers(req.headers);
184
+ const headers = prefixHeaders(new Headers(req.headers));
166
185
  if (!headers.has("Content-Type")) {
167
186
  headers.set("Content-Type", "application/json");
168
187
  }
@@ -339,7 +358,7 @@ var Client = class {
339
358
  publish(req) {
340
359
  return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
341
360
  var _a, _b;
342
- const headers = new Headers(req.headers);
361
+ const headers = prefixHeaders(new Headers(req.headers));
343
362
  headers.set("Upstash-Method", (_a = req.method) != null ? _a : "POST");
344
363
  if (typeof req.delay !== "undefined") {
345
364
  headers.set("Upstash-Delay", `${req.delay.toFixed()}s`);
@@ -377,7 +396,7 @@ var Client = class {
377
396
  */
378
397
  publishJSON(req) {
379
398
  return _chunkEROSIHWEjs.__async.call(void 0, this, null, function* () {
380
- const headers = new Headers(req.headers);
399
+ const headers = prefixHeaders(new Headers(req.headers));
381
400
  headers.set("Content-Type", "application/json");
382
401
  const res = yield this.publish(_chunkEROSIHWEjs.__spreadProps.call(void 0, _chunkEROSIHWEjs.__spreadValues.call(void 0, {}, req), {
383
402
  headers,
package/dist/index.mjs CHANGED
@@ -152,6 +152,25 @@ var Messages = class {
152
152
  }
153
153
  };
154
154
 
155
+ // src/client/utils.ts
156
+ function prefixHeaders(headers) {
157
+ const isIgnoredHeader = (header) => {
158
+ const lowerCaseHeader = header.toLowerCase();
159
+ return lowerCaseHeader.startsWith("content-type") || lowerCaseHeader.startsWith("upstash-");
160
+ };
161
+ const keysToBePrefixed = Array.from(headers.keys()).filter(
162
+ (key) => !isIgnoredHeader(key)
163
+ );
164
+ for (const key of keysToBePrefixed) {
165
+ const value = headers.get(key);
166
+ if (value !== null) {
167
+ headers.set(`Upstash-Forward-${key}`, value);
168
+ }
169
+ headers.delete(key);
170
+ }
171
+ return headers;
172
+ }
173
+
155
174
  // src/client/schedules.ts
156
175
  var Schedules = class {
157
176
  constructor(http) {
@@ -162,7 +181,7 @@ var Schedules = class {
162
181
  */
163
182
  create(req) {
164
183
  return __async(this, null, function* () {
165
- const headers = new Headers(req.headers);
184
+ const headers = prefixHeaders(new Headers(req.headers));
166
185
  if (!headers.has("Content-Type")) {
167
186
  headers.set("Content-Type", "application/json");
168
187
  }
@@ -339,7 +358,7 @@ var Client = class {
339
358
  publish(req) {
340
359
  return __async(this, null, function* () {
341
360
  var _a, _b;
342
- const headers = new Headers(req.headers);
361
+ const headers = prefixHeaders(new Headers(req.headers));
343
362
  headers.set("Upstash-Method", (_a = req.method) != null ? _a : "POST");
344
363
  if (typeof req.delay !== "undefined") {
345
364
  headers.set("Upstash-Delay", `${req.delay.toFixed()}s`);
@@ -377,7 +396,7 @@ var Client = class {
377
396
  */
378
397
  publishJSON(req) {
379
398
  return __async(this, null, function* () {
380
- const headers = new Headers(req.headers);
399
+ const headers = prefixHeaders(new Headers(req.headers));
381
400
  headers.set("Content-Type", "application/json");
382
401
  const res = yield this.publish(__spreadProps(__spreadValues({}, req), {
383
402
  headers,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@upstash/qstash",
3
- "version": "v2.2.0",
3
+ "version": "v2.3.0",
4
4
  "description": "Official Typescript client for QStash",
5
5
  "repository": {
6
6
  "type": "git",