@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.
Files changed (87) hide show
  1. package/README.md +79 -31
  2. package/dist/anchor.d.ts +7 -4
  3. package/dist/anchor.js +10 -5
  4. package/dist/client-diagnostics-CcFpkbAk.js +40 -0
  5. package/dist/client.d.ts +78 -3
  6. package/dist/client.js +198 -13
  7. package/dist/{console-BIz9t2cO.d.ts → console-h4KlhIik.d.ts} +97 -8
  8. package/dist/context-BqIsmYP1.js +61 -0
  9. package/dist/database/postgres.d.ts +738 -347
  10. package/dist/database/postgres.js +28 -7
  11. package/dist/{database-Cb2xjC1V.d.ts → database-CA1aHKN7.d.ts} +675 -276
  12. package/dist/database.d.ts +6 -98
  13. package/dist/database.js +2 -3
  14. package/dist/define-43mMR39K.js +89 -0
  15. package/dist/define-B3TF9zzn.d.ts +204 -0
  16. package/dist/errors-4gelGVmK.js +57 -0
  17. package/dist/errors-C6qptPoG.js +135 -0
  18. package/dist/errors-CyQyKAvy.d.ts +185 -0
  19. package/dist/fold-name-B7Zb3-MF.js +7 -0
  20. package/dist/{identity-3qtVC4rF.js → identity-CBOzgxSf.js} +7 -2
  21. package/dist/index-DNhy69Wt.d.ts +83 -0
  22. package/dist/index.d.ts +7 -7
  23. package/dist/index.js +196 -5
  24. package/dist/install-BcMPgPk_.js +1154 -0
  25. package/dist/install-W9ghhGoh.d.ts +36 -0
  26. package/dist/installed-B-PfERBU.js +30 -0
  27. package/dist/invariant-D8_xBqmZ.js +22 -0
  28. package/dist/migrate-B0k_0swk.d.ts +54 -0
  29. package/dist/migrate-BDQ8xqUs.js +289 -0
  30. package/dist/object-Da1zyPCR.js +11 -0
  31. package/dist/{operations-0B0QTVWX.d.ts → operations-D4A1Fcgf.d.ts} +37 -15
  32. package/dist/operations-DMMIfYPW.js +1159 -0
  33. package/dist/operations-GLeOqgMt.d.ts +257 -0
  34. package/dist/operations.d.ts +3 -7
  35. package/dist/operations.js +3 -2
  36. package/dist/overlay/client-DmsSMOzi.js +4 -0
  37. package/dist/overlay/dist-BoHMOFax.js +14 -0
  38. package/dist/overlay/dist-yIZmvSaU.js +1 -0
  39. package/dist/overlay/overlay.js +183 -177
  40. package/dist/page/loader.js +138 -18
  41. package/dist/{page-BuroSMXO.js → page-B41ozN63.js} +8 -6
  42. package/dist/{page-BtXADR6d.d.ts → page-DtbMOEMd.d.ts} +6 -5
  43. package/dist/page-tools-shared-NHUjKI8E.js +117 -0
  44. package/dist/path--zk6PEMz.js +18 -0
  45. package/dist/plugin-PS8PMYus.js +74 -0
  46. package/dist/realtime.d.ts +6 -12
  47. package/dist/realtime.js +23 -24
  48. package/dist/rpc-HBcWtg0T.d.ts +17 -0
  49. package/dist/rpc-RKPAusHp.js +153 -0
  50. package/dist/rpc.d.ts +2 -29
  51. package/dist/rpc.js +2 -75
  52. package/dist/runtime/auth.d.ts +5 -3
  53. package/dist/runtime/auth.js +8 -5
  54. package/dist/runtime/console.d.ts +1 -1
  55. package/dist/runtime/console.js +26 -21
  56. package/dist/runtime/index.d.ts +108 -60
  57. package/dist/runtime/index.js +684 -236
  58. package/dist/{server-BomGg3Gb.js → server-D8k-0GXe.js} +16 -7
  59. package/dist/server.d.ts +14 -88
  60. package/dist/server.js +7 -326
  61. package/dist/service-CFVm23k7.d.ts +158 -0
  62. package/dist/service-GHhhyQj4.js +609 -0
  63. package/dist/session-DVx-1Tym.d.ts +14 -0
  64. package/dist/session-EkudzUmm.js +503 -0
  65. package/dist/testing.d.ts +1 -1
  66. package/dist/testing.js +14 -2
  67. package/dist/tokens-DSbwkVSy.js +58 -0
  68. package/dist/types-BIS0hCEl.d.ts +124 -0
  69. package/dist/types-CZujrMFd.d.ts +322 -0
  70. package/dist/vite.d.ts +91 -87
  71. package/dist/vite.js +535 -796
  72. package/package.json +24 -27
  73. package/dist/database-BSnVrwHn.js +0 -60
  74. package/dist/database-C-ktS9Do.js +0 -95
  75. package/dist/define-BzW2Ychn.d.ts +0 -46
  76. package/dist/define-Cbhl6QVJ.js +0 -32
  77. package/dist/errors-BAQYcy3_.d.ts +0 -89
  78. package/dist/errors-DeD6wTCl.js +0 -77
  79. package/dist/h3-v1-request-DDGXJ9E7.js +0 -166
  80. package/dist/index-DklG2Etf.d.ts +0 -111
  81. package/dist/operations-NZG5dB8y.js +0 -732
  82. package/dist/page-tools-shared-D-amu6sx.js +0 -53
  83. package/dist/plugin-QElKQYkA.js +0 -725
  84. package/dist/request-DVc3M_AG.js +0 -14
  85. package/dist/src-CRTwnaEG.js +0 -1362
  86. package/dist/types-Cj8K7Vx7.d.ts +0 -176
  87. package/dist/types-Un2dcJWD.d.ts +0 -288
