@btst/stack 3.0.0-rc.1 → 3.0.0-rc.3

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 (1172) hide show
  1. package/README.md +122 -46
  2. package/dist/api/index.cjs +133 -29
  3. package/dist/api/index.d.cts +14 -32
  4. package/dist/api/index.d.mts +14 -32
  5. package/dist/api/index.d.ts +14 -32
  6. package/dist/api/index.mjs +133 -28
  7. package/dist/authorization/client.cjs +154 -0
  8. package/dist/authorization/client.d.cts +70 -0
  9. package/dist/authorization/client.d.mts +70 -0
  10. package/dist/authorization/client.d.ts +70 -0
  11. package/dist/authorization/client.mjs +152 -0
  12. package/dist/authorization/index.cjs +371 -0
  13. package/dist/authorization/index.d.cts +201 -0
  14. package/dist/authorization/index.d.mts +201 -0
  15. package/dist/authorization/index.d.ts +201 -0
  16. package/dist/authorization/index.mjs +365 -0
  17. package/dist/authorization/remote.cjs +117 -0
  18. package/dist/authorization/remote.d.cts +79 -0
  19. package/dist/authorization/remote.d.mts +79 -0
  20. package/dist/authorization/remote.d.ts +79 -0
  21. package/dist/authorization/remote.mjs +111 -0
  22. package/dist/authorization/server.cjs +77 -0
  23. package/dist/authorization/server.d.cts +51 -0
  24. package/dist/authorization/server.d.mts +51 -0
  25. package/dist/authorization/server.d.ts +51 -0
  26. package/dist/authorization/server.mjs +73 -0
  27. package/dist/client/components/index.cjs +1 -0
  28. package/dist/client/components/index.d.cts +23 -6
  29. package/dist/client/components/index.d.mts +23 -6
  30. package/dist/client/components/index.d.ts +23 -6
  31. package/dist/client/components/index.mjs +1 -1
  32. package/dist/client/hooks/index.cjs +8 -0
  33. package/dist/client/hooks/index.d.cts +25 -0
  34. package/dist/client/hooks/index.d.mts +25 -0
  35. package/dist/client/hooks/index.d.ts +25 -0
  36. package/dist/client/hooks/index.mjs +2 -0
  37. package/dist/client/index.cjs +38 -7
  38. package/dist/client/index.d.cts +30 -100
  39. package/dist/client/index.d.mts +30 -100
  40. package/dist/client/index.d.ts +30 -100
  41. package/dist/client/index.mjs +38 -7
  42. package/dist/client/server.cjs +96 -0
  43. package/dist/client/server.d.cts +57 -0
  44. package/dist/client/server.d.mts +57 -0
  45. package/dist/client/server.d.ts +57 -0
  46. package/dist/client/server.mjs +92 -0
  47. package/dist/components/auto-form/index.d.cts +2 -2
  48. package/dist/components/auto-form/index.d.mts +2 -2
  49. package/dist/components/auto-form/index.d.ts +2 -2
  50. package/dist/components/form-builder/index.d.cts +1 -1
  51. package/dist/components/form-builder/index.d.mts +1 -1
  52. package/dist/components/form-builder/index.d.ts +1 -1
  53. package/dist/components/stepped-auto-form/index.d.cts +1 -1
  54. package/dist/components/stepped-auto-form/index.d.mts +1 -1
  55. package/dist/components/stepped-auto-form/index.d.ts +1 -1
  56. package/dist/context/index.cjs +8 -2
  57. package/dist/context/index.d.cts +111 -89
  58. package/dist/context/index.d.mts +111 -89
  59. package/dist/context/index.d.ts +111 -89
  60. package/dist/context/index.mjs +3 -1
  61. package/dist/index.cjs +1 -2
  62. package/dist/index.d.cts +8 -3
  63. package/dist/index.d.mts +8 -3
  64. package/dist/index.d.ts +8 -3
  65. package/dist/index.mjs +1 -1
  66. package/dist/next/index.d.cts +30 -12
  67. package/dist/next/index.d.mts +30 -12
  68. package/dist/next/index.d.ts +30 -12
  69. package/dist/next/server.cjs +7 -0
  70. package/dist/next/server.d.cts +56 -0
  71. package/dist/next/server.d.mts +56 -0
  72. package/dist/next/server.d.ts +56 -0
  73. package/dist/next/server.mjs +1 -0
  74. package/dist/packages/stack/src/authorization/json.cjs +57 -0
  75. package/dist/packages/stack/src/authorization/json.mjs +55 -0
  76. package/dist/packages/stack/src/client/components/compose.cjs +91 -9
  77. package/dist/packages/stack/src/client/components/compose.mjs +92 -11
  78. package/dist/packages/stack/src/client/runtime.cjs +295 -0
  79. package/dist/packages/stack/src/client/runtime.mjs +293 -0
  80. package/dist/packages/stack/src/context/auth.cjs +141 -73
  81. package/dist/packages/stack/src/context/auth.mjs +139 -73
  82. package/dist/packages/stack/src/context/provider.cjs +11 -5
  83. package/dist/packages/stack/src/context/provider.mjs +11 -5
  84. package/dist/packages/stack/src/context/router.cjs +9 -0
  85. package/dist/packages/stack/src/context/router.mjs +7 -0
  86. package/dist/packages/stack/src/context/site-navigation.cjs +40 -0
  87. package/dist/packages/stack/src/context/site-navigation.mjs +38 -0
  88. package/dist/packages/stack/src/next/layout.cjs +27 -0
  89. package/dist/packages/stack/src/next/layout.mjs +25 -0
  90. package/dist/packages/stack/src/next/page.cjs +8 -6
  91. package/dist/packages/stack/src/next/page.mjs +8 -6
  92. package/dist/packages/stack/src/plugin-registration.cjs +59 -0
  93. package/dist/packages/stack/src/plugin-registration.mjs +57 -0
  94. package/dist/packages/stack/src/plugins/ai-chat/api/lifecycle-migrations.cjs +18 -0
  95. package/dist/packages/stack/src/plugins/ai-chat/api/lifecycle-migrations.mjs +16 -0
  96. package/dist/packages/stack/src/plugins/ai-chat/api/operations.cjs +1341 -0
  97. package/dist/packages/stack/src/plugins/ai-chat/api/operations.mjs +1333 -0
  98. package/dist/packages/stack/src/plugins/ai-chat/api/plugin.cjs +82 -640
  99. package/dist/packages/stack/src/plugins/ai-chat/api/plugin.mjs +78 -641
  100. package/dist/packages/stack/src/plugins/ai-chat/api/serializers.cjs +23 -0
  101. package/dist/packages/stack/src/plugins/ai-chat/api/serializers.mjs +20 -0
  102. package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-input.cjs +183 -111
  103. package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-input.mjs +187 -115
  104. package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-interface.cjs +562 -116
  105. package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-interface.mjs +567 -121
  106. package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-layout.cjs +6 -6
  107. package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-layout.mjs +6 -6
  108. package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-message.cjs +1 -1
  109. package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-message.mjs +1 -1
  110. package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-sidebar.cjs +45 -29
  111. package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-sidebar.mjs +46 -30
  112. package/dist/packages/stack/src/plugins/ai-chat/client/components/pages/404-page.cjs +1 -1
  113. package/dist/packages/stack/src/plugins/ai-chat/client/components/pages/404-page.mjs +1 -1
  114. package/dist/packages/stack/src/plugins/ai-chat/client/components/pages/chat-page.cjs +46 -7
  115. package/dist/packages/stack/src/plugins/ai-chat/client/components/pages/chat-page.internal.cjs +5 -3
  116. package/dist/packages/stack/src/plugins/ai-chat/client/components/pages/chat-page.internal.mjs +5 -3
  117. package/dist/packages/stack/src/plugins/ai-chat/client/components/pages/chat-page.mjs +48 -9
  118. package/dist/packages/stack/src/plugins/ai-chat/client/components/shared/default-error.cjs +1 -1
  119. package/dist/packages/stack/src/plugins/ai-chat/client/components/shared/default-error.mjs +1 -1
  120. package/dist/packages/stack/src/plugins/ai-chat/client/components/tool-call-display.cjs +1 -1
  121. package/dist/packages/stack/src/plugins/ai-chat/client/components/tool-call-display.mjs +1 -1
  122. package/dist/packages/stack/src/plugins/ai-chat/client/hooks/ai-chat-resource.cjs +1 -1
  123. package/dist/packages/stack/src/plugins/ai-chat/client/hooks/ai-chat-resource.mjs +1 -1
  124. package/dist/packages/stack/src/plugins/ai-chat/client/hooks/chat-hooks.cjs +179 -19
  125. package/dist/packages/stack/src/plugins/ai-chat/client/hooks/chat-hooks.mjs +180 -21
  126. package/dist/packages/stack/src/plugins/ai-chat/client/navigation.cjs +11 -0
  127. package/dist/packages/stack/src/plugins/ai-chat/client/navigation.mjs +9 -0
  128. package/dist/packages/stack/src/plugins/ai-chat/client/overrides.cjs +24 -0
  129. package/dist/packages/stack/src/plugins/ai-chat/client/overrides.mjs +21 -1
  130. package/dist/packages/stack/src/plugins/ai-chat/client/plugin.cjs +152 -82
  131. package/dist/packages/stack/src/plugins/ai-chat/client/plugin.mjs +152 -82
  132. package/dist/packages/stack/src/plugins/api/create-endpoint.cjs +27 -9
  133. package/dist/packages/stack/src/plugins/api/create-endpoint.mjs +27 -10
  134. package/dist/packages/stack/src/plugins/api/endpoint-inventory.cjs +125 -0
  135. package/dist/packages/stack/src/plugins/api/endpoint-inventory.mjs +123 -0
  136. package/dist/packages/stack/src/plugins/api/operation.cjs +208 -0
  137. package/dist/packages/stack/src/plugins/api/operation.mjs +198 -0
  138. package/dist/packages/stack/src/plugins/blog/api/lifecycle-migrations.cjs +17 -0
  139. package/dist/packages/stack/src/plugins/blog/api/lifecycle-migrations.mjs +15 -0
  140. package/dist/packages/stack/src/plugins/blog/api/mutations.cjs +10 -2
  141. package/dist/packages/stack/src/plugins/blog/api/mutations.mjs +10 -2
  142. package/dist/packages/stack/src/plugins/blog/api/operations.cjs +455 -0
  143. package/dist/packages/stack/src/plugins/blog/api/operations.mjs +448 -0
  144. package/dist/packages/stack/src/plugins/blog/api/plugin.cjs +51 -298
  145. package/dist/packages/stack/src/plugins/blog/api/plugin.mjs +55 -304
  146. package/dist/packages/stack/src/plugins/blog/client/components/forms/image-field.cjs +2 -1
  147. package/dist/packages/stack/src/plugins/blog/client/components/forms/image-field.mjs +2 -1
  148. package/dist/packages/stack/src/plugins/blog/client/components/forms/markdown-editor-with-overrides.cjs +2 -1
  149. package/dist/packages/stack/src/plugins/blog/client/components/forms/markdown-editor-with-overrides.mjs +2 -1
  150. package/dist/packages/stack/src/plugins/blog/client/components/forms/post-forms.cjs +82 -67
  151. package/dist/packages/stack/src/plugins/blog/client/components/forms/post-forms.mjs +84 -69
  152. package/dist/packages/stack/src/plugins/blog/client/components/pages/404-page.cjs +2 -1
  153. package/dist/packages/stack/src/plugins/blog/client/components/pages/404-page.mjs +2 -1
  154. package/dist/packages/stack/src/plugins/blog/client/components/pages/edit-post-page.cjs +22 -4
  155. package/dist/packages/stack/src/plugins/blog/client/components/pages/edit-post-page.internal.cjs +2 -1
  156. package/dist/packages/stack/src/plugins/blog/client/components/pages/edit-post-page.internal.mjs +2 -1
  157. package/dist/packages/stack/src/plugins/blog/client/components/pages/edit-post-page.mjs +23 -5
  158. package/dist/packages/stack/src/plugins/blog/client/components/pages/home-page.cjs +6 -2
  159. package/dist/packages/stack/src/plugins/blog/client/components/pages/home-page.internal.cjs +2 -1
  160. package/dist/packages/stack/src/plugins/blog/client/components/pages/home-page.internal.mjs +2 -1
  161. package/dist/packages/stack/src/plugins/blog/client/components/pages/home-page.mjs +6 -2
  162. package/dist/packages/stack/src/plugins/blog/client/components/pages/new-post-page.cjs +4 -2
  163. package/dist/packages/stack/src/plugins/blog/client/components/pages/new-post-page.internal.cjs +2 -1
  164. package/dist/packages/stack/src/plugins/blog/client/components/pages/new-post-page.internal.mjs +2 -1
  165. package/dist/packages/stack/src/plugins/blog/client/components/pages/new-post-page.mjs +4 -2
  166. package/dist/packages/stack/src/plugins/blog/client/components/pages/post-page.cjs +30 -3
  167. package/dist/packages/stack/src/plugins/blog/client/components/pages/post-page.internal.cjs +2 -1
  168. package/dist/packages/stack/src/plugins/blog/client/components/pages/post-page.internal.mjs +2 -1
  169. package/dist/packages/stack/src/plugins/blog/client/components/pages/post-page.mjs +31 -4
  170. package/dist/packages/stack/src/plugins/blog/client/components/pages/tag-page.cjs +4 -1
  171. package/dist/packages/stack/src/plugins/blog/client/components/pages/tag-page.internal.cjs +2 -1
  172. package/dist/packages/stack/src/plugins/blog/client/components/pages/tag-page.internal.mjs +2 -1
  173. package/dist/packages/stack/src/plugins/blog/client/components/pages/tag-page.mjs +4 -1
  174. package/dist/packages/stack/src/plugins/blog/client/components/shared/collapsible-tag-list.cjs +2 -1
  175. package/dist/packages/stack/src/plugins/blog/client/components/shared/collapsible-tag-list.mjs +2 -1
  176. package/dist/packages/stack/src/plugins/blog/client/components/shared/default-error.cjs +2 -1
  177. package/dist/packages/stack/src/plugins/blog/client/components/shared/default-error.mjs +2 -1
  178. package/dist/packages/stack/src/plugins/blog/client/components/shared/on-this-page.cjs +3 -2
  179. package/dist/packages/stack/src/plugins/blog/client/components/shared/on-this-page.mjs +3 -2
  180. package/dist/packages/stack/src/plugins/blog/client/components/shared/page-wrapper.cjs +2 -1
  181. package/dist/packages/stack/src/plugins/blog/client/components/shared/page-wrapper.mjs +2 -1
  182. package/dist/packages/stack/src/plugins/blog/client/components/shared/post-card.cjs +2 -1
  183. package/dist/packages/stack/src/plugins/blog/client/components/shared/post-card.mjs +2 -1
  184. package/dist/packages/stack/src/plugins/blog/client/components/shared/posts-list.cjs +2 -1
  185. package/dist/packages/stack/src/plugins/blog/client/components/shared/posts-list.mjs +2 -1
  186. package/dist/packages/stack/src/plugins/blog/client/components/shared/recent-posts-carousel.cjs +2 -1
  187. package/dist/packages/stack/src/plugins/blog/client/components/shared/recent-posts-carousel.mjs +2 -1
  188. package/dist/packages/stack/src/plugins/blog/client/components/shared/search-input.cjs +2 -2
  189. package/dist/packages/stack/src/plugins/blog/client/components/shared/search-input.mjs +1 -1
  190. package/dist/packages/stack/src/plugins/blog/client/constants.cjs +5 -0
  191. package/dist/packages/stack/src/plugins/blog/client/constants.mjs +3 -0
  192. package/dist/packages/stack/src/plugins/blog/client/hooks/blog-resource.cjs +2 -1
  193. package/dist/packages/stack/src/plugins/blog/client/hooks/blog-resource.mjs +2 -1
  194. package/dist/packages/stack/src/plugins/blog/client/plugin.cjs +169 -163
  195. package/dist/packages/stack/src/plugins/blog/client/plugin.mjs +169 -163
  196. package/dist/packages/stack/src/plugins/client/resource/hooks.cjs +31 -16
  197. package/dist/packages/stack/src/plugins/client/resource/hooks.mjs +31 -16
  198. package/dist/packages/stack/src/plugins/client/resource/internal.cjs +66 -52
  199. package/dist/packages/stack/src/plugins/client/resource/internal.mjs +66 -52
  200. package/dist/packages/stack/src/plugins/client/resource/use-form.cjs +20 -17
  201. package/dist/packages/stack/src/plugins/client/resource/use-form.mjs +20 -17
  202. package/dist/packages/stack/src/plugins/client/resource/use-select.cjs +39 -33
  203. package/dist/packages/stack/src/plugins/client/resource/use-select.mjs +39 -33
  204. package/dist/packages/stack/src/plugins/cms/api/lifecycle-migrations.cjs +13 -0
  205. package/dist/packages/stack/src/plugins/cms/api/lifecycle-migrations.mjs +11 -0
  206. package/dist/packages/stack/src/plugins/cms/api/operations.cjs +1763 -0
  207. package/dist/packages/stack/src/plugins/cms/api/operations.mjs +1756 -0
  208. package/dist/packages/stack/src/plugins/cms/api/plugin.cjs +165 -752
  209. package/dist/packages/stack/src/plugins/cms/api/plugin.mjs +164 -755
  210. package/dist/packages/stack/src/plugins/cms/client/components/forms/content-form.cjs +2 -1
  211. package/dist/packages/stack/src/plugins/cms/client/components/forms/content-form.mjs +2 -1
  212. package/dist/packages/stack/src/plugins/cms/client/components/forms/file-upload.cjs +2 -1
  213. package/dist/packages/stack/src/plugins/cms/client/components/forms/file-upload.mjs +2 -1
  214. package/dist/packages/stack/src/plugins/cms/client/components/forms/relation-field.cjs +2 -1
  215. package/dist/packages/stack/src/plugins/cms/client/components/forms/relation-field.mjs +2 -1
  216. package/dist/packages/stack/src/plugins/cms/client/components/inverse-relations-panel.cjs +23 -13
  217. package/dist/packages/stack/src/plugins/cms/client/components/inverse-relations-panel.mjs +24 -14
  218. package/dist/packages/stack/src/plugins/cms/client/components/pages/404-page.cjs +5 -4
  219. package/dist/packages/stack/src/plugins/cms/client/components/pages/404-page.mjs +6 -5
  220. package/dist/packages/stack/src/plugins/cms/client/components/pages/content-editor-page.cjs +40 -7
  221. package/dist/packages/stack/src/plugins/cms/client/components/pages/content-editor-page.internal.cjs +15 -9
  222. package/dist/packages/stack/src/plugins/cms/client/components/pages/content-editor-page.internal.mjs +14 -8
  223. package/dist/packages/stack/src/plugins/cms/client/components/pages/content-editor-page.mjs +41 -8
  224. package/dist/packages/stack/src/plugins/cms/client/components/pages/content-list-page.cjs +7 -1
  225. package/dist/packages/stack/src/plugins/cms/client/components/pages/content-list-page.internal.cjs +42 -29
  226. package/dist/packages/stack/src/plugins/cms/client/components/pages/content-list-page.internal.mjs +40 -27
  227. package/dist/packages/stack/src/plugins/cms/client/components/pages/content-list-page.mjs +7 -1
  228. package/dist/packages/stack/src/plugins/cms/client/components/pages/dashboard-page.cjs +4 -1
  229. package/dist/packages/stack/src/plugins/cms/client/components/pages/dashboard-page.internal.cjs +13 -7
  230. package/dist/packages/stack/src/plugins/cms/client/components/pages/dashboard-page.internal.mjs +12 -6
  231. package/dist/packages/stack/src/plugins/cms/client/components/pages/dashboard-page.mjs +4 -1
  232. package/dist/packages/stack/src/plugins/cms/client/components/shared/page-wrapper.cjs +2 -1
  233. package/dist/packages/stack/src/plugins/cms/client/components/shared/page-wrapper.mjs +2 -1
  234. package/dist/packages/stack/src/plugins/cms/client/constants.cjs +5 -0
  235. package/dist/packages/stack/src/plugins/cms/client/constants.mjs +3 -0
  236. package/dist/packages/stack/src/plugins/cms/client/hooks/cms-resource.cjs +2 -1
  237. package/dist/packages/stack/src/plugins/cms/client/hooks/cms-resource.mjs +2 -1
  238. package/dist/packages/stack/src/plugins/cms/client/overrides.cjs +26 -0
  239. package/dist/packages/stack/src/plugins/cms/client/overrides.mjs +24 -0
  240. package/dist/packages/stack/src/plugins/cms/client/plugin.cjs +102 -81
  241. package/dist/packages/stack/src/plugins/cms/client/plugin.mjs +103 -82
  242. package/dist/packages/stack/src/plugins/comments/api/getters.cjs +6 -2
  243. package/dist/packages/stack/src/plugins/comments/api/getters.mjs +6 -3
  244. package/dist/packages/stack/src/plugins/comments/api/lifecycle-migrations.cjs +18 -0
  245. package/dist/packages/stack/src/plugins/comments/api/lifecycle-migrations.mjs +16 -0
  246. package/dist/packages/stack/src/plugins/comments/api/mutations.cjs +179 -68
  247. package/dist/packages/stack/src/plugins/comments/api/mutations.mjs +179 -68
  248. package/dist/packages/stack/src/plugins/comments/api/operations.cjs +453 -0
  249. package/dist/packages/stack/src/plugins/comments/api/operations.mjs +445 -0
  250. package/dist/packages/stack/src/plugins/comments/api/plugin.cjs +51 -276
  251. package/dist/packages/stack/src/plugins/comments/api/plugin.mjs +48 -277
  252. package/dist/packages/stack/src/plugins/comments/client/components/comment-count.cjs +32 -5
  253. package/dist/packages/stack/src/plugins/comments/client/components/comment-count.mjs +34 -7
  254. package/dist/packages/stack/src/plugins/comments/client/components/comment-thread.cjs +161 -105
  255. package/dist/packages/stack/src/plugins/comments/client/components/comment-thread.mjs +162 -106
  256. package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.cjs +14 -2
  257. package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.internal.cjs +141 -71
  258. package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.internal.mjs +142 -72
  259. package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.mjs +14 -2
  260. package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-state.cjs +12 -0
  261. package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-state.mjs +9 -0
  262. package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.cjs +2 -1
  263. package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.internal.cjs +40 -26
  264. package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.internal.mjs +40 -26
  265. package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.mjs +2 -1
  266. package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.cjs +9 -1
  267. package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.internal.cjs +25 -20
  268. package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.internal.mjs +26 -21
  269. package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.mjs +9 -1
  270. package/dist/packages/stack/src/plugins/comments/client/components/shared/page-wrapper.cjs +2 -1
  271. package/dist/packages/stack/src/plugins/comments/client/components/shared/page-wrapper.mjs +2 -1
  272. package/dist/packages/stack/src/plugins/comments/client/components/shared/pagination.cjs +2 -1
  273. package/dist/packages/stack/src/plugins/comments/client/components/shared/pagination.mjs +2 -1
  274. package/dist/packages/stack/src/plugins/comments/client/constants.cjs +5 -0
  275. package/dist/packages/stack/src/plugins/comments/client/constants.mjs +3 -0
  276. package/dist/packages/stack/src/plugins/comments/client/hooks/use-comments.cjs +323 -290
  277. package/dist/packages/stack/src/plugins/comments/client/hooks/use-comments.mjs +325 -292
  278. package/dist/packages/stack/src/plugins/comments/client/localization/comments-thread.cjs +1 -0
  279. package/dist/packages/stack/src/plugins/comments/client/localization/comments-thread.mjs +1 -0
  280. package/dist/packages/stack/src/plugins/comments/client/plugin.cjs +78 -46
  281. package/dist/packages/stack/src/plugins/comments/client/plugin.mjs +80 -48
  282. package/dist/packages/stack/src/plugins/form-builder/api/getters.cjs +9 -0
  283. package/dist/packages/stack/src/plugins/form-builder/api/getters.mjs +9 -1
  284. package/dist/packages/stack/src/plugins/form-builder/api/lifecycle-migrations.cjs +15 -0
  285. package/dist/packages/stack/src/plugins/form-builder/api/lifecycle-migrations.mjs +13 -0
  286. package/dist/packages/stack/src/plugins/form-builder/api/operations.cjs +1093 -0
  287. package/dist/packages/stack/src/plugins/form-builder/api/operations.mjs +1082 -0
  288. package/dist/packages/stack/src/plugins/form-builder/api/plugin.cjs +97 -466
  289. package/dist/packages/stack/src/plugins/form-builder/api/plugin.mjs +92 -468
  290. package/dist/packages/stack/src/plugins/form-builder/api/query-key-defs.cjs +5 -0
  291. package/dist/packages/stack/src/plugins/form-builder/api/query-key-defs.mjs +5 -0
  292. package/dist/packages/stack/src/plugins/form-builder/client/components/forms/form-renderer.cjs +41 -11
  293. package/dist/packages/stack/src/plugins/form-builder/client/components/forms/form-renderer.mjs +42 -12
  294. package/dist/packages/stack/src/plugins/form-builder/client/components/pages/404-page.cjs +8 -5
  295. package/dist/packages/stack/src/plugins/form-builder/client/components/pages/404-page.mjs +9 -6
  296. package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-builder-page.cjs +36 -3
  297. package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-builder-page.internal.cjs +32 -11
  298. package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-builder-page.internal.mjs +35 -14
  299. package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-builder-page.mjs +37 -4
  300. package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-list-page.cjs +6 -1
  301. package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-list-page.internal.cjs +34 -26
  302. package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-list-page.internal.mjs +34 -26
  303. package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-list-page.mjs +6 -1
  304. package/dist/packages/stack/src/plugins/form-builder/client/components/pages/submissions-page.cjs +24 -7
  305. package/dist/packages/stack/src/plugins/form-builder/client/components/pages/submissions-page.internal.cjs +72 -40
  306. package/dist/packages/stack/src/plugins/form-builder/client/components/pages/submissions-page.internal.mjs +76 -44
  307. package/dist/packages/stack/src/plugins/form-builder/client/components/pages/submissions-page.mjs +25 -8
  308. package/dist/packages/stack/src/plugins/form-builder/client/components/shared/page-wrapper.cjs +2 -1
  309. package/dist/packages/stack/src/plugins/form-builder/client/components/shared/page-wrapper.mjs +2 -1
  310. package/dist/packages/stack/src/plugins/form-builder/client/constants.cjs +5 -0
  311. package/dist/packages/stack/src/plugins/form-builder/client/constants.mjs +3 -0
  312. package/dist/packages/stack/src/plugins/form-builder/client/hooks/form-builder-hooks.cjs +29 -0
  313. package/dist/packages/stack/src/plugins/form-builder/client/hooks/form-builder-hooks.mjs +28 -1
  314. package/dist/packages/stack/src/plugins/form-builder/client/hooks/form-builder-resource.cjs +2 -1
  315. package/dist/packages/stack/src/plugins/form-builder/client/hooks/form-builder-resource.mjs +2 -1
  316. package/dist/packages/stack/src/plugins/form-builder/client/plugin.cjs +113 -86
  317. package/dist/packages/stack/src/plugins/form-builder/client/plugin.mjs +114 -87
  318. package/dist/packages/stack/src/plugins/form-builder/schemas.cjs +9 -3
  319. package/dist/packages/stack/src/plugins/form-builder/schemas.mjs +9 -3
  320. package/dist/packages/stack/src/plugins/kanban/api/getters.cjs +47 -36
  321. package/dist/packages/stack/src/plugins/kanban/api/getters.mjs +47 -37
  322. package/dist/packages/stack/src/plugins/kanban/api/lifecycle-migrations.cjs +23 -0
  323. package/dist/packages/stack/src/plugins/kanban/api/lifecycle-migrations.mjs +21 -0
  324. package/dist/packages/stack/src/plugins/kanban/api/operations.cjs +1552 -0
  325. package/dist/packages/stack/src/plugins/kanban/api/operations.mjs +1543 -0
  326. package/dist/packages/stack/src/plugins/kanban/api/plugin.cjs +64 -631
  327. package/dist/packages/stack/src/plugins/kanban/api/plugin.mjs +62 -634
  328. package/dist/packages/stack/src/plugins/kanban/api/serializers.cjs +21 -0
  329. package/dist/packages/stack/src/plugins/kanban/api/serializers.mjs +21 -1
  330. package/dist/packages/stack/src/plugins/kanban/client/components/forms/board-form.cjs +2 -1
  331. package/dist/packages/stack/src/plugins/kanban/client/components/forms/board-form.mjs +2 -1
  332. package/dist/packages/stack/src/plugins/kanban/client/components/forms/column-form.cjs +2 -1
  333. package/dist/packages/stack/src/plugins/kanban/client/components/forms/column-form.mjs +2 -1
  334. package/dist/packages/stack/src/plugins/kanban/client/components/forms/task-form.cjs +72 -54
  335. package/dist/packages/stack/src/plugins/kanban/client/components/forms/task-form.mjs +74 -56
  336. package/dist/packages/stack/src/plugins/kanban/client/components/pages/404-page.cjs +4 -6
  337. package/dist/packages/stack/src/plugins/kanban/client/components/pages/404-page.mjs +5 -7
  338. package/dist/packages/stack/src/plugins/kanban/client/components/pages/board-page.cjs +22 -6
  339. package/dist/packages/stack/src/plugins/kanban/client/components/pages/board-page.internal.cjs +82 -77
  340. package/dist/packages/stack/src/plugins/kanban/client/components/pages/board-page.internal.mjs +83 -78
  341. package/dist/packages/stack/src/plugins/kanban/client/components/pages/board-page.mjs +23 -7
  342. package/dist/packages/stack/src/plugins/kanban/client/components/pages/boards-list-page.cjs +2 -1
  343. package/dist/packages/stack/src/plugins/kanban/client/components/pages/boards-list-page.internal.cjs +34 -24
  344. package/dist/packages/stack/src/plugins/kanban/client/components/pages/boards-list-page.internal.mjs +35 -25
  345. package/dist/packages/stack/src/plugins/kanban/client/components/pages/boards-list-page.mjs +2 -1
  346. package/dist/packages/stack/src/plugins/kanban/client/components/pages/new-board-page.cjs +2 -1
  347. package/dist/packages/stack/src/plugins/kanban/client/components/pages/new-board-page.internal.cjs +6 -9
  348. package/dist/packages/stack/src/plugins/kanban/client/components/pages/new-board-page.internal.mjs +7 -10
  349. package/dist/packages/stack/src/plugins/kanban/client/components/pages/new-board-page.mjs +2 -1
  350. package/dist/packages/stack/src/plugins/kanban/client/components/shared/column-content.cjs +72 -45
  351. package/dist/packages/stack/src/plugins/kanban/client/components/shared/column-content.mjs +73 -46
  352. package/dist/packages/stack/src/plugins/kanban/client/components/shared/default-error.cjs +2 -1
  353. package/dist/packages/stack/src/plugins/kanban/client/components/shared/default-error.mjs +2 -1
  354. package/dist/packages/stack/src/plugins/kanban/client/components/shared/kanban-board.cjs +4 -4
  355. package/dist/packages/stack/src/plugins/kanban/client/components/shared/kanban-board.mjs +4 -4
  356. package/dist/packages/stack/src/plugins/kanban/client/components/shared/permission-access-any.cjs +23 -0
  357. package/dist/packages/stack/src/plugins/kanban/client/components/shared/permission-access-any.mjs +21 -0
  358. package/dist/packages/stack/src/plugins/kanban/client/components/shared/task-card.cjs +54 -17
  359. package/dist/packages/stack/src/plugins/kanban/client/components/shared/task-card.mjs +55 -18
  360. package/dist/packages/stack/src/plugins/kanban/client/components/shared/user-avatar.cjs +2 -1
  361. package/dist/packages/stack/src/plugins/kanban/client/components/shared/user-avatar.mjs +2 -1
  362. package/dist/packages/stack/src/plugins/kanban/client/constants.cjs +5 -0
  363. package/dist/packages/stack/src/plugins/kanban/client/constants.mjs +3 -0
  364. package/dist/packages/stack/src/plugins/kanban/client/hooks/kanban-hooks.cjs +38 -9
  365. package/dist/packages/stack/src/plugins/kanban/client/hooks/kanban-hooks.mjs +39 -10
  366. package/dist/packages/stack/src/plugins/kanban/client/hooks/kanban-resource.cjs +2 -1
  367. package/dist/packages/stack/src/plugins/kanban/client/hooks/kanban-resource.mjs +2 -1
  368. package/dist/packages/stack/src/plugins/kanban/client/plugin.cjs +177 -104
  369. package/dist/packages/stack/src/plugins/kanban/client/plugin.mjs +178 -105
  370. package/dist/packages/stack/src/plugins/kanban/schemas.cjs +32 -23
  371. package/dist/packages/stack/src/plugins/kanban/schemas.mjs +33 -21
  372. package/dist/packages/stack/src/plugins/media/api/lifecycle-migrations.cjs +9 -0
  373. package/dist/packages/stack/src/plugins/media/api/lifecycle-migrations.mjs +7 -0
  374. package/dist/packages/stack/src/plugins/media/api/mutations.cjs +7 -2
  375. package/dist/packages/stack/src/plugins/media/api/mutations.mjs +7 -2
  376. package/dist/packages/stack/src/plugins/media/api/operations.cjs +1299 -0
  377. package/dist/packages/stack/src/plugins/media/api/operations.mjs +1290 -0
  378. package/dist/packages/stack/src/plugins/media/api/plugin.cjs +131 -508
  379. package/dist/packages/stack/src/plugins/media/api/plugin.mjs +127 -510
  380. package/dist/packages/stack/src/plugins/media/api/query-key-defs.cjs +26 -2
  381. package/dist/packages/stack/src/plugins/media/api/query-key-defs.mjs +25 -3
  382. package/dist/packages/stack/src/plugins/media/api/serializers.cjs +4 -2
  383. package/dist/packages/stack/src/plugins/media/api/serializers.mjs +4 -2
  384. package/dist/packages/stack/src/plugins/media/asset-url.cjs +13 -0
  385. package/dist/packages/stack/src/plugins/media/asset-url.mjs +11 -0
  386. package/dist/packages/stack/src/plugins/media/client/components/media-picker/asset-card.cjs +10 -10
  387. package/dist/packages/stack/src/plugins/media/client/components/media-picker/asset-card.mjs +12 -12
  388. package/dist/packages/stack/src/plugins/media/client/components/media-picker/folder-tree.cjs +47 -27
  389. package/dist/packages/stack/src/plugins/media/client/components/media-picker/folder-tree.mjs +49 -29
  390. package/dist/packages/stack/src/plugins/media/client/components/media-picker/index.cjs +225 -180
  391. package/dist/packages/stack/src/plugins/media/client/components/media-picker/index.mjs +228 -183
  392. package/dist/packages/stack/src/plugins/media/client/components/media-picker/upload-tab.cjs +1 -8
  393. package/dist/packages/stack/src/plugins/media/client/components/media-picker/upload-tab.mjs +2 -9
  394. package/dist/packages/stack/src/plugins/media/client/components/media-picker/url-tab.cjs +0 -6
  395. package/dist/packages/stack/src/plugins/media/client/components/media-picker/url-tab.mjs +1 -7
  396. package/dist/packages/stack/src/plugins/media/client/components/pages/library-page.cjs +4 -2
  397. package/dist/packages/stack/src/plugins/media/client/components/pages/library-page.internal.cjs +92 -75
  398. package/dist/packages/stack/src/plugins/media/client/components/pages/library-page.internal.mjs +93 -76
  399. package/dist/packages/stack/src/plugins/media/client/components/pages/library-page.mjs +4 -2
  400. package/dist/packages/stack/src/plugins/media/client/components/upload-permission-check.cjs +52 -0
  401. package/dist/packages/stack/src/plugins/media/client/components/upload-permission-check.mjs +49 -0
  402. package/dist/packages/stack/src/plugins/media/client/constants.cjs +5 -0
  403. package/dist/packages/stack/src/plugins/media/client/constants.mjs +3 -0
  404. package/dist/packages/stack/src/plugins/media/client/hooks/media-resource.cjs +2 -1
  405. package/dist/packages/stack/src/plugins/media/client/hooks/media-resource.mjs +2 -1
  406. package/dist/packages/stack/src/plugins/media/client/hooks/use-media.cjs +214 -43
  407. package/dist/packages/stack/src/plugins/media/client/hooks/use-media.mjs +217 -46
  408. package/dist/packages/stack/src/plugins/media/client/plugin.cjs +122 -62
  409. package/dist/packages/stack/src/plugins/media/client/plugin.mjs +123 -63
  410. package/dist/packages/stack/src/plugins/media/client/upload.cjs +121 -52
  411. package/dist/packages/stack/src/plugins/media/client/upload.mjs +121 -53
  412. package/dist/packages/stack/src/plugins/media/db.cjs +8 -0
  413. package/dist/packages/stack/src/plugins/media/db.mjs +8 -0
  414. package/dist/packages/stack/src/plugins/open-api/api/generator.cjs +36 -5
  415. package/dist/packages/stack/src/plugins/open-api/api/generator.mjs +36 -5
  416. package/dist/packages/stack/src/plugins/open-api/api/plugin.cjs +22 -11
  417. package/dist/packages/stack/src/plugins/open-api/api/plugin.mjs +22 -11
  418. package/dist/packages/stack/src/plugins/route-docs/client/components/pages/docs-page.cjs +65 -34
  419. package/dist/packages/stack/src/plugins/route-docs/client/components/pages/docs-page.mjs +56 -25
  420. package/dist/packages/stack/src/plugins/route-docs/client/constants.cjs +5 -0
  421. package/dist/packages/stack/src/plugins/route-docs/client/constants.mjs +3 -0
  422. package/dist/packages/stack/src/plugins/route-docs/client/hooks.cjs +9 -8
  423. package/dist/packages/stack/src/plugins/route-docs/client/hooks.mjs +10 -9
  424. package/dist/packages/stack/src/plugins/route-docs/client/plugin.cjs +143 -75
  425. package/dist/packages/stack/src/plugins/route-docs/client/plugin.mjs +144 -74
  426. package/dist/packages/stack/src/plugins/route-docs/client/schema.cjs +26 -0
  427. package/dist/packages/stack/src/plugins/route-docs/client/schema.mjs +23 -0
  428. package/dist/packages/stack/src/plugins/route-docs/generator.cjs +7 -4
  429. package/dist/packages/stack/src/plugins/route-docs/generator.mjs +7 -4
  430. package/dist/packages/stack/src/plugins/ui-builder/client/components/page-renderer.cjs +41 -12
  431. package/dist/packages/stack/src/plugins/ui-builder/client/components/page-renderer.mjs +42 -13
  432. package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-builder-page.cjs +37 -3
  433. package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-builder-page.internal.cjs +32 -20
  434. package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-builder-page.internal.mjs +34 -22
  435. package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-builder-page.mjs +38 -4
  436. package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-list-page.cjs +8 -2
  437. package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-list-page.internal.cjs +37 -19
  438. package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-list-page.internal.mjs +38 -20
  439. package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-list-page.mjs +8 -2
  440. package/dist/packages/stack/src/plugins/ui-builder/client/components/shared/default-error.cjs +2 -1
  441. package/dist/packages/stack/src/plugins/ui-builder/client/components/shared/default-error.mjs +2 -1
  442. package/dist/packages/stack/src/plugins/ui-builder/client/components/shared/page-wrapper.cjs +2 -1
  443. package/dist/packages/stack/src/plugins/ui-builder/client/components/shared/page-wrapper.mjs +2 -1
  444. package/dist/packages/stack/src/plugins/ui-builder/client/constants.cjs +5 -0
  445. package/dist/packages/stack/src/plugins/ui-builder/client/constants.mjs +3 -0
  446. package/dist/packages/stack/src/plugins/ui-builder/client/hooks/ui-builder-resource.cjs +2 -1
  447. package/dist/packages/stack/src/plugins/ui-builder/client/hooks/ui-builder-resource.mjs +2 -1
  448. package/dist/packages/stack/src/plugins/ui-builder/client/overrides.cjs +8 -0
  449. package/dist/packages/stack/src/plugins/ui-builder/client/overrides.mjs +6 -0
  450. package/dist/packages/stack/src/plugins/ui-builder/client/plugin.cjs +93 -53
  451. package/dist/packages/stack/src/plugins/ui-builder/client/plugin.mjs +94 -54
  452. package/dist/packages/stack/src/plugins/utils.cjs +4 -12
  453. package/dist/packages/stack/src/plugins/utils.mjs +5 -12
  454. package/dist/packages/stack/src/react-router/layout.cjs +14 -0
  455. package/dist/packages/stack/src/react-router/layout.mjs +12 -0
  456. package/dist/packages/stack/src/react-router/page.cjs +27 -16
  457. package/dist/packages/stack/src/react-router/page.mjs +28 -17
  458. package/dist/packages/stack/src/shared/initial-identity.cjs +27 -0
  459. package/dist/packages/stack/src/shared/initial-identity.mjs +23 -0
  460. package/dist/packages/stack/src/tanstack/layout.cjs +10 -0
  461. package/dist/packages/stack/src/tanstack/layout.mjs +8 -0
  462. package/dist/packages/stack/src/tanstack/page.cjs +11 -5
  463. package/dist/packages/stack/src/tanstack/page.mjs +11 -5
  464. package/dist/plugins/ai-chat/api/index.cjs +10 -0
  465. package/dist/plugins/ai-chat/api/index.d.cts +31 -5
  466. package/dist/plugins/ai-chat/api/index.d.mts +31 -5
  467. package/dist/plugins/ai-chat/api/index.d.ts +31 -5
  468. package/dist/plugins/ai-chat/api/index.mjs +3 -1
  469. package/dist/plugins/ai-chat/client/components/index.d.cts +1 -1
  470. package/dist/plugins/ai-chat/client/components/index.d.mts +1 -1
  471. package/dist/plugins/ai-chat/client/components/index.d.ts +1 -1
  472. package/dist/plugins/ai-chat/client/hooks/index.cjs +1 -0
  473. package/dist/plugins/ai-chat/client/hooks/index.d.cts +14 -8
  474. package/dist/plugins/ai-chat/client/hooks/index.d.mts +14 -8
  475. package/dist/plugins/ai-chat/client/hooks/index.d.ts +14 -8
  476. package/dist/plugins/ai-chat/client/hooks/index.mjs +1 -1
  477. package/dist/plugins/ai-chat/client/index.d.cts +21 -25
  478. package/dist/plugins/ai-chat/client/index.d.mts +21 -25
  479. package/dist/plugins/ai-chat/client/index.d.ts +21 -25
  480. package/dist/plugins/ai-chat/permissions.cjs +90 -0
  481. package/dist/plugins/ai-chat/permissions.d.cts +84 -0
  482. package/dist/plugins/ai-chat/permissions.d.mts +84 -0
  483. package/dist/plugins/ai-chat/permissions.d.ts +84 -0
  484. package/dist/plugins/ai-chat/permissions.mjs +88 -0
  485. package/dist/plugins/ai-chat/query-keys.cjs +116 -18
  486. package/dist/plugins/ai-chat/query-keys.d.cts +6 -2
  487. package/dist/plugins/ai-chat/query-keys.d.mts +6 -2
  488. package/dist/plugins/ai-chat/query-keys.d.ts +6 -2
  489. package/dist/plugins/ai-chat/query-keys.mjs +116 -19
  490. package/dist/plugins/api/index.cjs +4 -0
  491. package/dist/plugins/api/index.d.cts +13 -18
  492. package/dist/plugins/api/index.d.mts +13 -18
  493. package/dist/plugins/api/index.d.ts +13 -18
  494. package/dist/plugins/api/index.mjs +1 -0
  495. package/dist/plugins/blog/api/index.cjs +9 -2
  496. package/dist/plugins/blog/api/index.d.cts +118 -4
  497. package/dist/plugins/blog/api/index.d.mts +118 -4
  498. package/dist/plugins/blog/api/index.d.ts +118 -4
  499. package/dist/plugins/blog/api/index.mjs +4 -1
  500. package/dist/plugins/blog/client/hooks/index.d.cts +2 -2
  501. package/dist/plugins/blog/client/hooks/index.d.mts +2 -2
  502. package/dist/plugins/blog/client/hooks/index.d.ts +2 -2
  503. package/dist/plugins/blog/client/index.d.cts +210 -226
  504. package/dist/plugins/blog/client/index.d.mts +210 -226
  505. package/dist/plugins/blog/client/index.d.ts +210 -226
  506. package/dist/plugins/blog/permissions.cjs +47 -0
  507. package/dist/plugins/blog/permissions.d.cts +49 -0
  508. package/dist/plugins/blog/permissions.d.mts +49 -0
  509. package/dist/plugins/blog/permissions.d.ts +49 -0
  510. package/dist/plugins/blog/permissions.mjs +45 -0
  511. package/dist/plugins/blog/query-keys.d.cts +7 -3
  512. package/dist/plugins/blog/query-keys.d.mts +7 -3
  513. package/dist/plugins/blog/query-keys.d.ts +7 -3
  514. package/dist/plugins/client/hooks/index.d.cts +2 -2
  515. package/dist/plugins/client/hooks/index.d.mts +2 -2
  516. package/dist/plugins/client/hooks/index.d.ts +2 -2
  517. package/dist/plugins/client/index.cjs +3 -0
  518. package/dist/plugins/client/index.d.cts +30 -10
  519. package/dist/plugins/client/index.d.mts +30 -10
  520. package/dist/plugins/client/index.d.ts +30 -10
  521. package/dist/plugins/client/index.mjs +3 -0
  522. package/dist/plugins/cms/api/index.cjs +7 -0
  523. package/dist/plugins/cms/api/index.d.cts +173 -4
  524. package/dist/plugins/cms/api/index.d.mts +173 -4
  525. package/dist/plugins/cms/api/index.d.ts +173 -4
  526. package/dist/plugins/cms/api/index.mjs +2 -0
  527. package/dist/plugins/cms/client/hooks/index.d.cts +1 -1
  528. package/dist/plugins/cms/client/hooks/index.d.mts +1 -1
  529. package/dist/plugins/cms/client/hooks/index.d.ts +1 -1
  530. package/dist/plugins/cms/client/index.d.cts +188 -184
  531. package/dist/plugins/cms/client/index.d.mts +188 -184
  532. package/dist/plugins/cms/client/index.d.ts +188 -184
  533. package/dist/plugins/cms/permissions.cjs +46 -0
  534. package/dist/plugins/cms/permissions.d.cts +42 -0
  535. package/dist/plugins/cms/permissions.d.mts +42 -0
  536. package/dist/plugins/cms/permissions.d.ts +42 -0
  537. package/dist/plugins/cms/permissions.mjs +44 -0
  538. package/dist/plugins/cms/query-keys.d.cts +4 -4
  539. package/dist/plugins/cms/query-keys.d.mts +4 -4
  540. package/dist/plugins/cms/query-keys.d.ts +4 -4
  541. package/dist/plugins/comments/api/index.cjs +10 -0
  542. package/dist/plugins/comments/api/index.d.cts +54 -18
  543. package/dist/plugins/comments/api/index.d.mts +54 -18
  544. package/dist/plugins/comments/api/index.d.ts +54 -18
  545. package/dist/plugins/comments/api/index.mjs +3 -0
  546. package/dist/plugins/comments/client/components/index.d.cts +7 -2
  547. package/dist/plugins/comments/client/components/index.d.mts +7 -2
  548. package/dist/plugins/comments/client/components/index.d.ts +7 -2
  549. package/dist/plugins/comments/client/hooks/index.d.cts +12 -18
  550. package/dist/plugins/comments/client/hooks/index.d.mts +12 -18
  551. package/dist/plugins/comments/client/hooks/index.d.ts +12 -18
  552. package/dist/plugins/comments/client/index.d.cts +96 -114
  553. package/dist/plugins/comments/client/index.d.mts +96 -114
  554. package/dist/plugins/comments/client/index.d.ts +96 -114
  555. package/dist/plugins/comments/permissions.cjs +70 -0
  556. package/dist/plugins/comments/permissions.d.cts +76 -0
  557. package/dist/plugins/comments/permissions.d.mts +76 -0
  558. package/dist/plugins/comments/permissions.d.ts +76 -0
  559. package/dist/plugins/comments/permissions.mjs +68 -0
  560. package/dist/plugins/comments/query-keys.cjs +1 -1
  561. package/dist/plugins/comments/query-keys.d.cts +16 -19
  562. package/dist/plugins/comments/query-keys.d.mts +16 -19
  563. package/dist/plugins/comments/query-keys.d.ts +16 -19
  564. package/dist/plugins/comments/query-keys.mjs +1 -1
  565. package/dist/plugins/form-builder/api/index.cjs +8 -0
  566. package/dist/plugins/form-builder/api/index.d.cts +115 -4
  567. package/dist/plugins/form-builder/api/index.d.mts +115 -4
  568. package/dist/plugins/form-builder/api/index.d.ts +115 -4
  569. package/dist/plugins/form-builder/api/index.mjs +4 -1
  570. package/dist/plugins/form-builder/client/components/index.d.cts +6 -2
  571. package/dist/plugins/form-builder/client/components/index.d.mts +6 -2
  572. package/dist/plugins/form-builder/client/components/index.d.ts +6 -2
  573. package/dist/plugins/form-builder/client/hooks/index.cjs +2 -0
  574. package/dist/plugins/form-builder/client/hooks/index.d.cts +34 -8
  575. package/dist/plugins/form-builder/client/hooks/index.d.mts +34 -8
  576. package/dist/plugins/form-builder/client/hooks/index.d.ts +34 -8
  577. package/dist/plugins/form-builder/client/hooks/index.mjs +1 -1
  578. package/dist/plugins/form-builder/client/index.d.cts +153 -174
  579. package/dist/plugins/form-builder/client/index.d.mts +153 -174
  580. package/dist/plugins/form-builder/client/index.d.ts +153 -174
  581. package/dist/plugins/form-builder/permissions.cjs +95 -0
  582. package/dist/plugins/form-builder/permissions.d.cts +94 -0
  583. package/dist/plugins/form-builder/permissions.d.mts +94 -0
  584. package/dist/plugins/form-builder/permissions.d.ts +94 -0
  585. package/dist/plugins/form-builder/permissions.mjs +93 -0
  586. package/dist/plugins/form-builder/query-keys.cjs +11 -4
  587. package/dist/plugins/form-builder/query-keys.d.cts +38 -12
  588. package/dist/plugins/form-builder/query-keys.d.mts +38 -12
  589. package/dist/plugins/form-builder/query-keys.d.ts +38 -12
  590. package/dist/plugins/form-builder/query-keys.mjs +11 -4
  591. package/dist/plugins/kanban/api/index.cjs +9 -0
  592. package/dist/plugins/kanban/api/index.d.cts +137 -5
  593. package/dist/plugins/kanban/api/index.d.mts +137 -5
  594. package/dist/plugins/kanban/api/index.d.ts +137 -5
  595. package/dist/plugins/kanban/api/index.mjs +5 -2
  596. package/dist/plugins/kanban/client/components/index.d.cts +18 -10
  597. package/dist/plugins/kanban/client/components/index.d.mts +18 -10
  598. package/dist/plugins/kanban/client/components/index.d.ts +18 -10
  599. package/dist/plugins/kanban/client/hooks/index.d.cts +15 -7
  600. package/dist/plugins/kanban/client/hooks/index.d.mts +15 -7
  601. package/dist/plugins/kanban/client/hooks/index.d.ts +15 -7
  602. package/dist/plugins/kanban/client/index.d.cts +32 -28
  603. package/dist/plugins/kanban/client/index.d.mts +32 -28
  604. package/dist/plugins/kanban/client/index.d.ts +32 -28
  605. package/dist/plugins/kanban/permissions.cjs +101 -0
  606. package/dist/plugins/kanban/permissions.d.cts +109 -0
  607. package/dist/plugins/kanban/permissions.d.mts +109 -0
  608. package/dist/plugins/kanban/permissions.d.ts +109 -0
  609. package/dist/plugins/kanban/permissions.mjs +99 -0
  610. package/dist/plugins/kanban/query-keys.cjs +14 -15
  611. package/dist/plugins/kanban/query-keys.d.cts +63 -42
  612. package/dist/plugins/kanban/query-keys.d.mts +63 -42
  613. package/dist/plugins/kanban/query-keys.d.ts +63 -42
  614. package/dist/plugins/kanban/query-keys.mjs +14 -15
  615. package/dist/plugins/media/api/adapters/local.d.cts +1 -1
  616. package/dist/plugins/media/api/adapters/local.d.mts +1 -1
  617. package/dist/plugins/media/api/adapters/local.d.ts +1 -1
  618. package/dist/plugins/media/api/adapters/s3.d.cts +1 -1
  619. package/dist/plugins/media/api/adapters/s3.d.mts +1 -1
  620. package/dist/plugins/media/api/adapters/s3.d.ts +1 -1
  621. package/dist/plugins/media/api/adapters/vercel-blob.cjs +46 -0
  622. package/dist/plugins/media/api/adapters/vercel-blob.d.cts +6 -9
  623. package/dist/plugins/media/api/adapters/vercel-blob.d.mts +6 -9
  624. package/dist/plugins/media/api/adapters/vercel-blob.d.ts +6 -9
  625. package/dist/plugins/media/api/adapters/vercel-blob.mjs +46 -0
  626. package/dist/plugins/media/api/index.cjs +10 -0
  627. package/dist/plugins/media/api/index.d.cts +93 -6
  628. package/dist/plugins/media/api/index.d.mts +93 -6
  629. package/dist/plugins/media/api/index.d.ts +93 -6
  630. package/dist/plugins/media/api/index.mjs +2 -0
  631. package/dist/plugins/media/client/components/index.d.cts +1 -1
  632. package/dist/plugins/media/client/components/index.d.mts +1 -1
  633. package/dist/plugins/media/client/components/index.d.ts +1 -1
  634. package/dist/plugins/media/client/hooks/index.d.cts +20 -10
  635. package/dist/plugins/media/client/hooks/index.d.mts +20 -10
  636. package/dist/plugins/media/client/hooks/index.d.ts +20 -10
  637. package/dist/plugins/media/client/index.cjs +1 -0
  638. package/dist/plugins/media/client/index.d.cts +112 -100
  639. package/dist/plugins/media/client/index.d.mts +112 -100
  640. package/dist/plugins/media/client/index.d.ts +112 -100
  641. package/dist/plugins/media/client/index.mjs +1 -1
  642. package/dist/plugins/media/permissions.cjs +63 -0
  643. package/dist/plugins/media/permissions.d.cts +64 -0
  644. package/dist/plugins/media/permissions.d.mts +64 -0
  645. package/dist/plugins/media/permissions.d.ts +64 -0
  646. package/dist/plugins/media/permissions.mjs +61 -0
  647. package/dist/plugins/media/query-keys.cjs +29 -17
  648. package/dist/plugins/media/query-keys.d.cts +24 -31
  649. package/dist/plugins/media/query-keys.d.mts +24 -31
  650. package/dist/plugins/media/query-keys.d.ts +24 -31
  651. package/dist/plugins/media/query-keys.mjs +30 -18
  652. package/dist/plugins/open-api/api/index.d.cts +9 -4
  653. package/dist/plugins/open-api/api/index.d.mts +9 -4
  654. package/dist/plugins/open-api/api/index.d.ts +9 -4
  655. package/dist/plugins/route-docs/client/index.cjs +2 -2
  656. package/dist/plugins/route-docs/client/index.d.cts +54 -53
  657. package/dist/plugins/route-docs/client/index.d.mts +54 -53
  658. package/dist/plugins/route-docs/client/index.d.ts +54 -53
  659. package/dist/plugins/route-docs/client/index.mjs +2 -1
  660. package/dist/plugins/ui-builder/client/components/index.d.cts +8 -5
  661. package/dist/plugins/ui-builder/client/components/index.d.mts +8 -5
  662. package/dist/plugins/ui-builder/client/components/index.d.ts +8 -5
  663. package/dist/plugins/ui-builder/client/hooks/index.d.cts +5 -5
  664. package/dist/plugins/ui-builder/client/hooks/index.d.mts +5 -5
  665. package/dist/plugins/ui-builder/client/hooks/index.d.ts +5 -5
  666. package/dist/plugins/ui-builder/client/index.d.cts +151 -199
  667. package/dist/plugins/ui-builder/client/index.d.mts +151 -199
  668. package/dist/plugins/ui-builder/client/index.d.ts +151 -199
  669. package/dist/plugins/ui-builder/index.d.cts +11 -8
  670. package/dist/plugins/ui-builder/index.d.mts +11 -8
  671. package/dist/plugins/ui-builder/index.d.ts +11 -8
  672. package/dist/plugins/ui-builder/query-keys.d.cts +6 -6
  673. package/dist/plugins/ui-builder/query-keys.d.mts +6 -6
  674. package/dist/plugins/ui-builder/query-keys.d.ts +6 -6
  675. package/dist/react-router/index.cjs +2 -0
  676. package/dist/react-router/index.d.cts +41 -7
  677. package/dist/react-router/index.d.mts +41 -7
  678. package/dist/react-router/index.d.ts +41 -7
  679. package/dist/react-router/index.mjs +1 -0
  680. package/dist/shared/stack.0O62uXqP.d.ts +613 -0
  681. package/dist/shared/stack.0y6iTP03.d.ts +533 -0
  682. package/dist/shared/{stack.CbZenbej.d.cts → stack.1ukVJym7.d.cts} +3 -4
  683. package/dist/shared/{stack.CbZenbej.d.mts → stack.1ukVJym7.d.mts} +3 -4
  684. package/dist/shared/{stack.CbZenbej.d.ts → stack.1ukVJym7.d.ts} +3 -4
  685. package/dist/shared/stack.3Sr6qRtT.d.ts +507 -0
  686. package/dist/shared/{stack.9BAOaSqE.d.mts → stack.5_zzCejP.d.cts} +16 -14
  687. package/dist/shared/{stack.9BAOaSqE.d.ts → stack.5_zzCejP.d.mts} +16 -14
  688. package/dist/shared/{stack.9BAOaSqE.d.cts → stack.5_zzCejP.d.ts} +16 -14
  689. package/dist/shared/stack.B1UrNoVl.d.mts +533 -0
  690. package/dist/shared/{stack.B2xi4jj7.d.cts → stack.B1srlBud.d.mts} +2 -2
  691. package/dist/shared/stack.B3_aDcYL.d.cts +281 -0
  692. package/dist/shared/stack.B3_aDcYL.d.mts +281 -0
  693. package/dist/shared/stack.B3_aDcYL.d.ts +281 -0
  694. package/dist/shared/stack.B5yPgHsp.d.mts +507 -0
  695. package/dist/shared/stack.B8PG21zX.d.mts +764 -0
  696. package/dist/shared/stack.BFP_9pRX.d.cts +707 -0
  697. package/dist/shared/{stack.INBa9-TO.d.cts → stack.BGzgFx3R.d.cts} +5 -5
  698. package/dist/shared/stack.BJx1ZXrN.d.cts +118 -0
  699. package/dist/shared/{stack.7b3vsM8_.d.ts → stack.BK9Z2dcL.d.ts} +2 -2
  700. package/dist/shared/stack.BMHoxAn7.d.mts +707 -0
  701. package/dist/shared/stack.BMmvEBH_.d.ts +118 -0
  702. package/dist/shared/stack.BOZRaVpu.d.cts +1184 -0
  703. package/dist/shared/stack.BPLykw4s.d.ts +436 -0
  704. package/dist/shared/{stack.aqVZ6PEW.d.mts → stack.BRvqQWGt.d.cts} +40 -1
  705. package/dist/shared/{stack.aqVZ6PEW.d.cts → stack.BRvqQWGt.d.mts} +40 -1
  706. package/dist/shared/{stack.aqVZ6PEW.d.ts → stack.BRvqQWGt.d.ts} +40 -1
  707. package/dist/shared/stack.BSACE667.d.cts +23 -0
  708. package/dist/shared/stack.BYMentwB.d.cts +47 -0
  709. package/dist/shared/stack.BYMentwB.d.mts +47 -0
  710. package/dist/shared/stack.BYMentwB.d.ts +47 -0
  711. package/dist/shared/stack.Bt8hfw9o.d.ts +707 -0
  712. package/dist/shared/{stack.D7bewlgt.d.mts → stack.Bu2IPOLi.d.cts} +1 -0
  713. package/dist/shared/{stack.D7bewlgt.d.ts → stack.Bu2IPOLi.d.mts} +1 -0
  714. package/dist/shared/{stack.D7bewlgt.d.cts → stack.Bu2IPOLi.d.ts} +1 -0
  715. package/dist/shared/stack.BuxUQqL8.d.ts +408 -0
  716. package/dist/shared/stack.BzWGB5MG.d.cts +436 -0
  717. package/dist/shared/stack.C3bU9w6L.d.ts +351 -0
  718. package/dist/shared/stack.C4oVW2qK.d.cts +507 -0
  719. package/dist/shared/stack.CKXzdGiJ.d.cts +3 -0
  720. package/dist/shared/stack.CKXzdGiJ.d.mts +3 -0
  721. package/dist/shared/stack.CKXzdGiJ.d.ts +3 -0
  722. package/dist/shared/{stack.C3GBG8in.d.ts → stack.COrJrztD.d.cts} +1 -1
  723. package/dist/shared/{stack.C3GBG8in.d.cts → stack.COrJrztD.d.mts} +1 -1
  724. package/dist/shared/{stack.C3GBG8in.d.mts → stack.COrJrztD.d.ts} +1 -1
  725. package/dist/shared/stack.CX83YNuS.d.cts +408 -0
  726. package/dist/shared/stack.Cbd7sD5M.d.mts +118 -0
  727. package/dist/shared/{stack.B9NtGpAR.d.ts → stack.CcjENrr4.d.cts} +1 -5
  728. package/dist/shared/stack.CfK5NKlK.d.mts +613 -0
  729. package/dist/shared/{stack.3di7vQs6.d.mts → stack.CjCSDfWy.d.mts} +5 -5
  730. package/dist/shared/stack.Cmg7lzzy.d.cts +44 -0
  731. package/dist/shared/stack.Cmg7lzzy.d.mts +44 -0
  732. package/dist/shared/stack.Cmg7lzzy.d.ts +44 -0
  733. package/dist/shared/stack.CpE1mS3p.d.ts +331 -0
  734. package/dist/shared/stack.CskhFw3z.d.mts +23 -0
  735. package/dist/shared/stack.CvlC5kqe.d.cts +331 -0
  736. package/dist/shared/stack.CxKc9evq.d.ts +23 -0
  737. package/dist/shared/stack.CyalJ0j6.d.ts +764 -0
  738. package/dist/shared/stack.D6Pg-ufX.d.cts +764 -0
  739. package/dist/shared/{stack.lkebw2nj.d.mts → stack.DVEjWKCT.d.cts} +19 -5
  740. package/dist/shared/{stack.lkebw2nj.d.ts → stack.DVEjWKCT.d.mts} +19 -5
  741. package/dist/shared/{stack.lkebw2nj.d.cts → stack.DVEjWKCT.d.ts} +19 -5
  742. package/dist/shared/{stack.Cp_6mO5s.d.mts → stack.DbbvHbhn.d.mts} +1 -5
  743. package/dist/shared/stack.DiuRuzIs.d.cts +613 -0
  744. package/dist/shared/{stack.BMlLOMED.d.mts → stack.DjGixVx3.d.cts} +6 -2
  745. package/dist/shared/{stack.BMlLOMED.d.ts → stack.DjGixVx3.d.mts} +6 -2
  746. package/dist/shared/{stack.BMlLOMED.d.cts → stack.DjGixVx3.d.ts} +6 -2
  747. package/dist/shared/stack.DlBoNqYu.d.ts +1184 -0
  748. package/dist/shared/stack.DlCycSM-.d.mts +331 -0
  749. package/dist/shared/{stack.DycBcTeg.d.mts → stack.DmpPDPxA.d.cts} +2 -2
  750. package/dist/shared/{stack.CRelKJfH.d.ts → stack.Dpg_JjIo.d.ts} +5 -5
  751. package/dist/shared/stack.Dvy7FmaA.d.mts +1184 -0
  752. package/dist/shared/stack.DxHPKr2R.d.mts +436 -0
  753. package/dist/shared/stack.Egr3RWhA.d.mts +408 -0
  754. package/dist/shared/stack.Mak7pzIV.d.cts +533 -0
  755. package/dist/shared/stack.OYT8WU4n.d.mts +351 -0
  756. package/dist/shared/{stack.CPsYC2-Z.d.cts → stack.fdi94T4S.d.cts} +7 -7
  757. package/dist/shared/{stack.CPsYC2-Z.d.mts → stack.fdi94T4S.d.mts} +7 -7
  758. package/dist/shared/{stack.CPsYC2-Z.d.ts → stack.fdi94T4S.d.ts} +7 -7
  759. package/dist/shared/{stack.Dlgtumru.d.cts → stack.kaCV7vEL.d.ts} +1 -5
  760. package/dist/shared/stack.v2O65JqF.d.cts +351 -0
  761. package/dist/tanstack/index.cjs +2 -0
  762. package/dist/tanstack/index.d.cts +44 -14
  763. package/dist/tanstack/index.d.mts +44 -14
  764. package/dist/tanstack/index.d.ts +44 -14
  765. package/dist/tanstack/index.mjs +1 -0
  766. package/dist/tanstack/server.cjs +9 -0
  767. package/dist/tanstack/server.d.cts +15 -0
  768. package/dist/tanstack/server.d.mts +15 -0
  769. package/dist/tanstack/server.d.ts +15 -0
  770. package/dist/tanstack/server.mjs +7 -0
  771. package/package.json +203 -8
  772. package/src/__tests__/ai-chat-client-runtime.test.ts +481 -0
  773. package/src/__tests__/ai-chat-client-runtime.typecheck.tsx +130 -0
  774. package/src/__tests__/ai-chat-lifecycle-migrations.typecheck.ts +61 -0
  775. package/src/__tests__/ai-chat-query-keys.test.ts +125 -22
  776. package/src/__tests__/auth-provider.test.tsx +41 -314
  777. package/src/__tests__/auth-test-utils.ts +24 -0
  778. package/src/__tests__/authorization-client.test.tsx +767 -0
  779. package/src/__tests__/authorization-contraction.test.ts +182 -0
  780. package/src/__tests__/authorization-remote.test.ts +222 -0
  781. package/src/__tests__/authorization-server.test.ts +90 -0
  782. package/src/__tests__/authorization.test.ts +652 -0
  783. package/src/__tests__/authorization.typecheck.ts +671 -0
  784. package/src/__tests__/backend-plugin-factories.test.ts +54 -0
  785. package/src/__tests__/backend-plugin-factories.typecheck.ts +133 -0
  786. package/src/__tests__/client-plugin-ssr-loaders.test.ts +304 -138
  787. package/src/__tests__/client-runtime.test.ts +1021 -0
  788. package/src/__tests__/client-runtime.typecheck.ts +107 -0
  789. package/src/__tests__/client-stack-test-utils.ts +36 -0
  790. package/src/__tests__/content-lifecycle-migrations.typecheck.ts +122 -0
  791. package/src/__tests__/endpoint-inventory.test.ts +768 -0
  792. package/src/__tests__/entry-factories.test.tsx +104 -4
  793. package/src/__tests__/form-builder-query-keys.test.ts +32 -0
  794. package/src/__tests__/i18n-provider.test.tsx +4 -3
  795. package/src/__tests__/initial-identity-hydration.test.tsx +156 -0
  796. package/src/__tests__/initial-identity-layouts.test.tsx +204 -0
  797. package/src/__tests__/kanban-query-keys.test.ts +189 -2
  798. package/src/__tests__/managed-origin-hydration.browser.test.tsx +163 -0
  799. package/src/__tests__/media-query-keys.test.ts +91 -17
  800. package/src/__tests__/notify-provider.test.tsx +3 -2
  801. package/src/__tests__/package-metadata.test.ts +315 -0
  802. package/src/__tests__/page-component-overrides.test.tsx +3 -4
  803. package/src/__tests__/plugin-registration.test.tsx +183 -0
  804. package/src/__tests__/plugin-registration.typecheck.tsx +139 -0
  805. package/src/__tests__/plugins.test.tsx +72 -42
  806. package/src/__tests__/resource-factory.test.tsx +79 -2
  807. package/src/__tests__/resource-use-form.test.tsx +2 -2
  808. package/src/__tests__/resource-use-select.test.tsx +2 -4
  809. package/src/__tests__/router-overrides.test.tsx +20 -8
  810. package/src/__tests__/sitemap.test.ts +38 -22
  811. package/src/__tests__/stack-api.test.ts +39 -34
  812. package/src/__tests__/stack-auth.test.ts +44 -140
  813. package/src/__tests__/stack-constructors.test.ts +96 -0
  814. package/src/__tests__/stack-constructors.typecheck.ts +115 -0
  815. package/src/__tests__/use-list-state.test.tsx +7 -6
  816. package/src/__tests__/workflow-lifecycle-migrations.typecheck.ts +150 -0
  817. package/src/api/index.ts +204 -99
  818. package/src/authorization/client.tsx +310 -0
  819. package/src/authorization/index.ts +873 -0
  820. package/src/authorization/json.ts +70 -0
  821. package/src/authorization/remote.ts +234 -0
  822. package/src/authorization/server.ts +171 -0
  823. package/src/client/__tests__/server-origin.test.ts +119 -0
  824. package/src/client/components/compose.tsx +126 -18
  825. package/src/client/hooks/index.ts +12 -0
  826. package/src/client/hooks/use-list-state.ts +7 -13
  827. package/src/client/index.ts +105 -50
  828. package/src/client/runtime.ts +414 -0
  829. package/src/client/server.ts +174 -0
  830. package/src/context/auth.tsx +205 -154
  831. package/src/context/index.ts +10 -4
  832. package/src/context/provider.tsx +96 -57
  833. package/src/context/router.tsx +7 -0
  834. package/src/context/site-navigation.ts +52 -0
  835. package/src/next/index.tsx +2 -0
  836. package/src/next/layout.tsx +81 -0
  837. package/src/next/page.tsx +33 -12
  838. package/src/next/router.tsx +1 -1
  839. package/src/next/server.ts +5 -0
  840. package/src/plugin-registration.ts +70 -0
  841. package/src/plugins/ai-chat/__tests__/authorization.test.ts +2051 -0
  842. package/src/plugins/ai-chat/__tests__/chat-hooks.test.tsx +147 -0
  843. package/src/plugins/ai-chat/__tests__/chat-input-authorization.test.tsx +188 -0
  844. package/src/plugins/ai-chat/__tests__/client-sweep.test.tsx +1506 -34
  845. package/src/plugins/ai-chat/__tests__/hooks.test.tsx +131 -23
  846. package/src/plugins/ai-chat/api/getters.ts +2 -2
  847. package/src/plugins/ai-chat/api/index.ts +6 -1
  848. package/src/plugins/ai-chat/api/lifecycle-migrations.ts +20 -0
  849. package/src/plugins/ai-chat/api/operations.ts +1865 -0
  850. package/src/plugins/ai-chat/api/plugin.ts +78 -1168
  851. package/src/plugins/ai-chat/api/serializers.ts +30 -0
  852. package/src/plugins/ai-chat/client/components/chat-input.tsx +228 -129
  853. package/src/plugins/ai-chat/client/components/chat-interface.tsx +776 -183
  854. package/src/plugins/ai-chat/client/components/chat-layout.tsx +6 -7
  855. package/src/plugins/ai-chat/client/components/chat-message.tsx +1 -1
  856. package/src/plugins/ai-chat/client/components/chat-sidebar.tsx +57 -37
  857. package/src/plugins/ai-chat/client/components/pages/404-page.tsx +1 -1
  858. package/src/plugins/ai-chat/client/components/pages/chat-page.internal.tsx +5 -3
  859. package/src/plugins/ai-chat/client/components/pages/chat-page.tsx +56 -15
  860. package/src/plugins/ai-chat/client/components/shared/default-error.tsx +1 -1
  861. package/src/plugins/ai-chat/client/components/tool-call-display.tsx +1 -1
  862. package/src/plugins/ai-chat/client/hooks/ai-chat-resource.ts +1 -1
  863. package/src/plugins/ai-chat/client/hooks/chat-hooks.tsx +253 -20
  864. package/src/plugins/ai-chat/client/index.ts +1 -0
  865. package/src/plugins/ai-chat/client/navigation.ts +11 -0
  866. package/src/plugins/ai-chat/client/overrides.ts +47 -11
  867. package/src/plugins/ai-chat/client/plugin.tsx +208 -111
  868. package/src/plugins/ai-chat/permissions.ts +89 -0
  869. package/src/plugins/ai-chat/query-keys.ts +183 -25
  870. package/src/plugins/ai-chat/types.ts +7 -5
  871. package/src/plugins/api/create-endpoint.ts +40 -22
  872. package/src/plugins/api/endpoint-inventory.ts +206 -0
  873. package/src/plugins/api/index.ts +38 -4
  874. package/src/plugins/api/operation.ts +600 -0
  875. package/src/plugins/blog/__tests__/authorization.test.ts +1366 -0
  876. package/src/plugins/blog/__tests__/client-runtime.browser.test.tsx +257 -0
  877. package/src/plugins/blog/__tests__/client-runtime.test.ts +283 -0
  878. package/src/plugins/blog/__tests__/client-runtime.typecheck.tsx +98 -0
  879. package/src/plugins/blog/__tests__/client-sweep.test.tsx +212 -37
  880. package/src/plugins/blog/api/getters.ts +3 -3
  881. package/src/plugins/blog/api/index.ts +2 -0
  882. package/src/plugins/blog/api/lifecycle-migrations.ts +19 -0
  883. package/src/plugins/blog/api/mutations.ts +26 -5
  884. package/src/plugins/blog/api/operations.ts +727 -0
  885. package/src/plugins/blog/api/plugin.ts +99 -504
  886. package/src/plugins/blog/client/components/forms/image-field.tsx +2 -1
  887. package/src/plugins/blog/client/components/forms/markdown-editor-with-overrides.tsx +2 -1
  888. package/src/plugins/blog/client/components/forms/post-forms.tsx +61 -33
  889. package/src/plugins/blog/client/components/pages/404-page.tsx +3 -1
  890. package/src/plugins/blog/client/components/pages/edit-post-page.internal.tsx +2 -1
  891. package/src/plugins/blog/client/components/pages/edit-post-page.tsx +28 -5
  892. package/src/plugins/blog/client/components/pages/home-page.internal.tsx +2 -1
  893. package/src/plugins/blog/client/components/pages/home-page.tsx +7 -4
  894. package/src/plugins/blog/client/components/pages/new-post-page.internal.tsx +2 -1
  895. package/src/plugins/blog/client/components/pages/new-post-page.tsx +5 -2
  896. package/src/plugins/blog/client/components/pages/post-page.internal.tsx +2 -1
  897. package/src/plugins/blog/client/components/pages/post-page.tsx +38 -4
  898. package/src/plugins/blog/client/components/pages/tag-page.internal.tsx +2 -1
  899. package/src/plugins/blog/client/components/pages/tag-page.tsx +5 -1
  900. package/src/plugins/blog/client/components/shared/collapsible-tag-list.tsx +2 -1
  901. package/src/plugins/blog/client/components/shared/default-error.tsx +3 -1
  902. package/src/plugins/blog/client/components/shared/on-this-page.tsx +5 -2
  903. package/src/plugins/blog/client/components/shared/page-wrapper.tsx +2 -1
  904. package/src/plugins/blog/client/components/shared/post-card.tsx +2 -1
  905. package/src/plugins/blog/client/components/shared/posts-list.tsx +2 -1
  906. package/src/plugins/blog/client/components/shared/recent-posts-carousel.tsx +2 -1
  907. package/src/plugins/blog/client/components/shared/search-input.tsx +1 -1
  908. package/src/plugins/blog/client/constants.ts +2 -0
  909. package/src/plugins/blog/client/hooks/blog-resource.ts +2 -1
  910. package/src/plugins/blog/client/overrides.ts +1 -6
  911. package/src/plugins/blog/client/plugin.tsx +145 -129
  912. package/src/plugins/blog/permissions.ts +44 -0
  913. package/src/plugins/client/index.ts +108 -7
  914. package/src/plugins/client/resource/hooks.tsx +41 -18
  915. package/src/plugins/client/resource/internal.ts +77 -61
  916. package/src/plugins/client/resource/queries.ts +3 -4
  917. package/src/plugins/client/resource/use-form.ts +23 -20
  918. package/src/plugins/client/resource/use-select.ts +40 -34
  919. package/src/plugins/cms/__tests__/authorization.test.ts +2188 -0
  920. package/src/plugins/cms/__tests__/client-runtime.browser.test.tsx +245 -0
  921. package/src/plugins/cms/__tests__/client-runtime.test.ts +320 -0
  922. package/src/plugins/cms/__tests__/client-runtime.typecheck.tsx +208 -0
  923. package/src/plugins/cms/__tests__/client-sweep.test.tsx +202 -50
  924. package/src/plugins/cms/api/getters.ts +4 -4
  925. package/src/plugins/cms/api/index.ts +20 -0
  926. package/src/plugins/cms/api/lifecycle-migrations.ts +15 -0
  927. package/src/plugins/cms/api/mutations.ts +2 -2
  928. package/src/plugins/cms/api/operations.ts +2218 -0
  929. package/src/plugins/cms/api/plugin.ts +169 -1047
  930. package/src/plugins/cms/api/relations.ts +3 -1
  931. package/src/plugins/cms/client/components/forms/content-form.tsx +2 -1
  932. package/src/plugins/cms/client/components/forms/file-upload.tsx +3 -1
  933. package/src/plugins/cms/client/components/forms/relation-field.tsx +3 -1
  934. package/src/plugins/cms/client/components/inverse-relations-panel.tsx +29 -17
  935. package/src/plugins/cms/client/components/pages/404-page.tsx +7 -5
  936. package/src/plugins/cms/client/components/pages/content-editor-page.internal.tsx +19 -10
  937. package/src/plugins/cms/client/components/pages/content-editor-page.tsx +50 -12
  938. package/src/plugins/cms/client/components/pages/content-list-page.internal.tsx +48 -34
  939. package/src/plugins/cms/client/components/pages/content-list-page.tsx +8 -1
  940. package/src/plugins/cms/client/components/pages/dashboard-page.internal.tsx +15 -8
  941. package/src/plugins/cms/client/components/pages/dashboard-page.tsx +5 -1
  942. package/src/plugins/cms/client/components/shared/page-wrapper.tsx +2 -1
  943. package/src/plugins/cms/client/constants.ts +2 -0
  944. package/src/plugins/cms/client/hooks/cms-resource.ts +2 -1
  945. package/src/plugins/cms/client/index.ts +6 -1
  946. package/src/plugins/cms/client/overrides.ts +46 -6
  947. package/src/plugins/cms/client/plugin.tsx +135 -80
  948. package/src/plugins/cms/permissions.ts +43 -0
  949. package/src/plugins/cms/types.ts +174 -46
  950. package/src/plugins/comments/__tests__/authorization.test.ts +1570 -0
  951. package/src/plugins/comments/__tests__/client-runtime.browser.test.tsx +207 -0
  952. package/src/plugins/comments/__tests__/client-runtime.test.ts +224 -0
  953. package/src/plugins/comments/__tests__/client-runtime.typecheck.tsx +85 -0
  954. package/src/plugins/comments/__tests__/client-sweep.test.tsx +465 -79
  955. package/src/plugins/comments/api/getters.ts +19 -3
  956. package/src/plugins/comments/api/index.ts +2 -6
  957. package/src/plugins/comments/api/lifecycle-migrations.ts +20 -0
  958. package/src/plugins/comments/api/mutations.ts +261 -88
  959. package/src/plugins/comments/api/operations.ts +742 -0
  960. package/src/plugins/comments/api/plugin.ts +76 -548
  961. package/src/plugins/comments/client/components/comment-count.tsx +38 -5
  962. package/src/plugins/comments/client/components/comment-thread.tsx +154 -112
  963. package/src/plugins/comments/client/components/pages/moderation-page.internal.tsx +144 -78
  964. package/src/plugins/comments/client/components/pages/moderation-page.tsx +18 -2
  965. package/src/plugins/comments/client/components/pages/moderation-state.ts +13 -0
  966. package/src/plugins/comments/client/components/pages/my-comments-page.internal.tsx +38 -30
  967. package/src/plugins/comments/client/components/pages/my-comments-page.tsx +3 -1
  968. package/src/plugins/comments/client/components/pages/resource-comments-page.internal.tsx +29 -30
  969. package/src/plugins/comments/client/components/pages/resource-comments-page.tsx +10 -1
  970. package/src/plugins/comments/client/components/shared/page-wrapper.tsx +2 -1
  971. package/src/plugins/comments/client/components/shared/pagination.tsx +2 -1
  972. package/src/plugins/comments/client/constants.ts +2 -0
  973. package/src/plugins/comments/client/hooks/use-comments.tsx +430 -421
  974. package/src/plugins/comments/client/localization/comments-thread.ts +1 -0
  975. package/src/plugins/comments/client/plugin.tsx +113 -72
  976. package/src/plugins/comments/permissions.ts +68 -0
  977. package/src/plugins/comments/query-keys.ts +9 -10
  978. package/src/plugins/comments/schemas.ts +7 -8
  979. package/src/plugins/form-builder/__tests__/authorization.test.ts +1600 -0
  980. package/src/plugins/form-builder/__tests__/client-runtime.browser.test.tsx +255 -0
  981. package/src/plugins/form-builder/__tests__/client-runtime.test.ts +132 -0
  982. package/src/plugins/form-builder/__tests__/client-runtime.typecheck.tsx +77 -0
  983. package/src/plugins/form-builder/__tests__/client-sweep.test.tsx +350 -54
  984. package/src/plugins/form-builder/__tests__/form-renderer-authorization.test.tsx +162 -0
  985. package/src/plugins/form-builder/api/getters.ts +21 -5
  986. package/src/plugins/form-builder/api/index.ts +31 -0
  987. package/src/plugins/form-builder/api/lifecycle-migrations.ts +17 -0
  988. package/src/plugins/form-builder/api/operations.ts +1493 -0
  989. package/src/plugins/form-builder/api/plugin.ts +125 -632
  990. package/src/plugins/form-builder/api/query-key-defs.ts +7 -0
  991. package/src/plugins/form-builder/api/serializers.ts +1 -0
  992. package/src/plugins/form-builder/client/components/forms/form-renderer.tsx +49 -19
  993. package/src/plugins/form-builder/client/components/pages/404-page.tsx +9 -9
  994. package/src/plugins/form-builder/client/components/pages/form-builder-page.internal.tsx +54 -30
  995. package/src/plugins/form-builder/client/components/pages/form-builder-page.tsx +42 -9
  996. package/src/plugins/form-builder/client/components/pages/form-list-page.internal.tsx +46 -34
  997. package/src/plugins/form-builder/client/components/pages/form-list-page.tsx +6 -2
  998. package/src/plugins/form-builder/client/components/pages/submissions-page.internal.tsx +98 -64
  999. package/src/plugins/form-builder/client/components/pages/submissions-page.tsx +29 -9
  1000. package/src/plugins/form-builder/client/components/shared/page-wrapper.tsx +2 -1
  1001. package/src/plugins/form-builder/client/constants.ts +2 -0
  1002. package/src/plugins/form-builder/client/hooks/form-builder-hooks.tsx +68 -4
  1003. package/src/plugins/form-builder/client/hooks/form-builder-resource.ts +2 -1
  1004. package/src/plugins/form-builder/client/hooks/index.tsx +1 -0
  1005. package/src/plugins/form-builder/client/overrides.ts +1 -6
  1006. package/src/plugins/form-builder/client/plugin.tsx +128 -96
  1007. package/src/plugins/form-builder/permissions.ts +94 -0
  1008. package/src/plugins/form-builder/query-keys.ts +28 -3
  1009. package/src/plugins/form-builder/schemas.ts +9 -1
  1010. package/src/plugins/form-builder/types.ts +173 -41
  1011. package/src/plugins/kanban/__tests__/authorization.test.ts +1382 -0
  1012. package/src/plugins/kanban/__tests__/client-runtime.browser.test.tsx +302 -0
  1013. package/src/plugins/kanban/__tests__/client-runtime.test.ts +130 -0
  1014. package/src/plugins/kanban/__tests__/client-runtime.typecheck.tsx +81 -0
  1015. package/src/plugins/kanban/__tests__/client-sweep.test.tsx +418 -33
  1016. package/src/plugins/kanban/__tests__/identity-partition.test.tsx +306 -0
  1017. package/src/plugins/kanban/api/getters.ts +65 -50
  1018. package/src/plugins/kanban/api/index.ts +55 -4
  1019. package/src/plugins/kanban/api/lifecycle-migrations.ts +25 -0
  1020. package/src/plugins/kanban/api/mutations.ts +3 -3
  1021. package/src/plugins/kanban/api/operations.ts +2065 -0
  1022. package/src/plugins/kanban/api/plugin.ts +83 -1013
  1023. package/src/plugins/kanban/api/serializers.ts +26 -0
  1024. package/src/plugins/kanban/client/components/forms/board-form.tsx +3 -1
  1025. package/src/plugins/kanban/client/components/forms/column-form.tsx +3 -1
  1026. package/src/plugins/kanban/client/components/forms/task-form.tsx +92 -74
  1027. package/src/plugins/kanban/client/components/pages/404-page.tsx +6 -9
  1028. package/src/plugins/kanban/client/components/pages/board-page.internal.tsx +57 -74
  1029. package/src/plugins/kanban/client/components/pages/board-page.tsx +31 -7
  1030. package/src/plugins/kanban/client/components/pages/boards-list-page.internal.tsx +54 -45
  1031. package/src/plugins/kanban/client/components/pages/boards-list-page.tsx +2 -1
  1032. package/src/plugins/kanban/client/components/pages/new-board-page.internal.tsx +8 -12
  1033. package/src/plugins/kanban/client/components/pages/new-board-page.tsx +2 -1
  1034. package/src/plugins/kanban/client/components/shared/column-content.tsx +61 -48
  1035. package/src/plugins/kanban/client/components/shared/default-error.tsx +3 -1
  1036. package/src/plugins/kanban/client/components/shared/kanban-board.tsx +6 -6
  1037. package/src/plugins/kanban/client/components/shared/permission-access-any.tsx +32 -0
  1038. package/src/plugins/kanban/client/components/shared/task-card.tsx +64 -20
  1039. package/src/plugins/kanban/client/components/shared/user-avatar.tsx +3 -1
  1040. package/src/plugins/kanban/client/constants.ts +2 -0
  1041. package/src/plugins/kanban/client/hooks/kanban-hooks.tsx +55 -10
  1042. package/src/plugins/kanban/client/hooks/kanban-resource.ts +2 -1
  1043. package/src/plugins/kanban/client/overrides.ts +0 -5
  1044. package/src/plugins/kanban/client/plugin.tsx +201 -113
  1045. package/src/plugins/kanban/permissions.ts +100 -0
  1046. package/src/plugins/kanban/query-keys.ts +61 -21
  1047. package/src/plugins/kanban/schemas.ts +44 -18
  1048. package/src/plugins/kanban/types.ts +381 -1
  1049. package/src/plugins/media/__tests__/authorization.test.ts +1769 -0
  1050. package/src/plugins/media/__tests__/client-runtime.browser.test.tsx +975 -0
  1051. package/src/plugins/media/__tests__/client-runtime.test.ts +539 -0
  1052. package/src/plugins/media/__tests__/client-runtime.typecheck.tsx +135 -0
  1053. package/src/plugins/media/__tests__/client-sweep.test.tsx +292 -24
  1054. package/src/plugins/media/__tests__/identity-partition.test.tsx +741 -0
  1055. package/src/plugins/media/__tests__/plugin.test.ts +68 -28
  1056. package/src/plugins/media/__tests__/query-key-defs.test.ts +32 -2
  1057. package/src/plugins/media/api/adapters/vercel-blob.ts +84 -8
  1058. package/src/plugins/media/api/getters.ts +6 -6
  1059. package/src/plugins/media/api/index.ts +3 -0
  1060. package/src/plugins/media/api/lifecycle-migrations.ts +11 -0
  1061. package/src/plugins/media/api/mutations.ts +19 -13
  1062. package/src/plugins/media/api/operations.ts +1873 -0
  1063. package/src/plugins/media/api/plugin.ts +211 -899
  1064. package/src/plugins/media/api/query-key-defs.ts +66 -4
  1065. package/src/plugins/media/api/serializers.ts +4 -2
  1066. package/src/plugins/media/api/storage-adapter.ts +22 -4
  1067. package/src/plugins/media/asset-url.ts +14 -0
  1068. package/src/plugins/media/client/components/media-picker/asset-card.tsx +105 -98
  1069. package/src/plugins/media/client/components/media-picker/folder-tree.tsx +82 -60
  1070. package/src/plugins/media/client/components/media-picker/index.tsx +235 -171
  1071. package/src/plugins/media/client/components/media-picker/upload-tab.tsx +2 -10
  1072. package/src/plugins/media/client/components/media-picker/url-tab.tsx +1 -8
  1073. package/src/plugins/media/client/components/pages/library-page.internal.tsx +103 -82
  1074. package/src/plugins/media/client/components/pages/library-page.tsx +4 -2
  1075. package/src/plugins/media/client/components/upload-permission-check.tsx +75 -0
  1076. package/src/plugins/media/client/constants.ts +2 -0
  1077. package/src/plugins/media/client/hooks/media-resource.ts +2 -1
  1078. package/src/plugins/media/client/hooks/use-media.tsx +292 -49
  1079. package/src/plugins/media/client/index.ts +16 -3
  1080. package/src/plugins/media/client/overrides.ts +6 -17
  1081. package/src/plugins/media/client/plugin.tsx +188 -123
  1082. package/src/plugins/media/client/upload.ts +170 -53
  1083. package/src/plugins/media/db.ts +8 -0
  1084. package/src/plugins/media/permissions.ts +61 -0
  1085. package/src/plugins/media/query-keys.ts +63 -19
  1086. package/src/plugins/media/types.ts +8 -2
  1087. package/src/plugins/open-api/__tests__/route-introspection.test.ts +277 -0
  1088. package/src/plugins/open-api/api/generator.ts +49 -8
  1089. package/src/plugins/open-api/api/plugin.ts +36 -14
  1090. package/src/plugins/route-docs/client/components/pages/docs-page.tsx +63 -23
  1091. package/src/plugins/route-docs/client/constants.ts +2 -0
  1092. package/src/plugins/route-docs/client/hooks.ts +23 -13
  1093. package/src/plugins/route-docs/client/index.ts +7 -1
  1094. package/src/plugins/route-docs/client/plugin.tsx +222 -145
  1095. package/src/plugins/route-docs/client/schema.ts +31 -0
  1096. package/src/plugins/route-docs/generator.ts +9 -5
  1097. package/src/plugins/ui-builder/__tests__/client-sweep.test.tsx +427 -48
  1098. package/src/plugins/ui-builder/client/components/page-renderer.tsx +58 -16
  1099. package/src/plugins/ui-builder/client/components/pages/page-builder-page.internal.tsx +47 -26
  1100. package/src/plugins/ui-builder/client/components/pages/page-builder-page.tsx +43 -8
  1101. package/src/plugins/ui-builder/client/components/pages/page-list-page.internal.tsx +38 -19
  1102. package/src/plugins/ui-builder/client/components/pages/page-list-page.tsx +8 -2
  1103. package/src/plugins/ui-builder/client/components/shared/default-error.tsx +2 -1
  1104. package/src/plugins/ui-builder/client/components/shared/page-wrapper.tsx +2 -1
  1105. package/src/plugins/ui-builder/client/constants.ts +2 -0
  1106. package/src/plugins/ui-builder/client/hooks/ui-builder-resource.ts +2 -1
  1107. package/src/plugins/ui-builder/client/index.ts +4 -1
  1108. package/src/plugins/ui-builder/client/overrides.ts +16 -21
  1109. package/src/plugins/ui-builder/client/plugin.tsx +119 -66
  1110. package/src/plugins/ui-builder/client/registry.ts +3 -5
  1111. package/src/plugins/ui-builder/types.ts +7 -4
  1112. package/src/plugins/utils.ts +5 -1
  1113. package/src/react-router/index.tsx +6 -0
  1114. package/src/react-router/layout.ts +43 -0
  1115. package/src/react-router/page.tsx +46 -17
  1116. package/src/react-router/router.tsx +1 -1
  1117. package/src/shared/auth-types.ts +19 -70
  1118. package/src/shared/entry-factories.ts +12 -3
  1119. package/src/shared/initial-identity.ts +73 -0
  1120. package/src/shared/list-state.ts +12 -0
  1121. package/src/shared/types.ts +1 -0
  1122. package/src/tanstack/index.tsx +7 -0
  1123. package/src/tanstack/layout.ts +36 -0
  1124. package/src/tanstack/page.tsx +35 -13
  1125. package/src/tanstack/router.tsx +1 -1
  1126. package/src/tanstack/server.ts +18 -0
  1127. package/src/types.ts +557 -65
  1128. package/dist/shared/stack.80-y2TTR.d.mts +0 -840
  1129. package/dist/shared/stack.B-hEIoUw.d.ts +0 -406
  1130. package/dist/shared/stack.B8vdOMnQ.d.cts +0 -329
  1131. package/dist/shared/stack.BISAZ5LX.d.mts +0 -492
  1132. package/dist/shared/stack.BL5PvShn.d.mts +0 -193
  1133. package/dist/shared/stack.Be1QIHEn.d.cts +0 -23
  1134. package/dist/shared/stack.Be1QIHEn.d.mts +0 -23
  1135. package/dist/shared/stack.Be1QIHEn.d.ts +0 -23
  1136. package/dist/shared/stack.BjvOk_Bs.d.cts +0 -492
  1137. package/dist/shared/stack.Bk5UB_BT.d.ts +0 -840
  1138. package/dist/shared/stack.BozPgbrZ.d.cts +0 -201
  1139. package/dist/shared/stack.BozPgbrZ.d.mts +0 -201
  1140. package/dist/shared/stack.BozPgbrZ.d.ts +0 -201
  1141. package/dist/shared/stack.BqTR6qi2.d.ts +0 -193
  1142. package/dist/shared/stack.BvxHSZYT.d.cts +0 -406
  1143. package/dist/shared/stack.C1ATQ3pd.d.ts +0 -416
  1144. package/dist/shared/stack.C4_gEENS.d.cts +0 -97
  1145. package/dist/shared/stack.C4_gEENS.d.mts +0 -97
  1146. package/dist/shared/stack.C4_gEENS.d.ts +0 -97
  1147. package/dist/shared/stack.C5Y5lViI.d.cts +0 -461
  1148. package/dist/shared/stack.C8SwdUz8.d.ts +0 -461
  1149. package/dist/shared/stack.CBsp9rDM.d.cts +0 -193
  1150. package/dist/shared/stack.CMbX8Q5C.d.ts +0 -560
  1151. package/dist/shared/stack.Cf-DbL1A.d.ts +0 -329
  1152. package/dist/shared/stack.DHTvwoNG.d.mts +0 -329
  1153. package/dist/shared/stack.DJaKVY7v.d.cts +0 -76
  1154. package/dist/shared/stack.DJaKVY7v.d.mts +0 -76
  1155. package/dist/shared/stack.DJaKVY7v.d.ts +0 -76
  1156. package/dist/shared/stack.DKZMaVr6.d.cts +0 -416
  1157. package/dist/shared/stack.DQq8DEIv.d.mts +0 -461
  1158. package/dist/shared/stack.Dd-8shBE.d.ts +0 -492
  1159. package/dist/shared/stack.Dj04W2c3.d.mts +0 -560
  1160. package/dist/shared/stack.DrUBX-QE.d.cts +0 -34
  1161. package/dist/shared/stack.DrUBX-QE.d.mts +0 -34
  1162. package/dist/shared/stack.DrUBX-QE.d.ts +0 -34
  1163. package/dist/shared/stack.H5B8miAV.d.cts +0 -840
  1164. package/dist/shared/stack.aXdBOJAR.d.cts +0 -173
  1165. package/dist/shared/stack.aXdBOJAR.d.mts +0 -173
  1166. package/dist/shared/stack.aXdBOJAR.d.ts +0 -173
  1167. package/dist/shared/stack.eq5eg1yt.d.cts +0 -560
  1168. package/dist/shared/stack.f8Vke-eH.d.mts +0 -406
  1169. package/dist/shared/stack.oBokjN_J.d.mts +0 -416
  1170. package/dist/shared/{stack.B0muOwUF.d.cts → stack.Csi-4Mgz.d.cts} +8 -8
  1171. package/dist/shared/{stack.B0muOwUF.d.mts → stack.Csi-4Mgz.d.mts} +8 -8
  1172. package/dist/shared/{stack.B0muOwUF.d.ts → stack.Csi-4Mgz.d.ts} +8 -8
