@btst/stack 3.0.0-rc.2 → 3.0.0-rc.4

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 (1168) hide show
  1. package/README.md +118 -38
  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 +19 -7
  67. package/dist/next/index.d.mts +19 -7
  68. package/dist/next/index.d.ts +19 -7
  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/plugin-registration.cjs +59 -0
  91. package/dist/packages/stack/src/plugin-registration.mjs +57 -0
  92. package/dist/packages/stack/src/plugins/ai-chat/api/lifecycle-migrations.cjs +18 -0
  93. package/dist/packages/stack/src/plugins/ai-chat/api/lifecycle-migrations.mjs +16 -0
  94. package/dist/packages/stack/src/plugins/ai-chat/api/operations.cjs +1341 -0
  95. package/dist/packages/stack/src/plugins/ai-chat/api/operations.mjs +1333 -0
  96. package/dist/packages/stack/src/plugins/ai-chat/api/plugin.cjs +82 -640
  97. package/dist/packages/stack/src/plugins/ai-chat/api/plugin.mjs +78 -641
  98. package/dist/packages/stack/src/plugins/ai-chat/api/serializers.cjs +23 -0
  99. package/dist/packages/stack/src/plugins/ai-chat/api/serializers.mjs +20 -0
  100. package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-input.cjs +183 -111
  101. package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-input.mjs +187 -115
  102. package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-interface.cjs +562 -116
  103. package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-interface.mjs +567 -121
  104. package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-layout.cjs +6 -6
  105. package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-layout.mjs +6 -6
  106. package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-message.cjs +1 -1
  107. package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-message.mjs +1 -1
  108. package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-sidebar.cjs +45 -29
  109. package/dist/packages/stack/src/plugins/ai-chat/client/components/chat-sidebar.mjs +46 -30
  110. package/dist/packages/stack/src/plugins/ai-chat/client/components/pages/404-page.cjs +1 -1
  111. package/dist/packages/stack/src/plugins/ai-chat/client/components/pages/404-page.mjs +1 -1
  112. package/dist/packages/stack/src/plugins/ai-chat/client/components/pages/chat-page.cjs +46 -7
  113. package/dist/packages/stack/src/plugins/ai-chat/client/components/pages/chat-page.internal.cjs +5 -3
  114. package/dist/packages/stack/src/plugins/ai-chat/client/components/pages/chat-page.internal.mjs +5 -3
  115. package/dist/packages/stack/src/plugins/ai-chat/client/components/pages/chat-page.mjs +48 -9
  116. package/dist/packages/stack/src/plugins/ai-chat/client/components/shared/default-error.cjs +1 -1
  117. package/dist/packages/stack/src/plugins/ai-chat/client/components/shared/default-error.mjs +1 -1
  118. package/dist/packages/stack/src/plugins/ai-chat/client/components/tool-call-display.cjs +1 -1
  119. package/dist/packages/stack/src/plugins/ai-chat/client/components/tool-call-display.mjs +1 -1
  120. package/dist/packages/stack/src/plugins/ai-chat/client/hooks/ai-chat-resource.cjs +1 -1
  121. package/dist/packages/stack/src/plugins/ai-chat/client/hooks/ai-chat-resource.mjs +1 -1
  122. package/dist/packages/stack/src/plugins/ai-chat/client/hooks/chat-hooks.cjs +179 -19
  123. package/dist/packages/stack/src/plugins/ai-chat/client/hooks/chat-hooks.mjs +180 -21
  124. package/dist/packages/stack/src/plugins/ai-chat/client/navigation.cjs +11 -0
  125. package/dist/packages/stack/src/plugins/ai-chat/client/navigation.mjs +9 -0
  126. package/dist/packages/stack/src/plugins/ai-chat/client/overrides.cjs +24 -0
  127. package/dist/packages/stack/src/plugins/ai-chat/client/overrides.mjs +21 -1
  128. package/dist/packages/stack/src/plugins/ai-chat/client/plugin.cjs +152 -82
  129. package/dist/packages/stack/src/plugins/ai-chat/client/plugin.mjs +152 -82
  130. package/dist/packages/stack/src/plugins/api/create-endpoint.cjs +27 -9
  131. package/dist/packages/stack/src/plugins/api/create-endpoint.mjs +27 -10
  132. package/dist/packages/stack/src/plugins/api/endpoint-inventory.cjs +125 -0
  133. package/dist/packages/stack/src/plugins/api/endpoint-inventory.mjs +123 -0
  134. package/dist/packages/stack/src/plugins/api/operation.cjs +208 -0
  135. package/dist/packages/stack/src/plugins/api/operation.mjs +198 -0
  136. package/dist/packages/stack/src/plugins/blog/api/lifecycle-migrations.cjs +17 -0
  137. package/dist/packages/stack/src/plugins/blog/api/lifecycle-migrations.mjs +15 -0
  138. package/dist/packages/stack/src/plugins/blog/api/mutations.cjs +10 -2
  139. package/dist/packages/stack/src/plugins/blog/api/mutations.mjs +10 -2
  140. package/dist/packages/stack/src/plugins/blog/api/operations.cjs +455 -0
  141. package/dist/packages/stack/src/plugins/blog/api/operations.mjs +448 -0
  142. package/dist/packages/stack/src/plugins/blog/api/plugin.cjs +51 -298
  143. package/dist/packages/stack/src/plugins/blog/api/plugin.mjs +55 -304
  144. package/dist/packages/stack/src/plugins/blog/client/components/forms/image-field.cjs +2 -1
  145. package/dist/packages/stack/src/plugins/blog/client/components/forms/image-field.mjs +2 -1
  146. package/dist/packages/stack/src/plugins/blog/client/components/forms/markdown-editor-with-overrides.cjs +2 -1
  147. package/dist/packages/stack/src/plugins/blog/client/components/forms/markdown-editor-with-overrides.mjs +2 -1
  148. package/dist/packages/stack/src/plugins/blog/client/components/forms/post-forms.cjs +82 -67
  149. package/dist/packages/stack/src/plugins/blog/client/components/forms/post-forms.mjs +84 -69
  150. package/dist/packages/stack/src/plugins/blog/client/components/pages/404-page.cjs +2 -1
  151. package/dist/packages/stack/src/plugins/blog/client/components/pages/404-page.mjs +2 -1
  152. package/dist/packages/stack/src/plugins/blog/client/components/pages/edit-post-page.cjs +22 -4
  153. package/dist/packages/stack/src/plugins/blog/client/components/pages/edit-post-page.internal.cjs +2 -1
  154. package/dist/packages/stack/src/plugins/blog/client/components/pages/edit-post-page.internal.mjs +2 -1
  155. package/dist/packages/stack/src/plugins/blog/client/components/pages/edit-post-page.mjs +23 -5
  156. package/dist/packages/stack/src/plugins/blog/client/components/pages/home-page.cjs +6 -2
  157. package/dist/packages/stack/src/plugins/blog/client/components/pages/home-page.internal.cjs +2 -1
  158. package/dist/packages/stack/src/plugins/blog/client/components/pages/home-page.internal.mjs +2 -1
  159. package/dist/packages/stack/src/plugins/blog/client/components/pages/home-page.mjs +6 -2
  160. package/dist/packages/stack/src/plugins/blog/client/components/pages/new-post-page.cjs +4 -2
  161. package/dist/packages/stack/src/plugins/blog/client/components/pages/new-post-page.internal.cjs +2 -1
  162. package/dist/packages/stack/src/plugins/blog/client/components/pages/new-post-page.internal.mjs +2 -1
  163. package/dist/packages/stack/src/plugins/blog/client/components/pages/new-post-page.mjs +4 -2
  164. package/dist/packages/stack/src/plugins/blog/client/components/pages/post-page.cjs +30 -3
  165. package/dist/packages/stack/src/plugins/blog/client/components/pages/post-page.internal.cjs +2 -1
  166. package/dist/packages/stack/src/plugins/blog/client/components/pages/post-page.internal.mjs +2 -1
  167. package/dist/packages/stack/src/plugins/blog/client/components/pages/post-page.mjs +31 -4
  168. package/dist/packages/stack/src/plugins/blog/client/components/pages/tag-page.cjs +4 -1
  169. package/dist/packages/stack/src/plugins/blog/client/components/pages/tag-page.internal.cjs +2 -1
  170. package/dist/packages/stack/src/plugins/blog/client/components/pages/tag-page.internal.mjs +2 -1
  171. package/dist/packages/stack/src/plugins/blog/client/components/pages/tag-page.mjs +4 -1
  172. package/dist/packages/stack/src/plugins/blog/client/components/shared/collapsible-tag-list.cjs +2 -1
  173. package/dist/packages/stack/src/plugins/blog/client/components/shared/collapsible-tag-list.mjs +2 -1
  174. package/dist/packages/stack/src/plugins/blog/client/components/shared/default-error.cjs +2 -1
  175. package/dist/packages/stack/src/plugins/blog/client/components/shared/default-error.mjs +2 -1
  176. package/dist/packages/stack/src/plugins/blog/client/components/shared/on-this-page.cjs +3 -2
  177. package/dist/packages/stack/src/plugins/blog/client/components/shared/on-this-page.mjs +3 -2
  178. package/dist/packages/stack/src/plugins/blog/client/components/shared/page-wrapper.cjs +2 -1
  179. package/dist/packages/stack/src/plugins/blog/client/components/shared/page-wrapper.mjs +2 -1
  180. package/dist/packages/stack/src/plugins/blog/client/components/shared/post-card.cjs +2 -1
  181. package/dist/packages/stack/src/plugins/blog/client/components/shared/post-card.mjs +2 -1
  182. package/dist/packages/stack/src/plugins/blog/client/components/shared/posts-list.cjs +2 -1
  183. package/dist/packages/stack/src/plugins/blog/client/components/shared/posts-list.mjs +2 -1
  184. package/dist/packages/stack/src/plugins/blog/client/components/shared/recent-posts-carousel.cjs +2 -1
  185. package/dist/packages/stack/src/plugins/blog/client/components/shared/recent-posts-carousel.mjs +2 -1
  186. package/dist/packages/stack/src/plugins/blog/client/components/shared/search-input.cjs +2 -2
  187. package/dist/packages/stack/src/plugins/blog/client/components/shared/search-input.mjs +1 -1
  188. package/dist/packages/stack/src/plugins/blog/client/constants.cjs +5 -0
  189. package/dist/packages/stack/src/plugins/blog/client/constants.mjs +3 -0
  190. package/dist/packages/stack/src/plugins/blog/client/hooks/blog-resource.cjs +2 -1
  191. package/dist/packages/stack/src/plugins/blog/client/hooks/blog-resource.mjs +2 -1
  192. package/dist/packages/stack/src/plugins/blog/client/plugin.cjs +169 -163
  193. package/dist/packages/stack/src/plugins/blog/client/plugin.mjs +169 -163
  194. package/dist/packages/stack/src/plugins/client/resource/hooks.cjs +31 -16
  195. package/dist/packages/stack/src/plugins/client/resource/hooks.mjs +31 -16
  196. package/dist/packages/stack/src/plugins/client/resource/internal.cjs +66 -52
  197. package/dist/packages/stack/src/plugins/client/resource/internal.mjs +66 -52
  198. package/dist/packages/stack/src/plugins/client/resource/use-form.cjs +20 -17
  199. package/dist/packages/stack/src/plugins/client/resource/use-form.mjs +20 -17
  200. package/dist/packages/stack/src/plugins/client/resource/use-select.cjs +39 -33
  201. package/dist/packages/stack/src/plugins/client/resource/use-select.mjs +39 -33
  202. package/dist/packages/stack/src/plugins/cms/api/lifecycle-migrations.cjs +13 -0
  203. package/dist/packages/stack/src/plugins/cms/api/lifecycle-migrations.mjs +11 -0
  204. package/dist/packages/stack/src/plugins/cms/api/operations.cjs +1763 -0
  205. package/dist/packages/stack/src/plugins/cms/api/operations.mjs +1756 -0
  206. package/dist/packages/stack/src/plugins/cms/api/plugin.cjs +165 -752
  207. package/dist/packages/stack/src/plugins/cms/api/plugin.mjs +164 -755
  208. package/dist/packages/stack/src/plugins/cms/client/components/forms/content-form.cjs +2 -1
  209. package/dist/packages/stack/src/plugins/cms/client/components/forms/content-form.mjs +2 -1
  210. package/dist/packages/stack/src/plugins/cms/client/components/forms/file-upload.cjs +2 -1
  211. package/dist/packages/stack/src/plugins/cms/client/components/forms/file-upload.mjs +2 -1
  212. package/dist/packages/stack/src/plugins/cms/client/components/forms/relation-field.cjs +2 -1
  213. package/dist/packages/stack/src/plugins/cms/client/components/forms/relation-field.mjs +2 -1
  214. package/dist/packages/stack/src/plugins/cms/client/components/inverse-relations-panel.cjs +23 -13
  215. package/dist/packages/stack/src/plugins/cms/client/components/inverse-relations-panel.mjs +24 -14
  216. package/dist/packages/stack/src/plugins/cms/client/components/pages/404-page.cjs +5 -4
  217. package/dist/packages/stack/src/plugins/cms/client/components/pages/404-page.mjs +6 -5
  218. package/dist/packages/stack/src/plugins/cms/client/components/pages/content-editor-page.cjs +40 -7
  219. package/dist/packages/stack/src/plugins/cms/client/components/pages/content-editor-page.internal.cjs +15 -9
  220. package/dist/packages/stack/src/plugins/cms/client/components/pages/content-editor-page.internal.mjs +14 -8
  221. package/dist/packages/stack/src/plugins/cms/client/components/pages/content-editor-page.mjs +41 -8
  222. package/dist/packages/stack/src/plugins/cms/client/components/pages/content-list-page.cjs +7 -1
  223. package/dist/packages/stack/src/plugins/cms/client/components/pages/content-list-page.internal.cjs +42 -29
  224. package/dist/packages/stack/src/plugins/cms/client/components/pages/content-list-page.internal.mjs +40 -27
  225. package/dist/packages/stack/src/plugins/cms/client/components/pages/content-list-page.mjs +7 -1
  226. package/dist/packages/stack/src/plugins/cms/client/components/pages/dashboard-page.cjs +4 -1
  227. package/dist/packages/stack/src/plugins/cms/client/components/pages/dashboard-page.internal.cjs +13 -7
  228. package/dist/packages/stack/src/plugins/cms/client/components/pages/dashboard-page.internal.mjs +12 -6
  229. package/dist/packages/stack/src/plugins/cms/client/components/pages/dashboard-page.mjs +4 -1
  230. package/dist/packages/stack/src/plugins/cms/client/components/shared/page-wrapper.cjs +2 -1
  231. package/dist/packages/stack/src/plugins/cms/client/components/shared/page-wrapper.mjs +2 -1
  232. package/dist/packages/stack/src/plugins/cms/client/constants.cjs +5 -0
  233. package/dist/packages/stack/src/plugins/cms/client/constants.mjs +3 -0
  234. package/dist/packages/stack/src/plugins/cms/client/hooks/cms-resource.cjs +2 -1
  235. package/dist/packages/stack/src/plugins/cms/client/hooks/cms-resource.mjs +2 -1
  236. package/dist/packages/stack/src/plugins/cms/client/overrides.cjs +26 -0
  237. package/dist/packages/stack/src/plugins/cms/client/overrides.mjs +24 -0
  238. package/dist/packages/stack/src/plugins/cms/client/plugin.cjs +102 -81
  239. package/dist/packages/stack/src/plugins/cms/client/plugin.mjs +103 -82
  240. package/dist/packages/stack/src/plugins/comments/api/getters.cjs +6 -2
  241. package/dist/packages/stack/src/plugins/comments/api/getters.mjs +6 -3
  242. package/dist/packages/stack/src/plugins/comments/api/lifecycle-migrations.cjs +18 -0
  243. package/dist/packages/stack/src/plugins/comments/api/lifecycle-migrations.mjs +16 -0
  244. package/dist/packages/stack/src/plugins/comments/api/mutations.cjs +179 -68
  245. package/dist/packages/stack/src/plugins/comments/api/mutations.mjs +179 -68
  246. package/dist/packages/stack/src/plugins/comments/api/operations.cjs +453 -0
  247. package/dist/packages/stack/src/plugins/comments/api/operations.mjs +445 -0
  248. package/dist/packages/stack/src/plugins/comments/api/plugin.cjs +51 -276
  249. package/dist/packages/stack/src/plugins/comments/api/plugin.mjs +48 -277
  250. package/dist/packages/stack/src/plugins/comments/client/components/comment-count.cjs +32 -5
  251. package/dist/packages/stack/src/plugins/comments/client/components/comment-count.mjs +34 -7
  252. package/dist/packages/stack/src/plugins/comments/client/components/comment-thread.cjs +160 -104
  253. package/dist/packages/stack/src/plugins/comments/client/components/comment-thread.mjs +161 -105
  254. package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.cjs +14 -2
  255. package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.internal.cjs +141 -71
  256. package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.internal.mjs +142 -72
  257. package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.mjs +14 -2
  258. package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-state.cjs +12 -0
  259. package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-state.mjs +9 -0
  260. package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.cjs +2 -1
  261. package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.internal.cjs +40 -26
  262. package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.internal.mjs +40 -26
  263. package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.mjs +2 -1
  264. package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.cjs +9 -1
  265. package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.internal.cjs +25 -20
  266. package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.internal.mjs +26 -21
  267. package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.mjs +9 -1
  268. package/dist/packages/stack/src/plugins/comments/client/components/shared/page-wrapper.cjs +2 -1
  269. package/dist/packages/stack/src/plugins/comments/client/components/shared/page-wrapper.mjs +2 -1
  270. package/dist/packages/stack/src/plugins/comments/client/components/shared/pagination.cjs +2 -1
  271. package/dist/packages/stack/src/plugins/comments/client/components/shared/pagination.mjs +2 -1
  272. package/dist/packages/stack/src/plugins/comments/client/constants.cjs +5 -0
  273. package/dist/packages/stack/src/plugins/comments/client/constants.mjs +3 -0
  274. package/dist/packages/stack/src/plugins/comments/client/hooks/use-comments.cjs +323 -290
  275. package/dist/packages/stack/src/plugins/comments/client/hooks/use-comments.mjs +325 -292
  276. package/dist/packages/stack/src/plugins/comments/client/localization/comments-thread.cjs +1 -0
  277. package/dist/packages/stack/src/plugins/comments/client/localization/comments-thread.mjs +1 -0
  278. package/dist/packages/stack/src/plugins/comments/client/plugin.cjs +78 -46
  279. package/dist/packages/stack/src/plugins/comments/client/plugin.mjs +80 -48
  280. package/dist/packages/stack/src/plugins/form-builder/api/getters.cjs +9 -0
  281. package/dist/packages/stack/src/plugins/form-builder/api/getters.mjs +9 -1
  282. package/dist/packages/stack/src/plugins/form-builder/api/lifecycle-migrations.cjs +15 -0
  283. package/dist/packages/stack/src/plugins/form-builder/api/lifecycle-migrations.mjs +13 -0
  284. package/dist/packages/stack/src/plugins/form-builder/api/operations.cjs +1093 -0
  285. package/dist/packages/stack/src/plugins/form-builder/api/operations.mjs +1082 -0
  286. package/dist/packages/stack/src/plugins/form-builder/api/plugin.cjs +97 -466
  287. package/dist/packages/stack/src/plugins/form-builder/api/plugin.mjs +92 -468
  288. package/dist/packages/stack/src/plugins/form-builder/api/query-key-defs.cjs +5 -0
  289. package/dist/packages/stack/src/plugins/form-builder/api/query-key-defs.mjs +5 -0
  290. package/dist/packages/stack/src/plugins/form-builder/client/components/forms/form-renderer.cjs +41 -11
  291. package/dist/packages/stack/src/plugins/form-builder/client/components/forms/form-renderer.mjs +42 -12
  292. package/dist/packages/stack/src/plugins/form-builder/client/components/pages/404-page.cjs +8 -5
  293. package/dist/packages/stack/src/plugins/form-builder/client/components/pages/404-page.mjs +9 -6
  294. package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-builder-page.cjs +36 -3
  295. package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-builder-page.internal.cjs +32 -11
  296. package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-builder-page.internal.mjs +35 -14
  297. package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-builder-page.mjs +37 -4
  298. package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-list-page.cjs +6 -1
  299. package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-list-page.internal.cjs +34 -26
  300. package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-list-page.internal.mjs +34 -26
  301. package/dist/packages/stack/src/plugins/form-builder/client/components/pages/form-list-page.mjs +6 -1
  302. package/dist/packages/stack/src/plugins/form-builder/client/components/pages/submissions-page.cjs +24 -7
  303. package/dist/packages/stack/src/plugins/form-builder/client/components/pages/submissions-page.internal.cjs +72 -40
  304. package/dist/packages/stack/src/plugins/form-builder/client/components/pages/submissions-page.internal.mjs +76 -44
  305. package/dist/packages/stack/src/plugins/form-builder/client/components/pages/submissions-page.mjs +25 -8
  306. package/dist/packages/stack/src/plugins/form-builder/client/components/shared/page-wrapper.cjs +2 -1
  307. package/dist/packages/stack/src/plugins/form-builder/client/components/shared/page-wrapper.mjs +2 -1
  308. package/dist/packages/stack/src/plugins/form-builder/client/constants.cjs +5 -0
  309. package/dist/packages/stack/src/plugins/form-builder/client/constants.mjs +3 -0
  310. package/dist/packages/stack/src/plugins/form-builder/client/hooks/form-builder-hooks.cjs +29 -0
  311. package/dist/packages/stack/src/plugins/form-builder/client/hooks/form-builder-hooks.mjs +28 -1
  312. package/dist/packages/stack/src/plugins/form-builder/client/hooks/form-builder-resource.cjs +2 -1
  313. package/dist/packages/stack/src/plugins/form-builder/client/hooks/form-builder-resource.mjs +2 -1
  314. package/dist/packages/stack/src/plugins/form-builder/client/plugin.cjs +113 -86
  315. package/dist/packages/stack/src/plugins/form-builder/client/plugin.mjs +114 -87
  316. package/dist/packages/stack/src/plugins/form-builder/schemas.cjs +9 -3
  317. package/dist/packages/stack/src/plugins/form-builder/schemas.mjs +9 -3
  318. package/dist/packages/stack/src/plugins/kanban/api/getters.cjs +47 -36
  319. package/dist/packages/stack/src/plugins/kanban/api/getters.mjs +47 -37
  320. package/dist/packages/stack/src/plugins/kanban/api/lifecycle-migrations.cjs +23 -0
  321. package/dist/packages/stack/src/plugins/kanban/api/lifecycle-migrations.mjs +21 -0
  322. package/dist/packages/stack/src/plugins/kanban/api/operations.cjs +1552 -0
  323. package/dist/packages/stack/src/plugins/kanban/api/operations.mjs +1543 -0
  324. package/dist/packages/stack/src/plugins/kanban/api/plugin.cjs +64 -631
  325. package/dist/packages/stack/src/plugins/kanban/api/plugin.mjs +62 -634
  326. package/dist/packages/stack/src/plugins/kanban/api/serializers.cjs +21 -0
  327. package/dist/packages/stack/src/plugins/kanban/api/serializers.mjs +21 -1
  328. package/dist/packages/stack/src/plugins/kanban/client/components/forms/board-form.cjs +2 -1
  329. package/dist/packages/stack/src/plugins/kanban/client/components/forms/board-form.mjs +2 -1
  330. package/dist/packages/stack/src/plugins/kanban/client/components/forms/column-form.cjs +2 -1
  331. package/dist/packages/stack/src/plugins/kanban/client/components/forms/column-form.mjs +2 -1
  332. package/dist/packages/stack/src/plugins/kanban/client/components/forms/task-form.cjs +72 -54
  333. package/dist/packages/stack/src/plugins/kanban/client/components/forms/task-form.mjs +74 -56
  334. package/dist/packages/stack/src/plugins/kanban/client/components/pages/404-page.cjs +4 -6
  335. package/dist/packages/stack/src/plugins/kanban/client/components/pages/404-page.mjs +5 -7
  336. package/dist/packages/stack/src/plugins/kanban/client/components/pages/board-page.cjs +22 -6
  337. package/dist/packages/stack/src/plugins/kanban/client/components/pages/board-page.internal.cjs +82 -77
  338. package/dist/packages/stack/src/plugins/kanban/client/components/pages/board-page.internal.mjs +83 -78
  339. package/dist/packages/stack/src/plugins/kanban/client/components/pages/board-page.mjs +23 -7
  340. package/dist/packages/stack/src/plugins/kanban/client/components/pages/boards-list-page.cjs +2 -1
  341. package/dist/packages/stack/src/plugins/kanban/client/components/pages/boards-list-page.internal.cjs +34 -24
  342. package/dist/packages/stack/src/plugins/kanban/client/components/pages/boards-list-page.internal.mjs +35 -25
  343. package/dist/packages/stack/src/plugins/kanban/client/components/pages/boards-list-page.mjs +2 -1
  344. package/dist/packages/stack/src/plugins/kanban/client/components/pages/new-board-page.cjs +2 -1
  345. package/dist/packages/stack/src/plugins/kanban/client/components/pages/new-board-page.internal.cjs +6 -9
  346. package/dist/packages/stack/src/plugins/kanban/client/components/pages/new-board-page.internal.mjs +7 -10
  347. package/dist/packages/stack/src/plugins/kanban/client/components/pages/new-board-page.mjs +2 -1
  348. package/dist/packages/stack/src/plugins/kanban/client/components/shared/column-content.cjs +72 -45
  349. package/dist/packages/stack/src/plugins/kanban/client/components/shared/column-content.mjs +73 -46
  350. package/dist/packages/stack/src/plugins/kanban/client/components/shared/default-error.cjs +2 -1
  351. package/dist/packages/stack/src/plugins/kanban/client/components/shared/default-error.mjs +2 -1
  352. package/dist/packages/stack/src/plugins/kanban/client/components/shared/kanban-board.cjs +4 -4
  353. package/dist/packages/stack/src/plugins/kanban/client/components/shared/kanban-board.mjs +4 -4
  354. package/dist/packages/stack/src/plugins/kanban/client/components/shared/permission-access-any.cjs +23 -0
  355. package/dist/packages/stack/src/plugins/kanban/client/components/shared/permission-access-any.mjs +21 -0
  356. package/dist/packages/stack/src/plugins/kanban/client/components/shared/task-card.cjs +54 -17
  357. package/dist/packages/stack/src/plugins/kanban/client/components/shared/task-card.mjs +55 -18
  358. package/dist/packages/stack/src/plugins/kanban/client/components/shared/user-avatar.cjs +2 -1
  359. package/dist/packages/stack/src/plugins/kanban/client/components/shared/user-avatar.mjs +2 -1
  360. package/dist/packages/stack/src/plugins/kanban/client/constants.cjs +5 -0
  361. package/dist/packages/stack/src/plugins/kanban/client/constants.mjs +3 -0
  362. package/dist/packages/stack/src/plugins/kanban/client/hooks/kanban-hooks.cjs +38 -9
  363. package/dist/packages/stack/src/plugins/kanban/client/hooks/kanban-hooks.mjs +39 -10
  364. package/dist/packages/stack/src/plugins/kanban/client/hooks/kanban-resource.cjs +2 -1
  365. package/dist/packages/stack/src/plugins/kanban/client/hooks/kanban-resource.mjs +2 -1
  366. package/dist/packages/stack/src/plugins/kanban/client/plugin.cjs +177 -104
  367. package/dist/packages/stack/src/plugins/kanban/client/plugin.mjs +178 -105
  368. package/dist/packages/stack/src/plugins/kanban/schemas.cjs +32 -23
  369. package/dist/packages/stack/src/plugins/kanban/schemas.mjs +33 -21
  370. package/dist/packages/stack/src/plugins/media/api/lifecycle-migrations.cjs +9 -0
  371. package/dist/packages/stack/src/plugins/media/api/lifecycle-migrations.mjs +7 -0
  372. package/dist/packages/stack/src/plugins/media/api/mutations.cjs +7 -2
  373. package/dist/packages/stack/src/plugins/media/api/mutations.mjs +7 -2
  374. package/dist/packages/stack/src/plugins/media/api/operations.cjs +1299 -0
  375. package/dist/packages/stack/src/plugins/media/api/operations.mjs +1290 -0
  376. package/dist/packages/stack/src/plugins/media/api/plugin.cjs +131 -508
  377. package/dist/packages/stack/src/plugins/media/api/plugin.mjs +127 -510
  378. package/dist/packages/stack/src/plugins/media/api/query-key-defs.cjs +26 -2
  379. package/dist/packages/stack/src/plugins/media/api/query-key-defs.mjs +25 -3
  380. package/dist/packages/stack/src/plugins/media/api/serializers.cjs +4 -2
  381. package/dist/packages/stack/src/plugins/media/api/serializers.mjs +4 -2
  382. package/dist/packages/stack/src/plugins/media/asset-url.cjs +13 -0
  383. package/dist/packages/stack/src/plugins/media/asset-url.mjs +11 -0
  384. package/dist/packages/stack/src/plugins/media/client/components/media-picker/asset-card.cjs +10 -10
  385. package/dist/packages/stack/src/plugins/media/client/components/media-picker/asset-card.mjs +12 -12
  386. package/dist/packages/stack/src/plugins/media/client/components/media-picker/folder-tree.cjs +47 -27
  387. package/dist/packages/stack/src/plugins/media/client/components/media-picker/folder-tree.mjs +49 -29
  388. package/dist/packages/stack/src/plugins/media/client/components/media-picker/index.cjs +225 -180
  389. package/dist/packages/stack/src/plugins/media/client/components/media-picker/index.mjs +228 -183
  390. package/dist/packages/stack/src/plugins/media/client/components/media-picker/upload-tab.cjs +1 -8
  391. package/dist/packages/stack/src/plugins/media/client/components/media-picker/upload-tab.mjs +2 -9
  392. package/dist/packages/stack/src/plugins/media/client/components/media-picker/url-tab.cjs +0 -6
  393. package/dist/packages/stack/src/plugins/media/client/components/media-picker/url-tab.mjs +1 -7
  394. package/dist/packages/stack/src/plugins/media/client/components/pages/library-page.cjs +4 -2
  395. package/dist/packages/stack/src/plugins/media/client/components/pages/library-page.internal.cjs +92 -75
  396. package/dist/packages/stack/src/plugins/media/client/components/pages/library-page.internal.mjs +93 -76
  397. package/dist/packages/stack/src/plugins/media/client/components/pages/library-page.mjs +4 -2
  398. package/dist/packages/stack/src/plugins/media/client/components/upload-permission-check.cjs +52 -0
  399. package/dist/packages/stack/src/plugins/media/client/components/upload-permission-check.mjs +49 -0
  400. package/dist/packages/stack/src/plugins/media/client/constants.cjs +5 -0
  401. package/dist/packages/stack/src/plugins/media/client/constants.mjs +3 -0
  402. package/dist/packages/stack/src/plugins/media/client/hooks/media-resource.cjs +2 -1
  403. package/dist/packages/stack/src/plugins/media/client/hooks/media-resource.mjs +2 -1
  404. package/dist/packages/stack/src/plugins/media/client/hooks/use-media.cjs +214 -43
  405. package/dist/packages/stack/src/plugins/media/client/hooks/use-media.mjs +217 -46
  406. package/dist/packages/stack/src/plugins/media/client/plugin.cjs +122 -62
  407. package/dist/packages/stack/src/plugins/media/client/plugin.mjs +123 -63
  408. package/dist/packages/stack/src/plugins/media/client/upload.cjs +121 -52
  409. package/dist/packages/stack/src/plugins/media/client/upload.mjs +121 -53
  410. package/dist/packages/stack/src/plugins/media/db.cjs +8 -0
  411. package/dist/packages/stack/src/plugins/media/db.mjs +8 -0
  412. package/dist/packages/stack/src/plugins/open-api/api/generator.cjs +36 -5
  413. package/dist/packages/stack/src/plugins/open-api/api/generator.mjs +36 -5
  414. package/dist/packages/stack/src/plugins/open-api/api/plugin.cjs +22 -11
  415. package/dist/packages/stack/src/plugins/open-api/api/plugin.mjs +22 -11
  416. package/dist/packages/stack/src/plugins/route-docs/client/components/pages/docs-page.cjs +65 -34
  417. package/dist/packages/stack/src/plugins/route-docs/client/components/pages/docs-page.mjs +56 -25
  418. package/dist/packages/stack/src/plugins/route-docs/client/constants.cjs +5 -0
  419. package/dist/packages/stack/src/plugins/route-docs/client/constants.mjs +3 -0
  420. package/dist/packages/stack/src/plugins/route-docs/client/hooks.cjs +9 -8
  421. package/dist/packages/stack/src/plugins/route-docs/client/hooks.mjs +10 -9
  422. package/dist/packages/stack/src/plugins/route-docs/client/plugin.cjs +143 -75
  423. package/dist/packages/stack/src/plugins/route-docs/client/plugin.mjs +144 -74
  424. package/dist/packages/stack/src/plugins/route-docs/client/schema.cjs +26 -0
  425. package/dist/packages/stack/src/plugins/route-docs/client/schema.mjs +23 -0
  426. package/dist/packages/stack/src/plugins/route-docs/generator.cjs +7 -4
  427. package/dist/packages/stack/src/plugins/route-docs/generator.mjs +7 -4
  428. package/dist/packages/stack/src/plugins/ui-builder/client/components/page-renderer.cjs +41 -12
  429. package/dist/packages/stack/src/plugins/ui-builder/client/components/page-renderer.mjs +42 -13
  430. package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-builder-page.cjs +37 -3
  431. package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-builder-page.internal.cjs +32 -20
  432. package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-builder-page.internal.mjs +34 -22
  433. package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-builder-page.mjs +38 -4
  434. package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-list-page.cjs +8 -2
  435. package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-list-page.internal.cjs +37 -19
  436. package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-list-page.internal.mjs +38 -20
  437. package/dist/packages/stack/src/plugins/ui-builder/client/components/pages/page-list-page.mjs +8 -2
  438. package/dist/packages/stack/src/plugins/ui-builder/client/components/shared/default-error.cjs +2 -1
  439. package/dist/packages/stack/src/plugins/ui-builder/client/components/shared/default-error.mjs +2 -1
  440. package/dist/packages/stack/src/plugins/ui-builder/client/components/shared/page-wrapper.cjs +2 -1
  441. package/dist/packages/stack/src/plugins/ui-builder/client/components/shared/page-wrapper.mjs +2 -1
  442. package/dist/packages/stack/src/plugins/ui-builder/client/constants.cjs +5 -0
  443. package/dist/packages/stack/src/plugins/ui-builder/client/constants.mjs +3 -0
  444. package/dist/packages/stack/src/plugins/ui-builder/client/hooks/ui-builder-resource.cjs +2 -1
  445. package/dist/packages/stack/src/plugins/ui-builder/client/hooks/ui-builder-resource.mjs +2 -1
  446. package/dist/packages/stack/src/plugins/ui-builder/client/overrides.cjs +8 -0
  447. package/dist/packages/stack/src/plugins/ui-builder/client/overrides.mjs +6 -0
  448. package/dist/packages/stack/src/plugins/ui-builder/client/plugin.cjs +93 -53
  449. package/dist/packages/stack/src/plugins/ui-builder/client/plugin.mjs +94 -54
  450. package/dist/packages/stack/src/plugins/utils.cjs +4 -12
  451. package/dist/packages/stack/src/plugins/utils.mjs +5 -12
  452. package/dist/packages/stack/src/react-router/layout.cjs +14 -0
  453. package/dist/packages/stack/src/react-router/layout.mjs +12 -0
  454. package/dist/packages/stack/src/react-router/page.cjs +10 -5
  455. package/dist/packages/stack/src/react-router/page.mjs +11 -6
  456. package/dist/packages/stack/src/shared/initial-identity.cjs +27 -0
  457. package/dist/packages/stack/src/shared/initial-identity.mjs +23 -0
  458. package/dist/packages/stack/src/tanstack/layout.cjs +10 -0
  459. package/dist/packages/stack/src/tanstack/layout.mjs +8 -0
  460. package/dist/packages/stack/src/tanstack/page.cjs +6 -2
  461. package/dist/packages/stack/src/tanstack/page.mjs +6 -2
  462. package/dist/plugins/ai-chat/api/index.cjs +10 -0
  463. package/dist/plugins/ai-chat/api/index.d.cts +31 -5
  464. package/dist/plugins/ai-chat/api/index.d.mts +31 -5
  465. package/dist/plugins/ai-chat/api/index.d.ts +31 -5
  466. package/dist/plugins/ai-chat/api/index.mjs +3 -1
  467. package/dist/plugins/ai-chat/client/components/index.d.cts +1 -1
  468. package/dist/plugins/ai-chat/client/components/index.d.mts +1 -1
  469. package/dist/plugins/ai-chat/client/components/index.d.ts +1 -1
  470. package/dist/plugins/ai-chat/client/hooks/index.cjs +1 -0
  471. package/dist/plugins/ai-chat/client/hooks/index.d.cts +14 -8
  472. package/dist/plugins/ai-chat/client/hooks/index.d.mts +14 -8
  473. package/dist/plugins/ai-chat/client/hooks/index.d.ts +14 -8
  474. package/dist/plugins/ai-chat/client/hooks/index.mjs +1 -1
  475. package/dist/plugins/ai-chat/client/index.d.cts +21 -25
  476. package/dist/plugins/ai-chat/client/index.d.mts +21 -25
  477. package/dist/plugins/ai-chat/client/index.d.ts +21 -25
  478. package/dist/plugins/ai-chat/permissions.cjs +90 -0
  479. package/dist/plugins/ai-chat/permissions.d.cts +84 -0
  480. package/dist/plugins/ai-chat/permissions.d.mts +84 -0
  481. package/dist/plugins/ai-chat/permissions.d.ts +84 -0
  482. package/dist/plugins/ai-chat/permissions.mjs +88 -0
  483. package/dist/plugins/ai-chat/query-keys.cjs +116 -18
  484. package/dist/plugins/ai-chat/query-keys.d.cts +6 -2
  485. package/dist/plugins/ai-chat/query-keys.d.mts +6 -2
  486. package/dist/plugins/ai-chat/query-keys.d.ts +6 -2
  487. package/dist/plugins/ai-chat/query-keys.mjs +116 -19
  488. package/dist/plugins/api/index.cjs +4 -0
  489. package/dist/plugins/api/index.d.cts +13 -18
  490. package/dist/plugins/api/index.d.mts +13 -18
  491. package/dist/plugins/api/index.d.ts +13 -18
  492. package/dist/plugins/api/index.mjs +1 -0
  493. package/dist/plugins/blog/api/index.cjs +9 -2
  494. package/dist/plugins/blog/api/index.d.cts +118 -4
  495. package/dist/plugins/blog/api/index.d.mts +118 -4
  496. package/dist/plugins/blog/api/index.d.ts +118 -4
  497. package/dist/plugins/blog/api/index.mjs +4 -1
  498. package/dist/plugins/blog/client/hooks/index.d.cts +2 -2
  499. package/dist/plugins/blog/client/hooks/index.d.mts +2 -2
  500. package/dist/plugins/blog/client/hooks/index.d.ts +2 -2
  501. package/dist/plugins/blog/client/index.d.cts +210 -226
  502. package/dist/plugins/blog/client/index.d.mts +210 -226
  503. package/dist/plugins/blog/client/index.d.ts +210 -226
  504. package/dist/plugins/blog/permissions.cjs +47 -0
  505. package/dist/plugins/blog/permissions.d.cts +49 -0
  506. package/dist/plugins/blog/permissions.d.mts +49 -0
  507. package/dist/plugins/blog/permissions.d.ts +49 -0
  508. package/dist/plugins/blog/permissions.mjs +45 -0
  509. package/dist/plugins/blog/query-keys.d.cts +7 -3
  510. package/dist/plugins/blog/query-keys.d.mts +7 -3
  511. package/dist/plugins/blog/query-keys.d.ts +7 -3
  512. package/dist/plugins/client/hooks/index.d.cts +2 -2
  513. package/dist/plugins/client/hooks/index.d.mts +2 -2
  514. package/dist/plugins/client/hooks/index.d.ts +2 -2
  515. package/dist/plugins/client/index.cjs +3 -0
  516. package/dist/plugins/client/index.d.cts +30 -10
  517. package/dist/plugins/client/index.d.mts +30 -10
  518. package/dist/plugins/client/index.d.ts +30 -10
  519. package/dist/plugins/client/index.mjs +3 -0
  520. package/dist/plugins/cms/api/index.cjs +7 -0
  521. package/dist/plugins/cms/api/index.d.cts +173 -4
  522. package/dist/plugins/cms/api/index.d.mts +173 -4
  523. package/dist/plugins/cms/api/index.d.ts +173 -4
  524. package/dist/plugins/cms/api/index.mjs +2 -0
  525. package/dist/plugins/cms/client/hooks/index.d.cts +1 -1
  526. package/dist/plugins/cms/client/hooks/index.d.mts +1 -1
  527. package/dist/plugins/cms/client/hooks/index.d.ts +1 -1
  528. package/dist/plugins/cms/client/index.d.cts +188 -184
  529. package/dist/plugins/cms/client/index.d.mts +188 -184
  530. package/dist/plugins/cms/client/index.d.ts +188 -184
  531. package/dist/plugins/cms/permissions.cjs +46 -0
  532. package/dist/plugins/cms/permissions.d.cts +42 -0
  533. package/dist/plugins/cms/permissions.d.mts +42 -0
  534. package/dist/plugins/cms/permissions.d.ts +42 -0
  535. package/dist/plugins/cms/permissions.mjs +44 -0
  536. package/dist/plugins/cms/query-keys.d.cts +4 -4
  537. package/dist/plugins/cms/query-keys.d.mts +4 -4
  538. package/dist/plugins/cms/query-keys.d.ts +4 -4
  539. package/dist/plugins/comments/api/index.cjs +10 -0
  540. package/dist/plugins/comments/api/index.d.cts +54 -18
  541. package/dist/plugins/comments/api/index.d.mts +54 -18
  542. package/dist/plugins/comments/api/index.d.ts +54 -18
  543. package/dist/plugins/comments/api/index.mjs +3 -0
  544. package/dist/plugins/comments/client/components/index.d.cts +2 -2
  545. package/dist/plugins/comments/client/components/index.d.mts +2 -2
  546. package/dist/plugins/comments/client/components/index.d.ts +2 -2
  547. package/dist/plugins/comments/client/hooks/index.d.cts +12 -18
  548. package/dist/plugins/comments/client/hooks/index.d.mts +12 -18
  549. package/dist/plugins/comments/client/hooks/index.d.ts +12 -18
  550. package/dist/plugins/comments/client/index.d.cts +96 -114
  551. package/dist/plugins/comments/client/index.d.mts +96 -114
  552. package/dist/plugins/comments/client/index.d.ts +96 -114
  553. package/dist/plugins/comments/permissions.cjs +70 -0
  554. package/dist/plugins/comments/permissions.d.cts +76 -0
  555. package/dist/plugins/comments/permissions.d.mts +76 -0
  556. package/dist/plugins/comments/permissions.d.ts +76 -0
  557. package/dist/plugins/comments/permissions.mjs +68 -0
  558. package/dist/plugins/comments/query-keys.cjs +1 -1
  559. package/dist/plugins/comments/query-keys.d.cts +16 -19
  560. package/dist/plugins/comments/query-keys.d.mts +16 -19
  561. package/dist/plugins/comments/query-keys.d.ts +16 -19
  562. package/dist/plugins/comments/query-keys.mjs +1 -1
  563. package/dist/plugins/form-builder/api/index.cjs +8 -0
  564. package/dist/plugins/form-builder/api/index.d.cts +115 -4
  565. package/dist/plugins/form-builder/api/index.d.mts +115 -4
  566. package/dist/plugins/form-builder/api/index.d.ts +115 -4
  567. package/dist/plugins/form-builder/api/index.mjs +4 -1
  568. package/dist/plugins/form-builder/client/components/index.d.cts +6 -2
  569. package/dist/plugins/form-builder/client/components/index.d.mts +6 -2
  570. package/dist/plugins/form-builder/client/components/index.d.ts +6 -2
  571. package/dist/plugins/form-builder/client/hooks/index.cjs +2 -0
  572. package/dist/plugins/form-builder/client/hooks/index.d.cts +34 -8
  573. package/dist/plugins/form-builder/client/hooks/index.d.mts +34 -8
  574. package/dist/plugins/form-builder/client/hooks/index.d.ts +34 -8
  575. package/dist/plugins/form-builder/client/hooks/index.mjs +1 -1
  576. package/dist/plugins/form-builder/client/index.d.cts +153 -174
  577. package/dist/plugins/form-builder/client/index.d.mts +153 -174
  578. package/dist/plugins/form-builder/client/index.d.ts +153 -174
  579. package/dist/plugins/form-builder/permissions.cjs +95 -0
  580. package/dist/plugins/form-builder/permissions.d.cts +94 -0
  581. package/dist/plugins/form-builder/permissions.d.mts +94 -0
  582. package/dist/plugins/form-builder/permissions.d.ts +94 -0
  583. package/dist/plugins/form-builder/permissions.mjs +93 -0
  584. package/dist/plugins/form-builder/query-keys.cjs +11 -4
  585. package/dist/plugins/form-builder/query-keys.d.cts +38 -12
  586. package/dist/plugins/form-builder/query-keys.d.mts +38 -12
  587. package/dist/plugins/form-builder/query-keys.d.ts +38 -12
  588. package/dist/plugins/form-builder/query-keys.mjs +11 -4
  589. package/dist/plugins/kanban/api/index.cjs +9 -0
  590. package/dist/plugins/kanban/api/index.d.cts +137 -5
  591. package/dist/plugins/kanban/api/index.d.mts +137 -5
  592. package/dist/plugins/kanban/api/index.d.ts +137 -5
  593. package/dist/plugins/kanban/api/index.mjs +5 -2
  594. package/dist/plugins/kanban/client/components/index.d.cts +18 -10
  595. package/dist/plugins/kanban/client/components/index.d.mts +18 -10
  596. package/dist/plugins/kanban/client/components/index.d.ts +18 -10
  597. package/dist/plugins/kanban/client/hooks/index.d.cts +15 -7
  598. package/dist/plugins/kanban/client/hooks/index.d.mts +15 -7
  599. package/dist/plugins/kanban/client/hooks/index.d.ts +15 -7
  600. package/dist/plugins/kanban/client/index.d.cts +32 -28
  601. package/dist/plugins/kanban/client/index.d.mts +32 -28
  602. package/dist/plugins/kanban/client/index.d.ts +32 -28
  603. package/dist/plugins/kanban/permissions.cjs +101 -0
  604. package/dist/plugins/kanban/permissions.d.cts +109 -0
  605. package/dist/plugins/kanban/permissions.d.mts +109 -0
  606. package/dist/plugins/kanban/permissions.d.ts +109 -0
  607. package/dist/plugins/kanban/permissions.mjs +99 -0
  608. package/dist/plugins/kanban/query-keys.cjs +14 -15
  609. package/dist/plugins/kanban/query-keys.d.cts +63 -42
  610. package/dist/plugins/kanban/query-keys.d.mts +63 -42
  611. package/dist/plugins/kanban/query-keys.d.ts +63 -42
  612. package/dist/plugins/kanban/query-keys.mjs +14 -15
  613. package/dist/plugins/media/api/adapters/local.d.cts +1 -1
  614. package/dist/plugins/media/api/adapters/local.d.mts +1 -1
  615. package/dist/plugins/media/api/adapters/local.d.ts +1 -1
  616. package/dist/plugins/media/api/adapters/s3.d.cts +1 -1
  617. package/dist/plugins/media/api/adapters/s3.d.mts +1 -1
  618. package/dist/plugins/media/api/adapters/s3.d.ts +1 -1
  619. package/dist/plugins/media/api/adapters/vercel-blob.cjs +46 -0
  620. package/dist/plugins/media/api/adapters/vercel-blob.d.cts +6 -9
  621. package/dist/plugins/media/api/adapters/vercel-blob.d.mts +6 -9
  622. package/dist/plugins/media/api/adapters/vercel-blob.d.ts +6 -9
  623. package/dist/plugins/media/api/adapters/vercel-blob.mjs +46 -0
  624. package/dist/plugins/media/api/index.cjs +10 -0
  625. package/dist/plugins/media/api/index.d.cts +93 -6
  626. package/dist/plugins/media/api/index.d.mts +93 -6
  627. package/dist/plugins/media/api/index.d.ts +93 -6
  628. package/dist/plugins/media/api/index.mjs +2 -0
  629. package/dist/plugins/media/client/components/index.d.cts +1 -1
  630. package/dist/plugins/media/client/components/index.d.mts +1 -1
  631. package/dist/plugins/media/client/components/index.d.ts +1 -1
  632. package/dist/plugins/media/client/hooks/index.d.cts +20 -10
  633. package/dist/plugins/media/client/hooks/index.d.mts +20 -10
  634. package/dist/plugins/media/client/hooks/index.d.ts +20 -10
  635. package/dist/plugins/media/client/index.cjs +1 -0
  636. package/dist/plugins/media/client/index.d.cts +112 -100
  637. package/dist/plugins/media/client/index.d.mts +112 -100
  638. package/dist/plugins/media/client/index.d.ts +112 -100
  639. package/dist/plugins/media/client/index.mjs +1 -1
  640. package/dist/plugins/media/permissions.cjs +63 -0
  641. package/dist/plugins/media/permissions.d.cts +64 -0
  642. package/dist/plugins/media/permissions.d.mts +64 -0
  643. package/dist/plugins/media/permissions.d.ts +64 -0
  644. package/dist/plugins/media/permissions.mjs +61 -0
  645. package/dist/plugins/media/query-keys.cjs +29 -17
  646. package/dist/plugins/media/query-keys.d.cts +24 -31
  647. package/dist/plugins/media/query-keys.d.mts +24 -31
  648. package/dist/plugins/media/query-keys.d.ts +24 -31
  649. package/dist/plugins/media/query-keys.mjs +30 -18
  650. package/dist/plugins/open-api/api/index.d.cts +9 -4
  651. package/dist/plugins/open-api/api/index.d.mts +9 -4
  652. package/dist/plugins/open-api/api/index.d.ts +9 -4
  653. package/dist/plugins/route-docs/client/index.cjs +2 -2
  654. package/dist/plugins/route-docs/client/index.d.cts +54 -53
  655. package/dist/plugins/route-docs/client/index.d.mts +54 -53
  656. package/dist/plugins/route-docs/client/index.d.ts +54 -53
  657. package/dist/plugins/route-docs/client/index.mjs +2 -1
  658. package/dist/plugins/ui-builder/client/components/index.d.cts +8 -5
  659. package/dist/plugins/ui-builder/client/components/index.d.mts +8 -5
  660. package/dist/plugins/ui-builder/client/components/index.d.ts +8 -5
  661. package/dist/plugins/ui-builder/client/hooks/index.d.cts +5 -5
  662. package/dist/plugins/ui-builder/client/hooks/index.d.mts +5 -5
  663. package/dist/plugins/ui-builder/client/hooks/index.d.ts +5 -5
  664. package/dist/plugins/ui-builder/client/index.d.cts +151 -199
  665. package/dist/plugins/ui-builder/client/index.d.mts +151 -199
  666. package/dist/plugins/ui-builder/client/index.d.ts +151 -199
  667. package/dist/plugins/ui-builder/index.d.cts +11 -8
  668. package/dist/plugins/ui-builder/index.d.mts +11 -8
  669. package/dist/plugins/ui-builder/index.d.ts +11 -8
  670. package/dist/plugins/ui-builder/query-keys.d.cts +6 -6
  671. package/dist/plugins/ui-builder/query-keys.d.mts +6 -6
  672. package/dist/plugins/ui-builder/query-keys.d.ts +6 -6
  673. package/dist/react-router/index.cjs +2 -0
  674. package/dist/react-router/index.d.cts +29 -5
  675. package/dist/react-router/index.d.mts +29 -5
  676. package/dist/react-router/index.d.ts +29 -5
  677. package/dist/react-router/index.mjs +1 -0
  678. package/dist/shared/stack.0O62uXqP.d.ts +613 -0
  679. package/dist/shared/stack.0y6iTP03.d.ts +533 -0
  680. package/dist/shared/{stack.CbZenbej.d.cts → stack.1ukVJym7.d.cts} +3 -4
  681. package/dist/shared/{stack.CbZenbej.d.mts → stack.1ukVJym7.d.mts} +3 -4
  682. package/dist/shared/{stack.CbZenbej.d.ts → stack.1ukVJym7.d.ts} +3 -4
  683. package/dist/shared/stack.3Sr6qRtT.d.ts +507 -0
  684. package/dist/shared/{stack.9BAOaSqE.d.cts → stack.5_zzCejP.d.cts} +16 -14
  685. package/dist/shared/{stack.9BAOaSqE.d.mts → stack.5_zzCejP.d.mts} +16 -14
  686. package/dist/shared/{stack.9BAOaSqE.d.ts → stack.5_zzCejP.d.ts} +16 -14
  687. package/dist/shared/{stack.oVIdV7XS.d.mts → stack.94kN3pEK.d.mts} +4 -4
  688. package/dist/shared/stack.B1UrNoVl.d.mts +533 -0
  689. package/dist/shared/{stack.B2xi4jj7.d.cts → stack.B1srlBud.d.mts} +2 -2
  690. package/dist/shared/stack.B3_aDcYL.d.cts +281 -0
  691. package/dist/shared/stack.B3_aDcYL.d.mts +281 -0
  692. package/dist/shared/stack.B3_aDcYL.d.ts +281 -0
  693. package/dist/shared/stack.B5yPgHsp.d.mts +507 -0
  694. package/dist/shared/stack.BFP_9pRX.d.cts +707 -0
  695. package/dist/shared/stack.BJx1ZXrN.d.cts +118 -0
  696. package/dist/shared/{stack.7b3vsM8_.d.ts → stack.BK9Z2dcL.d.ts} +2 -2
  697. package/dist/shared/stack.BMHoxAn7.d.mts +707 -0
  698. package/dist/shared/stack.BMlTZnZp.d.ts +764 -0
  699. package/dist/shared/stack.BMmvEBH_.d.ts +118 -0
  700. package/dist/shared/stack.BPLykw4s.d.ts +436 -0
  701. package/dist/shared/{stack.aqVZ6PEW.d.mts → stack.BRvqQWGt.d.cts} +40 -1
  702. package/dist/shared/{stack.aqVZ6PEW.d.cts → stack.BRvqQWGt.d.mts} +40 -1
  703. package/dist/shared/{stack.aqVZ6PEW.d.ts → stack.BRvqQWGt.d.ts} +40 -1
  704. package/dist/shared/stack.BSACE667.d.cts +23 -0
  705. package/dist/shared/{stack.DzwZw-Ck.d.cts → stack.BTStHVTy.d.cts} +4 -4
  706. package/dist/shared/stack.BV0uNV4f.d.cts +764 -0
  707. package/dist/shared/stack.BYMentwB.d.cts +47 -0
  708. package/dist/shared/stack.BYMentwB.d.mts +47 -0
  709. package/dist/shared/stack.BYMentwB.d.ts +47 -0
  710. package/dist/shared/stack.BggTHKlo.d.mts +1184 -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.BzWGB5MG.d.cts +436 -0
  716. package/dist/shared/stack.C3bU9w6L.d.ts +351 -0
  717. package/dist/shared/stack.C4oVW2qK.d.cts +507 -0
  718. package/dist/shared/stack.CGmh-Lpe.d.ts +408 -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.Cbd7sD5M.d.mts +118 -0
  726. package/dist/shared/{stack.B9NtGpAR.d.ts → stack.CcjENrr4.d.cts} +1 -5
  727. package/dist/shared/stack.CfK5NKlK.d.mts +613 -0
  728. package/dist/shared/stack.Cmg7lzzy.d.cts +44 -0
  729. package/dist/shared/stack.Cmg7lzzy.d.mts +44 -0
  730. package/dist/shared/stack.Cmg7lzzy.d.ts +44 -0
  731. package/dist/shared/stack.CpE1mS3p.d.ts +331 -0
  732. package/dist/shared/stack.CskhFw3z.d.mts +23 -0
  733. package/dist/shared/stack.CtrnoQgH.d.cts +1184 -0
  734. package/dist/shared/stack.CvlC5kqe.d.cts +331 -0
  735. package/dist/shared/stack.CxKc9evq.d.ts +23 -0
  736. package/dist/shared/{stack.lkebw2nj.d.mts → stack.DVEjWKCT.d.cts} +19 -5
  737. package/dist/shared/{stack.lkebw2nj.d.ts → stack.DVEjWKCT.d.mts} +19 -5
  738. package/dist/shared/{stack.lkebw2nj.d.cts → stack.DVEjWKCT.d.ts} +19 -5
  739. package/dist/shared/{stack.Cp_6mO5s.d.mts → stack.DbbvHbhn.d.mts} +1 -5
  740. package/dist/shared/{stack.DseBJmGF.d.ts → stack.DfrRYOIl.d.ts} +4 -4
  741. package/dist/shared/stack.DiuRuzIs.d.cts +613 -0
  742. package/dist/shared/{stack.BMlLOMED.d.cts → stack.DjGixVx3.d.cts} +6 -2
  743. package/dist/shared/{stack.BMlLOMED.d.mts → stack.DjGixVx3.d.mts} +6 -2
  744. package/dist/shared/{stack.BMlLOMED.d.ts → stack.DjGixVx3.d.ts} +6 -2
  745. package/dist/shared/stack.DlCycSM-.d.mts +331 -0
  746. package/dist/shared/{stack.DycBcTeg.d.mts → stack.DmpPDPxA.d.cts} +2 -2
  747. package/dist/shared/stack.Doy2_wgl.d.mts +408 -0
  748. package/dist/shared/stack.DxHPKr2R.d.mts +436 -0
  749. package/dist/shared/stack.Mak7pzIV.d.cts +533 -0
  750. package/dist/shared/stack.OYT8WU4n.d.mts +351 -0
  751. package/dist/shared/{stack.CPsYC2-Z.d.cts → stack.fdi94T4S.d.cts} +7 -7
  752. package/dist/shared/{stack.CPsYC2-Z.d.mts → stack.fdi94T4S.d.mts} +7 -7
  753. package/dist/shared/{stack.CPsYC2-Z.d.ts → stack.fdi94T4S.d.ts} +7 -7
  754. package/dist/shared/{stack.Dlgtumru.d.cts → stack.kaCV7vEL.d.ts} +1 -5
  755. package/dist/shared/stack.lPKwd_v0.d.ts +1184 -0
  756. package/dist/shared/stack.lsbdKRj7.d.mts +764 -0
  757. package/dist/shared/stack.v2O65JqF.d.cts +351 -0
  758. package/dist/shared/stack.zch70Loj.d.cts +408 -0
  759. package/dist/tanstack/index.cjs +2 -0
  760. package/dist/tanstack/index.d.cts +27 -5
  761. package/dist/tanstack/index.d.mts +27 -5
  762. package/dist/tanstack/index.d.ts +27 -5
  763. package/dist/tanstack/index.mjs +1 -0
  764. package/dist/tanstack/server.cjs +9 -0
  765. package/dist/tanstack/server.d.cts +15 -0
  766. package/dist/tanstack/server.d.mts +15 -0
  767. package/dist/tanstack/server.d.ts +15 -0
  768. package/dist/tanstack/server.mjs +7 -0
  769. package/package.json +198 -3
  770. package/src/__tests__/ai-chat-client-runtime.test.ts +481 -0
  771. package/src/__tests__/ai-chat-client-runtime.typecheck.tsx +130 -0
  772. package/src/__tests__/ai-chat-lifecycle-migrations.typecheck.ts +61 -0
  773. package/src/__tests__/ai-chat-query-keys.test.ts +125 -22
  774. package/src/__tests__/auth-provider.test.tsx +41 -314
  775. package/src/__tests__/auth-test-utils.ts +24 -0
  776. package/src/__tests__/authorization-client.test.tsx +767 -0
  777. package/src/__tests__/authorization-contraction.test.ts +182 -0
  778. package/src/__tests__/authorization-remote.test.ts +222 -0
  779. package/src/__tests__/authorization-server.test.ts +90 -0
  780. package/src/__tests__/authorization.test.ts +652 -0
  781. package/src/__tests__/authorization.typecheck.ts +671 -0
  782. package/src/__tests__/backend-plugin-factories.test.ts +54 -0
  783. package/src/__tests__/backend-plugin-factories.typecheck.ts +133 -0
  784. package/src/__tests__/client-plugin-ssr-loaders.test.ts +304 -138
  785. package/src/__tests__/client-runtime.test.ts +1021 -0
  786. package/src/__tests__/client-runtime.typecheck.ts +107 -0
  787. package/src/__tests__/client-stack-test-utils.ts +36 -0
  788. package/src/__tests__/content-lifecycle-migrations.typecheck.ts +122 -0
  789. package/src/__tests__/endpoint-inventory.test.ts +768 -0
  790. package/src/__tests__/form-builder-query-keys.test.ts +32 -0
  791. package/src/__tests__/i18n-provider.test.tsx +4 -3
  792. package/src/__tests__/initial-identity-hydration.test.tsx +156 -0
  793. package/src/__tests__/initial-identity-layouts.test.tsx +204 -0
  794. package/src/__tests__/kanban-query-keys.test.ts +189 -2
  795. package/src/__tests__/managed-origin-hydration.browser.test.tsx +163 -0
  796. package/src/__tests__/media-query-keys.test.ts +91 -17
  797. package/src/__tests__/notify-provider.test.tsx +3 -2
  798. package/src/__tests__/package-metadata.test.ts +294 -0
  799. package/src/__tests__/page-component-overrides.test.tsx +3 -4
  800. package/src/__tests__/plugin-registration.test.tsx +183 -0
  801. package/src/__tests__/plugin-registration.typecheck.tsx +139 -0
  802. package/src/__tests__/plugins.test.tsx +72 -42
  803. package/src/__tests__/resource-factory.test.tsx +79 -2
  804. package/src/__tests__/resource-use-form.test.tsx +2 -2
  805. package/src/__tests__/resource-use-select.test.tsx +2 -4
  806. package/src/__tests__/router-overrides.test.tsx +20 -8
  807. package/src/__tests__/sitemap.test.ts +38 -22
  808. package/src/__tests__/stack-api.test.ts +39 -34
  809. package/src/__tests__/stack-auth.test.ts +44 -140
  810. package/src/__tests__/stack-constructors.test.ts +96 -0
  811. package/src/__tests__/stack-constructors.typecheck.ts +115 -0
  812. package/src/__tests__/use-list-state.test.tsx +7 -6
  813. package/src/__tests__/workflow-lifecycle-migrations.typecheck.ts +150 -0
  814. package/src/api/index.ts +204 -99
  815. package/src/authorization/client.tsx +310 -0
  816. package/src/authorization/index.ts +873 -0
  817. package/src/authorization/json.ts +70 -0
  818. package/src/authorization/remote.ts +234 -0
  819. package/src/authorization/server.ts +171 -0
  820. package/src/client/__tests__/server-origin.test.ts +119 -0
  821. package/src/client/components/compose.tsx +126 -18
  822. package/src/client/hooks/index.ts +12 -0
  823. package/src/client/hooks/use-list-state.ts +7 -13
  824. package/src/client/index.ts +105 -50
  825. package/src/client/runtime.ts +414 -0
  826. package/src/client/server.ts +174 -0
  827. package/src/context/auth.tsx +205 -154
  828. package/src/context/index.ts +10 -4
  829. package/src/context/provider.tsx +96 -57
  830. package/src/context/router.tsx +7 -0
  831. package/src/context/site-navigation.ts +52 -0
  832. package/src/next/layout.tsx +81 -0
  833. package/src/next/page.tsx +16 -3
  834. package/src/next/router.tsx +1 -1
  835. package/src/next/server.ts +5 -0
  836. package/src/plugin-registration.ts +70 -0
  837. package/src/plugins/ai-chat/__tests__/authorization.test.ts +2051 -0
  838. package/src/plugins/ai-chat/__tests__/chat-hooks.test.tsx +147 -0
  839. package/src/plugins/ai-chat/__tests__/chat-input-authorization.test.tsx +188 -0
  840. package/src/plugins/ai-chat/__tests__/client-sweep.test.tsx +1506 -34
  841. package/src/plugins/ai-chat/__tests__/hooks.test.tsx +131 -23
  842. package/src/plugins/ai-chat/api/getters.ts +2 -2
  843. package/src/plugins/ai-chat/api/index.ts +6 -1
  844. package/src/plugins/ai-chat/api/lifecycle-migrations.ts +20 -0
  845. package/src/plugins/ai-chat/api/operations.ts +1865 -0
  846. package/src/plugins/ai-chat/api/plugin.ts +78 -1168
  847. package/src/plugins/ai-chat/api/serializers.ts +30 -0
  848. package/src/plugins/ai-chat/client/components/chat-input.tsx +228 -129
  849. package/src/plugins/ai-chat/client/components/chat-interface.tsx +776 -183
  850. package/src/plugins/ai-chat/client/components/chat-layout.tsx +6 -7
  851. package/src/plugins/ai-chat/client/components/chat-message.tsx +1 -1
  852. package/src/plugins/ai-chat/client/components/chat-sidebar.tsx +57 -37
  853. package/src/plugins/ai-chat/client/components/pages/404-page.tsx +1 -1
  854. package/src/plugins/ai-chat/client/components/pages/chat-page.internal.tsx +5 -3
  855. package/src/plugins/ai-chat/client/components/pages/chat-page.tsx +56 -15
  856. package/src/plugins/ai-chat/client/components/shared/default-error.tsx +1 -1
  857. package/src/plugins/ai-chat/client/components/tool-call-display.tsx +1 -1
  858. package/src/plugins/ai-chat/client/hooks/ai-chat-resource.ts +1 -1
  859. package/src/plugins/ai-chat/client/hooks/chat-hooks.tsx +253 -20
  860. package/src/plugins/ai-chat/client/index.ts +1 -0
  861. package/src/plugins/ai-chat/client/navigation.ts +11 -0
  862. package/src/plugins/ai-chat/client/overrides.ts +47 -11
  863. package/src/plugins/ai-chat/client/plugin.tsx +208 -111
  864. package/src/plugins/ai-chat/permissions.ts +89 -0
  865. package/src/plugins/ai-chat/query-keys.ts +183 -25
  866. package/src/plugins/ai-chat/types.ts +7 -5
  867. package/src/plugins/api/create-endpoint.ts +40 -22
  868. package/src/plugins/api/endpoint-inventory.ts +206 -0
  869. package/src/plugins/api/index.ts +38 -4
  870. package/src/plugins/api/operation.ts +600 -0
  871. package/src/plugins/blog/__tests__/authorization.test.ts +1366 -0
  872. package/src/plugins/blog/__tests__/client-runtime.browser.test.tsx +257 -0
  873. package/src/plugins/blog/__tests__/client-runtime.test.ts +283 -0
  874. package/src/plugins/blog/__tests__/client-runtime.typecheck.tsx +98 -0
  875. package/src/plugins/blog/__tests__/client-sweep.test.tsx +212 -37
  876. package/src/plugins/blog/api/getters.ts +3 -3
  877. package/src/plugins/blog/api/index.ts +2 -0
  878. package/src/plugins/blog/api/lifecycle-migrations.ts +19 -0
  879. package/src/plugins/blog/api/mutations.ts +26 -5
  880. package/src/plugins/blog/api/operations.ts +727 -0
  881. package/src/plugins/blog/api/plugin.ts +99 -504
  882. package/src/plugins/blog/client/components/forms/image-field.tsx +2 -1
  883. package/src/plugins/blog/client/components/forms/markdown-editor-with-overrides.tsx +2 -1
  884. package/src/plugins/blog/client/components/forms/post-forms.tsx +61 -33
  885. package/src/plugins/blog/client/components/pages/404-page.tsx +3 -1
  886. package/src/plugins/blog/client/components/pages/edit-post-page.internal.tsx +2 -1
  887. package/src/plugins/blog/client/components/pages/edit-post-page.tsx +28 -5
  888. package/src/plugins/blog/client/components/pages/home-page.internal.tsx +2 -1
  889. package/src/plugins/blog/client/components/pages/home-page.tsx +7 -4
  890. package/src/plugins/blog/client/components/pages/new-post-page.internal.tsx +2 -1
  891. package/src/plugins/blog/client/components/pages/new-post-page.tsx +5 -2
  892. package/src/plugins/blog/client/components/pages/post-page.internal.tsx +2 -1
  893. package/src/plugins/blog/client/components/pages/post-page.tsx +38 -4
  894. package/src/plugins/blog/client/components/pages/tag-page.internal.tsx +2 -1
  895. package/src/plugins/blog/client/components/pages/tag-page.tsx +5 -1
  896. package/src/plugins/blog/client/components/shared/collapsible-tag-list.tsx +2 -1
  897. package/src/plugins/blog/client/components/shared/default-error.tsx +3 -1
  898. package/src/plugins/blog/client/components/shared/on-this-page.tsx +5 -2
  899. package/src/plugins/blog/client/components/shared/page-wrapper.tsx +2 -1
  900. package/src/plugins/blog/client/components/shared/post-card.tsx +2 -1
  901. package/src/plugins/blog/client/components/shared/posts-list.tsx +2 -1
  902. package/src/plugins/blog/client/components/shared/recent-posts-carousel.tsx +2 -1
  903. package/src/plugins/blog/client/components/shared/search-input.tsx +1 -1
  904. package/src/plugins/blog/client/constants.ts +2 -0
  905. package/src/plugins/blog/client/hooks/blog-resource.ts +2 -1
  906. package/src/plugins/blog/client/overrides.ts +1 -6
  907. package/src/plugins/blog/client/plugin.tsx +145 -129
  908. package/src/plugins/blog/permissions.ts +44 -0
  909. package/src/plugins/client/index.ts +108 -7
  910. package/src/plugins/client/resource/hooks.tsx +41 -18
  911. package/src/plugins/client/resource/internal.ts +77 -61
  912. package/src/plugins/client/resource/queries.ts +3 -4
  913. package/src/plugins/client/resource/use-form.ts +23 -20
  914. package/src/plugins/client/resource/use-select.ts +40 -34
  915. package/src/plugins/cms/__tests__/authorization.test.ts +2188 -0
  916. package/src/plugins/cms/__tests__/client-runtime.browser.test.tsx +245 -0
  917. package/src/plugins/cms/__tests__/client-runtime.test.ts +320 -0
  918. package/src/plugins/cms/__tests__/client-runtime.typecheck.tsx +208 -0
  919. package/src/plugins/cms/__tests__/client-sweep.test.tsx +202 -50
  920. package/src/plugins/cms/api/getters.ts +4 -4
  921. package/src/plugins/cms/api/index.ts +20 -0
  922. package/src/plugins/cms/api/lifecycle-migrations.ts +15 -0
  923. package/src/plugins/cms/api/mutations.ts +2 -2
  924. package/src/plugins/cms/api/operations.ts +2218 -0
  925. package/src/plugins/cms/api/plugin.ts +169 -1047
  926. package/src/plugins/cms/api/relations.ts +3 -1
  927. package/src/plugins/cms/client/components/forms/content-form.tsx +2 -1
  928. package/src/plugins/cms/client/components/forms/file-upload.tsx +3 -1
  929. package/src/plugins/cms/client/components/forms/relation-field.tsx +3 -1
  930. package/src/plugins/cms/client/components/inverse-relations-panel.tsx +29 -17
  931. package/src/plugins/cms/client/components/pages/404-page.tsx +7 -5
  932. package/src/plugins/cms/client/components/pages/content-editor-page.internal.tsx +19 -10
  933. package/src/plugins/cms/client/components/pages/content-editor-page.tsx +50 -12
  934. package/src/plugins/cms/client/components/pages/content-list-page.internal.tsx +48 -34
  935. package/src/plugins/cms/client/components/pages/content-list-page.tsx +8 -1
  936. package/src/plugins/cms/client/components/pages/dashboard-page.internal.tsx +15 -8
  937. package/src/plugins/cms/client/components/pages/dashboard-page.tsx +5 -1
  938. package/src/plugins/cms/client/components/shared/page-wrapper.tsx +2 -1
  939. package/src/plugins/cms/client/constants.ts +2 -0
  940. package/src/plugins/cms/client/hooks/cms-resource.ts +2 -1
  941. package/src/plugins/cms/client/index.ts +6 -1
  942. package/src/plugins/cms/client/overrides.ts +46 -6
  943. package/src/plugins/cms/client/plugin.tsx +135 -80
  944. package/src/plugins/cms/permissions.ts +43 -0
  945. package/src/plugins/cms/types.ts +174 -46
  946. package/src/plugins/comments/__tests__/authorization.test.ts +1570 -0
  947. package/src/plugins/comments/__tests__/client-runtime.browser.test.tsx +207 -0
  948. package/src/plugins/comments/__tests__/client-runtime.test.ts +224 -0
  949. package/src/plugins/comments/__tests__/client-runtime.typecheck.tsx +85 -0
  950. package/src/plugins/comments/__tests__/client-sweep.test.tsx +445 -82
  951. package/src/plugins/comments/api/getters.ts +19 -3
  952. package/src/plugins/comments/api/index.ts +2 -6
  953. package/src/plugins/comments/api/lifecycle-migrations.ts +20 -0
  954. package/src/plugins/comments/api/mutations.ts +261 -88
  955. package/src/plugins/comments/api/operations.ts +742 -0
  956. package/src/plugins/comments/api/plugin.ts +76 -548
  957. package/src/plugins/comments/client/components/comment-count.tsx +38 -5
  958. package/src/plugins/comments/client/components/comment-thread.tsx +148 -110
  959. package/src/plugins/comments/client/components/pages/moderation-page.internal.tsx +144 -78
  960. package/src/plugins/comments/client/components/pages/moderation-page.tsx +18 -2
  961. package/src/plugins/comments/client/components/pages/moderation-state.ts +13 -0
  962. package/src/plugins/comments/client/components/pages/my-comments-page.internal.tsx +38 -30
  963. package/src/plugins/comments/client/components/pages/my-comments-page.tsx +3 -1
  964. package/src/plugins/comments/client/components/pages/resource-comments-page.internal.tsx +29 -30
  965. package/src/plugins/comments/client/components/pages/resource-comments-page.tsx +10 -1
  966. package/src/plugins/comments/client/components/shared/page-wrapper.tsx +2 -1
  967. package/src/plugins/comments/client/components/shared/pagination.tsx +2 -1
  968. package/src/plugins/comments/client/constants.ts +2 -0
  969. package/src/plugins/comments/client/hooks/use-comments.tsx +430 -421
  970. package/src/plugins/comments/client/localization/comments-thread.ts +1 -0
  971. package/src/plugins/comments/client/plugin.tsx +113 -72
  972. package/src/plugins/comments/permissions.ts +68 -0
  973. package/src/plugins/comments/query-keys.ts +9 -10
  974. package/src/plugins/comments/schemas.ts +7 -8
  975. package/src/plugins/form-builder/__tests__/authorization.test.ts +1600 -0
  976. package/src/plugins/form-builder/__tests__/client-runtime.browser.test.tsx +255 -0
  977. package/src/plugins/form-builder/__tests__/client-runtime.test.ts +132 -0
  978. package/src/plugins/form-builder/__tests__/client-runtime.typecheck.tsx +77 -0
  979. package/src/plugins/form-builder/__tests__/client-sweep.test.tsx +350 -54
  980. package/src/plugins/form-builder/__tests__/form-renderer-authorization.test.tsx +162 -0
  981. package/src/plugins/form-builder/api/getters.ts +21 -5
  982. package/src/plugins/form-builder/api/index.ts +31 -0
  983. package/src/plugins/form-builder/api/lifecycle-migrations.ts +17 -0
  984. package/src/plugins/form-builder/api/operations.ts +1493 -0
  985. package/src/plugins/form-builder/api/plugin.ts +125 -632
  986. package/src/plugins/form-builder/api/query-key-defs.ts +7 -0
  987. package/src/plugins/form-builder/api/serializers.ts +1 -0
  988. package/src/plugins/form-builder/client/components/forms/form-renderer.tsx +49 -19
  989. package/src/plugins/form-builder/client/components/pages/404-page.tsx +9 -9
  990. package/src/plugins/form-builder/client/components/pages/form-builder-page.internal.tsx +54 -30
  991. package/src/plugins/form-builder/client/components/pages/form-builder-page.tsx +42 -9
  992. package/src/plugins/form-builder/client/components/pages/form-list-page.internal.tsx +46 -34
  993. package/src/plugins/form-builder/client/components/pages/form-list-page.tsx +6 -2
  994. package/src/plugins/form-builder/client/components/pages/submissions-page.internal.tsx +98 -64
  995. package/src/plugins/form-builder/client/components/pages/submissions-page.tsx +29 -9
  996. package/src/plugins/form-builder/client/components/shared/page-wrapper.tsx +2 -1
  997. package/src/plugins/form-builder/client/constants.ts +2 -0
  998. package/src/plugins/form-builder/client/hooks/form-builder-hooks.tsx +68 -4
  999. package/src/plugins/form-builder/client/hooks/form-builder-resource.ts +2 -1
  1000. package/src/plugins/form-builder/client/hooks/index.tsx +1 -0
  1001. package/src/plugins/form-builder/client/overrides.ts +1 -6
  1002. package/src/plugins/form-builder/client/plugin.tsx +128 -96
  1003. package/src/plugins/form-builder/permissions.ts +94 -0
  1004. package/src/plugins/form-builder/query-keys.ts +28 -3
  1005. package/src/plugins/form-builder/schemas.ts +9 -1
  1006. package/src/plugins/form-builder/types.ts +173 -41
  1007. package/src/plugins/kanban/__tests__/authorization.test.ts +1382 -0
  1008. package/src/plugins/kanban/__tests__/client-runtime.browser.test.tsx +302 -0
  1009. package/src/plugins/kanban/__tests__/client-runtime.test.ts +130 -0
  1010. package/src/plugins/kanban/__tests__/client-runtime.typecheck.tsx +81 -0
  1011. package/src/plugins/kanban/__tests__/client-sweep.test.tsx +418 -33
  1012. package/src/plugins/kanban/__tests__/identity-partition.test.tsx +306 -0
  1013. package/src/plugins/kanban/api/getters.ts +65 -50
  1014. package/src/plugins/kanban/api/index.ts +55 -4
  1015. package/src/plugins/kanban/api/lifecycle-migrations.ts +25 -0
  1016. package/src/plugins/kanban/api/mutations.ts +3 -3
  1017. package/src/plugins/kanban/api/operations.ts +2065 -0
  1018. package/src/plugins/kanban/api/plugin.ts +83 -1013
  1019. package/src/plugins/kanban/api/serializers.ts +26 -0
  1020. package/src/plugins/kanban/client/components/forms/board-form.tsx +3 -1
  1021. package/src/plugins/kanban/client/components/forms/column-form.tsx +3 -1
  1022. package/src/plugins/kanban/client/components/forms/task-form.tsx +92 -74
  1023. package/src/plugins/kanban/client/components/pages/404-page.tsx +6 -9
  1024. package/src/plugins/kanban/client/components/pages/board-page.internal.tsx +57 -74
  1025. package/src/plugins/kanban/client/components/pages/board-page.tsx +31 -7
  1026. package/src/plugins/kanban/client/components/pages/boards-list-page.internal.tsx +54 -45
  1027. package/src/plugins/kanban/client/components/pages/boards-list-page.tsx +2 -1
  1028. package/src/plugins/kanban/client/components/pages/new-board-page.internal.tsx +8 -12
  1029. package/src/plugins/kanban/client/components/pages/new-board-page.tsx +2 -1
  1030. package/src/plugins/kanban/client/components/shared/column-content.tsx +61 -48
  1031. package/src/plugins/kanban/client/components/shared/default-error.tsx +3 -1
  1032. package/src/plugins/kanban/client/components/shared/kanban-board.tsx +6 -6
  1033. package/src/plugins/kanban/client/components/shared/permission-access-any.tsx +32 -0
  1034. package/src/plugins/kanban/client/components/shared/task-card.tsx +64 -20
  1035. package/src/plugins/kanban/client/components/shared/user-avatar.tsx +3 -1
  1036. package/src/plugins/kanban/client/constants.ts +2 -0
  1037. package/src/plugins/kanban/client/hooks/kanban-hooks.tsx +55 -10
  1038. package/src/plugins/kanban/client/hooks/kanban-resource.ts +2 -1
  1039. package/src/plugins/kanban/client/overrides.ts +0 -5
  1040. package/src/plugins/kanban/client/plugin.tsx +201 -113
  1041. package/src/plugins/kanban/permissions.ts +100 -0
  1042. package/src/plugins/kanban/query-keys.ts +61 -21
  1043. package/src/plugins/kanban/schemas.ts +44 -18
  1044. package/src/plugins/kanban/types.ts +381 -1
  1045. package/src/plugins/media/__tests__/authorization.test.ts +1769 -0
  1046. package/src/plugins/media/__tests__/client-runtime.browser.test.tsx +975 -0
  1047. package/src/plugins/media/__tests__/client-runtime.test.ts +539 -0
  1048. package/src/plugins/media/__tests__/client-runtime.typecheck.tsx +135 -0
  1049. package/src/plugins/media/__tests__/client-sweep.test.tsx +292 -24
  1050. package/src/plugins/media/__tests__/identity-partition.test.tsx +741 -0
  1051. package/src/plugins/media/__tests__/plugin.test.ts +68 -28
  1052. package/src/plugins/media/__tests__/query-key-defs.test.ts +32 -2
  1053. package/src/plugins/media/api/adapters/vercel-blob.ts +84 -8
  1054. package/src/plugins/media/api/getters.ts +6 -6
  1055. package/src/plugins/media/api/index.ts +3 -0
  1056. package/src/plugins/media/api/lifecycle-migrations.ts +11 -0
  1057. package/src/plugins/media/api/mutations.ts +19 -13
  1058. package/src/plugins/media/api/operations.ts +1873 -0
  1059. package/src/plugins/media/api/plugin.ts +211 -899
  1060. package/src/plugins/media/api/query-key-defs.ts +66 -4
  1061. package/src/plugins/media/api/serializers.ts +4 -2
  1062. package/src/plugins/media/api/storage-adapter.ts +22 -4
  1063. package/src/plugins/media/asset-url.ts +14 -0
  1064. package/src/plugins/media/client/components/media-picker/asset-card.tsx +105 -98
  1065. package/src/plugins/media/client/components/media-picker/folder-tree.tsx +82 -60
  1066. package/src/plugins/media/client/components/media-picker/index.tsx +235 -171
  1067. package/src/plugins/media/client/components/media-picker/upload-tab.tsx +2 -10
  1068. package/src/plugins/media/client/components/media-picker/url-tab.tsx +1 -8
  1069. package/src/plugins/media/client/components/pages/library-page.internal.tsx +103 -82
  1070. package/src/plugins/media/client/components/pages/library-page.tsx +4 -2
  1071. package/src/plugins/media/client/components/upload-permission-check.tsx +75 -0
  1072. package/src/plugins/media/client/constants.ts +2 -0
  1073. package/src/plugins/media/client/hooks/media-resource.ts +2 -1
  1074. package/src/plugins/media/client/hooks/use-media.tsx +292 -49
  1075. package/src/plugins/media/client/index.ts +16 -3
  1076. package/src/plugins/media/client/overrides.ts +6 -17
  1077. package/src/plugins/media/client/plugin.tsx +188 -123
  1078. package/src/plugins/media/client/upload.ts +170 -53
  1079. package/src/plugins/media/db.ts +8 -0
  1080. package/src/plugins/media/permissions.ts +61 -0
  1081. package/src/plugins/media/query-keys.ts +63 -19
  1082. package/src/plugins/media/types.ts +8 -2
  1083. package/src/plugins/open-api/__tests__/route-introspection.test.ts +277 -0
  1084. package/src/plugins/open-api/api/generator.ts +49 -8
  1085. package/src/plugins/open-api/api/plugin.ts +36 -14
  1086. package/src/plugins/route-docs/client/components/pages/docs-page.tsx +63 -23
  1087. package/src/plugins/route-docs/client/constants.ts +2 -0
  1088. package/src/plugins/route-docs/client/hooks.ts +23 -13
  1089. package/src/plugins/route-docs/client/index.ts +7 -1
  1090. package/src/plugins/route-docs/client/plugin.tsx +222 -145
  1091. package/src/plugins/route-docs/client/schema.ts +31 -0
  1092. package/src/plugins/route-docs/generator.ts +9 -5
  1093. package/src/plugins/ui-builder/__tests__/client-sweep.test.tsx +427 -48
  1094. package/src/plugins/ui-builder/client/components/page-renderer.tsx +58 -16
  1095. package/src/plugins/ui-builder/client/components/pages/page-builder-page.internal.tsx +47 -26
  1096. package/src/plugins/ui-builder/client/components/pages/page-builder-page.tsx +43 -8
  1097. package/src/plugins/ui-builder/client/components/pages/page-list-page.internal.tsx +38 -19
  1098. package/src/plugins/ui-builder/client/components/pages/page-list-page.tsx +8 -2
  1099. package/src/plugins/ui-builder/client/components/shared/default-error.tsx +2 -1
  1100. package/src/plugins/ui-builder/client/components/shared/page-wrapper.tsx +2 -1
  1101. package/src/plugins/ui-builder/client/constants.ts +2 -0
  1102. package/src/plugins/ui-builder/client/hooks/ui-builder-resource.ts +2 -1
  1103. package/src/plugins/ui-builder/client/index.ts +4 -1
  1104. package/src/plugins/ui-builder/client/overrides.ts +16 -21
  1105. package/src/plugins/ui-builder/client/plugin.tsx +119 -66
  1106. package/src/plugins/ui-builder/client/registry.ts +3 -5
  1107. package/src/plugins/ui-builder/types.ts +7 -4
  1108. package/src/plugins/utils.ts +5 -1
  1109. package/src/react-router/index.tsx +5 -0
  1110. package/src/react-router/layout.ts +43 -0
  1111. package/src/react-router/page.tsx +12 -5
  1112. package/src/react-router/router.tsx +1 -1
  1113. package/src/shared/auth-types.ts +19 -70
  1114. package/src/shared/entry-factories.ts +3 -3
  1115. package/src/shared/initial-identity.ts +73 -0
  1116. package/src/shared/list-state.ts +12 -0
  1117. package/src/shared/types.ts +1 -0
  1118. package/src/tanstack/index.tsx +5 -0
  1119. package/src/tanstack/layout.ts +36 -0
  1120. package/src/tanstack/page.tsx +7 -2
  1121. package/src/tanstack/router.tsx +1 -1
  1122. package/src/tanstack/server.ts +18 -0
  1123. package/src/types.ts +557 -65
  1124. package/dist/shared/stack.B8vdOMnQ.d.cts +0 -329
  1125. package/dist/shared/stack.BISAZ5LX.d.mts +0 -492
  1126. package/dist/shared/stack.BL5PvShn.d.mts +0 -193
  1127. package/dist/shared/stack.Be1QIHEn.d.cts +0 -23
  1128. package/dist/shared/stack.Be1QIHEn.d.mts +0 -23
  1129. package/dist/shared/stack.Be1QIHEn.d.ts +0 -23
  1130. package/dist/shared/stack.BjvOk_Bs.d.cts +0 -492
  1131. package/dist/shared/stack.BozPgbrZ.d.cts +0 -201
  1132. package/dist/shared/stack.BozPgbrZ.d.mts +0 -201
  1133. package/dist/shared/stack.BozPgbrZ.d.ts +0 -201
  1134. package/dist/shared/stack.BqTR6qi2.d.ts +0 -193
  1135. package/dist/shared/stack.BsmDN8r9.d.cts +0 -406
  1136. package/dist/shared/stack.C1ATQ3pd.d.ts +0 -416
  1137. package/dist/shared/stack.C4_gEENS.d.cts +0 -97
  1138. package/dist/shared/stack.C4_gEENS.d.mts +0 -97
  1139. package/dist/shared/stack.C4_gEENS.d.ts +0 -97
  1140. package/dist/shared/stack.C5Y5lViI.d.cts +0 -461
  1141. package/dist/shared/stack.C8SwdUz8.d.ts +0 -461
  1142. package/dist/shared/stack.CBsp9rDM.d.cts +0 -193
  1143. package/dist/shared/stack.CKGjOI3Z.d.cts +0 -840
  1144. package/dist/shared/stack.Cf-DbL1A.d.ts +0 -329
  1145. package/dist/shared/stack.CuI_-z-_.d.cts +0 -560
  1146. package/dist/shared/stack.D2RVkQD8.d.mts +0 -560
  1147. package/dist/shared/stack.DHTvwoNG.d.mts +0 -329
  1148. package/dist/shared/stack.DJaKVY7v.d.cts +0 -76
  1149. package/dist/shared/stack.DJaKVY7v.d.mts +0 -76
  1150. package/dist/shared/stack.DJaKVY7v.d.ts +0 -76
  1151. package/dist/shared/stack.DKZMaVr6.d.cts +0 -416
  1152. package/dist/shared/stack.DOzsgzkY.d.ts +0 -406
  1153. package/dist/shared/stack.DQq8DEIv.d.mts +0 -461
  1154. package/dist/shared/stack.DXrOtuek.d.ts +0 -560
  1155. package/dist/shared/stack.DZHEHd-S.d.mts +0 -840
  1156. package/dist/shared/stack.Dd-8shBE.d.ts +0 -492
  1157. package/dist/shared/stack.EOPVnJrF.d.cts +0 -39
  1158. package/dist/shared/stack.EOPVnJrF.d.mts +0 -39
  1159. package/dist/shared/stack.EOPVnJrF.d.ts +0 -39
  1160. package/dist/shared/stack.NGKtwA6S.d.mts +0 -406
  1161. package/dist/shared/stack.WELCDuMs.d.ts +0 -840
  1162. package/dist/shared/stack.aXdBOJAR.d.cts +0 -173
  1163. package/dist/shared/stack.aXdBOJAR.d.mts +0 -173
  1164. package/dist/shared/stack.aXdBOJAR.d.ts +0 -173
  1165. package/dist/shared/stack.oBokjN_J.d.mts +0 -416
  1166. package/dist/shared/{stack.D18Dq3ve.d.mts → stack.CKc_Bais.d.cts} +8 -8
  1167. package/dist/shared/{stack.D18Dq3ve.d.ts → stack.CKc_Bais.d.mts} +8 -8
  1168. package/dist/shared/{stack.D18Dq3ve.d.cts → stack.CKc_Bais.d.ts} +8 -8
