@upstash/qstash 2.7.10 → 2.7.11-canary

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,3 +1,29 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
+ // If the importer is in node compatibility mode or this is not an ESM
20
+ // file that has been converted to a CommonJS file using a Babel-
21
+ // compatible transform (i.e. "__esModule" has not been set), then set
22
+ // "default" to the CommonJS "module.exports" for node compatibility.
23
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
+ mod
25
+ ));
26
+
1
27
  // src/receiver.ts
2
28
  import * as jose from "jose";
3
29
  import crypto2 from "crypto-js";
@@ -352,20 +378,13 @@ var upstash = () => {
352
378
  return {
353
379
  owner: "upstash",
354
380
  baseUrl: "https://qstash.upstash.io/llm",
355
- token: "",
356
- organization: void 0
381
+ token: ""
357
382
  };
358
383
  };
359
384
  var openai = ({
360
- token,
361
- organization
385
+ token
362
386
  }) => {
363
- return {
364
- token,
365
- owner: "openai",
366
- baseUrl: "https://api.openai.com",
367
- organization
368
- };
387
+ return { token, owner: "openai", baseUrl: "https://api.openai.com" };
369
388
  };
370
389
  var custom = ({
371
390
  baseUrl,
@@ -375,8 +394,7 @@ var custom = ({
375
394
  return {
376
395
  token,
377
396
  owner: "custom",
378
- baseUrl: trimmedBaseUrl,
379
- organization: void 0
397
+ baseUrl: trimmedBaseUrl
380
398
  };
381
399
  };
382
400
 
@@ -456,7 +474,7 @@ var Chat = class _Chat {
456
474
  */
457
475
  // eslint-disable-next-line @typescript-eslint/require-await
458
476
  createThirdParty = async (request) => {
459
- const { baseUrl, token, owner, organization } = request.provider;
477
+ const { baseUrl, token, owner } = request.provider;
460
478
  if (owner === "upstash")
461
479
  throw new Error("Upstash is not 3rd party provider!");
462
480
  delete request.provider;
@@ -470,9 +488,6 @@ var Chat = class _Chat {
470
488
  const headers = {
471
489
  "Content-Type": "application/json",
472
490
  Authorization: `Bearer ${token}`,
473
- ...organization ? {
474
- "OpenAI-Organization": organization
475
- } : {},
476
491
  ...isStream ? {
477
492
  Connection: "keep-alive",
478
493
  Accept: "text/event-stream",
@@ -688,7 +703,7 @@ function decodeBase64(base64) {
688
703
  return new TextDecoder().decode(intArray);
689
704
  } catch (error) {
690
705
  console.warn(
691
- `Upstash Qstash: Failed while decoding base64 "${base64}". Decoding with atob and returning it instead. ${error}`
706
+ `Upstash Qstash: Failed while decoding base64 "${base64}". Decoding with atob and returning it instead. Error: ${error}`
692
707
  );
693
708
  return atob(base64);
694
709
  }
@@ -1641,11 +1656,11 @@ var handleThirdPartyCallResult = async (request, requestPayload, client, workflo
1641
1656
  if (!(callbackMessage.status >= 200 && callbackMessage.status < 300)) {
1642
1657
  await debug?.log("WARN", "SUBMIT_THIRD_PARTY_RESULT", {
1643
1658
  status: callbackMessage.status,
1644
- body: atob(callbackMessage.body)
1659
+ body: decodeBase64(callbackMessage.body)
1645
1660
  });
1646
1661
  console.warn(
1647
1662
  `Workflow Warning: "context.call" failed with status ${callbackMessage.status} and will retry (if there are retries remaining). Error Message:
1648
- ${atob(callbackMessage.body)}`
1663
+ ${decodeBase64(callbackMessage.body)}`
1649
1664
  );
1650
1665
  return ok("call-will-retry");
1651
1666
  }
@@ -1681,7 +1696,7 @@ ${atob(callbackMessage.body)}`
1681
1696
  stepId: Number(stepIdString),
1682
1697
  stepName,
1683
1698
  stepType,
1684
- out: atob(callbackMessage.body),
1699
+ out: decodeBase64(callbackMessage.body),
1685
1700
  concurrent: Number(concurrentString)
1686
1701
  };
1687
1702
  await debug?.log("SUBMIT", "SUBMIT_THIRD_PARTY_RESULT", {
@@ -2075,6 +2090,7 @@ var AutoExecutor = class _AutoExecutor {
2075
2090
  * @param index index of the current step
2076
2091
  * @returns result[index] if lazyStepList > 1, otherwise result
2077
2092
  */
2093
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2078
2094
  static getResult(lazyStepList, result, index) {
2079
2095
  if (lazyStepList.length === 1) {
2080
2096
  return result;
@@ -2500,6 +2516,7 @@ var WorkflowContext = class {
2500
2516
  * @param headers call headers
2501
2517
  * @returns call result (parsed as JSON if possible)
2502
2518
  */
2519
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2503
2520
  async call(stepName, url, method, body, headers) {
2504
2521
  const result = await this.addStep(
2505
2522
  new LazyCallStep(stepName, url, method, body, headers ?? {})
@@ -2934,6 +2951,8 @@ var Workflow = class {
2934
2951
  };
2935
2952
 
2936
2953
  export {
2954
+ __commonJS,
2955
+ __toESM,
2937
2956
  SignatureError,
2938
2957
  Receiver,
2939
2958
  QstashError,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Receiver,
3
3
  serve
4
- } from "./chunk-HIWMJGFU.mjs";
4
+ } from "./chunk-KWSSCN6R.mjs";
5
5
 
6
6
  // node_modules/defu/dist/defu.mjs
7
7
  function isPlainObject(value) {
@@ -105,12 +105,10 @@ type RateLimit = {
105
105
  reset: string | null;
106
106
  };
107
107
 
108
- type Owner = "upstash" | "openai" | "custom";
109
- type ProviderReturnType<TOwner extends Owner = Owner, TBaseUrl extends string = string, TToken extends string = string, TOrganization extends string | undefined = string | undefined> = {
110
- owner: TOwner;
111
- baseUrl: TBaseUrl;
112
- token: TToken;
113
- organization: TOrganization;
108
+ type ProviderReturnType = {
109
+ owner: "upstash" | "openai" | "custom";
110
+ baseUrl: string;
111
+ token: string;
114
112
  };
115
113
  type AnalyticsConfig = {
116
114
  name: "helicone";
@@ -121,15 +119,26 @@ type AnalyticsSetup = {
121
119
  defaultHeaders?: Record<string, string | undefined>;
122
120
  };
123
121
  declare const setupAnalytics: (analytics: AnalyticsConfig | undefined, providerApiKey: string, providerBaseUrl?: string, provider?: "openai" | "upstash" | "custom") => AnalyticsSetup;
124
- declare const upstash: () => ProviderReturnType<"upstash", "https://qstash.upstash.io/llm", "">;
125
- declare const openai: <TToken extends string = string, TOrganization extends string | undefined = undefined>({ token, organization, }: {
126
- token: TToken;
127
- organization?: TOrganization;
128
- }) => ProviderReturnType<"openai", "https://api.openai.com", TToken, TOrganization extends string ? TOrganization : undefined>;
129
- declare const custom: <TToken extends string = string>({ baseUrl, token, }: {
122
+ declare const upstash: () => {
123
+ owner: "upstash";
124
+ baseUrl: "https://qstash.upstash.io/llm";
125
+ token: string;
126
+ };
127
+ declare const openai: ({ token, }: {
128
+ token: string;
129
+ }) => {
130
+ owner: "openai";
131
+ baseUrl: "https://api.openai.com";
132
+ token: string;
133
+ };
134
+ declare const custom: ({ baseUrl, token, }: {
135
+ token: string;
136
+ baseUrl: string;
137
+ }) => {
138
+ owner: "custom";
130
139
  baseUrl: string;
131
- token: TToken;
132
- }) => ProviderReturnType<"custom", string, TToken>;
140
+ token: string;
141
+ };
133
142
 
134
143
  type ChatCompletionMessage = {
135
144
  role: "system" | "assistant" | "user";
@@ -218,21 +227,21 @@ type ChatRequestFields = ChatRequestCommonFields & {
218
227
  messages: ChatCompletionMessage[];
219
228
  };
220
229
  type ChatRequestProviders = {
221
- provider: ProviderReturnType<"openai">;
230
+ provider: ProviderReturnType;
222
231
  model: OpenAIChatModel;
223
232
  analytics?: {
224
233
  name: "helicone";
225
234
  token: string;
226
235
  };
227
236
  } | {
228
- provider: ProviderReturnType<"custom">;
237
+ provider: ProviderReturnType;
229
238
  model: string;
230
239
  analytics?: {
231
240
  name: "helicone";
232
241
  token: string;
233
242
  };
234
243
  } | {
235
- provider: ProviderReturnType<"upstash">;
244
+ provider: ProviderReturnType;
236
245
  model: ChatModel;
237
246
  analytics?: {
238
247
  name: "helicone";
@@ -105,12 +105,10 @@ type RateLimit = {
105
105
  reset: string | null;
106
106
  };
107
107
 
108
- type Owner = "upstash" | "openai" | "custom";
109
- type ProviderReturnType<TOwner extends Owner = Owner, TBaseUrl extends string = string, TToken extends string = string, TOrganization extends string | undefined = string | undefined> = {
110
- owner: TOwner;
111
- baseUrl: TBaseUrl;
112
- token: TToken;
113
- organization: TOrganization;
108
+ type ProviderReturnType = {
109
+ owner: "upstash" | "openai" | "custom";
110
+ baseUrl: string;
111
+ token: string;
114
112
  };
115
113
  type AnalyticsConfig = {
116
114
  name: "helicone";
@@ -121,15 +119,26 @@ type AnalyticsSetup = {
121
119
  defaultHeaders?: Record<string, string | undefined>;
122
120
  };
123
121
  declare const setupAnalytics: (analytics: AnalyticsConfig | undefined, providerApiKey: string, providerBaseUrl?: string, provider?: "openai" | "upstash" | "custom") => AnalyticsSetup;
124
- declare const upstash: () => ProviderReturnType<"upstash", "https://qstash.upstash.io/llm", "">;
125
- declare const openai: <TToken extends string = string, TOrganization extends string | undefined = undefined>({ token, organization, }: {
126
- token: TToken;
127
- organization?: TOrganization;
128
- }) => ProviderReturnType<"openai", "https://api.openai.com", TToken, TOrganization extends string ? TOrganization : undefined>;
129
- declare const custom: <TToken extends string = string>({ baseUrl, token, }: {
122
+ declare const upstash: () => {
123
+ owner: "upstash";
124
+ baseUrl: "https://qstash.upstash.io/llm";
125
+ token: string;
126
+ };
127
+ declare const openai: ({ token, }: {
128
+ token: string;
129
+ }) => {
130
+ owner: "openai";
131
+ baseUrl: "https://api.openai.com";
132
+ token: string;
133
+ };
134
+ declare const custom: ({ baseUrl, token, }: {
135
+ token: string;
136
+ baseUrl: string;
137
+ }) => {
138
+ owner: "custom";
130
139
  baseUrl: string;
131
- token: TToken;
132
- }) => ProviderReturnType<"custom", string, TToken>;
140
+ token: string;
141
+ };
133
142
 
134
143
  type ChatCompletionMessage = {
135
144
  role: "system" | "assistant" | "user";
@@ -218,21 +227,21 @@ type ChatRequestFields = ChatRequestCommonFields & {
218
227
  messages: ChatCompletionMessage[];
219
228
  };
220
229
  type ChatRequestProviders = {
221
- provider: ProviderReturnType<"openai">;
230
+ provider: ProviderReturnType;
222
231
  model: OpenAIChatModel;
223
232
  analytics?: {
224
233
  name: "helicone";
225
234
  token: string;
226
235
  };
227
236
  } | {
228
- provider: ProviderReturnType<"custom">;
237
+ provider: ProviderReturnType;
229
238
  model: string;
230
239
  analytics?: {
231
240
  name: "helicone";
232
241
  token: string;
233
242
  };
234
243
  } | {
235
- provider: ProviderReturnType<"upstash">;
244
+ provider: ProviderReturnType;
236
245
  model: ChatModel;
237
246
  analytics?: {
238
247
  name: "helicone";
package/cloudflare.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a2 as RouteFunction, a3 as WorkflowServeOptions } from './client-orcgOcAm.mjs';
1
+ import { a2 as RouteFunction, a3 as WorkflowServeOptions } from './client-DkrYCqaq.mjs';
2
2
  import 'neverthrow';
3
3
 
4
4
  type WorkflowBindings = {
package/cloudflare.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a2 as RouteFunction, a3 as WorkflowServeOptions } from './client-orcgOcAm.js';
1
+ import { a2 as RouteFunction, a3 as WorkflowServeOptions } from './client-DkrYCqaq.js';
2
2
  import 'neverthrow';
3
3
 
4
4
  type WorkflowBindings = {