@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,1763 @@
1
+ 'use strict';
2
+
3
+ const api = require('@btst/stack/plugins/api');
4
+ const z = require('zod');
5
+ const schemaConverter = require('../../../../../ui/src/lib/schema-converter.cjs');
6
+ const plugins_cms_permissions = require('../../../../../../plugins/cms/permissions.cjs');
7
+ const schemas = require('../schemas.cjs');
8
+ const utils = require('../utils.cjs');
9
+ const getters = require('./getters.cjs');
10
+ const relations = require('./relations.cjs');
11
+
12
+ function operationContentType(contentType) {
13
+ return { ...contentType };
14
+ }
15
+ function operationContentItem(item) {
16
+ const {
17
+ parsedData,
18
+ contentType,
19
+ _relations,
20
+ ...serializedItem
21
+ } = item;
22
+ return {
23
+ ...serializedItem,
24
+ parsedData,
25
+ ...contentType ? { contentType: operationContentType(contentType) } : {}
26
+ };
27
+ }
28
+ function operationContentList(result) {
29
+ return {
30
+ items: result.items.map(operationContentItem),
31
+ total: result.total,
32
+ ...result.limit !== void 0 ? { limit: result.limit } : {},
33
+ ...result.offset !== void 0 ? { offset: result.offset } : {}
34
+ };
35
+ }
36
+ const JSONValueSchema = z.z.lazy(
37
+ () => z.z.union([
38
+ z.z.string(),
39
+ z.z.number(),
40
+ z.z.boolean(),
41
+ z.z.null(),
42
+ z.z.array(JSONValueSchema),
43
+ z.z.record(z.z.string(), JSONValueSchema)
44
+ ])
45
+ );
46
+ const CMSDataSchema = z.z.record(
47
+ z.z.string(),
48
+ JSONValueSchema
49
+ );
50
+ const EmptyInputSchema = z.z.object({});
51
+ const CMSContentTypeParamsSchema = z.z.object({
52
+ slug: z.z.string().min(1)
53
+ });
54
+ const CMSContentItemParamsSchema = z.z.object({
55
+ typeSlug: z.z.string().min(1),
56
+ id: z.z.string().min(1)
57
+ });
58
+ const CMSCreateContentItemBodySchema = z.z.object({
59
+ slug: z.z.string().min(1),
60
+ data: CMSDataSchema
61
+ });
62
+ const CMSUpdateContentItemBodySchema = z.z.object({
63
+ slug: z.z.string().min(1).optional(),
64
+ data: CMSDataSchema.optional()
65
+ });
66
+ const ListContentTypesInputSchema = EmptyInputSchema;
67
+ const GetContentTypeInputSchema = CMSContentTypeParamsSchema;
68
+ const GetContentItemInputSchema = CMSContentItemParamsSchema;
69
+ const CreateContentItemInputSchema = z.z.object({
70
+ typeSlug: z.z.string().min(1),
71
+ body: CMSCreateContentItemBodySchema
72
+ });
73
+ const UpdateContentItemInputSchema = z.z.object({
74
+ typeSlug: z.z.string().min(1),
75
+ id: z.z.string().min(1),
76
+ body: CMSUpdateContentItemBodySchema
77
+ });
78
+ const DeleteContentItemInputSchema = CMSContentItemParamsSchema;
79
+ class CMSOperationError extends api.OperationHttpError {
80
+ constructor(statusCode, message, code = "CMS_OPERATION_ERROR", issues) {
81
+ super(statusCode, message, code, issues);
82
+ this.name = "CMSOperationError";
83
+ }
84
+ }
85
+ function normalizeOperationError(error, fallback) {
86
+ if (error instanceof Error) return error;
87
+ return new Error(typeof error === "string" ? error : fallback, {
88
+ cause: error
89
+ });
90
+ }
91
+ async function runBeforeHook(hook, defaultMessage) {
92
+ if (!hook) return;
93
+ try {
94
+ await hook();
95
+ } catch (error) {
96
+ throw new CMSOperationError(
97
+ 403,
98
+ error instanceof Error ? error.message : defaultMessage,
99
+ "HOOK_DENIED"
100
+ );
101
+ }
102
+ }
103
+ function requestFields(context) {
104
+ return {
105
+ ...context.request ? { request: context.request, headers: context.request.headers } : {},
106
+ ...context.identity ? { userId: context.identity.id } : {}
107
+ };
108
+ }
109
+ function createContext(context) {
110
+ return Object.freeze({
111
+ ...context,
112
+ typeSlug: context.facts.contentType,
113
+ body: context.input.body,
114
+ ...requestFields(context)
115
+ });
116
+ }
117
+ function updateContext(context) {
118
+ return Object.freeze({
119
+ ...context,
120
+ typeSlug: context.facts.contentType,
121
+ params: Object.freeze({
122
+ typeSlug: context.facts.contentType,
123
+ id: context.facts.recordId
124
+ }),
125
+ body: context.input.body,
126
+ ...requestFields(context)
127
+ });
128
+ }
129
+ function deleteContext(context) {
130
+ return Object.freeze({
131
+ ...context,
132
+ typeSlug: context.facts.contentType,
133
+ params: Object.freeze({
134
+ typeSlug: context.facts.contentType,
135
+ id: context.facts.recordId
136
+ }),
137
+ ...requestFields(context)
138
+ });
139
+ }
140
+ function genericContext(context, typeSlug) {
141
+ return Object.freeze({
142
+ ...context,
143
+ ...typeSlug ? { typeSlug } : {},
144
+ ...requestFields(context)
145
+ });
146
+ }
147
+ function operationErrorContext(context, error) {
148
+ return Object.freeze({ ...context, error });
149
+ }
150
+ function getContentTypeZodSchema(contentType) {
151
+ return schemaConverter.formSchemaToZod(JSON.parse(contentType.jsonSchema));
152
+ }
153
+ async function getContentTypeOrThrow(adapter, ensureSynced, slug, message = "Content type not found") {
154
+ await ensureSynced();
155
+ const contentType = await adapter.findOne({
156
+ model: "contentType",
157
+ where: [{ field: "slug", value: slug, operator: "eq" }]
158
+ });
159
+ if (!contentType) {
160
+ throw new CMSOperationError(404, message, "CONTENT_TYPE_NOT_FOUND");
161
+ }
162
+ return contentType;
163
+ }
164
+ async function getRecordOrThrow(adapter, ensureSynced, typeSlug, id) {
165
+ await ensureSynced();
166
+ const item = await adapter.findOne({
167
+ model: "contentItem",
168
+ where: [{ field: "id", value: id, operator: "eq" }],
169
+ join: { contentType: true }
170
+ });
171
+ if (!item || item.contentType?.slug !== typeSlug) {
172
+ throw new CMSOperationError(
173
+ 404,
174
+ "Content item not found",
175
+ "RECORD_NOT_FOUND"
176
+ );
177
+ }
178
+ return item;
179
+ }
180
+ function recordFacts(item) {
181
+ if (!item.contentType) {
182
+ throw new CMSOperationError(
183
+ 500,
184
+ "Content item is missing its content type",
185
+ "CONTENT_TYPE_JOIN_MISSING"
186
+ );
187
+ }
188
+ return {
189
+ contentType: item.contentType.slug,
190
+ scope: "record",
191
+ recordId: item.id,
192
+ ...item.authorId ? { authorId: item.authorId } : {}
193
+ };
194
+ }
195
+ function collectionFacts(contentType) {
196
+ return { contentType, scope: "collection" };
197
+ }
198
+ function assertRecordFacts(item, facts) {
199
+ if (!facts.recordId || item.id !== facts.recordId || item.contentType?.slug !== facts.contentType || (item.authorId ?? void 0) !== facts.authorId) {
200
+ throw staleRecordError();
201
+ }
202
+ }
203
+ const AFFECTED_ROW_KEYS = [
204
+ "rowCount",
205
+ "affectedRows",
206
+ "rowsAffected",
207
+ "changes",
208
+ "numUpdatedRows"
209
+ ];
210
+ function hasPositiveCount(value) {
211
+ if (typeof value === "number") return Number.isFinite(value) && value > 0;
212
+ if (typeof value === "bigint") return value > 0n;
213
+ return false;
214
+ }
215
+ function didUpdateContentItem(result, expectedId) {
216
+ if (typeof result === "number" || typeof result === "bigint") {
217
+ return hasPositiveCount(result);
218
+ }
219
+ if (!result || typeof result !== "object") return false;
220
+ const record = result;
221
+ if ("count" in record) return hasPositiveCount(record.count);
222
+ if (Array.isArray(result)) {
223
+ return result.length > 0 && didUpdateContentItem(result[0], expectedId);
224
+ }
225
+ for (const key of AFFECTED_ROW_KEYS) {
226
+ if (key in record) return hasPositiveCount(record[key]);
227
+ }
228
+ if ("meta" in record) {
229
+ const meta = record.meta;
230
+ return Boolean(
231
+ meta && typeof meta === "object" && "changes" in meta && hasPositiveCount(meta.changes)
232
+ );
233
+ }
234
+ return record.id === expectedId;
235
+ }
236
+ function staleRecordError() {
237
+ return new CMSOperationError(
238
+ 409,
239
+ "Content item changed while authorization was being evaluated. Retry the operation.",
240
+ "RECORD_STATE_CHANGED"
241
+ );
242
+ }
243
+ function assertRecordSnapshot(current, expected) {
244
+ if (current.id !== expected.id || current.contentTypeId !== expected.contentTypeId || current.contentType?.slug !== expected.contentType?.slug || (current.authorId ?? void 0) !== (expected.authorId ?? void 0) || current.slug !== expected.slug || current.data !== expected.data || current.updatedAt.getTime() !== expected.updatedAt.getTime()) {
245
+ throw staleRecordError();
246
+ }
247
+ }
248
+ async function planRelatedItem(adapter, targetContentType, slug, data, authorId) {
249
+ const validation = getContentTypeZodSchema(targetContentType).safeParse(data);
250
+ if (!validation.success) {
251
+ throw new CMSOperationError(
252
+ 400,
253
+ `Validation failed for new ${targetContentType.slug}`,
254
+ "RELATED_RECORD_VALIDATION_FAILED",
255
+ validation.error.issues
256
+ );
257
+ }
258
+ const existing = await adapter.findOne({
259
+ model: "contentItem",
260
+ where: [
261
+ {
262
+ field: "contentTypeId",
263
+ value: targetContentType.id,
264
+ operator: "eq"
265
+ },
266
+ { field: "slug", value: slug, operator: "eq" }
267
+ ]
268
+ });
269
+ if (existing) {
270
+ throw relatedRecordSlugConflictError();
271
+ }
272
+ const now = /* @__PURE__ */ new Date();
273
+ return {
274
+ id: globalThis.crypto.randomUUID(),
275
+ contentTypeId: targetContentType.id,
276
+ slug,
277
+ data: JSON.stringify(validation.data),
278
+ ...authorId ? { authorId } : {},
279
+ createdAt: now,
280
+ updatedAt: now
281
+ };
282
+ }
283
+ function relatedRecordSlugConflictError() {
284
+ return new CMSOperationError(
285
+ 409,
286
+ "Inline related record could not be created because its slug is unavailable.",
287
+ "RELATED_RECORD_SLUG_CONFLICT"
288
+ );
289
+ }
290
+ async function planRelationsInData(adapter, contentType, data, ensureSynced, authorId) {
291
+ const relationFields = relations.extractRelationFields(contentType);
292
+ const processedData = { ...data };
293
+ const relationIds = {};
294
+ const newItems = [];
295
+ const plannedSlugs = /* @__PURE__ */ new Set();
296
+ for (const [fieldName, relationConfig] of Object.entries(relationFields)) {
297
+ if (!(fieldName in data)) continue;
298
+ const fieldValue = data[fieldName];
299
+ if (!fieldValue) {
300
+ relationIds[fieldName] = [];
301
+ continue;
302
+ }
303
+ const targetContentType = await getContentTypeOrThrow(
304
+ adapter,
305
+ ensureSynced,
306
+ relationConfig.targetType,
307
+ `Target content type "${relationConfig.targetType}" not found for relation field "${fieldName}"`
308
+ );
309
+ const ids = [];
310
+ if (relationConfig.type === "belongsTo") {
311
+ const value = fieldValue;
312
+ if (relations.isNewRelationValue(value)) {
313
+ const item = await resolvePlannedRelatedItem(
314
+ adapter,
315
+ targetContentType,
316
+ value.data,
317
+ authorId,
318
+ plannedSlugs,
319
+ newItems
320
+ );
321
+ ids.push(item.id);
322
+ processedData[fieldName] = { id: item.id };
323
+ } else if (relations.isExistingRelationValue(value)) {
324
+ ids.push(value.id);
325
+ }
326
+ } else {
327
+ const values = Array.isArray(fieldValue) ? fieldValue : [];
328
+ const processedValues = [];
329
+ for (const value of values) {
330
+ if (relations.isNewRelationValue(value)) {
331
+ const item = await resolvePlannedRelatedItem(
332
+ adapter,
333
+ targetContentType,
334
+ value.data,
335
+ authorId,
336
+ plannedSlugs,
337
+ newItems
338
+ );
339
+ ids.push(item.id);
340
+ processedValues.push({ id: item.id });
341
+ } else if (relations.isExistingRelationValue(value)) {
342
+ ids.push(value.id);
343
+ processedValues.push({ id: value.id });
344
+ }
345
+ }
346
+ processedData[fieldName] = processedValues;
347
+ }
348
+ relationIds[fieldName] = ids;
349
+ }
350
+ return { processedData, relationIds, newItems };
351
+ }
352
+ async function resolvePlannedRelatedItem(adapter, targetContentType, data, authorId, plannedSlugs, newItems) {
353
+ const slug = utils.slugify(
354
+ data.slug || data.name || data.title || `item-${Date.now()}`
355
+ );
356
+ const key = `${targetContentType.id}\0${slug}`;
357
+ if (plannedSlugs.has(key)) throw relatedRecordSlugConflictError();
358
+ const planned = await planRelatedItem(
359
+ adapter,
360
+ targetContentType,
361
+ slug,
362
+ data,
363
+ authorId
364
+ );
365
+ plannedSlugs.add(key);
366
+ newItems.push(planned);
367
+ return planned;
368
+ }
369
+ async function applyRelationWritePlan(adapter, plan) {
370
+ for (const item of plan.newItems) {
371
+ const existing = await adapter.findOne({
372
+ model: "contentItem",
373
+ where: [
374
+ {
375
+ field: "contentTypeId",
376
+ value: item.contentTypeId,
377
+ operator: "eq"
378
+ },
379
+ { field: "slug", value: item.slug, operator: "eq" }
380
+ ]
381
+ });
382
+ if (existing) throw staleRecordError();
383
+ await adapter.create({
384
+ model: "contentItem",
385
+ data: item
386
+ });
387
+ }
388
+ }
389
+ function relationFilterSnapshot(sourceContentType, fieldName, relation, targetContentType) {
390
+ return JSON.stringify([
391
+ sourceContentType.id,
392
+ sourceContentType.slug,
393
+ fieldName,
394
+ relation.type,
395
+ targetContentType.id,
396
+ targetContentType.slug
397
+ ]);
398
+ }
399
+ async function deriveRelationFilterAuthorization(adapter, ensureSynced, sourceContentType, fieldName, targetId) {
400
+ const relation = relations.extractRelationFields(sourceContentType)[fieldName];
401
+ if (!relation) {
402
+ throw new CMSOperationError(
403
+ 404,
404
+ `Relation field "${fieldName}" was not found on content type "${sourceContentType.slug}".`,
405
+ "RELATION_FIELD_NOT_FOUND"
406
+ );
407
+ }
408
+ const targetContentType = await getContentTypeOrThrow(
409
+ adapter,
410
+ ensureSynced,
411
+ relation.targetType,
412
+ `Target content type "${relation.targetType}" not found for relation field "${fieldName}"`
413
+ );
414
+ const target = await getRecordOrThrow(
415
+ adapter,
416
+ ensureSynced,
417
+ targetContentType.slug,
418
+ targetId
419
+ );
420
+ const targetFacts = recordFacts(target);
421
+ return {
422
+ permission: plugins_cms_permissions.cmsPermissions.record.read(targetFacts),
423
+ snapshot: relationFilterSnapshot(
424
+ sourceContentType,
425
+ fieldName,
426
+ relation,
427
+ targetContentType
428
+ ),
429
+ targetFacts
430
+ };
431
+ }
432
+ function relationTargetSnapshot(facts) {
433
+ return JSON.stringify([
434
+ facts.contentType,
435
+ facts.recordId,
436
+ facts.authorId ?? null
437
+ ]);
438
+ }
439
+ async function deriveRelationWriteAuthorization(adapter, contentType, data, ensureSynced, expectedSchemaSnapshot) {
440
+ const permissions = [];
441
+ const snapshot = [];
442
+ const targets = [];
443
+ const seenCreateTargetTypes = /* @__PURE__ */ new Set();
444
+ const seenReadTargets = /* @__PURE__ */ new Set();
445
+ const resolvedRelations = [];
446
+ for (const [fieldName, relationConfig] of Object.entries(
447
+ relations.extractRelationFields(contentType)
448
+ )) {
449
+ if (!(fieldName in data)) continue;
450
+ const value = data[fieldName];
451
+ const values = relationConfig.type === "belongsTo" ? [value] : Array.isArray(value) ? value : [];
452
+ const targetContentType = await getContentTypeOrThrow(
453
+ adapter,
454
+ ensureSynced,
455
+ relationConfig.targetType,
456
+ `Target content type "${relationConfig.targetType}" not found for relation field "${fieldName}"`
457
+ );
458
+ snapshot.push(
459
+ JSON.stringify([
460
+ fieldName,
461
+ relationConfig.type,
462
+ targetContentType.id,
463
+ targetContentType.slug
464
+ ])
465
+ );
466
+ resolvedRelations.push({ values, targetContentType });
467
+ }
468
+ snapshot.sort();
469
+ if (expectedSchemaSnapshot) {
470
+ assertRelationSchemaSnapshot(expectedSchemaSnapshot, snapshot);
471
+ }
472
+ for (const { values, targetContentType } of resolvedRelations) {
473
+ if (values.some(relations.isNewRelationValue) && !seenCreateTargetTypes.has(targetContentType.slug)) {
474
+ seenCreateTargetTypes.add(targetContentType.slug);
475
+ permissions.push(
476
+ plugins_cms_permissions.cmsPermissions.record.create({ contentType: targetContentType.slug })
477
+ );
478
+ }
479
+ for (const reference of values) {
480
+ if (relations.isNewRelationValue(reference) || !relations.isExistingRelationValue(reference)) {
481
+ continue;
482
+ }
483
+ const target = await getRecordOrThrow(
484
+ adapter,
485
+ ensureSynced,
486
+ targetContentType.slug,
487
+ reference.id
488
+ );
489
+ const facts = recordFacts(target);
490
+ const targetKey = relationTargetSnapshot(facts);
491
+ if (seenReadTargets.has(targetKey)) continue;
492
+ seenReadTargets.add(targetKey);
493
+ targets.push(facts);
494
+ permissions.push(plugins_cms_permissions.cmsPermissions.record.read(facts));
495
+ }
496
+ }
497
+ return {
498
+ permissions,
499
+ snapshot,
500
+ targets: targets.sort(
501
+ (left, right) => relationTargetSnapshot(left).localeCompare(relationTargetSnapshot(right))
502
+ )
503
+ };
504
+ }
505
+ function assertRelationSchemaSnapshot(authorized, current) {
506
+ if (JSON.stringify(authorized) !== JSON.stringify(current)) {
507
+ throw relationSchemaChangedError();
508
+ }
509
+ }
510
+ function assertRelationWriteAuthorization(authorized, current) {
511
+ assertRelationSchemaSnapshot(authorized.snapshot, current.snapshot);
512
+ if (JSON.stringify(authorized.targets.map(relationTargetSnapshot)) !== JSON.stringify(current.targets.map(relationTargetSnapshot))) {
513
+ throw staleRecordError();
514
+ }
515
+ }
516
+ function relationSchemaChangedError() {
517
+ return new CMSOperationError(
518
+ 409,
519
+ "Content type relations changed while authorization was being evaluated. Retry the operation.",
520
+ "RELATION_SCHEMA_CHANGED"
521
+ );
522
+ }
523
+ async function getPopulatedRelationSnapshot(adapter, sourceId) {
524
+ const relations = await adapter.findMany({
525
+ model: "contentRelation",
526
+ where: [{ field: "sourceId", value: sourceId, operator: "eq" }]
527
+ });
528
+ const targets = [];
529
+ const seenTargets = /* @__PURE__ */ new Set();
530
+ for (const relation of relations) {
531
+ if (seenTargets.has(relation.targetId)) continue;
532
+ const target = await adapter.findOne({
533
+ model: "contentItem",
534
+ where: [
535
+ { field: "id", value: relation.targetId, operator: "eq" }
536
+ ],
537
+ join: { contentType: true }
538
+ });
539
+ if (!target) continue;
540
+ seenTargets.add(target.id);
541
+ targets.push({
542
+ item: getters.serializeContentItemWithType(target),
543
+ facts: recordFacts(target)
544
+ });
545
+ }
546
+ return {
547
+ relationKeys: relations.map((relation) => `${relation.fieldName}\0${relation.targetId}`).sort(),
548
+ targets: targets.sort(
549
+ (left, right) => (left.facts.recordId ?? "").localeCompare(right.facts.recordId ?? "")
550
+ )
551
+ };
552
+ }
553
+ function assertPopulatedRelationSnapshot(authorized, current) {
554
+ const factsKey = (facts) => JSON.stringify([facts.contentType, facts.recordId, facts.authorId ?? null]);
555
+ if (JSON.stringify(authorized.relationKeys) !== JSON.stringify(current.relationKeys) || JSON.stringify(authorized.targets.map(({ facts }) => factsKey(facts))) !== JSON.stringify(current.targets.map(({ facts }) => factsKey(facts)))) {
556
+ throw new CMSOperationError(
557
+ 409,
558
+ "Related content changed while authorization was being evaluated. Retry the operation.",
559
+ "RECORD_STATE_CHANGED"
560
+ );
561
+ }
562
+ }
563
+ function populatedRelationsFromSnapshot(snapshot) {
564
+ const targetsById = new Map(
565
+ snapshot.targets.map((target) => [target.facts.recordId, target.item])
566
+ );
567
+ const populated = {};
568
+ for (const relationKey of snapshot.relationKeys) {
569
+ const [fieldName, targetId] = relationKey.split("\0");
570
+ if (!fieldName || !targetId) continue;
571
+ const target = targetsById.get(targetId);
572
+ if (target) (populated[fieldName] ??= []).push(target);
573
+ }
574
+ return populated;
575
+ }
576
+ function inverseSourceKey(source) {
577
+ return JSON.stringify([
578
+ source.contentTypeId,
579
+ source.contentTypeSlug,
580
+ source.contentTypeName,
581
+ source.fieldName
582
+ ]);
583
+ }
584
+ async function deriveInverseSourceAuthorization(adapter, ensureSynced, targetType) {
585
+ await ensureSynced();
586
+ const permissions = [];
587
+ const sources = [];
588
+ const seenSourceTypes = /* @__PURE__ */ new Set();
589
+ for (const contentType of await adapter.findMany({
590
+ model: "contentType"
591
+ })) {
592
+ for (const [fieldName, relation] of Object.entries(
593
+ relations.extractRelationFields(contentType)
594
+ )) {
595
+ if (relation.type !== "belongsTo" || relation.targetType !== targetType) {
596
+ continue;
597
+ }
598
+ sources.push({
599
+ contentTypeId: contentType.id,
600
+ contentTypeSlug: contentType.slug,
601
+ contentTypeName: contentType.name,
602
+ fieldName
603
+ });
604
+ if (seenSourceTypes.has(contentType.slug)) continue;
605
+ seenSourceTypes.add(contentType.slug);
606
+ permissions.push(
607
+ plugins_cms_permissions.cmsPermissions.contentType.read({ contentType: contentType.slug })
608
+ );
609
+ }
610
+ }
611
+ sources.sort(
612
+ (left, right) => inverseSourceKey(left).localeCompare(inverseSourceKey(right))
613
+ );
614
+ return {
615
+ permissions,
616
+ snapshot: sources.map(inverseSourceKey),
617
+ sources
618
+ };
619
+ }
620
+ async function listRecordsForRelation(adapter, contentType, fieldName, targetId, limit, offset) {
621
+ const relations = await adapter.findMany({
622
+ model: "contentRelation",
623
+ where: [
624
+ { field: "targetId", value: targetId, operator: "eq" },
625
+ { field: "fieldName", value: fieldName, operator: "eq" }
626
+ ]
627
+ });
628
+ const ids = [...new Set(relations.map((relation) => relation.sourceId))];
629
+ const items = [];
630
+ for (const id of ids) {
631
+ const item = await adapter.findOne({
632
+ model: "contentItem",
633
+ where: [
634
+ { field: "id", value: id, operator: "eq" },
635
+ {
636
+ field: "contentTypeId",
637
+ value: contentType.id,
638
+ operator: "eq"
639
+ }
640
+ ],
641
+ join: { contentType: true }
642
+ });
643
+ if (item) items.push(item);
644
+ }
645
+ items.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
646
+ return {
647
+ items: items.slice(offset, offset + limit).map(getters.serializeContentItemWithType),
648
+ total: items.length,
649
+ limit,
650
+ offset
651
+ };
652
+ }
653
+ function createCMSOperations(adapter, options) {
654
+ const { ensureSynced, getContentTypesWithCounts, hooks } = options;
655
+ const populatedRelationSnapshots = /* @__PURE__ */ new WeakMap();
656
+ const relationWriteAuthorizationSnapshots = /* @__PURE__ */ new WeakMap();
657
+ const relationFilterAuthorizationSnapshots = /* @__PURE__ */ new WeakMap();
658
+ const inverseSourceAuthorizationSnapshots = /* @__PURE__ */ new WeakMap();
659
+ const inverseTargetAuthorizationSnapshots = /* @__PURE__ */ new WeakMap();
660
+ const contentTypeListSnapshots = /* @__PURE__ */ new WeakMap();
661
+ const assertCurrentRelationWriteAuthorization = async (currentAdapter, authorized, contentTypeSlug, data) => {
662
+ let current;
663
+ try {
664
+ const contentType = await getContentTypeOrThrow(
665
+ currentAdapter,
666
+ ensureSynced,
667
+ contentTypeSlug
668
+ );
669
+ current = await deriveRelationWriteAuthorization(
670
+ currentAdapter,
671
+ contentType,
672
+ data,
673
+ ensureSynced,
674
+ authorized.snapshot
675
+ );
676
+ } catch (error) {
677
+ if (error instanceof CMSOperationError) {
678
+ if (error.code === "CONTENT_TYPE_NOT_FOUND") {
679
+ throw relationSchemaChangedError();
680
+ }
681
+ if (error.code === "RECORD_NOT_FOUND") throw staleRecordError();
682
+ }
683
+ throw error;
684
+ }
685
+ assertRelationWriteAuthorization(authorized, current);
686
+ };
687
+ const recheckRelationWriteAuthorization = async (input, contentTypeSlug, data) => {
688
+ const authorized = relationWriteAuthorizationSnapshots.get(input);
689
+ relationWriteAuthorizationSnapshots.delete(input);
690
+ if (!authorized) {
691
+ throw new CMSOperationError(
692
+ 500,
693
+ "Relation authorization snapshot is unavailable.",
694
+ "AUTHORIZATION_SNAPSHOT_MISSING"
695
+ );
696
+ }
697
+ await assertCurrentRelationWriteAuthorization(
698
+ adapter,
699
+ authorized,
700
+ contentTypeSlug,
701
+ data
702
+ );
703
+ return authorized;
704
+ };
705
+ const recheckInverseSourceAuthorization = async (input, targetType) => {
706
+ const authorized = inverseSourceAuthorizationSnapshots.get(input);
707
+ inverseSourceAuthorizationSnapshots.delete(input);
708
+ if (!authorized) {
709
+ throw new CMSOperationError(
710
+ 500,
711
+ "Inverse relation authorization snapshot is unavailable.",
712
+ "AUTHORIZATION_SNAPSHOT_MISSING"
713
+ );
714
+ }
715
+ const current = await deriveInverseSourceAuthorization(
716
+ adapter,
717
+ ensureSynced,
718
+ targetType
719
+ );
720
+ assertRelationSchemaSnapshot(authorized, current.snapshot);
721
+ return current.sources;
722
+ };
723
+ const recheckRelationFilterAuthorization = async (input, sourceType, fieldName, targetId) => {
724
+ const authorized = relationFilterAuthorizationSnapshots.get(input);
725
+ relationFilterAuthorizationSnapshots.delete(input);
726
+ if (!authorized) {
727
+ throw new CMSOperationError(
728
+ 500,
729
+ "Relation-filter authorization snapshot is unavailable.",
730
+ "AUTHORIZATION_SNAPSHOT_MISSING"
731
+ );
732
+ }
733
+ let sourceContentType;
734
+ try {
735
+ sourceContentType = await getContentTypeOrThrow(
736
+ adapter,
737
+ ensureSynced,
738
+ sourceType
739
+ );
740
+ } catch (error) {
741
+ if (error instanceof CMSOperationError && error.code === "CONTENT_TYPE_NOT_FOUND") {
742
+ throw relationSchemaChangedError();
743
+ }
744
+ throw error;
745
+ }
746
+ const relation = relations.extractRelationFields(sourceContentType)[fieldName];
747
+ if (!relation) throw relationSchemaChangedError();
748
+ let targetContentType;
749
+ try {
750
+ targetContentType = await getContentTypeOrThrow(
751
+ adapter,
752
+ ensureSynced,
753
+ relation.targetType
754
+ );
755
+ } catch (error) {
756
+ if (error instanceof CMSOperationError && error.code === "CONTENT_TYPE_NOT_FOUND") {
757
+ throw relationSchemaChangedError();
758
+ }
759
+ throw error;
760
+ }
761
+ const currentSnapshot = relationFilterSnapshot(
762
+ sourceContentType,
763
+ fieldName,
764
+ relation,
765
+ targetContentType
766
+ );
767
+ if (authorized.snapshot !== currentSnapshot) {
768
+ throw relationSchemaChangedError();
769
+ }
770
+ let target;
771
+ try {
772
+ target = await getRecordOrThrow(
773
+ adapter,
774
+ ensureSynced,
775
+ targetContentType.slug,
776
+ targetId
777
+ );
778
+ } catch (error) {
779
+ if (error instanceof CMSOperationError && error.code === "RECORD_NOT_FOUND") {
780
+ throw staleRecordError();
781
+ }
782
+ throw error;
783
+ }
784
+ const currentFacts = recordFacts(target);
785
+ if (authorized.targetFacts.contentType !== currentFacts.contentType || authorized.targetFacts.recordId !== currentFacts.recordId || authorized.targetFacts.authorId !== currentFacts.authorId) {
786
+ throw staleRecordError();
787
+ }
788
+ return sourceContentType;
789
+ };
790
+ const recheckInverseTargetAuthorization = async (input, targetType, targetId) => {
791
+ const authorized = inverseTargetAuthorizationSnapshots.get(input);
792
+ if (!authorized || authorized.contentType !== targetType || authorized.recordId !== targetId) {
793
+ throw new CMSOperationError(
794
+ 500,
795
+ "Inverse-relation target authorization snapshot is unavailable.",
796
+ "AUTHORIZATION_SNAPSHOT_MISSING"
797
+ );
798
+ }
799
+ const current = await adapter.findOne({
800
+ model: "contentItem",
801
+ where: [{ field: "id", value: targetId, operator: "eq" }],
802
+ join: { contentType: true }
803
+ });
804
+ if (!current) throw staleRecordError();
805
+ assertRecordFacts(current, authorized);
806
+ };
807
+ const listQuerySchema = schemas.createListContentQuerySchema(options.maxPageSize);
808
+ const paginationSchema = z.z.object({
809
+ limit: z.z.coerce.number().min(1).max(options.maxPageSize ?? schemas.DEFAULT_MAX_PAGE_SIZE).optional().default(20),
810
+ offset: z.z.coerce.number().min(0).optional().default(0)
811
+ });
812
+ const ListContentItemsInputSchema = z.z.object({
813
+ typeSlug: z.z.string().min(1),
814
+ query: listQuerySchema
815
+ });
816
+ const ListContentByRelationInputSchema = z.z.object({
817
+ typeSlug: z.z.string().min(1),
818
+ query: z.z.object({ field: z.z.string().min(1), targetId: z.z.string().min(1) }).merge(paginationSchema)
819
+ });
820
+ const GetInverseRelationsInputSchema = z.z.object({
821
+ slug: z.z.string().min(1),
822
+ query: z.z.object({ itemId: z.z.string().min(1).optional() })
823
+ });
824
+ const ListInverseRelationItemsInputSchema = z.z.object({
825
+ slug: z.z.string().min(1),
826
+ sourceType: z.z.string().min(1),
827
+ query: z.z.object({
828
+ itemId: z.z.string().min(1),
829
+ fieldName: z.z.string().min(1)
830
+ }).merge(paginationSchema)
831
+ });
832
+ const notifyError = async (error, operation, context) => {
833
+ await hooks?.onErrorExecuteContentOperation?.(
834
+ normalizeOperationError(error, `CMS ${operation} operation failed.`),
835
+ operation,
836
+ operationErrorContext(context, error)
837
+ );
838
+ };
839
+ const listContentTypes = api.defineOperation({
840
+ input: ListContentTypesInputSchema,
841
+ permission: plugins_cms_permissions.cmsPermissions.contentType.read,
842
+ facts: async () => {
843
+ await ensureSynced();
844
+ return {};
845
+ },
846
+ additionalPermissions: async ({ input }) => {
847
+ const contentTypes = await getContentTypesWithCounts();
848
+ contentTypeListSnapshots.set(input, contentTypes);
849
+ return contentTypes.map(
850
+ (contentType) => plugins_cms_permissions.cmsPermissions.record.read(collectionFacts(contentType.slug))
851
+ );
852
+ },
853
+ execute: ({ input }) => {
854
+ const contentTypes = contentTypeListSnapshots.get(input);
855
+ contentTypeListSnapshots.delete(input);
856
+ if (!contentTypes) {
857
+ throw new CMSOperationError(
858
+ 500,
859
+ "Content-type catalog authorization snapshot is unavailable.",
860
+ "AUTHORIZATION_SNAPSHOT_MISSING"
861
+ );
862
+ }
863
+ return contentTypes.map((contentType) => ({
864
+ ...operationContentType(contentType),
865
+ itemCount: contentType.itemCount
866
+ }));
867
+ },
868
+ onError: ({ error, ...context }) => notifyError(error, "list", genericContext(context))
869
+ });
870
+ const getContentTypeBySlug = api.defineOperation({
871
+ input: GetContentTypeInputSchema,
872
+ permission: plugins_cms_permissions.cmsPermissions.contentType.read,
873
+ facts: async ({ input }) => {
874
+ const contentType = await getContentTypeOrThrow(
875
+ adapter,
876
+ ensureSynced,
877
+ input.slug
878
+ );
879
+ return { contentType: contentType.slug };
880
+ },
881
+ execute: async ({ facts }) => operationContentType(
882
+ getters.serializeContentType(
883
+ await getContentTypeOrThrow(
884
+ adapter,
885
+ ensureSynced,
886
+ facts.contentType ?? ""
887
+ )
888
+ )
889
+ ),
890
+ onError: ({ error, ...context }) => notifyError(
891
+ error,
892
+ "get",
893
+ genericContext(context, context.facts.contentType)
894
+ )
895
+ });
896
+ const listContentItems = api.defineOperation({
897
+ input: ListContentItemsInputSchema,
898
+ permission: plugins_cms_permissions.cmsPermissions.record.read,
899
+ facts: async ({ input }) => {
900
+ const contentType = await getContentTypeOrThrow(
901
+ adapter,
902
+ ensureSynced,
903
+ input.typeSlug
904
+ );
905
+ if (!input.query.slug) {
906
+ return collectionFacts(contentType.slug);
907
+ }
908
+ const item = await getters.getContentItemBySlug(
909
+ adapter,
910
+ contentType.slug,
911
+ input.query.slug
912
+ );
913
+ const facts = {
914
+ contentType: contentType.slug,
915
+ scope: "record",
916
+ ...item ? {
917
+ recordId: item.id,
918
+ ...item.authorId ? { authorId: item.authorId } : {}
919
+ } : {}
920
+ };
921
+ return facts;
922
+ },
923
+ additionalPermissions: ({ facts }) => [
924
+ plugins_cms_permissions.cmsPermissions.contentType.read({ contentType: facts.contentType })
925
+ ],
926
+ execute: async ({ input, facts }) => {
927
+ const result = await getters.getAllContentItems(
928
+ adapter,
929
+ facts.contentType,
930
+ input.query
931
+ );
932
+ if (facts.scope === "record") {
933
+ if (!facts.recordId) {
934
+ if (result.items.length > 0) throw staleRecordError();
935
+ if (await getters.getContentItemBySlug(
936
+ adapter,
937
+ facts.contentType,
938
+ input.query.slug ?? ""
939
+ )) {
940
+ throw staleRecordError();
941
+ }
942
+ return operationContentList(result);
943
+ }
944
+ if (result.items.length > 1) throw staleRecordError();
945
+ if (result.items.length === 0) {
946
+ const current = await getters.getContentItemBySlug(
947
+ adapter,
948
+ facts.contentType,
949
+ input.query.slug ?? ""
950
+ );
951
+ if (!current) throw staleRecordError();
952
+ assertRecordFacts(current, facts);
953
+ } else {
954
+ assertRecordFacts(result.items[0], facts);
955
+ }
956
+ }
957
+ return operationContentList(result);
958
+ },
959
+ onError: ({ error, ...context }) => notifyError(
960
+ error,
961
+ "list",
962
+ genericContext(context, context.facts.contentType)
963
+ )
964
+ });
965
+ const getContentItem = api.defineOperation({
966
+ input: GetContentItemInputSchema,
967
+ permission: plugins_cms_permissions.cmsPermissions.record.read,
968
+ facts: async ({ input }) => recordFacts(
969
+ await getRecordOrThrow(adapter, ensureSynced, input.typeSlug, input.id)
970
+ ),
971
+ additionalPermissions: ({ facts }) => [
972
+ plugins_cms_permissions.cmsPermissions.contentType.read({ contentType: facts.contentType })
973
+ ],
974
+ execute: async ({ facts }) => {
975
+ const item = await getRecordOrThrow(
976
+ adapter,
977
+ ensureSynced,
978
+ facts.contentType,
979
+ facts.recordId ?? ""
980
+ );
981
+ assertRecordFacts(item, facts);
982
+ return operationContentItem(getters.serializeContentItemWithType(item));
983
+ },
984
+ onError: ({ error, ...context }) => notifyError(
985
+ error,
986
+ "get",
987
+ genericContext(context, context.facts.contentType)
988
+ )
989
+ });
990
+ const createContentItem = api.defineOperation({
991
+ input: CreateContentItemInputSchema,
992
+ permission: plugins_cms_permissions.cmsPermissions.record.create,
993
+ facts: async ({ input }) => ({
994
+ contentType: (await getContentTypeOrThrow(adapter, ensureSynced, input.typeSlug)).slug
995
+ }),
996
+ additionalPermissions: async ({ input, facts }) => {
997
+ const authorization = await deriveRelationWriteAuthorization(
998
+ adapter,
999
+ await getContentTypeOrThrow(adapter, ensureSynced, facts.contentType),
1000
+ input.body.data,
1001
+ ensureSynced
1002
+ );
1003
+ relationWriteAuthorizationSnapshots.set(input, authorization);
1004
+ return [
1005
+ plugins_cms_permissions.cmsPermissions.contentType.read({ contentType: facts.contentType }),
1006
+ ...authorization.permissions
1007
+ ];
1008
+ },
1009
+ execute: async (context) => {
1010
+ const lifecycleContext = createContext(context);
1011
+ const contentType = await getContentTypeOrThrow(
1012
+ adapter,
1013
+ ensureSynced,
1014
+ context.facts.contentType
1015
+ );
1016
+ const slug = utils.slugify(context.input.body.slug);
1017
+ if (!slug) {
1018
+ throw new CMSOperationError(
1019
+ 400,
1020
+ "Invalid slug: must contain at least one alphanumeric character",
1021
+ "INVALID_SLUG"
1022
+ );
1023
+ }
1024
+ const relationAuthorization = await recheckRelationWriteAuthorization(
1025
+ context.input,
1026
+ contentType.slug,
1027
+ context.input.body.data
1028
+ );
1029
+ const relationPlan = await planRelationsInData(
1030
+ adapter,
1031
+ contentType,
1032
+ context.input.body.data,
1033
+ ensureSynced,
1034
+ context.identity?.id
1035
+ );
1036
+ const validation = getContentTypeZodSchema(contentType).safeParse(
1037
+ relationPlan.processedData
1038
+ );
1039
+ if (!validation.success) {
1040
+ throw new CMSOperationError(
1041
+ 400,
1042
+ "Validation failed",
1043
+ "RECORD_VALIDATION_FAILED",
1044
+ validation.error.issues
1045
+ );
1046
+ }
1047
+ const existing = await adapter.findOne({
1048
+ model: "contentItem",
1049
+ where: [
1050
+ {
1051
+ field: "contentTypeId",
1052
+ value: contentType.id,
1053
+ operator: "eq"
1054
+ },
1055
+ { field: "slug", value: slug, operator: "eq" }
1056
+ ]
1057
+ });
1058
+ if (existing) {
1059
+ throw new CMSOperationError(
1060
+ 409,
1061
+ "Content item with this slug already exists",
1062
+ "DUPLICATE_SLUG"
1063
+ );
1064
+ }
1065
+ const validatedData = validation.data;
1066
+ await runBeforeHook(
1067
+ () => hooks?.onBeforeCreateContent?.(validatedData, lifecycleContext),
1068
+ "Create operation denied"
1069
+ );
1070
+ return adapter.transaction(async (tx) => {
1071
+ await assertCurrentRelationWriteAuthorization(
1072
+ tx,
1073
+ relationAuthorization,
1074
+ contentType.slug,
1075
+ context.input.body.data
1076
+ );
1077
+ const currentDuplicate = await tx.findOne({
1078
+ model: "contentItem",
1079
+ where: [
1080
+ {
1081
+ field: "contentTypeId",
1082
+ value: contentType.id,
1083
+ operator: "eq"
1084
+ },
1085
+ { field: "slug", value: slug, operator: "eq" }
1086
+ ]
1087
+ });
1088
+ if (currentDuplicate) {
1089
+ throw new CMSOperationError(
1090
+ 409,
1091
+ "Content item with this slug already exists",
1092
+ "DUPLICATE_SLUG"
1093
+ );
1094
+ }
1095
+ await applyRelationWritePlan(tx, relationPlan);
1096
+ const item = await tx.create({
1097
+ model: "contentItem",
1098
+ data: {
1099
+ contentTypeId: contentType.id,
1100
+ slug,
1101
+ data: JSON.stringify(validatedData),
1102
+ ...context.identity ? { authorId: context.identity.id } : {},
1103
+ createdAt: /* @__PURE__ */ new Date(),
1104
+ updatedAt: /* @__PURE__ */ new Date()
1105
+ }
1106
+ });
1107
+ await relations.syncRelations(tx, item.id, relationPlan.relationIds);
1108
+ const joined = await getRecordOrThrow(
1109
+ tx,
1110
+ ensureSynced,
1111
+ contentType.slug,
1112
+ item.id
1113
+ );
1114
+ return operationContentItem(getters.serializeContentItemWithType(joined));
1115
+ });
1116
+ },
1117
+ after: async (context) => {
1118
+ const base = createContext(context);
1119
+ const afterCreateContent = hooks?.onAfterCreateContent;
1120
+ await afterCreateContent?.(
1121
+ context.result,
1122
+ Object.freeze({ ...base, result: context.result })
1123
+ );
1124
+ },
1125
+ onError: async ({ error, ...context }) => {
1126
+ await notifyError(error, "create", createContext(context));
1127
+ }
1128
+ });
1129
+ const updateContentItem = api.defineOperation({
1130
+ input: UpdateContentItemInputSchema,
1131
+ permission: plugins_cms_permissions.cmsPermissions.record.update,
1132
+ facts: async ({ input }) => {
1133
+ const item = await getRecordOrThrow(
1134
+ adapter,
1135
+ ensureSynced,
1136
+ input.typeSlug,
1137
+ input.id
1138
+ );
1139
+ const facts = recordFacts(item);
1140
+ return {
1141
+ contentType: facts.contentType,
1142
+ recordId: facts.recordId ?? input.id,
1143
+ ...facts.authorId ? { authorId: facts.authorId } : {}
1144
+ };
1145
+ },
1146
+ additionalPermissions: async ({ input, facts }) => {
1147
+ const contentTypePermission = plugins_cms_permissions.cmsPermissions.contentType.read({
1148
+ contentType: facts.contentType
1149
+ });
1150
+ if (!input.body.data) return [contentTypePermission];
1151
+ const authorization = await deriveRelationWriteAuthorization(
1152
+ adapter,
1153
+ await getContentTypeOrThrow(adapter, ensureSynced, facts.contentType),
1154
+ input.body.data,
1155
+ ensureSynced
1156
+ );
1157
+ relationWriteAuthorizationSnapshots.set(input, authorization);
1158
+ return [contentTypePermission, ...authorization.permissions];
1159
+ },
1160
+ execute: async (context) => {
1161
+ const lifecycleContext = updateContext(context);
1162
+ const contentType = await getContentTypeOrThrow(
1163
+ adapter,
1164
+ ensureSynced,
1165
+ context.facts.contentType
1166
+ );
1167
+ const rawSlug = context.input.body.slug;
1168
+ const slug = rawSlug ? utils.slugify(rawSlug) : void 0;
1169
+ if (rawSlug && !slug) {
1170
+ throw new CMSOperationError(
1171
+ 400,
1172
+ "Invalid slug: must contain at least one alphanumeric character",
1173
+ "INVALID_SLUG"
1174
+ );
1175
+ }
1176
+ const bodyData = context.input.body.data;
1177
+ const relationAuthorization = bodyData ? await recheckRelationWriteAuthorization(
1178
+ context.input,
1179
+ contentType.slug,
1180
+ bodyData
1181
+ ) : void 0;
1182
+ const authorizedRecord = await getRecordOrThrow(
1183
+ adapter,
1184
+ ensureSynced,
1185
+ context.facts.contentType,
1186
+ context.facts.recordId
1187
+ );
1188
+ assertRecordFacts(authorizedRecord, context.facts);
1189
+ if (slug && slug !== authorizedRecord.slug) {
1190
+ const duplicate = await adapter.findOne({
1191
+ model: "contentItem",
1192
+ where: [
1193
+ {
1194
+ field: "contentTypeId",
1195
+ value: contentType.id,
1196
+ operator: "eq"
1197
+ },
1198
+ { field: "slug", value: slug, operator: "eq" }
1199
+ ]
1200
+ });
1201
+ if (duplicate) {
1202
+ throw new CMSOperationError(
1203
+ 409,
1204
+ "Content item with this slug already exists",
1205
+ "DUPLICATE_SLUG"
1206
+ );
1207
+ }
1208
+ }
1209
+ const relationPlan = bodyData ? await planRelationsInData(
1210
+ adapter,
1211
+ contentType,
1212
+ bodyData,
1213
+ ensureSynced,
1214
+ context.identity?.id
1215
+ ) : void 0;
1216
+ const currentData = authorizedRecord.data ? JSON.parse(authorizedRecord.data) : {};
1217
+ const validation = getContentTypeZodSchema(contentType).safeParse({
1218
+ ...currentData,
1219
+ ...relationPlan?.processedData ?? {}
1220
+ });
1221
+ if (!validation.success) {
1222
+ throw new CMSOperationError(
1223
+ 400,
1224
+ "Validation failed",
1225
+ "RECORD_VALIDATION_FAILED",
1226
+ validation.error.issues
1227
+ );
1228
+ }
1229
+ const mergedData = validation.data;
1230
+ await runBeforeHook(
1231
+ () => hooks?.onBeforeUpdateContent?.(
1232
+ context.facts.recordId,
1233
+ mergedData,
1234
+ lifecycleContext
1235
+ ),
1236
+ "Update operation denied"
1237
+ );
1238
+ return adapter.transaction(async (tx) => {
1239
+ if (bodyData && relationAuthorization) {
1240
+ await assertCurrentRelationWriteAuthorization(
1241
+ tx,
1242
+ relationAuthorization,
1243
+ contentType.slug,
1244
+ bodyData
1245
+ );
1246
+ }
1247
+ const current = await getRecordOrThrow(
1248
+ tx,
1249
+ ensureSynced,
1250
+ context.facts.contentType,
1251
+ context.facts.recordId
1252
+ );
1253
+ assertRecordFacts(current, context.facts);
1254
+ assertRecordSnapshot(current, authorizedRecord);
1255
+ if (slug && slug !== current.slug) {
1256
+ const duplicate = await tx.findOne({
1257
+ model: "contentItem",
1258
+ where: [
1259
+ {
1260
+ field: "contentTypeId",
1261
+ value: contentType.id,
1262
+ operator: "eq"
1263
+ },
1264
+ { field: "slug", value: slug, operator: "eq" }
1265
+ ]
1266
+ });
1267
+ if (duplicate) {
1268
+ throw new CMSOperationError(
1269
+ 409,
1270
+ "Content item with this slug already exists",
1271
+ "DUPLICATE_SLUG"
1272
+ );
1273
+ }
1274
+ }
1275
+ if (relationPlan) await applyRelationWritePlan(tx, relationPlan);
1276
+ const update = { updatedAt: /* @__PURE__ */ new Date() };
1277
+ if (slug) update.slug = slug;
1278
+ if (bodyData) update.data = JSON.stringify(mergedData);
1279
+ const matched = await tx.updateMany({
1280
+ model: "contentItem",
1281
+ where: [
1282
+ {
1283
+ field: "id",
1284
+ value: context.facts.recordId,
1285
+ operator: "eq"
1286
+ },
1287
+ {
1288
+ field: "contentTypeId",
1289
+ value: contentType.id,
1290
+ operator: "eq"
1291
+ },
1292
+ {
1293
+ field: "authorId",
1294
+ value: context.facts.authorId ?? null,
1295
+ operator: "eq"
1296
+ },
1297
+ {
1298
+ field: "updatedAt",
1299
+ value: current.updatedAt,
1300
+ operator: "eq"
1301
+ }
1302
+ ],
1303
+ update
1304
+ });
1305
+ if (!didUpdateContentItem(matched, context.facts.recordId)) {
1306
+ throw staleRecordError();
1307
+ }
1308
+ if (relationPlan) {
1309
+ await relations.syncRelations(
1310
+ tx,
1311
+ context.facts.recordId,
1312
+ relationPlan.relationIds
1313
+ );
1314
+ }
1315
+ const updated = await getRecordOrThrow(
1316
+ tx,
1317
+ ensureSynced,
1318
+ context.facts.contentType,
1319
+ context.facts.recordId
1320
+ );
1321
+ return operationContentItem(getters.serializeContentItemWithType(updated));
1322
+ });
1323
+ },
1324
+ after: async (context) => {
1325
+ const base = updateContext(context);
1326
+ const afterUpdateContent = hooks?.onAfterUpdateContent;
1327
+ await afterUpdateContent?.(
1328
+ context.result,
1329
+ Object.freeze({ ...base, result: context.result })
1330
+ );
1331
+ },
1332
+ onError: async ({ error, ...context }) => {
1333
+ await notifyError(error, "update", updateContext(context));
1334
+ }
1335
+ });
1336
+ const deleteContentItem = api.defineOperation({
1337
+ input: DeleteContentItemInputSchema,
1338
+ permission: plugins_cms_permissions.cmsPermissions.record.delete,
1339
+ facts: async ({ input }) => {
1340
+ const item = await getRecordOrThrow(
1341
+ adapter,
1342
+ ensureSynced,
1343
+ input.typeSlug,
1344
+ input.id
1345
+ );
1346
+ const facts = recordFacts(item);
1347
+ return {
1348
+ contentType: facts.contentType,
1349
+ recordId: facts.recordId ?? input.id,
1350
+ ...facts.authorId ? { authorId: facts.authorId } : {}
1351
+ };
1352
+ },
1353
+ before: async (context) => {
1354
+ const current = await getRecordOrThrow(
1355
+ adapter,
1356
+ ensureSynced,
1357
+ context.facts.contentType,
1358
+ context.facts.recordId
1359
+ );
1360
+ assertRecordFacts(current, context.facts);
1361
+ await runBeforeHook(
1362
+ () => hooks?.onBeforeDeleteContent?.(
1363
+ context.facts.recordId,
1364
+ deleteContext(context)
1365
+ ),
1366
+ "Delete operation denied"
1367
+ );
1368
+ },
1369
+ execute: async ({ facts }) => adapter.transaction(async (tx) => {
1370
+ const existing = await getRecordOrThrow(
1371
+ tx,
1372
+ ensureSynced,
1373
+ facts.contentType,
1374
+ facts.recordId
1375
+ );
1376
+ assertRecordFacts(existing, facts);
1377
+ const matched = await tx.updateMany({
1378
+ model: "contentItem",
1379
+ where: [
1380
+ { field: "id", value: facts.recordId, operator: "eq" },
1381
+ {
1382
+ field: "contentTypeId",
1383
+ value: existing.contentTypeId,
1384
+ operator: "eq"
1385
+ },
1386
+ {
1387
+ field: "authorId",
1388
+ value: facts.authorId ?? null,
1389
+ operator: "eq"
1390
+ },
1391
+ {
1392
+ field: "updatedAt",
1393
+ value: existing.updatedAt,
1394
+ operator: "eq"
1395
+ }
1396
+ ],
1397
+ update: { updatedAt: /* @__PURE__ */ new Date() }
1398
+ });
1399
+ if (!didUpdateContentItem(matched, facts.recordId)) {
1400
+ throw staleRecordError();
1401
+ }
1402
+ await tx.delete({
1403
+ model: "contentItem",
1404
+ where: [
1405
+ { field: "id", value: facts.recordId, operator: "eq" },
1406
+ {
1407
+ field: "contentTypeId",
1408
+ value: existing.contentTypeId,
1409
+ operator: "eq"
1410
+ }
1411
+ ]
1412
+ });
1413
+ return { success: true };
1414
+ }),
1415
+ after: async (context) => {
1416
+ const base = deleteContext(context);
1417
+ await hooks?.onAfterDeleteContent?.(
1418
+ context.facts.recordId,
1419
+ Object.freeze({ ...base, result: context.result })
1420
+ );
1421
+ },
1422
+ onError: async ({ error, ...context }) => {
1423
+ await notifyError(error, "delete", deleteContext(context));
1424
+ }
1425
+ });
1426
+ const getContentItemPopulated = api.defineOperation({
1427
+ input: GetContentItemInputSchema,
1428
+ permission: plugins_cms_permissions.cmsPermissions.record.read,
1429
+ facts: async ({ input }) => recordFacts(
1430
+ await getRecordOrThrow(adapter, ensureSynced, input.typeSlug, input.id)
1431
+ ),
1432
+ additionalPermissions: async ({ input, facts }) => {
1433
+ const snapshot = await getPopulatedRelationSnapshot(
1434
+ adapter,
1435
+ facts.recordId ?? ""
1436
+ );
1437
+ populatedRelationSnapshots.set(input, snapshot);
1438
+ const contentTypes = /* @__PURE__ */ new Set([
1439
+ facts.contentType,
1440
+ ...snapshot.targets.map(
1441
+ ({ facts: targetFacts }) => targetFacts.contentType
1442
+ )
1443
+ ]);
1444
+ return [
1445
+ ...[...contentTypes].map(
1446
+ (contentType) => plugins_cms_permissions.cmsPermissions.contentType.read({ contentType })
1447
+ ),
1448
+ ...snapshot.targets.map(
1449
+ ({ facts: targetFacts }) => plugins_cms_permissions.cmsPermissions.record.read(targetFacts)
1450
+ )
1451
+ ];
1452
+ },
1453
+ execute: async ({ input, facts }) => {
1454
+ try {
1455
+ const item = await getRecordOrThrow(
1456
+ adapter,
1457
+ ensureSynced,
1458
+ facts.contentType,
1459
+ facts.recordId ?? ""
1460
+ );
1461
+ assertRecordFacts(item, facts);
1462
+ const authorizedSnapshot = populatedRelationSnapshots.get(
1463
+ input
1464
+ );
1465
+ if (!authorizedSnapshot) {
1466
+ throw new CMSOperationError(
1467
+ 500,
1468
+ "Related-content authorization snapshot is unavailable.",
1469
+ "AUTHORIZATION_SNAPSHOT_MISSING"
1470
+ );
1471
+ }
1472
+ const currentSnapshot = await getPopulatedRelationSnapshot(
1473
+ adapter,
1474
+ facts.recordId ?? ""
1475
+ );
1476
+ assertPopulatedRelationSnapshot(authorizedSnapshot, currentSnapshot);
1477
+ const relations = populatedRelationsFromSnapshot(currentSnapshot);
1478
+ return {
1479
+ ...operationContentItem(getters.serializeContentItemWithType(item)),
1480
+ _relations: Object.fromEntries(
1481
+ Object.entries(relations).map(([field, records]) => [
1482
+ field,
1483
+ records.map(operationContentItem)
1484
+ ])
1485
+ )
1486
+ };
1487
+ } finally {
1488
+ populatedRelationSnapshots.delete(input);
1489
+ }
1490
+ },
1491
+ onError: ({ error, ...context }) => notifyError(
1492
+ error,
1493
+ "get",
1494
+ genericContext(context, context.facts.contentType)
1495
+ )
1496
+ });
1497
+ const listContentByRelation = api.defineOperation({
1498
+ input: ListContentByRelationInputSchema,
1499
+ permission: plugins_cms_permissions.cmsPermissions.record.read,
1500
+ facts: async ({ input }) => collectionFacts(
1501
+ (await getContentTypeOrThrow(adapter, ensureSynced, input.typeSlug)).slug
1502
+ ),
1503
+ additionalPermissions: async ({ input, facts }) => {
1504
+ const sourceContentType = await getContentTypeOrThrow(
1505
+ adapter,
1506
+ ensureSynced,
1507
+ facts.contentType
1508
+ );
1509
+ const authorization = await deriveRelationFilterAuthorization(
1510
+ adapter,
1511
+ ensureSynced,
1512
+ sourceContentType,
1513
+ input.query.field,
1514
+ input.query.targetId
1515
+ );
1516
+ relationFilterAuthorizationSnapshots.set(input, authorization);
1517
+ return [
1518
+ plugins_cms_permissions.cmsPermissions.contentType.read({ contentType: facts.contentType }),
1519
+ authorization.permission
1520
+ ];
1521
+ },
1522
+ execute: async ({ input, facts }) => {
1523
+ const sourceContentType = await recheckRelationFilterAuthorization(
1524
+ input,
1525
+ facts.contentType,
1526
+ input.query.field,
1527
+ input.query.targetId
1528
+ );
1529
+ const result = await listRecordsForRelation(
1530
+ adapter,
1531
+ sourceContentType,
1532
+ input.query.field,
1533
+ input.query.targetId,
1534
+ input.query.limit,
1535
+ input.query.offset
1536
+ );
1537
+ return {
1538
+ ...result,
1539
+ items: result.items.map(operationContentItem)
1540
+ };
1541
+ },
1542
+ onError: ({ error, ...context }) => notifyError(
1543
+ error,
1544
+ "list",
1545
+ genericContext(context, context.facts.contentType)
1546
+ )
1547
+ });
1548
+ const getInverseRelations = api.defineOperation({
1549
+ input: GetInverseRelationsInputSchema,
1550
+ permission: plugins_cms_permissions.cmsPermissions.contentType.read,
1551
+ facts: async ({ input }) => ({
1552
+ contentType: (await getContentTypeOrThrow(adapter, ensureSynced, input.slug)).slug
1553
+ }),
1554
+ additionalPermissions: async ({ input, facts }) => {
1555
+ const authorization = await deriveInverseSourceAuthorization(
1556
+ adapter,
1557
+ ensureSynced,
1558
+ facts.contentType ?? ""
1559
+ );
1560
+ inverseSourceAuthorizationSnapshots.set(
1561
+ input,
1562
+ authorization.snapshot
1563
+ );
1564
+ const permissions = [...authorization.permissions];
1565
+ if (input.query.itemId) {
1566
+ const targetFacts = recordFacts(
1567
+ await getRecordOrThrow(
1568
+ adapter,
1569
+ ensureSynced,
1570
+ facts.contentType ?? "",
1571
+ input.query.itemId
1572
+ )
1573
+ );
1574
+ inverseTargetAuthorizationSnapshots.set(input, targetFacts);
1575
+ permissions.push(plugins_cms_permissions.cmsPermissions.record.read(targetFacts));
1576
+ const authorizedSourceTypes = /* @__PURE__ */ new Set();
1577
+ for (const source of authorization.sources) {
1578
+ if (authorizedSourceTypes.has(source.contentTypeSlug)) continue;
1579
+ authorizedSourceTypes.add(source.contentTypeSlug);
1580
+ permissions.push(
1581
+ plugins_cms_permissions.cmsPermissions.record.read(collectionFacts(source.contentTypeSlug))
1582
+ );
1583
+ }
1584
+ }
1585
+ return permissions;
1586
+ },
1587
+ execute: async ({ input, facts }) => {
1588
+ try {
1589
+ const sources = await recheckInverseSourceAuthorization(
1590
+ input,
1591
+ facts.contentType ?? ""
1592
+ );
1593
+ if (input.query.itemId) {
1594
+ await recheckInverseTargetAuthorization(
1595
+ input,
1596
+ facts.contentType ?? "",
1597
+ input.query.itemId
1598
+ );
1599
+ }
1600
+ const inverseRelations = [];
1601
+ for (const source of sources) {
1602
+ let count = 0;
1603
+ if (input.query.itemId) {
1604
+ const relations = await adapter.findMany({
1605
+ model: "contentRelation",
1606
+ where: [
1607
+ {
1608
+ field: "targetId",
1609
+ value: input.query.itemId,
1610
+ operator: "eq"
1611
+ },
1612
+ {
1613
+ field: "fieldName",
1614
+ value: source.fieldName,
1615
+ operator: "eq"
1616
+ }
1617
+ ]
1618
+ });
1619
+ for (const sourceId of relations.map((value) => value.sourceId)) {
1620
+ const item = await adapter.findOne({
1621
+ model: "contentItem",
1622
+ where: [
1623
+ {
1624
+ field: "id",
1625
+ value: sourceId,
1626
+ operator: "eq"
1627
+ },
1628
+ {
1629
+ field: "contentTypeId",
1630
+ value: source.contentTypeId,
1631
+ operator: "eq"
1632
+ }
1633
+ ]
1634
+ });
1635
+ if (item) count += 1;
1636
+ }
1637
+ }
1638
+ inverseRelations.push({
1639
+ sourceType: source.contentTypeSlug,
1640
+ sourceTypeName: source.contentTypeName,
1641
+ fieldName: source.fieldName,
1642
+ count
1643
+ });
1644
+ }
1645
+ return {
1646
+ inverseRelations: inverseRelations.map((relation) => ({
1647
+ ...relation
1648
+ }))
1649
+ };
1650
+ } finally {
1651
+ inverseTargetAuthorizationSnapshots.delete(input);
1652
+ }
1653
+ },
1654
+ onError: ({ error, ...context }) => notifyError(
1655
+ error,
1656
+ "get",
1657
+ genericContext(context, context.facts.contentType)
1658
+ )
1659
+ });
1660
+ const listInverseRelationItems = api.defineOperation({
1661
+ input: ListInverseRelationItemsInputSchema,
1662
+ permission: plugins_cms_permissions.cmsPermissions.record.read,
1663
+ facts: async ({ input }) => {
1664
+ await getContentTypeOrThrow(adapter, ensureSynced, input.slug);
1665
+ const sourceType = await getContentTypeOrThrow(
1666
+ adapter,
1667
+ ensureSynced,
1668
+ input.sourceType
1669
+ );
1670
+ return collectionFacts(sourceType.slug);
1671
+ },
1672
+ additionalPermissions: async ({ input, facts }) => {
1673
+ const authorization = await deriveInverseSourceAuthorization(
1674
+ adapter,
1675
+ ensureSynced,
1676
+ input.slug
1677
+ );
1678
+ const source = authorization.sources.find(
1679
+ (value) => value.contentTypeSlug === facts.contentType && value.fieldName === input.query.fieldName
1680
+ );
1681
+ if (!source) {
1682
+ throw new CMSOperationError(
1683
+ 404,
1684
+ "Inverse relation not found",
1685
+ "INVERSE_RELATION_NOT_FOUND"
1686
+ );
1687
+ }
1688
+ inverseSourceAuthorizationSnapshots.set(
1689
+ input,
1690
+ authorization.snapshot
1691
+ );
1692
+ const targetFacts = recordFacts(
1693
+ await getRecordOrThrow(
1694
+ adapter,
1695
+ ensureSynced,
1696
+ input.slug,
1697
+ input.query.itemId
1698
+ )
1699
+ );
1700
+ inverseTargetAuthorizationSnapshots.set(input, targetFacts);
1701
+ return [
1702
+ plugins_cms_permissions.cmsPermissions.contentType.read({ contentType: facts.contentType }),
1703
+ plugins_cms_permissions.cmsPermissions.record.read(targetFacts)
1704
+ ];
1705
+ },
1706
+ execute: async ({ input, facts }) => {
1707
+ try {
1708
+ const sources = await recheckInverseSourceAuthorization(
1709
+ input,
1710
+ input.slug
1711
+ );
1712
+ const source = sources.find(
1713
+ (value) => value.contentTypeSlug === facts.contentType && value.fieldName === input.query.fieldName
1714
+ );
1715
+ if (!source) throw relationSchemaChangedError();
1716
+ await recheckInverseTargetAuthorization(
1717
+ input,
1718
+ input.slug,
1719
+ input.query.itemId
1720
+ );
1721
+ const result = await listRecordsForRelation(
1722
+ adapter,
1723
+ await getContentTypeOrThrow(adapter, ensureSynced, facts.contentType),
1724
+ source.fieldName,
1725
+ input.query.itemId,
1726
+ input.query.limit,
1727
+ input.query.offset
1728
+ );
1729
+ return {
1730
+ ...result,
1731
+ items: result.items.map(operationContentItem)
1732
+ };
1733
+ } finally {
1734
+ inverseTargetAuthorizationSnapshots.delete(input);
1735
+ }
1736
+ },
1737
+ onError: ({ error, ...context }) => notifyError(
1738
+ error,
1739
+ "list",
1740
+ genericContext(context, context.facts.contentType)
1741
+ )
1742
+ });
1743
+ return {
1744
+ listContentTypes,
1745
+ getContentTypeBySlug,
1746
+ listContentItems,
1747
+ getContentItem,
1748
+ createContentItem,
1749
+ updateContentItem,
1750
+ deleteContentItem,
1751
+ getContentItemPopulated,
1752
+ listContentByRelation,
1753
+ getInverseRelations,
1754
+ listInverseRelationItems
1755
+ };
1756
+ }
1757
+
1758
+ exports.CMSContentItemParamsSchema = CMSContentItemParamsSchema;
1759
+ exports.CMSContentTypeParamsSchema = CMSContentTypeParamsSchema;
1760
+ exports.CMSCreateContentItemBodySchema = CMSCreateContentItemBodySchema;
1761
+ exports.CMSOperationError = CMSOperationError;
1762
+ exports.CMSUpdateContentItemBodySchema = CMSUpdateContentItemBodySchema;
1763
+ exports.createCMSOperations = createCMSOperations;