@vite-hub/comments 0.3.1 → 0.5.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/README.md +37 -15
- package/dist/anchor.d.ts +2 -2
- package/dist/{client-diagnostics-CcFpkbAk.js → client-diagnostics-Bubm7Shd.js} +20 -5
- package/dist/client-files-CJZl5Kc4.js +53 -0
- package/dist/client.d.ts +567 -13
- package/dist/client.js +1209 -34
- package/dist/{console-h4KlhIik.d.ts → console-D1lwNMZn.d.ts} +2 -0
- package/dist/{migrate-BDQ8xqUs.js → database-6hXRnqDE.js} +47 -2
- package/dist/database-CTo7mx6t.d.ts +575 -0
- package/dist/database.d.ts +2 -1
- package/dist/database.js +2 -2
- package/dist/{define-43mMR39K.js → define-BMBSVbD9.js} +1 -1
- package/dist/{define-B3TF9zzn.d.ts → define-CmIFU96x.d.ts} +8 -4
- package/dist/{errors-4gelGVmK.js → errors-BJTZ9iyv.js} +24 -0
- package/dist/{errors-C6qptPoG.js → errors-Dq4AHjza.js} +23 -3
- package/dist/index-RiHzmV16.d.ts +194 -0
- package/dist/index.d.ts +6 -7
- package/dist/index.js +57 -9
- package/dist/{install-W9ghhGoh.d.ts → install-BGGQKbQ4.d.ts} +9 -3
- package/dist/{install-BcMPgPk_.js → install-DrAse1Fa.js} +912 -60
- package/dist/{installed-B-PfERBU.js → installed-C3EoqJEY.js} +7 -6
- package/dist/{operations-GLeOqgMt.d.ts → operations-BKhUWYkb.d.ts} +10 -5
- package/dist/{operations-D4A1Fcgf.d.ts → operations-VyyNZusz.d.ts} +13 -2
- package/dist/{operations-DMMIfYPW.js → operations-lsVKE0GH.js} +312 -219
- package/dist/operations.d.ts +2 -2
- package/dist/operations.js +2 -2
- package/dist/overlay/client-DBmJ4C1M.js +4 -0
- package/dist/overlay/overlay.js +41 -65
- package/dist/page/loader.js +39 -47
- package/dist/{page-DtbMOEMd.d.ts → page-Bzj0CszG.d.ts} +1 -10
- package/dist/{page-B41ozN63.js → page-DRz_sDY4.js} +1 -1
- package/dist/{page-tools-shared-NHUjKI8E.js → page-tools-shared-BNnuPK93.js} +6 -3
- package/dist/{plugin-PS8PMYus.js → plugin-DRsNaJaK.js} +34 -8
- package/dist/realtime.d.ts +2 -2
- package/dist/realtime.js +2 -2
- package/dist/reply-id-P_bSuEng.js +12 -0
- package/dist/request-log-Dj9Vw7qG.js +105 -0
- package/dist/request-origin-CFU0TQ7E.js +49 -0
- package/dist/{rpc-RKPAusHp.js → rpc-BQqYx8kb.js} +23 -7
- package/dist/{rpc-HBcWtg0T.d.ts → rpc-CuJ5GLIz.d.ts} +1 -1
- package/dist/rpc.d.ts +1 -1
- package/dist/rpc.js +1 -1
- package/dist/runtime/auth.d.ts +2 -2
- package/dist/runtime/auth.js +2 -2
- package/dist/runtime/console.d.ts +1 -1
- package/dist/runtime/console.js +3 -3
- package/dist/runtime/index.d.ts +42 -13
- package/dist/runtime/index.js +224 -22
- package/dist/{server-D8k-0GXe.js → server-Yk610niJ.js} +1 -1
- package/dist/server.d.ts +6 -5
- package/dist/server.js +6 -6
- package/dist/service-Bj-Mg63c.d.ts +73 -0
- package/dist/{service-GHhhyQj4.js → service-DA5BwfPQ.js} +71 -14
- package/dist/{session-DVx-1Tym.d.ts → session-DUcEor2W.d.ts} +3 -3
- package/dist/{session-EkudzUmm.js → session-X_g9dnU5.js} +27 -30
- package/dist/{service-CFVm23k7.d.ts → store-CsUNfC1w.d.ts} +11 -72
- package/dist/table-names-B9LlRC0B.js +16 -0
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +38 -5
- package/dist/{types-CZujrMFd.d.ts → types-BLaYh0_f.d.ts} +48 -4
- package/dist/{types-BIS0hCEl.d.ts → types-C35INXIs.d.ts} +88 -4
- package/dist/vite.d.ts +24 -7
- package/dist/vite.js +322 -173
- package/package.json +9 -9
- package/dist/errors-CyQyKAvy.d.ts +0 -185
- package/dist/index-DNhy69Wt.d.ts +0 -83
- package/dist/overlay/client-DmsSMOzi.js +0 -4
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
//#region ../internal/src/runtime/request-log.ts
|
|
2
|
+
function isRequestLog(value) {
|
|
3
|
+
return value !== null && typeof value === "object" && typeof Reflect.get(value, "set") === "function" && typeof Reflect.get(value, "warn") === "function" && typeof Reflect.get(value, "error") === "function";
|
|
4
|
+
}
|
|
5
|
+
function contextLog(value) {
|
|
6
|
+
const context = value !== null && typeof value === "object" ? Reflect.get(value, "context") : void 0;
|
|
7
|
+
return context !== null && typeof context === "object" ? Reflect.get(context, "log") : void 0;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The evlog request logger of a request, or `undefined` when the app does not register evlog. Pass a Nitro v3 event
|
|
11
|
+
* (evlog sets `event.req.context.log`) or its `Request` (`request.context.log`).
|
|
12
|
+
*/
|
|
13
|
+
function requestLog(input) {
|
|
14
|
+
const log = contextLog(input !== null && typeof input === "object" ? Reflect.get(input, "req") : void 0) ?? contextLog(input);
|
|
15
|
+
return isRequestLog(log) ? log : void 0;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The `Symbol.for()` key of the bridge on `globalThis`. Every bundled copy of this module and the Nitro plugin that
|
|
19
|
+
* `vitehub()` generates use the same key.
|
|
20
|
+
*/
|
|
21
|
+
const evlogBridgeKey = "vitehub.evlog";
|
|
22
|
+
function isEvlogBridge(value) {
|
|
23
|
+
return value !== null && typeof value === "object" && typeof Reflect.get(value, "createLogger") === "function";
|
|
24
|
+
}
|
|
25
|
+
/** The evlog bridge of this process, or `undefined` when the app does not register evlog. */
|
|
26
|
+
function evlogBridge() {
|
|
27
|
+
const bridge = globalThis[Symbol.for(evlogBridgeKey)];
|
|
28
|
+
return isEvlogBridge(bridge) ? bridge : void 0;
|
|
29
|
+
}
|
|
30
|
+
function activeBridge() {
|
|
31
|
+
const bridge = evlogBridge();
|
|
32
|
+
try {
|
|
33
|
+
return bridge && bridge.isEnabled?.() !== false ? bridge : void 0;
|
|
34
|
+
} catch {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A short name for the cause of a failure, safe to put in a log field: the string `code` of the error, such as
|
|
40
|
+
* `ENOSPC` or a ViteHub diagnostic code, else its class name. Never the message, which can hold paths or values.
|
|
41
|
+
*/
|
|
42
|
+
function errorCode(error) {
|
|
43
|
+
if (error === null || typeof error !== "object") return void 0;
|
|
44
|
+
const code = Reflect.get(error, "code");
|
|
45
|
+
if (typeof code === "string" && code) return code;
|
|
46
|
+
const name = Reflect.get(error, "name");
|
|
47
|
+
return typeof name === "string" && name && name !== "Error" ? name : void 0;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Emits one evlog event of its own, outside a request's wide event. The event also reaches the app's `evlog:drain`
|
|
51
|
+
* hooks. Returns `false` when the app does not register evlog or turned it off, and never throws.
|
|
52
|
+
*/
|
|
53
|
+
function emitLogEvent(event) {
|
|
54
|
+
const bridge = activeBridge();
|
|
55
|
+
if (!bridge) return false;
|
|
56
|
+
try {
|
|
57
|
+
const log = bridge.createLogger({
|
|
58
|
+
action: event.field,
|
|
59
|
+
message: event.message,
|
|
60
|
+
[event.field]: event.fields
|
|
61
|
+
}, event.waitUntil ? { waitUntil: event.waitUntil } : void 0);
|
|
62
|
+
if (event.level === "error") log.error(event.withError && event.error instanceof Error ? event.error : event.message);
|
|
63
|
+
else log[event.level](event.message);
|
|
64
|
+
const emitted = log.emit();
|
|
65
|
+
if (emitted && bridge.drain) {
|
|
66
|
+
const drained = Promise.resolve().then(() => bridge.drain?.(emitted)).catch((error) => {
|
|
67
|
+
console.error("[evlog] drain failed:", error);
|
|
68
|
+
});
|
|
69
|
+
event.waitUntil?.(drained);
|
|
70
|
+
}
|
|
71
|
+
return true;
|
|
72
|
+
} catch {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Logs a failure that the caller survives, with a fixed message and the `code` of the error. With the evlog request
|
|
78
|
+
* logger of `request`, it replaces `[field]` on the request's wide event and adds a warning. Pass `request` only when the
|
|
79
|
+
* request has not answered yet: evlog drops fields after it emits the wide event. Otherwise it emits an event of its
|
|
80
|
+
* own. Without evlog, or with evlog off, it calls `fallback`, which prints to the server console as before. It never
|
|
81
|
+
* throws.
|
|
82
|
+
*/
|
|
83
|
+
function logFailure(failure, fallback) {
|
|
84
|
+
const code = errorCode(failure.error);
|
|
85
|
+
const fields = {
|
|
86
|
+
...failure.fields,
|
|
87
|
+
...code ? { code } : {}
|
|
88
|
+
};
|
|
89
|
+
const log = failure.request !== void 0 && activeBridge() ? requestLog(failure.request) : void 0;
|
|
90
|
+
if (log) try {
|
|
91
|
+
log.set({ [failure.field]: false });
|
|
92
|
+
log.warn(failure.message, { [failure.field]: fields });
|
|
93
|
+
return;
|
|
94
|
+
} catch {}
|
|
95
|
+
if (emitLogEvent({
|
|
96
|
+
...failure,
|
|
97
|
+
fields,
|
|
98
|
+
level: failure.level ?? "warn"
|
|
99
|
+
})) return;
|
|
100
|
+
try {
|
|
101
|
+
fallback();
|
|
102
|
+
} catch {}
|
|
103
|
+
}
|
|
104
|
+
//#endregion
|
|
105
|
+
export { logFailure as t };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//#region ../internal/src/runtime/request-origin.ts
|
|
2
|
+
function firstHeaderValue(headers, name) {
|
|
3
|
+
return headers.get(name)?.split(",", 1)[0]?.trim() || void 0;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* The origin that the client used for `request`. A TLS-terminating proxy sends the client scheme in
|
|
7
|
+
* `X-Forwarded-Proto` and the client host in `X-Forwarded-Host`. Each proxy appends its value, so the first value wins.
|
|
8
|
+
* Without these headers, or with values that are not valid, the result is the origin of `request.url`.
|
|
9
|
+
*/
|
|
10
|
+
function forwardedRequestOrigin(request) {
|
|
11
|
+
const url = new URL(request.url);
|
|
12
|
+
const forwardedProtocol = firstHeaderValue(request.headers, "x-forwarded-proto")?.toLowerCase();
|
|
13
|
+
const protocol = forwardedProtocol === "http" || forwardedProtocol === "https" ? forwardedProtocol : url.protocol.slice(0, -1);
|
|
14
|
+
const host = firstHeaderValue(request.headers, "x-forwarded-host") ?? url.host;
|
|
15
|
+
if (/[\u0000-\u001F\s/\\?#@]/.test(host)) return url.origin;
|
|
16
|
+
try {
|
|
17
|
+
return new URL(`${protocol}://${host}`).origin;
|
|
18
|
+
} catch {
|
|
19
|
+
return url.origin;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Whether a request came in on one of the public `origins` of the app, such as the origin of `vitehub({ publicUrl })`.
|
|
24
|
+
* It compares the host that the client used, so a proxy that does not forward the scheme still matches. A loopback
|
|
25
|
+
* host, such as `localhost:3000` for a preview or a proxy that does not forward the host, also matches: it cannot be a
|
|
26
|
+
* second public hostname. Every request matches when `origins` is empty.
|
|
27
|
+
*/
|
|
28
|
+
function matchesPublicOrigin(request, origins) {
|
|
29
|
+
if (origins.length === 0) return true;
|
|
30
|
+
const { host, hostname } = new URL(forwardedRequestOrigin(request));
|
|
31
|
+
return isLoopbackHostname(hostname) || origins.some((origin) => new URL(origin).host === host);
|
|
32
|
+
}
|
|
33
|
+
/** `localhost`, `[::1]`, or an IPv4 address in `127.0.0.0/8`. URL parsing writes IPv4 addresses as four decimal parts. */
|
|
34
|
+
function isLoopbackHostname(hostname) {
|
|
35
|
+
return hostname === "localhost" || hostname === "[::1]" || /^127(?:\.\d{1,3}){3}$/.test(hostname);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Whether a browser treats `origin` as secure: `https:`, or `http:` on a loopback host (`localhost`, `*.localhost`,
|
|
39
|
+
* `127.0.0.0/8`, or `[::1]`). A route that answers with a secret, or builds a URL that carries one, needs this.
|
|
40
|
+
*/
|
|
41
|
+
function isSecureOrigin(origin) {
|
|
42
|
+
if (!URL.canParse(origin)) return false;
|
|
43
|
+
const { protocol, hostname } = new URL(origin);
|
|
44
|
+
if (protocol === "https:") return true;
|
|
45
|
+
if (protocol !== "http:") return false;
|
|
46
|
+
return isLoopbackHostname(hostname) || hostname.endsWith(".localhost");
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { isSecureOrigin as n, matchesPublicOrigin as r, forwardedRequestOrigin as t };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { i as commentsUnansweredError, t as commentsAnswerError } from "./client-diagnostics-
|
|
1
|
+
import { i as commentsUnansweredError, t as commentsAnswerError } from "./client-diagnostics-Bubm7Shd.js";
|
|
2
|
+
import { i as withCommentFiles, n as outboxAccountHeader, r as retryAfterOf } from "./client-files-CJZl5Kc4.js";
|
|
2
3
|
import { n as isRecordOrFunction, t as isRecord } from "./object-Da1zyPCR.js";
|
|
3
4
|
import { createBirpc } from "birpc";
|
|
4
5
|
//#region ../internal/src/operation-rpc.ts
|
|
@@ -96,7 +97,7 @@ async function callOperationRpc(name, input, send) {
|
|
|
96
97
|
*/
|
|
97
98
|
function createRpcTransport(options = {}) {
|
|
98
99
|
const base = (options.base ?? "").replace(/\/+$/, "");
|
|
99
|
-
async function call(operation, input) {
|
|
100
|
+
async function call(operation, input, account) {
|
|
100
101
|
const send = options.fetch ?? globalThis.fetch;
|
|
101
102
|
let outcome;
|
|
102
103
|
try {
|
|
@@ -107,7 +108,8 @@ function createRpcTransport(options = {}) {
|
|
|
107
108
|
credentials: "same-origin",
|
|
108
109
|
headers: {
|
|
109
110
|
"content-type": "application/json",
|
|
110
|
-
"x-vitehub-console": "1"
|
|
111
|
+
"x-vitehub-console": "1",
|
|
112
|
+
...account === void 0 ? {} : { [outboxAccountHeader]: encodeURIComponent(account) }
|
|
111
113
|
},
|
|
112
114
|
method: "POST"
|
|
113
115
|
});
|
|
@@ -124,27 +126,41 @@ function createRpcTransport(options = {}) {
|
|
|
124
126
|
const { message, ...failure } = outcome.error;
|
|
125
127
|
throw commentsAnswerError({
|
|
126
128
|
...failure,
|
|
127
|
-
why: message
|
|
129
|
+
why: message,
|
|
130
|
+
retryAfter: retryAfterOf(outcome.answer.response)
|
|
128
131
|
});
|
|
129
132
|
}
|
|
130
133
|
const { body, response } = outcome.answer;
|
|
131
|
-
|
|
134
|
+
const retryAfter = retryAfterOf(response);
|
|
135
|
+
if (!isRecordOrFunction(body) || typeof body.code !== "string" || typeof body.message !== "string") throw commentsUnansweredError(response.status, void 0, retryAfter);
|
|
132
136
|
throw commentsAnswerError({
|
|
133
137
|
code: body.code,
|
|
134
138
|
status: typeof body.status === "number" ? body.status : response.status,
|
|
135
139
|
why: body.message,
|
|
140
|
+
...retryAfter === void 0 ? {} : { retryAfter },
|
|
136
141
|
...typeof body.fix === "string" ? { fix: body.fix } : {},
|
|
137
142
|
...isRecordOrFunction(body.details) ? { details: body.details } : {}
|
|
138
143
|
});
|
|
139
144
|
}
|
|
145
|
+
const upload = (input, account) => call("comments.upload", input, account);
|
|
140
146
|
return {
|
|
141
|
-
create
|
|
147
|
+
async create({ files, outbox, ...input }) {
|
|
148
|
+
return call("comments.create", await withCommentFiles(input, {
|
|
149
|
+
files,
|
|
150
|
+
outbox
|
|
151
|
+
}, input.subject, (data) => upload(data, outbox?.account)), outbox?.account);
|
|
152
|
+
},
|
|
142
153
|
delete: (input) => call("comments.delete", input),
|
|
143
154
|
edit: (input) => call("comments.edit", input),
|
|
144
155
|
get: (input) => call("comments.get", input),
|
|
145
156
|
list: (query) => call("comments.list", query),
|
|
146
157
|
reopen: (input) => call("comments.reopen", input),
|
|
147
|
-
reply
|
|
158
|
+
async reply({ subject, files, outbox, ...input }) {
|
|
159
|
+
return call("comments.reply", await withCommentFiles(input, {
|
|
160
|
+
files,
|
|
161
|
+
outbox
|
|
162
|
+
}, subject, (data) => upload(data, outbox?.account)), outbox?.account);
|
|
163
|
+
},
|
|
148
164
|
resolve: (input) => call("comments.resolve", input),
|
|
149
165
|
users: (input) => call("comments.users", input)
|
|
150
166
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { k as CommentsTransport } from "./types-BLaYh0_f.js";
|
|
2
2
|
//#region src/operations-core/rpc.d.ts
|
|
3
3
|
interface RpcTransportOptions {
|
|
4
4
|
/** The app origin and mount, such as `https://app.example.com` or `/portal`. Defaults to the page origin. */
|
package/dist/rpc.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as createRpcTransport, t as RpcTransportOptions } from "./rpc-
|
|
1
|
+
import { n as createRpcTransport, t as RpcTransportOptions } from "./rpc-CuJ5GLIz.js";
|
|
2
2
|
export { RpcTransportOptions, createRpcTransport };
|
package/dist/rpc.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as createRpcTransport } from "./rpc-
|
|
1
|
+
import { t as createRpcTransport } from "./rpc-BQqYx8kb.js";
|
|
2
2
|
export { createRpcTransport };
|
package/dist/runtime/auth.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as CommentsPeople, g as CommentsUser } from "../define-
|
|
2
|
-
import {
|
|
1
|
+
import { d as CommentsPeople, g as CommentsUser } from "../define-CmIFU96x.js";
|
|
2
|
+
import { f as CommentsRequestEvent } from "../types-C35INXIs.js";
|
|
3
3
|
//#region src/runtime/auth.d.ts
|
|
4
4
|
/** The ViteHub Auth user of a request, or null. Generated Comments files pass it as `session` when the app has Auth. */
|
|
5
5
|
export declare function commentsAuthSession(event: CommentsRequestEvent): Promise<CommentsUser | null>;
|
package/dist/runtime/auth.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as createAuthUsers } from "../server-
|
|
1
|
+
import { n as createAuthUsers } from "../server-Yk610niJ.js";
|
|
2
2
|
import { getStandardContext } from "@vite-hub/runtime/internal/h3";
|
|
3
3
|
//#region src/runtime/auth.ts
|
|
4
|
-
const authServer = () => import("@vite-hub/auth/server");
|
|
4
|
+
const authServer = () => import("@vite-hub/auth/internal/server");
|
|
5
5
|
/** The ViteHub Auth user of a request, or null. Generated Comments files pass it as `session` when the app has Auth. */
|
|
6
6
|
async function commentsAuthSession(event) {
|
|
7
7
|
const request = getStandardContext(event).req;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ViteHubConsoleRecord } from "../console-
|
|
1
|
+
import { n as ViteHubConsoleRecord } from "../console-D1lwNMZn.js";
|
|
2
2
|
//#region src/runtime/console.d.ts
|
|
3
3
|
/** The threads of the app as Console records: open threads first, each group newest activity first. It runs on each Console request. */
|
|
4
4
|
export declare function readCommentsConsoleRecords(): Promise<ViteHubConsoleRecord[]>;
|
package/dist/runtime/console.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as commentsPageScope } from "../page-
|
|
1
|
+
import { n as commentsPageScope } from "../page-DRz_sDY4.js";
|
|
2
2
|
import { t as describeCommentContext } from "../context-BqIsmYP1.js";
|
|
3
|
-
import { n as installedComments } from "../plugin-
|
|
3
|
+
import { n as installedComments } from "../plugin-DRsNaJaK.js";
|
|
4
4
|
//#region src/runtime/console.ts
|
|
5
5
|
function excerpt(text) {
|
|
6
6
|
const line = text.replace(/\s+/g, " ").trim();
|
|
@@ -54,7 +54,7 @@ async function readCommentsConsoleRecords() {
|
|
|
54
54
|
...describeCommentContext(thread.context ?? null),
|
|
55
55
|
...thread.resolvedBy ? [{
|
|
56
56
|
label: "Resolved by",
|
|
57
|
-
value: author(thread.resolvedBy)
|
|
57
|
+
value: `${thread.resolvedActor ? `${thread.resolvedActor.name ?? thread.resolvedActor.id} for ` : ""}${author(thread.resolvedBy)}`
|
|
58
58
|
}] : []
|
|
59
59
|
]
|
|
60
60
|
};
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { s as CommentContext } from "../types-
|
|
2
|
-
import { g as CommentsUser } from "../define-
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
5
|
-
import {
|
|
6
|
-
import { t as CommentsSessionOptions } from "../session-
|
|
7
|
-
import { t as InstallCommentsOptions } from "../install-
|
|
1
|
+
import { s as CommentContext } from "../types-BLaYh0_f.js";
|
|
2
|
+
import { g as CommentsUser } from "../define-CmIFU96x.js";
|
|
3
|
+
import { f as CommentsRequestEvent } from "../types-C35INXIs.js";
|
|
4
|
+
import { t as CommentsDatabase } from "../store-CsUNfC1w.js";
|
|
5
|
+
import { t as Comments } from "../index-RiHzmV16.js";
|
|
6
|
+
import { t as CommentsSessionOptions } from "../session-DUcEor2W.js";
|
|
7
|
+
import { t as InstallCommentsOptions } from "../install-BGGQKbQ4.js";
|
|
8
8
|
//#region src/runtime/github-login.d.ts
|
|
9
9
|
/** The Server Env names of the OAuth client that people sign in to Comments with: a GitHub App's, or an OAuth App's. */
|
|
10
10
|
export declare const githubLoginEnv: {
|
|
@@ -16,7 +16,7 @@ interface CommentsGitHubLogin {
|
|
|
16
16
|
configured(): boolean;
|
|
17
17
|
/** The person signed in with GitHub, with what they may do in the repository. Null without a session. */
|
|
18
18
|
user(event: CommentsRequestEvent): Promise<CommentsUser | null>;
|
|
19
|
-
/** The sign-in, callback, and sign-out routes under `/
|
|
19
|
+
/** The sign-in, callback, and sign-out routes under `/_vitehub/comments/auth/`. */
|
|
20
20
|
handle(request: Request & CommentsRequestEvent, path: string): Promise<Response>;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
@@ -96,7 +96,7 @@ interface CommentsHandlerOptions extends CommentsSessionOptions {
|
|
|
96
96
|
components?: Readonly<Record<string, readonly string[]>>;
|
|
97
97
|
}
|
|
98
98
|
/**
|
|
99
|
-
* The Comments API at `/
|
|
99
|
+
* The Comments API at `/_vitehub/comments/**`, as a Fetchable: mount it as a Nitro or H3 route, or call
|
|
100
100
|
* `fetch(request)`. The overlay calls it; every route checks the `authorize` policy of `defineComments()` for the user of
|
|
101
101
|
* the request, and inline edits also check `content.can()`.
|
|
102
102
|
*/
|
|
@@ -112,7 +112,7 @@ interface CommentsPluginOptions extends CommentsSessionOptions {
|
|
|
112
112
|
/** The Database of `defineComments({ database })`, or undefined when the app has none. The first Comments call reads it. */
|
|
113
113
|
database: () => CommentsDatabase | undefined | Promise<CommentsDatabase | undefined>;
|
|
114
114
|
/**
|
|
115
|
-
* Path of the overlay script below the app base, such as `/
|
|
115
|
+
* Path of the overlay script below the app base, such as `/_vitehub/comments/assets/overlay.js`. The page tools
|
|
116
116
|
* loader imports it for people that may read comments.
|
|
117
117
|
*/
|
|
118
118
|
overlay: string | false;
|
|
@@ -133,6 +133,8 @@ interface CommentsPluginOptions extends CommentsSessionOptions {
|
|
|
133
133
|
/** The tables of a Postgres Database. Default: the SQLite tables. */
|
|
134
134
|
tables?: InstallCommentsOptions["tables"];
|
|
135
135
|
dialect?: InstallCommentsOptions["dialect"];
|
|
136
|
+
/** Loads `@vite-hub/webhooks`, when `defineComments({ send })` is on. */
|
|
137
|
+
webhooks?: InstallCommentsOptions["webhooks"];
|
|
136
138
|
}
|
|
137
139
|
/** The Comments definition that the Nitro plugin installed, for the Console reader. */
|
|
138
140
|
export declare function installedComments(): Comments | undefined;
|
|
@@ -202,9 +204,20 @@ interface ViteHubMcpInputSchema {
|
|
|
202
204
|
required?: string[];
|
|
203
205
|
additionalProperties?: boolean;
|
|
204
206
|
}
|
|
205
|
-
/**
|
|
207
|
+
/** An image that the Agent sees, such as a screenshot attached to a comment. */
|
|
208
|
+
interface ViteHubMcpImage {
|
|
209
|
+
/** The bytes, Base64-encoded. */
|
|
210
|
+
data: string;
|
|
211
|
+
/** Such as `image/png`. */
|
|
212
|
+
mimeType: string;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* What a tool call returns: text for the Agent, the images that it refers to, and the same data as JSON.
|
|
216
|
+
* `mcpToolResult()` turns it into the MCP result, with one `image` block for each image after the text.
|
|
217
|
+
*/
|
|
206
218
|
interface ViteHubMcpToolResult {
|
|
207
219
|
text: string;
|
|
220
|
+
images?: ViteHubMcpImage[];
|
|
208
221
|
structured?: Record<string, unknown>;
|
|
209
222
|
isError?: boolean;
|
|
210
223
|
}
|
|
@@ -258,10 +271,26 @@ interface CommentsMcpToolsOptions {
|
|
|
258
271
|
*/
|
|
259
272
|
export declare function commentsMcpTools(comments: Comments, options?: CommentsMcpToolsOptions): ViteHubMcpTool[];
|
|
260
273
|
//#endregion
|
|
274
|
+
//#region ../internal/src/runtime/mcp-server.d.ts
|
|
275
|
+
type ToolResultContent = ({
|
|
276
|
+
type: "text";
|
|
277
|
+
text: string;
|
|
278
|
+
} | {
|
|
279
|
+
type: "image";
|
|
280
|
+
data: string;
|
|
281
|
+
mimeType: string;
|
|
282
|
+
})[];
|
|
283
|
+
/** The MCP result of a `ViteHubMcpTool` call: a text block, then one image block for each image. */
|
|
284
|
+
export declare function mcpToolResult(result: ViteHubMcpToolResult): {
|
|
285
|
+
content: ToolResultContent;
|
|
286
|
+
structuredContent?: Record<string, unknown>;
|
|
287
|
+
isError: boolean;
|
|
288
|
+
};
|
|
289
|
+
//#endregion
|
|
261
290
|
//#region ../internal/src/runtime/page-tools.d.ts
|
|
262
291
|
/**
|
|
263
|
-
* The route of `GET /_vitehub/page/
|
|
264
|
-
* app in `
|
|
292
|
+
* The route of `GET /_vitehub/page/tools`: a Fetchable (https://fetchable.org). `installViteHubPageTools()` binds
|
|
293
|
+
* each Request to its app in Nitro's `request` hook, so the route finds the tools of that app.
|
|
265
294
|
*/
|
|
266
295
|
export declare const viteHubPageSessionHandler: {
|
|
267
296
|
fetch(request: Request): Promise<Response>;
|