@upstash/workflow 0.1.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/LICENSE +21 -0
- package/README.md +3 -0
- package/chunk-JDMP6KKR.mjs +2006 -0
- package/cloudflare.d.mts +33 -0
- package/cloudflare.d.ts +33 -0
- package/cloudflare.js +2017 -0
- package/cloudflare.mjs +37 -0
- package/h3.d.mts +10 -0
- package/h3.d.ts +10 -0
- package/h3.js +2328 -0
- package/h3.mjs +348 -0
- package/hono.d.mts +25 -0
- package/hono.d.ts +25 -0
- package/hono.js +2002 -0
- package/hono.mjs +22 -0
- package/index.d.mts +57 -0
- package/index.d.ts +57 -0
- package/index.js +2038 -0
- package/index.mjs +18 -0
- package/nextjs.d.mts +18 -0
- package/nextjs.d.ts +18 -0
- package/nextjs.js +2022 -0
- package/nextjs.mjs +41 -0
- package/package.json +99 -0
- package/solidjs.d.mts +16 -0
- package/solidjs.d.ts +16 -0
- package/solidjs.js +2001 -0
- package/solidjs.mjs +21 -0
- package/svelte.d.mts +18 -0
- package/svelte.d.ts +18 -0
- package/svelte.js +1995 -0
- package/svelte.mjs +15 -0
- package/types-CfN1Epuj.d.mts +616 -0
- package/types-CfN1Epuj.d.ts +616 -0
package/nextjs.mjs
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {
|
|
2
|
+
serve
|
|
3
|
+
} from "./chunk-JDMP6KKR.mjs";
|
|
4
|
+
|
|
5
|
+
// platforms/nextjs.ts
|
|
6
|
+
import { NextResponse } from "next/server";
|
|
7
|
+
var serve2 = (routeFunction, options) => {
|
|
8
|
+
const handler = serve(routeFunction, {
|
|
9
|
+
onStepFinish: (workflowRunId) => new NextResponse(JSON.stringify({ workflowRunId }), { status: 200 }),
|
|
10
|
+
...options
|
|
11
|
+
});
|
|
12
|
+
return async (request) => {
|
|
13
|
+
return await handler(request);
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
var servePagesRouter = (routeFunction, options) => {
|
|
17
|
+
const handler = serve(routeFunction, options);
|
|
18
|
+
return async (request_, res) => {
|
|
19
|
+
if (request_.method?.toUpperCase() !== "POST") {
|
|
20
|
+
res.status(405).json("Only POST requests are allowed in worklfows");
|
|
21
|
+
return;
|
|
22
|
+
} else if (!request_.url) {
|
|
23
|
+
res.status(400).json("url not found in the request");
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const protocol = request_.headers["x-forwarded-proto"];
|
|
27
|
+
const baseUrl = options?.baseUrl ?? `${protocol}://${request_.headers.host}`;
|
|
28
|
+
const request = new Request(options?.url ?? `${baseUrl}${request_.url}`, {
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
30
|
+
body: JSON.stringify(request_.body) ?? "",
|
|
31
|
+
headers: new Headers(request_.headersDistinct),
|
|
32
|
+
method: "POST"
|
|
33
|
+
});
|
|
34
|
+
const response = await handler(request);
|
|
35
|
+
res.status(response.status).json(await response.json());
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
serve2 as serve,
|
|
40
|
+
servePagesRouter
|
|
41
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@upstash/workflow",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Durable, Reliable and Performant Serverless Functions",
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"module": "./index.mjs",
|
|
7
|
+
"types": "./index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"./*"
|
|
10
|
+
],
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./index.mjs",
|
|
14
|
+
"require": "./index.js"
|
|
15
|
+
},
|
|
16
|
+
"./dist/nextjs": {
|
|
17
|
+
"import": "./nextjs.mjs",
|
|
18
|
+
"require": "./nextjs.js"
|
|
19
|
+
},
|
|
20
|
+
"./nextjs": {
|
|
21
|
+
"import": "./nextjs.mjs",
|
|
22
|
+
"require": "./nextjs.js"
|
|
23
|
+
},
|
|
24
|
+
"./h3": {
|
|
25
|
+
"import": "./h3.mjs",
|
|
26
|
+
"require": "./h3.js"
|
|
27
|
+
},
|
|
28
|
+
"./svelte": {
|
|
29
|
+
"import": "./svelte.mjs",
|
|
30
|
+
"require": "./svelte.js"
|
|
31
|
+
},
|
|
32
|
+
"./solidjs": {
|
|
33
|
+
"import": "./solidjs.mjs",
|
|
34
|
+
"require": "./solidjs.js"
|
|
35
|
+
},
|
|
36
|
+
"./workflow": {
|
|
37
|
+
"import": "./workflow.mjs",
|
|
38
|
+
"require": "./workflow.js"
|
|
39
|
+
},
|
|
40
|
+
"./hono": {
|
|
41
|
+
"import": "./hono.mjs",
|
|
42
|
+
"require": "./hono.js"
|
|
43
|
+
},
|
|
44
|
+
"./cloudflare": {
|
|
45
|
+
"import": "./cloudflare.mjs",
|
|
46
|
+
"require": "./cloudflare.js"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "tsup && cp README.md ./dist/ && cp package.json ./dist/ && cp LICENSE ./dist/",
|
|
51
|
+
"test": "bun test src",
|
|
52
|
+
"fmt": "prettier --write .",
|
|
53
|
+
"lint": "tsc && eslint \"{src,platforms}/**/*.{js,ts,tsx}\" --quiet --fix",
|
|
54
|
+
"check-exports": "bun run build && cd dist && attw -P",
|
|
55
|
+
"prepare": "husky"
|
|
56
|
+
},
|
|
57
|
+
"repository": {
|
|
58
|
+
"type": "git",
|
|
59
|
+
"url": "git+https://github.com/upstash/workflow-ts.git"
|
|
60
|
+
},
|
|
61
|
+
"keywords": [
|
|
62
|
+
"upstash",
|
|
63
|
+
"qstash",
|
|
64
|
+
"workflow",
|
|
65
|
+
"serverless"
|
|
66
|
+
],
|
|
67
|
+
"author": "Cahid Arda Oz",
|
|
68
|
+
"license": "MIT",
|
|
69
|
+
"bugs": {
|
|
70
|
+
"url": "https://github.com/upstash/workflow-ts/issues"
|
|
71
|
+
},
|
|
72
|
+
"homepage": "https://github.com/upstash/workflow-ts#readme",
|
|
73
|
+
"devDependencies": {
|
|
74
|
+
"@commitlint/cli": "^19.5.0",
|
|
75
|
+
"@commitlint/config-conventional": "^19.5.0",
|
|
76
|
+
"@eslint/js": "^9.11.1",
|
|
77
|
+
"@solidjs/start": "^1.0.8",
|
|
78
|
+
"@sveltejs/kit": "^2.6.1",
|
|
79
|
+
"@types/bun": "^1.1.10",
|
|
80
|
+
"eslint": "^9.11.1",
|
|
81
|
+
"eslint-plugin-unicorn": "^55.0.0",
|
|
82
|
+
"globals": "^15.10.0",
|
|
83
|
+
"h3": "^1.12.0",
|
|
84
|
+
"hono": "^4.6.3",
|
|
85
|
+
"husky": "^9.1.6",
|
|
86
|
+
"next": "^14.2.14",
|
|
87
|
+
"prettier": "3.3.3",
|
|
88
|
+
"tsc": "^2.0.4",
|
|
89
|
+
"tsup": "^8.3.0",
|
|
90
|
+
"typescript": "5.4.5",
|
|
91
|
+
"typescript-eslint": "^8.8.0"
|
|
92
|
+
},
|
|
93
|
+
"dependencies": {
|
|
94
|
+
"@upstash/qstash": "^2.7.12"
|
|
95
|
+
},
|
|
96
|
+
"directories": {
|
|
97
|
+
"example": "examples"
|
|
98
|
+
}
|
|
99
|
+
}
|
package/solidjs.d.mts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { APIEvent } from '@solidjs/start/server';
|
|
2
|
+
import { R as RouteFunction, W as WorkflowServeOptions } from './types-CfN1Epuj.mjs';
|
|
3
|
+
import '@upstash/qstash';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Serve method to serve a Upstash Workflow in a Nextjs project
|
|
7
|
+
*
|
|
8
|
+
* See for options https://upstash.com/docs/qstash/workflows/basics/serve
|
|
9
|
+
*
|
|
10
|
+
* @param routeFunction workflow function
|
|
11
|
+
* @param options workflow options
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">) => (event: APIEvent) => Promise<Response>;
|
|
15
|
+
|
|
16
|
+
export { serve };
|
package/solidjs.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { APIEvent } from '@solidjs/start/server';
|
|
2
|
+
import { R as RouteFunction, W as WorkflowServeOptions } from './types-CfN1Epuj.js';
|
|
3
|
+
import '@upstash/qstash';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Serve method to serve a Upstash Workflow in a Nextjs project
|
|
7
|
+
*
|
|
8
|
+
* See for options https://upstash.com/docs/qstash/workflows/basics/serve
|
|
9
|
+
*
|
|
10
|
+
* @param routeFunction workflow function
|
|
11
|
+
* @param options workflow options
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: Omit<WorkflowServeOptions<Response, TInitialPayload>, "onStepFinish">) => (event: APIEvent) => Promise<Response>;
|
|
15
|
+
|
|
16
|
+
export { serve };
|