@questpie/admin 1.1.0 → 2.0.0

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 (965) hide show
  1. package/README.md +245 -474
  2. package/dist/_virtual/rolldown_runtime.mjs +18 -0
  3. package/dist/augmentation.d.mts +315 -0
  4. package/dist/augmentation.d.mts.map +1 -0
  5. package/dist/client/blocks/block-registry.d.mts +199 -0
  6. package/dist/client/blocks/block-registry.d.mts.map +1 -0
  7. package/dist/client/blocks/block-registry.mjs +88 -0
  8. package/dist/client/blocks/block-registry.mjs.map +1 -0
  9. package/dist/client/blocks/block-renderer.d.mts +52 -0
  10. package/dist/client/blocks/block-renderer.d.mts.map +1 -0
  11. package/dist/client/blocks/block-renderer.mjs +71 -0
  12. package/dist/client/blocks/block-renderer.mjs.map +1 -0
  13. package/dist/client/blocks/index.d.mts +4 -0
  14. package/dist/client/blocks/prefetch.d.mts +45 -0
  15. package/dist/client/blocks/prefetch.d.mts.map +1 -0
  16. package/dist/client/blocks/prefetch.mjs +26 -0
  17. package/dist/client/blocks/prefetch.mjs.map +1 -0
  18. package/dist/client/blocks/types.d.mts +69 -0
  19. package/dist/client/blocks/types.d.mts.map +1 -0
  20. package/dist/client/blocks/types.mjs +20 -0
  21. package/dist/client/blocks/types.mjs.map +1 -0
  22. package/dist/client/builder/admin-builder.d.mts +112 -0
  23. package/dist/client/builder/admin-builder.d.mts.map +1 -0
  24. package/dist/client/builder/admin-builder.mjs +185 -0
  25. package/dist/client/builder/admin-builder.mjs.map +1 -0
  26. package/dist/client/builder/admin-types.d.mts +73 -0
  27. package/dist/client/builder/admin-types.d.mts.map +1 -0
  28. package/dist/client/builder/admin.d.mts +121 -0
  29. package/dist/client/builder/admin.d.mts.map +1 -0
  30. package/dist/client/builder/admin.mjs +160 -0
  31. package/dist/client/builder/admin.mjs.map +1 -0
  32. package/dist/client/builder/defaults/components.mjs +20 -0
  33. package/dist/client/builder/defaults/components.mjs.map +1 -0
  34. package/dist/client/builder/defaults/core.d.mts +354 -0
  35. package/dist/client/builder/defaults/core.d.mts.map +1 -0
  36. package/dist/client/builder/defaults/core.mjs +49 -0
  37. package/dist/client/builder/defaults/core.mjs.map +1 -0
  38. package/dist/client/builder/defaults/fields.mjs +328 -0
  39. package/dist/client/builder/defaults/fields.mjs.map +1 -0
  40. package/dist/client/builder/defaults/pages.mjs +58 -0
  41. package/dist/client/builder/defaults/pages.mjs.map +1 -0
  42. package/dist/client/builder/defaults/starter.d.mts +351 -0
  43. package/dist/client/builder/defaults/starter.d.mts.map +1 -0
  44. package/dist/client/builder/defaults/starter.mjs +28 -0
  45. package/dist/client/builder/defaults/starter.mjs.map +1 -0
  46. package/dist/client/builder/defaults/views.mjs +27 -0
  47. package/dist/client/builder/defaults/views.mjs.map +1 -0
  48. package/dist/client/builder/defaults/widgets.mjs +31 -0
  49. package/dist/client/builder/defaults/widgets.mjs.map +1 -0
  50. package/dist/client/builder/field/field.d.mts +229 -0
  51. package/dist/client/builder/field/field.d.mts.map +1 -0
  52. package/dist/client/builder/field/field.mjs +83 -0
  53. package/dist/client/builder/field/field.mjs.map +1 -0
  54. package/dist/client/builder/index.d.mts +36 -0
  55. package/dist/client/builder/index.d.mts.map +1 -0
  56. package/dist/client/builder/page/page.d.mts +36 -0
  57. package/dist/client/builder/page/page.d.mts.map +1 -0
  58. package/dist/client/builder/page/page.mjs +27 -0
  59. package/dist/client/builder/page/page.mjs.map +1 -0
  60. package/dist/client/builder/proxies.d.mts +2 -0
  61. package/dist/client/builder/proxies.mjs +24 -0
  62. package/dist/client/builder/proxies.mjs.map +1 -0
  63. package/dist/client/builder/qa.d.mts +50 -0
  64. package/dist/client/builder/qa.d.mts.map +1 -0
  65. package/dist/client/builder/qa.mjs +42 -0
  66. package/dist/client/builder/qa.mjs.map +1 -0
  67. package/dist/client/builder/registry.d.mts +70 -0
  68. package/dist/client/builder/registry.d.mts.map +1 -0
  69. package/dist/client/builder/types/action-registry.d.mts +2 -0
  70. package/dist/client/builder/types/action-registry.mjs +142 -0
  71. package/dist/client/builder/types/action-registry.mjs.map +1 -0
  72. package/dist/client/builder/types/action-types.d.mts +253 -0
  73. package/dist/client/builder/types/action-types.d.mts.map +1 -0
  74. package/dist/client/builder/types/collection-types.d.mts +199 -0
  75. package/dist/client/builder/types/collection-types.d.mts.map +1 -0
  76. package/dist/client/builder/types/collection-types.mjs +11 -0
  77. package/dist/client/builder/types/collection-types.mjs.map +1 -0
  78. package/dist/client/builder/types/common.d.mts +60 -0
  79. package/dist/client/builder/types/common.d.mts.map +1 -0
  80. package/dist/client/builder/types/field-types.d.mts +593 -0
  81. package/dist/client/builder/types/field-types.d.mts.map +1 -0
  82. package/dist/client/builder/types/field-types.mjs +19 -0
  83. package/dist/client/builder/types/field-types.mjs.map +1 -0
  84. package/dist/client/builder/types/global-types.d.mts +22 -0
  85. package/dist/client/builder/types/global-types.d.mts.map +1 -0
  86. package/dist/client/builder/types/ui-config.d.mts +160 -0
  87. package/dist/client/builder/types/ui-config.d.mts.map +1 -0
  88. package/dist/client/builder/types/views.d.mts +89 -0
  89. package/dist/client/builder/types/views.d.mts.map +1 -0
  90. package/dist/client/builder/types/widget-types.d.mts +563 -0
  91. package/dist/client/builder/types/widget-types.d.mts.map +1 -0
  92. package/dist/client/builder/validation.d.mts +3 -0
  93. package/dist/client/builder/validation.mjs +208 -0
  94. package/dist/client/builder/validation.mjs.map +1 -0
  95. package/dist/client/builder/view/view.d.mts +129 -0
  96. package/dist/client/builder/view/view.d.mts.map +1 -0
  97. package/dist/client/builder/view/view.mjs +109 -0
  98. package/dist/client/builder/view/view.mjs.map +1 -0
  99. package/dist/client/builder/widget/widget.d.mts +33 -0
  100. package/dist/client/builder/widget/widget.d.mts.map +1 -0
  101. package/dist/client/builder/widget/widget.mjs +26 -0
  102. package/dist/client/builder/widget/widget.mjs.map +1 -0
  103. package/dist/client/components/actions/action-button.d.mts +2 -0
  104. package/dist/client/components/actions/action-button.mjs +135 -0
  105. package/dist/client/components/actions/action-button.mjs.map +1 -0
  106. package/dist/client/components/actions/action-dialog.d.mts +2 -0
  107. package/dist/client/components/actions/action-dialog.mjs +264 -0
  108. package/dist/client/components/actions/action-dialog.mjs.map +1 -0
  109. package/dist/client/components/actions/confirmation-dialog.d.mts +2 -0
  110. package/dist/client/components/actions/confirmation-dialog.mjs +82 -0
  111. package/dist/client/components/actions/confirmation-dialog.mjs.map +1 -0
  112. package/dist/client/components/actions/header-actions.d.mts +2 -0
  113. package/dist/client/components/actions/header-actions.mjs +117 -0
  114. package/dist/client/components/actions/header-actions.mjs.map +1 -0
  115. package/dist/client/components/actions/index.d.mts +4 -0
  116. package/dist/client/components/admin-link.d.mts +67 -0
  117. package/dist/client/components/admin-link.d.mts.map +1 -0
  118. package/dist/client/components/admin-link.mjs +92 -0
  119. package/dist/client/components/admin-link.mjs.map +1 -0
  120. package/dist/client/components/auth/auth-guard.d.mts +51 -0
  121. package/dist/client/components/auth/auth-guard.d.mts.map +1 -0
  122. package/dist/client/components/auth/auth-guard.mjs +60 -0
  123. package/dist/client/components/auth/auth-guard.mjs.map +1 -0
  124. package/dist/client/components/auth/auth-loading.d.mts +36 -0
  125. package/dist/client/components/auth/auth-loading.d.mts.map +1 -0
  126. package/dist/client/components/auth/auth-loading.mjs +27 -0
  127. package/dist/client/components/auth/auth-loading.mjs.map +1 -0
  128. package/dist/client/components/auth/index.d.mts +2 -0
  129. package/dist/client/components/blocks/block-canvas.mjs +90 -0
  130. package/dist/client/components/blocks/block-canvas.mjs.map +1 -0
  131. package/dist/client/components/blocks/block-editor-context.mjs +58 -0
  132. package/dist/client/components/blocks/block-editor-context.mjs.map +1 -0
  133. package/dist/client/components/blocks/block-editor-layout.mjs +82 -0
  134. package/dist/client/components/blocks/block-editor-layout.mjs.map +1 -0
  135. package/dist/client/components/blocks/block-editor-provider.mjs +155 -0
  136. package/dist/client/components/blocks/block-editor-provider.mjs.map +1 -0
  137. package/dist/client/components/blocks/block-fields-renderer.mjs +70 -0
  138. package/dist/client/components/blocks/block-fields-renderer.mjs.map +1 -0
  139. package/dist/client/components/blocks/block-insert-button.mjs +72 -0
  140. package/dist/client/components/blocks/block-insert-button.mjs.map +1 -0
  141. package/dist/client/components/blocks/block-item-menu.mjs +161 -0
  142. package/dist/client/components/blocks/block-item-menu.mjs.map +1 -0
  143. package/dist/client/components/blocks/block-item.mjs +187 -0
  144. package/dist/client/components/blocks/block-item.mjs.map +1 -0
  145. package/dist/client/components/blocks/block-library-sidebar.mjs +190 -0
  146. package/dist/client/components/blocks/block-library-sidebar.mjs.map +1 -0
  147. package/dist/client/components/blocks/block-tree.mjs +45 -0
  148. package/dist/client/components/blocks/block-tree.mjs.map +1 -0
  149. package/dist/client/components/blocks/block-type-icon.mjs +50 -0
  150. package/dist/client/components/blocks/block-type-icon.mjs.map +1 -0
  151. package/dist/client/components/blocks/utils/tree-utils.mjs +186 -0
  152. package/dist/client/components/blocks/utils/tree-utils.mjs.map +1 -0
  153. package/dist/client/components/component-renderer.d.mts +125 -0
  154. package/dist/client/components/component-renderer.d.mts.map +1 -0
  155. package/dist/client/components/component-renderer.mjs +145 -0
  156. package/dist/client/components/component-renderer.mjs.map +1 -0
  157. package/dist/client/components/error-boundary.mjs +92 -0
  158. package/dist/client/components/error-boundary.mjs.map +1 -0
  159. package/dist/client/components/fields/array-field.d.mts +44 -0
  160. package/dist/client/components/fields/array-field.d.mts.map +1 -0
  161. package/dist/client/components/fields/array-field.mjs +231 -0
  162. package/dist/client/components/fields/array-field.mjs.map +1 -0
  163. package/dist/client/components/fields/asset-preview-field.d.mts +52 -0
  164. package/dist/client/components/fields/asset-preview-field.d.mts.map +1 -0
  165. package/dist/client/components/fields/asset-preview-field.mjs +60 -0
  166. package/dist/client/components/fields/asset-preview-field.mjs.map +1 -0
  167. package/dist/client/components/fields/blocks-field/blocks-field.d.mts +41 -0
  168. package/dist/client/components/fields/blocks-field/blocks-field.d.mts.map +1 -0
  169. package/dist/client/components/fields/blocks-field/blocks-field.mjs +101 -0
  170. package/dist/client/components/fields/blocks-field/blocks-field.mjs.map +1 -0
  171. package/dist/client/components/fields/blocks-field/index.d.mts +1 -0
  172. package/dist/client/components/fields/boolean-field.d.mts +30 -0
  173. package/dist/client/components/fields/boolean-field.d.mts.map +1 -0
  174. package/dist/client/components/fields/boolean-field.mjs +47 -0
  175. package/dist/client/components/fields/boolean-field.mjs.map +1 -0
  176. package/dist/client/components/fields/custom-field.d.mts +3 -0
  177. package/dist/client/components/fields/date-field.d.mts +22 -0
  178. package/dist/client/components/fields/date-field.d.mts.map +1 -0
  179. package/dist/client/components/fields/date-field.mjs +42 -0
  180. package/dist/client/components/fields/date-field.mjs.map +1 -0
  181. package/dist/client/components/fields/datetime-field.d.mts +23 -0
  182. package/dist/client/components/fields/datetime-field.d.mts.map +1 -0
  183. package/dist/client/components/fields/datetime-field.mjs +43 -0
  184. package/dist/client/components/fields/datetime-field.mjs.map +1 -0
  185. package/dist/client/components/fields/email-field.d.mts +19 -0
  186. package/dist/client/components/fields/email-field.d.mts.map +1 -0
  187. package/dist/client/components/fields/email-field.mjs +38 -0
  188. package/dist/client/components/fields/email-field.mjs.map +1 -0
  189. package/dist/client/components/fields/embedded-collection.d.mts +3 -0
  190. package/dist/client/components/fields/field-types.d.mts +571 -0
  191. package/dist/client/components/fields/field-types.d.mts.map +1 -0
  192. package/dist/client/components/fields/field-utils.d.mts +1 -0
  193. package/dist/client/components/fields/field-utils.mjs +65 -0
  194. package/dist/client/components/fields/field-utils.mjs.map +1 -0
  195. package/dist/client/components/fields/field-wrapper.d.mts +3 -0
  196. package/dist/client/components/fields/field-wrapper.mjs +49 -0
  197. package/dist/client/components/fields/field-wrapper.mjs.map +1 -0
  198. package/dist/client/components/fields/index.d.mts +33 -0
  199. package/dist/client/components/fields/json-field.d.mts +84 -0
  200. package/dist/client/components/fields/json-field.d.mts.map +1 -0
  201. package/dist/client/components/fields/json-field.mjs +248 -0
  202. package/dist/client/components/fields/json-field.mjs.map +1 -0
  203. package/dist/client/components/fields/locale-badge.d.mts +1 -0
  204. package/dist/client/components/fields/locale-badge.mjs +17 -0
  205. package/dist/client/components/fields/locale-badge.mjs.map +1 -0
  206. package/dist/client/components/fields/number-field.d.mts +23 -0
  207. package/dist/client/components/fields/number-field.d.mts.map +1 -0
  208. package/dist/client/components/fields/number-field.mjs +40 -0
  209. package/dist/client/components/fields/number-field.mjs.map +1 -0
  210. package/dist/client/components/fields/object-array-field.d.mts +2 -0
  211. package/dist/client/components/fields/object-array-field.mjs +313 -0
  212. package/dist/client/components/fields/object-array-field.mjs.map +1 -0
  213. package/dist/client/components/fields/object-field.d.mts +32 -0
  214. package/dist/client/components/fields/object-field.d.mts.map +1 -0
  215. package/dist/client/components/fields/object-field.mjs +128 -0
  216. package/dist/client/components/fields/object-field.mjs.map +1 -0
  217. package/dist/client/components/fields/relation/displays/cards-display.d.mts +2 -0
  218. package/dist/client/components/fields/relation/displays/cards-display.mjs +140 -0
  219. package/dist/client/components/fields/relation/displays/cards-display.mjs.map +1 -0
  220. package/dist/client/components/fields/relation/displays/chips-display.d.mts +2 -0
  221. package/dist/client/components/fields/relation/displays/chips-display.mjs +100 -0
  222. package/dist/client/components/fields/relation/displays/chips-display.mjs.map +1 -0
  223. package/dist/client/components/fields/relation/displays/grid-display.d.mts +2 -0
  224. package/dist/client/components/fields/relation/displays/grid-display.mjs +114 -0
  225. package/dist/client/components/fields/relation/displays/grid-display.mjs.map +1 -0
  226. package/dist/client/components/fields/relation/displays/index.d.mts +6 -0
  227. package/dist/client/components/fields/relation/displays/list-display.d.mts +2 -0
  228. package/dist/client/components/fields/relation/displays/list-display.mjs +128 -0
  229. package/dist/client/components/fields/relation/displays/list-display.mjs.map +1 -0
  230. package/dist/client/components/fields/relation/displays/table-display.d.mts +2 -0
  231. package/dist/client/components/fields/relation/displays/table-display.mjs +134 -0
  232. package/dist/client/components/fields/relation/displays/table-display.mjs.map +1 -0
  233. package/dist/client/components/fields/relation/displays/types.d.mts +22 -0
  234. package/dist/client/components/fields/relation/displays/types.d.mts.map +1 -0
  235. package/dist/client/components/fields/relation/displays/types.mjs +73 -0
  236. package/dist/client/components/fields/relation/displays/types.mjs.map +1 -0
  237. package/dist/client/components/fields/relation/index.d.mts +3 -0
  238. package/dist/client/components/fields/relation/relation-items-display.d.mts +5 -0
  239. package/dist/client/components/fields/relation/relation-items-display.mjs +47 -0
  240. package/dist/client/components/fields/relation/relation-items-display.mjs.map +1 -0
  241. package/dist/client/components/fields/relation-field.d.mts +134 -0
  242. package/dist/client/components/fields/relation-field.d.mts.map +1 -0
  243. package/dist/client/components/fields/relation-field.mjs +106 -0
  244. package/dist/client/components/fields/relation-field.mjs.map +1 -0
  245. package/dist/client/components/fields/relation-picker.d.mts +4 -0
  246. package/dist/client/components/fields/relation-picker.mjs +301 -0
  247. package/dist/client/components/fields/relation-picker.mjs.map +1 -0
  248. package/dist/client/components/fields/relation-select.d.mts +3 -0
  249. package/dist/client/components/fields/relation-select.mjs +219 -0
  250. package/dist/client/components/fields/relation-select.mjs.map +1 -0
  251. package/dist/client/components/fields/reverse-relation-field.d.mts +2 -0
  252. package/dist/client/components/fields/rich-text-editor/bubble-menu.mjs +56 -0
  253. package/dist/client/components/fields/rich-text-editor/bubble-menu.mjs.map +1 -0
  254. package/dist/client/components/fields/rich-text-editor/extensions.mjs +118 -0
  255. package/dist/client/components/fields/rich-text-editor/extensions.mjs.map +1 -0
  256. package/dist/client/components/fields/rich-text-editor/image-popover.mjs +196 -0
  257. package/dist/client/components/fields/rich-text-editor/image-popover.mjs.map +1 -0
  258. package/dist/client/components/fields/rich-text-editor/index.d.mts +4 -0
  259. package/dist/client/components/fields/rich-text-editor/index.mjs +187 -0
  260. package/dist/client/components/fields/rich-text-editor/index.mjs.map +1 -0
  261. package/dist/client/components/fields/rich-text-editor/link-popover.mjs +86 -0
  262. package/dist/client/components/fields/rich-text-editor/link-popover.mjs.map +1 -0
  263. package/dist/client/components/fields/rich-text-editor/presets.d.mts +11 -0
  264. package/dist/client/components/fields/rich-text-editor/presets.d.mts.map +1 -0
  265. package/dist/client/components/fields/rich-text-editor/presets.mjs +124 -0
  266. package/dist/client/components/fields/rich-text-editor/presets.mjs.map +1 -0
  267. package/dist/client/components/fields/rich-text-editor/slash-commands.mjs +145 -0
  268. package/dist/client/components/fields/rich-text-editor/slash-commands.mjs.map +1 -0
  269. package/dist/client/components/fields/rich-text-editor/table-controls.mjs +124 -0
  270. package/dist/client/components/fields/rich-text-editor/table-controls.mjs.map +1 -0
  271. package/dist/client/components/fields/rich-text-editor/toolbar.mjs +280 -0
  272. package/dist/client/components/fields/rich-text-editor/toolbar.mjs.map +1 -0
  273. package/dist/client/components/fields/rich-text-editor/types.d.mts +78 -0
  274. package/dist/client/components/fields/rich-text-editor/types.d.mts.map +1 -0
  275. package/dist/client/components/fields/rich-text-editor/types.mjs +31 -0
  276. package/dist/client/components/fields/rich-text-editor/types.mjs.map +1 -0
  277. package/dist/client/components/fields/rich-text-editor/utils.mjs +51 -0
  278. package/dist/client/components/fields/rich-text-editor/utils.mjs.map +1 -0
  279. package/dist/client/components/fields/rich-text-editor/variants.d.mts +2 -0
  280. package/dist/client/components/fields/rich-text-field.d.mts +14 -0
  281. package/dist/client/components/fields/rich-text-field.d.mts.map +1 -0
  282. package/dist/client/components/fields/rich-text-field.mjs +26 -0
  283. package/dist/client/components/fields/rich-text-field.mjs.map +1 -0
  284. package/dist/client/components/fields/select-field.d.mts +25 -0
  285. package/dist/client/components/fields/select-field.d.mts.map +1 -0
  286. package/dist/client/components/fields/select-field.mjs +53 -0
  287. package/dist/client/components/fields/select-field.mjs.map +1 -0
  288. package/dist/client/components/fields/status-field.d.mts +2 -0
  289. package/dist/client/components/fields/text-field.d.mts +22 -0
  290. package/dist/client/components/fields/text-field.d.mts.map +1 -0
  291. package/dist/client/components/fields/text-field.mjs +39 -0
  292. package/dist/client/components/fields/text-field.mjs.map +1 -0
  293. package/dist/client/components/fields/textarea-field.d.mts +22 -0
  294. package/dist/client/components/fields/textarea-field.d.mts.map +1 -0
  295. package/dist/client/components/fields/textarea-field.mjs +39 -0
  296. package/dist/client/components/fields/textarea-field.mjs.map +1 -0
  297. package/dist/client/components/fields/time-field.d.mts +20 -0
  298. package/dist/client/components/fields/time-field.d.mts.map +1 -0
  299. package/dist/client/components/fields/time-field.mjs +39 -0
  300. package/dist/client/components/fields/time-field.mjs.map +1 -0
  301. package/dist/client/components/fields/upload-field.d.mts +97 -0
  302. package/dist/client/components/fields/upload-field.d.mts.map +1 -0
  303. package/dist/client/components/fields/upload-field.mjs +497 -0
  304. package/dist/client/components/fields/upload-field.mjs.map +1 -0
  305. package/dist/client/components/filter-builder/columns-tab.d.mts +1 -0
  306. package/dist/client/components/filter-builder/columns-tab.mjs +131 -0
  307. package/dist/client/components/filter-builder/columns-tab.mjs.map +1 -0
  308. package/dist/client/components/filter-builder/filter-builder-sheet.d.mts +1 -0
  309. package/dist/client/components/filter-builder/filter-builder-sheet.mjs +157 -0
  310. package/dist/client/components/filter-builder/filter-builder-sheet.mjs.map +1 -0
  311. package/dist/client/components/filter-builder/filters-tab.d.mts +1 -0
  312. package/dist/client/components/filter-builder/filters-tab.mjs +380 -0
  313. package/dist/client/components/filter-builder/filters-tab.mjs.map +1 -0
  314. package/dist/client/components/filter-builder/index.d.mts +5 -0
  315. package/dist/client/components/filter-builder/saved-views-tab.d.mts +1 -0
  316. package/dist/client/components/filter-builder/saved-views-tab.mjs +125 -0
  317. package/dist/client/components/filter-builder/saved-views-tab.mjs.map +1 -0
  318. package/dist/client/components/index.d.mts +80 -0
  319. package/dist/client/components/locale-switcher.d.mts +2 -0
  320. package/dist/client/components/locale-switcher.mjs +128 -0
  321. package/dist/client/components/locale-switcher.mjs.map +1 -0
  322. package/dist/client/components/media/media-grid.mjs +139 -0
  323. package/dist/client/components/media/media-grid.mjs.map +1 -0
  324. package/dist/client/components/media/media-picker-dialog.mjs +255 -0
  325. package/dist/client/components/media/media-picker-dialog.mjs.map +1 -0
  326. package/dist/client/components/preview/live-preview-mode.mjs +211 -0
  327. package/dist/client/components/preview/live-preview-mode.mjs.map +1 -0
  328. package/dist/client/components/preview/preview-pane.mjs +179 -0
  329. package/dist/client/components/preview/preview-pane.mjs.map +1 -0
  330. package/dist/client/components/primitives/asset-preview.mjs +363 -0
  331. package/dist/client/components/primitives/asset-preview.mjs.map +1 -0
  332. package/dist/client/components/primitives/checkbox-input.mjs +33 -0
  333. package/dist/client/components/primitives/checkbox-input.mjs.map +1 -0
  334. package/dist/client/components/primitives/date-input.mjs +218 -0
  335. package/dist/client/components/primitives/date-input.mjs.map +1 -0
  336. package/dist/client/components/primitives/dropzone.mjs +239 -0
  337. package/dist/client/components/primitives/dropzone.mjs.map +1 -0
  338. package/dist/client/components/primitives/number-input.mjs +113 -0
  339. package/dist/client/components/primitives/number-input.mjs.map +1 -0
  340. package/dist/client/components/primitives/select-multi.mjs +256 -0
  341. package/dist/client/components/primitives/select-multi.mjs.map +1 -0
  342. package/dist/client/components/primitives/select-single.mjs +183 -0
  343. package/dist/client/components/primitives/select-single.mjs.map +1 -0
  344. package/dist/client/components/primitives/text-input.mjs +40 -0
  345. package/dist/client/components/primitives/text-input.mjs.map +1 -0
  346. package/dist/client/components/primitives/textarea-input.mjs +38 -0
  347. package/dist/client/components/primitives/textarea-input.mjs.map +1 -0
  348. package/dist/client/components/primitives/time-input.mjs +72 -0
  349. package/dist/client/components/primitives/time-input.mjs.map +1 -0
  350. package/dist/client/components/primitives/toggle-input.mjs +31 -0
  351. package/dist/client/components/primitives/toggle-input.mjs.map +1 -0
  352. package/dist/client/components/primitives/types.d.mts +14 -0
  353. package/dist/client/components/primitives/types.d.mts.map +1 -0
  354. package/dist/client/components/primitives/types.mjs +13 -0
  355. package/dist/client/components/primitives/types.mjs.map +1 -0
  356. package/dist/client/components/sheets/index.d.mts +1 -0
  357. package/dist/client/components/sheets/resource-sheet.d.mts +1 -0
  358. package/dist/client/components/sheets/resource-sheet.mjs +78 -0
  359. package/dist/client/components/sheets/resource-sheet.mjs.map +1 -0
  360. package/dist/client/components/ui/accordion.d.mts +2 -0
  361. package/dist/client/components/ui/accordion.mjs +50 -0
  362. package/dist/client/components/ui/accordion.mjs.map +1 -0
  363. package/dist/client/components/ui/alert.mjs +32 -0
  364. package/dist/client/components/ui/alert.mjs.map +1 -0
  365. package/dist/client/components/ui/avatar.d.mts +3 -0
  366. package/dist/client/components/ui/badge.d.mts +3 -0
  367. package/dist/client/components/ui/badge.mjs +35 -0
  368. package/dist/client/components/ui/badge.mjs.map +1 -0
  369. package/dist/client/components/ui/button.d.mts +3 -0
  370. package/dist/client/components/ui/button.mjs +49 -0
  371. package/dist/client/components/ui/button.mjs.map +1 -0
  372. package/dist/client/components/ui/card.d.mts +2 -0
  373. package/dist/{card-BKHjBQfw.mjs → client/components/ui/card.mjs} +3 -10
  374. package/dist/{card-BKHjBQfw.mjs.map → client/components/ui/card.mjs.map} +1 -1
  375. package/dist/client/components/ui/checkbox.d.mts +2 -0
  376. package/dist/client/components/ui/checkbox.mjs +27 -0
  377. package/dist/client/components/ui/checkbox.mjs.map +1 -0
  378. package/dist/client/components/ui/combobox.d.mts +3 -0
  379. package/dist/client/components/ui/command.mjs +69 -0
  380. package/dist/client/components/ui/command.mjs.map +1 -0
  381. package/dist/client/components/ui/dialog.d.mts +3 -0
  382. package/dist/client/components/ui/dialog.mjs +83 -0
  383. package/dist/client/components/ui/dialog.mjs.map +1 -0
  384. package/dist/client/components/ui/drawer.mjs +75 -0
  385. package/dist/client/components/ui/drawer.mjs.map +1 -0
  386. package/dist/client/components/ui/dropdown-menu.d.mts +3 -0
  387. package/dist/client/components/ui/dropdown-menu.mjs +89 -0
  388. package/dist/client/components/ui/dropdown-menu.mjs.map +1 -0
  389. package/dist/client/components/ui/empty-state.mjs +53 -0
  390. package/dist/client/components/ui/empty-state.mjs.map +1 -0
  391. package/dist/client/components/ui/field.d.mts +3 -0
  392. package/dist/client/components/ui/field.mjs +78 -0
  393. package/dist/client/components/ui/field.mjs.map +1 -0
  394. package/dist/client/components/ui/input-group.d.mts +4 -0
  395. package/dist/client/components/ui/input-group.mjs +68 -0
  396. package/dist/client/components/ui/input-group.mjs.map +1 -0
  397. package/dist/client/components/ui/input.d.mts +2 -0
  398. package/dist/client/components/ui/input.mjs +17 -0
  399. package/dist/client/components/ui/input.mjs.map +1 -0
  400. package/dist/client/components/ui/kbd.mjs +24 -0
  401. package/dist/client/components/ui/kbd.mjs.map +1 -0
  402. package/dist/client/components/ui/label.d.mts +2 -0
  403. package/dist/client/components/ui/label.mjs +15 -0
  404. package/dist/client/components/ui/label.mjs.map +1 -0
  405. package/dist/client/components/ui/popover.d.mts +3 -0
  406. package/dist/client/components/ui/popover.mjs +49 -0
  407. package/dist/client/components/ui/popover.mjs.map +1 -0
  408. package/dist/client/components/ui/responsive-dialog.mjs +102 -0
  409. package/dist/client/components/ui/responsive-dialog.mjs.map +1 -0
  410. package/dist/client/components/ui/scroll-area.d.mts +2 -0
  411. package/dist/client/components/ui/search-input.mjs +74 -0
  412. package/dist/client/components/ui/search-input.mjs.map +1 -0
  413. package/dist/client/components/ui/select.d.mts +3 -0
  414. package/dist/client/components/ui/select.mjs +85 -0
  415. package/dist/client/components/ui/select.mjs.map +1 -0
  416. package/dist/client/components/ui/separator.d.mts +2 -0
  417. package/dist/client/components/ui/separator.mjs +17 -0
  418. package/dist/client/components/ui/separator.mjs.map +1 -0
  419. package/dist/client/components/ui/sheet.d.mts +3 -0
  420. package/dist/client/components/ui/sheet.mjs +78 -0
  421. package/dist/client/components/ui/sheet.mjs.map +1 -0
  422. package/dist/client/components/ui/sidebar.d.mts +8 -0
  423. package/dist/client/components/ui/sidebar.mjs +256 -0
  424. package/dist/client/components/ui/sidebar.mjs.map +1 -0
  425. package/dist/client/components/ui/skeleton.d.mts +1 -0
  426. package/dist/client/components/ui/skeleton.mjs +15 -0
  427. package/dist/client/components/ui/skeleton.mjs.map +1 -0
  428. package/dist/client/components/ui/sonner.d.mts +14 -0
  429. package/dist/client/components/ui/sonner.d.mts.map +1 -0
  430. package/dist/client/components/ui/sonner.mjs +55 -0
  431. package/dist/client/components/ui/sonner.mjs.map +1 -0
  432. package/dist/client/components/ui/spinner.d.mts +1 -0
  433. package/dist/client/components/ui/spinner.mjs +18 -0
  434. package/dist/client/components/ui/spinner.mjs.map +1 -0
  435. package/dist/client/components/ui/switch.d.mts +2 -0
  436. package/dist/client/components/ui/switch.mjs +23 -0
  437. package/dist/client/components/ui/switch.mjs.map +1 -0
  438. package/dist/client/components/ui/table.d.mts +2 -0
  439. package/dist/client/components/ui/table.mjs +66 -0
  440. package/dist/client/components/ui/table.mjs.map +1 -0
  441. package/dist/client/components/ui/tabs.d.mts +3 -0
  442. package/dist/client/components/ui/tabs.mjs +49 -0
  443. package/dist/client/components/ui/tabs.mjs.map +1 -0
  444. package/dist/client/components/ui/textarea.d.mts +2 -0
  445. package/dist/client/components/ui/textarea.mjs +15 -0
  446. package/dist/client/components/ui/textarea.mjs.map +1 -0
  447. package/dist/client/components/ui/toolbar.mjs +54 -0
  448. package/dist/client/components/ui/toolbar.mjs.map +1 -0
  449. package/dist/client/components/ui/tooltip.d.mts +2 -0
  450. package/dist/client/components/ui/tooltip.mjs +45 -0
  451. package/dist/client/components/ui/tooltip.mjs.map +1 -0
  452. package/dist/client/components/widgets/chart-widget.d.mts +57 -0
  453. package/dist/client/components/widgets/chart-widget.d.mts.map +1 -0
  454. package/dist/client/components/widgets/chart-widget.mjs +282 -0
  455. package/dist/client/components/widgets/chart-widget.mjs.map +1 -0
  456. package/dist/client/components/widgets/progress-widget.d.mts +41 -0
  457. package/dist/client/components/widgets/progress-widget.d.mts.map +1 -0
  458. package/dist/client/components/widgets/progress-widget.mjs +110 -0
  459. package/dist/client/components/widgets/progress-widget.mjs.map +1 -0
  460. package/dist/client/components/widgets/quick-actions-widget.d.mts +29 -0
  461. package/dist/client/components/widgets/quick-actions-widget.d.mts.map +1 -0
  462. package/dist/client/components/widgets/quick-actions-widget.mjs +121 -0
  463. package/dist/client/components/widgets/quick-actions-widget.mjs.map +1 -0
  464. package/dist/client/components/widgets/recent-items-widget.d.mts +51 -0
  465. package/dist/client/components/widgets/recent-items-widget.d.mts.map +1 -0
  466. package/dist/client/components/widgets/recent-items-widget.mjs +101 -0
  467. package/dist/client/components/widgets/recent-items-widget.mjs.map +1 -0
  468. package/dist/client/components/widgets/stats-widget.d.mts +55 -0
  469. package/dist/client/components/widgets/stats-widget.d.mts.map +1 -0
  470. package/dist/client/components/widgets/stats-widget.mjs +150 -0
  471. package/dist/client/components/widgets/stats-widget.mjs.map +1 -0
  472. package/dist/client/components/widgets/table-widget.d.mts +31 -0
  473. package/dist/client/components/widgets/table-widget.d.mts.map +1 -0
  474. package/dist/client/components/widgets/table-widget.mjs +139 -0
  475. package/dist/client/components/widgets/table-widget.mjs.map +1 -0
  476. package/dist/client/components/widgets/timeline-widget.d.mts +51 -0
  477. package/dist/client/components/widgets/timeline-widget.d.mts.map +1 -0
  478. package/dist/client/components/widgets/timeline-widget.mjs +168 -0
  479. package/dist/client/components/widgets/timeline-widget.mjs.map +1 -0
  480. package/dist/client/components/widgets/value-widget.d.mts +39 -0
  481. package/dist/client/components/widgets/value-widget.d.mts.map +1 -0
  482. package/dist/client/components/widgets/value-widget.mjs +111 -0
  483. package/dist/client/components/widgets/value-widget.mjs.map +1 -0
  484. package/dist/client/components/widgets/widget-skeletons.mjs +145 -0
  485. package/dist/client/components/widgets/widget-skeletons.mjs.map +1 -0
  486. package/dist/client/context/focus-context.d.mts +88 -0
  487. package/dist/client/context/focus-context.d.mts.map +1 -0
  488. package/dist/client/context/focus-context.mjs +178 -0
  489. package/dist/client/context/focus-context.mjs.map +1 -0
  490. package/dist/client/contexts/breadcrumb-context.mjs +32 -0
  491. package/dist/client/contexts/breadcrumb-context.mjs.map +1 -0
  492. package/dist/client/hooks/typed-hooks.d.mts +84 -0
  493. package/dist/client/hooks/typed-hooks.d.mts.map +1 -0
  494. package/dist/client/hooks/typed-hooks.mjs +272 -0
  495. package/dist/client/hooks/typed-hooks.mjs.map +1 -0
  496. package/dist/client/hooks/use-action.mjs +201 -0
  497. package/dist/client/hooks/use-action.mjs.map +1 -0
  498. package/dist/client/hooks/use-admin-config.mjs +40 -0
  499. package/dist/client/hooks/use-admin-config.mjs.map +1 -0
  500. package/dist/client/hooks/use-admin-preferences.mjs +68 -0
  501. package/dist/client/hooks/use-admin-preferences.mjs.map +1 -0
  502. package/dist/client/hooks/use-admin-routes.mjs +97 -0
  503. package/dist/client/hooks/use-admin-routes.mjs.map +1 -0
  504. package/dist/client/hooks/use-auth.d.mts +98 -0
  505. package/dist/client/hooks/use-auth.d.mts.map +1 -0
  506. package/dist/{use-auth-BoLmWtmU.mjs → client/hooks/use-auth.mjs} +3 -3
  507. package/dist/client/hooks/use-auth.mjs.map +1 -0
  508. package/dist/client/hooks/use-collection-fields.mjs +32 -0
  509. package/dist/client/hooks/use-collection-fields.mjs.map +1 -0
  510. package/dist/client/hooks/use-collection-meta.mjs +121 -0
  511. package/dist/client/hooks/use-collection-meta.mjs.map +1 -0
  512. package/dist/client/hooks/use-collection-schema.mjs +67 -0
  513. package/dist/client/hooks/use-collection-schema.mjs.map +1 -0
  514. package/dist/client/hooks/use-collection-validation.mjs +74 -0
  515. package/dist/client/hooks/use-collection-validation.mjs.map +1 -0
  516. package/dist/client/hooks/use-collection.d.mts +86 -0
  517. package/dist/client/hooks/use-collection.d.mts.map +1 -0
  518. package/dist/client/hooks/use-collection.mjs +214 -0
  519. package/dist/client/hooks/use-collection.mjs.map +1 -0
  520. package/dist/client/hooks/use-current-user.d.mts +57 -0
  521. package/dist/client/hooks/use-current-user.d.mts.map +1 -0
  522. package/dist/client/hooks/use-current-user.mjs +79 -0
  523. package/dist/client/hooks/use-current-user.mjs.map +1 -0
  524. package/dist/client/hooks/use-field-hooks.mjs +191 -0
  525. package/dist/client/hooks/use-field-hooks.mjs.map +1 -0
  526. package/dist/client/hooks/use-field-options.d.mts +90 -0
  527. package/dist/client/hooks/use-field-options.d.mts.map +1 -0
  528. package/dist/client/hooks/use-field-options.mjs +184 -0
  529. package/dist/client/hooks/use-field-options.mjs.map +1 -0
  530. package/dist/client/hooks/use-global-fields.mjs +27 -0
  531. package/dist/client/hooks/use-global-fields.mjs.map +1 -0
  532. package/dist/client/hooks/use-global-meta.mjs +59 -0
  533. package/dist/client/hooks/use-global-meta.mjs.map +1 -0
  534. package/dist/client/hooks/use-global-schema.mjs +33 -0
  535. package/dist/client/hooks/use-global-schema.mjs.map +1 -0
  536. package/dist/client/hooks/use-global.d.mts +40 -0
  537. package/dist/client/hooks/use-global.d.mts.map +1 -0
  538. package/dist/client/hooks/use-global.mjs +74 -0
  539. package/dist/client/hooks/use-global.mjs.map +1 -0
  540. package/dist/client/hooks/use-locks.mjs +245 -0
  541. package/dist/client/hooks/use-locks.mjs.map +1 -0
  542. package/dist/client/hooks/use-media-query.d.mts +23 -0
  543. package/dist/client/hooks/use-media-query.d.mts.map +1 -0
  544. package/dist/client/hooks/use-media-query.mjs +62 -0
  545. package/dist/client/hooks/use-media-query.mjs.map +1 -0
  546. package/dist/client/hooks/use-prefill-params.mjs +47 -0
  547. package/dist/client/hooks/use-prefill-params.mjs.map +1 -0
  548. package/dist/client/hooks/use-questpie-query-options.mjs +28 -0
  549. package/dist/client/hooks/use-questpie-query-options.mjs.map +1 -0
  550. package/dist/client/hooks/use-reactive-fields.d.mts +75 -0
  551. package/dist/client/hooks/use-reactive-fields.d.mts.map +1 -0
  552. package/dist/client/hooks/use-reactive-fields.mjs +164 -0
  553. package/dist/client/hooks/use-reactive-fields.mjs.map +1 -0
  554. package/dist/client/hooks/use-realtime-highlight.mjs +96 -0
  555. package/dist/client/hooks/use-realtime-highlight.mjs.map +1 -0
  556. package/dist/client/hooks/use-saved-views.mjs +65 -0
  557. package/dist/client/hooks/use-saved-views.mjs.map +1 -0
  558. package/dist/client/hooks/use-search.mjs +147 -0
  559. package/dist/client/hooks/use-search.mjs.map +1 -0
  560. package/dist/client/hooks/use-server-validation.mjs +199 -0
  561. package/dist/client/hooks/use-server-validation.mjs.map +1 -0
  562. package/dist/client/hooks/use-server-widget-data.d.mts +26 -0
  563. package/dist/client/hooks/use-server-widget-data.d.mts.map +1 -0
  564. package/dist/client/hooks/use-server-widget-data.mjs +40 -0
  565. package/dist/client/hooks/use-server-widget-data.mjs.map +1 -0
  566. package/dist/client/hooks/use-setup-status.d.mts +39 -0
  567. package/dist/client/hooks/use-setup-status.d.mts.map +1 -0
  568. package/dist/client/hooks/use-setup-status.mjs +50 -0
  569. package/dist/client/hooks/use-setup-status.mjs.map +1 -0
  570. package/dist/client/hooks/use-upload-collection.mjs +32 -0
  571. package/dist/client/hooks/use-upload-collection.mjs.map +1 -0
  572. package/dist/client/hooks/use-upload.d.mts +23 -0
  573. package/dist/client/hooks/use-upload.d.mts.map +1 -0
  574. package/dist/client/hooks/use-upload.mjs +145 -0
  575. package/dist/client/hooks/use-upload.mjs.map +1 -0
  576. package/dist/client/hooks/use-validation-error-map.mjs +53 -0
  577. package/dist/client/hooks/use-validation-error-map.mjs.map +1 -0
  578. package/dist/client/hooks/use-view-state.mjs +261 -0
  579. package/dist/client/hooks/use-view-state.mjs.map +1 -0
  580. package/dist/client/i18n/hooks.mjs +160 -0
  581. package/dist/client/i18n/hooks.mjs.map +1 -0
  582. package/dist/client/i18n/intl-cache.mjs +65 -0
  583. package/dist/client/i18n/intl-cache.mjs.map +1 -0
  584. package/dist/client/i18n/messages.mjs +7 -0
  585. package/dist/client/i18n/messages.mjs.map +1 -0
  586. package/dist/client/i18n/simple.d.mts +22 -0
  587. package/dist/client/i18n/simple.d.mts.map +1 -0
  588. package/dist/client/i18n/simple.mjs +157 -0
  589. package/dist/client/i18n/simple.mjs.map +1 -0
  590. package/dist/client/i18n/types.d.mts +110 -0
  591. package/dist/client/i18n/types.d.mts.map +1 -0
  592. package/dist/client/lib/utils.d.mts +1 -0
  593. package/dist/client/lib/utils.mjs +28 -0
  594. package/dist/client/lib/utils.mjs.map +1 -0
  595. package/dist/client/preview/block-scope-context.d.mts +74 -0
  596. package/dist/client/preview/block-scope-context.d.mts.map +1 -0
  597. package/dist/client/preview/block-scope-context.mjs +93 -0
  598. package/dist/client/preview/block-scope-context.mjs.map +1 -0
  599. package/dist/client/preview/index.d.mts +5 -0
  600. package/dist/client/preview/preview-banner.d.mts +46 -0
  601. package/dist/client/preview/preview-banner.d.mts.map +1 -0
  602. package/dist/client/preview/preview-banner.mjs +95 -0
  603. package/dist/client/preview/preview-banner.mjs.map +1 -0
  604. package/dist/client/preview/preview-field.d.mts +108 -0
  605. package/dist/client/preview/preview-field.d.mts.map +1 -0
  606. package/dist/client/preview/preview-field.mjs +125 -0
  607. package/dist/client/preview/preview-field.mjs.map +1 -0
  608. package/dist/client/preview/types.d.mts +115 -0
  609. package/dist/client/preview/types.d.mts.map +1 -0
  610. package/dist/client/preview/types.mjs +21 -0
  611. package/dist/client/preview/types.mjs.map +1 -0
  612. package/dist/client/preview/use-collection-preview.d.mts +71 -0
  613. package/dist/client/preview/use-collection-preview.d.mts.map +1 -0
  614. package/dist/client/preview/use-collection-preview.mjs +114 -0
  615. package/dist/client/preview/use-collection-preview.mjs.map +1 -0
  616. package/dist/client/runtime/content-locales-provider.d.mts +1 -0
  617. package/dist/client/runtime/content-locales-provider.mjs +85 -0
  618. package/dist/client/runtime/content-locales-provider.mjs.map +1 -0
  619. package/dist/client/runtime/index.d.mts +7 -0
  620. package/dist/client/runtime/index.mjs +8 -0
  621. package/dist/client/runtime/locale-scope.d.mts +2 -0
  622. package/dist/{runtime-6VZM878K.mjs → client/runtime/locale-scope.mjs} +3 -4
  623. package/dist/client/runtime/locale-scope.mjs.map +1 -0
  624. package/dist/client/runtime/provider.d.mts +10107 -0
  625. package/dist/client/runtime/provider.d.mts.map +1 -0
  626. package/dist/client/runtime/provider.mjs +229 -0
  627. package/dist/client/runtime/provider.mjs.map +1 -0
  628. package/dist/client/runtime/routes.d.mts +49 -0
  629. package/dist/client/runtime/routes.d.mts.map +1 -0
  630. package/dist/client/runtime/routes.mjs +107 -0
  631. package/dist/client/runtime/routes.mjs.map +1 -0
  632. package/dist/client/runtime/translations-provider.d.mts +2 -0
  633. package/dist/client/runtime/translations-provider.mjs +181 -0
  634. package/dist/client/runtime/translations-provider.mjs.map +1 -0
  635. package/dist/client/scope/index.d.mts +3 -0
  636. package/dist/client/scope/picker.d.mts +54 -0
  637. package/dist/client/scope/picker.d.mts.map +1 -0
  638. package/dist/client/scope/picker.mjs +161 -0
  639. package/dist/client/scope/picker.mjs.map +1 -0
  640. package/dist/client/scope/provider.d.mts +104 -0
  641. package/dist/client/scope/provider.d.mts.map +1 -0
  642. package/dist/client/scope/provider.mjs +159 -0
  643. package/dist/client/scope/provider.mjs.map +1 -0
  644. package/dist/client/scope/types.d.mts +112 -0
  645. package/dist/client/scope/types.d.mts.map +1 -0
  646. package/dist/client/styles/index.css +80 -0
  647. package/dist/client/utils/auto-expand-fields.mjs +65 -0
  648. package/dist/client/utils/auto-expand-fields.mjs.map +1 -0
  649. package/dist/client/utils/build-field-definitions-from-schema.mjs +256 -0
  650. package/dist/client/utils/build-field-definitions-from-schema.mjs.map +1 -0
  651. package/dist/client/utils/detect-relations.mjs +46 -0
  652. package/dist/client/utils/detect-relations.mjs.map +1 -0
  653. package/dist/client/utils/locale-to-flag.d.mts +118 -0
  654. package/dist/client/utils/locale-to-flag.d.mts.map +1 -0
  655. package/dist/client/utils/locale-to-flag.mjs +130 -0
  656. package/dist/client/utils/locale-to-flag.mjs.map +1 -0
  657. package/dist/client/utils/routes.mjs +196 -0
  658. package/dist/client/utils/routes.mjs.map +1 -0
  659. package/dist/client/views/auth/accept-invite-form.d.mts +73 -0
  660. package/dist/client/views/auth/accept-invite-form.d.mts.map +1 -0
  661. package/dist/client/views/auth/accept-invite-form.mjs +180 -0
  662. package/dist/client/views/auth/accept-invite-form.mjs.map +1 -0
  663. package/dist/client/views/auth/auth-layout.d.mts +44 -0
  664. package/dist/client/views/auth/auth-layout.d.mts.map +1 -0
  665. package/dist/client/views/auth/auth-layout.mjs +53 -0
  666. package/dist/client/views/auth/auth-layout.mjs.map +1 -0
  667. package/dist/client/views/auth/forgot-password-form.d.mts +59 -0
  668. package/dist/client/views/auth/forgot-password-form.d.mts.map +1 -0
  669. package/dist/{forgot-password-page-Bcp-An4Y.mjs → client/views/auth/forgot-password-form.mjs} +22 -89
  670. package/dist/client/views/auth/forgot-password-form.mjs.map +1 -0
  671. package/dist/client/views/auth/index.d.mts +7 -0
  672. package/dist/client/views/auth/invite-form.d.mts +1 -0
  673. package/dist/client/views/auth/invite-form.mjs +155 -0
  674. package/dist/client/views/auth/invite-form.mjs.map +1 -0
  675. package/dist/client/views/auth/login-form.d.mts +76 -0
  676. package/dist/client/views/auth/login-form.d.mts.map +1 -0
  677. package/dist/client/views/auth/login-form.mjs +167 -0
  678. package/dist/client/views/auth/login-form.mjs.map +1 -0
  679. package/dist/client/views/auth/reset-password-form.d.mts +66 -0
  680. package/dist/client/views/auth/reset-password-form.d.mts.map +1 -0
  681. package/dist/client/views/auth/reset-password-form.mjs +188 -0
  682. package/dist/client/views/auth/reset-password-form.mjs.map +1 -0
  683. package/dist/client/views/auth/setup-form.d.mts +61 -0
  684. package/dist/client/views/auth/setup-form.d.mts.map +1 -0
  685. package/dist/{setup-page-YAP_fzqh.mjs → client/views/auth/setup-form.mjs} +46 -124
  686. package/dist/client/views/auth/setup-form.mjs.map +1 -0
  687. package/dist/client/views/collection/auto-form-fields.d.mts +4 -0
  688. package/dist/client/views/collection/auto-form-fields.mjs +453 -0
  689. package/dist/client/views/collection/auto-form-fields.mjs.map +1 -0
  690. package/dist/client/views/collection/bulk-action-toolbar.mjs +291 -0
  691. package/dist/client/views/collection/bulk-action-toolbar.mjs.map +1 -0
  692. package/dist/client/views/collection/cells/complex-cells.d.mts +46 -0
  693. package/dist/client/views/collection/cells/complex-cells.d.mts.map +1 -0
  694. package/dist/client/views/collection/cells/complex-cells.mjs +327 -0
  695. package/dist/client/views/collection/cells/complex-cells.mjs.map +1 -0
  696. package/dist/client/views/collection/cells/index.d.mts +7 -0
  697. package/dist/client/views/collection/cells/primitive-cells.d.mts +76 -0
  698. package/dist/client/views/collection/cells/primitive-cells.d.mts.map +1 -0
  699. package/dist/client/views/collection/cells/primitive-cells.mjs +165 -0
  700. package/dist/client/views/collection/cells/primitive-cells.mjs.map +1 -0
  701. package/dist/client/views/collection/cells/relation-cells.d.mts +21 -0
  702. package/dist/client/views/collection/cells/relation-cells.d.mts.map +1 -0
  703. package/dist/client/views/collection/cells/relation-cells.mjs +105 -0
  704. package/dist/client/views/collection/cells/relation-cells.mjs.map +1 -0
  705. package/dist/client/views/collection/cells/shared/asset-thumbnail.d.mts +1 -0
  706. package/dist/client/views/collection/cells/shared/asset-thumbnail.mjs +189 -0
  707. package/dist/client/views/collection/cells/shared/asset-thumbnail.mjs.map +1 -0
  708. package/dist/client/views/collection/cells/shared/cell-helpers.d.mts +2 -0
  709. package/dist/client/views/collection/cells/shared/cell-helpers.mjs +78 -0
  710. package/dist/client/views/collection/cells/shared/cell-helpers.mjs.map +1 -0
  711. package/dist/client/views/collection/cells/shared/relation-chip.d.mts +1 -0
  712. package/dist/client/views/collection/cells/shared/relation-chip.mjs +37 -0
  713. package/dist/client/views/collection/cells/shared/relation-chip.mjs.map +1 -0
  714. package/dist/client/views/collection/cells/upload-cells.d.mts +25 -0
  715. package/dist/client/views/collection/cells/upload-cells.d.mts.map +1 -0
  716. package/dist/client/views/collection/cells/upload-cells.mjs +20 -0
  717. package/dist/client/views/collection/cells/upload-cells.mjs.map +1 -0
  718. package/dist/client/views/collection/columns/build-columns.d.mts +2 -0
  719. package/dist/client/views/collection/columns/build-columns.mjs +156 -0
  720. package/dist/client/views/collection/columns/build-columns.mjs.map +1 -0
  721. package/dist/client/views/collection/columns/column-defaults.d.mts +2 -0
  722. package/dist/client/views/collection/columns/column-defaults.mjs +108 -0
  723. package/dist/client/views/collection/columns/column-defaults.mjs.map +1 -0
  724. package/dist/client/views/collection/columns/index.d.mts +3 -0
  725. package/dist/client/views/collection/columns/types.d.mts +2 -0
  726. package/dist/client/views/collection/field-context.mjs +127 -0
  727. package/dist/client/views/collection/field-context.mjs.map +1 -0
  728. package/dist/client/views/collection/field-renderer.mjs +171 -0
  729. package/dist/client/views/collection/field-renderer.mjs.map +1 -0
  730. package/dist/client/views/collection/form-view.d.mts +112 -0
  731. package/dist/client/views/collection/form-view.d.mts.map +1 -0
  732. package/dist/client/views/collection/form-view.mjs +903 -0
  733. package/dist/client/views/collection/form-view.mjs.map +1 -0
  734. package/dist/client/views/collection/index.d.mts +9 -0
  735. package/dist/client/views/collection/table-view.d.mts +102 -0
  736. package/dist/client/views/collection/table-view.d.mts.map +1 -0
  737. package/dist/client/views/collection/table-view.mjs +695 -0
  738. package/dist/client/views/collection/table-view.mjs.map +1 -0
  739. package/dist/client/views/collection/view-skeletons.mjs +121 -0
  740. package/dist/client/views/collection/view-skeletons.mjs.map +1 -0
  741. package/dist/client/views/common/global-search.d.mts +1 -0
  742. package/dist/client/views/common/global-search.mjs +376 -0
  743. package/dist/client/views/common/global-search.mjs.map +1 -0
  744. package/dist/client/views/common/index.d.mts +1 -0
  745. package/dist/client/views/dashboard/dashboard-grid.mjs +385 -0
  746. package/dist/client/views/dashboard/dashboard-grid.mjs.map +1 -0
  747. package/dist/client/views/dashboard/dashboard-widget.mjs +178 -0
  748. package/dist/client/views/dashboard/dashboard-widget.mjs.map +1 -0
  749. package/dist/client/views/dashboard/widget-card.mjs +159 -0
  750. package/dist/client/views/dashboard/widget-card.mjs.map +1 -0
  751. package/dist/client/views/globals/global-form-view.d.mts +74 -0
  752. package/dist/client/views/globals/global-form-view.d.mts.map +1 -0
  753. package/dist/client/views/globals/global-form-view.mjs +181 -0
  754. package/dist/client/views/globals/global-form-view.mjs.map +1 -0
  755. package/dist/client/views/index.d.mts +28 -0
  756. package/dist/client/views/layout/admin-layout-provider.d.mts +140 -0
  757. package/dist/client/views/layout/admin-layout-provider.d.mts.map +1 -0
  758. package/dist/client/views/layout/admin-layout-provider.mjs +90 -0
  759. package/dist/client/views/layout/admin-layout-provider.mjs.map +1 -0
  760. package/dist/client/views/layout/admin-layout.d.mts +151 -0
  761. package/dist/client/views/layout/admin-layout.d.mts.map +1 -0
  762. package/dist/client/views/layout/admin-layout.mjs +144 -0
  763. package/dist/client/views/layout/admin-layout.mjs.map +1 -0
  764. package/dist/client/views/layout/admin-root.d.mts +7 -0
  765. package/dist/client/views/layout/admin-router.d.mts +125 -0
  766. package/dist/client/views/layout/admin-router.d.mts.map +1 -0
  767. package/dist/client/views/layout/admin-router.mjs +594 -0
  768. package/dist/client/views/layout/admin-router.mjs.map +1 -0
  769. package/dist/client/views/layout/admin-sidebar.d.mts +105 -0
  770. package/dist/client/views/layout/admin-sidebar.d.mts.map +1 -0
  771. package/dist/client/views/layout/admin-sidebar.mjs +550 -0
  772. package/dist/client/views/layout/admin-sidebar.mjs.map +1 -0
  773. package/dist/client/views/layout/admin-topbar.mjs +128 -0
  774. package/dist/client/views/layout/admin-topbar.mjs.map +1 -0
  775. package/dist/client/views/layout/index.d.mts +5 -0
  776. package/dist/client/views/pages/accept-invite-page.d.mts +67 -0
  777. package/dist/client/views/pages/accept-invite-page.d.mts.map +1 -0
  778. package/dist/client/views/pages/accept-invite-page.mjs +143 -0
  779. package/dist/client/views/pages/accept-invite-page.mjs.map +1 -0
  780. package/dist/client/views/pages/dashboard-page.d.mts +52 -0
  781. package/dist/client/views/pages/dashboard-page.d.mts.map +1 -0
  782. package/dist/client/views/pages/dashboard-page.mjs +45 -0
  783. package/dist/client/views/pages/dashboard-page.mjs.map +1 -0
  784. package/dist/client/views/pages/forgot-password-page.d.mts +59 -0
  785. package/dist/client/views/pages/forgot-password-page.d.mts.map +1 -0
  786. package/dist/client/views/pages/forgot-password-page.mjs +80 -0
  787. package/dist/client/views/pages/forgot-password-page.mjs.map +1 -0
  788. package/dist/client/views/pages/index.d.mts +7 -0
  789. package/dist/client/views/pages/invite-page.d.mts +71 -0
  790. package/dist/client/views/pages/invite-page.d.mts.map +1 -0
  791. package/dist/client/views/pages/invite-page.mjs +86 -0
  792. package/dist/client/views/pages/invite-page.mjs.map +1 -0
  793. package/dist/client/views/pages/login-page.d.mts +76 -0
  794. package/dist/client/views/pages/login-page.d.mts.map +1 -0
  795. package/dist/client/views/pages/login-page.mjs +98 -0
  796. package/dist/client/views/pages/login-page.mjs.map +1 -0
  797. package/dist/client/views/pages/reset-password-page.d.mts +66 -0
  798. package/dist/client/views/pages/reset-password-page.d.mts.map +1 -0
  799. package/dist/client/views/pages/reset-password-page.mjs +105 -0
  800. package/dist/client/views/pages/reset-password-page.mjs.map +1 -0
  801. package/dist/client/views/pages/setup-page.d.mts +64 -0
  802. package/dist/client/views/pages/setup-page.d.mts.map +1 -0
  803. package/dist/client/views/pages/setup-page.mjs +91 -0
  804. package/dist/client/views/pages/setup-page.mjs.map +1 -0
  805. package/dist/client.d.mts +92 -3
  806. package/dist/client.d.mts.map +1 -0
  807. package/dist/client.mjs +54 -12
  808. package/dist/components/rich-text/index.d.mts +1 -0
  809. package/dist/components/rich-text/rich-text-renderer.d.mts +104 -0
  810. package/dist/components/rich-text/rich-text-renderer.d.mts.map +1 -0
  811. package/dist/components/rich-text/rich-text-renderer.mjs +210 -0
  812. package/dist/components/rich-text/rich-text-renderer.mjs.map +1 -0
  813. package/dist/index.d.mts +62 -3
  814. package/dist/index.mjs +54 -12
  815. package/dist/server/adapters/nextjs.d.mts +121 -0
  816. package/dist/server/adapters/nextjs.d.mts.map +1 -0
  817. package/dist/server/adapters/nextjs.mjs +111 -0
  818. package/dist/server/adapters/nextjs.mjs.map +1 -0
  819. package/dist/server/adapters/tanstack.d.mts +133 -0
  820. package/dist/server/adapters/tanstack.d.mts.map +1 -0
  821. package/dist/server/adapters/tanstack.mjs +90 -0
  822. package/dist/server/adapters/tanstack.mjs.map +1 -0
  823. package/dist/server/augmentation.d.mts +1523 -0
  824. package/dist/server/augmentation.d.mts.map +1 -0
  825. package/dist/server/auth-helpers.d.mts +143 -0
  826. package/dist/server/auth-helpers.d.mts.map +1 -0
  827. package/dist/server/auth-helpers.mjs +108 -0
  828. package/dist/server/auth-helpers.mjs.map +1 -0
  829. package/dist/server/block/block-builder.d.mts +319 -0
  830. package/dist/server/block/block-builder.d.mts.map +1 -0
  831. package/dist/server/block/block-builder.mjs +217 -0
  832. package/dist/server/block/block-builder.mjs.map +1 -0
  833. package/dist/server/block/index.d.mts +3 -0
  834. package/dist/server/block/introspection.d.mts +84 -0
  835. package/dist/server/block/introspection.d.mts.map +1 -0
  836. package/dist/server/block/introspection.mjs +89 -0
  837. package/dist/server/block/introspection.mjs.map +1 -0
  838. package/dist/server/block/prefetch.d.mts +78 -0
  839. package/dist/server/block/prefetch.d.mts.map +1 -0
  840. package/dist/server/block/prefetch.mjs +240 -0
  841. package/dist/server/block/prefetch.mjs.map +1 -0
  842. package/dist/server/fields/blocks.d.mts +139 -0
  843. package/dist/server/fields/blocks.d.mts.map +1 -0
  844. package/dist/server/fields/blocks.mjs +192 -0
  845. package/dist/server/fields/blocks.mjs.map +1 -0
  846. package/dist/server/fields/index.d.mts +48 -0
  847. package/dist/server/fields/index.d.mts.map +1 -0
  848. package/dist/server/fields/index.mjs +16 -0
  849. package/dist/server/fields/index.mjs.map +1 -0
  850. package/dist/server/fields/rich-text.d.mts +135 -0
  851. package/dist/server/fields/rich-text.d.mts.map +1 -0
  852. package/dist/server/fields/rich-text.mjs +188 -0
  853. package/dist/server/fields/rich-text.mjs.map +1 -0
  854. package/dist/server/i18n/index.d.mts +16 -0
  855. package/dist/server/i18n/index.d.mts.map +1 -0
  856. package/dist/server/i18n/index.mjs +44 -0
  857. package/dist/server/i18n/index.mjs.map +1 -0
  858. package/dist/server/i18n/messages/cs.mjs +461 -0
  859. package/dist/server/i18n/messages/cs.mjs.map +1 -0
  860. package/dist/server/i18n/messages/de.mjs +461 -0
  861. package/dist/server/i18n/messages/de.mjs.map +1 -0
  862. package/dist/server/i18n/messages/en.mjs +493 -0
  863. package/dist/server/i18n/messages/en.mjs.map +1 -0
  864. package/dist/server/i18n/messages/es.mjs +461 -0
  865. package/dist/server/i18n/messages/es.mjs.map +1 -0
  866. package/dist/server/i18n/messages/fr.mjs +461 -0
  867. package/dist/server/i18n/messages/fr.mjs.map +1 -0
  868. package/dist/server/i18n/messages/index.mjs +24 -0
  869. package/dist/server/i18n/messages/index.mjs.map +1 -0
  870. package/dist/server/i18n/messages/pl.mjs +461 -0
  871. package/dist/server/i18n/messages/pl.mjs.map +1 -0
  872. package/dist/server/i18n/messages/pt.mjs +464 -0
  873. package/dist/server/i18n/messages/pt.mjs.map +1 -0
  874. package/dist/server/i18n/messages/sk.mjs +490 -0
  875. package/dist/server/i18n/messages/sk.mjs.map +1 -0
  876. package/dist/server/index.d.mts +20 -0
  877. package/dist/server/modules/admin/functions/admin-config.mjs +348 -0
  878. package/dist/server/modules/admin/functions/admin-config.mjs.map +1 -0
  879. package/dist/server/modules/admin/functions/execute-action.d.mts +107 -0
  880. package/dist/server/modules/admin/functions/execute-action.d.mts.map +1 -0
  881. package/dist/server/modules/admin/functions/execute-action.mjs +331 -0
  882. package/dist/server/modules/admin/functions/execute-action.mjs.map +1 -0
  883. package/dist/server/modules/admin/functions/locales.mjs +80 -0
  884. package/dist/server/modules/admin/functions/locales.mjs.map +1 -0
  885. package/dist/server/modules/admin/functions/preview.d.mts +70 -0
  886. package/dist/server/modules/admin/functions/preview.d.mts.map +1 -0
  887. package/dist/server/modules/admin/functions/preview.mjs +243 -0
  888. package/dist/server/modules/admin/functions/preview.mjs.map +1 -0
  889. package/dist/server/modules/admin/functions/reactive.d.mts +99 -0
  890. package/dist/server/modules/admin/functions/reactive.d.mts.map +1 -0
  891. package/dist/server/modules/admin/functions/reactive.mjs +378 -0
  892. package/dist/server/modules/admin/functions/reactive.mjs.map +1 -0
  893. package/dist/server/modules/admin/functions/setup.d.mts +84 -0
  894. package/dist/server/modules/admin/functions/setup.d.mts.map +1 -0
  895. package/dist/server/modules/admin/functions/setup.mjs +131 -0
  896. package/dist/server/modules/admin/functions/setup.mjs.map +1 -0
  897. package/dist/server/modules/admin/functions/translations.mjs +125 -0
  898. package/dist/server/modules/admin/functions/translations.mjs.map +1 -0
  899. package/dist/server/modules/admin/functions/widget-data.d.mts +33 -0
  900. package/dist/server/modules/admin/functions/widget-data.d.mts.map +1 -0
  901. package/dist/server/modules/admin/functions/widget-data.mjs +70 -0
  902. package/dist/server/modules/admin/functions/widget-data.mjs.map +1 -0
  903. package/dist/server/modules/admin/index.d.mts +16879 -0
  904. package/dist/server/modules/admin/index.d.mts.map +1 -0
  905. package/dist/server/modules/admin/index.mjs +249 -0
  906. package/dist/server/modules/admin/index.mjs.map +1 -0
  907. package/dist/server/modules/admin-preferences/collections/admin-preferences.collection.d.mts +3 -0
  908. package/dist/server/modules/admin-preferences/collections/admin-preferences.collection.mjs +48 -0
  909. package/dist/server/modules/admin-preferences/collections/admin-preferences.collection.mjs.map +1 -0
  910. package/dist/server/modules/admin-preferences/collections/locks.collection.d.mts +3 -0
  911. package/dist/server/modules/admin-preferences/collections/locks.collection.mjs +79 -0
  912. package/dist/server/modules/admin-preferences/collections/locks.collection.mjs.map +1 -0
  913. package/dist/server/modules/admin-preferences/collections/saved-views.collection.d.mts +1490 -0
  914. package/dist/server/modules/admin-preferences/collections/saved-views.collection.d.mts.map +1 -0
  915. package/dist/server/modules/admin-preferences/collections/saved-views.collection.mjs +57 -0
  916. package/dist/server/modules/admin-preferences/collections/saved-views.collection.mjs.map +1 -0
  917. package/dist/server/patch.d.mts +100 -0
  918. package/dist/server/patch.d.mts.map +1 -0
  919. package/dist/server/patch.mjs +1062 -0
  920. package/dist/server/patch.mjs.map +1 -0
  921. package/dist/server.d.mts +21 -250
  922. package/dist/server.mjs +19 -832
  923. package/dist/shared/preview-utils.d.mts +54 -0
  924. package/dist/shared/preview-utils.d.mts.map +1 -0
  925. package/dist/{preview-utils-BKQ9-TMa.mjs → shared/preview-utils.mjs} +2 -2
  926. package/dist/shared/preview-utils.mjs.map +1 -0
  927. package/dist/{saved-views.types-BMsz5mCy.d.mts → shared/types/saved-views.types.d.mts} +7 -2
  928. package/dist/shared/types/saved-views.types.d.mts.map +1 -0
  929. package/dist/shared.d.mts +3 -57
  930. package/dist/shared.mjs +1 -1
  931. package/package.json +12 -17
  932. package/dist/auth-layout-M8K8_q5R.mjs +0 -181
  933. package/dist/auth-layout-M8K8_q5R.mjs.map +0 -1
  934. package/dist/bulk-upload-dialog-D7w7W1Hl.mjs +0 -273
  935. package/dist/bulk-upload-dialog-D7w7W1Hl.mjs.map +0 -1
  936. package/dist/client-B7r47hEd.d.mts +0 -13403
  937. package/dist/client-B7r47hEd.d.mts.map +0 -1
  938. package/dist/client-njX1rZmi.mjs +0 -22612
  939. package/dist/client-njX1rZmi.mjs.map +0 -1
  940. package/dist/content-locales-provider-BXvuIgfg.mjs +0 -1650
  941. package/dist/content-locales-provider-BXvuIgfg.mjs.map +0 -1
  942. package/dist/dashboard-page-B4PGEdc2.mjs +0 -2500
  943. package/dist/dashboard-page-B4PGEdc2.mjs.map +0 -1
  944. package/dist/dashboard-page-mCY0pgZv.mjs +0 -3
  945. package/dist/dropzone-Do3awXKd.mjs +0 -634
  946. package/dist/dropzone-Do3awXKd.mjs.map +0 -1
  947. package/dist/forgot-password-page-Bcp-An4Y.mjs.map +0 -1
  948. package/dist/forgot-password-page-CEwsdLwn.mjs +0 -3
  949. package/dist/index-BYyqkWtn.d.mts +0 -2753
  950. package/dist/index-BYyqkWtn.d.mts.map +0 -1
  951. package/dist/login-page-BUnpCbCa.mjs +0 -3
  952. package/dist/login-page-CP4gA-dl.mjs +0 -298
  953. package/dist/login-page-CP4gA-dl.mjs.map +0 -1
  954. package/dist/preview-utils-BKQ9-TMa.mjs.map +0 -1
  955. package/dist/reset-password-page-BqfDmLxA.mjs +0 -281
  956. package/dist/reset-password-page-BqfDmLxA.mjs.map +0 -1
  957. package/dist/reset-password-page-CufHz3h3.mjs +0 -3
  958. package/dist/runtime-6VZM878K.mjs.map +0 -1
  959. package/dist/saved-views.types-BMsz5mCy.d.mts.map +0 -1
  960. package/dist/server.d.mts.map +0 -1
  961. package/dist/server.mjs.map +0 -1
  962. package/dist/setup-page-BNNzt_Z6.mjs +0 -3
  963. package/dist/setup-page-YAP_fzqh.mjs.map +0 -1
  964. package/dist/shared.d.mts.map +0 -1
  965. package/dist/use-auth-BoLmWtmU.mjs.map +0 -1
