@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
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=`vitehub`,t=[`comment`];function n(e,n){let r=new URLSearchParams(e);if(r.has(`vitehub`)||t.some(e=>r.has(e)))return!0;let i=n.split(`;`).map(e=>e.trim());return i.includes(`vitehub-tools=1`)?!0:i.includes(`vitehub_session=1`)&&!i.some(e=>e.startsWith(`vitehub-tools=`))}`${JSON.stringify([e,...t])}`;var r=/^[A-Za-z0-9][A-Za-z0-9-]{0,38}\/(?!\.+$)[A-Za-z0-9._-]{1,100}$/;function i(e){return e&&r.test(e)?e:void 0}function a(e,...t){return typeof e==`function`?e(...t):e}var o=Error.captureStackTrace,s=class e extends Error{get why(){return this.message}constructor(t,n=e){super(t.why,{cause:t.cause}),this.code=this.name=t.code,this.docs=t.docs,this.fix=t.fix,this.sources=t.sources,this.data=t.data,o?.(this,n)}toJSON(){return{name:this.name,why:this.why,fix:this.fix,docs:this.docs,sources:this.sources,cause:this.cause,data:this.data,stack:this.stack}}};function c(e,t){return typeof e==`string`?`${e}/${t.toLowerCase()}`:e?.(t)}var l=e=>t=>t instanceof s&&e in t;function u(e){let t=e.reporters??[],n=Symbol(),r=Object.defineProperty({},"is",{value:l(n)}),{docsBase:i}=e;for(let o of Object.keys(e.codes)){let l=e.codes[o],u=l.docs===!1?void 0:l.docs||c(i,o),d=(e={},r={})=>{let i=new s({code:o,why:a(l.why,e),fix:a(l.fix,e),docs:u,cause:e.cause,sources:e.sources,data:a(l.data,e)},d);i[n]=1;for(let e of t)e(i,r);return i};d.is=e=>r.is(e)&&e.code===o,r[o]=d}return r}var d=u({docsBase:`https://vitehub.dev/docs/comments/diagnostics`,codes:{COMMENTS_HOSTED_CONFLICT:{why:`This page runs the app's own Comments, so the Hosted Comments script does not start its overlay.`,fix:"Remove the Hosted Comments script, or keep it and set `comments: { overlay: false }` to turn off the app's overlay. See https://vitehub.dev/docs/comments/configure#add-hosted-comments"},COMMENTS_OUTBOX_ACCOUNT_CHANGED:{why:`The current author is not the author of this queued comment.`,fix:`Sign in as the original author and retry the outbox.`},COMMENTS_OUTBOX_RESOLVE_BLOCKED:{why:`Queued delivery must resume before the thread can close.`,fix:`Go online, then retry or dismiss any blocked comments and resolve the thread again.`},COMMENTS_OUTBOX_SENDING:{why:`The server may already have this comment, so the draft cannot change.`,fix:`Wait for delivery to finish, then edit or delete the server copy.`},COMMENTS_OVERLAY_ELEMENT_TAKEN:{why:({name:e})=>`Another script defined the <${e}> element, so this Comments overlay cannot start.`,fix:`Load one Comments overlay script on the page. Remove the other script that defines the element.`},COMMENTS_R0001:{why:({target:e})=>`createAnchor() found nothing to anchor to for ${e}.`,fix:`Pass an element, a non-empty selection, or a point that is over an element of the page.`},COMMENTS_R0013:{why:`The comments request did not get an answer from the server.`,fix:`Check the connection and the app URL, then try again.`},COMMENTS_R0015:{why:`The comment list kept changing while its pages were loading.`,fix:`Refresh again. The previous cache is kept until two complete scans agree.`}}});function f(e){let{code:t,details:n,fix:r,retryAfter:i,status:a,why:o}=e,c=t.startsWith(`COMMENTS_`)?`https://vitehub.dev/docs/comments/diagnostics/${t.toLowerCase()}`:void 0;return Object.assign(new s({code:t,why:o,...r?{fix:r}:{},...c?{docs:c}:{}}),{status:a,...n?{details:n}:{},...i===void 0?{}:{retryAfter:i}})}function p(e,t,n){return Object.assign(d.COMMENTS_R0013(t===void 0?{}:{cause:t}),{status:e,...n===void 0?{}:{retryAfter:n}})}var m=`vitehub-comments:connect`;function h(e){return`vitehub-comments:${e}`}function g(e){return`/comments/${encodeURIComponent(e)}/embed`}var _=15e3,v=3e4,y=5e3,b=`vitehub-comments:`,x=RegExp(`^#(/?)vhc=([\\w-]+)$`);function S(e=!1){let t=x.exec(location.hash);if(!t)return;let[,n,r]=t,i=new URL(location.href);return e&&i.searchParams.delete(`vhp`),i.hash=n?`#/`:``,history.replaceState(history.state,``,i),r}function C(e){try{return sessionStorage.getItem(e)===`1`}catch{return!1}}function w(){try{for(let e=0;e<sessionStorage.length;e++)if(sessionStorage.key(e)?.startsWith(b))return!0}catch{}return!1}function T(e){try{sessionStorage.setItem(e,`1`)}catch{}}function E(e,t){let n=document.createElement(`iframe`);n.src=`${e}${g(t)}`,n.hidden=!0,n.tabIndex=-1,n.title=`ViteHub Comments`,n.setAttribute(`aria-hidden`,`true`),n.setAttribute(`data-comments-ui`,``);let r=new MessageChannel,i=new Map,a=
|
|
1
|
+
var e=`vitehub`,t=[`comment`];function n(e,n){let r=new URLSearchParams(e);if(r.has(`vitehub`)||t.some(e=>r.has(e)))return!0;let i=n.split(`;`).map(e=>e.trim());return i.includes(`vitehub-tools=1`)?!0:i.includes(`vitehub_session=1`)&&!i.some(e=>e.startsWith(`vitehub-tools=`))}`${JSON.stringify([e,...t])}`;var r=/^[A-Za-z0-9][A-Za-z0-9-]{0,38}\/(?!\.+$)[A-Za-z0-9._-]{1,100}$/;function i(e){return e&&r.test(e)?e:void 0}function a(e,...t){return typeof e==`function`?e(...t):e}var o=Error.captureStackTrace,s=class e extends Error{get why(){return this.message}constructor(t,n=e){super(t.why,{cause:t.cause}),this.code=this.name=t.code,this.docs=t.docs,this.fix=t.fix,this.sources=t.sources,this.data=t.data,o?.(this,n)}toJSON(){return{name:this.name,why:this.why,fix:this.fix,docs:this.docs,sources:this.sources,cause:this.cause,data:this.data,stack:this.stack}}};function c(e,t){return typeof e==`string`?`${e}/${t.toLowerCase()}`:e?.(t)}var l=e=>t=>t instanceof s&&e in t;function u(e){let t=e.reporters??[],n=Symbol(),r=Object.defineProperty({},"is",{value:l(n)}),{docsBase:i}=e;for(let o of Object.keys(e.codes)){let l=e.codes[o],u=l.docs===!1?void 0:l.docs||c(i,o),d=(e={},r={})=>{let i=new s({code:o,why:a(l.why,e),fix:a(l.fix,e),docs:u,cause:e.cause,sources:e.sources,data:a(l.data,e)},d);i[n]=1;for(let e of t)e(i,r);return i};d.is=e=>r.is(e)&&e.code===o,r[o]=d}return r}var d=u({docsBase:`https://vitehub.dev/docs/comments/diagnostics`,codes:{COMMENTS_HOSTED_CONFLICT:{why:`This page runs the app's own Comments, so the Hosted Comments script does not start its overlay.`,fix:"Remove the Hosted Comments script, or keep it and set `comments: { overlay: false }` to turn off the app's overlay. See https://vitehub.dev/docs/comments/configure#add-hosted-comments"},COMMENTS_OUTBOX_ACCOUNT_CHANGED:{why:`The current author is not the author of this queued comment.`,fix:`Sign in as the original author and retry the outbox.`},COMMENTS_OUTBOX_RESOLVE_BLOCKED:{why:`Queued delivery must resume before the thread can close.`,fix:`Go online, then retry or dismiss any blocked comments and resolve the thread again.`},COMMENTS_OUTBOX_SENDING:{why:`The server may already have this comment, so the draft cannot change.`,fix:`Wait for delivery to finish, then edit or delete the server copy.`},COMMENTS_OVERLAY_ELEMENT_TAKEN:{why:({name:e})=>`Another script defined the <${e}> element, so this Comments overlay cannot start.`,fix:`Load one Comments overlay script on the page. Remove the other script that defines the element.`},COMMENTS_R0001:{why:({target:e})=>`createAnchor() found nothing to anchor to for ${e}.`,fix:`Pass an element, a non-empty selection, or a point that is over an element of the page.`},COMMENTS_R0013:{why:`The comments request did not get an answer from the server.`,fix:`Check the connection and the app URL, then try again.`},COMMENTS_R0015:{why:`The comment list kept changing while its pages were loading.`,fix:`Refresh again. The previous cache is kept until two complete scans agree.`}}});function f(e){let{code:t,details:n,fix:r,retryAfter:i,status:a,why:o}=e,c=t.startsWith(`COMMENTS_`)?`https://vitehub.dev/docs/comments/diagnostics/${t.toLowerCase()}`:void 0;return Object.assign(new s({code:t,why:o,...r?{fix:r}:{},...c?{docs:c}:{}}),{status:a,...n?{details:n}:{},...i===void 0?{}:{retryAfter:i}})}function p(e,t,n){return Object.assign(d.COMMENTS_R0013(t===void 0?{}:{cause:t}),{status:e,...n===void 0?{}:{retryAfter:n}})}var m=`vitehub-comments:connect`;function h(e){return`vitehub-comments:${e}`}function g(e){return`/comments/${encodeURIComponent(e)}/embed`}var _=15e3,v=3e4,y=5e3,b=`vitehub-comments:`,x=RegExp(`^#(/?)vhc=([\\w-]+)$`);function S(e=!1){let t=x.exec(location.hash);if(!t)return;let[,n,r]=t,i=new URL(location.href);return e&&i.searchParams.delete(`vhp`),i.hash=n?`#/`:``,history.replaceState(history.state,``,i),r}function C(e){try{return sessionStorage.getItem(e)===`1`}catch{return!1}}function w(){try{for(let e=0;e<sessionStorage.length;e++)if(sessionStorage.key(e)?.startsWith(b))return!0}catch{}return!1}function T(e){try{sessionStorage.setItem(e,`1`)}catch{}}function E(e,t){let n=document.createElement(`iframe`);n.src=`${e}${g(t)}`,n.hidden=!0,n.tabIndex=-1,n.title=`ViteHub Comments`,n.setAttribute(`aria-hidden`,`true`),n.setAttribute(`data-comments-ui`,``);let r=new MessageChannel,i=new Map,a=new Set,o=0,s={call:(e,t)=>new Promise((n,a)=>{let s=++o,c=setTimeout(()=>{i.delete(s),a(p(0))},v);i.set(s,e=>{clearTimeout(c),e.ok?n(e):a(f(e.error))}),r.port1.postMessage({id:s,method:e,input:t})}),onChange(e){return a.add(e),()=>a.delete(e)}};return new Promise((t,o)=>{let c=setTimeout(()=>o(p(0)),_);r.port1.addEventListener(`message`,({data:e})=>{if(typeof e!=`object`||!e)return;let n=Reflect.get(e,`event`);if(n===`ready`)clearTimeout(c),t(s);else if(n===`changed`)for(let e of a)e();else{let t=Reflect.get(e,`id`),n=typeof t==`number`?i.get(t):void 0;if(!n||typeof t!=`number`)return;i.delete(t),n(e)}}),r.port1.start(),n.addEventListener(`load`,()=>n.contentWindow?.postMessage({type:m},e,[r.port2]),{once:!0}),n.addEventListener(`error`,()=>o(p(0)),{once:!0}),document.documentElement.append(n)})}async function D(e,t){return await new Promise(n=>{let r=setTimeout(()=>i(!1),y);function i(t){clearTimeout(r),e.removeEventListener(`message`,a),n(t)}function a({data:e}){e.type===`redeemed`&&e.code===t&&i(!0)}e.addEventListener(`message`,a),e.postMessage({type:`code`,code:t})})}function O(){return import(new URL(`hosted-comments/tools.js`,``+import.meta.url).href)}async function k(e,t,r,i=n(location.search,document.cookie),a){let o=S(a!==void 0),s=`${b}${e}`;if(!o&&!C(s)&&!i)return;T(s);let c=new BroadcastChannel(h(e)),l=E(t,e),u=async e=>(await(await l).call(`redeem`,e)).value===!0,d=O(),f={id:e,console:t,...r?{repository:r}:{},...a?{consoleUrl:a}:{}};c.addEventListener(`message`,({data:e})=>{e.type===`code`&&u(e.code).then(t=>{t&&(c.postMessage({type:`redeemed`,code:e.code}),d.then(({mountHostedComments:e})=>e(l,f)))},()=>void 0)});let p=o?await u(o).catch(()=>!1):!1;if(o&&!p&&await D(c,o)){window.close();return}let{mountHostedComments:m}=await d;await m(l,f)}function A(e){return typeof e==`object`&&!!e&&typeof Reflect.get(e,`id`)==`string`&&typeof Reflect.get(e,`team`)==`string`}async function j(e,t,r){let i=n(location.search,``)||w(),a=x.test(location.hash);if(!i&&!a)return;let o=new URL(`/comments/project`,t);for(let t of e)o.searchParams.append(`key`,t);o.searchParams.set(`base`,r);let s=await fetch(o,{credentials:`omit`}).then(e=>e.ok?e.json():void 0).catch(()=>void 0),c=typeof s==`object`&&s?Reflect.get(s,`projects`):void 0,l=Array.isArray(c)?c.filter(A):[],u=e=>{let n=new URL(`/open`,t);return n.searchParams.set(`project`,`${location.origin}${r}`),n.searchParams.set(`path`,`/`),e&&n.searchParams.set(`app`,e),n.href},d=e=>k(e,t,void 0,!0,u(e)),f=a?new URLSearchParams(location.search).get(`vhp`):null,p=l.filter(e=>C(`${b}${e.id}`)),m=f?l.find(e=>e.id===f):l.length===1?l[0]:p.length===1?p[0]:void 0;if(m)return await d(m.id);a&&S(!0);let{mountHostedProjectChoice:h}=await O();await h(u(),l.map(e=>({team:e.team,choose:()=>void d(e.id)})))}var M=document.querySelector(`script[data-vitehub-comments], script[data-vitehub-console-key]`),N=new URL(import.meta.url).origin,P=M?.dataset.vitehubComments,F=M?.dataset.vitehubConsoleKey?.split(/\s+/).filter(Boolean)??[];P?k(P,N,i(M?.dataset.vitehubRepo)):F.length&&j(F,N,M?.dataset.vitehubBase??``);
|
|
@@ -1,104 +1,6 @@
|
|
|
1
1
|
import { D as CommentUser, T as CommentThread, n as CommentActor, s as CommentContext, w as CommentSubject, y as CommentMessage } from "./types-BX3vH18p.js";
|
|
2
|
-
import {
|
|
3
|
-
import "./store-DvNTDNgn.js";
|
|
4
|
-
import { _ as ListCommentThreadsOptions, g as FindCommentThreadInput, h as EditCommentInput, m as DefineCommentsOptions, o as CommentsErrorCode, p as CreateCommentThreadInput, v as ReplyInput, y as ReplyOptions } from "./types-l6GOb_yc.js";
|
|
5
|
-
import { n as commentSends, t as CommentSendState } from "./database-CPua6Q6_.js";
|
|
2
|
+
import { D as CommentsPolicyGate, c as CreateCommentThreadInput, d as FindCommentThreadInput, f as ListCommentThreadsOptions, h as CommentAction, j as CommentsUser, l as DefineCommentsOptions, m as ReplyOptions, p as ReplyInput, t as CommentsErrorCode, u as EditCommentInput } from "./types-qzJKgWYS.js";
|
|
6
3
|
import { Result } from "@vite-hub/runtime";
|
|
7
|
-
type SendRow = typeof commentSends.$inferSelect;
|
|
8
|
-
interface EndpointLike {
|
|
9
|
-
id: string;
|
|
10
|
-
kind: "url" | "inbox";
|
|
11
|
-
agent: string | null;
|
|
12
|
-
host: string | null;
|
|
13
|
-
disabledAt: number | null;
|
|
14
|
-
}
|
|
15
|
-
interface PairingLike {
|
|
16
|
-
state: "waiting" | "paired" | "used" | "refused";
|
|
17
|
-
agent: string | null;
|
|
18
|
-
host: string | null;
|
|
19
|
-
address: string | null;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* The parts of `@vite-hub/webhooks` that Send uses: member pairing and member endpoints. The generated plugin imports the
|
|
23
|
-
* package only when `send` is on.
|
|
24
|
-
*/
|
|
25
|
-
interface CommentSendWebhooks {
|
|
26
|
-
startMemberPairing: (owner: string) => Promise<Result<{
|
|
27
|
-
code: string;
|
|
28
|
-
secret: string;
|
|
29
|
-
expiresAt: number;
|
|
30
|
-
}, string>>;
|
|
31
|
-
pairMemberEndpoint: (input: unknown, options?: {
|
|
32
|
-
hosts?: readonly string[];
|
|
33
|
-
}) => Promise<Result<{
|
|
34
|
-
status: "paired";
|
|
35
|
-
pairing: PairingLike;
|
|
36
|
-
} | {
|
|
37
|
-
status: "expired" | "used";
|
|
38
|
-
} | {
|
|
39
|
-
status: "refused";
|
|
40
|
-
reason: string;
|
|
41
|
-
}, string>>;
|
|
42
|
-
refuseMemberPairing: (code: string) => Promise<Result<boolean, string>>;
|
|
43
|
-
getMemberPairing: (owner: string, code: string) => Promise<Result<PairingLike | null, string>>;
|
|
44
|
-
cancelMemberPairing: (owner: string, code: string) => Promise<Result<void, string>>;
|
|
45
|
-
allowMemberPairing: (owner: string, code: string, options: {
|
|
46
|
-
name: string | ((pairing: PairingLike) => string);
|
|
47
|
-
ownerName?: string;
|
|
48
|
-
ownerEmail?: string;
|
|
49
|
-
hosts?: readonly string[];
|
|
50
|
-
}) => Promise<Result<{
|
|
51
|
-
status: "allowed";
|
|
52
|
-
endpoint: EndpointLike;
|
|
53
|
-
pairing: PairingLike;
|
|
54
|
-
} | {
|
|
55
|
-
status: "expired" | "not-owner";
|
|
56
|
-
}, string>>;
|
|
57
|
-
getMemberEndpoint: (owner: string, options?: {
|
|
58
|
-
address?: string;
|
|
59
|
-
endpointId?: string;
|
|
60
|
-
}) => Promise<Result<EndpointLike | null, string>>;
|
|
61
|
-
getMemberDelivery: (id: string) => Promise<{
|
|
62
|
-
state: "pending" | "sending" | "sent" | "dead" | "cancelled";
|
|
63
|
-
inbox: boolean;
|
|
64
|
-
} | undefined>;
|
|
65
|
-
sendToMemberEndpoint: (owner: string, body: unknown, options: {
|
|
66
|
-
event: string;
|
|
67
|
-
key: string;
|
|
68
|
-
endpointId: string;
|
|
69
|
-
deliveryId: string;
|
|
70
|
-
sealBody: boolean;
|
|
71
|
-
hosts?: readonly string[];
|
|
72
|
-
}) => Promise<Result<{
|
|
73
|
-
id: string;
|
|
74
|
-
status: "sent" | "inbox" | "pending" | "failed";
|
|
75
|
-
}, string>>;
|
|
76
|
-
}
|
|
77
|
-
/** A thread of a send as its reader gets it: the thread, and whether it is the sender's ask or a quote. */
|
|
78
|
-
type CommentSendThread = CommentThread & {
|
|
79
|
-
role: "ask" | "quote";
|
|
80
|
-
};
|
|
81
|
-
/** What a read token, or `comments_get_send`, opens: the send and exactly its threads, as the sender may read them. */
|
|
82
|
-
interface CommentSendView {
|
|
83
|
-
send: {
|
|
84
|
-
id: string;
|
|
85
|
-
page: string;
|
|
86
|
-
subject: CommentSubject;
|
|
87
|
-
state: SendRow["state"];
|
|
88
|
-
createdAt: number;
|
|
89
|
-
};
|
|
90
|
-
threads: CommentSendThread[];
|
|
91
|
-
}
|
|
92
|
-
/** What the server checked before a read, as `comments.can()` takes it. */
|
|
93
|
-
interface CommentSendPolicy {
|
|
94
|
-
gate?: CommentsPolicyGate;
|
|
95
|
-
console?: boolean;
|
|
96
|
-
}
|
|
97
|
-
/** Which sends `listOwn` returns. Default: the sent and working ones, at most 20. */
|
|
98
|
-
interface CommentSendListOptions extends CommentSendPolicy {
|
|
99
|
-
states?: readonly Extract<CommentSendState, "sent" | "working" | "done">[];
|
|
100
|
-
limit?: number;
|
|
101
|
-
}
|
|
102
4
|
/**
|
|
103
5
|
* The context of a thread as label and value pairs, in the order a person reads them: page, element, components,
|
|
104
6
|
* browser, build. The Console and Agent tools show these.
|
|
@@ -134,7 +36,7 @@ interface Comments {
|
|
|
134
36
|
by: CommentUser;
|
|
135
37
|
actor?: CommentActor;
|
|
136
38
|
}): Promise<Result<CommentThread, Codes<"COMMENTS_NOT_INSTALLED" | "COMMENTS_NOT_FOUND">>>;
|
|
137
|
-
/**
|
|
39
|
+
/** Opens a resolved thread again. */
|
|
138
40
|
reopen(threadId: string): Promise<Result<CommentThread, Codes<"COMMENTS_NOT_INSTALLED" | "COMMENTS_NOT_FOUND">>>;
|
|
139
41
|
/** Deletes a thread and all its messages. */
|
|
140
42
|
remove(threadId: string): Promise<Result<void, Codes<"COMMENTS_NOT_INSTALLED" | "COMMENTS_NOT_FOUND">>>;
|
|
@@ -166,24 +68,14 @@ interface Comments {
|
|
|
166
68
|
limit?: number;
|
|
167
69
|
gate?: CommentsPolicyGate;
|
|
168
70
|
}): Promise<Result<CommentUser[], Codes<"COMMENTS_NOT_INSTALLED">>>;
|
|
169
|
-
/**
|
|
170
|
-
* With `send`: the sends of `user`, newest first, with the threads that `user` may still read. Default: the ones that
|
|
171
|
-
* reached the agent and that it has not finished, at most 20. As it scans, it marks finished sends as done.
|
|
172
|
-
*/
|
|
173
|
-
listSends(user: CommentsUser, options?: CommentSendListOptions): Promise<Result<CommentSendView[], Codes<"COMMENTS_NOT_INSTALLED" | "COMMENTS_SEND_OFF">>>;
|
|
174
|
-
/**
|
|
175
|
-
* With `send`: a send of `user` with the threads that `user` may still read, as `comments_get_send` opens it. A send
|
|
176
|
-
* that reached the agent becomes `working`, also while its delivery waits for the receiver's answer.
|
|
177
|
-
*/
|
|
178
|
-
readSend(user: CommentsUser, id: string, policy?: CommentSendPolicy): Promise<Result<CommentSendView, Codes<"COMMENTS_NOT_INSTALLED" | "COMMENTS_NOT_FOUND" | "COMMENTS_SEND_OFF">>>;
|
|
179
71
|
/**
|
|
180
72
|
* With `forge`: brings the thread's pull request comments in line with the thread now, and posts what failed
|
|
181
73
|
* before. Every change starts this on its own; `flush()` waits for it.
|
|
182
74
|
*/
|
|
183
75
|
sync(threadId: string): Promise<void>;
|
|
184
|
-
/** Waits for the pull request syncs
|
|
76
|
+
/** Waits for the pull request syncs, `onMention` calls, and `onComment` `waitUntil` work that earlier changes started. On Cloudflare, pass it to `waitUntil`. */
|
|
185
77
|
flush(): Promise<void>;
|
|
186
78
|
}
|
|
187
79
|
/** Defines Comments for the app: the access policy, the people, the hooks, and the trusted server API. */
|
|
188
80
|
declare function defineComments(options?: DefineCommentsOptions): Comments;
|
|
189
|
-
export {
|
|
81
|
+
export { defineComments as n, describeCommentContext as r, Comments as t };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { A as ElementAnchor, C as CommentStatusInput, D as CommentUser, E as CommentUploadInput, M as PageAnchor, N as TextAnchor, O as CommentUsersInput, S as CommentStatus, T as CommentThread, _ as CommentListCursor, a as CommentBuild, b as CommentMetadata, c as CommentCreateInput, d as CommentDeliveryError, f as CommentEditInput, g as CommentGetInput, h as CommentForgeLink, i as CommentAttachment, j as ImageAnchor, k as CommentsTransport, l as CommentDeleteInput, m as CommentFiles, n as CommentActor, o as CommentComponent, p as CommentEvent, r as CommentAnchor, s as CommentContext, t as AreaAnchor, u as CommentDelivery, v as CommentListQuery, w as CommentSubject, x as CommentReplyInput, y as CommentMessage } from "./types-BX3vH18p.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
export { type AreaAnchor, type CommentAction, type CommentActor, type CommentAnchor, type CommentAttachment, type CommentBuild, type CommentComponent, type CommentContext, type CommentCreateInput, type CommentDeleteInput, type CommentDelivery, type CommentDeliveryError, type CommentEditInput, type CommentEvent, type CommentFiles, type CommentForgeLink, type CommentGetInput, type CommentListCursor, type CommentListQuery, type CommentMentionEvent, type CommentMessage, type CommentMessageEvent, type CommentMetadata, type CommentReplyInput, type CommentSendAddressContext, type CommentSendData, type CommentSendListOptions, type CommentSendOptions, type CommentSendPayloadContext, type CommentSendPolicy, type CommentSendPromptContext, type CommentSendThread, type CommentSendView, type CommentStatus, type CommentStatusInput, type CommentSubject, type CommentSubjectDefinition, type CommentThread, type CommentUploadInput, type CommentUser, type CommentUsersInput, Comments, type CommentsAttachmentFile, type CommentsAuthorize, type CommentsAuthorizeContext, type CommentsCanMentionContext, type CommentsDefinition, type CommentsErrorCode, type CommentsForgeOptions, type CommentsForgeTarget, type CommentsGitHubAccess, type CommentsIdentifyContext, type CommentsPageContext, type CommentsPageSubject, type CommentsPeople, type CommentsPolicyGate, type CommentsRateLimit, type CommentsReadAttachmentContext, type CommentsRequestEvent, type CommentsStoreAttachmentContext, type CommentsTransport, type CommentsUser, type CreateCommentThreadInput, type DefineCommentsOptions, type EditCommentInput, type ElementAnchor, type FindCommentThreadInput, type ImageAnchor, type ListCommentThreadsOptions, type PageAnchor, type ReplyInput, type ReplyOptions, type TextAnchor, commentRoom, commentsRoleAllows, defaultPolicy, defineCommentSubject, defineComments, describeCommentContext, normalizeCommentPage };
|
|
2
|
+
import { A as CommentsStoreAttachmentContext, C as CommentsDefinition, D as CommentsPolicyGate, E as CommentsPeopleSearchContext, M as commentsRoleAllows, N as defaultPolicy, O as CommentsRateLimit, P as defineCommentSubject, S as CommentsCanMentionContext, T as CommentsPeople, _ as CommentMessageEvent, a as CommentsPageContext, b as CommentsAuthorize, c as CreateCommentThreadInput, d as FindCommentThreadInput, f as ListCommentThreadsOptions, g as CommentMentionEvent, h as CommentAction, i as CommentsIdentifyContext, j as CommentsUser, k as CommentsReadAttachmentContext, l as DefineCommentsOptions, m as ReplyOptions, n as CommentsForgeOptions, o as CommentsPageSubject, p as ReplyInput, r as CommentsForgeTarget, s as CommentsRequestEvent, t as CommentsErrorCode, u as EditCommentInput, v as CommentSubjectDefinition, w as CommentsGitHubAccess, x as CommentsAuthorizeContext, y as CommentsAttachmentFile } from "./types-qzJKgWYS.js";
|
|
3
|
+
import { n as defineComments, r as describeCommentContext, t as Comments } from "./index-d6NsDxu9.js";
|
|
4
|
+
import { c as normalizeCommentPage, t as commentRoom } from "./page-BgvzzsJb.js";
|
|
5
|
+
export { type AreaAnchor, type CommentAction, type CommentActor, type CommentAnchor, type CommentAttachment, type CommentBuild, type CommentComponent, type CommentContext, type CommentCreateInput, type CommentDeleteInput, type CommentDelivery, type CommentDeliveryError, type CommentEditInput, type CommentEvent, type CommentFiles, type CommentForgeLink, type CommentGetInput, type CommentListCursor, type CommentListQuery, type CommentMentionEvent, type CommentMessage, type CommentMessageEvent, type CommentMetadata, type CommentReplyInput, type CommentStatus, type CommentStatusInput, type CommentSubject, type CommentSubjectDefinition, type CommentThread, type CommentUploadInput, type CommentUser, type CommentUsersInput, Comments, type CommentsAttachmentFile, type CommentsAuthorize, type CommentsAuthorizeContext, type CommentsCanMentionContext, type CommentsDefinition, type CommentsErrorCode, type CommentsForgeOptions, type CommentsForgeTarget, type CommentsGitHubAccess, type CommentsIdentifyContext, type CommentsPageContext, type CommentsPageSubject, type CommentsPeople, type CommentsPeopleSearchContext, type CommentsPolicyGate, type CommentsRateLimit, type CommentsReadAttachmentContext, type CommentsRequestEvent, type CommentsStoreAttachmentContext, type CommentsTransport, type CommentsUser, type CreateCommentThreadInput, type DefineCommentsOptions, type EditCommentInput, type ElementAnchor, type FindCommentThreadInput, type ImageAnchor, type ListCommentThreadsOptions, type PageAnchor, type ReplyInput, type ReplyOptions, type TextAnchor, commentRoom, commentsRoleAllows, defaultPolicy, defineCommentSubject, defineComments, describeCommentContext, normalizeCommentPage };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { C as threadChanged, S as suggest, T as clientRateLimitIssue, a as createThread, b as scopeOf, c as earlierThread, g as replyToThread, l as editMessage, r as can, s as earlierReply } from "./service-
|
|
2
|
-
import { a as defineCommentSubject, i as defaultPolicy, n as commentsRoleAllows, s as markCommentsDefinition } from "./define-
|
|
3
|
-
import { t as commentsErrorDiagnostics } from "./errors-
|
|
4
|
-
import { t as commentsErrors } from "./errors-
|
|
5
|
-
import { a as
|
|
6
|
-
import {
|
|
1
|
+
import { C as threadChanged, S as suggest, T as clientRateLimitIssue, a as createThread, b as scopeOf, c as earlierThread, g as replyToThread, l as editMessage, r as can, s as earlierReply } from "./service-DaMq8TBw.js";
|
|
2
|
+
import { a as defineCommentSubject, i as defaultPolicy, n as commentsRoleAllows, s as markCommentsDefinition } from "./define-C-LUOouq.js";
|
|
3
|
+
import { t as commentsErrorDiagnostics } from "./errors-DeSEHzRf.js";
|
|
4
|
+
import { t as commentsErrors } from "./errors-C5utwZ5H.js";
|
|
5
|
+
import { a as runtimes, i as runtimeOf, t as pendingKey } from "./installed-BqQKo6WC.js";
|
|
6
|
+
import { n as commentRoom, p as normalizeCommentPage } from "./page-CDhmXO-y.js";
|
|
7
7
|
import { t as describeCommentContext } from "./context-DbkBjITZ.js";
|
|
8
8
|
// src/index.ts
|
|
9
9
|
/** A thread that someone deleted during the change: the store reads it again and finds nothing. */
|
|
@@ -157,7 +157,6 @@ function defineComments(options = {}) {
|
|
|
157
157
|
const thread = await current.store.setStatus(threadId, "open", { id: "" }, Date.now()).catch(gone);
|
|
158
158
|
if (!thread) return notFound(threadId);
|
|
159
159
|
await threadChanged(current, thread);
|
|
160
|
-
await current.reopened?.(thread);
|
|
161
160
|
return [void 0, thread];
|
|
162
161
|
},
|
|
163
162
|
async remove(threadId) {
|
|
@@ -217,19 +216,6 @@ function defineComments(options = {}) {
|
|
|
217
216
|
...subject ? { subject } : {}
|
|
218
217
|
})];
|
|
219
218
|
},
|
|
220
|
-
async listSends(user, listOptions) {
|
|
221
|
-
if (!await runtime()) return notInstalled();
|
|
222
|
-
const service = await commentSendOf(comments);
|
|
223
|
-
if (!service) return [commentsErrors.COMMENTS_SEND_OFF(), void 0];
|
|
224
|
-
return [void 0, await service.listOwn(user, listOptions)];
|
|
225
|
-
},
|
|
226
|
-
async readSend(user, id, policy) {
|
|
227
|
-
if (!await runtime()) return notInstalled();
|
|
228
|
-
const service = await commentSendOf(comments);
|
|
229
|
-
if (!service) return [commentsErrors.COMMENTS_SEND_OFF(), void 0];
|
|
230
|
-
const opened = await service.readOwn(user, id, policy);
|
|
231
|
-
return opened ? [void 0, opened] : notFound(id);
|
|
232
|
-
},
|
|
233
219
|
async sync(threadId) {
|
|
234
220
|
await runtime();
|
|
235
221
|
await runtimes.get(comments)?.sync?.(threadId);
|