@dyrected/core 2.5.53 → 2.5.56

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 (409) hide show
  1. package/dist/{app-config-oOarB6Fw.d.cts → app-config-Bxg_DVxv.d.cts} +3 -1
  2. package/dist/{app-config-oOarB6Fw.d.ts → app-config-Bxg_DVxv.d.ts} +3 -1
  3. package/dist/index.d.cts +2 -2
  4. package/dist/index.d.ts +2 -2
  5. package/dist/server.d.cts +1 -1
  6. package/dist/server.d.ts +1 -1
  7. package/package.json +1 -1
  8. package/dist/__tests__/admin-auth.test.d.ts +0 -2
  9. package/dist/__tests__/admin-auth.test.d.ts.map +0 -1
  10. package/dist/__tests__/admin-auth.test.js +0 -440
  11. package/dist/__tests__/admin-auth.test.js.map +0 -1
  12. package/dist/__tests__/app.test.d.ts +0 -2
  13. package/dist/__tests__/app.test.d.ts.map +0 -1
  14. package/dist/__tests__/app.test.js +0 -27
  15. package/dist/__tests__/app.test.js.map +0 -1
  16. package/dist/__tests__/config.test.d.ts +0 -2
  17. package/dist/__tests__/config.test.d.ts.map +0 -1
  18. package/dist/__tests__/config.test.js +0 -91
  19. package/dist/__tests__/config.test.js.map +0 -1
  20. package/dist/__tests__/deleteMany.test.d.ts +0 -2
  21. package/dist/__tests__/deleteMany.test.d.ts.map +0 -1
  22. package/dist/__tests__/deleteMany.test.js +0 -75
  23. package/dist/__tests__/deleteMany.test.js.map +0 -1
  24. package/dist/__tests__/depth.test.d.ts +0 -2
  25. package/dist/__tests__/depth.test.d.ts.map +0 -1
  26. package/dist/__tests__/depth.test.js +0 -81
  27. package/dist/__tests__/depth.test.js.map +0 -1
  28. package/dist/__tests__/dynamic-options.test.d.ts +0 -2
  29. package/dist/__tests__/dynamic-options.test.d.ts.map +0 -1
  30. package/dist/__tests__/dynamic-options.test.js +0 -132
  31. package/dist/__tests__/dynamic-options.test.js.map +0 -1
  32. package/dist/__tests__/email.service.test.d.ts +0 -2
  33. package/dist/__tests__/email.service.test.d.ts.map +0 -1
  34. package/dist/__tests__/email.service.test.js +0 -46
  35. package/dist/__tests__/email.service.test.js.map +0 -1
  36. package/dist/__tests__/field-inference.test-types.d.ts +0 -24
  37. package/dist/__tests__/field-inference.test-types.d.ts.map +0 -1
  38. package/dist/__tests__/field-inference.test-types.js +0 -87
  39. package/dist/__tests__/field-inference.test-types.js.map +0 -1
  40. package/dist/__tests__/fixtures/editorial-workflow.d.ts +0 -9
  41. package/dist/__tests__/fixtures/editorial-workflow.d.ts.map +0 -1
  42. package/dist/__tests__/fixtures/editorial-workflow.js +0 -12
  43. package/dist/__tests__/fixtures/editorial-workflow.js.map +0 -1
  44. package/dist/__tests__/hooks.test.d.ts +0 -2
  45. package/dist/__tests__/hooks.test.d.ts.map +0 -1
  46. package/dist/__tests__/hooks.test.js +0 -320
  47. package/dist/__tests__/hooks.test.js.map +0 -1
  48. package/dist/__tests__/mocks.d.ts +0 -74
  49. package/dist/__tests__/mocks.d.ts.map +0 -1
  50. package/dist/__tests__/mocks.js +0 -159
  51. package/dist/__tests__/mocks.js.map +0 -1
  52. package/dist/__tests__/openapi.test.d.ts +0 -2
  53. package/dist/__tests__/openapi.test.d.ts.map +0 -1
  54. package/dist/__tests__/openapi.test.js +0 -95
  55. package/dist/__tests__/openapi.test.js.map +0 -1
  56. package/dist/__tests__/parse-sort.test.d.ts +0 -2
  57. package/dist/__tests__/parse-sort.test.d.ts.map +0 -1
  58. package/dist/__tests__/parse-sort.test.js +0 -24
  59. package/dist/__tests__/parse-sort.test.js.map +0 -1
  60. package/dist/__tests__/preferences.test.d.ts +0 -2
  61. package/dist/__tests__/preferences.test.d.ts.map +0 -1
  62. package/dist/__tests__/preferences.test.js +0 -168
  63. package/dist/__tests__/preferences.test.js.map +0 -1
  64. package/dist/__tests__/router.test.d.ts +0 -2
  65. package/dist/__tests__/router.test.d.ts.map +0 -1
  66. package/dist/__tests__/router.test.js +0 -52
  67. package/dist/__tests__/router.test.js.map +0 -1
  68. package/dist/__tests__/where.test.d.ts +0 -2
  69. package/dist/__tests__/where.test.d.ts.map +0 -1
  70. package/dist/__tests__/where.test.js +0 -105
  71. package/dist/__tests__/where.test.js.map +0 -1
  72. package/dist/__tests__/workflow.test.d.ts +0 -2
  73. package/dist/__tests__/workflow.test.d.ts.map +0 -1
  74. package/dist/__tests__/workflow.test.js +0 -497
  75. package/dist/__tests__/workflow.test.js.map +0 -1
  76. package/dist/app-B2tg7Djj.d.cts +0 -1575
  77. package/dist/app-B2tg7Djj.d.ts +0 -1575
  78. package/dist/app-BElen1tP.d.cts +0 -1690
  79. package/dist/app-BElen1tP.d.ts +0 -1690
  80. package/dist/app-BOrsS7Tz.d.cts +0 -1771
  81. package/dist/app-BOrsS7Tz.d.ts +0 -1771
  82. package/dist/app-Bh4_Opv0.d.cts +0 -1522
  83. package/dist/app-Bh4_Opv0.d.ts +0 -1522
  84. package/dist/app-BibuoHQG.d.cts +0 -1764
  85. package/dist/app-BibuoHQG.d.ts +0 -1764
  86. package/dist/app-Bv9gaDAN.d.cts +0 -561
  87. package/dist/app-Bv9gaDAN.d.ts +0 -561
  88. package/dist/app-BvG3bRc8.d.cts +0 -419
  89. package/dist/app-BvG3bRc8.d.ts +0 -419
  90. package/dist/app-C-HgyliB.d.cts +0 -1694
  91. package/dist/app-C-HgyliB.d.ts +0 -1694
  92. package/dist/app-C3B9N1KR.d.cts +0 -1522
  93. package/dist/app-C3B9N1KR.d.ts +0 -1522
  94. package/dist/app-Cc2mG3zi.d.cts +0 -373
  95. package/dist/app-Cc2mG3zi.d.ts +0 -373
  96. package/dist/app-Ctfmo2Re.d.cts +0 -1692
  97. package/dist/app-Ctfmo2Re.d.ts +0 -1692
  98. package/dist/app-D0ffogDd.d.cts +0 -1690
  99. package/dist/app-D0ffogDd.d.ts +0 -1690
  100. package/dist/app-D2uR47gK.d.cts +0 -1690
  101. package/dist/app-D2uR47gK.d.ts +0 -1690
  102. package/dist/app-DDJJa0ep.d.cts +0 -1621
  103. package/dist/app-DDJJa0ep.d.ts +0 -1621
  104. package/dist/app-DO1s9YW1.d.cts +0 -1621
  105. package/dist/app-DO1s9YW1.d.ts +0 -1621
  106. package/dist/app-DTP3-9PJ.d.cts +0 -561
  107. package/dist/app-DTP3-9PJ.d.ts +0 -561
  108. package/dist/app-DZt5nslu.d.cts +0 -374
  109. package/dist/app-DZt5nslu.d.ts +0 -377
  110. package/dist/app-DbKDGYTI.d.cts +0 -566
  111. package/dist/app-DbKDGYTI.d.ts +0 -566
  112. package/dist/app-Dk3SzV1a.d.cts +0 -374
  113. package/dist/app-Dk3SzV1a.d.ts +0 -374
  114. package/dist/app-DnX9mNsh.d.cts +0 -374
  115. package/dist/app-DnX9mNsh.d.ts +0 -374
  116. package/dist/app-DqRO-CMi.d.cts +0 -1457
  117. package/dist/app-DqRO-CMi.d.ts +0 -1457
  118. package/dist/app-DvaFpOtj.d.cts +0 -398
  119. package/dist/app-DvaFpOtj.d.ts +0 -398
  120. package/dist/app-FGzip4XM.d.cts +0 -1563
  121. package/dist/app-FGzip4XM.d.ts +0 -1563
  122. package/dist/app-KApbf4XL.d.cts +0 -362
  123. package/dist/app-KApbf4XL.d.ts +0 -362
  124. package/dist/app-T0alZAE0.d.cts +0 -383
  125. package/dist/app-T0alZAE0.d.ts +0 -383
  126. package/dist/app-aW2FMuYM.d.cts +0 -1759
  127. package/dist/app-aW2FMuYM.d.ts +0 -1759
  128. package/dist/app-config-2vF6W56z.d.cts +0 -1335
  129. package/dist/app-config-2vF6W56z.d.ts +0 -1335
  130. package/dist/app-config-3XBnu9Xz.d.cts +0 -1379
  131. package/dist/app-config-3XBnu9Xz.d.ts +0 -1379
  132. package/dist/app-config-BLMX-9MN.d.cts +0 -1045
  133. package/dist/app-config-BLMX-9MN.d.ts +0 -1045
  134. package/dist/app-config-CaEQH0Kb.d.cts +0 -1383
  135. package/dist/app-config-CaEQH0Kb.d.ts +0 -1383
  136. package/dist/app-config-DLK6bCaP.d.cts +0 -1390
  137. package/dist/app-config-DLK6bCaP.d.ts +0 -1390
  138. package/dist/app-oQt5-9MU.d.cts +0 -1560
  139. package/dist/app-oQt5-9MU.d.ts +0 -1560
  140. package/dist/app-rZj1VFer.d.cts +0 -1621
  141. package/dist/app-rZj1VFer.d.ts +0 -1621
  142. package/dist/app-wo82JRHl.d.cts +0 -445
  143. package/dist/app-wo82JRHl.d.ts +0 -445
  144. package/dist/app.d.ts +0 -21
  145. package/dist/app.d.ts.map +0 -1
  146. package/dist/app.js +0 -56
  147. package/dist/app.js.map +0 -1
  148. package/dist/auth/jexl.d.ts +0 -10
  149. package/dist/auth/jexl.d.ts.map +0 -1
  150. package/dist/auth/jexl.js +0 -22
  151. package/dist/auth/jexl.js.map +0 -1
  152. package/dist/auth/password.d.ts +0 -10
  153. package/dist/auth/password.d.ts.map +0 -1
  154. package/dist/auth/password.js +0 -28
  155. package/dist/auth/password.js.map +0 -1
  156. package/dist/auth/token.d.ts +0 -22
  157. package/dist/auth/token.d.ts.map +0 -1
  158. package/dist/auth/token.js +0 -40
  159. package/dist/auth/token.js.map +0 -1
  160. package/dist/chunk-22JTWD74.js +0 -1784
  161. package/dist/chunk-23URSKPI.js +0 -2371
  162. package/dist/chunk-2JMA3M5S.js +0 -2475
  163. package/dist/chunk-3FZEUK36.js +0 -2470
  164. package/dist/chunk-3VUH2MNW.js +0 -1903
  165. package/dist/chunk-44O2LDPT.js +0 -1513
  166. package/dist/chunk-45JDQDA2.js +0 -1899
  167. package/dist/chunk-4C4L6SD2.js +0 -1524
  168. package/dist/chunk-4EDMZAM5.js +0 -2692
  169. package/dist/chunk-52T4RCFU.js +0 -1972
  170. package/dist/chunk-6ZXEGKT6.js +0 -619
  171. package/dist/chunk-7GGHK75W.js +0 -1835
  172. package/dist/chunk-ALNQINX7.js +0 -2496
  173. package/dist/chunk-B6KDKYXB.js +0 -2502
  174. package/dist/chunk-BEONZV6M.js +0 -1951
  175. package/dist/chunk-C4GEQ5RP.js +0 -1993
  176. package/dist/chunk-CQDVPMEU.js +0 -613
  177. package/dist/chunk-DOJHZ7XN.js +0 -2394
  178. package/dist/chunk-EH7G3LLL.js +0 -2065
  179. package/dist/chunk-EXXOPW3I.js +0 -2483
  180. package/dist/chunk-F4ZC6TXR.js +0 -2065
  181. package/dist/chunk-FCXE5CVC.js +0 -1528
  182. package/dist/chunk-FDQYPPG3.js +0 -2698
  183. package/dist/chunk-FURYJ254.mjs +0 -33
  184. package/dist/chunk-G2QQLBHW.js +0 -24
  185. package/dist/chunk-GM4WW6IE.js +0 -66
  186. package/dist/chunk-GZODLJ3C.js +0 -1861
  187. package/dist/chunk-IIY3E7Q7.js +0 -1996
  188. package/dist/chunk-JJN4J5NS.js +0 -2069
  189. package/dist/chunk-MRUHCNDM.js +0 -1940
  190. package/dist/chunk-NKDX67AW.js +0 -2698
  191. package/dist/chunk-NYUB4AHZ.js +0 -1951
  192. package/dist/chunk-OD4SLW7H.js +0 -1930
  193. package/dist/chunk-OE5MH3NB.js +0 -2070
  194. package/dist/chunk-PH36WQYS.js +0 -1875
  195. package/dist/chunk-PKNFV7KE.js +0 -2469
  196. package/dist/chunk-SUGK7UYL.js +0 -311
  197. package/dist/chunk-TIJHR54M.js +0 -1879
  198. package/dist/chunk-TUUHGLB5.js +0 -2609
  199. package/dist/chunk-UBTRANFX.js +0 -2476
  200. package/dist/chunk-VJWUG2XK.js +0 -1951
  201. package/dist/chunk-W6KURRMW.js +0 -2471
  202. package/dist/chunk-Y4AYI52W.js +0 -631
  203. package/dist/chunk-YDOBB7MY.js +0 -1457
  204. package/dist/chunk-YNJ3YC4N.js +0 -2483
  205. package/dist/chunk-ZFAOBRHT.js +0 -2709
  206. package/dist/controllers/admin-auth.controller.d.ts +0 -68
  207. package/dist/controllers/admin-auth.controller.d.ts.map +0 -1
  208. package/dist/controllers/admin-auth.controller.js +0 -414
  209. package/dist/controllers/admin-auth.controller.js.map +0 -1
  210. package/dist/controllers/auth.controller.d.ts +0 -125
  211. package/dist/controllers/auth.controller.d.ts.map +0 -1
  212. package/dist/controllers/auth.controller.js +0 -323
  213. package/dist/controllers/auth.controller.js.map +0 -1
  214. package/dist/controllers/collection.controller.d.ts +0 -157
  215. package/dist/controllers/collection.controller.d.ts.map +0 -1
  216. package/dist/controllers/collection.controller.js +0 -779
  217. package/dist/controllers/collection.controller.js.map +0 -1
  218. package/dist/controllers/global.controller.d.ts +0 -17
  219. package/dist/controllers/global.controller.d.ts.map +0 -1
  220. package/dist/controllers/global.controller.js +0 -132
  221. package/dist/controllers/global.controller.js.map +0 -1
  222. package/dist/controllers/media.controller.d.ts +0 -38
  223. package/dist/controllers/media.controller.d.ts.map +0 -1
  224. package/dist/controllers/media.controller.js +0 -162
  225. package/dist/controllers/media.controller.js.map +0 -1
  226. package/dist/controllers/preview.controller.d.ts +0 -37
  227. package/dist/controllers/preview.controller.d.ts.map +0 -1
  228. package/dist/controllers/preview.controller.js +0 -48
  229. package/dist/controllers/preview.controller.js.map +0 -1
  230. package/dist/index-BKYugiYp.d.cts +0 -1988
  231. package/dist/index-BKYugiYp.d.ts +0 -1988
  232. package/dist/index-BSWCiAen.d.cts +0 -1983
  233. package/dist/index-BSWCiAen.d.ts +0 -1983
  234. package/dist/index-BfLDb3b0.d.cts +0 -1467
  235. package/dist/index-BfLDb3b0.d.ts +0 -1467
  236. package/dist/index-Bi4sX_eC.d.cts +0 -1491
  237. package/dist/index-Bi4sX_eC.d.ts +0 -1491
  238. package/dist/index-Bp7PDOYG.d.cts +0 -1750
  239. package/dist/index-Bp7PDOYG.d.ts +0 -1750
  240. package/dist/index-ByXooLy-.d.cts +0 -1762
  241. package/dist/index-ByXooLy-.d.ts +0 -1762
  242. package/dist/index-C9Vp1DCT.d.cts +0 -1563
  243. package/dist/index-C9Vp1DCT.d.ts +0 -1563
  244. package/dist/index-CFezd8p1.d.cts +0 -1986
  245. package/dist/index-CFezd8p1.d.ts +0 -1986
  246. package/dist/index-CdQwnbfh.d.cts +0 -1889
  247. package/dist/index-CdQwnbfh.d.ts +0 -1889
  248. package/dist/index-D38_E0gf.d.cts +0 -336
  249. package/dist/index-D38_E0gf.d.ts +0 -336
  250. package/dist/index-DR2z1rrf.d.cts +0 -1503
  251. package/dist/index-DR2z1rrf.d.ts +0 -1503
  252. package/dist/index-DTrpTru7.d.cts +0 -1881
  253. package/dist/index-DTrpTru7.d.ts +0 -1881
  254. package/dist/index-DfAmTZXk.d.cts +0 -1749
  255. package/dist/index-DfAmTZXk.d.ts +0 -1749
  256. package/dist/index-DfkPT4NR.d.cts +0 -1584
  257. package/dist/index-DfkPT4NR.d.ts +0 -1584
  258. package/dist/index-DzUlE5Hc.d.cts +0 -1751
  259. package/dist/index-DzUlE5Hc.d.ts +0 -1751
  260. package/dist/index-M_m6dXZV.d.cts +0 -1889
  261. package/dist/index-M_m6dXZV.d.ts +0 -1889
  262. package/dist/index-RylhgOwj.d.cts +0 -340
  263. package/dist/index-RylhgOwj.d.ts +0 -340
  264. package/dist/index-qhLus8ZO.d.cts +0 -1881
  265. package/dist/index-qhLus8ZO.d.ts +0 -1881
  266. package/dist/index-xB1lMg79.d.cts +0 -1456
  267. package/dist/index-xB1lMg79.d.ts +0 -1456
  268. package/dist/index.d.mts +0 -417
  269. package/dist/index.d.ts.map +0 -1
  270. package/dist/index.js.map +0 -1
  271. package/dist/index.mjs +0 -1974
  272. package/dist/middleware/auth.d.ts +0 -18
  273. package/dist/middleware/auth.d.ts.map +0 -1
  274. package/dist/middleware/auth.js +0 -45
  275. package/dist/middleware/auth.js.map +0 -1
  276. package/dist/password-ACI2YUGZ.js +0 -8
  277. package/dist/router.d.ts +0 -8
  278. package/dist/router.d.ts.map +0 -1
  279. package/dist/router.js +0 -625
  280. package/dist/router.js.map +0 -1
  281. package/dist/server.d.ts.map +0 -1
  282. package/dist/server.js.map +0 -1
  283. package/dist/services/audit.service.d.ts +0 -23
  284. package/dist/services/audit.service.d.ts.map +0 -1
  285. package/dist/services/audit.service.js +0 -28
  286. package/dist/services/audit.service.js.map +0 -1
  287. package/dist/services/defaults.service.d.ts +0 -8
  288. package/dist/services/defaults.service.d.ts.map +0 -1
  289. package/dist/services/defaults.service.js +0 -55
  290. package/dist/services/defaults.service.js.map +0 -1
  291. package/dist/services/email-template.d.ts +0 -46
  292. package/dist/services/email-template.d.ts.map +0 -1
  293. package/dist/services/email-template.js +0 -88
  294. package/dist/services/email-template.js.map +0 -1
  295. package/dist/services/email.service.d.ts +0 -33
  296. package/dist/services/email.service.d.ts.map +0 -1
  297. package/dist/services/email.service.js +0 -96
  298. package/dist/services/email.service.js.map +0 -1
  299. package/dist/services/media.service.d.ts +0 -20
  300. package/dist/services/media.service.d.ts.map +0 -1
  301. package/dist/services/media.service.js +0 -49
  302. package/dist/services/media.service.js.map +0 -1
  303. package/dist/services/population.service.d.ts +0 -20
  304. package/dist/services/population.service.d.ts.map +0 -1
  305. package/dist/services/population.service.js +0 -194
  306. package/dist/services/population.service.js.map +0 -1
  307. package/dist/token-7QG5DBME.mjs +0 -10
  308. package/dist/types/access.d.ts +0 -38
  309. package/dist/types/access.d.ts.map +0 -1
  310. package/dist/types/access.js +0 -2
  311. package/dist/types/access.js.map +0 -1
  312. package/dist/types/adapters.d.ts +0 -146
  313. package/dist/types/adapters.d.ts.map +0 -1
  314. package/dist/types/adapters.js +0 -2
  315. package/dist/types/adapters.js.map +0 -1
  316. package/dist/types/admin-auth.d.ts +0 -132
  317. package/dist/types/admin-auth.d.ts.map +0 -1
  318. package/dist/types/admin-auth.js +0 -2
  319. package/dist/types/admin-auth.js.map +0 -1
  320. package/dist/types/admin.d.ts +0 -65
  321. package/dist/types/admin.d.ts.map +0 -1
  322. package/dist/types/admin.js +0 -2
  323. package/dist/types/admin.js.map +0 -1
  324. package/dist/types/app-config.d.ts +0 -143
  325. package/dist/types/app-config.d.ts.map +0 -1
  326. package/dist/types/app-config.js +0 -2
  327. package/dist/types/app-config.js.map +0 -1
  328. package/dist/types/documents.d.ts +0 -65
  329. package/dist/types/documents.d.ts.map +0 -1
  330. package/dist/types/documents.js +0 -2
  331. package/dist/types/documents.js.map +0 -1
  332. package/dist/types/hooks.d.ts +0 -122
  333. package/dist/types/hooks.d.ts.map +0 -1
  334. package/dist/types/hooks.js +0 -2
  335. package/dist/types/hooks.js.map +0 -1
  336. package/dist/types/index.d.ts +0 -13
  337. package/dist/types/index.d.ts.map +0 -1
  338. package/dist/types/index.js +0 -13
  339. package/dist/types/index.js.map +0 -1
  340. package/dist/types/request.d.ts +0 -42
  341. package/dist/types/request.d.ts.map +0 -1
  342. package/dist/types/request.js +0 -2
  343. package/dist/types/request.js.map +0 -1
  344. package/dist/types/schema-config.d.ts +0 -303
  345. package/dist/types/schema-config.d.ts.map +0 -1
  346. package/dist/types/schema-config.js +0 -2
  347. package/dist/types/schema-config.js.map +0 -1
  348. package/dist/types/schema-core.d.ts +0 -294
  349. package/dist/types/schema-core.d.ts.map +0 -1
  350. package/dist/types/schema-core.js +0 -2
  351. package/dist/types/schema-core.js.map +0 -1
  352. package/dist/types/schema-inference.d.ts +0 -73
  353. package/dist/types/schema-inference.d.ts.map +0 -1
  354. package/dist/types/schema-inference.js +0 -2
  355. package/dist/types/schema-inference.js.map +0 -1
  356. package/dist/types/workflows.d.ts +0 -84
  357. package/dist/types/workflows.d.ts.map +0 -1
  358. package/dist/types/workflows.js +0 -7
  359. package/dist/types/workflows.js.map +0 -1
  360. package/dist/utils/admin-auth.d.ts +0 -5
  361. package/dist/utils/admin-auth.d.ts.map +0 -1
  362. package/dist/utils/admin-auth.js +0 -39
  363. package/dist/utils/admin-auth.js.map +0 -1
  364. package/dist/utils/config.d.ts +0 -8
  365. package/dist/utils/config.d.ts.map +0 -1
  366. package/dist/utils/config.js +0 -238
  367. package/dist/utils/config.js.map +0 -1
  368. package/dist/utils/hooks.d.ts +0 -41
  369. package/dist/utils/hooks.d.ts.map +0 -1
  370. package/dist/utils/hooks.js +0 -173
  371. package/dist/utils/hooks.js.map +0 -1
  372. package/dist/utils/openapi.d.ts +0 -6
  373. package/dist/utils/openapi.d.ts.map +0 -1
  374. package/dist/utils/openapi.js +0 -842
  375. package/dist/utils/openapi.js.map +0 -1
  376. package/dist/utils/parse-sort.d.ts +0 -7
  377. package/dist/utils/parse-sort.d.ts.map +0 -1
  378. package/dist/utils/parse-sort.js +0 -23
  379. package/dist/utils/parse-sort.js.map +0 -1
  380. package/dist/utils/parse-where.d.ts +0 -63
  381. package/dist/utils/parse-where.d.ts.map +0 -1
  382. package/dist/utils/parse-where.js +0 -196
  383. package/dist/utils/parse-where.js.map +0 -1
  384. package/dist/utils/readonly-db.d.ts +0 -9
  385. package/dist/utils/readonly-db.d.ts.map +0 -1
  386. package/dist/utils/readonly-db.js +0 -21
  387. package/dist/utils/readonly-db.js.map +0 -1
  388. package/dist/utils/setup-prompt.d.ts +0 -11
  389. package/dist/utils/setup-prompt.d.ts.map +0 -1
  390. package/dist/utils/setup-prompt.js +0 -863
  391. package/dist/utils/setup-prompt.js.map +0 -1
  392. package/dist/utils/swagger.d.ts +0 -11
  393. package/dist/utils/swagger.d.ts.map +0 -1
  394. package/dist/utils/swagger.js +0 -62
  395. package/dist/utils/swagger.js.map +0 -1
  396. package/dist/utils/upload-validation.d.ts +0 -23
  397. package/dist/utils/upload-validation.d.ts.map +0 -1
  398. package/dist/utils/upload-validation.js +0 -44
  399. package/dist/utils/upload-validation.js.map +0 -1
  400. package/dist/utils/where-sanitizer.d.ts +0 -10
  401. package/dist/utils/where-sanitizer.d.ts.map +0 -1
  402. package/dist/utils/where-sanitizer.js +0 -67
  403. package/dist/utils/where-sanitizer.js.map +0 -1
  404. package/dist/where-sanitizer-7Q4JXMX6.js +0 -57
  405. package/dist/where-sanitizer-DQIWTQZW.js +0 -50
  406. package/dist/workflows.d.ts +0 -54
  407. package/dist/workflows.d.ts.map +0 -1
  408. package/dist/workflows.js +0 -282
  409. package/dist/workflows.js.map +0 -1
