opacacms 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (399) hide show
  1. package/bun.lock +34 -0
  2. package/dist/admin/api-client.d.ts +8 -0
  3. package/dist/admin/auth-client.d.ts +940 -0
  4. package/dist/admin/custom-field.d.ts +71 -0
  5. package/dist/admin/index.d.ts +11 -0
  6. package/dist/admin/react.d.ts +3 -0
  7. package/dist/admin/router.d.ts +7 -0
  8. package/dist/admin/stores/admin-queries.d.ts +32 -0
  9. package/dist/admin/stores/auth.d.ts +33 -0
  10. package/dist/admin/stores/column-visibility.d.ts +21 -0
  11. package/dist/admin/stores/config.d.ts +7 -0
  12. package/dist/admin/stores/media.d.ts +44 -0
  13. package/dist/admin/stores/query.d.ts +4 -0
  14. package/dist/admin/stores/ui.d.ts +11 -0
  15. package/dist/admin/ui/admin-client.d.ts +7 -0
  16. package/dist/admin/ui/admin-layout.d.ts +14 -0
  17. package/dist/admin/ui/components/ColumnVisibilityToggle.d.ts +10 -0
  18. package/dist/admin/ui/components/DataDetailSheet.d.ts +13 -0
  19. package/dist/admin/ui/components/DataDetailView.d.ts +9 -0
  20. package/dist/admin/ui/components/Table.d.ts +10 -0
  21. package/dist/admin/ui/components/fields/ArrayField.d.ts +13 -0
  22. package/dist/admin/ui/components/fields/BlocksField.d.ts +17 -0
  23. package/dist/admin/ui/components/fields/BooleanField.d.ts +13 -0
  24. package/dist/admin/ui/components/fields/CollapsibleField.d.ts +16 -0
  25. package/dist/admin/ui/components/fields/DateField.d.ts +13 -0
  26. package/dist/admin/ui/components/fields/FileField.d.ts +23 -0
  27. package/dist/admin/ui/components/fields/GroupField.d.ts +13 -0
  28. package/dist/admin/ui/components/fields/JoinField.d.ts +15 -0
  29. package/dist/admin/ui/components/fields/NumberField.d.ts +14 -0
  30. package/dist/admin/ui/components/fields/RadioField.d.ts +17 -0
  31. package/dist/admin/ui/components/fields/RelationshipField.d.ts +16 -0
  32. package/dist/admin/ui/components/fields/RowField.d.ts +12 -0
  33. package/dist/admin/ui/components/fields/SelectField.d.ts +18 -0
  34. package/dist/admin/ui/components/fields/TabsField.d.ts +15 -0
  35. package/dist/admin/ui/components/fields/TextAreaField.d.ts +14 -0
  36. package/dist/admin/ui/components/fields/TextField.d.ts +14 -0
  37. package/dist/admin/ui/components/fields/VirtualField.d.ts +8 -0
  38. package/dist/admin/ui/components/fields/index.d.ts +28 -0
  39. package/dist/admin/ui/components/fields/richtext-editor/index.d.ts +10 -0
  40. package/dist/admin/ui/components/fields/richtext-editor/nodes/ImageComponent.d.ts +7 -0
  41. package/dist/admin/ui/components/fields/richtext-editor/nodes/ImageNode.d.ts +27 -0
  42. package/dist/admin/ui/components/fields/richtext-editor/plugins/ComponentPickerPlugin.d.ts +1 -0
  43. package/dist/admin/ui/components/fields/richtext-editor/plugins/EditableSyncPlugin.d.ts +5 -0
  44. package/dist/admin/ui/components/fields/richtext-editor/plugins/NotionToolbarPlugin.d.ts +1 -0
  45. package/dist/admin/ui/components/fields/richtext-editor/plugins/SimpleToolbarPlugin.d.ts +1 -0
  46. package/dist/admin/ui/components/fields/richtext-editor/plugins/ValueSyncPlugin.d.ts +5 -0
  47. package/dist/admin/ui/components/fields/utils.d.ts +1 -0
  48. package/dist/admin/ui/components/link.d.ts +8 -0
  49. package/dist/admin/ui/components/media/AssetManagerModal.d.ts +17 -0
  50. package/dist/admin/ui/components/toast.d.ts +10 -0
  51. package/dist/admin/ui/components/ui/accordion.d.ts +11 -0
  52. package/dist/admin/ui/components/ui/alert-dialog.d.ts +12 -0
  53. package/dist/admin/ui/components/ui/blocks.d.ts +5 -0
  54. package/dist/admin/ui/components/ui/breadcrumbs.d.ts +7 -0
  55. package/dist/admin/ui/components/ui/button.d.ts +7 -0
  56. package/dist/admin/ui/components/ui/collapsible.d.ts +16 -0
  57. package/dist/admin/ui/components/ui/dialog.d.ts +27 -0
  58. package/dist/admin/ui/components/ui/group.d.ts +6 -0
  59. package/dist/admin/ui/components/ui/index.d.ts +17 -0
  60. package/dist/admin/ui/components/ui/input.d.ts +5 -0
  61. package/dist/admin/ui/components/ui/join.d.ts +7 -0
  62. package/dist/admin/ui/components/ui/label.d.ts +3 -0
  63. package/dist/admin/ui/components/ui/radio-group.d.ts +13 -0
  64. package/dist/admin/ui/components/ui/relationship-detail-sheet.d.ts +9 -0
  65. package/dist/admin/ui/components/ui/relationship.d.ts +8 -0
  66. package/dist/admin/ui/components/ui/scroll-area.d.ts +7 -0
  67. package/dist/admin/ui/components/ui/select.d.ts +37 -0
  68. package/dist/admin/ui/components/ui/separator.d.ts +8 -0
  69. package/dist/admin/ui/components/ui/sheet.d.ts +28 -0
  70. package/dist/admin/ui/components/ui/tabs.d.ts +17 -0
  71. package/dist/admin/ui/components/ui/utils.d.ts +1 -0
  72. package/dist/admin/ui/hooks/use-debounce.d.ts +1 -0
  73. package/dist/admin/ui/views/collection-list-view.d.ts +5 -0
  74. package/dist/admin/ui/views/dashboard-view.d.ts +10 -0
  75. package/dist/admin/ui/views/document-edit-view.d.ts +7 -0
  76. package/dist/admin/ui/views/global-edit-view.d.ts +19 -0
  77. package/dist/admin/ui/views/init-view.d.ts +4 -0
  78. package/dist/admin/ui/views/login-view.d.ts +4 -0
  79. package/dist/admin/ui/views/media-registry-view.d.ts +7 -0
  80. package/dist/admin/ui/views/settings-view.d.ts +7 -0
  81. package/dist/admin/webcomponent.d.ts +1 -0
  82. package/dist/api.d.ts +6 -0
  83. package/dist/auth/index.d.ts +2107 -0
  84. package/dist/auth/migrations.d.ts +5 -0
  85. package/dist/auth/premissions.d.ts +6 -0
  86. package/dist/chunk-16vgcf3k.js +88 -0
  87. package/dist/chunk-2zm8cy1w.js +9482 -0
  88. package/dist/chunk-5gvbp2qa.js +167 -0
  89. package/dist/chunk-62ev8gnc.js +41 -0
  90. package/dist/chunk-6dhs73zq.js +126 -0
  91. package/dist/chunk-6ew02s0c.js +472 -0
  92. package/dist/chunk-7a9kn0np.js +116 -0
  93. package/dist/chunk-8gkhn1d4.js +309 -0
  94. package/dist/chunk-8sqjbsgt.js +42 -0
  95. package/dist/chunk-9kxpbcb1.js +85 -0
  96. package/dist/chunk-cvdd4eqh.js +110 -0
  97. package/dist/chunk-d3ffeqp9.js +87 -0
  98. package/dist/chunk-dy5t83hr.js +261 -0
  99. package/dist/chunk-f3nvxn63.js +17 -0
  100. package/dist/chunk-hmhcense.js +1352 -0
  101. package/dist/chunk-j4d50hrx.js +20 -0
  102. package/dist/chunk-jwjk85ze.js +15 -0
  103. package/dist/chunk-kwp83w8b.js +250 -0
  104. package/dist/chunk-s8mqwnm1.js +14 -0
  105. package/dist/chunk-srsac177.js +85 -0
  106. package/dist/chunk-v521d72w.js +10 -0
  107. package/dist/chunk-xa7rjsn2.js +20 -0
  108. package/dist/chunk-xg35h5a3.js +15 -0
  109. package/dist/chunk-ybbbqj63.js +130 -0
  110. package/dist/chunk-zvwb67nd.js +332 -0
  111. package/dist/cli/commands/generate-types.d.ts +1 -0
  112. package/dist/cli/commands/init.d.ts +1 -0
  113. package/dist/cli/commands/migrate-commands.d.ts +5 -0
  114. package/dist/cli/commands/seed-command.d.ts +2 -0
  115. package/dist/cli/d1-mock.d.ts +30 -0
  116. package/dist/cli/index.d.ts +5 -0
  117. package/dist/cli/index.test.d.ts +1 -0
  118. package/dist/cli/r2-mock.d.ts +46 -0
  119. package/dist/cli/seeding.d.ts +17 -0
  120. package/dist/client.d.ts +51 -0
  121. package/dist/config-utils.d.ts +6 -0
  122. package/dist/config.d.ts +10 -0
  123. package/dist/db/adapter.d.ts +34 -0
  124. package/dist/db/better-sqlite.d.ts +40 -0
  125. package/dist/db/bun-sqlite.d.ts +40 -0
  126. package/dist/db/d1.d.ts +42 -0
  127. package/dist/db/kysely/data-mapper.d.ts +6 -0
  128. package/dist/db/kysely/field-mapper.d.ts +22 -0
  129. package/dist/db/kysely/migration-generator.d.ts +9 -0
  130. package/dist/db/kysely/query-builder.d.ts +9 -0
  131. package/dist/db/kysely/schema-builder.d.ts +15 -0
  132. package/dist/db/kysely/sql-utils.d.ts +1 -0
  133. package/dist/db/postgres.d.ts +51 -0
  134. package/dist/db/sqlite.d.ts +41 -0
  135. package/dist/db/system-schema.d.ts +2 -0
  136. package/dist/index.d.ts +6 -0
  137. package/dist/runtimes/bun.d.ts +17 -0
  138. package/dist/runtimes/cloudflare-workers.d.ts +10 -0
  139. package/dist/runtimes/next.d.ts +16 -0
  140. package/dist/runtimes/node.d.ts +18 -0
  141. package/dist/schema/collection.d.ts +100 -0
  142. package/dist/schema/fields/base.d.ts +83 -0
  143. package/dist/schema/fields/index.d.ts +135 -0
  144. package/dist/schema/global.d.ts +82 -0
  145. package/dist/schema/index.d.ts +4 -0
  146. package/dist/schema/infer.d.ts +55 -0
  147. package/dist/server/admin-router.d.ts +9 -0
  148. package/dist/server/admin.d.ts +18 -0
  149. package/dist/server/assets.d.ts +47 -0
  150. package/dist/server/collection-router.d.ts +14 -0
  151. package/dist/server/handlers.d.ts +76 -0
  152. package/dist/server/middlewares/admin.d.ts +6 -0
  153. package/dist/server/middlewares/auth.d.ts +16 -0
  154. package/dist/server/middlewares/context.d.ts +9 -0
  155. package/dist/server/middlewares/cors.d.ts +3 -0
  156. package/dist/server/middlewares/database-init.d.ts +11 -0
  157. package/dist/server/middlewares/rate-limit.d.ts +3 -0
  158. package/dist/server/router.d.ts +7 -0
  159. package/dist/server/setup-middlewares.d.ts +17 -0
  160. package/dist/server/system-router.d.ts +9 -0
  161. package/dist/server.d.ts +6 -0
  162. package/dist/src/admin/index.css +47 -0
  163. package/dist/src/admin/index.js +176 -0
  164. package/dist/src/admin/webcomponent.js +19 -0
  165. package/dist/src/api.js +27 -0
  166. package/dist/src/cli/index.js +157 -0
  167. package/dist/src/client.js +9 -0
  168. package/dist/src/db/bun-sqlite.js +523 -0
  169. package/dist/src/db/d1.js +568 -0
  170. package/dist/src/db/postgres.js +520 -0
  171. package/dist/src/db/sqlite.js +534 -0
  172. package/dist/src/index.js +20 -0
  173. package/dist/src/runtimes/bun.js +36 -0
  174. package/dist/src/runtimes/cloudflare-workers.js +29 -0
  175. package/dist/src/runtimes/next.js +26 -0
  176. package/dist/src/runtimes/node.js +38 -0
  177. package/dist/src/server.js +27 -0
  178. package/dist/src/storage/index.js +355 -0
  179. package/dist/storage/adapters/cloudflare-r2.d.ts +6 -0
  180. package/dist/storage/adapters/local.d.ts +6 -0
  181. package/dist/storage/adapters/s3.d.ts +13 -0
  182. package/dist/storage/errors.d.ts +12 -0
  183. package/dist/storage/index.d.ts +5 -0
  184. package/dist/storage/types.d.ts +31 -0
  185. package/dist/types.d.ts +484 -0
  186. package/dist/utils/lexical.d.ts +5 -0
  187. package/dist/utils/logger.d.ts +35 -0
  188. package/dist/validation.d.ts +300 -0
  189. package/dist/validator.d.ts +9 -0
  190. package/global.d.ts +11 -0
  191. package/package.json +151 -0
  192. package/src/admin/api-client.ts +63 -0
  193. package/src/admin/auth-client.ts +40 -0
  194. package/src/admin/custom-field.ts +179 -0
  195. package/src/admin/index.ts +15 -0
  196. package/src/admin/react.tsx +72 -0
  197. package/src/admin/router.ts +9 -0
  198. package/src/admin/stores/admin-queries.ts +121 -0
  199. package/src/admin/stores/auth.ts +61 -0
  200. package/src/admin/stores/column-visibility.ts +67 -0
  201. package/src/admin/stores/config.ts +15 -0
  202. package/src/admin/stores/media.ts +95 -0
  203. package/src/admin/stores/query.ts +13 -0
  204. package/src/admin/stores/ui.ts +29 -0
  205. package/src/admin/ui/admin-client.tsx +283 -0
  206. package/src/admin/ui/admin-layout.tsx +276 -0
  207. package/src/admin/ui/components/ColumnVisibilityToggle.tsx +141 -0
  208. package/src/admin/ui/components/DataDetailSheet.tsx +141 -0
  209. package/src/admin/ui/components/DataDetailView.tsx +175 -0
  210. package/src/admin/ui/components/Table.tsx +67 -0
  211. package/src/admin/ui/components/fields/ArrayField.tsx +166 -0
  212. package/src/admin/ui/components/fields/BlocksField.tsx +202 -0
  213. package/src/admin/ui/components/fields/BooleanField.tsx +50 -0
  214. package/src/admin/ui/components/fields/CollapsibleField.tsx +75 -0
  215. package/src/admin/ui/components/fields/DateField.tsx +45 -0
  216. package/src/admin/ui/components/fields/FileField.tsx +322 -0
  217. package/src/admin/ui/components/fields/GroupField.tsx +50 -0
  218. package/src/admin/ui/components/fields/JoinField.tsx +23 -0
  219. package/src/admin/ui/components/fields/NumberField.tsx +46 -0
  220. package/src/admin/ui/components/fields/RadioField.tsx +62 -0
  221. package/src/admin/ui/components/fields/RelationshipField.tsx +278 -0
  222. package/src/admin/ui/components/fields/RowField.tsx +40 -0
  223. package/src/admin/ui/components/fields/SelectField.tsx +59 -0
  224. package/src/admin/ui/components/fields/TabsField.tsx +101 -0
  225. package/src/admin/ui/components/fields/TextAreaField.tsx +54 -0
  226. package/src/admin/ui/components/fields/TextField.tsx +49 -0
  227. package/src/admin/ui/components/fields/VirtualField.tsx +53 -0
  228. package/src/admin/ui/components/fields/index.tsx +371 -0
  229. package/src/admin/ui/components/fields/richtext-editor/index.tsx +211 -0
  230. package/src/admin/ui/components/fields/richtext-editor/nodes/ImageComponent.tsx +142 -0
  231. package/src/admin/ui/components/fields/richtext-editor/nodes/ImageNode.tsx +95 -0
  232. package/src/admin/ui/components/fields/richtext-editor/plugins/ComponentPickerPlugin.tsx +226 -0
  233. package/src/admin/ui/components/fields/richtext-editor/plugins/EditableSyncPlugin.tsx +16 -0
  234. package/src/admin/ui/components/fields/richtext-editor/plugins/NotionToolbarPlugin.tsx +184 -0
  235. package/src/admin/ui/components/fields/richtext-editor/plugins/SimpleToolbarPlugin.tsx +240 -0
  236. package/src/admin/ui/components/fields/richtext-editor/plugins/ValueSyncPlugin.tsx +40 -0
  237. package/src/admin/ui/components/fields/utils.ts +1 -0
  238. package/src/admin/ui/components/link.tsx +41 -0
  239. package/src/admin/ui/components/media/AssetManagerModal.tsx +334 -0
  240. package/src/admin/ui/components/toast.tsx +72 -0
  241. package/src/admin/ui/components/ui/accordion.tsx +51 -0
  242. package/src/admin/ui/components/ui/alert-dialog.tsx +98 -0
  243. package/src/admin/ui/components/ui/blocks.tsx +32 -0
  244. package/src/admin/ui/components/ui/breadcrumbs.tsx +59 -0
  245. package/src/admin/ui/components/ui/button.tsx +26 -0
  246. package/src/admin/ui/components/ui/collapsible.tsx +124 -0
  247. package/src/admin/ui/components/ui/dialog.tsx +79 -0
  248. package/src/admin/ui/components/ui/group.tsx +20 -0
  249. package/src/admin/ui/components/ui/index.ts +17 -0
  250. package/src/admin/ui/components/ui/input.tsx +12 -0
  251. package/src/admin/ui/components/ui/join.tsx +53 -0
  252. package/src/admin/ui/components/ui/label.tsx +11 -0
  253. package/src/admin/ui/components/ui/radio-group.tsx +75 -0
  254. package/src/admin/ui/components/ui/relationship-detail-sheet.tsx +122 -0
  255. package/src/admin/ui/components/ui/relationship.tsx +58 -0
  256. package/src/admin/ui/components/ui/scroll-area.tsx +19 -0
  257. package/src/admin/ui/components/ui/select.tsx +187 -0
  258. package/src/admin/ui/components/ui/separator.tsx +21 -0
  259. package/src/admin/ui/components/ui/sheet.tsx +106 -0
  260. package/src/admin/ui/components/ui/tabs.tsx +116 -0
  261. package/src/admin/ui/components/ui/utils.ts +3 -0
  262. package/src/admin/ui/hooks/use-debounce.ts +15 -0
  263. package/src/admin/ui/styles/_locale-switcher.scss +33 -0
  264. package/src/admin/ui/styles/accordion.scss +60 -0
  265. package/src/admin/ui/styles/animations.scss +41 -0
  266. package/src/admin/ui/styles/asset-manager.scss +547 -0
  267. package/src/admin/ui/styles/badge.scss +13 -0
  268. package/src/admin/ui/styles/base.scss +22 -0
  269. package/src/admin/ui/styles/button.scss +161 -0
  270. package/src/admin/ui/styles/card.scss +13 -0
  271. package/src/admin/ui/styles/collapsible.scss +75 -0
  272. package/src/admin/ui/styles/data-detail.scss +92 -0
  273. package/src/admin/ui/styles/dialog.scss +102 -0
  274. package/src/admin/ui/styles/empty-state.scss +22 -0
  275. package/src/admin/ui/styles/group.scss +19 -0
  276. package/src/admin/ui/styles/index.scss +33 -0
  277. package/src/admin/ui/styles/input.scss +80 -0
  278. package/src/admin/ui/styles/label.scss +12 -0
  279. package/src/admin/ui/styles/layout.scss +56 -0
  280. package/src/admin/ui/styles/lexical.scss +469 -0
  281. package/src/admin/ui/styles/loading.scss +102 -0
  282. package/src/admin/ui/styles/media-registry.scss +597 -0
  283. package/src/admin/ui/styles/pagination.scss +20 -0
  284. package/src/admin/ui/styles/radio-group.scss +66 -0
  285. package/src/admin/ui/styles/row.scss +17 -0
  286. package/src/admin/ui/styles/scrollbar.scss +36 -0
  287. package/src/admin/ui/styles/select.scss +121 -0
  288. package/src/admin/ui/styles/separator.scss +14 -0
  289. package/src/admin/ui/styles/sheet.scss +152 -0
  290. package/src/admin/ui/styles/sidebar.scss +148 -0
  291. package/src/admin/ui/styles/switch.scss +59 -0
  292. package/src/admin/ui/styles/table.scss +207 -0
  293. package/src/admin/ui/styles/tabs.scss +62 -0
  294. package/src/admin/ui/styles/toast.scss +45 -0
  295. package/src/admin/ui/styles/variables.scss +24 -0
  296. package/src/admin/ui/views/collection-list-view.tsx +720 -0
  297. package/src/admin/ui/views/dashboard-view.tsx +263 -0
  298. package/src/admin/ui/views/document-edit-view.tsx +384 -0
  299. package/src/admin/ui/views/global-edit-view.tsx +226 -0
  300. package/src/admin/ui/views/init-view.tsx +182 -0
  301. package/src/admin/ui/views/login-view.tsx +123 -0
  302. package/src/admin/ui/views/media-registry-view.tsx +1104 -0
  303. package/src/admin/ui/views/settings-view.tsx +729 -0
  304. package/src/admin/webcomponent.tsx +15 -0
  305. package/src/api.ts +9 -0
  306. package/src/auth/index.ts +194 -0
  307. package/src/auth/migrations.ts +87 -0
  308. package/src/auth/premissions.ts +46 -0
  309. package/src/cli/commands/generate-types.ts +116 -0
  310. package/src/cli/commands/init.ts +95 -0
  311. package/src/cli/commands/migrate-commands.ts +160 -0
  312. package/src/cli/commands/seed-command.ts +11 -0
  313. package/src/cli/d1-mock.ts +101 -0
  314. package/src/cli/index.test.ts +84 -0
  315. package/src/cli/index.ts +183 -0
  316. package/src/cli/r2-mock.ts +217 -0
  317. package/src/cli/seeding.ts +405 -0
  318. package/src/client.ts +181 -0
  319. package/src/config-utils.ts +102 -0
  320. package/src/config.ts +49 -0
  321. package/src/db/adapter.ts +53 -0
  322. package/src/db/better-sqlite.ts +630 -0
  323. package/src/db/bun-sqlite.ts +646 -0
  324. package/src/db/d1.ts +711 -0
  325. package/src/db/kysely/data-mapper.ts +142 -0
  326. package/src/db/kysely/field-mapper.ts +148 -0
  327. package/src/db/kysely/migration-generator.ts +223 -0
  328. package/src/db/kysely/query-builder.ts +92 -0
  329. package/src/db/kysely/schema-builder.ts +439 -0
  330. package/src/db/kysely/sql-utils.ts +13 -0
  331. package/src/db/postgres.ts +621 -0
  332. package/src/db/sqlite.ts +658 -0
  333. package/src/db/system-schema.ts +121 -0
  334. package/src/index.ts +13 -0
  335. package/src/runtimes/README.md +59 -0
  336. package/src/runtimes/bun.ts +49 -0
  337. package/src/runtimes/cloudflare-workers.ts +38 -0
  338. package/src/runtimes/next.ts +26 -0
  339. package/src/runtimes/node.ts +52 -0
  340. package/src/schema/collection.ts +184 -0
  341. package/src/schema/fields/base.ts +164 -0
  342. package/src/schema/fields/index.ts +427 -0
  343. package/src/schema/global.ts +145 -0
  344. package/src/schema/index.ts +4 -0
  345. package/src/schema/infer.ts +72 -0
  346. package/src/server/admin-router.ts +20 -0
  347. package/src/server/admin.ts +142 -0
  348. package/src/server/assets.ts +306 -0
  349. package/src/server/collection-router.ts +55 -0
  350. package/src/server/handlers.ts +722 -0
  351. package/src/server/middlewares/admin.ts +27 -0
  352. package/src/server/middlewares/auth.ts +89 -0
  353. package/src/server/middlewares/context.ts +17 -0
  354. package/src/server/middlewares/cors.ts +24 -0
  355. package/src/server/middlewares/database-init.ts +74 -0
  356. package/src/server/middlewares/rate-limit.ts +71 -0
  357. package/src/server/router.ts +47 -0
  358. package/src/server/setup-middlewares.ts +58 -0
  359. package/src/server/system-router.ts +35 -0
  360. package/src/server.ts +9 -0
  361. package/src/storage/adapters/cloudflare-r2.ts +136 -0
  362. package/src/storage/adapters/local.ts +146 -0
  363. package/src/storage/adapters/s3.ts +186 -0
  364. package/src/storage/errors.ts +46 -0
  365. package/src/storage/index.ts +5 -0
  366. package/src/storage/types.ts +39 -0
  367. package/src/types.ts +577 -0
  368. package/src/utils/lexical.ts +37 -0
  369. package/src/utils/logger.ts +73 -0
  370. package/src/validation.ts +429 -0
  371. package/src/validator.ts +179 -0
  372. package/test/admin-custom-field.test.ts +162 -0
  373. package/test/admin-react-field.test.tsx +134 -0
  374. package/test/api-features.test.ts +78 -0
  375. package/test/api.test.ts +178 -0
  376. package/test/auth.test.ts +62 -0
  377. package/test/cli-integration.test.ts +146 -0
  378. package/test/cli.test.ts +25 -0
  379. package/test/db/postgres.test.ts +95 -0
  380. package/test/db/sqlite-filter.test.ts +53 -0
  381. package/test/db/sqlite.test.ts +82 -0
  382. package/test/engine-features.test.ts +79 -0
  383. package/test/globals.test.ts +74 -0
  384. package/test/integration-tmp/db-app/opacacms.config.ts +15 -0
  385. package/test/integration-tmp/my-sqlite-app/opacacms.config.ts +25 -0
  386. package/test/integration-tmp/my-test-app/index.ts +8 -0
  387. package/test/integration-tmp/my-test-app/opacacms.config.ts +16 -0
  388. package/test/integration-tmp/my-test-app/package.json +12 -0
  389. package/test/populate.test.ts +79 -0
  390. package/test/runtimes.test.ts +43 -0
  391. package/test/schema-builder.test.ts +107 -0
  392. package/test/schema-features.test.ts +63 -0
  393. package/test/seeding.test.ts +68 -0
  394. package/test/storage/local.test.ts +72 -0
  395. package/test/storage/s3.test.ts +60 -0
  396. package/test/structural-data.test.ts +100 -0
  397. package/test/test-setup.ts +11 -0
  398. package/test/validation.test.ts +162 -0
  399. package/tsconfig.json +42 -0
