@upstash/qstash 2.7.10 → 2.7.11-canary-2

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-HIWMJGFU.mjs";
4
+ } from "./chunk-KGI26PDH.mjs";
5
5
 
6
6
  // node_modules/defu/dist/defu.mjs
7
7
  function isPlainObject(value) {
@@ -352,20 +352,13 @@ var upstash = () => {
352
352
  return {
353
353
  owner: "upstash",
354
354
  baseUrl: "https://qstash.upstash.io/llm",
355
- token: "",
356
- organization: void 0
355
+ token: ""
357
356
  };
358
357
  };
359
358
  var openai = ({
360
- token,
361
- organization
359
+ token
362
360
  }) => {
363
- return {
364
- token,
365
- owner: "openai",
366
- baseUrl: "https://api.openai.com",
367
- organization
368
- };
361
+ return { token, owner: "openai", baseUrl: "https://api.openai.com" };
369
362
  };
370
363
  var custom = ({
371
364
  baseUrl,
@@ -375,8 +368,7 @@ var custom = ({
375
368
  return {
376
369
  token,
377
370
  owner: "custom",
378
- baseUrl: trimmedBaseUrl,
379
- organization: void 0
371
+ baseUrl: trimmedBaseUrl
380
372
  };
381
373
  };
382
374
 
@@ -456,7 +448,7 @@ var Chat = class _Chat {
456
448
  */
457
449
  // eslint-disable-next-line @typescript-eslint/require-await
458
450
  createThirdParty = async (request) => {
459
- const { baseUrl, token, owner, organization } = request.provider;
451
+ const { baseUrl, token, owner } = request.provider;
460
452
  if (owner === "upstash")
461
453
  throw new Error("Upstash is not 3rd party provider!");
462
454
  delete request.provider;
@@ -470,9 +462,6 @@ var Chat = class _Chat {
470
462
  const headers = {
471
463
  "Content-Type": "application/json",
472
464
  Authorization: `Bearer ${token}`,
473
- ...organization ? {
474
- "OpenAI-Organization": organization
475
- } : {},
476
465
  ...isStream ? {
477
466
  Connection: "keep-alive",
478
467
  Accept: "text/event-stream",
@@ -688,7 +677,7 @@ function decodeBase64(base64) {
688
677
  return new TextDecoder().decode(intArray);
689
678
  } catch (error) {
690
679
  console.warn(
691
- `Upstash Qstash: Failed while decoding base64 "${base64}". Decoding with atob and returning it instead. ${error}`
680
+ `Upstash Qstash: Failed while decoding base64 "${base64}". Decoding with atob and returning it instead. Error: ${error}`
692
681
  );
693
682
  return atob(base64);
694
683
  }
@@ -1641,11 +1630,11 @@ var handleThirdPartyCallResult = async (request, requestPayload, client, workflo
1641
1630
  if (!(callbackMessage.status >= 200 && callbackMessage.status < 300)) {
1642
1631
  await debug?.log("WARN", "SUBMIT_THIRD_PARTY_RESULT", {
1643
1632
  status: callbackMessage.status,
1644
- body: atob(callbackMessage.body)
1633
+ body: decodeBase64(callbackMessage.body)
1645
1634
  });
1646
1635
  console.warn(
1647
1636
  `Workflow Warning: "context.call" failed with status ${callbackMessage.status} and will retry (if there are retries remaining). Error Message:
1648
- ${atob(callbackMessage.body)}`
1637
+ ${decodeBase64(callbackMessage.body)}`
1649
1638
  );
1650
1639
  return ok("call-will-retry");
1651
1640
  }
@@ -1681,7 +1670,7 @@ ${atob(callbackMessage.body)}`
1681
1670
  stepId: Number(stepIdString),
1682
1671
  stepName,
1683
1672
  stepType,
1684
- out: atob(callbackMessage.body),
1673
+ out: decodeBase64(callbackMessage.body),
1685
1674
  concurrent: Number(concurrentString)
1686
1675
  };
1687
1676
  await debug?.log("SUBMIT", "SUBMIT_THIRD_PARTY_RESULT", {
@@ -2075,6 +2064,7 @@ var AutoExecutor = class _AutoExecutor {
2075
2064
  * @param index index of the current step
2076
2065
  * @returns result[index] if lazyStepList > 1, otherwise result
2077
2066
  */
2067
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2078
2068
  static getResult(lazyStepList, result, index) {
2079
2069
  if (lazyStepList.length === 1) {
2080
2070
  return result;
@@ -2500,6 +2490,7 @@ var WorkflowContext = class {
2500
2490
  * @param headers call headers
2501
2491
  * @returns call result (parsed as JSON if possible)
2502
2492
  */
2493
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2503
2494
  async call(stepName, url, method, body, headers) {
2504
2495
  const result = await this.addStep(
2505
2496
  new LazyCallStep(stepName, url, method, body, headers ?? {})
@@ -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 = {