@nodehive/nextjs 0.1.3 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (762) hide show
  1. package/README.md +1 -1
  2. package/dist/auth/index.d.ts +2 -3
  3. package/dist/auth/index.js.map +1 -1
  4. package/dist/auth/internal/config.d.ts +15 -5
  5. package/dist/auth/internal/config.js.map +1 -1
  6. package/dist/auth/internal/draft-mode.d.ts +2 -3
  7. package/dist/auth/internal/draft-mode.js +3 -20
  8. package/dist/auth/internal/draft-mode.js.map +1 -1
  9. package/dist/auth/internal/editor-locale.d.ts +0 -1
  10. package/dist/auth/internal/handoff.d.ts +0 -1
  11. package/dist/auth/internal/has-session.d.ts +0 -1
  12. package/dist/auth/internal/has-session.js +1 -1
  13. package/dist/auth/internal/has-session.js.map +1 -1
  14. package/dist/auth/internal/i18n.d.ts +10 -0
  15. package/dist/auth/internal/i18n.js +25 -0
  16. package/dist/auth/internal/i18n.js.map +1 -0
  17. package/dist/auth/internal/logout.d.ts +1 -2
  18. package/dist/auth/internal/logout.js +3 -3
  19. package/dist/auth/internal/logout.js.map +1 -1
  20. package/dist/auth/internal/next-cookie-storage.d.ts +5 -2
  21. package/dist/auth/internal/next-cookie-storage.js +8 -1
  22. package/dist/auth/internal/next-cookie-storage.js.map +1 -1
  23. package/dist/auth/internal/nodehive-client.d.ts +6 -4
  24. package/dist/auth/internal/nodehive-client.js +6 -4
  25. package/dist/auth/internal/nodehive-client.js.map +1 -1
  26. package/dist/auth/internal/oauth-config.d.ts +0 -1
  27. package/dist/auth/internal/proxy-helpers.d.ts +0 -1
  28. package/dist/auth/internal/proxy-helpers.js +4 -4
  29. package/dist/auth/internal/proxy-helpers.js.map +1 -1
  30. package/dist/auth/internal/refresh.d.ts +1 -2
  31. package/dist/auth/internal/refresh.js +4 -4
  32. package/dist/auth/internal/refresh.js.map +1 -1
  33. package/dist/auth/internal/require-auth.d.ts +0 -1
  34. package/dist/auth/internal/require-auth.js +1 -1
  35. package/dist/auth/internal/require-auth.js.map +1 -1
  36. package/dist/auth/internal/return-to.d.ts +0 -1
  37. package/dist/auth/internal/roles.d.ts +17 -0
  38. package/dist/auth/internal/roles.js +39 -0
  39. package/dist/auth/internal/roles.js.map +1 -0
  40. package/dist/auth/internal/routes/callback.d.ts +1 -2
  41. package/dist/auth/internal/routes/callback.js +6 -6
  42. package/dist/auth/internal/routes/callback.js.map +1 -1
  43. package/dist/auth/internal/routes/chips-exchange.d.ts +1 -2
  44. package/dist/auth/internal/routes/chips-exchange.js +5 -5
  45. package/dist/auth/internal/routes/chips-exchange.js.map +1 -1
  46. package/dist/auth/internal/routes/draft.d.ts +1 -2
  47. package/dist/auth/internal/routes/draft.js +3 -3
  48. package/dist/auth/internal/routes/draft.js.map +1 -1
  49. package/dist/auth/internal/routes/index.d.ts +4 -2
  50. package/dist/auth/internal/routes/index.js +7 -7
  51. package/dist/auth/internal/routes/index.js.map +1 -1
  52. package/dist/auth/internal/routes/login.d.ts +0 -1
  53. package/dist/auth/internal/routes/login.js +3 -3
  54. package/dist/auth/internal/routes/login.js.map +1 -1
  55. package/dist/auth/internal/routes/popup-done.d.ts +2 -2
  56. package/dist/auth/internal/routes/popup-done.js +9 -7
  57. package/dist/auth/internal/routes/popup-done.js.map +1 -1
  58. package/dist/auth/internal/routes/refresh.d.ts +2 -5
  59. package/dist/auth/internal/routes/refresh.js +8 -2
  60. package/dist/auth/internal/routes/refresh.js.map +1 -1
  61. package/dist/auth/internal/same-origin.d.ts +0 -1
  62. package/dist/auth/internal/session-gates.d.ts +27 -3
  63. package/dist/auth/internal/session-gates.js +35 -3
  64. package/dist/auth/internal/session-gates.js.map +1 -1
  65. package/dist/auth/internal/update-session.d.ts +1 -2
  66. package/dist/auth/internal/update-session.js +1 -1
  67. package/dist/auth/internal/update-session.js.map +1 -1
  68. package/dist/auth/internal/use-editor-login.d.ts +0 -1
  69. package/dist/auth/internal/use-editor-login.js +2 -3
  70. package/dist/auth/internal/use-editor-login.js.map +1 -1
  71. package/dist/auth/proxy.d.ts +7 -8
  72. package/dist/auth/proxy.js +6 -6
  73. package/dist/auth/proxy.js.map +1 -1
  74. package/dist/auth/react.d.ts +1 -2
  75. package/dist/auth/react.js +1 -1
  76. package/dist/auth/react.js.map +1 -1
  77. package/dist/auth/routes.d.ts +3 -3
  78. package/dist/auth/routes.js +1 -1
  79. package/dist/auth/routes.js.map +1 -1
  80. package/dist/auth/server.d.ts +14 -12
  81. package/dist/auth/server.js +14 -9
  82. package/dist/auth/server.js.map +1 -1
  83. package/dist/bridge-protocol/index.d.ts +50 -0
  84. package/dist/bridge-protocol/index.js +25 -0
  85. package/dist/bridge-protocol/index.js.map +1 -0
  86. package/dist/puck-editor/editor.d.ts +8 -0
  87. package/dist/puck-editor/editor.js +9 -0
  88. package/dist/puck-editor/editor.js.map +1 -0
  89. package/dist/puck-editor/fields.d.ts +6 -7
  90. package/dist/puck-editor/fields.js +3 -3
  91. package/dist/puck-editor/fields.js.map +1 -1
  92. package/dist/puck-editor/index.d.ts +17 -14
  93. package/dist/puck-editor/index.js +13 -11
  94. package/dist/puck-editor/index.js.map +1 -1
  95. package/dist/puck-editor/internal/api/client.d.ts +19 -4
  96. package/dist/puck-editor/internal/api/client.js +56 -19
  97. package/dist/puck-editor/internal/api/client.js.map +1 -1
  98. package/dist/puck-editor/internal/api/config.d.ts +36 -3
  99. package/dist/puck-editor/internal/api/config.js.map +1 -1
  100. package/dist/puck-editor/internal/api/create-puck-api.d.ts +1 -2
  101. package/dist/puck-editor/internal/api/create-puck-api.js +10 -13
  102. package/dist/puck-editor/internal/api/create-puck-api.js.map +1 -1
  103. package/dist/puck-editor/internal/api/handlers/create-page.d.ts +1 -2
  104. package/dist/puck-editor/internal/api/handlers/create-page.js +6 -4
  105. package/dist/puck-editor/internal/api/handlers/create-page.js.map +1 -1
  106. package/dist/puck-editor/internal/api/handlers/entities.d.ts +6 -5
  107. package/dist/puck-editor/internal/api/handlers/entities.js +60 -15
  108. package/dist/puck-editor/internal/api/handlers/entities.js.map +1 -1
  109. package/dist/puck-editor/internal/api/handlers/publish.d.ts +3 -6
  110. package/dist/puck-editor/internal/api/handlers/publish.js +57 -14
  111. package/dist/puck-editor/internal/api/handlers/publish.js.map +1 -1
  112. package/dist/puck-editor/internal/api/handlers/template.d.ts +5 -2
  113. package/dist/puck-editor/internal/api/handlers/template.js +28 -60
  114. package/dist/puck-editor/internal/api/handlers/template.js.map +1 -1
  115. package/dist/puck-editor/internal/api/handlers/upload.d.ts +10 -2
  116. package/dist/puck-editor/internal/api/handlers/upload.js +93 -28
  117. package/dist/puck-editor/internal/api/handlers/upload.js.map +1 -1
  118. package/dist/puck-editor/internal/api/localize-message.d.ts +15 -0
  119. package/dist/puck-editor/internal/api/localize-message.js +15 -0
  120. package/dist/puck-editor/internal/api/localize-message.js.map +1 -0
  121. package/dist/puck-editor/internal/api/media-params.d.ts +3 -3
  122. package/dist/puck-editor/internal/api/media-params.js +23 -19
  123. package/dist/puck-editor/internal/api/media-params.js.map +1 -1
  124. package/dist/puck-editor/internal/api/media-upload.d.ts +5 -3
  125. package/dist/puck-editor/internal/api/media-upload.js +33 -22
  126. package/dist/puck-editor/internal/api/media-upload.js.map +1 -1
  127. package/dist/puck-editor/internal/api/space.d.ts +0 -1
  128. package/dist/puck-editor/internal/api/type-segment.d.ts +2 -0
  129. package/dist/puck-editor/internal/api/type-segment.js +9 -0
  130. package/dist/puck-editor/internal/api/type-segment.js.map +1 -0
  131. package/dist/puck-editor/internal/content-model.d.ts +31 -3
  132. package/dist/puck-editor/internal/content-model.js +76 -6
  133. package/dist/puck-editor/internal/content-model.js.map +1 -1
  134. package/dist/puck-editor/internal/dictionaries.d.ts +225 -0
  135. package/dist/puck-editor/internal/dictionaries.js +673 -0
  136. package/dist/puck-editor/internal/dictionaries.js.map +1 -0
  137. package/dist/puck-editor/internal/editor/allowed-types.d.ts +1 -2
  138. package/dist/puck-editor/internal/editor/allowed-types.js +2 -2
  139. package/dist/puck-editor/internal/editor/allowed-types.js.map +1 -1
  140. package/dist/puck-editor/internal/editor/canvas-add-picker.d.ts +0 -1
  141. package/dist/puck-editor/internal/editor/canvas-add-picker.js +5 -5
  142. package/dist/puck-editor/internal/editor/canvas-add-picker.js.map +1 -1
  143. package/dist/puck-editor/internal/editor/canvas-empty-state.d.ts +0 -1
  144. package/dist/puck-editor/internal/editor/canvas-empty-state.js +4 -4
  145. package/dist/puck-editor/internal/editor/canvas-empty-state.js.map +1 -1
  146. package/dist/puck-editor/internal/editor/canvas-quick-add.d.ts +0 -1
  147. package/dist/puck-editor/internal/editor/canvas-quick-add.js +8 -8
  148. package/dist/puck-editor/internal/editor/canvas-quick-add.js.map +1 -1
  149. package/dist/puck-editor/internal/editor/canvas-scroll.d.ts +0 -1
  150. package/dist/puck-editor/internal/editor/component-icons.d.ts +1 -2
  151. package/dist/puck-editor/internal/editor/component-icons.js.map +1 -1
  152. package/dist/puck-editor/internal/editor/component-item.d.ts +0 -1
  153. package/dist/puck-editor/internal/editor/component-item.js +2 -2
  154. package/dist/puck-editor/internal/editor/component-item.js.map +1 -1
  155. package/dist/puck-editor/internal/editor/compose-save-issues.d.ts +15 -0
  156. package/dist/puck-editor/internal/editor/compose-save-issues.js +16 -0
  157. package/dist/puck-editor/internal/editor/compose-save-issues.js.map +1 -0
  158. package/dist/puck-editor/internal/editor/dirty-state.d.ts +3 -0
  159. package/dist/puck-editor/internal/editor/dirty-state.js +7 -0
  160. package/dist/puck-editor/internal/editor/dirty-state.js.map +1 -0
  161. package/dist/puck-editor/internal/editor/draft-restore-banner.d.ts +9 -0
  162. package/dist/puck-editor/internal/editor/draft-restore-banner.js +289 -0
  163. package/dist/puck-editor/internal/editor/draft-restore-banner.js.map +1 -0
  164. package/dist/puck-editor/internal/editor/draft-storage.d.ts +41 -0
  165. package/dist/puck-editor/internal/editor/draft-storage.js +129 -0
  166. package/dist/puck-editor/internal/editor/draft-storage.js.map +1 -0
  167. package/dist/puck-editor/internal/editor/editor-action-bar.d.ts +0 -1
  168. package/dist/puck-editor/internal/editor/editor-action-bar.js +4 -4
  169. package/dist/puck-editor/internal/editor/editor-action-bar.js.map +1 -1
  170. package/dist/puck-editor/internal/editor/editor-header-actions.d.ts +6 -4
  171. package/dist/puck-editor/internal/editor/editor-header-actions.js +119 -60
  172. package/dist/puck-editor/internal/editor/editor-header-actions.js.map +1 -1
  173. package/dist/puck-editor/internal/editor/find-missing-required-fields.d.ts +0 -1
  174. package/dist/puck-editor/internal/editor/grouped-drawer-panel.d.ts +1 -2
  175. package/dist/puck-editor/internal/editor/grouped-drawer-panel.js +6 -6
  176. package/dist/puck-editor/internal/editor/grouped-drawer-panel.js.map +1 -1
  177. package/dist/puck-editor/internal/editor/grouped-entry-list.d.ts +1 -2
  178. package/dist/puck-editor/internal/editor/grouped-entry-list.js +7 -6
  179. package/dist/puck-editor/internal/editor/grouped-entry-list.js.map +1 -1
  180. package/dist/puck-editor/internal/editor/header-save-button.d.ts +4 -4
  181. package/dist/puck-editor/internal/editor/header-save-button.js +66 -27
  182. package/dist/puck-editor/internal/editor/header-save-button.js.map +1 -1
  183. package/dist/puck-editor/internal/editor/leave-confirm-dialog.d.ts +5 -0
  184. package/dist/puck-editor/internal/editor/leave-confirm-dialog.js +140 -0
  185. package/dist/puck-editor/internal/editor/leave-confirm-dialog.js.map +1 -0
  186. package/dist/puck-editor/internal/editor/page-template-picker.d.ts +0 -1
  187. package/dist/puck-editor/internal/editor/page-template-picker.js +5 -5
  188. package/dist/puck-editor/internal/editor/page-template-picker.js.map +1 -1
  189. package/dist/puck-editor/internal/editor/picker-entry-item.d.ts +1 -2
  190. package/dist/puck-editor/internal/editor/picker-entry-item.js +4 -4
  191. package/dist/puck-editor/internal/editor/picker-entry-item.js.map +1 -1
  192. package/dist/puck-editor/internal/editor/picker-model.d.ts +14 -5
  193. package/dist/puck-editor/internal/editor/picker-model.js +157 -132
  194. package/dist/puck-editor/internal/editor/picker-model.js.map +1 -1
  195. package/dist/puck-editor/internal/editor/publish-puck-data.d.ts +18 -4
  196. package/dist/puck-editor/internal/editor/publish-puck-data.js +25 -4
  197. package/dist/puck-editor/internal/editor/publish-puck-data.js.map +1 -1
  198. package/dist/puck-editor/internal/editor/puck-editor.d.ts +6 -4
  199. package/dist/puck-editor/internal/editor/puck-editor.js +270 -209
  200. package/dist/puck-editor/internal/editor/puck-editor.js.map +1 -1
  201. package/dist/puck-editor/internal/editor/save-guard.d.ts +15 -0
  202. package/dist/puck-editor/internal/editor/save-guard.js +30 -0
  203. package/dist/puck-editor/internal/editor/save-guard.js.map +1 -0
  204. package/dist/puck-editor/internal/editor/save-page-context.d.ts +8 -0
  205. package/dist/puck-editor/internal/editor/save-page-context.js +34 -0
  206. package/dist/puck-editor/internal/editor/save-page-context.js.map +1 -0
  207. package/dist/puck-editor/internal/editor/section-template-modal.d.ts +0 -1
  208. package/dist/puck-editor/internal/editor/section-template-modal.js +2 -2
  209. package/dist/puck-editor/internal/editor/section-template-modal.js.map +1 -1
  210. package/dist/puck-editor/internal/editor/use-draft-recovery.d.ts +16 -0
  211. package/dist/puck-editor/internal/editor/use-draft-recovery.js +194 -0
  212. package/dist/puck-editor/internal/editor/use-draft-recovery.js.map +1 -0
  213. package/dist/puck-editor/internal/editor/use-frame-zoom.d.ts +0 -1
  214. package/dist/puck-editor/internal/editor/use-is-dirty.d.ts +1 -0
  215. package/dist/puck-editor/internal/editor/use-is-dirty.js +32 -0
  216. package/dist/puck-editor/internal/editor/use-is-dirty.js.map +1 -0
  217. package/dist/puck-editor/internal/editor/use-scroll-lock-outside.d.ts +0 -1
  218. package/dist/puck-editor/internal/editor-config.d.ts +16 -3
  219. package/dist/puck-editor/internal/editor-config.js +8 -1
  220. package/dist/puck-editor/internal/editor-config.js.map +1 -1
  221. package/dist/puck-editor/internal/editor-query-client.d.ts +0 -1
  222. package/dist/puck-editor/internal/fields/checkbox-group/checkbox-group-field.d.ts +0 -1
  223. package/dist/puck-editor/internal/fields/checkbox-group/checkbox-group-field.js +2 -2
  224. package/dist/puck-editor/internal/fields/checkbox-group/checkbox-group-field.js.map +1 -1
  225. package/dist/puck-editor/internal/fields/checkbox-group/create-checkbox-group-field.d.ts +0 -1
  226. package/dist/puck-editor/internal/fields/checkbox-group/create-checkbox-group-field.js +1 -1
  227. package/dist/puck-editor/internal/fields/checkbox-group/create-checkbox-group-field.js.map +1 -1
  228. package/dist/puck-editor/internal/fields/date-picker/create-date-picker-field.d.ts +0 -1
  229. package/dist/puck-editor/internal/fields/date-picker/create-date-picker-field.js +1 -1
  230. package/dist/puck-editor/internal/fields/date-picker/create-date-picker-field.js.map +1 -1
  231. package/dist/puck-editor/internal/fields/date-picker/date-picker.d.ts +0 -1
  232. package/dist/puck-editor/internal/fields/date-picker/date-picker.js +90 -73
  233. package/dist/puck-editor/internal/fields/date-picker/date-picker.js.map +1 -1
  234. package/dist/puck-editor/internal/fields/index.d.ts +10 -10
  235. package/dist/puck-editor/internal/fields/index.js +10 -9
  236. package/dist/puck-editor/internal/fields/index.js.map +1 -1
  237. package/dist/puck-editor/internal/fields/link-picker/anchor.d.ts +0 -1
  238. package/dist/puck-editor/internal/fields/link-picker/anchor.js +1 -1
  239. package/dist/puck-editor/internal/fields/link-picker/anchor.js.map +1 -1
  240. package/dist/puck-editor/internal/fields/link-picker/create-link-field.d.ts +1 -2
  241. package/dist/puck-editor/internal/fields/link-picker/create-link-field.js +1 -1
  242. package/dist/puck-editor/internal/fields/link-picker/create-link-field.js.map +1 -1
  243. package/dist/puck-editor/internal/fields/link-picker/humanize.d.ts +0 -1
  244. package/dist/puck-editor/internal/fields/link-picker/link-picker-control.d.ts +0 -1
  245. package/dist/puck-editor/internal/fields/link-picker/link-picker-control.js +208 -140
  246. package/dist/puck-editor/internal/fields/link-picker/link-picker-control.js.map +1 -1
  247. package/dist/puck-editor/internal/fields/link-picker/link-picker-field.d.ts +1 -2
  248. package/dist/puck-editor/internal/fields/link-picker/link-picker-field.js +6 -6
  249. package/dist/puck-editor/internal/fields/link-picker/link-picker-field.js.map +1 -1
  250. package/dist/puck-editor/internal/fields/link-picker/link-value.d.ts +25 -5
  251. package/dist/puck-editor/internal/fields/link-picker/link-value.js +56 -6
  252. package/dist/puck-editor/internal/fields/link-picker/link-value.js.map +1 -1
  253. package/dist/puck-editor/internal/fields/link-picker/rich-text-link-button.d.ts +0 -1
  254. package/dist/puck-editor/internal/fields/link-picker/rich-text-link-button.js +4 -4
  255. package/dist/puck-editor/internal/fields/link-picker/rich-text-link-button.js.map +1 -1
  256. package/dist/puck-editor/internal/fields/link-picker/richtext-extensions.d.ts +0 -1
  257. package/dist/puck-editor/internal/fields/link-picker/segmented-control.d.ts +0 -1
  258. package/dist/puck-editor/internal/fields/link-picker/segmented-control.js +3 -3
  259. package/dist/puck-editor/internal/fields/link-picker/segmented-control.js.map +1 -1
  260. package/dist/puck-editor/internal/fields/link-picker/types.d.ts +0 -1
  261. package/dist/puck-editor/internal/fields/media-array/create-media-array-field.d.ts +2 -3
  262. package/dist/puck-editor/internal/fields/media-array/create-media-array-field.js +1 -1
  263. package/dist/puck-editor/internal/fields/media-array/create-media-array-field.js.map +1 -1
  264. package/dist/puck-editor/internal/fields/media-array/media-array-field.d.ts +2 -3
  265. package/dist/puck-editor/internal/fields/media-array/media-array-field.js +100 -88
  266. package/dist/puck-editor/internal/fields/media-array/media-array-field.js.map +1 -1
  267. package/dist/puck-editor/internal/fields/media-array/reorder.d.ts +0 -1
  268. package/dist/puck-editor/internal/fields/media-selector/create-media-selector-field.d.ts +2 -3
  269. package/dist/puck-editor/internal/fields/media-selector/create-media-selector-field.js +1 -1
  270. package/dist/puck-editor/internal/fields/media-selector/create-media-selector-field.js.map +1 -1
  271. package/dist/puck-editor/internal/fields/media-selector/crop-editor-dialog.d.ts +1 -2
  272. package/dist/puck-editor/internal/fields/media-selector/crop-editor-dialog.js +4 -4
  273. package/dist/puck-editor/internal/fields/media-selector/crop-editor-dialog.js.map +1 -1
  274. package/dist/puck-editor/internal/fields/media-selector/crop-types.d.ts +0 -1
  275. package/dist/puck-editor/internal/fields/media-selector/extract-fields.d.ts +0 -1
  276. package/dist/puck-editor/internal/fields/media-selector/image-upload-form.d.ts +0 -1
  277. package/dist/puck-editor/internal/fields/media-selector/image-upload-form.js +19 -10
  278. package/dist/puck-editor/internal/fields/media-selector/image-upload-form.js.map +1 -1
  279. package/dist/puck-editor/internal/fields/media-selector/media-selector-field.d.ts +7 -3
  280. package/dist/puck-editor/internal/fields/media-selector/media-selector-field.js +29 -22
  281. package/dist/puck-editor/internal/fields/media-selector/media-selector-field.js.map +1 -1
  282. package/dist/puck-editor/internal/fields/media-selector/media-selector-modal.d.ts +1 -2
  283. package/dist/puck-editor/internal/fields/media-selector/media-selector-modal.js +281 -255
  284. package/dist/puck-editor/internal/fields/media-selector/media-selector-modal.js.map +1 -1
  285. package/dist/puck-editor/internal/fields/media-selector/use-debounced-value.d.ts +0 -1
  286. package/dist/puck-editor/internal/fields/media-selector/use-media-library.d.ts +15 -2
  287. package/dist/puck-editor/internal/fields/media-selector/use-media-library.js +23 -18
  288. package/dist/puck-editor/internal/fields/media-selector/use-media-library.js.map +1 -1
  289. package/dist/puck-editor/internal/fields/media-selector/video-upload-form.d.ts +0 -1
  290. package/dist/puck-editor/internal/fields/media-selector/video-upload-form.js +12 -6
  291. package/dist/puck-editor/internal/fields/media-selector/video-upload-form.js.map +1 -1
  292. package/dist/puck-editor/internal/fields/node-selector/create-node-selector-field.d.ts +0 -1
  293. package/dist/puck-editor/internal/fields/node-selector/create-node-selector-field.js +2 -2
  294. package/dist/puck-editor/internal/fields/node-selector/create-node-selector-field.js.map +1 -1
  295. package/dist/puck-editor/internal/fields/required-field-label.d.ts +0 -1
  296. package/dist/puck-editor/internal/fields/required-field-label.js +1 -1
  297. package/dist/puck-editor/internal/fields/required-field-label.js.map +1 -1
  298. package/dist/puck-editor/internal/fields/required.d.ts +0 -1
  299. package/dist/puck-editor/internal/fields/rich-text/create-rich-text-field.d.ts +13 -3
  300. package/dist/puck-editor/internal/fields/rich-text/create-rich-text-field.js +32 -22
  301. package/dist/puck-editor/internal/fields/rich-text/create-rich-text-field.js.map +1 -1
  302. package/dist/puck-editor/internal/i18n.d.ts +2 -181
  303. package/dist/puck-editor/internal/i18n.js +2 -358
  304. package/dist/puck-editor/internal/i18n.js.map +1 -1
  305. package/dist/puck-editor/internal/locale.d.ts +0 -1
  306. package/dist/puck-editor/internal/localize.d.ts +1 -2
  307. package/dist/puck-editor/internal/localize.js.map +1 -1
  308. package/dist/puck-editor/internal/plugins/agent-plugin/agent-bridge.d.ts +3 -3
  309. package/dist/puck-editor/internal/plugins/agent-plugin/agent-bridge.js +41 -32
  310. package/dist/puck-editor/internal/plugins/agent-plugin/agent-bridge.js.map +1 -1
  311. package/dist/puck-editor/internal/plugins/agent-plugin/agent-info-panel.d.ts +0 -1
  312. package/dist/puck-editor/internal/plugins/agent-plugin/agent-info-panel.js +2 -2
  313. package/dist/puck-editor/internal/plugins/agent-plugin/agent-info-panel.js.map +1 -1
  314. package/dist/puck-editor/internal/plugins/agent-plugin/agent-plugin.d.ts +3 -3
  315. package/dist/puck-editor/internal/plugins/agent-plugin/agent-plugin.js.map +1 -1
  316. package/dist/puck-editor/internal/plugins/agent-plugin/apply-patch-to-puck.d.ts +0 -1
  317. package/dist/puck-editor/internal/plugins/agent-plugin/apply-patch-to-puck.js +1 -1
  318. package/dist/puck-editor/internal/plugins/agent-plugin/apply-patch-to-puck.js.map +1 -1
  319. package/dist/puck-editor/internal/plugins/agent-plugin/catalog.d.ts +0 -1
  320. package/dist/puck-editor/internal/plugins/agent-plugin/constants.d.ts +0 -1
  321. package/dist/puck-editor/internal/plugins/agent-plugin/create-page.d.ts +0 -1
  322. package/dist/puck-editor/internal/plugins/agent-plugin/find-component-location.d.ts +0 -1
  323. package/dist/puck-editor/internal/plugins/agent-plugin/help.d.ts +0 -1
  324. package/dist/puck-editor/internal/plugins/agent-plugin/index.d.ts +1 -2
  325. package/dist/puck-editor/internal/plugins/agent-plugin/index.js +1 -1
  326. package/dist/puck-editor/internal/plugins/agent-plugin/index.js.map +1 -1
  327. package/dist/puck-editor/internal/plugins/agent-plugin/list-media.d.ts +2 -2
  328. package/dist/puck-editor/internal/plugins/agent-plugin/list-media.js +4 -3
  329. package/dist/puck-editor/internal/plugins/agent-plugin/list-media.js.map +1 -1
  330. package/dist/puck-editor/internal/plugins/agent-plugin/templates.d.ts +5 -6
  331. package/dist/puck-editor/internal/plugins/agent-plugin/templates.js +2 -2
  332. package/dist/puck-editor/internal/plugins/agent-plugin/templates.js.map +1 -1
  333. package/dist/puck-editor/internal/plugins/agent-plugin/upload-media.d.ts +1 -2
  334. package/dist/puck-editor/internal/plugins/agent-plugin/use-agent-handle.d.ts +0 -1
  335. package/dist/puck-editor/internal/plugins/agent-plugin/use-agent-handle.js +2 -2
  336. package/dist/puck-editor/internal/plugins/agent-plugin/use-agent-handle.js.map +1 -1
  337. package/dist/puck-editor/internal/plugins/blocks-plugin/blocks-panel.d.ts +0 -1
  338. package/dist/puck-editor/internal/plugins/blocks-plugin/blocks-panel.js +3 -3
  339. package/dist/puck-editor/internal/plugins/blocks-plugin/blocks-panel.js.map +1 -1
  340. package/dist/puck-editor/internal/plugins/blocks-plugin/blocks-plugin.d.ts +0 -1
  341. package/dist/puck-editor/internal/plugins/blocks-plugin/blocks-plugin.js +1 -1
  342. package/dist/puck-editor/internal/plugins/blocks-plugin/blocks-plugin.js.map +1 -1
  343. package/dist/puck-editor/internal/plugins/blocks-plugin/index.d.ts +1 -2
  344. package/dist/puck-editor/internal/plugins/blocks-plugin/index.js +1 -1
  345. package/dist/puck-editor/internal/plugins/blocks-plugin/index.js.map +1 -1
  346. package/dist/puck-editor/internal/plugins/outline-plugin/index.d.ts +1 -2
  347. package/dist/puck-editor/internal/plugins/outline-plugin/index.js +1 -1
  348. package/dist/puck-editor/internal/plugins/outline-plugin/index.js.map +1 -1
  349. package/dist/puck-editor/internal/plugins/outline-plugin/outline-panel.d.ts +0 -1
  350. package/dist/puck-editor/internal/plugins/outline-plugin/outline-panel.js +46 -31
  351. package/dist/puck-editor/internal/plugins/outline-plugin/outline-panel.js.map +1 -1
  352. package/dist/puck-editor/internal/plugins/outline-plugin/outline-plugin.d.ts +0 -1
  353. package/dist/puck-editor/internal/plugins/outline-plugin/outline-plugin.js +1 -1
  354. package/dist/puck-editor/internal/plugins/outline-plugin/outline-plugin.js.map +1 -1
  355. package/dist/puck-editor/internal/plugins/outline-plugin/outline-tree.d.ts +0 -1
  356. package/dist/puck-editor/internal/plugins/sections-plugin/index.d.ts +1 -2
  357. package/dist/puck-editor/internal/plugins/sections-plugin/index.js +1 -1
  358. package/dist/puck-editor/internal/plugins/sections-plugin/index.js.map +1 -1
  359. package/dist/puck-editor/internal/plugins/sections-plugin/sections-panel.d.ts +0 -1
  360. package/dist/puck-editor/internal/plugins/sections-plugin/sections-panel.js +5 -5
  361. package/dist/puck-editor/internal/plugins/sections-plugin/sections-panel.js.map +1 -1
  362. package/dist/puck-editor/internal/plugins/sections-plugin/sections-plugin.d.ts +0 -1
  363. package/dist/puck-editor/internal/plugins/sections-plugin/sections-plugin.js +1 -1
  364. package/dist/puck-editor/internal/plugins/sections-plugin/sections-plugin.js.map +1 -1
  365. package/dist/puck-editor/internal/plugins/templates-plugin/ai-options-fields.d.ts +0 -1
  366. package/dist/puck-editor/internal/plugins/templates-plugin/ai-options-fields.js +2 -2
  367. package/dist/puck-editor/internal/plugins/templates-plugin/ai-options-fields.js.map +1 -1
  368. package/dist/puck-editor/internal/plugins/templates-plugin/apply-vehicle-slot-constraints.d.ts +0 -1
  369. package/dist/puck-editor/internal/plugins/templates-plugin/apply-vehicle-slot-constraints.js +1 -1
  370. package/dist/puck-editor/internal/plugins/templates-plugin/apply-vehicle-slot-constraints.js.map +1 -1
  371. package/dist/puck-editor/internal/plugins/templates-plugin/component-template-modal.d.ts +1 -2
  372. package/dist/puck-editor/internal/plugins/templates-plugin/component-template-modal.js +3 -3
  373. package/dist/puck-editor/internal/plugins/templates-plugin/component-template-modal.js.map +1 -1
  374. package/dist/puck-editor/internal/plugins/templates-plugin/custom-template-list.d.ts +1 -2
  375. package/dist/puck-editor/internal/plugins/templates-plugin/custom-template-list.js +224 -219
  376. package/dist/puck-editor/internal/plugins/templates-plugin/custom-template-list.js.map +1 -1
  377. package/dist/puck-editor/internal/plugins/templates-plugin/index.d.ts +5 -6
  378. package/dist/puck-editor/internal/plugins/templates-plugin/index.js +5 -5
  379. package/dist/puck-editor/internal/plugins/templates-plugin/index.js.map +1 -1
  380. package/dist/puck-editor/internal/plugins/templates-plugin/root-drop-zone.d.ts +0 -1
  381. package/dist/puck-editor/internal/plugins/templates-plugin/root-drop-zone.js +3 -3
  382. package/dist/puck-editor/internal/plugins/templates-plugin/root-drop-zone.js.map +1 -1
  383. package/dist/puck-editor/internal/plugins/templates-plugin/template-form.d.ts +1 -2
  384. package/dist/puck-editor/internal/plugins/templates-plugin/template-form.js +17 -16
  385. package/dist/puck-editor/internal/plugins/templates-plugin/template-form.js.map +1 -1
  386. package/dist/puck-editor/internal/plugins/templates-plugin/template-vehicles.d.ts +1 -2
  387. package/dist/puck-editor/internal/plugins/templates-plugin/template-vehicles.js +1 -1
  388. package/dist/puck-editor/internal/plugins/templates-plugin/template-vehicles.js.map +1 -1
  389. package/dist/puck-editor/internal/plugins/templates-plugin/templates-panel.d.ts +0 -1
  390. package/dist/puck-editor/internal/plugins/templates-plugin/templates-panel.js +171 -161
  391. package/dist/puck-editor/internal/plugins/templates-plugin/templates-panel.js.map +1 -1
  392. package/dist/puck-editor/internal/plugins/templates-plugin/templates-plugin.d.ts +0 -1
  393. package/dist/puck-editor/internal/plugins/templates-plugin/templates-plugin.js +1 -1
  394. package/dist/puck-editor/internal/plugins/templates-plugin/templates-plugin.js.map +1 -1
  395. package/dist/puck-editor/internal/plugins/templates-plugin/templates.d.ts +2 -3
  396. package/dist/puck-editor/internal/plugins/templates-plugin/templates.js +9 -2
  397. package/dist/puck-editor/internal/plugins/templates-plugin/templates.js.map +1 -1
  398. package/dist/puck-editor/internal/plugins/templates-plugin/use-template-dnd.d.ts +0 -1
  399. package/dist/puck-editor/internal/plugins/templates-plugin/use-template-dnd.js +22 -20
  400. package/dist/puck-editor/internal/plugins/templates-plugin/use-template-dnd.js.map +1 -1
  401. package/dist/puck-editor/internal/plugins/templates-plugin/use-templates.d.ts +14 -5
  402. package/dist/puck-editor/internal/plugins/templates-plugin/use-templates.js +23 -15
  403. package/dist/puck-editor/internal/plugins/templates-plugin/use-templates.js.map +1 -1
  404. package/dist/puck-editor/internal/puck-augmentation.d.ts +0 -1
  405. package/dist/puck-editor/internal/puck-editor-provider.d.ts +0 -1
  406. package/dist/puck-editor/internal/puck-node.d.ts +0 -1
  407. package/dist/puck-editor/internal/puck-props.d.ts +13 -0
  408. package/dist/puck-editor/internal/puck-props.js +2 -0
  409. package/dist/puck-editor/internal/puck-props.js.map +1 -0
  410. package/dist/puck-editor/internal/puck-wrapper.d.ts +25 -6
  411. package/dist/puck-editor/internal/puck-wrapper.js +124 -115
  412. package/dist/puck-editor/internal/puck-wrapper.js.map +1 -1
  413. package/dist/puck-editor/internal/render/cropped-image.d.ts +1 -2
  414. package/dist/puck-editor/internal/render/cropped-image.js.map +1 -1
  415. package/dist/puck-editor/internal/smart-actions/action-selection.d.ts +8 -0
  416. package/dist/puck-editor/internal/smart-actions/action-selection.js +10 -0
  417. package/dist/puck-editor/internal/smart-actions/action-selection.js.map +1 -0
  418. package/dist/puck-editor/internal/smart-actions/index.d.ts +10 -4
  419. package/dist/puck-editor/internal/smart-actions/index.js +27 -12
  420. package/dist/puck-editor/internal/smart-actions/index.js.map +1 -1
  421. package/dist/puck-editor/internal/smart-actions/new-page.d.ts +3 -2
  422. package/dist/puck-editor/internal/smart-actions/new-page.js +6 -6
  423. package/dist/puck-editor/internal/smart-actions/new-page.js.map +1 -1
  424. package/dist/puck-editor/internal/smart-actions/open-puck-editor.d.ts +3 -2
  425. package/dist/puck-editor/internal/smart-actions/open-puck-editor.js +49 -37
  426. package/dist/puck-editor/internal/smart-actions/open-puck-editor.js.map +1 -1
  427. package/dist/puck-editor/internal/ui/calendar.d.ts +0 -1
  428. package/dist/puck-editor/internal/ui/calendar.js +1 -1
  429. package/dist/puck-editor/internal/ui/calendar.js.map +1 -1
  430. package/dist/puck-editor/internal/ui/component-list-accordion.d.ts +0 -1
  431. package/dist/puck-editor/internal/ui/dialog.d.ts +0 -1
  432. package/dist/puck-editor/internal/ui/dialog.js +33 -20
  433. package/dist/puck-editor/internal/ui/dialog.js.map +1 -1
  434. package/dist/puck-editor/internal/ui/drawer-item-content.d.ts +0 -1
  435. package/dist/puck-editor/internal/ui/icon-button.d.ts +0 -1
  436. package/dist/puck-editor/internal/ui/icon-button.js +1 -1
  437. package/dist/puck-editor/internal/ui/icon-button.js.map +1 -1
  438. package/dist/puck-editor/internal/ui/load-error-notice.d.ts +6 -0
  439. package/dist/puck-editor/internal/ui/load-error-notice.js +81 -0
  440. package/dist/puck-editor/internal/ui/load-error-notice.js.map +1 -0
  441. package/dist/puck-editor/internal/ui/popover.d.ts +0 -1
  442. package/dist/puck-editor/internal/ui/popover.js +1 -1
  443. package/dist/puck-editor/internal/ui/popover.js.map +1 -1
  444. package/dist/puck-editor/internal/ui/required-mark.d.ts +0 -1
  445. package/dist/puck-editor/internal/ui/scroll-area.d.ts +8 -0
  446. package/dist/puck-editor/internal/ui/scroll-area.js +160 -0
  447. package/dist/puck-editor/internal/ui/scroll-area.js.map +1 -0
  448. package/dist/puck-editor/internal/ui/search-control.d.ts +0 -1
  449. package/dist/puck-editor/internal/ui/search-control.js +3 -3
  450. package/dist/puck-editor/internal/ui/search-control.js.map +1 -1
  451. package/dist/puck-editor/internal/ui/use-panel-search-focus.d.ts +0 -1
  452. package/dist/puck-editor/internal/use-puck-overlay.d.ts +1 -2
  453. package/dist/puck-editor/internal/use-puck-overlay.js +6 -5
  454. package/dist/puck-editor/internal/use-puck-overlay.js.map +1 -1
  455. package/dist/puck-editor/internal/utils.d.ts +0 -1
  456. package/dist/puck-editor/render.d.ts +2 -3
  457. package/dist/puck-editor/render.js +1 -1
  458. package/dist/puck-editor/render.js.map +1 -1
  459. package/dist/puck-editor/server.d.ts +3 -4
  460. package/dist/puck-editor/server.js +1 -1
  461. package/dist/puck-editor/server.js.map +1 -1
  462. package/dist/puck-editor/smart-actions.d.ts +1 -2
  463. package/dist/puck-editor/smart-actions.js +1 -1
  464. package/dist/puck-editor/smart-actions.js.map +1 -1
  465. package/dist/shared/cn.d.ts +0 -1
  466. package/dist/shared/i18n.d.ts +0 -1
  467. package/dist/shared/revalidate-path.d.ts +1 -0
  468. package/dist/shared/revalidate-path.js +2 -0
  469. package/dist/shared/revalidate-path.js.map +1 -0
  470. package/dist/shared/toolbar-action.d.ts +0 -1
  471. package/dist/shared/use-is-hydrated.d.ts +0 -1
  472. package/dist/shared/use-is-in-iframe.d.ts +0 -1
  473. package/dist/shared/use-is-in-iframe.js +1 -1
  474. package/dist/shared/use-is-in-iframe.js.map +1 -1
  475. package/dist/smart-actions/internal/backend-edit-link.d.ts +6 -0
  476. package/dist/smart-actions/internal/backend-edit-link.js +60 -0
  477. package/dist/smart-actions/internal/backend-edit-link.js.map +1 -0
  478. package/dist/smart-actions/internal/get-smart-actions-context.d.ts +1 -2
  479. package/dist/smart-actions/internal/get-smart-actions-context.js +2 -2
  480. package/dist/smart-actions/internal/get-smart-actions-context.js.map +1 -1
  481. package/dist/smart-actions/internal/i18n.d.ts +1 -2
  482. package/dist/smart-actions/internal/i18n.js +16 -2
  483. package/dist/smart-actions/internal/i18n.js.map +1 -1
  484. package/dist/smart-actions/internal/logout-form.d.ts +2 -2
  485. package/dist/smart-actions/internal/logout-form.js +47 -40
  486. package/dist/smart-actions/internal/logout-form.js.map +1 -1
  487. package/dist/smart-actions/internal/refresh-page.d.ts +3 -2
  488. package/dist/smart-actions/internal/refresh-page.js +60 -53
  489. package/dist/smart-actions/internal/refresh-page.js.map +1 -1
  490. package/dist/smart-actions/internal/smart-actions-button.d.ts +22 -4
  491. package/dist/smart-actions/internal/smart-actions-button.js +36 -13
  492. package/dist/smart-actions/internal/smart-actions-button.js.map +1 -1
  493. package/dist/smart-actions/internal/smart-actions-config.d.ts +12 -4
  494. package/dist/smart-actions/internal/smart-actions-config.js +36 -80
  495. package/dist/smart-actions/internal/smart-actions-config.js.map +1 -1
  496. package/dist/smart-actions/internal/smart-actions-toolbar-client.d.ts +5 -11
  497. package/dist/smart-actions/internal/smart-actions-toolbar-client.js +13 -53
  498. package/dist/smart-actions/internal/smart-actions-toolbar-client.js.map +1 -1
  499. package/dist/smart-actions/internal/toolbar/smart-actions-toolbar.d.ts +1 -2
  500. package/dist/smart-actions/internal/toolbar/smart-actions-toolbar.js +4 -4
  501. package/dist/smart-actions/internal/toolbar/smart-actions-toolbar.js.map +1 -1
  502. package/dist/smart-actions/internal/toolbar/storage.d.ts +1 -2
  503. package/dist/smart-actions/internal/toolbar/storage.js.map +1 -1
  504. package/dist/smart-actions/internal/toolbar/types.d.ts +1 -2
  505. package/dist/smart-actions/internal/toolbar/types.js.map +1 -1
  506. package/dist/smart-actions/internal/toolbar/use-smart-actions-toolbar-mode.d.ts +1 -2
  507. package/dist/smart-actions/internal/toolbar/use-smart-actions-toolbar-mode.js +1 -1
  508. package/dist/smart-actions/internal/toolbar/use-smart-actions-toolbar-mode.js.map +1 -1
  509. package/dist/smart-actions/internal/ui/tooltip.d.ts +0 -1
  510. package/dist/smart-actions/internal/ui/tooltip.js +1 -1
  511. package/dist/smart-actions/internal/ui/tooltip.js.map +1 -1
  512. package/dist/smart-actions/internal/user-profile.d.ts +0 -1
  513. package/dist/smart-actions/internal/user-profile.js +71 -24
  514. package/dist/smart-actions/internal/user-profile.js.map +1 -1
  515. package/dist/smart-actions/server.d.ts +5 -4
  516. package/dist/smart-actions/server.js +2 -2
  517. package/dist/smart-actions/server.js.map +1 -1
  518. package/dist/theme.css +1 -1
  519. package/dist/visual-editor/index.d.ts +3 -4
  520. package/dist/visual-editor/index.js +3 -3
  521. package/dist/visual-editor/index.js.map +1 -1
  522. package/dist/visual-editor/internal/bridge/connector.d.ts +4 -3
  523. package/dist/visual-editor/internal/bridge/connector.js +22 -21
  524. package/dist/visual-editor/internal/bridge/connector.js.map +1 -1
  525. package/dist/visual-editor/internal/bridge/draft-mode-self-heal.d.ts +0 -1
  526. package/dist/visual-editor/internal/bridge/editor-auth-gate-server.d.ts +5 -3
  527. package/dist/visual-editor/internal/bridge/editor-auth-gate-server.js +7 -8
  528. package/dist/visual-editor/internal/bridge/editor-auth-gate-server.js.map +1 -1
  529. package/dist/visual-editor/internal/bridge/editor-auth-gate.d.ts +3 -3
  530. package/dist/visual-editor/internal/bridge/editor-auth-gate.js +4 -2
  531. package/dist/visual-editor/internal/bridge/editor-auth-gate.js.map +1 -1
  532. package/dist/visual-editor/internal/i18n.d.ts +3 -2
  533. package/dist/visual-editor/internal/i18n.js +32 -4
  534. package/dist/visual-editor/internal/i18n.js.map +1 -1
  535. package/dist/visual-editor/internal/overlays/drupal-origin.d.ts +1 -7
  536. package/dist/visual-editor/internal/overlays/drupal-origin.js +16 -3
  537. package/dist/visual-editor/internal/overlays/drupal-origin.js.map +1 -1
  538. package/dist/visual-editor/internal/overlays/edit-button.d.ts +5 -4
  539. package/dist/visual-editor/internal/overlays/edit-button.js +46 -44
  540. package/dist/visual-editor/internal/overlays/edit-button.js.map +1 -1
  541. package/dist/visual-editor/internal/overlays/edit-icon.d.ts +0 -1
  542. package/dist/visual-editor/internal/overlays/fragment/fragment-wrapper.d.ts +11 -2
  543. package/dist/visual-editor/internal/overlays/fragment/fragment-wrapper.js +18 -7
  544. package/dist/visual-editor/internal/overlays/fragment/fragment-wrapper.js.map +1 -1
  545. package/dist/visual-editor/internal/overlays/iframe-wrapper.d.ts +0 -1
  546. package/dist/visual-editor/internal/overlays/iframe-wrapper.js +1 -1
  547. package/dist/visual-editor/internal/overlays/iframe-wrapper.js.map +1 -1
  548. package/dist/visual-editor/internal/overlays/menu/menu-wrapper.d.ts +12 -3
  549. package/dist/visual-editor/internal/overlays/menu/menu-wrapper.js +14 -5
  550. package/dist/visual-editor/internal/overlays/menu/menu-wrapper.js.map +1 -1
  551. package/dist/visual-editor/internal/overlays/node/node-metadata.d.ts +4 -2
  552. package/dist/visual-editor/internal/overlays/node/node-metadata.js +10 -4
  553. package/dist/visual-editor/internal/overlays/node/node-metadata.js.map +1 -1
  554. package/dist/visual-editor/internal/overlays/node/node-wrapper.d.ts +5 -3
  555. package/dist/visual-editor/internal/overlays/node/node-wrapper.js +4 -2
  556. package/dist/visual-editor/internal/overlays/node/node-wrapper.js.map +1 -1
  557. package/dist/visual-editor/internal/overlays/paragraph/paragraph-wrapper.d.ts +11 -2
  558. package/dist/visual-editor/internal/overlays/paragraph/paragraph-wrapper.js +18 -7
  559. package/dist/visual-editor/internal/overlays/paragraph/paragraph-wrapper.js.map +1 -1
  560. package/dist/visual-editor/internal/revalidate-route.d.ts +0 -1
  561. package/dist/visual-editor/internal/revalidate-route.js +1 -1
  562. package/dist/visual-editor/internal/revalidate-route.js.map +1 -1
  563. package/dist/visual-editor/server.d.ts +6 -7
  564. package/dist/visual-editor/server.js +6 -6
  565. package/dist/visual-editor/server.js.map +1 -1
  566. package/package.json +20 -3
  567. package/dist/auth/index.d.ts.map +0 -1
  568. package/dist/auth/internal/config.d.ts.map +0 -1
  569. package/dist/auth/internal/draft-mode.d.ts.map +0 -1
  570. package/dist/auth/internal/editor-locale.d.ts.map +0 -1
  571. package/dist/auth/internal/handoff.d.ts.map +0 -1
  572. package/dist/auth/internal/has-session.d.ts.map +0 -1
  573. package/dist/auth/internal/logout.d.ts.map +0 -1
  574. package/dist/auth/internal/next-cookie-storage.d.ts.map +0 -1
  575. package/dist/auth/internal/nodehive-client.d.ts.map +0 -1
  576. package/dist/auth/internal/oauth-config.d.ts.map +0 -1
  577. package/dist/auth/internal/proxy-helpers.d.ts.map +0 -1
  578. package/dist/auth/internal/refresh.d.ts.map +0 -1
  579. package/dist/auth/internal/require-auth.d.ts.map +0 -1
  580. package/dist/auth/internal/return-to.d.ts.map +0 -1
  581. package/dist/auth/internal/routes/callback.d.ts.map +0 -1
  582. package/dist/auth/internal/routes/chips-exchange.d.ts.map +0 -1
  583. package/dist/auth/internal/routes/draft.d.ts.map +0 -1
  584. package/dist/auth/internal/routes/index.d.ts.map +0 -1
  585. package/dist/auth/internal/routes/login.d.ts.map +0 -1
  586. package/dist/auth/internal/routes/popup-done.d.ts.map +0 -1
  587. package/dist/auth/internal/routes/refresh.d.ts.map +0 -1
  588. package/dist/auth/internal/same-origin.d.ts.map +0 -1
  589. package/dist/auth/internal/session-gates.d.ts.map +0 -1
  590. package/dist/auth/internal/update-session.d.ts.map +0 -1
  591. package/dist/auth/internal/use-editor-login.d.ts.map +0 -1
  592. package/dist/auth/proxy.d.ts.map +0 -1
  593. package/dist/auth/react.d.ts.map +0 -1
  594. package/dist/auth/routes.d.ts.map +0 -1
  595. package/dist/auth/server.d.ts.map +0 -1
  596. package/dist/puck-editor/fields.d.ts.map +0 -1
  597. package/dist/puck-editor/index.d.ts.map +0 -1
  598. package/dist/puck-editor/internal/api/client.d.ts.map +0 -1
  599. package/dist/puck-editor/internal/api/config.d.ts.map +0 -1
  600. package/dist/puck-editor/internal/api/create-puck-api.d.ts.map +0 -1
  601. package/dist/puck-editor/internal/api/handlers/create-page.d.ts.map +0 -1
  602. package/dist/puck-editor/internal/api/handlers/entities.d.ts.map +0 -1
  603. package/dist/puck-editor/internal/api/handlers/publish.d.ts.map +0 -1
  604. package/dist/puck-editor/internal/api/handlers/template.d.ts.map +0 -1
  605. package/dist/puck-editor/internal/api/handlers/upload.d.ts.map +0 -1
  606. package/dist/puck-editor/internal/api/media-params.d.ts.map +0 -1
  607. package/dist/puck-editor/internal/api/media-upload.d.ts.map +0 -1
  608. package/dist/puck-editor/internal/api/space.d.ts.map +0 -1
  609. package/dist/puck-editor/internal/content-model.d.ts.map +0 -1
  610. package/dist/puck-editor/internal/editor/allowed-types.d.ts.map +0 -1
  611. package/dist/puck-editor/internal/editor/canvas-add-picker.d.ts.map +0 -1
  612. package/dist/puck-editor/internal/editor/canvas-empty-state.d.ts.map +0 -1
  613. package/dist/puck-editor/internal/editor/canvas-quick-add.d.ts.map +0 -1
  614. package/dist/puck-editor/internal/editor/canvas-scroll.d.ts.map +0 -1
  615. package/dist/puck-editor/internal/editor/component-icons.d.ts.map +0 -1
  616. package/dist/puck-editor/internal/editor/component-item.d.ts.map +0 -1
  617. package/dist/puck-editor/internal/editor/editor-action-bar.d.ts.map +0 -1
  618. package/dist/puck-editor/internal/editor/editor-header-actions.d.ts.map +0 -1
  619. package/dist/puck-editor/internal/editor/find-missing-required-fields.d.ts.map +0 -1
  620. package/dist/puck-editor/internal/editor/grouped-drawer-panel.d.ts.map +0 -1
  621. package/dist/puck-editor/internal/editor/grouped-entry-list.d.ts.map +0 -1
  622. package/dist/puck-editor/internal/editor/header-save-button.d.ts.map +0 -1
  623. package/dist/puck-editor/internal/editor/page-template-picker.d.ts.map +0 -1
  624. package/dist/puck-editor/internal/editor/picker-entry-item.d.ts.map +0 -1
  625. package/dist/puck-editor/internal/editor/picker-model.d.ts.map +0 -1
  626. package/dist/puck-editor/internal/editor/publish-puck-data.d.ts.map +0 -1
  627. package/dist/puck-editor/internal/editor/puck-editor.d.ts.map +0 -1
  628. package/dist/puck-editor/internal/editor/section-template-modal.d.ts.map +0 -1
  629. package/dist/puck-editor/internal/editor/use-frame-zoom.d.ts.map +0 -1
  630. package/dist/puck-editor/internal/editor/use-scroll-lock-outside.d.ts.map +0 -1
  631. package/dist/puck-editor/internal/editor-config.d.ts.map +0 -1
  632. package/dist/puck-editor/internal/editor-query-client.d.ts.map +0 -1
  633. package/dist/puck-editor/internal/fields/checkbox-group/checkbox-group-field.d.ts.map +0 -1
  634. package/dist/puck-editor/internal/fields/checkbox-group/create-checkbox-group-field.d.ts.map +0 -1
  635. package/dist/puck-editor/internal/fields/date-picker/create-date-picker-field.d.ts.map +0 -1
  636. package/dist/puck-editor/internal/fields/date-picker/date-picker.d.ts.map +0 -1
  637. package/dist/puck-editor/internal/fields/index.d.ts.map +0 -1
  638. package/dist/puck-editor/internal/fields/link-picker/anchor.d.ts.map +0 -1
  639. package/dist/puck-editor/internal/fields/link-picker/create-link-field.d.ts.map +0 -1
  640. package/dist/puck-editor/internal/fields/link-picker/humanize.d.ts.map +0 -1
  641. package/dist/puck-editor/internal/fields/link-picker/link-picker-control.d.ts.map +0 -1
  642. package/dist/puck-editor/internal/fields/link-picker/link-picker-field.d.ts.map +0 -1
  643. package/dist/puck-editor/internal/fields/link-picker/link-value.d.ts.map +0 -1
  644. package/dist/puck-editor/internal/fields/link-picker/rich-text-link-button.d.ts.map +0 -1
  645. package/dist/puck-editor/internal/fields/link-picker/richtext-extensions.d.ts.map +0 -1
  646. package/dist/puck-editor/internal/fields/link-picker/segmented-control.d.ts.map +0 -1
  647. package/dist/puck-editor/internal/fields/link-picker/types.d.ts.map +0 -1
  648. package/dist/puck-editor/internal/fields/media-array/create-media-array-field.d.ts.map +0 -1
  649. package/dist/puck-editor/internal/fields/media-array/media-array-field.d.ts.map +0 -1
  650. package/dist/puck-editor/internal/fields/media-array/reorder.d.ts.map +0 -1
  651. package/dist/puck-editor/internal/fields/media-selector/create-media-selector-field.d.ts.map +0 -1
  652. package/dist/puck-editor/internal/fields/media-selector/crop-editor-dialog.d.ts.map +0 -1
  653. package/dist/puck-editor/internal/fields/media-selector/crop-types.d.ts.map +0 -1
  654. package/dist/puck-editor/internal/fields/media-selector/extract-fields.d.ts.map +0 -1
  655. package/dist/puck-editor/internal/fields/media-selector/image-upload-form.d.ts.map +0 -1
  656. package/dist/puck-editor/internal/fields/media-selector/media-selector-field.d.ts.map +0 -1
  657. package/dist/puck-editor/internal/fields/media-selector/media-selector-modal.d.ts.map +0 -1
  658. package/dist/puck-editor/internal/fields/media-selector/use-debounced-value.d.ts.map +0 -1
  659. package/dist/puck-editor/internal/fields/media-selector/use-media-library.d.ts.map +0 -1
  660. package/dist/puck-editor/internal/fields/media-selector/video-upload-form.d.ts.map +0 -1
  661. package/dist/puck-editor/internal/fields/node-selector/create-node-selector-field.d.ts.map +0 -1
  662. package/dist/puck-editor/internal/fields/required-field-label.d.ts.map +0 -1
  663. package/dist/puck-editor/internal/fields/required.d.ts.map +0 -1
  664. package/dist/puck-editor/internal/fields/rich-text/create-rich-text-field.d.ts.map +0 -1
  665. package/dist/puck-editor/internal/i18n.d.ts.map +0 -1
  666. package/dist/puck-editor/internal/locale.d.ts.map +0 -1
  667. package/dist/puck-editor/internal/localize.d.ts.map +0 -1
  668. package/dist/puck-editor/internal/plugins/agent-plugin/agent-bridge.d.ts.map +0 -1
  669. package/dist/puck-editor/internal/plugins/agent-plugin/agent-info-panel.d.ts.map +0 -1
  670. package/dist/puck-editor/internal/plugins/agent-plugin/agent-plugin.d.ts.map +0 -1
  671. package/dist/puck-editor/internal/plugins/agent-plugin/apply-patch-to-puck.d.ts.map +0 -1
  672. package/dist/puck-editor/internal/plugins/agent-plugin/catalog.d.ts.map +0 -1
  673. package/dist/puck-editor/internal/plugins/agent-plugin/constants.d.ts.map +0 -1
  674. package/dist/puck-editor/internal/plugins/agent-plugin/create-page.d.ts.map +0 -1
  675. package/dist/puck-editor/internal/plugins/agent-plugin/find-component-location.d.ts.map +0 -1
  676. package/dist/puck-editor/internal/plugins/agent-plugin/help.d.ts.map +0 -1
  677. package/dist/puck-editor/internal/plugins/agent-plugin/index.d.ts.map +0 -1
  678. package/dist/puck-editor/internal/plugins/agent-plugin/list-media.d.ts.map +0 -1
  679. package/dist/puck-editor/internal/plugins/agent-plugin/templates.d.ts.map +0 -1
  680. package/dist/puck-editor/internal/plugins/agent-plugin/upload-media.d.ts.map +0 -1
  681. package/dist/puck-editor/internal/plugins/agent-plugin/use-agent-handle.d.ts.map +0 -1
  682. package/dist/puck-editor/internal/plugins/blocks-plugin/blocks-panel.d.ts.map +0 -1
  683. package/dist/puck-editor/internal/plugins/blocks-plugin/blocks-plugin.d.ts.map +0 -1
  684. package/dist/puck-editor/internal/plugins/blocks-plugin/index.d.ts.map +0 -1
  685. package/dist/puck-editor/internal/plugins/outline-plugin/index.d.ts.map +0 -1
  686. package/dist/puck-editor/internal/plugins/outline-plugin/outline-panel.d.ts.map +0 -1
  687. package/dist/puck-editor/internal/plugins/outline-plugin/outline-plugin.d.ts.map +0 -1
  688. package/dist/puck-editor/internal/plugins/outline-plugin/outline-tree.d.ts.map +0 -1
  689. package/dist/puck-editor/internal/plugins/sections-plugin/index.d.ts.map +0 -1
  690. package/dist/puck-editor/internal/plugins/sections-plugin/sections-panel.d.ts.map +0 -1
  691. package/dist/puck-editor/internal/plugins/sections-plugin/sections-plugin.d.ts.map +0 -1
  692. package/dist/puck-editor/internal/plugins/templates-plugin/ai-options-fields.d.ts.map +0 -1
  693. package/dist/puck-editor/internal/plugins/templates-plugin/apply-vehicle-slot-constraints.d.ts.map +0 -1
  694. package/dist/puck-editor/internal/plugins/templates-plugin/component-template-modal.d.ts.map +0 -1
  695. package/dist/puck-editor/internal/plugins/templates-plugin/custom-template-list.d.ts.map +0 -1
  696. package/dist/puck-editor/internal/plugins/templates-plugin/index.d.ts.map +0 -1
  697. package/dist/puck-editor/internal/plugins/templates-plugin/root-drop-zone.d.ts.map +0 -1
  698. package/dist/puck-editor/internal/plugins/templates-plugin/template-form.d.ts.map +0 -1
  699. package/dist/puck-editor/internal/plugins/templates-plugin/template-vehicles.d.ts.map +0 -1
  700. package/dist/puck-editor/internal/plugins/templates-plugin/templates-panel.d.ts.map +0 -1
  701. package/dist/puck-editor/internal/plugins/templates-plugin/templates-plugin.d.ts.map +0 -1
  702. package/dist/puck-editor/internal/plugins/templates-plugin/templates.d.ts.map +0 -1
  703. package/dist/puck-editor/internal/plugins/templates-plugin/use-template-dnd.d.ts.map +0 -1
  704. package/dist/puck-editor/internal/plugins/templates-plugin/use-templates.d.ts.map +0 -1
  705. package/dist/puck-editor/internal/puck-augmentation.d.ts.map +0 -1
  706. package/dist/puck-editor/internal/puck-editor-provider.d.ts.map +0 -1
  707. package/dist/puck-editor/internal/puck-node.d.ts.map +0 -1
  708. package/dist/puck-editor/internal/puck-wrapper.d.ts.map +0 -1
  709. package/dist/puck-editor/internal/render/cropped-image.d.ts.map +0 -1
  710. package/dist/puck-editor/internal/smart-actions/index.d.ts.map +0 -1
  711. package/dist/puck-editor/internal/smart-actions/new-page.d.ts.map +0 -1
  712. package/dist/puck-editor/internal/smart-actions/open-puck-editor.d.ts.map +0 -1
  713. package/dist/puck-editor/internal/ui/calendar.d.ts.map +0 -1
  714. package/dist/puck-editor/internal/ui/component-list-accordion.d.ts.map +0 -1
  715. package/dist/puck-editor/internal/ui/dialog.d.ts.map +0 -1
  716. package/dist/puck-editor/internal/ui/drawer-item-content.d.ts.map +0 -1
  717. package/dist/puck-editor/internal/ui/icon-button.d.ts.map +0 -1
  718. package/dist/puck-editor/internal/ui/popover.d.ts.map +0 -1
  719. package/dist/puck-editor/internal/ui/required-mark.d.ts.map +0 -1
  720. package/dist/puck-editor/internal/ui/search-control.d.ts.map +0 -1
  721. package/dist/puck-editor/internal/ui/use-panel-search-focus.d.ts.map +0 -1
  722. package/dist/puck-editor/internal/use-puck-overlay.d.ts.map +0 -1
  723. package/dist/puck-editor/internal/utils.d.ts.map +0 -1
  724. package/dist/puck-editor/render.d.ts.map +0 -1
  725. package/dist/puck-editor/server.d.ts.map +0 -1
  726. package/dist/puck-editor/smart-actions.d.ts.map +0 -1
  727. package/dist/shared/cn.d.ts.map +0 -1
  728. package/dist/shared/i18n.d.ts.map +0 -1
  729. package/dist/shared/toolbar-action.d.ts.map +0 -1
  730. package/dist/shared/use-is-hydrated.d.ts.map +0 -1
  731. package/dist/shared/use-is-in-iframe.d.ts.map +0 -1
  732. package/dist/smart-actions/internal/get-smart-actions-context.d.ts.map +0 -1
  733. package/dist/smart-actions/internal/i18n.d.ts.map +0 -1
  734. package/dist/smart-actions/internal/logout-form.d.ts.map +0 -1
  735. package/dist/smart-actions/internal/refresh-page.d.ts.map +0 -1
  736. package/dist/smart-actions/internal/smart-actions-button.d.ts.map +0 -1
  737. package/dist/smart-actions/internal/smart-actions-config.d.ts.map +0 -1
  738. package/dist/smart-actions/internal/smart-actions-toolbar-client.d.ts.map +0 -1
  739. package/dist/smart-actions/internal/toolbar/smart-actions-toolbar.d.ts.map +0 -1
  740. package/dist/smart-actions/internal/toolbar/storage.d.ts.map +0 -1
  741. package/dist/smart-actions/internal/toolbar/types.d.ts.map +0 -1
  742. package/dist/smart-actions/internal/toolbar/use-smart-actions-toolbar-mode.d.ts.map +0 -1
  743. package/dist/smart-actions/internal/ui/tooltip.d.ts.map +0 -1
  744. package/dist/smart-actions/internal/user-profile.d.ts.map +0 -1
  745. package/dist/smart-actions/server.d.ts.map +0 -1
  746. package/dist/visual-editor/index.d.ts.map +0 -1
  747. package/dist/visual-editor/internal/bridge/connector.d.ts.map +0 -1
  748. package/dist/visual-editor/internal/bridge/draft-mode-self-heal.d.ts.map +0 -1
  749. package/dist/visual-editor/internal/bridge/editor-auth-gate-server.d.ts.map +0 -1
  750. package/dist/visual-editor/internal/bridge/editor-auth-gate.d.ts.map +0 -1
  751. package/dist/visual-editor/internal/i18n.d.ts.map +0 -1
  752. package/dist/visual-editor/internal/overlays/drupal-origin.d.ts.map +0 -1
  753. package/dist/visual-editor/internal/overlays/edit-button.d.ts.map +0 -1
  754. package/dist/visual-editor/internal/overlays/edit-icon.d.ts.map +0 -1
  755. package/dist/visual-editor/internal/overlays/fragment/fragment-wrapper.d.ts.map +0 -1
  756. package/dist/visual-editor/internal/overlays/iframe-wrapper.d.ts.map +0 -1
  757. package/dist/visual-editor/internal/overlays/menu/menu-wrapper.d.ts.map +0 -1
  758. package/dist/visual-editor/internal/overlays/node/node-metadata.d.ts.map +0 -1
  759. package/dist/visual-editor/internal/overlays/node/node-wrapper.d.ts.map +0 -1
  760. package/dist/visual-editor/internal/overlays/paragraph/paragraph-wrapper.d.ts.map +0 -1
  761. package/dist/visual-editor/internal/revalidate-route.d.ts.map +0 -1
  762. package/dist/visual-editor/server.d.ts.map +0 -1
