@vite-hub/comments 0.7.0 → 0.8.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 +4 -10
- package/dist/anchor.d.ts +1 -1
- package/dist/client-request-B1DCz3a9.js +29 -0
- package/dist/client.d.ts +20 -240
- package/dist/client.js +3 -421
- package/dist/database.d.ts +1 -2
- package/dist/database.js +1 -1
- package/dist/{define-BqPcuDhf.js → define-C-LUOouq.js} +1 -1
- package/dist/{errors-C0VwRHiy.js → errors-C5utwZ5H.js} +0 -24
- package/dist/{errors-CBvIpwbo.js → errors-DeSEHzRf.js} +0 -12
- package/dist/hosted/hosted-comments/frame.js +4 -1
- package/dist/hosted/hosted-comments/tools.js +65 -74
- package/dist/hosted/hosted-comments.js +1 -1
- package/dist/{index-D1T7RJ4R.d.ts → index-d6NsDxu9.d.ts} +4 -112
- package/dist/index.d.ts +4 -5
- package/dist/index.js +6 -20
- package/dist/{install-CqBWFmU7.js → install-BueV_fJY.js} +7 -771
- package/dist/{install-9L4ASzUC.d.ts → install-F-_O7zDr.d.ts} +5 -11
- package/dist/{installed-wUYjqk_k.js → installed-BqQKo6WC.js} +2 -7
- package/dist/{database-BuSNVwTx.js → migrate-oseJAYbm.js} +2 -46
- package/dist/{operations-kMPw-Cyb.js → operations-0llC5kKO.js} +46 -47
- package/dist/{operations-Qt8ASQqW.d.ts → operations-jaihyWw2.d.ts} +35 -3
- package/dist/operations.d.ts +3 -3
- package/dist/operations.js +2 -2
- package/dist/overlay/client-ZBsUybIe.js +4 -0
- package/dist/overlay/overlay.js +47 -43
- package/dist/page/loader.js +31 -27
- package/dist/page-BgvzzsJb.d.ts +32 -0
- package/dist/{page-2NzFladc.js → page-CDhmXO-y.js} +24 -1
- package/dist/{page-tools-shared-BNw-aWEH.js → page-tools-shared-BCdvqA4S.js} +40 -2
- package/dist/{plugin-ChOHe7vq.js → plugin-DGUqlc3C.js} +9 -9
- package/dist/realtime.d.ts +6 -8
- package/dist/realtime.js +2 -4
- package/dist/runtime/auth.d.ts +1 -2
- package/dist/runtime/auth.js +1 -1
- package/dist/runtime/client-request-plugin.d.ts +2 -0
- package/dist/runtime/client-request-plugin.js +21 -0
- package/dist/runtime/console.js +2 -2
- package/dist/runtime/index.d.ts +5 -8
- package/dist/runtime/index.js +23 -151
- package/dist/{server-8o9u8leM.js → server-CAMs6viR.js} +1 -1
- package/dist/server.d.ts +11 -7
- package/dist/server.js +7 -6
- package/dist/{store-DvNTDNgn.d.ts → service-CMVA_Ryv.d.ts} +67 -1
- package/dist/{service-XT2A8YEF.js → service-DaMq8TBw.js} +35 -33
- package/dist/{session-DGdFKWDB.js → session-B7GDrqsK.js} +204 -39
- package/dist/{session-CN4irEqf.d.ts → session-EzQqBeE8.d.ts} +2 -3
- package/dist/{table-names-BIHjuEFK.js → table-names-DUmWROM4.js} +1 -3
- package/dist/testing.js +1 -1
- package/dist/{define-B1jLSPe9.d.ts → types-qzJKgWYS.d.ts} +157 -4
- package/dist/vite.d.ts +2 -19
- package/dist/vite.js +15 -51
- package/package.json +8 -8
- package/dist/database-CPua6Q6_.d.ts +0 -573
- package/dist/overlay/client-CrnKCZXc.js +0 -4
- package/dist/overlay/dist-yIZmvSaU.js +0 -1
- package/dist/page-DE71P_gQ.d.ts +0 -11
- package/dist/request-origin-B-CPVAVk.js +0 -53
- package/dist/service-IvgrI4XM.d.ts +0 -71
- package/dist/types-l6GOb_yc.d.ts +0 -206
|
@@ -52,7 +52,7 @@ const viteHubPageSessionPath = "/_vitehub/page/tools";
|
|
|
52
52
|
* The URL of the loader script, below the app base. Its version query changes when the loader changes, so caches keep
|
|
53
53
|
* it 5 minutes.
|
|
54
54
|
*/
|
|
55
|
-
const viteHubPageToolsLoader = "/_vitehub/page/assets/loader.js?v=
|
|
55
|
+
const viteHubPageToolsLoader = "/_vitehub/page/assets/loader.js?v=28";
|
|
56
56
|
/** The attribute of the script that loads the page tools. A page that has it does not get a second one. */
|
|
57
57
|
const viteHubPageToolsMarker = "data-vitehub-page-tools";
|
|
58
58
|
/** The bootstrap's opening tag, so the server can recognize the generated bootstrap when it replaces it. */
|
|
@@ -93,6 +93,24 @@ function withViteHubBase(base, path) {
|
|
|
93
93
|
function text(value) {
|
|
94
94
|
return typeof value === "string" && value ? value : void 0;
|
|
95
95
|
}
|
|
96
|
+
function readTool(value) {
|
|
97
|
+
if (value === null || typeof value !== "object") return void 0;
|
|
98
|
+
const id = text(Reflect.get(value, "id"));
|
|
99
|
+
const script = text(Reflect.get(value, "script"));
|
|
100
|
+
if (!id || !script) return void 0;
|
|
101
|
+
const tool = {
|
|
102
|
+
id,
|
|
103
|
+
label: text(Reflect.get(value, "label")) ?? id,
|
|
104
|
+
icon: text(Reflect.get(value, "icon")) ?? "",
|
|
105
|
+
script
|
|
106
|
+
};
|
|
107
|
+
if (Reflect.get(value, "lazy") === true) tool.lazy = true;
|
|
108
|
+
const hotkey = text(Reflect.get(value, "hotkey"));
|
|
109
|
+
if (hotkey) tool.hotkey = hotkey;
|
|
110
|
+
const param = text(Reflect.get(value, "param"));
|
|
111
|
+
if (param) tool.param = param;
|
|
112
|
+
return tool;
|
|
113
|
+
}
|
|
96
114
|
/**
|
|
97
115
|
* An account from untrusted input, or `undefined` when it has no name or its `signOut` is not a path of this origin. The
|
|
98
116
|
* browser posts to `signOut` with the session cookie, so it never goes to another site.
|
|
@@ -114,4 +132,24 @@ function readViteHubPageAccount(value) {
|
|
|
114
132
|
if (Reflect.get(value, "guest") === true) account.guest = true;
|
|
115
133
|
return account;
|
|
116
134
|
}
|
|
117
|
-
|
|
135
|
+
/** The tools and the account of a session answer. Entries without an id or a script are skipped. */
|
|
136
|
+
function readViteHubPageSession(value) {
|
|
137
|
+
const tools = value !== null && typeof value === "object" ? Reflect.get(value, "tools") : void 0;
|
|
138
|
+
const session = { tools: Array.isArray(tools) ? tools.map(readTool).filter((tool) => Boolean(tool)) : [] };
|
|
139
|
+
const account = value !== null && typeof value === "object" ? readViteHubPageAccount(Reflect.get(value, "account")) : void 0;
|
|
140
|
+
if (account) session.account = account;
|
|
141
|
+
return session;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* The `Symbol.for()` key of the session that the server hands to the loader in the page. The handoff is an inline script
|
|
145
|
+
* with the page's nonce that sets this global. Markup cannot set a symbol key, so a page's own content cannot forge it.
|
|
146
|
+
*/
|
|
147
|
+
const viteHubPageSessionHandoffKey = "vitehub.page-tools.session";
|
|
148
|
+
function scriptJson(value) {
|
|
149
|
+
return JSON.stringify(value).replaceAll("<", "\\u003c").replaceAll("\u2028", "\\u2028").replaceAll("\u2029", "\\u2029");
|
|
150
|
+
}
|
|
151
|
+
/** The inline script that hands a session to the loader, with the page's nonce when there is one. */
|
|
152
|
+
function viteHubPageSessionHandoffScript(handoff, nonce) {
|
|
153
|
+
return `<script${nonce ? ` nonce="${nonce}"` : ""}>globalThis[Symbol.for(${JSON.stringify(viteHubPageSessionHandoffKey)})]=${scriptJson(handoff)}<\/script>`;
|
|
154
|
+
}
|
|
155
|
+
export { viteHubPageSessionPath as a, viteHubPageToolsHintCookie as c, viteHubPageToolsLoader as d, viteHubPageToolsMarker as f, withViteHubBase as h, viteHubPageSessionHandoffScript as i, viteHubPageToolsInlineScript as l, viteHubPageToolsWanted as m, readViteHubPageSession as n, viteHubPageToolsAssets as o, viteHubPageToolsQuery as p, viteHubBasePath as r, viteHubPageToolsCookie as s, readViteHubPageAccount as t, viteHubPageToolsInlineStart as u };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { a as registerViteHubPageTool, i as installViteHubSiteVisitor, n as resolveCommentsPage, r as installViteHubPageTools, t as resolveCommentsIdentity } from "./session-
|
|
2
|
-
import { r as commentsRoleGrants } from "./define-
|
|
3
|
-
import { t as commentsErrorDiagnostics } from "./errors-
|
|
4
|
-
import { i as installCommentsRuntime } from "./server-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { a as registerViteHubPageTool, i as installViteHubSiteVisitor, n as resolveCommentsPage, r as installViteHubPageTools, t as resolveCommentsIdentity } from "./session-B7GDrqsK.js";
|
|
2
|
+
import { r as commentsRoleGrants } from "./define-C-LUOouq.js";
|
|
3
|
+
import { t as commentsErrorDiagnostics } from "./errors-DeSEHzRf.js";
|
|
4
|
+
import { i as installCommentsRuntime } from "./server-CAMs6viR.js";
|
|
5
|
+
import { r as runtimeBuilds } from "./installed-BqQKo6WC.js";
|
|
6
|
+
import { t as commentsTableNames } from "./table-names-DUmWROM4.js";
|
|
7
7
|
import { installRequestStandardContext } from "@vite-hub/runtime/internal/h3";
|
|
8
8
|
import { configuredPublicOrigins } from "@vite-hub/runtime/internal/public-url";
|
|
9
9
|
// ../internal/src/runtime/user-data.ts
|
|
@@ -38,7 +38,7 @@ function defineCommentsPlugin(options) {
|
|
|
38
38
|
warned = true;
|
|
39
39
|
throw Object.assign(commentsErrorDiagnostics.COMMENTS_R0010(), { status: 503 });
|
|
40
40
|
}
|
|
41
|
-
const { installComments } = await import("./install-
|
|
41
|
+
const { installComments } = await import("./install-BueV_fJY.js").then((n) => n.n);
|
|
42
42
|
return installComments(options.comments, {
|
|
43
43
|
database,
|
|
44
44
|
development: options.development === true,
|
|
@@ -48,7 +48,6 @@ function defineCommentsPlugin(options) {
|
|
|
48
48
|
...options.users ? { users: options.users } : {},
|
|
49
49
|
...options.attachments ? { attachments: options.attachments } : {},
|
|
50
50
|
...options.rateLimit ? { rateLimit: options.rateLimit } : {},
|
|
51
|
-
...options.webhooks ? { webhooks: options.webhooks } : {},
|
|
52
51
|
...options.realtime ? { realtime: options.realtime } : {}
|
|
53
52
|
});
|
|
54
53
|
})().catch((error) => {
|
|
@@ -97,7 +96,8 @@ function defineCommentsPlugin(options) {
|
|
|
97
96
|
});
|
|
98
97
|
installViteHubPageTools(nitroApp, {
|
|
99
98
|
base: options.base,
|
|
100
|
-
origins: options.development === true ? [] : configuredPublicOrigins
|
|
99
|
+
origins: options.development === true ? [] : configuredPublicOrigins,
|
|
100
|
+
sessionHandoff: options.comments.options.pageToolsSessionHandoff === true
|
|
101
101
|
});
|
|
102
102
|
};
|
|
103
103
|
}
|
package/dist/realtime.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { T as CommentThread } from "./types-BX3vH18p.js";
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
4
|
-
import "./
|
|
2
|
+
import { n as commentsChangeNotice } from "./page-BgvzzsJb.js";
|
|
3
|
+
import { t as Comments } from "./index-d6NsDxu9.js";
|
|
4
|
+
import { t as CommentsSessionOptions } from "./session-EzQqBeE8.js";
|
|
5
|
+
import "./types-qzJKgWYS.js";
|
|
5
6
|
import { RealtimeDefinition } from "@vite-hub/realtime";
|
|
6
7
|
/**
|
|
7
8
|
* The Realtime Definition of the page presence rooms: who is on a page and where their cursor is. Rooms hold no
|
|
@@ -13,9 +14,6 @@ export declare function commentsRealtime(comments: Comments, options?: CommentsS
|
|
|
13
14
|
document: false;
|
|
14
15
|
identify: NonNullable<RealtimeDefinition["identify"]>;
|
|
15
16
|
}>;
|
|
16
|
-
/** The notice that tells the open pages of a thread to load their threads again. */
|
|
17
|
-
export declare const commentsChangeNotice: {
|
|
18
|
-
readonly type: "comments";
|
|
19
|
-
};
|
|
20
17
|
/** Tells the browsers on the page of a thread that it changed, so they load their threads again. It never throws. */
|
|
21
|
-
export declare function notifyCommentsChange(thread: Pick<CommentThread, "subject">): Promise<void>;
|
|
18
|
+
export declare function notifyCommentsChange(thread: Pick<CommentThread, "subject">): Promise<void>;
|
|
19
|
+
export { commentsChangeNotice };
|
package/dist/realtime.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as text } from "./identity-CT7-UGmS.js";
|
|
2
|
-
import {
|
|
3
|
-
import { n as resolveCommentsPage, t as resolveCommentsIdentity } from "./session-
|
|
2
|
+
import { i as commentsNoticeDefinition, n as commentRoom, p as normalizeCommentPage, r as commentsChangeNotice, t as commentNoticeRoom } from "./page-CDhmXO-y.js";
|
|
3
|
+
import { n as resolveCommentsPage, t as resolveCommentsIdentity } from "./session-B7GDrqsK.js";
|
|
4
4
|
// src/realtime.ts
|
|
5
5
|
function toRealtimeUser(user) {
|
|
6
6
|
const result = { id: user.id };
|
|
@@ -45,8 +45,6 @@ function commentsRealtime(comments, options = {}, purpose = "presence") {
|
|
|
45
45
|
...purpose === "notices" ? { awareness: false } : {}
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
-
/** The notice that tells the open pages of a thread to load their threads again. */
|
|
49
|
-
const commentsChangeNotice = { type: "comments" };
|
|
50
48
|
/** Tells the browsers on the page of a thread that it changed, so they load their threads again. It never throws. */
|
|
51
49
|
async function notifyCommentsChange(thread) {
|
|
52
50
|
await (await import("@vite-hub/realtime/server").catch(() => void 0))?.notifyRealtimeRoom(commentsNoticeDefinition, commentNoticeRoom(thread.subject), commentsChangeNotice);
|
package/dist/runtime/auth.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { f as CommentsRequestEvent } from "../types-l6GOb_yc.js";
|
|
1
|
+
import { T as CommentsPeople, j as CommentsUser, s as CommentsRequestEvent } from "../types-qzJKgWYS.js";
|
|
3
2
|
/** The ViteHub Auth user of a request, or null. Generated Comments files pass it as `session` when the app has Auth. */
|
|
4
3
|
export declare function commentsAuthSession(event: CommentsRequestEvent): Promise<CommentsUser | null>;
|
|
5
4
|
/** The users of ViteHub Auth, for `@` suggestions. Generated Comments files pass it as `users` when the app has Auth. */
|
package/dist/runtime/auth.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as createAuthUsers } from "../server-
|
|
1
|
+
import { n as createAuthUsers } from "../server-CAMs6viR.js";
|
|
2
2
|
import { getStandardContext } from "@vite-hub/runtime/internal/h3";
|
|
3
3
|
// src/runtime/auth.ts
|
|
4
4
|
const authServer = () => import("@vite-hub/auth/internal/server");
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { t as isRecord } from "../object-CAK6UYR5.js";
|
|
2
|
+
import { n as runWithClientRequest } from "../client-request-B1DCz3a9.js";
|
|
3
|
+
// ../internal/src/runtime/client-request-plugin.ts
|
|
4
|
+
const installed = Symbol.for("vitehub.client-request.installed");
|
|
5
|
+
function isRequest(value) {
|
|
6
|
+
return isRecord(value) && typeof value.url === "string" && value.headers instanceof Headers;
|
|
7
|
+
}
|
|
8
|
+
/** Keeps each request that the Nitro app serves for `clientRequest()`. Auth and Comments each ship it, so it wraps `fetch` once. */
|
|
9
|
+
function clientRequestPlugin(nitroApp) {
|
|
10
|
+
if (!isRecord(nitroApp)) return;
|
|
11
|
+
const h3 = nitroApp.h3;
|
|
12
|
+
const owner = isRecord(h3) && h3.fetch instanceof Function ? h3 : nitroApp;
|
|
13
|
+
const fetch = owner.fetch;
|
|
14
|
+
if (!(fetch instanceof Function) || owner[installed]) return;
|
|
15
|
+
owner[installed] = true;
|
|
16
|
+
owner.fetch = (request, ...rest) => {
|
|
17
|
+
const call = () => Reflect.apply(fetch, owner, [request, ...rest]);
|
|
18
|
+
return isRequest(request) ? runWithClientRequest(request, call) : call();
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export { clientRequestPlugin as default };
|
package/dist/runtime/console.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as describeCommentContext } from "../context-DbkBjITZ.js";
|
|
2
|
-
import {
|
|
3
|
-
import { n as installedComments } from "../plugin-
|
|
2
|
+
import { a as commentsPageScope } from "../page-CDhmXO-y.js";
|
|
3
|
+
import { n as installedComments } from "../plugin-DGUqlc3C.js";
|
|
4
4
|
// src/runtime/console.ts
|
|
5
5
|
function excerpt(text) {
|
|
6
6
|
const line = text.replace(/\s+/g, " ").trim();
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { s as CommentContext } from "../types-BX3vH18p.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { t as
|
|
6
|
-
import {
|
|
7
|
-
import { t as CommentsDatabase } from "../store-DvNTDNgn.js";
|
|
2
|
+
import { t as Comments } from "../index-d6NsDxu9.js";
|
|
3
|
+
import { j as CommentsUser, s as CommentsRequestEvent } from "../types-qzJKgWYS.js";
|
|
4
|
+
import { t as CommentsSessionOptions } from "../session-EzQqBeE8.js";
|
|
5
|
+
import { t as InstallCommentsOptions } from "../install-F-_O7zDr.js";
|
|
6
|
+
import { o as CommentsDatabase } from "../service-CMVA_Ryv.js";
|
|
8
7
|
/**
|
|
9
8
|
* A person that Site access in the ViteHub Console signed in to the app: a Console member, or a guest, with their roles,
|
|
10
9
|
* such as `console` and `comments-write`. The Console signs them in a Site access token, which the app keeps in its
|
|
@@ -162,8 +161,6 @@ interface CommentsPluginOptions extends CommentsSessionOptions {
|
|
|
162
161
|
/** The tables of a Postgres Database. Default: the SQLite tables. */
|
|
163
162
|
tables?: InstallCommentsOptions["tables"];
|
|
164
163
|
dialect?: InstallCommentsOptions["dialect"];
|
|
165
|
-
/** Loads `@vite-hub/webhooks`, when `defineComments({ send })` is on. */
|
|
166
|
-
webhooks?: InstallCommentsOptions["webhooks"];
|
|
167
164
|
/** Loads `@vite-hub/comments/realtime`, when the app has the page presence rooms. */
|
|
168
165
|
realtime?: InstallCommentsOptions["realtime"];
|
|
169
166
|
/** Install more segments of the pill, such as the **Console** segment of `vite-hub`. Only with the overlay on. */
|
package/dist/runtime/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { a as runWithActiveCloudflareEnv, i as getActiveCloudflareBinding, r as rememberGitHubToken, t as forgetGitHubToken } from "../tokens-Bx4lZ0yt.js";
|
|
2
|
-
import {
|
|
2
|
+
import { n as resolveCommentsPage, o as viteHubPageSessionHandler, s as applicationRequestOrigin, t as resolveCommentsIdentity } from "../session-B7GDrqsK.js";
|
|
3
3
|
import "../client-files-lC6X7XyS.js";
|
|
4
|
-
import { t as commentsErrors } from "../errors-
|
|
4
|
+
import { t as commentsErrors } from "../errors-C5utwZ5H.js";
|
|
5
5
|
import { i as text, n as guestFromHeaders, t as authorOf } from "../identity-CT7-UGmS.js";
|
|
6
|
-
import {
|
|
7
|
-
import { a as commentThreadSummary, c as hiddenThreadsNote, n as commentAnchorSchema, o as commentThreadsText, r as commentInputSchemas, s as describeCommentThread, t as commentActions } from "../operations-
|
|
8
|
-
import { c as validateCommentsDefinition, o as deniedForMissingPolicy } from "../define-
|
|
9
|
-
import { h as readAttachment, i as contextSchema, n as base64, o as deniedError, p as mentionedPeople, r as can } from "../service-
|
|
10
|
-
import {
|
|
11
|
-
import { n as
|
|
12
|
-
import { n as installedComments, t as defineCommentsPlugin } from "../plugin-ChOHe7vq.js";
|
|
6
|
+
import { i as runtimeOf, n as resolveCommentsRuntime } from "../installed-BqQKo6WC.js";
|
|
7
|
+
import { a as commentThreadSummary, c as hiddenThreadsNote, n as commentAnchorSchema, o as commentThreadsText, r as commentInputSchemas, s as describeCommentThread, t as commentActions } from "../operations-0llC5kKO.js";
|
|
8
|
+
import { c as validateCommentsDefinition, o as deniedForMissingPolicy } from "../define-C-LUOouq.js";
|
|
9
|
+
import { h as readAttachment, i as contextSchema, n as base64, o as deniedError, p as mentionedPeople, r as can } from "../service-DaMq8TBw.js";
|
|
10
|
+
import { a as commentsPageScope, p as normalizeCommentPage, s as commentsRoute } from "../page-CDhmXO-y.js";
|
|
11
|
+
import { n as installedComments, t as defineCommentsPlugin } from "../plugin-DGUqlc3C.js";
|
|
13
12
|
import { t as invariant } from "../invariant-CmdvZ3vp.js";
|
|
14
|
-
import { t as commentsErrorDiagnostics } from "../errors-
|
|
13
|
+
import { t as commentsErrorDiagnostics } from "../errors-DeSEHzRf.js";
|
|
14
|
+
import { t as clientRequest } from "../client-request-B1DCz3a9.js";
|
|
15
15
|
import { getStandardContext, installRequestStandardContext } from "@vite-hub/runtime/internal/h3";
|
|
16
16
|
import * as v from "valibot";
|
|
17
17
|
import { configuredConsoleOrigin } from "@vite-hub/runtime/internal/console";
|
|
@@ -55,14 +55,8 @@ const fieldBody = v.object({
|
|
|
55
55
|
function status(code) {
|
|
56
56
|
switch (code) {
|
|
57
57
|
case "COMMENTS_NOT_FOUND":
|
|
58
|
-
case "COMMENTS_CONTENT_MISSING":
|
|
59
|
-
case "COMMENTS_SEND_OFF": return 404;
|
|
60
|
-
case "COMMENTS_SEND_GRANT_INVALID": return 401;
|
|
61
|
-
case "COMMENTS_SEND_CODE_EXPIRED": return 410;
|
|
62
|
-
case "COMMENTS_SEND_CODE_USED": return 409;
|
|
63
|
-
case "COMMENTS_SEND_CODE_REFUSED": return 422;
|
|
58
|
+
case "COMMENTS_CONTENT_MISSING": return 404;
|
|
64
59
|
case "COMMENTS_FORBIDDEN":
|
|
65
|
-
case "COMMENTS_SEND_INSECURE":
|
|
66
60
|
case "COMMENTS_POLICY_MISSING":
|
|
67
61
|
case "COMMENTS_FIELD_FORBIDDEN": return 403;
|
|
68
62
|
case "COMMENTS_RESOLVED":
|
|
@@ -282,7 +276,6 @@ function createCommentsHandler(options) {
|
|
|
282
276
|
url: `${route}/auth/github`
|
|
283
277
|
} : void 0;
|
|
284
278
|
const signOut = user && user.github && github ? `${route}/auth/sign-out` : void 0;
|
|
285
|
-
const send = Boolean(comments.options.send && user && !user.guest && comment && await commentSendOf(comments));
|
|
286
279
|
const agent = identity.commentsAgent && read ? {
|
|
287
280
|
...identity.commentsAgent,
|
|
288
281
|
mcp: `${configuredConsoleOrigin()}/mcp/account`
|
|
@@ -303,7 +296,6 @@ function createCommentsHandler(options) {
|
|
|
303
296
|
...options.attachments === false ? { attachments: false } : {},
|
|
304
297
|
...options.presence === false ? { presence: false } : {},
|
|
305
298
|
content: Boolean(options.content),
|
|
306
|
-
...send ? { send: true } : {},
|
|
307
299
|
...agent ? { agent } : {},
|
|
308
300
|
...repository ? { repository } : {},
|
|
309
301
|
...subject ? { subject } : {},
|
|
@@ -501,77 +493,6 @@ function createCommentsHandler(options) {
|
|
|
501
493
|
const env = request["~standard"].runtime?.cloudflare?.env;
|
|
502
494
|
return env ? await runWithActiveCloudflareEnv(env, () => handle(request)) : await handle(request);
|
|
503
495
|
} };
|
|
504
|
-
async function sendRoute(request, url, parts, pageOf) {
|
|
505
|
-
const service = await commentSendOf(comments);
|
|
506
|
-
if (!service) return failure$1(commentsErrors.COMMENTS_SEND_OFF());
|
|
507
|
-
const method = request.method;
|
|
508
|
-
const [, action, code] = parts;
|
|
509
|
-
if (method === "POST" && action === "pair" && !code) {
|
|
510
|
-
const [error, paired] = await service.pair(await readJson(request), applicationRequestOrigin(request));
|
|
511
|
-
return error ? json({
|
|
512
|
-
error,
|
|
513
|
-
reason: {
|
|
514
|
-
COMMENTS_SEND_CODE_EXPIRED: "expired",
|
|
515
|
-
COMMENTS_SEND_CODE_USED: "used",
|
|
516
|
-
COMMENTS_SEND_CODE_REFUSED: "refused",
|
|
517
|
-
COMMENTS_SEND_INSECURE: "insecure"
|
|
518
|
-
}[error.code] ?? "invalid"
|
|
519
|
-
}, { status: status(error.code) }) : json({ data: paired });
|
|
520
|
-
}
|
|
521
|
-
if (method === "GET" && action && action.startsWith("send_") && !code) {
|
|
522
|
-
const token = /^Bearer\s+(\S+)$/i.exec(request.headers.get("authorization") ?? "")?.[1];
|
|
523
|
-
if (!token) return failure$1(commentsErrors.COMMENTS_SEND_GRANT_INVALID());
|
|
524
|
-
return respond(await service.read(decodeURIComponent(action), token));
|
|
525
|
-
}
|
|
526
|
-
const { user, gate } = await identityOf(request);
|
|
527
|
-
const pathname = url.pathname;
|
|
528
|
-
const caller = async () => {
|
|
529
|
-
const subject = (await pageOf())?.subject;
|
|
530
|
-
if (!subject) return void 0;
|
|
531
|
-
return {
|
|
532
|
-
user,
|
|
533
|
-
gate,
|
|
534
|
-
subject,
|
|
535
|
-
page: normalizeCommentPage(url.searchParams.get("page") ?? "/"),
|
|
536
|
-
origin: applicationRequestOrigin(request),
|
|
537
|
-
route: pathname.slice(0, pathname.indexOf(commentsRoute) + commentsRoute.length)
|
|
538
|
-
};
|
|
539
|
-
};
|
|
540
|
-
if (action === "pair" && code && !parts[3]) {
|
|
541
|
-
const who = {
|
|
542
|
-
user,
|
|
543
|
-
gate,
|
|
544
|
-
subject: {
|
|
545
|
-
kind: "page",
|
|
546
|
-
id: "/"
|
|
547
|
-
},
|
|
548
|
-
page: "/",
|
|
549
|
-
origin: "",
|
|
550
|
-
route: ""
|
|
551
|
-
};
|
|
552
|
-
if (method === "GET") return json({ data: await service.check(who, decodeURIComponent(code)) });
|
|
553
|
-
if (method === "DELETE") {
|
|
554
|
-
await service.cancel(who, decodeURIComponent(code));
|
|
555
|
-
return json({ data: null });
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
const who = await caller();
|
|
559
|
-
if (!who) return failure$1(commentsErrors.COMMENTS_INVALID_INPUT({ issue: "page: Give the page that Send is on." }));
|
|
560
|
-
if (method === "GET" && action === "status" && !code) return json({ data: await service.status(who) });
|
|
561
|
-
if (method === "POST" && action === "start" && !code) return respond(await service.start(who));
|
|
562
|
-
if (method === "POST" && action === "allow" && !code) {
|
|
563
|
-
const body = await readJson(request);
|
|
564
|
-
const given = typeof body === "object" && body !== null ? Reflect.get(body, "code") : void 0;
|
|
565
|
-
if (typeof given !== "string" || !given) return failure$1(commentsErrors.COMMENTS_INVALID_INPUT({ issue: "code: Send the setup code that the agent used." }));
|
|
566
|
-
const selection = typeof body === "object" && body !== null ? Reflect.get(body, "selection") : void 0;
|
|
567
|
-
return respond(await service.allow(who, given, typeof selection === "string" ? selection : ""));
|
|
568
|
-
}
|
|
569
|
-
if (method === "POST" && !action) return respond(await service.send(who));
|
|
570
|
-
return json({ error: {
|
|
571
|
-
code: "COMMENTS_NOT_FOUND",
|
|
572
|
-
why: `No Comments route ${method} ${url.pathname.slice(url.pathname.indexOf(commentsRoute) + commentsRoute.length)}.`
|
|
573
|
-
} }, { status: 404 });
|
|
574
|
-
}
|
|
575
496
|
async function route(request) {
|
|
576
497
|
const url = new URL(request.url);
|
|
577
498
|
const path = url.pathname.slice(url.pathname.indexOf("/_vitehub/comments") + 18).replace(/\/+$/, "") || "/";
|
|
@@ -585,11 +506,10 @@ function createCommentsHandler(options) {
|
|
|
585
506
|
id: subjectId
|
|
586
507
|
} } : void 0;
|
|
587
508
|
const subjectOf = async () => (await pageOf())?.subject;
|
|
588
|
-
if (method !== "GET" && !
|
|
509
|
+
if (method !== "GET" && !sameOrigin(request)) return json({ error: {
|
|
589
510
|
code: "COMMENTS_FORBIDDEN",
|
|
590
511
|
why: "Comments requests must come from the site's own pages."
|
|
591
512
|
} }, { status: 403 });
|
|
592
|
-
if (parts[0] === "send") return await sendRoute(request, url, parts, pageOf);
|
|
593
513
|
if (method === "GET" && path === "/session") {
|
|
594
514
|
const current = await pageOf();
|
|
595
515
|
return await session(request, current?.subject, current?.revision);
|
|
@@ -852,7 +772,12 @@ function commentsMcpTools(comments, options = {}) {
|
|
|
852
772
|
})
|
|
853
773
|
};
|
|
854
774
|
}
|
|
855
|
-
|
|
775
|
+
async function finishWrite(context) {
|
|
776
|
+
const standard = context.event?.["~standard"];
|
|
777
|
+
if (standard?.waitUntil) standard.waitUntil(comments.flush());
|
|
778
|
+
else await comments.flush();
|
|
779
|
+
}
|
|
780
|
+
return [
|
|
856
781
|
{
|
|
857
782
|
name: "comments_list_threads",
|
|
858
783
|
title: "List ViteHub Comments threads",
|
|
@@ -990,11 +915,7 @@ function commentsMcpTools(comments, options = {}) {
|
|
|
990
915
|
body: {
|
|
991
916
|
type: "string",
|
|
992
917
|
description: "Markdown, at most 10,000 characters."
|
|
993
|
-
}
|
|
994
|
-
...comments.options.send ? { send: {
|
|
995
|
-
type: "string",
|
|
996
|
-
description: "The send ID from comments_get_send when answering an ask."
|
|
997
|
-
} } : {}
|
|
918
|
+
}
|
|
998
919
|
},
|
|
999
920
|
required: ["id", "body"],
|
|
1000
921
|
additionalProperties: false
|
|
@@ -1006,26 +927,13 @@ function commentsMcpTools(comments, options = {}) {
|
|
|
1006
927
|
const { thread, grant } = found;
|
|
1007
928
|
const author = identity.user ? authorOf(identity.user) : guestFor(context);
|
|
1008
929
|
if (!author) return forbidden("write");
|
|
1009
|
-
const send = text(input.send);
|
|
1010
|
-
if (send) {
|
|
1011
|
-
const service = await commentSendOf(comments);
|
|
1012
|
-
const opened = identity.user && !identity.user.guest && await service?.readOwn(identity.user, send, {
|
|
1013
|
-
gate: identity.gate,
|
|
1014
|
-
console: admitted
|
|
1015
|
-
});
|
|
1016
|
-
if (!opened || !opened.threads.some((entry) => entry.id === thread.id && entry.role === "ask")) return forbidden("write");
|
|
1017
|
-
}
|
|
1018
930
|
spend(grant, "write", thread.id);
|
|
1019
931
|
const [error, message] = await comments.reply(thread.id, {
|
|
1020
932
|
body: text(input.body) ?? "",
|
|
1021
|
-
author
|
|
1022
|
-
...send ? { actor: {
|
|
1023
|
-
id: "comments-mcp",
|
|
1024
|
-
name: "Comments agent"
|
|
1025
|
-
} } : {}
|
|
933
|
+
author
|
|
1026
934
|
});
|
|
1027
935
|
if (error) return failure(error.why);
|
|
1028
|
-
await
|
|
936
|
+
await finishWrite(context);
|
|
1029
937
|
return {
|
|
1030
938
|
text: `Replied to thread ${thread.id}.`,
|
|
1031
939
|
structured: { message: { ...message } }
|
|
@@ -1064,7 +972,7 @@ function commentsMcpTools(comments, options = {}) {
|
|
|
1064
972
|
};
|
|
1065
973
|
const [error, updated] = input.resolved === false ? await comments.reopen(thread.id) : await comments.resolve(thread.id, { by: author });
|
|
1066
974
|
if (error) return failure(error.why);
|
|
1067
|
-
await
|
|
975
|
+
await finishWrite(context);
|
|
1068
976
|
return {
|
|
1069
977
|
text: `Thread ${updated.id} is ${updated.status}.`,
|
|
1070
978
|
structured: { thread: { ...commentThreadSummary(updated) } }
|
|
@@ -1072,42 +980,6 @@ function commentsMcpTools(comments, options = {}) {
|
|
|
1072
980
|
}
|
|
1073
981
|
}
|
|
1074
982
|
];
|
|
1075
|
-
if (comments.options.send) tools.push({
|
|
1076
|
-
name: "comments_get_send",
|
|
1077
|
-
title: "Read a ViteHub Comments send",
|
|
1078
|
-
description: "ViteHub Comments: read the threads that the signed-in user sent to their agent with Send in the comment pill. Each thread says whether it is an ask, the user's own question, or a quote, what someone else said. Without an id, it reads the user's latest send that no agent read yet. Answer each ask with comments_reply, passing the send ID as `send`.",
|
|
1079
|
-
section: "comments",
|
|
1080
|
-
annotations: { readOnlyHint: true },
|
|
1081
|
-
inputSchema: {
|
|
1082
|
-
type: "object",
|
|
1083
|
-
properties: { id: {
|
|
1084
|
-
type: "string",
|
|
1085
|
-
description: "The send id, such as send_… from the delivery. Default: the latest unread send."
|
|
1086
|
-
} },
|
|
1087
|
-
additionalProperties: false
|
|
1088
|
-
},
|
|
1089
|
-
async call(input, context) {
|
|
1090
|
-
const { user, gate } = await identityFor(context);
|
|
1091
|
-
if (!user || user.guest) return forbidden("read");
|
|
1092
|
-
const service = await commentSendOf(comments);
|
|
1093
|
-
if (!service) return failure(`${commentsErrors.COMMENTS_SEND_OFF().why} ${commentsErrors.COMMENTS_SEND_OFF().fix}`);
|
|
1094
|
-
const id = text(input.id);
|
|
1095
|
-
const opened = await service.readOwn(user, id, {
|
|
1096
|
-
gate,
|
|
1097
|
-
console: admitted
|
|
1098
|
-
});
|
|
1099
|
-
if (!opened) return failure(id ? `No send ${id} of this user.` : "This user has no send that an agent did not read yet.");
|
|
1100
|
-
const { send, threads } = opened;
|
|
1101
|
-
return {
|
|
1102
|
-
text: [`Send ${send.id} from ${send.page}, ${new Date(send.createdAt).toISOString()}: ${threads.length} ${threads.length === 1 ? "thread" : "threads"}.`, ...threads.flatMap((thread) => ["", `${thread.role === "ask" ? "Ask" : "Quote"}: ${describeCommentThread(thread)}`])].join("\n"),
|
|
1103
|
-
structured: {
|
|
1104
|
-
send: { ...send },
|
|
1105
|
-
threads: threads.map((thread) => ({ ...thread }))
|
|
1106
|
-
}
|
|
1107
|
-
};
|
|
1108
|
-
}
|
|
1109
|
-
});
|
|
1110
|
-
return tools;
|
|
1111
983
|
}
|
|
1112
984
|
// ../internal/src/runtime/mcp-server.ts
|
|
1113
985
|
/** The MCP result of a `ViteHubMcpTool` call: a text block, then one image block for each image. */
|
|
@@ -1184,7 +1056,7 @@ function createCommentsGitHubLogin(options = {}) {
|
|
|
1184
1056
|
const clientId = serverEnv(githubLoginEnv.clientId);
|
|
1185
1057
|
const clientSecret = serverEnv(githubLoginEnv.clientSecret);
|
|
1186
1058
|
const secret = sessionSecret();
|
|
1187
|
-
const origin = applicationRequestOrigin(request);
|
|
1059
|
+
const origin = applicationRequestOrigin(clientRequest(request));
|
|
1188
1060
|
const key = [
|
|
1189
1061
|
origin,
|
|
1190
1062
|
clientId,
|
package/dist/server.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as maximumCommentBodyLength, i as CommentsRuntime, n as CommentsAttachmentStore, r as CommentsForgeHooks } from "./service-
|
|
3
|
-
import {
|
|
4
|
-
import { a as
|
|
1
|
+
import { F as validateCommentsDefinition, T as CommentsPeople } from "./types-qzJKgWYS.js";
|
|
2
|
+
import { a as maximumCommentBodyLength, c as CommentsTables, i as CommentsRuntime, l as createCommentsStore, n as CommentsAttachmentStore, o as CommentsDatabase, r as CommentsForgeHooks, s as CommentsStore } from "./service-CMVA_Ryv.js";
|
|
3
|
+
import { D as CommentUser } from "./types-BX3vH18p.js";
|
|
4
|
+
import { a as commentInputSchemas, i as commentAnchorSchema, n as CommentsCaller, o as commentsOperations, r as commentActions, t as CommentThreadsPage } from "./operations-jaihyWw2.js";
|
|
5
5
|
import { n as createRpcTransport, t as RpcTransportOptions } from "./rpc-D-eqtyfh.js";
|
|
6
|
-
import { n as installComments, t as InstallCommentsOptions } from "./install-
|
|
6
|
+
import { n as installComments, t as InstallCommentsOptions } from "./install-F-_O7zDr.js";
|
|
7
|
+
import { a as hostedCommentsEndedNotice, i as hostedCommentsChangeNotice, o as hostedCommentsNoticeDefinition, r as hostedCommentNoticeRoom } from "./page-BgvzzsJb.js";
|
|
7
8
|
/** Where mentions find people. The same shape as `defineComments({ people })`. */
|
|
8
9
|
export type CommentsUsers = CommentsPeople;
|
|
9
10
|
/**
|
|
@@ -15,5 +16,8 @@ export declare function installCommentsRuntime(runtime: CommentsRuntime | (() =>
|
|
|
15
16
|
export declare function commentsRuntime(): Promise<CommentsRuntime>;
|
|
16
17
|
export declare function hasCommentsRuntime(): boolean;
|
|
17
18
|
/** People from a Better Auth instance, through its internal adapter. The generated Nitro plugin passes it when the app has Auth. */
|
|
18
|
-
export declare function createAuthUsers(getAuth: () => object | Promise<object>):
|
|
19
|
-
|
|
19
|
+
export declare function createAuthUsers(getAuth: () => object | Promise<object>): {
|
|
20
|
+
byIds(ids: readonly string[]): Promise<CommentUser[]>;
|
|
21
|
+
search(query: string, limit: number): Promise<CommentUser[]>;
|
|
22
|
+
};
|
|
23
|
+
export { CommentThreadsPage, type CommentsAttachmentStore, CommentsCaller, type CommentsDatabase, type CommentsForgeHooks, type CommentsRuntime, type CommentsStore, type CommentsTables, type InstallCommentsOptions, RpcTransportOptions, commentActions, commentAnchorSchema, commentInputSchemas, commentsOperations, createCommentsStore, createRpcTransport, hostedCommentNoticeRoom, hostedCommentsChangeNotice, hostedCommentsEndedNotice, hostedCommentsNoticeDefinition, installComments, maximumCommentBodyLength, validateCommentsDefinition };
|
package/dist/server.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { i as installCommentsRuntime, n as createAuthUsers, r as hasCommentsRuntime, t as commentsRuntime } from "./server-
|
|
2
|
-
import { i as commentsOperations, n as commentAnchorSchema, r as commentInputSchemas, t as commentActions } from "./operations-
|
|
1
|
+
import { i as installCommentsRuntime, n as createAuthUsers, r as hasCommentsRuntime, t as commentsRuntime } from "./server-CAMs6viR.js";
|
|
2
|
+
import { i as commentsOperations, n as commentAnchorSchema, r as commentInputSchemas, t as commentActions } from "./operations-0llC5kKO.js";
|
|
3
3
|
import { t as createRpcTransport } from "./rpc-kkxzQ3Qy.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { c as validateCommentsDefinition } from "./define-
|
|
7
|
-
|
|
4
|
+
import { r as createCommentsStore, t as installComments } from "./install-BueV_fJY.js";
|
|
5
|
+
import { f as maximumCommentBodyLength } from "./service-DaMq8TBw.js";
|
|
6
|
+
import { c as validateCommentsDefinition } from "./define-C-LUOouq.js";
|
|
7
|
+
import { c as hostedCommentNoticeRoom, d as hostedCommentsNoticeDefinition, l as hostedCommentsChangeNotice, u as hostedCommentsEndedNotice } from "./page-CDhmXO-y.js";
|
|
8
|
+
export { commentActions, commentAnchorSchema, commentInputSchemas, commentsOperations, commentsRuntime, createAuthUsers, createCommentsStore, createRpcTransport, hasCommentsRuntime, hostedCommentNoticeRoom, hostedCommentsChangeNotice, hostedCommentsEndedNotice, hostedCommentsNoticeDefinition, installComments, installCommentsRuntime, maximumCommentBodyLength, validateCommentsDefinition };
|
|
@@ -1,6 +1,19 @@
|
|
|
1
|
+
import { C as CommentsDefinition, T as CommentsPeople, j as CommentsUser } from "./types-qzJKgWYS.js";
|
|
1
2
|
import { a as commentThreads, i as commentMessages, n as commentCounters } from "./database-DUs3c2al.js";
|
|
2
3
|
import { D as CommentUser, S as CommentStatus, T as CommentThread, b as CommentMetadata, n as CommentActor, r as CommentAnchor, s as CommentContext, v as CommentListQuery, w as CommentSubject } from "./types-BX3vH18p.js";
|
|
4
|
+
import "valibot";
|
|
3
5
|
import { LibSQLDatabase } from "drizzle-orm/libsql";
|
|
6
|
+
/** The part of `checkRateLimit()` from `vite-hub/rate-limit` that a public write calls. */
|
|
7
|
+
type SharedRateLimit = (request: Request, name: string, options: {
|
|
8
|
+
key: string;
|
|
9
|
+
limit: number;
|
|
10
|
+
window: `${number}${"ms" | "s" | "m" | "h" | "d"}`;
|
|
11
|
+
}) => Promise<[unknown, {
|
|
12
|
+
allowed: boolean;
|
|
13
|
+
reason?: string;
|
|
14
|
+
retryAfter?: number;
|
|
15
|
+
cause?: unknown;
|
|
16
|
+
} | undefined]>;
|
|
4
17
|
/**
|
|
5
18
|
* The Drizzle database that the store uses. The store calls `select`, `insert`, `update`, and `delete` (with
|
|
6
19
|
* `onConflictDoNothing()` and `returning()`), which SQLite, libSQL, D1, and Postgres Drizzle databases all offer, and
|
|
@@ -92,4 +105,57 @@ interface CommentsStore {
|
|
|
92
105
|
knownUsersByIds: (ids: readonly string[], canRead: (thread: CommentThread) => Promise<boolean>) => Promise<CommentUser[]>;
|
|
93
106
|
}
|
|
94
107
|
declare function createCommentsStore(database: CommentsDatabase, tables?: CommentsTables): CommentsStore;
|
|
95
|
-
|
|
108
|
+
/** Longest message, in characters. */
|
|
109
|
+
declare const maximumCommentBodyLength = 10000;
|
|
110
|
+
/** The parts of a Blob store that attachments use: `blob` of `@vite-hub/blob`. */
|
|
111
|
+
interface CommentsAttachmentStore {
|
|
112
|
+
put: (pathname: string, body: Uint8Array, options: {
|
|
113
|
+
contentType: string;
|
|
114
|
+
}) => Promise<readonly [unknown, unknown]>;
|
|
115
|
+
get?: (pathname: string) => Promise<readonly [unknown, Blob | null | undefined]>;
|
|
116
|
+
}
|
|
117
|
+
/** A file to answer, with the headers that keep a browser from running it. */
|
|
118
|
+
interface CommentsAttachmentBody {
|
|
119
|
+
key: string;
|
|
120
|
+
name: string;
|
|
121
|
+
/** The stored media type when Comments attaches that type, else `application/octet-stream`. */
|
|
122
|
+
type: string;
|
|
123
|
+
size: number;
|
|
124
|
+
/** Whether a browser may show it in the page: images other than SVG. */
|
|
125
|
+
inline: boolean;
|
|
126
|
+
data: Blob;
|
|
127
|
+
}
|
|
128
|
+
/** The pull request sync of `defineComments({ forge })`. */
|
|
129
|
+
interface CommentsForgeHooks {
|
|
130
|
+
/** Starts the sync of a thread after a change. */
|
|
131
|
+
changed: (threadId: string) => void;
|
|
132
|
+
/** The threads with their `forge` link. */
|
|
133
|
+
attach: (threads: CommentThread[]) => Promise<CommentThread[]>;
|
|
134
|
+
}
|
|
135
|
+
/** Everything that the comment operations, the server API, and the overlay API share. */
|
|
136
|
+
interface CommentsRuntime {
|
|
137
|
+
definition: CommentsDefinition;
|
|
138
|
+
/**
|
|
139
|
+
* The app's `identify`, given the server event of a call. With it, the comment operations ask it for the user, as
|
|
140
|
+
* the overlay API does, instead of taking the Console's user.
|
|
141
|
+
*/
|
|
142
|
+
identify?: (event: unknown) => Promise<CommentsUser | null>;
|
|
143
|
+
store: CommentsStore;
|
|
144
|
+
/** The Auth adapter. `people` wins over it. Without both, `@` finds the authors that the store knows. */
|
|
145
|
+
users?: CommentsPeople;
|
|
146
|
+
/** Vite's serve command, for the default guest policy. */
|
|
147
|
+
development?: boolean;
|
|
148
|
+
/** The Blob store for attachments, when the app has one and no `storeAttachment`. */
|
|
149
|
+
attachments?: CommentsAttachmentStore;
|
|
150
|
+
forge?: CommentsForgeHooks;
|
|
151
|
+
/**
|
|
152
|
+
* `checkRateLimit` of ViteHub Rate Limit, when it counts in a KV store that every server process shares. Guest writes
|
|
153
|
+
* then count under the Rate Limit name `comments`. Without it, they count in the memory of this process.
|
|
154
|
+
*/
|
|
155
|
+
rateLimit?: SharedRateLimit;
|
|
156
|
+
/** Work that runs after the answer, such as `onMention`. `flush()` of the server API waits for it. */
|
|
157
|
+
background?: (task: Promise<unknown>) => void;
|
|
158
|
+
/** Tells the open pages of a thread that it changed, such as through a Realtime notice to its page room. */
|
|
159
|
+
changed?: (thread: CommentThread) => Promise<void>;
|
|
160
|
+
}
|
|
161
|
+
export { maximumCommentBodyLength as a, CommentsTables as c, CommentsRuntime as i, createCommentsStore as l, CommentsAttachmentStore as n, CommentsDatabase as o, CommentsForgeHooks as r, CommentsStore as s, CommentsAttachmentBody as t, SharedRateLimit as u };
|