@@ -1,1491 +0,0 @@
1
- import { icons } from 'lucide-react';
2
-
3
- type AdminAuthProvisioningMode = "jit_only" | "jit_plus_membership_management" | "preprovisioned_only";
4
- interface AdminAuthClaimMapping {
5
- sub?: string;
6
- email?: string;
7
- name?: string;
8
- roles?: string;
9
- groups?: string;
10
- siteIds?: string;
11
- workspaceIds?: string;
12
- }
13
- interface AdminAuthResolvedIdentity {
14
- sub: string;
15
- email?: string;
16
- name?: string;
17
- roles?: string[];
18
- groups?: string[];
19
- siteIds?: string[];
20
- workspaceIds?: string[];
21
- rawClaims?: Record<string, unknown>;
22
- }
23
- interface AdminAuthAccessResolution {
24
- allowed: boolean;
25
- roles?: string[];
26
- data?: Record<string, unknown>;
27
- }
28
- interface AdminAuthResolveAccessArgs {
29
- identity: AdminAuthResolvedIdentity;
30
- providerId: string;
31
- siteId?: string;
32
- workspaceId?: string;
33
- req: {
34
- method: string;
35
- path: string;
36
- url: string;
37
- headers: Record<string, string | undefined>;
38
- };
39
- user: Record<string, unknown> | null;
40
- }
41
- interface BaseAdminAuthProvider {
42
- id: string;
43
- type: "oidc" | "custom" | "cloud";
44
- displayName?: string;
45
- autoRedirect?: boolean;
46
- allowJitProvisioning?: boolean;
47
- claimMapping?: AdminAuthClaimMapping;
48
- }
49
- interface OIDCAdminAuthProvider extends BaseAdminAuthProvider {
50
- type: "oidc";
51
- issuer: string;
52
- clientId: string;
53
- clientSecret: string;
54
- redirectUri?: string;
55
- scopes?: string[];
56
- authorizationEndpoint?: string;
57
- tokenEndpoint?: string;
58
- userInfoEndpoint?: string;
59
- }
60
- interface CustomAdminAuthProvider extends BaseAdminAuthProvider {
61
- type: "custom" | "cloud";
62
- startUrl?: string;
63
- issuer?: string;
64
- audience?: string;
65
- secret?: string;
66
- jwksUri?: string;
67
- tokenParam?: string;
68
- }
69
- type AdminAuthProvider = OIDCAdminAuthProvider | CustomAdminAuthProvider;
70
- interface PublicAdminAuthProvider {
71
- id: string;
72
- type: AdminAuthProvider["type"];
73
- displayName: string;
74
- autoRedirect?: boolean;
75
- }
76
- interface PublicAdminAuthConfig {
77
- mode: "local" | "external";
78
- collectionSlug?: string;
79
- provisioningMode?: AdminAuthProvisioningMode;
80
- providers: PublicAdminAuthProvider[];
81
- }
82
- interface AdminAuthConfig {
83
- mode: "local" | "external";
84
- collectionSlug?: string;
85
- provisioningMode?: AdminAuthProvisioningMode;
86
- providers: AdminAuthProvider[];
87
- resolveAccess?: (args: AdminAuthResolveAccessArgs) => Promise<AdminAuthAccessResolution> | AdminAuthAccessResolution;
88
- }
89
-
90
- /** A valid icon component name from the Lucide icon set bundled with Dyrected Admin. */
91
- type AdminIconName = keyof typeof icons;
92
- /** Ordered custom component keys rendered around the built-in Admin dashboard. */
93
- interface AdminDashboardComponentSlots {
94
- beforeDashboard?: string[];
95
- afterDashboard?: string[];
96
- }
97
- /** Ordered custom component keys rendered around a collection's list content. */
98
- interface CollectionListComponentSlots {
99
- beforeList?: string[];
100
- beforeListTable?: string[];
101
- afterListTable?: string[];
102
- afterList?: string[];
103
- }
104
- /**
105
- * Branding and metadata options for the Dyrected Admin UI.
106
- *
107
- * @example
108
- * admin: {
109
- * branding: {
110
- * logo: '/logo.svg',
111
- * primaryColor: '#6366f1',
112
- * },
113
- * meta: {
114
- * titleSuffix: '- My App',
115
- * },
116
- * }
117
- */
118
- interface AdminConfig {
119
- /** Custom component slots around the built-in dashboard. */
120
- components?: AdminDashboardComponentSlots;
121
- branding?: {
122
- /** Full logo image shown in the expanded sidebar. URL or imported image asset. */
123
- logo?: string;
124
- /** Compact logo mark used in the collapsed sidebar state. */
125
- logoMark?: string;
126
- /** Text alternative or addition to the logo image. */
127
- logoText?: string;
128
- /**
129
- * Primary accent colour as any CSS colour value.
130
- * @example '#6366f1'
131
- * @example 'hsl(240 50% 60%)'
132
- */
133
- primaryColor?: string;
134
- /** Browser tab favicon URL. */
135
- favicon?: string;
136
- /** Font family for body and UI text. Must be loaded separately. */
137
- fontSans?: string;
138
- /** Font family for headings. Must be loaded separately. */
139
- fontSerif?: string;
140
- };
141
- meta?: {
142
- /**
143
- * String appended to every Admin page's `<title>`.
144
- * @default '- Dyrected'
145
- */
146
- titleSuffix?: string;
147
- };
148
- }
149
-
150
- /**
151
- * The minimum shape of every document returned by the database layer.
152
- *
153
- * All documents have an `id` field assigned by the adapter. Additional fields
154
- * are stored as `unknown` until you narrow them with your own interface.
155
- *
156
- * Use this as the base when declaring your collection document types:
157
- * ```ts
158
- * interface Post extends BaseDocument {
159
- * title: string
160
- * slug: string
161
- * }
162
- * ```
163
- */
164
- interface BaseDocument {
165
- /** The document's unique identifier, assigned by the database adapter. */
166
- id: string;
167
- [key: string]: any;
168
- }
169
- /**
170
- * The envelope returned by collection list endpoints (`GET /api/collections/:slug`).
171
- *
172
- * @template T The document type.
173
- */
174
- interface PaginatedResult<T = Record<string, any>> {
175
- /** The documents on the current page. */
176
- docs: T[];
177
- /** Total number of documents matching the query (across all pages). */
178
- total: number;
179
- /** Maximum number of documents per page as requested. */
180
- limit: number;
181
- /** The current page number (1-indexed). */
182
- page: number;
183
- /** Total number of pages given the current `limit`. */
184
- totalPages: number;
185
- /** Whether a next page exists. */
186
- hasNextPage: boolean;
187
- /** Whether a previous page exists. */
188
- hasPrevPage: boolean;
189
- }
190
- /**
191
- * Metadata returned after a file is uploaded and stored.
192
- * Stored on the document in upload collections.
193
- */
194
- interface FileData {
195
- filename: string;
196
- filesize?: number;
197
- mimeType: string;
198
- /** Public URL of the stored file. */
199
- url: string;
200
- width?: number;
201
- height?: number;
202
- focalPoint?: {
203
- x: number;
204
- y: number;
205
- };
206
- /** Base64-encoded BlurHash string for progressive image loading. */
207
- blurhash?: string;
208
- /** `'upload'` for server-stored files; `'external'` for provider-managed files. */
209
- type?: "upload" | "external";
210
- provider?: string;
211
- provider_metadata?: unknown;
212
- [key: string]: unknown;
213
- }
214
-
215
- /**
216
- * Minimum HTTP request context passed to every server-side hook and resolver.
217
- *
218
- * The full Web Standard `Request` is available as `raw` when you need it, but
219
- * most hooks only need `query` (URL search parameters).
220
- */
221
- interface HookRequestContext {
222
- /** Parsed URL query-string parameters, e.g. `{ page: '2', search: 'hello' }`. */
223
- query: Record<string, string>;
224
- /** Incoming HTTP headers, lowercased. */
225
- headers: Record<string, string>;
226
- /** The raw Web Standard `Request` object. Useful for streaming or advanced header inspection. */
227
- raw?: Request;
228
- }
229
- /**
230
- * Base shape of an authenticated user as decoded from the JWT.
231
- *
232
- * The actual shape will include every field on your auth collection — this
233
- * interface only guarantees the properties that Dyrected always stamps on the
234
- * token. Extend it in your own codebase for stronger typing:
235
- *
236
- * @example
237
- * declare module '@dyrected/core' {
238
- * interface AuthenticatedUser {
239
- * role: 'admin' | 'editor'
240
- * organizationId: string
241
- * }
242
- * }
243
- */
244
- interface AuthenticatedUser {
245
- /** The user's document ID in the database. */
246
- sub: string;
247
- /** The user's email address. */
248
- email?: string;
249
- /** Slug of the collection this user was authenticated against. */
250
- collection: string;
251
- /** Array of role strings, if your auth collection has a `roles` field. */
252
- roles?: string[];
253
- /** Any additional fields from the auth collection document. */
254
- [key: string]: unknown;
255
- }
256
-
257
- type FieldType = "text" | "textarea" | "richText" | "number" | "boolean" | "date" | "datetime" | "time" | "select" | "multiSelect" | "radio" | "relationship" | "array" | "object" | "json" | "blocks" | "image" | "email" | "url" | "icon" | "join" | "row";
258
- interface DynamicOptionsResolverArgs {
259
- db?: DatabaseAdapter;
260
- user?: AuthenticatedUser;
261
- req: HookRequestContext;
262
- }
263
- type DynamicOptionsResolver = (args: DynamicOptionsResolverArgs) => Promise<DynamicOptionItem[]> | DynamicOptionItem[];
264
- interface DynamicOptionsConfig {
265
- resolve: DynamicOptionsResolver;
266
- cacheTTL?: number;
267
- }
268
- type DynamicOptionItem = string | {
269
- label: string;
270
- value: unknown;
271
- };
272
- interface Block {
273
- slug: string;
274
- labels?: {
275
- singular: string;
276
- plural: string;
277
- };
278
- fields: Field[];
279
- }
280
- interface FieldBase {
281
- name?: string;
282
- label?: string;
283
- required?: boolean;
284
- unique?: boolean;
285
- defaultValue?: unknown;
286
- options?: string[] | {
287
- label: string;
288
- value: unknown;
289
- }[] | DynamicOptionsResolver | DynamicOptionsConfig;
290
- relationTo?: string;
291
- hasMany?: boolean;
292
- fields?: Field[];
293
- blocks?: Block[];
294
- collection?: string;
295
- on?: string;
296
- limit?: number;
297
- access?: {
298
- read?: AccessFunction | string;
299
- update?: AccessFunction | string;
300
- };
301
- admin?: BaseFieldAdmin;
302
- renameTo?: string;
303
- promoted?: boolean;
304
- }
305
- interface BaseFieldAdmin {
306
- placeholder?: string;
307
- component?: string;
308
- description?: string;
309
- hidden?: boolean;
310
- filterable?: boolean;
311
- readOnly?: boolean;
312
- condition?: ((data: Record<string, unknown>, siblingData: Record<string, unknown>) => boolean) | string;
313
- tab?: string;
314
- width?: string;
315
- }
316
- interface FieldBeforeChangeHookArgs<TValue = unknown, TDoc extends object = Record<string, unknown>> {
317
- value: TValue;
318
- originalDoc?: TDoc;
319
- data: Record<string, unknown>;
320
- user?: AuthenticatedUser;
321
- db: ReadonlyDatabaseAdapter;
322
- }
323
- type FieldBeforeChangeHook$1<TValue = unknown, TDoc extends object = Record<string, unknown>> = (args: FieldBeforeChangeHookArgs<TValue, TDoc>) => unknown;
324
- interface FieldAfterReadHookArgs<TValue = unknown, TDoc extends object = Record<string, unknown>> {
325
- value: TValue;
326
- doc: TDoc;
327
- user?: AuthenticatedUser;
328
- db: ReadonlyDatabaseAdapter;
329
- }
330
- type FieldAfterReadHook$1<TValue = unknown, TDoc extends object = Record<string, unknown>> = (args: FieldAfterReadHookArgs<TValue, TDoc>) => unknown;
331
- type FieldHooks<TValue> = {
332
- hooks?: {
333
- beforeChange?: Array<FieldBeforeChangeHook$1<TValue>>;
334
- afterRead?: Array<FieldAfterReadHook$1<TValue>>;
335
- };
336
- };
337
- interface FieldAdminOnChangeHookArgs<TValue = unknown> {
338
- value: TValue;
339
- siblingData: Record<string, unknown>;
340
- data: Record<string, unknown>;
341
- setValue: (value: unknown) => void;
342
- }
343
- type FieldAdminOnChangeHook<TValue = unknown> = (args: FieldAdminOnChangeHookArgs<TValue>) => unknown;
344
- type FieldAdminHooks<TValue> = {
345
- admin?: {
346
- hooks?: {
347
- onChange?: FieldAdminOnChangeHook<TValue>;
348
- };
349
- };
350
- };
351
- interface FieldAdminOptionsHookArgs {
352
- siblingData: Record<string, unknown>;
353
- data: Record<string, unknown>;
354
- }
355
- type FieldAdminOptionsHookResult = Array<string | {
356
- label: string;
357
- value: unknown;
358
- }>;
359
- type FieldAdminOptionsHook = (args: FieldAdminOptionsHookArgs) => FieldAdminOptionsHookResult | Promise<FieldAdminOptionsHookResult>;
360
- type TypedField<TType extends FieldType, TValue, TAdminExtra = Record<never, never>> = Omit<FieldBase, "admin"> & {
361
- type: TType;
362
- admin?: BaseFieldAdmin & TAdminExtra;
363
- } & FieldHooks<TValue> & FieldAdminHooks<TValue>;
364
- type BooleanFieldAdmin = {
365
- layout?: "checkbox" | "switch";
366
- };
367
- type SelectFieldAdmin = {
368
- layout?: "radio" | "select";
369
- direction?: "horizontal" | "vertical";
370
- hooks?: {
371
- options?: FieldAdminOptionsHook;
372
- };
373
- };
374
- type RadioFieldAdmin = {
375
- direction?: "horizontal" | "vertical";
376
- hooks?: {
377
- options?: FieldAdminOptionsHook;
378
- };
379
- };
380
- type MultiSelectFieldAdmin = {
381
- hooks?: {
382
- options?: FieldAdminOptionsHook;
383
- };
384
- };
385
- type TextField = TypedField<"text", string>;
386
- type TextareaField = TypedField<"textarea", string>;
387
- type EmailField = TypedField<"email", string>;
388
- type UrlField = TypedField<"url", string>;
389
- type IconField = TypedField<"icon", string>;
390
- type DateField = TypedField<"date", string>;
391
- type DateTimeField = TypedField<"datetime", string>;
392
- type TimeField = TypedField<"time", string>;
393
- type SelectField = TypedField<"select", string, SelectFieldAdmin>;
394
- type RadioField = TypedField<"radio", string, RadioFieldAdmin>;
395
- type NumberField = TypedField<"number", number>;
396
- type BooleanField = TypedField<"boolean", boolean, BooleanFieldAdmin>;
397
- type MultiSelectField = TypedField<"multiSelect", string[], MultiSelectFieldAdmin>;
398
- type RelationshipField = TypedField<"relationship", string | string[]>;
399
- type ImageField = TypedField<"image", string | string[]>;
400
- type RichTextField = TypedField<"richText", Record<string, unknown>>;
401
- type JsonField = TypedField<"json", Record<string, unknown>>;
402
- type ObjectField = TypedField<"object", unknown>;
403
- type ArrayField = TypedField<"array", unknown>;
404
- type BlocksField = TypedField<"blocks", unknown>;
405
- type JoinField = TypedField<"join", unknown>;
406
- type RowField = TypedField<"row", unknown>;
407
- type Field = TextField | TextareaField | EmailField | UrlField | IconField | DateField | DateTimeField | TimeField | SelectField | RadioField | NumberField | BooleanField | MultiSelectField | RelationshipField | ImageField | RichTextField | JsonField | ObjectField | ArrayField | BlocksField | JoinField | RowField;
408
- interface UploadConfig {
409
- allowedMimeTypes?: string[];
410
- maxFileSize?: number;
411
- staticDir?: string;
412
- staticURL?: string;
413
- adminThumbnail?: string;
414
- imageSizes?: {
415
- name: string;
416
- width?: number;
417
- height?: number;
418
- crop?: string;
419
- fit?: string;
420
- withoutEnlargement?: boolean;
421
- formatOptions?: Record<string, unknown>;
422
- }[];
423
- }
424
-
425
- declare const LIFECYCLE_EVENT_NAMES: readonly ["revision.created", "workflow.transitioned", "entry.published", "entry.unpublished"];
426
- type LifecycleEventName = (typeof LIFECYCLE_EVENT_NAMES)[number];
427
- interface WorkflowState {
428
- /** Stable machine-readable state key. */
429
- name: string;
430
- /** Label rendered in the Admin UI. */
431
- label: string;
432
- /** Marks the state whose revision is visible to public readers. */
433
- published?: boolean;
434
- /** Optional visual tone used by the Admin UI. */
435
- color?: "neutral" | "warning" | "success" | "danger" | "info";
436
- }
437
- interface WorkflowTransition {
438
- /** Stable transition key used by the REST and SDK APIs. */
439
- name: string;
440
- label: string;
441
- from: string | string[];
442
- to: string;
443
- /** Every listed capability is required. */
444
- requiredCapabilities?: string[];
445
- /** Require a non-empty comment when performing the transition. */
446
- requireComment?: boolean;
447
- /** Remove the public snapshot after this transition commits. */
448
- unpublish?: boolean;
449
- }
450
- interface WorkflowRole {
451
- /** Existing user role value, for example `editor` or `publisher`. */
452
- role: string;
453
- capabilities: string[];
454
- }
455
- interface WorkflowConfig<TDoc extends object = Record<string, unknown>> {
456
- initialState: string;
457
- /** State used for a new working revision created from published content. */
458
- draftState?: string;
459
- states: WorkflowState[];
460
- transitions: WorkflowTransition[];
461
- /** Maps values in `user.roles` to workflow capabilities. */
462
- roles?: WorkflowRole[];
463
- hooks?: {
464
- beforeTransition?: CollectionBeforeTransitionHook<TDoc>[];
465
- afterTransition?: CollectionAfterTransitionHook<TDoc>[];
466
- };
467
- }
468
- interface WorkflowMetadata {
469
- state: string;
470
- revision: number;
471
- publishedRevision?: number;
472
- publishedAt?: string;
473
- publishedBy?: string;
474
- /** Transitions currently allowed for the requesting user. Response-only. */
475
- availableTransitions?: string[];
476
- }
477
- interface WorkflowTransitionContext<TDoc extends object = Record<string, unknown>> {
478
- transition: WorkflowTransition;
479
- from: string;
480
- to: string;
481
- doc: TDoc;
482
- user?: AuthenticatedUser;
483
- comment?: string;
484
- req: HookRequestContext;
485
- db: DatabaseAdapter;
486
- }
487
- type CollectionBeforeTransitionHook<TDoc extends object = Record<string, unknown>> = (args: WorkflowTransitionContext<TDoc>) => void | Promise<void>;
488
- type CollectionAfterTransitionHook<TDoc extends object = Record<string, unknown>> = (args: WorkflowTransitionContext<TDoc> & {
489
- event: LifecycleEvent;
490
- }) => void | Promise<void>;
491
- interface LifecycleEvent<TPayload = Record<string, unknown>> {
492
- id: string;
493
- name: LifecycleEventName;
494
- collection: string;
495
- documentId: string;
496
- occurredAt: string;
497
- actorId?: string;
498
- payload: TPayload;
499
- attempts: number;
500
- status: "pending" | "processing" | "delivered" | "failed";
501
- nextAttemptAt?: string;
502
- deliveredAt?: string;
503
- lastError?: string;
504
- }
505
- type LifecycleEventHandler = (event: LifecycleEvent) => void | Promise<void>;
506
-
507
- /**
508
- * A hook that runs **before a field value is saved** to the database.
509
- *
510
- * Return the transformed value to persist. Return `undefined` to leave the
511
- * value unchanged (same as returning the original `value`).
512
- *
513
- * Field `beforeChange` hooks run recursively inside `array`, `object`, and
514
- * `blocks` fields — every nested item is processed automatically.
515
- *
516
- * @template TValue The TypeScript type of this field's value.
517
- * @template TDoc The document shape of the parent collection/global.
518
- *
519
- * @example
520
- * // Normalise email to lowercase
521
- * const normaliseEmail: FieldBeforeChangeHook<string> = ({ value }) =>
522
- * value?.toLowerCase().trim()
523
- *
524
- * @example
525
- * // Hash a password with bcrypt
526
- * const hashPassword: FieldBeforeChangeHook<string> = async ({ value }) =>
527
- * value ? bcrypt.hash(value, 10) : value
528
- */
529
- type FieldBeforeChangeHook<TValue = unknown, TDoc extends object = Record<string, unknown>> = (args: {
530
- /** The current value of this field (after any previous hooks in the chain). */
531
- value: TValue;
532
- /** The full document as it existed before this update. `undefined` on create. */
533
- originalDoc?: TDoc;
534
- /** The full incoming data payload being written. */
535
- data: Partial<TDoc>;
536
- /** The authenticated user, or `undefined` for unauthenticated requests. */
537
- user?: AuthenticatedUser;
538
- /**
539
- * Database adapter for cross-collection reads. Write operations (create,
540
- * update, delete) will throw — use `afterChange`/`afterDelete` for writes.
541
- */
542
- db: ReadonlyDatabaseAdapter;
543
- }) => TValue | undefined | Promise<TValue | undefined>;
544
- /**
545
- * A hook that runs **after a field value is read** from the database, before
546
- * the response is sent to the client.
547
- *
548
- * Return the transformed value to return to the client. Use this for masking,
549
- * formatting, or adding computed properties.
550
- *
551
- * @template TValue The TypeScript type of this field's value.
552
- * @template TDoc The document shape of the parent collection/global.
553
- *
554
- * @example
555
- * // Mask sensitive value for non-admins
556
- * const maskForPublic: FieldAfterReadHook<string> = ({ value, user }) =>
557
- * user?.role === 'admin' ? value : '••••••••'
558
- */
559
- type FieldAfterReadHook<TValue = unknown, TDoc extends object = Record<string, unknown>> = (args: {
560
- /** The raw field value as stored in the database. */
561
- value: TValue;
562
- /** The full document being returned (with defaults applied). */
563
- doc: TDoc;
564
- /** The authenticated user, or `undefined` for unauthenticated requests. */
565
- user?: AuthenticatedUser;
566
- /**
567
- * Database adapter for cross-collection reads. Write operations (create,
568
- * update, delete) will throw — use `afterChange`/`afterDelete` for writes.
569
- */
570
- db: ReadonlyDatabaseAdapter;
571
- }) => TValue | undefined | Promise<TValue | undefined>;
572
- /**
573
- * @deprecated Use {@link FieldBeforeChangeHook} or {@link FieldAfterReadHook} instead.
574
- * This alias remains for backwards compatibility.
575
- */
576
- type FieldHook<TDoc extends object = Record<string, unknown>, TValue = unknown> = FieldBeforeChangeHook<TValue, TDoc>;
577
- /**
578
- * Runs before Dyrected queries the database for a list or single-document fetch.
579
- *
580
- * Return a new `where` query object to override or extend the current filter.
581
- * Return `undefined` (or nothing) to leave the query unchanged.
582
- *
583
- * @example
584
- * // Scope all reads to the current user's own documents
585
- * const scopeToUser: CollectionBeforeReadHook = ({ user, query }) => ({
586
- * ...query,
587
- * owner: { equals: user?.sub },
588
- * })
589
- */
590
- type CollectionBeforeReadHook = (args: {
591
- /** The HTTP request context. */
592
- req: HookRequestContext;
593
- /** The current `where` query filter. Modify and return to override. */
594
- query?: Record<string, unknown>;
595
- /** The authenticated user, or `undefined` for unauthenticated requests. */
596
- user?: AuthenticatedUser;
597
- /**
598
- * Database adapter for cross-collection reads. Write operations (create,
599
- * update, delete) will throw — use `afterChange`/`afterDelete` for writes.
600
- */
601
- db: ReadonlyDatabaseAdapter;
602
- }) => Record<string, unknown> | void | Promise<Record<string, unknown> | void>;
603
- /**
604
- * Runs after a document (or list of documents) is fetched from the database,
605
- * before the response is sent to the client.
606
- *
607
- * Return a modified document to send instead. Useful for adding computed
608
- * virtual fields or transforming the shape of the response.
609
- *
610
- * @template TDoc The shape of the collection's document.
611
- *
612
- * @example
613
- * // Add a computed fullName field
614
- * const addFullName: CollectionAfterReadHook<User> = ({ doc }) => ({
615
- * ...doc,
616
- * fullName: `${doc.firstName} ${doc.lastName}`.trim(),
617
- * })
618
- */
619
- type CollectionAfterReadHook<TDoc extends object = Record<string, unknown>> = (args: {
620
- /** The document as fetched from the database (with defaults applied). */
621
- doc: TDoc;
622
- /** The HTTP request context. */
623
- req: HookRequestContext;
624
- /** The authenticated user, or `undefined` for unauthenticated requests. */
625
- user?: AuthenticatedUser;
626
- /**
627
- * Database adapter for cross-collection reads. Write operations (create,
628
- * update, delete) will throw — use `afterChange`/`afterDelete` for writes.
629
- */
630
- db: ReadonlyDatabaseAdapter;
631
- }) => TDoc | Promise<TDoc>;
632
- /**
633
- * Runs **before** a document is created or updated in the database.
634
- *
635
- * Return a modified data object to write instead of the original. This is the
636
- * right place for data transformation, normalisation, slug generation, and
637
- * validation (throw to abort the write).
638
- *
639
- * @template TDoc The shape of the collection's document.
640
- *
641
- * @example
642
- * // Auto-generate a slug on create
643
- * const generateSlug: CollectionBeforeChangeHook<Post> = ({ data, operation }) => {
644
- * if (operation === 'create' || data.title !== undefined) {
645
- * return { ...data, slug: slugify(data.title ?? '') }
646
- * }
647
- * return data
648
- * }
649
- *
650
- * @example
651
- * // Abort the write with a validation error
652
- * const validateStock: CollectionBeforeChangeHook<Product> = ({ data }) => {
653
- * if ((data.stock ?? 0) < 0) throw new Error('Stock cannot be negative.')
654
- * return data
655
- * }
656
- */
657
- type CollectionBeforeChangeHook<TDoc extends object = Record<string, unknown>> = (args: {
658
- /** The incoming data payload being written. */
659
- data: Partial<TDoc>;
660
- /**
661
- * The existing document before this update. Only present on `'update'`
662
- * operations; `undefined` on `'create'`.
663
- */
664
- doc?: TDoc;
665
- /** The HTTP request context. */
666
- req: HookRequestContext;
667
- /** The authenticated user, or `undefined` for unauthenticated requests. */
668
- user?: AuthenticatedUser;
669
- /** Whether this is a new document or an update to an existing one. */
670
- operation: "create" | "update";
671
- /**
672
- * Database adapter for cross-collection reads. Write operations (create,
673
- * update, delete) will throw — use `afterChange`/`afterDelete` for writes.
674
- */
675
- db: ReadonlyDatabaseAdapter;
676
- }) => Partial<TDoc> | void | Promise<Partial<TDoc> | void>;
677
- /**
678
- * Runs **after** a document is created or updated in the database.
679
- *
680
- * **Isolation**: errors thrown inside this hook are caught by the framework,
681
- * logged to the console, and then discarded. The HTTP response returns the
682
- * saved document as if nothing went wrong — because from the database's
683
- * perspective, nothing did. This means a transient email failure or webhook
684
- * timeout will never turn a successful write into a 500 for the caller.
685
- *
686
- * The return value is ignored — this hook is for side-effects only (emails,
687
- * webhooks, cache revalidation, search index updates, etc.).
688
- *
689
- * **Awaiting vs fire-and-forget**: `await`ing inside this hook is fine for
690
- * fast, reliable calls. For slow or unreliable external services prefer
691
- * fire-and-forget with your own `.catch()` so the response doesn't block:
692
- *
693
- * ```ts
694
- * // ✓ fast & reliable — safe to await
695
- * afterChange: [async ({ doc }) => {
696
- * await revalidatePath(`/posts/${doc.slug}`)
697
- * }]
698
- *
699
- * // ✓ slow or unreliable — fire-and-forget
700
- * afterChange: [({ doc }) => {
701
- * sendEmail({ to: doc.email, ... }).catch(console.error)
702
- * }]
703
- * ```
704
- *
705
- * @template TDoc The shape of the collection's document.
706
- *
707
- * @example
708
- * // Send a webhook after every save
709
- * const sendWebhook: CollectionAfterChangeHook<Post> = async ({ doc, operation }) => {
710
- * await fetch('https://hooks.example.com/content', {
711
- * method: 'POST',
712
- * body: JSON.stringify({ event: operation, doc }),
713
- * })
714
- * }
715
- *
716
- * @example
717
- * // Only act when a specific field changed
718
- * const onStatusChange: CollectionAfterChangeHook<Post> = async ({ doc, previousDoc, operation }) => {
719
- * if (operation === 'update' && doc.status !== previousDoc?.status) {
720
- * await notifySubscribers(doc)
721
- * }
722
- * }
723
- */
724
- type CollectionAfterChangeHook<TDoc extends object = Record<string, unknown>> = (args: {
725
- /** The document as it was written to the database. */
726
- doc: TDoc;
727
- /**
728
- * Snapshot of the document before the write. Only present on `'update'`
729
- * operations; `undefined` on `'create'`.
730
- */
731
- previousDoc?: TDoc;
732
- /** The HTTP request context. */
733
- req: HookRequestContext;
734
- /** The authenticated user, or `undefined` for unauthenticated requests. */
735
- user?: AuthenticatedUser;
736
- /** Whether this was a new document or an update. */
737
- operation: "create" | "update";
738
- /**
739
- * Database adapter with full read/write access. The DB write for this
740
- * operation has already committed — safe for side-effect writes.
741
- */
742
- db: DatabaseAdapter;
743
- }) => void | Promise<void>;
744
- /**
745
- * Runs **before** a document is deleted from the database.
746
- *
747
- * Throw an error to cancel the deletion — the document will not be removed
748
- * and the API will return a `500` with your error message.
749
- *
750
- * @template TDoc The shape of the collection's document.
751
- *
752
- * @example
753
- * // Prevent deletion when other documents reference this one
754
- * const guardReferences: CollectionBeforeDeleteHook<Category> = async ({ id, doc }) => {
755
- * const refs = await db.find({ collection: 'posts', where: { category: { equals: id } } })
756
- * if (refs.total > 0) throw new Error(`${refs.total} post(s) still reference this category.`)
757
- * }
758
- */
759
- type CollectionBeforeDeleteHook<TDoc extends object = Record<string, unknown>> = (args: {
760
- /** The ID of the document about to be deleted. */
761
- id: string;
762
- /** The full document about to be deleted. */
763
- doc: TDoc;
764
- /** The HTTP request context. */
765
- req: HookRequestContext;
766
- /** The authenticated user, or `undefined` for unauthenticated requests. */
767
- user?: AuthenticatedUser;
768
- /**
769
- * Database adapter for cross-collection reads. Write operations (create,
770
- * update, delete) will throw — use `afterDelete` for post-deletion writes.
771
- */
772
- db: ReadonlyDatabaseAdapter;
773
- }) => void | Promise<void>;
774
- /**
775
- * Runs **after** a document has been deleted from the database.
776
- *
777
- * **Isolation**: same as {@link CollectionAfterChangeHook} — errors are caught,
778
- * logged, and discarded. The deletion is already committed; a hook failure will
779
- * never cause the deleted ID to appear in the `failed` list of a bulk delete or
780
- * turn a successful single delete into a 500.
781
- *
782
- * Use for cleanup side-effects — removing related media, invalidating caches,
783
- * notifying downstream services, etc.
784
- *
785
- * @template TDoc The shape of the collection's document.
786
- */
787
- type CollectionAfterDeleteHook<TDoc extends object = Record<string, unknown>> = (args: {
788
- /** The ID of the deleted document. */
789
- id: string;
790
- /** The document as it was just before deletion. */
791
- doc: TDoc;
792
- /** The HTTP request context. */
793
- req: HookRequestContext;
794
- /** The authenticated user, or `undefined` for unauthenticated requests. */
795
- user?: AuthenticatedUser;
796
- /**
797
- * Database adapter with full read/write access. The deletion has already
798
- * committed — safe for cascade deletes or cleanup writes.
799
- */
800
- db: DatabaseAdapter;
801
- }) => void | Promise<void>;
802
- /** @see {@link CollectionBeforeReadHook} */
803
- type GlobalBeforeReadHook = CollectionBeforeReadHook;
804
- /**
805
- * Runs after the global document is fetched, before the response is sent.
806
- * @see {@link CollectionAfterReadHook}
807
- */
808
- type GlobalAfterReadHook<TDoc extends object = Record<string, unknown>> = (args: {
809
- doc: TDoc;
810
- req: HookRequestContext;
811
- user?: AuthenticatedUser;
812
- /**
813
- * Database adapter for cross-collection reads. Write operations (create,
814
- * update, delete) will throw — use `afterChange` for writes.
815
- */
816
- db: ReadonlyDatabaseAdapter;
817
- }) => TDoc | Promise<TDoc>;
818
- /**
819
- * Runs before the global document is updated.
820
- * Operation is always `'update'` (globals cannot be created or deleted).
821
- * @see {@link CollectionBeforeChangeHook}
822
- */
823
- type GlobalBeforeChangeHook<TDoc extends object = Record<string, unknown>> = (args: {
824
- data: Partial<TDoc>;
825
- doc?: TDoc;
826
- req: HookRequestContext;
827
- user?: AuthenticatedUser;
828
- operation: "update";
829
- /**
830
- * Database adapter for cross-collection reads. Write operations (create,
831
- * update, delete) will throw — use `afterChange` for writes.
832
- */
833
- db: ReadonlyDatabaseAdapter;
834
- }) => Partial<TDoc> | void | Promise<Partial<TDoc> | void>;
835
- /**
836
- * Runs after the global document is updated. Side-effects only.
837
- *
838
- * **Isolation**: errors are caught, logged, and discarded — same behaviour as
839
- * {@link CollectionAfterChangeHook}. The update is already committed.
840
- *
841
- * @see {@link CollectionAfterChangeHook}
842
- */
843
- type GlobalAfterChangeHook<TDoc extends object = Record<string, unknown>> = (args: {
844
- doc: TDoc;
845
- previousDoc?: TDoc;
846
- req: HookRequestContext;
847
- user?: AuthenticatedUser;
848
- operation: "update";
849
- /**
850
- * Database adapter with full read/write access. The DB write for this
851
- * operation has already committed — safe for side-effect writes.
852
- */
853
- db: DatabaseAdapter;
854
- }) => void | Promise<void>;
855
- /**
856
- * @deprecated Use the specific hook types instead:
857
- * {@link CollectionBeforeChangeHook}, {@link CollectionAfterReadHook}, etc.
858
- *
859
- * This broad type remains for backwards compatibility with the internal hook runner.
860
- */
861
- type HookFunction<TDoc extends object = Record<string, unknown>> = (args: {
862
- data?: Partial<TDoc>;
863
- doc?: TDoc;
864
- user?: AuthenticatedUser;
865
- req?: HookRequestContext;
866
- operation?: "create" | "update" | "delete";
867
- db?: DatabaseAdapter;
868
- [key: string]: unknown;
869
- }) => unknown | Promise<unknown>;
870
- /**
871
- * A function that determines whether the current user can perform an operation.
872
- *
873
- * Return `true` to allow, `false` to deny.
874
- * Return a `where`-style object to allow access only to matching documents
875
- * (useful for multi-tenant setups where users can only see their own data).
876
- *
877
- * Can also be expressed as a Jexl expression **string** for simple role checks
878
- * that need to be serialised (e.g. stored in the database or sent to the Admin UI).
879
- *
880
- * @template TDoc The shape of the collection's document.
881
- *
882
- * @example
883
- * // Simple role check
884
- * access: {
885
- * delete: ({ user }) => user?.roles?.includes('admin') ?? false,
886
- * }
887
- *
888
- * @example
889
- * // Row-level: users can only read their own documents
890
- * access: {
891
- * read: ({ user }) => ({ owner: { equals: user?.sub } }),
892
- * }
893
- *
894
- * @example
895
- * // Jexl string — evaluated server-side
896
- * access: {
897
- * update: "user.roles contains 'editor'",
898
- * }
899
- */
900
- type AccessFunction<TDoc extends object = Record<string, unknown>> = (args: {
901
- user: AuthenticatedUser | undefined;
902
- doc?: TDoc;
903
- data?: Partial<TDoc>;
904
- req: HookRequestContext;
905
- }) => boolean | Record<string, unknown> | Promise<boolean | Record<string, unknown>>;
906
- /**
907
- * Defines a Dyrected collection — a named set of documents with a shared schema.
908
- *
909
- * Pass your document's TypeScript type as the generic parameter `TDoc` to get
910
- * fully typed hooks and access functions:
911
- *
912
- * ```ts
913
- * interface Post {
914
- * id: string
915
- * title: string
916
- * slug: string
917
- * status: 'draft' | 'published'
918
- * publishedAt?: string
919
- * }
920
- *
921
- * export const Posts = defineCollection<Post>({
922
- * slug: 'posts',
923
- * hooks: {
924
- * beforeChange: [({ data, operation }) => {
925
- * // `data` is typed as Partial<Post>
926
- * if (operation === 'create') return { ...data, status: 'draft' }
927
- * return data
928
- * }],
929
- * afterChange: [({ doc, previousDoc }) => {
930
- * // `doc` and `previousDoc` are typed as Post
931
- * if (doc.status !== previousDoc?.status) notifySubscribers(doc)
932
- * }],
933
- * },
934
- * fields: [...],
935
- * })
936
- * ```
937
- *
938
- * @template TDoc The TypeScript shape of a document in this collection.
939
- * Defaults to `Record<string, unknown>` for untyped usage.
940
- */
941
- interface CollectionConfig<TDoc extends object = Record<string, unknown>> {
942
- /**
943
- * Unique identifier for this collection.
944
- * Used as the URL segment (`/api/collections/:slug`) and the database table/collection name.
945
- * Use kebab-case, e.g. `'blog-posts'`.
946
- */
947
- slug: string;
948
- /**
949
- * Restricts this collection to a specific site in a multi-tenant deployment.
950
- * When set, only requests bearing a matching `X-Site-Id` header can access it.
951
- */
952
- siteId?: string;
953
- /**
954
- * If `true`, this collection is shared across all sites in a multi-tenant
955
- * deployment and accessible regardless of the `X-Site-Id` header.
956
- */
957
- shared?: boolean;
958
- /** Human-readable names for documents in this collection, shown in the Admin UI. */
959
- labels?: {
960
- singular: string;
961
- plural: string;
962
- };
963
- /**
964
- * If `true`, this collection is an **auth collection** — it gains
965
- * `POST /api/collections/:slug/login` and `POST /api/collections/:slug/logout`
966
- * endpoints, and documents are expected to have a `password` field.
967
- */
968
- auth?: boolean;
969
- /**
970
- * If `true` (or a config object), this collection supports **file uploads**.
971
- * Documents gain file-related fields (`url`, `filename`, `mimeType`, etc.)
972
- * and the create endpoint accepts `multipart/form-data`.
973
- */
974
- upload?: boolean | UploadConfig;
975
- /** Field definitions that make up the document schema for this collection. */
976
- fields: Field[];
977
- /**
978
- * If `true`, Dyrected automatically adds `createdAt` and `updatedAt`
979
- * timestamp fields to every document. Defaults to `true`.
980
- */
981
- timestamps?: boolean;
982
- /**
983
- * Initial documents to seed into this collection the first time it is
984
- * fetched and found to be empty (e.g. for demo data or defaults).
985
- */
986
- initialData?: Partial<TDoc>[];
987
- /**
988
- * If `true`, every create, update, and delete operation on this collection
989
- * is logged to the `__audit` collection with before/after snapshots and the
990
- * acting user's identity.
991
- */
992
- audit?: boolean;
993
- /**
994
- * Optional state-machine workflow for this collection. Workflow-enabled
995
- * entries keep an editable working revision and an independent public
996
- * snapshot, so editing published content never changes the live response.
997
- */
998
- workflow?: WorkflowConfig<TDoc>;
999
- /**
1000
- * Collection-level access control.
1001
- *
1002
- * Each key is an operation; the value is a function (or Jexl string) that
1003
- * returns `true` to allow or `false` to deny. Returning a `where`-style
1004
- * object grants access only to matching documents.
1005
- *
1006
- * @example
1007
- * access: {
1008
- * read: () => true, // public read
1009
- * create: ({ user }) => !!user, // logged-in users only
1010
- * update: ({ user }) => user?.roles?.includes('editor') ?? false,
1011
- * delete: ({ user }) => user?.roles?.includes('admin') ?? false,
1012
- * }
1013
- */
1014
- access?: {
1015
- read?: AccessFunction<TDoc> | string;
1016
- create?: AccessFunction<TDoc> | string;
1017
- update?: AccessFunction<TDoc> | string;
1018
- delete?: AccessFunction<TDoc> | string;
1019
- };
1020
- /**
1021
- * Collection-level lifecycle hooks.
1022
- *
1023
- * Hooks run in the order they appear in the array. The return value of each
1024
- * hook is passed as the input to the next. Throwing inside any hook aborts
1025
- * the operation and returns a `500` error.
1026
- *
1027
- * See the [Hooks reference](/docs/concepts/hooks) for the full lifecycle diagram.
1028
- */
1029
- hooks?: {
1030
- /**
1031
- * Runs before the database is queried. Return a modified `where` object
1032
- * to override the query filter.
1033
- */
1034
- beforeRead?: CollectionBeforeReadHook[];
1035
- /**
1036
- * Runs after documents are fetched. Return a modified doc to change what
1037
- * the client receives. Runs on every document in a list response.
1038
- */
1039
- afterRead?: CollectionAfterReadHook<TDoc>[];
1040
- /**
1041
- * Runs before create or update. Return modified data to change what is
1042
- * written to the database. Throw to abort the write entirely.
1043
- */
1044
- beforeChange?: CollectionBeforeChangeHook<TDoc>[];
1045
- /**
1046
- * Runs after create or update is committed. For side-effects only —
1047
- * webhooks, cache busting, notifications. Return value is ignored.
1048
- *
1049
- * Errors are **isolated**: caught, logged, and discarded so a failing
1050
- * side-effect never turns a successful write into an HTTP 500.
1051
- * See {@link CollectionAfterChangeHook} for the await-vs-fire-and-forget guidance.
1052
- */
1053
- afterChange?: CollectionAfterChangeHook<TDoc>[];
1054
- /**
1055
- * Runs before a document is deleted. Throw to cancel the deletion.
1056
- */
1057
- beforeDelete?: CollectionBeforeDeleteHook<TDoc>[];
1058
- /**
1059
- * Runs after a document has been deleted. For cleanup side-effects only.
1060
- *
1061
- * Errors are **isolated**: caught, logged, and discarded — the deletion is
1062
- * already committed and will not be undone.
1063
- */
1064
- afterDelete?: CollectionAfterDeleteHook<TDoc>[];
1065
- };
1066
- /** Admin UI configuration for this collection. */
1067
- admin?: {
1068
- /**
1069
- * Lucide icon displayed beside this collection in the Admin sidebar.
1070
- * Uses Lucide component names, e.g. `'Newspaper'` or `'ShoppingBag'`.
1071
- */
1072
- icon?: AdminIconName;
1073
- /** Custom component slots for this collection's list view. */
1074
- components?: CollectionListComponentSlots;
1075
- /**
1076
- * The field name used as the document's display title in the Admin list
1077
- * view and breadcrumbs. Defaults to `'title'` if the field exists.
1078
- */
1079
- useAsTitle?: string;
1080
- /**
1081
- * Field names to show as columns in the Admin list view.
1082
- * Defaults to a sensible set of the first few non-structural fields.
1083
- */
1084
- defaultColumns?: string[];
1085
- /**
1086
- * Groups this collection under a named section in the Admin sidebar.
1087
- * Collections with the same `group` are visually grouped together.
1088
- */
1089
- group?: string;
1090
- /** If `true`, this collection is not shown in the Admin UI sidebar. */
1091
- hidden?: boolean;
1092
- /** If `false`, disables the filter UI entirely for this collection. Defaults to `true`. */
1093
- filterable?: boolean;
1094
- /**
1095
- * URL to open in the Live Preview pane when editing a document.
1096
- * Pass a function to derive the URL from the document's fields.
1097
- *
1098
- * @example
1099
- * previewUrl: (doc) => `https://mysite.com/blog/${doc.slug}`
1100
- */
1101
- previewUrl?: string | ((doc: TDoc, opts: {
1102
- locale?: string;
1103
- }) => string | null);
1104
- /**
1105
- * How the Live Preview pane communicates with the frontend.
1106
- * - `'postMessage'` (default) — sends a `postMessage` with the current doc data.
1107
- * - `'token'` — passes a short-lived preview token as a query parameter.
1108
- */
1109
- previewMode?: "postMessage" | "token";
1110
- /**
1111
- * Frontend URL pattern for this collection, used by `url` fields to
1112
- * resolve internal links. Use `{fieldName}` placeholders.
1113
- *
1114
- * @example
1115
- * urlPattern: '/blog/{slug}' // → /blog/my-post
1116
- * urlPattern: '/{slug}' // → /about
1117
- */
1118
- urlPattern?: string;
1119
- };
1120
- }
1121
- /**
1122
- * Defines a Dyrected global — a singleton document without pagination or IDs.
1123
- *
1124
- * Globals are ideal for site-wide settings, feature flags, or any data where
1125
- * there is always exactly one record (e.g. `site-settings`, `navigation`, `theme`).
1126
- *
1127
- * Pass your document's TypeScript type as the generic parameter `TDoc` to get
1128
- * fully typed hooks:
1129
- *
1130
- * ```ts
1131
- * interface SiteSettings {
1132
- * siteName: string
1133
- * tagline: string
1134
- * maintenanceMode: boolean
1135
- * }
1136
- *
1137
- * export const Settings = defineGlobal<SiteSettings>({
1138
- * slug: 'site-settings',
1139
- * hooks: {
1140
- * afterChange: [({ doc }) => {
1141
- * // `doc` is typed as SiteSettings
1142
- * if (doc.maintenanceMode) alertOnCall()
1143
- * }],
1144
- * },
1145
- * fields: [...],
1146
- * })
1147
- * ```
1148
- *
1149
- * @template TDoc The TypeScript shape of this global's document.
1150
- */
1151
- interface GlobalConfig<TDoc extends object = Record<string, unknown>> {
1152
- /**
1153
- * Unique identifier for this global.
1154
- * Used as the URL segment (`/api/globals/:slug`) and the storage key.
1155
- */
1156
- slug: string;
1157
- /** Restricts this global to a specific site in a multi-tenant deployment. */
1158
- siteId?: string;
1159
- /**
1160
- * If `true`, this global is shared across all sites in a multi-tenant
1161
- * deployment.
1162
- */
1163
- shared?: boolean;
1164
- /** Human-readable label shown in the Admin UI sidebar. */
1165
- label?: string;
1166
- /** Field definitions for this global's document schema. */
1167
- fields: Field[];
1168
- /** Access control for reading and updating this global. */
1169
- access?: {
1170
- read?: AccessFunction<TDoc>;
1171
- update?: AccessFunction<TDoc>;
1172
- };
1173
- /**
1174
- * Global-level lifecycle hooks.
1175
- * Globals support `beforeRead`, `afterRead`, `beforeChange`, and `afterChange`.
1176
- * There are no delete hooks since globals cannot be deleted.
1177
- */
1178
- hooks?: {
1179
- beforeRead?: GlobalBeforeReadHook[];
1180
- afterRead?: GlobalAfterReadHook<TDoc>[];
1181
- beforeChange?: GlobalBeforeChangeHook<TDoc>[];
1182
- afterChange?: GlobalAfterChangeHook<TDoc>[];
1183
- };
1184
- /** Admin UI configuration for this global. */
1185
- admin?: {
1186
- /**
1187
- * Lucide icon displayed beside this global in the Admin sidebar.
1188
- * Uses Lucide component names, e.g. `'Settings2'` or `'Palette'`.
1189
- */
1190
- icon?: AdminIconName;
1191
- /** Groups this global under a named section in the Admin sidebar. */
1192
- group?: string;
1193
- /** If `true`, this global is not shown in the Admin UI sidebar. */
1194
- hidden?: boolean;
1195
- };
1196
- /**
1197
- * Initial data to seed this global with the first time it is fetched and
1198
- * found to be empty.
1199
- */
1200
- initialData?: Partial<TDoc>;
1201
- }
1202
- /**
1203
- * The interface every database adapter must implement.
1204
- *
1205
- * Dyrected ships adapters for PostgreSQL, MySQL, SQLite, and MongoDB.
1206
- * Implement this interface to connect any other database.
1207
- */
1208
- interface DatabaseAdapter {
1209
- /** Find a paginated list of documents in a collection. */
1210
- find(args: {
1211
- collection: string;
1212
- where?: Record<string, unknown>;
1213
- limit?: number;
1214
- page?: number;
1215
- sort?: string;
1216
- }): Promise<PaginatedResult>;
1217
- /** Find a single document by its ID. Returns `null` if not found. */
1218
- findOne(args: {
1219
- collection: string;
1220
- id: string;
1221
- }): Promise<BaseDocument | null>;
1222
- /** Insert a new document and return it with its generated `id`. */
1223
- create(args: {
1224
- collection: string;
1225
- data: Record<string, unknown>;
1226
- }): Promise<BaseDocument>;
1227
- /** Update a document by ID and return the updated document. */
1228
- update(args: {
1229
- collection: string;
1230
- id: string;
1231
- data: Record<string, unknown>;
1232
- }): Promise<BaseDocument>;
1233
- /** Delete a document by ID. Return value is intentionally untyped — callers do not use it. */
1234
- delete(args: {
1235
- collection: string;
1236
- id: string;
1237
- }): Promise<unknown>;
1238
- /** Fetch the singleton document for a global. Returns an empty object if not yet initialised. */
1239
- getGlobal(args: {
1240
- slug: string;
1241
- }): Promise<Record<string, unknown>>;
1242
- /** Create or replace the singleton document for a global. */
1243
- updateGlobal(args: {
1244
- slug: string;
1245
- data: Record<string, unknown>;
1246
- }): Promise<Record<string, unknown>>;
1247
- /**
1248
- * Sync the database schema with the current collection and global configs.
1249
- * Called on startup to create tables/collections that don't exist yet.
1250
- * Not all adapters implement this (e.g. MongoDB is schema-less).
1251
- */
1252
- sync?(collections: CollectionConfig[], globals: GlobalConfig[]): Promise<void>;
1253
- /**
1254
- * Execute a raw SQL query or database command.
1255
- * Optional — not all adapters support raw access.
1256
- */
1257
- execute?(query: string, params?: unknown[]): Promise<unknown>;
1258
- /**
1259
- * Run all adapter operations in `callback` as one atomic transaction.
1260
- * Shipped adapters implement this; workflow transitions require it.
1261
- */
1262
- transaction?<T>(callback: (db: DatabaseAdapter) => Promise<T>): Promise<T>;
1263
- }
1264
- /**
1265
- * Read-only view of the database adapter. Exposes only `find`, `findOne`,
1266
- * and `getGlobal` — no write operations.
1267
- *
1268
- * Passed to `beforeChange`, `beforeDelete`, `beforeRead`, `afterRead`,
1269
- * and field-level hooks. Write operations are available in `afterChange`
1270
- * and `afterDelete` hooks where the full {@link DatabaseAdapter} is provided.
1271
- */
1272
- type ReadonlyDatabaseAdapter = Pick<DatabaseAdapter, "find" | "findOne" | "getGlobal">;
1273
- /**
1274
- * The interface every storage adapter must implement.
1275
- *
1276
- * Dyrected ships adapters for local disk, S3, Cloudflare R2, Cloudinary, and
1277
- * Backblaze B2. Implement this interface to use any other storage provider.
1278
- */
1279
- interface StorageAdapter {
1280
- /**
1281
- * Upload a file and return its metadata (URL, dimensions, etc.).
1282
- * The `prefix` is a path prefix used for multi-tenant setups.
1283
- */
1284
- upload(args: {
1285
- filename: string;
1286
- buffer: Uint8Array;
1287
- mimeType: string;
1288
- prefix?: string;
1289
- }): Promise<FileData>;
1290
- /** Delete a file by its stored filename. */
1291
- delete(args: {
1292
- filename: string;
1293
- }): Promise<void>;
1294
- /** Return the public URL for a stored file. */
1295
- getURL(args: {
1296
- filename: string;
1297
- }): string;
1298
- /**
1299
- * Retrieve the file's raw bytes and MIME type for serving via the API.
1300
- * Only needed by adapters that serve files through the Dyrected API
1301
- * (e.g. `LocalStorage`). Cloud adapters return `null` here and rely on
1302
- * direct CDN URLs instead.
1303
- */
1304
- resolve?(args: {
1305
- filename: string;
1306
- }): Promise<{
1307
- buffer: Uint8Array;
1308
- mimeType: string;
1309
- } | null>;
1310
- }
1311
- /**
1312
- * Processes uploaded images — generates metadata (dimensions, BlurHash) and
1313
- * produces resized variants defined in `UploadConfig.imageSizes`.
1314
- *
1315
- * @example
1316
- * import { SharpImageService } from '@dyrected/image-sharp'
1317
- * defineConfig({ image: new SharpImageService(), ... })
1318
- */
1319
- interface ImageService {
1320
- process(args: {
1321
- buffer: Uint8Array;
1322
- mimeType: string;
1323
- config?: boolean | UploadConfig;
1324
- focalPoint?: {
1325
- x: number;
1326
- y: number;
1327
- };
1328
- }): Promise<{
1329
- metadata: {
1330
- width?: number;
1331
- height?: number;
1332
- /** Base64-encoded BlurHash for progressive loading. */
1333
- blurhash?: string;
1334
- };
1335
- /** Generated image sizes keyed by their `name`. */
1336
- sizes?: Record<string, {
1337
- buffer: Uint8Array;
1338
- width: number;
1339
- height: number;
1340
- filename: string;
1341
- }>;
1342
- }>;
1343
- }
1344
- /**
1345
- * The root configuration object passed to `createDyrectedApp`.
1346
- *
1347
- * This is the single source of truth for your entire Dyrected instance —
1348
- * collections, globals, database adapter, storage, email, and more.
1349
- *
1350
- * @example
1351
- * import { defineConfig } from '@dyrected/core'
1352
- * import { SQLiteAdapter } from '@dyrected/db-sqlite'
1353
- *
1354
- * export default defineConfig({
1355
- * db: new SQLiteAdapter({ filename: './db.sqlite' }),
1356
- * collections: [Posts, Users],
1357
- * globals: [SiteSettings],
1358
- * })
1359
- */
1360
- interface DyrectedConfig {
1361
- /** Collection definitions. Each collection maps to a database table/collection. */
1362
- collections: CollectionConfig<any>[];
1363
- /** Global (singleton) definitions. Each global maps to a single document. */
1364
- globals: GlobalConfig<any>[];
1365
- /**
1366
- * The database adapter. Required for all data operations.
1367
- * @see {@link DatabaseAdapter}
1368
- */
1369
- db?: DatabaseAdapter;
1370
- /**
1371
- * The storage adapter for file uploads.
1372
- * Required when any collection has `upload: true`.
1373
- * @see {@link StorageAdapter}
1374
- */
1375
- storage?: StorageAdapter;
1376
- /**
1377
- * The image processing service. Required when any upload collection
1378
- * defines `imageSizes`.
1379
- * @see {@link ImageService}
1380
- */
1381
- image?: ImageService;
1382
- /** Admin UI branding and metadata. */
1383
- admin?: AdminConfig;
1384
- /**
1385
- * Deployment-level authentication strategy for the CMS dashboard (`/admin`).
1386
- * This is separate from collection-level `auth: true`, which continues to
1387
- * power application/customer auth independently.
1388
- */
1389
- adminAuth?: AdminAuthConfig;
1390
- /**
1391
- * Email transport configuration. Required for welcome emails, password
1392
- * resets, and invite links.
1393
- *
1394
- * @example
1395
- * email: {
1396
- * from: 'no-reply@myapp.com',
1397
- * send: async ({ to, subject, html }) => {
1398
- * await resend.emails.send({ from, to, subject, html })
1399
- * },
1400
- * }
1401
- */
1402
- email?: {
1403
- /** The `From` address for all outbound emails. */
1404
- from: string;
1405
- /** The send function. Wire in any email provider (Resend, SendGrid, SES, etc.). */
1406
- send: (args: {
1407
- to: string;
1408
- subject: string;
1409
- html: string;
1410
- }) => Promise<void>;
1411
- /** Override the default email templates. */
1412
- templates?: {
1413
- welcome?: (args: {
1414
- email: string;
1415
- }) => {
1416
- subject?: string;
1417
- html: string;
1418
- };
1419
- invite?: (args: {
1420
- token: string;
1421
- invitedByEmail?: string;
1422
- }) => {
1423
- subject?: string;
1424
- html: string;
1425
- };
1426
- resetPassword?: (args: {
1427
- token: string;
1428
- url?: string;
1429
- }) => {
1430
- subject?: string;
1431
- html: string;
1432
- };
1433
- passwordChanged?: (args: {
1434
- email: string;
1435
- }) => {
1436
- subject?: string;
1437
- html: string;
1438
- };
1439
- };
1440
- };
1441
- /**
1442
- * Redis connection URL. Required for distributed caching of dynamic option
1443
- * resolvers and other server-side caches in multi-instance deployments.
1444
- *
1445
- * @example
1446
- * redis: { url: process.env.REDIS_URL }
1447
- */
1448
- redis?: {
1449
- url: string;
1450
- };
1451
- /** Durable lifecycle-event delivery configuration. */
1452
- events?: {
1453
- handlers: LifecycleEventHandler[];
1454
- /** Maximum delivery attempts before an event remains failed. Defaults to 8. */
1455
- maxAttempts?: number;
1456
- /** Initial exponential-backoff delay in milliseconds. Defaults to 1000. */
1457
- retryDelayMs?: number;
1458
- };
1459
- /**
1460
- * Cross-Origin Resource Sharing (CORS) configuration.
1461
- * List all origins that are allowed to call the Dyrected API.
1462
- *
1463
- * @example
1464
- * cors: { origins: ['https://myapp.com', 'https://www.myapp.com'] }
1465
- */
1466
- cors?: {
1467
- origins: string[];
1468
- };
1469
- /**
1470
- * Callback to dynamically fetch additional collections and globals for a
1471
- * given site ID at request time. Used in multi-tenant deployments where each
1472
- * site has its own schema stored in the database.
1473
- *
1474
- * @param siteId The `X-Site-Id` header value from the incoming request.
1475
- * @returns Extra collections and globals to merge into the config for this request.
1476
- *
1477
- * @example
1478
- * onSchemaFetch: async (siteId) => {
1479
- * const site = await db.findOne({ collection: 'sites', id: siteId })
1480
- * return buildSchemaFromSiteConfig(site)
1481
- * }
1482
- */
1483
- onSchemaFetch?: (siteId: string) => Promise<{
1484
- collections?: CollectionConfig<any>[];
1485
- globals?: GlobalConfig<any>[];
1486
- admin?: AdminConfig;
1487
- adminAuth?: AdminAuthConfig;
1488
- }>;
1489
- }
1490
-
1491
- export { type FieldBeforeChangeHook as $, type AdminAuthConfig as A, type Block as B, type CollectionConfig as C, type DyrectedConfig as D, type CollectionListComponentSlots as E, type Field as F, type GlobalConfig as G, type HookRequestContext as H, type CustomAdminAuthProvider as I, type DatabaseAdapter as J, type DateField as K, type LifecycleEventName as L, type DateTimeField as M, type DynamicOptionItem as N, type DynamicOptionsConfig as O, type PublicAdminAuthConfig as P, type DynamicOptionsResolver as Q, type DynamicOptionsResolverArgs as R, type EmailField as S, type FieldAdminOnChangeHook as T, type FieldAdminOnChangeHookArgs as U, type FieldAdminOptionsHook as V, type WorkflowConfig as W, type FieldAdminOptionsHookArgs as X, type FieldAdminOptionsHookResult as Y, type FieldAfterReadHook as Z, type FieldAfterReadHookArgs as _, type AuthenticatedUser as a, type FieldBeforeChangeHookArgs as a0, type FieldHook as a1, type FieldType as a2, type FileData as a3, type GlobalAfterChangeHook as a4, type GlobalAfterReadHook as a5, type GlobalBeforeChangeHook as a6, type GlobalBeforeReadHook as a7, type HookFunction as a8, type IconField as a9, type WorkflowState as aA, type WorkflowTransitionContext as aB, type ImageField as aa, type ImageService as ab, type JoinField as ac, type JsonField as ad, LIFECYCLE_EVENT_NAMES as ae, type LifecycleEventHandler as af, type MultiSelectField as ag, type NumberField as ah, type OIDCAdminAuthProvider as ai, type ObjectField as aj, type PaginatedResult as ak, type PublicAdminAuthProvider as al, type RadioField as am, type ReadonlyDatabaseAdapter as an, type RelationshipField as ao, type RichTextField as ap, type RowField as aq, type SelectField as ar, type StorageAdapter as as, type TextField as at, type TextareaField as au, type TimeField as av, type UploadConfig as aw, type UrlField as ax, type WorkflowMetadata as ay, type WorkflowRole as az, type WorkflowTransition as b, type LifecycleEvent as c, type BaseDocument as d, type AccessFunction as e, type AdminAuthAccessResolution as f, type AdminAuthClaimMapping as g, type AdminAuthProvider as h, type AdminAuthProvisioningMode as i, type AdminAuthResolveAccessArgs as j, type AdminAuthResolvedIdentity as k, type AdminConfig as l, type AdminDashboardComponentSlots as m, type AdminIconName as n, type ArrayField as o, type BaseAdminAuthProvider as p, type BlocksField as q, type BooleanField as r, type CollectionAfterChangeHook as s, type CollectionAfterDeleteHook as t, type CollectionAfterReadHook as u, type CollectionAfterTransitionHook as v, type CollectionBeforeChangeHook as w, type CollectionBeforeDeleteHook as x, type CollectionBeforeReadHook as y, type CollectionBeforeTransitionHook as z };