@@ -0,0 +1,1570 @@
1
+ import { createMemoryAdapter } from "@btst/adapter-memory";
2
+ import { defineDb, type DatabaseDefinition } from "@btst/db";
3
+ import { describe, expect, it, vi } from "vitest";
4
+ import { z } from "zod";
5
+ import { createBackendStack } from "../../../api";
6
+ import { defineAuthorization } from "../../../authorization";
7
+ import {
8
+ createServerAuth,
9
+ type ServerAuth,
10
+ } from "../../../authorization/server";
11
+ import {
12
+ commentsBackendPlugin,
13
+ COMMENTS_LIFECYCLE_HOOK_MIGRATIONS,
14
+ type CommentsBackendHooks,
15
+ type CommentsBackendOptions,
16
+ } from "../api";
17
+ import { commentsPermissions } from "../permissions";
18
+ import type { Comment, CommentLike } from "../types";
19
+
20
+ const memoryAdapter = (db: DatabaseDefinition) => createMemoryAdapter(db)({});
21
+
22
+ const authorization = defineAuthorization({
23
+ identity: z.object({
24
+ id: z.string(),
25
+ role: z.enum(["user", "moderator"]),
26
+ }),
27
+ permissions: [commentsPermissions] as const,
28
+ rules: ({ comments }) => [
29
+ comments.thread.read.when(({ identity, facts }) => {
30
+ if (facts.scope === "public") return true;
31
+ if (facts.scope === "own") {
32
+ return (
33
+ identity?.id === facts.authorId || identity?.role === "moderator"
34
+ );
35
+ }
36
+ return identity?.role === "moderator";
37
+ }),
38
+ comments.thread.createComment.when(({ identity }) => identity !== null),
39
+ comments.comment.edit.when(
40
+ ({ identity, facts }) =>
41
+ identity?.id === facts.authorId || identity?.role === "moderator",
42
+ ),
43
+ comments.comment.delete.when(
44
+ ({ identity, facts }) =>
45
+ identity?.id === facts.authorId || identity?.role === "moderator",
46
+ ),
47
+ comments.comment.react.when(
48
+ ({ identity, facts }) => identity !== null && facts.status === "approved",
49
+ ),
50
+ comments.comment.moderate.when(
51
+ ({ identity }) => identity?.role === "moderator",
52
+ ),
53
+ ],
54
+ });
55
+
56
+ type Identity = { id: string; role: "user" | "moderator" };
57
+
58
+ function identityFromRequest(request: Request): Identity | null {
59
+ const id = request.headers.get("x-user-id");
60
+ const role = request.headers.get("x-user-role");
61
+ if (!id || (role !== "user" && role !== "moderator")) return null;
62
+ return { id, role };
63
+ }
64
+
65
+ function createAuth(
66
+ getIdentity: (
67
+ request: Request,
68
+ ) => Identity | null | Promise<Identity | null> = identityFromRequest,
69
+ ) {
70
+ return createServerAuth({
71
+ authorization,
72
+ getIdentity: ({ request }) => getIdentity(request),
73
+ });
74
+ }
75
+
76
+ const moderatorOnlyAuthorization = defineAuthorization({
77
+ identity: z.object({
78
+ id: z.string(),
79
+ role: z.enum(["user", "moderator"]),
80
+ }),
81
+ permissions: [commentsPermissions] as const,
82
+ rules: ({ comments }) => [
83
+ comments.thread.read.when(({ identity }) => identity?.role === "moderator"),
84
+ comments.thread.createComment.when(
85
+ ({ identity }) => identity?.role === "moderator",
86
+ ),
87
+ comments.comment.edit.when(
88
+ ({ identity }) => identity?.role === "moderator",
89
+ ),
90
+ comments.comment.delete.when(
91
+ ({ identity }) => identity?.role === "moderator",
92
+ ),
93
+ comments.comment.react.when(
94
+ ({ identity }) => identity?.role === "moderator",
95
+ ),
96
+ comments.comment.moderate.when(
97
+ ({ identity }) => identity?.role === "moderator",
98
+ ),
99
+ ],
100
+ });
101
+
102
+ const missingRulesAuthorization = defineAuthorization({
103
+ identity: z.object({
104
+ id: z.string(),
105
+ role: z.enum(["user", "moderator"]),
106
+ }),
107
+ permissions: [commentsPermissions] as const,
108
+ rules: () => [],
109
+ });
110
+
111
+ const throwingRulesAuthorization = defineAuthorization({
112
+ identity: z.object({
113
+ id: z.string(),
114
+ role: z.enum(["user", "moderator"]),
115
+ }),
116
+ permissions: [commentsPermissions] as const,
117
+ rules: ({ comments }) => [
118
+ comments.thread.read.when(() => {
119
+ throw new Error("rule unavailable");
120
+ }),
121
+ comments.thread.createComment.when(() => {
122
+ throw new Error("rule unavailable");
123
+ }),
124
+ comments.comment.edit.when(() => {
125
+ throw new Error("rule unavailable");
126
+ }),
127
+ comments.comment.delete.when(() => {
128
+ throw new Error("rule unavailable");
129
+ }),
130
+ comments.comment.react.when(() => {
131
+ throw new Error("rule unavailable");
132
+ }),
133
+ comments.comment.moderate.when(() => {
134
+ throw new Error("rule unavailable");
135
+ }),
136
+ ],
137
+ });
138
+
139
+ function createModeratorOnlyAuth(
140
+ getIdentity: (
141
+ request: Request,
142
+ ) => Identity | null | Promise<Identity | null> = identityFromRequest,
143
+ ) {
144
+ return createServerAuth({
145
+ authorization: moderatorOnlyAuthorization,
146
+ getIdentity: ({ request }) => getIdentity(request),
147
+ });
148
+ }
149
+
150
+ function makeBackend(options?: {
151
+ plugin?: CommentsBackendOptions;
152
+ auth?: ServerAuth<any>;
153
+ }) {
154
+ return createBackendStack({
155
+ basePath: "/api",
156
+ plugins: { comments: commentsBackendPlugin(options?.plugin) },
157
+ adapter: memoryAdapter,
158
+ ...(options?.auth ? { auth: options.auth as never } : {}),
159
+ });
160
+ }
161
+
162
+ function request(
163
+ path: string,
164
+ options?: { method?: string; identity?: Identity; body?: unknown },
165
+ ) {
166
+ const headers = new Headers();
167
+ if (options?.identity) {
168
+ headers.set("x-user-id", options.identity.id);
169
+ headers.set("x-user-role", options.identity.role);
170
+ }
171
+ if (options?.body !== undefined)
172
+ headers.set("content-type", "application/json");
173
+ return new Request(`http://localhost/api${path}`, {
174
+ method: options?.method ?? "GET",
175
+ headers,
176
+ ...(options?.body === undefined
177
+ ? {}
178
+ : { body: JSON.stringify(options.body) }),
179
+ });
180
+ }
181
+
182
+ async function seedComment(
183
+ backend: ReturnType<typeof makeBackend>,
184
+ overrides: Partial<Comment> = {},
185
+ ) {
186
+ return backend.adapter.create<Comment>({
187
+ model: "comment",
188
+ data: {
189
+ resourceId: "post-1",
190
+ resourceType: "post",
191
+ parentId: null,
192
+ authorId: "owner-1",
193
+ body: "Authorization tracer",
194
+ status: "approved",
195
+ likes: 0,
196
+ createdAt: new Date("2026-01-01T00:00:00.000Z"),
197
+ updatedAt: new Date("2026-01-01T00:00:00.000Z"),
198
+ ...overrides,
199
+ },
200
+ });
201
+ }
202
+
203
+ const owner = { id: "owner-1", role: "user" } as const;
204
+ const viewer = { id: "viewer-1", role: "user" } as const;
205
+ const moderator = { id: "moderator-1", role: "moderator" } as const;
206
+
207
+ type CommentsOperationApi = ReturnType<
208
+ typeof makeBackend
209
+ >["trusted"]["comments"];
210
+
211
+ type OperationScenario = {
212
+ readonly name: string;
213
+ readonly hook: keyof CommentsBackendHooks;
214
+ readonly prepare: (
215
+ backend: ReturnType<typeof makeBackend>,
216
+ ) => Promise<(api: CommentsOperationApi) => Promise<unknown>>;
217
+ readonly invalid: (api: CommentsOperationApi) => Promise<unknown>;
218
+ };
219
+
220
+ const operationScenarios: readonly OperationScenario[] = [
221
+ {
222
+ name: "listComments",
223
+ hook: "onBeforeListComments",
224
+ prepare: async () => (api) => api.listComments({ status: "pending" }),
225
+ invalid: (api) => api.listComments({ limit: 0 }),
226
+ },
227
+ {
228
+ name: "getCommentCount",
229
+ hook: "onBeforeCountComments",
230
+ prepare: async () => (api) =>
231
+ api.getCommentCount({
232
+ resourceId: "post-1",
233
+ resourceType: "post",
234
+ status: "pending",
235
+ }),
236
+ invalid: (api) =>
237
+ api.getCommentCount({ resourceId: "", resourceType: "post" }),
238
+ },
239
+ {
240
+ name: "createComment",
241
+ hook: "onBeforeCreateComment",
242
+ prepare: async () => (api) =>
243
+ api.createComment({
244
+ resourceId: "post-1",
245
+ resourceType: "post",
246
+ body: "Operation matrix",
247
+ authorId: "trusted-job",
248
+ }),
249
+ invalid: (api) =>
250
+ api.createComment({
251
+ resourceId: "post-1",
252
+ resourceType: "post",
253
+ body: "",
254
+ authorId: "trusted-job",
255
+ }),
256
+ },
257
+ {
258
+ name: "updateComment",
259
+ hook: "onBeforeUpdateComment",
260
+ prepare: async (backend) => {
261
+ const comment = await seedComment(backend);
262
+ return (api) =>
263
+ api.updateComment({
264
+ id: comment.id,
265
+ data: { body: "Updated by matrix" },
266
+ });
267
+ },
268
+ invalid: (api) =>
269
+ api.updateComment({ id: "", data: { body: "Updated by matrix" } }),
270
+ },
271
+ {
272
+ name: "toggleLike",
273
+ hook: "onBeforeToggleCommentReaction",
274
+ prepare: async (backend) => {
275
+ const comment = await seedComment(backend);
276
+ return (api) =>
277
+ api.toggleLike({ id: comment.id, authorId: "trusted-job" });
278
+ },
279
+ invalid: (api) => api.toggleLike({ id: "", authorId: "trusted-job" }),
280
+ },
281
+ {
282
+ name: "updateCommentStatus",
283
+ hook: "onBeforeModerateComment",
284
+ prepare: async (backend) => {
285
+ const comment = await seedComment(backend, { status: "pending" });
286
+ return (api) =>
287
+ api.updateCommentStatus({
288
+ id: comment.id,
289
+ data: { status: "approved" },
290
+ });
291
+ },
292
+ invalid: (api) =>
293
+ api.updateCommentStatus({ id: "", data: { status: "approved" } }),
294
+ },
295
+ {
296
+ name: "deleteComment",
297
+ hook: "onBeforeDeleteComment",
298
+ prepare: async (backend) => {
299
+ const comment = await seedComment(backend);
300
+ return (api) => api.deleteComment({ id: comment.id });
301
+ },
302
+ invalid: (api) => api.deleteComment({ id: "" }),
303
+ },
304
+ ];
305
+
306
+ describe("Comments authorization inventory", () => {
307
+ it("records every removed lifecycle name and canonical replacement", () => {
308
+ expect(COMMENTS_LIFECYCLE_HOOK_MIGRATIONS).toEqual({
309
+ onBeforeList: "onBeforeListComments",
310
+ onBeforeCount: "onBeforeCountComments",
311
+ onBeforeListByAuthor: "onBeforeListCommentsByAuthor",
312
+ onBeforePost: "onBeforeCreateComment",
313
+ onAfterPost: "onAfterCreateComment",
314
+ onBeforeEdit: "onBeforeUpdateComment",
315
+ onAfterEdit: "onAfterUpdateComment",
316
+ onBeforeLike: "onBeforeToggleCommentReaction",
317
+ onBeforeStatusChange: "onBeforeModerateComment",
318
+ onAfterApprove: "onAfterApproveComment",
319
+ onBeforeDelete: "onBeforeDeleteComment",
320
+ onAfterDelete: "onAfterDeleteComment",
321
+ });
322
+ });
323
+
324
+ it.each([
325
+ {
326
+ allowPosting: true,
327
+ allowEditing: true,
328
+ routes: ["createComment", "updateComment"],
329
+ },
330
+ { allowPosting: true, allowEditing: false, routes: ["createComment"] },
331
+ { allowPosting: false, allowEditing: true, routes: ["updateComment"] },
332
+ { allowPosting: false, allowEditing: false, routes: [] },
333
+ ])(
334
+ "keeps conditional routes declared when posting=$allowPosting and editing=$allowEditing",
335
+ ({ allowPosting, allowEditing, routes }) => {
336
+ const backend = makeBackend({
337
+ plugin: { allowPosting, allowEditing },
338
+ });
339
+ const composed = Object.keys(
340
+ (backend.router as unknown as { endpoints: Record<string, unknown> })
341
+ .endpoints,
342
+ )
343
+ .filter(
344
+ (name) =>
345
+ name === "comments_createComment" ||
346
+ name === "comments_updateComment",
347
+ )
348
+ .map((name) => name.replace("comments_", ""))
349
+ .sort();
350
+ expect(composed).toEqual([...routes].sort());
351
+ },
352
+ );
353
+
354
+ it("covers every maintained transport operation with one descriptor", () => {
355
+ const plugin = commentsBackendPlugin();
356
+ const adapter = memoryAdapter(defineDb({}).use(plugin.dbPlugin));
357
+ const operations = plugin.operations?.(adapter);
358
+ const expected = [
359
+ "createComment",
360
+ "deleteComment",
361
+ "getCommentCount",
362
+ "listComments",
363
+ "toggleLike",
364
+ "updateComment",
365
+ "updateCommentStatus",
366
+ ];
367
+
368
+ expect(Object.keys(operations ?? {}).sort()).toEqual(expected);
369
+ expect(
370
+ Object.fromEntries(
371
+ Object.entries(operations ?? {}).map(([name, operation]) => [
372
+ name,
373
+ operation.permission.id,
374
+ ]),
375
+ ),
376
+ ).toEqual({
377
+ listComments: "comments:thread.read",
378
+ getCommentCount: "comments:thread.read",
379
+ createComment: "comments:thread.createComment",
380
+ updateComment: "comments:comment.edit",
381
+ toggleLike: "comments:comment.react",
382
+ updateCommentStatus: "comments:comment.moderate",
383
+ deleteComment: "comments:comment.delete",
384
+ });
385
+
386
+ const backend = makeBackend({ auth: createAuth() });
387
+ expect(
388
+ Object.keys(
389
+ backend.forRequest(request("/comments")).operations.comments,
390
+ ).sort(),
391
+ ).toEqual(expected);
392
+ expect(Object.keys(backend.trusted.comments).sort()).toEqual(expected);
393
+ expect("comments" in backend.raw).toBe(false);
394
+ expect(
395
+ "getCommentById" in
396
+ backend.forRequest(request("/comments")).operations.comments,
397
+ ).toBe(false);
398
+ expect("getCommentById" in backend.trusted.comments).toBe(false);
399
+ expect(
400
+ "toggleCommentLike" in
401
+ backend.forRequest(request("/comments")).operations.comments,
402
+ ).toBe(false);
403
+ expect("toggleCommentLike" in backend.trusted.comments).toBe(false);
404
+ expect(
405
+ "prefetchForRoute" in
406
+ backend.forRequest(request("/comments")).operations.comments,
407
+ ).toBe(false);
408
+ expect("prefetchForRoute" in backend.trusted.comments).toBe(false);
409
+
410
+ const routeNames = Object.keys(
411
+ (backend.router as unknown as { endpoints: Record<string, unknown> })
412
+ .endpoints,
413
+ )
414
+ .filter((name) => name.startsWith("comments_"))
415
+ .sort();
416
+ expect(routeNames).toEqual([
417
+ "comments_createComment",
418
+ "comments_deleteComment",
419
+ "comments_getCommentCount",
420
+ "comments_listComments",
421
+ "comments_toggleLike",
422
+ "comments_updateComment",
423
+ "comments_updateCommentStatus",
424
+ ]);
425
+ });
426
+
427
+ it("validates the schema-backed vocabulary at runtime", () => {
428
+ expect(
429
+ commentsPermissions.thread.read({
430
+ scope: "public",
431
+ resourceId: "post-1",
432
+ resourceType: "post",
433
+ }),
434
+ ).toMatchObject({ id: "comments:thread.read" });
435
+ expect(() =>
436
+ commentsPermissions.comment.edit({
437
+ commentId: "comment-1",
438
+ authorId: "owner-1",
439
+ status: "published" as "approved",
440
+ }),
441
+ ).toThrow();
442
+ expect(
443
+ commentsPermissions.comment.moderate({
444
+ commentId: "comment-1",
445
+ resourceId: "post-1",
446
+ resourceType: "post",
447
+ currentStatus: "pending",
448
+ nextStatus: "approved",
449
+ }),
450
+ ).toMatchObject({ id: "comments:comment.moderate" });
451
+ expect(() =>
452
+ commentsPermissions.comment.moderate({
453
+ commentId: "comment-1",
454
+ resourceId: "post-1",
455
+ resourceType: "post",
456
+ currentStatus: "pending",
457
+ nextStatus: "published" as "approved",
458
+ }),
459
+ ).toThrow();
460
+ });
461
+ });
462
+
463
+ describe("Comments protected-operation matrix", () => {
464
+ it.each(operationScenarios)(
465
+ "enforces anonymous, authenticated denial, and allowed $name",
466
+ async (scenario) => {
467
+ const lifecycle = vi.fn();
468
+ const backend = makeBackend({
469
+ auth: createModeratorOnlyAuth(),
470
+ plugin: {
471
+ hooks: { [scenario.hook]: lifecycle } as CommentsBackendHooks,
472
+ },
473
+ });
474
+ const run = await scenario.prepare(backend);
475
+
476
+ await expect(
477
+ run(
478
+ backend.forRequest(request("/comments")).operations
479
+ .comments as CommentsOperationApi,
480
+ ),
481
+ ).rejects.toMatchObject({ statusCode: 401 });
482
+ await expect(
483
+ run(
484
+ backend.forRequest(request("/comments", { identity: viewer }))
485
+ .operations.comments as CommentsOperationApi,
486
+ ),
487
+ ).rejects.toMatchObject({ statusCode: 403 });
488
+ expect(lifecycle).not.toHaveBeenCalled();
489
+
490
+ await expect(
491
+ run(
492
+ backend.forRequest(request("/comments", { identity: moderator }))
493
+ .operations.comments as CommentsOperationApi,
494
+ ),
495
+ ).resolves.toBeDefined();
496
+ expect(lifecycle).toHaveBeenCalledTimes(1);
497
+ },
498
+ );
499
+
500
+ it.each(operationScenarios)(
501
+ "keeps identity, missing-rule, and rule failures before $name lifecycle",
502
+ async (scenario) => {
503
+ const authFailures = [
504
+ createModeratorOnlyAuth(() => {
505
+ throw new Error("session unavailable");
506
+ }),
507
+ createServerAuth({
508
+ authorization: missingRulesAuthorization,
509
+ getIdentity: () => owner,
510
+ }),
511
+ createServerAuth({
512
+ authorization: throwingRulesAuthorization,
513
+ getIdentity: () => owner,
514
+ }),
515
+ ] as const;
516
+
517
+ for (const auth of authFailures) {
518
+ const lifecycle = vi.fn();
519
+ const backend = makeBackend({
520
+ auth,
521
+ plugin: {
522
+ hooks: { [scenario.hook]: lifecycle } as CommentsBackendHooks,
523
+ },
524
+ });
525
+ const run = await scenario.prepare(backend);
526
+ await expect(
527
+ run(
528
+ backend.forRequest(request("/comments", { identity: owner }))
529
+ .operations.comments as CommentsOperationApi,
530
+ ),
531
+ ).rejects.toBeInstanceOf(Error);
532
+ expect(lifecycle).not.toHaveBeenCalled();
533
+ }
534
+ },
535
+ );
536
+
537
+ it.each(operationScenarios)(
538
+ "keeps validation and $name lifecycle on trusted execution",
539
+ async (scenario) => {
540
+ const lifecycle = vi.fn();
541
+ const backend = makeBackend({
542
+ plugin: {
543
+ hooks: { [scenario.hook]: lifecycle } as CommentsBackendHooks,
544
+ },
545
+ });
546
+ const run = await scenario.prepare(backend);
547
+
548
+ await expect(
549
+ scenario.invalid(backend.trusted.comments),
550
+ ).rejects.toThrow();
551
+ expect(lifecycle).not.toHaveBeenCalled();
552
+ await expect(run(backend.trusted.comments)).resolves.toBeDefined();
553
+ expect(lifecycle).toHaveBeenCalledTimes(1);
554
+ },
555
+ );
556
+
557
+ it("fails closed before lifecycle when record-backed fact derivation fails", async () => {
558
+ const hooks = {
559
+ onBeforeCreateComment: vi.fn(),
560
+ onBeforeUpdateComment: vi.fn(),
561
+ onBeforeToggleCommentReaction: vi.fn(),
562
+ onBeforeModerateComment: vi.fn(),
563
+ onBeforeDeleteComment: vi.fn(),
564
+ };
565
+ const backend = makeBackend({
566
+ auth: createModeratorOnlyAuth(),
567
+ plugin: { hooks },
568
+ });
569
+ const api = backend.forRequest(
570
+ request("/comments", { identity: moderator }),
571
+ ).operations.comments;
572
+ const failures = [
573
+ () =>
574
+ api.createComment({
575
+ resourceId: "post-1",
576
+ resourceType: "post",
577
+ parentId: "missing-comment",
578
+ body: "Missing parent",
579
+ }),
580
+ () =>
581
+ api.updateComment({
582
+ id: "missing-comment",
583
+ data: { body: "Missing comment" },
584
+ }),
585
+ () => api.toggleLike({ id: "missing-comment" }),
586
+ () =>
587
+ api.updateCommentStatus({
588
+ id: "missing-comment",
589
+ data: { status: "approved" },
590
+ }),
591
+ () => api.deleteComment({ id: "missing-comment" }),
592
+ ];
593
+
594
+ for (const failure of failures) {
595
+ await expect(failure()).rejects.toMatchObject({
596
+ code: "COMMENT_NOT_FOUND",
597
+ });
598
+ }
599
+ for (const hook of Object.values(hooks)) {
600
+ expect(hook).not.toHaveBeenCalled();
601
+ }
602
+ });
603
+
604
+ it("derives transition facts from current storage and the requested next status", async () => {
605
+ const transitionAuthorization = defineAuthorization({
606
+ identity: z.object({ id: z.string(), role: z.literal("moderator") }),
607
+ permissions: [commentsPermissions] as const,
608
+ rules: ({ comments }) => [
609
+ comments.comment.moderate.when(
610
+ ({ identity, facts }) =>
611
+ identity?.role === "moderator" && facts.nextStatus === "approved",
612
+ ),
613
+ ],
614
+ });
615
+ const backend = makeBackend({
616
+ auth: createServerAuth({
617
+ authorization: transitionAuthorization,
618
+ getIdentity: () => moderator,
619
+ }),
620
+ });
621
+ const approve = await seedComment(backend, { status: "pending" });
622
+ const spam = await seedComment(backend, { status: "pending" });
623
+ const api = backend.forRequest(
624
+ request("/comments", { identity: moderator }),
625
+ ).operations.comments;
626
+
627
+ await expect(
628
+ api.updateCommentStatus({
629
+ id: approve.id,
630
+ data: { status: "approved" },
631
+ }),
632
+ ).resolves.toMatchObject({ status: "approved" });
633
+ await expect(
634
+ api.updateCommentStatus({
635
+ id: spam.id,
636
+ data: { status: "spam" },
637
+ }),
638
+ ).rejects.toMatchObject({ statusCode: 403 });
639
+ });
640
+
641
+ it("atomically rejects a moderation update when authorized state changes", async () => {
642
+ const afterApprove = vi.fn();
643
+ const backend = makeBackend({
644
+ auth: createAuth(),
645
+ plugin: { hooks: { onAfterApproveComment: afterApprove } },
646
+ });
647
+ const pending = await seedComment(backend, { status: "pending" });
648
+ const updateMany = backend.adapter.updateMany.bind(backend.adapter);
649
+ let raced = false;
650
+ vi.spyOn(backend.adapter, "updateMany").mockImplementation(
651
+ async (input) => {
652
+ if (
653
+ !raced &&
654
+ input.model === "comment" &&
655
+ input.update.status === "approved"
656
+ ) {
657
+ raced = true;
658
+ await backend.adapter.update<Comment>({
659
+ model: "comment",
660
+ where: [{ field: "id", value: pending.id, operator: "eq" }],
661
+ update: { status: "spam", updatedAt: new Date() },
662
+ });
663
+ }
664
+ return updateMany(input);
665
+ },
666
+ );
667
+
668
+ await expect(
669
+ backend
670
+ .forRequest(request("/comments", { identity: moderator }))
671
+ .operations.comments.updateCommentStatus({
672
+ id: pending.id,
673
+ data: { status: "approved" },
674
+ }),
675
+ ).rejects.toMatchObject({
676
+ statusCode: 409,
677
+ code: "COMMENT_STATE_CHANGED",
678
+ });
679
+ expect(
680
+ await backend.adapter.findOne<Comment>({
681
+ model: "comment",
682
+ where: [{ field: "id", value: pending.id, operator: "eq" }],
683
+ }),
684
+ ).toMatchObject({ status: "spam" });
685
+ expect(afterApprove).not.toHaveBeenCalled();
686
+ });
687
+
688
+ it.each([
689
+ { label: "Postgres rowCount", result: { rowCount: 0 } },
690
+ { label: "MySQL affectedRows", result: { affectedRows: 0 } },
691
+ { label: "MySQL result tuple", result: [{ affectedRows: 0 }, 1] },
692
+ { label: "Postgres.js count", result: { count: 0 } },
693
+ { label: "Cloudflare D1 metadata", result: { meta: { changes: 0 } } },
694
+ {
695
+ label: "nested count metadata",
696
+ result: { affectedRows: { id: "meta" } },
697
+ },
698
+ { label: "array count metadata", result: { affectedRows: [0, 1] } },
699
+ { label: "unknown wrong-id object", result: { id: "unrelated" } },
700
+ ])("fails closed for a zero-row $label result", async ({ result }) => {
701
+ const afterApprove = vi.fn();
702
+ const backend = makeBackend({
703
+ auth: createAuth(),
704
+ plugin: { hooks: { onAfterApproveComment: afterApprove } },
705
+ });
706
+ const pending = await seedComment(backend, { status: "pending" });
707
+ vi.spyOn(backend.adapter, "updateMany").mockResolvedValue(result as never);
708
+
709
+ await expect(
710
+ backend
711
+ .forRequest(request("/comments", { identity: moderator }))
712
+ .operations.comments.updateCommentStatus({
713
+ id: pending.id,
714
+ data: { status: "approved" },
715
+ }),
716
+ ).rejects.toMatchObject({
717
+ statusCode: 409,
718
+ code: "COMMENT_STATE_CHANGED",
719
+ });
720
+ expect(
721
+ await backend.adapter.findOne<Comment>({
722
+ model: "comment",
723
+ where: [{ field: "id", value: pending.id, operator: "eq" }],
724
+ }),
725
+ ).toMatchObject({ status: "pending" });
726
+ expect(afterApprove).not.toHaveBeenCalled();
727
+ });
728
+
729
+ it.each([
730
+ { label: "Postgres.js count", result: { count: 1 } },
731
+ {
732
+ label: "Postgres.js array count",
733
+ result: Object.assign([], { count: 1 }),
734
+ },
735
+ { label: "Cloudflare D1 metadata", result: { meta: { changes: 1 } } },
736
+ ])("accepts a successful $label result", async ({ result }) => {
737
+ const backend = makeBackend({ auth: createAuth() });
738
+ const pending = await seedComment(backend, { status: "pending" });
739
+ const updateMany = backend.adapter.updateMany.bind(backend.adapter);
740
+ vi.spyOn(backend.adapter, "updateMany").mockImplementation(
741
+ async (input) => {
742
+ await updateMany(input);
743
+ return result as never;
744
+ },
745
+ );
746
+
747
+ await expect(
748
+ backend
749
+ .forRequest(request("/comments", { identity: moderator }))
750
+ .operations.comments.updateCommentStatus({
751
+ id: pending.id,
752
+ data: { status: "approved" },
753
+ }),
754
+ ).resolves.toMatchObject({ status: "approved" });
755
+ });
756
+
757
+ it("returns the atomic moderation snapshot when the row changes after the write", async () => {
758
+ const afterApprove = vi.fn();
759
+ const backend = makeBackend({
760
+ auth: createAuth(),
761
+ plugin: { hooks: { onAfterApproveComment: afterApprove } },
762
+ });
763
+ const pending = await seedComment(backend, { status: "pending" });
764
+ const updateMany = backend.adapter.updateMany.bind(backend.adapter);
765
+ const update = backend.adapter.update.bind(backend.adapter);
766
+ let raced = false;
767
+ vi.spyOn(backend.adapter, "updateMany").mockImplementation(
768
+ async (input) => {
769
+ const result = await updateMany(input);
770
+ if (
771
+ !raced &&
772
+ input.model === "comment" &&
773
+ input.update.status === "approved"
774
+ ) {
775
+ raced = true;
776
+ await update({
777
+ model: "comment",
778
+ where: [{ field: "id", value: pending.id, operator: "eq" }],
779
+ update: { status: "spam", updatedAt: new Date() },
780
+ });
781
+ }
782
+ return result;
783
+ },
784
+ );
785
+
786
+ const result = await backend
787
+ .forRequest(request("/comments", { identity: moderator }))
788
+ .operations.comments.updateCommentStatus({
789
+ id: pending.id,
790
+ data: { status: "approved" },
791
+ });
792
+
793
+ expect(result).toMatchObject({ status: "approved" });
794
+ expect(afterApprove).toHaveBeenCalledWith(
795
+ expect.objectContaining({ status: "approved" }),
796
+ expect.objectContaining({
797
+ result: expect.objectContaining({ status: "approved" }),
798
+ }),
799
+ );
800
+ expect(
801
+ await backend.adapter.findOne<Comment>({
802
+ model: "comment",
803
+ where: [{ field: "id", value: pending.id, operator: "eq" }],
804
+ }),
805
+ ).toMatchObject({ status: "spam" });
806
+ });
807
+
808
+ it("atomically rejects an edit when authorized ownership changes", async () => {
809
+ const afterEdit = vi.fn();
810
+ const backend = makeBackend({
811
+ auth: createAuth(),
812
+ plugin: { hooks: { onAfterUpdateComment: afterEdit } },
813
+ });
814
+ const comment = await seedComment(backend);
815
+ const updateMany = backend.adapter.updateMany.bind(backend.adapter);
816
+ let raced = false;
817
+ vi.spyOn(backend.adapter, "updateMany").mockImplementation(
818
+ async (input) => {
819
+ if (
820
+ !raced &&
821
+ input.model === "comment" &&
822
+ input.update.body === "Raced edit"
823
+ ) {
824
+ raced = true;
825
+ await backend.adapter.update<Comment>({
826
+ model: "comment",
827
+ where: [{ field: "id", value: comment.id, operator: "eq" }],
828
+ update: { authorId: viewer.id },
829
+ });
830
+ }
831
+ return updateMany(input);
832
+ },
833
+ );
834
+
835
+ await expect(
836
+ backend
837
+ .forRequest(request("/comments", { identity: owner }))
838
+ .operations.comments.updateComment({
839
+ id: comment.id,
840
+ data: { body: "Raced edit" },
841
+ }),
842
+ ).rejects.toMatchObject({
843
+ statusCode: 409,
844
+ code: "COMMENT_STATE_CHANGED",
845
+ });
846
+ expect(
847
+ await backend.adapter.findOne<Comment>({
848
+ model: "comment",
849
+ where: [{ field: "id", value: comment.id, operator: "eq" }],
850
+ }),
851
+ ).toMatchObject({ authorId: viewer.id, body: "Authorization tracer" });
852
+ expect(afterEdit).not.toHaveBeenCalled();
853
+ });
854
+
855
+ it("returns the atomic edit snapshot when the row changes after the write", async () => {
856
+ const afterEdit = vi.fn();
857
+ const backend = makeBackend({
858
+ auth: createAuth(),
859
+ plugin: { hooks: { onAfterUpdateComment: afterEdit } },
860
+ });
861
+ const comment = await seedComment(backend);
862
+ const updateMany = backend.adapter.updateMany.bind(backend.adapter);
863
+ const update = backend.adapter.update.bind(backend.adapter);
864
+ let raced = false;
865
+ vi.spyOn(backend.adapter, "updateMany").mockImplementation(
866
+ async (input) => {
867
+ const result = await updateMany(input);
868
+ if (
869
+ !raced &&
870
+ input.model === "comment" &&
871
+ input.update.body === "First edit"
872
+ ) {
873
+ raced = true;
874
+ await update({
875
+ model: "comment",
876
+ where: [{ field: "id", value: comment.id, operator: "eq" }],
877
+ update: { body: "Second edit", updatedAt: new Date() },
878
+ });
879
+ }
880
+ return result;
881
+ },
882
+ );
883
+
884
+ const result = await backend
885
+ .forRequest(request("/comments", { identity: owner }))
886
+ .operations.comments.updateComment({
887
+ id: comment.id,
888
+ data: { body: "First edit" },
889
+ });
890
+
891
+ expect(result).toMatchObject({ body: "First edit" });
892
+ expect(afterEdit).toHaveBeenCalledWith(
893
+ expect.objectContaining({ body: "First edit" }),
894
+ expect.objectContaining({
895
+ result: expect.objectContaining({ body: "First edit" }),
896
+ }),
897
+ );
898
+ expect(
899
+ await backend.adapter.findOne<Comment>({
900
+ model: "comment",
901
+ where: [{ field: "id", value: comment.id, operator: "eq" }],
902
+ }),
903
+ ).toMatchObject({ body: "Second edit" });
904
+ });
905
+
906
+ it.each([
907
+ { initiallyLiked: false, label: "like" },
908
+ { initiallyLiked: true, label: "unlike" },
909
+ ])(
910
+ "rolls back a $label when authorized visibility changes before commit",
911
+ async ({ initiallyLiked }) => {
912
+ const backend = makeBackend({ auth: createAuth() });
913
+ const comment = await seedComment(backend);
914
+ if (initiallyLiked) {
915
+ await backend.adapter.create<CommentLike>({
916
+ model: "commentLike",
917
+ data: {
918
+ commentId: comment.id,
919
+ authorId: viewer.id,
920
+ createdAt: new Date(),
921
+ },
922
+ });
923
+ await backend.adapter.update<Comment>({
924
+ model: "comment",
925
+ where: [{ field: "id", value: comment.id, operator: "eq" }],
926
+ update: { likes: 1 },
927
+ });
928
+ }
929
+ const transaction = backend.adapter.transaction.bind(backend.adapter);
930
+ let raced = false;
931
+ vi.spyOn(backend.adapter, "transaction").mockImplementation(
932
+ async (callback) => {
933
+ return transaction(async (tx) => {
934
+ const updateMany = tx.updateMany.bind(tx);
935
+ vi.spyOn(tx, "updateMany").mockImplementation(async (input) => {
936
+ if (
937
+ !raced &&
938
+ input.model === "comment" &&
939
+ "likes" in input.update
940
+ ) {
941
+ raced = true;
942
+ await tx.update<Comment>({
943
+ model: "comment",
944
+ where: [{ field: "id", value: comment.id, operator: "eq" }],
945
+ update: { status: "spam" },
946
+ });
947
+ }
948
+ return updateMany(input);
949
+ });
950
+ return callback(tx);
951
+ });
952
+ },
953
+ );
954
+
955
+ await expect(
956
+ backend
957
+ .forRequest(request("/comments", { identity: viewer }))
958
+ .operations.comments.toggleLike({ id: comment.id }),
959
+ ).rejects.toMatchObject({
960
+ statusCode: 409,
961
+ code: "COMMENT_STATE_CHANGED",
962
+ });
963
+ expect(
964
+ await backend.adapter.findOne<Comment>({
965
+ model: "comment",
966
+ where: [{ field: "id", value: comment.id, operator: "eq" }],
967
+ }),
968
+ ).toMatchObject({
969
+ likes: initiallyLiked ? 1 : 0,
970
+ status: "approved",
971
+ });
972
+ const storedLike = await backend.adapter.findOne<CommentLike>({
973
+ model: "commentLike",
974
+ where: [
975
+ { field: "commentId", value: comment.id, operator: "eq" },
976
+ { field: "authorId", value: viewer.id, operator: "eq" },
977
+ ],
978
+ });
979
+ expect(storedLike !== null).toBe(initiallyLiked);
980
+ },
981
+ );
982
+
983
+ it("atomically rejects deletion when authorized ownership changes", async () => {
984
+ const afterDelete = vi.fn();
985
+ const backend = makeBackend({
986
+ auth: createAuth(),
987
+ plugin: { hooks: { onAfterDeleteComment: afterDelete } },
988
+ });
989
+ const comment = await seedComment(backend);
990
+ const transaction = backend.adapter.transaction.bind(backend.adapter);
991
+ let raced = false;
992
+ vi.spyOn(backend.adapter, "transaction").mockImplementation(
993
+ async (callback) => {
994
+ if (!raced) {
995
+ raced = true;
996
+ await backend.adapter.update<Comment>({
997
+ model: "comment",
998
+ where: [{ field: "id", value: comment.id, operator: "eq" }],
999
+ update: { authorId: viewer.id },
1000
+ });
1001
+ }
1002
+ return transaction(callback);
1003
+ },
1004
+ );
1005
+
1006
+ await expect(
1007
+ backend
1008
+ .forRequest(request("/comments", { identity: owner }))
1009
+ .operations.comments.deleteComment({ id: comment.id }),
1010
+ ).rejects.toMatchObject({
1011
+ statusCode: 409,
1012
+ code: "COMMENT_STATE_CHANGED",
1013
+ });
1014
+ expect(
1015
+ await backend.adapter.findOne<Comment>({
1016
+ model: "comment",
1017
+ where: [{ field: "id", value: comment.id, operator: "eq" }],
1018
+ }),
1019
+ ).toMatchObject({ authorId: viewer.id });
1020
+ expect(afterDelete).not.toHaveBeenCalled();
1021
+ });
1022
+ });
1023
+
1024
+ describe("Comments operation-first authorization", () => {
1025
+ it("enforces anonymous, owner, non-owner and moderator behavior across the catalog", async () => {
1026
+ const backend = makeBackend({
1027
+ auth: createAuth(),
1028
+ plugin: {
1029
+ autoApprove: true,
1030
+ hooks: { onBeforeCreateComment: vi.fn() },
1031
+ },
1032
+ });
1033
+ const comment = await seedComment(backend);
1034
+
1035
+ const anonymousCreate = await backend.handler(
1036
+ request("/comments", {
1037
+ method: "POST",
1038
+ body: {
1039
+ resourceId: "post-1",
1040
+ resourceType: "post",
1041
+ body: "Anonymous",
1042
+ },
1043
+ }),
1044
+ );
1045
+ expect(anonymousCreate.status).toBe(401);
1046
+ expect(
1047
+ await backend
1048
+ .forRequest(request("/comments", { identity: viewer }))
1049
+ .operations.comments.createComment({
1050
+ resourceId: "post-1",
1051
+ resourceType: "post",
1052
+ body: "Authenticated",
1053
+ }),
1054
+ ).toMatchObject({ authorId: viewer.id });
1055
+
1056
+ await expect(
1057
+ backend
1058
+ .forRequest(request("/comments", { identity: viewer }))
1059
+ .operations.comments.updateComment({
1060
+ id: comment.id,
1061
+ data: { body: "No" },
1062
+ }),
1063
+ ).rejects.toMatchObject({ statusCode: 403 });
1064
+ expect(
1065
+ await backend
1066
+ .forRequest(request("/comments", { identity: owner }))
1067
+ .operations.comments.updateComment({
1068
+ id: comment.id,
1069
+ data: { body: "Owner edit" },
1070
+ }),
1071
+ ).toMatchObject({ body: "Owner edit" });
1072
+ expect(
1073
+ await backend
1074
+ .forRequest(request("/comments", { identity: moderator }))
1075
+ .operations.comments.updateComment({
1076
+ id: comment.id,
1077
+ data: { body: "Moderator edit" },
1078
+ }),
1079
+ ).toMatchObject({ body: "Moderator edit" });
1080
+
1081
+ const anonymousLike = await backend.handler(
1082
+ request(`/comments/${comment.id}/like`, { method: "POST", body: {} }),
1083
+ );
1084
+ expect(anonymousLike.status).toBe(401);
1085
+ expect(
1086
+ await backend
1087
+ .forRequest(request("/comments", { identity: viewer }))
1088
+ .operations.comments.toggleLike({ id: comment.id }),
1089
+ ).toEqual({ likes: 1, isLiked: true });
1090
+
1091
+ const pending = await seedComment(backend, { status: "pending" });
1092
+ await expect(
1093
+ backend
1094
+ .forRequest(request("/comments", { identity: viewer }))
1095
+ .operations.comments.toggleLike({ id: pending.id }),
1096
+ ).rejects.toMatchObject({ statusCode: 403 });
1097
+ await expect(
1098
+ backend
1099
+ .forRequest(request("/comments", { identity: owner }))
1100
+ .operations.comments.updateCommentStatus({
1101
+ id: pending.id,
1102
+ data: { status: "approved" },
1103
+ }),
1104
+ ).rejects.toMatchObject({ statusCode: 403 });
1105
+ expect(
1106
+ await backend
1107
+ .forRequest(request("/comments", { identity: moderator }))
1108
+ .operations.comments.updateCommentStatus({
1109
+ id: pending.id,
1110
+ data: { status: "approved" },
1111
+ }),
1112
+ ).toMatchObject({ status: "approved" });
1113
+
1114
+ const viewerOwned = await seedComment(backend, { authorId: viewer.id });
1115
+ await expect(
1116
+ backend
1117
+ .forRequest(request("/comments", { identity: owner }))
1118
+ .operations.comments.deleteComment({ id: viewerOwned.id }),
1119
+ ).rejects.toMatchObject({ statusCode: 403 });
1120
+ expect(
1121
+ await backend
1122
+ .forRequest(request("/comments", { identity: moderator }))
1123
+ .operations.comments.deleteComment({ id: viewerOwned.id }),
1124
+ ).toEqual({ success: true });
1125
+ });
1126
+
1127
+ it("protects non-public counts with the same explicit read scopes", async () => {
1128
+ const backend = makeBackend({ auth: createAuth() });
1129
+ await seedComment(backend);
1130
+ await seedComment(backend, { status: "pending" });
1131
+
1132
+ const approved = await backend.handler(
1133
+ request("/comments/count?resourceId=post-1&resourceType=post"),
1134
+ );
1135
+ expect(approved.status).toBe(200);
1136
+ expect(await approved.json()).toEqual({ count: 1 });
1137
+
1138
+ const anonymousPending = await backend.handler(
1139
+ request(
1140
+ "/comments/count?resourceId=post-1&resourceType=post&status=pending",
1141
+ ),
1142
+ );
1143
+ const viewerPending = await backend.handler(
1144
+ request(
1145
+ "/comments/count?resourceId=post-1&resourceType=post&status=pending",
1146
+ {
1147
+ identity: viewer,
1148
+ },
1149
+ ),
1150
+ );
1151
+ expect(anonymousPending.status).toBe(401);
1152
+ expect(viewerPending.status).toBe(403);
1153
+ expect(
1154
+ await backend
1155
+ .forRequest(request("/comments", { identity: moderator }))
1156
+ .operations.comments.getCommentCount({
1157
+ resourceId: "post-1",
1158
+ resourceType: "post",
1159
+ status: "pending",
1160
+ }),
1161
+ ).toEqual({ count: 1 });
1162
+ });
1163
+
1164
+ it("makes approved threads explicitly public and scopes private rows on the server", async () => {
1165
+ const backend = makeBackend({ auth: createAuth() });
1166
+ await seedComment(backend);
1167
+ await seedComment(backend, {
1168
+ authorId: owner.id,
1169
+ status: "pending",
1170
+ body: "Owner pending",
1171
+ createdAt: new Date("2026-01-02T00:00:00.000Z"),
1172
+ });
1173
+ await seedComment(backend, {
1174
+ authorId: viewer.id,
1175
+ status: "pending",
1176
+ body: "Viewer pending",
1177
+ createdAt: new Date("2026-01-03T00:00:00.000Z"),
1178
+ });
1179
+
1180
+ const publicResponse = await backend.handler(
1181
+ request("/comments?resourceId=post-1&resourceType=post"),
1182
+ );
1183
+ expect(publicResponse.status).toBe(200);
1184
+ expect(
1185
+ (await publicResponse.json()).items.map((item: Comment) => item.status),
1186
+ ).toEqual(["approved"]);
1187
+
1188
+ const ownerResult = await backend
1189
+ .forRequest(request("/comments", { identity: owner }))
1190
+ .operations.comments.listComments({
1191
+ resourceId: "post-1",
1192
+ resourceType: "post",
1193
+ });
1194
+ expect(ownerResult.items.map((item) => item.body)).toEqual([
1195
+ "Authorization tracer",
1196
+ "Owner pending",
1197
+ ]);
1198
+ expect(
1199
+ ownerResult.items.some((item) => item.body === "Viewer pending"),
1200
+ ).toBe(false);
1201
+
1202
+ const anonymousModeration = await backend.handler(
1203
+ request("/comments?status=pending"),
1204
+ );
1205
+ const viewerModeration = await backend.handler(
1206
+ request("/comments?status=pending", { identity: viewer }),
1207
+ );
1208
+ expect(anonymousModeration.status).toBe(401);
1209
+ expect(viewerModeration.status).toBe(403);
1210
+ const moderation = await backend
1211
+ .forRequest(request("/comments", { identity: moderator }))
1212
+ .operations.comments.listComments({ status: "pending" });
1213
+ expect(moderation.items).toHaveLength(2);
1214
+
1215
+ await expect(
1216
+ backend
1217
+ .forRequest(request("/comments", { identity: viewer }))
1218
+ .operations.comments.listComments({ authorId: owner.id }),
1219
+ ).rejects.toMatchObject({ statusCode: 403 });
1220
+ expect(
1221
+ await backend
1222
+ .forRequest(request("/comments", { identity: owner }))
1223
+ .operations.comments.listComments({ authorId: owner.id }),
1224
+ ).toMatchObject({ total: 2 });
1225
+ });
1226
+
1227
+ it("uses request identity for authorship and reactions instead of spoofable input", async () => {
1228
+ const backend = makeBackend({
1229
+ auth: createAuth(),
1230
+ plugin: { autoApprove: true },
1231
+ });
1232
+ const api = backend.forRequest(request("/comments", { identity: viewer }))
1233
+ .operations.comments;
1234
+ const created = await api.createComment({
1235
+ resourceId: "post-1",
1236
+ resourceType: "post",
1237
+ body: "Viewer comment",
1238
+ authorId: owner.id,
1239
+ });
1240
+ expect(created.authorId).toBe(viewer.id);
1241
+
1242
+ await api.toggleLike({ id: created.id, authorId: owner.id });
1243
+ const like = await backend.adapter.findOne<CommentLike>({
1244
+ model: "commentLike",
1245
+ where: [{ field: "commentId", value: created.id }],
1246
+ });
1247
+ expect(like?.authorId).toBe(viewer.id);
1248
+
1249
+ const httpCreated = await backend.handler(
1250
+ request("/comments", {
1251
+ method: "POST",
1252
+ identity: owner,
1253
+ body: {
1254
+ resourceId: "post-1",
1255
+ resourceType: "post",
1256
+ body: "HTTP owner",
1257
+ authorId: viewer.id,
1258
+ },
1259
+ }),
1260
+ );
1261
+ expect(httpCreated.status).toBe(200);
1262
+ expect((await httpCreated.json()).authorId).toBe(owner.id);
1263
+ });
1264
+
1265
+ it("reloads ownership and status facts before every protected mutation", async () => {
1266
+ let backend: ReturnType<typeof makeBackend>;
1267
+ backend = makeBackend({
1268
+ auth: createAuth(),
1269
+ plugin: {
1270
+ hooks: {
1271
+ onBeforeUpdateComment: async (id) => {
1272
+ await backend.adapter.update<Comment>({
1273
+ model: "comment",
1274
+ where: [{ field: "id", value: id }],
1275
+ update: { authorId: viewer.id },
1276
+ });
1277
+ },
1278
+ },
1279
+ },
1280
+ });
1281
+ const comment = await seedComment(backend);
1282
+
1283
+ const spoofedBrowserDescriptor = commentsPermissions.comment.edit({
1284
+ commentId: comment.id,
1285
+ authorId: owner.id,
1286
+ status: "approved",
1287
+ });
1288
+ expect(authorization.can(spoofedBrowserDescriptor, owner)).toBe(true);
1289
+ await expect(
1290
+ backend
1291
+ .forRequest(request("/comments", { identity: owner }))
1292
+ .operations.comments.updateComment({
1293
+ id: comment.id,
1294
+ data: { body: "Stale edit" },
1295
+ }),
1296
+ ).rejects.toMatchObject({ statusCode: 409, code: "COMMENT_STATE_CHANGED" });
1297
+ expect(
1298
+ await backend.adapter.findOne<Comment>({
1299
+ model: "comment",
1300
+ where: [{ field: "id", value: comment.id }],
1301
+ }),
1302
+ ).toMatchObject({ body: "Authorization tracer", authorId: viewer.id });
1303
+ });
1304
+
1305
+ it("keeps authorization failures outside the lifecycle and exposes typed immutable context after auth", async () => {
1306
+ const events: string[] = [];
1307
+ const backend = makeBackend({
1308
+ auth: createAuth(),
1309
+ plugin: {
1310
+ hooks: {
1311
+ onBeforeUpdateComment: (_id, _data, context) => {
1312
+ events.push(
1313
+ `before:${context.identity?.id}:${context.facts.authorId}`,
1314
+ );
1315
+ expect(Object.isFrozen(context)).toBe(true);
1316
+ expect(Object.isFrozen(context.input)).toBe(true);
1317
+ },
1318
+ onAfterUpdateComment: (result, context) => {
1319
+ events.push(`after:${result.body}`);
1320
+ expect(context.result).toBe(result);
1321
+ },
1322
+ },
1323
+ },
1324
+ });
1325
+ const comment = await seedComment(backend);
1326
+
1327
+ await expect(
1328
+ backend
1329
+ .forRequest(request("/comments", { identity: viewer }))
1330
+ .operations.comments.updateComment({
1331
+ id: comment.id,
1332
+ data: { body: "Denied" },
1333
+ }),
1334
+ ).rejects.toMatchObject({ statusCode: 403 });
1335
+ expect(events).toEqual([]);
1336
+
1337
+ await backend
1338
+ .forRequest(request("/comments", { identity: owner }))
1339
+ .operations.comments.updateComment({
1340
+ id: comment.id,
1341
+ data: { body: "Allowed" },
1342
+ });
1343
+ expect(events).toEqual(["before:owner-1:owner-1", "after:Allowed"]);
1344
+ });
1345
+
1346
+ it("keeps identity, rule, and missing-rule failures before lifecycle hooks", async () => {
1347
+ const missingRules = defineAuthorization({
1348
+ identity: z.object({ id: z.string(), role: z.literal("user") }),
1349
+ permissions: [commentsPermissions] as const,
1350
+ rules: () => [],
1351
+ });
1352
+ const cases = [
1353
+ createAuth(() => {
1354
+ throw new Error("session unavailable");
1355
+ }),
1356
+ createServerAuth({
1357
+ authorization: missingRules,
1358
+ getIdentity: () => ({ id: owner.id, role: "user" as const }),
1359
+ }),
1360
+ ] as const;
1361
+
1362
+ for (const auth of cases) {
1363
+ const lifecycle = vi.fn();
1364
+ const backend = makeBackend({
1365
+ auth,
1366
+ plugin: { hooks: { onBeforeDeleteComment: lifecycle } },
1367
+ });
1368
+ const comment = await seedComment(backend);
1369
+ await expect(
1370
+ backend
1371
+ .forRequest(request("/comments", { identity: owner }))
1372
+ .operations.comments.deleteComment({ id: comment.id }),
1373
+ ).rejects.toSatisfy(
1374
+ (error: unknown) =>
1375
+ error instanceof Error &&
1376
+ (error.message === "session unavailable" ||
1377
+ (error as Error & { statusCode?: number }).statusCode === 403),
1378
+ );
1379
+ expect(lifecycle).not.toHaveBeenCalled();
1380
+ }
1381
+ });
1382
+
1383
+ it("keeps HTTP, request and trusted transports on the same validated lifecycle", async () => {
1384
+ const events: string[] = [];
1385
+ const getIdentity = vi.fn((operationRequest: Request) => {
1386
+ const id = operationRequest.headers.get("x-user-id");
1387
+ const role = operationRequest.headers.get("x-user-role");
1388
+ return id && (role === "user" || role === "moderator")
1389
+ ? ({ id, role } as Identity)
1390
+ : null;
1391
+ });
1392
+ const backend = makeBackend({
1393
+ auth: createAuth(getIdentity),
1394
+ plugin: {
1395
+ hooks: {
1396
+ onBeforeCreateComment: (_input, context) => {
1397
+ events.push(`before:${context.identity?.id ?? "trusted"}`);
1398
+ },
1399
+ onAfterCreateComment: (comment, context) => {
1400
+ events.push(`after:${comment.authorId}`);
1401
+ expect(context.result).toBe(comment);
1402
+ },
1403
+ },
1404
+ },
1405
+ });
1406
+ const input = {
1407
+ resourceId: "post-1",
1408
+ resourceType: "post",
1409
+ body: "Parity",
1410
+ };
1411
+
1412
+ const http = await backend.handler(
1413
+ request("/comments", { method: "POST", identity: owner, body: input }),
1414
+ );
1415
+ expect(http.status).toBe(200);
1416
+ const requestCreated = await backend
1417
+ .forRequest(request("/comments", { identity: viewer }))
1418
+ .operations.comments.createComment(input);
1419
+ getIdentity.mockClear();
1420
+ const trustedCreated = await backend.trusted.comments.createComment({
1421
+ ...input,
1422
+ authorId: "job-1",
1423
+ });
1424
+
1425
+ expect((await http.json()).authorId).toBe(owner.id);
1426
+ expect(requestCreated.authorId).toBe(viewer.id);
1427
+ expect(trustedCreated.authorId).toBe("job-1");
1428
+ expect(getIdentity).not.toHaveBeenCalled();
1429
+ expect(events).toEqual([
1430
+ "before:owner-1",
1431
+ "after:owner-1",
1432
+ "before:viewer-1",
1433
+ "after:viewer-1",
1434
+ "before:trusted",
1435
+ "after:job-1",
1436
+ ]);
1437
+
1438
+ await expect(
1439
+ backend.trusted.comments.createComment({
1440
+ ...input,
1441
+ body: "",
1442
+ authorId: "job-1",
1443
+ }),
1444
+ ).rejects.toThrow();
1445
+ });
1446
+
1447
+ it.each(["request", "trusted"] as const)(
1448
+ "invokes every canonical comments lifecycle through %s execution",
1449
+ async (transport) => {
1450
+ const events: string[] = [];
1451
+ const backend = makeBackend({
1452
+ auth: createAuth(),
1453
+ plugin: {
1454
+ hooks: {
1455
+ onBeforeListCommentsByAuthor: () => {
1456
+ events.push("list:author");
1457
+ },
1458
+ onBeforeListComments: () => {
1459
+ events.push("list");
1460
+ },
1461
+ onBeforeCountComments: () => {
1462
+ events.push("count");
1463
+ },
1464
+ onBeforeCreateComment: () => {
1465
+ events.push("create:before");
1466
+ },
1467
+ onAfterCreateComment: () => {
1468
+ events.push("create:after");
1469
+ },
1470
+ onBeforeUpdateComment: () => {
1471
+ events.push("update:before");
1472
+ },
1473
+ onAfterUpdateComment: () => {
1474
+ events.push("update:after");
1475
+ },
1476
+ onBeforeToggleCommentReaction: () => {
1477
+ events.push("reaction");
1478
+ },
1479
+ onBeforeModerateComment: () => {
1480
+ events.push("moderate:before");
1481
+ },
1482
+ onAfterApproveComment: () => {
1483
+ events.push("approve:after");
1484
+ },
1485
+ onBeforeDeleteComment: () => {
1486
+ events.push("delete:before");
1487
+ },
1488
+ onAfterDeleteComment: () => {
1489
+ events.push("delete:after");
1490
+ },
1491
+ },
1492
+ },
1493
+ });
1494
+ const updateTarget = await seedComment(backend, {
1495
+ body: "Update target",
1496
+ });
1497
+ const reactionTarget = await seedComment(backend, {
1498
+ body: "Reaction target",
1499
+ });
1500
+ const moderationTarget = await seedComment(backend, {
1501
+ body: "Moderation target",
1502
+ status: "pending",
1503
+ });
1504
+ const deleteTarget = await seedComment(backend, {
1505
+ body: "Delete target",
1506
+ });
1507
+ const api =
1508
+ transport === "request"
1509
+ ? backend.forRequest(request("/lifecycle", { identity: moderator }))
1510
+ .operations.comments
1511
+ : backend.trusted.comments;
1512
+
1513
+ await api.listComments({ authorId: owner.id });
1514
+ await api.getCommentCount({
1515
+ resourceId: "post-1",
1516
+ resourceType: "post",
1517
+ });
1518
+ await api.createComment({
1519
+ resourceId: "post-1",
1520
+ resourceType: "post",
1521
+ body: "Lifecycle create",
1522
+ ...(transport === "trusted" ? { authorId: "job-1" } : {}),
1523
+ });
1524
+ await api.updateComment({
1525
+ id: updateTarget.id,
1526
+ data: { body: "Lifecycle update" },
1527
+ });
1528
+ await api.toggleLike({
1529
+ id: reactionTarget.id,
1530
+ ...(transport === "trusted" ? { authorId: "job-1" } : {}),
1531
+ });
1532
+ await api.updateCommentStatus({
1533
+ id: moderationTarget.id,
1534
+ data: { status: "approved" },
1535
+ });
1536
+ await api.deleteComment({ id: deleteTarget.id });
1537
+
1538
+ expect(events).toEqual([
1539
+ "list:author",
1540
+ "list",
1541
+ "count",
1542
+ "create:before",
1543
+ "create:after",
1544
+ "update:before",
1545
+ "update:after",
1546
+ "reaction",
1547
+ "moderate:before",
1548
+ "approve:after",
1549
+ "delete:before",
1550
+ "delete:after",
1551
+ ]);
1552
+ },
1553
+ );
1554
+
1555
+ it("preserves permissive operation behavior only when no auth provider is configured", async () => {
1556
+ const unauthenticatedBackend = makeBackend({ auth: createAuth() });
1557
+ const noAuthBackend = makeBackend();
1558
+ const protectedComment = await seedComment(unauthenticatedBackend);
1559
+ const trustedComment = await seedComment(noAuthBackend);
1560
+
1561
+ const denied = await unauthenticatedBackend.handler(
1562
+ request(`/comments/${protectedComment.id}`, { method: "DELETE" }),
1563
+ );
1564
+ expect(denied.status).toBe(401);
1565
+ const allowed = await noAuthBackend.handler(
1566
+ request(`/comments/${trustedComment.id}`, { method: "DELETE" }),
1567
+ );
1568
+ expect(allowed.status).toBe(200);
1569
+ });
1570
+ });