@vite-hub/comments 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +79 -31
- package/dist/anchor.d.ts +7 -4
- package/dist/anchor.js +10 -5
- package/dist/client-diagnostics-CcFpkbAk.js +40 -0
- package/dist/client.d.ts +78 -3
- package/dist/client.js +198 -13
- package/dist/{console-BIz9t2cO.d.ts → console-h4KlhIik.d.ts} +97 -8
- package/dist/context-BqIsmYP1.js +61 -0
- package/dist/database/postgres.d.ts +738 -347
- package/dist/database/postgres.js +28 -7
- package/dist/{database-Cb2xjC1V.d.ts → database-CA1aHKN7.d.ts} +675 -276
- package/dist/database.d.ts +6 -98
- package/dist/database.js +2 -3
- package/dist/define-43mMR39K.js +89 -0
- package/dist/define-B3TF9zzn.d.ts +204 -0
- package/dist/errors-4gelGVmK.js +57 -0
- package/dist/errors-C6qptPoG.js +135 -0
- package/dist/errors-CyQyKAvy.d.ts +185 -0
- package/dist/fold-name-B7Zb3-MF.js +7 -0
- package/dist/{identity-3qtVC4rF.js → identity-CBOzgxSf.js} +7 -2
- package/dist/index-DNhy69Wt.d.ts +83 -0
- package/dist/index.d.ts +7 -7
- package/dist/index.js +196 -5
- package/dist/install-BcMPgPk_.js +1154 -0
- package/dist/install-W9ghhGoh.d.ts +36 -0
- package/dist/installed-B-PfERBU.js +30 -0
- package/dist/invariant-D8_xBqmZ.js +22 -0
- package/dist/migrate-B0k_0swk.d.ts +54 -0
- package/dist/migrate-BDQ8xqUs.js +289 -0
- package/dist/object-Da1zyPCR.js +11 -0
- package/dist/{operations-0B0QTVWX.d.ts → operations-D4A1Fcgf.d.ts} +37 -15
- package/dist/operations-DMMIfYPW.js +1159 -0
- package/dist/operations-GLeOqgMt.d.ts +257 -0
- package/dist/operations.d.ts +3 -7
- package/dist/operations.js +3 -2
- package/dist/overlay/client-DmsSMOzi.js +4 -0
- package/dist/overlay/dist-BoHMOFax.js +14 -0
- package/dist/overlay/dist-yIZmvSaU.js +1 -0
- package/dist/overlay/overlay.js +183 -177
- package/dist/page/loader.js +138 -18
- package/dist/{page-BuroSMXO.js → page-B41ozN63.js} +8 -6
- package/dist/{page-BtXADR6d.d.ts → page-DtbMOEMd.d.ts} +6 -5
- package/dist/page-tools-shared-NHUjKI8E.js +117 -0
- package/dist/path--zk6PEMz.js +18 -0
- package/dist/plugin-PS8PMYus.js +74 -0
- package/dist/realtime.d.ts +6 -12
- package/dist/realtime.js +23 -24
- package/dist/rpc-HBcWtg0T.d.ts +17 -0
- package/dist/rpc-RKPAusHp.js +153 -0
- package/dist/rpc.d.ts +2 -29
- package/dist/rpc.js +2 -75
- package/dist/runtime/auth.d.ts +5 -3
- package/dist/runtime/auth.js +8 -5
- package/dist/runtime/console.d.ts +1 -1
- package/dist/runtime/console.js +26 -21
- package/dist/runtime/index.d.ts +108 -60
- package/dist/runtime/index.js +684 -236
- package/dist/{server-BomGg3Gb.js → server-D8k-0GXe.js} +16 -7
- package/dist/server.d.ts +14 -88
- package/dist/server.js +7 -326
- package/dist/service-CFVm23k7.d.ts +158 -0
- package/dist/service-GHhhyQj4.js +609 -0
- package/dist/session-DVx-1Tym.d.ts +14 -0
- package/dist/session-EkudzUmm.js +503 -0
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +14 -2
- package/dist/tokens-DSbwkVSy.js +58 -0
- package/dist/types-BIS0hCEl.d.ts +124 -0
- package/dist/types-CZujrMFd.d.ts +322 -0
- package/dist/vite.d.ts +91 -87
- package/dist/vite.js +535 -796
- package/package.json +24 -27
- package/dist/database-BSnVrwHn.js +0 -60
- package/dist/database-C-ktS9Do.js +0 -95
- package/dist/define-BzW2Ychn.d.ts +0 -46
- package/dist/define-Cbhl6QVJ.js +0 -32
- package/dist/errors-BAQYcy3_.d.ts +0 -89
- package/dist/errors-DeD6wTCl.js +0 -77
- package/dist/h3-v1-request-DDGXJ9E7.js +0 -166
- package/dist/index-DklG2Etf.d.ts +0 -111
- package/dist/operations-NZG5dB8y.js +0 -732
- package/dist/page-tools-shared-D-amu6sx.js +0 -53
- package/dist/plugin-QElKQYkA.js +0 -725
- package/dist/request-DVc3M_AG.js +0 -14
- package/dist/src-CRTwnaEG.js +0 -1362
- package/dist/types-Cj8K7Vx7.d.ts +0 -176
- package/dist/types-Un2dcJWD.d.ts +0 -288
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { s as CommentContext } from "../types-CZujrMFd.js";
|
|
2
|
+
import { g as CommentsUser } from "../define-B3TF9zzn.js";
|
|
3
|
+
import { s as CommentsRequestEvent } from "../types-BIS0hCEl.js";
|
|
4
|
+
import { t as Comments } from "../index-DNhy69Wt.js";
|
|
5
|
+
import { o as CommentsDatabase } from "../service-CFVm23k7.js";
|
|
6
|
+
import { t as CommentsSessionOptions } from "../session-DVx-1Tym.js";
|
|
7
|
+
import { t as InstallCommentsOptions } from "../install-W9ghhGoh.js";
|
|
4
8
|
//#region src/runtime/github-login.d.ts
|
|
5
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. */
|
|
6
10
|
export declare const githubLoginEnv: {
|
|
@@ -11,9 +15,9 @@ interface CommentsGitHubLogin {
|
|
|
11
15
|
/** Whether the server has the OAuth client, so the overlay offers **Sign in with GitHub**. */
|
|
12
16
|
configured(): boolean;
|
|
13
17
|
/** The person signed in with GitHub, with what they may do in the repository. Null without a session. */
|
|
14
|
-
user(event:
|
|
18
|
+
user(event: CommentsRequestEvent): Promise<CommentsUser | null>;
|
|
15
19
|
/** The sign-in, callback, and sign-out routes under `/api/_vitehub/comments/auth/`. */
|
|
16
|
-
handle(
|
|
20
|
+
handle(request: Request & CommentsRequestEvent, path: string): Promise<Response>;
|
|
17
21
|
}
|
|
18
22
|
/**
|
|
19
23
|
* Sign in with GitHub for Comments, with no database: ViteHub Auth's `stateless()` preset keeps the session, and the
|
|
@@ -27,17 +31,6 @@ export declare function createCommentsGitHubLogin(options?: {
|
|
|
27
31
|
basePath?: string;
|
|
28
32
|
}): CommentsGitHubLogin;
|
|
29
33
|
//#endregion
|
|
30
|
-
//#region src/runtime/session.d.ts
|
|
31
|
-
interface CommentsSessionOptions {
|
|
32
|
-
/** Reads the ViteHub Auth user only when no custom `identify` is configured. */
|
|
33
|
-
session?: (event: H3Event) => Promise<CommentsUser | null | undefined>;
|
|
34
|
-
/**
|
|
35
|
-
* Checks Console section access for the action before custom `identify` or Comments policies. `false` or a failed
|
|
36
|
-
* check denies access; otherwise this is the user when no custom `identify` is configured.
|
|
37
|
-
*/
|
|
38
|
-
consoleSession?: (event: H3Event, action?: CommentsAction) => Promise<CommentsUser | null | undefined | false>;
|
|
39
|
-
}
|
|
40
|
-
//#endregion
|
|
41
34
|
//#region src/runtime/handler.d.ts
|
|
42
35
|
/** One field address, as `parseContentField()` from `@vite-hub/content/client` reads it. */
|
|
43
36
|
interface CommentsContentField {
|
|
@@ -92,6 +85,8 @@ interface CommentsHandlerOptions extends CommentsSessionOptions {
|
|
|
92
85
|
};
|
|
93
86
|
/** Whether the page presence rooms run, because the host has a Realtime authority. */
|
|
94
87
|
realtime: boolean;
|
|
88
|
+
/** `false` hides the overlay's faces and cursors, for an app that shows its own presence. Threads still update live. */
|
|
89
|
+
presence?: false;
|
|
95
90
|
/** The commit and branch of this build. New threads keep them in `context.build`. */
|
|
96
91
|
build?: NonNullable<CommentContext["build"]>;
|
|
97
92
|
/**
|
|
@@ -101,29 +96,43 @@ interface CommentsHandlerOptions extends CommentsSessionOptions {
|
|
|
101
96
|
components?: Readonly<Record<string, readonly string[]>>;
|
|
102
97
|
}
|
|
103
98
|
/**
|
|
104
|
-
* The Comments API at `/api/_vitehub/comments
|
|
105
|
-
* `
|
|
99
|
+
* The Comments API at `/api/_vitehub/comments/**`, as a Fetchable: mount it as a Nitro or H3 route, or call
|
|
100
|
+
* `fetch(request)`. The overlay calls it; every route checks the `authorize` policy of `defineComments()` for the user of
|
|
101
|
+
* the request, and inline edits also check `content.can()`.
|
|
106
102
|
*/
|
|
107
|
-
export declare function createCommentsHandler(options: CommentsHandlerOptions):
|
|
103
|
+
export declare function createCommentsHandler(options: CommentsHandlerOptions): {
|
|
104
|
+
fetch(request: Request): Promise<Response>;
|
|
105
|
+
};
|
|
108
106
|
//#endregion
|
|
109
107
|
//#region src/runtime/plugin.d.ts
|
|
110
108
|
interface CommentsPluginOptions extends CommentsSessionOptions {
|
|
111
109
|
comments: Comments;
|
|
112
110
|
/** Offers GitHub sign-in or account switching through the overlay, even before read access is granted. */
|
|
113
111
|
githubLogin?: CommentsGitHubLogin;
|
|
114
|
-
/** The Database of `defineComments({ database })`, or undefined when the app has none. */
|
|
115
|
-
database: () => CommentsDatabase | undefined
|
|
112
|
+
/** The Database of `defineComments({ database })`, or undefined when the app has none. The first Comments call reads it. */
|
|
113
|
+
database: () => CommentsDatabase | undefined | Promise<CommentsDatabase | undefined>;
|
|
116
114
|
/**
|
|
117
115
|
* Path of the overlay script below the app base, such as `/api/_vitehub/comments/assets/overlay.js`. The page tools
|
|
118
116
|
* loader imports it for people that may read comments.
|
|
119
117
|
*/
|
|
120
|
-
overlay: string;
|
|
118
|
+
overlay: string | false;
|
|
121
119
|
/** The app base, such as `/portal/`. The page tools use it for the loader tag of Nitro 3 pages. Default: the root. */
|
|
122
120
|
base?: string;
|
|
123
121
|
/** Vite's serve/build identity, recorded by the generated plugin. Defaults to false. */
|
|
124
122
|
development?: boolean;
|
|
125
123
|
/** What the server log says when `database()` returns nothing. */
|
|
126
124
|
missingDatabase?: string;
|
|
125
|
+
/** The Auth users for `@` suggestions, when the app has Auth. */
|
|
126
|
+
users?: InstallCommentsOptions["users"];
|
|
127
|
+
/** The Blob store for attachments, when the app has Blob. */
|
|
128
|
+
attachments?: InstallCommentsOptions["attachments"];
|
|
129
|
+
/** `checkRateLimit` of ViteHub Rate Limit, when it counts in a KV store that every server process shares. */
|
|
130
|
+
rateLimit?: InstallCommentsOptions["rateLimit"];
|
|
131
|
+
/** Who keeps the tables up to date: `comments` for a Database that `comments()` opens itself. Default `app`. */
|
|
132
|
+
schema?: InstallCommentsOptions["schema"];
|
|
133
|
+
/** The tables of a Postgres Database. Default: the SQLite tables. */
|
|
134
|
+
tables?: InstallCommentsOptions["tables"];
|
|
135
|
+
dialect?: InstallCommentsOptions["dialect"];
|
|
127
136
|
}
|
|
128
137
|
/** The Comments definition that the Nitro plugin installed, for the Console reader. */
|
|
129
138
|
export declare function installedComments(): Comments | undefined;
|
|
@@ -133,38 +142,63 @@ export declare function installedComments(): Comments | undefined;
|
|
|
133
142
|
*/
|
|
134
143
|
export declare function defineCommentsPlugin(options: CommentsPluginOptions): (nitroApp: unknown) => void;
|
|
135
144
|
//#endregion
|
|
136
|
-
//#region src/runtime/
|
|
137
|
-
/** The
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}): Promise<{
|
|
142
|
-
id: string;
|
|
143
|
-
name?: string;
|
|
144
|
-
email?: string;
|
|
145
|
-
image?: string;
|
|
146
|
-
} | null>;
|
|
147
|
-
authorize(context: {
|
|
148
|
-
event: unknown;
|
|
149
|
-
kind?: "read" | "write";
|
|
150
|
-
}): Promise<boolean>;
|
|
151
|
-
user(context: {
|
|
152
|
-
event: unknown;
|
|
153
|
-
}): Promise<Record<string, unknown> | null>;
|
|
154
|
-
}
|
|
145
|
+
//#region src/runtime/database.d.ts
|
|
146
|
+
/** The runtime Database registry of `@vite-hub/database/runtime/registry`, as the generated Nitro plugin passes it. */
|
|
147
|
+
type CommentsDatabaseRegistry = Record<string, {
|
|
148
|
+
db: CommentsDatabase;
|
|
149
|
+
} | undefined>;
|
|
155
150
|
/**
|
|
156
|
-
* The
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
151
|
+
* The Database that `defineComments({ database })` names, else `default`, else the only one. The plugin calls it when
|
|
152
|
+
* the server starts. On Cloudflare that is before any request, so a D1 Database can't connect yet: its db throws until
|
|
153
|
+
* a request brings the binding. An app without a default Database uses a placeholder that throws
|
|
154
|
+
* `DATABASE_DISABLED` or `DATABASE_NOT_FOUND`. The store reads the db per query, by which time the binding is there.
|
|
160
155
|
*/
|
|
161
|
-
export declare function
|
|
156
|
+
export declare function selectCommentsDatabase(databases: CommentsDatabaseRegistry, name?: string): CommentsDatabase | undefined;
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region src/runtime/definition.d.ts
|
|
159
|
+
/**
|
|
160
|
+
* The Comments definition of `server/comments.ts`: its `comments` export, else its default export. Both forms run the
|
|
161
|
+
* same surfaces. The generated files call it, so a file without `defineComments()` fails with `COMMENTS_B0002`.
|
|
162
|
+
*/
|
|
163
|
+
export declare function commentsDefinitionOf(module: {
|
|
164
|
+
comments?: unknown;
|
|
165
|
+
default?: unknown;
|
|
166
|
+
}, file: string): Comments;
|
|
162
167
|
//#endregion
|
|
163
168
|
//#region ../internal/src/runtime/mcp-tools.d.ts
|
|
169
|
+
/**
|
|
170
|
+
* The JSON Schema of one argument. A tool lists only these keywords, plus
|
|
171
|
+
* `description` and `title` for the Agent.
|
|
172
|
+
*/
|
|
173
|
+
type ViteHubMcpValueSchema = {
|
|
174
|
+
description?: string;
|
|
175
|
+
title?: string;
|
|
176
|
+
enum?: ReadonlyArray<string | number | boolean | null>;
|
|
177
|
+
} & ({
|
|
178
|
+
type?: never;
|
|
179
|
+
} | {
|
|
180
|
+
type: "boolean";
|
|
181
|
+
} | {
|
|
182
|
+
type: "integer" | "number";
|
|
183
|
+
minimum?: number;
|
|
184
|
+
maximum?: number;
|
|
185
|
+
} | {
|
|
186
|
+
type: "string";
|
|
187
|
+
minLength?: number;
|
|
188
|
+
maxLength?: number;
|
|
189
|
+
} | {
|
|
190
|
+
type: "array";
|
|
191
|
+
items?: ViteHubMcpValueSchema;
|
|
192
|
+
} | {
|
|
193
|
+
type: "object";
|
|
194
|
+
properties?: Record<string, ViteHubMcpValueSchema>;
|
|
195
|
+
required?: string[];
|
|
196
|
+
additionalProperties?: boolean;
|
|
197
|
+
});
|
|
164
198
|
/** A JSON Schema object for the arguments of a tool. */
|
|
165
199
|
interface ViteHubMcpInputSchema {
|
|
166
200
|
type: "object";
|
|
167
|
-
properties: Record<string,
|
|
201
|
+
properties: Record<string, ViteHubMcpValueSchema>;
|
|
168
202
|
required?: string[];
|
|
169
203
|
additionalProperties?: boolean;
|
|
170
204
|
}
|
|
@@ -178,12 +212,16 @@ interface ViteHubMcpToolResult {
|
|
|
178
212
|
interface ViteHubMcpToolContext {
|
|
179
213
|
/** The checked user, with every field, or null for a caller without accounts. */
|
|
180
214
|
user: Record<string, unknown> | null;
|
|
181
|
-
/** The request event, when available, for owners that resolve request identity. */
|
|
182
|
-
event?:
|
|
215
|
+
/** The request event with its Standard Context, when available, for owners that resolve request identity. */
|
|
216
|
+
event?: {
|
|
217
|
+
readonly "~standard": {
|
|
218
|
+
readonly req: Request;
|
|
219
|
+
};
|
|
220
|
+
};
|
|
183
221
|
}
|
|
184
222
|
/**
|
|
185
|
-
* One tool
|
|
186
|
-
* The server lists and runs a tool only for a person whose Console access includes the tool's `section`.
|
|
223
|
+
* One tool for an app's own MCP server, such as a Comments tool of `commentsMcpTools()`. ViteHub MCP offers operations
|
|
224
|
+
* instead. The server lists and runs a tool only for a person whose Console access includes the tool's `section`.
|
|
187
225
|
*/
|
|
188
226
|
interface ViteHubMcpTool {
|
|
189
227
|
/** Snake case and prefixed with the owner, such as `comments_list_threads`. */
|
|
@@ -204,19 +242,29 @@ interface ViteHubMcpTool {
|
|
|
204
242
|
}
|
|
205
243
|
//#endregion
|
|
206
244
|
//#region src/runtime/mcp.d.ts
|
|
245
|
+
interface CommentsMcpToolsOptions {
|
|
246
|
+
/**
|
|
247
|
+
* The caller passed the Console access check of the `comments` section, as the comment operations do. `authorize`
|
|
248
|
+
* then gets `console: true`. Without `identify`, the default policy also trusts `context.user`, as it does for the
|
|
249
|
+
* comment operations. Default `false`.
|
|
250
|
+
*/
|
|
251
|
+
console?: boolean;
|
|
252
|
+
}
|
|
207
253
|
/**
|
|
208
|
-
* The Comments tools
|
|
209
|
-
* as the overlay does.
|
|
210
|
-
* With a request event,
|
|
211
|
-
*
|
|
254
|
+
* The Comments tools for an app's own MCP server. Each call resolves the Comments identity and checks `authorize`,
|
|
255
|
+
* as the overlay does. The server supplies the checked `context.user`. ViteHub MCP offers the comment operations instead.
|
|
256
|
+
* With `identify` and a request event, `identify` names the user, as in the overlay API. Otherwise the tools use the
|
|
257
|
+
* checked `context.user`. Replies and resolves show that user as the author.
|
|
212
258
|
*/
|
|
213
|
-
export declare function commentsMcpTools(comments: Comments, options?:
|
|
259
|
+
export declare function commentsMcpTools(comments: Comments, options?: CommentsMcpToolsOptions): ViteHubMcpTool[];
|
|
214
260
|
//#endregion
|
|
215
261
|
//#region ../internal/src/runtime/page-tools.d.ts
|
|
216
262
|
/**
|
|
217
|
-
* The
|
|
218
|
-
*
|
|
263
|
+
* The route of `GET /_vitehub/page/session`: a Fetchable (https://fetchable.org). Nitro 3 binds each Request to its
|
|
264
|
+
* app in `installViteHubPageTools()`, so the route finds the tools of that app.
|
|
219
265
|
*/
|
|
220
|
-
export declare
|
|
266
|
+
export declare const viteHubPageSessionHandler: {
|
|
267
|
+
fetch(request: Request): Promise<Response>;
|
|
268
|
+
};
|
|
221
269
|
//#endregion
|
|
222
|
-
export type {
|
|
270
|
+
export type { CommentsContent, CommentsContentField, CommentsDatabaseRegistry, CommentsGitHubLogin, CommentsHandlerOptions, CommentsMcpToolsOptions, CommentsPluginOptions };
|