@@ -0,0 +1,79 @@
1
+ import { afterAll, beforeAll, expect, test } from "bun:test";
2
+ import { Hono } from "hono";
3
+ import { defineConfig } from "../src/config";
4
+ import { createBunSQLiteAdapter } from "../src/db/bun-sqlite";
5
+ import { createAPIRouter } from "../src/server/router";
6
+
7
+ let app: Hono;
8
+ const dbPath = ":memory:";
9
+ const db = createBunSQLiteAdapter(dbPath, { push: true });
10
+
11
+ beforeAll(async () => {
12
+ const config = defineConfig({
13
+ db,
14
+ collections: [
15
+ {
16
+ slug: "authors",
17
+ fields: [{ name: "name", type: "text" }],
18
+ },
19
+ {
20
+ slug: "posts",
21
+ fields: [
22
+ { name: "title", type: "text" },
23
+ { name: "authorId", type: "relationship", relationTo: "authors" },
24
+ ],
25
+ },
26
+ ],
27
+ });
28
+
29
+ app = new Hono();
30
+ app.route("/", createAPIRouter(config));
31
+
32
+ await db.connect();
33
+ });
34
+
35
+ afterAll(async () => {
36
+ await db.disconnect();
37
+ });
38
+
39
+ test("POST /api/authors - create author", async () => {
40
+ const res = await app.request("/api/authors", {
41
+ method: "POST",
42
+ headers: { "Content-Type": "application/json" },
43
+ body: JSON.stringify({ name: "Jane Doe" }),
44
+ });
45
+ expect(res.status).toBe(201);
46
+ const data = (await res.json()) as any;
47
+ expect(data.id).toBeDefined();
48
+ // store id for next test
49
+ process.env.TEST_AUTHOR_ID = data.id.toString();
50
+ });
51
+
52
+ test("POST /api/posts - create post with authorId", async () => {
53
+ const authorId = process.env.TEST_AUTHOR_ID;
54
+ const res = await app.request("/api/posts", {
55
+ method: "POST",
56
+ headers: { "Content-Type": "application/json" },
57
+ body: JSON.stringify({ title: "Hello World", authorId }),
58
+ });
59
+ expect(res.status).toBe(201);
60
+ const data = (await res.json()) as any;
61
+ expect(data.authorId).toBe(authorId);
62
+ process.env.TEST_POST_ID = data.id.toString();
63
+ });
64
+
65
+ test("GET /api/posts/:id?populate=authorId - retrieves populated data", async () => {
66
+ const postId = process.env.TEST_POST_ID;
67
+ const res = await app.request(`/api/posts/${postId}?populate=authorId`);
68
+ expect(res.status).toBe(200);
69
+ const data = (await res.json()) as any;
70
+ expect(data.authorId).toBeObject();
71
+ expect(data.authorId.name).toBe("Jane Doe");
72
+ });
73
+
74
+ test("GET /api/posts - handles populate for multiple docs", async () => {
75
+ const res = await app.request(`/api/posts?populate=authorId`);
76
+ expect(res.status).toBe(200);
77
+ const data = (await res.json()) as any;
78
+ expect(data.docs[0].authorId.name).toBe("Jane Doe");
79
+ });
@@ -0,0 +1,43 @@
1
+ import { describe, expect, test } from "bun:test";
2
+ import { createBunSQLiteAdapter } from "../src/db/bun-sqlite";
3
+ import { createBunHandler } from "../src/runtimes/bun";
4
+ import { createCloudflareWorkersHandler } from "../src/runtimes/cloudflare-workers";
5
+ import { createNextHandler } from "../src/runtimes/next";
6
+ import { createNodeHandler } from "../src/runtimes/node";
7
+ import type { OpacaConfig } from "../src/types";
8
+
9
+ describe("Runtimes", () => {
10
+ const mockConfig: OpacaConfig = {
11
+ db: createBunSQLiteAdapter(":memory:"),
12
+ collections: [],
13
+ };
14
+
15
+ test("Next.js handler should export proper HTTP methods", () => {
16
+ const handler = createNextHandler(mockConfig);
17
+ expect(handler.GET).toBeDefined();
18
+ expect(handler.POST).toBeDefined();
19
+ expect(handler.PUT).toBeDefined();
20
+ expect(handler.DELETE).toBeDefined();
21
+ expect(handler.PATCH).toBeDefined();
22
+ expect(handler.OPTIONS).toBeDefined();
23
+ expect(typeof handler.GET).toBe("function");
24
+ });
25
+
26
+ test("Bun handler should expose app and init function", () => {
27
+ const handler = createBunHandler(mockConfig);
28
+ expect(handler.app).toBeDefined();
29
+ expect(typeof handler.init).toBe("function");
30
+ });
31
+
32
+ test("Node handler should expose app and init function", () => {
33
+ const handler = createNodeHandler(mockConfig);
34
+ expect(handler.app).toBeDefined();
35
+ expect(typeof handler.init).toBe("function");
36
+ });
37
+
38
+ test("Cloudflare Workers handler should expose a fetch method", () => {
39
+ const handler = createCloudflareWorkersHandler(mockConfig);
40
+ expect(handler.fetch).toBeDefined();
41
+ expect(typeof handler.fetch).toBe("function");
42
+ });
43
+ });
@@ -0,0 +1,107 @@
1
+ import { describe, expect, test } from "bun:test";
2
+ import { Collection, Field } from "../src/schema";
3
+
4
+ describe("Fluent API Schema Builder", () => {
5
+ test("Should build a valid OpacaCMS Collection object matching perfectly with legacy JSON", () => {
6
+ const builder = Collection.create("posts")
7
+ .label("Blog Posts")
8
+ .useAsTitle("title")
9
+ .timestamps(true)
10
+ .fields([
11
+ Field.text("title").required().description("The post title"),
12
+ Field.richText("content").mode("notion"),
13
+ Field.relationship("author").to("users").single(),
14
+ ])
15
+ .access({
16
+ read: () => true,
17
+ update: ({ data }) => {
18
+ // Type Test: Ensure 'data' has inferred types.
19
+ // Because of TypeScript generics, data.title, data.content, data.author should be recognized.
20
+ // Hovering over 'data' in an IDE would show: { title: string; content: any; author: string | string[] }
21
+ const _title: string = data.title;
22
+ const _auth: string | string[] = data.author;
23
+
24
+ return true;
25
+ },
26
+ });
27
+
28
+ const schema = builder.build();
29
+
30
+ expect(schema).toEqual({
31
+ slug: "posts",
32
+ label: "Blog Posts",
33
+ timestamps: true,
34
+ admin: {
35
+ useAsTitle: "title",
36
+ },
37
+ fields: [
38
+ {
39
+ type: "text",
40
+ name: "title",
41
+ required: true,
42
+ admin: { description: "The post title" },
43
+ },
44
+ {
45
+ type: "richtext",
46
+ name: "content",
47
+ options: { defaultMode: "notion" },
48
+ },
49
+ {
50
+ type: "relationship",
51
+ name: "author",
52
+ relationTo: "users",
53
+ hasMany: false,
54
+ },
55
+ ],
56
+ access: expect.any(Object), // Access object is present containing the functions
57
+ });
58
+ });
59
+
60
+ test("Should build complex nested fields (Array, Group, Blocks)", () => {
61
+ const builder = Collection.create("settings").fields([
62
+ Field.group("contact").fields(Field.text("email").required(), Field.text("phone")),
63
+ Field.array("links").of(Field.row().fields(Field.text("label"), Field.text("url"))),
64
+ Field.blocks("layout").blocks(
65
+ Field.block("hero").label("Hero Section").fields(Field.text("headline")),
66
+ ),
67
+ ]);
68
+
69
+ const schema = builder.build();
70
+
71
+ expect(schema.fields).toEqual([
72
+ {
73
+ type: "group",
74
+ name: "contact",
75
+ fields: [
76
+ { type: "text", name: "email", required: true },
77
+ { type: "text", name: "phone" },
78
+ ],
79
+ },
80
+ {
81
+ type: "array",
82
+ name: "links",
83
+ fields: [
84
+ {
85
+ type: "row",
86
+ name: "",
87
+ fields: [
88
+ { type: "text", name: "label" },
89
+ { type: "text", name: "url" },
90
+ ],
91
+ },
92
+ ],
93
+ },
94
+ {
95
+ type: "blocks",
96
+ name: "layout",
97
+ blocks: [
98
+ {
99
+ slug: "hero",
100
+ label: "Hero Section",
101
+ fields: [{ type: "text", name: "headline" }],
102
+ },
103
+ ],
104
+ },
105
+ ]);
106
+ });
107
+ });
@@ -0,0 +1,63 @@
1
+ import { describe, expect, test } from "bun:test";
2
+ import { Collection, Field } from "../src/schema";
3
+
4
+ describe("Fluent API Schema Features", () => {
5
+ test("Should support Slug fields correctly", () => {
6
+ const posts = Collection.create("posts")
7
+ .fields([Field.text("title"), Field.slug("slug").from("title").unique()])
8
+ .build();
9
+
10
+ expect(posts.slug).toBe("posts");
11
+ expect(posts.fields).toHaveLength(2);
12
+ expect(posts.fields[1]!.type).toBe("slug");
13
+ expect((posts.fields[1] as any).from).toBe("title");
14
+ expect(posts.fields[1]!.unique).toBe(true);
15
+ });
16
+
17
+ test("Should support field localization", () => {
18
+ const pages = Collection.create("pages")
19
+ .fields([Field.text("title").localized()])
20
+ .build();
21
+
22
+ expect(pages.fields[0]!.localized).toBe(true);
23
+ });
24
+
25
+ test("Should support versions and drafts", () => {
26
+ const pages = Collection.create("pages")
27
+ .versions({ drafts: true, maxRevisions: 10, autosave: true })
28
+ .build();
29
+
30
+ expect(pages.versions).toBeDefined();
31
+ expect(pages.versions!.drafts).toBe(true);
32
+ expect(pages.versions!.maxRevisions).toBe(10);
33
+ });
34
+
35
+ test("Should support webhooks", () => {
36
+ const subs = Collection.create("subscribers")
37
+ .webhooks([
38
+ {
39
+ events: ["afterCreate"],
40
+ url: "https://example.com/webhook",
41
+ },
42
+ ])
43
+ .build();
44
+
45
+ expect(subs.webhooks).toBeDefined();
46
+ expect(subs.webhooks![0]!.events).toContain("afterCreate");
47
+ expect(subs.webhooks![0]!.url).toBe("https://example.com/webhook");
48
+ });
49
+
50
+ test("Should support admin UI views and bulk actions", () => {
51
+ const orders = Collection.create("orders")
52
+ .admin({
53
+ views: [{ name: "Pending", filter: { status: "pending" } }],
54
+ bulkActions: [{ label: "Approve", action: async () => true }],
55
+ })
56
+ .build();
57
+
58
+ expect(orders.admin).toBeDefined();
59
+ expect((orders.admin as any).views).toBeDefined();
60
+ expect((orders.admin as any).views![0]!.name).toBe("Pending");
61
+ expect((orders.admin as any).bulkActions).toBeDefined();
62
+ });
63
+ });
@@ -0,0 +1,68 @@
1
+ import { describe, expect, test } from "bun:test";
2
+ import { generateRecord, sortCollections } from "../src/cli/seeding";
3
+ import { createBunSQLiteAdapter } from "../src/db/bun-sqlite";
4
+ import type { Collection, DatabaseAdapter } from "../src/types";
5
+
6
+ describe("Seeding Logic", () => {
7
+ const mockDb = {
8
+ find: async () => ({ docs: [{ id: "123" }], totalDocs: 1 }),
9
+ create: async () => ({ id: "456" }),
10
+ } as unknown as DatabaseAdapter;
11
+
12
+ const collections: Collection[] = [
13
+ {
14
+ slug: "users",
15
+ fields: [
16
+ { name: "name", type: "text" },
17
+ { name: "email", type: "text" },
18
+ ],
19
+ },
20
+ {
21
+ slug: "posts",
22
+ fields: [
23
+ { name: "title", type: "text" },
24
+ { name: "author", type: "relationship", relationTo: "users" },
25
+ ],
26
+ },
27
+ ];
28
+
29
+ test("sortCollections handles dependencies", () => {
30
+ const sorted = sortCollections(collections);
31
+ const userIndex = sorted.findIndex((c) => c.slug === "users");
32
+ const postIndex = sorted.findIndex((c) => c.slug === "posts");
33
+ expect(userIndex).toBeLessThan(postIndex);
34
+ });
35
+
36
+ test("generateRecord creates mock data", async () => {
37
+ const userRecord = await generateRecord(mockDb, collections[0]!);
38
+ expect(userRecord.name).toBeString();
39
+ expect(userRecord.email).toBeString();
40
+ });
41
+
42
+ test("generateRecord handles relationships", async () => {
43
+ const postRecord = await generateRecord(mockDb, collections[1]!);
44
+ expect(postRecord.title).toBeString();
45
+ expect(postRecord.author).toBe("123");
46
+ });
47
+
48
+ test("integrates with real database", async () => {
49
+ const db = createBunSQLiteAdapter(":memory:", { push: true });
50
+ await db.connect();
51
+
52
+ try {
53
+ // Create tables
54
+ await db.unsafe("CREATE TABLE users (id TEXT PRIMARY KEY, name TEXT, email TEXT)");
55
+ await db.migrate(collections as Collection[]);
56
+
57
+ const record = await generateRecord(db, collections[0]!);
58
+ const created = (await db.create("users", record)) as any;
59
+
60
+ expect(created.name).toBe(record.name);
61
+
62
+ const found = await db.find("users");
63
+ expect(found.docs.length).toBe(1);
64
+ } finally {
65
+ await db.disconnect();
66
+ }
67
+ });
68
+ });
@@ -0,0 +1,72 @@
1
+ import { afterAll, beforeAll, describe, expect, test } from "bun:test";
2
+ import fs from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { createLocalAdapter } from "../../src/storage/adapters/local";
5
+ import { FileTooLargeError, Invalidmime_typeError } from "../../src/storage/errors";
6
+
7
+ const TEST_DIR = path.resolve(process.cwd(), ".test_uploads");
8
+
9
+ describe("Local Storage Adapter", () => {
10
+ const adapter = createLocalAdapter({
11
+ uploadDir: TEST_DIR,
12
+ publicUrl: "/media",
13
+ });
14
+
15
+ const mockBuffer = Buffer.from("fake image data");
16
+ const mockFile = {
17
+ filename: "test-image.jpg",
18
+ original_filename: "test-image.jpg",
19
+ mime_type: "image/jpeg",
20
+ filesize: mockBuffer.length,
21
+ buffer: mockBuffer,
22
+ };
23
+
24
+ beforeAll(async () => {
25
+ await fs.mkdir(TEST_DIR, { recursive: true });
26
+ });
27
+
28
+ afterAll(async () => {
29
+ await fs.rm(TEST_DIR, { recursive: true, force: true });
30
+ });
31
+
32
+ test("successfully writes a file to disk and returns correct URL", async () => {
33
+ const result = await adapter.upload(mockFile);
34
+
35
+ expect(result.filename).toBe("test-image.jpg");
36
+ expect(result.url).toBe("/media/test-image.jpg");
37
+
38
+ const fileExists = await adapter.exists!("test-image.jpg");
39
+ expect(fileExists).toBe(true);
40
+
41
+ const content = await fs.readFile(path.join(TEST_DIR, "test-image.jpg"));
42
+ expect(content.toString()).toBe("fake image data");
43
+ });
44
+
45
+ test("successfully deletes a file from disk", async () => {
46
+ await adapter.upload({ ...mockFile, filename: "to-delete.png" });
47
+ expect(await adapter.exists!("to-delete.png")).toBe(true);
48
+
49
+ await adapter.delete("to-delete.png");
50
+
51
+ expect(await adapter.exists!("to-delete.png")).toBe(false);
52
+ });
53
+
54
+ test("generates unique filenames to prevent collisions", async () => {
55
+ const options = { generateUniqueName: true };
56
+ const result1 = await adapter.upload(mockFile, options);
57
+ const result2 = await adapter.upload(mockFile, options);
58
+
59
+ expect(result1.filename).not.toBe(result2.filename);
60
+ expect(result1.filename).toMatch(/^test-image-[a-z0-9-]+\.jpg$/);
61
+ });
62
+
63
+ test("enforces maxFileSize limit", async () => {
64
+ const options = { maxFileSize: 5 }; // Very small limit
65
+ expect(adapter.upload(mockFile, options)).rejects.toBeInstanceOf(FileTooLargeError);
66
+ });
67
+
68
+ test("enforces mime_type limit", async () => {
69
+ const options = { allowedmime_types: ["image/png"] };
70
+ expect(adapter.upload(mockFile, options)).rejects.toBeInstanceOf(Invalidmime_typeError);
71
+ });
72
+ });
@@ -0,0 +1,60 @@
1
+ import { describe, expect, mock, test } from "bun:test";
2
+ import { createS3Adapter } from "../../src/storage/adapters/s3";
3
+ import { FileTooLargeError, Invalidmime_typeError } from "../../src/storage/errors";
4
+
5
+ // Mock the AWS SDK
6
+ mock.module("@aws-sdk/client-s3", () => {
7
+ return {
8
+ S3Client: mock().mockImplementation(() => ({
9
+ send: mock().mockResolvedValue({}), // Simulate a successful HTTP response
10
+ })),
11
+ PutObjectCommand: mock(),
12
+ DeleteObjectCommand: mock(),
13
+ GetObjectCommand: mock(),
14
+ HeadObjectCommand: mock(),
15
+ };
16
+ });
17
+
18
+ describe("S3 Storage Adapter", () => {
19
+ const config = {
20
+ region: "us-east-1",
21
+ bucket: "test-bucket",
22
+ credentials: { accessKeyId: "test", secretAccessKey: "test" },
23
+ };
24
+ const adapter = createS3Adapter(config);
25
+
26
+ const mockFile = {
27
+ filename: "test.jpg",
28
+ original_filename: "test.jpg",
29
+ mime_type: "image/jpeg",
30
+ filesize: 1024,
31
+ buffer: Buffer.from("fake image data"),
32
+ };
33
+
34
+ test("throws FileTooLargeError if file exceeds maxFileSize limit", async () => {
35
+ const options = { maxFileSize: 500 }; // Limit is 500 bytes
36
+ expect(adapter.upload(mockFile, options)).rejects.toBeInstanceOf(FileTooLargeError);
37
+ });
38
+
39
+ test("throws Invalidmime_typeError if mime type is not allowed", async () => {
40
+ const options = { allowedmime_types: ["image/png"] }; // Only allow PNG
41
+ expect(adapter.upload(mockFile, options)).rejects.toBeInstanceOf(Invalidmime_typeError);
42
+ });
43
+
44
+ test("generates a unique filename if generateUniqueName is true", async () => {
45
+ const options = { generateUniqueName: true };
46
+ const result = await adapter.upload(mockFile, options);
47
+
48
+ expect(result.filename).not.toBe("test.jpg");
49
+ expect(result.filename).toMatch(/^test-[a-z0-9-]+\.jpg$/);
50
+ });
51
+
52
+ test("applies the prefix correctly to the generated URL", async () => {
53
+ const prefixedAdapter = createS3Adapter({ ...config, prefix: "uploads/images" });
54
+ const result = await prefixedAdapter.upload(mockFile);
55
+
56
+ expect(result.url).toBe(
57
+ "https://test-bucket.s3.us-east-1.amazonaws.com/uploads/images/test.jpg",
58
+ );
59
+ });
60
+ });
@@ -0,0 +1,100 @@
1
+ import { afterAll, beforeAll, describe, expect, it } from "bun:test";
2
+ import { BunSQLiteAdapter } from "../src/db/bun-sqlite";
3
+ import type { Collection } from "../src/types";
4
+
5
+ describe("BunSQLiteAdapter Structural Data", () => {
6
+ let db: BunSQLiteAdapter;
7
+
8
+ const complexCollection: Collection = {
9
+ slug: "complex_docs",
10
+ fields: [
11
+ { name: "title", type: "text" },
12
+ {
13
+ name: "seo",
14
+ type: "group",
15
+ fields: [
16
+ { name: "title", type: "text" },
17
+ { name: "desc", type: "text" },
18
+ ],
19
+ },
20
+ {
21
+ name: "contentBlocks",
22
+ type: "blocks",
23
+ blocks: [
24
+ {
25
+ slug: "hero",
26
+ fields: [{ name: "headline", type: "text" }],
27
+ },
28
+ {
29
+ slug: "text",
30
+ fields: [{ name: "body", type: "text" }],
31
+ },
32
+ ],
33
+ },
34
+ ],
35
+ };
36
+
37
+ beforeAll(async () => {
38
+ db = new BunSQLiteAdapter(":memory:", { push: true });
39
+ await db.connect();
40
+ await db.migrate([complexCollection]);
41
+ });
42
+
43
+ afterAll(async () => {
44
+ await db.disconnect();
45
+ });
46
+
47
+ it("should create and retrieve a document with group fields and nested blocks properly", async () => {
48
+ const data = {
49
+ title: "Main Title",
50
+ seo: { title: "SEO Title", desc: "SEO Desc" },
51
+ contentBlocks: [
52
+ { blockType: "hero", headline: "Welcome" },
53
+ { blockType: "text", body: "Some body text" },
54
+ ],
55
+ };
56
+
57
+ const created = await db.create("complex_docs", data);
58
+
59
+ expect(created).toBeDefined();
60
+ expect((created as any).title).toBe("Main Title");
61
+ expect((created as any).seo).toEqual({ title: "SEO Title", desc: "SEO Desc" });
62
+ expect((created as any).contentBlocks).toHaveLength(2);
63
+ expect((created as any).contentBlocks[0].blockType).toBe("hero");
64
+ expect((created as any).contentBlocks[0].headline).toBe("Welcome");
65
+
66
+ const found = await db.findOne("complex_docs", { id: (created as any).id });
67
+ expect((found as any).seo).toEqual({ title: "SEO Title", desc: "SEO Desc" });
68
+ expect((found as any).contentBlocks).toHaveLength(2);
69
+ });
70
+
71
+ it("should update a document with group fields and nested blocks properly", async () => {
72
+ const created = await db.create("complex_docs", {
73
+ title: "Old Title",
74
+ seo: { title: "Old SEO", desc: "Old Desc" },
75
+ contentBlocks: [{ blockType: "text", body: "Old text" }],
76
+ });
77
+
78
+ const updated = await db.update(
79
+ "complex_docs",
80
+ { id: (created as any).id },
81
+ {
82
+ title: "New Title",
83
+ seo: { title: "New SEO", desc: "New Desc" },
84
+ contentBlocks: [
85
+ { blockType: "hero", headline: "New Hero" },
86
+ { blockType: "text", body: "New Text" },
87
+ ],
88
+ },
89
+ );
90
+
91
+ expect((updated as any).title).toBe("New Title");
92
+ expect((updated as any).seo.title).toBe("New SEO");
93
+ expect((updated as any).contentBlocks).toHaveLength(2);
94
+ expect((updated as any).contentBlocks[0].blockType).toBe("hero");
95
+
96
+ const found = await db.findOne("complex_docs", { id: (created as any).id });
97
+ expect((found as any).seo).toEqual({ title: "New SEO", desc: "New Desc" });
98
+ expect((found as any).contentBlocks).toHaveLength(2);
99
+ });
100
+ });
@@ -0,0 +1,11 @@
1
+ import { mock } from "bun:test";
2
+ import { GlobalRegistrator } from "@happy-dom/global-registrator";
3
+
4
+ GlobalRegistrator.register();
5
+
6
+ // Mock Cloudflare workers for tests so @hono-rate-limiter/cloudflare doesn't crash
7
+ mock.module("cloudflare:workers", () => {
8
+ return {
9
+ DurableObject: class {},
10
+ };
11
+ });