@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 +1 @@
1
- {"version":3,"file":"template.js","names":["NextResponse","resolveSpaceUuid","SPACE_TYPE","UUID_RE","resultJson","result","json","status","success","invalidTemplateRef","config","fragmentType","id","model","templates","test","handleSaveTemplate","request","name","content","category","aiDescription","aiInstructions","dataField","categoryField","aiDescriptionField","aiInstructionsField","message","ALLOWED_CATEGORIES","Set","has","client","createClient","attributes","title","relationships","spaceId","uuid","space_id","data","type","payload","method","error","console","handleUpdateTemplate","undefined","Object","keys","length","createUserClient","handleDeleteTemplate"],"sources":["../../../../../src/puck-editor/internal/api/handlers/template.ts"],"sourcesContent":["import { NextRequest, NextResponse } from 'next/server';\n\nimport type { PuckApiRuntime } from '../config';\nimport { resolveSpaceUuid, SPACE_TYPE } from '../space';\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\nfunction resultJson(result: { success: boolean; message: string }) {\n return NextResponse.json(result, { status: result.success ? 200 : 500 });\n}\n\n// fragmentType and id land in the JSON:API URL; the fragment type from the\n// path must match the configured one, the id must be a UUID — anything else\n// could smuggle path segments (fetch normalizes ..).\nfunction invalidTemplateRef(\n config: PuckApiRuntime,\n fragmentType: string,\n id: string\n) {\n return (\n fragmentType !== config.model.templates.fragmentType || !UUID_RE.test(id)\n );\n}\n\nexport async function handleSaveTemplate(\n config: PuckApiRuntime,\n request: NextRequest\n) {\n const { name, content, category, aiDescription, aiInstructions } =\n await request.json();\n const {\n fragmentType,\n dataField,\n categoryField,\n aiDescriptionField,\n aiInstructionsField,\n } = config.model.templates;\n\n if (typeof name !== 'string' || !name) {\n return NextResponse.json(\n { success: false, message: 'Name is required' },\n { status: 400 }\n );\n }\n if (typeof content !== 'string' || !content) {\n return NextResponse.json(\n { success: false, message: 'Content is required' },\n { status: 400 }\n );\n }\n\n const ALLOWED_CATEGORIES = new Set(['page', 'section', 'block']);\n\n if (typeof category !== 'string' || !ALLOWED_CATEGORIES.has(category)) {\n return NextResponse.json(\n {\n success: false,\n message: 'Category must be one of page, section, block',\n },\n { status: 400 }\n );\n }\n\n const client = await config.createClient();\n\n const attributes: Record<string, unknown> = {\n title: name,\n status: true,\n [dataField]: content,\n [categoryField]: category,\n };\n if (typeof aiDescription === 'string' && aiDescription) {\n attributes[aiDescriptionField] = aiDescription;\n }\n if (typeof aiInstructions === 'string' && aiInstructions) {\n attributes[aiInstructionsField] = aiInstructions;\n }\n\n let relationships;\n if (config.spaceId) {\n const uuid = await resolveSpaceUuid(client, config.spaceId);\n if (!uuid) {\n return resultJson({\n success: false,\n message: 'Could not resolve the NodeHive space; template not saved.',\n });\n }\n relationships = { space_id: { data: [{ type: SPACE_TYPE, id: uuid }] } };\n }\n\n const payload = {\n data: {\n type: `nodehive_fragment--${fragmentType}`,\n attributes,\n ...(relationships ? { relationships } : {}),\n },\n };\n\n try {\n await client.request(`/jsonapi/nodehive_fragment/${fragmentType}`, {\n method: 'POST',\n data: payload,\n });\n } catch (error) {\n console.error('Error saving template:', error);\n return resultJson({\n success: false,\n message: `An error occurred while saving the template: ${error}`,\n });\n }\n\n return resultJson({ success: true, message: 'Template saved' });\n}\n\nexport async function handleUpdateTemplate(\n config: PuckApiRuntime,\n fragmentType: string,\n id: string,\n request: NextRequest\n) {\n if (invalidTemplateRef(config, fragmentType, id)) {\n return NextResponse.json(\n { success: false, message: 'invalid fragmentType or id' },\n { status: 400 }\n );\n }\n\n const { title, aiDescription, aiInstructions } = await request.json();\n const { aiDescriptionField, aiInstructionsField } = config.model.templates;\n\n const attributes: Record<string, unknown> = {};\n if (title !== undefined) {\n if (typeof title !== 'string' || !title) {\n return NextResponse.json(\n { success: false, message: 'Name is required' },\n { status: 400 }\n );\n }\n attributes.title = title;\n }\n if (aiDescription !== undefined) {\n if (typeof aiDescription !== 'string') {\n return NextResponse.json(\n { success: false, message: 'aiDescription must be a string' },\n { status: 400 }\n );\n }\n attributes[aiDescriptionField] = aiDescription || null;\n }\n if (aiInstructions !== undefined) {\n if (typeof aiInstructions !== 'string') {\n return NextResponse.json(\n { success: false, message: 'aiInstructions must be a string' },\n { status: 400 }\n );\n }\n attributes[aiInstructionsField] = aiInstructions || null;\n }\n if (Object.keys(attributes).length === 0) {\n return NextResponse.json(\n { success: false, message: 'No fields to update' },\n { status: 400 }\n );\n }\n\n const payload = {\n data: {\n type: `nodehive_fragment--${fragmentType}`,\n id,\n attributes,\n },\n };\n\n try {\n await config\n .createUserClient()\n .request(`/jsonapi/nodehive_fragment/${fragmentType}/${id}`, {\n method: 'PATCH',\n data: payload,\n });\n } catch (error) {\n console.error('Error updating template:', error);\n return resultJson({\n success: false,\n message: `An error occurred while updating the template: ${error}`,\n });\n }\n\n return resultJson({ success: true, message: 'Template updated' });\n}\n\nexport async function handleDeleteTemplate(\n config: PuckApiRuntime,\n fragmentType: string,\n id: string\n) {\n if (invalidTemplateRef(config, fragmentType, id)) {\n return NextResponse.json(\n { success: false, message: 'invalid fragmentType or id' },\n { status: 400 }\n );\n }\n\n try {\n await config\n .createUserClient()\n .request(`/jsonapi/nodehive_fragment/${fragmentType}/${id}`, {\n method: 'DELETE',\n });\n } catch (error) {\n console.error('Error deleting template:', error);\n return resultJson({\n success: false,\n message: `An error occurred while deleting the template: ${error}`,\n });\n }\n\n return resultJson({ success: true, message: 'Template deleted' });\n}\n"],"mappings":"AAAA,SAAsBA,YAAY,QAAQ,aAAa;AAGvD,SAASC,gBAAgB,EAAEC,UAAU,QAAQ,UAAU;AAEvD,MAAMC,OAAO,GACX,iEAAiE;AAEnE,SAASC,UAAUA,CAACC,MAA6C,EAAE;EACjE,OAAOL,YAAY,CAACM,IAAI,CAACD,MAAM,EAAE;IAAEE,MAAM,EAAEF,MAAM,CAACG,OAAO,GAAG,GAAG,GAAG;EAAI,CAAC,CAAC;AAC1E;;AAEA;AACA;AACA;AACA,SAASC,kBAAkBA,CACzBC,MAAsB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AE,IAAI;IAAEmB,OAAO,EAAE;EAAmB,CAAC,CAAC;AACnE;AAEA,OAAO,eAAewB,oBAAoBA,CACxCzC,MAAsB,EACtBC,YAAoB,EACpBC,EAAU,EACV;EACA,IAAIH,kBAAkB,CAACC,MAAM,EAAEC,YAAY,EAAEC,EAAE,CAAC,EAAE;IAChD,OAAOZ,YAAY,CAACM,IAAI,CACtB;MAAEE,OAAO,EAAE,KAAK;MAAEmB,OAAO,EAAE;IAA6B,CAAC,EACzD;MAAEpB,MAAM,EAAE;IAAI,CAChB,CAAC;EACH;EAEA,IAAI;IACF,MAAMG,MAAM,CACTwC,gBAAgB,CAAC,CAAC,CAClBjC,OAAO,CAAC,8BAA8BN,YAAY,IAAIC,EAAE,EAAE,EAAE;MAC3D8B,MAAM,EAAE;IACV,CAAC,CAAC;EACN,CAAC,CAAC,OAAOC,KAAK,EAAE;IACdC,OAAO,CAACD,KAAK,CAAC,0BAA0B,EAAEA,KAAK,CAAC;IAChD,OAAOvC,UAAU,CAAC;MAChBI,OAAO,EAAE,KAAK;MACdmB,OAAO,EAAE,kDAAkDgB,KAAK;IAClE,CAAC,CAAC;EACJ;EAEA,OAAOvC,UAAU,CAAC;IAAEI,OAAO,EAAE,IAAI;IAAEmB,OAAO,EAAE;EAAmB,CAAC,CAAC;AACnE","ignoreList":[]}
1
+ {"version":3,"file":"template.js","names":["NextResponse","resolveSpaceUuid","SPACE_TYPE","UUID_RE","resultJson","result","json","status","success","badRequest","message","code","invalidTemplateRef","config","fragmentType","id","model","templates","test","handleSaveTemplate","request","name","content","category","aiDescription","aiInstructions","dataField","categoryField","aiDescriptionField","aiInstructionsField","ALLOWED_CATEGORIES","Set","has","client","createUserClient","attributes","title","relationships","spaceId","uuid","space_id","data","type","payload","method","error","console","handleUpdateTemplate","undefined","Object","keys","length","handleDeleteTemplate"],"sources":["../../../../../src/puck-editor/internal/api/handlers/template.ts"],"sourcesContent":["import { NextRequest, NextResponse } from 'next/server';\n\nimport type { PuckApiRuntime } from '../config.ts';\nimport type { PuckApiMessageCode } from '../localize-message.ts';\nimport { resolveSpaceUuid, SPACE_TYPE } from '../space.ts';\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\nfunction resultJson(result: {\n success: boolean;\n message: string;\n code?: PuckApiMessageCode;\n}) {\n return NextResponse.json(result, { status: result.success ? 200 : 500 });\n}\n\nfunction badRequest(message: string, code?: PuckApiMessageCode) {\n return NextResponse.json({ success: false, message, code }, { status: 400 });\n}\n\n// fragmentType and id land in the JSON:API URL; the fragment type from the\n// path must match the configured one, the id must be a UUID — anything else\n// could smuggle path segments (fetch normalizes ..).\nfunction invalidTemplateRef(\n config: PuckApiRuntime,\n fragmentType: string,\n id: string\n) {\n return (\n fragmentType !== config.model.templates.fragmentType || !UUID_RE.test(id)\n );\n}\n\nexport async function handleSaveTemplate(\n config: PuckApiRuntime,\n request: NextRequest\n) {\n const { name, content, category, aiDescription, aiInstructions } =\n await request.json();\n const {\n fragmentType,\n dataField,\n categoryField,\n aiDescriptionField,\n aiInstructionsField,\n } = config.model.templates;\n\n if (typeof name !== 'string' || !name) {\n return badRequest('Name is required', 'nameRequired');\n }\n if (typeof content !== 'string' || !content) {\n return badRequest('Content is required', 'contentRequired');\n }\n\n const ALLOWED_CATEGORIES = new Set(['page', 'section', 'block']);\n\n if (typeof category !== 'string' || !ALLOWED_CATEGORIES.has(category)) {\n return badRequest('Category must be one of page, section, block');\n }\n\n const client = config.createUserClient();\n\n const attributes: Record<string, unknown> = {\n title: name,\n status: true,\n [dataField]: content,\n [categoryField]: category,\n };\n if (typeof aiDescription === 'string' && aiDescription) {\n attributes[aiDescriptionField] = aiDescription;\n }\n if (typeof aiInstructions === 'string' && aiInstructions) {\n attributes[aiInstructionsField] = aiInstructions;\n }\n\n let relationships;\n if (config.spaceId) {\n const uuid = await resolveSpaceUuid(client, config.spaceId);\n if (!uuid) {\n return resultJson({\n success: false,\n message: 'Could not resolve the NodeHive space; template not saved.',\n code: 'spaceUnresolved',\n });\n }\n relationships = { space_id: { data: [{ type: SPACE_TYPE, id: uuid }] } };\n }\n\n const payload = {\n data: {\n type: `nodehive_fragment--${fragmentType}`,\n attributes,\n ...(relationships ? { relationships } : {}),\n },\n };\n\n try {\n await client.request(`/jsonapi/nodehive_fragment/${fragmentType}`, {\n method: 'POST',\n data: payload,\n });\n } catch (error) {\n console.error('Error saving template:', error);\n return resultJson({\n success: false,\n message: `An error occurred while saving the template: ${error}`,\n code: 'templateSaveError',\n });\n }\n\n return resultJson({\n success: true,\n message: 'Template saved',\n });\n}\n\nexport async function handleUpdateTemplate(\n config: PuckApiRuntime,\n fragmentType: string,\n id: string,\n request: NextRequest\n) {\n if (invalidTemplateRef(config, fragmentType, id)) {\n return badRequest('invalid fragmentType or id');\n }\n\n const { title, aiDescription, aiInstructions } = await request.json();\n const { aiDescriptionField, aiInstructionsField } = config.model.templates;\n\n const attributes: Record<string, unknown> = {};\n if (title !== undefined) {\n if (typeof title !== 'string' || !title) {\n return badRequest('Name is required', 'nameRequired');\n }\n attributes.title = title;\n }\n if (aiDescription !== undefined) {\n if (typeof aiDescription !== 'string') {\n return badRequest('aiDescription must be a string');\n }\n attributes[aiDescriptionField] = aiDescription || null;\n }\n if (aiInstructions !== undefined) {\n if (typeof aiInstructions !== 'string') {\n return badRequest('aiInstructions must be a string');\n }\n attributes[aiInstructionsField] = aiInstructions || null;\n }\n if (Object.keys(attributes).length === 0) {\n return badRequest('No fields to update');\n }\n\n const payload = {\n data: {\n type: `nodehive_fragment--${fragmentType}`,\n id,\n attributes,\n },\n };\n\n try {\n await config\n .createUserClient()\n .request(`/jsonapi/nodehive_fragment/${fragmentType}/${id}`, {\n method: 'PATCH',\n data: payload,\n });\n } catch (error) {\n console.error('Error updating template:', error);\n return resultJson({\n success: false,\n message: `An error occurred while updating the template: ${error}`,\n code: 'templateUpdateError',\n });\n }\n\n return resultJson({\n success: true,\n message: 'Template updated',\n });\n}\n\nexport async function handleDeleteTemplate(\n config: PuckApiRuntime,\n fragmentType: string,\n id: string\n) {\n if (invalidTemplateRef(config, fragmentType, id)) {\n return badRequest('invalid fragmentType or id');\n }\n\n try {\n await config\n .createUserClient()\n .request(`/jsonapi/nodehive_fragment/${fragmentType}/${id}`, {\n method: 'DELETE',\n });\n } catch (error) {\n console.error('Error deleting template:', error);\n return resultJson({\n success: false,\n message: `An error occurred while deleting the template: ${error}`,\n code: 'templateDeleteError',\n });\n }\n\n return resultJson({\n success: true,\n message: 'Template deleted',\n });\n}\n"],"mappings":"AAAA,SAAsBA,YAAY,QAAQ,aAAa;AAIvD,SAASC,gBAAgB,EAAEC,UAAU,QAAQ,aAAa;AAE1D,MAAMC,OAAO,GACX,iEAAiE;AAEnE,SAASC,UAAUA,CAACC,MAInB,EAAE;EACD,OAAOL,YAAY,CAACM,IAAI,CAACD,MAAM,EAAE;IAAEE,MAAM,EAAEF,MAAM,CAACG,OAAO,GAAG,GAAG,GAAG;EAAI,CAAC,CAAC;AAC1E;AAEA,SAASC,UAAUA,CAACC,OAAe,EAAEC,IAAyB,EAAE;EAC9D,OAAOX,YAAY,CAACM,IAAI,CAAC;IAAEE,OAAO,EAAE,KAAK;IAAEE,OAAO;IAAEC;EAAK,CAAC,EAAE;IAAEJ,MAAM,EAAE;EAAI,CAAC,CAAC;AAC9E;;AAEA;AACA;AACA;AACA,SAASK,kBAAkBA,CACzBC,MAAsB,EACtBC,YAAoB,EACpBC,EAAU,EACV;EACA,OACED,YAAY,KAAKD,MAAM,CAACG,KAAK,CAACC,SAAS,CAACH,YAAY,IAAI,CAACX,OAAO,CAACe,IAAI,CAACH,EAAE,CAAC;AAE7E;AAEA,OAAO,eAAeI,kBAAkBA,CACtCN,MAAsB,EACtBO,OAAoB,EACpB;EACA,MAAM;IAAEC,IAAI;IAAEC,OAAO;IAAEC,QAAQ;IAAEC,aAAa;IAAEC;EAAe,CAAC,GAC9D,MAAML,OAAO,CAACd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A0B,EAAEA,KAAK,CAAC;IAChD,OAAOzC,UAAU,CAAC;MAChBI,OAAO,EAAE,KAAK;MACdE,OAAO,EAAE,kDAAkDmC,KAAK,EAAE;MAClElC,IAAI,EAAE;IACR,CAAC,CAAC;EACJ;EAEA,OAAOP,UAAU,CAAC;IAChBI,OAAO,EAAE,IAAI;IACbE,OAAO,EAAE;EACX,CAAC,CAAC;AACJ;AAEA,OAAO,eAAe0C,oBAAoBA,CACxCvC,MAAsB,EACtBC,YAAoB,EACpBC,EAAU,EACV;EACA,IAAIH,kBAAkB,CAACC,MAAM,EAAEC,YAAY,EAAEC,EAAE,CAAC,EAAE;IAChD,OAAON,UAAU,CAAC,4BAA4B,CAAC;EACjD;EAEA,IAAI;IACF,MAAMI,MAAM,CACTqB,gBAAgB,CAAC,CAAC,CAClBd,OAAO,CAAC,8BAA8BN,YAAY,IAAIC,EAAE,EAAE,EAAE;MAC3D6B,MAAM,EAAE;IACV,CAAC,CAAC;EACN,CAAC,CAAC,OAAOC,KAAK,EAAE;IACdC,OAAO,CAACD,KAAK,CAAC,0BAA0B,EAAEA,KAAK,CAAC;IAChD,OAAOzC,UAAU,CAAC;MAChBI,OAAO,EAAE,KAAK;MACdE,OAAO,EAAE,kDAAkDmC,KAAK,EAAE;MAClElC,IAAI,EAAE;IACR,CAAC,CAAC;EACJ;EAEA,OAAOP,UAAU,CAAC;IAChBI,OAAO,EAAE,IAAI;IACbE,OAAO,EAAE;EACX,CAAC,CAAC;AACJ","ignoreList":[]}
@@ -1,5 +1,6 @@
1
1
  import { NextRequest, NextResponse } from 'next/server';
