@btst/stack 2.7.0 → 2.8.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 (181) hide show
  1. package/README.md +1 -0
  2. package/dist/packages/stack/src/plugins/blog/client/components/loading/post-navigation-skeleton.cjs +13 -0
  3. package/dist/packages/stack/src/plugins/blog/client/components/loading/post-navigation-skeleton.mjs +11 -0
  4. package/dist/packages/stack/src/plugins/blog/client/components/loading/recent-posts-carousel-skeleton.cjs +17 -0
  5. package/dist/packages/stack/src/plugins/blog/client/components/loading/recent-posts-carousel-skeleton.mjs +15 -0
  6. package/dist/packages/stack/src/plugins/blog/client/components/pages/post-page.internal.cjs +18 -7
  7. package/dist/packages/stack/src/plugins/blog/client/components/pages/post-page.internal.mjs +18 -7
  8. package/dist/packages/stack/src/plugins/blog/client/components/shared/post-navigation.cjs +48 -52
  9. package/dist/packages/stack/src/plugins/blog/client/components/shared/post-navigation.mjs +49 -53
  10. package/dist/packages/stack/src/plugins/blog/client/components/shared/recent-posts-carousel.cjs +34 -37
  11. package/dist/packages/stack/src/plugins/blog/client/components/shared/recent-posts-carousel.mjs +35 -38
  12. package/dist/packages/stack/src/plugins/blog/client/hooks/blog-hooks.cjs +4 -21
  13. package/dist/packages/stack/src/plugins/blog/client/hooks/blog-hooks.mjs +4 -21
  14. package/dist/packages/stack/src/plugins/comments/api/getters.cjs +284 -0
  15. package/dist/packages/stack/src/plugins/comments/api/getters.mjs +280 -0
  16. package/dist/packages/stack/src/plugins/comments/api/mutations.cjs +118 -0
  17. package/dist/packages/stack/src/plugins/comments/api/mutations.mjs +112 -0
  18. package/dist/packages/stack/src/plugins/comments/api/plugin.cjs +335 -0
  19. package/dist/packages/stack/src/plugins/comments/api/plugin.mjs +333 -0
  20. package/dist/packages/stack/src/plugins/comments/api/query-key-defs.cjs +60 -0
  21. package/dist/packages/stack/src/plugins/comments/api/query-key-defs.mjs +55 -0
  22. package/dist/packages/stack/src/plugins/comments/api/serializers.cjs +23 -0
  23. package/dist/packages/stack/src/plugins/comments/api/serializers.mjs +21 -0
  24. package/dist/packages/stack/src/plugins/comments/client/components/comment-count.cjs +46 -0
  25. package/dist/packages/stack/src/plugins/comments/client/components/comment-count.mjs +44 -0
  26. package/dist/packages/stack/src/plugins/comments/client/components/comment-form.cjs +86 -0
  27. package/dist/packages/stack/src/plugins/comments/client/components/comment-form.mjs +84 -0
  28. package/dist/packages/stack/src/plugins/comments/client/components/comment-thread.cjs +540 -0
  29. package/dist/packages/stack/src/plugins/comments/client/components/comment-thread.mjs +538 -0
  30. package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.cjs +64 -0
  31. package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.internal.cjs +426 -0
  32. package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.internal.mjs +424 -0
  33. package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.mjs +62 -0
  34. package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.cjs +66 -0
  35. package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.internal.cjs +256 -0
  36. package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.internal.mjs +254 -0
  37. package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.mjs +64 -0
  38. package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.cjs +86 -0
  39. package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.internal.cjs +191 -0
  40. package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.internal.mjs +189 -0
  41. package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.mjs +84 -0
  42. package/dist/packages/stack/src/plugins/comments/client/components/shared/page-wrapper.cjs +27 -0
  43. package/dist/packages/stack/src/plugins/comments/client/components/shared/page-wrapper.mjs +25 -0
  44. package/dist/packages/stack/src/plugins/comments/client/components/shared/pagination.cjs +37 -0
  45. package/dist/packages/stack/src/plugins/comments/client/components/shared/pagination.mjs +35 -0
  46. package/dist/packages/stack/src/plugins/comments/client/hooks/use-comments.cjs +476 -0
  47. package/dist/packages/stack/src/plugins/comments/client/hooks/use-comments.mjs +464 -0
  48. package/dist/packages/stack/src/plugins/comments/client/localization/comments-moderation.cjs +67 -0
  49. package/dist/packages/stack/src/plugins/comments/client/localization/comments-moderation.mjs +65 -0
  50. package/dist/packages/stack/src/plugins/comments/client/localization/comments-my.cjs +27 -0
  51. package/dist/packages/stack/src/plugins/comments/client/localization/comments-my.mjs +25 -0
  52. package/dist/packages/stack/src/plugins/comments/client/localization/comments-thread.cjs +30 -0
  53. package/dist/packages/stack/src/plugins/comments/client/localization/comments-thread.mjs +28 -0
  54. package/dist/packages/stack/src/plugins/comments/client/localization/index.cjs +13 -0
  55. package/dist/packages/stack/src/plugins/comments/client/localization/index.mjs +11 -0
  56. package/dist/packages/stack/src/plugins/comments/client/plugin.cjs +116 -0
  57. package/dist/packages/stack/src/plugins/comments/client/plugin.mjs +114 -0
  58. package/dist/packages/stack/src/plugins/comments/client/utils.cjs +41 -0
  59. package/dist/packages/stack/src/plugins/comments/client/utils.mjs +37 -0
  60. package/dist/packages/stack/src/plugins/comments/db.cjs +75 -0
  61. package/dist/packages/stack/src/plugins/comments/db.mjs +73 -0
  62. package/dist/packages/stack/src/plugins/comments/schemas.cjs +45 -0
  63. package/dist/packages/stack/src/plugins/comments/schemas.mjs +38 -0
  64. package/dist/packages/stack/src/plugins/kanban/client/components/forms/task-form.cjs +0 -1
  65. package/dist/packages/stack/src/plugins/kanban/client/components/forms/task-form.mjs +0 -1
  66. package/dist/packages/stack/src/plugins/kanban/client/components/pages/board-page.internal.cjs +39 -22
  67. package/dist/packages/stack/src/plugins/kanban/client/components/pages/board-page.internal.mjs +40 -23
  68. package/dist/packages/ui/src/components/avatar.mjs +1 -1
  69. package/dist/packages/ui/src/components/pagination-controls.cjs +64 -0
  70. package/dist/packages/ui/src/components/pagination-controls.mjs +62 -0
  71. package/dist/packages/ui/src/components/when-visible.cjs +39 -0
  72. package/dist/packages/ui/src/components/when-visible.mjs +37 -0
  73. package/dist/plugins/blog/client/hooks/index.d.cts +1 -1
  74. package/dist/plugins/blog/client/hooks/index.d.mts +1 -1
  75. package/dist/plugins/blog/client/hooks/index.d.ts +1 -1
  76. package/dist/plugins/blog/client/index.d.cts +24 -2
  77. package/dist/plugins/blog/client/index.d.mts +24 -2
  78. package/dist/plugins/blog/client/index.d.ts +24 -2
  79. package/dist/plugins/comments/api/index.cjs +21 -0
  80. package/dist/plugins/comments/api/index.d.cts +126 -0
  81. package/dist/plugins/comments/api/index.d.mts +126 -0
  82. package/dist/plugins/comments/api/index.d.ts +126 -0
  83. package/dist/plugins/comments/api/index.mjs +5 -0
  84. package/dist/plugins/comments/client/components/index.cjs +15 -0
  85. package/dist/plugins/comments/client/components/index.d.cts +125 -0
  86. package/dist/plugins/comments/client/components/index.d.mts +125 -0
  87. package/dist/plugins/comments/client/components/index.d.ts +125 -0
  88. package/dist/plugins/comments/client/components/index.mjs +5 -0
  89. package/dist/plugins/comments/client/hooks/index.cjs +17 -0
  90. package/dist/plugins/comments/client/hooks/index.d.cts +200 -0
  91. package/dist/plugins/comments/client/hooks/index.d.mts +200 -0
  92. package/dist/plugins/comments/client/hooks/index.d.ts +200 -0
  93. package/dist/plugins/comments/client/hooks/index.mjs +1 -0
  94. package/dist/plugins/comments/client/index.cjs +9 -0
  95. package/dist/plugins/comments/client/index.d.cts +262 -0
  96. package/dist/plugins/comments/client/index.d.mts +262 -0
  97. package/dist/plugins/comments/client/index.d.ts +262 -0
  98. package/dist/plugins/comments/client/index.mjs +2 -0
  99. package/dist/plugins/comments/client.css +2 -0
  100. package/dist/plugins/comments/query-keys.cjs +113 -0
  101. package/dist/plugins/comments/query-keys.d.cts +71 -0
  102. package/dist/plugins/comments/query-keys.d.mts +71 -0
  103. package/dist/plugins/comments/query-keys.d.ts +71 -0
  104. package/dist/plugins/comments/query-keys.mjs +111 -0
  105. package/dist/plugins/comments/style.css +15 -0
  106. package/dist/plugins/kanban/api/index.d.cts +1 -1
  107. package/dist/plugins/kanban/api/index.d.mts +1 -1
  108. package/dist/plugins/kanban/api/index.d.ts +1 -1
  109. package/dist/plugins/kanban/client/hooks/index.d.cts +1 -1
  110. package/dist/plugins/kanban/client/hooks/index.d.mts +1 -1
  111. package/dist/plugins/kanban/client/hooks/index.d.ts +1 -1
  112. package/dist/plugins/kanban/client/index.d.cts +1 -1
  113. package/dist/plugins/kanban/client/index.d.mts +1 -1
  114. package/dist/plugins/kanban/client/index.d.ts +1 -1
  115. package/dist/plugins/kanban/query-keys.d.cts +1 -1
  116. package/dist/plugins/kanban/query-keys.d.mts +1 -1
  117. package/dist/plugins/kanban/query-keys.d.ts +1 -1
  118. package/dist/shared/{stack.FeaWkglm.d.ts → stack.BxFl46lB.d.cts} +24 -1
  119. package/dist/shared/stack.C-b3Sn8j.d.cts +142 -0
  120. package/dist/shared/stack.C-b3Sn8j.d.mts +142 -0
  121. package/dist/shared/stack.C-b3Sn8j.d.ts +142 -0
  122. package/dist/shared/stack.CJE9sAjV.d.ts +335 -0
  123. package/dist/shared/stack.CmHRdhl8.d.cts +335 -0
  124. package/dist/shared/{stack.CNLHlv7r.d.mts → stack.DOZ1EXjM.d.mts} +6 -12
  125. package/dist/shared/{stack.FeaWkglm.d.mts → stack.DRpeDS6X.d.ts} +24 -1
  126. package/dist/shared/{stack.CQAZwXhV.d.cts → stack.DX-tQ93o.d.cts} +6 -12
  127. package/dist/shared/stack.Dcz6636A.d.mts +335 -0
  128. package/dist/shared/{stack.FeaWkglm.d.cts → stack.Jb0kQDJC.d.mts} +24 -1
  129. package/dist/shared/stack.Ldfkr5b2.d.cts +112 -0
  130. package/dist/shared/stack.Ldfkr5b2.d.mts +112 -0
  131. package/dist/shared/stack.Ldfkr5b2.d.ts +112 -0
  132. package/dist/shared/{stack.D3BsrpAz.d.ts → stack.VF6FhyZw.d.ts} +6 -12
  133. package/package.json +69 -4
  134. package/src/plugins/blog/client/components/loading/post-navigation-skeleton.tsx +10 -0
  135. package/src/plugins/blog/client/components/loading/recent-posts-carousel-skeleton.tsx +18 -0
  136. package/src/plugins/blog/client/components/pages/post-page.internal.tsx +23 -8
  137. package/src/plugins/blog/client/components/shared/post-navigation.tsx +0 -5
  138. package/src/plugins/blog/client/components/shared/recent-posts-carousel.tsx +1 -5
  139. package/src/plugins/blog/client/hooks/blog-hooks.tsx +8 -33
  140. package/src/plugins/blog/client/overrides.ts +26 -1
  141. package/src/plugins/cms/client/components/shared/pagination.tsx +14 -42
  142. package/src/plugins/comments/api/getters.ts +444 -0
  143. package/src/plugins/comments/api/index.ts +21 -0
  144. package/src/plugins/comments/api/mutations.ts +206 -0
  145. package/src/plugins/comments/api/plugin.ts +628 -0
  146. package/src/plugins/comments/api/query-key-defs.ts +143 -0
  147. package/src/plugins/comments/api/serializers.ts +37 -0
  148. package/src/plugins/comments/client/components/comment-count.tsx +66 -0
  149. package/src/plugins/comments/client/components/comment-form.tsx +112 -0
  150. package/src/plugins/comments/client/components/comment-thread.tsx +799 -0
  151. package/src/plugins/comments/client/components/index.tsx +11 -0
  152. package/src/plugins/comments/client/components/pages/moderation-page.internal.tsx +550 -0
  153. package/src/plugins/comments/client/components/pages/moderation-page.tsx +70 -0
  154. package/src/plugins/comments/client/components/pages/my-comments-page.internal.tsx +367 -0
  155. package/src/plugins/comments/client/components/pages/my-comments-page.tsx +72 -0
  156. package/src/plugins/comments/client/components/pages/resource-comments-page.internal.tsx +225 -0
  157. package/src/plugins/comments/client/components/pages/resource-comments-page.tsx +97 -0
  158. package/src/plugins/comments/client/components/shared/page-wrapper.tsx +32 -0
  159. package/src/plugins/comments/client/components/shared/pagination.tsx +44 -0
  160. package/src/plugins/comments/client/hooks/index.tsx +13 -0
  161. package/src/plugins/comments/client/hooks/use-comments.tsx +717 -0
  162. package/src/plugins/comments/client/index.ts +14 -0
  163. package/src/plugins/comments/client/localization/comments-moderation.ts +75 -0
  164. package/src/plugins/comments/client/localization/comments-my.ts +32 -0
  165. package/src/plugins/comments/client/localization/comments-thread.ts +32 -0
  166. package/src/plugins/comments/client/localization/index.ts +11 -0
  167. package/src/plugins/comments/client/overrides.ts +164 -0
  168. package/src/plugins/comments/client/plugin.tsx +195 -0
  169. package/src/plugins/comments/client/utils.ts +67 -0
  170. package/src/plugins/comments/client.css +2 -0
  171. package/src/plugins/comments/db.ts +77 -0
  172. package/src/plugins/comments/query-keys.ts +189 -0
  173. package/src/plugins/comments/schemas.ts +72 -0
  174. package/src/plugins/comments/style.css +15 -0
  175. package/src/plugins/comments/types.ts +73 -0
  176. package/src/plugins/kanban/client/components/forms/task-form.tsx +0 -1
  177. package/src/plugins/kanban/client/components/pages/board-page.internal.tsx +46 -27
  178. package/src/plugins/kanban/client/overrides.ts +27 -1
  179. package/dist/shared/{stack.Rtcvl8sS.d.cts → stack.BOokfhZD.d.cts} +3 -3
  180. package/dist/shared/{stack.D4Cea8II.d.ts → stack.BvCR4-9H.d.ts} +3 -3
  181. package/dist/shared/{stack.HE_IvqV5.d.mts → stack.CWxAl9K3.d.mts} +3 -3