@@ -1,111 +0,0 @@
1
- import { C as DefineCommentsOptions$1, D as ReplyOptions, E as ReplyInput, S as CreateCommentThreadInput, T as ListCommentThreadsOptions, d as CommentThread, h as CommentsErrorCode, l as CommentMention, m as CommentsAuthorizeContext$1, o as CommentContext, r as CommentAuthor, t as Comment, w as EditCommentInput, x as CommentsUser } from "./types-Un2dcJWD.js";
2
- import { a as CommentsAuthorizeContext$2, o as CommentsDefinition } from "./define-BzW2Ychn.js";
3
- import { Result } from "@vite-hub/runtime";
4
- import { RuntimeDrizzleDatabase } from "@vite-hub/database";
5
- //#region src/definition.d.ts
6
- /** Both entry forms share a factory; each runtime supplies its own action and thread shape. */
7
- interface CommentsAuthorizeContext {
8
- user: CommentsAuthorizeContext$1["user"];
9
- action: CommentsAuthorizeContext$1["action"] | CommentsAuthorizeContext$2["action"];
10
- /** The live-site thread scope. Operations use `subject` instead. */
11
- scope?: CommentsAuthorizeContext$1["scope"];
12
- thread?: CommentsAuthorizeContext$1["thread"] | CommentsAuthorizeContext$2["thread"];
13
- actor?: CommentsAuthorizeContext$2["actor"];
14
- subject?: CommentsAuthorizeContext$2["subject"];
15
- }
16
- type DefineCommentsOptions = Omit<DefineCommentsOptions$1, "authorize"> & Omit<CommentsDefinition, "authorize"> & {
17
- authorize?: (context: CommentsAuthorizeContext) => boolean | void | Promise<boolean | void>;
18
- };
19
- //#endregion
20
- //#region src/store.d.ts
21
- type CommentsDatabase = RuntimeDrizzleDatabase<Record<string, unknown>>;
22
- //#endregion
23
- //#region src/context.d.ts
24
- /**
25
- * The context of a thread as label and value pairs, in the order a person reads them: page, element, components,
26
- * browser, build. The Console and Agent tools show these.
27
- */
28
- declare function describeCommentContext(context: CommentContext | null): Array<{
29
- label: string;
30
- value: string;
31
- }>;
32
- //#endregion
33
- //#region src/index.d.ts
34
- type Codes<T extends CommentsErrorCode> = T;
35
- /** The Comments runtime of an app: the `comments` export of `server/comments.ts`. */
36
- interface Comments {
37
- readonly options: DefineCommentsOptions$1;
38
- /** Threads with their comments, newest activity first. */
39
- list(options?: ListCommentThreadsOptions): Promise<Result<CommentThread[], Codes<"COMMENTS_NOT_INSTALLED">>>;
40
- get(id: string): Promise<Result<CommentThread, Codes<"COMMENTS_NOT_INSTALLED" | "COMMENTS_NOT_FOUND">>>;
41
- /** The thread that holds a comment, for a route that has only the comment id. */
42
- getByComment(commentId: string): Promise<Result<CommentThread, Codes<"COMMENTS_NOT_INSTALLED" | "COMMENTS_NOT_FOUND">>>;
43
- /** Thread `#number` of a scope. */
44
- getByNumber(scope: string, number: number): Promise<Result<CommentThread, Codes<"COMMENTS_NOT_INSTALLED" | "COMMENTS_NOT_FOUND">>>;
45
- /**
46
- * Starts a thread with its first comment, numbered next in its scope. Runs `onComment`. A thread of the `"pages"`
47
- * scope needs an `anchor`; other scopes keep their own anchor in `metadata`.
48
- */
49
- create(input: CreateCommentThreadInput): Promise<Result<CommentThread, Codes<"COMMENTS_NOT_INSTALLED" | "COMMENTS_INVALID_INPUT">>>;
50
- /** Adds a comment to an open thread. Runs `onComment`. */
51
- reply(threadId: string, input: ReplyInput, options?: ReplyOptions): Promise<Result<Comment, Codes<"COMMENTS_NOT_INSTALLED" | "COMMENTS_NOT_FOUND" | "COMMENTS_INVALID_INPUT" | "COMMENTS_RESOLVED">>>;
52
- resolve(threadId: string, options: {
53
- by: CommentAuthor;
54
- }): Promise<Result<CommentThread, Codes<"COMMENTS_NOT_INSTALLED" | "COMMENTS_NOT_FOUND">>>;
55
- reopen(threadId: string): Promise<Result<CommentThread, Codes<"COMMENTS_NOT_INSTALLED" | "COMMENTS_NOT_FOUND">>>;
56
- /** Deletes a thread and all its comments. */
57
- remove(threadId: string): Promise<Result<void, Codes<"COMMENTS_NOT_INSTALLED" | "COMMENTS_NOT_FOUND">>>;
58
- /** Deletes one comment. Deleting the first comment deletes the thread. */
59
- removeComment(commentId: string): Promise<Result<void, Codes<"COMMENTS_NOT_INSTALLED" | "COMMENTS_NOT_FOUND">>>;
60
- /** Changes the text of a comment and sets `editedAt`. */
61
- edit(commentId: string, input: EditCommentInput): Promise<Result<Comment, Codes<"COMMENTS_NOT_INSTALLED" | "COMMENTS_NOT_FOUND" | "COMMENTS_INVALID_INPUT">>>;
62
- /** Deletes every thread of a scope, such as when app code deletes the document that the scope names. */
63
- removeScope(scope: string): Promise<Result<{
64
- removed: number;
65
- }, Codes<"COMMENTS_NOT_INSTALLED">>>;
66
- /**
67
- * Whether the `authorize` policy allows an action. Without a policy, see `defaultPolicy()`. `scope` defaults to the
68
- * thread's, else `"pages"`.
69
- */
70
- can(context: Omit<CommentsAuthorizeContext$1, "scope"> & {
71
- scope?: string;
72
- }): Promise<boolean>;
73
- /**
74
- * People that `@` suggests: the `people` option, or the authors of earlier comments in the scope, `"pages"` by
75
- * default, so names from an app's own scopes never reach the overlay.
76
- */
77
- people(context: {
78
- query: string;
79
- user: CommentsAuthorizeContext$1["user"];
80
- scope?: string;
81
- }): Promise<Result<CommentMention[], Codes<"COMMENTS_NOT_INSTALLED">>>;
82
- /**
83
- * With `forge`: brings the thread's pull request comments in line with the thread now, and posts what failed
84
- * before. Every change starts this on its own; `flush()` waits for it.
85
- */
86
- sync(threadId: string): Promise<void>;
87
- /** Waits for the pull request syncs that earlier changes started. On Cloudflare, pass it to `waitUntil`. */
88
- flush(): Promise<void>;
89
- }
90
- /**
91
- * The policy without `authorize`, for every action: a person signed in with GitHub needs push access to the repository
92
- * of the build; any other signed-in user may; anonymous people may only on the development server, as guests.
93
- * `development` comes from Vite's command in the generated Nitro plugin, and defaults to false.
94
- */
95
- declare function defaultPolicy(user: CommentsUser | null, development?: boolean): boolean;
96
- /**
97
- * Defines Comments for the app. A default export from `server/comments.ts` selects numbered, authorized Operations.
98
- * A named `comments` export selects the live-site API, overlay, and presence rooms.
99
- */
100
- declare function defineComments(input?: DefineCommentsOptions): Comments & CommentsDefinition;
101
- declare function defineComments<T>(input: T & (T extends DefineCommentsOptions$1 | CommentsDefinition ? unknown : never)): Comments & CommentsDefinition;
102
- /**
103
- * Connects a Comments definition to its Database. The generated Nitro plugin calls it when the server starts; call it
104
- * yourself only in tests or outside ViteHub. Only the Vite dev server enables `development`; it defaults to false.
105
- */
106
- declare function installComments(comments: Comments, runtime: {
107
- database: CommentsDatabase;
108
- development?: boolean;
109
- }): void;
110
- //#endregion
111
- export { describeCommentContext as a, DefineCommentsOptions as c, installComments as i, defaultPolicy as n, CommentsDatabase as o, defineComments as r, CommentsAuthorizeContext as s, Comments as t };