Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate workflow and llm #213

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions platforms/cloudflare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,18 @@ const getArgs = (
* @param routeFunction workflow function
* @param options workflow options
* @returns
*
* @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
* Please use https://github.com/upstash/workflow-js
* Migration Guide: https://upstash.com/docs/workflow/migration
*/
export const serve = <TInitialPayload = unknown>(
routeFunction: RouteFunction<TInitialPayload>,
options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">
): ((...args: PagesHandlerArgs | WorkersHandlerArgs) => Promise<Response>) => {
const handler = async (...args: PagesHandlerArgs | WorkersHandlerArgs) => {
const { request, env } = getArgs(args);
// eslint-disable-next-line @typescript-eslint/no-deprecated
const serveHandler = serveBase(routeFunction, {
env,
...options,
Expand Down
6 changes: 6 additions & 0 deletions platforms/h3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ function transformHeaders(headers: IncomingHttpHeaders): [string, string][] {
return formattedHeaders as [string, string][];
}

/**
* @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
* Please use https://github.com/upstash/workflow-js
* Migration Guide: https://upstash.com/docs/workflow/migration
*/
export const serve = <TInitialPayload = unknown>(
routeFunction: RouteFunction<TInitialPayload>,
options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">
Expand All @@ -92,6 +97,7 @@ export const serve = <TInitialPayload = unknown>(
method: "POST",
});

// eslint-disable-next-line @typescript-eslint/no-deprecated
const serveHandler = serveBase<TInitialPayload>(routeFunction, options);
return await serveHandler(request);
});
Expand Down
5 changes: 5 additions & 0 deletions platforms/hono.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export type WorkflowBindings = {
* @param routeFunction workflow function
* @param options workflow options
* @returns
*
* @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
* Please use https://github.com/upstash/workflow-js
* Migration Guide: https://upstash.com/docs/workflow/migration
*/
export const serve = <
TInitialPayload = unknown,
Expand All @@ -31,6 +35,7 @@ export const serve = <
const environment = context.env;
const request = context.req.raw;

// eslint-disable-next-line @typescript-eslint/no-deprecated
const serveHandler = serveBase(routeFunction, {
// when hono is used without cf workers, it sends a DebugHTTPServer
// object in `context.env`. don't pass env if this is the case:
Expand Down
11 changes: 11 additions & 0 deletions platforms/nextjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,16 @@ export function verifySignatureAppRouter(
* @param routeFunction workflow function
* @param options workflow options
* @returns
*
* @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
* Please use https://github.com/upstash/workflow-js
* Migration Guide: https://upstash.com/docs/workflow/migration
*/
export const serve = <TInitialPayload = unknown>(
routeFunction: RouteFunction<TInitialPayload>,
options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">
): ((request: Request) => Promise<Response>) => {
// eslint-disable-next-line @typescript-eslint/no-deprecated
const handler = serveBase<TInitialPayload>(routeFunction, {
onStepFinish: (workflowRunId: string) =>
new Response(JSON.stringify({ workflowRunId }), { status: 200 }),
Expand All @@ -217,10 +222,16 @@ export const serve = <TInitialPayload = unknown>(
};
};

/**
* @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
* Please use https://github.com/upstash/workflow-js
* Migration Guide: https://upstash.com/docs/workflow/migration
*/
export const servePagesRouter = <TInitialPayload = unknown>(
routeFunction: RouteFunction<TInitialPayload>,
options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">
): NextApiHandler => {
// eslint-disable-next-line @typescript-eslint/no-deprecated
const handler = serveBase(routeFunction, options);

return async (req: NextApiRequest, res: NextApiResponse) => {
Expand Down
4 changes: 3 additions & 1 deletion platforms/nuxt.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { verifySignatureH3 } from "./h3";

/**
* @deprecated Use import { verifySignatureH3 } from "@upstash/qstash/h3" instead
* @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
* Please use https://github.com/upstash/workflow-js
* Migration Guide: https://upstash.com/docs/workflow/migration
*/
// eslint-disable-next-line unicorn/prefer-export-from
export const verifySignatureNuxt = verifySignatureH3;
5 changes: 5 additions & 0 deletions platforms/solidjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ export const verifySignatureSolidjs = (
* @param routeFunction workflow function
* @param options workflow options
* @returns
*
* @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
* Please use https://github.com/upstash/workflow-js
* Migration Guide: https://upstash.com/docs/workflow/migration
*/
export const serve = <TInitialPayload = unknown>(
routeFunction: RouteFunction<TInitialPayload>,
Expand All @@ -72,6 +76,7 @@ export const serve = <TInitialPayload = unknown>(
}

// create serve handler
// eslint-disable-next-line @typescript-eslint/no-deprecated
const serveHandler = serveBase<TInitialPayload>(routeFunction, options);

return await serveHandler(event.request);
Expand Down
5 changes: 5 additions & 0 deletions platforms/svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ export const verifySignatureSvelte = <
* @param routeFunction workflow function
* @param options workflow options
* @returns
*
* @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
* Please use https://github.com/upstash/workflow-js
* Migration Guide: https://upstash.com/docs/workflow/migration
*/
export const serve = <TInitialPayload = unknown>(
routeFunction: RouteFunction<TInitialPayload>,
Expand All @@ -68,6 +72,7 @@ export const serve = <TInitialPayload = unknown>(
}
): RequestHandler => {
const handler: RequestHandler = async ({ request }) => {
// eslint-disable-next-line @typescript-eslint/no-deprecated
const serveMethod = serveBase<TInitialPayload>(routeFunction, options);
return await serveMethod(request);
};
Expand Down
1 change: 1 addition & 0 deletions src/client/api/llm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ describe("llm", () => {
await client.publishJSON({
api: {
name: "llm",
// eslint-disable-next-line @typescript-eslint/no-deprecated
provider: upstash(),
analytics: { name: "helicone", token: analyticsToken },
},
Expand Down
8 changes: 8 additions & 0 deletions src/client/api/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ export class LLMProvider<TOwner extends LLMOwner> extends BaseProvider<"llm", LL

// PROVIDERS

/**
* @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
*
* Please use an alternative LLM provider.
*
* openai: https://upstash.com/docs/qstash/integrations/llm
* anthropic: https://upstash.com/docs/qstash/integrations/anthropic
*/
export const upstash = (): LLMProvider<"upstash"> => {
return new LLMProvider("https://qstash.upstash.io/llm", "", "upstash");
};
Expand Down
1 change: 1 addition & 0 deletions src/client/api/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const getProviderInfo = (
upstashToken: string
): ProviderInfo => {
const { name, provider, ...parameters } = api;
// eslint-disable-next-line @typescript-eslint/no-deprecated
const finalProvider = provider ?? upstash();

// use upstash token if it's not set
Expand Down
5 changes: 5 additions & 0 deletions src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,13 @@ export class Client {
* Access the workflow API.
*
* cancel workflows.
*
* @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
* Please use @upstash/workflow instead https://github.com/upstash/workflow-js
* Migration Guide: https://upstash.com/docs/workflow/migration
*/
public get workflow(): Workflow {
// eslint-disable-next-line @typescript-eslint/no-deprecated
return new Workflow(this.http);
}

Expand Down
2 changes: 1 addition & 1 deletion src/client/llm/chat.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-deprecated */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-explicit-any */
Expand All @@ -14,7 +15,6 @@ async function checkStream(
stream: AsyncIterable<ChatCompletionChunk>,
expectInStream: string[] // array of strings to expect in stream
): Promise<void> {
// eslint-disable-next-line @typescript-eslint/no-deprecated
const _stream = OpenAIStream(stream);
const textResponse = new StreamingTextResponse(_stream);
const text = await textResponse.text();
Expand Down
2 changes: 2 additions & 0 deletions src/client/workflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ describe("workflow tests", () => {
);
expect(result.isOk()).toBeTrue();

// eslint-disable-next-line @typescript-eslint/no-deprecated
const cancelResult = await qstashClient.workflow.cancel(workflowRunId);
expect(cancelResult).toBeTrue();

// eslint-disable-next-line @typescript-eslint/no-deprecated
const throws = qstashClient.workflow.cancel(workflowRunId);
expect(throws).rejects.toThrow(
new QstashError(`{"error":"workflowRun ${workflowRunId} not found"}`)
Expand Down
5 changes: 5 additions & 0 deletions src/client/workflow/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ export * from "./context";
export * from "./types";
export * from "./logger";

/**
* @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
* Please use https://github.com/upstash/workflow-js
* Migration Guide: https://upstash.com/docs/workflow/migration
*/
export class Workflow {
private readonly http;

Expand Down
1 change: 1 addition & 0 deletions src/client/workflow/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const testEndpoint = async <TInitialPayload = unknown>({
}) => {
let counter = 0;

// eslint-disable-next-line @typescript-eslint/no-deprecated
const endpoint = workflowServe<TInitialPayload>(routeFunction, {
qstashClient,
url: LOCAL_WORKFLOW_URL,
Expand Down
1 change: 1 addition & 0 deletions src/client/workflow/receiver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const receiver = new Receiver({ currentSigningKey, nextSigningKey });
/**
* endpoint to call in the receiver tests
*/
// eslint-disable-next-line @typescript-eslint/no-deprecated
const endpoint = serve(
async (context) => {
await context.run("step 1", () => {
Expand Down
3 changes: 1 addition & 2 deletions src/client/workflow/serve.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-deprecated */
/* eslint-disable unicorn/consistent-function-scoping */
/* eslint-disable unicorn/no-null */
/* eslint-disable @typescript-eslint/require-await */
Expand Down Expand Up @@ -332,7 +333,6 @@ describe("serve", () => {
});

describe("failure settings", () => {
// eslint-disable-next-line unicorn/consistent-function-scoping
const routeFunction: RouteFunction<unknown> = async (context) => {
await context.sleep("sleep-step", 1);
};
Expand Down Expand Up @@ -424,7 +424,6 @@ describe("serve", () => {
_status,
_header,
_body
// eslint-disable-next-line unicorn/consistent-function-scoping
) => {
return;
};
Expand Down
4 changes: 4 additions & 0 deletions src/client/workflow/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ export const processOptions = <TResponse extends Response = Response, TInitialPa
* @param routeFunction - A function that uses WorkflowContext as a parameter and runs a workflow.
* @param options - Options including the client, onFinish callback, and initialPayloadParser.
* @returns An async method that consumes incoming requests and runs the workflow.
*
* @deprecated as of version 2.7.17. Will be removed in qstash-js 3.0.0.
* Please use https://github.com/upstash/workflow-js
* Migration Guide: https://upstash.com/docs/workflow/migration
*/
export const serve = <
TInitialPayload = unknown,
Expand Down
Loading