@@ -1,12 +1,13 @@
1
1
  import { NextResponse } from 'next/server';
2
2
  import { DrupalJsonApiParams } from 'drupal-jsonapi-params';
3
- import { normalizeLang } from '../../locale';
4
- import { buildMediaListParams, buildMediaParams } from '../media-params';
3
+ import { normalizeLang } from "../../locale.js";
4
+ import { buildMediaListParams, buildMediaParams } from "../media-params.js";
5
5
 
6
6
  // All handlers run behind requireAuth, so they act as the logged-in editor
7
7
  // and stay uncached; site rendering keeps its own cached data layer.
8
8
 
9
9
  const NO_STORE = 'no-store, no-cache, must-revalidate';
10
+ const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
10
11
  const NODE_LIST_LIMIT = 50;
11
12
  export async function handleLinks(config, lang) {
12
13
  if (!config.getLinks) {
@@ -18,7 +19,9 @@ export async function handleLinks(config, lang) {
18
19
  }
19
20
  try {
20
21
  const links = await config.getLinks(lang ?? '');
21
- return NextResponse.json(links);
22
+ const response = NextResponse.json(links);
23
+ response.headers.set('Cache-Control', NO_STORE);
24
+ return response;
22
25
  } catch (error) {
23
26
  console.error('Error fetching puck links:', error);
24
27
  return NextResponse.json({
@@ -29,12 +32,17 @@ export async function handleLinks(config, lang) {
29
32
  }
30
33
  }
31
34
  export async function handleNodeList(config, type, searchParams) {
35
+ if (!config.spaceId) {
36
+ const response = NextResponse.json([]);
37
+ response.headers.set('Cache-Control', NO_STORE);
38
+ return response;
39
+ }
32
40
  try {
33
41
  const lang = normalizeLang(searchParams.get('lang'));
34
42
  const query = searchParams.get('query')?.trim() ?? '';
35
43
  const searchFields = (searchParams.get('searchFields') ?? 'title').split(',').map(field => field.trim()).filter(Boolean);
36
44
  const fields = (searchParams.get('fields') ?? '').split(',').map(field => field.trim()).filter(Boolean);
37
- const apiParams = new DrupalJsonApiParams().addSort('created', 'DESC').addPageLimit(NODE_LIST_LIMIT);
45
+ const apiParams = new DrupalJsonApiParams().addFilter('nodehive_space.meta.drupal_internal__target_id', config.spaceId).addSort('created', 'DESC').addPageLimit(NODE_LIST_LIMIT);
38
46
  if (fields.length) {
39
47
  apiParams.addFields(`node--${type}`, fields);
40
48
  }
@@ -50,7 +58,9 @@ export async function handleNodeList(config, type, searchParams) {
50
58
  lang,
51
59
  params: apiParams
52
60
  });
53
- return NextResponse.json(nodes?.data ?? []);
61
+ const response = NextResponse.json(nodes?.data ?? []);
62
+ response.headers.set('Cache-Control', NO_STORE);
63
+ return response;
54
64
  } catch (error) {
55
65
  console.error('Error fetching node:', error);
56
66
  return NextResponse.json({
@@ -61,18 +71,39 @@ export async function handleNodeList(config, type, searchParams) {
61
71
  }
62
72
  }
63
73
  export async function handleNodeItem(config, type, id, lang) {
74
+ if (!UUID_RE.test(id)) {
75
+ return NextResponse.json({
76
+ error: 'invalid id'
77
+ }, {
78
+ status: 400
79
+ });
80
+ }
81
+ if (!config.spaceId) {
82
+ return NextResponse.json({
83
+ error: `Node not found: ${type}/${id}`
84
+ }, {
85
+ status: 404
86
+ });
87
+ }
64
88
  try {
65
- const node = await config.createUserClient().getNode(id, type, {
66
- lang
89
+ // Query the collection instead of the UUID endpoint so Drupal applies the
90
+ // space relationship filter. A direct UUID request would bypass it.
91
+ const apiParams = new DrupalJsonApiParams().addFilter('id', id).addFilter('nodehive_space.meta.drupal_internal__target_id', config.spaceId).addPageLimit(1);
92
+ const nodes = await config.createUserClient().getNodes(type, {
93
+ lang,
94
+ params: apiParams
67
95
  });
68
- if (!node?.data) {
96
+ const node = nodes?.data?.[0];
97
+ if (!node) {
69
98
  return NextResponse.json({
70
99
  error: `Node not found: ${type}/${id}`
71
100
  }, {
72
101
  status: 404
73
102
  });
74
103
  }
75
- return NextResponse.json(node.data);
104
+ const response = NextResponse.json(node);
105
+ response.headers.set('Cache-Control', NO_STORE);
106
+ return response;
76
107
  } catch (error) {
77
108
  console.error('Error fetching node:', error);
78
109
  return NextResponse.json({
@@ -91,7 +122,7 @@ export async function handleMediaList(config, type, searchParams) {
91
122
  const client = await config.createClient();
92
123
  const mediaList = await client.getMediaList(type, {
93
124
  lang,
94
- params: buildMediaListParams(type, query, offset, limit)
125
+ params: buildMediaListParams(type, config.model.media, query, offset, limit)
95
126
  });
96
127
  const response = NextResponse.json(mediaList);
97
128
  response.headers.set('Cache-Control', NO_STORE);
@@ -106,10 +137,17 @@ export async function handleMediaList(config, type, searchParams) {
106
137
  }
107
138
  }
108
139
  export async function handleMediaItem(config, type, id, lang) {
140
+ if (!UUID_RE.test(id)) {
141
+ return NextResponse.json({
142
+ error: 'invalid id'
143
+ }, {
144
+ status: 400
145
+ });
146
+ }
109
147
  try {
110
148
  const media = await config.createUserClient().getMedia(id, type, {
111
149
  lang,
112
- params: buildMediaParams(type)
150
+ params: buildMediaParams(type, config.model.media)
113
151
  });
114
152
  if (!media?.data) {
115
153
  return NextResponse.json({
@@ -131,15 +169,20 @@ export async function handleMediaItem(config, type, id, lang) {
131
169
  }
132
170
  }
133
171
  export async function handleFragmentList(config, type, searchParams) {
172
+ if (!config.spaceId) {
173
+ const response = NextResponse.json({
174
+ data: []
175
+ });
176
+ response.headers.set('Cache-Control', NO_STORE);
177
+ return response;
178
+ }
134
179
  try {
135
180
  const lang = normalizeLang(searchParams.get('lang'));
136
181
  const query = searchParams.get('query') ?? undefined;
137
182
  const offset = searchParams.get('offset') ?? undefined;
138
183
  const limit = searchParams.get('limit') ?? undefined;
139
184
  const apiParams = new DrupalJsonApiParams().addSort('created', 'DESC');
140
- if (config.spaceId) {
141
- apiParams.addFilter('space_id.meta.drupal_internal__target_id', config.spaceId);
142
- }
185
+ apiParams.addFilter('space_id.meta.drupal_internal__target_id', config.spaceId);
143
186
  if (query) {
144
187
  apiParams.addFilter('title', query, 'CONTAINS');
145
188
  }
@@ -153,7 +196,9 @@ export async function handleFragmentList(config, type, searchParams) {
153
196
  lang,
154
197
  params: apiParams
155
198
  });
156
- return NextResponse.json(fragments);
199
+ const response = NextResponse.json(fragments);
200
+ response.headers.set('Cache-Control', NO_STORE);
201
+ return response;
157
202
  } catch (error) {
158
203
  console.error('Error fetching fragments:', error);
159
204
  return NextResponse.json({
@@ -1 +1 @@
1
- {"version":3,"file":"entities.js","names":["NextResponse","DrupalJsonApiParams","normalizeLang","buildMediaListParams","buildMediaParams","NO_STORE","NODE_LIST_LIMIT","handleLinks","config","lang","getLinks","json","error","status","links","console","handleNodeList","type","searchParams","get","query","trim","searchFields","split","map","field","filter","Boolean","fields","apiParams","addSort","addPageLimit","length","addFields","addGroup","forEach","addFilter","nodes","createUserClient","getNodes","params","data","handleNodeItem","id","node","getNode","handleMediaList","undefined","offset","limit","client","createClient","mediaList","getMediaList","response","headers","set","handleMediaItem","media","getMedia","handleFragmentList","spaceId","addPageOffset","Number","fragments","getFragments"],"sources":["../../../../../src/puck-editor/internal/api/handlers/entities.ts"],"sourcesContent":["import { NextResponse } from 'next/server';\nimport { DrupalJsonApiParams } from 'drupal-jsonapi-params';\n\nimport { normalizeLang } from '../../locale';\nimport type { PuckApiConfig } from '../config';\nimport { buildMediaListParams, buildMediaParams } from '../media-params';\n\n// All handlers run behind requireAuth, so they act as the logged-in editor\n// and stay uncached; site rendering keeps its own cached data layer.\n\nconst NO_STORE = 'no-store, no-cache, must-revalidate';\n\nconst NODE_LIST_LIMIT = 50;\n\nexport async function handleLinks(config: PuckApiConfig, lang?: string) {\n if (!config.getLinks) {\n return NextResponse.json(\n { error: 'links are not configured (PuckApiConfig.getLinks)' },\n { status: 404 }\n );\n }\n\n try {\n const links = await config.getLinks(lang ?? '');\n return NextResponse.json(links);\n } catch (error) {\n console.error('Error fetching puck links:', error);\n return NextResponse.json(\n { error: 'Failed to load links' },\n { status: 500 }\n );\n }\n}\n\nexport async function handleNodeList(\n config: PuckApiConfig,\n type: string,\n searchParams: URLSearchParams\n) {\n try {\n const lang = normalizeLang(searchParams.get('lang'));\n const query = searchParams.get('query')?.trim() ?? '';\n const searchFields = (searchParams.get('searchFields') ?? 'title')\n .split(',')\n .map((field) => field.trim())\n .filter(Boolean);\n const fields = (searchParams.get('fields') ?? '')\n .split(',')\n .map((field) => field.trim())\n .filter(Boolean);\n\n const apiParams = new DrupalJsonApiParams()\n .addSort('created', 'DESC')\n .addPageLimit(NODE_LIST_LIMIT);\n\n if (fields.length) {\n apiParams.addFields(`node--${type}`, fields);\n }\n\n if (query) {\n if (searchFields.length > 1) {\n apiParams.addGroup('node-search', 'OR');\n searchFields.forEach((field) =>\n apiParams.addFilter(field, query, 'CONTAINS', 'node-search')\n );\n } else {\n apiParams.addFilter(searchFields[0] ?? 'title', query, 'CONTAINS');\n }\n }\n\n const nodes = await config\n .createUserClient()\n .getNodes(type, { lang, params: apiParams });\n\n return NextResponse.json(nodes?.data ?? []);\n } catch (error) {\n console.error('Error fetching node:', error);\n return NextResponse.json(\n { error: 'An unexpected error occurred' },\n { status: 500 }\n );\n }\n}\n\nexport async function handleNodeItem(\n config: PuckApiConfig,\n type: string,\n id: string,\n lang?: string\n) {\n try {\n const node = await config.createUserClient().getNode(id, type, { lang });\n\n if (!node?.data) {\n return NextResponse.json(\n { error: `Node not found: ${type}/${id}` },\n { status: 404 }\n );\n }\n\n return NextResponse.json(node.data);\n } catch (error) {\n console.error('Error fetching node:', error);\n return NextResponse.json(\n { error: 'An unexpected error occurred' },\n { status: 500 }\n );\n }\n}\n\nexport async function handleMediaList(\n config: PuckApiConfig,\n type: string,\n searchParams: URLSearchParams\n) {\n try {\n const lang = normalizeLang(searchParams.get('lang'));\n const query = searchParams.get('query') ?? undefined;\n const offset = searchParams.get('offset') ?? undefined;\n const limit = searchParams.get('limit') ?? undefined;\n\n const client = await config.createClient();\n const mediaList = await client.getMediaList(type, {\n lang,\n params: buildMediaListParams(type, query, offset, limit),\n });\n\n const response = NextResponse.json(mediaList);\n response.headers.set('Cache-Control', NO_STORE);\n return response;\n } catch (error) {\n console.error('Error fetching media:', error);\n return NextResponse.json(\n { error: 'An unexpected error occurred' },\n { status: 500 }\n );\n }\n}\n\nexport async function handleMediaItem(\n config: PuckApiConfig,\n type: string,\n id: string,\n lang?: string\n) {\n try {\n const media = await config.createUserClient().getMedia(id, type, {\n lang,\n params: buildMediaParams(type),\n });\n\n if (!media?.data) {\n return NextResponse.json({ error: 'Media not found' }, { status: 404 });\n }\n\n const response = NextResponse.json(media);\n response.headers.set('Cache-Control', NO_STORE);\n return response;\n } catch (error) {\n console.error('Error fetching media:', error);\n return NextResponse.json(\n { error: 'An unexpected error occurred' },\n { status: 500 }\n );\n }\n}\n\nexport async function handleFragmentList(\n config: PuckApiConfig,\n type: string,\n searchParams: URLSearchParams\n) {\n try {\n const lang = normalizeLang(searchParams.get('lang'));\n const query = searchParams.get('query') ?? undefined;\n const offset = searchParams.get('offset') ?? undefined;\n const limit = searchParams.get('limit') ?? undefined;\n\n const apiParams = new DrupalJsonApiParams().addSort('created', 'DESC');\n if (config.spaceId) {\n apiParams.addFilter(\n 'space_id.meta.drupal_internal__target_id',\n config.spaceId\n );\n }\n if (query) {\n apiParams.addFilter('title', query, 'CONTAINS');\n }\n if (offset) {\n apiParams.addPageOffset(Number(offset));\n }\n if (limit) {\n apiParams.addPageLimit(Number(limit));\n }\n\n const fragments = await config.createUserClient().getFragments(type, {\n lang,\n params: apiParams,\n });\n\n return NextResponse.json(fragments);\n } catch (error) {\n console.error('Error fetching fragments:', error);\n return NextResponse.json(\n { error: 'An unexpected error occurred' },\n { status: 500 }\n );\n }\n}\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,aAAa;AAC1C,SAASC,mBAAmB,QAAQ,uBAAuB;AAE3D,SAASC,aAAa,QAAQ,cAAc;AAE5C,SAASC,oBAAoB,EAAEC,gBAAgB,QAAQ,iBAAiB;;AAExE;AACA;;AAEA,MAAMC,QAAQ,GAAG,qCAAqC;AAEtD,MAAMC,eAAe,GAAG,EAAE;AAE1B,OAAO,eAAeC,WAAWA,CAACC,MAAqB,EAAEC,IAAa,EAAE;EACtE,IAA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EAAE;IAA+B,CAAC,EACzC;MAAEC,MAAM,EAAE;IAAI,CAChB,CAAC;EACH;AACF","ignoreList":[]}
1
+ {"version":3,"file":"entities.js","names":["NextResponse","DrupalJsonApiParams","normalizeLang","buildMediaListParams","buildMediaParams","NO_STORE","UUID_RE","NODE_LIST_LIMIT","handleLinks","config","lang","getLinks","json","error","status","links","response","headers","set","console","handleNodeList","type","searchParams","spaceId","get","query","trim","searchFields","split","map","field","filter","Boolean","fields","apiParams","addFilter","addSort","addPageLimit","length","addFields","addGroup","forEach","nodes","createUserClient","getNodes","params","data","handleNodeItem","id","test","node","handleMediaList","undefined","offset","limit","client","createClient","mediaList","getMediaList","model","media","handleMediaItem","getMedia","handleFragmentList","addPageOffset","Number","fragments","getFragments"],"sources":["../../../../../src/puck-editor/internal/api/handlers/entities.ts"],"sourcesContent":["import { NextResponse } from 'next/server';\nimport { DrupalJsonApiParams } from 'drupal-jsonapi-params';\n\nimport { normalizeLang } from '../../locale.ts';\nimport type { PuckApiConfig, PuckApiRuntime } from '../config.ts';\nimport { buildMediaListParams, buildMediaParams } from '../media-params.ts';\n\n// All handlers run behind requireAuth, so they act as the logged-in editor\n// and stay uncached; site rendering keeps its own cached data layer.\n\nconst NO_STORE = 'no-store, no-cache, must-revalidate';\n\nconst UUID_RE =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\nconst NODE_LIST_LIMIT = 50;\n\nexport async function handleLinks(config: PuckApiConfig, lang?: string) {\n if (!config.getLinks) {\n return NextResponse.json(\n { error: 'links are not configured (PuckApiConfig.getLinks)' },\n { status: 404 }\n );\n }\n\n try {\n const links = await config.getLinks(lang ?? '');\n const response = NextResponse.json(links);\n response.headers.set('Cache-Control', NO_STORE);\n return response;\n } catch (error) {\n console.error('Error fetching puck links:', error);\n return NextResponse.json(\n { error: 'Failed to load links' },\n { status: 500 }\n );\n }\n}\n\nexport async function handleNodeList(\n config: PuckApiConfig,\n type: string,\n searchParams: URLSearchParams\n) {\n if (!config.spaceId) {\n const response = NextResponse.json([]);\n response.headers.set('Cache-Control', NO_STORE);\n return response;\n }\n\n try {\n const lang = normalizeLang(searchParams.get('lang'));\n const query = searchParams.get('query')?.trim() ?? '';\n const searchFields = (searchParams.get('searchFields') ?? 'title')\n .split(',')\n .map((field) => field.trim())\n .filter(Boolean);\n const fields = (searchParams.get('fields') ?? '')\n .split(',')\n .map((field) => field.trim())\n .filter(Boolean);\n\n const apiParams = new DrupalJsonApiParams()\n .addFilter(\n 'nodehive_space.meta.drupal_internal__target_id',\n config.spaceId\n )\n .addSort('created', 'DESC')\n .addPageLimit(NODE_LIST_LIMIT);\n\n if (fields.length) {\n apiParams.addFields(`node--${type}`, fields);\n }\n\n if (query) {\n if (searchFields.length > 1) {\n apiParams.addGroup('node-search', 'OR');\n searchFields.forEach((field) =>\n apiParams.addFilter(field, query, 'CONTAINS', 'node-search')\n );\n } else {\n apiParams.addFilter(searchFields[0] ?? 'title', query, 'CONTAINS');\n }\n }\n\n const nodes = await config\n .createUserClient()\n .getNodes(type, { lang, params: apiParams });\n\n const response = NextResponse.json(nodes?.data ?? []);\n response.headers.set('Cache-Control', NO_STORE);\n return response;\n } catch (error) {\n console.error('Error fetching node:', error);\n return NextResponse.json(\n { error: 'An unexpected error occurred' },\n { status: 500 }\n );\n }\n}\n\nexport async function handleNodeItem(\n config: PuckApiConfig,\n type: string,\n id: string,\n lang?: string\n) {\n if (!UUID_RE.test(id)) {\n return NextResponse.json({ error: 'invalid id' }, { status: 400 });\n }\n\n if (!config.spaceId) {\n return NextResponse.json(\n { error: `Node not found: ${type}/${id}` },\n { status: 404 }\n );\n }\n\n try {\n // Query the collection instead of the UUID endpoint so Drupal applies the\n // space relationship filter. A direct UUID request would bypass it.\n const apiParams = new DrupalJsonApiParams()\n .addFilter('id', id)\n .addFilter(\n 'nodehive_space.meta.drupal_internal__target_id',\n config.spaceId\n )\n .addPageLimit(1);\n const nodes = await config.createUserClient().getNodes(type, {\n lang,\n params: apiParams,\n });\n const node = nodes?.data?.[0];\n\n if (!node) {\n return NextResponse.json(\n { error: `Node not found: ${type}/${id}` },\n { status: 404 }\n );\n }\n\n const response = NextResponse.json(node);\n response.headers.set('Cache-Control', NO_STORE);\n return response;\n } catch (error) {\n console.error('Error fetching node:', error);\n return NextResponse.json(\n { error: 'An unexpected error occurred' },\n { status: 500 }\n );\n }\n}\n\nexport async function handleMediaList(\n config: PuckApiRuntime,\n type: string,\n searchParams: URLSearchParams\n) {\n try {\n const lang = normalizeLang(searchParams.get('lang'));\n const query = searchParams.get('query') ?? undefined;\n const offset = searchParams.get('offset') ?? undefined;\n const limit = searchParams.get('limit') ?? undefined;\n\n const client = await config.createClient();\n const mediaList = await client.getMediaList(type, {\n lang,\n params: buildMediaListParams(\n type,\n config.model.media,\n query,\n offset,\n limit\n ),\n });\n\n const response = NextResponse.json(mediaList);\n response.headers.set('Cache-Control', NO_STORE);\n return response;\n } catch (error) {\n console.error('Error fetching media:', error);\n return NextResponse.json(\n { error: 'An unexpected error occurred' },\n { status: 500 }\n );\n }\n}\n\nexport async function handleMediaItem(\n config: PuckApiRuntime,\n type: string,\n id: string,\n lang?: string\n) {\n if (!UUID_RE.test(id)) {\n return NextResponse.json({ error: 'invalid id' }, { status: 400 });\n }\n\n try {\n const media = await config.createUserClient().getMedia(id, type, {\n lang,\n params: buildMediaParams(type, config.model.media),\n });\n\n if (!media?.data) {\n return NextResponse.json({ error: 'Media not found' }, { status: 404 });\n }\n\n const response = NextResponse.json(media);\n response.headers.set('Cache-Control', NO_STORE);\n return response;\n } catch (error) {\n console.error('Error fetching media:', error);\n return NextResponse.json(\n { error: 'An unexpected error occurred' },\n { status: 500 }\n );\n }\n}\n\nexport async function handleFragmentList(\n config: PuckApiConfig,\n type: string,\n searchParams: URLSearchParams\n) {\n if (!config.spaceId) {\n const response = NextResponse.json({ data: [] });\n response.headers.set('Cache-Control', NO_STORE);\n return response;\n }\n\n try {\n const lang = normalizeLang(searchParams.get('lang'));\n const query = searchParams.get('query') ?? undefined;\n const offset = searchParams.get('offset') ?? undefined;\n const limit = searchParams.get('limit') ?? undefined;\n\n const apiParams = new DrupalJsonApiParams().addSort('created', 'DESC');\n apiParams.addFilter(\n 'space_id.meta.drupal_internal__target_id',\n config.spaceId\n );\n if (query) {\n apiParams.addFilter('title', query, 'CONTAINS');\n }\n if (offset) {\n apiParams.addPageOffset(Number(offset));\n }\n if (limit) {\n apiParams.addPageLimit(Number(limit));\n }\n\n const fragments = await config.createUserClient().getFragments(type, {\n lang,\n params: apiParams,\n });\n\n const response = NextResponse.json(fragments);\n response.headers.set('Cache-Control', NO_STORE);\n return response;\n } catch (error) {\n console.error('Error fetching fragments:', error);\n return NextResponse.json(\n { error: 'An unexpected error occurred' },\n { status: 500 }\n );\n }\n}\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,aAAa;AAC1C,SAASC,mBAAmB,QAAQ,uBAAuB;AAE3D,SAASC,aAAa,QAAQ,iBAAiB;AAE/C,SAASC,oBAAoB,EAAEC,gBAAgB,QAAQ,oBAAoB;;AAE3E;AACA;;AAEA,MAAMC,QAAQ,GAAG,qCAAqC;AAEtD,MAAMC,OAAO,GACX,iEAAiE;AAEnE,MAAMC,eAAe,GAAG,EAAE;AAE1B,OAAO,eAAeC,WAAWA,CAACC,MAAqB,EAAEC,IAAa,EAAE;EACtE,IAAI,CAACD,MAAM,CAACE,QAAQ,EAAE;IACpB,OAAOX,YAAY,CAACY,IAAI,CACtB;MAAEC,KAAK,EAAE;IAAoD,CAAC,EAC9D;MAAEC,MAAM,EAAE;IAAI,CAChB,CAAC;EACH;EAEA,IAAI;IACF,MAAMC,KAAK,GAAG,MAAMN,MAAM,CAACE,QAAQ,CAACD,IAAI,IAAI,EAAE,CAAC;IAC/C,MAAMM,QAAQ,GAAGhB,YAAY,CAACY,IAAI,CAACG,KAAK,CAAC;IACzCC,QAAQ,CAACC,OAAO,CAACC,GAAG,CAAC,eAAe,EA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,QAAQ;EACjB,CAAC,CAAC,OAAOH,KAAK,EAAE;IACdM,OAAO,CAACN,KAAK,CAAC,2BAA2B,EAAEA,KAAK,CAAC;IACjD,OAAOb,YAAY,CAACY,IAAI,CACtB;MAAEC,KAAK,EAAE;IAA+B,CAAC,EACzC;MAAEC,MAAM,EAAE;IAAI,CAChB,CAAC;EACH;AACF","ignoreList":[]}
@@ -1,6 +1,3 @@
1
- import { NextRequest, NextResponse } from 'next/server';
2
- import type { PuckApiRuntime } from '../config';
3
- export declare function handlePublish(config: PuckApiRuntime, request: NextRequest): Promise<NextResponse<{
4
- status: string;
5
- }>>;
6
- //# sourceMappingURL=publish.d.ts.map
1
+ import { NextRequest } from 'next/server';
2
+ import type { PuckApiRuntime } from '../config.js';
3
+ export declare function handlePublish(config: PuckApiRuntime, request: NextRequest): Promise<Response>;
@@ -1,18 +1,15 @@
1
1
  import { revalidatePath } from 'next/cache';
2
2
  import { NextResponse } from 'next/server';
3
- import { DEFAULT_METADATA_FIELDS, getBundle } from '../../content-model';
3
+ import { DEFAULT_METADATA_FIELDS, getBundle, mediaEntityType } from "../../content-model.js";
4
+ import { normalizeLang } from "../../locale.js";
4
5
  const TYPE_RE = /^[a-z_]+(--[a-z_]+)?$/;
5
6
  const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
6
- export async function handlePublish(config, request) {
7
+ function rejectInvalidPayload(config, payload) {
7
8
  const {
8
- path,
9
9
  type,
10
- data,
11
10
  nodeId,
12
- fieldName,
13
- lang,
14
- pageSettings
15
- } = await request.json();
11
+ fieldName
12
+ } = payload;
16
13
  const bundle = getBundle(config.model, type);
17
14
  const allowedFieldNames = bundle ? new Set([bundle.dataField]) : new Set([...config.model.bundles.map(b => b.dataField), config.model.templates.dataField]);
18
15
  if (typeof fieldName !== 'string' || !allowedFieldNames.has(fieldName) || typeof type !== 'string' || !TYPE_RE.test(type) || typeof nodeId !== 'string' || !UUID_RE.test(nodeId)) {
@@ -23,6 +20,50 @@ export async function handlePublish(config, request) {
23
20
  status: 400
24
21
  });
25
22
  }
23
+ return null;
24
+ }
25
+ export async function handlePublish(config, request) {
26
+ const body = await request.json();
27
+ let payload = {
28
+ path: body.path,
29
+ type: body.type,
30
+ data: body.data,
31
+ nodeId: body.nodeId,
32
+ fieldName: body.fieldName,
33
+ lang: normalizeLang(body.lang),
34
+ pageSettings: body.pageSettings
35
+ };
36
+ const invalid = rejectInvalidPayload(config, payload);
37
+ if (invalid) return invalid;
38
+ if (config.onBeforePublish) {
39
+ const result = await config.onBeforePublish(payload, {
40
+ request,
41
+ model: config.model,
42
+ createUserClient: config.createUserClient
43
+ });
44
+ if (result instanceof Response) return result;
45
+ if (!result || typeof result !== 'object') {
46
+ return NextResponse.json({
47
+ status: 'error',
48
+ message: 'onBeforePublish must return a payload or a Response'
49
+ }, {
50
+ status: 400
51
+ });
52
+ }
53
+ payload = result;
54
+ const invalidAfterHook = rejectInvalidPayload(config, payload);
55
+ if (invalidAfterHook) return invalidAfterHook;
56
+ }
57
+ const {
58
+ path,
59
+ type,
60
+ data,
61
+ nodeId,
62
+ fieldName,
63
+ lang,
64
+ pageSettings
65
+ } = payload;
66
+ const bundle = getBundle(config.model, type);
26
67
  const meta = bundle?.metadataFields ?? DEFAULT_METADATA_FIELDS;
27
68
  const jsonApiType = type.replace('node--', '');
28
69
  try {
@@ -42,10 +83,12 @@ export async function handlePublish(config, request) {
42
83
  attributes.status = pageSettings.published;
43
84
  }
44
85
  if (typeof pageSettings?.urlAlias === 'string') {
45
- const alias = pageSettings.urlAlias.trim();
46
- if (alias) {
86
+ const trimmed = pageSettings.urlAlias.trim();
87
+ const alias = trimmed && !trimmed.startsWith('/') ? `/${trimmed}` : trimmed;
88
+ const safeAlias = !!alias && !/\s/.test(alias) && !alias.includes('..') && !alias.startsWith('//');
89
+ if (safeAlias) {
47
90
  attributes.path = {
48
- alias: alias.startsWith('/') ? alias : `/${alias}`
91
+ alias
49
92
  };
50
93
  }
51
94
  }
@@ -57,7 +100,7 @@ export async function handlePublish(config, request) {
57
100
  } else if (meta.image && pageSettings?.metadataImage?.id) {
58
101
  relationships[meta.image] = {
59
102
  data: {
60
- type: pageSettings.metadataImage.type || 'media--image',
103
+ type: pageSettings.metadataImage.type || mediaEntityType(config.model.media.imageType),
61
104
  id: pageSettings.metadataImage.id
62
105
  }
63
106
  };
@@ -91,12 +134,12 @@ export async function handlePublish(config, request) {
91
134
  }
92
135
  return NextResponse.json({
93
136
  status: 'error',
94
- message: `Error updating Drupal node: ${error instanceof Error ? error.message : 'Unknown error'}`
137
+ message: 'Error updating Drupal node'
95
138
  }, {
96
139
  status: 500
97
140
  });
98
141
  }
99
- if (typeof path === 'string' && path) {
142
+ if (typeof path === 'string' && path.startsWith('/') && !path.includes('..')) {
100
143
  revalidatePath(path);
101
144
  }
102
145
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"publish.js","names":["revalidatePath","NextResponse","DEFAULT_METADATA_FIELDS","getBundle","TYPE_RE","UUID_RE","handlePublish","config","request","path","type","data","nodeId","fieldName","lang","pageSettings","json","bundle","model","allowedFieldNames","Set","dataField","bundles","map","b","templates","has","test","status","message","meta","metadataFields","jsonApiType","replace","attributes","JSON","stringify","title","trim","metadataTitle","description","metadataDescription","published","urlAlias","alias","startsWith","relationships","image","metadataImage","id","client","createUserClient","endpoint","payload","Object","keys","length","method","headers","Accept","error","details","console","Error","onPublished"],"sources":["../../../../../src/puck-editor/internal/api/handlers/publish.ts"],"sourcesContent":["import { revalidatePath } from 'next/cache';\nimport { NextRequest, NextResponse } from 'next/server';\n\nimport { DEFAULT_METADATA_FIELDS, getBundle } from '../../content-model';\nimport type { PuckApiRuntime } from '../config';\n\nconst TYPE_RE = /^[a-z_]+(--[a-z_]+)?$/;\nconst UUID_RE =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\nexport async function handlePublish(\n config: PuckApiRuntime,\n request: NextRequest\n) {\n const { path, type, data, nodeId, fieldName, lang, pageSettings } =\n await request.json();\n\n const bundle = getBundle(config.model, type);\n const allowedFieldNames = bundle\n ? new Set([bundle.dataField])\n : new Set([\n ...config.model.bundles.map((b) => b.dataField),\n config.model.templates.dataField,\n ]);\n\n if (\n typeof fieldName !== 'string' ||\n !allowedFieldNames.has(fieldName) ||\n typeof type !== 'string' ||\n !TYPE_RE.test(type) ||\n typeof nodeId !== 'string' ||\n !UUID_RE.test(nodeId)\n ) {\n return NextResponse.json(\n { status: 'error', message: 'invalid fieldName, type, or nodeId' },\n { status: 400 }\n );\n }\n\n const meta = bundle?.metadataFields ?? DEFAULT_METADATA_FIELDS;\n const jsonApiType = type.replace('node--', '');\n try {\n const attributes: Record<string, unknown> = {\n [fieldName]: JSON.stringify(data),\n };\n\n if (typeof pageSettings?.title === 'string' && pageSettings.title.trim()) {\n attributes.title = pageSettings.title.trim();\n }\n\n if (meta.title && typeof pageSettings?.metadataTitle === 'string') {\n attributes[meta.title] = pageSettings.metadataTitle;\n }\n\n if (\n meta.description &&\n typeof pageSettings?.metadataDescription === 'string'\n ) {\n attributes[meta.description] = pageSettings.metadataDescription;\n }\n\n if (typeof pageSettings?.published === 'boolean') {\n attributes.status = pageSettings.published;\n }\n\n if (typeof pageSettings?.urlAlias === 'string') {\n const alias = pageSettings.urlAlias.trim();\n if (alias) {\n attributes.path = {\n alias: alias.startsWith('/') ? alias : `/${alias}`,\n };\n }\n }\n\n const relationships: Record<string, unknown> = {};\n if (meta.image && pageSettings?.metadataImage === null) {\n relationships[meta.image] = {\n data: null,\n };\n } else if (meta.image && pageSettings?.metadataImage?.id) {\n relationships[meta.image] = {\n data: {\n type: pageSettings.metadataImage.type || 'media--image',\n id: pageSettings.metadataImage.id,\n },\n };\n }\n\n const client = config.createUserClient();\n const endpoint = `/jsonapi/node/${jsonApiType}/${nodeId}`;\n const payload = {\n data: {\n type: type,\n id: nodeId,\n attributes,\n ...(Object.keys(relationships).length > 0 ? { relationships } : {}),\n },\n };\n\n await client.request(endpoint, {\n method: 'PATCH',\n lang,\n data: payload,\n headers: { Accept: 'application/vnd.api+json' },\n });\n } catch (error) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const details = (error as any)?.details;\n console.error('Error updating Drupal node:', error);\n if (details) {\n console.error(\n 'Drupal response details:',\n JSON.stringify(details, null, 2)\n );\n }\n return NextResponse.json(\n {\n status: 'error',\n message: `Error updating Drupal node: ${\n error instanceof Error ? error.message : 'Unknown error'\n }`,\n },\n { status: 500 }\n );\n }\n\n if (typeof path === 'string' && path) {\n revalidatePath(path);\n }\n\n try {\n await config.onPublished?.({ nodeId, path, lang });\n } catch (error) {\n console.error('onPublished hook failed:', error);\n }\n\n return NextResponse.json({ status: 'ok' });\n}\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,YAAY;AAC3C,SAAsBC,YAAY,QAAQ,aAAa;AAEvD,SAASC,uBAAuB,EAAEC,SAAS,QAAQ,qBAAqB;AAGxE,MAAMC,OAAO,GAAG,uBAAuB;AACvC,MAAMC,OAAO,GACX,iEAAiE;AAEnE,OAAO,eAAeC,aAAaA,CACjCC,MAAsB,EACtBC,OAAoB,EACpB;EACA,MAAM;IAAEC,IAAI;IAAEC,IAAI;IAAEC,IAAI;IAAEC,MAAM;IAAEC,SAAS;IAAEC,IAAI;IAAEC;EAAa,CAAC,GAC/D,MAAMP,OAAO,CAACQ,IAAI,CAAC,CAAC;EAEtB,MAAMC,MAAM,GAAGd,SAAS,CAACI,MAAM,CAACW,KAAK,EAAER,IAAI,CAAC;EAC5C,MAAMS,iBAAiB,GAAGF,MAAM,GAC5B,IAAIG,GAAG,CAAC,CAACH,MAAM,CAACI,SAAS,CAAC,CAAC,GAC3B,IAAID,GAAG,CAAC,CACN,GAAGb,MAAM,CAACW,KAAK,CAACI,OAAO,CAACC,GAAG,CAAEC,CAAC,IAAKA,CAAC,CAACH,SAAS,CAAC,EAC/Cd,MAAM,C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G;UAAEV;QAAc,CAAC,GAAG,CAAC,CAAC;MACpE;IACF,CAAC;IAED,MAAMI,MAAM,CAAC1C,OAAO,CAAC4C,QAAQ,EAAE;MAC7BK,MAAM,EAAE,OAAO;MACf3C,IAAI;MACJH,IAAI,EAAE0C,OAAO;MACbK,OAAO,EAAE;QAAEC,MAAM,EAAE;MAA2B;IAChD,CAAC,CAAC;EACJ,CAAC,CAAC,OAAOC,KAAK,EAAE;IACd;IACA,MAAMC,OAAO,GAAID,KAAK,EAAUC,OAAO;IACvCC,OAAO,CAACF,KAAK,CAAC,6BAA6B,EAAEA,KAAK,CAAC;IACnD,IAAIC,OAAO,EAAE;MACXC,OAAO,CAACF,KAAK,CACX,0BAA0B,EAC1BzB,IAAI,CAACC,SAAS,CAACyB,OAAO,EAAE,IAAI,EAAE,CAAC,CACjC,CAAC;IACH;IACA,OAAO5D,YAAY,CAACe,IAAI,CACtB;MACEY,MAAM,EAAE,OAAO;MACfC,OAAO,EAAE,+BACP+B,KAAK,YAAYG,KAAK,GAAGH,KAAK,CAAC/B,OAAO,GAAG,eAAe;IAE5D,CAAC,EACD;MAAED,MAAM,EAAE;IAAI,CAChB,CAAC;EACH;EAEA,IAAI,OAAOnB,IAAI,KAAK,QAAQ,IAAIA,IAAI,EAAE;IACpCT,cAAc,CAACS,IAAI,CAAC;EACtB;EAEA,IAAI;IACF,MAAMF,MAAM,CAACyD,WAAW,GAAG;MAAEpD,MAAM;MAAEH,IAAI;MAAEK;IAAK,CAAC,CAAC;EACpD,CAAC,CAAC,OAAO8C,KAAK,EAAE;IACdE,OAAO,CAACF,KAAK,CAAC,0BAA0B,EAAEA,KAAK,CAAC;EAClD;EAEA,OAAO3D,YAAY,CAACe,IAAI,CAAC;IAAEY,MAAM,EAAE;EAAK,CAAC,CAAC;AAC5C","ignoreList":[]}
1
+ {"version":3,"file":"publish.js","names":["revalidatePath","NextResponse","DEFAULT_METADATA_FIELDS","getBundle","mediaEntityType","normalizeLang","TYPE_RE","UUID_RE","rejectInvalidPayload","config","payload","type","nodeId","fieldName","bundle","model","allowedFieldNames","Set","dataField","bundles","map","b","templates","has","test","json","status","message","handlePublish","request","body","path","data","lang","pageSettings","invalid","onBeforePublish","result","createUserClient","Response","invalidAfterHook","meta","metadataFields","jsonApiType","replace","attributes","JSON","stringify","title","trim","metadataTitle","description","metadataDescription","published","urlAlias","trimmed","alias","startsWith","safeAlias","includes","relationships","image","metadataImage","id","media","imageType","client","endpoint","Object","keys","length","method","headers","Accept","error","details","console","onPublished"],"sources":["../../../../../src/puck-editor/internal/api/handlers/publish.ts"],"sourcesContent":["import { revalidatePath } from 'next/cache';\nimport { NextRequest, NextResponse } from 'next/server';\n\nimport {\n DEFAULT_METADATA_FIELDS,\n getBundle,\n mediaEntityType,\n} from '../../content-model.ts';\nimport { normalizeLang } from '../../locale.ts';\nimport type { PuckApiRuntime, PuckPublishPayload } from '../config.ts';\n\nconst TYPE_RE = /^[a-z_]+(--[a-z_]+)?$/;\nconst UUID_RE =\n /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\n\nfunction rejectInvalidPayload(\n config: PuckApiRuntime,\n payload: PuckPublishPayload\n) {\n const { type, nodeId, fieldName } = payload;\n const bundle = getBundle(config.model, type);\n const allowedFieldNames = bundle\n ? new Set([bundle.dataField])\n : new Set([\n ...config.model.bundles.map((b) => b.dataField),\n config.model.templates.dataField,\n ]);\n\n if (\n typeof fieldName !== 'string' ||\n !allowedFieldNames.has(fieldName) ||\n typeof type !== 'string' ||\n !TYPE_RE.test(type) ||\n typeof nodeId !== 'string' ||\n !UUID_RE.test(nodeId)\n ) {\n return NextResponse.json(\n { status: 'error', message: 'invalid fieldName, type, or nodeId' },\n { status: 400 }\n );\n }\n\n return null;\n}\n\nexport async function handlePublish(\n config: PuckApiRuntime,\n request: NextRequest\n) {\n const body = await request.json();\n let payload: PuckPublishPayload = {\n path: body.path,\n type: body.type,\n data: body.data,\n nodeId: body.nodeId,\n fieldName: body.fieldName,\n lang: normalizeLang(body.lang),\n pageSettings: body.pageSettings,\n };\n\n const invalid = rejectInvalidPayload(config, payload);\n if (invalid) return invalid;\n\n if (config.onBeforePublish) {\n const result: unknown = await config.onBeforePublish(payload, {\n request,\n model: config.model,\n createUserClient: config.createUserClient,\n });\n if (result instanceof Response) return result;\n if (!result || typeof result !== 'object') {\n return NextResponse.json(\n {\n status: 'error',\n message: 'onBeforePublish must return a payload or a Response',\n },\n { status: 400 }\n );\n }\n payload = result as PuckPublishPayload;\n const invalidAfterHook = rejectInvalidPayload(config, payload);\n if (invalidAfterHook) return invalidAfterHook;\n }\n\n const { path, type, data, nodeId, fieldName, lang, pageSettings } = payload;\n const bundle = getBundle(config.model, type);\n const meta = bundle?.metadataFields ?? DEFAULT_METADATA_FIELDS;\n const jsonApiType = type.replace('node--', '');\n try {\n const attributes: Record<string, unknown> = {\n [fieldName]: JSON.stringify(data),\n };\n\n if (typeof pageSettings?.title === 'string' && pageSettings.title.trim()) {\n attributes.title = pageSettings.title.trim();\n }\n\n if (meta.title && typeof pageSettings?.metadataTitle === 'string') {\n attributes[meta.title] = pageSettings.metadataTitle;\n }\n\n if (\n meta.description &&\n typeof pageSettings?.metadataDescription === 'string'\n ) {\n attributes[meta.description] = pageSettings.metadataDescription;\n }\n\n if (typeof pageSettings?.published === 'boolean') {\n attributes.status = pageSettings.published;\n }\n\n if (typeof pageSettings?.urlAlias === 'string') {\n const trimmed = pageSettings.urlAlias.trim();\n const alias =\n trimmed && !trimmed.startsWith('/') ? `/${trimmed}` : trimmed;\n const safeAlias =\n !!alias &&\n !/\\s/.test(alias) &&\n !alias.includes('..') &&\n !alias.startsWith('//');\n if (safeAlias) {\n attributes.path = { alias };\n }\n }\n\n const relationships: Record<string, unknown> = {};\n if (meta.image && pageSettings?.metadataImage === null) {\n relationships[meta.image] = {\n data: null,\n };\n } else if (meta.image && pageSettings?.metadataImage?.id) {\n relationships[meta.image] = {\n data: {\n type:\n pageSettings.metadataImage.type ||\n mediaEntityType(config.model.media.imageType),\n id: pageSettings.metadataImage.id,\n },\n };\n }\n\n const client = config.createUserClient();\n const endpoint = `/jsonapi/node/${jsonApiType}/${nodeId}`;\n const payload = {\n data: {\n type: type,\n id: nodeId,\n attributes,\n ...(Object.keys(relationships).length > 0 ? { relationships } : {}),\n },\n };\n\n await client.request(endpoint, {\n method: 'PATCH',\n lang,\n data: payload,\n headers: { Accept: 'application/vnd.api+json' },\n });\n } catch (error) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const details = (error as any)?.details;\n console.error('Error updating Drupal node:', error);\n if (details) {\n console.error(\n 'Drupal response details:',\n JSON.stringify(details, null, 2)\n );\n }\n return NextResponse.json(\n { status: 'error', message: 'Error updating Drupal node' },\n { status: 500 }\n );\n }\n\n if (\n typeof path === 'string' &&\n path.startsWith('/') &&\n !path.includes('..')\n ) {\n revalidatePath(path);\n }\n\n try {\n await config.onPublished?.({ nodeId, path, lang });\n } catch (error) {\n console.error('onPublished hook failed:', error);\n }\n\n return NextResponse.json({ status: 'ok' });\n}\n"],"mappings":"AAAA,SAASA,cAAc,QAAQ,YAAY;AAC3C,SAAsBC,YAAY,QAAQ,aAAa;AAEvD,SACEC,uBAAuB,EACvBC,SAAS,EACTC,eAAe,QACV,wBAAwB;AAC/B,SAASC,aAAa,QAAQ,iBAAiB;AAG/C,MAAMC,OAAO,GAAG,uBAAuB;AACvC,MAAMC,OAAO,GACX,iEAAiE;AAEnE,SAASC,oBAAoBA,CAC3BC,MAAsB,EACtBC,OAA2B,EAC3B;EACA,MAAM;IAAEC,IAAI;IAAEC,MAAM;IAAEC;EAAU,CAAC,GAAGH,OAAO;EAC3C,MAAMI,MAAM,GAAGX,SAAS,CAACM,MAAM,CAACM,KAAK,EAAEJ,IAAI,CAAC;EAC5C,MAAMK,iBAAiB,GAAGF,MAAM,GAC5B,IAAIG,GAAG,CAAC,CAACH,MAAM,CAACI,SAAS,CAAC,CAAC,GAC3B,IAA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AAC,EAC1D;MAAED,MAAM,EAAE;IAAI,CAChB,CAAC;EACH;EAEA,IACE,OAAOK,IAAI,KAAK,QAAQ,IACxBA,IAAI,CAAC0B,UAAU,CAAC,GAAG,CAAC,IACpB,CAAC1B,IAAI,CAAC4B,QAAQ,CAAC,IAAI,CAAC,EACpB;IACA3D,cAAc,CAAC+B,IAAI,CAAC;EACtB;EAEA,IAAI;IACF,MAAMtB,MAAM,CAACoE,WAAW,GAAG;MAAEjE,MAAM;MAAEmB,IAAI;MAAEE;IAAK,CAAC,CAAC;EACpD,CAAC,CAAC,OAAOyC,KAAK,EAAE;IACdE,OAAO,CAACF,KAAK,CAAC,0BAA0B,EAAEA,KAAK,CAAC;EAClD;EAEA,OAAOzE,YAAY,CAACwB,IAAI,CAAC;IAAEC,MAAM,EAAE;EAAK,CAAC,CAAC;AAC5C","ignoreList":[]}
@@ -1,15 +1,18 @@
1
1
  import { NextRequest, NextResponse } from 'next/server';
2
- import type { PuckApiRuntime } from '../config';
2
+ import type { PuckApiRuntime } from '../config.js';
3
+ import type { PuckApiMessageCode } from '../localize-message.js';
3
4
  export declare function handleSaveTemplate(config: PuckApiRuntime, request: NextRequest): Promise<NextResponse<{
4
5
  success: boolean;
5
6
  message: string;
7
+ code?: PuckApiMessageCode;
6
8
  }>>;
7
9
  export declare function handleUpdateTemplate(config: PuckApiRuntime, fragmentType: string, id: string, request: NextRequest): Promise<NextResponse<{
8
10
  success: boolean;
9
11
  message: string;
12
+ code?: PuckApiMessageCode;
10
13
  }>>;
11
14
  export declare function handleDeleteTemplate(config: PuckApiRuntime, fragmentType: string, id: string): Promise<NextResponse<{
12
15
  success: boolean;
13
16
  message: string;
17
+ code?: PuckApiMessageCode;
14
18
  }>>;
15
- //# sourceMappingURL=template.d.ts.map
@@ -1,11 +1,20 @@
1
1
  import { NextResponse } from 'next/server';
2
- import { resolveSpaceUuid, SPACE_TYPE } from '../space';
2
+ import { resolveSpaceUuid, SPACE_TYPE } from "../space.js";
3
3
  const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
4
4
  function resultJson(result) {
5
5
  return NextResponse.json(result, {
6
6
  status: result.success ? 200 : 500
7
7
  });
8
8
  }
9
+ function badRequest(message, code) {
10
+ return NextResponse.json({
11
+ success: false,
12
+ message,
13
+ code
14
+ }, {
15
+ status: 400
16
+ });
17
+ }
9
18
 
10
19
  // fragmentType and id land in the JSON:API URL; the fragment type from the
11
20
  // path must match the configured one, the id must be a UUID — anything else
@@ -29,31 +38,16 @@ export async function handleSaveTemplate(config, request) {
29
38
  aiInstructionsField
30
39
  } = config.model.templates;
31
40
  if (typeof name !== 'string' || !name) {
32
- return NextResponse.json({
33
- success: false,
34
- message: 'Name is required'
35
- }, {
36
- status: 400
37
- });
41
+ return badRequest('Name is required', 'nameRequired');
38
42
  }
39
43
  if (typeof content !== 'string' || !content) {
40
- return NextResponse.json({
41
- success: false,
42
- message: 'Content is required'
43
- }, {
44
- status: 400
45
- });
44
+ return badRequest('Content is required', 'contentRequired');
46
45
  }
47
46
  const ALLOWED_CATEGORIES = new Set(['page', 'section', 'block']);
48
47
  if (typeof category !== 'string' || !ALLOWED_CATEGORIES.has(category)) {
49
- return NextResponse.json({
50
- success: false,
51
- message: 'Category must be one of page, section, block'
52
- }, {
53
- status: 400
54
- });
48
+ return badRequest('Category must be one of page, section, block');
55
49
  }
56
- const client = await config.createClient();
50
+ const client = config.createUserClient();
57
51
  const attributes = {
58
52
  title: name,
59
53
  status: true,
@@ -72,7 +66,8 @@ export async function handleSaveTemplate(config, request) {
72
66
  if (!uuid) {
73
67
  return resultJson({
74
68
  success: false,
75
- message: 'Could not resolve the NodeHive space; template not saved.'
69
+ message: 'Could not resolve the NodeHive space; template not saved.',
70
+ code: 'spaceUnresolved'
76
71
  });
77
72
  }
78
73
  relationships = {
@@ -102,7 +97,8 @@ export async function handleSaveTemplate(config, request) {
102
97
  console.error('Error saving template:', error);
103
98
  return resultJson({
104
99
  success: false,
105
- message: `An error occurred while saving the template: ${error}`
100
+ message: `An error occurred while saving the template: ${error}`,
101
+ code: 'templateSaveError'
106
102
  });
107
103
  }
108
104
  return resultJson({
@@ -112,12 +108,7 @@ export async function handleSaveTemplate(config, request) {
112
108
  }
113
109
  export async function handleUpdateTemplate(config, fragmentType, id, request) {
114
110
  if (invalidTemplateRef(config, fragmentType, id)) {
115
- return NextResponse.json({
116
- success: false,
117
- message: 'invalid fragmentType or id'
118
- }, {
119
- status: 400
120
- });
111
+ return badRequest('invalid fragmentType or id');
121
112
  }
122
113
  const {
123
114
  title,
@@ -131,44 +122,24 @@ export async function handleUpdateTemplate(config, fragmentType, id, request) {
131
122
  const attributes = {};
132
123
  if (title !== undefined) {
133
124
  if (typeof title !== 'string' || !title) {
134
- return NextResponse.json({
135
- success: false,
136
- message: 'Name is required'
137
- }, {
138
- status: 400
139
- });
125
+ return badRequest('Name is required', 'nameRequired');
140
126
  }
141
127
  attributes.title = title;
142
128
  }
143
129
  if (aiDescription !== undefined) {
144
130
  if (typeof aiDescription !== 'string') {
145
- return NextResponse.json({
146
- success: false,
147
- message: 'aiDescription must be a string'
148
- }, {
149
- status: 400
150
- });
131
+ return badRequest('aiDescription must be a string');
151
132
  }
152
133
  attributes[aiDescriptionField] = aiDescription || null;
153
134
  }
154
135
  if (aiInstructions !== undefined) {
155
136
  if (typeof aiInstructions !== 'string') {
156
- return NextResponse.json({
157
- success: false,
158
- message: 'aiInstructions must be a string'
159
- }, {
160
- status: 400
161
- });
137
+ return badRequest('aiInstructions must be a string');
162
138
  }
163
139
  attributes[aiInstructionsField] = aiInstructions || null;
164
140
  }
165
141
  if (Object.keys(attributes).length === 0) {
166
- return NextResponse.json({
167
- success: false,
168
- message: 'No fields to update'
169
- }, {
170
- status: 400
171
- });
142
+ return badRequest('No fields to update');
172
143
  }
173
144
  const payload = {
174
145
  data: {
@@ -186,7 +157,8 @@ export async function handleUpdateTemplate(config, fragmentType, id, request) {
186
157
  console.error('Error updating template:', error);
187
158
  return resultJson({
188
159
  success: false,
189
- message: `An error occurred while updating the template: ${error}`
160
+ message: `An error occurred while updating the template: ${error}`,
161
+ code: 'templateUpdateError'
190
162
  });
191
163
  }
192
164
  return resultJson({
@@ -196,12 +168,7 @@ export async function handleUpdateTemplate(config, fragmentType, id, request) {
196
168
  }
197
169
  export async function handleDeleteTemplate(config, fragmentType, id) {
198
170
  if (invalidTemplateRef(config, fragmentType, id)) {
199
- return NextResponse.json({
200
- success: false,
201
- message: 'invalid fragmentType or id'
202
- }, {
203
- status: 400
204
- });
171
+ return badRequest('invalid fragmentType or id');
205
172
  }
206
173
  try {
207
174
  await config.createUserClient().request(`/jsonapi/nodehive_fragment/${fragmentType}/${id}`, {
@@ -211,7 +178,8 @@ export async function handleDeleteTemplate(config, fragmentType, id) {
211
178
  console.error('Error deleting template:', error);
212
179
  return resultJson({
213
180
  success: false,
214
- message: `An error occurred while deleting the template: ${error}`
181
+ message: `An error occurred while deleting the template: ${error}`,
182
+ code: 'templateDeleteError'
215
183
  });
216
184
  }
217
185
  return resultJson({