2
- import type { PuckApiRuntime } from '../config';
2
+ import type { PuckApiRuntime } from '../config.js';
3
+ import type { ApiMessageParams, PuckApiMessageCode } from '../localize-message.js';
3
4
  /**
4
5
  * Editor upload forms send multipart form data (file/videoUrl + name/alt);
5
6
  * the agent bridge sends JSON with an inline data: URL for images or a
@@ -9,5 +10,12 @@ import type { PuckApiRuntime } from '../config';
9
10
  export declare function handleUpload(config: PuckApiRuntime, request: NextRequest): Promise<NextResponse<{
10
11
  status: string;
11
12
  message: string;
13
+ code: PuckApiMessageCode | undefined;
14
+ params: ApiMessageParams | undefined;
15
+ }> | NextResponse<{
16
+ status: string;
17
+ message: string;
18
+ code: PuckApiMessageCode | undefined;
19
+ id: string | null;
20
+ data: unknown;
12
21
  }>>;
13
- //# sourceMappingURL=upload.d.ts.map
@@ -1,7 +1,5 @@
1
1
  import { NextResponse } from 'next/server';
2
- import { MEDIA_TYPES } from '../../plugins/agent-plugin/constants';
3
- import { uploadImage, uploadRemoteVideo } from '../media-upload';
4
- const ALLOWED_TYPES = new Set(MEDIA_TYPES);
2
+ import { uploadImage, uploadRemoteVideo } from "../media-upload.js";
5
3
  function decodeDataUrl(url) {
6
4
  const match = /^data:([^;,]*)(;base64)?,([\s\S]*)$/.exec(url);
7
5
  if (!match) return null;
@@ -17,27 +15,69 @@ function imageFilename(mime, name) {
17
15
  const base = name?.replace(/\.[^.]+$/, '') || 'image';
18
16
  return `${base}.${ext}`;
19
17
  }
20
- function errorJson(message, status) {
18
+ function errorJson(message, status, code, params) {
21
19
  return NextResponse.json({
22
20
  status: 'error',
23
- message
21
+ message,
22
+ code,
23
+ params
24
24
  }, {
25
25
  status
26
26
  });
27
27
  }
28
28
  function resultJson(result) {
29
29
  if (!result.success) {
30
- return errorJson(result.message, 502);
30
+ return errorJson(result.message, 502, result.code);
31
31
  }
32
32
  const data = result.data;
33
33
  return NextResponse.json({
34
34
  status: 'ok',
35
35
  message: result.message,
36
+ code: result.code,
36
37
  id: data?.id ?? null,
37
38
  data: result.data
38
39
  });
39
40
  }
40
41
 
42
+ /**
43
+ * Reads the request body but aborts once it exceeds `maxBytes`, so a client
44
+ * that lies about or omits Content-Length cannot force the whole payload into
45
+ * memory before the per-file size check runs.
46
+ */
47
+ async function readBodyWithinLimit(request, maxBytes) {
48
+ const body = request.body;
49
+ if (!body) return new ArrayBuffer(0);
50
+ const reader = body.getReader();
51
+ const chunks = [];
52
+ let total = 0;
53
+ try {
54
+ for (;;) {
55
+ const {
56
+ done,
57
+ value
58
+ } = await reader.read();
59
+ if (done) break;
60
+ if (!value) continue;
61
+ total += value.byteLength;
62
+ if (total > maxBytes) {
63
+ await reader.cancel();
64
+ return null;
65
+ }
66
+ chunks.push(value);
67
+ }
68
+ } finally {
69
+ reader.releaseLock();
70
+ }
71
+ const out = new ArrayBuffer(total);
72
+ const view = new Uint8Array(out);
73
+ let offset = 0;
74
+ for (const chunk of chunks) {
75
+ view.set(chunk, offset);
76
+ offset += chunk.byteLength;
77
+ }
78
+ return out;
79
+ }
80
+
41
81
  /**
42
82
  * Editor upload forms send multipart form data (file/videoUrl + name/alt);
43
83
  * the agent bridge sends JSON with an inline data: URL for images or a
@@ -45,27 +85,42 @@ function resultJson(result) {
45
85
  * external URLs.
46
86
  */