@@ -0,0 +1,240 @@
1
+ //#region src/server/block/prefetch.ts
2
+ /**
3
+ * Expand relation/upload fields declared in `prefetchWith`.
4
+ *
5
+ * Uses the same object syntax as `with` in find operations:
6
+ * ```ts
7
+ * { backgroundImage: true, author: { with: { avatar: true } } }
8
+ * ```
9
+ *
10
+ * Nested `with` is passed through to the collection's `find` call,
11
+ * reusing the existing relation resolution machinery.
12
+ *
13
+ * @internal
14
+ */
15
+ async function expandDeclaredFields(allNodes, values, blockDefinitions, ctx) {
16
+ const expansionsByCollection = /* @__PURE__ */ new Map();
17
+ for (const node of allNodes) {
18
+ const blockDef = blockDefinitions[node.type];
19
+ const prefetchWith = blockDef?.state.prefetchWith;
20
+ if (!prefetchWith || typeof prefetchWith !== "object") continue;
21
+ if (!blockDef?.state.fields) continue;
22
+ const blockValues = values[node.id] || {};
23
+ for (const [fieldName, fieldConfig] of Object.entries(prefetchWith)) {
24
+ if (!fieldConfig) continue;
25
+ const fieldDef = blockDef.state.fields[fieldName];
26
+ if (!fieldDef || typeof fieldDef !== "object") continue;
27
+ const metadata = "getMetadata" in fieldDef && typeof fieldDef.getMetadata === "function" ? fieldDef.getMetadata() : void 0;
28
+ if (!metadata) continue;
29
+ if (metadata.type !== "relation") continue;
30
+ const targetCollection = metadata.targetCollection;
31
+ if (!targetCollection || typeof targetCollection !== "string") continue;
32
+ const value = blockValues[fieldName];
33
+ if (!value) continue;
34
+ const stringIds = (Array.isArray(value) ? value : [value]).filter((id) => typeof id === "string" && id.length > 0);
35
+ if (stringIds.length === 0) continue;
36
+ const nestedWith = typeof fieldConfig === "object" && fieldConfig.with ? fieldConfig.with : void 0;
37
+ const groupKey = nestedWith ? `${targetCollection}:${JSON.stringify(nestedWith)}` : targetCollection;
38
+ if (!expansionsByCollection.has(groupKey)) expansionsByCollection.set(groupKey, {
39
+ ids: /* @__PURE__ */ new Set(),
40
+ targets: [],
41
+ nestedWith
42
+ });
43
+ const entry = expansionsByCollection.get(groupKey);
44
+ for (const id of stringIds) entry.ids.add(id);
45
+ entry.targets.push({
46
+ blockId: node.id,
47
+ fieldName,
48
+ isSingle: !Array.isArray(value),
49
+ nestedWith
50
+ });
51
+ }
52
+ }
53
+ if (expansionsByCollection.size === 0) return {};
54
+ const fetchedByGroup = /* @__PURE__ */ new Map();
55
+ const fetchPromises = [...expansionsByCollection.entries()].map(async ([groupKey, { ids, nestedWith }]) => {
56
+ const collection = groupKey.includes(":") ? groupKey.slice(0, groupKey.indexOf(":")) : groupKey;
57
+ try {
58
+ const appApi = ctx.app?.api?.collections?.[collection];
59
+ if (!appApi?.find) {
60
+ console.warn(`[prefetch] Collection "${collection}" not found on app API, skipping`);
61
+ return;
62
+ }
63
+ const result = await appApi.find({
64
+ where: { id: { in: [...ids] } },
65
+ limit: ids.size,
66
+ ...nestedWith ? { with: nestedWith } : {}
67
+ });
68
+ const recordMap = /* @__PURE__ */ new Map();
69
+ for (const doc of result?.docs || []) if (doc && typeof doc === "object" && "id" in doc) recordMap.set(doc.id, doc);
70
+ fetchedByGroup.set(groupKey, recordMap);
71
+ } catch (error) {
72
+ console.error(`[prefetch] Failed to fetch from "${collection}":`, error);
73
+ }
74
+ });
75
+ await Promise.all(fetchPromises);
76
+ const expandedData = {};
77
+ for (const [groupKey, { targets }] of expansionsByCollection) {
78
+ const recordMap = fetchedByGroup.get(groupKey);
79
+ if (!recordMap) continue;
80
+ for (const { blockId, fieldName, isSingle } of targets) {
81
+ if (!expandedData[blockId]) expandedData[blockId] = {};
82
+ const blockVal = (values[blockId] || {})[fieldName];
83
+ if (isSingle) expandedData[blockId][fieldName] = recordMap.get(blockVal) ?? null;
84
+ else {
85
+ const ids = blockVal;
86
+ expandedData[blockId][fieldName] = ids.map((id) => recordMap.get(id)).filter(Boolean);
87
+ }
88
+ }
89
+ }
90
+ return expandedData;
91
+ }
92
+ /**
93
+ * Process blocks data for a single blocks document.
94
+ *
95
+ * This function does two things:
96
+ * 1. **Expands declared fields** from `.prefetch({ with: [...] })` (batch-fetched)
97
+ * 2. **Executes prefetch functions/loaders** for blocks that have them
98
+ *
99
+ * The results are merged into `_data[blockId]`. Prefetch function / loader data
100
+ * takes precedence over expanded data on key conflicts.
101
+ *
102
+ * @param blocks - The blocks document to process
103
+ * @param blockDefinitions - Registered block definitions
104
+ * @param ctx - Prefetch context
105
+ * @returns The blocks document with `_data` populated
106
+ */
107
+ async function processBlocksDocument(blocks, blockDefinitions, ctx) {
108
+ if (!blocks || !blocks._tree || !blocks._values) return blocks;
109
+ const allNodes = [];
110
+ const collectNodes = (nodes) => {
111
+ for (const node of nodes) {
112
+ allNodes.push(node);
113
+ if (node.children.length > 0) collectNodes(node.children);
114
+ }
115
+ };
116
+ collectNodes(blocks._tree);
117
+ const expandedData = await expandDeclaredFields(allNodes, blocks._values, blockDefinitions, ctx);
118
+ const prefetchedData = await executePrefetchFunctions(allNodes, blocks._values, blockDefinitions, ctx, expandedData);
119
+ const mergedData = {};
120
+ const allBlockIds = new Set([...Object.keys(expandedData), ...Object.keys(prefetchedData)]);
121
+ for (const blockId of allBlockIds) mergedData[blockId] = {
122
+ ...expandedData[blockId] || {},
123
+ ...prefetchedData[blockId] || {}
124
+ };
125
+ return {
126
+ ...blocks,
127
+ _data: mergedData
128
+ };
129
+ }
130
+ /**
131
+ * Execute prefetch functions and loaders for blocks.
132
+ *
133
+ * Handles two shapes:
134
+ * - Shape 1: `state.prefetch` — call with `{ values, ctx }`
135
+ * - Shape 3: `state._prefetchLoader` — call with `{ values, expanded, ctx }`
136
+ *
137
+ * Shape 2 (with-only) has no function to call — expansion is handled separately.
138
+ *
139
+ * @internal
140
+ */
141
+ async function executePrefetchFunctions(allNodes, values, blockDefinitions, ctx, expandedData) {
142
+ const prefetchedData = {};
143
+ const prefetchPromises = [];
144
+ for (const node of allNodes) {
145
+ const blockDef = blockDefinitions[node.type];
146
+ if (!blockDef) continue;
147
+ const blockValues = values[node.id] || {};
148
+ const prefetchCtx = {
149
+ blockId: node.id,
150
+ blockType: node.type,
151
+ app: ctx.app,
152
+ db: ctx.db,
153
+ locale: ctx.locale
154
+ };
155
+ const loader = blockDef.state._prefetchLoader;
156
+ if (typeof loader === "function") {
157
+ const expanded = expandedData[node.id] || {};
158
+ prefetchPromises.push((async () => {
159
+ try {
160
+ const data = await loader({
161
+ values: blockValues,
162
+ expanded,
163
+ ctx: prefetchCtx
164
+ });
165
+ if (data && typeof data === "object") prefetchedData[node.id] = data;
166
+ } catch (error) {
167
+ console.error(`Block prefetch loader failed for ${node.type}:${node.id}:`, error);
168
+ prefetchedData[node.id] = { _error: "Prefetch failed" };
169
+ }
170
+ })());
171
+ } else if (blockDef.state.prefetch) prefetchPromises.push((async () => {
172
+ try {
173
+ const data = await blockDef.executePrefetch(blockValues, prefetchCtx);
174
+ prefetchedData[node.id] = data;
175
+ } catch (error) {
176
+ console.error(`Block prefetch failed for ${node.type}:${node.id}:`, error);
177
+ prefetchedData[node.id] = { _error: "Prefetch failed" };
178
+ }
179
+ })());
180
+ }
181
+ await Promise.all(prefetchPromises);
182
+ return prefetchedData;
183
+ }
184
+ /**
185
+ * Process blocks prefetch for a document.
186
+ * Finds all blocks fields in the document and processes them.
187
+ *
188
+ * @param doc - The document containing blocks fields
189
+ * @param fieldDefinitions - Field definitions to identify blocks fields
190
+ * @param blockDefinitions - Registered block definitions
191
+ * @param ctx - Prefetch context
192
+ * @returns The document with blocks prefetch data attached
193
+ */
194
+ async function processDocumentBlocksPrefetch(doc, fieldDefinitions, blockDefinitions, ctx) {
195
+ if (!doc || !blockDefinitions || Object.keys(blockDefinitions).length === 0) return doc;
196
+ const result = { ...doc };
197
+ for (const [fieldName, fieldDef] of Object.entries(fieldDefinitions)) if (fieldDef?.state?.config?.type === "blocks" && result[fieldName]) result[fieldName] = await processBlocksDocument(result[fieldName], blockDefinitions, ctx);
198
+ return result;
199
+ }
200
+ /**
201
+ * Create an afterRead hook for processing blocks prefetch.
202
+ * This hook can be added to collections that have blocks fields.
203
+ *
204
+ * @example
205
+ * ```ts
206
+ * import { createBlocksPrefetchHook } from "@questpie/admin/server";
207
+ *
208
+ * const pages = q.collection("pages")
209
+ * .fields((f) => ({
210
+ * title: f.text({ required: true }),
211
+ * content: f.blocks({ allowedBlocks: ["hero", "text"] }),
212
+ * }))
213
+ * .hooks({
214
+ * afterRead: createBlocksPrefetchHook(),
215
+ * });
216
+ * ```
217
+ */
218
+ function createBlocksPrefetchHook() {
219
+ return async (ctx) => {
220
+ const blocks = ctx.app?.state?.blocks;
221
+ if (!blocks || Object.keys(blocks).length === 0) return;
222
+ for (const [key, value] of Object.entries(ctx.data)) if (isBlocksDocument(value)) ctx.data[key] = await processBlocksDocument(value, blocks, {
223
+ app: ctx.app,
224
+ db: ctx.db,
225
+ locale: ctx.locale
226
+ });
227
+ };
228
+ }
229
+ /**
230
+ * Check if a value is a blocks document.
231
+ */
232
+ function isBlocksDocument(value) {
233
+ if (!value || typeof value !== "object") return false;
234
+ const doc = value;
235
+ return Array.isArray(doc._tree) && typeof doc._values === "object" && doc._values !== null;
236
+ }
237
+
238
+ //#endregion
239
+ export { createBlocksPrefetchHook, processBlocksDocument, processDocumentBlocksPrefetch };
240
+ //# sourceMappingURL=prefetch.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prefetch.mjs","names":["expandedData: Record<string, Record<string, unknown>>","allNodes: Array<{ id: string; type: string; children: any[] }>","mergedData: Record<string, Record<string, unknown>>","prefetchedData: Record<string, Record<string, unknown>>","prefetchPromises: Promise<void>[]","prefetchCtx: BlockPrefetchContext","result: Record<string, unknown>"],"sources":["../../../src/server/block/prefetch.ts"],"sourcesContent":["/**\n * Server CRUD Block Prefetch Utility\n *\n * Handles data fetching for blocks during the afterRead hook.\n * The fetched data is attached to `_data[blockId]` in the response.\n *\n * Two mechanisms populate `_data`:\n *\n * 1. **Declared field expansion** (`.prefetch({ with: [...] })`): Explicitly\n * declared relation/upload fields are batch-fetched and expanded to full records.\n * Only the fields listed in `with` are expanded — nothing is implicit.\n *\n * 2. **Custom prefetch function** (`.prefetch(fn)`): For computed data that can't\n * be auto-expanded, define a prefetch function that returns arbitrary data.\n *\n * 3. **Expand + loader** (`.prefetch({ with: [...], loader })`): Expand fields\n * first, then pass the expanded data to a loader for additional processing.\n *\n * @example\n * ```ts\n * // Shape 1: Pure function\n * block(\"featuredPosts\").prefetch(async ({ values, ctx }) => {\n * return { posts: await fetchPosts(values.count) };\n * })\n *\n * // Shape 2: Expand specific fields\n * block(\"hero\").prefetch({ with: ['backgroundImage'] })\n *\n * // Shape 3: Expand + custom loader\n * block(\"hero\").prefetch({\n * with: ['backgroundImage'],\n * loader: async ({ expanded, ctx }) => ({\n * analytics: await getStats(),\n * }),\n * })\n * ```\n */\n\nimport type { RegisteredApp } from \"questpie\";\nimport type { BlocksDocument } from \"../fields/blocks.js\";\nimport type {\n\tAnyBlockDefinition,\n\tBlockPrefetchContext,\n} from \"./block-builder.js\";\n\n/**\n * Context for blocks prefetch processing.\n * Typed via Register.app when registered.\n */\nexport interface BlocksPrefetchContext {\n\t/** CMS app instance — typed via Register.app */\n\tapp: RegisteredApp;\n\t/** Database client */\n\tdb: unknown;\n\t/** Current locale */\n\tlocale?: string;\n}\n\n// ============================================================================\n// Declared field expansion (replaces old auto-expansion)\n// ============================================================================\n\n/**\n * Tracks a field that needs expansion.\n * @internal\n */\ninterface ExpansionTarget {\n\tblockId: string;\n\tfieldName: string;\n\t/** Whether the original value was a single ID (not an array) */\n\tisSingle: boolean;\n\t/** Nested `with` config to pass through to the collection's find call */\n\tnestedWith?: Record<string, unknown>;\n}\n\n/**\n * Expand relation/upload fields declared in `prefetchWith`.\n *\n * Uses the same object syntax as `with` in find operations:\n * ```ts\n * { backgroundImage: true, author: { with: { avatar: true } } }\n * ```\n *\n * Nested `with` is passed through to the collection's `find` call,\n * reusing the existing relation resolution machinery.\n *\n * @internal\n */\nasync function expandDeclaredFields(\n\tallNodes: Array<{ id: string; type: string }>,\n\tvalues: Record<string, Record<string, unknown>>,\n\tblockDefinitions: Record<string, AnyBlockDefinition>,\n\tctx: BlocksPrefetchContext,\n): Promise<Record<string, Record<string, unknown>>> {\n\t// Group expansion requirements by target collection for batch fetching\n\t// Key: \"collection:nestedWithHash\" to separate different with configs\n\tconst expansionsByCollection = new Map<\n\t\tstring,\n\t\t{\n\t\t\tids: Set<string>;\n\t\t\ttargets: ExpansionTarget[];\n\t\t\tnestedWith?: Record<string, unknown>;\n\t\t}\n\t>();\n\n\tfor (const node of allNodes) {\n\t\tconst blockDef = blockDefinitions[node.type];\n\t\tconst prefetchWith = blockDef?.state.prefetchWith;\n\t\tif (!prefetchWith || typeof prefetchWith !== \"object\") continue;\n\t\tif (!blockDef?.state.fields) continue;\n\n\t\tconst blockValues = values[node.id] || {};\n\n\t\tfor (const [fieldName, fieldConfig] of Object.entries(prefetchWith)) {\n\t\t\tif (!fieldConfig) continue;\n\n\t\t\tconst fieldDef = blockDef.state.fields[fieldName];\n\t\t\tif (!fieldDef || typeof fieldDef !== \"object\") continue;\n\n\t\t\t// Get field metadata to find the target collection\n\t\t\tconst metadata =\n\t\t\t\t\"getMetadata\" in fieldDef &&\n\t\t\t\ttypeof (fieldDef as any).getMetadata === \"function\"\n\t\t\t\t\t? (fieldDef as any).getMetadata()\n\t\t\t\t\t: undefined;\n\t\t\tif (!metadata) continue;\n\n\t\t\t// Support relation fields and upload fields\n\t\t\tif (metadata.type !== \"relation\") continue;\n\n\t\t\tconst targetCollection = metadata.targetCollection;\n\t\t\tif (!targetCollection || typeof targetCollection !== \"string\") continue;\n\n\t\t\t// Extract ID(s) from block value\n\t\t\tconst value = blockValues[fieldName];\n\t\t\tif (!value) continue;\n\n\t\t\tconst rawIds = Array.isArray(value) ? value : [value];\n\t\t\tconst stringIds = rawIds.filter(\n\t\t\t\t(id): id is string => typeof id === \"string\" && id.length > 0,\n\t\t\t);\n\t\t\tif (stringIds.length === 0) continue;\n\n\t\t\t// Extract nested `with` config (for passing to collection find)\n\t\t\tconst nestedWith =\n\t\t\t\ttypeof fieldConfig === \"object\" && fieldConfig.with\n\t\t\t\t\t? (fieldConfig.with as Record<string, unknown>)\n\t\t\t\t\t: undefined;\n\n\t\t\t// Group by collection + nested with config\n\t\t\tconst groupKey = nestedWith\n\t\t\t\t? `${targetCollection}:${JSON.stringify(nestedWith)}`\n\t\t\t\t: targetCollection;\n\n\t\t\tif (!expansionsByCollection.has(groupKey)) {\n\t\t\t\texpansionsByCollection.set(groupKey, {\n\t\t\t\t\tids: new Set(),\n\t\t\t\t\ttargets: [],\n\t\t\t\t\tnestedWith,\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst entry = expansionsByCollection.get(groupKey)!;\n\t\t\tfor (const id of stringIds) entry.ids.add(id);\n\t\t\tentry.targets.push({\n\t\t\t\tblockId: node.id,\n\t\t\t\tfieldName,\n\t\t\t\tisSingle: !Array.isArray(value),\n\t\t\t\tnestedWith,\n\t\t\t});\n\t\t}\n\t}\n\n\tif (expansionsByCollection.size === 0) return {};\n\n\t// Batch-fetch records from each target collection\n\tconst fetchedByGroup = new Map<string, Map<string, unknown>>();\n\n\tconst fetchPromises = [...expansionsByCollection.entries()].map(\n\t\tasync ([groupKey, { ids, nestedWith }]) => {\n\t\t\t// Extract collection name from group key\n\t\t\tconst collection = groupKey.includes(\":\")\n\t\t\t\t? groupKey.slice(0, groupKey.indexOf(\":\"))\n\t\t\t\t: groupKey;\n\n\t\t\ttry {\n\t\t\t\tconst appApi = (ctx.app as any)?.api?.collections?.[collection];\n\t\t\t\tif (!appApi?.find) {\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`[prefetch] Collection \"${collection}\" not found on app API, skipping`,\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Pass nested `with` through to collection's find — reuses existing\n\t\t\t\t// relation resolution machinery (same as find({ with: { ... } }))\n\t\t\t\tconst result = await appApi.find({\n\t\t\t\t\twhere: { id: { in: [...ids] } },\n\t\t\t\t\tlimit: ids.size,\n\t\t\t\t\t...(nestedWith ? { with: nestedWith } : {}),\n\t\t\t\t});\n\n\t\t\t\tconst recordMap = new Map<string, unknown>();\n\t\t\t\tfor (const doc of result?.docs || []) {\n\t\t\t\t\tif (doc && typeof doc === \"object\" && \"id\" in doc) {\n\t\t\t\t\t\trecordMap.set((doc as any).id, doc);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfetchedByGroup.set(groupKey, recordMap);\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t`[prefetch] Failed to fetch from \"${collection}\":`,\n\t\t\t\t\terror,\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t);\n\tawait Promise.all(fetchPromises);\n\n\t// Distribute expanded records to block _data\n\tconst expandedData: Record<string, Record<string, unknown>> = {};\n\n\tfor (const [groupKey, { targets }] of expansionsByCollection) {\n\t\tconst recordMap = fetchedByGroup.get(groupKey);\n\t\tif (!recordMap) continue;\n\n\t\tfor (const { blockId, fieldName, isSingle } of targets) {\n\t\t\tif (!expandedData[blockId]) expandedData[blockId] = {};\n\n\t\t\tconst blockVal = (values[blockId] || {})[fieldName];\n\t\t\tif (isSingle) {\n\t\t\t\texpandedData[blockId][fieldName] =\n\t\t\t\t\trecordMap.get(blockVal as string) ?? null;\n\t\t\t} else {\n\t\t\t\tconst ids = blockVal as string[];\n\t\t\t\texpandedData[blockId][fieldName] = ids\n\t\t\t\t\t.map((id) => recordMap.get(id))\n\t\t\t\t\t.filter(Boolean);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn expandedData;\n}\n\n// ============================================================================\n// Prefetch function execution\n// ============================================================================\n\n/**\n * Process blocks data for a single blocks document.\n *\n * This function does two things:\n * 1. **Expands declared fields** from `.prefetch({ with: [...] })` (batch-fetched)\n * 2. **Executes prefetch functions/loaders** for blocks that have them\n *\n * The results are merged into `_data[blockId]`. Prefetch function / loader data\n * takes precedence over expanded data on key conflicts.\n *\n * @param blocks - The blocks document to process\n * @param blockDefinitions - Registered block definitions\n * @param ctx - Prefetch context\n * @returns The blocks document with `_data` populated\n */\nexport async function processBlocksDocument(\n\tblocks: BlocksDocument | null | undefined,\n\tblockDefinitions: Record<string, AnyBlockDefinition>,\n\tctx: BlocksPrefetchContext,\n): Promise<BlocksDocument | null | undefined> {\n\tif (!blocks || !blocks._tree || !blocks._values) {\n\t\treturn blocks;\n\t}\n\n\t// Flatten the tree\n\tconst allNodes: Array<{ id: string; type: string; children: any[] }> = [];\n\tconst collectNodes = (\n\t\tnodes: Array<{ id: string; type: string; children: any[] }>,\n\t) => {\n\t\tfor (const node of nodes) {\n\t\t\tallNodes.push(node);\n\t\t\tif (node.children.length > 0) {\n\t\t\t\tcollectNodes(node.children);\n\t\t\t}\n\t\t}\n\t};\n\tcollectNodes(blocks._tree);\n\n\t// Step 1: Expand declared `with` fields (batch across all blocks)\n\tconst expandedData = await expandDeclaredFields(\n\t\tallNodes,\n\t\tblocks._values,\n\t\tblockDefinitions,\n\t\tctx,\n\t);\n\n\t// Step 2: Execute prefetch functions and loaders\n\tconst prefetchedData = await executePrefetchFunctions(\n\t\tallNodes,\n\t\tblocks._values,\n\t\tblockDefinitions,\n\t\tctx,\n\t\texpandedData,\n\t);\n\n\t// Step 3: Merge expanded + prefetched (prefetched overrides on conflict)\n\tconst mergedData: Record<string, Record<string, unknown>> = {};\n\tconst allBlockIds = new Set([\n\t\t...Object.keys(expandedData),\n\t\t...Object.keys(prefetchedData),\n\t]);\n\n\tfor (const blockId of allBlockIds) {\n\t\tmergedData[blockId] = {\n\t\t\t...(expandedData[blockId] || {}),\n\t\t\t...(prefetchedData[blockId] || {}),\n\t\t};\n\t}\n\n\treturn {\n\t\t...blocks,\n\t\t_data: mergedData,\n\t};\n}\n\n/**\n * Execute prefetch functions and loaders for blocks.\n *\n * Handles two shapes:\n * - Shape 1: `state.prefetch` — call with `{ values, ctx }`\n * - Shape 3: `state._prefetchLoader` — call with `{ values, expanded, ctx }`\n *\n * Shape 2 (with-only) has no function to call — expansion is handled separately.\n *\n * @internal\n */\nasync function executePrefetchFunctions(\n\tallNodes: Array<{ id: string; type: string }>,\n\tvalues: Record<string, Record<string, unknown>>,\n\tblockDefinitions: Record<string, AnyBlockDefinition>,\n\tctx: BlocksPrefetchContext,\n\texpandedData: Record<string, Record<string, unknown>>,\n): Promise<Record<string, Record<string, unknown>>> {\n\tconst prefetchedData: Record<string, Record<string, unknown>> = {};\n\tconst prefetchPromises: Promise<void>[] = [];\n\n\tfor (const node of allNodes) {\n\t\tconst blockDef = blockDefinitions[node.type];\n\t\tif (!blockDef) continue;\n\n\t\tconst blockValues = values[node.id] || {};\n\t\tconst prefetchCtx: BlockPrefetchContext = {\n\t\t\tblockId: node.id,\n\t\t\tblockType: node.type,\n\t\t\tapp: ctx.app,\n\t\t\tdb: ctx.db,\n\t\t\tlocale: ctx.locale,\n\t\t};\n\n\t\t// Shape 3: with + loader\n\t\tconst loader = (blockDef.state as any)._prefetchLoader;\n\t\tif (typeof loader === \"function\") {\n\t\t\tconst expanded = expandedData[node.id] || {};\n\t\t\tprefetchPromises.push(\n\t\t\t\t(async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst data = await loader({\n\t\t\t\t\t\t\tvalues: blockValues,\n\t\t\t\t\t\t\texpanded,\n\t\t\t\t\t\t\tctx: prefetchCtx,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (data && typeof data === \"object\") {\n\t\t\t\t\t\t\tprefetchedData[node.id] = data as Record<string, unknown>;\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`Block prefetch loader failed for ${node.type}:${node.id}:`,\n\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tprefetchedData[node.id] = { _error: \"Prefetch failed\" };\n\t\t\t\t\t}\n\t\t\t\t})(),\n\t\t\t);\n\t\t}\n\t\t// Shape 1: pure function prefetch\n\t\telse if (blockDef.state.prefetch) {\n\t\t\tprefetchPromises.push(\n\t\t\t\t(async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst data = await blockDef.executePrefetch(\n\t\t\t\t\t\t\tblockValues,\n\t\t\t\t\t\t\tprefetchCtx,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tprefetchedData[node.id] = data;\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`Block prefetch failed for ${node.type}:${node.id}:`,\n\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tprefetchedData[node.id] = { _error: \"Prefetch failed\" };\n\t\t\t\t\t}\n\t\t\t\t})(),\n\t\t\t);\n\t\t}\n\t}\n\n\tawait Promise.all(prefetchPromises);\n\treturn prefetchedData;\n}\n\n/**\n * Process blocks prefetch for a document.\n * Finds all blocks fields in the document and processes them.\n *\n * @param doc - The document containing blocks fields\n * @param fieldDefinitions - Field definitions to identify blocks fields\n * @param blockDefinitions - Registered block definitions\n * @param ctx - Prefetch context\n * @returns The document with blocks prefetch data attached\n */\nexport async function processDocumentBlocksPrefetch<\n\tT extends Record<string, unknown>,\n>(\n\tdoc: T,\n\tfieldDefinitions: Record<string, { state: { config: { type?: string } } }>,\n\tblockDefinitions: Record<string, AnyBlockDefinition>,\n\tctx: BlocksPrefetchContext,\n): Promise<T> {\n\tif (!doc || !blockDefinitions || Object.keys(blockDefinitions).length === 0) {\n\t\treturn doc;\n\t}\n\n\tconst result: Record<string, unknown> = { ...doc };\n\n\t// Find all blocks fields and process them\n\tfor (const [fieldName, fieldDef] of Object.entries(fieldDefinitions)) {\n\t\tconst fieldType = fieldDef?.state?.config?.type;\n\n\t\tif (fieldType === \"blocks\" && result[fieldName]) {\n\t\t\tresult[fieldName] = await processBlocksDocument(\n\t\t\t\tresult[fieldName] as BlocksDocument,\n\t\t\t\tblockDefinitions,\n\t\t\t\tctx,\n\t\t\t);\n\t\t}\n\t}\n\n\treturn result as T;\n}\n\n/**\n * Create an afterRead hook for processing blocks prefetch.\n * This hook can be added to collections that have blocks fields.\n *\n * @example\n * ```ts\n * import { createBlocksPrefetchHook } from \"@questpie/admin/server\";\n *\n * const pages = q.collection(\"pages\")\n * .fields((f) => ({\n * title: f.text({ required: true }),\n * content: f.blocks({ allowedBlocks: [\"hero\", \"text\"] }),\n * }))\n * .hooks({\n * afterRead: createBlocksPrefetchHook(),\n * });\n * ```\n */\nexport function createBlocksPrefetchHook() {\n\treturn async (ctx: {\n\t\tdata: Record<string, unknown>;\n\t\tapp: any;\n\t\tdb: unknown;\n\t\tlocale?: string;\n\t}) => {\n\t\tconst blocks = ctx.app?.state?.blocks;\n\t\tif (!blocks || Object.keys(blocks).length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Process any field that looks like blocks data\n\t\tfor (const [key, value] of Object.entries(ctx.data)) {\n\t\t\tif (isBlocksDocument(value)) {\n\t\t\t\tctx.data[key] = await processBlocksDocument(value, blocks, {\n\t\t\t\t\tapp: ctx.app,\n\t\t\t\t\tdb: ctx.db,\n\t\t\t\t\tlocale: ctx.locale,\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t};\n}\n\n/**\n * Check if a value is a blocks document.\n */\nfunction isBlocksDocument(value: unknown): value is BlocksDocument {\n\tif (!value || typeof value !== \"object\") return false;\n\tconst doc = value as Record<string, unknown>;\n\treturn (\n\t\tArray.isArray(doc._tree) &&\n\t\ttypeof doc._values === \"object\" &&\n\t\tdoc._values !== null\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;AAwFA,eAAe,qBACd,UACA,QACA,kBACA,KACmD;CAGnD,MAAM,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,WAAW,EAC7C;AAID,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,IAAI,KAAK,CAClD,KAAI,iBAAiB,MAAM,CAC1B,KAAI,KAAK,OAAO,MAAM,sBAAsB,OAAO,QAAQ;GAC1D,KAAK,IAAI;GACT,IAAI,IAAI;GACR,QAAQ,IAAI;GACZ,CAAC;;;;;;AASN,SAAS,iBAAiB,OAAyC;AAClE,KAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;CAChD,MAAM,MAAM;AACZ,QACC,MAAM,QAAQ,IAAI,MAAM,IACxB,OAAO,IAAI,YAAY,YACvB,IAAI,YAAY"}
@@ -0,0 +1,139 @@
1
+ import { AnyBlockDefinition } from "../block/block-builder.mjs";
2
+ import { z } from "zod";
3
+ import * as questpie18982 from "questpie";
4
+ import { BaseFieldConfig, ContextualOperators, FieldMetadataBase } from "questpie";
5
+
6
+ //#region src/server/fields/blocks.d.ts
7
+
8
+ /**
9
+ * Block node in the tree structure.
10
+ * Each block has an id, type, and optional children.
11
+ */
12
+ interface BlockNode {
13
+ /** Unique identifier for this block instance */
14
+ id: string;
15
+ /** Block type name (e.g., "hero", "text", "image") */
16
+ type: string;
17
+ /** Nested child blocks */
18
+ children: BlockNode[];
19
+ }
20
+ /**
21
+ * Block field values.
22
+ * Maps field names to their values for a single block.
23
+ */
24
+ type BlockValues = Record<string, {}>;
25
+ /**
26
+ * Blocks document structure.
27
+ * Normalized format separating tree structure from values.
28
+ */
29
+ interface BlocksDocument {
30
+ /** Tree structure defining block hierarchy */
31
+ _tree: BlockNode[];
32
+ /** Map of block id to field values */
33
+ _values: Record<string, BlockValues>;
34
+ /** Prefetched data for blocks (populated by afterRead hook) */
35
+ _data?: Record<string, Record<string, {}>>;
36
+ }
37
+ /**
38
+ * Blocks field metadata - augmentable by external packages.
39
+ *
40
+ * @example Admin augmentation:
41
+ * ```ts
42
+ * declare module "@questpie/admin/server" {
43
+ * interface BlocksFieldMeta {
44
+ * admin?: {
45
+ * addLabel?: string;
46
+ * emptyMessage?: string;
47
+ * }
48
+ * }
49
+ * }
50
+ * ```
51
+ */
52
+ interface BlocksFieldMeta {
53
+ /** Phantom property to prevent interface collapse - enables module augmentation */
54
+ _?: never;
55
+ }
56
+ /**
57
+ * Blocks field configuration options.
58
+ */
59
+ interface BlocksFieldConfig extends BaseFieldConfig {
60
+ /** Field-specific metadata, augmentable by external packages. */
61
+ meta?: BlocksFieldMeta;
62
+ /**
63
+ * Allowed block types.
64
+ * If specified, only these block types can be added.
65
+ * Block types must be registered via `.blocks()` on the CMS builder.
66
+ */
67
+ allowedBlocks?: string[];
68
+ /**
69
+ * Minimum number of blocks required.
70
+ */
71
+ minBlocks?: number;
72
+ /**
73
+ * Maximum number of blocks allowed.
74
+ */
75
+ maxBlocks?: number;
76
+ /**
77
+ * Allow nesting blocks (blocks with children).
78
+ * @default true
79
+ */
80
+ allowNesting?: boolean;
81
+ /**
82
+ * Maximum nesting depth for blocks.
83
+ * Only applies when allowNesting is true.
84
+ * @default 3
85
+ */
86
+ maxDepth?: number;
87
+ /**
88
+ * Placeholder text shown when no blocks exist.
89
+ */
90
+ placeholder?: string;
91
+ /**
92
+ * Block definitions injected at build time by `.blocks()` patch.
93
+ * Used for per-block field validation in toZodSchema().
94
+ * @internal
95
+ */
96
+ _blockDefinitions?: Record<string, AnyBlockDefinition>;
97
+ }
98
+ /**
99
+ * Blocks field factory.
100
+ * Creates a visual block editor field for page builder functionality.
101
+ *
102
+ * @example
103
+ * ```ts
104
+ * // Basic blocks field
105
+ * const content = blocksField({ label: "Content" });
106
+ *
107
+ * // With allowed blocks
108
+ * const pageContent = blocksField({
109
+ * label: "Page Sections",
110
+ * allowedBlocks: ["hero", "features", "testimonials", "cta"],
111
+ * minBlocks: 1,
112
+ * maxBlocks: 20,
113
+ * });
114
+ *
115
+ * // With nesting disabled
116
+ * const simpleBlocks = blocksField({
117
+ * label: "Components",
118
+ * allowNesting: false,
119
+ * });
120
+ * ```
121
+ */
122
+ declare const blocksField: {
123
+ readonly type: "blocks";
124
+ readonly _value: BlocksDocument;
125
+ readonly toColumn: (_name: string, config: BlocksFieldConfig) => any;
126
+ readonly toZodSchema: (config: BlocksFieldConfig) => z.ZodType<BlocksDocument | null | undefined, unknown, z.core.$ZodTypeInternals<BlocksDocument | null | undefined, unknown>>;
127
+ readonly getOperators: <TApp>() => ContextualOperators<questpie18982.OperatorMap, questpie18982.OperatorMap>;
128
+ readonly getMetadata: (config: BlocksFieldConfig) => FieldMetadataBase & {
129
+ allowedBlocks?: string[];
130
+ minBlocks?: number;
131
+ maxBlocks?: number;
132
+ allowNesting: boolean;
133
+ maxDepth: number;
134
+ placeholder?: string;
135
+ };
136
+ };
137
+ //#endregion
138
+ export { BlockNode, BlockValues, BlocksDocument, BlocksFieldConfig, BlocksFieldMeta, blocksField };
139
+ //# sourceMappingURL=blocks.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blocks.d.mts","names":[],"sources":["../../../src/server/fields/blocks.ts"],"sourcesContent":[],"mappings":";;;;;;;AAkFA;AAYA;;;AA4CqB,UAvGJ,SAAA,CAuGI;EA5CsB;EAAe,EAAA,EAAA,MAAA;EAsJ7C;EAEoB,IAAA,EAAA,MAAA;EAEA;EAmBZ,QAAA,EAlOV,SAkOU,EAAA;;;;;;AAuGH,KAlUN,WAAA,GAAc,MAkUR,CAAA,MAAA,EAAA,CAAA,CAAA,CAAA;;;;;UA5TD,cAAA;;SAET;;WAEE,eAAe;;UAEhB,eAAe;;;;;;;;;;;;;;;;;UAsBP,eAAA;;;;;;;UAYA,iBAAA,SAA0B;;SAEnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBA0Ca,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;cA0GvB;;mBAEoB;6CAEA;iCAmBZ,sBAAiB,CAAA,CAAA,QAAA,4CAAA,CAAA,CAAA,IAAA,CAAA,kBAAA;qCAuGpB,oBAvGoB,aAAA,CAuGpB,WAAA,EAAA,aAAA,CAAA,WAAA;iCAIG,sBAAoB"}
@@ -0,0 +1,192 @@
1
+ import { z } from "zod";
2
+ import { field, isNotNull, isNull, jsonb, sql } from "questpie";
3
+
4
+ //#region src/server/fields/blocks.ts
5
+ /**
6
+ * Blocks Field Type
7
+ *
8
+ * Visual block editor field stored as JSONB.
9
+ * Provides a tree-based structure for page builder functionality.
10
+ *
11
+ * The blocks field stores data in a normalized format:
12
+ * - _tree: Array of block nodes with id, type, and children
13
+ * - _values: Record mapping block id to field values
14
+ *
15
+ * This field type is only available when using adminModule.
16
+ */
17
+ /**
18
+ * Get operators for blocks field.
19
+ * Provides operators for querying block content.
20
+ */
21
+ function getBlocksOperators() {
22
+ return {
23
+ column: {
24
+ hasBlockType: (col, value) => sql`EXISTS (
25
+ SELECT 1 FROM jsonb_array_elements(${col}->'_tree') AS block
26
+ WHERE block->>'type' = ${value}
27
+ )`,
28
+ blockCount: (col, value) => {
29
+ const { op, count } = value;
30
+ const operator = op === "gte" ? ">=" : op === "lte" ? "<=" : "=";
31
+ return sql`jsonb_array_length(${col}->'_tree') ${sql.raw(operator)} ${count}`;
32
+ },
33
+ isEmpty: (col) => sql`(
34
+ ${col} IS NULL
35
+ OR ${col}->'_tree' IS NULL
36
+ OR jsonb_array_length(${col}->'_tree') = 0
37
+ )`,
38
+ isNotEmpty: (col) => sql`(
39
+ ${col} IS NOT NULL
40
+ AND ${col}->'_tree' IS NOT NULL
41
+ AND jsonb_array_length(${col}->'_tree') > 0
42
+ )`,
43
+ isNull: (col) => isNull(col),
44
+ isNotNull: (col) => isNotNull(col)
45
+ },
46
+ jsonb: {
47
+ hasBlockType: (col, value, ctx) => {
48
+ const path = ctx.jsonbPath?.join(",") ?? "";
49
+ return sql`EXISTS (
50
+ SELECT 1 FROM jsonb_array_elements(${col}#>'{${sql.raw(path)},_tree}') AS block
51
+ WHERE block->>'type' = ${value}
52
+ )`;
53
+ },
54
+ isEmpty: (col, _value, ctx) => {
55
+ const path = ctx.jsonbPath?.join(",") ?? "";
56
+ return sql`(
57
+ ${col}#>'{${sql.raw(path)}}' IS NULL
58
+ OR ${col}#>'{${sql.raw(path)},_tree}' IS NULL
59
+ OR jsonb_array_length(${col}#>'{${sql.raw(path)},_tree}') = 0
60
+ )`;
61
+ },
62
+ isNotEmpty: (col, _value, ctx) => {
63
+ const path = ctx.jsonbPath?.join(",") ?? "";
64
+ return sql`(
65
+ ${col}#>'{${sql.raw(path)}}' IS NOT NULL
66
+ AND ${col}#>'{${sql.raw(path)},_tree}' IS NOT NULL
67
+ AND jsonb_array_length(${col}#>'{${sql.raw(path)},_tree}') > 0
68
+ )`;
69
+ },
70
+ isNull: (col, _value, ctx) => {
71
+ const path = ctx.jsonbPath?.join(",") ?? "";
72
+ return sql`${col}#>'{${sql.raw(path)}}' IS NULL`;
73
+ },
74
+ isNotNull: (col, _value, ctx) => {
75
+ const path = ctx.jsonbPath?.join(",") ?? "";
76
+ return sql`${col}#>'{${sql.raw(path)}}' IS NOT NULL`;
77
+ }
78
+ }
79
+ };
80
+ }
81
+ /**
82
+ * Blocks field factory.
83
+ * Creates a visual block editor field for page builder functionality.
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * // Basic blocks field
88
+ * const content = blocksField({ label: "Content" });
89
+ *
90
+ * // With allowed blocks
91
+ * const pageContent = blocksField({
92
+ * label: "Page Sections",
93
+ * allowedBlocks: ["hero", "features", "testimonials", "cta"],
94
+ * minBlocks: 1,
95
+ * maxBlocks: 20,
96
+ * });
97
+ *
98
+ * // With nesting disabled
99
+ * const simpleBlocks = blocksField({
100
+ * label: "Components",
101
+ * allowNesting: false,
102
+ * });
103
+ * ```
104
+ */
105
+ const blocksField = field()({
106
+ type: "blocks",
107
+ _value: void 0,
108
+ toColumn(_name, config) {
109
+ let column = jsonb();
110
+ if (config.required && config.nullable !== true) column = column.notNull();
111
+ if (config.default !== void 0) {
112
+ const defaultValue = typeof config.default === "function" ? config.default() : config.default;
113
+ column = column.default(defaultValue);
114
+ }
115
+ return column;
116
+ },
117
+ toZodSchema(config) {
118
+ const blockNodeSchema = z.lazy(() => z.object({
119
+ id: z.string(),
120
+ type: z.string(),
121
+ children: z.array(blockNodeSchema).default([])
122
+ }));
123
+ let docSchema = z.object({
124
+ _tree: z.array(blockNodeSchema),
125
+ _values: z.record(z.string(), z.record(z.string(), z.any()))
126
+ });
127
+ if (config.minBlocks !== void 0 || config.maxBlocks !== void 0) docSchema = docSchema.refine((doc) => {
128
+ const count = doc._tree.length;
129
+ if (config.minBlocks !== void 0 && count < config.minBlocks) return false;
130
+ if (config.maxBlocks !== void 0 && count > config.maxBlocks) return false;
131
+ return true;
132
+ }, { message: config.minBlocks !== void 0 && config.maxBlocks !== void 0 ? `Must have between ${config.minBlocks} and ${config.maxBlocks} blocks` : config.minBlocks !== void 0 ? `Must have at least ${config.minBlocks} blocks` : `Must have at most ${config.maxBlocks} blocks` });
133
+ if (config._blockDefinitions && Object.keys(config._blockDefinitions).length > 0) {
134
+ const blockDefs = config._blockDefinitions;
135
+ docSchema = docSchema.superRefine((doc, ctx) => {
136
+ const allNodes = [];
137
+ const collectNodes = (nodes) => {
138
+ for (const node of nodes) {
139
+ allNodes.push(node);
140
+ if (node.children.length > 0) collectNodes(node.children);
141
+ }
142
+ };
143
+ collectNodes(doc._tree);
144
+ for (const node of allNodes) {
145
+ const blockDef = blockDefs[node.type];
146
+ if (!blockDef?.state.fields) continue;
147
+ const blockValues = doc._values[node.id] || {};
148
+ for (const [fieldName, fieldDef] of Object.entries(blockDef.state.fields)) if (fieldDef && typeof fieldDef === "object" && "toZodSchema" in fieldDef && typeof fieldDef.toZodSchema === "function") {
149
+ const result = fieldDef.toZodSchema().safeParse(blockValues[fieldName]);
150
+ if (!result.success) for (const issue of result.error.issues) ctx.addIssue({
151
+ ...issue,
152
+ path: [
153
+ "_values",
154
+ node.id,
155
+ fieldName,
156
+ ...issue.path
157
+ ],
158
+ message: `Block "${node.type}" field "${fieldName}": ${issue.message}`
159
+ });
160
+ }
161
+ }
162
+ });
163
+ }
164
+ if (!config.required && config.nullable !== false) return docSchema.nullish();
165
+ return docSchema;
166
+ },
167
+ getOperators() {
168
+ return getBlocksOperators();
169
+ },
170
+ getMetadata(config) {
171
+ return {
172
+ type: "blocks",
173
+ label: config.label,
174
+ description: config.description,
175
+ required: config.required ?? false,
176
+ localized: config.localized ?? false,
177
+ readOnly: config.input === false,
178
+ writeOnly: config.output === false,
179
+ meta: config.meta,
180
+ allowedBlocks: config.allowedBlocks,
181
+ minBlocks: config.minBlocks,
182
+ maxBlocks: config.maxBlocks,
183
+ allowNesting: config.allowNesting ?? true,
184
+ maxDepth: config.maxDepth ?? 3,
185
+ placeholder: config.placeholder
186
+ };
187
+ }
188
+ });
189
+
190
+ //#endregion
191
+ export { blocksField };
192
+ //# sourceMappingURL=blocks.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blocks.mjs","names":["column: any","blockNodeSchema: z.ZodType<BlockNode>","allNodes: BlockNode[]"],"sources":["../../../src/server/fields/blocks.ts"],"sourcesContent":["/**\n * Blocks Field Type\n *\n * Visual block editor field stored as JSONB.\n * Provides a tree-based structure for page builder functionality.\n *\n * The blocks field stores data in a normalized format:\n * - _tree: Array of block nodes with id, type, and children\n * - _values: Record mapping block id to field values\n *\n * This field type is only available when using adminModule.\n */\n\nimport {\n\ttype BaseFieldConfig,\n\ttype ContextualOperators,\n\ttype FieldMetadataBase,\n\tfield,\n\tisNotNull,\n\tisNull,\n\tjsonb,\n\tsql,\n} from \"questpie\";\n\nimport { z } from \"zod\";\nimport type { AnyBlockDefinition } from \"../block/block-builder.js\";\n\n// ============================================================================\n// Blocks Data Schema\n// ============================================================================\n\n/**\n * Block node in the tree structure.\n * Each block has an id, type, and optional children.\n */\nexport interface BlockNode {\n\t/** Unique identifier for this block instance */\n\tid: string;\n\t/** Block type name (e.g., \"hero\", \"text\", \"image\") */\n\ttype: string;\n\t/** Nested child blocks */\n\tchildren: BlockNode[];\n}\n\n/**\n * Block field values.\n * Maps field names to their values for a single block.\n */\nexport type BlockValues = Record<string, {}>;\n\n/**\n * Blocks document structure.\n * Normalized format separating tree structure from values.\n */\nexport interface BlocksDocument {\n\t/** Tree structure defining block hierarchy */\n\t_tree: BlockNode[];\n\t/** Map of block id to field values */\n\t_values: Record<string, BlockValues>;\n\t/** Prefetched data for blocks (populated by afterRead hook) */\n\t_data?: Record<string, Record<string, {}>>;\n}\n\n// ============================================================================\n// Blocks Field Meta (augmentable by admin)\n// ============================================================================\n\n/**\n * Blocks field metadata - augmentable by external packages.\n *\n * @example Admin augmentation:\n * ```ts\n * declare module \"@questpie/admin/server\" {\n * interface BlocksFieldMeta {\n * admin?: {\n * addLabel?: string;\n * emptyMessage?: string;\n * }\n * }\n * }\n * ```\n */\nexport interface BlocksFieldMeta {\n\t/** Phantom property to prevent interface collapse - enables module augmentation */\n\t_?: never;\n}\n\n// ============================================================================\n// Blocks Field Configuration\n// ============================================================================\n\n/**\n * Blocks field configuration options.\n */\nexport interface BlocksFieldConfig extends BaseFieldConfig {\n\t/** Field-specific metadata, augmentable by external packages. */\n\tmeta?: BlocksFieldMeta;\n\n\t/**\n\t * Allowed block types.\n\t * If specified, only these block types can be added.\n\t * Block types must be registered via `.blocks()` on the CMS builder.\n\t */\n\tallowedBlocks?: string[];\n\n\t/**\n\t * Minimum number of blocks required.\n\t */\n\tminBlocks?: number;\n\n\t/**\n\t * Maximum number of blocks allowed.\n\t */\n\tmaxBlocks?: number;\n\n\t/**\n\t * Allow nesting blocks (blocks with children).\n\t * @default true\n\t */\n\tallowNesting?: boolean;\n\n\t/**\n\t * Maximum nesting depth for blocks.\n\t * Only applies when allowNesting is true.\n\t * @default 3\n\t */\n\tmaxDepth?: number;\n\n\t/**\n\t * Placeholder text shown when no blocks exist.\n\t */\n\tplaceholder?: string;\n\n\t/**\n\t * Block definitions injected at build time by `.blocks()` patch.\n\t * Used for per-block field validation in toZodSchema().\n\t * @internal\n\t */\n\t_blockDefinitions?: Record<string, AnyBlockDefinition>;\n}\n\n// ============================================================================\n// Blocks Field Operators\n// ============================================================================\n\n/**\n * Get operators for blocks field.\n * Provides operators for querying block content.\n */\nfunction getBlocksOperators(): ContextualOperators {\n\treturn {\n\t\tcolumn: {\n\t\t\t// Check if any block of a specific type exists\n\t\t\thasBlockType: (col, value) =>\n\t\t\t\tsql`EXISTS (\n\t\t\t\t\tSELECT 1 FROM jsonb_array_elements(${col}->'_tree') AS block\n\t\t\t\t\tWHERE block->>'type' = ${value}\n\t\t\t\t)`,\n\t\t\t// Count blocks at root level\n\t\t\tblockCount: (col, value) => {\n\t\t\t\tconst { op, count } = value as { op: string; count: number };\n\t\t\t\tconst operator = op === \"gte\" ? \">=\" : op === \"lte\" ? \"<=\" : \"=\";\n\t\t\t\treturn sql`jsonb_array_length(${col}->'_tree') ${sql.raw(operator)} ${count}`;\n\t\t\t},\n\t\t\t// Check if document is empty (no blocks)\n\t\t\tisEmpty: (col) =>\n\t\t\t\tsql`(\n\t\t\t\t\t${col} IS NULL \n\t\t\t\t\tOR ${col}->'_tree' IS NULL\n\t\t\t\t\tOR jsonb_array_length(${col}->'_tree') = 0\n\t\t\t\t)`,\n\t\t\tisNotEmpty: (col) =>\n\t\t\t\tsql`(\n\t\t\t\t\t${col} IS NOT NULL \n\t\t\t\t\tAND ${col}->'_tree' IS NOT NULL\n\t\t\t\t\tAND jsonb_array_length(${col}->'_tree') > 0\n\t\t\t\t)`,\n\t\t\tisNull: (col) => isNull(col),\n\t\t\tisNotNull: (col) => isNotNull(col),\n\t\t},\n\t\tjsonb: {\n\t\t\thasBlockType: (col, value, ctx) => {\n\t\t\t\tconst path = ctx.jsonbPath?.join(\",\") ?? \"\";\n\t\t\t\treturn sql`EXISTS (\n\t\t\t\t\tSELECT 1 FROM jsonb_array_elements(${col}#>'{${sql.raw(path)},_tree}') AS block\n\t\t\t\t\tWHERE block->>'type' = ${value}\n\t\t\t\t)`;\n\t\t\t},\n\t\t\tisEmpty: (col, _value, ctx) => {\n\t\t\t\tconst path = ctx.jsonbPath?.join(\",\") ?? \"\";\n\t\t\t\treturn sql`(\n\t\t\t\t\t${col}#>'{${sql.raw(path)}}' IS NULL \n\t\t\t\t\tOR ${col}#>'{${sql.raw(path)},_tree}' IS NULL\n\t\t\t\t\tOR jsonb_array_length(${col}#>'{${sql.raw(path)},_tree}') = 0\n\t\t\t\t)`;\n\t\t\t},\n\t\t\tisNotEmpty: (col, _value, ctx) => {\n\t\t\t\tconst path = ctx.jsonbPath?.join(\",\") ?? \"\";\n\t\t\t\treturn sql`(\n\t\t\t\t\t${col}#>'{${sql.raw(path)}}' IS NOT NULL \n\t\t\t\t\tAND ${col}#>'{${sql.raw(path)},_tree}' IS NOT NULL\n\t\t\t\t\tAND jsonb_array_length(${col}#>'{${sql.raw(path)},_tree}') > 0\n\t\t\t\t)`;\n\t\t\t},\n\t\t\tisNull: (col, _value, ctx) => {\n\t\t\t\tconst path = ctx.jsonbPath?.join(\",\") ?? \"\";\n\t\t\t\treturn sql`${col}#>'{${sql.raw(path)}}' IS NULL`;\n\t\t\t},\n\t\t\tisNotNull: (col, _value, ctx) => {\n\t\t\t\tconst path = ctx.jsonbPath?.join(\",\") ?? \"\";\n\t\t\t\treturn sql`${col}#>'{${sql.raw(path)}}' IS NOT NULL`;\n\t\t\t},\n\t\t},\n\t};\n}\n\n// ============================================================================\n// Blocks Field Definition\n// ============================================================================\n\n/**\n * Blocks field factory.\n * Creates a visual block editor field for page builder functionality.\n *\n * @example\n * ```ts\n * // Basic blocks field\n * const content = blocksField({ label: \"Content\" });\n *\n * // With allowed blocks\n * const pageContent = blocksField({\n * label: \"Page Sections\",\n * allowedBlocks: [\"hero\", \"features\", \"testimonials\", \"cta\"],\n * minBlocks: 1,\n * maxBlocks: 20,\n * });\n *\n * // With nesting disabled\n * const simpleBlocks = blocksField({\n * label: \"Components\",\n * allowNesting: false,\n * });\n * ```\n */\nexport const blocksField = field<BlocksFieldConfig, BlocksDocument>()({\n\ttype: \"blocks\" as const,\n\t_value: undefined as unknown as BlocksDocument,\n\n\ttoColumn(_name: string, config: BlocksFieldConfig) {\n\t\t// Blocks are always stored as JSONB\n\t\tlet column: any = jsonb();\n\n\t\t// Apply constraints\n\t\tif (config.required && config.nullable !== true) {\n\t\t\tcolumn = column.notNull();\n\t\t}\n\t\tif (config.default !== undefined) {\n\t\t\tconst defaultValue =\n\t\t\t\ttypeof config.default === \"function\"\n\t\t\t\t\t? config.default()\n\t\t\t\t\t: config.default;\n\t\t\tcolumn = column.default(defaultValue);\n\t\t}\n\n\t\treturn column;\n\t},\n\n\ttoZodSchema(config: BlocksFieldConfig) {\n\t\t// Block node schema (recursive for nested blocks)\n\t\tconst blockNodeSchema: z.ZodType<BlockNode> = z.lazy(() =>\n\t\t\tz.object({\n\t\t\t\tid: z.string(),\n\t\t\t\ttype: z.string(),\n\t\t\t\tchildren: z.array(blockNodeSchema).default([]),\n\t\t\t}),\n\t\t);\n\n\t\t// Blocks document schema\n\t\tlet docSchema = z.object({\n\t\t\t_tree: z.array(blockNodeSchema),\n\t\t\t_values: z.record(z.string(), z.record(z.string(), z.any())),\n\t\t});\n\n\t\t// Apply validation for min/max blocks\n\t\tif (config.minBlocks !== undefined || config.maxBlocks !== undefined) {\n\t\t\tdocSchema = docSchema.refine(\n\t\t\t\t(doc) => {\n\t\t\t\t\tconst count = doc._tree.length;\n\t\t\t\t\tif (config.minBlocks !== undefined && count < config.minBlocks) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tif (config.maxBlocks !== undefined && count > config.maxBlocks) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\treturn true;\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tmessage:\n\t\t\t\t\t\tconfig.minBlocks !== undefined && config.maxBlocks !== undefined\n\t\t\t\t\t\t\t? `Must have between ${config.minBlocks} and ${config.maxBlocks} blocks`\n\t\t\t\t\t\t\t: config.minBlocks !== undefined\n\t\t\t\t\t\t\t\t? `Must have at least ${config.minBlocks} blocks`\n\t\t\t\t\t\t\t\t: `Must have at most ${config.maxBlocks} blocks`,\n\t\t\t\t},\n\t\t\t) as typeof docSchema;\n\t\t}\n\n\t\t// Per-block field validation when block definitions are available\n\t\tif (\n\t\t\tconfig._blockDefinitions &&\n\t\t\tObject.keys(config._blockDefinitions).length > 0\n\t\t) {\n\t\t\tconst blockDefs = config._blockDefinitions;\n\t\t\tdocSchema = docSchema.superRefine((doc, ctx) => {\n\t\t\t\t// Collect all block nodes (flatten tree)\n\t\t\t\tconst allNodes: BlockNode[] = [];\n\t\t\t\tconst collectNodes = (nodes: BlockNode[]) => {\n\t\t\t\t\tfor (const node of nodes) {\n\t\t\t\t\t\tallNodes.push(node);\n\t\t\t\t\t\tif (node.children.length > 0) {\n\t\t\t\t\t\t\tcollectNodes(node.children);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tcollectNodes(doc._tree);\n\n\t\t\t\t// Validate each block's values against its definition's field schemas\n\t\t\t\tfor (const node of allNodes) {\n\t\t\t\t\tconst blockDef = blockDefs[node.type];\n\t\t\t\t\tif (!blockDef?.state.fields) continue;\n\n\t\t\t\t\tconst blockValues = doc._values[node.id] || {};\n\n\t\t\t\t\tfor (const [fieldName, fieldDef] of Object.entries(\n\t\t\t\t\t\tblockDef.state.fields,\n\t\t\t\t\t)) {\n\t\t\t\t\t\t// Server FieldDefinition has toZodSchema()\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tfieldDef &&\n\t\t\t\t\t\t\ttypeof fieldDef === \"object\" &&\n\t\t\t\t\t\t\t\"toZodSchema\" in fieldDef &&\n\t\t\t\t\t\t\ttypeof (fieldDef as any).toZodSchema === \"function\"\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tconst fieldSchema = (fieldDef as any).toZodSchema() as z.ZodType;\n\t\t\t\t\t\t\tconst result = fieldSchema.safeParse(blockValues[fieldName]);\n\t\t\t\t\t\t\tif (!result.success) {\n\t\t\t\t\t\t\t\tfor (const issue of result.error.issues) {\n\t\t\t\t\t\t\t\t\tctx.addIssue({\n\t\t\t\t\t\t\t\t\t\t...issue,\n\t\t\t\t\t\t\t\t\t\tpath: [\"_values\", node.id, fieldName, ...issue.path],\n\t\t\t\t\t\t\t\t\t\tmessage: `Block \"${node.type}\" field \"${fieldName}\": ${issue.message}`,\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}) as typeof docSchema;\n\t\t}\n\n\t\t// Nullability\n\t\tif (!config.required && config.nullable !== false) {\n\t\t\treturn docSchema.nullish() as z.ZodType<\n\t\t\t\tBlocksDocument | null | undefined\n\t\t\t>;\n\t\t}\n\n\t\treturn docSchema as z.ZodType<BlocksDocument>;\n\t},\n\n\tgetOperators<TApp>() {\n\t\treturn getBlocksOperators();\n\t},\n\n\tgetMetadata(config: BlocksFieldConfig): FieldMetadataBase & {\n\t\tallowedBlocks?: string[];\n\t\tminBlocks?: number;\n\t\tmaxBlocks?: number;\n\t\tallowNesting: boolean;\n\t\tmaxDepth: number;\n\t\tplaceholder?: string;\n\t} {\n\t\treturn {\n\t\t\ttype: \"blocks\",\n\t\t\tlabel: config.label,\n\t\t\tdescription: config.description,\n\t\t\trequired: config.required ?? false,\n\t\t\tlocalized: config.localized ?? false,\n\t\t\treadOnly: config.input === false,\n\t\t\twriteOnly: config.output === false,\n\t\t\tmeta: config.meta,\n\t\t\t// Blocks specific\n\t\t\tallowedBlocks: config.allowedBlocks,\n\t\t\tminBlocks: config.minBlocks,\n\t\t\tmaxBlocks: config.maxBlocks,\n\t\t\tallowNesting: config.allowNesting ?? true,\n\t\t\tmaxDepth: config.maxDepth ?? 3,\n\t\t\tplaceholder: config.placeholder,\n\t\t};\n\t},\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqJA,SAAS,qBAA0C;AAClD,QAAO;EACN,QAAQ;GAEP,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