@vite-hub/comments 0.1.0 → 0.3.1
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/types-Cj8K7Vx7.d.ts
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
//#region src/operations-core/types.d.ts
|
|
2
|
-
/** A person. The signed-in user and every author have this shape. */
|
|
3
|
-
interface CommentUser {
|
|
4
|
-
id: string;
|
|
5
|
-
/** Shown when there is one, else the `id`. */
|
|
6
|
-
name?: string;
|
|
7
|
-
image?: string;
|
|
8
|
-
}
|
|
9
|
-
/** The agent that wrote a comment on behalf of a user. */
|
|
10
|
-
interface CommentActor {
|
|
11
|
-
id: string;
|
|
12
|
-
name?: string;
|
|
13
|
-
}
|
|
14
|
-
type CommentStatus = "open" | "resolved";
|
|
15
|
-
/** What a thread is about. `page` takes an app path as `id`. Other kinds, such as `content`, name their own ids. */
|
|
16
|
-
interface CommentSubject {
|
|
17
|
-
kind: string;
|
|
18
|
-
id: string;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Every offset is in thousandths of the element box, so `500` is the middle.
|
|
22
|
-
* An anchor with a rectangle keeps it inside the box: `x + width <= 1000`.
|
|
23
|
-
*/
|
|
24
|
-
interface PageAnchor {
|
|
25
|
-
kind: "page";
|
|
26
|
-
}
|
|
27
|
-
interface ElementAnchor {
|
|
28
|
-
kind: "element";
|
|
29
|
-
selector: string;
|
|
30
|
-
x: number;
|
|
31
|
-
y: number;
|
|
32
|
-
}
|
|
33
|
-
/** A W3C TextQuoteSelector inside the element that `selector` names. */
|
|
34
|
-
interface TextAnchor {
|
|
35
|
-
kind: "text";
|
|
36
|
-
selector: string;
|
|
37
|
-
exact: string;
|
|
38
|
-
prefix: string;
|
|
39
|
-
suffix: string;
|
|
40
|
-
}
|
|
41
|
-
interface AreaAnchor {
|
|
42
|
-
kind: "area";
|
|
43
|
-
selector: string;
|
|
44
|
-
x: number;
|
|
45
|
-
y: number;
|
|
46
|
-
width: number;
|
|
47
|
-
height: number;
|
|
48
|
-
}
|
|
49
|
-
/** A point on an image, or an area when `width` and `height` are set. */
|
|
50
|
-
interface ImageAnchor {
|
|
51
|
-
kind: "image";
|
|
52
|
-
selector: string;
|
|
53
|
-
x: number;
|
|
54
|
-
y: number;
|
|
55
|
-
width?: number;
|
|
56
|
-
height?: number;
|
|
57
|
-
}
|
|
58
|
-
type CommentAnchor = PageAnchor | ElementAnchor | TextAnchor | AreaAnchor | ImageAnchor;
|
|
59
|
-
/** One Markdown message. The first message of a thread is the comment. */
|
|
60
|
-
interface CommentMessage {
|
|
61
|
-
id: string;
|
|
62
|
-
threadId: string;
|
|
63
|
-
body: string;
|
|
64
|
-
author: CommentUser;
|
|
65
|
-
actor?: CommentActor;
|
|
66
|
-
/** Ids of the users mentioned in `body`. */
|
|
67
|
-
mentions: string[];
|
|
68
|
-
/** Blob keys. Always empty for now: attachments come with the upload operation. */
|
|
69
|
-
attachments: string[];
|
|
70
|
-
/** Milliseconds since the epoch. */
|
|
71
|
-
createdAt: number;
|
|
72
|
-
editedAt?: number;
|
|
73
|
-
}
|
|
74
|
-
interface CommentThread {
|
|
75
|
-
id: string;
|
|
76
|
-
/** The numbering scope. `n` is unique inside it. */
|
|
77
|
-
scope: string;
|
|
78
|
-
/** The number that pins and `?comment=<n>` show. */
|
|
79
|
-
n: number;
|
|
80
|
-
subject: CommentSubject;
|
|
81
|
-
anchor: CommentAnchor;
|
|
82
|
-
status: CommentStatus;
|
|
83
|
-
resolvedBy?: CommentUser;
|
|
84
|
-
resolvedAt?: number;
|
|
85
|
-
author: CommentUser;
|
|
86
|
-
actor?: CommentActor;
|
|
87
|
-
/** Oldest first. */
|
|
88
|
-
messages: CommentMessage[];
|
|
89
|
-
createdAt: number;
|
|
90
|
-
updatedAt: number;
|
|
91
|
-
}
|
|
92
|
-
interface CommentListQuery {
|
|
93
|
-
subject?: CommentSubject;
|
|
94
|
-
/** An app path. The same as a `page` subject. */
|
|
95
|
-
page?: string;
|
|
96
|
-
status?: CommentStatus;
|
|
97
|
-
/** Only threads that the signed-in user started. */
|
|
98
|
-
mine?: boolean;
|
|
99
|
-
/** Only threads that mention the signed-in user. */
|
|
100
|
-
mentions?: boolean;
|
|
101
|
-
/** Most threads in the answer. Default 200, at most 500. */
|
|
102
|
-
limit?: number;
|
|
103
|
-
/** Where the next page starts: the `updatedAt` and `id` of the last thread of the page before. Threads come newest first. */
|
|
104
|
-
before?: CommentListCursor;
|
|
105
|
-
}
|
|
106
|
-
/** The position of a thread in a list: the list is ordered by `updatedAt`, then `id`, newest first. */
|
|
107
|
-
interface CommentListCursor {
|
|
108
|
-
updatedAt: number;
|
|
109
|
-
id: string;
|
|
110
|
-
}
|
|
111
|
-
/** By id, or by number inside its scope, as `?comment=<n>` names it. */
|
|
112
|
-
type CommentGetInput = {
|
|
113
|
-
id: string;
|
|
114
|
-
} | {
|
|
115
|
-
scope: string;
|
|
116
|
-
n: number;
|
|
117
|
-
};
|
|
118
|
-
interface CommentCreateInput {
|
|
119
|
-
subject: CommentSubject;
|
|
120
|
-
anchor: CommentAnchor;
|
|
121
|
-
body: string;
|
|
122
|
-
mentions?: string[];
|
|
123
|
-
attachments?: string[];
|
|
124
|
-
}
|
|
125
|
-
interface CommentReplyInput {
|
|
126
|
-
threadId: string;
|
|
127
|
-
body: string;
|
|
128
|
-
mentions?: string[];
|
|
129
|
-
attachments?: string[];
|
|
130
|
-
}
|
|
131
|
-
interface CommentEditInput {
|
|
132
|
-
threadId: string;
|
|
133
|
-
messageId: string;
|
|
134
|
-
body: string;
|
|
135
|
-
mentions?: string[];
|
|
136
|
-
}
|
|
137
|
-
/** Without `messageId` the whole thread goes. Deleting the first message also deletes the thread. */
|
|
138
|
-
interface CommentDeleteInput {
|
|
139
|
-
threadId: string;
|
|
140
|
-
messageId?: string;
|
|
141
|
-
}
|
|
142
|
-
interface CommentStatusInput {
|
|
143
|
-
threadId: string;
|
|
144
|
-
}
|
|
145
|
-
interface CommentUsersInput {
|
|
146
|
-
query: string;
|
|
147
|
-
limit?: number;
|
|
148
|
-
}
|
|
149
|
-
type CommentEvent = {
|
|
150
|
-
type: "thread";
|
|
151
|
-
thread: CommentThread;
|
|
152
|
-
} | {
|
|
153
|
-
type: "deleted";
|
|
154
|
-
threadId: string;
|
|
155
|
-
} | {
|
|
156
|
-
type: "reconnected";
|
|
157
|
-
};
|
|
158
|
-
/**
|
|
159
|
-
* The seam between the browser and the server. Each method has the name and the input of one `comments.*` operation.
|
|
160
|
-
* A mutation returns the thread as it is afterwards, and `delete` returns `null` when the thread is gone.
|
|
161
|
-
*/
|
|
162
|
-
interface CommentsTransport {
|
|
163
|
-
list: (query: CommentListQuery) => Promise<CommentThread[]>;
|
|
164
|
-
get: (input: CommentGetInput) => Promise<CommentThread | null>;
|
|
165
|
-
create: (input: CommentCreateInput) => Promise<CommentThread>;
|
|
166
|
-
reply: (input: CommentReplyInput) => Promise<CommentThread>;
|
|
167
|
-
edit: (input: CommentEditInput) => Promise<CommentThread>;
|
|
168
|
-
delete: (input: CommentDeleteInput) => Promise<CommentThread | null>;
|
|
169
|
-
resolve: (input: CommentStatusInput) => Promise<CommentThread>;
|
|
170
|
-
reopen: (input: CommentStatusInput) => Promise<CommentThread>;
|
|
171
|
-
users: (input: CommentUsersInput) => Promise<CommentUser[]>;
|
|
172
|
-
/** Live updates, such as Realtime. Without it the client refreshes when the window gets focus. */
|
|
173
|
-
subscribe?: (listener: (event: CommentEvent) => void) => () => void;
|
|
174
|
-
}
|
|
175
|
-
//#endregion
|
|
176
|
-
export { TextAnchor as C, PageAnchor as S, CommentUser as _, CommentDeleteInput as a, ElementAnchor as b, CommentGetInput as c, CommentMessage as d, CommentReplyInput as f, CommentThread as g, CommentSubject as h, CommentCreateInput as i, CommentListCursor as l, CommentStatusInput as m, CommentActor as n, CommentEditInput as o, CommentStatus as p, CommentAnchor as r, CommentEvent as s, AreaAnchor as t, CommentListQuery as u, CommentUsersInput as v, ImageAnchor as x, CommentsTransport as y };
|
package/dist/types-Un2dcJWD.d.ts
DELETED
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
import { H3Event } from "h3";
|
|
2
|
-
//#region src/types.d.ts
|
|
3
|
-
/** The person who wrote a comment. The row keeps a copy, so the name stays when the Auth user changes. */
|
|
4
|
-
interface CommentAuthor {
|
|
5
|
-
id: string;
|
|
6
|
-
name: string;
|
|
7
|
-
image?: string;
|
|
8
|
-
/** True for a guest that named itself in the browser. Show the name, never trust it. */
|
|
9
|
-
guest?: boolean;
|
|
10
|
-
}
|
|
11
|
-
/** A person that a comment mentions with `@`. */
|
|
12
|
-
interface CommentMention {
|
|
13
|
-
id: string;
|
|
14
|
-
name: string;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Where a thread sits on its page. The overlay tries each hint in order and uses the first one it finds: the Content
|
|
18
|
-
* field, the CSS path checked against the label, the label alone, then the page point.
|
|
19
|
-
*/
|
|
20
|
-
interface CommentAnchor {
|
|
21
|
-
/** The `data-content-field` address of the element or its closest ancestor, such as `about#hero.title`. */
|
|
22
|
-
field?: string;
|
|
23
|
-
/** CSS path of the element, at most 10 levels, from its closest ancestor with an id or a Content field. */
|
|
24
|
-
selector: string;
|
|
25
|
-
/** Tag and the first 40 characters of the element text, to check that `selector` still finds the same element. */
|
|
26
|
-
label: string;
|
|
27
|
-
/** Position of the pin in the element box, in thousandths of its width and height. */
|
|
28
|
-
x: number;
|
|
29
|
-
y: number;
|
|
30
|
-
/** Fallback position: thousandths of the document width, and CSS pixels from the document top. */
|
|
31
|
-
page: {
|
|
32
|
-
x: number;
|
|
33
|
-
y: number;
|
|
34
|
-
};
|
|
35
|
-
/** Viewport width when the pin was dropped. */
|
|
36
|
-
viewport: {
|
|
37
|
-
width: number;
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
/** A Vue component that renders the element of a thread. */
|
|
41
|
-
interface CommentComponent {
|
|
42
|
-
/** The component name, such as `PricingCard`. `<script setup>` components get the name of their file. */
|
|
43
|
-
name: string;
|
|
44
|
-
/**
|
|
45
|
-
* Source files that may define it, relative to the project root. Production builds keep only the name, so a
|
|
46
|
-
* name that two files share, such as `index`, gets both.
|
|
47
|
-
*/
|
|
48
|
-
files?: string[];
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* What a person saw when they started a thread, so a teammate or an Agent can find the code to change. The overlay
|
|
52
|
-
* reads the page, the element, the Vue components, and the browser; the server adds the build.
|
|
53
|
-
*/
|
|
54
|
-
interface CommentContext {
|
|
55
|
-
/** The page origin and pathname, without credentials, query parameters, or a hash. */
|
|
56
|
-
url: string;
|
|
57
|
-
title?: string;
|
|
58
|
-
/** The Vue Router route pattern, such as `/blog/:id(.*)*`. */
|
|
59
|
-
route?: string;
|
|
60
|
-
element?: {
|
|
61
|
-
tag: string;
|
|
62
|
-
id?: string;
|
|
63
|
-
/** `data-testid`, `data-test`, or `data-cy` of the element or its closest ancestor. */
|
|
64
|
-
testId?: string;
|
|
65
|
-
/** The `role` attribute, or the role of the tag, such as `button` or `heading`. */
|
|
66
|
-
role?: string;
|
|
67
|
-
/** `aria-label`, `alt`, `title`, or the first 120 characters of the text. */
|
|
68
|
-
name?: string;
|
|
69
|
-
classes?: string[];
|
|
70
|
-
};
|
|
71
|
-
/** Outermost first. Empty on pages that Vue does not render. */
|
|
72
|
-
components?: CommentComponent[];
|
|
73
|
-
environment?: {
|
|
74
|
-
viewport: {
|
|
75
|
-
width: number;
|
|
76
|
-
height: number;
|
|
77
|
-
};
|
|
78
|
-
devicePixelRatio: number;
|
|
79
|
-
userAgent: string;
|
|
80
|
-
language?: string;
|
|
81
|
-
colorScheme?: "light" | "dark";
|
|
82
|
-
timeZone?: string;
|
|
83
|
-
};
|
|
84
|
-
/** The build that served the page, when the build could read it. */
|
|
85
|
-
build?: CommentBuild;
|
|
86
|
-
}
|
|
87
|
-
/** The build that served a page: what the CI or host told the build, else Git. */
|
|
88
|
-
interface CommentBuild {
|
|
89
|
-
commit?: string;
|
|
90
|
-
branch?: string;
|
|
91
|
-
/** The GitHub repository, as `owner/name`. */
|
|
92
|
-
repository?: string;
|
|
93
|
-
/** The pull request that the build previews, when the host names it. */
|
|
94
|
-
pullRequest?: number;
|
|
95
|
-
}
|
|
96
|
-
interface Comment {
|
|
97
|
-
id: string;
|
|
98
|
-
threadId: string;
|
|
99
|
-
/** Plain text, at most 4,000 characters. */
|
|
100
|
-
body: string;
|
|
101
|
-
mentions: CommentMention[];
|
|
102
|
-
author: CommentAuthor;
|
|
103
|
-
/** ISO time. */
|
|
104
|
-
createdAt: string;
|
|
105
|
-
editedAt: string | null;
|
|
106
|
-
}
|
|
107
|
-
type CommentThreadStatus = "open" | "resolved";
|
|
108
|
-
/**
|
|
109
|
-
* Fields that app code keeps on a thread, such as where its own UI anchors it: at most 50 keys, and strings of at most
|
|
110
|
-
* 4,000 characters.
|
|
111
|
-
*/
|
|
112
|
-
type CommentMetadata = Record<string, string | number | boolean | null>;
|
|
113
|
-
interface CommentThread {
|
|
114
|
-
id: string;
|
|
115
|
-
/**
|
|
116
|
-
* The list the thread belongs to. `"pages"` for threads that people pin on the app's pages; app code picks its own,
|
|
117
|
-
* such as `doc:42`, for threads in its own UI.
|
|
118
|
-
*/
|
|
119
|
-
scope: string;
|
|
120
|
-
/** 1, 2, 3, … in the order threads start in their scope, so people can say "#3". */
|
|
121
|
-
number: number;
|
|
122
|
-
/** Normalized pathname of the page, such as `/pricing`. */
|
|
123
|
-
page: string;
|
|
124
|
-
/** Where the overlay places the pin. Null for a thread that app code anchors itself, in `metadata`. */
|
|
125
|
-
anchor: CommentAnchor | null;
|
|
126
|
-
metadata: CommentMetadata | null;
|
|
127
|
-
/** Null for threads that server code created without it. */
|
|
128
|
-
context: CommentContext | null;
|
|
129
|
-
status: CommentThreadStatus;
|
|
130
|
-
createdBy: CommentAuthor;
|
|
131
|
-
resolvedBy: CommentAuthor | null;
|
|
132
|
-
resolvedAt: string | null;
|
|
133
|
-
createdAt: string;
|
|
134
|
-
updatedAt: string;
|
|
135
|
-
/** Oldest first. The first comment opened the thread. */
|
|
136
|
-
comments: Comment[];
|
|
137
|
-
/** The pull request comment of the thread, when `defineComments({ forge })` syncs it. */
|
|
138
|
-
forge?: CommentForgeLink | null;
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Where a thread sits on its pull request.
|
|
142
|
-
* - `posted`: on the pull request.
|
|
143
|
-
* - `pending`: being posted.
|
|
144
|
-
* - `failed`: the forge refused it; the next change, or `comments.sync()`, tries again.
|
|
145
|
-
*/
|
|
146
|
-
interface CommentForgeLink {
|
|
147
|
-
repository: string;
|
|
148
|
-
pullRequest: number;
|
|
149
|
-
state: "posted" | "pending" | "failed";
|
|
150
|
-
/** The comment that holds the thread's first comment. */
|
|
151
|
-
url?: string;
|
|
152
|
-
/** Why the forge refused it. */
|
|
153
|
-
error?: string;
|
|
154
|
-
/** `author` when it posted with the person's own GitHub token, `app` when the GitHub App posted it for them. */
|
|
155
|
-
postedAs?: "author" | "app";
|
|
156
|
-
}
|
|
157
|
-
interface CommentsForgeTarget {
|
|
158
|
-
repository: string;
|
|
159
|
-
pullRequest: number;
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Posts each thread to the pull request of the build that served its page: one comment per comment, and one summary
|
|
163
|
-
* comment that lists every thread. Credentials come from Server Env: a GitHub App (`VITEHUB_GITHUB_APP_ID` with
|
|
164
|
-
* `VITEHUB_GITHUB_PRIVATE_KEY`), else `VITEHUB_GITHUB_TOKEN`.
|
|
165
|
-
*/
|
|
166
|
-
interface CommentsForgeOptions {
|
|
167
|
-
/** Only GitHub for now. */
|
|
168
|
-
provider: "github";
|
|
169
|
-
/** `owner/name`. Default: the repository of the build that served the thread's page. */
|
|
170
|
-
repository?: string;
|
|
171
|
-
/**
|
|
172
|
-
* The pull request of a thread. Default: the one the build names, else the open pull request whose head is the
|
|
173
|
-
* build's branch. Return `undefined` to keep the thread off GitHub.
|
|
174
|
-
*/
|
|
175
|
-
pullRequest?: (thread: CommentThread) => number | undefined | Promise<number | undefined>;
|
|
176
|
-
/**
|
|
177
|
-
* The GitHub token of the person who wrote a comment, such as the user token of their GitHub sign-in, so the
|
|
178
|
-
* comment posts as them. Without one, the GitHub App posts it with their name.
|
|
179
|
-
*/
|
|
180
|
-
token?: (author: CommentAuthor) => string | undefined | Promise<string | undefined>;
|
|
181
|
-
/** The heading of the summary comment. Default `"Preview comments"`. */
|
|
182
|
-
title?: string;
|
|
183
|
-
/** GitHub Enterprise API base. Default `https://api.github.com`. */
|
|
184
|
-
apiUrl?: string;
|
|
185
|
-
fetch?: typeof fetch;
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* - `read`: see pins and threads, and join the page room.
|
|
189
|
-
* - `comment`: start threads and reply; signed-in authors can delete their own comments.
|
|
190
|
-
* - `resolve`: resolve and reopen; signed-in users can delete any thread or comment.
|
|
191
|
-
*/
|
|
192
|
-
type CommentsAction = "read" | "comment" | "resolve";
|
|
193
|
-
/** The user that `identify` or the ViteHub Auth session resolved. `null` for an anonymous request. */
|
|
194
|
-
type CommentsUser = Record<string, unknown> & {
|
|
195
|
-
id: string;
|
|
196
|
-
github?: CommentsGitHubAccess;
|
|
197
|
-
};
|
|
198
|
-
/** What GitHub says about a person who signed in to Comments with GitHub. */
|
|
199
|
-
interface CommentsGitHubAccess {
|
|
200
|
-
/** Their GitHub username. */
|
|
201
|
-
login: string;
|
|
202
|
-
/** The repository of the build, `owner/name`, when Comments knows it. */
|
|
203
|
-
repository?: string;
|
|
204
|
-
/** Whether they can push to `repository`. False when Comments does not know the repository. */
|
|
205
|
-
write: boolean;
|
|
206
|
-
}
|
|
207
|
-
interface CommentsAuthorizeContext {
|
|
208
|
-
user: CommentsUser | null;
|
|
209
|
-
action: CommentsAction;
|
|
210
|
-
/** The scope of the threads, such as `"pages"` for the overlay and the Console. */
|
|
211
|
-
scope: string;
|
|
212
|
-
/** The thread the action changes. Undefined for reads and new threads. */
|
|
213
|
-
thread?: CommentThread;
|
|
214
|
-
}
|
|
215
|
-
interface CommentsIdentifyContext {
|
|
216
|
-
event: H3Event;
|
|
217
|
-
}
|
|
218
|
-
interface CommentsPeopleContext {
|
|
219
|
-
/** Text after `@`, possibly empty. */
|
|
220
|
-
query: string;
|
|
221
|
-
user: CommentsUser | null;
|
|
222
|
-
}
|
|
223
|
-
interface CommentCreatedEvent {
|
|
224
|
-
thread: CommentThread;
|
|
225
|
-
comment: Comment;
|
|
226
|
-
/** People the comment mentions. */
|
|
227
|
-
mentions: CommentMention[];
|
|
228
|
-
}
|
|
229
|
-
interface DefineCommentsOptions {
|
|
230
|
-
/**
|
|
231
|
-
* Who may read, comment, and resolve. Return `false` to deny. Return `true` for `user: null` to let guests comment
|
|
232
|
-
* under a name they choose. Without it: a person signed in with GitHub may do everything when they can push to the
|
|
233
|
-
* repository of the build; any other signed-in user may do everything; anonymous people may comment as guests on the
|
|
234
|
-
* development server only.
|
|
235
|
-
*/
|
|
236
|
-
authorize?: (context: CommentsAuthorizeContext) => boolean | void | Promise<boolean | void>;
|
|
237
|
-
/** Resolves the user of a request. Without it, Comments reads the ViteHub Auth session. Return `null` for anonymous. */
|
|
238
|
-
identify?: (context: CommentsIdentifyContext) => CommentsUser | null | undefined | Promise<CommentsUser | null | undefined>;
|
|
239
|
-
/** Name of the Database that stores comments. Defaults to the `default` Database, or the only one. */
|
|
240
|
-
database?: string;
|
|
241
|
-
/** People that `@` suggests. Without it, the authors of earlier comments. */
|
|
242
|
-
people?: (context: CommentsPeopleContext) => CommentMention[] | Promise<CommentMention[]>;
|
|
243
|
-
/** Runs after a comment saves, such as to notify mentioned people by Email. Errors are logged, not returned. */
|
|
244
|
-
onComment?: (event: CommentCreatedEvent) => void | Promise<void>;
|
|
245
|
-
/** Posts threads to the pull request that the page previews. Needs `vitehub db generate` for its table. */
|
|
246
|
-
forge?: CommentsForgeOptions;
|
|
247
|
-
}
|
|
248
|
-
interface ListCommentThreadsOptions {
|
|
249
|
-
/** Only the threads of this scope. Without it, threads of every scope. */
|
|
250
|
-
scope?: string;
|
|
251
|
-
/** Only the threads of this page. */
|
|
252
|
-
page?: string;
|
|
253
|
-
status?: CommentThreadStatus;
|
|
254
|
-
/** Newest activity first. Default 200, at most 500. */
|
|
255
|
-
limit?: number;
|
|
256
|
-
}
|
|
257
|
-
interface CreateCommentThreadInput {
|
|
258
|
-
/** Default `"pages"`, which needs an `anchor`. */
|
|
259
|
-
scope?: string;
|
|
260
|
-
page: string;
|
|
261
|
-
anchor?: CommentAnchor;
|
|
262
|
-
context?: CommentContext;
|
|
263
|
-
metadata?: CommentMetadata;
|
|
264
|
-
body: string;
|
|
265
|
-
author: CommentAuthor;
|
|
266
|
-
mentions?: CommentMention[];
|
|
267
|
-
}
|
|
268
|
-
interface EditCommentInput {
|
|
269
|
-
body: string;
|
|
270
|
-
/** Replaces the mentions. Default: none. */
|
|
271
|
-
mentions?: CommentMention[];
|
|
272
|
-
}
|
|
273
|
-
interface ReplyInput {
|
|
274
|
-
body: string;
|
|
275
|
-
author: CommentAuthor;
|
|
276
|
-
mentions?: CommentMention[];
|
|
277
|
-
}
|
|
278
|
-
interface ReplyOptions {
|
|
279
|
-
/**
|
|
280
|
-
* Reply to a resolved thread, and keep it resolved, for apps whose own UI allows that. Default `false`: the reply
|
|
281
|
-
* fails with `COMMENTS_RESOLVED`, as on the overlay.
|
|
282
|
-
*/
|
|
283
|
-
allowResolved?: boolean;
|
|
284
|
-
}
|
|
285
|
-
/** Codes of the errors that Comments methods return in the `[error, data]` tuple. */
|
|
286
|
-
type CommentsErrorCode = "COMMENTS_NOT_INSTALLED" | "COMMENTS_NOT_FOUND" | "COMMENTS_INVALID_INPUT" | "COMMENTS_FORBIDDEN" | "COMMENTS_RESOLVED" | "COMMENTS_CONTENT_MISSING" | "COMMENTS_FIELD_INVALID" | "COMMENTS_FIELD_NOT_EDITABLE" | "COMMENTS_FIELD_FORBIDDEN" | "COMMENTS_FIELD_CONFLICT" | "COMMENTS_FIELD_LOCKED";
|
|
287
|
-
//#endregion
|
|
288
|
-
export { DefineCommentsOptions as C, ReplyOptions as D, ReplyInput as E, CreateCommentThreadInput as S, ListCommentThreadsOptions as T, CommentsForgeTarget as _, CommentComponent as a, CommentsPeopleContext as b, CommentForgeLink as c, CommentThread as d, CommentThreadStatus as f, CommentsForgeOptions as g, CommentsErrorCode as h, CommentBuild as i, CommentMention as l, CommentsAuthorizeContext as m, CommentAnchor as n, CommentContext as o, CommentsAction as p, CommentAuthor as r, CommentCreatedEvent as s, Comment as t, CommentMetadata as u, CommentsGitHubAccess as v, EditCommentInput as w, CommentsUser as x, CommentsIdentifyContext as y };
|