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