@maydotinc/q-studio 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/dist/core/index.d.ts +864 -0
- package/dist/core/index.js +2490 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/ui/assets/favicon.ico +0 -0
- package/dist/core/ui/assets/index.css +1 -0
- package/dist/core/ui/assets/index.js +475 -0
- package/dist/core/ui/index.html +33 -0
- package/dist/express/index.d.ts +38 -0
- package/dist/express/index.js +86 -0
- package/dist/express/index.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" href="./assets/favicon.ico" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>Workbench</title>
|
|
8
|
+
<!-- Prevent flash of wrong theme by setting dark class immediately -->
|
|
9
|
+
<script>
|
|
10
|
+
(() => {
|
|
11
|
+
var stored = localStorage.getItem('workbench:theme');
|
|
12
|
+
var isDark = stored ? stored === 'dark' : window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
13
|
+
if (isDark) document.documentElement.classList.add('dark');
|
|
14
|
+
})();
|
|
15
|
+
</script>
|
|
16
|
+
<style>
|
|
17
|
+
/* Prevent flash - set background immediately */
|
|
18
|
+
html { background-color: hsl(0 0% 98%); }
|
|
19
|
+
html.dark { background-color: hsl(0 0% 4%); }
|
|
20
|
+
</style>
|
|
21
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
22
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
23
|
+
<link
|
|
24
|
+
href="https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=Geist+Mono:wght@400;500&display=swap"
|
|
25
|
+
rel="stylesheet"
|
|
26
|
+
/>
|
|
27
|
+
<script type="module" crossorigin src="./assets/index.js"></script>
|
|
28
|
+
<link rel="stylesheet" crossorigin href="./assets/index.css">
|
|
29
|
+
</head>
|
|
30
|
+
<body>
|
|
31
|
+
<div id="root"></div>
|
|
32
|
+
</body>
|
|
33
|
+
</html>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { WorkbenchOptions } from '@maydotinc/q-studio/core';
|
|
2
|
+
export { WorkbenchOptions } from '@maydotinc/q-studio/core';
|
|
3
|
+
import { Queue } from 'bullmq';
|
|
4
|
+
import { Router } from 'express';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Mount the Workbench dashboard on an Express app.
|
|
8
|
+
*
|
|
9
|
+
* Returns an Express `Router` so it composes with `app.use("/path", router)`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import express from "express";
|
|
14
|
+
* import { Queue } from "bullmq";
|
|
15
|
+
* import { qStudio } from "@maydotinc/q-studio/express";
|
|
16
|
+
*
|
|
17
|
+
* const app = express();
|
|
18
|
+
* const emailQueue = new Queue("email", {
|
|
19
|
+
* connection: { url: process.env.REDIS_URL! },
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* app.use(
|
|
23
|
+
* "/jobs",
|
|
24
|
+
* qStudio({
|
|
25
|
+
* queues: [emailQueue],
|
|
26
|
+
* auth: {
|
|
27
|
+
* username: process.env.WORKBENCH_USER!,
|
|
28
|
+
* password: process.env.WORKBENCH_PASS!,
|
|
29
|
+
* },
|
|
30
|
+
* }),
|
|
31
|
+
* );
|
|
32
|
+
*
|
|
33
|
+
* app.listen(3000);
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
declare function qStudio(options: WorkbenchOptions | Queue[]): Router;
|
|
37
|
+
|
|
38
|
+
export { qStudio };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import {
|
|
3
|
+
BASIC_AUTH_CHALLENGE,
|
|
4
|
+
buildRouteTable,
|
|
5
|
+
checkBasicAuth,
|
|
6
|
+
renderIndexHtml,
|
|
7
|
+
resolveBasePath,
|
|
8
|
+
serveStaticAsset,
|
|
9
|
+
WorkbenchCore
|
|
10
|
+
} from "@maydotinc/q-studio/core";
|
|
11
|
+
import express from "express";
|
|
12
|
+
function qStudio(options) {
|
|
13
|
+
const core = new WorkbenchCore(options);
|
|
14
|
+
const router = express.Router();
|
|
15
|
+
if (core.requiresAuth()) {
|
|
16
|
+
router.use((req, res, next) => {
|
|
17
|
+
if (!checkBasicAuth(
|
|
18
|
+
req.headers.authorization,
|
|
19
|
+
core.options.auth.username,
|
|
20
|
+
core.options.auth.password
|
|
21
|
+
)) {
|
|
22
|
+
res.set(BASIC_AUTH_CHALLENGE.headers);
|
|
23
|
+
res.status(BASIC_AUTH_CHALLENGE.status).send(BASIC_AUTH_CHALLENGE.body);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
next();
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
router.use("/api", (_req, res, next) => {
|
|
30
|
+
res.set("Access-Control-Allow-Origin", "*");
|
|
31
|
+
res.set("Access-Control-Allow-Methods", "GET,HEAD,PUT,PATCH,POST,DELETE");
|
|
32
|
+
res.set("Access-Control-Allow-Headers", "*");
|
|
33
|
+
next();
|
|
34
|
+
});
|
|
35
|
+
router.use("/api", express.json());
|
|
36
|
+
for (const route of buildRouteTable(core)) {
|
|
37
|
+
router[route.method](`/api${route.path}`, async (req, res) => {
|
|
38
|
+
try {
|
|
39
|
+
const result = await route.handler({
|
|
40
|
+
params: req.params,
|
|
41
|
+
query: req.query,
|
|
42
|
+
body: req.body
|
|
43
|
+
});
|
|
44
|
+
res.status(result.status).json(result.body);
|
|
45
|
+
} catch (error) {
|
|
46
|
+
res.status(500).json({
|
|
47
|
+
error: error instanceof Error ? error.message : "Internal server error"
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
router.get("/config", (_req, res) => {
|
|
53
|
+
res.json(core.getConfig());
|
|
54
|
+
});
|
|
55
|
+
router.get("/favicon.ico", (req, res) => {
|
|
56
|
+
const asset = serveStaticAsset("favicon.ico");
|
|
57
|
+
if (asset.status === 404 || !asset.body) {
|
|
58
|
+
res.status(404).type("text/plain").send("Not found");
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
res.status(200).type(asset.contentType).send(asset.body);
|
|
62
|
+
});
|
|
63
|
+
router.get("/assets/:file", (req, res) => {
|
|
64
|
+
const asset = serveStaticAsset(req.params.file);
|
|
65
|
+
if (asset.status === 404 || !asset.body) {
|
|
66
|
+
res.status(404).type("text/plain").send("Not found");
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
res.status(200).type(asset.contentType).send(asset.body);
|
|
70
|
+
});
|
|
71
|
+
router.use((req, res, next) => {
|
|
72
|
+
if (req.method !== "GET") {
|
|
73
|
+
next();
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const pathname = (req.originalUrl ?? req.url).split("?")[0] ?? "/";
|
|
77
|
+
const basePath = resolveBasePath(core.options.basePath, pathname);
|
|
78
|
+
const html = renderIndexHtml(basePath, core.options.title || "Workbench");
|
|
79
|
+
res.status(200).type("text/html; charset=utf-8").send(html.body);
|
|
80
|
+
});
|
|
81
|
+
return router;
|
|
82
|
+
}
|
|
83
|
+
export {
|
|
84
|
+
qStudio
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\n BASIC_AUTH_CHALLENGE,\n buildRouteTable,\n checkBasicAuth,\n renderIndexHtml,\n resolveBasePath,\n serveStaticAsset,\n WorkbenchCore,\n type WorkbenchOptions,\n} from \"@maydotinc/q-studio/core\";\nimport type { Queue } from \"bullmq\";\nimport express, { type Router } from \"express\";\n\n/**\n * Mount the Workbench dashboard on an Express app.\n *\n * Returns an Express `Router` so it composes with `app.use(\"/path\", router)`.\n *\n * @example\n * ```ts\n * import express from \"express\";\n * import { Queue } from \"bullmq\";\n * import { qStudio } from \"@maydotinc/q-studio/express\";\n *\n * const app = express();\n * const emailQueue = new Queue(\"email\", {\n * connection: { url: process.env.REDIS_URL! },\n * });\n *\n * app.use(\n * \"/jobs\",\n * qStudio({\n * queues: [emailQueue],\n * auth: {\n * username: process.env.WORKBENCH_USER!,\n * password: process.env.WORKBENCH_PASS!,\n * },\n * }),\n * );\n *\n * app.listen(3000);\n * ```\n */\nexport function qStudio(options: WorkbenchOptions | Queue[]): Router {\n const core = new WorkbenchCore(options);\n const router = express.Router();\n\n if (core.requiresAuth()) {\n router.use((req, res, next) => {\n if (\n !checkBasicAuth(\n req.headers.authorization,\n core.options.auth!.username,\n core.options.auth!.password,\n )\n ) {\n res.set(BASIC_AUTH_CHALLENGE.headers);\n res.status(BASIC_AUTH_CHALLENGE.status).send(BASIC_AUTH_CHALLENGE.body);\n return;\n }\n next();\n });\n }\n\n router.use(\"/api\", (_req, res, next) => {\n res.set(\"Access-Control-Allow-Origin\", \"*\");\n res.set(\"Access-Control-Allow-Methods\", \"GET,HEAD,PUT,PATCH,POST,DELETE\");\n res.set(\"Access-Control-Allow-Headers\", \"*\");\n next();\n });\n\n router.use(\"/api\", express.json());\n\n for (const route of buildRouteTable(core)) {\n router[route.method](`/api${route.path}`, async (req, res) => {\n try {\n const result = await route.handler({\n params: req.params as Record<string, string>,\n query: req.query as Record<string, string | undefined>,\n body: req.body,\n });\n res.status(result.status).json(result.body);\n } catch (error) {\n res.status(500).json({\n error:\n error instanceof Error ? error.message : \"Internal server error\",\n });\n }\n });\n }\n\n router.get(\"/config\", (_req, res) => {\n res.json(core.getConfig());\n });\n\n router.get(\"/favicon.ico\", (req, res) => {\n const asset = serveStaticAsset(\"favicon.ico\");\n if (asset.status === 404 || !asset.body) {\n res.status(404).type(\"text/plain\").send(\"Not found\");\n return;\n }\n\n res.status(200).type(asset.contentType).send(asset.body);\n });\n\n router.get(\"/assets/:file\", (req, res) => {\n const asset = serveStaticAsset(req.params.file as string);\n if (asset.status === 404 || !asset.body) {\n res.status(404).type(\"text/plain\").send(\"Not found\");\n return;\n }\n res.status(200).type(asset.contentType).send(asset.body);\n });\n\n router.use((req, res, next) => {\n if (req.method !== \"GET\") {\n next();\n return;\n }\n const pathname = (req.originalUrl ?? req.url).split(\"?\")[0] ?? \"/\";\n const basePath = resolveBasePath(core.options.basePath, pathname);\n const html = renderIndexHtml(basePath, core.options.title || \"Workbench\");\n res.status(200).type(\"text/html; charset=utf-8\").send(html.body);\n });\n\n return router;\n}\n\nexport type { WorkbenchOptions } from \"@maydotinc/q-studio/core\";\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAEP,OAAO,aAA8B;AAgC9B,SAAS,QAAQ,SAA6C;AACnE,QAAM,OAAO,IAAI,cAAc,OAAO;AACtC,QAAM,SAAS,QAAQ,OAAO;AAE9B,MAAI,KAAK,aAAa,GAAG;AACvB,WAAO,IAAI,CAAC,KAAK,KAAK,SAAS;AAC7B,UACE,CAAC;AAAA,QACC,IAAI,QAAQ;AAAA,QACZ,KAAK,QAAQ,KAAM;AAAA,QACnB,KAAK,QAAQ,KAAM;AAAA,MACrB,GACA;AACA,YAAI,IAAI,qBAAqB,OAAO;AACpC,YAAI,OAAO,qBAAqB,MAAM,EAAE,KAAK,qBAAqB,IAAI;AACtE;AAAA,MACF;AACA,WAAK;AAAA,IACP,CAAC;AAAA,EACH;AAEA,SAAO,IAAI,QAAQ,CAAC,MAAM,KAAK,SAAS;AACtC,QAAI,IAAI,+BAA+B,GAAG;AAC1C,QAAI,IAAI,gCAAgC,gCAAgC;AACxE,QAAI,IAAI,gCAAgC,GAAG;AAC3C,SAAK;AAAA,EACP,CAAC;AAED,SAAO,IAAI,QAAQ,QAAQ,KAAK,CAAC;AAEj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;AACxB,WAAK;AACL;AAAA,IACF;AACA,UAAM,YAAY,IAAI,eAAe,IAAI,KAAK,MAAM,GAAG,EAAE,CAAC,KAAK;AAC/D,UAAM,WAAW,gBAAgB,KAAK,QAAQ,UAAU,QAAQ;AAChE,UAAM,OAAO,gBAAgB,UAAU,KAAK,QAAQ,SAAS,WAAW;AACxE,QAAI,OAAO,GAAG,EAAE,KAAK,0BAA0B,EAAE,KAAK,KAAK,IAAI;AAAA,EACjE,CAAC;AAED,SAAO;AACT;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@maydotinc/q-studio",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Q Studio — private BullMQ dashboard for Express.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
"./core": {
|
|
8
|
+
"types": "./dist/core/index.d.ts",
|
|
9
|
+
"import": "./dist/core/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./express": {
|
|
12
|
+
"types": "./dist/express/index.d.ts",
|
|
13
|
+
"import": "./dist/express/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"publishConfig": {
|
|
20
|
+
"access": "restricted"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "pnpm run build:core && pnpm run build:express",
|
|
24
|
+
"build:core": "pnpm --dir ../core run build && rm -rf ../q-studio/dist/core && mkdir -p ../q-studio/dist && cp -R ../core/dist ../q-studio/dist/core",
|
|
25
|
+
"build:express": "pnpm --dir ../express run build && rm -rf ../q-studio/dist/express && mkdir -p ../q-studio/dist && cp -R ../express/dist ../q-studio/dist/express",
|
|
26
|
+
"typecheck": "pnpm --dir ../core run typecheck && pnpm --dir ../express run typecheck",
|
|
27
|
+
"lint": "biome check .",
|
|
28
|
+
"clean": "rm -rf dist .turbo"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@radix-ui/react-checkbox": "^1.3.3",
|
|
32
|
+
"@radix-ui/react-hover-card": "^1.1.15",
|
|
33
|
+
"@xyflow/react": "^12.10.1",
|
|
34
|
+
"dagre": "^0.8.5",
|
|
35
|
+
"framer-motion": "^12.38.0",
|
|
36
|
+
"hono": "^4.6.14",
|
|
37
|
+
"lru-cache": "^11.2.7"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"bullmq": ">=5.0.0",
|
|
41
|
+
"express": ">=4.18.0",
|
|
42
|
+
"ioredis": ">=5.0.0"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/node": "^22.10.2",
|
|
46
|
+
"typescript": "^5.7.2"
|
|
47
|
+
}
|
|
48
|
+
}
|