@dyrected/core 2.8.3 → 2.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{app-config-BccpBUqJ.d.cts → app-config-DQhcrGDE.d.cts} +472 -85
- package/dist/{app-config-BccpBUqJ.d.ts → app-config-DQhcrGDE.d.ts} +472 -85
- package/dist/chunk-JSBRDJBE.js +30 -0
- package/dist/{chunk-GFFGDHST.js → chunk-TYPDQTE2.js} +1879 -42
- package/dist/index.cjs +1954 -41
- package/dist/index.d.cts +20 -5
- package/dist/index.d.ts +20 -5
- package/dist/index.js +87 -9
- package/dist/{observability-KCMTV7GO.js → observability-HQF4EUSV.js} +1 -0
- package/dist/server.cjs +2109 -45
- package/dist/server.d.cts +38 -16
- package/dist/server.d.ts +38 -16
- package/dist/server.js +250 -17
- package/dist/{where-sanitizer-WJ2W2QCE.js → where-sanitizer-3MNFMYA2.js} +2 -0
- package/package.json +3 -3
- package/dist/__tests__/access-features.test.d.ts +0 -2
- package/dist/__tests__/access-features.test.d.ts.map +0 -1
- package/dist/__tests__/access-features.test.js +0 -159
- package/dist/__tests__/access-features.test.js.map +0 -1
- package/dist/__tests__/access-parity.test.d.ts +0 -2
- package/dist/__tests__/access-parity.test.d.ts.map +0 -1
- package/dist/__tests__/access-parity.test.js +0 -338
- package/dist/__tests__/access-parity.test.js.map +0 -1
- package/dist/__tests__/access.test.d.ts +0 -2
- package/dist/__tests__/access.test.d.ts.map +0 -1
- package/dist/__tests__/access.test.js +0 -137
- package/dist/__tests__/access.test.js.map +0 -1
- package/dist/__tests__/admin-auth.test.d.ts +0 -2
- package/dist/__tests__/admin-auth.test.d.ts.map +0 -1
- package/dist/__tests__/admin-auth.test.js +0 -440
- package/dist/__tests__/admin-auth.test.js.map +0 -1
- package/dist/__tests__/app.test.d.ts +0 -2
- package/dist/__tests__/app.test.d.ts.map +0 -1
- package/dist/__tests__/app.test.js +0 -112
- package/dist/__tests__/app.test.js.map +0 -1
- package/dist/__tests__/audit.test.d.ts +0 -2
- package/dist/__tests__/audit.test.d.ts.map +0 -1
- package/dist/__tests__/audit.test.js +0 -125
- package/dist/__tests__/audit.test.js.map +0 -1
- package/dist/__tests__/auth-hydration.test.d.ts +0 -2
- package/dist/__tests__/auth-hydration.test.d.ts.map +0 -1
- package/dist/__tests__/auth-hydration.test.js +0 -90
- package/dist/__tests__/auth-hydration.test.js.map +0 -1
- package/dist/__tests__/auth-invite.test.d.ts +0 -2
- package/dist/__tests__/auth-invite.test.d.ts.map +0 -1
- package/dist/__tests__/auth-invite.test.js +0 -152
- package/dist/__tests__/auth-invite.test.js.map +0 -1
- package/dist/__tests__/auth-lockout.test.d.ts +0 -2
- package/dist/__tests__/auth-lockout.test.d.ts.map +0 -1
- package/dist/__tests__/auth-lockout.test.js +0 -154
- package/dist/__tests__/auth-lockout.test.js.map +0 -1
- package/dist/__tests__/auth-sessions.test.d.ts +0 -2
- package/dist/__tests__/auth-sessions.test.d.ts.map +0 -1
- package/dist/__tests__/auth-sessions.test.js +0 -118
- package/dist/__tests__/auth-sessions.test.js.map +0 -1
- package/dist/__tests__/config.test.d.ts +0 -2
- package/dist/__tests__/config.test.d.ts.map +0 -1
- package/dist/__tests__/config.test.js +0 -402
- package/dist/__tests__/config.test.js.map +0 -1
- package/dist/__tests__/define-field.test.d.ts +0 -2
- package/dist/__tests__/define-field.test.d.ts.map +0 -1
- package/dist/__tests__/define-field.test.js +0 -121
- package/dist/__tests__/define-field.test.js.map +0 -1
- package/dist/__tests__/deleteMany.test.d.ts +0 -2
- package/dist/__tests__/deleteMany.test.d.ts.map +0 -1
- package/dist/__tests__/deleteMany.test.js +0 -75
- package/dist/__tests__/deleteMany.test.js.map +0 -1
- package/dist/__tests__/depth.test.d.ts +0 -2
- package/dist/__tests__/depth.test.d.ts.map +0 -1
- package/dist/__tests__/depth.test.js +0 -115
- package/dist/__tests__/depth.test.js.map +0 -1
- package/dist/__tests__/dynamic-options.test.d.ts +0 -2
- package/dist/__tests__/dynamic-options.test.d.ts.map +0 -1
- package/dist/__tests__/dynamic-options.test.js +0 -168
- package/dist/__tests__/dynamic-options.test.js.map +0 -1
- package/dist/__tests__/email.service.test.d.ts +0 -2
- package/dist/__tests__/email.service.test.d.ts.map +0 -1
- package/dist/__tests__/email.service.test.js +0 -52
- package/dist/__tests__/email.service.test.js.map +0 -1
- package/dist/__tests__/field-inference.test-types.d.ts +0 -161
- package/dist/__tests__/field-inference.test-types.d.ts.map +0 -1
- package/dist/__tests__/field-inference.test-types.js +0 -87
- package/dist/__tests__/field-inference.test-types.js.map +0 -1
- package/dist/__tests__/fixtures/editorial-workflow.d.ts +0 -14
- package/dist/__tests__/fixtures/editorial-workflow.d.ts.map +0 -1
- package/dist/__tests__/fixtures/editorial-workflow.js +0 -12
- package/dist/__tests__/fixtures/editorial-workflow.js.map +0 -1
- package/dist/__tests__/hooks.test.d.ts +0 -2
- package/dist/__tests__/hooks.test.d.ts.map +0 -1
- package/dist/__tests__/hooks.test.js +0 -320
- package/dist/__tests__/hooks.test.js.map +0 -1
- package/dist/__tests__/mocks.d.ts +0 -75
- package/dist/__tests__/mocks.d.ts.map +0 -1
- package/dist/__tests__/mocks.js +0 -170
- package/dist/__tests__/mocks.js.map +0 -1
- package/dist/__tests__/observability.test.d.ts +0 -2
- package/dist/__tests__/observability.test.d.ts.map +0 -1
- package/dist/__tests__/observability.test.js +0 -233
- package/dist/__tests__/observability.test.js.map +0 -1
- package/dist/__tests__/openapi.test.d.ts +0 -2
- package/dist/__tests__/openapi.test.d.ts.map +0 -1
- package/dist/__tests__/openapi.test.js +0 -105
- package/dist/__tests__/openapi.test.js.map +0 -1
- package/dist/__tests__/parse-sort.test.d.ts +0 -2
- package/dist/__tests__/parse-sort.test.d.ts.map +0 -1
- package/dist/__tests__/parse-sort.test.js +0 -24
- package/dist/__tests__/parse-sort.test.js.map +0 -1
- package/dist/__tests__/preferences.test.d.ts +0 -2
- package/dist/__tests__/preferences.test.d.ts.map +0 -1
- package/dist/__tests__/preferences.test.js +0 -168
- package/dist/__tests__/preferences.test.js.map +0 -1
- package/dist/__tests__/router.test.d.ts +0 -2
- package/dist/__tests__/router.test.d.ts.map +0 -1
- package/dist/__tests__/router.test.js +0 -70
- package/dist/__tests__/router.test.js.map +0 -1
- package/dist/__tests__/search.test.d.ts +0 -2
- package/dist/__tests__/search.test.d.ts.map +0 -1
- package/dist/__tests__/search.test.js +0 -174
- package/dist/__tests__/search.test.js.map +0 -1
- package/dist/__tests__/upload-validation.test.d.ts +0 -2
- package/dist/__tests__/upload-validation.test.d.ts.map +0 -1
- package/dist/__tests__/upload-validation.test.js +0 -41
- package/dist/__tests__/upload-validation.test.js.map +0 -1
- package/dist/__tests__/where.test.d.ts +0 -2
- package/dist/__tests__/where.test.d.ts.map +0 -1
- package/dist/__tests__/where.test.js +0 -105
- package/dist/__tests__/where.test.js.map +0 -1
- package/dist/__tests__/workflow.test.d.ts +0 -2
- package/dist/__tests__/workflow.test.d.ts.map +0 -1
- package/dist/__tests__/workflow.test.js +0 -684
- package/dist/__tests__/workflow.test.js.map +0 -1
- package/dist/app-config-7G-3tF_I.d.cts +0 -2259
- package/dist/app-config-7G-3tF_I.d.ts +0 -2259
- package/dist/app-config-9hs8DRED.d.cts +0 -1718
- package/dist/app-config-9hs8DRED.d.ts +0 -1718
- package/dist/app-config-B3ByBjCN.d.cts +0 -2222
- package/dist/app-config-B3ByBjCN.d.ts +0 -2222
- package/dist/app-config-B5tYsZaH.d.cts +0 -2404
- package/dist/app-config-B5tYsZaH.d.ts +0 -2404
- package/dist/app-config-BEuyPktb.d.cts +0 -2556
- package/dist/app-config-BEuyPktb.d.ts +0 -2556
- package/dist/app-config-BIkjQWzU.d.cts +0 -2218
- package/dist/app-config-BIkjQWzU.d.ts +0 -2218
- package/dist/app-config-BcuZIpvL.d.cts +0 -1951
- package/dist/app-config-BcuZIpvL.d.ts +0 -1951
- package/dist/app-config-BfpeE3bF.d.cts +0 -2100
- package/dist/app-config-BfpeE3bF.d.ts +0 -2100
- package/dist/app-config-Bm9-2Am6.d.cts +0 -1875
- package/dist/app-config-Bm9-2Am6.d.ts +0 -1875
- package/dist/app-config-BqhrBrSM.d.cts +0 -1522
- package/dist/app-config-BqhrBrSM.d.ts +0 -1522
- package/dist/app-config-Bxg_DVxv.d.cts +0 -1413
- package/dist/app-config-Bxg_DVxv.d.ts +0 -1413
- package/dist/app-config-C0twGIaF.d.cts +0 -1597
- package/dist/app-config-C0twGIaF.d.ts +0 -1597
- package/dist/app-config-C0uxEU7Q.d.cts +0 -1874
- package/dist/app-config-C0uxEU7Q.d.ts +0 -1874
- package/dist/app-config-C3X5BAyK.d.cts +0 -1539
- package/dist/app-config-C3X5BAyK.d.ts +0 -1539
- package/dist/app-config-C9VJ6rTv.d.cts +0 -2092
- package/dist/app-config-C9VJ6rTv.d.ts +0 -2092
- package/dist/app-config-CBOn8IyZ.d.cts +0 -1838
- package/dist/app-config-CBOn8IyZ.d.ts +0 -1838
- package/dist/app-config-CCe-yq9q.d.cts +0 -2222
- package/dist/app-config-CCe-yq9q.d.ts +0 -2222
- package/dist/app-config-CJAGGPrk.d.cts +0 -1900
- package/dist/app-config-CJAGGPrk.d.ts +0 -1900
- package/dist/app-config-CPOs7THF.d.cts +0 -2217
- package/dist/app-config-CPOs7THF.d.ts +0 -2217
- package/dist/app-config-CYV70eoF.d.cts +0 -2100
- package/dist/app-config-CYV70eoF.d.ts +0 -2100
- package/dist/app-config-ChsrBB7p.d.cts +0 -2100
- package/dist/app-config-ChsrBB7p.d.ts +0 -2100
- package/dist/app-config-CiEDJm0e.d.cts +0 -1912
- package/dist/app-config-CiEDJm0e.d.ts +0 -1912
- package/dist/app-config-CstocO9M.d.cts +0 -1580
- package/dist/app-config-CstocO9M.d.ts +0 -1580
- package/dist/app-config-Ctp454zB.d.cts +0 -2214
- package/dist/app-config-Ctp454zB.d.ts +0 -2214
- package/dist/app-config-CwaU1de2.d.cts +0 -1868
- package/dist/app-config-CwaU1de2.d.ts +0 -1868
- package/dist/app-config-DCDh8Gbx.d.cts +0 -1926
- package/dist/app-config-DCDh8Gbx.d.ts +0 -1926
- package/dist/app-config-DCWinlNK.d.cts +0 -2091
- package/dist/app-config-DCWinlNK.d.ts +0 -2091
- package/dist/app-config-DIwvzbpe.d.cts +0 -1555
- package/dist/app-config-DIwvzbpe.d.ts +0 -1555
- package/dist/app-config-DJmNYgYh.d.cts +0 -2305
- package/dist/app-config-DJmNYgYh.d.ts +0 -2305
- package/dist/app-config-DO3laV58.d.cts +0 -2397
- package/dist/app-config-DO3laV58.d.ts +0 -2397
- package/dist/app-config-DVdSospO.d.cts +0 -1842
- package/dist/app-config-DVdSospO.d.ts +0 -1842
- package/dist/app-config-DZf_mmi9.d.cts +0 -2211
- package/dist/app-config-DZf_mmi9.d.ts +0 -2211
- package/dist/app-config-DbK2Tv6i.d.cts +0 -2080
- package/dist/app-config-DbK2Tv6i.d.ts +0 -2080
- package/dist/app-config-Dkndq5ni.d.cts +0 -1580
- package/dist/app-config-Dkndq5ni.d.ts +0 -1580
- package/dist/app-config-Dms6kvE-.d.cts +0 -2072
- package/dist/app-config-Dms6kvE-.d.ts +0 -2072
- package/dist/app-config-DqCipvSI.d.cts +0 -1411
- package/dist/app-config-DqCipvSI.d.ts +0 -1411
- package/dist/app-config-Dv5XACR4.d.cts +0 -2065
- package/dist/app-config-Dv5XACR4.d.ts +0 -2065
- package/dist/app-config-P-SF5nnR.d.cts +0 -1568
- package/dist/app-config-P-SF5nnR.d.ts +0 -1568
- package/dist/app-config-SkUoN5JU.d.cts +0 -2192
- package/dist/app-config-SkUoN5JU.d.ts +0 -2192
- package/dist/app-config-WzqpuZMr.d.cts +0 -2566
- package/dist/app-config-WzqpuZMr.d.ts +0 -2566
- package/dist/app-config-_kkj71CB.d.cts +0 -2010
- package/dist/app-config-_kkj71CB.d.ts +0 -2010
- package/dist/app-config-fEjRm1o9.d.cts +0 -2402
- package/dist/app-config-fEjRm1o9.d.ts +0 -2402
- package/dist/app-config-oU1EGHND.d.cts +0 -1538
- package/dist/app-config-oU1EGHND.d.ts +0 -1538
- package/dist/app-config-ouBRb6Bf.d.cts +0 -1716
- package/dist/app-config-ouBRb6Bf.d.ts +0 -1716
- package/dist/app-config-oz8H_MOX.d.cts +0 -2224
- package/dist/app-config-oz8H_MOX.d.ts +0 -2224
- package/dist/app-config-tITj_0sn.d.cts +0 -1926
- package/dist/app-config-tITj_0sn.d.ts +0 -1926
- package/dist/app-config-wnLtFu6c.d.cts +0 -1538
- package/dist/app-config-wnLtFu6c.d.ts +0 -1538
- package/dist/app-config-x-CnipcA.d.cts +0 -2072
- package/dist/app-config-x-CnipcA.d.ts +0 -2072
- package/dist/app.d.ts +0 -35
- package/dist/app.d.ts.map +0 -1
- package/dist/app.js +0 -164
- package/dist/app.js.map +0 -1
- package/dist/auth/access.d.ts +0 -5
- package/dist/auth/access.d.ts.map +0 -1
- package/dist/auth/access.js +0 -59
- package/dist/auth/access.js.map +0 -1
- package/dist/auth/jexl.d.ts +0 -13
- package/dist/auth/jexl.d.ts.map +0 -1
- package/dist/auth/jexl.js +0 -30
- package/dist/auth/jexl.js.map +0 -1
- package/dist/auth/lockout.d.ts +0 -11
- package/dist/auth/lockout.d.ts.map +0 -1
- package/dist/auth/lockout.js +0 -37
- package/dist/auth/lockout.js.map +0 -1
- package/dist/auth/password.d.ts +0 -10
- package/dist/auth/password.d.ts.map +0 -1
- package/dist/auth/password.js +0 -28
- package/dist/auth/password.js.map +0 -1
- package/dist/auth/sessions.d.ts +0 -39
- package/dist/auth/sessions.d.ts.map +0 -1
- package/dist/auth/sessions.js +0 -126
- package/dist/auth/sessions.js.map +0 -1
- package/dist/auth/token.d.ts +0 -23
- package/dist/auth/token.d.ts.map +0 -1
- package/dist/auth/token.js +0 -40
- package/dist/auth/token.js.map +0 -1
- package/dist/chunk-23NM4LDU.js +0 -2883
- package/dist/chunk-2TKDCCIR.js +0 -2622
- package/dist/chunk-2UXLA4YN.js +0 -3139
- package/dist/chunk-2WODKOUB.js +0 -1627
- package/dist/chunk-35NM2WPO.js +0 -1658
- package/dist/chunk-3CMG2BH2.js +0 -1618
- package/dist/chunk-3SFITPX4.js +0 -2628
- package/dist/chunk-3TRRTN6U.js +0 -3441
- package/dist/chunk-57FNM42D.js +0 -2392
- package/dist/chunk-5U2WRCNH.js +0 -3140
- package/dist/chunk-5ZIA5COH.js +0 -3414
- package/dist/chunk-6TWQ6GTD.js +0 -3480
- package/dist/chunk-AKYYGMFS.js +0 -3365
- package/dist/chunk-AQO4HI2Y.js +0 -3204
- package/dist/chunk-BAMX7YUC.js +0 -1815
- package/dist/chunk-BQV3QW3Y.js +0 -2588
- package/dist/chunk-CQVTQ67D.js +0 -2632
- package/dist/chunk-CUOPCOU2.js +0 -1644
- package/dist/chunk-DCY7QHRB.js +0 -1637
- package/dist/chunk-DFBLNYUH.js +0 -3402
- package/dist/chunk-EH3MJGB5.js +0 -2571
- package/dist/chunk-EJG6AMYB.js +0 -3537
- package/dist/chunk-ELHRRPKX.js +0 -2863
- package/dist/chunk-EOW4YMAV.js +0 -1637
- package/dist/chunk-G43REXPX.js +0 -3147
- package/dist/chunk-GFKBPBJJ.js +0 -3637
- package/dist/chunk-HRLSFTLR.js +0 -3061
- package/dist/chunk-JFA22YFB.js +0 -1625
- package/dist/chunk-K3ASMUKV.js +0 -2601
- package/dist/chunk-KEKOEAX6.js +0 -3139
- package/dist/chunk-L65PQYDP.js +0 -1536
- package/dist/chunk-LFGSRQLX.js +0 -3568
- package/dist/chunk-M3HKRN7E.js +0 -1665
- package/dist/chunk-MQZH7RQC.js +0 -1667
- package/dist/chunk-NNZRYF3U.js +0 -3537
- package/dist/chunk-PRQ2RF5C.js +0 -3485
- package/dist/chunk-PYE2JSY4.js +0 -3568
- package/dist/chunk-PZMDK3MH.js +0 -3203
- package/dist/chunk-QCXLDKZO.js +0 -3272
- package/dist/chunk-QTIAQBNH.js +0 -3097
- package/dist/chunk-ROECUARS.js +0 -2615
- package/dist/chunk-SM32ND5M.js +0 -3472
- package/dist/chunk-T2DGC4MD.js +0 -3008
- package/dist/chunk-T626OZMH.js +0 -2602
- package/dist/chunk-TEGRS6J7.js +0 -2609
- package/dist/chunk-TLU77TLE.js +0 -3203
- package/dist/chunk-UKUEKTAO.js +0 -513
- package/dist/chunk-VCYYBN5J.js +0 -1873
- package/dist/chunk-VM43G3IG.js +0 -506
- package/dist/chunk-VWJKFZQU.js +0 -3139
- package/dist/chunk-WF5A6PDJ.js +0 -1618
- package/dist/chunk-WVD7PORQ.js +0 -1672
- package/dist/chunk-XX7N64NL.js +0 -3550
- package/dist/chunk-XZLIBQSO.js +0 -2397
- package/dist/chunk-YEBCT77K.js +0 -3269
- package/dist/chunk-YSSHLGQ6.js +0 -3139
- package/dist/chunk-YXEKNN5X.js +0 -3085
- package/dist/chunk-Z7CFUYVP.js +0 -3653
- package/dist/chunk-ZISFMAEL.js +0 -3550
- package/dist/controllers/admin-auth.controller.d.ts +0 -71
- package/dist/controllers/admin-auth.controller.d.ts.map +0 -1
- package/dist/controllers/admin-auth.controller.js +0 -450
- package/dist/controllers/admin-auth.controller.js.map +0 -1
- package/dist/controllers/audit.controller.d.ts +0 -42
- package/dist/controllers/audit.controller.d.ts.map +0 -1
- package/dist/controllers/audit.controller.js +0 -149
- package/dist/controllers/audit.controller.js.map +0 -1
- package/dist/controllers/auth.controller.d.ts +0 -143
- package/dist/controllers/auth.controller.d.ts.map +0 -1
- package/dist/controllers/auth.controller.js +0 -572
- package/dist/controllers/auth.controller.js.map +0 -1
- package/dist/controllers/collection.controller.d.ts +0 -170
- package/dist/controllers/collection.controller.d.ts.map +0 -1
- package/dist/controllers/collection.controller.js +0 -1033
- package/dist/controllers/collection.controller.js.map +0 -1
- package/dist/controllers/global.controller.d.ts +0 -20
- package/dist/controllers/global.controller.d.ts.map +0 -1
- package/dist/controllers/global.controller.js +0 -182
- package/dist/controllers/global.controller.js.map +0 -1
- package/dist/controllers/media.controller.d.ts +0 -39
- package/dist/controllers/media.controller.d.ts.map +0 -1
- package/dist/controllers/media.controller.js +0 -178
- package/dist/controllers/media.controller.js.map +0 -1
- package/dist/controllers/preview.controller.d.ts +0 -37
- package/dist/controllers/preview.controller.d.ts.map +0 -1
- package/dist/controllers/preview.controller.js +0 -48
- package/dist/controllers/preview.controller.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/middleware/auth.d.ts +0 -19
- package/dist/middleware/auth.d.ts.map +0 -1
- package/dist/middleware/auth.js +0 -157
- package/dist/middleware/auth.js.map +0 -1
- package/dist/middleware/rate-limit.d.ts +0 -9
- package/dist/middleware/rate-limit.d.ts.map +0 -1
- package/dist/middleware/rate-limit.js +0 -75
- package/dist/middleware/rate-limit.js.map +0 -1
- package/dist/network.d.ts +0 -6
- package/dist/network.d.ts.map +0 -1
- package/dist/network.js +0 -70
- package/dist/network.js.map +0 -1
- package/dist/observability-CNM4QFE4.js +0 -34
- package/dist/observability-L5BORBB2.js +0 -34
- package/dist/observability.d.ts +0 -113
- package/dist/observability.d.ts.map +0 -1
- package/dist/observability.js +0 -497
- package/dist/observability.js.map +0 -1
- package/dist/router.d.ts +0 -8
- package/dist/router.d.ts.map +0 -1
- package/dist/router.js +0 -704
- package/dist/router.js.map +0 -1
- package/dist/server.d.ts.map +0 -1
- package/dist/server.js.map +0 -1
- package/dist/services/audit.service.d.ts +0 -23
- package/dist/services/audit.service.d.ts.map +0 -1
- package/dist/services/audit.service.js +0 -39
- package/dist/services/audit.service.js.map +0 -1
- package/dist/services/defaults.service.d.ts +0 -8
- package/dist/services/defaults.service.d.ts.map +0 -1
- package/dist/services/defaults.service.js +0 -55
- package/dist/services/defaults.service.js.map +0 -1
- package/dist/services/email-template.d.ts +0 -46
- package/dist/services/email-template.d.ts.map +0 -1
- package/dist/services/email-template.js +0 -88
- package/dist/services/email-template.js.map +0 -1
- package/dist/services/email.service.d.ts +0 -34
- package/dist/services/email.service.d.ts.map +0 -1
- package/dist/services/email.service.js +0 -129
- package/dist/services/email.service.js.map +0 -1
- package/dist/services/media.service.d.ts +0 -20
- package/dist/services/media.service.d.ts.map +0 -1
- package/dist/services/media.service.js +0 -49
- package/dist/services/media.service.js.map +0 -1
- package/dist/services/population.service.d.ts +0 -20
- package/dist/services/population.service.d.ts.map +0 -1
- package/dist/services/population.service.js +0 -224
- package/dist/services/population.service.js.map +0 -1
- package/dist/types/access.d.ts +0 -48
- package/dist/types/access.d.ts.map +0 -1
- package/dist/types/access.js +0 -2
- package/dist/types/access.js.map +0 -1
- package/dist/types/adapters.d.ts +0 -152
- package/dist/types/adapters.d.ts.map +0 -1
- package/dist/types/adapters.js +0 -2
- package/dist/types/adapters.js.map +0 -1
- package/dist/types/admin-auth.d.ts +0 -132
- package/dist/types/admin-auth.d.ts.map +0 -1
- package/dist/types/admin-auth.js +0 -2
- package/dist/types/admin-auth.js.map +0 -1
- package/dist/types/admin.d.ts +0 -86
- package/dist/types/admin.d.ts.map +0 -1
- package/dist/types/admin.js +0 -2
- package/dist/types/admin.js.map +0 -1
- package/dist/types/app-config.d.ts +0 -279
- package/dist/types/app-config.d.ts.map +0 -1
- package/dist/types/app-config.js +0 -2
- package/dist/types/app-config.js.map +0 -1
- package/dist/types/documents.d.ts +0 -65
- package/dist/types/documents.d.ts.map +0 -1
- package/dist/types/documents.js +0 -2
- package/dist/types/documents.js.map +0 -1
- package/dist/types/hooks.d.ts +0 -122
- package/dist/types/hooks.d.ts.map +0 -1
- package/dist/types/hooks.js +0 -2
- package/dist/types/hooks.js.map +0 -1
- package/dist/types/index.d.ts +0 -13
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -13
- package/dist/types/index.js.map +0 -1
- package/dist/types/request.d.ts +0 -42
- package/dist/types/request.d.ts.map +0 -1
- package/dist/types/request.js +0 -2
- package/dist/types/request.js.map +0 -1
- package/dist/types/schema-config.d.ts +0 -443
- package/dist/types/schema-config.d.ts.map +0 -1
- package/dist/types/schema-config.js +0 -2
- package/dist/types/schema-config.js.map +0 -1
- package/dist/types/schema-core.d.ts +0 -628
- package/dist/types/schema-core.d.ts.map +0 -1
- package/dist/types/schema-core.js +0 -2
- package/dist/types/schema-core.js.map +0 -1
- package/dist/types/schema-inference.d.ts +0 -73
- package/dist/types/schema-inference.d.ts.map +0 -1
- package/dist/types/schema-inference.js +0 -2
- package/dist/types/schema-inference.js.map +0 -1
- package/dist/types/workflows.d.ts +0 -121
- package/dist/types/workflows.d.ts.map +0 -1
- package/dist/types/workflows.js +0 -7
- package/dist/types/workflows.js.map +0 -1
- package/dist/utils/access-control.d.ts +0 -35
- package/dist/utils/access-control.d.ts.map +0 -1
- package/dist/utils/access-control.js +0 -161
- package/dist/utils/access-control.js.map +0 -1
- package/dist/utils/admin-auth.d.ts +0 -5
- package/dist/utils/admin-auth.d.ts.map +0 -1
- package/dist/utils/admin-auth.js +0 -39
- package/dist/utils/admin-auth.js.map +0 -1
- package/dist/utils/block-references.d.ts +0 -10
- package/dist/utils/block-references.d.ts.map +0 -1
- package/dist/utils/block-references.js +0 -100
- package/dist/utils/block-references.js.map +0 -1
- package/dist/utils/collection-search.d.ts +0 -11
- package/dist/utils/collection-search.d.ts.map +0 -1
- package/dist/utils/collection-search.js +0 -204
- package/dist/utils/collection-search.js.map +0 -1
- package/dist/utils/config.d.ts +0 -8
- package/dist/utils/config.d.ts.map +0 -1
- package/dist/utils/config.js +0 -336
- package/dist/utils/config.js.map +0 -1
- package/dist/utils/hooks.d.ts +0 -41
- package/dist/utils/hooks.d.ts.map +0 -1
- package/dist/utils/hooks.js +0 -177
- package/dist/utils/hooks.js.map +0 -1
- package/dist/utils/openapi.d.ts +0 -6
- package/dist/utils/openapi.d.ts.map +0 -1
- package/dist/utils/openapi.js +0 -981
- package/dist/utils/openapi.js.map +0 -1
- package/dist/utils/parse-sort.d.ts +0 -43
- package/dist/utils/parse-sort.d.ts.map +0 -1
- package/dist/utils/parse-sort.js +0 -70
- package/dist/utils/parse-sort.js.map +0 -1
- package/dist/utils/parse-where.d.ts +0 -69
- package/dist/utils/parse-where.d.ts.map +0 -1
- package/dist/utils/parse-where.js +0 -202
- package/dist/utils/parse-where.js.map +0 -1
- package/dist/utils/readonly-db.d.ts +0 -9
- package/dist/utils/readonly-db.d.ts.map +0 -1
- package/dist/utils/readonly-db.js +0 -21
- package/dist/utils/readonly-db.js.map +0 -1
- package/dist/utils/swagger.d.ts +0 -11
- package/dist/utils/swagger.d.ts.map +0 -1
- package/dist/utils/swagger.js +0 -62
- package/dist/utils/swagger.js.map +0 -1
- package/dist/utils/upload-validation.d.ts +0 -23
- package/dist/utils/upload-validation.d.ts.map +0 -1
- package/dist/utils/upload-validation.js +0 -46
- package/dist/utils/upload-validation.js.map +0 -1
- package/dist/utils/where-sanitizer.d.ts +0 -10
- package/dist/utils/where-sanitizer.d.ts.map +0 -1
- package/dist/utils/where-sanitizer.js +0 -67
- package/dist/utils/where-sanitizer.js.map +0 -1
- package/dist/workflows.d.ts +0 -86
- package/dist/workflows.d.ts.map +0 -1
- package/dist/workflows.js +0 -405
- package/dist/workflows.js.map +0 -1
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns true if `mimeType` matches any of the allowed patterns.
|
|
3
|
-
* Patterns support an any-type wildcard, a `type/*` wildcard (e.g. `image/*`),
|
|
4
|
-
* or an exact `type/subtype` match. Matching is case-insensitive.
|
|
5
|
-
*/
|
|
6
|
-
export function isMimeAllowed(mimeType, allowed) {
|
|
7
|
-
const type = (mimeType || "").toLowerCase().trim();
|
|
8
|
-
return allowed.some((raw) => {
|
|
9
|
-
const pattern = (raw || "").toLowerCase().trim();
|
|
10
|
-
if (!pattern)
|
|
11
|
-
return false;
|
|
12
|
-
if (pattern === "*" || pattern === "*/*")
|
|
13
|
-
return true;
|
|
14
|
-
if (pattern.endsWith("/*"))
|
|
15
|
-
return type.startsWith(pattern.slice(0, -1)); // "image/*" -> "image/"
|
|
16
|
-
return type === pattern;
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Validates an uploaded file against a collection's {@link UploadConfig}.
|
|
21
|
-
* Enforces `allowedMimeTypes` and `maxFileSize` when they are configured.
|
|
22
|
-
* Returns `null` when the upload is allowed (or when no config restricts it).
|
|
23
|
-
*/
|
|
24
|
-
export function validateUpload(file, config) {
|
|
25
|
-
if (!config)
|
|
26
|
-
return null;
|
|
27
|
-
const { allowedMimeTypes, maxFileSize } = config;
|
|
28
|
-
if (allowedMimeTypes && allowedMimeTypes.length > 0) {
|
|
29
|
-
if (!isMimeAllowed(file.type || "", allowedMimeTypes)) {
|
|
30
|
-
return {
|
|
31
|
-
status: 415,
|
|
32
|
-
message: `File type "${file.type || "unknown"}" is not allowed. Allowed types: ${allowedMimeTypes.join(", ")}.`,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
if (typeof maxFileSize === "number" &&
|
|
37
|
-
typeof file.size === "number" &&
|
|
38
|
-
file.size > maxFileSize) {
|
|
39
|
-
return {
|
|
40
|
-
status: 413,
|
|
41
|
-
message: `File is too large (${file.size} bytes). Maximum allowed size is ${maxFileSize} bytes.`,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=upload-validation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upload-validation.js","sourceRoot":"","sources":["../../src/utils/upload-validation.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,QAAgB,EAAE,OAAiB;IAC/D,MAAM,IAAI,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAC;IACnD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;QAC1B,MAAM,OAAO,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,IAAI,EAA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'./parse-where.js';
|
|
2
|
-
import type { Field } from '../types/index.js';
|
|
3
|
-
/**
|
|
4
|
-
* Sanitizes a WhereClause by stripping out any fields that:
|
|
5
|
-
* 1. Do not exist in the schema.
|
|
6
|
-
* 2. Have admin.filterable === false.
|
|
7
|
-
* 3. Are of a type that is never filterable (e.g. password, richText).
|
|
8
|
-
*/
|
|
9
|
-
export declare function sanitizeWhereClause(where: WhereClause, fields: Field[]): WhereClause;
|
|
10
|
-
//# sourceMappingURL=where-sanitizer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"where-sanitizer.d.ts","sourceRoot":"","sources":["../../src/utils/where-sanitizer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAY/C;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,WAAW,CAwDpF"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
const NEVER_FILTERABLE_TYPES = [
|
|
2
|
-
'password',
|
|
3
|
-
'richText',
|
|
4
|
-
'json',
|
|
5
|
-
'file',
|
|
6
|
-
'image',
|
|
7
|
-
'join',
|
|
8
|
-
'collapsible'
|
|
9
|
-
];
|
|
10
|
-
/**
|
|
11
|
-
* Sanitizes a WhereClause by stripping out any fields that:
|
|
12
|
-
* 1. Do not exist in the schema.
|
|
13
|
-
* 2. Have admin.filterable === false.
|
|
14
|
-
* 3. Are of a type that is never filterable (e.g. password, richText).
|
|
15
|
-
*/
|
|
16
|
-
export function sanitizeWhereClause(where, fields) {
|
|
17
|
-
// Build a fast lookup map for fields, including nested fields if needed.
|
|
18
|
-
// For simplicity, we just look at top-level fields for now, as the DSL is flat.
|
|
19
|
-
// If the DSL supports nested properties (e.g., block fields), we'd need a deep lookup.
|
|
20
|
-
const fieldMap = new Map();
|
|
21
|
-
function addFieldsToMap(fList, prefix = '') {
|
|
22
|
-
for (const f of fList) {
|
|
23
|
-
if ('name' in f && f.name) {
|
|
24
|
-
fieldMap.set(prefix + f.name, f);
|
|
25
|
-
}
|
|
26
|
-
// If we support filtering inside groups/rows, we would recurse here.
|
|
27
|
-
// But for now, let's just do top-level.
|
|
28
|
-
if (f.type === 'object' || f.type === 'row' || f.type === 'array') {
|
|
29
|
-
if ('fields' in f && Array.isArray(f.fields)) {
|
|
30
|
-
addFieldsToMap(f.fields, f.type === 'object' || f.type === 'array' ? `${prefix}${f.name}.` : prefix);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
addFieldsToMap(fields);
|
|
36
|
-
function walk(node) {
|
|
37
|
-
const result = {};
|
|
38
|
-
for (const [key, value] of Object.entries(node)) {
|
|
39
|
-
if (key === 'AND' || key === 'OR') {
|
|
40
|
-
if (Array.isArray(value)) {
|
|
41
|
-
const processed = value.map(v => walk(v)).filter(v => Object.keys(v).length > 0);
|
|
42
|
-
if (processed.length > 0) {
|
|
43
|
-
result[key] = processed;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
// It's a field condition
|
|
49
|
-
if (key === 'id') {
|
|
50
|
-
result[key] = value;
|
|
51
|
-
continue;
|
|
52
|
-
}
|
|
53
|
-
const fieldDef = fieldMap.get(key);
|
|
54
|
-
if (!fieldDef)
|
|
55
|
-
continue; // Field doesn't exist
|
|
56
|
-
if (fieldDef.admin?.filterable === false)
|
|
57
|
-
continue; // Explicitly opted out
|
|
58
|
-
if (NEVER_FILTERABLE_TYPES.includes(fieldDef.type))
|
|
59
|
-
continue; // Never filterable type
|
|
60
|
-
// Keep the field
|
|
61
|
-
result[key] = value;
|
|
62
|
-
}
|
|
63
|
-
return result;
|
|
64
|
-
}
|
|
65
|
-
return walk(where);
|
|
66
|
-
}
|
|
67
|
-
//# sour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KAAK,CAAC,CAAC;AACrB,CAAC"}
|
package/dist/workflows.d.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import type { AuthenticatedUser, BaseDocument, CollectionConfig, DyrectedConfig, HookRequestContext, LifecycleEvent, LifecycleEventName, WorkflowConfig, WorkflowTransition } from "./types/index.js";
|
|
2
|
-
export declare const WORKFLOW_HISTORY_COLLECTION = "__workflow_history";
|
|
3
|
-
export declare const LIFECYCLE_EVENTS_COLLECTION = "__lifecycle_events";
|
|
4
|
-
/**
|
|
5
|
-
* Role mapping for {@link definePublishingWorkflow}. Map your app's own role
|
|
6
|
-
* values onto the publishing workflow's two capability tiers.
|
|
7
|
-
*/
|
|
8
|
-
export interface PublishingWorkflowOptions {
|
|
9
|
-
/** Role values allowed to edit and submit for review. Defaults to `["editor"]`. */
|
|
10
|
-
editors?: string[];
|
|
11
|
-
/** Role values allowed to also publish and unpublish. Defaults to `["publisher", "admin"]`. */
|
|
12
|
-
publishers?: string[];
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Build a `draft → in review → published` editorial workflow, mapping your own
|
|
16
|
-
* role values onto its capability tiers. Reach for this instead of
|
|
17
|
-
* {@link publishingWorkflow} when your roles aren't named
|
|
18
|
-
* `editor`/`publisher`/`admin`.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* workflow: definePublishingWorkflow({
|
|
22
|
-
* editors: ["writer"],
|
|
23
|
-
* publishers: ["managing-editor", "admin"],
|
|
24
|
-
* })
|
|
25
|
-
*/
|
|
26
|
-
export declare function definePublishingWorkflow(options?: PublishingWorkflowOptions): WorkflowConfig;
|
|
27
|
-
/**
|
|
28
|
-
* The default `draft → in review → published` editorial workflow, using the
|
|
29
|
-
* conventional role names `editor`, `publisher`, and `admin`. Shorthand for
|
|
30
|
-
* `definePublishingWorkflow()` — use {@link definePublishingWorkflow} to map
|
|
31
|
-
* your own role names onto its capability tiers.
|
|
32
|
-
*/
|
|
33
|
-
export declare function publishingWorkflow(): WorkflowConfig;
|
|
34
|
-
export declare function simplePublishingWorkflow(): WorkflowConfig;
|
|
35
|
-
export declare function workflowCapabilities(workflow: WorkflowConfig, user?: AuthenticatedUser): Set<string>;
|
|
36
|
-
export declare function canViewWorkflowDraft(workflow: WorkflowConfig, user?: AuthenticatedUser): boolean;
|
|
37
|
-
export declare function availableWorkflowTransitions(workflow: WorkflowConfig, state: string, user?: AuthenticatedUser): WorkflowTransition[];
|
|
38
|
-
export declare function initializeWorkflowDocument(data: Record<string, unknown>, workflow: WorkflowConfig): {
|
|
39
|
-
__workflow: {
|
|
40
|
-
state: string;
|
|
41
|
-
revision: number;
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
/** The state a legacy document is treated as: the published one, else the last. */
|
|
45
|
-
export declare function publishedStateName(workflow: WorkflowConfig): string;
|
|
46
|
-
export declare function materializeWorkflowDocument(doc: BaseDocument, workflow: WorkflowConfig, user?: AuthenticatedUser): BaseDocument | null;
|
|
47
|
-
export declare function createLifecycleEvent(args: {
|
|
48
|
-
name: LifecycleEventName;
|
|
49
|
-
collection: string;
|
|
50
|
-
documentId: string;
|
|
51
|
-
actorId?: string;
|
|
52
|
-
payload: Record<string, unknown>;
|
|
53
|
-
}): LifecycleEvent;
|
|
54
|
-
export declare function dispatchLifecycleEvent(config: DyrectedConfig, event: LifecycleEvent): Promise<void>;
|
|
55
|
-
export declare function dispatchPendingLifecycleEvents(config: DyrectedConfig, limit?: number): Promise<number>;
|
|
56
|
-
export declare function saveWorkflowDraft(args: {
|
|
57
|
-
config: DyrectedConfig;
|
|
58
|
-
collection: CollectionConfig;
|
|
59
|
-
id: string;
|
|
60
|
-
originalDoc: BaseDocument;
|
|
61
|
-
data: Record<string, unknown>;
|
|
62
|
-
user?: AuthenticatedUser;
|
|
63
|
-
}): Promise<{
|
|
64
|
-
doc: BaseDocument;
|
|
65
|
-
event: LifecycleEvent;
|
|
66
|
-
}>;
|
|
67
|
-
export declare function createWorkflowDocument(args: {
|
|
68
|
-
config: DyrectedConfig;
|
|
69
|
-
collection: CollectionConfig;
|
|
70
|
-
data: Record<string, unknown>;
|
|
71
|
-
user?: AuthenticatedUser;
|
|
72
|
-
}): Promise<{
|
|
73
|
-
doc: BaseDocument;
|
|
74
|
-
event: LifecycleEvent;
|
|
75
|
-
}>;
|
|
76
|
-
export declare function transitionWorkflow(args: {
|
|
77
|
-
config: DyrectedConfig;
|
|
78
|
-
collection: CollectionConfig;
|
|
79
|
-
id: string;
|
|
80
|
-
transitionName: string;
|
|
81
|
-
expectedRevision?: number;
|
|
82
|
-
comment?: string;
|
|
83
|
-
user?: AuthenticatedUser;
|
|
84
|
-
req: HookRequestContext;
|
|
85
|
-
}): Promise<BaseDocument>;
|
|
86
|
-
//# sourceMappingURL=workflows.d.ts.map
|
package/dist/workflows.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"workflows.d.ts","sourceRoot":"","sources":["../src/workflows.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAEhB,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,cAAc,EAEd,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAG1B,eAAO,MAAM,2BAA2B,uBAAuB,CAAC;AAChE,eAAO,MAAM,2BAA2B,uBAAuB,CAAC;AAOhE;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,mFAAmF;IACnF,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,+FAA+F;IAC/F,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,GAAE,yBAA8B,GAAG,cAAc,CAsBhG;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,IAAI,cAAc,CAEnD;AAED,wBAAgB,wBAAwB,IAAI,cAAc,CAgBzD;AAQD,wBAAgB,o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AC;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,YAAY,CAAC;IAC1B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,iBAAiB,CAAC;CAC1B,GAAG,OAAO,CAAC;IAAE,GAAG,EAAE,YAAY,CAAC;IAAC,KAAK,EAAE,cAAc,CAAA;CAAE,CAAC,CA+CxD;AAED,wBAAsB,sBAAsB,CAAC,IAAI,EAAE;IACjD,MAAM,EAAE,cAAc,CAAC;IACvB,UAAU,EAAE,gBAAgB,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,IAAI,CAAC,EAAE,iBAAiB,CAAC;CAC1B,GAAG,OAAO,CAAC;IAAE,GAAG,EAAE,YAAY,CAAC;IAAC,KAAK,EAAE,cAAc,CAAA;CAAE,CAAC,CAmBxD;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE;IAC7C,MAAM,EAAE,cAAc,CAAC;IACvB,UAAU,EAAE,gBAAgB,CAAC;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,GAAG,EAAE,kBAAkB,CAAC;CACzB,GAAG,OAAO,CAAC,YAAY,CAAC,CA8FxB"}
|
package/dist/workflows.js
DELETED
|
@@ -1,405 +0,0 @@
|
|
|
1
|
-
import { getConfigLogger, getObservabilityRuntime } from "./observability.js";
|
|
2
|
-
export const WORKFLOW_HISTORY_COLLECTION = "__workflow_history";
|
|
3
|
-
export const LIFECYCLE_EVENTS_COLLECTION = "__lifecycle_events";
|
|
4
|
-
/** Capabilities granted to the "editor" tier — edit and submit for review. */
|
|
5
|
-
const EDITOR_CAPABILITIES = ["entry.edit", "entry.submit"];
|
|
6
|
-
/** Capabilities granted to the "publisher" tier — edit, submit, publish, unpublish. */
|
|
7
|
-
const PUBLISHER_CAPABILITIES = ["entry.edit", "entry.submit", "entry.publish", "entry.unpublish"];
|
|
8
|
-
/**
|
|
9
|
-
* Build a `draft → in review → published` editorial workflow, mapping your own
|
|
10
|
-
* role values onto its capability tiers. Reach for this instead of
|
|
11
|
-
* {@link publishingWorkflow} when your roles aren't named
|
|
12
|
-
* `editor`/`publisher`/`admin`.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* workflow: definePublishingWorkflow({
|
|
16
|
-
* editors: ["writer"],
|
|
17
|
-
* publishers: ["managing-editor", "admin"],
|
|
18
|
-
* })
|
|
19
|
-
*/
|
|
20
|
-
export function definePublishingWorkflow(options = {}) {
|
|
21
|
-
const editors = options.editors ?? ["editor"];
|
|
22
|
-
const publishers = options.publishers ?? ["publisher", "admin"];
|
|
23
|
-
return {
|
|
24
|
-
initialState: "draft",
|
|
25
|
-
draftState: "draft",
|
|
26
|
-
states: [
|
|
27
|
-
{ name: "draft", label: "Draft", color: "neutral" },
|
|
28
|
-
{ name: "in_review", label: "In review", color: "warning" },
|
|
29
|
-
{ name: "published", label: "Published", color: "success", published: true },
|
|
30
|
-
],
|
|
31
|
-
transitions: [
|
|
32
|
-
{ name: "submit", label: "Submit for review", from: "draft", to: "in_review", requiredCapabilities: ["entry.submit"] },
|
|
33
|
-
{ name: "publish", label: "Publish", from: "in_review", to: "published", requiredCapabilities: ["entry.publish"] },
|
|
34
|
-
{ name: "reject", label: "Request changes", from: "in_review", to: "draft", requiredCapabilities: ["entry.publish"], requireComment: true },
|
|
35
|
-
{ name: "unpublish", label: "Unpublish", from: "published", to: "draft", requiredCapabilities: ["entry.unpublish"], unpublish: true },
|
|
36
|
-
],
|
|
37
|
-
roles: [
|
|
38
|
-
...editors.map((role) => ({ role, capabilities: [...EDITOR_CAPABILITIES] })),
|
|
39
|
-
...publishers.map((role) => ({ role, capabilities: [...PUBLISHER_CAPABILITIES] })),
|
|
40
|
-
],
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* The default `draft → in review → published` editorial workflow, using the
|
|
45
|
-
* conventional role names `editor`, `publisher`, and `admin`. Shorthand for
|
|
46
|
-
* `definePublishingWorkflow()` — use {@link definePublishingWorkflow} to map
|
|
47
|
-
* your own role names onto its capability tiers.
|
|
48
|
-
*/
|
|
49
|
-
export function publishingWorkflow() {
|
|
50
|
-
return definePublishingWorkflow();
|
|
51
|
-
}
|
|
52
|
-
export function simplePublishingWorkflow() {
|
|
53
|
-
return {
|
|
54
|
-
initialState: "draft",
|
|
55
|
-
draftState: "draft",
|
|
56
|
-
states: [
|
|
57
|
-
{ name: "draft", label: "Draft", color: "neutral" },
|
|
58
|
-
{ name: "published", label: "Published", color: "success", published: true },
|
|
59
|
-
],
|
|
60
|
-
transitions: [
|
|
61
|
-
{ name: "publish", label: "Publish", from: "draft", to: "published" },
|
|
62
|
-
{ name: "unpublish", label: "Unpublish", from: "published", to: "draft", unpublish: true },
|
|
63
|
-
],
|
|
64
|
-
// Intentionally no `roles`: this lightweight workflow (synthesized from
|
|
65
|
-
// `drafts: true`) does no capability-based gating. Draft visibility for a
|
|
66
|
-
// no-roles workflow is handled in `canViewWorkflowDraft`.
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
function publicMetadata(meta) {
|
|
70
|
-
const { availableTransitions: _availableTransitions, ...safe } = meta;
|
|
71
|
-
return safe;
|
|
72
|
-
}
|
|
73
|
-
export function workflowCapabilities(workflow, user) {
|
|
74
|
-
const capabilities = new Set(Array.isArray(user?.capabilities) ? user.capabilities : []);
|
|
75
|
-
const roles = Array.isArray(user?.roles) ? user.roles : [];
|
|
76
|
-
for (const mapping of workflow.roles ?? []) {
|
|
77
|
-
if (roles.includes(mapping.role))
|
|
78
|
-
mapping.capabilities.forEach((capability) => capabilities.add(capability));
|
|
79
|
-
}
|
|
80
|
-
return capabilities;
|
|
81
|
-
}
|
|
82
|
-
export function canViewWorkflowDraft(workflow, user) {
|
|
83
|
-
if (!user)
|
|
84
|
-
return false;
|
|
85
|
-
const capabilities = workflowCapabilities(workflow, user);
|
|
86
|
-
if (capabilities.has("entry.edit"))
|
|
87
|
-
return true;
|
|
88
|
-
if (workflow.transitions.some((transition) => (transition.requiredCapabilities ?? []).some((capability) => capabilities.has(capability)))) {
|
|
89
|
-
return true;
|
|
90
|
-
}
|
|
91
|
-
// A workflow with no role→capability mappings (e.g. the one synthesized from
|
|
92
|
-
// `drafts: true`) does no capability-based gating. Rather than hide drafts
|
|
93
|
-
// from everyone — which would empty the Admin list — let any authenticated
|
|
94
|
-
// user view them. Unauthenticated/public readers are already excluded above,
|
|
95
|
-
// so drafts still never leak to the public site.
|
|
96
|
-
if (!workflow.roles || workflow.roles.length === 0)
|
|
97
|
-
return true;
|
|
98
|
-
return false;
|
|
99
|
-
}
|
|
100
|
-
export function availableWorkflowTransitions(workflow, state, user) {
|
|
101
|
-
const capabilities = workflowCapabilities(workflow, user);
|
|
102
|
-
return workflow.transitions.filter((transition) => {
|
|
103
|
-
const from = Array.isArray(transition.from) ? transition.from : [transition.from];
|
|
104
|
-
return from.includes(state) && (transition.requiredCapabilities ?? []).every((item) => capabilities.has(item));
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
export function initializeWorkflowDocument(data, workflow) {
|
|
108
|
-
return {
|
|
109
|
-
...data,
|
|
110
|
-
__workflow: { state: workflow.initialState, revision: 1 },
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
/** The state a legacy document is treated as: the published one, else the last. */
|
|
114
|
-
export function publishedStateName(workflow) {
|
|
115
|
-
return (workflow.states.find((state) => state.published)?.name ??
|
|
116
|
-
workflow.states[workflow.states.length - 1]?.name ??
|
|
117
|
-
workflow.initialState);
|
|
118
|
-
}
|
|
119
|
-
export function materializeWorkflowDocument(doc, workflow, user) {
|
|
120
|
-
const meta = doc.__workflow;
|
|
121
|
-
const publishedState = publishedStateName(workflow);
|
|
122
|
-
// Legacy content: a document that predates the workflow (no `__workflow`).
|
|
123
|
-
// Treat it as already-published live content — its own fields are the
|
|
124
|
-
// published snapshot — so it stays visible to everyone and surfaces the
|
|
125
|
-
// workflow panel in the Admin. Without this, enabling `drafts`/workflow on an
|
|
126
|
-
// existing collection would leave old documents with no workflow metadata.
|
|
127
|
-
if (!meta) {
|
|
128
|
-
const { __published: _legacyPublished, __workflow: _legacyWorkflow, ...working } = doc;
|
|
129
|
-
const state = publishedStateName(workflow);
|
|
130
|
-
return {
|
|
131
|
-
...working,
|
|
132
|
-
_workflow: {
|
|
133
|
-
state,
|
|
134
|
-
revision: 1,
|
|
135
|
-
availableTransitions: availableWorkflowTransitions(workflow, state, user).map((item) => item.name),
|
|
136
|
-
},
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
const { __published, __workflow, ...working } = doc;
|
|
140
|
-
if (!canViewWorkflowDraft(workflow, user)) {
|
|
141
|
-
if (!__published || typeof __published !== "object") {
|
|
142
|
-
if (meta.state === publishedState) {
|
|
143
|
-
return { ...working, _workflow: publicMetadata(meta) };
|
|
144
|
-
}
|
|
145
|
-
return null;
|
|
146
|
-
}
|
|
147
|
-
return { id: doc.id, ...__published, _workflow: publicMetadata(meta) };
|
|
148
|
-
}
|
|
149
|
-
return {
|
|
150
|
-
...working,
|
|
151
|
-
_workflow: {
|
|
152
|
-
...meta,
|
|
153
|
-
availableTransitions: availableWorkflowTransitions(workflow, meta.state, user).map((item) => item.name),
|
|
154
|
-
},
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
function eventId() {
|
|
158
|
-
return globalThis.crypto?.randomUUID?.() ?? `evt_${Date.now()}_${Math.random().toString(36).slice(2)}`;
|
|
159
|
-
}
|
|
160
|
-
export function createLifecycleEvent(args) {
|
|
161
|
-
return {
|
|
162
|
-
id: eventId(),
|
|
163
|
-
name: args.name,
|
|
164
|
-
collection: args.collection,
|
|
165
|
-
documentId: args.documentId,
|
|
166
|
-
occurredAt: new Date().toISOString(),
|
|
167
|
-
actorId: args.actorId,
|
|
168
|
-
payload: args.payload,
|
|
169
|
-
attempts: 0,
|
|
170
|
-
status: "pending",
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
async function persistEvent(db, event) {
|
|
174
|
-
await db.create({ collection: LIFECYCLE_EVENTS_COLLECTION, data: event });
|
|
175
|
-
}
|
|
176
|
-
export async function dispatchLifecycleEvent(config, event) {
|
|
177
|
-
const db = config.db;
|
|
178
|
-
if (!db || !config.events?.handlers.length)
|
|
179
|
-
return;
|
|
180
|
-
const maxAttempts = config.events.maxAttempts ?? 8;
|
|
181
|
-
const retryDelayMs = config.events.retryDelayMs ?? 1_000;
|
|
182
|
-
const attempts = event.attempts + 1;
|
|
183
|
-
try {
|
|
184
|
-
await db.update({ collection: LIFECYCLE_EVENTS_COLLECTION, id: event.id, data: { status: "processing", attempts } });
|
|
185
|
-
for (const handler of config.events.handlers)
|
|
186
|
-
await handler({ ...event, status: "processing", attempts });
|
|
187
|
-
await db.update({
|
|
188
|
-
collection: LIFECYCLE_EVENTS_COLLECTION,
|
|
189
|
-
id: event.id,
|
|
190
|
-
data: { status: "delivered", attempts, deliveredAt: new Date().toISOString(), lastError: null },
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
catch (error) {
|
|
194
|
-
const exhausted = attempts >= maxAttempts;
|
|
195
|
-
await db.update({
|
|
196
|
-
collection: LIFECYCLE_EVENTS_COLLECTION,
|
|
197
|
-
id: event.id,
|
|
198
|
-
data: {
|
|
199
|
-
status: "failed",
|
|
200
|
-
attempts,
|
|
201
|
-
lastError: error instanceof Error ? error.message : String(error),
|
|
202
|
-
nextAttemptAt: exhausted ? null : new Date(Date.now() + retryDelayMs * 2 ** (attempts - 1)).toISOString(),
|
|
203
|
-
},
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
// Drain the durable lifecycle-event outbox: deliver pending events and retry
|
|
208
|
-
// failed ones that are due, with backoff. Returns how many were dispatched.
|
|
209
|
-
//
|
|
210
|
-
// DESIGN NOTE — core intentionally does NOT schedule this itself. Immediate
|
|
211
|
-
// delivery is attempted inline after each change (see `void dispatchLifecycleEvent`
|
|
212
|
-
// above); this function drains the outbox for retries and for anything the inline
|
|
213
|
-
// attempt missed. The host owns the process, so the host schedules the drain:
|
|
214
|
-
// Dyrected Cloud runs it via BullMQ/Redis every 30s; self-hosters call it from a
|
|
215
|
-
// cron / worker / platform scheduler (Vercel Cron, Cloudflare Cron Triggers, …).
|
|
216
|
-
//
|
|
217
|
-
// FUTURE — consider: an opt-in `events.autoDispatch: { intervalMs }` could start a
|
|
218
|
-
// `setInterval` in `createDyrectedApp` as a convenience for long-lived,
|
|
219
|
-
// single-instance Node servers. Keep it opt-in and off by default — a built-in
|
|
220
|
-
// timer is unreliable on serverless (the process is ephemeral) and would
|
|
221
|
-
// double-dispatch across multiple instances without coordination.
|
|
222
|
-
export async function dispatchPendingLifecycleEvents(config, limit = 50) {
|
|
223
|
-
if (!config.db || !config.events?.handlers.length)
|
|
224
|
-
return 0;
|
|
225
|
-
const maxAttempts = config.events.maxAttempts ?? 8;
|
|
226
|
-
const result = await config.db.find({
|
|
227
|
-
collection: LIFECYCLE_EVENTS_COLLECTION,
|
|
228
|
-
where: { status: { in: ["pending", "failed"] } },
|
|
229
|
-
sort: "occurredAt",
|
|
230
|
-
limit,
|
|
231
|
-
});
|
|
232
|
-
const now = Date.now();
|
|
233
|
-
const due = result.docs.filter((doc) => Number(doc.attempts ?? 0) < maxAttempts &&
|
|
234
|
-
(!doc.nextAttemptAt || new Date(doc.nextAttemptAt).getTime() <= now));
|
|
235
|
-
for (const event of due)
|
|
236
|
-
await dispatchLifecycleEvent(config, event);
|
|
237
|
-
return due.length;
|
|
238
|
-
}
|
|
239
|
-
export async function saveWorkflowDraft(args) {
|
|
240
|
-
const { config, collection, id, originalDoc, data, user } = args;
|
|
241
|
-
const db = config.db;
|
|
242
|
-
const workflow = collection.workflow;
|
|
243
|
-
if (!db.transaction)
|
|
244
|
-
throw new Error(`The configured database adapter does not support workflow transactions.`);
|
|
245
|
-
const previous = originalDoc.__workflow;
|
|
246
|
-
const isLegacyPublishedDoc = !previous;
|
|
247
|
-
const baselineRevision = previous?.revision ?? 1;
|
|
248
|
-
const event = createLifecycleEvent({
|
|
249
|
-
name: "revision.created",
|
|
250
|
-
collection: collection.slug,
|
|
251
|
-
documentId: id,
|
|
252
|
-
actorId: user?.sub,
|
|
253
|
-
payload: {
|
|
254
|
-
revision: baselineRevision + 1,
|
|
255
|
-
previousRevision: isLegacyPublishedDoc ? baselineRevision : previous?.revision ?? null,
|
|
256
|
-
},
|
|
257
|
-
});
|
|
258
|
-
const doc = await db.transaction(async (tx) => {
|
|
259
|
-
const nextMeta = {
|
|
260
|
-
...(previous ?? {}),
|
|
261
|
-
state: isLegacyPublishedDoc
|
|
262
|
-
? workflow.draftState ?? workflow.initialState
|
|
263
|
-
: originalDoc.__published
|
|
264
|
-
? workflow.draftState ?? workflow.initialState
|
|
265
|
-
: previous.state,
|
|
266
|
-
revision: baselineRevision + 1,
|
|
267
|
-
...(isLegacyPublishedDoc ? { publishedRevision: baselineRevision } : {}),
|
|
268
|
-
};
|
|
269
|
-
const updateData = {
|
|
270
|
-
...data,
|
|
271
|
-
__workflow: nextMeta,
|
|
272
|
-
};
|
|
273
|
-
if (isLegacyPublishedDoc) {
|
|
274
|
-
const { __workflow: _legacyWorkflow, __published: _legacyPublished, ...publishedSnapshot } = originalDoc;
|
|
275
|
-
updateData.__published = publishedSnapshot;
|
|
276
|
-
}
|
|
277
|
-
const updated = await tx.update({ collection: collection.slug, id, data: updateData });
|
|
278
|
-
await persistEvent(tx, event);
|
|
279
|
-
return updated;
|
|
280
|
-
});
|
|
281
|
-
void dispatchLifecycleEvent(config, event);
|
|
282
|
-
return { doc, event };
|
|
283
|
-
}
|
|
284
|
-
export async function createWorkflowDocument(args) {
|
|
285
|
-
const { config, collection, data, user } = args;
|
|
286
|
-
const db = config.db;
|
|
287
|
-
if (!db.transaction)
|
|
288
|
-
throw new Error(`The configured database adapter does not support workflow transactions.`);
|
|
289
|
-
let event;
|
|
290
|
-
const doc = await db.transaction(async (tx) => {
|
|
291
|
-
const created = await tx.create({ collection: collection.slug, data });
|
|
292
|
-
event = createLifecycleEvent({
|
|
293
|
-
name: "revision.created",
|
|
294
|
-
collection: collection.slug,
|
|
295
|
-
documentId: created.id,
|
|
296
|
-
actorId: user?.sub,
|
|
297
|
-
payload: { revision: 1, previousRevision: null },
|
|
298
|
-
});
|
|
299
|
-
await persistEvent(tx, event);
|
|
300
|
-
return created;
|
|
301
|
-
});
|
|
302
|
-
void dispatchLifecycleEvent(config, event);
|
|
303
|
-
return { doc, event };
|
|
304
|
-
}
|
|
305
|
-
export async function transitionWorkflow(args) {
|
|
306
|
-
const { config, collection, id, transitionName, expectedRevision, comment, user, req } = args;
|
|
307
|
-
const db = config.db;
|
|
308
|
-
const workflow = collection.workflow;
|
|
309
|
-
if (!db.transaction)
|
|
310
|
-
throw new Error(`The configured database adapter does not support workflow transactions.`);
|
|
311
|
-
const original = await db.findOne({ collection: collection.slug, id });
|
|
312
|
-
if (!original)
|
|
313
|
-
throw Object.assign(new Error("Not Found"), { statusCode: 404 });
|
|
314
|
-
const meta = original.__workflow;
|
|
315
|
-
if (!meta)
|
|
316
|
-
throw Object.assign(new Error("Entry has no workflow metadata"), { statusCode: 409 });
|
|
317
|
-
if (expectedRevision !== undefined && expectedRevision !== meta.revision) {
|
|
318
|
-
throw Object.assign(new Error("This entry changed since it was loaded. Refresh before transitioning it."), { statusCode: 409 });
|
|
319
|
-
}
|
|
320
|
-
const transition = workflow.transitions.find((item) => item.name === transitionName);
|
|
321
|
-
const fromStates = transition ? (Array.isArray(transition.from) ? transition.from : [transition.from]) : [];
|
|
322
|
-
if (!transition || !fromStates.includes(meta.state)) {
|
|
323
|
-
throw Object.assign(new Error(`Transition "${transitionName}" is not valid from "${meta.state}".`), { statusCode: 409 });
|
|
324
|
-
}
|
|
325
|
-
if (!availableWorkflowTransitions(workflow, meta.state, user).some((item) => item.name === transition.name)) {
|
|
326
|
-
throw Object.assign(new Error(`You do not have permission to perform "${transition.label}".`), { statusCode: 403 });
|
|
327
|
-
}
|
|
328
|
-
if (transition.requireComment && !comment?.trim()) {
|
|
329
|
-
throw Object.assign(new Error(`A comment is required for "${transition.label}".`), { statusCode: 400 });
|
|
330
|
-
}
|
|
331
|
-
const hookContext = { transition, from: meta.state, to: transition.to, doc: original, user, comment, req, db };
|
|
332
|
-
for (const hook of workflow.hooks?.beforeTransition ?? [])
|
|
333
|
-
await hook(hookContext);
|
|
334
|
-
const events = [createLifecycleEvent({
|
|
335
|
-
name: "workflow.transitioned",
|
|
336
|
-
collection: collection.slug,
|
|
337
|
-
documentId: id,
|
|
338
|
-
actorId: user?.sub,
|
|
339
|
-
payload: { transition: transition.name, from: meta.state, to: transition.to, revision: meta.revision, comment },
|
|
340
|
-
})];
|
|
341
|
-
const targetState = workflow.states.find((state) => state.name === transition.to);
|
|
342
|
-
if (targetState.published) {
|
|
343
|
-
events.push(createLifecycleEvent({ name: "entry.published", collection: collection.slug, documentId: id, actorId: user?.sub, payload: { revision: meta.revision } }));
|
|
344
|
-
}
|
|
345
|
-
else if (transition.unpublish) {
|
|
346
|
-
events.push(createLifecycleEvent({ name: "entry.unpublished", collection: collection.slug, documentId: id, actorId: user?.sub, payload: { revision: meta.publishedRevision } }));
|
|
347
|
-
}
|
|
348
|
-
const updated = await db.transaction(async (tx) => {
|
|
349
|
-
const locked = await tx.findOne({ collection: collection.slug, id });
|
|
350
|
-
if (!locked)
|
|
351
|
-
throw Object.assign(new Error("Not Found"), { statusCode: 404 });
|
|
352
|
-
const lockedMeta = locked.__workflow;
|
|
353
|
-
if (lockedMeta.revision !== meta.revision ||
|
|
354
|
-
lockedMeta.state !== meta.state ||
|
|
355
|
-
(expectedRevision !== undefined && lockedMeta.revision !== expectedRevision)) {
|
|
356
|
-
throw Object.assign(new Error("This entry changed since it was loaded. Refresh before transitioning it."), { statusCode: 409 });
|
|
357
|
-
}
|
|
358
|
-
const now = new Date().toISOString();
|
|
359
|
-
const { __published: _published, __workflow: _workflow, id: _id, ...working } = locked;
|
|
360
|
-
const nextMeta = {
|
|
361
|
-
...lockedMeta,
|
|
362
|
-
state: transition.to,
|
|
363
|
-
...(targetState.published ? { publishedRevision: lockedMeta.revision, publishedAt: now, publishedBy: user?.sub } : {}),
|
|
364
|
-
...(transition.unpublish ? { publishedRevision: undefined, publishedAt: undefined, publishedBy: undefined } : {}),
|
|
365
|
-
};
|
|
366
|
-
const data = { __workflow: nextMeta };
|
|
367
|
-
if (targetState.published)
|
|
368
|
-
data.__published = working;
|
|
369
|
-
if (transition.unpublish)
|
|
370
|
-
data.__published = null;
|
|
371
|
-
const next = await tx.update({ collection: collection.slug, id, data });
|
|
372
|
-
await tx.create({
|
|
373
|
-
collection: WORKFLOW_HISTORY_COLLECTION,
|
|
374
|
-
data: { collection: collection.slug, documentId: id, transition: transition.name, from: lockedMeta.state, to: transition.to, revision: lockedMeta.revision, comment: comment ?? null, actorId: user?.sub ?? null, createdAt: now },
|
|
375
|
-
});
|
|
376
|
-
for (const event of events)
|
|
377
|
-
await persistEvent(tx, event);
|
|
378
|
-
if (collection.audit) {
|
|
379
|
-
await tx.create({ collection: "__audit", data: { collection: collection.slug, documentId: id, operation: "workflow.transition", user: user?.sub ?? null, timestamp: now, changes: JSON.stringify({ transition: transition.name, from: lockedMeta.state, to: transition.to, revision: lockedMeta.revision }) } });
|
|
380
|
-
}
|
|
381
|
-
return next;
|
|
382
|
-
});
|
|
383
|
-
for (const event of events)
|
|
384
|
-
void dispatchLifecycleEvent(config, event);
|
|
385
|
-
for (const hook of workflow.hooks?.afterTransition ?? []) {
|
|
386
|
-
try {
|
|
387
|
-
await hook({ ...hookContext, doc: updated, event: events[0] });
|
|
388
|
-
}
|
|
389
|
-
catch (error) {
|
|
390
|
-
getObservabilityRuntime(config)?.recordWorkflowHookFailure({
|
|
391
|
-
collection: collection.slug,
|
|
392
|
-
transition: transition.name,
|
|
393
|
-
});
|
|
394
|
-
getConfigLogger(config, "workflow").error({
|
|
395
|
-
err: error,
|
|
396
|
-
msg: "afterTransition hook failed",
|
|
397
|
-
collection: collection.slug,
|
|
398
|
-
transition: transition.name,
|
|
399
|
-
documentId: id,
|
|
400
|
-
});
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
return updated;
|
|
404
|
-
}
|
|
405
|
-
//# sourceMappingURL=workflows.js.map
|