47
87
  export async function handleUpload(config, request) {
88
+ const media = config.model.media;
48
89
  const maxUploadBytes = config.model.maxUploadBytes;
49
90
  const maxUploadMb = maxUploadBytes / 1024 / 1024;
91
+ const allowedTypes = new Set(media.uploadTypes);
92
+ const maxBodyBytes = Math.ceil(maxUploadBytes * 1.4);
93
+ const tooLarge = () => errorJson(`payload too large (max ${maxUploadMb} MB)`, 413, 'payloadTooLarge', {
94
+ maxMb: maxUploadMb
95
+ });
50
96
  const declared = Number(request.headers.get('content-length') || 0);
51
- if (declared > maxUploadBytes * 1.4) {
52
- return errorJson(`payload too large (max ${maxUploadMb} MB)`, 413);
97
+ if (declared > maxBodyBytes) {
98
+ return tooLarge();
99
+ }
100
+ const rawBody = await readBodyWithinLimit(request, maxBodyBytes);
101
+ if (rawBody === null) {
102
+ return tooLarge();
53
103
  }
54
104
  const client = config.createUserClient();
55
- if (request.headers.get('content-type')?.includes('multipart/form-data')) {
56
- const form = await request.formData();
57
- const type = String(form.get('type') || 'image');
105
+ const contentType = request.headers.get('content-type') || '';
106
+ if (contentType.includes('multipart/form-data')) {
107
+ const form = await new Response(rawBody, {
108
+ headers: {
109
+ 'content-type': contentType
110
+ }
111
+ }).formData();
112
+ const type = String(form.get('type') || media.imageType);
58
113
  const name = form.get('name') || undefined;
59
114
  const lang = form.get('lang') || undefined;
60
- if (!ALLOWED_TYPES.has(type)) {
61
- return errorJson('invalid media type', 400);
115
+ if (!allowedTypes.has(type)) {
116
+ return errorJson('invalid media type', 400, 'invalidMediaType');
62
117
  }
63
- if (type === 'remote_video') {
118
+ if (type === media.remoteVideoType) {
64
119
  const videoUrl = form.get('videoUrl');
65
120
  if (typeof videoUrl !== 'string' || !/^https?:\/\//i.test(videoUrl)) {
66
- return errorJson('remote_video expects a http(s) page url', 400);
121
+ return errorJson('remote_video expects a http(s) page url', 400, 'invalidVideoUrl');
67
122
  }
68
- return resultJson(await uploadRemoteVideo(client, {
123
+ return resultJson(await uploadRemoteVideo(client, media, {
69
124
  videoUrl,
70
125
  name,
71
126
  lang
@@ -73,37 +128,45 @@ export async function handleUpload(config, request) {
73
128
  }
74
129
  const file = form.get('file');
75
130
  if (!(file instanceof File)) {
76
- return errorJson('file is required', 400);
131
+ return errorJson('file is required', 400, 'fileRequired');
77
132
  }
78
133
  if (file.size > maxUploadBytes) {
79
- return errorJson(`image too large (max ${maxUploadMb} MB)`, 413);
134
+ return errorJson(`image too large (max ${maxUploadMb} MB)`, 413, 'payloadTooLarge', {
135
+ maxMb: maxUploadMb
136
+ });
80
137
  }
81
138
  const alt = form.get('alt') || undefined;
82
- return resultJson(await uploadImage(client, {
139
+ return resultJson(await uploadImage(client, media, {
83
140
  file,
84
141
  alt,
85
142
  name,
86
143
  lang
87
144
  }));
88
145
  }
146
+ let jsonBody;
147
+ try {
148
+ jsonBody = JSON.parse(new TextDecoder().decode(rawBody));
149
+ } catch {
150
+ return errorJson('invalid json body', 400);
151
+ }
89
152
  const {
90
- type = 'image',
153
+ type = media.imageType,
91
154
  url,
92
155
  name,
93
156
  alt,
94
157
  lang
95
- } = await request.json();
96
- if (!ALLOWED_TYPES.has(type)) {
97
- return errorJson('invalid media type', 400);
158
+ } = jsonBody;
159
+ if (!allowedTypes.has(type)) {
160
+ return errorJson('invalid media type', 400, 'invalidMediaType');
98
161
  }
99
162
  if (typeof url !== 'string') {
100
163
  return errorJson('url is required', 400);
101
164
  }
102
- if (type === 'remote_video') {
165
+ if (type === media.remoteVideoType) {
103
166
  if (!/^https?:\/\//i.test(url)) {
104
- return errorJson('remote_video expects a http(s) page url', 400);
167
+ return errorJson('remote_video expects a http(s) page url', 400, 'invalidVideoUrl');
105
168
  }
106
- return resultJson(await uploadRemoteVideo(client, {
169
+ return resultJson(await uploadRemoteVideo(client, media, {
107
170
  videoUrl: url,
108
171
  name,
109
172
  lang
@@ -114,12 +177,14 @@ export async function handleUpload(config, request) {
114
177
  return errorJson('image expects an inline data: URL (base64-encode the file)', 400);
115
178
  }
116
179
  if (decoded.bytes.byteLength > maxUploadBytes) {
117
- return errorJson(`image too large (max ${maxUploadMb} MB)`, 413);
180
+ return errorJson(`image too large (max ${maxUploadMb} MB)`, 413, 'payloadTooLarge', {
181
+ maxMb: maxUploadMb
182
+ });
118
183
  }
119
184
  const file = new File([new Uint8Array(decoded.bytes)], imageFilename(decoded.mime, name), {
120
185
  type: decoded.mime
121
186
  });
122
- return resultJson(await uploadImage(client, {
187
+ return resultJson(await uploadImage(client, media, {
123
188
  file,
124
189
  alt,
125
190
  name,
@@ -1 +1 @@
1
- {"version":3,"file":"upload.js","names":["NextResponse","MEDIA_TYPES","uploadImage","uploadRemoteVideo","ALLOWED_TYPES","Set","decodeDataUrl","url","match","exec","mime","bytes","Buffer","from","decodeURIComponent","imageFilename","name","ext","split","base","replace","errorJson","message","status","json","resultJson","result","success","data","id","handleUpload","config","request","maxUploadBytes","model","maxUploadMb","declared","Number","headers","get","client","createUserClient","includes","form","formData","type","String","undefined","lang","has","videoUrl","test","file","File","size","alt","decoded","startsWith","byteLength","Uint8Array"],"sources":["../../../../../src/puck-editor/internal/api/handlers/upload.ts"],"sourcesContent":["import { NextRequest, NextResponse } from 'next/server';\n\nimport { MEDIA_TYPES } from '../../plugins/agent-plugin/constants';\nimport type { PuckApiRuntime } from '../config';\nimport {\n uploadImage,\n uploadRemoteVideo,\n type MediaUploadResult,\n} from '../media-upload';\n\nconst ALLOWED_TYPES = new Set<string>(MEDIA_TYPES);\n\nfunction decodeDataUrl(url: string): { bytes: Buffer; mime: string } | null {\n const match = /^data:([^;,]*)(;base64)?,([\\s\\S]*)$/.exec(url);\n if (!match) return null;\n const mime = match[1] || 'image/png';\n const bytes = match[2]\n ? Buffer.from(match[3], 'base64')\n : Buffer.from(decodeURIComponent(match[3]));\n return { bytes, mime };\n}\n\nfunction imageFilename(mime: string, name?: string): string {\n const ext = mime.split('/')[1]?.split('+')[0] || 'bin';\n const base = name?.replace(/\\.[^.]+$/, '') || 'image';\n return `${base}.${ext}`;\n}\n\nfunction errorJson(message: string, status: number) {\n return NextResponse.json({ status: 'error', message }, { status });\n}\n\nfunction resultJson(result: MediaUploadResult) {\n if (!result.success) {\n return errorJson(result.message, 502);\n }\n const data = result.data as { id?: string } | undefined;\n return NextResponse.json({\n status: 'ok',\n message: result.message,\n id: data?.id ?? null,\n data: result.data,\n });\n}\n\n/**\n * Editor upload forms send multipart form data (file/videoUrl + name/alt);\n * the agent bridge sends JSON with an inline data: URL for images or a\n * YouTube/Vimeo page URL for remote_video. The server never fetches\n * external URLs.\n */\nexport async function handleUpload(\n config: PuckApiRuntime,\n request: NextRequest\n) {\n const maxUploadBytes = config.model.maxUploadBytes;\n const maxUploadMb = maxUploadBytes / 1024 / 1024;\n const declared = Number(request.headers.get('content-length') || 0);\n if (declared > maxUploadBytes * 1.4) {\n return errorJson(`payload too large (max ${maxUploadMb} MB)`, 413);\n }\n\n const client = config.createUserClient();\n\n if (request.headers.get('content-type')?.includes('multipart/form-data')) {\n const form = await request.formData();\n const type = String(form.get('type') || 'image');\n const name = (form.get('name') as string) || undefined;\n const lang = (form.get('lang') as string) || undefined;\n\n if (!ALLOWED_TYPES.has(type)) {\n return errorJson('invalid media type', 400);\n }\n\n if (type === 'remote_video') {\n const videoUrl = form.get('videoUrl');\n if (typeof videoUrl !== 'string' || !/^https?:\\/\\//i.test(videoUrl)) {\n return errorJson('remote_video expects a http(s) page url', 400);\n }\n return resultJson(\n await uploadRemoteVideo(client, { videoUrl, name, lang })\n );\n }\n\n const file = form.get('file');\n if (!(file instanceof File)) {\n return errorJson('file is required', 400);\n }\n if (file.size > maxUploadBytes) {\n return errorJson(`image too large (max ${maxUploadMb} MB)`, 413);\n }\n const alt = (form.get('alt') as string) || undefined;\n return resultJson(await uploadImage(client, { file, alt, name, lang }));\n }\n\n const { type = 'image', url, name, alt, lang } = await request.json();\n\n if (!ALLOWED_TYPES.has(type)) {\n return errorJson('invalid media type', 400);\n }\n if (typeof url !== 'string') {\n return errorJson('url is required', 400);\n }\n\n if (type === 'remote_video') {\n if (!/^https?:\\/\\//i.test(url)) {\n return errorJson('remote_video expects a http(s) page url', 400);\n }\n return resultJson(\n await uploadRemoteVideo(client, { videoUrl: url, name, lang })\n );\n }\n\n const decoded = url.startsWith('data:') ? decodeDataUrl(url) : null;\n if (!decoded) {\n return errorJson(\n 'image expects an inline data: URL (base64-encode the file)',\n 400\n );\n }\n if (decoded.bytes.byteLength > maxUploadBytes) {\n return errorJson(`image too large (max ${maxUploadMb} MB)`, 413);\n }\n const file = new File(\n [new Uint8Array(decoded.bytes)],\n imageFilename(decoded.mime, name),\n { type: decoded.mime }\n );\n return resultJson(await uploadImage(client, { file, alt, name, lang }));\n}\n"],"mappings":"AAAA,SAAsBA,YAAY,QAAQ,aAAa;AAEvD,SAASC,WAAW,QAAQ,sCAAsC;AAElE,SACEC,WAAW,EACXC,iBAAiB,QAEZ,iBAAiB;AAExB,MAAMC,aAAa,GAAG,IAAIC,GAAG,CAASJ,WAAW,CAAC;AAElD,SAASK,aAAaA,CAACC,GAAW,EAA0C;EAC1E,MAAMC,KAAK,GAAG,qCAAqC,CAACC,IAAI,CAACF,GAAG,CAAC;EAC7D,IAAI,CAACC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C,yCAAyC,EAAE,GAAG,CAAC;IAClE;IACA,OAAOI,UAAU,CACf,MAAMtB,iBAAiB,CAACqC,MAAM,EAAE;MAAEU,QAAQ,EAAE3C,GAAG;MAAES,IAAI;MAAEgC;IAAK,CAAC,CAC/D,CAAC;EACH;EAEA,MAAMQ,OAAO,GAAGjD,GAAG,CAACkD,UAAU,CAAC,OAAO,CAAC,GAAGnD,aAAa,CAACC,GAAG,CAAC,GAAG,IAAI;EACnE,IAAI,CAACiD,OAAO,EAAE;IACZ,OAAOnC,SAAS,CACd,4DAA4D,EAC5D,GACF,CAAC;EACH;EACA,IAAImC,OAAO,CAAC7C,KAAK,CAAC+C,UAAU,GAAGzB,cAAc,EAAE;IAC7C,OAAOZ,SAAS,CAAC,wBAAwBc,WAAW,MAAM,EAAE,GAAG,CAAC;EAClE;EACA,MAAMiB,IAAI,GAAG,IAAIC,IAAI,CACnB,CAAC,IAAIM,UAAU,CAACH,OAAO,CAAC7C,KAAK,CAAC,CAAC,EAC/BI,aAAa,CAACyC,OAAO,CAAC9C,IAAI,EAAEM,IAAI,CAAC,EACjC;IAAE6B,IAAI,EAAEW,OAAO,CAAC9C;EAAK,CACvB,CAAC;EACD,OAAOe,UAAU,CAAC,MAAMvB,WAAW,CAACsC,MAAM,EAAE;IAAEY,IAAI;IAAEG,GAAG;IAAEvC,IAAI;IAAEgC;EAAK,CAAC,CAAC,CAAC;AACzE","ignoreList":[]}
1
+ {"version":3,"file":"upload.js","names":["NextResponse","uploadImage","uploadRemoteVideo","decodeDataUrl","url","match","exec","mime","bytes","Buffer","from","decodeURIComponent","imageFilename","name","ext","split","base","replace","errorJson","message","status","code","params","json","resultJson","result","success","data","id","readBodyWithinLimit","request","maxBytes","body","ArrayBuffer","reader","getReader","chunks","total","done","value","read","byteLength","cancel","push","releaseLock","out","view","Uint8Array","offset","chunk","set","handleUpload","config","media","model","maxUploadBytes","maxUploadMb","allowedTypes","Set","uploadTypes","maxBodyBytes","Math","ceil","tooLarge","maxMb","declared","Number","headers","get","rawBody","client","createUserClient","contentType","includes","form","Response","formData","type","String","imageType","undefined","lang","has","remoteVideoType","videoUrl","test","file","File","size","alt","jsonBody","JSON","parse","TextDecoder","decode","decoded","startsWith"],"sources":["../../../../../src/puck-editor/internal/api/handlers/upload.ts"],"sourcesContent":["import { NextRequest, NextResponse } from 'next/server';\n\nimport type { PuckApiRuntime } from '../config.ts';\nimport type {\n ApiMessageParams,\n PuckApiMessageCode,\n} from '../localize-message.ts';\nimport {\n uploadImage,\n uploadRemoteVideo,\n type MediaUploadResult,\n} from '../media-upload.ts';\n\nfunction decodeDataUrl(url: string): { bytes: Buffer; mime: string } | null {\n const match = /^data:([^;,]*)(;base64)?,([\\s\\S]*)$/.exec(url);\n if (!match) return null;\n const mime = match[1] || 'image/png';\n const bytes = match[2]\n ? Buffer.from(match[3], 'base64')\n : Buffer.from(decodeURIComponent(match[3]));\n return { bytes, mime };\n}\n\nfunction imageFilename(mime: string, name?: string): string {\n const ext = mime.split('/')[1]?.split('+')[0] || 'bin';\n const base = name?.replace(/\\.[^.]+$/, '') || 'image';\n return `${base}.${ext}`;\n}\n\nfunction errorJson(\n message: string,\n status: number,\n code?: PuckApiMessageCode,\n params?: ApiMessageParams\n) {\n return NextResponse.json(\n { status: 'error', message, code, params },\n { status }\n );\n}\n\nfunction resultJson(result: MediaUploadResult) {\n if (!result.success) {\n return errorJson(result.message, 502, result.code);\n }\n const data = result.data as { id?: string } | undefined;\n return NextResponse.json({\n status: 'ok',\n message: result.message,\n code: result.code,\n id: data?.id ?? null,\n data: result.data,\n });\n}\n\n/**\n * Reads the request body but aborts once it exceeds `maxBytes`, so a client\n * that lies about or omits Content-Length cannot force the whole payload into\n * memory before the per-file size check runs.\n */\nasync function readBodyWithinLimit(\n request: NextRequest,\n maxBytes: number\n): Promise<ArrayBuffer | null> {\n const body = request.body;\n if (!body) return new ArrayBuffer(0);\n const reader = body.getReader();\n const chunks: Uint8Array[] = [];\n let total = 0;\n try {\n for (;;) {\n const { done, value } = await reader.read();\n if (done) break;\n if (!value) continue;\n total += value.byteLength;\n if (total > maxBytes) {\n await reader.cancel();\n return null;\n }\n chunks.push(value);\n }\n } finally {\n reader.releaseLock();\n }\n const out = new ArrayBuffer(total);\n const view = new Uint8Array(out);\n let offset = 0;\n for (const chunk of chunks) {\n view.set(chunk, offset);\n offset += chunk.byteLength;\n }\n return out;\n}\n\n/**\n * Editor upload forms send multipart form data (file/videoUrl + name/alt);\n * the agent bridge sends JSON with an inline data: URL for images or a\n * YouTube/Vimeo page URL for remote_video. The server never fetches\n * external URLs.\n */\nexport async function handleUpload(\n config: PuckApiRuntime,\n request: NextRequest\n) {\n const media = config.model.media;\n const maxUploadBytes = config.model.maxUploadBytes;\n const maxUploadMb = maxUploadBytes / 1024 / 1024;\n const allowedTypes = new Set(media.uploadTypes);\n const maxBodyBytes = Math.ceil(maxUploadBytes * 1.4);\n\n const tooLarge = () =>\n errorJson(\n `payload too large (max ${maxUploadMb} MB)`,\n 413,\n 'payloadTooLarge',\n {\n maxMb: maxUploadMb,\n }\n );\n\n const declared = Number(request.headers.get('content-length') || 0);\n if (declared > maxBodyBytes) {\n return tooLarge();\n }\n\n const rawBody = await readBodyWithinLimit(request, maxBodyBytes);\n if (rawBody === null) {\n return tooLarge();\n }\n\n const client = config.createUserClient();\n const contentType = request.headers.get('content-type') || '';\n\n if (contentType.includes('multipart/form-data')) {\n const form = await new Response(rawBody, {\n headers: { 'content-type': contentType },\n }).formData();\n const type = String(form.get('type') || media.imageType);\n const name = (form.get('name') as string) || undefined;\n const lang = (form.get('lang') as string) || undefined;\n\n if (!allowedTypes.has(type)) {\n return errorJson('invalid media type', 400, 'invalidMediaType');\n }\n\n if (type === media.remoteVideoType) {\n const videoUrl = form.get('videoUrl');\n if (typeof videoUrl !== 'string' || !/^https?:\\/\\//i.test(videoUrl)) {\n return errorJson(\n 'remote_video expects a http(s) page url',\n 400,\n 'invalidVideoUrl'\n );\n }\n return resultJson(\n await uploadRemoteVideo(client, media, { videoUrl, name, lang })\n );\n }\n\n const file = form.get('file');\n if (!(file instanceof File)) {\n return errorJson('file is required', 400, 'fileRequired');\n }\n if (file.size > maxUploadBytes) {\n return errorJson(\n `image too large (max ${maxUploadMb} MB)`,\n 413,\n 'payloadTooLarge',\n { maxMb: maxUploadMb }\n );\n }\n const alt = (form.get('alt') as string) || undefined;\n return resultJson(\n await uploadImage(client, media, { file, alt, name, lang })\n );\n }\n\n let jsonBody: {\n type?: string;\n url?: unknown;\n name?: string;\n alt?: string;\n lang?: string;\n };\n try {\n jsonBody = JSON.parse(new TextDecoder().decode(rawBody));\n } catch {\n return errorJson('invalid json body', 400);\n }\n const { type = media.imageType, url, name, alt, lang } = jsonBody;\n\n if (!allowedTypes.has(type)) {\n return errorJson('invalid media type', 400, 'invalidMediaType');\n }\n if (typeof url !== 'string') {\n return errorJson('url is required', 400);\n }\n\n if (type === media.remoteVideoType) {\n if (!/^https?:\\/\\//i.test(url)) {\n return errorJson(\n 'remote_video expects a http(s) page url',\n 400,\n 'invalidVideoUrl'\n );\n }\n return resultJson(\n await uploadRemoteVideo(client, media, { videoUrl: url, name, lang })\n );\n }\n\n const decoded = url.startsWith('data:') ? decodeDataUrl(url) : null;\n if (!decoded) {\n return errorJson(\n 'image expects an inline data: URL (base64-encode the file)',\n 400\n );\n }\n if (decoded.bytes.byteLength > maxUploadBytes) {\n return errorJson(\n `image too large (max ${maxUploadMb} MB)`,\n 413,\n 'payloadTooLarge',\n {\n maxMb: maxUploadMb,\n }\n );\n }\n const file = new File(\n [new Uint8Array(decoded.bytes)],\n imageFilename(decoded.mime, name),\n { type: decoded.mime }\n );\n return resultJson(\n await uploadImage(client, media, { file, alt, name, lang })\n );\n}\n"],"mappings":"AAAA,SAAsBA,YAAY,QAAQ,aAAa;AAOvD,SACEC,WAAW,EACXC,iBAAiB,QAEZ,oBAAoB;AAE3B,SAASC,aAAaA,CAACC,GAAW,EAA0C;EAC1E,MAAMC,KAAK,GAAG,qCAAqC,CA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AG,IAAI;EACnE,IAAI,CAAC2F,OAAO,EAAE;IACZ,OAAO7E,SAAS,CACd,4DAA4D,EAC5D,GACF,CAAC;EACH;EACA,IAAI6E,OAAO,CAACvF,KAAK,CAACiC,UAAU,GAAGc,cAAc,EAAE;IAC7C,OAAOrC,SAAS,CACd,wBAAwBsC,WAAW,MAAM,EACzC,GAAG,EACH,iBAAiB,EACjB;MACEQ,KAAK,EAAER;IACT,CACF,CAAC;EACH;EACA,MAAM8B,IAAI,GAAG,IAAIC,IAAI,CACnB,CAAC,IAAIxC,UAAU,CAACgD,OAAO,CAACvF,KAAK,CAAC,CAAC,EAC/BI,aAAa,CAACmF,OAAO,CAACxF,IAAI,EAAEM,IAAI,CAAC,EACjC;IAAEgE,IAAI,EAAEkB,OAAO,CAACxF;EAAK,CACvB,CAAC;EACD,OAAOiB,UAAU,CACf,MAAMvB,WAAW,CAACqE,MAAM,EAAEjB,KAAK,EAAE;IAAEiC,IAAI;IAAEG,GAAG;IAAE5E,IAAI;IAAEoE;EAAK,CAAC,CAC5D,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,15 @@
1
+ export type PuckApiMessageCode = 'authRequired' | 'fileUploadFailed' | 'mediaCreateFailed' | 'imageUploaded' | 'unexpectedError' | 'videoUrlRequired' | 'remoteVideoCreateFailed' | 'remoteVideoAdded' | 'payloadTooLarge' | 'invalidMediaType' | 'invalidVideoUrl' | 'fileRequired' | 'nameRequired' | 'contentRequired' | 'spaceUnresolved' | 'templateSaveError' | 'templateUpdateError' | 'templateDeleteError' | 'builtinNotEditable' | 'builtinNotDeletable';
2
+ export type ApiMessageParams = Record<string, string | number>;
3
+ export type ServerMessageCatalog = Record<PuckApiMessageCode, string>;
4
+ /**
5
+ * Resolve a server/client API result into a localized string: a stable `code`
6
+ * maps to the typed catalog (overridable per project), an unknown or missing
7
+ * code falls back to the server-provided English `message`.
8
+ */
9
+ export declare function localizeApiMessage(dict: {
10
+ serverMessages: ServerMessageCatalog;
11
+ }, result: {
12
+ code?: string;
13
+ message?: string;
14
+ params?: ApiMessageParams;
15
+ }): string;
@@ -0,0 +1,15 @@
1
+ function interpolate(template, params) {
2
+ if (!params) return template;
3
+ return Object.entries(params).reduce((text, [key, value]) => text.split(`{${key}}`).join(String(value)), template);
4
+ }
5
+
6
+ /**
7
+ * Resolve a server/client API result into a localized string: a stable `code`
8
+ * maps to the typed catalog (overridable per project), an unknown or missing
9
+ * code falls back to the server-provided English `message`.
10
+ */
11
+ export function localizeApiMessage(dict, result) {
12
+ const template = result.code && Object.hasOwn(dict.serverMessages, result.code) ? dict.serverMessages[result.code] : undefined;
13
+ return interpolate(template ?? result.message ?? '', result.params);
14
+ }
15
+ //# sourceMappingURL=localize-message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localize-message.js","names":["interpolate","template","params","Object","entries","reduce","text","key","value","split","join","String","localizeApiMessage","dict","result","code","hasOwn","serverMessages","undefined","message"],"sources":["../../../../src/puck-editor/internal/api/localize-message.ts"],"sourcesContent":["export type PuckApiMessageCode =\n | 'authRequired'\n | 'fileUploadFailed'\n | 'mediaCreateFailed'\n | 'imageUploaded'\n | 'unexpectedError'\n | 'videoUrlRequired'\n | 'remoteVideoCreateFailed'\n | 'remoteVideoAdded'\n | 'payloadTooLarge'\n | 'invalidMediaType'\n | 'invalidVideoUrl'\n | 'fileRequired'\n | 'nameRequired'\n | 'contentRequired'\n | 'spaceUnresolved'\n | 'templateSaveError'\n | 'templateUpdateError'\n | 'templateDeleteError'\n | 'builtinNotEditable'\n | 'builtinNotDeletable';\n\nexport type ApiMessageParams = Record<string, string | number>;\n\nexport type ServerMessageCatalog = Record<PuckApiMessageCode, string>;\n\nfunction interpolate(template: string, params?: ApiMessageParams): string {\n if (!params) return template;\n return Object.entries(params).reduce(\n (text, [key, value]) => text.split(`{${key}}`).join(String(value)),\n template\n );\n}\n\n/**\n * Resolve a server/client API result into a localized string: a stable `code`\n * maps to the typed catalog (overridable per project), an unknown or missing\n * code falls back to the server-provided English `message`.\n */\nexport function localizeApiMessage(\n dict: { serverMessages: ServerMessageCatalog },\n result: {\n code?: string;\n message?: string;\n params?: ApiMessageParams;\n }\n): string {\n const template =\n result.code && Object.hasOwn(dict.serverMessages, result.code)\n ? dict.serverMessages[result.code as PuckApiMessageCode]\n : undefined;\n return interpolate(template ?? result.message ?? '', result.params);\n}\n"],"mappings":"AA0BA,SAASA,WAAWA,CAACC,QAAgB,EAAEC,MAAyB,EAAU;EACxE,IAAI,CAACA,MAAM,EAAE,OAAOD,QAAQ;EAC5B,OAAOE,MAAM,CAACC,OAAO,CAACF,MAAM,CAAC,CAACG,MAAM,CAClC,CAACC,IAAI,EAAE,CAACC,GAAG,EAAEC,KAAK,CAAC,KAAKF,IAAI,CAACG,KAAK,CAAC,IAAIF,GAAG,GAAG,CAAC,CAACG,IAAI,CAACC,MAAM,CAACH,KAAK,CAAC,CAAC,EAClEP,QACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASW,kBAAkBA,CAChCC,IAA8C,EAC9CC,MAIC,EACO;EACR,MAAMb,QAAQ,GACZa,MAAM,CAACC,IAAI,IAAIZ,MAAM,CAACa,MAAM,CAACH,IAAI,CAACI,cAAc,EAAEH,MAAM,CAACC,IAAI,CAAC,GAC1DF,IAAI,CAACI,cAAc,CAACH,MAAM,CAACC,IAAI,CAAuB,GACtDG,SAAS;EACf,OAAOlB,WAAW,CAACC,QAAQ,IAAIa,MAAM,CAACK,OAAO,IAAI,EAAE,EAAEL,MAAM,CAACZ,MAAM,CAAC;AACrE","ignoreList":[]}
@@ -1,4 +1,4 @@
1
1
  import { DrupalJsonApiParams } from 'drupal-jsonapi-params';
2
- export declare function buildMediaParams(type: string): DrupalJsonApiParams;
3
- export declare function buildMediaListParams(type: string, query?: string, offset?: string, limit?: string): DrupalJsonApiParams;
4
- //# sourceMappingURL=media-params.d.ts.map
2
+ import { type PuckMediaConfig } from '../content-model.js';
3
+ export declare function buildMediaParams(type: string, media: PuckMediaConfig): DrupalJsonApiParams;
4
+ export declare function buildMediaListParams(type: string, media: PuckMediaConfig, query?: string, offset?: string, limit?: string): DrupalJsonApiParams;
@@ -1,20 +1,27 @@
1
1
  import { DrupalJsonApiParams } from 'drupal-jsonapi-params';
2
- export function buildMediaParams(type) {
2
+ import { mediaEntityType } from "../content-model.js";
3
+ function addImageFields(apiParams, media) {
4
+ apiParams.addInclude([media.imageFileField, 'thumbnail']);
5
+ apiParams.addFields(mediaEntityType(media.imageType), ['name', 'thumbnail', media.imageFileField]);
6
+ apiParams.addFields('file--image', ['uri']);
7
+ }
8
+ function addRemoteVideoFields(apiParams, media) {
9
+ apiParams.addInclude(['thumbnail']);
10
+ apiParams.addFields(mediaEntityType(media.remoteVideoType), ['name', 'thumbnail', media.remoteVideoUrlField]);
11
+ }
12
+ export function buildMediaParams(type, media) {
3
13
  const apiParams = new DrupalJsonApiParams();
4
- if (type === 'image') {
5
- apiParams.addInclude(['field_media_image', 'thumbnail']);
6
- apiParams.addFields('media--image', ['name', 'thumbnail', 'field_media_image']);
7
- apiParams.addFields('file--image', ['uri']);
8
- } else if (type === 'remote_video') {
9
- apiParams.addInclude(['thumbnail']);
10
- apiParams.addFields('media--remote_video', ['name', 'thumbnail', 'field_media_oembed_video']);
11
- } else if (type === 'video') {
12
- apiParams.addInclude(['field_media_image']);
13
- apiParams.addFields('media--video', ['name', 'field_media_image', 'field_media_video_file']);
14
+ if (type === media.imageType) {
15
+ addImageFields(apiParams, media);
16
+ } else if (type === media.remoteVideoType) {
17
+ addRemoteVideoFields(apiParams, media);
18
+ } else if (type === media.videoType) {
19
+ apiParams.addInclude([media.imageFileField]);
20
+ apiParams.addFields(mediaEntityType(media.videoType), ['name', media.imageFileField, media.videoFileField]);
14
21
  }
15
22
  return apiParams;
16
23
  }
17
- export function buildMediaListParams(type, query, offset, limit) {
24
+ export function buildMediaListParams(type, media, query, offset, limit) {
18
25
  const apiParams = new DrupalJsonApiParams().addSort('created', 'DESC');
19
26
  if (query) {
20
27
  apiParams.addFilter('name', query, 'CONTAINS');
@@ -25,13 +32,10 @@ export function buildMediaListParams(type, query, offset, limit) {
25
32
  if (limit) {
26
33
  apiParams.addPageLimit(Number(limit));
27
34
  }
28
- if (type === 'image') {
29
- apiParams.addInclude(['field_media_image', 'thumbnail']);
30
- apiParams.addFields('media--image', ['name', 'thumbnail', 'field_media_image']);
31
- apiParams.addFields('file--image', ['uri']);
32
- } else if (type === 'remote_video') {
33
- apiParams.addInclude(['thumbnail']);
34
- apiParams.addFields('media--remote_video', ['name', 'thumbnail', 'field_media_oembed_video']);
35
+ if (type === media.imageType) {
36
+ addImageFields(apiParams, media);
37
+ } else if (type === media.remoteVideoType) {
38
+ addRemoteVideoFields(apiParams, media);
35
39
  }
36
40
  return apiParams;
37
41
  }
@@ -1 +1 @@
1
- {"version":3,"file":"media-params.js","names":["DrupalJsonApiParams","buildMediaParams","type","apiParams","addInclude","addFields","buildMediaListParams","query","offset","limit","addSort","addFilter","addPageOffset","Number","addPageLimit"],"sources":["../../../../src/puck-editor/internal/api/media-params.ts"],"sourcesContent":["import { DrupalJsonApiParams } from 'drupal-jsonapi-params';\n\nexport function buildMediaParams(type: string) {\n const apiParams = new DrupalJsonApiParams();\n if (type === 'image') {\n apiParams.addInclude(['field_media_image', 'thumbnail']);\n apiParams.addFields('media--image', [\n 'name',\n 'thumbnail',\n 'field_media_image',\n ]);\n apiParams.addFields('file--image', ['uri']);\n } else if (type === 'remote_video') {\n apiParams.addInclude(['thumbnail']);\n apiParams.addFields('media--remote_video', [\n 'name',\n 'thumbnail',\n 'field_media_oembed_video',\n ]);\n } else if (type === 'video') {\n apiParams.addInclude(['field_media_image']);\n apiParams.addFields('media--video', [\n 'name',\n 'field_media_image',\n 'field_media_video_file',\n ]);\n }\n return apiParams;\n}\n\nexport function buildMediaListParams(\n type: string,\n query?: string,\n offset?: string,\n limit?: string\n) {\n const apiParams = new DrupalJsonApiParams().addSort('created', 'DESC');\n if (query) {\n apiParams.addFilter('name', query, 'CONTAINS');\n }\n if (offset) {\n apiParams.addPageOffset(Number(offset));\n }\n if (limit) {\n apiParams.addPageLimit(Number(limit));\n }\n\n if (type === 'image') {\n apiParams.addInclude(['field_media_image', 'thumbnail']);\n apiParams.addFields('media--image', [\n 'name',\n 'thumbnail',\n 'field_media_image',\n ]);\n apiParams.addFields('file--image', ['uri']);\n } else if (type === 'remote_video') {\n apiParams.addInclude(['thumbnail']);\n apiParams.addFields('media--remote_video', [\n 'name',\n 'thumbnail',\n 'field_media_oembed_video',\n ]);\n }\n return apiParams;\n}\n"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,uBAAuB;AAE3D,OAAO,SAASC,gBAAgBA,CAACC,IAAY,EAAE;EAC7C,MAAMC,SAAS,GAAG,IAAIH,mBAAmB,CAAC,CAAC;EAC3C,IAAIE,IAAI,KAAK,OAAO,EAAE;IACpBC,SAAS,CAACC,UAAU,CAAC,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAC;IACxDD,SAAS,CAACE,SAAS,CAAC,cAAc,EAAE,CAClC,MAAM,EACN,WAAW,EACX,mBAAmB,CACpB,CAAC;IACFF,SAAS,CAACE,SAAS,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,CAAC;EAC7C,CAAC,MAAM,IAAIH,IAAI,KAAK,cAAc,EAAE;IAClCC,SAAS,CAACC,UAAU,CAAC,CAAC,WAAW,CAAC,CAAC;IACnCD,SAAS,CAACE,SAAS,CAAC,qBAAqB,EAAE,CACzC,MAAM,EACN,WAAW,EACX,0BAA0B,CAC3B,CAAC;EACJ,CAAC,MAAM,IAAIH,IAAI,KAAK,OAAO,EAAE;IAC3BC,SAAS,CAACC,UAAU,CAAC,CAAC,mBAAmB,CAAC,CAAC;IAC3CD,SAAS,CAACE,SAAS,CAAC,cAAc,EAAE,CAClC,MAAM,EACN,mBAAmB,EACnB,wBAAwB,CACzB,CAAC;EACJ;EACA,OAAOF,SAAS;AAClB;AAEA,OAAO,SAASG,oBAAoBA,CAClCJ,IAAY,EACZK,KAAc,EACdC,MAAe,EACfC,KAAc,EACd;EACA,MAAMN,SAAS,GAAG,IAAIH,mBAAmB,CAAC,CAAC,CAACU,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC;EACtE,IAAIH,KAAK,EAAE;IACTJ,SAAS,CAACQ,SAAS,CAAC,MAAM,EAAEJ,KAAK,EAAE,UAAU,CAAC;EAChD;EACA,IAAIC,MAAM,EAAE;IACVL,SAAS,CAACS,aAAa,CAACC,MAAM,CAACL,MAAM,CAAC,CAAC;EACzC;EACA,IAAIC,KAAK,EAAE;IACTN,SAAS,CAACW,YAAY,CAACD,MAAM,CAACJ,KAAK,CAAC,CAAC;EACvC;EAEA,IAAIP,IAAI,KAAK,OAAO,EAAE;IACpBC,SAAS,CAACC,UAAU,CAAC,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAC;IACxDD,SAAS,CAACE,SAAS,CAAC,cAAc,EAAE,CAClC,MAAM,EACN,WAAW,EACX,mBAAmB,CACpB,CAAC;IACFF,SAAS,CAACE,SAAS,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,CAAC;EAC7C,CAAC,MAAM,IAAIH,IAAI,KAAK,cAAc,EAAE;IAClCC,SAAS,CAACC,UAAU,CAAC,CAAC,WAAW,CAAC,CAAC;IACnCD,SAAS,CAACE,SAAS,CAAC,qBAAqB,EAAE,CACzC,MAAM,EACN,WAAW,EACX,0BAA0B,CAC3B,CAAC;EACJ;EACA,OAAOF,SAAS;AAClB","ignoreList":[]}
1
+ {"version":3,"file":"media-params.js","names":["DrupalJsonApiParams","mediaEntityType","addImageFields","apiParams","media","addInclude","imageFileField","addFields","imageType","addRemoteVideoFields","remoteVideoType","remoteVideoUrlField","buildMediaParams","type","videoType","videoFileField","buildMediaListParams","query","offset","limit","addSort","addFilter","addPageOffset","Number","addPageLimit"],"sources":["../../../../src/puck-editor/internal/api/media-params.ts"],"sourcesContent":["import { DrupalJsonApiParams } from 'drupal-jsonapi-params';\n\nimport { mediaEntityType, type PuckMediaConfig } from '../content-model.ts';\n\nfunction addImageFields(\n apiParams: DrupalJsonApiParams,\n media: PuckMediaConfig\n) {\n apiParams.addInclude([media.imageFileField, 'thumbnail']);\n apiParams.addFields(mediaEntityType(media.imageType), [\n 'name',\n 'thumbnail',\n media.imageFileField,\n ]);\n apiParams.addFields('file--image', ['uri']);\n}\n\nfunction addRemoteVideoFields(\n apiParams: DrupalJsonApiParams,\n media: PuckMediaConfig\n) {\n apiParams.addInclude(['thumbnail']);\n apiParams.addFields(mediaEntityType(media.remoteVideoType), [\n 'name',\n 'thumbnail',\n media.remoteVideoUrlField,\n ]);\n}\n\nexport function buildMediaParams(type: string, media: PuckMediaConfig) {\n const apiParams = new DrupalJsonApiParams();\n if (type === media.imageType) {\n addImageFields(apiParams, media);\n } else if (type === media.remoteVideoType) {\n addRemoteVideoFields(apiParams, media);\n } else if (type === media.videoType) {\n apiParams.addInclude([media.imageFileField]);\n apiParams.addFields(mediaEntityType(media.videoType), [\n 'name',\n media.imageFileField,\n media.videoFileField,\n ]);\n }\n return apiParams;\n}\n\nexport function buildMediaListParams(\n type: string,\n media: PuckMediaConfig,\n query?: string,\n offset?: string,\n limit?: string\n) {\n const apiParams = new DrupalJsonApiParams().addSort('created', 'DESC');\n if (query) {\n apiParams.addFilter('name', query, 'CONTAINS');\n }\n if (offset) {\n apiParams.addPageOffset(Number(offset));\n }\n if (limit) {\n apiParams.addPageLimit(Number(limit));\n }\n\n if (type === media.imageType) {\n addImageFields(apiParams, media);\n } else if (type === media.remoteVideoType) {\n addRemoteVideoFields(apiParams, media);\n }\n return apiParams;\n}\n"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,uBAAuB;AAE3D,SAASC,eAAe,QAA8B,qBAAqB;AAE3E,SAASC,cAAcA,CACrBC,SAA8B,EAC9BC,KAAsB,EACtB;EACAD,SAAS,CAACE,UAAU,CAAC,CAACD,KAAK,CAACE,cAAc,EAAE,WAAW,CAAC,CAAC;EACzDH,SAAS,CAAC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AAO,CAAC,SAAS,EAAE,MAAM,CAAC;EACtE,IAAIH,KAAK,EAAE;IACTd,SAAS,CAACkB,SAAS,CAAC,MAAM,EAAEJ,KAAK,EAAE,UAAU,CAAC;EAChD;EACA,IAAIC,MAAM,EAAE;IACVf,SAAS,CAACmB,aAAa,CAACC,MAAM,CAACL,MAAM,CAAC,CAAC;EACzC;EACA,IAAIC,KAAK,EAAE;IACThB,SAAS,CAACqB,YAAY,CAACD,MAAM,CAACJ,KAAK,CAAC,CAAC;EACvC;EAEA,IAAIN,IAAI,KAAKT,KAAK,CAACI,SAAS,EAAE;IAC5BN,cAAc,CAACC,SAAS,EAAEC,KAAK,CAAC;EAClC,CAAC,MAAM,IAAIS,IAAI,KAAKT,KAAK,CAACM,eAAe,EAAE;IACzCD,oBAAoB,CAACN,SAAS,EAAEC,KAAK,CAAC;EACxC;EACA,OAAOD,SAAS;AAClB","ignoreList":[]}
@@ -1,7 +1,10 @@
1
1
  import type { NodeHiveClient } from 'nodehive-js';
2
+ import { type PuckMediaConfig } from '../content-model.js';
3
+ import type { PuckApiMessageCode } from './localize-message.js';
2
4
  export type MediaUploadResult = {
3
5
  success: boolean;
4
6
  message: string;
7
+ code?: PuckApiMessageCode;
5
8
  data?: unknown;
6
9
  };
7
10
  /**
@@ -9,16 +12,15 @@ export type MediaUploadResult = {
9
12
  * the JSON:API file upload process: upload the binary to create a file entity,
10
13
  * then create a media entity referencing it.
11
14
  */
12
- export declare function uploadImage(client: NodeHiveClient, { file, alt, name, lang, }: {
15
+ export declare function uploadImage(client: NodeHiveClient, media: PuckMediaConfig, { file, alt, name, lang, }: {
13
16
  file: File;
14
17
  alt?: string;
15
18
  name?: string;
16
19
  lang?: string;
17
20
  }): Promise<MediaUploadResult>;
18
21
  /** Creates a remote video media entity in Drupal from a YouTube/Vimeo page URL. */
19
- export declare function uploadRemoteVideo(client: NodeHiveClient, { videoUrl, name, lang }: {
22
+ export declare function uploadRemoteVideo(client: NodeHiveClient, media: PuckMediaConfig, { videoUrl, name, lang }: {
20
23
  videoUrl: string;
21
24
  name?: string;
22
25
  lang?: string;
23
26
  }): Promise<MediaUploadResult>;
24
- //# sourceMappingURL=media-upload.d.ts.map