@getworkbench/core 0.2.0 → 0.3.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/hono.d.ts ADDED
@@ -0,0 +1,43 @@
1
+ import { Hono } from 'hono';
2
+ import { W as WorkbenchCore } from './workbench-CRdU4cB7.js';
3
+ import 'bullmq';
4
+
5
+ /**
6
+ * Create API routes for Workbench as a Hono app.
7
+ *
8
+ * Iterates the framework-agnostic `buildRouteTable(core)` and registers
9
+ * each route on a fresh Hono instance. Adapters that don't speak Hono can
10
+ * use `buildRouteTable` directly — see `@getworkbench/express` and
11
+ * `@getworkbench/fastify`.
12
+ */
13
+ declare function createApiRoutes(core: WorkbenchCore): Hono;
14
+
15
+ /**
16
+ * Build an API-only Hono app for Workbench: `/api/*` and `/config`, with CORS
17
+ * on `/api/*` and optional basic-auth. Does **not** serve `index.html`,
18
+ * `/assets/:file`, or any static UI.
19
+ *
20
+ * Used by the Tauri desktop sidecar, which hosts the dashboard UI from the
21
+ * Tauri webview directly and only needs the JSON API on a loopback port.
22
+ *
23
+ * Adapter consumers (`@getworkbench/hono`, `@getworkbench/elysia`, etc.)
24
+ * continue to use {@link buildWorkbenchApp} which also serves the bundled UI.
25
+ */
26
+ declare function buildWorkbenchApiApp(core: WorkbenchCore): Hono;
27
+
28
+ /**
29
+ * Build a fully-wired Hono app for Workbench:
30
+ *
31
+ * - `POST /api/*`, `GET /api/*` etc. — JSON API
32
+ * - `GET /config` — UI bootstrap config
33
+ * - `GET /assets/:file` — static asset reader
34
+ * - `GET *` — `index.html` with `<base href>`
35
+ * - CORS on `/api/*`
36
+ * - Basic auth on everything when `core.requiresAuth()` is true
37
+ *
38
+ * Used directly by `@getworkbench/hono` (returned as-is for `.route()`
39
+ * mounting) and indirectly by `createFetchHandler` for non-Hono adapters.
40
+ */
41
+ declare function buildWorkbenchApp(core: WorkbenchCore): Hono;
42
+
43
+ export { buildWorkbenchApiApp, buildWorkbenchApp, createApiRoutes };
package/dist/hono.js ADDED
@@ -0,0 +1,32 @@
1
+ import {
2
+ buildWorkbenchApp,
3
+ createApiRoutes
4
+ } from "./chunk-O7DNWUZD.js";
5
+
6
+ // src/server/hono-api-app.ts
7
+ import { Hono } from "hono";
8
+ import { basicAuth } from "hono/basic-auth";
9
+ import { cors } from "hono/cors";
10
+ function buildWorkbenchApiApp(core) {
11
+ const app = new Hono();
12
+ app.use("/api/*", cors());
13
+ app.use("/config", cors());
14
+ if (core.requiresAuth()) {
15
+ app.use(
16
+ "*",
17
+ basicAuth({
18
+ username: core.options.auth.username,
19
+ password: core.options.auth.password
20
+ })
21
+ );
22
+ }
23
+ app.route("/api", createApiRoutes(core));
24
+ app.get("/config", (c) => c.json(core.getConfig()));
25
+ return app;
26
+ }
27
+ export {
28
+ buildWorkbenchApiApp,
29
+ buildWorkbenchApp,
30
+ createApiRoutes
31
+ };
32
+ //# sourceMappingURL=hono.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/server/hono-api-app.ts"],"sourcesContent":["import { Hono } from \"hono\";\nimport { basicAuth } from \"hono/basic-auth\";\nimport { cors } from \"hono/cors\";\nimport { createApiRoutes } from \"../api/router\";\nimport type { WorkbenchCore } from \"../core/workbench\";\n\n/**\n * Build an API-only Hono app for Workbench: `/api/*` and `/config`, with CORS\n * on `/api/*` and optional basic-auth. Does **not** serve `index.html`,\n * `/assets/:file`, or any static UI.\n *\n * Used by the Tauri desktop sidecar, which hosts the dashboard UI from the\n * Tauri webview directly and only needs the JSON API on a loopback port.\n *\n * Adapter consumers (`@getworkbench/hono`, `@getworkbench/elysia`, etc.)\n * continue to use {@link buildWorkbenchApp} which also serves the bundled UI.\n */\nexport function buildWorkbenchApiApp(core: WorkbenchCore): Hono {\n const app = new Hono();\n\n app.use(\"/api/*\", cors());\n app.use(\"/config\", cors());\n\n if (core.requiresAuth()) {\n app.use(\n \"*\",\n basicAuth({\n username: core.options.auth!.username,\n password: core.options.auth!.password,\n }),\n );\n }\n\n app.route(\"/api\", createApiRoutes(core));\n\n app.get(\"/config\", (c) => c.json(core.getConfig()));\n\n return app;\n}\n"],"mappings":";;;;;;AAAA,SAAS,YAAY;AACrB,SAAS,iBAAiB;AAC1B,SAAS,YAAY;AAed,SAAS,qBAAqB,MAA2B;AAC9D,QAAM,MAAM,IAAI,KAAK;AAErB,MAAI,IAAI,UAAU,KAAK,CAAC;AACxB,MAAI,IAAI,WAAW,KAAK,CAAC;AAEzB,MAAI,KAAK,aAAa,GAAG;AACvB,QAAI;AAAA,MACF;AAAA,MACA,UAAU;AAAA,QACR,UAAU,KAAK,QAAQ,KAAM;AAAA,QAC7B,UAAU,KAAK,QAAQ,KAAM;AAAA,MAC/B,CAAC;AAAA,IACH;AAAA,EACF;AAEA,MAAI,MAAM,QAAQ,gBAAgB,IAAI,CAAC;AAEvC,MAAI,IAAI,WAAW,CAAC,MAAM,EAAE,KAAK,KAAK,UAAU,CAAC,CAAC;AAElD,SAAO;AACT;","names":[]}