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