@@ -0,0 +1,1366 @@
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
+ blogBackendPlugin,
13
+ BLOG_LIFECYCLE_HOOK_MIGRATIONS,
14
+ type BlogBackendHooks,
15
+ } from "../api";
16
+ import { blogPermissions } from "../permissions";
17
+ import type { Post } from "../types";
18
+
19
+ const memoryAdapter = (db: DatabaseDefinition) => createMemoryAdapter(db)({});
20
+
21
+ describe("Blog authorization inventory", () => {
22
+ it("records every removed lifecycle name and canonical replacement", () => {
23
+ expect(BLOG_LIFECYCLE_HOOK_MIGRATIONS).toEqual({
24
+ onBeforeNextPreviousPosts: "onBeforeGetNextPreviousPosts",
25
+ onPostsRead: "onAfterListPosts",
26
+ onPostCreated: "onAfterCreatePost",
27
+ onPostUpdated: "onAfterUpdatePost",
28
+ onPostDeleted: "onAfterDeletePost",
29
+ onNextPreviousPostsRead: "onAfterGetNextPreviousPosts",
30
+ onListPostsError: "onErrorListPosts",
31
+ onNextPreviousPostsError: "onErrorGetNextPreviousPosts",
32
+ onCreatePostError: "onErrorCreatePost",
33
+ onUpdatePostError: "onErrorUpdatePost",
34
+ onDeletePostError: "onErrorDeletePost",
35
+ });
36
+ });
37
+
38
+ it("covers every maintained HTTP and programmatic operation with a stable descriptor", () => {
39
+ const plugin = blogBackendPlugin();
40
+ const adapter = memoryAdapter(defineDb({}).use(plugin.dbPlugin));
41
+ const operations = plugin.operations?.(adapter);
42
+
43
+ expect(Object.keys(operations ?? {}).sort()).toEqual([
44
+ "createPost",
45
+ "deletePost",
46
+ "getNextPreviousPosts",
47
+ "listPosts",
48
+ "listTags",
49
+ "updatePost",
50
+ ]);
51
+ expect(
52
+ Object.fromEntries(
53
+ Object.entries(operations ?? {}).map(([key, operation]) => [
54
+ key,
55
+ operation.permission.id,
56
+ ]),
57
+ ),
58
+ ).toEqual({
59
+ listPosts: "blog:post.read",
60
+ createPost: "blog:post.create",
61
+ updatePost: "blog:post.update",
62
+ deletePost: "blog:post.delete",
63
+ getNextPreviousPosts: "blog:post.read",
64
+ listTags: "blog:tag.read",
65
+ });
66
+ expect(blogPermissions.post.read({ scope: "published" })).toMatchObject({
67
+ id: "blog:post.read",
68
+ });
69
+ expect(blogPermissions.post.create({ publish: "draft" })).toMatchObject({
70
+ id: "blog:post.create",
71
+ });
72
+ expect(
73
+ blogPermissions.post.update({
74
+ id: "post-1",
75
+ publish: "publish",
76
+ }),
77
+ ).toMatchObject({ id: "blog:post.update" });
78
+ expect(blogPermissions.tag.read()).toMatchObject({
79
+ id: "blog:tag.read",
80
+ });
81
+ });
82
+ });
83
+
84
+ const authorization = defineAuthorization({
85
+ identity: z.object({
86
+ id: z.string(),
87
+ role: z.enum(["user", "admin"]),
88
+ }),
89
+ permissions: [blogPermissions] as const,
90
+ rules: ({ blog }) => [
91
+ blog.post.read.when(({ identity, facts }) => {
92
+ if (facts.scope === "published") return true;
93
+ if (facts.scope === "post" && (!facts.exists || facts.published)) {
94
+ return true;
95
+ }
96
+ return (
97
+ identity?.role === "admin" ||
98
+ (facts.scope === "post" && identity?.id === facts.authorId)
99
+ );
100
+ }),
101
+ blog.post.create.when(
102
+ ({ identity, facts }) =>
103
+ identity !== null &&
104
+ (facts.publish === "draft" || identity.role === "admin"),
105
+ ),
106
+ blog.post.update.when(
107
+ ({ identity, facts }) =>
108
+ identity !== null &&
109
+ (identity.role === "admin" ||
110
+ (identity.id === facts.authorId && facts.publish === "unchanged")),
111
+ ),
112
+ blog.post.delete.when(
113
+ ({ identity, facts }) =>
114
+ identity !== null &&
115
+ (identity.role === "admin" || identity.id === facts.authorId),
116
+ ),
117
+ blog.tag.read.allow(),
118
+ ],
119
+ });
120
+
121
+ function createAuth(
122
+ getIdentity: (
123
+ request: Request,
124
+ ) =>
125
+ | { id: string; role: "user" | "admin" }
126
+ | null
127
+ | Promise<{ id: string; role: "user" | "admin" } | null> = (request) => {
128
+ const id = request.headers.get("x-user-id");
129
+ const role = request.headers.get("x-user-role");
130
+ if (!id || (role !== "user" && role !== "admin")) return null;
131
+ return { id, role };
132
+ },
133
+ ) {
134
+ return createServerAuth({
135
+ authorization,
136
+ getIdentity: ({ request }) => getIdentity(request),
137
+ });
138
+ }
139
+
140
+ function makeBackend(options?: {
141
+ hooks?: BlogBackendHooks;
142
+ auth?: ServerAuth<any>;
143
+ }) {
144
+ return createBackendStack({
145
+ basePath: "/api",
146
+ plugins: {
147
+ blog: blogBackendPlugin(options?.hooks ? { hooks: options.hooks } : {}),
148
+ },
149
+ adapter: memoryAdapter,
150
+ ...(options?.auth ? { auth: options.auth as never } : {}),
151
+ });
152
+ }
153
+
154
+ async function seedPost(
155
+ backend: ReturnType<typeof makeBackend>,
156
+ slug: string,
157
+ authorId: string | null = "author-1",
158
+ ) {
159
+ return backend.adapter.create<Post>({
160
+ model: "post",
161
+ data: {
162
+ ...(authorId ? { authorId } : {}),
163
+ title: "Authorization tracer",
164
+ slug,
165
+ content: "Content",
166
+ excerpt: "Excerpt",
167
+ published: true,
168
+ tags: [],
169
+ createdAt: new Date(),
170
+ updatedAt: new Date(),
171
+ },
172
+ });
173
+ }
174
+
175
+ async function postExists(backend: ReturnType<typeof makeBackend>, id: string) {
176
+ return !!(await backend.adapter.findOne<Post>({
177
+ model: "post",
178
+ where: [{ field: "id", value: id }],
179
+ }));
180
+ }
181
+
182
+ function deleteRequest(id: string, identity?: { id: string; role: string }) {
183
+ return new Request(`http://localhost/api/posts/${id}`, {
184
+ method: "DELETE",
185
+ headers: identity
186
+ ? { "x-user-id": identity.id, "x-user-role": identity.role }
187
+ : undefined,
188
+ });
189
+ }
190
+
191
+ function request(
192
+ path: string,
193
+ options?: {
194
+ method?: string;
195
+ identity?: { id: string; role: string };
196
+ body?: unknown;
197
+ },
198
+ ) {
199
+ const headers = new Headers();
200
+ if (options?.identity) {
201
+ headers.set("x-user-id", options.identity.id);
202
+ headers.set("x-user-role", options.identity.role);
203
+ }
204
+ if (options?.body !== undefined) {
205
+ headers.set("content-type", "application/json");
206
+ }
207
+ return new Request(`http://localhost/api${path}`, {
208
+ method: options?.method ?? "GET",
209
+ headers,
210
+ ...(options?.body !== undefined
211
+ ? { body: JSON.stringify(options.body) }
212
+ : {}),
213
+ });
214
+ }
215
+
216
+ const protectedBlogOperations = [
217
+ "listPosts",
218
+ "createPost",
219
+ "updatePost",
220
+ "deletePost",
221
+ ] as const;
222
+ type ProtectedBlogOperation = (typeof protectedBlogOperations)[number];
223
+
224
+ const protectedCreateInput = {
225
+ title: "Protected operation",
226
+ content: "Content",
227
+ excerpt: "Excerpt",
228
+ slug: "protected-operation",
229
+ published: false,
230
+ tags: [],
231
+ };
232
+
233
+ function protectedLifecycleHooks(events: string[]): BlogBackendHooks {
234
+ const observed = () => {
235
+ events.push("lifecycle");
236
+ };
237
+ return {
238
+ onBeforeListPosts: observed,
239
+ onErrorListPosts: observed,
240
+ onBeforeCreatePost: observed,
241
+ onErrorCreatePost: observed,
242
+ onBeforeUpdatePost: observed,
243
+ onErrorUpdatePost: observed,
244
+ onBeforeDeletePost: observed,
245
+ onErrorDeletePost: observed,
246
+ };
247
+ }
248
+
249
+ async function invokeProtectedOperation(
250
+ backend: ReturnType<typeof makeBackend>,
251
+ operation: ProtectedBlogOperation,
252
+ operationRequest: Request,
253
+ ) {
254
+ const api = backend.forRequest(operationRequest).operations.blog;
255
+ switch (operation) {
256
+ case "listPosts":
257
+ return api.listPosts({ published: false });
258
+ case "createPost":
259
+ return api.createPost(protectedCreateInput);
260
+ case "updatePost": {
261
+ const post = await seedPost(backend, "protected-update", "admin-1");
262
+ return api.updatePost({
263
+ id: post.id,
264
+ data: { ...protectedCreateInput, title: "Updated" },
265
+ });
266
+ }
267
+ case "deletePost": {
268
+ const post = await seedPost(backend, "protected-delete", "admin-1");
269
+ return api.deletePost({ id: post.id });
270
+ }
271
+ }
272
+ }
273
+
274
+ describe("Blog operation-first authorization", () => {
275
+ it.each(protectedBlogOperations)(
276
+ "keeps %s identity failures outside the lifecycle",
277
+ async (operation) => {
278
+ const events: string[] = [];
279
+ const backend = makeBackend({
280
+ auth: createAuth(() => {
281
+ throw new Error("session unavailable");
282
+ }),
283
+ hooks: protectedLifecycleHooks(events),
284
+ });
285
+
286
+ await expect(
287
+ invokeProtectedOperation(backend, operation, request("/protected")),
288
+ ).rejects.toThrow("session unavailable");
289
+ expect(events).toEqual([]);
290
+ },
291
+ );
292
+
293
+ it("keeps every protected operation's rule failure and missing rule outside the lifecycle", async () => {
294
+ const failingAuthorization = defineAuthorization({
295
+ identity: z.object({ id: z.string(), role: z.literal("admin") }),
296
+ permissions: [blogPermissions] as const,
297
+ rules: ({ blog }) => [
298
+ blog.post.read.when(() => {
299
+ throw new Error("policy unavailable");
300
+ }),
301
+ blog.post.create.when(() => {
302
+ throw new Error("policy unavailable");
303
+ }),
304
+ blog.post.update.when(() => {
305
+ throw new Error("policy unavailable");
306
+ }),
307
+ blog.post.delete.when(() => {
308
+ throw new Error("policy unavailable");
309
+ }),
310
+ ],
311
+ });
312
+ const missingRuleAuthorization = defineAuthorization({
313
+ identity: z.object({ id: z.string(), role: z.literal("admin") }),
314
+ permissions: [blogPermissions] as const,
315
+ rules: () => [],
316
+ });
317
+
318
+ for (const [authorizationDefinition, expected] of [
319
+ [failingAuthorization, "policy unavailable"],
320
+ [missingRuleAuthorization, { statusCode: 403 }],
321
+ ] as const) {
322
+ const events: string[] = [];
323
+ const backend = makeBackend({
324
+ auth: createServerAuth({
325
+ authorization: authorizationDefinition,
326
+ getIdentity: () => ({ id: "admin-1", role: "admin" as const }),
327
+ }),
328
+ hooks: protectedLifecycleHooks(events),
329
+ });
330
+ for (const operation of protectedBlogOperations) {
331
+ const result = expect(
332
+ invokeProtectedOperation(
333
+ backend,
334
+ operation,
335
+ request("/protected", {
336
+ identity: { id: "admin-1", role: "admin" },
337
+ }),
338
+ ),
339
+ ).rejects;
340
+ if (typeof expected === "string") {
341
+ await result.toThrow(expected);
342
+ } else {
343
+ await result.toMatchObject(expected);
344
+ }
345
+ }
346
+ expect(events).toEqual([]);
347
+ }
348
+ });
349
+
350
+ it.each(["listPosts", "createPost", "updatePost", "deletePost"] as const)(
351
+ "keeps %s trusted-fact loader failures outside the lifecycle",
352
+ async (operation) => {
353
+ const events: string[] = [];
354
+ const backend = makeBackend({
355
+ auth: createAuth(),
356
+ hooks: protectedLifecycleHooks(events),
357
+ });
358
+ let call: Promise<unknown>;
359
+ if (operation === "listPosts") {
360
+ vi.spyOn(backend.adapter, "findOne").mockRejectedValueOnce(
361
+ new Error("facts unavailable"),
362
+ );
363
+ call = backend
364
+ .forRequest(
365
+ request("/protected", {
366
+ identity: { id: "admin-1", role: "admin" },
367
+ }),
368
+ )
369
+ .operations.blog.listPosts({ slug: "protected-detail" });
370
+ } else if (operation === "createPost") {
371
+ vi.spyOn(
372
+ blogPermissions.post.create.schema,
373
+ "parse",
374
+ ).mockImplementationOnce(() => {
375
+ throw new Error("facts unavailable");
376
+ });
377
+ call = backend
378
+ .forRequest(
379
+ request("/protected", {
380
+ identity: { id: "admin-1", role: "admin" },
381
+ }),
382
+ )
383
+ .operations.blog.createPost(protectedCreateInput);
384
+ } else {
385
+ const post = await seedPost(backend, `facts-${operation}`, "admin-1");
386
+ vi.spyOn(backend.adapter, "findOne").mockRejectedValueOnce(
387
+ new Error("facts unavailable"),
388
+ );
389
+ const api = backend.forRequest(
390
+ request("/protected", {
391
+ identity: { id: "admin-1", role: "admin" },
392
+ }),
393
+ ).operations.blog;
394
+ call =
395
+ operation === "updatePost"
396
+ ? api.updatePost({
397
+ id: post.id,
398
+ data: { ...protectedCreateInput, title: "Updated" },
399
+ })
400
+ : api.deletePost({ id: post.id });
401
+ }
402
+
403
+ await expect(call).rejects.toThrow("facts unavailable");
404
+ expect(events).toEqual([]);
405
+ },
406
+ );
407
+
408
+ it("makes published reads and tags explicitly public while protecting drafts", async () => {
409
+ const events: string[] = [];
410
+ const backend = makeBackend({
411
+ auth: createAuth(),
412
+ hooks: {
413
+ onBeforeListPosts: (filter, context) => {
414
+ events.push(`before:${String(filter.published)}`);
415
+ expect(context).toMatchObject({
416
+ identity:
417
+ filter.published === true
418
+ ? null
419
+ : { id: "admin-1", role: "admin" },
420
+ facts: {
421
+ scope: filter.published === true ? "published" : "drafts",
422
+ },
423
+ input: filter,
424
+ request: expect.any(Request),
425
+ });
426
+ },
427
+ onAfterListPosts: (posts, _filter, context) => {
428
+ events.push(`after:${posts.length}`);
429
+ expect(context.result.items).toBe(posts);
430
+ },
431
+ onErrorListPosts: () => {
432
+ events.push("error");
433
+ },
434
+ },
435
+ });
436
+ await seedPost(backend, "public-post");
437
+ const draft = await seedPost(backend, "draft-post", "author-1");
438
+ await backend.adapter.update<Post>({
439
+ model: "post",
440
+ where: [{ field: "id", value: draft.id }],
441
+ update: { published: false },
442
+ });
443
+
444
+ const published = await backend.handler(request("/posts?published=true"));
445
+ expect(published.status).toBe(200);
446
+ expect((await published.json()).items).toHaveLength(1);
447
+ expect(events).toEqual(["before:true", "after:1"]);
448
+
449
+ events.length = 0;
450
+ const anonymousDrafts = await backend.handler(
451
+ request("/posts?published=false"),
452
+ );
453
+ const viewerDrafts = await backend.handler(
454
+ request("/posts?published=false", {
455
+ identity: { id: "viewer-1", role: "user" },
456
+ }),
457
+ );
458
+ expect(anonymousDrafts.status).toBe(401);
459
+ expect(viewerDrafts.status).toBe(403);
460
+ expect(events).toEqual([]);
461
+
462
+ const adminDrafts = await backend.handler(
463
+ request("/posts?published=false", {
464
+ identity: { id: "admin-1", role: "admin" },
465
+ }),
466
+ );
467
+ expect(adminDrafts.status).toBe(200);
468
+ expect((await adminDrafts.json()).items).toHaveLength(1);
469
+
470
+ const tags = await backend.handler(request("/tags"));
471
+ expect(tags.status).toBe(200);
472
+ expect(await tags.json()).toEqual([]);
473
+ });
474
+
475
+ it("derives post-detail visibility on the server", async () => {
476
+ const backend = makeBackend({ auth: createAuth() });
477
+ const draft = await seedPost(backend, "owner-draft", "author-1");
478
+ await backend.adapter.update<Post>({
479
+ model: "post",
480
+ where: [{ field: "id", value: draft.id }],
481
+ update: { published: false },
482
+ });
483
+
484
+ const anonymous = await backend.handler(request("/posts?slug=owner-draft"));
485
+ expect(
486
+ authorization.can(blogPermissions.post.read({ scope: "published" }), {
487
+ id: "viewer-1",
488
+ role: "user",
489
+ }),
490
+ ).toBe(true);
491
+ const viewer = await backend.handler(
492
+ request("/posts?slug=owner-draft", {
493
+ identity: { id: "viewer-1", role: "user" },
494
+ }),
495
+ );
496
+ expect(anonymous.status).toBe(401);
497
+ expect(viewer.status).toBe(403);
498
+
499
+ const ownerResult = await backend
500
+ .forRequest(
501
+ request("/posts?slug=owner-draft", {
502
+ identity: { id: "author-1", role: "user" },
503
+ }),
504
+ )
505
+ .operations.blog.listPosts({ slug: "owner-draft" });
506
+ expect(ownerResult.items).toHaveLength(1);
507
+
508
+ const missing = await backend.handler(request("/posts?slug=missing"));
509
+ expect(missing.status).toBe(200);
510
+ expect((await missing.json()).items).toEqual([]);
511
+ });
512
+
513
+ it("does not expose a draft created after a missing post detail is authorized", async () => {
514
+ let backend: ReturnType<typeof makeBackend>;
515
+ backend = makeBackend({
516
+ auth: createAuth(),
517
+ hooks: {
518
+ onBeforeListPosts: async (filter) => {
519
+ if (filter.slug !== "new-draft") return;
520
+ await backend.adapter.create<Post>({
521
+ model: "post",
522
+ data: {
523
+ title: "New draft",
524
+ slug: "new-draft",
525
+ content: "Private",
526
+ excerpt: "Private",
527
+ published: false,
528
+ tags: [],
529
+ createdAt: new Date(),
530
+ updatedAt: new Date(),
531
+ },
532
+ });
533
+ },
534
+ },
535
+ });
536
+
537
+ await expect(
538
+ backend
539
+ .forRequest(request("/posts?slug=new-draft"))
540
+ .operations.blog.listPosts({ slug: "new-draft" }),
541
+ ).rejects.toMatchObject({
542
+ statusCode: 409,
543
+ code: "POST_READ_STATE_CHANGED",
544
+ });
545
+ });
546
+
547
+ it("does not expose a post unpublished after public detail authorization", async () => {
548
+ let backend: ReturnType<typeof makeBackend>;
549
+ backend = makeBackend({
550
+ auth: createAuth(),
551
+ hooks: {
552
+ onBeforeListPosts: async (filter) => {
553
+ if (filter.slug !== "newly-private") return;
554
+ await backend.adapter.update<Post>({
555
+ model: "post",
556
+ where: [{ field: "slug", value: filter.slug }],
557
+ update: { published: false },
558
+ });
559
+ },
560
+ },
561
+ });
562
+ await seedPost(backend, "newly-private");
563
+
564
+ await expect(
565
+ backend
566
+ .forRequest(request("/posts?slug=newly-private"))
567
+ .operations.blog.listPosts({ slug: "newly-private" }),
568
+ ).rejects.toMatchObject({
569
+ statusCode: 409,
570
+ code: "POST_READ_STATE_CHANGED",
571
+ });
572
+ });
573
+
574
+ it("keeps public navigation and tags on the same HTTP/request/trusted operations", async () => {
575
+ const events: string[] = [];
576
+ const getIdentity = vi.fn(() => null);
577
+ const backend = makeBackend({
578
+ auth: createAuth(getIdentity),
579
+ hooks: {
580
+ onBeforeGetNextPreviousPosts: (_query, context) => {
581
+ events.push(`before:${context.facts.scope}`);
582
+ },
583
+ onAfterGetNextPreviousPosts: (_result, context) => {
584
+ events.push(`after:${context.facts.scope}`);
585
+ },
586
+ },
587
+ });
588
+ await seedPost(backend, "navigation-post");
589
+
590
+ const navigationPath = "/posts/next-previous?date=2030-01-01T00:00:00.000Z";
591
+ const navigationInput = { date: "2030-01-01T00:00:00.000Z" };
592
+ const navigation = await backend.handler(request(navigationPath));
593
+ expect(navigation.status).toBe(200);
594
+ expect(await navigation.json()).toMatchObject({
595
+ previous: { slug: "navigation-post" },
596
+ next: null,
597
+ });
598
+ expect(
599
+ await backend
600
+ .forRequest(request(navigationPath))
601
+ .operations.blog.getNextPreviousPosts(navigationInput),
602
+ ).toMatchObject({ previous: { slug: "navigation-post" }, next: null });
603
+
604
+ getIdentity.mockClear();
605
+ expect(
606
+ await backend.trusted.blog.getNextPreviousPosts(navigationInput),
607
+ ).toMatchObject({ previous: { slug: "navigation-post" }, next: null });
608
+ expect(events).toEqual([
609
+ "before:published",
610
+ "after:published",
611
+ "before:published",
612
+ "after:published",
613
+ "before:published",
614
+ "after:published",
615
+ ]);
616
+
617
+ const tagsResponse = await backend.handler(request("/tags"));
618
+ expect(tagsResponse.status).toBe(200);
619
+ expect(await tagsResponse.json()).toEqual([]);
620
+ expect(
621
+ await backend.forRequest(request("/tags")).operations.blog.listTags({}),
622
+ ).toEqual([]);
623
+ getIdentity.mockClear();
624
+ expect(await backend.trusted.blog.listTags({})).toEqual([]);
625
+
626
+ const trustedDrafts = await backend.trusted.blog.listPosts({
627
+ published: false,
628
+ });
629
+ expect(trustedDrafts.items).toEqual([]);
630
+ expect(getIdentity).not.toHaveBeenCalled();
631
+ });
632
+
633
+ it.each(["request", "trusted"] as const)(
634
+ "invokes every renamed Blog lifecycle through %s execution",
635
+ async (transport) => {
636
+ const events: string[] = [];
637
+ const record = (event: string) => {
638
+ events.push(event);
639
+ };
640
+ let failingOperation:
641
+ | "list"
642
+ | "navigation"
643
+ | "create"
644
+ | "update"
645
+ | "delete"
646
+ | undefined;
647
+ const rejectWhenFailing = (
648
+ operation: NonNullable<typeof failingOperation>,
649
+ ) => {
650
+ if (failingOperation !== operation) return;
651
+ events.push(`before-error:${operation}`);
652
+ throw new Error(`${operation} rejected`);
653
+ };
654
+ const backend = makeBackend({
655
+ auth: createAuth(),
656
+ hooks: {
657
+ onBeforeListPosts: () => rejectWhenFailing("list"),
658
+ onAfterListPosts: () => record("after:list"),
659
+ onErrorListPosts: () => record("error:list"),
660
+ onBeforeGetNextPreviousPosts: () => {
661
+ events.push("before:navigation");
662
+ rejectWhenFailing("navigation");
663
+ },
664
+ onAfterGetNextPreviousPosts: () => record("after:navigation"),
665
+ onErrorGetNextPreviousPosts: () => record("error:navigation"),
666
+ onBeforeCreatePost: () => rejectWhenFailing("create"),
667
+ onAfterCreatePost: () => record("after:create"),
668
+ onErrorCreatePost: () => record("error:create"),
669
+ onBeforeUpdatePost: () => rejectWhenFailing("update"),
670
+ onAfterUpdatePost: () => record("after:update"),
671
+ onErrorUpdatePost: () => record("error:update"),
672
+ onBeforeDeletePost: () => rejectWhenFailing("delete"),
673
+ onAfterDeletePost: () => record("after:delete"),
674
+ onErrorDeletePost: () => record("error:delete"),
675
+ },
676
+ });
677
+ const api =
678
+ transport === "request"
679
+ ? backend.forRequest(
680
+ request("/lifecycle", {
681
+ identity: { id: "author-1", role: "user" },
682
+ }),
683
+ ).operations.blog
684
+ : backend.trusted.blog;
685
+ const postInput = {
686
+ title: "Lifecycle post",
687
+ content: "Content",
688
+ excerpt: "Excerpt",
689
+ slug: `lifecycle-${transport}`,
690
+ published: false,
691
+ tags: [],
692
+ };
693
+
694
+ await api.listPosts({ published: true });
695
+ await api.getNextPreviousPosts({ date: "2030-01-01T00:00:00.000Z" });
696
+ const created = await api.createPost(postInput);
697
+ await api.updatePost({
698
+ id: created.id,
699
+ data: { ...postInput, title: "Lifecycle post updated" },
700
+ });
701
+ await api.deletePost({ id: created.id });
702
+
703
+ const errorTarget = await seedPost(
704
+ backend,
705
+ `lifecycle-error-${transport}`,
706
+ );
707
+ for (const [operation, invoke] of [
708
+ ["list", () => api.listPosts({ published: true })],
709
+ [
710
+ "navigation",
711
+ () =>
712
+ api.getNextPreviousPosts({
713
+ date: "2030-01-01T00:00:00.000Z",
714
+ }),
715
+ ],
716
+ [
717
+ "create",
718
+ () => api.createPost({ ...postInput, slug: `rejected-${transport}` }),
719
+ ],
720
+ [
721
+ "update",
722
+ () =>
723
+ api.updatePost({
724
+ id: errorTarget.id,
725
+ data: {
726
+ ...postInput,
727
+ title: "Rejected update",
728
+ published: true,
729
+ },
730
+ }),
731
+ ],
732
+ ["delete", () => api.deletePost({ id: errorTarget.id })],
733
+ ] as const) {
734
+ failingOperation = operation;
735
+ await expect(invoke()).rejects.toThrow(`${operation} rejected`);
736
+ }
737
+
738
+ expect(events).toEqual([
739
+ "after:list",
740
+ "before:navigation",
741
+ "after:navigation",
742
+ "after:create",
743
+ "after:update",
744
+ "after:delete",
745
+ "before-error:list",
746
+ "error:list",
747
+ "before:navigation",
748
+ "before-error:navigation",
749
+ "error:navigation",
750
+ "before-error:create",
751
+ "error:create",
752
+ "before-error:update",
753
+ "error:update",
754
+ "before-error:delete",
755
+ "error:delete",
756
+ ]);
757
+ },
758
+ );
759
+
760
+ it("uses trusted create/update facts across HTTP, request, and trusted entry points", async () => {
761
+ const events: string[] = [];
762
+ const backend = makeBackend({
763
+ auth: createAuth(),
764
+ hooks: {
765
+ onBeforeCreatePost: (_data, context) => {
766
+ events.push(`create:before:${context.identity?.id ?? "trusted"}`);
767
+ expect(context.facts).toEqual({
768
+ publish: context.input.published ? "published" : "draft",
769
+ });
770
+ },
771
+ onAfterCreatePost: (post, context) => {
772
+ events.push(`create:after:${post.authorId ?? "none"}`);
773
+ expect(context.result).toBe(post);
774
+ },
775
+ onBeforeUpdatePost: (_id, _data, context) => {
776
+ events.push(
777
+ `update:before:${context.identity?.id ?? "trusted"}:${context.facts.publish}`,
778
+ );
779
+ },
780
+ onAfterUpdatePost: (post, context) => {
781
+ events.push(`update:after:${String(post.published)}`);
782
+ expect(context.result).toBe(post);
783
+ },
784
+ },
785
+ });
786
+ const createBody = {
787
+ title: "Created through operation",
788
+ content: "Content",
789
+ excerpt: "Excerpt",
790
+ slug: "created-through-operation",
791
+ published: false,
792
+ tags: [],
793
+ };
794
+
795
+ const anonymousCreate = await backend.handler(
796
+ request("/posts", { method: "POST", body: createBody }),
797
+ );
798
+ expect(anonymousCreate.status).toBe(401);
799
+ expect(events).toEqual([]);
800
+
801
+ const owner = { id: "author-1", role: "user" as const };
802
+ const createdResponse = await backend.handler(
803
+ request("/posts", {
804
+ method: "POST",
805
+ identity: owner,
806
+ body: createBody,
807
+ }),
808
+ );
809
+ expect(createdResponse.status).toBe(200);
810
+ const created = (await createdResponse.json()) as Post;
811
+ expect(created).toMatchObject({
812
+ authorId: "author-1",
813
+ slug: "created-through-operation",
814
+ published: false,
815
+ });
816
+ expect(events).toEqual(["create:before:author-1", "create:after:author-1"]);
817
+
818
+ const requestCreated = await backend
819
+ .forRequest(request("/posts", { method: "POST", identity: owner }))
820
+ .operations.blog.createPost({
821
+ ...createBody,
822
+ slug: "request-created-operation",
823
+ });
824
+ expect(requestCreated.authorId).toBe("author-1");
825
+ const trustedCreated = await backend.trusted.blog.createPost({
826
+ ...createBody,
827
+ slug: "trusted-created-operation",
828
+ });
829
+ expect(trustedCreated.authorId).toBeUndefined();
830
+
831
+ const eventsBeforeDeniedCreate = events.length;
832
+ const ownerPublishedCreate = await backend.handler(
833
+ request("/posts", {
834
+ method: "POST",
835
+ identity: owner,
836
+ body: { ...createBody, slug: "owner-published", published: true },
837
+ }),
838
+ );
839
+ expect(
840
+ authorization.can(
841
+ blogPermissions.post.create({ publish: "draft" }),
842
+ owner,
843
+ ),
844
+ ).toBe(true);
845
+ expect(ownerPublishedCreate.status).toBe(403);
846
+ expect(events).toHaveLength(eventsBeforeDeniedCreate);
847
+
848
+ const adminPublishedCreate = await backend.handler(
849
+ request("/posts", {
850
+ method: "POST",
851
+ identity: { id: "admin-1", role: "admin" },
852
+ body: { ...createBody, slug: "admin-published", published: true },
853
+ }),
854
+ );
855
+ expect(adminPublishedCreate.status).toBe(200);
856
+ expect(await adminPublishedCreate.json()).toMatchObject({
857
+ authorId: "admin-1",
858
+ published: true,
859
+ });
860
+
861
+ const spoofedBrowserFacts = blogPermissions.post.update({
862
+ id: created.id,
863
+ authorId: "viewer-1",
864
+ publish: "unchanged",
865
+ });
866
+ expect(
867
+ authorization.can(spoofedBrowserFacts, {
868
+ id: "viewer-1",
869
+ role: "user",
870
+ }),
871
+ ).toBe(true);
872
+ const eventsBeforeAnonymousUpdate = events.length;
873
+ const anonymousUpdate = await backend.handler(
874
+ request(`/posts/${created.id}`, {
875
+ method: "PUT",
876
+ body: { ...createBody, title: "Anonymous edit" },
877
+ }),
878
+ );
879
+ expect(anonymousUpdate.status).toBe(401);
880
+ expect(events).toHaveLength(eventsBeforeAnonymousUpdate);
881
+ const httpOwnerUpdate = await backend.handler(
882
+ request(`/posts/${created.id}`, {
883
+ method: "PUT",
884
+ identity: owner,
885
+ body: { ...createBody, title: "HTTP owner edit" },
886
+ }),
887
+ );
888
+ expect(httpOwnerUpdate.status).toBe(200);
889
+ await expect(
890
+ backend
891
+ .forRequest(
892
+ request("/posts", {
893
+ identity: { id: "viewer-1", role: "user" },
894
+ }),
895
+ )
896
+ .operations.blog.updatePost({
897
+ id: created.id,
898
+ data: { ...createBody, title: "Spoofed" },
899
+ }),
900
+ ).rejects.toMatchObject({ statusCode: 403 });
901
+
902
+ await backend
903
+ .forRequest(request("/posts", { identity: owner }))
904
+ .operations.blog.updatePost({
905
+ id: created.id,
906
+ data: { ...createBody, title: "Owner edit" },
907
+ });
908
+ expect(events).toContain("update:before:author-1:unchanged");
909
+
910
+ await expect(
911
+ backend
912
+ .forRequest(request("/posts", { identity: owner }))
913
+ .operations.blog.updatePost({
914
+ id: created.id,
915
+ data: { ...createBody, published: true },
916
+ }),
917
+ ).rejects.toMatchObject({ statusCode: 403 });
918
+
919
+ await backend
920
+ .forRequest(
921
+ request("/posts", {
922
+ identity: { id: "admin-1", role: "admin" },
923
+ }),
924
+ )
925
+ .operations.blog.updatePost({
926
+ id: created.id,
927
+ data: { ...createBody, published: true },
928
+ });
929
+ expect(events).toContain("update:before:admin-1:publish");
930
+
931
+ await backend.trusted.blog.updatePost({
932
+ id: created.id,
933
+ data: createBody,
934
+ });
935
+ expect(events).toContain("update:before:trusted:unpublish");
936
+ });
937
+
938
+ it("does not apply a publish update when authoritative state changes after authorization", async () => {
939
+ let backend: ReturnType<typeof makeBackend>;
940
+ backend = makeBackend({
941
+ auth: createAuth(),
942
+ hooks: {
943
+ onBeforeUpdatePost: async (id) => {
944
+ await backend.adapter.update<Post>({
945
+ model: "post",
946
+ where: [{ field: "id", value: id }],
947
+ update: { published: false },
948
+ });
949
+ },
950
+ },
951
+ });
952
+ const post = await seedPost(backend, "publish-race", "author-1");
953
+
954
+ await expect(
955
+ backend
956
+ .forRequest(
957
+ request(`/posts/${post.id}`, {
958
+ identity: { id: "author-1", role: "user" },
959
+ }),
960
+ )
961
+ .operations.blog.updatePost({
962
+ id: post.id,
963
+ data: { ...protectedCreateInput, published: true },
964
+ }),
965
+ ).rejects.toMatchObject({
966
+ statusCode: 409,
967
+ code: "POST_STATE_CHANGED",
968
+ });
969
+ expect(
970
+ await backend.adapter.findOne<Post>({
971
+ model: "post",
972
+ where: [{ field: "id", value: post.id }],
973
+ }),
974
+ ).toMatchObject({ published: false });
975
+ });
976
+ });
977
+
978
+ describe("Blog delete one-rule authorization tracer", () => {
979
+ it("returns 401 for anonymous HTTP deletion and 403 for an authenticated denial", async () => {
980
+ const lifecycleEvents: string[] = [];
981
+ const backend = makeBackend({
982
+ auth: createAuth(),
983
+ hooks: {
984
+ onBeforeDeletePost: () => {
985
+ lifecycleEvents.push("before");
986
+ },
987
+ onAfterDeletePost: () => {
988
+ lifecycleEvents.push("after");
989
+ },
990
+ onErrorDeletePost: () => {
991
+ lifecycleEvents.push("error");
992
+ throw new Error("hook must not replace denial");
993
+ },
994
+ },
995
+ });
996
+ const anonymousPost = await seedPost(backend, "anonymous-post");
997
+ const authorlessPost = await seedPost(backend, "authorless-post", null);
998
+ const viewerPost = await seedPost(backend, "viewer-post");
999
+
1000
+ const anonymous = await backend.handler(deleteRequest(anonymousPost.id));
1001
+ const authorless = await backend.handler(deleteRequest(authorlessPost.id));
1002
+ const viewer = await backend.handler(
1003
+ deleteRequest(viewerPost.id, { id: "viewer-1", role: "user" }),
1004
+ );
1005
+
1006
+ expect(anonymous.status).toBe(401);
1007
+ expect(authorless.status).toBe(401);
1008
+ expect(viewer.status).toBe(403);
1009
+ expect(await postExists(backend, anonymousPost.id)).toBe(true);
1010
+ expect(await postExists(backend, authorlessPost.id)).toBe(true);
1011
+ expect(await postExists(backend, viewerPost.id)).toBe(true);
1012
+ expect(lifecycleEvents).toEqual([]);
1013
+ });
1014
+
1015
+ it("derives trusted facts and allows the owner through HTTP", async () => {
1016
+ const backend = makeBackend({ auth: createAuth() });
1017
+ const post = await seedPost(backend, "owned-post", "author-1");
1018
+
1019
+ const response = await backend.handler(
1020
+ deleteRequest(post.id, { id: "author-1", role: "user" }),
1021
+ );
1022
+
1023
+ expect(response.status).toBe(200);
1024
+ expect(await response.json()).toEqual({ success: true });
1025
+ expect(await postExists(backend, post.id)).toBe(false);
1026
+ });
1027
+
1028
+ it("ignores spoofed browser ownership facts", async () => {
1029
+ const backend = makeBackend({ auth: createAuth() });
1030
+ const post = await seedPost(backend, "spoofed-delete", "author-1");
1031
+ expect(
1032
+ authorization.can(
1033
+ blogPermissions.post.delete({
1034
+ id: post.id,
1035
+ authorId: "viewer-1",
1036
+ }),
1037
+ { id: "viewer-1", role: "user" },
1038
+ ),
1039
+ ).toBe(true);
1040
+
1041
+ const response = await backend.handler(
1042
+ deleteRequest(post.id, { id: "viewer-1", role: "user" }),
1043
+ );
1044
+ expect(response.status).toBe(403);
1045
+ expect(await postExists(backend, post.id)).toBe(true);
1046
+ });
1047
+
1048
+ it("powers the authorized request API with the same operation", async () => {
1049
+ let hookContext: unknown;
1050
+ const backend = makeBackend({
1051
+ auth: createAuth(),
1052
+ hooks: {
1053
+ onBeforeDeletePost: async (_id, context) => {
1054
+ hookContext = context;
1055
+ },
1056
+ },
1057
+ });
1058
+ const post = await seedPost(backend, "request-post", "author-1");
1059
+
1060
+ await expect(
1061
+ backend
1062
+ .forRequest(deleteRequest(post.id, { id: "viewer-1", role: "user" }))
1063
+ .operations.blog.deletePost({ id: post.id }),
1064
+ ).rejects.toMatchObject({ statusCode: 403 });
1065
+ expect(await postExists(backend, post.id)).toBe(true);
1066
+
1067
+ await backend
1068
+ .forRequest(deleteRequest(post.id, { id: "author-1", role: "user" }))
1069
+ .operations.blog.deletePost({ id: post.id });
1070
+ expect(hookContext).toMatchObject({
1071
+ identity: { id: "author-1", role: "user" },
1072
+ input: { id: post.id },
1073
+ facts: { id: post.id, authorId: "author-1" },
1074
+ request: expect.any(Request),
1075
+ });
1076
+ expect(await postExists(backend, post.id)).toBe(false);
1077
+ });
1078
+
1079
+ it("freezes lifecycle identity without corrupting the request auth cache", async () => {
1080
+ let beforeCalls = 0;
1081
+ const backend = makeBackend({
1082
+ auth: createAuth(),
1083
+ hooks: {
1084
+ onBeforeDeletePost: (_id, context) => {
1085
+ beforeCalls += 1;
1086
+ if (context.identity) {
1087
+ (context.identity as { id: string }).id = "author-2";
1088
+ }
1089
+ },
1090
+ },
1091
+ });
1092
+ const viewerPost = await seedPost(backend, "viewer-owned", "viewer-1");
1093
+ const otherPost = await seedPost(backend, "other-owned", "author-2");
1094
+ const request = deleteRequest(viewerPost.id, {
1095
+ id: "viewer-1",
1096
+ role: "user",
1097
+ });
1098
+ const requestApi = backend.forRequest(request).operations.blog;
1099
+
1100
+ await expect(requestApi.deletePost({ id: viewerPost.id })).rejects.toThrow(
1101
+ "Cannot assign to read only property",
1102
+ );
1103
+ await expect(
1104
+ requestApi.deletePost({ id: otherPost.id }),
1105
+ ).rejects.toMatchObject({ statusCode: 403 });
1106
+
1107
+ expect(beforeCalls).toBe(1);
1108
+ expect(await postExists(backend, viewerPost.id)).toBe(true);
1109
+ expect(await postExists(backend, otherPost.id)).toBe(true);
1110
+ });
1111
+
1112
+ it("keeps trusted calls validated and lifecycle-aware without resolving identity", async () => {
1113
+ const events: string[] = [];
1114
+ const getIdentity = vi.fn(() => ({
1115
+ id: "viewer-1",
1116
+ role: "user" as const,
1117
+ }));
1118
+ const backend = makeBackend({
1119
+ auth: createAuth(getIdentity),
1120
+ hooks: {
1121
+ onBeforeDeletePost: (id) => {
1122
+ events.push(`before:${id}`);
1123
+ },
1124
+ onAfterDeletePost: (id, context) => {
1125
+ events.push(`after:${id}`);
1126
+ expect(context).toMatchObject({
1127
+ identity: null,
1128
+ input: { id },
1129
+ facts: { id, authorId: "author-1" },
1130
+ result: { success: true },
1131
+ });
1132
+ },
1133
+ onErrorDeletePost: (_error, context) => {
1134
+ events.push(`error:${context.params?.id ?? "invalid"}`);
1135
+ },
1136
+ },
1137
+ });
1138
+ const post = await seedPost(backend, "trusted-post");
1139
+
1140
+ await backend.trusted.blog.deletePost({ id: post.id });
1141
+
1142
+ expect(events).toEqual([`before:${post.id}`, `after:${post.id}`]);
1143
+ expect(getIdentity).not.toHaveBeenCalled();
1144
+ expect(await postExists(backend, post.id)).toBe(false);
1145
+ await expect(
1146
+ backend.trusted.blog.deletePost({ id: 1 } as never),
1147
+ ).rejects.toBeInstanceOf(z.ZodError);
1148
+ expect(events).toEqual([`before:${post.id}`, `after:${post.id}`]);
1149
+ });
1150
+
1151
+ it("does not enter the lifecycle when trusted fact derivation fails", async () => {
1152
+ const onErrorDeletePost = vi.fn();
1153
+ const backend = makeBackend({
1154
+ hooks: { onErrorDeletePost },
1155
+ });
1156
+ const post = await seedPost(backend, "fact-failure");
1157
+ vi.spyOn(backend.adapter, "findOne").mockRejectedValueOnce(
1158
+ new Error("database unavailable"),
1159
+ );
1160
+
1161
+ await expect(
1162
+ backend.trusted.blog.deletePost({ id: post.id }),
1163
+ ).rejects.toThrow("database unavailable");
1164
+
1165
+ expect(onErrorDeletePost).not.toHaveBeenCalled();
1166
+ expect(await postExists(backend, post.id)).toBe(true);
1167
+ });
1168
+
1169
+ it("runs the error lifecycle after authorization without replacing the operation error", async () => {
1170
+ const events: string[] = [];
1171
+ const backend = makeBackend({
1172
+ auth: createAuth(),
1173
+ hooks: {
1174
+ onBeforeDeletePost: (_id, context) => {
1175
+ events.push(`before:${context.identity?.id}`);
1176
+ },
1177
+ onErrorDeletePost: (error, context) => {
1178
+ events.push(`error:${context.identity?.id}:${error.message}`);
1179
+ throw new Error("observability unavailable");
1180
+ },
1181
+ },
1182
+ });
1183
+ const post = await seedPost(backend, "execution-failure", "author-1");
1184
+ vi.spyOn(backend.adapter, "delete").mockRejectedValueOnce(
1185
+ new Error("delete unavailable"),
1186
+ );
1187
+
1188
+ await expect(
1189
+ backend
1190
+ .forRequest(deleteRequest(post.id, { id: "author-1", role: "user" }))
1191
+ .operations.blog.deletePost({ id: post.id }),
1192
+ ).rejects.toThrow("delete unavailable");
1193
+
1194
+ expect(events).toEqual([
1195
+ "before:author-1",
1196
+ "error:author-1:delete unavailable",
1197
+ ]);
1198
+ expect(await postExists(backend, post.id)).toBe(true);
1199
+ });
1200
+
1201
+ it("normalizes non-Error failures for the Blog error hook", async () => {
1202
+ let observedError: Error | undefined;
1203
+ const backend = makeBackend({
1204
+ hooks: {
1205
+ onErrorDeletePost: (error) => {
1206
+ observedError = error;
1207
+ },
1208
+ },
1209
+ });
1210
+ const post = await seedPost(backend, "non-error-failure");
1211
+ vi.spyOn(backend.adapter, "delete").mockRejectedValueOnce(
1212
+ "delete unavailable",
1213
+ );
1214
+
1215
+ await expect(backend.trusted.blog.deletePost({ id: post.id })).rejects.toBe(
1216
+ "delete unavailable",
1217
+ );
1218
+ expect(observedError).toBeInstanceOf(Error);
1219
+ expect(observedError?.message).toBe("delete unavailable");
1220
+ });
1221
+
1222
+ it("preserves allow-all behavior when authorization is omitted", async () => {
1223
+ const backend = makeBackend();
1224
+ const post = await seedPost(backend, "legacy-post");
1225
+
1226
+ const response = await backend.handler(deleteRequest(post.id));
1227
+
1228
+ expect(response.status).toBe(200);
1229
+ expect(await postExists(backend, post.id)).toBe(false);
1230
+ });
1231
+
1232
+ it("keeps identity and rule failures as errors", async () => {
1233
+ const identityLifecycleEvents: string[] = [];
1234
+ const identityFailure = makeBackend({
1235
+ auth: createAuth(() => {
1236
+ throw new Error("session unavailable");
1237
+ }),
1238
+ hooks: {
1239
+ onBeforeDeletePost: () => {
1240
+ identityLifecycleEvents.push("before");
1241
+ },
1242
+ onAfterDeletePost: () => {
1243
+ identityLifecycleEvents.push("after");
1244
+ },
1245
+ onErrorDeletePost: () => {
1246
+ identityLifecycleEvents.push("error");
1247
+ throw new Error("hook must not replace identity failure");
1248
+ },
1249
+ },
1250
+ });
1251
+ const identityFailurePost = await seedPost(
1252
+ identityFailure,
1253
+ "identity-failure",
1254
+ );
1255
+
1256
+ await expect(
1257
+ identityFailure
1258
+ .forRequest(deleteRequest(identityFailurePost.id))
1259
+ .operations.blog.deletePost({ id: identityFailurePost.id }),
1260
+ ).rejects.toThrow("session unavailable");
1261
+ expect(await postExists(identityFailure, identityFailurePost.id)).toBe(
1262
+ true,
1263
+ );
1264
+ expect(identityLifecycleEvents).toEqual([]);
1265
+
1266
+ const failingAuthorization = defineAuthorization({
1267
+ identity: z.object({ id: z.string(), role: z.literal("admin") }),
1268
+ permissions: [blogPermissions] as const,
1269
+ rules: ({ blog }) => [
1270
+ blog.post.delete.when(() => {
1271
+ throw new Error("policy unavailable");
1272
+ }),
1273
+ ],
1274
+ });
1275
+ const ruleLifecycleEvents: string[] = [];
1276
+ const ruleFailure = createBackendStack({
1277
+ basePath: "/api",
1278
+ plugins: {
1279
+ blog: blogBackendPlugin({
1280
+ hooks: {
1281
+ onBeforeDeletePost: () => {
1282
+ ruleLifecycleEvents.push("before");
1283
+ },
1284
+ onAfterDeletePost: () => {
1285
+ ruleLifecycleEvents.push("after");
1286
+ },
1287
+ onErrorDeletePost: () => {
1288
+ ruleLifecycleEvents.push("error");
1289
+ throw new Error("hook must not replace rule failure");
1290
+ },
1291
+ },
1292
+ }),
1293
+ },
1294
+ adapter: memoryAdapter,
1295
+ auth: createServerAuth({
1296
+ authorization: failingAuthorization,
1297
+ getIdentity: () => ({ id: "admin-1", role: "admin" as const }),
1298
+ }),
1299
+ });
1300
+ const ruleFailurePost = await seedPost(
1301
+ ruleFailure as ReturnType<typeof makeBackend>,
1302
+ "rule-failure",
1303
+ );
1304
+
1305
+ await expect(
1306
+ ruleFailure
1307
+ .forRequest(deleteRequest(ruleFailurePost.id))
1308
+ .operations.blog.deletePost({ id: ruleFailurePost.id }),
1309
+ ).rejects.toThrow("policy unavailable");
1310
+ expect(ruleLifecycleEvents).toEqual([]);
1311
+ expect(
1312
+ await postExists(
1313
+ ruleFailure as ReturnType<typeof makeBackend>,
1314
+ ruleFailurePost.id,
1315
+ ),
1316
+ ).toBe(true);
1317
+
1318
+ const missingRuleAuthorization = defineAuthorization({
1319
+ identity: z.object({ id: z.string(), role: z.literal("admin") }),
1320
+ permissions: [blogPermissions] as const,
1321
+ rules: () => [],
1322
+ });
1323
+ const missingRuleLifecycleEvents: string[] = [];
1324
+ const missingRule = createBackendStack({
1325
+ basePath: "/api",
1326
+ plugins: {
1327
+ blog: blogBackendPlugin({
1328
+ hooks: {
1329
+ onBeforeDeletePost: () => {
1330
+ missingRuleLifecycleEvents.push("before");
1331
+ },
1332
+ onAfterDeletePost: () => {
1333
+ missingRuleLifecycleEvents.push("after");
1334
+ },
1335
+ onErrorDeletePost: () => {
1336
+ missingRuleLifecycleEvents.push("error");
1337
+ throw new Error("hook must not replace missing-rule denial");
1338
+ },
1339
+ },
1340
+ }),
1341
+ },
1342
+ adapter: memoryAdapter,
1343
+ auth: createServerAuth({
1344
+ authorization: missingRuleAuthorization,
1345
+ getIdentity: () => ({ id: "admin-1", role: "admin" as const }),
1346
+ }),
1347
+ });
1348
+ const missingRulePost = await seedPost(
1349
+ missingRule as ReturnType<typeof makeBackend>,
1350
+ "missing-rule",
1351
+ );
1352
+
1353
+ await expect(
1354
+ missingRule
1355
+ .forRequest(deleteRequest(missingRulePost.id))
1356
+ .operations.blog.deletePost({ id: missingRulePost.id }),
1357
+ ).rejects.toMatchObject({ statusCode: 403 });
1358
+ expect(missingRuleLifecycleEvents).toEqual([]);
1359
+ expect(
1360
+ await postExists(
1361
+ missingRule as ReturnType<typeof makeBackend>,
1362
+ missingRulePost.id,
1363
+ ),
1364
+ ).toBe(true);
1365
+ });
1366
+ });