@@ -0,0 +1,28 @@
1
+ const COMMENTS_THREAD = {
2
+ COMMENTS_TITLE: "Comments",
3
+ COMMENTS_EMPTY: "Be the first to comment.",
4
+ COMMENTS_EDITED_BADGE: "(edited)",
5
+ COMMENTS_PENDING_BADGE: "Pending approval",
6
+ COMMENTS_LIKE_ARIA: "Like",
7
+ COMMENTS_UNLIKE_ARIA: "Unlike",
8
+ COMMENTS_REPLY_BUTTON: "Reply",
9
+ COMMENTS_EDIT_BUTTON: "Edit",
10
+ COMMENTS_DELETE_BUTTON: "Delete",
11
+ COMMENTS_SAVE_EDIT: "Save",
12
+ COMMENTS_REPLIES_SINGULAR: "reply",
13
+ COMMENTS_REPLIES_PLURAL: "replies",
14
+ COMMENTS_HIDE_REPLIES: "Hide replies",
15
+ COMMENTS_DELETE_CONFIRM: "Delete this comment?",
16
+ COMMENTS_LOGIN_PROMPT: "Please sign in to leave a comment.",
17
+ COMMENTS_LOGIN_LINK: "Sign in",
18
+ COMMENTS_FORM_PLACEHOLDER: "Write a comment\u2026",
19
+ COMMENTS_FORM_CANCEL: "Cancel",
20
+ COMMENTS_FORM_POST_COMMENT: "Post comment",
21
+ COMMENTS_FORM_POST_REPLY: "Post reply",
22
+ COMMENTS_FORM_POSTING: "Posting\u2026",
23
+ COMMENTS_FORM_SUBMIT_ERROR: "Failed to submit comment",
24
+ COMMENTS_LOAD_MORE: "Load more comments",
25
+ COMMENTS_LOADING_MORE: "Loading\u2026"
26
+ };
27
+
28
+ export { COMMENTS_THREAD };
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ const commentsThread = require('./comments-thread.cjs');
4
+ const commentsModeration = require('./comments-moderation.cjs');
5
+ const commentsMy = require('./comments-my.cjs');
6
+
7
+ const COMMENTS_LOCALIZATION = {
8
+ ...commentsThread.COMMENTS_THREAD,
9
+ ...commentsModeration.COMMENTS_MODERATION,
10
+ ...commentsMy.COMMENTS_MY
11
+ };
12
+
13
+ exports.COMMENTS_LOCALIZATION = COMMENTS_LOCALIZATION;
@@ -0,0 +1,11 @@
1
+ import { COMMENTS_THREAD } from './comments-thread.mjs';
2
+ import { COMMENTS_MODERATION } from './comments-moderation.mjs';
3
+ import { COMMENTS_MY } from './comments-my.mjs';
4
+
5
+ const COMMENTS_LOCALIZATION = {
6
+ ...COMMENTS_THREAD,
7
+ ...COMMENTS_MODERATION,
8
+ ...COMMENTS_MY
9
+ };
10
+
11
+ export { COMMENTS_LOCALIZATION };
@@ -0,0 +1,116 @@
1
+ 'use strict';
2
+
3
+ const React = require('react');
4
+ const client = require('@btst/stack/plugins/client');
5
+ const yar = require('@btst/yar');
6
+
7
+ const ModerationPageComponent = React.lazy(
8
+ () => import('./components/pages/moderation-page.cjs').then((m) => ({
9
+ default: m.ModerationPageComponent
10
+ }))
11
+ );
12
+ const UserCommentsPageComponent = React.lazy(
13
+ () => import('./components/pages/my-comments-page.cjs').then((m) => ({
14
+ default: m.UserCommentsPageComponent
15
+ }))
16
+ );
17
+ function createModerationLoader(config) {
18
+ return async () => {
19
+ if (typeof window === "undefined") {
20
+ const { apiBasePath, apiBaseURL, headers, hooks } = config;
21
+ const context = {
22
+ path: "/comments/moderation",
23
+ isSSR: true,
24
+ apiBaseURL,
25
+ apiBasePath,
26
+ headers
27
+ };
28
+ try {
29
+ if (hooks?.beforeLoadModeration) {
30
+ await hooks.beforeLoadModeration(context);
31
+ }
32
+ } catch (error) {
33
+ if (client.isConnectionError(error)) {
34
+ console.warn(
35
+ "[btst/comments] route.loader() failed \u2014 no server running at build time."
36
+ );
37
+ }
38
+ if (hooks?.onLoadError) {
39
+ await hooks.onLoadError(error, context);
40
+ }
41
+ }
42
+ }
43
+ };
44
+ }
45
+ function createUserCommentsLoader(config) {
46
+ return async () => {
47
+ if (typeof window === "undefined") {
48
+ const { apiBasePath, apiBaseURL, headers, hooks } = config;
49
+ const context = {
50
+ path: "/comments",
51
+ isSSR: true,
52
+ apiBaseURL,
53
+ apiBasePath,
54
+ headers
55
+ };
56
+ try {
57
+ if (hooks?.beforeLoadUserComments) {
58
+ await hooks.beforeLoadUserComments(context);
59
+ }
60
+ } catch (error) {
61
+ if (client.isConnectionError(error)) {
62
+ console.warn(
63
+ "[btst/comments] route.loader() failed \u2014 no server running at build time."
64
+ );
65
+ }
66
+ if (hooks?.onLoadError) {
67
+ await hooks.onLoadError(error, context);
68
+ }
69
+ }
70
+ }
71
+ };
72
+ }
73
+ function createCommentsRouteMeta(config, path, title, description) {
74
+ return () => {
75
+ const fullUrl = `${config.siteBaseURL}${config.siteBasePath}${path}`;
76
+ return [
77
+ { title },
78
+ { name: "title", content: title },
79
+ { name: "description", content: description },
80
+ { name: "robots", content: "noindex, nofollow" },
81
+ { property: "og:title", content: title },
82
+ { property: "og:description", content: description },
83
+ { property: "og:url", content: fullUrl },
84
+ { name: "twitter:card", content: "summary" },
85
+ { name: "twitter:title", content: title },
86
+ { name: "twitter:description", content: description }
87
+ ];
88
+ };
89
+ }
90
+ const commentsClientPlugin = (config) => client.defineClientPlugin({
91
+ name: "comments",
92
+ routes: () => ({
93
+ moderation: yar.createRoute("/comments/moderation", () => ({
94
+ PageComponent: ModerationPageComponent,
95
+ loader: createModerationLoader(config),
96
+ meta: createCommentsRouteMeta(
97
+ config,
98
+ "/comments/moderation",
99
+ "Comment Moderation",
100
+ "Review and manage comments across all resources."
101
+ )
102
+ })),
103
+ userComments: yar.createRoute("/comments", () => ({
104
+ PageComponent: UserCommentsPageComponent,
105
+ loader: createUserCommentsLoader(config),
106
+ meta: createCommentsRouteMeta(
107
+ config,
108
+ "/comments",
109
+ "User Comments",
110
+ "View and manage your comments across resources."
111
+ )
112
+ }))
113
+ })
114
+ });
115
+
116
+ exports.commentsClientPlugin = commentsClientPlugin;
@@ -0,0 +1,114 @@
1
+ import { lazy } from 'react';
2
+ import { defineClientPlugin, isConnectionError } from '@btst/stack/plugins/client';
3
+ import { createRoute } from '@btst/yar';
4
+
5
+ const ModerationPageComponent = lazy(
6
+ () => import('./components/pages/moderation-page.mjs').then((m) => ({
7
+ default: m.ModerationPageComponent
8
+ }))
9
+ );
10
+ const UserCommentsPageComponent = lazy(
11
+ () => import('./components/pages/my-comments-page.mjs').then((m) => ({
12
+ default: m.UserCommentsPageComponent
13
+ }))
14
+ );
15
+ function createModerationLoader(config) {
16
+ return async () => {
17
+ if (typeof window === "undefined") {
18
+ const { apiBasePath, apiBaseURL, headers, hooks } = config;
19
+ const context = {
20
+ path: "/comments/moderation",
21
+ isSSR: true,
22
+ apiBaseURL,
23
+ apiBasePath,
24
+ headers
25
+ };
26
+ try {
27
+ if (hooks?.beforeLoadModeration) {
28
+ await hooks.beforeLoadModeration(context);
29
+ }
30
+ } catch (error) {
31
+ if (isConnectionError(error)) {
32
+ console.warn(
33
+ "[btst/comments] route.loader() failed \u2014 no server running at build time."
34
+ );
35
+ }
36
+ if (hooks?.onLoadError) {
37
+ await hooks.onLoadError(error, context);
38
+ }
39
+ }
40
+ }
41
+ };
42
+ }
43
+ function createUserCommentsLoader(config) {
44
+ return async () => {
45
+ if (typeof window === "undefined") {
46
+ const { apiBasePath, apiBaseURL, headers, hooks } = config;
47
+ const context = {
48
+ path: "/comments",
49
+ isSSR: true,
50
+ apiBaseURL,
51
+ apiBasePath,
52
+ headers
53
+ };
54
+ try {
55
+ if (hooks?.beforeLoadUserComments) {
56
+ await hooks.beforeLoadUserComments(context);
57
+ }
58
+ } catch (error) {
59
+ if (isConnectionError(error)) {
60
+ console.warn(
61
+ "[btst/comments] route.loader() failed \u2014 no server running at build time."
62
+ );
63
+ }
64
+ if (hooks?.onLoadError) {
65
+ await hooks.onLoadError(error, context);
66
+ }
67
+ }
68
+ }
69
+ };
70
+ }
71
+ function createCommentsRouteMeta(config, path, title, description) {
72
+ return () => {
73
+ const fullUrl = `${config.siteBaseURL}${config.siteBasePath}${path}`;
74
+ return [
75
+ { title },
76
+ { name: "title", content: title },
77
+ { name: "description", content: description },
78
+ { name: "robots", content: "noindex, nofollow" },
79
+ { property: "og:title", content: title },
80
+ { property: "og:description", content: description },
81
+ { property: "og:url", content: fullUrl },
82
+ { name: "twitter:card", content: "summary" },
83
+ { name: "twitter:title", content: title },
84
+ { name: "twitter:description", content: description }
85
+ ];
86
+ };
87
+ }
88
+ const commentsClientPlugin = (config) => defineClientPlugin({
89
+ name: "comments",
90
+ routes: () => ({
91
+ moderation: createRoute("/comments/moderation", () => ({
92
+ PageComponent: ModerationPageComponent,
93
+ loader: createModerationLoader(config),
94
+ meta: createCommentsRouteMeta(
95
+ config,
96
+ "/comments/moderation",
97
+ "Comment Moderation",
98
+ "Review and manage comments across all resources."
99
+ )
100
+ })),
101
+ userComments: createRoute("/comments", () => ({
102
+ PageComponent: UserCommentsPageComponent,
103
+ loader: createUserCommentsLoader(config),
104
+ meta: createCommentsRouteMeta(
105
+ config,
106
+ "/comments",
107
+ "User Comments",
108
+ "View and manage your comments across resources."
109
+ )
110
+ }))
111
+ })
112
+ });
113
+
114
+ export { commentsClientPlugin };
@@ -0,0 +1,41 @@
1
+ 'use strict';
2
+
3
+ const React = require('react');
4
+
5
+ function useResolvedCurrentUserId(raw) {
6
+ const [resolved, setResolved] = React.useState(
7
+ typeof raw === "string" ? raw : void 0
8
+ );
9
+ React.useEffect(() => {
10
+ if (typeof raw === "function") {
11
+ void Promise.resolve(raw()).then((id) => setResolved(id ?? void 0)).catch((err) => {
12
+ console.error(
13
+ "[btst/comments] Failed to resolve currentUserId:",
14
+ err
15
+ );
16
+ });
17
+ } else {
18
+ setResolved(raw ?? void 0);
19
+ }
20
+ }, [raw]);
21
+ return resolved;
22
+ }
23
+ function toError(error) {
24
+ if (error instanceof Error) return error;
25
+ if (typeof error === "object" && error !== null) {
26
+ const obj = error;
27
+ const message = (typeof obj.message === "string" ? obj.message : null) || (typeof obj.error === "string" ? obj.error : null) || JSON.stringify(error);
28
+ const err = new Error(message);
29
+ Object.assign(err, error);
30
+ return err;
31
+ }
32
+ return new Error(String(error));
33
+ }
34
+ function getInitials(name) {
35
+ if (!name) return "?";
36
+ return name.split(" ").filter(Boolean).slice(0, 2).map((n) => n[0]).join("").toUpperCase();
37
+ }
38
+
39
+ exports.getInitials = getInitials;
40
+ exports.toError = toError;
41
+ exports.useResolvedCurrentUserId = useResolvedCurrentUserId;
@@ -0,0 +1,37 @@
1
+ import { useState, useEffect } from 'react';
2
+
3
+ function useResolvedCurrentUserId(raw) {
4
+ const [resolved, setResolved] = useState(
5
+ typeof raw === "string" ? raw : void 0
6
+ );
7
+ useEffect(() => {
8
+ if (typeof raw === "function") {
9
+ void Promise.resolve(raw()).then((id) => setResolved(id ?? void 0)).catch((err) => {
10
+ console.error(
11
+ "[btst/comments] Failed to resolve currentUserId:",
12
+ err
13
+ );
14
+ });
15
+ } else {
16
+ setResolved(raw ?? void 0);
17
+ }
18
+ }, [raw]);
19
+ return resolved;
20
+ }
21
+ function toError(error) {
22
+ if (error instanceof Error) return error;
23
+ if (typeof error === "object" && error !== null) {
24
+ const obj = error;
25
+ const message = (typeof obj.message === "string" ? obj.message : null) || (typeof obj.error === "string" ? obj.error : null) || JSON.stringify(error);
26
+ const err = new Error(message);
27
+ Object.assign(err, error);
28
+ return err;
29
+ }
30
+ return new Error(String(error));
31
+ }
32
+ function getInitials(name) {
33
+ if (!name) return "?";
34
+ return name.split(" ").filter(Boolean).slice(0, 2).map((n) => n[0]).join("").toUpperCase();
35
+ }
36
+
37
+ export { getInitials, toError, useResolvedCurrentUserId };
@@ -0,0 +1,75 @@
1
+ 'use strict';
2
+
3
+ const db = require('@btst/db');
4
+
5
+ const commentsSchema = db.createDbPlugin("comments", {
6
+ comment: {
7
+ modelName: "comment",
8
+ fields: {
9
+ resourceId: {
10
+ type: "string",
11
+ required: true
12
+ },
13
+ resourceType: {
14
+ type: "string",
15
+ required: true
16
+ },
17
+ parentId: {
18
+ type: "string",
19
+ required: false
20
+ },
21
+ authorId: {
22
+ type: "string",
23
+ required: true
24
+ },
25
+ body: {
26
+ type: "string",
27
+ required: true
28
+ },
29
+ status: {
30
+ type: "string",
31
+ defaultValue: "pending"
32
+ },
33
+ likes: {
34
+ type: "number",
35
+ defaultValue: 0
36
+ },
37
+ editedAt: {
38
+ type: "date",
39
+ required: false
40
+ },
41
+ createdAt: {
42
+ type: "date",
43
+ defaultValue: () => /* @__PURE__ */ new Date()
44
+ },
45
+ updatedAt: {
46
+ type: "date",
47
+ defaultValue: () => /* @__PURE__ */ new Date()
48
+ }
49
+ }
50
+ },
51
+ commentLike: {
52
+ modelName: "commentLike",
53
+ fields: {
54
+ commentId: {
55
+ type: "string",
56
+ required: true,
57
+ references: {
58
+ model: "comment",
59
+ field: "id",
60
+ onDelete: "cascade"
61
+ }
62
+ },
63
+ authorId: {
64
+ type: "string",
65
+ required: true
66
+ },
67
+ createdAt: {
68
+ type: "date",
69
+ defaultValue: () => /* @__PURE__ */ new Date()
70
+ }
71
+ }
72
+ }
73
+ });
74
+
75
+ exports.commentsSchema = commentsSchema;
@@ -0,0 +1,73 @@
1
+ import { createDbPlugin } from '@btst/db';
2
+
3
+ const commentsSchema = createDbPlugin("comments", {
4
+ comment: {
5
+ modelName: "comment",
6
+ fields: {
7
+ resourceId: {
8
+ type: "string",
9
+ required: true
10
+ },
11
+ resourceType: {
12
+ type: "string",
13
+ required: true
14
+ },
15
+ parentId: {
16
+ type: "string",
17
+ required: false
18
+ },
19
+ authorId: {
20
+ type: "string",
21
+ required: true
22
+ },
23
+ body: {
24
+ type: "string",
25
+ required: true
26
+ },
27
+ status: {
28
+ type: "string",
29
+ defaultValue: "pending"
30
+ },
31
+ likes: {
32
+ type: "number",
33
+ defaultValue: 0
34
+ },
35
+ editedAt: {
36
+ type: "date",
37
+ required: false
38
+ },
39
+ createdAt: {
40
+ type: "date",
41
+ defaultValue: () => /* @__PURE__ */ new Date()
42
+ },
43
+ updatedAt: {
44
+ type: "date",
45
+ defaultValue: () => /* @__PURE__ */ new Date()
46
+ }
47
+ }
48
+ },
49
+ commentLike: {
50
+ modelName: "commentLike",
51
+ fields: {
52
+ commentId: {
53
+ type: "string",
54
+ required: true,
55
+ references: {
56
+ model: "comment",
57
+ field: "id",
58
+ onDelete: "cascade"
59
+ }
60
+ },
61
+ authorId: {
62
+ type: "string",
63
+ required: true
64
+ },
65
+ createdAt: {
66
+ type: "date",
67
+ defaultValue: () => /* @__PURE__ */ new Date()
68
+ }
69
+ }
70
+ }
71
+ });
72
+
73
+ export { commentsSchema };
@@ -0,0 +1,45 @@
1
+ 'use strict';
2
+
3
+ const z = require('zod');
4
+
5
+ const CommentStatusSchema = z.z.enum(["pending", "approved", "spam"]);
6
+ const createCommentSchema = z.z.object({
7
+ resourceId: z.z.string().min(1, "Resource ID is required"),
8
+ resourceType: z.z.string().min(1, "Resource type is required"),
9
+ parentId: z.z.string().optional().nullable(),
10
+ body: z.z.string().min(1, "Body is required").max(1e4, "Comment too long")
11
+ });
12
+ createCommentSchema.extend({
13
+ authorId: z.z.string().min(1, "Author ID is required")
14
+ });
15
+ const updateCommentSchema = z.z.object({
16
+ body: z.z.string().min(1, "Body is required").max(1e4, "Comment too long")
17
+ });
18
+ const updateCommentStatusSchema = z.z.object({
19
+ status: CommentStatusSchema
20
+ });
21
+ const CommentListQuerySchema = z.z.object({
22
+ resourceId: z.z.string().optional(),
23
+ resourceType: z.z.string().optional(),
24
+ parentId: z.z.string().optional().nullable(),
25
+ status: CommentStatusSchema.optional(),
26
+ authorId: z.z.string().optional(),
27
+ sort: z.z.enum(["asc", "desc"]).optional(),
28
+ limit: z.z.coerce.number().int().min(1).max(100).optional(),
29
+ offset: z.z.coerce.number().int().min(0).optional()
30
+ });
31
+ CommentListQuerySchema.extend({
32
+ currentUserId: z.z.string().optional()
33
+ });
34
+ const CommentCountQuerySchema = z.z.object({
35
+ resourceId: z.z.string().min(1),
36
+ resourceType: z.z.string().min(1),
37
+ status: CommentStatusSchema.optional()
38
+ });
39
+
40
+ exports.CommentCountQuerySchema = CommentCountQuerySchema;
41
+ exports.CommentListQuerySchema = CommentListQuerySchema;
42
+ exports.CommentStatusSchema = CommentStatusSchema;
43
+ exports.createCommentSchema = createCommentSchema;
44
+ exports.updateCommentSchema = updateCommentSchema;
45
+ exports.updateCommentStatusSchema = updateCommentStatusSchema;
@@ -0,0 +1,38 @@
1
+ import { z } from 'zod';
2
+
3
+ const CommentStatusSchema = z.enum(["pending", "approved", "spam"]);
4
+ const createCommentSchema = z.object({
5
+ resourceId: z.string().min(1, "Resource ID is required"),
6
+ resourceType: z.string().min(1, "Resource type is required"),
7
+ parentId: z.string().optional().nullable(),
8
+ body: z.string().min(1, "Body is required").max(1e4, "Comment too long")
9
+ });
10
+ createCommentSchema.extend({
11
+ authorId: z.string().min(1, "Author ID is required")
12
+ });
13
+ const updateCommentSchema = z.object({
14
+ body: z.string().min(1, "Body is required").max(1e4, "Comment too long")
15
+ });
16
+ const updateCommentStatusSchema = z.object({
17
+ status: CommentStatusSchema
18
+ });
19
+ const CommentListQuerySchema = z.object({
20
+ resourceId: z.string().optional(),
21
+ resourceType: z.string().optional(),
22
+ parentId: z.string().optional().nullable(),
23
+ status: CommentStatusSchema.optional(),
24
+ authorId: z.string().optional(),
25
+ sort: z.enum(["asc", "desc"]).optional(),
26
+ limit: z.coerce.number().int().min(1).max(100).optional(),
27
+ offset: z.coerce.number().int().min(0).optional()
28
+ });
29
+ CommentListQuerySchema.extend({
30
+ currentUserId: z.string().optional()
31
+ });
32
+ const CommentCountQuerySchema = z.object({
33
+ resourceId: z.string().min(1),
34
+ resourceType: z.string().min(1),
35
+ status: CommentStatusSchema.optional()
36
+ });
37
+
38
+ export { CommentCountQuerySchema, CommentListQuerySchema, CommentStatusSchema, createCommentSchema, updateCommentSchema, updateCommentStatusSchema };
@@ -160,7 +160,6 @@ function TaskForm({
160
160
  onChange: (value) => setDescription(typeof value === "string" ? value : ""),
161
161
  output: "markdown",
162
162
  placeholder: "Describe the task...",
163
- editable: !isPending,
164
163
  className: "min-h-[150px]"
165
164
  }
166
165
  )
@@ -158,7 +158,6 @@ function TaskForm({
158
158
  onChange: (value) => setDescription(typeof value === "string" ? value : ""),
159
159
  output: "markdown",
160
160
  placeholder: "Describe the task...",
161
- editable: !isPending,
162
161
  className: "min-h-[150px]"
163
162
  }
164
163
  )