@dyrected/core 2.5.52 → 2.5.55

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-DqCipvSI.d.cts} +1 -1
  2. package/dist/{app-config-oOarB6Fw.d.ts → app-config-DqCipvSI.d.ts} +1 -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,1467 +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?: {
302
- placeholder?: string;
303
- component?: string;
304
- description?: string;
305
- hidden?: boolean;
306
- filterable?: boolean;
307
- readOnly?: boolean;
308
- condition?: ((data: Record<string, unknown>, siblingData: Record<string, unknown>) => boolean) | string;
309
- layout?: "checkbox" | "switch" | "radio" | "select" | string;
310
- direction?: "horizontal" | "vertical";
311
- tab?: string;
312
- width?: string;
313
- hooks?: {
314
- options?: (args: {
315
- siblingData: Record<string, unknown>;
316
- data: Record<string, unknown>;
317
- }) => Array<string | {
318
- label: string;
319
- value: unknown;
320
- }> | Promise<Array<string | {
321
- label: string;
322
- value: unknown;
323
- }>>;
324
- };
325
- };
326
- renameTo?: string;
327
- promoted?: boolean;
328
- }
329
- type FieldHooks<TValue> = {
330
- hooks?: {
331
- beforeChange?: Array<(args: {
332
- value: TValue;
333
- originalDoc?: Record<string, unknown>;
334
- data: Record<string, unknown>;
335
- user?: AuthenticatedUser;
336
- db: ReadonlyDatabaseAdapter;
337
- }) => unknown>;
338
- afterRead?: Array<(args: {
339
- value: TValue;
340
- doc: Record<string, unknown>;
341
- user?: AuthenticatedUser;
342
- db: ReadonlyDatabaseAdapter;
343
- }) => unknown>;
344
- };
345
- };
346
- type FieldAdminHooks<TValue> = {
347
- admin?: {
348
- hooks?: {
349
- onChange?: (args: {
350
- value: TValue;
351
- siblingData: Record<string, unknown>;
352
- data: Record<string, unknown>;
353
- setValue: (value: unknown) => void;
354
- }) => unknown;
355
- };
356
- };
357
- };
358
- type TypedField<TType extends FieldType, TValue> = FieldBase & {
359
- type: TType;
360
- } & FieldHooks<TValue> & FieldAdminHooks<TValue>;
361
- type TextField = TypedField<"text", string>;
362
- type TextareaField = TypedField<"textarea", string>;
363
- type EmailField = TypedField<"email", string>;
364
- type UrlField = TypedField<"url", string>;
365
- type IconField = TypedField<"icon", string>;
366
- type DateField = TypedField<"date", string>;
367
- type DateTimeField = TypedField<"datetime", string>;
368
- type TimeField = TypedField<"time", string>;
369
- type SelectField = TypedField<"select", string>;
370
- type RadioField = TypedField<"radio", string>;
371
- type NumberField = TypedField<"number", number>;
372
- type BooleanField = TypedField<"boolean", boolean>;
373
- type MultiSelectField = TypedField<"multiSelect", string[]>;
374
- type RelationshipField = TypedField<"relationship", string | string[]>;
375
- type ImageField = TypedField<"image", string | string[]>;
376
- type RichTextField = TypedField<"richText", Record<string, unknown>>;
377
- type JsonField = TypedField<"json", Record<string, unknown>>;
378
- type ObjectField = TypedField<"object", unknown>;
379
- type ArrayField = TypedField<"array", unknown>;
380
- type BlocksField = TypedField<"blocks", unknown>;
381
- type JoinField = TypedField<"join", unknown>;
382
- type RowField = TypedField<"row", unknown>;
383
- type Field = TextField | TextareaField | EmailField | UrlField | IconField | DateField | DateTimeField | TimeField | SelectField | RadioField | NumberField | BooleanField | MultiSelectField | RelationshipField | ImageField | RichTextField | JsonField | ObjectField | ArrayField | BlocksField | JoinField | RowField;
384
- interface UploadConfig {
385
- allowedMimeTypes?: string[];
386
- maxFileSize?: number;
387
- staticDir?: string;
388
- staticURL?: string;
389
- adminThumbnail?: string;
390
- imageSizes?: {
391
- name: string;
392
- width?: number;
393
- height?: number;
394
- crop?: string;
395
- fit?: string;
396
- withoutEnlargement?: boolean;
397
- formatOptions?: Record<string, unknown>;
398
- }[];
399
- }
400
-
401
- declare const LIFECYCLE_EVENT_NAMES: readonly ["revision.created", "workflow.transitioned", "entry.published", "entry.unpublished"];
402
- type LifecycleEventName = (typeof LIFECYCLE_EVENT_NAMES)[number];
403
- interface WorkflowState {
404
- /** Stable machine-readable state key. */
405
- name: string;
406
- /** Label rendered in the Admin UI. */
407
- label: string;
408
- /** Marks the state whose revision is visible to public readers. */
409
- published?: boolean;
410
- /** Optional visual tone used by the Admin UI. */
411
- color?: "neutral" | "warning" | "success" | "danger" | "info";
412
- }
413
- interface WorkflowTransition {
414
- /** Stable transition key used by the REST and SDK APIs. */
415
- name: string;
416
- label: string;
417
- from: string | string[];
418
- to: string;
419
- /** Every listed capability is required. */
420
- requiredCapabilities?: string[];
421
- /** Require a non-empty comment when performing the transition. */
422
- requireComment?: boolean;
423
- /** Remove the public snapshot after this transition commits. */
424
- unpublish?: boolean;
425
- }
426
- interface WorkflowRole {
427
- /** Existing user role value, for example `editor` or `publisher`. */
428
- role: string;
429
- capabilities: string[];
430
- }
431
- interface WorkflowConfig<TDoc extends object = Record<string, unknown>> {
432
- initialState: string;
433
- /** State used for a new working revision created from published content. */
434
- draftState?: string;
435
- states: WorkflowState[];
436
- transitions: WorkflowTransition[];
437
- /** Maps values in `user.roles` to workflow capabilities. */
438
- roles?: WorkflowRole[];
439
- hooks?: {
440
- beforeTransition?: CollectionBeforeTransitionHook<TDoc>[];
441
- afterTransition?: CollectionAfterTransitionHook<TDoc>[];
442
- };
443
- }
444
- interface WorkflowMetadata {
445
- state: string;
446
- revision: number;
447
- publishedRevision?: number;
448
- publishedAt?: string;
449
- publishedBy?: string;
450
- /** Transitions currently allowed for the requesting user. Response-only. */
451
- availableTransitions?: string[];
452
- }
453
- interface WorkflowTransitionContext<TDoc extends object = Record<string, unknown>> {
454
- transition: WorkflowTransition;
455
- from: string;
456
- to: string;
457
- doc: TDoc;
458
- user?: AuthenticatedUser;
459
- comment?: string;
460
- req: HookRequestContext;
461
- db: DatabaseAdapter;
462
- }
463
- type CollectionBeforeTransitionHook<TDoc extends object = Record<string, unknown>> = (args: WorkflowTransitionContext<TDoc>) => void | Promise<void>;
464
- type CollectionAfterTransitionHook<TDoc extends object = Record<string, unknown>> = (args: WorkflowTransitionContext<TDoc> & {
465
- event: LifecycleEvent;
466
- }) => void | Promise<void>;
467
- interface LifecycleEvent<TPayload = Record<string, unknown>> {
468
- id: string;
469
- name: LifecycleEventName;
470
- collection: string;
471
- documentId: string;
472
- occurredAt: string;
473
- actorId?: string;
474
- payload: TPayload;
475
- attempts: number;
476
- status: "pending" | "processing" | "delivered" | "failed";
477
- nextAttemptAt?: string;
478
- deliveredAt?: string;
479
- lastError?: string;
480
- }
481
- type LifecycleEventHandler = (event: LifecycleEvent) => void | Promise<void>;
482
-
483
- /**
484
- * A hook that runs **before a field value is saved** to the database.
485
- *
486
- * Return the transformed value to persist. Return `undefined` to leave the
487
- * value unchanged (same as returning the original `value`).
488
- *
489
- * Field `beforeChange` hooks run recursively inside `array`, `object`, and
490
- * `blocks` fields — every nested item is processed automatically.
491
- *
492
- * @template TValue The TypeScript type of this field's value.
493
- * @template TDoc The document shape of the parent collection/global.
494
- *
495
- * @example
496
- * // Normalise email to lowercase
497
- * const normaliseEmail: FieldBeforeChangeHook<string> = ({ value }) =>
498
- * value?.toLowerCase().trim()
499
- *
500
- * @example
501
- * // Hash a password with bcrypt
502
- * const hashPassword: FieldBeforeChangeHook<string> = async ({ value }) =>
503
- * value ? bcrypt.hash(value, 10) : value
504
- */
505
- type FieldBeforeChangeHook<TValue = unknown, TDoc extends object = Record<string, unknown>> = (args: {
506
- /** The current value of this field (after any previous hooks in the chain). */
507
- value: TValue;
508
- /** The full document as it existed before this update. `undefined` on create. */
509
- originalDoc?: TDoc;
510
- /** The full incoming data payload being written. */
511
- data: Partial<TDoc>;
512
- /** The authenticated user, or `undefined` for unauthenticated requests. */
513
- user?: AuthenticatedUser;
514
- /**
515
- * Database adapter for cross-collection reads. Write operations (create,
516
- * update, delete) will throw — use `afterChange`/`afterDelete` for writes.
517
- */
518
- db: ReadonlyDatabaseAdapter;
519
- }) => TValue | undefined | Promise<TValue | undefined>;
520
- /**
521
- * A hook that runs **after a field value is read** from the database, before
522
- * the response is sent to the client.
523
- *
524
- * Return the transformed value to return to the client. Use this for masking,
525
- * formatting, or adding computed properties.
526
- *
527
- * @template TValue The TypeScript type of this field's value.
528
- * @template TDoc The document shape of the parent collection/global.
529
- *
530
- * @example
531
- * // Mask sensitive value for non-admins
532
- * const maskForPublic: FieldAfterReadHook<string> = ({ value, user }) =>
533
- * user?.role === 'admin' ? value : '••••••••'
534
- */
535
- type FieldAfterReadHook<TValue = unknown, TDoc extends object = Record<string, unknown>> = (args: {
536
- /** The raw field value as stored in the database. */
537
- value: TValue;
538
- /** The full document being returned (with defaults applied). */
539
- doc: TDoc;
540
- /** The authenticated user, or `undefined` for unauthenticated requests. */
541
- user?: AuthenticatedUser;
542
- /**
543
- * Database adapter for cross-collection reads. Write operations (create,
544
- * update, delete) will throw — use `afterChange`/`afterDelete` for writes.
545
- */
546
- db: ReadonlyDatabaseAdapter;
547
- }) => TValue | undefined | Promise<TValue | undefined>;
548
- /**
549
- * @deprecated Use {@link FieldBeforeChangeHook} or {@link FieldAfterReadHook} instead.
550
- * This alias remains for backwards compatibility.
551
- */
552
- type FieldHook<TDoc extends object = Record<string, unknown>, TValue = unknown> = FieldBeforeChangeHook<TValue, TDoc>;
553
- /**
554
- * Runs before Dyrected queries the database for a list or single-document fetch.
555
- *
556
- * Return a new `where` query object to override or extend the current filter.
557
- * Return `undefined` (or nothing) to leave the query unchanged.
558
- *
559
- * @example
560
- * // Scope all reads to the current user's own documents
561
- * const scopeToUser: CollectionBeforeReadHook = ({ user, query }) => ({
562
- * ...query,
563
- * owner: { equals: user?.sub },
564
- * })
565
- */
566
- type CollectionBeforeReadHook = (args: {
567
- /** The HTTP request context. */
568
- req: HookRequestContext;
569
- /** The current `where` query filter. Modify and return to override. */
570
- query?: Record<string, unknown>;
571
- /** The authenticated user, or `undefined` for unauthenticated requests. */
572
- user?: AuthenticatedUser;
573
- /**
574
- * Database adapter for cross-collection reads. Write operations (create,
575
- * update, delete) will throw — use `afterChange`/`afterDelete` for writes.
576
- */
577
- db: ReadonlyDatabaseAdapter;
578
- }) => Record<string, unknown> | void | Promise<Record<string, unknown> | void>;
579
- /**
580
- * Runs after a document (or list of documents) is fetched from the database,
581
- * before the response is sent to the client.
582
- *
583
- * Return a modified document to send instead. Useful for adding computed
584
- * virtual fields or transforming the shape of the response.
585
- *
586
- * @template TDoc The shape of the collection's document.
587
- *
588
- * @example
589
- * // Add a computed fullName field
590
- * const addFullName: CollectionAfterReadHook<User> = ({ doc }) => ({
591
- * ...doc,
592
- * fullName: `${doc.firstName} ${doc.lastName}`.trim(),
593
- * })
594
- */
595
- type CollectionAfterReadHook<TDoc extends object = Record<string, unknown>> = (args: {
596
- /** The document as fetched from the database (with defaults applied). */
597
- doc: TDoc;
598
- /** The HTTP request context. */
599
- req: HookRequestContext;
600
- /** The authenticated user, or `undefined` for unauthenticated requests. */
601
- user?: AuthenticatedUser;
602
- /**
603
- * Database adapter for cross-collection reads. Write operations (create,
604
- * update, delete) will throw — use `afterChange`/`afterDelete` for writes.
605
- */
606
- db: ReadonlyDatabaseAdapter;
607
- }) => TDoc | Promise<TDoc>;
608
- /**
609
- * Runs **before** a document is created or updated in the database.
610
- *
611
- * Return a modified data object to write instead of the original. This is the
612
- * right place for data transformation, normalisation, slug generation, and
613
- * validation (throw to abort the write).
614
- *
615
- * @template TDoc The shape of the collection's document.
616
- *
617
- * @example
618
- * // Auto-generate a slug on create
619
- * const generateSlug: CollectionBeforeChangeHook<Post> = ({ data, operation }) => {
620
- * if (operation === 'create' || data.title !== undefined) {
621
- * return { ...data, slug: slugify(data.title ?? '') }
622
- * }
623
- * return data
624
- * }
625
- *
626
- * @example
627
- * // Abort the write with a validation error
628
- * const validateStock: CollectionBeforeChangeHook<Product> = ({ data }) => {
629
- * if ((data.stock ?? 0) < 0) throw new Error('Stock cannot be negative.')
630
- * return data
631
- * }
632
- */
633
- type CollectionBeforeChangeHook<TDoc extends object = Record<string, unknown>> = (args: {
634
- /** The incoming data payload being written. */
635
- data: Partial<TDoc>;
636
- /**
637
- * The existing document before this update. Only present on `'update'`
638
- * operations; `undefined` on `'create'`.
639
- */
640
- doc?: TDoc;
641
- /** The HTTP request context. */
642
- req: HookRequestContext;
643
- /** The authenticated user, or `undefined` for unauthenticated requests. */
644
- user?: AuthenticatedUser;
645
- /** Whether this is a new document or an update to an existing one. */
646
- operation: "create" | "update";
647
- /**
648
- * Database adapter for cross-collection reads. Write operations (create,
649
- * update, delete) will throw — use `afterChange`/`afterDelete` for writes.
650
- */
651
- db: ReadonlyDatabaseAdapter;
652
- }) => Partial<TDoc> | void | Promise<Partial<TDoc> | void>;
653
- /**
654
- * Runs **after** a document is created or updated in the database.
655
- *
656
- * **Isolation**: errors thrown inside this hook are caught by the framework,
657
- * logged to the console, and then discarded. The HTTP response returns the
658
- * saved document as if nothing went wrong — because from the database's
659
- * perspective, nothing did. This means a transient email failure or webhook
660
- * timeout will never turn a successful write into a 500 for the caller.
661
- *
662
- * The return value is ignored — this hook is for side-effects only (emails,
663
- * webhooks, cache revalidation, search index updates, etc.).
664
- *
665
- * **Awaiting vs fire-and-forget**: `await`ing inside this hook is fine for
666
- * fast, reliable calls. For slow or unreliable external services prefer
667
- * fire-and-forget with your own `.catch()` so the response doesn't block:
668
- *
669
- * ```ts
670
- * // ✓ fast & reliable — safe to await
671
- * afterChange: [async ({ doc }) => {
672
- * await revalidatePath(`/posts/${doc.slug}`)
673
- * }]
674
- *
675
- * // ✓ slow or unreliable — fire-and-forget
676
- * afterChange: [({ doc }) => {
677
- * sendEmail({ to: doc.email, ... }).catch(console.error)
678
- * }]
679
- * ```
680
- *
681
- * @template TDoc The shape of the collection's document.
682
- *
683
- * @example
684
- * // Send a webhook after every save
685
- * const sendWebhook: CollectionAfterChangeHook<Post> = async ({ doc, operation }) => {
686
- * await fetch('https://hooks.example.com/content', {
687
- * method: 'POST',
688
- * body: JSON.stringify({ event: operation, doc }),
689
- * })
690
- * }
691
- *
692
- * @example
693
- * // Only act when a specific field changed
694
- * const onStatusChange: CollectionAfterChangeHook<Post> = async ({ doc, previousDoc, operation }) => {
695
- * if (operation === 'update' && doc.status !== previousDoc?.status) {
696
- * await notifySubscribers(doc)
697
- * }
698
- * }
699
- */
700
- type CollectionAfterChangeHook<TDoc extends object = Record<string, unknown>> = (args: {
701
- /** The document as it was written to the database. */
702
- doc: TDoc;
703
- /**
704
- * Snapshot of the document before the write. Only present on `'update'`
705
- * operations; `undefined` on `'create'`.
706
- */
707
- previousDoc?: TDoc;
708
- /** The HTTP request context. */
709
- req: HookRequestContext;
710
- /** The authenticated user, or `undefined` for unauthenticated requests. */
711
- user?: AuthenticatedUser;
712
- /** Whether this was a new document or an update. */
713
- operation: "create" | "update";
714
- /**
715
- * Database adapter with full read/write access. The DB write for this
716
- * operation has already committed — safe for side-effect writes.
717
- */
718
- db: DatabaseAdapter;
719
- }) => void | Promise<void>;
720
- /**
721
- * Runs **before** a document is deleted from the database.
722
- *
723
- * Throw an error to cancel the deletion — the document will not be removed
724
- * and the API will return a `500` with your error message.
725
- *
726
- * @template TDoc The shape of the collection's document.
727
- *
728
- * @example
729
- * // Prevent deletion when other documents reference this one
730
- * const guardReferences: CollectionBeforeDeleteHook<Category> = async ({ id, doc }) => {
731
- * const refs = await db.find({ collection: 'posts', where: { category: { equals: id } } })
732
- * if (refs.total > 0) throw new Error(`${refs.total} post(s) still reference this category.`)
733
- * }
734
- */
735
- type CollectionBeforeDeleteHook<TDoc extends object = Record<string, unknown>> = (args: {
736
- /** The ID of the document about to be deleted. */
737
- id: string;
738
- /** The full document about to be deleted. */
739
- doc: TDoc;
740
- /** The HTTP request context. */
741
- req: HookRequestContext;
742
- /** The authenticated user, or `undefined` for unauthenticated requests. */
743
- user?: AuthenticatedUser;
744
- /**
745
- * Database adapter for cross-collection reads. Write operations (create,
746
- * update, delete) will throw — use `afterDelete` for post-deletion writes.
747
- */
748
- db: ReadonlyDatabaseAdapter;
749
- }) => void | Promise<void>;
750
- /**
751
- * Runs **after** a document has been deleted from the database.
752
- *
753
- * **Isolation**: same as {@link CollectionAfterChangeHook} — errors are caught,
754
- * logged, and discarded. The deletion is already committed; a hook failure will
755
- * never cause the deleted ID to appear in the `failed` list of a bulk delete or
756
- * turn a successful single delete into a 500.
757
- *
758
- * Use for cleanup side-effects — removing related media, invalidating caches,
759
- * notifying downstream services, etc.
760
- *
761
- * @template TDoc The shape of the collection's document.
762
- */
763
- type CollectionAfterDeleteHook<TDoc extends object = Record<string, unknown>> = (args: {
764
- /** The ID of the deleted document. */
765
- id: string;
766
- /** The document as it was just before deletion. */
767
- doc: TDoc;
768
- /** The HTTP request context. */
769
- req: HookRequestContext;
770
- /** The authenticated user, or `undefined` for unauthenticated requests. */
771
- user?: AuthenticatedUser;
772
- /**
773
- * Database adapter with full read/write access. The deletion has already
774
- * committed — safe for cascade deletes or cleanup writes.
775
- */
776
- db: DatabaseAdapter;
777
- }) => void | Promise<void>;
778
- /** @see {@link CollectionBeforeReadHook} */
779
- type GlobalBeforeReadHook = CollectionBeforeReadHook;
780
- /**
781
- * Runs after the global document is fetched, before the response is sent.
782
- * @see {@link CollectionAfterReadHook}
783
- */
784
- type GlobalAfterReadHook<TDoc extends object = Record<string, unknown>> = (args: {
785
- doc: TDoc;
786
- req: HookRequestContext;
787
- user?: AuthenticatedUser;
788
- /**
789
- * Database adapter for cross-collection reads. Write operations (create,
790
- * update, delete) will throw — use `afterChange` for writes.
791
- */
792
- db: ReadonlyDatabaseAdapter;
793
- }) => TDoc | Promise<TDoc>;
794
- /**
795
- * Runs before the global document is updated.
796
- * Operation is always `'update'` (globals cannot be created or deleted).
797
- * @see {@link CollectionBeforeChangeHook}
798
- */
799
- type GlobalBeforeChangeHook<TDoc extends object = Record<string, unknown>> = (args: {
800
- data: Partial<TDoc>;
801
- doc?: TDoc;
802
- req: HookRequestContext;
803
- user?: AuthenticatedUser;
804
- operation: "update";
805
- /**
806
- * Database adapter for cross-collection reads. Write operations (create,
807
- * update, delete) will throw — use `afterChange` for writes.
808
- */
809
- db: ReadonlyDatabaseAdapter;
810
- }) => Partial<TDoc> | void | Promise<Partial<TDoc> | void>;
811
- /**
812
- * Runs after the global document is updated. Side-effects only.
813
- *
814
- * **Isolation**: errors are caught, logged, and discarded — same behaviour as
815
- * {@link CollectionAfterChangeHook}. The update is already committed.
816
- *
817
- * @see {@link CollectionAfterChangeHook}
818
- */
819
- type GlobalAfterChangeHook<TDoc extends object = Record<string, unknown>> = (args: {
820
- doc: TDoc;
821
- previousDoc?: TDoc;
822
- req: HookRequestContext;
823
- user?: AuthenticatedUser;
824
- operation: "update";
825
- /**
826
- * Database adapter with full read/write access. The DB write for this
827
- * operation has already committed — safe for side-effect writes.
828
- */
829
- db: DatabaseAdapter;
830
- }) => void | Promise<void>;
831
- /**
832
- * @deprecated Use the specific hook types instead:
833
- * {@link CollectionBeforeChangeHook}, {@link CollectionAfterReadHook}, etc.
834
- *
835
- * This broad type remains for backwards compatibility with the internal hook runner.
836
- */
837
- type HookFunction<TDoc extends object = Record<string, unknown>> = (args: {
838
- data?: Partial<TDoc>;
839
- doc?: TDoc;
840
- user?: AuthenticatedUser;
841
- req?: HookRequestContext;
842
- operation?: "create" | "update" | "delete";
843
- db?: DatabaseAdapter;
844
- [key: string]: unknown;
845
- }) => unknown | Promise<unknown>;
846
- /**
847
- * A function that determines whether the current user can perform an operation.
848
- *
849
- * Return `true` to allow, `false` to deny.
850
- * Return a `where`-style object to allow access only to matching documents
851
- * (useful for multi-tenant setups where users can only see their own data).
852
- *
853
- * Can also be expressed as a Jexl expression **string** for simple role checks
854
- * that need to be serialised (e.g. stored in the database or sent to the Admin UI).
855
- *
856
- * @template TDoc The shape of the collection's document.
857
- *
858
- * @example
859
- * // Simple role check
860
- * access: {
861
- * delete: ({ user }) => user?.roles?.includes('admin') ?? false,
862
- * }
863
- *
864
- * @example
865
- * // Row-level: users can only read their own documents
866
- * access: {
867
- * read: ({ user }) => ({ owner: { equals: user?.sub } }),
868
- * }
869
- *
870
- * @example
871
- * // Jexl string — evaluated server-side
872
- * access: {
873
- * update: "user.roles contains 'editor'",
874
- * }
875
- */
876
- type AccessFunction<TDoc extends object = Record<string, unknown>> = (args: {
877
- user: AuthenticatedUser | undefined;
878
- doc?: TDoc;
879
- data?: Partial<TDoc>;
880
- req: HookRequestContext;
881
- }) => boolean | Record<string, unknown> | Promise<boolean | Record<string, unknown>>;
882
- /**
883
- * Defines a Dyrected collection — a named set of documents with a shared schema.
884
- *
885
- * Pass your document's TypeScript type as the generic parameter `TDoc` to get
886
- * fully typed hooks and access functions:
887
- *
888
- * ```ts
889
- * interface Post {
890
- * id: string
891
- * title: string
892
- * slug: string
893
- * status: 'draft' | 'published'
894
- * publishedAt?: string
895
- * }
896
- *
897
- * export const Posts = defineCollection<Post>({
898
- * slug: 'posts',
899
- * hooks: {
900
- * beforeChange: [({ data, operation }) => {
901
- * // `data` is typed as Partial<Post>
902
- * if (operation === 'create') return { ...data, status: 'draft' }
903
- * return data
904
- * }],
905
- * afterChange: [({ doc, previousDoc }) => {
906
- * // `doc` and `previousDoc` are typed as Post
907
- * if (doc.status !== previousDoc?.status) notifySubscribers(doc)
908
- * }],
909
- * },
910
- * fields: [...],
911
- * })
912
- * ```
913
- *
914
- * @template TDoc The TypeScript shape of a document in this collection.
915
- * Defaults to `Record<string, unknown>` for untyped usage.
916
- */
917
- interface CollectionConfig<TDoc extends object = Record<string, unknown>> {
918
- /**
919
- * Unique identifier for this collection.
920
- * Used as the URL segment (`/api/collections/:slug`) and the database table/collection name.
921
- * Use kebab-case, e.g. `'blog-posts'`.
922
- */
923
- slug: string;
924
- /**
925
- * Restricts this collection to a specific site in a multi-tenant deployment.
926
- * When set, only requests bearing a matching `X-Site-Id` header can access it.
927
- */
928
- siteId?: string;
929
- /**
930
- * If `true`, this collection is shared across all sites in a multi-tenant
931
- * deployment and accessible regardless of the `X-Site-Id` header.
932
- */
933
- shared?: boolean;
934
- /** Human-readable names for documents in this collection, shown in the Admin UI. */
935
- labels?: {
936
- singular: string;
937
- plural: string;
938
- };
939
- /**
940
- * If `true`, this collection is an **auth collection** — it gains
941
- * `POST /api/collections/:slug/login` and `POST /api/collections/:slug/logout`
942
- * endpoints, and documents are expected to have a `password` field.
943
- */
944
- auth?: boolean;
945
- /**
946
- * If `true` (or a config object), this collection supports **file uploads**.
947
- * Documents gain file-related fields (`url`, `filename`, `mimeType`, etc.)
948
- * and the create endpoint accepts `multipart/form-data`.
949
- */
950
- upload?: boolean | UploadConfig;
951
- /** Field definitions that make up the document schema for this collection. */
952
- fields: Field[];
953
- /**
954
- * If `true`, Dyrected automatically adds `createdAt` and `updatedAt`
955
- * timestamp fields to every document. Defaults to `true`.
956
- */
957
- timestamps?: boolean;
958
- /**
959
- * Initial documents to seed into this collection the first time it is
960
- * fetched and found to be empty (e.g. for demo data or defaults).
961
- */
962
- initialData?: Partial<TDoc>[];
963
- /**
964
- * If `true`, every create, update, and delete operation on this collection
965
- * is logged to the `__audit` collection with before/after snapshots and the
966
- * acting user's identity.
967
- */
968
- audit?: boolean;
969
- /**
970
- * Optional state-machine workflow for this collection. Workflow-enabled
971
- * entries keep an editable working revision and an independent public
972
- * snapshot, so editing published content never changes the live response.
973
- */
974
- workflow?: WorkflowConfig<TDoc>;
975
- /**
976
- * Collection-level access control.
977
- *
978
- * Each key is an operation; the value is a function (or Jexl string) that
979
- * returns `true` to allow or `false` to deny. Returning a `where`-style
980
- * object grants access only to matching documents.
981
- *
982
- * @example
983
- * access: {
984
- * read: () => true, // public read
985
- * create: ({ user }) => !!user, // logged-in users only
986
- * update: ({ user }) => user?.roles?.includes('editor') ?? false,
987
- * delete: ({ user }) => user?.roles?.includes('admin') ?? false,
988
- * }
989
- */
990
- access?: {
991
- read?: AccessFunction<TDoc> | string;
992
- create?: AccessFunction<TDoc> | string;
993
- update?: AccessFunction<TDoc> | string;
994
- delete?: AccessFunction<TDoc> | string;
995
- };
996
- /**
997
- * Collection-level lifecycle hooks.
998
- *
999
- * Hooks run in the order they appear in the array. The return value of each
1000
- * hook is passed as the input to the next. Throwing inside any hook aborts
1001
- * the operation and returns a `500` error.
1002
- *
1003
- * See the [Hooks reference](/docs/concepts/hooks) for the full lifecycle diagram.
1004
- */
1005
- hooks?: {
1006
- /**
1007
- * Runs before the database is queried. Return a modified `where` object
1008
- * to override the query filter.
1009
- */
1010
- beforeRead?: CollectionBeforeReadHook[];
1011
- /**
1012
- * Runs after documents are fetched. Return a modified doc to change what
1013
- * the client receives. Runs on every document in a list response.
1014
- */
1015
- afterRead?: CollectionAfterReadHook<TDoc>[];
1016
- /**
1017
- * Runs before create or update. Return modified data to change what is
1018
- * written to the database. Throw to abort the write entirely.
1019
- */
1020
- beforeChange?: CollectionBeforeChangeHook<TDoc>[];
1021
- /**
1022
- * Runs after create or update is committed. For side-effects only —
1023
- * webhooks, cache busting, notifications. Return value is ignored.
1024
- *
1025
- * Errors are **isolated**: caught, logged, and discarded so a failing
1026
- * side-effect never turns a successful write into an HTTP 500.
1027
- * See {@link CollectionAfterChangeHook} for the await-vs-fire-and-forget guidance.
1028
- */
1029
- afterChange?: CollectionAfterChangeHook<TDoc>[];
1030
- /**
1031
- * Runs before a document is deleted. Throw to cancel the deletion.
1032
- */
1033
- beforeDelete?: CollectionBeforeDeleteHook<TDoc>[];
1034
- /**
1035
- * Runs after a document has been deleted. For cleanup side-effects only.
1036
- *
1037
- * Errors are **isolated**: caught, logged, and discarded — the deletion is
1038
- * already committed and will not be undone.
1039
- */
1040
- afterDelete?: CollectionAfterDeleteHook<TDoc>[];
1041
- };
1042
- /** Admin UI configuration for this collection. */
1043
- admin?: {
1044
- /**
1045
- * Lucide icon displayed beside this collection in the Admin sidebar.
1046
- * Uses Lucide component names, e.g. `'Newspaper'` or `'ShoppingBag'`.
1047
- */
1048
- icon?: AdminIconName;
1049
- /** Custom component slots for this collection's list view. */
1050
- components?: CollectionListComponentSlots;
1051
- /**
1052
- * The field name used as the document's display title in the Admin list
1053
- * view and breadcrumbs. Defaults to `'title'` if the field exists.
1054
- */
1055
- useAsTitle?: string;
1056
- /**
1057
- * Field names to show as columns in the Admin list view.
1058
- * Defaults to a sensible set of the first few non-structural fields.
1059
- */
1060
- defaultColumns?: string[];
1061
- /**
1062
- * Groups this collection under a named section in the Admin sidebar.
1063
- * Collections with the same `group` are visually grouped together.
1064
- */
1065
- group?: string;
1066
- /** If `true`, this collection is not shown in the Admin UI sidebar. */
1067
- hidden?: boolean;
1068
- /** If `false`, disables the filter UI entirely for this collection. Defaults to `true`. */
1069
- filterable?: boolean;
1070
- /**
1071
- * URL to open in the Live Preview pane when editing a document.
1072
- * Pass a function to derive the URL from the document's fields.
1073
- *
1074
- * @example
1075
- * previewUrl: (doc) => `https://mysite.com/blog/${doc.slug}`
1076
- */
1077
- previewUrl?: string | ((doc: TDoc, opts: {
1078
- locale?: string;
1079
- }) => string | null);
1080
- /**
1081
- * How the Live Preview pane communicates with the frontend.
1082
- * - `'postMessage'` (default) — sends a `postMessage` with the current doc data.
1083
- * - `'token'` — passes a short-lived preview token as a query parameter.
1084
- */
1085
- previewMode?: "postMessage" | "token";
1086
- /**
1087
- * Frontend URL pattern for this collection, used by `url` fields to
1088
- * resolve internal links. Use `{fieldName}` placeholders.
1089
- *
1090
- * @example
1091
- * urlPattern: '/blog/{slug}' // → /blog/my-post
1092
- * urlPattern: '/{slug}' // → /about
1093
- */
1094
- urlPattern?: string;
1095
- };
1096
- }
1097
- /**
1098
- * Defines a Dyrected global — a singleton document without pagination or IDs.
1099
- *
1100
- * Globals are ideal for site-wide settings, feature flags, or any data where
1101
- * there is always exactly one record (e.g. `site-settings`, `navigation`, `theme`).
1102
- *
1103
- * Pass your document's TypeScript type as the generic parameter `TDoc` to get
1104
- * fully typed hooks:
1105
- *
1106
- * ```ts
1107
- * interface SiteSettings {
1108
- * siteName: string
1109
- * tagline: string
1110
- * maintenanceMode: boolean
1111
- * }
1112
- *
1113
- * export const Settings = defineGlobal<SiteSettings>({
1114
- * slug: 'site-settings',
1115
- * hooks: {
1116
- * afterChange: [({ doc }) => {
1117
- * // `doc` is typed as SiteSettings
1118
- * if (doc.maintenanceMode) alertOnCall()
1119
- * }],
1120
- * },
1121
- * fields: [...],
1122
- * })
1123
- * ```
1124
- *
1125
- * @template TDoc The TypeScript shape of this global's document.
1126
- */
1127
- interface GlobalConfig<TDoc extends object = Record<string, unknown>> {
1128
- /**
1129
- * Unique identifier for this global.
1130
- * Used as the URL segment (`/api/globals/:slug`) and the storage key.
1131
- */
1132
- slug: string;
1133
- /** Restricts this global to a specific site in a multi-tenant deployment. */
1134
- siteId?: string;
1135
- /**
1136
- * If `true`, this global is shared across all sites in a multi-tenant
1137
- * deployment.
1138
- */
1139
- shared?: boolean;
1140
- /** Human-readable label shown in the Admin UI sidebar. */
1141
- label?: string;
1142
- /** Field definitions for this global's document schema. */
1143
- fields: Field[];
1144
- /** Access control for reading and updating this global. */
1145
- access?: {
1146
- read?: AccessFunction<TDoc>;
1147
- update?: AccessFunction<TDoc>;
1148
- };
1149
- /**
1150
- * Global-level lifecycle hooks.
1151
- * Globals support `beforeRead`, `afterRead`, `beforeChange`, and `afterChange`.
1152
- * There are no delete hooks since globals cannot be deleted.
1153
- */
1154
- hooks?: {
1155
- beforeRead?: GlobalBeforeReadHook[];
1156
- afterRead?: GlobalAfterReadHook<TDoc>[];
1157
- beforeChange?: GlobalBeforeChangeHook<TDoc>[];
1158
- afterChange?: GlobalAfterChangeHook<TDoc>[];
1159
- };
1160
- /** Admin UI configuration for this global. */
1161
- admin?: {
1162
- /**
1163
- * Lucide icon displayed beside this global in the Admin sidebar.
1164
- * Uses Lucide component names, e.g. `'Settings2'` or `'Palette'`.
1165
- */
1166
- icon?: AdminIconName;
1167
- /** Groups this global under a named section in the Admin sidebar. */
1168
- group?: string;
1169
- /** If `true`, this global is not shown in the Admin UI sidebar. */
1170
- hidden?: boolean;
1171
- };
1172
- /**
1173
- * Initial data to seed this global with the first time it is fetched and
1174
- * found to be empty.
1175
- */
1176
- initialData?: Partial<TDoc>;
1177
- }
1178
- /**
1179
- * The interface every database adapter must implement.
1180
- *
1181
- * Dyrected ships adapters for PostgreSQL, MySQL, SQLite, and MongoDB.
1182
- * Implement this interface to connect any other database.
1183
- */
1184
- interface DatabaseAdapter {
1185
- /** Find a paginated list of documents in a collection. */
1186
- find(args: {
1187
- collection: string;
1188
- where?: Record<string, unknown>;
1189
- limit?: number;
1190
- page?: number;
1191
- sort?: string;
1192
- }): Promise<PaginatedResult>;
1193
- /** Find a single document by its ID. Returns `null` if not found. */
1194
- findOne(args: {
1195
- collection: string;
1196
- id: string;
1197
- }): Promise<BaseDocument | null>;
1198
- /** Insert a new document and return it with its generated `id`. */
1199
- create(args: {
1200
- collection: string;
1201
- data: Record<string, unknown>;
1202
- }): Promise<BaseDocument>;
1203
- /** Update a document by ID and return the updated document. */
1204
- update(args: {
1205
- collection: string;
1206
- id: string;
1207
- data: Record<string, unknown>;
1208
- }): Promise<BaseDocument>;
1209
- /** Delete a document by ID. Return value is intentionally untyped — callers do not use it. */
1210
- delete(args: {
1211
- collection: string;
1212
- id: string;
1213
- }): Promise<unknown>;
1214
- /** Fetch the singleton document for a global. Returns an empty object if not yet initialised. */
1215
- getGlobal(args: {
1216
- slug: string;
1217
- }): Promise<Record<string, unknown>>;
1218
- /** Create or replace the singleton document for a global. */
1219
- updateGlobal(args: {
1220
- slug: string;
1221
- data: Record<string, unknown>;
1222
- }): Promise<Record<string, unknown>>;
1223
- /**
1224
- * Sync the database schema with the current collection and global configs.
1225
- * Called on startup to create tables/collections that don't exist yet.
1226
- * Not all adapters implement this (e.g. MongoDB is schema-less).
1227
- */
1228
- sync?(collections: CollectionConfig[], globals: GlobalConfig[]): Promise<void>;
1229
- /**
1230
- * Execute a raw SQL query or database command.
1231
- * Optional — not all adapters support raw access.
1232
- */
1233
- execute?(query: string, params?: unknown[]): Promise<unknown>;
1234
- /**
1235
- * Run all adapter operations in `callback` as one atomic transaction.
1236
- * Shipped adapters implement this; workflow transitions require it.
1237
- */
1238
- transaction?<T>(callback: (db: DatabaseAdapter) => Promise<T>): Promise<T>;
1239
- }
1240
- /**
1241
- * Read-only view of the database adapter. Exposes only `find`, `findOne`,
1242
- * and `getGlobal` — no write operations.
1243
- *
1244
- * Passed to `beforeChange`, `beforeDelete`, `beforeRead`, `afterRead`,
1245
- * and field-level hooks. Write operations are available in `afterChange`
1246
- * and `afterDelete` hooks where the full {@link DatabaseAdapter} is provided.
1247
- */
1248
- type ReadonlyDatabaseAdapter = Pick<DatabaseAdapter, "find" | "findOne" | "getGlobal">;
1249
- /**
1250
- * The interface every storage adapter must implement.
1251
- *
1252
- * Dyrected ships adapters for local disk, S3, Cloudflare R2, Cloudinary, and
1253
- * Backblaze B2. Implement this interface to use any other storage provider.
1254
- */
1255
- interface StorageAdapter {
1256
- /**
1257
- * Upload a file and return its metadata (URL, dimensions, etc.).
1258
- * The `prefix` is a path prefix used for multi-tenant setups.
1259
- */
1260
- upload(args: {
1261
- filename: string;
1262
- buffer: Uint8Array;
1263
- mimeType: string;
1264
- prefix?: string;
1265
- }): Promise<FileData>;
1266
- /** Delete a file by its stored filename. */
1267
- delete(args: {
1268
- filename: string;
1269
- }): Promise<void>;
1270
- /** Return the public URL for a stored file. */
1271
- getURL(args: {
1272
- filename: string;
1273
- }): string;
1274
- /**
1275
- * Retrieve the file's raw bytes and MIME type for serving via the API.
1276
- * Only needed by adapters that serve files through the Dyrected API
1277
- * (e.g. `LocalStorage`). Cloud adapters return `null` here and rely on
1278
- * direct CDN URLs instead.
1279
- */
1280
- resolve?(args: {
1281
- filename: string;
1282
- }): Promise<{
1283
- buffer: Uint8Array;
1284
- mimeType: string;
1285
- } | null>;
1286
- }
1287
- /**
1288
- * Processes uploaded images — generates metadata (dimensions, BlurHash) and
1289
- * produces resized variants defined in `UploadConfig.imageSizes`.
1290
- *
1291
- * @example
1292
- * import { SharpImageService } from '@dyrected/image-sharp'
1293
- * defineConfig({ image: new SharpImageService(), ... })
1294
- */
1295
- interface ImageService {
1296
- process(args: {
1297
- buffer: Uint8Array;
1298
- mimeType: string;
1299
- config?: boolean | UploadConfig;
1300
- focalPoint?: {
1301
- x: number;
1302
- y: number;
1303
- };
1304
- }): Promise<{
1305
- metadata: {
1306
- width?: number;
1307
- height?: number;
1308
- /** Base64-encoded BlurHash for progressive loading. */
1309
- blurhash?: string;
1310
- };
1311
- /** Generated image sizes keyed by their `name`. */
1312
- sizes?: Record<string, {
1313
- buffer: Uint8Array;
1314
- width: number;
1315
- height: number;
1316
- filename: string;
1317
- }>;
1318
- }>;
1319
- }
1320
- /**
1321
- * The root configuration object passed to `createDyrectedApp`.
1322
- *
1323
- * This is the single source of truth for your entire Dyrected instance —
1324
- * collections, globals, database adapter, storage, email, and more.
1325
- *
1326
- * @example
1327
- * import { defineConfig } from '@dyrected/core'
1328
- * import { SQLiteAdapter } from '@dyrected/db-sqlite'
1329
- *
1330
- * export default defineConfig({
1331
- * db: new SQLiteAdapter({ filename: './db.sqlite' }),
1332
- * collections: [Posts, Users],
1333
- * globals: [SiteSettings],
1334
- * })
1335
- */
1336
- interface DyrectedConfig {
1337
- /** Collection definitions. Each collection maps to a database table/collection. */
1338
- collections: CollectionConfig<any>[];
1339
- /** Global (singleton) definitions. Each global maps to a single document. */
1340
- globals: GlobalConfig<any>[];
1341
- /**
1342
- * The database adapter. Required for all data operations.
1343
- * @see {@link DatabaseAdapter}
1344
- */
1345
- db?: DatabaseAdapter;
1346
- /**
1347
- * The storage adapter for file uploads.
1348
- * Required when any collection has `upload: true`.
1349
- * @see {@link StorageAdapter}
1350
- */
1351
- storage?: StorageAdapter;
1352
- /**
1353
- * The image processing service. Required when any upload collection
1354
- * defines `imageSizes`.
1355
- * @see {@link ImageService}
1356
- */
1357
- image?: ImageService;
1358
- /** Admin UI branding and metadata. */
1359
- admin?: AdminConfig;
1360
- /**
1361
- * Deployment-level authentication strategy for the CMS dashboard (`/admin`).
1362
- * This is separate from collection-level `auth: true`, which continues to
1363
- * power application/customer auth independently.
1364
- */
1365
- adminAuth?: AdminAuthConfig;
1366
- /**
1367
- * Email transport configuration. Required for welcome emails, password
1368
- * resets, and invite links.
1369
- *
1370
- * @example
1371
- * email: {
1372
- * from: 'no-reply@myapp.com',
1373
- * send: async ({ to, subject, html }) => {
1374
- * await resend.emails.send({ from, to, subject, html })
1375
- * },
1376
- * }
1377
- */
1378
- email?: {
1379
- /** The `From` address for all outbound emails. */
1380
- from: string;
1381
- /** The send function. Wire in any email provider (Resend, SendGrid, SES, etc.). */
1382
- send: (args: {
1383
- to: string;
1384
- subject: string;
1385
- html: string;
1386
- }) => Promise<void>;
1387
- /** Override the default email templates. */
1388
- templates?: {
1389
- welcome?: (args: {
1390
- email: string;
1391
- }) => {
1392
- subject?: string;
1393
- html: string;
1394
- };
1395
- invite?: (args: {
1396
- token: string;
1397
- invitedByEmail?: string;
1398
- }) => {
1399
- subject?: string;
1400
- html: string;
1401
- };
1402
- resetPassword?: (args: {
1403
- token: string;
1404
- url?: string;
1405
- }) => {
1406
- subject?: string;
1407
- html: string;
1408
- };
1409
- passwordChanged?: (args: {
1410
- email: string;
1411
- }) => {
1412
- subject?: string;
1413
- html: string;
1414
- };
1415
- };
1416
- };
1417
- /**
1418
- * Redis connection URL. Required for distributed caching of dynamic option
1419
- * resolvers and other server-side caches in multi-instance deployments.
1420
- *
1421
- * @example
1422
- * redis: { url: process.env.REDIS_URL }
1423
- */
1424
- redis?: {
1425
- url: string;
1426
- };
1427
- /** Durable lifecycle-event delivery configuration. */
1428
- events?: {
1429
- handlers: LifecycleEventHandler[];
1430
- /** Maximum delivery attempts before an event remains failed. Defaults to 8. */
1431
- maxAttempts?: number;
1432
- /** Initial exponential-backoff delay in milliseconds. Defaults to 1000. */
1433
- retryDelayMs?: number;
1434
- };
1435
- /**
1436
- * Cross-Origin Resource Sharing (CORS) configuration.
1437
- * List all origins that are allowed to call the Dyrected API.
1438
- *
1439
- * @example
1440
- * cors: { origins: ['https://myapp.com', 'https://www.myapp.com'] }
1441
- */
1442
- cors?: {
1443
- origins: string[];
1444
- };
1445
- /**
1446
- * Callback to dynamically fetch additional collections and globals for a
1447
- * given site ID at request time. Used in multi-tenant deployments where each
1448
- * site has its own schema stored in the database.
1449
- *
1450
- * @param siteId The `X-Site-Id` header value from the incoming request.
1451
- * @returns Extra collections and globals to merge into the config for this request.
1452
- *
1453
- * @example
1454
- * onSchemaFetch: async (siteId) => {
1455
- * const site = await db.findOne({ collection: 'sites', id: siteId })
1456
- * return buildSchemaFromSiteConfig(site)
1457
- * }
1458
- */
1459
- onSchemaFetch?: (siteId: string) => Promise<{
1460
- collections?: CollectionConfig<any>[];
1461
- globals?: GlobalConfig<any>[];
1462
- admin?: AdminConfig;
1463
- adminAuth?: AdminAuthConfig;
1464
- }>;
1465
- }
1466
-
1467
- export { type GlobalBeforeChangeHook 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 FieldAfterReadHook as T, type FieldBeforeChangeHook as U, type FieldHook as V, type WorkflowConfig as W, type FieldType as X, type FileData as Y, type GlobalAfterChangeHook as Z, type GlobalAfterReadHook as _, type AuthenticatedUser as a, type GlobalBeforeReadHook as a0, type HookFunction as a1, type IconField as a2, type ImageField as a3, type ImageService as a4, type JoinField as a5, type JsonField as a6, LIFECYCLE_EVENT_NAMES as a7, type LifecycleEventHandler as a8, type MultiSelectField as a9, type NumberField as aa, type OIDCAdminAuthProvider as ab, type ObjectField as ac, type PaginatedResult as ad, type PublicAdminAuthProvider as ae, type RadioField as af, type ReadonlyDatabaseAdapter as ag, type RelationshipField as ah, type RichTextField as ai, type RowField as aj, type SelectField as ak, type StorageAdapter as al, type TextField as am, type TextareaField as an, type TimeField as ao, type UploadConfig as ap, type UrlField as aq, type WorkflowMetadata as ar, type WorkflowRole as as, type WorkflowState as at, type WorkflowTransitionContext as au, 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 };