@vite-hub/comments 0.5.1 → 0.6.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 +21 -4
- package/dist/{client-diagnostics-CvfTW5d4.js → client-diagnostics-D987sEK7.js} +4 -0
- package/dist/client.d.ts +96 -19
- package/dist/client.js +525 -79
- package/dist/{console-CK2F53QP.d.ts → console-CCLX_eIk.d.ts} +1 -1
- package/dist/{database-BkPoOdZr.js → database-Cguz3hZL.js} +1 -1
- package/dist/database.js +1 -1
- package/dist/{define-9uMM3Ewc.js → define-C2tnAtBU.js} +2 -2
- package/dist/{errors-DFNiJg67.js → errors-ByCRdInk.js} +1 -1
- package/dist/hosted/hosted-comments/{client-B3dlmmQd.js → client-Czl2zu9P.js} +3 -3
- package/dist/hosted/hosted-comments/frame.js +1 -1
- package/dist/hosted/hosted-comments/overlay-DpS0P-nd.js +186 -0
- package/dist/hosted/hosted-comments/protocol-DuB0Zhs-.js +1 -0
- package/dist/hosted/hosted-comments/rest-transport-CKZG_jZ4.js +1 -0
- package/dist/hosted/hosted-comments/tools-D8xg-kDW.js +126 -0
- package/dist/hosted/hosted-comments.js +13 -3
- package/dist/{index-BEnHTj2Z.d.ts → index-D1T7RJ4R.d.ts} +5 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +11 -10
- package/dist/{install-B-FQpi47.d.ts → install-9L4ASzUC.d.ts} +11 -2
- package/dist/{install-BUXxryut.js → install-D6hXZaSN.js} +45 -19
- package/dist/{installed-C9SkldMi.js → installed-bPUnazFf.js} +1 -1
- package/dist/{operations-CKC_lMG_.js → operations-B1ALn4VS.js} +7 -7
- package/dist/{operations-Cic9A9e_.d.ts → operations-BkkrI8a3.d.ts} +1 -1
- package/dist/operations.d.ts +2 -2
- package/dist/operations.js +2 -2
- package/dist/overlay/{client-CerbVjTz.js → client-C7ftI-CB.js} +3 -3
- package/dist/overlay/overlay.js +42 -16
- package/dist/page/loader.js +1 -1
- package/dist/{page-xzgZ6DGm.js → page-2NzFladc.js} +5 -1
- package/dist/{plugin-B2hETRii.js → plugin-l4sPt5-n.js} +13 -7
- package/dist/realtime.d.ts +11 -3
- package/dist/realtime.js +14 -6
- package/dist/{rpc-BKY7XRlR.js → rpc-BYmbVkr8.js} +1 -1
- package/dist/rpc.js +1 -1
- package/dist/runtime/auth.js +1 -1
- package/dist/runtime/console.d.ts +1 -1
- package/dist/runtime/console.js +2 -2
- package/dist/runtime/index.d.ts +42 -10
- package/dist/runtime/index.js +16 -8
- package/dist/{server-BGbD7H5s.js → server-DvSehkPP.js} +1 -1
- package/dist/server.d.ts +3 -3
- package/dist/server.js +6 -6
- package/dist/{service-DDD4Ubxd.js → service-BIGe1Hpo.js} +11 -6
- package/dist/{service-CPiWPoiY.d.ts → service-IvgrI4XM.d.ts} +2 -0
- package/dist/{session-BGN6Vlm6.js → session-CCRLR9bf.js} +24 -9
- package/dist/{session-CTh9nisq.d.ts → session-CN4irEqf.d.ts} +1 -1
- package/dist/testing.js +1 -1
- package/dist/vite.d.ts +19 -2
- package/dist/vite.js +39 -10
- package/package.json +7 -7
- package/dist/hosted/hosted-comments/overlay-4-mWX4Uz.js +0 -170
- package/dist/hosted/hosted-comments/protocol-BHvtQKte.js +0 -1
- package/dist/hosted/hosted-comments/rest-transport-D-9_pNqZ.js +0 -1
- package/dist/hosted/hosted-comments/tools-CdwnUCOr.js +0 -126
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { i as installCommentsRuntime } from "./server-
|
|
1
|
+
import { i as installCommentsRuntime } from "./server-DvSehkPP.js";
|
|
2
2
|
import { r as guestIdPrefix } from "./identity-CT7-UGmS.js";
|
|
3
|
-
import { t as commentsErrorDiagnostics } from "./errors-
|
|
4
|
-
import { a as commentsSchemaGate, d as commentForge, f as commentMessages, m as commentsSchema, p as commentThreads, r as commentSendsTables, t as commentSends, u as commentCounters } from "./database-
|
|
3
|
+
import { t as commentsErrorDiagnostics } from "./errors-ByCRdInk.js";
|
|
4
|
+
import { a as commentsSchemaGate, d as commentForge, f as commentMessages, m as commentsSchema, p as commentThreads, r as commentSendsTables, t as commentSends, u as commentCounters } from "./database-Cguz3hZL.js";
|
|
5
5
|
import { t as logFailure } from "./request-log-DllKQXj7.js";
|
|
6
6
|
import { i as getActiveCloudflareBinding, n as recentGitHubToken } from "./tokens-Bx4lZ0yt.js";
|
|
7
7
|
import { t as describeCommentContext } from "./context-DbkBjITZ.js";
|
|
8
8
|
import { t as invariant } from "./invariant-CmdvZ3vp.js";
|
|
9
9
|
import { n as isSecureOrigin } from "./request-origin-YPzfE2eh.js";
|
|
10
10
|
import { t as commentsErrors } from "./errors-C0VwRHiy.js";
|
|
11
|
-
import { n as pendingKey, o as runtimes } from "./installed-
|
|
11
|
+
import { n as pendingKey, o as runtimes } from "./installed-bPUnazFf.js";
|
|
12
12
|
import { getStandardContext } from "@vite-hub/runtime/internal/h3";
|
|
13
13
|
import * as v from "valibot";
|
|
14
14
|
import { and, asc, desc, eq, getTableName, gt, gte, inArray, isNotNull, isNull, like, lt, lte, or, sql } from "drizzle-orm";
|
|
@@ -1464,9 +1464,12 @@ function createCommentSendService(options) {
|
|
|
1464
1464
|
const forbidden = () => [commentsErrors.COMMENTS_FORBIDDEN({ action: "send" }), void 0];
|
|
1465
1465
|
const insecure = (origin) => isSecureOrigin(origin) ? void 0 : [commentsErrors.COMMENTS_SEND_INSECURE({ origin }), void 0];
|
|
1466
1466
|
const deliveryFailed = "The agent's receiver did not take the send.";
|
|
1467
|
+
async function deliveryOf(row) {
|
|
1468
|
+
return row.delivery ? await (await webhooks()).getMemberDelivery(row.delivery) : void 0;
|
|
1469
|
+
}
|
|
1467
1470
|
async function reconcile(row) {
|
|
1468
1471
|
if (row.state !== "pending") return row;
|
|
1469
|
-
const delivery =
|
|
1472
|
+
const delivery = (await deliveryOf(row))?.state;
|
|
1470
1473
|
const state = delivery === "sent" ? "sent" : delivery === "dead" || delivery === "cancelled" || !delivery && Date.now() - row.updatedAt > 6e4 ? "failed" : "pending";
|
|
1471
1474
|
if (state === "pending") return row;
|
|
1472
1475
|
const error = state === "failed" ? deliveryFailed : null;
|
|
@@ -1606,12 +1609,13 @@ function createCommentSendService(options) {
|
|
|
1606
1609
|
}
|
|
1607
1610
|
async function view(row, user, policy) {
|
|
1608
1611
|
const opened = await viewOf(row, user, policy);
|
|
1609
|
-
|
|
1612
|
+
if (row.state !== "sent" && row.state !== "pending") return opened;
|
|
1613
|
+
const state = await store.setSendState(row.id, ["pending", "sent"], "working", Date.now()) ? "working" : (await store.send(row.id))?.state ?? row.state;
|
|
1610
1614
|
return {
|
|
1611
1615
|
...opened,
|
|
1612
1616
|
send: {
|
|
1613
1617
|
...opened.send,
|
|
1614
|
-
state
|
|
1618
|
+
state
|
|
1615
1619
|
}
|
|
1616
1620
|
};
|
|
1617
1621
|
}
|
|
@@ -1622,13 +1626,15 @@ function createCommentSendService(options) {
|
|
|
1622
1626
|
status: "failed",
|
|
1623
1627
|
reason: "No agent is paired. Press Send to pair one."
|
|
1624
1628
|
};
|
|
1629
|
+
const inbox = endpoint.kind === "inbox";
|
|
1625
1630
|
const resultOf = (row) => row.state === "failed" ? {
|
|
1626
1631
|
status: "failed",
|
|
1627
1632
|
reason: row.error ?? deliveryFailed
|
|
1628
1633
|
} : {
|
|
1629
1634
|
status: row.state === "pending" ? "pending" : "sent",
|
|
1630
1635
|
id: row.id,
|
|
1631
|
-
...row.thread ? { thread: row.thread } : {}
|
|
1636
|
+
...row.thread ? { thread: row.thread } : {},
|
|
1637
|
+
inbox
|
|
1632
1638
|
};
|
|
1633
1639
|
const live = [
|
|
1634
1640
|
"pending",
|
|
@@ -1705,7 +1711,10 @@ function createCommentSendService(options) {
|
|
|
1705
1711
|
};
|
|
1706
1712
|
}
|
|
1707
1713
|
const fail = async (reason) => {
|
|
1708
|
-
await store.setSendState(id, ["pending"], "failed", Date.now(), { error: reason })
|
|
1714
|
+
if (!await store.setSendState(id, ["pending"], "failed", Date.now(), { error: reason })) {
|
|
1715
|
+
const current = await store.send(id);
|
|
1716
|
+
if (current) return resultOf(current);
|
|
1717
|
+
}
|
|
1709
1718
|
return {
|
|
1710
1719
|
status: "failed",
|
|
1711
1720
|
reason
|
|
@@ -1753,11 +1762,15 @@ function createCommentSendService(options) {
|
|
|
1753
1762
|
});
|
|
1754
1763
|
if (error || delivered.status === "failed") return fail(error?.why ?? deliveryFailed);
|
|
1755
1764
|
const status = delivered.status === "pending" ? "pending" : "sent";
|
|
1756
|
-
await store.setSendState(id, ["pending"], status, Date.now(), { delivery: delivered.id })
|
|
1765
|
+
if (!await store.setSendState(id, ["pending"], status, Date.now(), { delivery: delivered.id })) {
|
|
1766
|
+
const current = await store.send(id);
|
|
1767
|
+
if (current) return resultOf(current);
|
|
1768
|
+
}
|
|
1757
1769
|
return {
|
|
1758
1770
|
status,
|
|
1759
1771
|
id,
|
|
1760
|
-
...thread ? { thread } : {}
|
|
1772
|
+
...thread ? { thread } : {},
|
|
1773
|
+
inbox
|
|
1761
1774
|
};
|
|
1762
1775
|
}
|
|
1763
1776
|
return {
|
|
@@ -1777,20 +1790,25 @@ function createCommentSendService(options) {
|
|
|
1777
1790
|
]);
|
|
1778
1791
|
const latest = candidate && await reconcile(candidate);
|
|
1779
1792
|
const agent = agentOf(endpoint);
|
|
1780
|
-
let
|
|
1793
|
+
let last = {};
|
|
1781
1794
|
if (latest?.state === "sent" || latest?.state === "working") {
|
|
1782
1795
|
const byId = new Map(open.map((thread) => [thread.id, thread]));
|
|
1783
|
-
if (!finished(latest, (id) => byId.get(id)))
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1796
|
+
if (!finished(latest, (id) => byId.get(id))) {
|
|
1797
|
+
const send = {
|
|
1798
|
+
id: latest.id,
|
|
1799
|
+
...latest.thread ? { thread: latest.thread } : {}
|
|
1800
|
+
};
|
|
1801
|
+
last = latest.state === "sent" ? { sent: {
|
|
1802
|
+
...send,
|
|
1803
|
+
inbox: (await deliveryOf(latest))?.inbox ?? false
|
|
1804
|
+
} } : { working: send };
|
|
1805
|
+
} else await store.setSendState(latest.id, ["sent", "working"], "done", now);
|
|
1788
1806
|
}
|
|
1789
1807
|
return {
|
|
1790
1808
|
count: ready.length,
|
|
1791
1809
|
selection: await selectionOf(caller.subject, ready),
|
|
1792
1810
|
...agent ? { agent } : {},
|
|
1793
|
-
...
|
|
1811
|
+
...last,
|
|
1794
1812
|
...latest?.state === "pending" ? { pending: true } : {},
|
|
1795
1813
|
...limitedUntil === void 0 ? {} : { retryAt: limitedUntil }
|
|
1796
1814
|
};
|
|
@@ -1904,6 +1922,7 @@ function createCommentSendService(options) {
|
|
|
1904
1922
|
if (allowed.status !== "allowed") return allowed.status === "not-owner" ? forbidden() : [commentsErrors.COMMENTS_SEND_CODE_EXPIRED(), void 0];
|
|
1905
1923
|
return [void 0, await deliver(caller, user, {
|
|
1906
1924
|
id: allowed.endpoint.id,
|
|
1925
|
+
kind: allowed.endpoint.kind,
|
|
1907
1926
|
thread: allowed.pairing.address
|
|
1908
1927
|
}, confirmed)];
|
|
1909
1928
|
},
|
|
@@ -1930,7 +1949,12 @@ function createCommentSendService(options) {
|
|
|
1930
1949
|
const found = id ? await store.send(id) : await store.latestSend(user.id, void 0, ["pending", "sent"]);
|
|
1931
1950
|
if (found?.member !== user.id) return void 0;
|
|
1932
1951
|
const row = await reconcile(found);
|
|
1933
|
-
if (row.state === "failed"
|
|
1952
|
+
if (row.state === "failed") return void 0;
|
|
1953
|
+
if (row.state === "pending") {
|
|
1954
|
+
if (!id) return void 0;
|
|
1955
|
+
const delivery = (await deliveryOf(row))?.state;
|
|
1956
|
+
if (delivery !== "sending" && delivery !== "sent") return void 0;
|
|
1957
|
+
}
|
|
1934
1958
|
return view(row, user, policy);
|
|
1935
1959
|
},
|
|
1936
1960
|
async listOwn(user, options = {}) {
|
|
@@ -2056,6 +2080,8 @@ function installComments(comments, install) {
|
|
|
2056
2080
|
...install.attachments ? { attachments: install.attachments } : {},
|
|
2057
2081
|
...install.rateLimit ? { rateLimit: install.rateLimit } : {}
|
|
2058
2082
|
};
|
|
2083
|
+
const realtime = install.realtime;
|
|
2084
|
+
if (realtime && !install.tenant) runtime.changed = async (thread) => (await realtime()).notifyCommentsChange(thread);
|
|
2059
2085
|
let sync;
|
|
2060
2086
|
if (comments.options.forge) {
|
|
2061
2087
|
const forge = createForgeSync(comments.options.forge, {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as hasCommentsRuntime, t as commentsRuntime } from "./server-
|
|
1
|
+
import { r as hasCommentsRuntime, t as commentsRuntime } from "./server-DvSehkPP.js";
|
|
2
2
|
// src/installed.ts
|
|
3
3
|
/** The runtime that `installComments()` connected to each definition. */
|
|
4
4
|
const runtimes = /* @__PURE__ */ new WeakMap();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { n as outboxAccountHeader } from "./client-files-lC6X7XyS.js";
|
|
2
|
-
import { t as commentsErrorDiagnostics } from "./errors-
|
|
2
|
+
import { t as commentsErrorDiagnostics } from "./errors-ByCRdInk.js";
|
|
3
3
|
import { n as pagePathOf, t as isPagePath } from "./path-8yqMd8zR.js";
|
|
4
4
|
import { n as isRecordOrFunction } from "./object-CAK6UYR5.js";
|
|
5
|
-
import { C as
|
|
5
|
+
import { C as threadChanged, E as createClientRateLimit, S as suggest, _ as requestIdSchema, a as createThread, c as earlierThread, d as maximumAttachmentBytes, f as maximumCommentBodyLength, g as replyToThread, h as readAttachment, l as editMessage, m as personOf, n as base64, o as deniedError, r as can, s as earlierReply, t as attachmentThread, u as fail, v as retried, w as clientAddressKey, x as storeAttachment, y as retriedReply } from "./service-BIGe1Hpo.js";
|
|
6
6
|
import { n as guestFromHeaders, t as authorOf } from "./identity-CT7-UGmS.js";
|
|
7
7
|
import { t as describeCommentContext } from "./context-DbkBjITZ.js";
|
|
8
|
-
import { t as commentsRuntime } from "./server-
|
|
8
|
+
import { t as commentsRuntime } from "./server-DvSehkPP.js";
|
|
9
9
|
import { defineDiagnostics } from "nostics";
|
|
10
10
|
import { toJsonSchema } from "@valibot/to-json-schema";
|
|
11
11
|
import { getStandardContext } from "@vite-hub/runtime/internal/h3";
|
|
@@ -905,18 +905,18 @@ const commentActions = {
|
|
|
905
905
|
}
|
|
906
906
|
if (deletesThread) {
|
|
907
907
|
if (await who.runtime.store.deleteThread(found.id, owns ? ownerId : void 0) === false) throw fail(commentsErrorDiagnostics.COMMENTS_R0009({ action: "delete" }), 403);
|
|
908
|
-
who.runtime
|
|
908
|
+
await threadChanged(who.runtime, found);
|
|
909
909
|
return null;
|
|
910
910
|
}
|
|
911
911
|
const next = await who.runtime.store.deleteMessage(found.id, target.id, Date.now());
|
|
912
|
-
who.runtime
|
|
912
|
+
await threadChanged(who.runtime, next);
|
|
913
913
|
return next;
|
|
914
914
|
},
|
|
915
915
|
async setStatus(input, who, status) {
|
|
916
916
|
const found = await load(who, input.threadId);
|
|
917
917
|
await allow(who, "resolve", { thread: found });
|
|
918
918
|
const next = await who.runtime.store.setStatus(found.id, status, author(who), Date.now(), status === "resolved" ? who.actor : void 0);
|
|
919
|
-
who.runtime
|
|
919
|
+
await threadChanged(who.runtime, next);
|
|
920
920
|
if (status === "open") await who.runtime.reopened?.(next);
|
|
921
921
|
return next;
|
|
922
922
|
},
|
|
@@ -964,7 +964,7 @@ const commentActions = {
|
|
|
964
964
|
}
|
|
965
965
|
if (thread.status !== "resolved" || thread.messages.some((message) => message.createdAt > (thread.resolvedAt ?? 0))) {
|
|
966
966
|
thread = await who.runtime.store.setStatus(thread.id, "resolved", by, Date.now(), who.actor);
|
|
967
|
-
who.runtime
|
|
967
|
+
await threadChanged(who.runtime, thread);
|
|
968
968
|
}
|
|
969
969
|
resolved.push(thread);
|
|
970
970
|
} catch (cause) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as CommentsRuntime, t as CommentsAttachmentBody } from "./service-
|
|
1
|
+
import { i as CommentsRuntime, t as CommentsAttachmentBody } from "./service-IvgrI4XM.js";
|
|
2
2
|
import { t as AnyOperation } from "./operations-8hqTi0DH.js";
|
|
3
3
|
import { f as CommentsPolicyGate, g as CommentsUser } from "./define-B1jLSPe9.js";
|
|
4
4
|
import { C as CommentStatusInput, D as CommentUser, E as CommentUploadInput, O as CommentUsersInput, T as CommentThread, c as CommentCreateInput, f as CommentEditInput, g as CommentGetInput, i as CommentAttachment, l as CommentDeleteInput, n as CommentActor, s as CommentContext, v as CommentListQuery, x as CommentReplyInput, y as CommentMessage } from "./types-BX3vH18p.js";
|
package/dist/operations.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as maximumCommentBodyLength } from "./service-
|
|
2
|
-
import { a as commentsOperations, i as commentInputSchemas, n as commentActions, r as commentAnchorSchema, t as CommentsCaller } from "./operations-
|
|
1
|
+
import { a as maximumCommentBodyLength } from "./service-IvgrI4XM.js";
|
|
2
|
+
import { a as commentsOperations, i as commentInputSchemas, n as commentActions, r as commentAnchorSchema, t as CommentsCaller } from "./operations-BkkrI8a3.js";
|
|
3
3
|
export { CommentsCaller, commentActions, commentAnchorSchema, commentInputSchemas, commentsOperations, maximumCommentBodyLength };
|
package/dist/operations.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as commentsOperations, n as commentAnchorSchema, r as commentInputSchemas, t as commentActions } from "./operations-
|
|
2
|
-
import { f as maximumCommentBodyLength } from "./service-
|
|
1
|
+
import { i as commentsOperations, n as commentAnchorSchema, r as commentInputSchemas, t as commentActions } from "./operations-B1ALn4VS.js";
|
|
2
|
+
import { f as maximumCommentBodyLength } from "./service-BIGe1Hpo.js";
|
|
3
3
|
export { commentActions, commentAnchorSchema, commentInputSchemas, commentsOperations, maximumCommentBodyLength };
|