@wervt/nuxt 0.3.3 → 0.3.5
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/dev.d.ts +1 -3
- package/dist/dev.js +33 -11
- package/dist/env-types.js +1 -2
- package/dist/icons.js +1 -2
- package/dist/loading.js +30 -0
- package/dist/module.d.ts +0 -2
- package/dist/module.js +3 -2
- package/dist/node_modules/.pnpm/nitro@3.0.260903-beta/node_modules/nitro/dist/runtime/internal/task.js +1 -2
- package/dist/og-image.js +1 -2
- package/dist/preview.d.ts +1 -3
- package/dist/preview.js +1 -2
- package/dist/provision.d.ts +12 -2
- package/dist/provision.js +35 -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 +1 -3
- package/dist/runtime/app/snapshot.js +1 -2
- package/dist/runtime/app/useShape.d.ts +1 -3
- package/dist/runtime/app/useShape.js +3 -4
- package/dist/runtime/app/useWervtFeedback.d.ts +0 -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/invite.d.ts +1 -3
- package/dist/runtime/email/invite.js +1 -2
- package/dist/runtime/email/render.d.ts +1 -3
- package/dist/runtime/email/render.js +1 -2
- package/dist/runtime/server/access.d.ts +1 -3
- package/dist/runtime/server/access.js +1 -2
- package/dist/runtime/server/agent-token-plugin.d.ts +0 -2
- package/dist/runtime/server/agent-token-plugin.js +1 -2
- package/dist/runtime/server/anthropic.d.ts +1 -3
- package/dist/runtime/server/anthropic.js +1 -2
- 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 +1 -3
- package/dist/runtime/server/identity.js +1 -2
- 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 +1 -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 +0 -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 +0 -2
- package/dist/runtime/server/user.js +1 -2
- package/dist/runtime/server/validate.d.ts +0 -2
- package/dist/runtime/server/validate.js +1 -2
- package/dist/runtime/shared/agent-token.d.ts +1 -3
- package/dist/runtime/shared/agent-token.js +1 -2
- 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 +0 -2
- package/dist/runtime/shared/shape.js +1 -2
- package/dist/runtime/shared/user.d.ts +1 -3
- package/dist/runtime/shared/user.js +1 -2
- package/dist/seed.js +1 -2
- package/dist/shapes.js +1 -2
- package/dist/storage.d.ts +2 -3
- package/dist/storage.js +7 -2
- package/dist/studio-preview.js +38 -0
- package/package.json +6 -6
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { shapeParser } from "../shared/shape.js";
|
|
2
2
|
import { applyMessages, loadSnapshot } from "./snapshot.js";
|
|
3
|
-
import { ShapeStream } from "@electric-sql/client";
|
|
4
|
-
import { getCurrentScope, onScopeDispose, ref, shallowRef } from "vue";
|
|
5
3
|
import { onNuxtReady, useAsyncData, useRequestEvent, useRequestFetch } from "#app";
|
|
6
|
-
|
|
4
|
+
import { getCurrentScope, onScopeDispose, ref, shallowRef } from "vue";
|
|
5
|
+
import { ShapeStream } from "@electric-sql/client";
|
|
6
|
+
// src/runtime/app/useShape.ts
|
|
7
7
|
function useShape(path, options = {}) {
|
|
8
8
|
const key = options.key ?? `wervt-shape:${path}`;
|
|
9
9
|
const fetchClient = import.meta.server ? inProcessFetch() : void 0;
|
|
@@ -154,5 +154,4 @@ function inProcessFetch() {
|
|
|
154
154
|
function absolute(path) {
|
|
155
155
|
return new URL(path, import.meta.client ? location.origin : "http://localhost").href;
|
|
156
156
|
}
|
|
157
|
-
//#endregion
|
|
158
157
|
export { preloadShape, useShape };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/runtime/app/useWervtFeedback.d.ts
|
|
2
1
|
interface KontorWidget {
|
|
3
2
|
open(): void;
|
|
4
3
|
close(): void;
|
|
@@ -21,5 +20,4 @@ export declare function useWervtFeedback(): {
|
|
|
21
20
|
close: () => void | undefined;
|
|
22
21
|
setContext(values: Record<string, unknown>): void;
|
|
23
22
|
};
|
|
24
|
-
//#endregion
|
|
25
23
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/runtime/app/useWervtFeedback.ts
|
|
2
2
|
const pendingFeedbackContext = {};
|
|
3
3
|
/**
|
|
4
4
|
* Controls the feedback widget (`wervt: { feedback: { key } }`): open it from your own button,
|
|
@@ -17,5 +17,4 @@ function useWervtFeedback() {
|
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
//#endregion
|
|
21
20
|
export { pendingFeedbackContext, useWervtFeedback };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
//#region src/runtime/app/useWervtTrack.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Custom events for wervt's analytics, e.g. `track('signup')` or `track('click', url)`. They
|
|
4
3
|
* show up with their counts and visitors in the dashboard and `wervt stats`. Like page views
|
|
5
4
|
* they are cookieless: only the event, its label and the current path are sent. Does nothing
|
|
6
5
|
* in `nuxt dev`, during SSR and with `wervt.analytics: false`.
|
|
7
6
|
*/
|
|
8
|
-
export declare function useWervtTrack(): (name: string, label?: string) => void;
|
|
9
|
-
//#endregion
|
|
7
|
+
export declare function useWervtTrack(): (name: string, label?: string) => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useRuntimeConfig } from "#app";
|
|
2
|
-
|
|
2
|
+
// src/runtime/app/useWervtTrack.ts
|
|
3
3
|
/**
|
|
4
4
|
* Custom events for wervt's analytics, e.g. `track('signup')` or `track('click', url)`. They
|
|
5
5
|
* show up with their counts and visitors in the dashboard and `wervt stats`. Like page views
|
|
@@ -20,5 +20,4 @@ function useWervtTrack() {
|
|
|
20
20
|
navigator.sendBeacon?.(`${base}/_wervt/view`, new Blob([body], { type: "application/json" }));
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
//#endregion
|
|
24
23
|
export { useWervtTrack };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/runtime/app/useWervtUpdate.d.ts
|
|
2
1
|
/** State behind `useWervtUpdate()`, set by the update check (`plugins/update.client`). */
|
|
3
2
|
export declare const useUpdateAvailable: () => import("vue").Ref<boolean, boolean>;
|
|
4
3
|
/**
|
|
@@ -9,5 +8,4 @@ export declare const useUpdateAvailable: () => import("vue").Ref<boolean, boolea
|
|
|
9
8
|
export declare function useWervtUpdate(): {
|
|
10
9
|
available: Readonly<import("vue").Ref<boolean, boolean>>;
|
|
11
10
|
reload: () => void;
|
|
12
|
-
};
|
|
13
|
-
//#endregion
|
|
11
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { readonly } from "vue";
|
|
2
1
|
import { reloadNuxtApp, useState } from "#app";
|
|
3
|
-
|
|
2
|
+
import { readonly } from "vue";
|
|
3
|
+
// src/runtime/app/useWervtUpdate.ts
|
|
4
4
|
/** State behind `useWervtUpdate()`, set by the update check (`plugins/update.client`). */
|
|
5
5
|
const useUpdateAvailable = () => useState("wervt-update", () => false);
|
|
6
6
|
/**
|
|
@@ -17,5 +17,4 @@ function useWervtUpdate() {
|
|
|
17
17
|
})
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
//#endregion
|
|
21
20
|
export { useUpdateAvailable, useWervtUpdate };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { WervtUser } from "../shared/user.js";
|
|
2
|
-
//#region src/runtime/app/useWervtUser.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* The signed-in wervt user, or `null`. Read during SSR and kept in the payload; apps without
|
|
5
4
|
* SSR load it from `/_wervt/user` before they render. Public apps get one when the visitor
|
|
@@ -9,5 +8,4 @@ export declare function useWervtUser(): import("vue").Ref<WervtUser | null, Werv
|
|
|
9
8
|
/** Sign in with wervt, then come back to `redirect` (a path in this app). */
|
|
10
9
|
export declare const wervtLoginUrl: (redirect?: string) => string;
|
|
11
10
|
/** Sign out of wervt (all apps), then come back to `redirect`. */
|
|
12
|
-
export declare const wervtLogoutUrl: (redirect?: string) => string;
|
|
13
|
-
//#endregion
|
|
11
|
+
export declare const wervtLogoutUrl: (redirect?: string) => string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DEV_LOGIN_COOKIE, devUser, parseWervtUser } from "../shared/user.js";
|
|
2
2
|
import { useCookie, useRequestHeaders, useState } from "#app";
|
|
3
|
-
|
|
3
|
+
// src/runtime/app/useWervtUser.ts
|
|
4
4
|
/**
|
|
5
5
|
* The signed-in wervt user, or `null`. Read during SSR and kept in the payload; apps without
|
|
6
6
|
* SSR load it from `/_wervt/user` before they render. Public apps get one when the visitor
|
|
@@ -14,5 +14,4 @@ function useWervtUser() {
|
|
|
14
14
|
const wervtLoginUrl = (redirect = "/") => `/_wervt/login?redirect=${encodeURIComponent(redirect)}`;
|
|
15
15
|
/** Sign out of wervt (all apps), then come back to `redirect`. */
|
|
16
16
|
const wervtLogoutUrl = (redirect = "/") => `/_wervt/logout?redirect=${encodeURIComponent(redirect)}`;
|
|
17
|
-
//#endregion
|
|
18
17
|
export { useWervtUser, wervtLoginUrl, wervtLogoutUrl };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { InjectionKey, PropType } from "vue";
|
|
2
|
-
//#region src/runtime/email/components.d.ts
|
|
3
2
|
/** The template's subject, handed to renderEmail() while rendering. */
|
|
4
3
|
export declare const SUBJECT_KEY: InjectionKey<(subject: string) => void>;
|
|
5
4
|
export declare const emailTheme: {
|
|
@@ -187,5 +186,4 @@ export declare const EmailCode: import("vue").DefineComponent<import("vue").Extr
|
|
|
187
186
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
188
187
|
export declare const EmailDivider: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
189
188
|
[key: string]: any;
|
|
190
|
-
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
191
|
-
//#endregion
|
|
189
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineComponent, h, inject } from "vue";
|
|
2
|
-
|
|
2
|
+
// src/runtime/email/components.ts
|
|
3
3
|
/** The template's subject, handed to renderEmail() while rendering. */
|
|
4
4
|
const SUBJECT_KEY = Symbol("wervt-email-subject");
|
|
5
5
|
const emailTheme = {
|
|
@@ -598,5 +598,4 @@ function table(attrs, children) {
|
|
|
598
598
|
}
|
|
599
599
|
}, children);
|
|
600
600
|
}
|
|
601
|
-
//#endregion
|
|
602
601
|
export { EmailButton, EmailCode, EmailDivider, EmailHeading, EmailLink, EmailMuted, EmailText, SUBJECT_KEY, WervtEmail, emailTheme };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/runtime/email/invite.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* An invitation to an app: who invited, where to go, and that signing in with this address is
|
|
4
3
|
* all it takes. Send it with `sendMail({ to, template: InviteEmail, props: { by, app, url } })`.
|
|
@@ -71,5 +70,4 @@ export declare const InviteEmail: import("vue").DefineComponent<import("vue").Ex
|
|
|
71
70
|
message: string;
|
|
72
71
|
action: string;
|
|
73
72
|
note: string;
|
|
74
|
-
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
75
|
-
//#endregion
|
|
73
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EmailButton, EmailHeading, EmailMuted, EmailText, WervtEmail } from "./components.js";
|
|
2
2
|
import { defineComponent, h } from "vue";
|
|
3
|
-
|
|
3
|
+
// src/runtime/email/invite.ts
|
|
4
4
|
/**
|
|
5
5
|
* An invitation to an app: who invited, where to go, and that signing in with this address is
|
|
6
6
|
* all it takes. Send it with `sendMail({ to, template: InviteEmail, props: { by, app, url } })`.
|
|
@@ -56,5 +56,4 @@ const InviteEmail = defineComponent({
|
|
|
56
56
|
]);
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
|
-
//#endregion
|
|
60
59
|
export { InviteEmail };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Component } from "vue";
|
|
2
|
-
//#region src/runtime/email/render.d.ts
|
|
3
2
|
export interface RenderedEmail {
|
|
4
3
|
subject: string;
|
|
5
4
|
html: string;
|
|
@@ -13,5 +12,4 @@ export type EmailProps<T> = T extends (new () => {
|
|
|
13
12
|
* Renders an email template (a component with `<WervtEmail>` at its root) to HTML, a plain-text
|
|
14
13
|
* part and its subject.
|
|
15
14
|
*/
|
|
16
|
-
export declare function renderEmail<T extends Component>(template: T, props?: EmailProps<T>): Promise<RenderedEmail>;
|
|
17
|
-
//#endregion
|
|
15
|
+
export declare function renderEmail<T extends Component>(template: T, props?: EmailProps<T>): Promise<RenderedEmail>;
|
|
@@ -2,7 +2,7 @@ import { SUBJECT_KEY } from "./components.js";
|
|
|
2
2
|
import { createSSRApp } from "vue";
|
|
3
3
|
import { convert } from "html-to-text";
|
|
4
4
|
import { renderToString } from "vue/server-renderer";
|
|
5
|
-
|
|
5
|
+
// src/runtime/email/render.ts
|
|
6
6
|
const DOCTYPE = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
|
|
7
7
|
/**
|
|
8
8
|
* Renders an email template (a component with `<WervtEmail>` at its root) to HTML, a plain-text
|
|
@@ -64,5 +64,4 @@ function toText(html) {
|
|
|
64
64
|
]
|
|
65
65
|
}).trim();
|
|
66
66
|
}
|
|
67
|
-
//#endregion
|
|
68
67
|
export { renderEmail };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { RequestEvent } from "nuxt/server";
|
|
2
|
-
//#region src/runtime/server/access.d.ts
|
|
3
2
|
export interface WervtInvite {
|
|
4
3
|
email: string;
|
|
5
4
|
/** Who invited them. */
|
|
@@ -31,5 +30,4 @@ export interface WervtAccess {
|
|
|
31
30
|
* 409 when the app isn't invite-only, 429 past the limits (25 invites per person and day, 500 per
|
|
32
31
|
* app).
|
|
33
32
|
*/
|
|
34
|
-
export declare function useWervtAccess(event: RequestEvent): WervtAccess;
|
|
35
|
-
//#endregion
|
|
33
|
+
export declare function useWervtAccess(event: RequestEvent): WervtAccess;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DEV_LOGIN_COOKIE, devUser } from "../shared/user.js";
|
|
2
2
|
import { createError, getCookie } from "nuxt/server";
|
|
3
|
-
|
|
3
|
+
// src/runtime/server/access.ts
|
|
4
4
|
const devInvites = [];
|
|
5
5
|
/**
|
|
6
6
|
* Invites on an invite-only app (`wervt access <app> --invite`), as the user of this request: the
|
|
@@ -84,5 +84,4 @@ function devAccess(event) {
|
|
|
84
84
|
}
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
|
-
//#endregion
|
|
88
87
|
export { useWervtAccess };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/runtime/server/agent-token-plugin.d.ts
|
|
2
1
|
interface EnrichContext {
|
|
3
2
|
event: Record<string, unknown>;
|
|
4
3
|
headers?: Record<string, string>;
|
|
@@ -9,5 +8,4 @@ interface NitroAppHooks {
|
|
|
9
8
|
};
|
|
10
9
|
}
|
|
11
10
|
export default function wervtAgentToken(nitroApp: NitroAppHooks): void;
|
|
12
|
-
//#endregion
|
|
13
11
|
export {};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { parseAgentToken } from "../shared/agent-token.js";
|
|
2
|
-
|
|
2
|
+
// src/runtime/server/agent-token-plugin.ts
|
|
3
3
|
function wervtAgentToken(nitroApp) {
|
|
4
4
|
nitroApp.hooks.hook("evlog:enrich", (ctx) => {
|
|
5
5
|
const agentToken = parseAgentToken(ctx.headers?.["x-wervt-agent-token"]);
|
|
6
6
|
if (agentToken) ctx.event.agentToken = agentToken;
|
|
7
7
|
});
|
|
8
8
|
}
|
|
9
|
-
//#endregion
|
|
10
9
|
export { wervtAgentToken as default };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import Anthropic from "@anthropic-ai/sdk";
|
|
2
|
-
//#region src/runtime/server/anthropic.d.ts
|
|
3
2
|
export interface UseAnthropicOptions {
|
|
4
3
|
/**
|
|
5
4
|
* The key for `nuxt dev`, where there is no workload identity. Default: `ANTHROPIC_API_KEY`.
|
|
@@ -17,5 +16,4 @@ export interface UseAnthropicOptions {
|
|
|
17
16
|
* Needs `wervt identity enable <app>` and a federation rule for the app's subject
|
|
18
17
|
* (`wervt identity status <app>`). In `nuxt dev` it uses `options.devApiKey` instead.
|
|
19
18
|
*/
|
|
20
|
-
export declare function useAnthropic(options?: UseAnthropicOptions): Anthropic;
|
|
21
|
-
//#endregion
|
|
19
|
+
export declare function useAnthropic(options?: UseAnthropicOptions): Anthropic;
|
|
@@ -2,7 +2,7 @@ import { useWorkloadIdentity } from "./identity.js";
|
|
|
2
2
|
import { createError } from "nuxt/server";
|
|
3
3
|
import Anthropic from "@anthropic-ai/sdk";
|
|
4
4
|
import { oidcFederationProvider } from "@anthropic-ai/sdk/lib/credentials/oidc-federation";
|
|
5
|
-
|
|
5
|
+
// src/runtime/server/anthropic.ts
|
|
6
6
|
const BASE_URL = "https://api.anthropic.com";
|
|
7
7
|
let client;
|
|
8
8
|
/**
|
|
@@ -49,5 +49,4 @@ function create(options) {
|
|
|
49
49
|
})
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
-
//#endregion
|
|
53
52
|
export { useAnthropic };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/runtime/server/boot.d.ts
|
|
2
1
|
declare const _default: import("nuxt/server").EventHandler<{
|
|
3
2
|
error: string;
|
|
4
3
|
ok?: undefined;
|
|
@@ -6,5 +5,4 @@ declare const _default: import("nuxt/server").EventHandler<{
|
|
|
6
5
|
error?: undefined;
|
|
7
6
|
ok: boolean;
|
|
8
7
|
}>;
|
|
9
|
-
//#endregion
|
|
10
8
|
export { _default as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineEventHandler } from "nuxt/server";
|
|
2
|
-
|
|
2
|
+
// src/runtime/server/boot.ts
|
|
3
3
|
var boot_default = defineEventHandler((event) => {
|
|
4
4
|
event.res.headers.set("cache-control", "no-store");
|
|
5
5
|
if (event.req.headers.get("x-wervt-task") !== "1") {
|
|
@@ -8,5 +8,4 @@ var boot_default = defineEventHandler((event) => {
|
|
|
8
8
|
}
|
|
9
9
|
return { ok: true };
|
|
10
10
|
});
|
|
11
|
-
//#endregion
|
|
12
11
|
export { boot_default as default };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { PostgresJsDatabase } from "drizzle-orm/postgres-js";
|
|
2
2
|
import { AnyRelations, EmptyRelations } from "drizzle-orm";
|
|
3
|
-
//#region src/runtime/server/db.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Drizzle client for the app's database. In production the wervt runtime injects
|
|
6
5
|
* DATABASE_URL for the app's own role, whose search_path is its own schema, so
|
|
@@ -15,5 +14,4 @@ import { AnyRelations, EmptyRelations } from "drizzle-orm";
|
|
|
15
14
|
*/
|
|
16
15
|
export declare function useDb<TRelations extends AnyRelations = EmptyRelations>(options?: {
|
|
17
16
|
relations?: TRelations;
|
|
18
|
-
}): PostgresJsDatabase<TRelations>;
|
|
19
|
-
//#endregion
|
|
17
|
+
}): PostgresJsDatabase<TRelations>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { drizzle } from "drizzle-orm/postgres-js";
|
|
2
2
|
import postgres from "postgres";
|
|
3
|
-
|
|
3
|
+
// src/runtime/server/db.ts
|
|
4
4
|
let client;
|
|
5
5
|
const clients = /* @__PURE__ */ new Map();
|
|
6
6
|
/**
|
|
@@ -32,5 +32,4 @@ function useDb(options) {
|
|
|
32
32
|
}
|
|
33
33
|
return db;
|
|
34
34
|
}
|
|
35
|
-
//#endregion
|
|
36
35
|
export { useDb };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DEV_LOGIN_COOKIE } from "../shared/user.js";
|
|
2
2
|
import { defineEventHandler, deleteCookie, getQuery, sendRedirect, setCookie } from "nuxt/server";
|
|
3
|
-
|
|
3
|
+
// src/runtime/server/dev-auth.ts
|
|
4
4
|
var dev_auth_default = defineEventHandler((event) => {
|
|
5
5
|
const { redirect } = getQuery(event);
|
|
6
6
|
const target = typeof redirect === "string" && redirect.startsWith("/") ? redirect : "/";
|
|
@@ -11,5 +11,4 @@ var dev_auth_default = defineEventHandler((event) => {
|
|
|
11
11
|
else deleteCookie(event, DEV_LOGIN_COOKIE, { path: "/" });
|
|
12
12
|
return sendRedirect(event, target);
|
|
13
13
|
});
|
|
14
|
-
//#endregion
|
|
15
14
|
export { dev_auth_default as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { renderEmail } from "../email/render.js";
|
|
2
2
|
import { createError, defineEventHandler, getQuery } from "nuxt/server";
|
|
3
3
|
import { templates } from "#wervt/emails";
|
|
4
|
-
|
|
4
|
+
// src/runtime/server/email-preview.ts
|
|
5
5
|
const list = templates;
|
|
6
6
|
const page = (body) => new Response(`<!doctype html><meta charset="utf-8"><title>Emails</title><body style="font:15px/1.6 system-ui;margin:40px">${body}</body>`, { headers: { "content-type": "text/html; charset=utf-8" } });
|
|
7
7
|
const escape = (value) => value.replace(/[&<>"]/g, (c) => ({
|
|
@@ -26,5 +26,4 @@ var email_preview_default = defineEventHandler(async (event) => {
|
|
|
26
26
|
if ("text" in getQuery(event)) return new Response(`Subject: ${mail.subject}\n\n${mail.text}\n`, { headers: { "content-type": "text/plain; charset=utf-8" } });
|
|
27
27
|
return new Response(mail.html, { headers: { "content-type": "text/html; charset=utf-8" } });
|
|
28
28
|
});
|
|
29
|
-
//#endregion
|
|
30
29
|
export { email_preview_default as default };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/runtime/server/identity.d.ts
|
|
2
1
|
export interface WorkloadIdentity {
|
|
3
2
|
/**
|
|
4
3
|
* A fresh JWT that says "I am this wervt app", for `audience` (a provider on wervt's list, e.g.
|
|
@@ -16,5 +15,4 @@ export interface WorkloadIdentity {
|
|
|
16
15
|
* doesn't sign for, 429 past 10 tokens a minute, 503 when the issuer is off. In `nuxt dev` there
|
|
17
16
|
* is no issuer, so it always throws.
|
|
18
17
|
*/
|
|
19
|
-
export declare function useWorkloadIdentity(): WorkloadIdentity;
|
|
20
|
-
//#endregion
|
|
18
|
+
export declare function useWorkloadIdentity(): WorkloadIdentity;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createError } from "nuxt/server";
|
|
2
|
-
|
|
2
|
+
// src/runtime/server/identity.ts
|
|
3
3
|
/**
|
|
4
4
|
* The app's workload identity: tokens signed by wervt's issuer, so the app can authenticate to an
|
|
5
5
|
* AI provider (Anthropic's Workload Identity Federation) without an API key. Its owner turns it
|
|
@@ -33,5 +33,4 @@ function useWorkloadIdentity() {
|
|
|
33
33
|
return body.token;
|
|
34
34
|
} };
|
|
35
35
|
}
|
|
36
|
-
//#endregion
|
|
37
36
|
export { useWorkloadIdentity };
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { RequestEvent } from "nuxt/server";
|
|
2
2
|
import { createEvlogError, log } from "evlog";
|
|
3
|
-
//#region src/runtime/server/logger.d.ts
|
|
4
3
|
/** The request's wide event: `useLogger(event).set({ user: { id } })` adds fields to it. */
|
|
5
4
|
export declare function useLogger<T extends object = Record<string, unknown>>(event: RequestEvent, service?: string): import("evlog").AuditableLogger<T>;
|
|
6
|
-
//#endregion
|
|
7
5
|
export { createEvlogError, log };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { createEvlogError, log, useLogger as useLogger$1 } from "evlog";
|
|
2
|
-
|
|
2
|
+
// src/runtime/server/logger.ts
|
|
3
3
|
/** The request's wide event: `useLogger(event).set({ user: { id } })` adds fields to it. */
|
|
4
4
|
function useLogger(event, service) {
|
|
5
5
|
return useLogger$1(event, service);
|
|
6
6
|
}
|
|
7
|
-
//#endregion
|
|
8
7
|
export { createEvlogError, log, useLogger };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { EmailProps } from "../email/render.js";
|
|
2
2
|
import { Component } from "vue";
|
|
3
|
-
//#region src/runtime/server/mail.d.ts
|
|
4
3
|
export interface SendMailOptions<T extends Component> {
|
|
5
4
|
/** One recipient. */
|
|
6
5
|
to: string;
|
|
@@ -19,5 +18,4 @@ export interface SendMailOptions<T extends Component> {
|
|
|
19
18
|
*/
|
|
20
19
|
export declare function sendMail<T extends Component>(options: SendMailOptions<T>): Promise<{
|
|
21
20
|
id: string;
|
|
22
|
-
}>;
|
|
23
|
-
//#endregion
|
|
21
|
+
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { renderEmail } from "../email/render.js";
|
|
2
2
|
import { createError } from "nuxt/server";
|
|
3
|
-
|
|
3
|
+
// src/runtime/server/mail.ts
|
|
4
4
|
/**
|
|
5
5
|
* Renders a template and sends it through wervt. Throws on failure, with the status the platform
|
|
6
6
|
* answered: 400 (invalid mail), 429 (the app's or the recipient's hourly limit), 502/503.
|
|
@@ -39,5 +39,4 @@ async function sendMail(options) {
|
|
|
39
39
|
});
|
|
40
40
|
return { id: body.id ?? "" };
|
|
41
41
|
}
|
|
42
|
-
//#endregion
|
|
43
42
|
export { sendMail };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CORS, fetchAuth, mcpEndpoint } from "./mcp-auth.js";
|
|
2
2
|
import { defineEventHandler } from "nuxt/server";
|
|
3
|
-
|
|
3
|
+
// src/runtime/server/mcp-auth-server.ts
|
|
4
4
|
var mcp_auth_server_default = defineEventHandler(async (event) => {
|
|
5
5
|
const endpoint = mcpEndpoint(event);
|
|
6
6
|
if (event.req.method === "OPTIONS") return new Response(null, {
|
|
@@ -17,5 +17,4 @@ var mcp_auth_server_default = defineEventHandler(async (event) => {
|
|
|
17
17
|
});
|
|
18
18
|
return Response.json(await res.json(), { headers: CORS });
|
|
19
19
|
});
|
|
20
|
-
//#endregion
|
|
21
20
|
export { mcp_auth_server_default as default };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { WervtUser } from "../shared/user.js";
|
|
2
2
|
import { RequestEvent } from "nuxt/server";
|
|
3
|
-
//#region src/runtime/server/mcp-auth.d.ts
|
|
4
3
|
/** What `wervt:mcp:token` handlers get: set `user` to accept the token. */
|
|
5
4
|
export interface McpTokenContext {
|
|
6
5
|
token: string;
|
|
@@ -57,5 +56,4 @@ export declare function verifyAccessToken(token: string, endpoint: McpEndpoint):
|
|
|
57
56
|
/** The user a bearer token on `/mcp` stands for: a wervt access token, or the app's own. */
|
|
58
57
|
export declare function authenticateMcp(token: string, event: RequestEvent, endpoint: McpEndpoint): Promise<WervtUser | undefined>;
|
|
59
58
|
/** Makes `useWervtUser(event)` return the token's user while a tool runs over MCP. */
|
|
60
|
-
export declare function setMcpUser(event: RequestEvent, user: WervtUser): void;
|
|
61
|
-
//#endregion
|
|
59
|
+
export declare function setMcpUser(event: RequestEvent, user: WervtUser): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { userFromClaims } from "./mcp-claims.js";
|
|
2
2
|
import { getRequestURL, useServerHooks } from "nuxt/server";
|
|
3
3
|
import { createRemoteJWKSet, customFetch, errors, jwtVerify } from "jose";
|
|
4
|
-
|
|
4
|
+
// src/runtime/server/mcp-auth.ts
|
|
5
5
|
const trimSlash = (url) => url.replace(/\/+$/, "");
|
|
6
6
|
/**
|
|
7
7
|
* Where this app's `/mcp` and wervt's login live, from the runtime's `WERVT_APP_URL` and
|
|
@@ -95,5 +95,4 @@ async function authenticateMcp(token, event, endpoint) {
|
|
|
95
95
|
function setMcpUser(event, user) {
|
|
96
96
|
event.context.wervtMcpUser = user;
|
|
97
97
|
}
|
|
98
|
-
//#endregion
|
|
99
98
|
export { CORS, authenticateMcp, fetchAuth, mcpEndpoint, protectedResourceMetadata, setMcpUser, verifyAccessToken };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { WervtUser } from "../shared/user.js";
|
|
2
|
-
//#region src/runtime/server/mcp-claims.d.ts
|
|
3
2
|
/** The wervt user an access token's claims name, or undefined when they're incomplete. */
|
|
4
|
-
export declare function userFromClaims(claims: Record<string, unknown>): WervtUser | undefined;
|
|
5
|
-
//#endregion
|
|
3
|
+
export declare function userFromClaims(claims: Record<string, unknown>): WervtUser | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/runtime/server/mcp-claims.ts
|
|
2
2
|
/** The wervt user an access token's claims name, or undefined when they're incomplete. */
|
|
3
3
|
function userFromClaims(claims) {
|
|
4
4
|
const { sub, email, name, picture, accounts } = claims;
|
|
@@ -14,5 +14,4 @@ function userFromClaims(claims) {
|
|
|
14
14
|
function isAccounts(value) {
|
|
15
15
|
return typeof value === "object" && value !== null && !Array.isArray(value) && Object.values(value).every((id) => typeof id === "string");
|
|
16
16
|
}
|
|
17
|
-
//#endregion
|
|
18
17
|
export { userFromClaims };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CORS, mcpEndpoint, protectedResourceMetadata } from "./mcp-auth.js";
|
|
2
2
|
import { defineEventHandler, getRequestURL } from "nuxt/server";
|
|
3
|
-
|
|
3
|
+
// src/runtime/server/mcp-metadata.ts
|
|
4
4
|
var mcp_metadata_default = defineEventHandler((event) => {
|
|
5
5
|
const endpoint = mcpEndpoint(event);
|
|
6
6
|
if (event.req.method === "OPTIONS") return new Response(null, {
|
|
@@ -11,5 +11,4 @@ var mcp_metadata_default = defineEventHandler((event) => {
|
|
|
11
11
|
const mcp = getRequestURL(event).pathname.endsWith("/mcp");
|
|
12
12
|
return Response.json(protectedResourceMetadata(endpoint, mcp ? endpoint.resource : endpoint.app), { headers: CORS });
|
|
13
13
|
});
|
|
14
|
-
//#endregion
|
|
15
14
|
export { mcp_metadata_default as default };
|
|
@@ -6,7 +6,7 @@ import { allTools, toolInputSchema } from "./tool-handlers.js";
|
|
|
6
6
|
import { defineEventHandler } from "nuxt/server";
|
|
7
7
|
import { server } from "#wervt/mcp";
|
|
8
8
|
import { defineMcpHandler } from "h3-mcp";
|
|
9
|
-
|
|
9
|
+
// src/runtime/server/mcp.ts
|
|
10
10
|
const MAX_BODY = 4194304;
|
|
11
11
|
const text = (value) => [{
|
|
12
12
|
type: "text",
|
|
@@ -104,5 +104,4 @@ var mcp_default = defineEventHandler(async (event) => {
|
|
|
104
104
|
});
|
|
105
105
|
return (await handler)(event);
|
|
106
106
|
});
|
|
107
|
-
//#endregion
|
|
108
107
|
export { mcp_default as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface ErrorContext {
|
|
2
|
+
event?: {
|
|
3
|
+
req?: Request;
|
|
4
|
+
path?: string;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
interface NitroAppHooks {
|
|
8
|
+
hooks: {
|
|
9
|
+
hook(name: 'error', handler: (error: unknown, context: ErrorContext) => void): unknown;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export default function wervtPreviewErrors(nitroApp: NitroAppHooks): void;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { recordPreviewError, trimStack } from "../shared/preview-errors.js";
|
|
2
|
+
// src/runtime/server/preview-errors-plugin.ts
|
|
3
|
+
function wervtPreviewErrors(nitroApp) {
|
|
4
|
+
const file = process.env.WERVT_PREVIEW_ERRORS;
|
|
5
|
+
if (!file) return;
|
|
6
|
+
nitroApp.hooks.hook("error", (error, { event }) => {
|
|
7
|
+
const status = error ?? {};
|
|
8
|
+
if ((status.status ?? status.statusCode ?? 500) < 500) return;
|
|
9
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
10
|
+
recordPreviewError(file, {
|
|
11
|
+
at: Date.now(),
|
|
12
|
+
source: "server",
|
|
13
|
+
message: `${err.name}: ${err.message}`,
|
|
14
|
+
stack: trimStack(err.stack),
|
|
15
|
+
url: event?.req ? new URL(event.req.url).pathname : event?.path
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
export { wervtPreviewErrors as default };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { InferInsertModel } from "drizzle-orm";
|
|
2
2
|
import { PgTable } from "drizzle-orm/pg-core";
|
|
3
|
-
//#region src/runtime/server/seed.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Inserts `rows` into `table` only while it is empty, so a seed task can run again without
|
|
6
5
|
* duplicating data or touching what users created. Returns how many rows it inserted.
|
|
@@ -14,5 +13,4 @@ import { PgTable } from "drizzle-orm/pg-core";
|
|
|
14
13
|
* },
|
|
15
14
|
* })
|
|
16
15
|
*/
|
|
17
|
-
export declare function seedTable<T extends PgTable>(table: T, rows: InferInsertModel<T>[]): Promise<number>;
|
|
18
|
-
//#endregion
|
|
16
|
+
export declare function seedTable<T extends PgTable>(table: T, rows: InferInsertModel<T>[]): Promise<number>;
|