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,82 @@
1
+ import type { AccessConfig, Global as GlobalType, IconName } from "../types";
2
+ import { type FieldBuilder } from "./fields";
3
+ import type { InferFields } from "./infer";
4
+ export type Global = GlobalType;
5
+ /**
6
+ * A Fluent API Builder for defining OpacaCMS Globals.
7
+ */
8
+ export declare class GlobalBuilder<TFields extends Record<string, any> = {}> {
9
+ protected config: Partial<Global>;
10
+ protected _fields: FieldBuilder<any, any>[];
11
+ constructor(slug: string);
12
+ /**
13
+ * Enables or disables timestamps (createdAt, updatedAt) for this global.
14
+ * Defaults to true.
15
+ */
16
+ timestamps(enabled?: boolean | {
17
+ createdAt?: string;
18
+ updatedAt?: string;
19
+ }): this;
20
+ /**
21
+ * Sets the label for this global in the Admin UI.
22
+ */
23
+ label(label: string): this;
24
+ /**
25
+ * Sets the Lucide icon for this global.
26
+ */
27
+ icon(iconName: IconName): this;
28
+ /**
29
+ * Defines the fields for this global schema.
30
+ */
31
+ fields<T extends readonly any[]>(fields: [...T]): GlobalBuilder<InferFields<T>>;
32
+ /**
33
+ * Configuration for who can read and update this global.
34
+ */
35
+ access(rules: AccessConfig): this;
36
+ /**
37
+ * Defines a virtual/computed field with full type inference of the current global data.
38
+ */
39
+ virtual<TName extends string, TReturn = any>(name: TName, options: {
40
+ label?: string;
41
+ resolve: (args: {
42
+ data: TFields;
43
+ req: any;
44
+ user: any;
45
+ session: any;
46
+ apiKey?: any;
47
+ }) => TReturn | Promise<TReturn>;
48
+ returnType?: "string" | "number" | "boolean" | "json";
49
+ }): GlobalBuilder<TFields & {
50
+ [K in TName]: TReturn;
51
+ }>;
52
+ /**
53
+ * Alias for .virtual()
54
+ */
55
+ computed<TName extends string, TReturn = any>(name: TName, options: {
56
+ label?: string;
57
+ resolve: (args: {
58
+ data: TFields;
59
+ req: any;
60
+ user: any;
61
+ session: any;
62
+ apiKey?: any;
63
+ }) => TReturn | Promise<TReturn>;
64
+ returnType?: "string" | "number" | "boolean" | "json";
65
+ }): GlobalBuilder<TFields & {
66
+ [K in TName]: TReturn;
67
+ }>;
68
+ /**
69
+ * Extends the global with arbitrary configuration.
70
+ */
71
+ extend(opts: Record<string, any>): this;
72
+ /**
73
+ * Compiles the builder down into the raw Global object expected by OpacaCMS.
74
+ */
75
+ build(): Global;
76
+ }
77
+ /**
78
+ * Singleton factory for creating Globals.
79
+ */
80
+ export declare const Global: {
81
+ create: (slug: string) => GlobalBuilder<{}>;
82
+ };
@@ -0,0 +1,4 @@
1
+ export { Collection, CollectionBuilder } from "./collection";
2
+ export { Field, FieldBuilder } from "./fields/index";
3
+ export { Global, GlobalBuilder } from "./global";
4
+ export type { AccessRules, InferFields } from "./infer";
@@ -0,0 +1,55 @@
1
+ import type { FieldBuilder } from "./fields/base";
2
+ /**
3
+ * Helper to convert a union of types into an intersection.
4
+ */
5
+ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
6
+ type Flatten<T> = {
7
+ [K in keyof T]: T[K];
8
+ } & {};
9
+ /**
10
+ * Extracts the TName and TValue from a single FieldBuilder.
11
+ */
12
+ export type InferField<T extends FieldBuilder<any, any, any, any>> = T extends FieldBuilder<any, any, infer TValue, any> ? TValue : any;
13
+ /**
14
+ * Internal helper to distribute over a union of FieldBuilders.
15
+ * Matches against the class generics for maximum reliability.
16
+ */
17
+ type ProcessField<F> = F extends FieldBuilder<"group", infer N, any, infer Sub> ? N extends string ? {
18
+ [K in N]: Sub extends readonly any[] ? InferFields<Sub> : unknown;
19
+ } : {} : F extends FieldBuilder<"array", infer N, any, infer Sub> ? N extends string ? {
20
+ [K in N]: Sub extends readonly any[] ? InferFields<Sub>[] : unknown[];
21
+ } : {} : F extends FieldBuilder<"row" | "collapsible", any, any, infer Sub> ? Sub extends readonly any[] ? InferFields<Sub> : {} : F extends FieldBuilder<"tabs", any, any, infer Sub> ? Sub extends readonly any[] ? UnionToIntersection<Sub[number] extends {
22
+ fields: infer S;
23
+ } ? S extends readonly any[] ? InferFields<S> : {} : {}> : {} : F extends FieldBuilder<any, infer N, infer V, any> ? N extends string ? N extends "" ? {} : {
24
+ [K in N]: V;
25
+ } : {} : {};
26
+ /**
27
+ * Magically maps an array of FieldBuilders into a recursive object type representation.
28
+ *
29
+ * Performance Optimized:
30
+ * - Uses ProcessField helper for guaranteed union distribution.
31
+ * - UnionToIntersection merges individual field objects into a clean intersection.
32
+ */
33
+ export type InferFields<T extends readonly any[]> = Flatten<UnionToIntersection<ProcessField<T[number]>>>;
34
+ /**
35
+ * Access rules with strongly typed hooks.
36
+ */
37
+ export interface AccessRules<TFields extends Record<string, any>> {
38
+ read?: (args: {
39
+ user: any;
40
+ data?: TFields;
41
+ }) => boolean | Promise<boolean>;
42
+ create?: (args: {
43
+ user: any;
44
+ data: TFields;
45
+ }) => boolean | Promise<boolean>;
46
+ update?: (args: {
47
+ user: any;
48
+ data: TFields;
49
+ }) => boolean | Promise<boolean>;
50
+ delete?: (args: {
51
+ user: any;
52
+ data?: TFields;
53
+ }) => boolean | Promise<boolean>;
54
+ }
55
+ export {};
@@ -0,0 +1,9 @@
1
+ import { Hono } from "hono";
2
+ import type { Auth } from "../auth";
3
+ import type { OpacaConfig } from "../types";
4
+ import type { ApiContextVariables } from "./router";
5
+ export declare function createAdminRouter(config: OpacaConfig, state: {
6
+ auth: Auth | undefined;
7
+ }): Hono<{
8
+ Variables: ApiContextVariables;
9
+ }, import("hono/types").BlankSchema, "/">;
@@ -0,0 +1,18 @@
1
+ import type { Context } from "hono";
2
+ import type { Auth } from "../auth";
3
+ import type { OpacaConfig } from "../types";
4
+ type AdminHandlers = {
5
+ getMetadata: (c: Context) => Response;
6
+ getCollections: (c: Context) => Response;
7
+ getConfig: (c: Context) => Promise<Response>;
8
+ getSetupStatus: (c: Context) => Promise<Response>;
9
+ createApiKey: (c: Context) => Promise<Response>;
10
+ };
11
+ /**
12
+ * Creates the admin handlers for the OpacaCMS.
13
+ * @param config The OpacaCMS configuration.
14
+ * @param getAuth A function that returns the authentication instance.
15
+ * @returns An object containing the admin handlers for hono integration.
16
+ */
17
+ export declare function createAdminHandlers(config: OpacaConfig, getAuth: () => Auth | undefined): AdminHandlers;
18
+ export {};
@@ -0,0 +1,47 @@
1
+ import type { Context } from "hono";
2
+ import type { OpacaConfig } from "../types";
3
+ export declare function createAssetsHandlers(config: OpacaConfig): {
4
+ upload(c: Context): Promise<(Response & import("hono").TypedResponse<any, 201, "json">) | (Response & import("hono").TypedResponse<{
5
+ error: string;
6
+ }, 401, "json">) | (Response & import("hono").TypedResponse<{
7
+ error: string;
8
+ }, 500, "json">) | (Response & import("hono").TypedResponse<{
9
+ error: string;
10
+ }, 404, "json">) | (Response & import("hono").TypedResponse<{
11
+ error: any;
12
+ }, 400, "json">)>;
13
+ list(c: Context): Promise<(Response & import("hono").TypedResponse<{
14
+ error: string;
15
+ }, 401, "json">) | (Response & import("hono").TypedResponse<{
16
+ docs: any[];
17
+ folders: {
18
+ name: string;
19
+ buckets: string[];
20
+ }[];
21
+ totalDocs: number;
22
+ limit: number;
23
+ page: number;
24
+ totalPages: number;
25
+ }, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
26
+ error: any;
27
+ }, 500, "json">)>;
28
+ presign(c: Context): Promise<(Response & import("hono").TypedResponse<{
29
+ error: string;
30
+ }, 401, "json">) | (Response & import("hono").TypedResponse<{
31
+ error: string;
32
+ }, 404, "json">) | (Response & import("hono").TypedResponse<{
33
+ error: string;
34
+ }, 400, "json">) | (Response & import("hono").TypedResponse<{
35
+ uploadUrl: any;
36
+ filename: any;
37
+ }, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
38
+ error: any;
39
+ }, 500, "json">)>;
40
+ serve(c: Context): Promise<(Response & import("hono").TypedResponse<{
41
+ error: string;
42
+ }, 404, "json">) | (Response & import("hono").TypedResponse<{
43
+ error: string;
44
+ }, 400, "json">) | (Response & import("hono").TypedResponse<any, import("hono/utils/http-status").ContentfulStatusCode, "body">) | (Response & import("hono").TypedResponse<{
45
+ error: any;
46
+ }, 500, "json">)>;
47
+ };
@@ -0,0 +1,14 @@
1
+ import type { Hono } from "hono";
2
+ import type { Auth } from "../auth";
3
+ import type { OpacaConfig } from "../types";
4
+ import type { ApiContextVariables } from "./router";
5
+ export declare function mountCollectionRoutes(router: Hono<{
6
+ Variables: ApiContextVariables;
7
+ }>, config: OpacaConfig, state: {
8
+ auth: Auth | undefined;
9
+ }): void;
10
+ export declare function mountGlobalRoutes(router: Hono<{
11
+ Variables: ApiContextVariables;
12
+ }>, config: OpacaConfig, state: {
13
+ auth: Auth | undefined;
14
+ }): void;
@@ -0,0 +1,76 @@
1
+ import type { Context } from "hono";
2
+ import type { Collection, Global, OpacaConfig } from "../types";
3
+ /**
4
+ * Hydrates a document with virtual fields and nested fields.
5
+ * @param doc document to hydrate
6
+ * @param fields fields to hydrate
7
+ * @param c context
8
+ * @returns hydrated document
9
+ */
10
+ export declare const hydrateDoc: (doc: any, fields: any[], c: Context, config: OpacaConfig) => Promise<any>;
11
+ /**
12
+ * Creates handlers for a collection
13
+ * @param config opaca config
14
+ * @param collection collection config
15
+ * @param getAuth auth function
16
+ * @returns collection handlers
17
+ */
18
+ export declare function createHandlers(config: OpacaConfig, collection: Collection, getAuth?: () => any): {
19
+ find(c: Context): Promise<(Response & import("hono").TypedResponse<{
20
+ message: string;
21
+ }, 403, "json">) | (Response & import("hono").TypedResponse<{
22
+ docs: never[];
23
+ folders?: string[] | undefined;
24
+ totalDocs: number;
25
+ limit: number;
26
+ totalPages: number;
27
+ page: number;
28
+ pagingCounter: number;
29
+ hasPrevPage: boolean;
30
+ hasNextPage: boolean;
31
+ prevPage: number | null;
32
+ nextPage: number | null;
33
+ }, import("hono/utils/http-status").ContentfulStatusCode, "json">)>;
34
+ findOne(c: Context): Promise<Response & import("hono").TypedResponse<any, import("hono/utils/http-status").ContentfulStatusCode, "json">>;
35
+ create(c: Context): Promise<(Response & import("hono").TypedResponse<{
36
+ message: string;
37
+ }, 403, "json">) | (Response & import("hono").TypedResponse<{
38
+ message: string;
39
+ errors: {
40
+ [x: string]: {
41
+ [x: string]: any;
42
+ _errors: string[];
43
+ } | undefined;
44
+ _errors: string[];
45
+ };
46
+ }, 400, "json">) | (Response & import("hono").TypedResponse<any, 201, "json">)>;
47
+ update(c: Context): Promise<Response & import("hono").TypedResponse<any, import("hono/utils/http-status").ContentfulStatusCode, "json">>;
48
+ delete(c: Context): Promise<Response & import("hono").TypedResponse<{
49
+ message: string;
50
+ }, import("hono/utils/http-status").ContentfulStatusCode, "json">>;
51
+ findVersions(c: Context): Promise<(Response & import("hono").TypedResponse<{
52
+ message: string;
53
+ }, 403, "json">) | (Response & import("hono").TypedResponse<never, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
54
+ message: string;
55
+ error: any;
56
+ }, 500, "json">)>;
57
+ restoreVersion(c: Context): Promise<(Response & import("hono").TypedResponse<{
58
+ message: string;
59
+ }, 403, "json">) | (Response & import("hono").TypedResponse<{
60
+ message: string;
61
+ }, 404, "json">) | (Response & import("hono").TypedResponse<never, import("hono/utils/http-status").ContentfulStatusCode, "json">) | (Response & import("hono").TypedResponse<{
62
+ message: string;
63
+ error: any;
64
+ }, 500, "json">)>;
65
+ };
66
+ /**
67
+ * Creates handlers for global collections
68
+ * @param config opaca config
69
+ * @param globalConfig global config
70
+ * @param getAuth auth function
71
+ * @returns global handlers
72
+ */
73
+ export declare function createGlobalHandlers(config: OpacaConfig, globalConfig: Global, getAuth?: () => any): {
74
+ find(c: Context): Promise<Response & import("hono").TypedResponse<any, import("hono/utils/http-status").ContentfulStatusCode, "json">>;
75
+ update(c: Context): Promise<Response & import("hono").TypedResponse<any, import("hono/utils/http-status").ContentfulStatusCode, "json">>;
76
+ };
@@ -0,0 +1,6 @@
1
+ import type { Context, Next } from "hono";
2
+ export declare const adminMiddleware: (c: Context, next: Next) => Promise<(Response & import("hono").TypedResponse<{
3
+ message: string;
4
+ }, 401, "json">) | (Response & import("hono").TypedResponse<{
5
+ message: string;
6
+ }, 403, "json">) | undefined>;
@@ -0,0 +1,16 @@
1
+ import type { Session, User } from "better-auth";
2
+ import type { MiddlewareHandler } from "hono";
3
+ import type { Auth } from "../../auth";
4
+ export type AuthContextVariables = {
5
+ user: User | null;
6
+ session: Session | null;
7
+ apiKey?: {
8
+ id: string;
9
+ name: string | null;
10
+ permissions?: Record<string, string[]> | null;
11
+ referenceId: string;
12
+ } | null;
13
+ };
14
+ export declare function createAuthMiddleware(getAuth: () => Auth | undefined): MiddlewareHandler<{
15
+ Variables: AuthContextVariables;
16
+ }>;
@@ -0,0 +1,9 @@
1
+ import type { MiddlewareHandler } from "hono";
2
+ import type { OpacaConfig } from "../../types";
3
+ export type OpacaContextVariables = {
4
+ config: OpacaConfig;
5
+ db: OpacaConfig["db"];
6
+ };
7
+ export declare function createContextMiddleware(config: OpacaConfig): MiddlewareHandler<{
8
+ Variables: OpacaContextVariables;
9
+ }>;
@@ -0,0 +1,3 @@
1
+ import type { MiddlewareHandler } from "hono";
2
+ import type { OpacaConfig } from "../../types";
3
+ export declare function createCorsMiddleware(config: OpacaConfig): MiddlewareHandler;
@@ -0,0 +1,11 @@
1
+ import type { MiddlewareHandler } from "hono";
2
+ import { type Auth } from "../../auth";
3
+ import type { OpacaConfig } from "../../types";
4
+ /**
5
+ * Middleware for database connection and schema synchronization.
6
+ * This runs once per server startup via a 'migrated' flag in the shared state.
7
+ */
8
+ export declare function createDatabaseInitMiddleware(config: OpacaConfig, state: {
9
+ auth: Auth | undefined;
10
+ migrated: boolean;
11
+ }): MiddlewareHandler;
@@ -0,0 +1,3 @@
1
+ import type { MiddlewareHandler } from "hono";
2
+ import type { OpacaConfig } from "../../types";
3
+ export declare function createRateLimitMiddleware(config: OpacaConfig): MiddlewareHandler;
@@ -0,0 +1,7 @@
1
+ import { Hono } from "hono";
2
+ import type { OpacaConfig } from "../types";
3
+ import { type ApiContextVariables } from "./setup-middlewares";
4
+ export type { ApiContextVariables } from "./setup-middlewares";
5
+ export declare function createAPIRouter(config: OpacaConfig): Hono<{
6
+ Variables: ApiContextVariables;
7
+ }>;
@@ -0,0 +1,17 @@
1
+ import type { Hono } from "hono";
2
+ import type { Auth } from "../auth";
3
+ import type { OpacaConfig } from "../types";
4
+ import { type AuthContextVariables } from "./middlewares/auth";
5
+ import { type OpacaContextVariables } from "./middlewares/context";
6
+ export type ApiContextVariables = OpacaContextVariables & AuthContextVariables;
7
+ export declare function setupMiddlewares(router: Hono<{
8
+ Variables: ApiContextVariables;
9
+ }>, config: OpacaConfig, state: {
10
+ auth: Auth | undefined;
11
+ migrated: boolean;
12
+ }): void;
13
+ export declare function setupAuthMiddlewares(router: Hono<{
14
+ Variables: ApiContextVariables;
15
+ }>, config: OpacaConfig, state: {
16
+ auth: Auth | undefined;
17
+ }): void;
@@ -0,0 +1,9 @@
1
+ import { Hono } from "hono";
2
+ import type { OpacaConfig } from "../types";
3
+ import type { ApiContextVariables } from "./router";
4
+ export declare function createSystemRouter(config: OpacaConfig): Hono<{
5
+ Variables: ApiContextVariables;
6
+ }, import("hono/types").BlankSchema, "/">;
7
+ export declare function createAssetsServingRouter(config: OpacaConfig): Hono<{
8
+ Variables: ApiContextVariables;
9
+ }, import("hono/types").BlankSchema, "/">;
@@ -0,0 +1,6 @@
1
+ export * from "./config";
2
+ export * from "./db/adapter";
3
+ export * from "./server/admin";
4
+ export * from "./server/handlers";
5
+ export * from "./server/router";
6
+ export * from "./types";
@@ -0,0 +1,47 @@
1
+ /* src/admin/ui/styles/accordion.scss */
2
+
3
+
4
+ /* src/admin/ui/styles/button.scss */
5
+
6
+
7
+ /* src/admin/ui/styles/collapsible.scss */
8
+
9
+
10
+ /* src/admin/ui/styles/dialog.scss */
11
+
12
+
13
+ /* src/admin/ui/styles/group.scss */
14
+
15
+
16
+ /* src/admin/ui/styles/input.scss */
17
+
18
+
19
+ /* src/admin/ui/styles/label.scss */
20
+
21
+
22
+ /* src/admin/ui/styles/radio-group.scss */
23
+
24
+
25
+ /* src/admin/ui/styles/select.scss */
26
+
27
+
28
+ /* src/admin/ui/styles/sheet.scss */
29
+
30
+
31
+ /* src/admin/ui/styles/tabs.scss */
32
+
33
+
34
+ /* src/admin/ui/styles/index.scss */
35
+
36
+
37
+ /* src/admin/ui/styles/asset-manager.scss */
38
+
39
+
40
+ /* src/admin/ui/styles/lexical.scss */
41
+
42
+
43
+ /* src/admin/ui/styles/data-detail.scss */
44
+
45
+
46
+ /* src/admin/ui/styles/media-registry.scss */
47
+
@@ -0,0 +1,176 @@
1
+ import {
2
+ $config,
3
+ $hasMetadataError,
4
+ $isFetchingConfig,
5
+ $needsInit,
6
+ $router,
7
+ AdminClient,
8
+ AdminLayout,
9
+ Breadcrumbs,
10
+ Link,
11
+ Toast,
12
+ ToastContainer,
13
+ createFetcherStore,
14
+ createMutatorStore,
15
+ invalidateKeys,
16
+ mutateCache,
17
+ revalidateKeys,
18
+ setConfig,
19
+ setNeedsInit
20
+ } from "../../chunk-2zm8cy1w.js";
21
+ import"../../chunk-16vgcf3k.js";
22
+ import {
23
+ $isSidebarCollapsed,
24
+ $toasts,
25
+ clearToast,
26
+ notify,
27
+ toggleSidebar
28
+ } from "../../chunk-j4d50hrx.js";
29
+ import"../../chunk-8sqjbsgt.js";
30
+
31
+ // src/admin/custom-field.ts
32
+ function defineCustomField(tagName, adapter) {
33
+ if (typeof window === "undefined")
34
+ return;
35
+ if (customElements.get(tagName)) {
36
+ console.warn(`[OpacaCMS] Custom field tag "${tagName}" is already defined.`);
37
+ return;
38
+ }
39
+
40
+ class OpacaCustomFieldElement extends HTMLElement {
41
+ _value;
42
+ _fieldConfig;
43
+ _error;
44
+ _parentData;
45
+ _isMounted = false;
46
+ handleChange = (newValue) => {
47
+ this.dispatchEvent(new CustomEvent("opacachange", {
48
+ detail: { value: newValue },
49
+ bubbles: true,
50
+ composed: true
51
+ }));
52
+ };
53
+ getProps() {
54
+ return {
55
+ value: this._value,
56
+ fieldConfig: this._fieldConfig,
57
+ disabled: this.getAttribute("data-disabled") === "true",
58
+ readOnly: this.getAttribute("data-readonly") === "true",
59
+ error: this._error,
60
+ parentData: this._parentData,
61
+ onChange: this.handleChange
62
+ };
63
+ }
64
+ set error(err) {
65
+ if (this._error !== err) {
66
+ this._error = err;
67
+ if (this._isMounted && adapter.update) {
68
+ adapter.update(this, this.getProps());
69
+ }
70
+ }
71
+ }
72
+ get error() {
73
+ return this._error;
74
+ }
75
+ set parentData(data) {
76
+ this._parentData = data;
77
+ if (this._isMounted && adapter.update) {
78
+ adapter.update(this, this.getProps());
79
+ }
80
+ }
81
+ get parentData() {
82
+ return this._parentData;
83
+ }
84
+ set value(val) {
85
+ const oldValue = this._value;
86
+ this._value = val;
87
+ if (this._isMounted && adapter.update && oldValue !== val) {
88
+ adapter.update(this, this.getProps());
89
+ }
90
+ }
91
+ get value() {
92
+ return this._value;
93
+ }
94
+ set fieldConfig(config) {
95
+ this._fieldConfig = config;
96
+ if (this._isMounted && adapter.update) {
97
+ adapter.update(this, this.getProps());
98
+ }
99
+ }
100
+ get fieldConfig() {
101
+ return this._fieldConfig;
102
+ }
103
+ connectedCallback() {
104
+ if (!this._isMounted) {
105
+ adapter.mount(this, this.getProps());
106
+ this._isMounted = true;
107
+ }
108
+ }
109
+ disconnectedCallback() {
110
+ if (this._isMounted) {
111
+ if (adapter.unmount) {
112
+ adapter.unmount(this);
113
+ }
114
+ this._isMounted = false;
115
+ }
116
+ }
117
+ }
118
+ customElements.define(tagName, OpacaCustomFieldElement);
119
+ }
120
+ // src/admin/react.tsx
121
+ import React from "react";
122
+ import { createRoot } from "react-dom/client";
123
+ function defineReactField(tagName, Component) {
124
+ defineCustomField(tagName, {
125
+ mount: (container, props) => {
126
+ const el = container;
127
+ const root = createRoot(el);
128
+ el._opacaReactRoot = root;
129
+ root.render(React.createElement(Component, props));
130
+ },
131
+ update: (container, props) => {
132
+ const el = container;
133
+ const root = el._opacaReactRoot;
134
+ if (root) {
135
+ root.render(React.createElement(Component, props));
136
+ }
137
+ },
138
+ unmount: (container) => {
139
+ const el = container;
140
+ const root = el._opacaReactRoot;
141
+ if (root) {
142
+ setTimeout(() => {
143
+ root.unmount();
144
+ delete el._opacaReactRoot;
145
+ }, 0);
146
+ }
147
+ }
148
+ });
149
+ }
150
+ export {
151
+ toggleSidebar,
152
+ setNeedsInit,
153
+ setConfig,
154
+ revalidateKeys,
155
+ notify,
156
+ mutateCache,
157
+ invalidateKeys,
158
+ defineReactField,
159
+ defineCustomField,
160
+ createMutatorStore,
161
+ createFetcherStore,
162
+ clearToast,
163
+ ToastContainer,
164
+ Toast,
165
+ Link,
166
+ Breadcrumbs,
167
+ AdminLayout,
168
+ AdminClient,
169
+ $toasts,
170
+ $router,
171
+ $needsInit,
172
+ $isSidebarCollapsed,
173
+ $isFetchingConfig,
174
+ $hasMetadataError,
175
+ $config
176
+ };
@@ -0,0 +1,19 @@
1
+ import {
2
+ AdminClient
3
+ } from "../../chunk-2zm8cy1w.js";
4
+ import"../../chunk-16vgcf3k.js";
5
+ import"../../chunk-j4d50hrx.js";
6
+ import"../../chunk-8sqjbsgt.js";
7
+
8
+ // src/admin/webcomponent.tsx
9
+ import r2wc from "@r2wc/react-to-web-component";
10
+ var OpacaAdminWebComponent = r2wc(AdminClient, {
11
+ props: {
12
+ serverUrl: "string",
13
+ config: "json",
14
+ initialNeedsInit: "boolean"
15
+ }
16
+ });
17
+ if (typeof window !== "undefined" && !customElements.get("opaca-admin")) {
18
+ customElements.define("opaca-admin", OpacaAdminWebComponent);
19
+ }