@wervt/nuxt 0.3.2 → 0.3.4
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/README.md +2 -0
- package/dist/dev.d.ts +4 -4
- package/dist/dev.js +33 -11
- package/dist/env-types.js +13 -0
- package/dist/icons.js +30 -0
- package/dist/loading.js +30 -0
- package/dist/module.d.ts +0 -2
- package/dist/module.js +42 -2
- package/dist/node_modules/.pnpm/nitro@3.0.260903-beta/node_modules/nitro/dist/runtime/internal/task.js +1 -2
- package/dist/node_modules/.pnpm/nitro@3.0.260903-beta/node_modules/nitro/dist/runtime/task.js +1 -2
- package/dist/og-image.js +38 -0
- package/dist/preview.d.ts +1 -3
- package/dist/preview.js +1 -2
- package/dist/provision.d.ts +31 -4
- package/dist/provision.js +82 -21
- package/dist/route-tools.js +1 -2
- package/dist/runtime/app/plugins/analytics.client.d.ts +0 -2
- package/dist/runtime/app/plugins/analytics.client.js +1 -2
- package/dist/runtime/app/plugins/feedback.client.d.ts +0 -2
- package/dist/runtime/app/plugins/feedback.client.js +1 -2
- package/dist/runtime/app/plugins/update.client.d.ts +0 -2
- package/dist/runtime/app/plugins/update.client.js +1 -2
- package/dist/runtime/app/plugins/user.client.d.ts +0 -2
- package/dist/runtime/app/plugins/user.client.js +1 -2
- package/dist/runtime/app/plugins/webmcp.client.d.ts +0 -2
- package/dist/runtime/app/plugins/webmcp.client.js +1 -2
- package/dist/runtime/app/preview-error.d.ts +26 -0
- package/dist/runtime/app/preview-error.js +69 -0
- package/dist/runtime/app/snapshot.d.ts +15 -0
- package/dist/runtime/app/snapshot.js +63 -0
- package/dist/runtime/app/useShape.d.ts +8 -3
- package/dist/runtime/app/useShape.js +10 -55
- package/dist/runtime/app/useWervtFeedback.d.ts +1 -2
- package/dist/runtime/app/useWervtFeedback.js +1 -2
- package/dist/runtime/app/useWervtTrack.d.ts +1 -3
- package/dist/runtime/app/useWervtTrack.js +1 -2
- package/dist/runtime/app/useWervtUpdate.d.ts +1 -3
- package/dist/runtime/app/useWervtUpdate.js +2 -3
- package/dist/runtime/app/useWervtUser.d.ts +1 -3
- package/dist/runtime/app/useWervtUser.js +1 -2
- package/dist/runtime/email/components.d.ts +1 -3
- package/dist/runtime/email/components.js +1 -2
- package/dist/runtime/email/index.d.ts +2 -1
- package/dist/runtime/email/index.js +2 -1
- package/dist/runtime/email/invite.d.ts +73 -0
- package/dist/runtime/email/invite.js +59 -0
- package/dist/runtime/email/render.d.ts +1 -3
- package/dist/runtime/email/render.js +1 -2
- package/dist/runtime/server/access.d.ts +4 -5
- package/dist/runtime/server/access.js +4 -4
- package/dist/runtime/server/agent-token-plugin.d.ts +11 -0
- package/dist/runtime/server/agent-token-plugin.js +9 -0
- package/dist/runtime/server/anthropic.d.ts +19 -0
- package/dist/runtime/server/anthropic.js +52 -0
- package/dist/runtime/server/boot.d.ts +0 -2
- package/dist/runtime/server/boot.js +1 -2
- package/dist/runtime/server/db.d.ts +1 -3
- package/dist/runtime/server/db.js +1 -2
- package/dist/runtime/server/dev-auth.d.ts +0 -2
- package/dist/runtime/server/dev-auth.js +1 -2
- package/dist/runtime/server/email-preview.d.ts +0 -2
- package/dist/runtime/server/email-preview.js +1 -2
- package/dist/runtime/server/identity.d.ts +18 -0
- package/dist/runtime/server/identity.js +36 -0
- package/dist/runtime/server/index.d.ts +4 -3
- package/dist/runtime/server/index.js +4 -3
- package/dist/runtime/server/logger.d.ts +0 -2
- package/dist/runtime/server/logger.js +1 -2
- package/dist/runtime/server/mail.d.ts +1 -3
- package/dist/runtime/server/mail.js +1 -2
- package/dist/runtime/server/mcp-auth-server.d.ts +0 -2
- package/dist/runtime/server/mcp-auth-server.js +1 -2
- package/dist/runtime/server/mcp-auth.d.ts +1 -3
- package/dist/runtime/server/mcp-auth.js +1 -2
- package/dist/runtime/server/mcp-claims.d.ts +1 -3
- package/dist/runtime/server/mcp-claims.js +1 -2
- package/dist/runtime/server/mcp-metadata.d.ts +0 -2
- package/dist/runtime/server/mcp-metadata.js +1 -2
- package/dist/runtime/server/mcp.d.ts +0 -2
- package/dist/runtime/server/mcp.js +1 -2
- package/dist/runtime/server/preview-errors-plugin.d.ts +13 -0
- package/dist/runtime/server/preview-errors-plugin.js +19 -0
- package/dist/runtime/server/seed.d.ts +1 -3
- package/dist/runtime/server/seed.js +1 -2
- package/dist/runtime/server/shape.d.ts +1 -3
- package/dist/runtime/server/shape.js +1 -2
- package/dist/runtime/server/storage-plugin.d.ts +1 -3
- package/dist/runtime/server/storage-plugin.js +1 -2
- package/dist/runtime/server/task-handlers.d.ts +2 -3
- package/dist/runtime/server/task-handlers.js +1 -2
- package/dist/runtime/server/task-list-nitro2.d.ts +0 -2
- package/dist/runtime/server/task-list-nitro2.js +1 -2
- package/dist/runtime/server/task-list-nitro3.d.ts +0 -2
- package/dist/runtime/server/task-list-nitro3.js +1 -2
- package/dist/runtime/server/task-run-nitro2.d.ts +0 -2
- package/dist/runtime/server/task-run-nitro2.js +1 -2
- package/dist/runtime/server/task-run-nitro3.d.ts +0 -2
- package/dist/runtime/server/task-run-nitro3.js +1 -2
- package/dist/runtime/server/tasks.d.ts +1 -3
- package/dist/runtime/server/tasks.js +1 -2
- package/dist/runtime/server/tool-handlers.d.ts +1 -3
- package/dist/runtime/server/tool-handlers.js +1 -2
- package/dist/runtime/server/tool-list.js +1 -2
- package/dist/runtime/server/tool-run.js +1 -2
- package/dist/runtime/server/tools.d.ts +1 -2
- package/dist/runtime/server/tools.js +1 -2
- package/dist/runtime/server/user-route.d.ts +0 -2
- package/dist/runtime/server/user-route.js +1 -2
- package/dist/runtime/server/user.d.ts +9 -5
- package/dist/runtime/server/user.js +29 -5
- package/dist/runtime/server/validate.d.ts +1 -2
- package/dist/runtime/server/validate.js +1 -2
- package/dist/runtime/shared/agent-token.d.ts +7 -0
- package/dist/runtime/shared/agent-token.js +16 -0
- package/dist/runtime/shared/mark.d.ts +1 -0
- package/dist/runtime/shared/mark.js +3 -0
- package/dist/runtime/shared/preview-errors.d.ts +10 -0
- package/dist/runtime/shared/preview-errors.js +14 -0
- package/dist/runtime/shared/shape.d.ts +1 -2
- package/dist/runtime/shared/shape.js +1 -2
- package/dist/runtime/shared/user.d.ts +9 -3
- package/dist/runtime/shared/user.js +5 -3
- package/dist/seed.js +1 -2
- package/dist/shapes.js +1 -2
- package/dist/storage.d.ts +50 -4
- package/dist/storage.js +224 -5
- package/dist/studio-preview.js +34 -0
- package/package.json +17 -8
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createS3Provider, setFileStorageProvider } from "#imports";
|
|
2
|
-
|
|
2
|
+
// src/runtime/server/storage-plugin.ts
|
|
3
3
|
function wervtStorage() {
|
|
4
4
|
const env = process.env;
|
|
5
5
|
if (!env.WERVT_S3_URL || !env.WERVT_S3_BUCKET) return;
|
|
@@ -12,5 +12,4 @@ function wervtStorage() {
|
|
|
12
12
|
publicEndpoint: env.WERVT_S3_PUBLIC_URL
|
|
13
13
|
}));
|
|
14
14
|
}
|
|
15
|
-
//#endregion
|
|
16
15
|
export { wervtStorage as default };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/runtime/server/task-handlers.d.ts
|
|
2
1
|
type RunTask = (name: string, options: {
|
|
3
2
|
payload?: Record<string, unknown>;
|
|
4
3
|
}) => Promise<{
|
|
@@ -12,8 +11,8 @@ type Registry = Record<string, {
|
|
|
12
11
|
}>;
|
|
13
12
|
/** `POST /_wervt/tasks/:name`: runs a task when the control plane asks. */
|
|
14
13
|
export declare function taskRunHandler(runTask: RunTask): import("nuxt/server").EventHandler<Promise<{
|
|
15
|
-
error: string;
|
|
16
14
|
result?: undefined;
|
|
15
|
+
error: string;
|
|
17
16
|
} | {
|
|
18
17
|
error?: undefined;
|
|
19
18
|
result: {} | null;
|
|
@@ -25,4 +24,4 @@ export declare function taskListHandler(tasks: Registry): import("nuxt/server").
|
|
|
25
24
|
}[] | {
|
|
26
25
|
error: string;
|
|
27
26
|
}>>;
|
|
28
|
-
|
|
27
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineEventHandler } from "nuxt/server";
|
|
2
|
-
|
|
2
|
+
// src/runtime/server/task-handlers.ts
|
|
3
3
|
function trusted(event) {
|
|
4
4
|
if (event.req.headers.get("x-wervt-task") === "1") return true;
|
|
5
5
|
event.res.status = 404;
|
|
@@ -34,5 +34,4 @@ function taskListHandler(tasks) {
|
|
|
34
34
|
}));
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
-
//#endregion
|
|
38
37
|
export { taskListHandler, taskRunHandler };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { taskListHandler } from "./task-handlers.js";
|
|
2
2
|
import { tasks } from "#nitro-internal-virtual/tasks";
|
|
3
|
-
|
|
3
|
+
// src/runtime/server/task-list-nitro2.ts
|
|
4
4
|
var task_list_nitro2_default = taskListHandler(tasks);
|
|
5
|
-
//#endregion
|
|
6
5
|
export { task_list_nitro2_default as default };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { taskListHandler } from "./task-handlers.js";
|
|
2
2
|
import { tasks } from "#nitro/virtual/tasks";
|
|
3
|
-
|
|
3
|
+
// src/runtime/server/task-list-nitro3.ts
|
|
4
4
|
var task_list_nitro3_default = taskListHandler(tasks);
|
|
5
|
-
//#endregion
|
|
6
5
|
export { task_list_nitro3_default as default };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/runtime/server/task-run-nitro2.d.ts
|
|
2
1
|
declare const _default: import("nuxt/server").EventHandler<Promise<{
|
|
3
2
|
error: string;
|
|
4
3
|
result?: undefined;
|
|
@@ -6,5 +5,4 @@ declare const _default: import("nuxt/server").EventHandler<Promise<{
|
|
|
6
5
|
error?: undefined;
|
|
7
6
|
result: {} | null;
|
|
8
7
|
}>>;
|
|
9
|
-
//#endregion
|
|
10
8
|
export { _default as default };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { taskRunHandler } from "./task-handlers.js";
|
|
2
2
|
import { runTask } from "nitropack/runtime";
|
|
3
|
-
|
|
3
|
+
// src/runtime/server/task-run-nitro2.ts
|
|
4
4
|
var task_run_nitro2_default = taskRunHandler(runTask);
|
|
5
|
-
//#endregion
|
|
6
5
|
export { task_run_nitro2_default as default };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/runtime/server/task-run-nitro3.d.ts
|
|
2
1
|
declare const _default: import("nuxt/server").EventHandler<Promise<{
|
|
3
2
|
error: string;
|
|
4
3
|
result?: undefined;
|
|
@@ -6,5 +5,4 @@ declare const _default: import("nuxt/server").EventHandler<Promise<{
|
|
|
6
5
|
error?: undefined;
|
|
7
6
|
result: {} | null;
|
|
8
7
|
}>>;
|
|
9
|
-
//#endregion
|
|
10
8
|
export { _default as default };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { taskRunHandler } from "./task-handlers.js";
|
|
2
2
|
import { runTask } from "../../node_modules/.pnpm/nitro@3.0.260903-beta/node_modules/nitro/dist/runtime/internal/task.js";
|
|
3
3
|
import "../../node_modules/.pnpm/nitro@3.0.260903-beta/node_modules/nitro/dist/runtime/task.js";
|
|
4
|
-
|
|
4
|
+
// src/runtime/server/task-run-nitro3.ts
|
|
5
5
|
var task_run_nitro3_default = taskRunHandler(runTask);
|
|
6
|
-
//#endregion
|
|
7
6
|
export { task_run_nitro3_default as default };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/runtime/server/tasks.d.ts
|
|
2
1
|
export interface TaskEvent<P = Record<string, unknown>> {
|
|
3
2
|
name: string;
|
|
4
3
|
/** `{ scheduledTime }` for scheduled runs, or what was passed to a manual run. */
|
|
@@ -16,5 +15,4 @@ export interface Task<R = unknown, P = Record<string, unknown>> {
|
|
|
16
15
|
run(event: TaskEvent<P>): TaskResult<R> | Promise<TaskResult<R>>;
|
|
17
16
|
}
|
|
18
17
|
/** A task in `server/tasks/` (`server/tasks/presence/sweep.ts` is `presence:sweep`). */
|
|
19
|
-
export declare function defineTask<R = unknown, P = Record<string, unknown>>(task: Task<R, P>): Task<R, P>;
|
|
20
|
-
//#endregion
|
|
18
|
+
export declare function defineTask<R = unknown, P = Record<string, unknown>>(task: Task<R, P>): Task<R, P>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/runtime/server/tasks.ts
|
|
2
2
|
/** A task in `server/tasks/` (`server/tasks/presence/sweep.ts` is `presence:sweep`). */
|
|
3
3
|
function defineTask(task) {
|
|
4
4
|
if (typeof task.run !== "function") task.run = () => {
|
|
@@ -6,5 +6,4 @@ function defineTask(task) {
|
|
|
6
6
|
};
|
|
7
7
|
return task;
|
|
8
8
|
}
|
|
9
|
-
//#endregion
|
|
10
9
|
export { defineTask };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Input } from "./validate.js";
|
|
2
2
|
import { Tool } from "./tools.js";
|
|
3
|
-
//#region src/runtime/server/tool-handlers.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Every tool by the name agents see. A tool may rename itself (`name`), so the file-derived
|
|
6
5
|
* keys of `#wervt/tools` are only a default and the whole list is loaded once.
|
|
@@ -40,5 +39,4 @@ export declare const runTool: import("nuxt/server").EventHandler<Promise<{
|
|
|
40
39
|
error?: undefined;
|
|
41
40
|
issues?: undefined;
|
|
42
41
|
result: {} | null;
|
|
43
|
-
}>>;
|
|
44
|
-
//#endregion
|
|
42
|
+
}>>;
|
|
@@ -4,7 +4,7 @@ import { TOOL_ROUTE } from "./tools.js";
|
|
|
4
4
|
import { defineEventHandler } from "nuxt/server";
|
|
5
5
|
import { toJsonSchema } from "@valibot/to-json-schema";
|
|
6
6
|
import { routeMethods, tools } from "#wervt/tools";
|
|
7
|
-
|
|
7
|
+
// src/runtime/server/tool-handlers.ts
|
|
8
8
|
let index;
|
|
9
9
|
/**
|
|
10
10
|
* Every tool by the name agents see. A tool may rename itself (`name`), so the file-derived
|
|
@@ -90,5 +90,4 @@ const runTool = defineEventHandler(async (event) => {
|
|
|
90
90
|
}
|
|
91
91
|
return { result: await tool.handler(event, input) ?? null };
|
|
92
92
|
});
|
|
93
|
-
//#endregion
|
|
94
93
|
export { allTools, listTools, loadTool, runTool, toolInputSchema };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Input, Output } from "./validate.js";
|
|
2
2
|
import { RequestEvent } from "nuxt/server";
|
|
3
|
-
//#region src/runtime/server/tools.d.ts
|
|
4
3
|
export interface Tool<I extends Input | undefined = Input | undefined, R = unknown> {
|
|
5
4
|
/** Overrides the name from the file path. Agents see it, so keep it short and stable. */
|
|
6
5
|
name?: string;
|
|
@@ -48,4 +47,4 @@ export declare const TOOL_ROUTE: unique symbol;
|
|
|
48
47
|
export declare function defineToolRoute<R, P extends Input | undefined = undefined, I extends Input | undefined = undefined>(route: ToolRoute<P, I, R>): import("nuxt/server").EventHandler<Promise<R>> & {
|
|
49
48
|
[TOOL_ROUTE]: Tool<Input | undefined, unknown>;
|
|
50
49
|
};
|
|
51
|
-
|
|
50
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { validate } from "./validate.js";
|
|
2
2
|
import { defineEventHandler, getQuery, getRouterParams, readBody } from "nuxt/server";
|
|
3
3
|
import * as v from "valibot";
|
|
4
|
-
|
|
4
|
+
// src/runtime/server/tools.ts
|
|
5
5
|
/** A tool in `server/tools/` (`server/tools/todos/add.ts` is `todos.add`). */
|
|
6
6
|
function defineTool(tool) {
|
|
7
7
|
return tool;
|
|
@@ -55,5 +55,4 @@ function entries(input) {
|
|
|
55
55
|
if ("entries" in input) return input.entries;
|
|
56
56
|
throw new Error("defineToolRoute: `params` and `input` must be objects to merge into a tool.");
|
|
57
57
|
}
|
|
58
|
-
//#endregion
|
|
59
58
|
export { TOOL_ROUTE, defineTool, defineToolRoute };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { useWervtUser } from "./user.js";
|
|
2
2
|
import { defineEventHandler } from "nuxt/server";
|
|
3
|
-
|
|
3
|
+
// src/runtime/server/user-route.ts
|
|
4
4
|
var user_route_default = defineEventHandler((event) => {
|
|
5
5
|
event.res.headers.set("cache-control", "private, no-store");
|
|
6
6
|
return { user: useWervtUser(event) ?? null };
|
|
7
7
|
});
|
|
8
|
-
//#endregion
|
|
9
8
|
export { user_route_default as default };
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { DEV_LOGIN_COOKIE, WervtUser, parseWervtUser } from "../shared/user.js";
|
|
1
|
+
import { DEV_LOGIN_COOKIE, WervtRole, WervtUser, parseWervtUser } from "../shared/user.js";
|
|
2
2
|
import { RequestEvent } from "nuxt/server";
|
|
3
|
-
//#region src/runtime/server/user.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* The signed-in wervt user, or `undefined` when nobody is signed in.
|
|
6
5
|
* Private apps always have one (the runtime checked the login and the allow-list); public
|
|
7
6
|
* apps get one when the visitor is signed in. Send people to `/_wervt/login` to sign in.
|
|
8
7
|
* In a tool called over MCP, it's the user the client signed in as.
|
|
9
8
|
*/
|
|
10
|
-
export declare
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
export declare function useWervtUser(event: RequestEvent): WervtUser | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* The signed-in user if their role is one of `roles`, e.g.
|
|
12
|
+
* `requireWervtRole(event, 'owner', 'member', 'admin')` for the app's own admin features.
|
|
13
|
+
* Throws 401 without a signed-in user, 403 with another role.
|
|
14
|
+
*/
|
|
15
|
+
export declare function requireWervtRole(event: RequestEvent, ...roles: WervtRole[]): WervtUser;
|
|
16
|
+
export { DEV_LOGIN_COOKIE, type WervtRole, type WervtUser, parseWervtUser };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DEV_LOGIN_COOKIE, devUser, parseWervtUser } from "../shared/user.js";
|
|
2
|
-
import { getCookie } from "nuxt/server";
|
|
3
|
-
|
|
2
|
+
import { createError, getCookie } from "nuxt/server";
|
|
3
|
+
// src/runtime/server/user.ts
|
|
4
4
|
const MCP_USER = "wervtMcpUser";
|
|
5
5
|
/**
|
|
6
6
|
* The signed-in wervt user, or `undefined` when nobody is signed in.
|
|
@@ -8,6 +8,30 @@ const MCP_USER = "wervtMcpUser";
|
|
|
8
8
|
* apps get one when the visitor is signed in. Send people to `/_wervt/login` to sign in.
|
|
9
9
|
* In a tool called over MCP, it's the user the client signed in as.
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
function useWervtUser(event) {
|
|
12
|
+
const header = parseWervtUser(event.req.headers.get("x-wervt-user"));
|
|
13
|
+
const mcp = event.context[MCP_USER];
|
|
14
|
+
if (mcp) return mcp.role || header?.id !== mcp.id ? mcp : {
|
|
15
|
+
...mcp,
|
|
16
|
+
role: header.role
|
|
17
|
+
};
|
|
18
|
+
return header ?? devUser(getCookie(event, "wervt_dev_login") === "1");
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The signed-in user if their role is one of `roles`, e.g.
|
|
22
|
+
* `requireWervtRole(event, 'owner', 'member', 'admin')` for the app's own admin features.
|
|
23
|
+
* Throws 401 without a signed-in user, 403 with another role.
|
|
24
|
+
*/
|
|
25
|
+
function requireWervtRole(event, ...roles) {
|
|
26
|
+
const user = useWervtUser(event);
|
|
27
|
+
if (!user) throw createError({
|
|
28
|
+
status: 401,
|
|
29
|
+
message: "sign in at /_wervt/login first"
|
|
30
|
+
});
|
|
31
|
+
if (!user.role || !roles.includes(user.role)) throw createError({
|
|
32
|
+
status: 403,
|
|
33
|
+
message: `needs role ${roles.join(", ")}`
|
|
34
|
+
});
|
|
35
|
+
return user;
|
|
36
|
+
}
|
|
37
|
+
export { DEV_LOGIN_COOKIE, parseWervtUser, requireWervtRole, useWervtUser };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { RequestEvent } from "nuxt/server";
|
|
2
2
|
import * as v from "valibot";
|
|
3
|
-
//#region src/runtime/server/validate.d.ts
|
|
4
3
|
type Schema = v.GenericSchema | v.GenericSchemaAsync;
|
|
5
4
|
type Shape = v.ObjectEntriesAsync;
|
|
6
5
|
export type Input = Schema | Shape;
|
|
@@ -40,4 +39,4 @@ export declare const vh: {
|
|
|
40
39
|
/** Positive integer id (e.g. a serial primary key) → number. */
|
|
41
40
|
id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.DigitsAction<string, undefined>, v.TransformAction<any, number>, v.SafeIntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
|
|
42
41
|
};
|
|
43
|
-
|
|
42
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createError, getQuery, getRouterParams, readBody } from "nuxt/server";
|
|
2
2
|
import * as v from "valibot";
|
|
3
|
-
|
|
3
|
+
// src/runtime/server/validate.ts
|
|
4
4
|
function toSchema(input) {
|
|
5
5
|
return "kind" in input && input.kind === "schema" ? input : v.objectAsync(input);
|
|
6
6
|
}
|
|
@@ -47,5 +47,4 @@ const vh = {
|
|
|
47
47
|
/** Positive integer id (e.g. a serial primary key) → number. */
|
|
48
48
|
id: v.pipe(v.string(), v.digits(), v.transform(Number), v.safeInteger(), v.minValue(1))
|
|
49
49
|
};
|
|
50
|
-
//#endregion
|
|
51
50
|
export { safeValidate, toSchema, useSafeValidatedBody, useSafeValidatedParams, useSafeValidatedQuery, useValidatedBody, useValidatedParams, useValidatedQuery, validate, vh };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Who minted the agent token a request came with, and its id (the control plane's log). */
|
|
2
|
+
export interface AgentToken {
|
|
3
|
+
id: string;
|
|
4
|
+
by: string;
|
|
5
|
+
}
|
|
6
|
+
/** Parses the `x-wervt-agent-token` header the runtime sets (and strips from client requests). */
|
|
7
|
+
export declare function parseAgentToken(header: string | null | undefined): AgentToken | undefined;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/runtime/shared/agent-token.ts
|
|
2
|
+
/** Parses the `x-wervt-agent-token` header the runtime sets (and strips from client requests). */
|
|
3
|
+
function parseAgentToken(header) {
|
|
4
|
+
if (!header) return void 0;
|
|
5
|
+
try {
|
|
6
|
+
const value = JSON.parse(decodeURIComponent(header));
|
|
7
|
+
if (typeof value?.id !== "string" || typeof value.by !== "string") return void 0;
|
|
8
|
+
return {
|
|
9
|
+
id: value.id,
|
|
10
|
+
by: value.by
|
|
11
|
+
};
|
|
12
|
+
} catch {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export { parseAgentToken };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const WERVT_MARK = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 32 32\" role=\"img\" aria-label=\"wervt\"><defs> <mask id=\"w56m\" maskUnits=\"userSpaceOnUse\" x=\"-4\" y=\"-4\" width=\"40\" height=\"40\"><rect x=\"-4\" y=\"-4\" width=\"40\" height=\"40\" fill=\"#fff\"/><path d=\"M-15.47 20.8 Q-12.8 19.4 -10.13 20.8 Q-7.47 22.2 -4.8 20.8 Q-2.13 19.4 0.53 20.8 Q3.2 22.2 5.87 20.8 Q8.53 19.4 11.2 20.8 Q13.87 22.2 16.53 20.8 Q19.2 19.4 21.87 20.8 Q24.53 22.2 27.2 20.8 Q29.87 19.4 32.53 20.8 Q35.2 22.2 37.87 20.8\" fill=\"none\" stroke=\"#000\" stroke-width=\"1.5\"/></mask> <clipPath id=\"w56a\"><path d=\"M-15.47 20.8 Q-12.8 19.4 -10.13 20.8 Q-7.47 22.2 -4.8 20.8 Q-2.13 19.4 0.53 20.8 Q3.2 22.2 5.87 20.8 Q8.53 19.4 11.2 20.8 Q13.87 22.2 16.53 20.8 Q19.2 19.4 21.87 20.8 Q24.53 22.2 27.2 20.8 Q29.87 19.4 32.53 20.8 Q35.2 22.2 37.87 20.8 L37.87 -4 L-15.47 -4 Z\"/></clipPath> <clipPath id=\"w56b\"><path d=\"M-15.47 20.8 Q-12.8 19.4 -10.13 20.8 Q-7.47 22.2 -4.8 20.8 Q-2.13 19.4 0.53 20.8 Q3.2 22.2 5.87 20.8 Q8.53 19.4 11.2 20.8 Q13.87 22.2 16.53 20.8 Q19.2 19.4 21.87 20.8 Q24.53 22.2 27.2 20.8 Q29.87 19.4 32.53 20.8 Q35.2 22.2 37.87 20.8 L37.87 40 L-15.47 40 Z\"/></clipPath></defs> <g mask=\"url(#w56m)\"><path d=\"M4 5 L11.8 5 L16 19.66 L20.2 5 L28 5 L18.1 27 L13.9 27 Z\" clip-path=\"url(#w56a)\" fill=\"currentColor\"/><path d=\"M4 5 L11.8 5 L16 19.66 L20.2 5 L28 5 L18.1 27 L13.9 27 Z\" clip-path=\"url(#w56b)\" style=\"fill:var(--a)\"/></g></svg>";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// src/runtime/shared/mark.ts
|
|
2
|
+
const WERVT_MARK = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" role="img" aria-label="wervt"><defs> <mask id="w56m" maskUnits="userSpaceOnUse" x="-4" y="-4" width="40" height="40"><rect x="-4" y="-4" width="40" height="40" fill="#fff"/><path d="M-15.47 20.8 Q-12.8 19.4 -10.13 20.8 Q-7.47 22.2 -4.8 20.8 Q-2.13 19.4 0.53 20.8 Q3.2 22.2 5.87 20.8 Q8.53 19.4 11.2 20.8 Q13.87 22.2 16.53 20.8 Q19.2 19.4 21.87 20.8 Q24.53 22.2 27.2 20.8 Q29.87 19.4 32.53 20.8 Q35.2 22.2 37.87 20.8" fill="none" stroke="#000" stroke-width="1.5"/></mask> <clipPath id="w56a"><path d="M-15.47 20.8 Q-12.8 19.4 -10.13 20.8 Q-7.47 22.2 -4.8 20.8 Q-2.13 19.4 0.53 20.8 Q3.2 22.2 5.87 20.8 Q8.53 19.4 11.2 20.8 Q13.87 22.2 16.53 20.8 Q19.2 19.4 21.87 20.8 Q24.53 22.2 27.2 20.8 Q29.87 19.4 32.53 20.8 Q35.2 22.2 37.87 20.8 L37.87 -4 L-15.47 -4 Z"/></clipPath> <clipPath id="w56b"><path d="M-15.47 20.8 Q-12.8 19.4 -10.13 20.8 Q-7.47 22.2 -4.8 20.8 Q-2.13 19.4 0.53 20.8 Q3.2 22.2 5.87 20.8 Q8.53 19.4 11.2 20.8 Q13.87 22.2 16.53 20.8 Q19.2 19.4 21.87 20.8 Q24.53 22.2 27.2 20.8 Q29.87 19.4 32.53 20.8 Q35.2 22.2 37.87 20.8 L37.87 40 L-15.47 40 Z"/></clipPath></defs> <g mask="url(#w56m)"><path d="M4 5 L11.8 5 L16 19.66 L20.2 5 L28 5 L18.1 27 L13.9 27 Z" clip-path="url(#w56a)" fill="currentColor"/><path d="M4 5 L11.8 5 L16 19.66 L20.2 5 L28 5 L18.1 27 L13.9 27 Z" clip-path="url(#w56b)" style="fill:var(--a)"/></g></svg>`;
|
|
3
|
+
export { WERVT_MARK };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface PreviewError {
|
|
2
|
+
at: number;
|
|
3
|
+
source: 'browser' | 'server';
|
|
4
|
+
message: string;
|
|
5
|
+
stack?: string;
|
|
6
|
+
url?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function recordPreviewError(file: string, error: PreviewError): Promise<void>;
|
|
9
|
+
/** The frames that point at the app; enough to find the line, not a wall of text. */
|
|
10
|
+
export declare function trimStack(stack: string | undefined): string | undefined;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { appendFile, mkdir } from "node:fs/promises";
|
|
2
|
+
import { dirname } from "node:path";
|
|
3
|
+
// src/runtime/shared/preview-errors.ts
|
|
4
|
+
async function recordPreviewError(file, error) {
|
|
5
|
+
try {
|
|
6
|
+
await mkdir(dirname(file), { recursive: true });
|
|
7
|
+
await appendFile(file, `${JSON.stringify(error)}\n`);
|
|
8
|
+
} catch {}
|
|
9
|
+
}
|
|
10
|
+
/** The frames that point at the app; enough to find the line, not a wall of text. */
|
|
11
|
+
function trimStack(stack) {
|
|
12
|
+
return stack?.split("\n").slice(1).filter((line) => !line.includes("node_modules")).slice(0, 6).join("\n");
|
|
13
|
+
}
|
|
14
|
+
export { recordPreviewError, trimStack };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/runtime/shared/shape.d.ts
|
|
2
1
|
declare const shapeRow: unique symbol;
|
|
3
2
|
export type ShapeResponse<Row> = Response & {
|
|
4
3
|
readonly [shapeRow]?: Row;
|
|
@@ -15,4 +14,4 @@ export declare const shapeParser: {
|
|
|
15
14
|
timestamp: typeof parseTimestamp;
|
|
16
15
|
timestamptz: typeof parseTimestamp;
|
|
17
16
|
};
|
|
18
|
-
|
|
17
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/runtime/shared/shape.ts
|
|
2
2
|
/**
|
|
3
3
|
* Postgres text of a `timestamp`/`timestamptz` as a Date, like Drizzle's default `mode: 'date'`
|
|
4
4
|
* reads it. Drizzle stores `timestamp` without time zone as UTC, so it's read as UTC too.
|
|
@@ -12,5 +12,4 @@ const shapeParser = {
|
|
|
12
12
|
timestamp: parseTimestamp,
|
|
13
13
|
timestamptz: parseTimestamp
|
|
14
14
|
};
|
|
15
|
-
//#endregion
|
|
16
15
|
export { parseTimestamp, shapeParser };
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* What the user is to this app: its `owner` or one of its `member`s (`wervt members`), a wervt
|
|
3
|
+
* `admin`, someone `invited` through the app (invite-only apps) or `allowed` by the app's list
|
|
4
|
+
* (`wervt access --add`). `public` is anyone else signed in to a public app.
|
|
5
|
+
*/
|
|
6
|
+
export type WervtRole = 'owner' | 'member' | 'admin' | 'invited' | 'allowed' | 'public';
|
|
2
7
|
export interface WervtUser {
|
|
3
8
|
id: string;
|
|
4
9
|
email: string;
|
|
@@ -6,11 +11,12 @@ export interface WervtUser {
|
|
|
6
11
|
image?: string;
|
|
7
12
|
/** Linked login accounts, provider id to the user's id there, e.g. `{ twitch: '1234' }`. */
|
|
8
13
|
accounts?: Record<string, string>;
|
|
14
|
+
/** Missing only for users an app's own `/mcp` tokens stand for (`wervt:mcp:token`). */
|
|
15
|
+
role?: WervtRole;
|
|
9
16
|
}
|
|
10
17
|
/** Cookie set by the dev stand-in for `/_wervt/login` (see `server/dev-auth.ts`). */
|
|
11
18
|
export declare const DEV_LOGIN_COOKIE = "wervt_dev_login";
|
|
12
19
|
/** Parses the `x-wervt-user` header the runtime sets (and strips from client requests). */
|
|
13
20
|
export declare function parseWervtUser(header: string | null | undefined): WervtUser | undefined;
|
|
14
21
|
/** During `nuxt dev`: the configured dev user, after `/_wervt/login`. */
|
|
15
|
-
export declare function devUser(loggedIn: boolean): WervtUser | undefined;
|
|
16
|
-
//#endregion
|
|
22
|
+
export declare function devUser(loggedIn: boolean): WervtUser | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/runtime/shared/user.ts
|
|
2
2
|
/** Cookie set by the dev stand-in for `/_wervt/login` (see `server/dev-auth.ts`). */
|
|
3
3
|
const DEV_LOGIN_COOKIE = "wervt_dev_login";
|
|
4
4
|
/** Parses the `x-wervt-user` header the runtime sets (and strips from client requests). */
|
|
@@ -14,7 +14,9 @@ function parseWervtUser(header) {
|
|
|
14
14
|
function devUser(loggedIn) {
|
|
15
15
|
const user = process.env.WERVT_DEV_USER;
|
|
16
16
|
if (!import.meta.dev || !loggedIn || !user) return void 0;
|
|
17
|
-
return
|
|
17
|
+
return {
|
|
18
|
+
role: "owner",
|
|
19
|
+
...JSON.parse(user)
|
|
20
|
+
};
|
|
18
21
|
}
|
|
19
|
-
//#endregion
|
|
20
22
|
export { DEV_LOGIN_COOKIE, devUser, parseWervtUser };
|
package/dist/seed.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/seed.ts
|
|
2
2
|
/** The conventional seed task: `server/tasks/db/seed.ts`. */
|
|
3
3
|
const SEED_TASK = "db:seed";
|
|
4
4
|
/**
|
|
@@ -48,5 +48,4 @@ async function runDevSeed(baseUrl, { fetch: request = fetch, timeout = 12e4, int
|
|
|
48
48
|
result: body.result
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
|
-
//#endregion
|
|
52
51
|
export { SEED_TASK, runDevSeed, unscheduleSeed };
|
package/dist/shapes.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readdir } from "node:fs/promises";
|
|
2
2
|
import { extname, join, relative, sep } from "node:path";
|
|
3
|
-
|
|
3
|
+
// src/shapes.ts
|
|
4
4
|
const ROUTE_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
5
5
|
".ts",
|
|
6
6
|
".mts",
|
|
@@ -66,5 +66,4 @@ function shapeRoutesTypes(routes, typesDir, shapeTypes) {
|
|
|
66
66
|
""
|
|
67
67
|
].join("\n");
|
|
68
68
|
}
|
|
69
|
-
//#endregion
|
|
70
69
|
export { findShapeRoutes, shapeRoutes, shapeRoutesTypes, shapesManifest };
|
package/dist/storage.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/storage.d.ts
|
|
2
1
|
export interface StorageOptions {
|
|
3
2
|
/** Garage's admin API, e.g. http://garage:3903 */
|
|
4
3
|
adminUrl: string;
|
|
@@ -13,14 +12,61 @@ export interface StorageUsage {
|
|
|
13
12
|
bytes: number;
|
|
14
13
|
/** Multipart uploads started but never completed or aborted. */
|
|
15
14
|
unfinishedUploads: number;
|
|
15
|
+
/** The bucket's size limit in bytes, null for none. */
|
|
16
|
+
maxBytes: number | null;
|
|
17
|
+
}
|
|
18
|
+
export interface StorageQuota {
|
|
19
|
+
/** Bytes the bucket may hold; null for no limit. Garage refuses uploads past it. */
|
|
20
|
+
maxBytes: number | null;
|
|
16
21
|
}
|
|
17
22
|
export declare class StorageError extends Error {}
|
|
23
|
+
export interface StoredObject {
|
|
24
|
+
key: string;
|
|
25
|
+
size: number;
|
|
26
|
+
/** ISO time. */
|
|
27
|
+
lastModified: string;
|
|
28
|
+
}
|
|
29
|
+
export interface ObjectListing {
|
|
30
|
+
prefix: string;
|
|
31
|
+
/** Prefixes one level below `prefix`, ending in `/`. */
|
|
32
|
+
folders: string[];
|
|
33
|
+
files: StoredObject[];
|
|
34
|
+
/** Pass as `token` for the next page. */
|
|
35
|
+
next?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface ObjectDetails extends StoredObject {
|
|
38
|
+
contentType: string | null;
|
|
39
|
+
/** `x-amz-meta-*` headers, without the prefix. */
|
|
40
|
+
metadata: Record<string, string>;
|
|
41
|
+
}
|
|
42
|
+
/** S3's limit for object keys, in bytes. */
|
|
43
|
+
export declare const MAX_KEY_BYTES = 1024;
|
|
18
44
|
export declare function createStorage(options: StorageOptions): {
|
|
19
45
|
ensureLayout: () => Promise<void>;
|
|
20
|
-
provision: (app: string, appOrigin: string) => Promise<{
|
|
46
|
+
provision: (app: string, appOrigin: string, quota?: StorageQuota) => Promise<{
|
|
21
47
|
bucket: string;
|
|
22
48
|
}>;
|
|
49
|
+
setQuota: (app: string, quota: StorageQuota) => Promise<boolean>;
|
|
23
50
|
usage: (app: string) => Promise<StorageUsage | undefined>;
|
|
51
|
+
list: (app: string, { prefix, token, limit }?: {
|
|
52
|
+
prefix?: string;
|
|
53
|
+
token?: string;
|
|
54
|
+
limit?: number;
|
|
55
|
+
}) => Promise<ObjectListing | undefined>;
|
|
56
|
+
describe: (app: string, key: string) => Promise<ObjectDetails | undefined>;
|
|
57
|
+
downloadUrl: (app: string, key: string, { publicUrl, expiresIn }: {
|
|
58
|
+
publicUrl: string;
|
|
59
|
+
expiresIn?: number;
|
|
60
|
+
}) => Promise<string>;
|
|
61
|
+
remove: (app: string, key: string) => Promise<{
|
|
62
|
+
deleted: string[];
|
|
63
|
+
} | undefined>;
|
|
64
|
+
sweepAbandonedUploads: (app: string, { graceMs, now }?: {
|
|
65
|
+
graceMs?: number | undefined;
|
|
66
|
+
now?: number | undefined;
|
|
67
|
+
}) => Promise<{
|
|
68
|
+
deleted: string[];
|
|
69
|
+
}>;
|
|
70
|
+
hasBucket: (app: string) => Promise<boolean>;
|
|
24
71
|
drop: (app: string) => Promise<void>;
|
|
25
|
-
};
|
|
26
|
-
//#endregion
|
|
72
|
+
};
|