@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.
- package/package.json +1 -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 -27
- package/dist/__tests__/app.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 -91
- package/dist/__tests__/config.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 -81
- 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 -132
- 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 -46
- package/dist/__tests__/email.service.test.js.map +0 -1
- package/dist/__tests__/field-inference.test-types.d.ts +0 -24
- 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 -9
- 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 -74
- package/dist/__tests__/mocks.d.ts.map +0 -1
- package/dist/__tests__/mocks.js +0 -159
- package/dist/__tests__/mocks.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 -95
- 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 -52
- package/dist/__tests__/router.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 -497
- package/dist/__tests__/workflow.test.js.map +0 -1
- package/dist/app-B2tg7Djj.d.cts +0 -1575
- package/dist/app-B2tg7Djj.d.ts +0 -1575
- package/dist/app-BElen1tP.d.cts +0 -1690
- package/dist/app-BElen1tP.d.ts +0 -1690
- package/dist/app-BOrsS7Tz.d.cts +0 -1771
- package/dist/app-BOrsS7Tz.d.ts +0 -1771
- package/dist/app-Bh4_Opv0.d.cts +0 -1522
- package/dist/app-Bh4_Opv0.d.ts +0 -1522
- package/dist/app-BibuoHQG.d.cts +0 -1764
- package/dist/app-BibuoHQG.d.ts +0 -1764
- package/dist/app-Bv9gaDAN.d.cts +0 -561
- package/dist/app-Bv9gaDAN.d.ts +0 -561
- package/dist/app-BvG3bRc8.d.cts +0 -419
- package/dist/app-BvG3bRc8.d.ts +0 -419
- package/dist/app-C-HgyliB.d.cts +0 -1694
- package/dist/app-C-HgyliB.d.ts +0 -1694
- package/dist/app-C3B9N1KR.d.cts +0 -1522
- package/dist/app-C3B9N1KR.d.ts +0 -1522
- package/dist/app-Cc2mG3zi.d.cts +0 -373
- package/dist/app-Cc2mG3zi.d.ts +0 -373
- package/dist/app-Ctfmo2Re.d.cts +0 -1692
- package/dist/app-Ctfmo2Re.d.ts +0 -1692
- package/dist/app-D0ffogDd.d.cts +0 -1690
- package/dist/app-D0ffogDd.d.ts +0 -1690
- package/dist/app-D2uR47gK.d.cts +0 -1690
- package/dist/app-D2uR47gK.d.ts +0 -1690
- package/dist/app-DDJJa0ep.d.cts +0 -1621
- package/dist/app-DDJJa0ep.d.ts +0 -1621
- package/dist/app-DO1s9YW1.d.cts +0 -1621
- package/dist/app-DO1s9YW1.d.ts +0 -1621
- package/dist/app-DTP3-9PJ.d.cts +0 -561
- package/dist/app-DTP3-9PJ.d.ts +0 -561
- package/dist/app-DZt5nslu.d.cts +0 -374
- package/dist/app-DZt5nslu.d.ts +0 -377
- package/dist/app-DbKDGYTI.d.cts +0 -566
- package/dist/app-DbKDGYTI.d.ts +0 -566
- package/dist/app-Dk3SzV1a.d.cts +0 -374
- package/dist/app-Dk3SzV1a.d.ts +0 -374
- package/dist/app-DnX9mNsh.d.cts +0 -374
- package/dist/app-DnX9mNsh.d.ts +0 -374
- package/dist/app-DqRO-CMi.d.cts +0 -1457
- package/dist/app-DqRO-CMi.d.ts +0 -1457
- package/dist/app-DvaFpOtj.d.cts +0 -398
- package/dist/app-DvaFpOtj.d.ts +0 -398
- package/dist/app-FGzip4XM.d.cts +0 -1563
- package/dist/app-FGzip4XM.d.ts +0 -1563
- package/dist/app-KApbf4XL.d.cts +0 -362
- package/dist/app-KApbf4XL.d.ts +0 -362
- package/dist/app-T0alZAE0.d.cts +0 -383
- package/dist/app-T0alZAE0.d.ts +0 -383
- package/dist/app-aW2FMuYM.d.cts +0 -1759
- package/dist/app-aW2FMuYM.d.ts +0 -1759
- package/dist/app-config-2vF6W56z.d.cts +0 -1335
- package/dist/app-config-2vF6W56z.d.ts +0 -1335
- package/dist/app-config-3XBnu9Xz.d.cts +0 -1379
- package/dist/app-config-3XBnu9Xz.d.ts +0 -1379
- package/dist/app-config-BLMX-9MN.d.cts +0 -1045
- package/dist/app-config-BLMX-9MN.d.ts +0 -1045
- package/dist/app-config-CaEQH0Kb.d.cts +0 -1383
- package/dist/app-config-CaEQH0Kb.d.ts +0 -1383
- package/dist/app-config-DLK6bCaP.d.cts +0 -1390
- package/dist/app-config-DLK6bCaP.d.ts +0 -1390
- package/dist/app-config-oOarB6Fw.d.cts +0 -1411
- package/dist/app-config-oOarB6Fw.d.ts +0 -1411
- package/dist/app-oQt5-9MU.d.cts +0 -1560
- package/dist/app-oQt5-9MU.d.ts +0 -1560
- package/dist/app-rZj1VFer.d.cts +0 -1621
- package/dist/app-rZj1VFer.d.ts +0 -1621
- package/dist/app-wo82JRHl.d.cts +0 -445
- package/dist/app-wo82JRHl.d.ts +0 -445
- package/dist/app.d.ts +0 -21
- package/dist/app.d.ts.map +0 -1
- package/dist/app.js +0 -56
- package/dist/app.js.map +0 -1
- package/dist/auth/jexl.d.ts +0 -10
- package/dist/auth/jexl.d.ts.map +0 -1
- package/dist/auth/jexl.js +0 -22
- package/dist/auth/jexl.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/token.d.ts +0 -22
- 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-22JTWD74.js +0 -1784
- package/dist/chunk-23URSKPI.js +0 -2371
- package/dist/chunk-2JMA3M5S.js +0 -2475
- package/dist/chunk-3FZEUK36.js +0 -2470
- package/dist/chunk-3VUH2MNW.js +0 -1903
- package/dist/chunk-44O2LDPT.js +0 -1513
- package/dist/chunk-45JDQDA2.js +0 -1899
- package/dist/chunk-4C4L6SD2.js +0 -1524
- package/dist/chunk-4EDMZAM5.js +0 -2692
- package/dist/chunk-52T4RCFU.js +0 -1972
- package/dist/chunk-6ZXEGKT6.js +0 -619
- package/dist/chunk-7GGHK75W.js +0 -1835
- package/dist/chunk-ALNQINX7.js +0 -2496
- package/dist/chunk-B6KDKYXB.js +0 -2502
- package/dist/chunk-BEONZV6M.js +0 -1951
- package/dist/chunk-C4GEQ5RP.js +0 -1993
- package/dist/chunk-CQDVPMEU.js +0 -613
- package/dist/chunk-DOJHZ7XN.js +0 -2394
- package/dist/chunk-EH7G3LLL.js +0 -2065
- package/dist/chunk-EXXOPW3I.js +0 -2483
- package/dist/chunk-F4ZC6TXR.js +0 -2065
- package/dist/chunk-FCXE5CVC.js +0 -1528
- package/dist/chunk-FDQYPPG3.js +0 -2698
- package/dist/chunk-FURYJ254.mjs +0 -33
- package/dist/chunk-G2QQLBHW.js +0 -24
- package/dist/chunk-GM4WW6IE.js +0 -66
- package/dist/chunk-GZODLJ3C.js +0 -1861
- package/dist/chunk-IIY3E7Q7.js +0 -1996
- package/dist/chunk-JJN4J5NS.js +0 -2069
- package/dist/chunk-MRUHCNDM.js +0 -1940
- package/dist/chunk-NKDX67AW.js +0 -2698
- package/dist/chunk-NYUB4AHZ.js +0 -1951
- package/dist/chunk-OD4SLW7H.js +0 -1930
- package/dist/chunk-OE5MH3NB.js +0 -2070
- package/dist/chunk-PH36WQYS.js +0 -1875
- package/dist/chunk-PKNFV7KE.js +0 -2469
- package/dist/chunk-SUGK7UYL.js +0 -311
- package/dist/chunk-TIJHR54M.js +0 -1879
- package/dist/chunk-TUUHGLB5.js +0 -2609
- package/dist/chunk-UBTRANFX.js +0 -2476
- package/dist/chunk-VJWUG2XK.js +0 -1951
- package/dist/chunk-W6KURRMW.js +0 -2471
- package/dist/chunk-Y4AYI52W.js +0 -631
- package/dist/chunk-YDOBB7MY.js +0 -1457
- package/dist/chunk-YNJ3YC4N.js +0 -2483
- package/dist/chunk-ZFAOBRHT.js +0 -2709
- package/dist/controllers/admin-auth.controller.d.ts +0 -68
- package/dist/controllers/admin-auth.controller.d.ts.map +0 -1
- package/dist/controllers/admin-auth.controller.js +0 -414
- package/dist/controllers/admin-auth.controller.js.map +0 -1
- package/dist/controllers/auth.controller.d.ts +0 -125
- package/dist/controllers/auth.controller.d.ts.map +0 -1
- package/dist/controllers/auth.controller.js +0 -323
- package/dist/controllers/auth.controller.js.map +0 -1
- package/dist/controllers/collection.controller.d.ts +0 -157
- package/dist/controllers/collection.controller.d.ts.map +0 -1
- package/dist/controllers/collection.controller.js +0 -779
- package/dist/controllers/collection.controller.js.map +0 -1
- package/dist/controllers/global.controller.d.ts +0 -17
- package/dist/controllers/global.controller.d.ts.map +0 -1
- package/dist/controllers/global.controller.js +0 -132
- package/dist/controllers/global.controller.js.map +0 -1
- package/dist/controllers/media.controller.d.ts +0 -38
- package/dist/controllers/media.controller.d.ts.map +0 -1
- package/dist/controllers/media.controller.js +0 -162
- 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-BKYugiYp.d.cts +0 -1988
- package/dist/index-BKYugiYp.d.ts +0 -1988
- package/dist/index-BSWCiAen.d.cts +0 -1983
- package/dist/index-BSWCiAen.d.ts +0 -1983
- package/dist/index-BfLDb3b0.d.cts +0 -1467
- package/dist/index-BfLDb3b0.d.ts +0 -1467
- package/dist/index-Bi4sX_eC.d.cts +0 -1491
- package/dist/index-Bi4sX_eC.d.ts +0 -1491
- package/dist/index-Bp7PDOYG.d.cts +0 -1750
- package/dist/index-Bp7PDOYG.d.ts +0 -1750
- package/dist/index-ByXooLy-.d.cts +0 -1762
- package/dist/index-ByXooLy-.d.ts +0 -1762
- package/dist/index-C9Vp1DCT.d.cts +0 -1563
- package/dist/index-C9Vp1DCT.d.ts +0 -1563
- package/dist/index-CFezd8p1.d.cts +0 -1986
- package/dist/index-CFezd8p1.d.ts +0 -1986
- package/dist/index-CdQwnbfh.d.cts +0 -1889
- package/dist/index-CdQwnbfh.d.ts +0 -1889
- package/dist/index-D38_E0gf.d.cts +0 -336
- package/dist/index-D38_E0gf.d.ts +0 -336
- package/dist/index-DR2z1rrf.d.cts +0 -1503
- package/dist/index-DR2z1rrf.d.ts +0 -1503
- package/dist/index-DTrpTru7.d.cts +0 -1881
- package/dist/index-DTrpTru7.d.ts +0 -1881
- package/dist/index-DfAmTZXk.d.cts +0 -1749
- package/dist/index-DfAmTZXk.d.ts +0 -1749
- package/dist/index-DfkPT4NR.d.cts +0 -1584
- package/dist/index-DfkPT4NR.d.ts +0 -1584
- package/dist/index-DzUlE5Hc.d.cts +0 -1751
- package/dist/index-DzUlE5Hc.d.ts +0 -1751
- package/dist/index-M_m6dXZV.d.cts +0 -1889
- package/dist/index-M_m6dXZV.d.ts +0 -1889
- package/dist/index-RylhgOwj.d.cts +0 -340
- package/dist/index-RylhgOwj.d.ts +0 -340
- package/dist/index-qhLus8ZO.d.cts +0 -1881
- package/dist/index-qhLus8ZO.d.ts +0 -1881
- package/dist/index-xB1lMg79.d.cts +0 -1456
- package/dist/index-xB1lMg79.d.ts +0 -1456
- package/dist/index.d.mts +0 -417
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -1974
- package/dist/middleware/auth.d.ts +0 -18
- package/dist/middleware/auth.d.ts.map +0 -1
- package/dist/middleware/auth.js +0 -45
- package/dist/middleware/auth.js.map +0 -1
- package/dist/password-ACI2YUGZ.js +0 -8
- package/dist/router.d.ts +0 -8
- package/dist/router.d.ts.map +0 -1
- package/dist/router.js +0 -625
- 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 -28
- 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 -33
- package/dist/services/email.service.d.ts.map +0 -1
- package/dist/services/email.service.js +0 -96
- 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 -194
- package/dist/services/population.service.js.map +0 -1
- package/dist/token-7QG5DBME.mjs +0 -10
- package/dist/types/access.d.ts +0 -38
- 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 -146
- 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 -65
- 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 -143
- 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 -303
- 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 -294
- 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 -84
- 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/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/config.d.ts +0 -8
- package/dist/utils/config.d.ts.map +0 -1
- package/dist/utils/config.js +0 -238
- 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 -173
- 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 -842
- package/dist/utils/openapi.js.map +0 -1
- package/dist/utils/parse-sort.d.ts +0 -7
- package/dist/utils/parse-sort.d.ts.map +0 -1
- package/dist/utils/parse-sort.js +0 -23
- package/dist/utils/parse-sort.js.map +0 -1
- package/dist/utils/parse-where.d.ts +0 -63
- package/dist/utils/parse-where.d.ts.map +0 -1
- package/dist/utils/parse-where.js +0 -196
- 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/setup-prompt.d.ts +0 -11
- package/dist/utils/setup-prompt.d.ts.map +0 -1
- package/dist/utils/setup-prompt.js +0 -863
- package/dist/utils/setup-prompt.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 -44
- 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/where-sanitizer-7Q4JXMX6.js +0 -57
- package/dist/where-sanitizer-DQIWTQZW.js +0 -50
- package/dist/workflows.d.ts +0 -54
- package/dist/workflows.d.ts.map +0 -1
- package/dist/workflows.js +0 -282
- package/dist/workflows.js.map +0 -1
package/dist/chunk-44O2LDPT.js
DELETED
|
@@ -1,1513 +0,0 @@
|
|
|
1
|
-
// src/workflows.js
|
|
2
|
-
var WORKFLOW_HISTORY_COLLECTION = "__workflow_history";
|
|
3
|
-
var LIFECYCLE_EVENTS_COLLECTION = "__lifecycle_events";
|
|
4
|
-
function publishingWorkflow() {
|
|
5
|
-
return {
|
|
6
|
-
initialState: "draft",
|
|
7
|
-
draftState: "draft",
|
|
8
|
-
states: [
|
|
9
|
-
{ name: "draft", label: "Draft", color: "neutral" },
|
|
10
|
-
{ name: "in_review", label: "In review", color: "warning" },
|
|
11
|
-
{ name: "published", label: "Published", color: "success", published: true }
|
|
12
|
-
],
|
|
13
|
-
transitions: [
|
|
14
|
-
{ name: "submit", label: "Submit for review", from: "draft", to: "in_review", requiredCapabilities: ["entry.submit"] },
|
|
15
|
-
{ name: "publish", label: "Publish", from: "in_review", to: "published", requiredCapabilities: ["entry.publish"] },
|
|
16
|
-
{ name: "reject", label: "Request changes", from: "in_review", to: "draft", requiredCapabilities: ["entry.publish"], requireComment: true },
|
|
17
|
-
{ name: "unpublish", label: "Unpublish", from: "published", to: "draft", requiredCapabilities: ["entry.unpublish"], unpublish: true }
|
|
18
|
-
],
|
|
19
|
-
roles: [
|
|
20
|
-
{ role: "editor", capabilities: ["entry.edit", "entry.submit"] },
|
|
21
|
-
{ role: "publisher", capabilities: ["entry.edit", "entry.submit", "entry.publish", "entry.unpublish"] },
|
|
22
|
-
{ role: "admin", capabilities: ["entry.edit", "entry.submit", "entry.publish", "entry.unpublish"] }
|
|
23
|
-
]
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
function publicMetadata(meta) {
|
|
27
|
-
const { availableTransitions: _availableTransitions, ...safe } = meta;
|
|
28
|
-
return safe;
|
|
29
|
-
}
|
|
30
|
-
function workflowCapabilities(workflow, user) {
|
|
31
|
-
const capabilities = new Set(Array.isArray(user?.capabilities) ? user.capabilities : []);
|
|
32
|
-
const roles = Array.isArray(user?.roles) ? user.roles : [];
|
|
33
|
-
for (const mapping of workflow.roles ?? []) {
|
|
34
|
-
if (roles.includes(mapping.role))
|
|
35
|
-
mapping.capabilities.forEach((capability) => capabilities.add(capability));
|
|
36
|
-
}
|
|
37
|
-
return capabilities;
|
|
38
|
-
}
|
|
39
|
-
function canViewWorkflowDraft(workflow, user) {
|
|
40
|
-
if (!user)
|
|
41
|
-
return false;
|
|
42
|
-
const capabilities = workflowCapabilities(workflow, user);
|
|
43
|
-
if (capabilities.has("entry.edit"))
|
|
44
|
-
return true;
|
|
45
|
-
return workflow.transitions.some((transition) => (transition.requiredCapabilities ?? []).some((capability) => capabilities.has(capability)));
|
|
46
|
-
}
|
|
47
|
-
function availableWorkflowTransitions(workflow, state, user) {
|
|
48
|
-
const capabilities = workflowCapabilities(workflow, user);
|
|
49
|
-
return workflow.transitions.filter((transition) => {
|
|
50
|
-
const from = Array.isArray(transition.from) ? transition.from : [transition.from];
|
|
51
|
-
return from.includes(state) && (transition.requiredCapabilities ?? []).every((item) => capabilities.has(item));
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
function initializeWorkflowDocument(data, workflow) {
|
|
55
|
-
return {
|
|
56
|
-
...data,
|
|
57
|
-
__workflow: { state: workflow.initialState, revision: 1 }
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
function materializeWorkflowDocument(doc, workflow, user) {
|
|
61
|
-
const meta = doc.__workflow;
|
|
62
|
-
if (!meta)
|
|
63
|
-
return doc;
|
|
64
|
-
const { __published, __workflow, ...working } = doc;
|
|
65
|
-
if (!canViewWorkflowDraft(workflow, user)) {
|
|
66
|
-
if (!__published || typeof __published !== "object")
|
|
67
|
-
return null;
|
|
68
|
-
return { id: doc.id, ...__published, _workflow: publicMetadata(meta) };
|
|
69
|
-
}
|
|
70
|
-
return {
|
|
71
|
-
...working,
|
|
72
|
-
_workflow: {
|
|
73
|
-
...meta,
|
|
74
|
-
availableTransitions: availableWorkflowTransitions(workflow, meta.state, user).map((item) => item.name)
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
function eventId() {
|
|
79
|
-
return globalThis.crypto?.randomUUID?.() ?? `evt_${Date.now()}_${Math.random().toString(36).slice(2)}`;
|
|
80
|
-
}
|
|
81
|
-
function createLifecycleEvent(args) {
|
|
82
|
-
return {
|
|
83
|
-
id: eventId(),
|
|
84
|
-
name: args.name,
|
|
85
|
-
collection: args.collection,
|
|
86
|
-
documentId: args.documentId,
|
|
87
|
-
occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
88
|
-
actorId: args.actorId,
|
|
89
|
-
payload: args.payload,
|
|
90
|
-
attempts: 0,
|
|
91
|
-
status: "pending"
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
async function persistEvent(db, event) {
|
|
95
|
-
await db.create({ collection: LIFECYCLE_EVENTS_COLLECTION, data: event });
|
|
96
|
-
}
|
|
97
|
-
async function dispatchLifecycleEvent(config, event) {
|
|
98
|
-
const db = config.db;
|
|
99
|
-
if (!db || !config.events?.handlers.length)
|
|
100
|
-
return;
|
|
101
|
-
const maxAttempts = config.events.maxAttempts ?? 8;
|
|
102
|
-
const retryDelayMs = config.events.retryDelayMs ?? 1e3;
|
|
103
|
-
const attempts = event.attempts + 1;
|
|
104
|
-
try {
|
|
105
|
-
await db.update({ collection: LIFECYCLE_EVENTS_COLLECTION, id: event.id, data: { status: "processing", attempts } });
|
|
106
|
-
for (const handler of config.events.handlers)
|
|
107
|
-
await handler({ ...event, status: "processing", attempts });
|
|
108
|
-
await db.update({
|
|
109
|
-
collection: LIFECYCLE_EVENTS_COLLECTION,
|
|
110
|
-
id: event.id,
|
|
111
|
-
data: { status: "delivered", attempts, deliveredAt: (/* @__PURE__ */ new Date()).toISOString(), lastError: null }
|
|
112
|
-
});
|
|
113
|
-
} catch (error) {
|
|
114
|
-
const exhausted = attempts >= maxAttempts;
|
|
115
|
-
await db.update({
|
|
116
|
-
collection: LIFECYCLE_EVENTS_COLLECTION,
|
|
117
|
-
id: event.id,
|
|
118
|
-
data: {
|
|
119
|
-
status: "failed",
|
|
120
|
-
attempts,
|
|
121
|
-
lastError: error instanceof Error ? error.message : String(error),
|
|
122
|
-
nextAttemptAt: exhausted ? null : new Date(Date.now() + retryDelayMs * 2 ** (attempts - 1)).toISOString()
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
async function dispatchPendingLifecycleEvents(config, limit = 50) {
|
|
128
|
-
if (!config.db || !config.events?.handlers.length)
|
|
129
|
-
return 0;
|
|
130
|
-
const maxAttempts = config.events.maxAttempts ?? 8;
|
|
131
|
-
const result = await config.db.find({
|
|
132
|
-
collection: LIFECYCLE_EVENTS_COLLECTION,
|
|
133
|
-
where: { status: { in: ["pending", "failed"] } },
|
|
134
|
-
sort: "occurredAt",
|
|
135
|
-
limit
|
|
136
|
-
});
|
|
137
|
-
const now = Date.now();
|
|
138
|
-
const due = result.docs.filter((doc) => Number(doc.attempts ?? 0) < maxAttempts && (!doc.nextAttemptAt || new Date(doc.nextAttemptAt).getTime() <= now));
|
|
139
|
-
for (const event of due)
|
|
140
|
-
await dispatchLifecycleEvent(config, event);
|
|
141
|
-
return due.length;
|
|
142
|
-
}
|
|
143
|
-
async function saveWorkflowDraft(args) {
|
|
144
|
-
const { config, collection, id, originalDoc, data, user } = args;
|
|
145
|
-
const db = config.db;
|
|
146
|
-
const workflow = collection.workflow;
|
|
147
|
-
if (!db.transaction)
|
|
148
|
-
throw new Error(`The configured database adapter does not support workflow transactions.`);
|
|
149
|
-
const previous = originalDoc.__workflow;
|
|
150
|
-
const event = createLifecycleEvent({
|
|
151
|
-
name: "revision.created",
|
|
152
|
-
collection: collection.slug,
|
|
153
|
-
documentId: id,
|
|
154
|
-
actorId: user?.sub,
|
|
155
|
-
payload: { revision: previous.revision + 1, previousRevision: previous.revision }
|
|
156
|
-
});
|
|
157
|
-
const doc = await db.transaction(async (tx) => {
|
|
158
|
-
const nextMeta = {
|
|
159
|
-
...previous,
|
|
160
|
-
state: originalDoc.__published ? workflow.draftState ?? workflow.initialState : previous.state,
|
|
161
|
-
revision: previous.revision + 1
|
|
162
|
-
};
|
|
163
|
-
const updated = await tx.update({ collection: collection.slug, id, data: { ...data, __workflow: nextMeta } });
|
|
164
|
-
await persistEvent(tx, event);
|
|
165
|
-
return updated;
|
|
166
|
-
});
|
|
167
|
-
void dispatchLifecycleEvent(config, event);
|
|
168
|
-
return { doc, event };
|
|
169
|
-
}
|
|
170
|
-
async function createWorkflowDocument(args) {
|
|
171
|
-
const { config, collection, data, user } = args;
|
|
172
|
-
const db = config.db;
|
|
173
|
-
if (!db.transaction)
|
|
174
|
-
throw new Error(`The configured database adapter does not support workflow transactions.`);
|
|
175
|
-
let event;
|
|
176
|
-
const doc = await db.transaction(async (tx) => {
|
|
177
|
-
const created = await tx.create({ collection: collection.slug, data });
|
|
178
|
-
event = createLifecycleEvent({
|
|
179
|
-
name: "revision.created",
|
|
180
|
-
collection: collection.slug,
|
|
181
|
-
documentId: created.id,
|
|
182
|
-
actorId: user?.sub,
|
|
183
|
-
payload: { revision: 1, previousRevision: null }
|
|
184
|
-
});
|
|
185
|
-
await persistEvent(tx, event);
|
|
186
|
-
return created;
|
|
187
|
-
});
|
|
188
|
-
void dispatchLifecycleEvent(config, event);
|
|
189
|
-
return { doc, event };
|
|
190
|
-
}
|
|
191
|
-
async function transitionWorkflow(args) {
|
|
192
|
-
const { config, collection, id, transitionName, expectedRevision, comment, user, req } = args;
|
|
193
|
-
const db = config.db;
|
|
194
|
-
const workflow = collection.workflow;
|
|
195
|
-
if (!db.transaction)
|
|
196
|
-
throw new Error(`The configured database adapter does not support workflow transactions.`);
|
|
197
|
-
const original = await db.findOne({ collection: collection.slug, id });
|
|
198
|
-
if (!original)
|
|
199
|
-
throw Object.assign(new Error("Not Found"), { statusCode: 404 });
|
|
200
|
-
const meta = original.__workflow;
|
|
201
|
-
if (!meta)
|
|
202
|
-
throw Object.assign(new Error("Entry has no workflow metadata"), { statusCode: 409 });
|
|
203
|
-
if (expectedRevision !== void 0 && expectedRevision !== meta.revision) {
|
|
204
|
-
throw Object.assign(new Error("This entry changed since it was loaded. Refresh before transitioning it."), { statusCode: 409 });
|
|
205
|
-
}
|
|
206
|
-
const transition = workflow.transitions.find((item) => item.name === transitionName);
|
|
207
|
-
const fromStates = transition ? Array.isArray(transition.from) ? transition.from : [transition.from] : [];
|
|
208
|
-
if (!transition || !fromStates.includes(meta.state)) {
|
|
209
|
-
throw Object.assign(new Error(`Transition "${transitionName}" is not valid from "${meta.state}".`), { statusCode: 409 });
|
|
210
|
-
}
|
|
211
|
-
if (!availableWorkflowTransitions(workflow, meta.state, user).some((item) => item.name === transition.name)) {
|
|
212
|
-
throw Object.assign(new Error(`You do not have permission to perform "${transition.label}".`), { statusCode: 403 });
|
|
213
|
-
}
|
|
214
|
-
if (transition.requireComment && !comment?.trim()) {
|
|
215
|
-
throw Object.assign(new Error(`A comment is required for "${transition.label}".`), { statusCode: 400 });
|
|
216
|
-
}
|
|
217
|
-
const hookContext = { transition, from: meta.state, to: transition.to, doc: original, user, comment, req, db };
|
|
218
|
-
for (const hook of workflow.hooks?.beforeTransition ?? [])
|
|
219
|
-
await hook(hookContext);
|
|
220
|
-
const events = [createLifecycleEvent({
|
|
221
|
-
name: "workflow.transitioned",
|
|
222
|
-
collection: collection.slug,
|
|
223
|
-
documentId: id,
|
|
224
|
-
actorId: user?.sub,
|
|
225
|
-
payload: { transition: transition.name, from: meta.state, to: transition.to, revision: meta.revision, comment }
|
|
226
|
-
})];
|
|
227
|
-
const targetState = workflow.states.find((state) => state.name === transition.to);
|
|
228
|
-
if (targetState.published) {
|
|
229
|
-
events.push(createLifecycleEvent({ name: "entry.published", collection: collection.slug, documentId: id, actorId: user?.sub, payload: { revision: meta.revision } }));
|
|
230
|
-
} else if (transition.unpublish) {
|
|
231
|
-
events.push(createLifecycleEvent({ name: "entry.unpublished", collection: collection.slug, documentId: id, actorId: user?.sub, payload: { revision: meta.publishedRevision } }));
|
|
232
|
-
}
|
|
233
|
-
const updated = await db.transaction(async (tx) => {
|
|
234
|
-
const locked = await tx.findOne({ collection: collection.slug, id });
|
|
235
|
-
if (!locked)
|
|
236
|
-
throw Object.assign(new Error("Not Found"), { statusCode: 404 });
|
|
237
|
-
const lockedMeta = locked.__workflow;
|
|
238
|
-
if (lockedMeta.revision !== meta.revision || lockedMeta.state !== meta.state || expectedRevision !== void 0 && lockedMeta.revision !== expectedRevision) {
|
|
239
|
-
throw Object.assign(new Error("This entry changed since it was loaded. Refresh before transitioning it."), { statusCode: 409 });
|
|
240
|
-
}
|
|
241
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
242
|
-
const { __published: _published, __workflow: _workflow, id: _id, ...working } = locked;
|
|
243
|
-
const nextMeta = {
|
|
244
|
-
...lockedMeta,
|
|
245
|
-
state: transition.to,
|
|
246
|
-
...targetState.published ? { publishedRevision: lockedMeta.revision, publishedAt: now, publishedBy: user?.sub } : {},
|
|
247
|
-
...transition.unpublish ? { publishedRevision: void 0, publishedAt: void 0, publishedBy: void 0 } : {}
|
|
248
|
-
};
|
|
249
|
-
const data = { __workflow: nextMeta };
|
|
250
|
-
if (targetState.published)
|
|
251
|
-
data.__published = working;
|
|
252
|
-
if (transition.unpublish)
|
|
253
|
-
data.__published = null;
|
|
254
|
-
const next = await tx.update({ collection: collection.slug, id, data });
|
|
255
|
-
await tx.create({
|
|
256
|
-
collection: WORKFLOW_HISTORY_COLLECTION,
|
|
257
|
-
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 }
|
|
258
|
-
});
|
|
259
|
-
for (const event of events)
|
|
260
|
-
await persistEvent(tx, event);
|
|
261
|
-
if (collection.audit) {
|
|
262
|
-
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 }) } });
|
|
263
|
-
}
|
|
264
|
-
return next;
|
|
265
|
-
});
|
|
266
|
-
for (const event of events)
|
|
267
|
-
void dispatchLifecycleEvent(config, event);
|
|
268
|
-
for (const hook of workflow.hooks?.afterTransition ?? []) {
|
|
269
|
-
try {
|
|
270
|
-
await hook({ ...hookContext, doc: updated, event: events[0] });
|
|
271
|
-
} catch (error) {
|
|
272
|
-
console.error("[dyrected/workflow] afterTransition hook failed:", error);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
return updated;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
// src/utils/admin-auth.js
|
|
279
|
-
function getAdminAuthCollection(config) {
|
|
280
|
-
const requestedSlug = config.adminAuth?.collectionSlug;
|
|
281
|
-
if (requestedSlug) {
|
|
282
|
-
return config.collections.find((collection) => collection.slug === requestedSlug) ?? null;
|
|
283
|
-
}
|
|
284
|
-
return config.collections.find((collection) => collection.slug === "__admins") ?? config.collections.find((collection) => collection.auth) ?? null;
|
|
285
|
-
}
|
|
286
|
-
function getPublicAdminAuthConfig(adminAuth) {
|
|
287
|
-
const providers = (adminAuth?.providers ?? []).map((provider) => ({
|
|
288
|
-
id: provider.id,
|
|
289
|
-
type: provider.type,
|
|
290
|
-
displayName: provider.displayName || humanizeProviderName(provider.id, provider.type),
|
|
291
|
-
autoRedirect: provider.autoRedirect
|
|
292
|
-
}));
|
|
293
|
-
return {
|
|
294
|
-
mode: adminAuth?.mode ?? "local",
|
|
295
|
-
collectionSlug: adminAuth?.collectionSlug,
|
|
296
|
-
provisioningMode: adminAuth?.provisioningMode,
|
|
297
|
-
providers
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
function humanizeProviderName(id, type) {
|
|
301
|
-
const cleaned = id.replace(/[-_]+/g, " ").trim();
|
|
302
|
-
if (!cleaned)
|
|
303
|
-
return type.toUpperCase();
|
|
304
|
-
return cleaned.replace(/\b\w/g, (char) => char.toUpperCase());
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
// src/utils/config.js
|
|
308
|
-
var AUDIT_COLLECTION_SLUG = "__audit";
|
|
309
|
-
var SYSTEM_FIELDS = [
|
|
310
|
-
{
|
|
311
|
-
name: "createdAt",
|
|
312
|
-
type: "date",
|
|
313
|
-
label: "Created At",
|
|
314
|
-
admin: { readOnly: true, hidden: true }
|
|
315
|
-
},
|
|
316
|
-
{
|
|
317
|
-
name: "updatedAt",
|
|
318
|
-
type: "date",
|
|
319
|
-
label: "Updated At",
|
|
320
|
-
admin: { readOnly: true, hidden: true }
|
|
321
|
-
},
|
|
322
|
-
{
|
|
323
|
-
name: "createdBy",
|
|
324
|
-
type: "text",
|
|
325
|
-
label: "Created By",
|
|
326
|
-
admin: { readOnly: true, hidden: true }
|
|
327
|
-
},
|
|
328
|
-
{
|
|
329
|
-
name: "updatedBy",
|
|
330
|
-
type: "text",
|
|
331
|
-
label: "Updated By",
|
|
332
|
-
admin: { readOnly: true, hidden: true }
|
|
333
|
-
}
|
|
334
|
-
];
|
|
335
|
-
var AUDIT_COLLECTION = {
|
|
336
|
-
slug: AUDIT_COLLECTION_SLUG,
|
|
337
|
-
labels: { singular: "Audit Log", plural: "Audit Logs" },
|
|
338
|
-
fields: [
|
|
339
|
-
{ name: "collection", type: "text", label: "Collection", required: true },
|
|
340
|
-
{ name: "documentId", type: "text", label: "Document ID" },
|
|
341
|
-
{ name: "operation", type: "select", label: "Operation", options: ["create", "update", "delete"], required: true },
|
|
342
|
-
{ name: "user", type: "text", label: "User ID" },
|
|
343
|
-
{ name: "timestamp", type: "date", label: "Timestamp", required: true },
|
|
344
|
-
{ name: "changes", type: "json", label: "Changes" }
|
|
345
|
-
],
|
|
346
|
-
admin: { hidden: true }
|
|
347
|
-
};
|
|
348
|
-
var WORKFLOW_HISTORY_COLLECTION_CONFIG = {
|
|
349
|
-
slug: WORKFLOW_HISTORY_COLLECTION,
|
|
350
|
-
labels: { singular: "Workflow transition", plural: "Workflow transitions" },
|
|
351
|
-
fields: [
|
|
352
|
-
{ name: "collection", type: "text", required: true },
|
|
353
|
-
{ name: "documentId", type: "text", required: true },
|
|
354
|
-
{ name: "transition", type: "text", required: true },
|
|
355
|
-
{ name: "from", type: "text", required: true },
|
|
356
|
-
{ name: "to", type: "text", required: true },
|
|
357
|
-
{ name: "revision", type: "number", required: true },
|
|
358
|
-
{ name: "comment", type: "textarea" },
|
|
359
|
-
{ name: "actorId", type: "text" },
|
|
360
|
-
{ name: "createdAt", type: "date", required: true }
|
|
361
|
-
],
|
|
362
|
-
access: { read: ({ user }) => !!user, create: () => false, update: () => false, delete: () => false },
|
|
363
|
-
admin: { hidden: true }
|
|
364
|
-
};
|
|
365
|
-
var LIFECYCLE_EVENTS_COLLECTION_CONFIG = {
|
|
366
|
-
slug: LIFECYCLE_EVENTS_COLLECTION,
|
|
367
|
-
labels: { singular: "Lifecycle event", plural: "Lifecycle events" },
|
|
368
|
-
fields: [
|
|
369
|
-
{ name: "name", type: "text", required: true },
|
|
370
|
-
{ name: "collection", type: "text", required: true },
|
|
371
|
-
{ name: "documentId", type: "text", required: true },
|
|
372
|
-
{ name: "occurredAt", type: "date", required: true },
|
|
373
|
-
{ name: "actorId", type: "text" },
|
|
374
|
-
{ name: "payload", type: "json", required: true },
|
|
375
|
-
{ name: "attempts", type: "number", required: true },
|
|
376
|
-
{ name: "status", type: "select", options: ["pending", "processing", "delivered", "failed"], required: true },
|
|
377
|
-
{ name: "nextAttemptAt", type: "date" },
|
|
378
|
-
{ name: "deliveredAt", type: "date" },
|
|
379
|
-
{ name: "lastError", type: "textarea" }
|
|
380
|
-
],
|
|
381
|
-
access: { read: ({ user }) => !!user?.roles?.includes("admin"), create: () => false, update: () => false, delete: () => false },
|
|
382
|
-
admin: { hidden: true }
|
|
383
|
-
};
|
|
384
|
-
function normalizeConfig(config) {
|
|
385
|
-
const collections = config?.collections || [];
|
|
386
|
-
const globals = config?.globals || [];
|
|
387
|
-
const needsAudit = collections.some((col) => col.audit);
|
|
388
|
-
const needsWorkflow = collections.some((col) => col.workflow);
|
|
389
|
-
const adminAuthCollectionSlug = getAdminAuthCollection({
|
|
390
|
-
collections,
|
|
391
|
-
adminAuth: config.adminAuth
|
|
392
|
-
})?.slug;
|
|
393
|
-
const normalizedCollections = collections.map((col) => {
|
|
394
|
-
let fields = col.fields || [];
|
|
395
|
-
const existingFieldNames = new Set(fields.map((f) => f.name));
|
|
396
|
-
if (col.auth) {
|
|
397
|
-
if (!existingFieldNames.has("email")) {
|
|
398
|
-
fields = [
|
|
399
|
-
...fields,
|
|
400
|
-
{
|
|
401
|
-
name: "email",
|
|
402
|
-
type: "email",
|
|
403
|
-
label: "Email",
|
|
404
|
-
required: true,
|
|
405
|
-
unique: true,
|
|
406
|
-
promoted: true,
|
|
407
|
-
access: {
|
|
408
|
-
update: "!id"
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
];
|
|
412
|
-
}
|
|
413
|
-
if (!existingFieldNames.has("password")) {
|
|
414
|
-
fields = [
|
|
415
|
-
...fields,
|
|
416
|
-
{
|
|
417
|
-
name: "password",
|
|
418
|
-
type: "text",
|
|
419
|
-
label: "Password",
|
|
420
|
-
required: true,
|
|
421
|
-
access: {
|
|
422
|
-
update: "!id || user.id == id"
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
];
|
|
426
|
-
}
|
|
427
|
-
if (!existingFieldNames.has("roles")) {
|
|
428
|
-
fields = [
|
|
429
|
-
...fields,
|
|
430
|
-
{
|
|
431
|
-
name: "roles",
|
|
432
|
-
type: "select",
|
|
433
|
-
label: "Roles",
|
|
434
|
-
defaultValue: [],
|
|
435
|
-
options: [
|
|
436
|
-
{ value: "admin", label: "Admin" },
|
|
437
|
-
{ value: "editor", label: "Editor" },
|
|
438
|
-
{ value: "viewer", label: "Viewer" }
|
|
439
|
-
],
|
|
440
|
-
access: {
|
|
441
|
-
update: "user.roles && 'admin' in user.roles"
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
];
|
|
445
|
-
}
|
|
446
|
-
fields = fields.map((field) => {
|
|
447
|
-
if (field.name === "email") {
|
|
448
|
-
return {
|
|
449
|
-
...field,
|
|
450
|
-
access: {
|
|
451
|
-
...field.access || {},
|
|
452
|
-
update: "!id"
|
|
453
|
-
}
|
|
454
|
-
};
|
|
455
|
-
}
|
|
456
|
-
if (field.name === "password") {
|
|
457
|
-
return {
|
|
458
|
-
...field,
|
|
459
|
-
admin: { ...field.admin || {} },
|
|
460
|
-
access: {
|
|
461
|
-
...field.access || {},
|
|
462
|
-
update: "!id || user.id == id"
|
|
463
|
-
}
|
|
464
|
-
};
|
|
465
|
-
}
|
|
466
|
-
if (field.name === "roles") {
|
|
467
|
-
return {
|
|
468
|
-
...field,
|
|
469
|
-
access: {
|
|
470
|
-
...field.access || {},
|
|
471
|
-
// Must be an admin; cannot edit own roles (no self-elevation).
|
|
472
|
-
update: "user.roles && 'admin' in user.roles && user.id != id"
|
|
473
|
-
}
|
|
474
|
-
};
|
|
475
|
-
}
|
|
476
|
-
return field;
|
|
477
|
-
});
|
|
478
|
-
}
|
|
479
|
-
if (adminAuthCollectionSlug && col.slug === adminAuthCollectionSlug && config.adminAuth?.mode === "external") {
|
|
480
|
-
const externalAdminFields = [
|
|
481
|
-
{
|
|
482
|
-
name: "authProvider",
|
|
483
|
-
type: "text",
|
|
484
|
-
label: "Auth Provider",
|
|
485
|
-
admin: { readOnly: true, hidden: true }
|
|
486
|
-
},
|
|
487
|
-
{
|
|
488
|
-
name: "externalSubject",
|
|
489
|
-
type: "text",
|
|
490
|
-
label: "External Subject",
|
|
491
|
-
admin: { readOnly: true, hidden: true }
|
|
492
|
-
},
|
|
493
|
-
{
|
|
494
|
-
name: "authSource",
|
|
495
|
-
type: "text",
|
|
496
|
-
label: "Auth Source",
|
|
497
|
-
admin: { readOnly: true, hidden: true }
|
|
498
|
-
},
|
|
499
|
-
{
|
|
500
|
-
name: "lastLoginAt",
|
|
501
|
-
type: "date",
|
|
502
|
-
label: "Last Login At",
|
|
503
|
-
admin: { readOnly: true, hidden: true }
|
|
504
|
-
}
|
|
505
|
-
];
|
|
506
|
-
for (const field of externalAdminFields) {
|
|
507
|
-
if (!existingFieldNames.has(field.name)) {
|
|
508
|
-
fields = [...fields, field];
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
const updatedFieldNames = new Set(fields.map((f) => f.name));
|
|
513
|
-
const fieldsToInject = SYSTEM_FIELDS.filter((f) => !updatedFieldNames.has(f.name));
|
|
514
|
-
return {
|
|
515
|
-
...col,
|
|
516
|
-
fields: [...fields, ...fieldsToInject]
|
|
517
|
-
};
|
|
518
|
-
});
|
|
519
|
-
const hasAuditCollection = normalizedCollections.some((col) => col.slug === AUDIT_COLLECTION_SLUG);
|
|
520
|
-
const systemCollections = [];
|
|
521
|
-
if (needsAudit && !hasAuditCollection)
|
|
522
|
-
systemCollections.push(AUDIT_COLLECTION);
|
|
523
|
-
if (needsWorkflow && !normalizedCollections.some((col) => col.slug === WORKFLOW_HISTORY_COLLECTION)) {
|
|
524
|
-
systemCollections.push(WORKFLOW_HISTORY_COLLECTION_CONFIG);
|
|
525
|
-
}
|
|
526
|
-
if (needsWorkflow && !normalizedCollections.some((col) => col.slug === LIFECYCLE_EVENTS_COLLECTION)) {
|
|
527
|
-
systemCollections.push(LIFECYCLE_EVENTS_COLLECTION_CONFIG);
|
|
528
|
-
}
|
|
529
|
-
return {
|
|
530
|
-
...config,
|
|
531
|
-
collections: [...normalizedCollections, ...systemCollections],
|
|
532
|
-
globals
|
|
533
|
-
};
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
// src/utils/hooks.js
|
|
537
|
-
async function runCollectionHooks(hooks, args, options = {}) {
|
|
538
|
-
if (!hooks || hooks.length === 0) {
|
|
539
|
-
return args.data ?? args.doc ?? void 0;
|
|
540
|
-
}
|
|
541
|
-
let currentPayload = args.data ?? args.doc ?? void 0;
|
|
542
|
-
for (const hook of hooks) {
|
|
543
|
-
try {
|
|
544
|
-
const result = await hook({
|
|
545
|
-
...args,
|
|
546
|
-
data: args.data !== void 0 ? currentPayload : void 0,
|
|
547
|
-
doc: args.doc !== void 0 ? currentPayload : void 0
|
|
548
|
-
});
|
|
549
|
-
if (result !== void 0) {
|
|
550
|
-
currentPayload = result;
|
|
551
|
-
}
|
|
552
|
-
} catch (err) {
|
|
553
|
-
if (options.isolated) {
|
|
554
|
-
console.error("[dyrected/core] Side-effect hook failed (error isolated \u2014 DB write was successful):", err);
|
|
555
|
-
} else {
|
|
556
|
-
throw err;
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
return currentPayload;
|
|
561
|
-
}
|
|
562
|
-
async function executeFieldBeforeChange(fields, data, originalDoc, user, db) {
|
|
563
|
-
if (!data || typeof data !== "object")
|
|
564
|
-
return data;
|
|
565
|
-
const result = { ...data };
|
|
566
|
-
for (const field of fields) {
|
|
567
|
-
if (!field.name)
|
|
568
|
-
continue;
|
|
569
|
-
const value = result[field.name];
|
|
570
|
-
const origValue = originalDoc?.[field.name];
|
|
571
|
-
let updatedValue = value;
|
|
572
|
-
if (field.hooks?.beforeChange) {
|
|
573
|
-
for (const hook of field.hooks.beforeChange) {
|
|
574
|
-
const typedHook = hook;
|
|
575
|
-
const hookArgs = {
|
|
576
|
-
value: updatedValue,
|
|
577
|
-
originalDoc: originalDoc ?? void 0,
|
|
578
|
-
data: result,
|
|
579
|
-
user,
|
|
580
|
-
db
|
|
581
|
-
};
|
|
582
|
-
updatedValue = await typedHook(hookArgs);
|
|
583
|
-
}
|
|
584
|
-
result[field.name] = updatedValue;
|
|
585
|
-
}
|
|
586
|
-
if (updatedValue !== void 0 && updatedValue !== null) {
|
|
587
|
-
if (field.type === "object" && field.fields) {
|
|
588
|
-
result[field.name] = await executeFieldBeforeChange(field.fields, updatedValue, origValue, user, db);
|
|
589
|
-
} else if (field.type === "array" && field.fields && Array.isArray(updatedValue)) {
|
|
590
|
-
const arrayResult = [];
|
|
591
|
-
for (let i = 0; i < updatedValue.length; i++) {
|
|
592
|
-
const item = updatedValue[i];
|
|
593
|
-
const origItem = Array.isArray(origValue) ? origValue[i] : null;
|
|
594
|
-
arrayResult.push(await executeFieldBeforeChange(field.fields, item, origItem, user, db));
|
|
595
|
-
}
|
|
596
|
-
result[field.name] = arrayResult;
|
|
597
|
-
} else if (field.type === "blocks" && field.blocks && Array.isArray(updatedValue)) {
|
|
598
|
-
const blocksResult = [];
|
|
599
|
-
for (let i = 0; i < updatedValue.length; i++) {
|
|
600
|
-
const blockData = updatedValue[i];
|
|
601
|
-
const origBlock = Array.isArray(origValue) ? origValue[i] : null;
|
|
602
|
-
const blockConfig = field.blocks.find((b) => b.slug === blockData.blockType);
|
|
603
|
-
if (blockConfig) {
|
|
604
|
-
blocksResult.push(await executeFieldBeforeChange(blockConfig.fields, blockData, origBlock, user, db));
|
|
605
|
-
} else {
|
|
606
|
-
blocksResult.push(blockData);
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
result[field.name] = blocksResult;
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
return result;
|
|
614
|
-
}
|
|
615
|
-
async function executeFieldAfterRead(fields, doc, user, db) {
|
|
616
|
-
if (!doc || typeof doc !== "object")
|
|
617
|
-
return doc;
|
|
618
|
-
const result = { ...doc };
|
|
619
|
-
for (const field of fields) {
|
|
620
|
-
if (!field.name)
|
|
621
|
-
continue;
|
|
622
|
-
const value = result[field.name];
|
|
623
|
-
let updatedValue = value;
|
|
624
|
-
if (field.hooks?.afterRead) {
|
|
625
|
-
for (const hook of field.hooks.afterRead) {
|
|
626
|
-
const typedHook = hook;
|
|
627
|
-
const hookArgs = {
|
|
628
|
-
value: updatedValue,
|
|
629
|
-
doc: result,
|
|
630
|
-
user,
|
|
631
|
-
db
|
|
632
|
-
};
|
|
633
|
-
updatedValue = await typedHook(hookArgs);
|
|
634
|
-
}
|
|
635
|
-
result[field.name] = updatedValue;
|
|
636
|
-
}
|
|
637
|
-
if (updatedValue !== void 0 && updatedValue !== null) {
|
|
638
|
-
if (field.type === "object" && field.fields) {
|
|
639
|
-
result[field.name] = await executeFieldAfterRead(field.fields, updatedValue, user, db);
|
|
640
|
-
} else if (field.type === "array" && field.fields && Array.isArray(updatedValue)) {
|
|
641
|
-
const arrayResult = [];
|
|
642
|
-
for (const item of updatedValue) {
|
|
643
|
-
arrayResult.push(await executeFieldAfterRead(field.fields, item, user, db));
|
|
644
|
-
}
|
|
645
|
-
result[field.name] = arrayResult;
|
|
646
|
-
} else if (field.type === "blocks" && field.blocks && Array.isArray(updatedValue)) {
|
|
647
|
-
const blocksResult = [];
|
|
648
|
-
for (const blockData of updatedValue) {
|
|
649
|
-
const typedBlock = blockData;
|
|
650
|
-
const blockConfig = field.blocks.find((b) => b.slug === typedBlock.blockType);
|
|
651
|
-
if (blockConfig) {
|
|
652
|
-
blocksResult.push(await executeFieldAfterRead(blockConfig.fields, typedBlock, user, db));
|
|
653
|
-
} else {
|
|
654
|
-
blocksResult.push(blockData);
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
result[field.name] = blocksResult;
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
return result;
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
// src/utils/openapi.js
|
|
665
|
-
function generateOpenApi(config) {
|
|
666
|
-
const spec = {
|
|
667
|
-
openapi: "3.0.0",
|
|
668
|
-
info: {
|
|
669
|
-
title: "Dyrected API",
|
|
670
|
-
version: "1.0.0",
|
|
671
|
-
description: "Automatically generated OpenAPI specification for the Dyrected project."
|
|
672
|
-
},
|
|
673
|
-
components: {
|
|
674
|
-
schemas: {
|
|
675
|
-
WorkflowMetadata: {
|
|
676
|
-
type: "object",
|
|
677
|
-
required: ["state", "revision"],
|
|
678
|
-
properties: {
|
|
679
|
-
state: { type: "string" },
|
|
680
|
-
revision: { type: "integer", minimum: 1 },
|
|
681
|
-
publishedRevision: { type: "integer", minimum: 1 },
|
|
682
|
-
publishedAt: { type: "string", format: "date-time" },
|
|
683
|
-
publishedBy: { type: "string" },
|
|
684
|
-
availableTransitions: { type: "array", items: { type: "string" } }
|
|
685
|
-
}
|
|
686
|
-
},
|
|
687
|
-
WorkflowTransitionRequest: {
|
|
688
|
-
type: "object",
|
|
689
|
-
properties: {
|
|
690
|
-
expectedRevision: { type: "integer", minimum: 1 },
|
|
691
|
-
comment: { type: "string" }
|
|
692
|
-
}
|
|
693
|
-
},
|
|
694
|
-
WorkflowHistoryEntry: {
|
|
695
|
-
type: "object",
|
|
696
|
-
required: [
|
|
697
|
-
"collection",
|
|
698
|
-
"documentId",
|
|
699
|
-
"transition",
|
|
700
|
-
"from",
|
|
701
|
-
"to",
|
|
702
|
-
"revision",
|
|
703
|
-
"createdAt"
|
|
704
|
-
],
|
|
705
|
-
properties: {
|
|
706
|
-
id: { type: "string" },
|
|
707
|
-
collection: { type: "string" },
|
|
708
|
-
documentId: { type: "string" },
|
|
709
|
-
transition: { type: "string" },
|
|
710
|
-
from: { type: "string" },
|
|
711
|
-
to: { type: "string" },
|
|
712
|
-
revision: { type: "integer" },
|
|
713
|
-
comment: { type: "string", nullable: true },
|
|
714
|
-
actorId: { type: "string", nullable: true },
|
|
715
|
-
createdAt: { type: "string", format: "date-time" }
|
|
716
|
-
}
|
|
717
|
-
},
|
|
718
|
-
Error: {
|
|
719
|
-
type: "object",
|
|
720
|
-
properties: {
|
|
721
|
-
message: { type: "string" },
|
|
722
|
-
errors: {
|
|
723
|
-
type: "array",
|
|
724
|
-
items: { type: "object", additionalProperties: true }
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
},
|
|
728
|
-
AuthCredentials: {
|
|
729
|
-
type: "object",
|
|
730
|
-
required: ["email", "password"],
|
|
731
|
-
properties: {
|
|
732
|
-
email: { type: "string", format: "email" },
|
|
733
|
-
password: { type: "string" }
|
|
734
|
-
}
|
|
735
|
-
},
|
|
736
|
-
TokenResponse: {
|
|
737
|
-
type: "object",
|
|
738
|
-
properties: {
|
|
739
|
-
token: { type: "string" },
|
|
740
|
-
user: { type: "object", additionalProperties: true }
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
},
|
|
744
|
-
securitySchemes: {
|
|
745
|
-
ApiKeyAuth: {
|
|
746
|
-
type: "apiKey",
|
|
747
|
-
in: "header",
|
|
748
|
-
name: "x-api-key"
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
},
|
|
752
|
-
paths: {},
|
|
753
|
-
security: [{ ApiKeyAuth: [] }]
|
|
754
|
-
};
|
|
755
|
-
spec.paths["/api/schemas"] = {
|
|
756
|
-
get: {
|
|
757
|
-
tags: ["System"],
|
|
758
|
-
summary: "Get the serialized Dyrected schema",
|
|
759
|
-
security: [],
|
|
760
|
-
responses: {
|
|
761
|
-
200: { description: "Collection and global schema definitions" }
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
};
|
|
765
|
-
spec.paths["/api/openapi.json"] = {
|
|
766
|
-
get: {
|
|
767
|
-
tags: ["System"],
|
|
768
|
-
summary: "Get the OpenAPI specification",
|
|
769
|
-
security: [],
|
|
770
|
-
responses: { 200: { description: "OpenAPI 3.0 document" } }
|
|
771
|
-
}
|
|
772
|
-
};
|
|
773
|
-
spec.paths["/api/docs"] = {
|
|
774
|
-
get: {
|
|
775
|
-
tags: ["System"],
|
|
776
|
-
summary: "Open interactive API documentation",
|
|
777
|
-
security: [],
|
|
778
|
-
responses: { 200: { description: "Swagger UI HTML" } }
|
|
779
|
-
}
|
|
780
|
-
};
|
|
781
|
-
spec.paths["/api/dyrected/options/{collection}/{field}"] = {
|
|
782
|
-
get: {
|
|
783
|
-
tags: ["System"],
|
|
784
|
-
summary: "Resolve dynamic field options",
|
|
785
|
-
parameters: [
|
|
786
|
-
{
|
|
787
|
-
name: "collection",
|
|
788
|
-
in: "path",
|
|
789
|
-
required: true,
|
|
790
|
-
schema: { type: "string" }
|
|
791
|
-
},
|
|
792
|
-
{
|
|
793
|
-
name: "field",
|
|
794
|
-
in: "path",
|
|
795
|
-
required: true,
|
|
796
|
-
schema: { type: "string" }
|
|
797
|
-
}
|
|
798
|
-
],
|
|
799
|
-
responses: { 200: { description: "Resolved option items" } }
|
|
800
|
-
}
|
|
801
|
-
};
|
|
802
|
-
spec.paths["/api/preferences/{key}"] = {
|
|
803
|
-
get: {
|
|
804
|
-
tags: ["Preferences"],
|
|
805
|
-
summary: "Get an authenticated user preference",
|
|
806
|
-
parameters: [
|
|
807
|
-
{ name: "key", in: "path", required: true, schema: { type: "string" } }
|
|
808
|
-
],
|
|
809
|
-
responses: { 200: { description: "Preference value" } }
|
|
810
|
-
},
|
|
811
|
-
put: {
|
|
812
|
-
tags: ["Preferences"],
|
|
813
|
-
summary: "Set an authenticated user preference",
|
|
814
|
-
parameters: [
|
|
815
|
-
{ name: "key", in: "path", required: true, schema: { type: "string" } }
|
|
816
|
-
],
|
|
817
|
-
requestBody: {
|
|
818
|
-
required: true,
|
|
819
|
-
content: { "application/json": { schema: { type: "object" } } }
|
|
820
|
-
},
|
|
821
|
-
responses: { 200: { description: "Updated preference" } }
|
|
822
|
-
}
|
|
823
|
-
};
|
|
824
|
-
spec.paths["/api/preview-token"] = {
|
|
825
|
-
post: {
|
|
826
|
-
tags: ["Preview"],
|
|
827
|
-
summary: "Create a preview token",
|
|
828
|
-
responses: { 200: { description: "Short-lived preview token" } }
|
|
829
|
-
}
|
|
830
|
-
};
|
|
831
|
-
spec.paths["/api/preview-data"] = {
|
|
832
|
-
get: {
|
|
833
|
-
tags: ["Preview"],
|
|
834
|
-
summary: "Resolve preview data from a token",
|
|
835
|
-
security: [],
|
|
836
|
-
parameters: [
|
|
837
|
-
{
|
|
838
|
-
name: "token",
|
|
839
|
-
in: "query",
|
|
840
|
-
required: true,
|
|
841
|
-
schema: { type: "string" }
|
|
842
|
-
}
|
|
843
|
-
],
|
|
844
|
-
responses: { 200: { description: "Preview document data" } }
|
|
845
|
-
}
|
|
846
|
-
};
|
|
847
|
-
for (const collection of config.collections) {
|
|
848
|
-
spec.components.schemas[collection.slug] = collectionToSchema(collection);
|
|
849
|
-
}
|
|
850
|
-
for (const global of config.globals) {
|
|
851
|
-
spec.components.schemas[global.slug] = globalToSchema(global);
|
|
852
|
-
}
|
|
853
|
-
for (const collection of config.collections) {
|
|
854
|
-
const slug = collection.slug;
|
|
855
|
-
const path = `/api/collections/${slug}`;
|
|
856
|
-
const labels = collection.labels || { singular: slug, plural: `${slug}s` };
|
|
857
|
-
spec.paths[path] = {
|
|
858
|
-
get: {
|
|
859
|
-
tags: ["Collections"],
|
|
860
|
-
summary: `Find ${labels.plural}`,
|
|
861
|
-
parameters: [
|
|
862
|
-
{
|
|
863
|
-
name: "limit",
|
|
864
|
-
in: "query",
|
|
865
|
-
schema: { type: "integer", default: 10 }
|
|
866
|
-
},
|
|
867
|
-
{
|
|
868
|
-
name: "page",
|
|
869
|
-
in: "query",
|
|
870
|
-
schema: { type: "integer", default: 1 }
|
|
871
|
-
},
|
|
872
|
-
{
|
|
873
|
-
name: "where",
|
|
874
|
-
in: "query",
|
|
875
|
-
schema: { type: "string" },
|
|
876
|
-
description: "JSON filter"
|
|
877
|
-
},
|
|
878
|
-
{
|
|
879
|
-
name: "sort",
|
|
880
|
-
in: "query",
|
|
881
|
-
schema: { type: "string" },
|
|
882
|
-
description: "Sort field (e.g. -createdAt)"
|
|
883
|
-
}
|
|
884
|
-
],
|
|
885
|
-
responses: {
|
|
886
|
-
200: {
|
|
887
|
-
description: "Success",
|
|
888
|
-
content: {
|
|
889
|
-
"application/json": {
|
|
890
|
-
schema: {
|
|
891
|
-
type: "object",
|
|
892
|
-
properties: {
|
|
893
|
-
docs: {
|
|
894
|
-
type: "array",
|
|
895
|
-
items: { $ref: `#/components/schemas/${slug}` }
|
|
896
|
-
},
|
|
897
|
-
total: { type: "integer" },
|
|
898
|
-
limit: { type: "integer" },
|
|
899
|
-
page: { type: "integer" }
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
},
|
|
907
|
-
post: {
|
|
908
|
-
tags: ["Collections"],
|
|
909
|
-
summary: `Create ${labels.singular}`,
|
|
910
|
-
requestBody: {
|
|
911
|
-
required: true,
|
|
912
|
-
content: {
|
|
913
|
-
"application/json": {
|
|
914
|
-
schema: { $ref: `#/components/schemas/${slug}` }
|
|
915
|
-
}
|
|
916
|
-
}
|
|
917
|
-
},
|
|
918
|
-
responses: {
|
|
919
|
-
201: {
|
|
920
|
-
description: "Created",
|
|
921
|
-
content: {
|
|
922
|
-
"application/json": {
|
|
923
|
-
schema: { $ref: `#/components/schemas/${slug}` }
|
|
924
|
-
}
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
};
|
|
930
|
-
spec.paths[`${path}/{id}`] = {
|
|
931
|
-
get: {
|
|
932
|
-
tags: ["Collections"],
|
|
933
|
-
summary: `Get a single ${labels.singular}`,
|
|
934
|
-
parameters: [
|
|
935
|
-
{
|
|
936
|
-
name: "id",
|
|
937
|
-
in: "path",
|
|
938
|
-
required: true,
|
|
939
|
-
schema: { type: "string" }
|
|
940
|
-
}
|
|
941
|
-
],
|
|
942
|
-
responses: {
|
|
943
|
-
200: {
|
|
944
|
-
description: "Success",
|
|
945
|
-
content: {
|
|
946
|
-
"application/json": {
|
|
947
|
-
schema: { $ref: `#/components/schemas/${slug}` }
|
|
948
|
-
}
|
|
949
|
-
}
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
},
|
|
953
|
-
patch: {
|
|
954
|
-
tags: ["Collections"],
|
|
955
|
-
summary: `Update ${labels.singular}`,
|
|
956
|
-
parameters: [
|
|
957
|
-
{
|
|
958
|
-
name: "id",
|
|
959
|
-
in: "path",
|
|
960
|
-
required: true,
|
|
961
|
-
schema: { type: "string" }
|
|
962
|
-
}
|
|
963
|
-
],
|
|
964
|
-
requestBody: {
|
|
965
|
-
required: true,
|
|
966
|
-
content: {
|
|
967
|
-
"application/json": {
|
|
968
|
-
schema: { $ref: `#/components/schemas/${slug}` }
|
|
969
|
-
}
|
|
970
|
-
}
|
|
971
|
-
},
|
|
972
|
-
responses: {
|
|
973
|
-
200: {
|
|
974
|
-
description: "Updated",
|
|
975
|
-
content: {
|
|
976
|
-
"application/json": {
|
|
977
|
-
schema: { $ref: `#/components/schemas/${slug}` }
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
},
|
|
983
|
-
delete: {
|
|
984
|
-
tags: ["Collections"],
|
|
985
|
-
summary: `Delete ${labels.singular}`,
|
|
986
|
-
parameters: [
|
|
987
|
-
{
|
|
988
|
-
name: "id",
|
|
989
|
-
in: "path",
|
|
990
|
-
required: true,
|
|
991
|
-
schema: { type: "string" }
|
|
992
|
-
}
|
|
993
|
-
],
|
|
994
|
-
responses: {
|
|
995
|
-
204: { description: "Deleted" }
|
|
996
|
-
}
|
|
997
|
-
}
|
|
998
|
-
};
|
|
999
|
-
spec.paths[`${path}/delete-many`] = {
|
|
1000
|
-
delete: {
|
|
1001
|
-
tags: ["Collections"],
|
|
1002
|
-
summary: `Delete multiple ${labels.plural}`,
|
|
1003
|
-
requestBody: {
|
|
1004
|
-
required: true,
|
|
1005
|
-
content: {
|
|
1006
|
-
"application/json": {
|
|
1007
|
-
schema: {
|
|
1008
|
-
type: "object",
|
|
1009
|
-
required: ["ids"],
|
|
1010
|
-
properties: {
|
|
1011
|
-
ids: { type: "array", items: { type: "string" } }
|
|
1012
|
-
}
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
},
|
|
1017
|
-
responses: { 200: { description: "Deleted and failed document IDs" } }
|
|
1018
|
-
}
|
|
1019
|
-
};
|
|
1020
|
-
spec.paths[`${path}/seed`] = {
|
|
1021
|
-
post: {
|
|
1022
|
-
tags: ["Collections"],
|
|
1023
|
-
summary: `Seed initial ${labels.plural}`,
|
|
1024
|
-
responses: { 200: { description: "Seeded documents" } }
|
|
1025
|
-
}
|
|
1026
|
-
};
|
|
1027
|
-
if (collection.upload) {
|
|
1028
|
-
spec.paths[`${path}/media`] = {
|
|
1029
|
-
get: {
|
|
1030
|
-
tags: ["Media"],
|
|
1031
|
-
summary: `List ${labels.plural}`,
|
|
1032
|
-
responses: { 200: { description: "Paginated media documents" } }
|
|
1033
|
-
},
|
|
1034
|
-
post: {
|
|
1035
|
-
tags: ["Media"],
|
|
1036
|
-
summary: `Upload ${labels.singular}`,
|
|
1037
|
-
requestBody: {
|
|
1038
|
-
required: true,
|
|
1039
|
-
content: {
|
|
1040
|
-
"multipart/form-data": {
|
|
1041
|
-
schema: {
|
|
1042
|
-
type: "object",
|
|
1043
|
-
required: ["file"],
|
|
1044
|
-
properties: { file: { type: "string", format: "binary" } }
|
|
1045
|
-
}
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
},
|
|
1049
|
-
responses: { 201: { description: "Uploaded media document" } }
|
|
1050
|
-
}
|
|
1051
|
-
};
|
|
1052
|
-
spec.paths[`${path}/media/{filename}`] = {
|
|
1053
|
-
get: {
|
|
1054
|
-
tags: ["Media"],
|
|
1055
|
-
summary: `Serve ${labels.singular} bytes`,
|
|
1056
|
-
parameters: [
|
|
1057
|
-
{
|
|
1058
|
-
name: "filename",
|
|
1059
|
-
in: "path",
|
|
1060
|
-
required: true,
|
|
1061
|
-
schema: { type: "string" }
|
|
1062
|
-
}
|
|
1063
|
-
],
|
|
1064
|
-
security: [],
|
|
1065
|
-
responses: {
|
|
1066
|
-
200: { description: "Stored file" },
|
|
1067
|
-
404: { description: "File not found" }
|
|
1068
|
-
}
|
|
1069
|
-
}
|
|
1070
|
-
};
|
|
1071
|
-
}
|
|
1072
|
-
if (collection.auth) {
|
|
1073
|
-
const publicAuthPost = (summary) => ({
|
|
1074
|
-
tags: ["Authentication"],
|
|
1075
|
-
summary,
|
|
1076
|
-
security: [],
|
|
1077
|
-
requestBody: {
|
|
1078
|
-
required: true,
|
|
1079
|
-
content: {
|
|
1080
|
-
"application/json": {
|
|
1081
|
-
schema: { type: "object", additionalProperties: true }
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
|
-
},
|
|
1085
|
-
responses: {
|
|
1086
|
-
200: { description: "Success" },
|
|
1087
|
-
400: { description: "Invalid request" }
|
|
1088
|
-
}
|
|
1089
|
-
});
|
|
1090
|
-
spec.paths[`${path}/login`] = {
|
|
1091
|
-
post: {
|
|
1092
|
-
...publicAuthPost(`Log in to ${labels.plural}`),
|
|
1093
|
-
requestBody: {
|
|
1094
|
-
required: true,
|
|
1095
|
-
content: {
|
|
1096
|
-
"application/json": {
|
|
1097
|
-
schema: { $ref: "#/components/schemas/AuthCredentials" }
|
|
1098
|
-
}
|
|
1099
|
-
}
|
|
1100
|
-
},
|
|
1101
|
-
responses: {
|
|
1102
|
-
200: {
|
|
1103
|
-
description: "Authenticated",
|
|
1104
|
-
content: {
|
|
1105
|
-
"application/json": {
|
|
1106
|
-
schema: { $ref: "#/components/schemas/TokenResponse" }
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
},
|
|
1110
|
-
401: { description: "Invalid credentials" }
|
|
1111
|
-
}
|
|
1112
|
-
}
|
|
1113
|
-
};
|
|
1114
|
-
spec.paths[`${path}/logout`] = {
|
|
1115
|
-
post: {
|
|
1116
|
-
tags: ["Authentication"],
|
|
1117
|
-
summary: `Log out of ${labels.plural}`,
|
|
1118
|
-
responses: { 200: { description: "Logged out" } }
|
|
1119
|
-
}
|
|
1120
|
-
};
|
|
1121
|
-
spec.paths[`${path}/init`] = {
|
|
1122
|
-
get: {
|
|
1123
|
-
tags: ["Authentication"],
|
|
1124
|
-
summary: `Get ${labels.plural} initialization state`,
|
|
1125
|
-
security: [],
|
|
1126
|
-
responses: { 200: { description: "Initialization state" } }
|
|
1127
|
-
}
|
|
1128
|
-
};
|
|
1129
|
-
spec.paths[`${path}/first-user`] = {
|
|
1130
|
-
post: publicAuthPost(`Register the first ${labels.singular}`)
|
|
1131
|
-
};
|
|
1132
|
-
spec.paths[`${path}/me`] = {
|
|
1133
|
-
get: {
|
|
1134
|
-
tags: ["Authentication"],
|
|
1135
|
-
summary: `Get the current ${labels.singular}`,
|
|
1136
|
-
responses: { 200: { description: "Authenticated user" } }
|
|
1137
|
-
}
|
|
1138
|
-
};
|
|
1139
|
-
spec.paths[`${path}/refresh-token`] = {
|
|
1140
|
-
post: {
|
|
1141
|
-
tags: ["Authentication"],
|
|
1142
|
-
summary: "Refresh an authentication token",
|
|
1143
|
-
responses: { 200: { description: "Refreshed token" } }
|
|
1144
|
-
}
|
|
1145
|
-
};
|
|
1146
|
-
spec.paths[`${path}/forgot-password`] = {
|
|
1147
|
-
post: publicAuthPost("Request a password reset")
|
|
1148
|
-
};
|
|
1149
|
-
spec.paths[`${path}/reset-password`] = {
|
|
1150
|
-
post: publicAuthPost("Reset a password")
|
|
1151
|
-
};
|
|
1152
|
-
spec.paths[`${path}/invite`] = {
|
|
1153
|
-
post: {
|
|
1154
|
-
tags: ["Authentication"],
|
|
1155
|
-
summary: `Invite a ${labels.singular}`,
|
|
1156
|
-
responses: { 200: { description: "Invitation sent" } }
|
|
1157
|
-
}
|
|
1158
|
-
};
|
|
1159
|
-
spec.paths[`${path}/accept-invite`] = {
|
|
1160
|
-
post: publicAuthPost("Accept an invitation")
|
|
1161
|
-
};
|
|
1162
|
-
spec.paths[`${path}/{id}/change-password`] = {
|
|
1163
|
-
post: {
|
|
1164
|
-
tags: ["Authentication"],
|
|
1165
|
-
summary: `Change a ${labels.singular} password`,
|
|
1166
|
-
parameters: [
|
|
1167
|
-
{
|
|
1168
|
-
name: "id",
|
|
1169
|
-
in: "path",
|
|
1170
|
-
required: true,
|
|
1171
|
-
schema: { type: "string" }
|
|
1172
|
-
}
|
|
1173
|
-
],
|
|
1174
|
-
responses: { 200: { description: "Password changed" } }
|
|
1175
|
-
}
|
|
1176
|
-
};
|
|
1177
|
-
}
|
|
1178
|
-
if (collection.workflow) {
|
|
1179
|
-
spec.paths[`${path}/{id}/transitions/{transition}`] = {
|
|
1180
|
-
post: {
|
|
1181
|
-
tags: ["Workflows"],
|
|
1182
|
-
summary: `Transition ${labels.singular} workflow`,
|
|
1183
|
-
parameters: [
|
|
1184
|
-
{
|
|
1185
|
-
name: "id",
|
|
1186
|
-
in: "path",
|
|
1187
|
-
required: true,
|
|
1188
|
-
schema: { type: "string" }
|
|
1189
|
-
},
|
|
1190
|
-
{
|
|
1191
|
-
name: "transition",
|
|
1192
|
-
in: "path",
|
|
1193
|
-
required: true,
|
|
1194
|
-
schema: {
|
|
1195
|
-
type: "string",
|
|
1196
|
-
enum: collection.workflow.transitions.map((item) => item.name)
|
|
1197
|
-
}
|
|
1198
|
-
}
|
|
1199
|
-
],
|
|
1200
|
-
requestBody: {
|
|
1201
|
-
content: {
|
|
1202
|
-
"application/json": {
|
|
1203
|
-
schema: {
|
|
1204
|
-
$ref: "#/components/schemas/WorkflowTransitionRequest"
|
|
1205
|
-
}
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
},
|
|
1209
|
-
responses: {
|
|
1210
|
-
200: {
|
|
1211
|
-
description: "Transition applied",
|
|
1212
|
-
content: {
|
|
1213
|
-
"application/json": {
|
|
1214
|
-
schema: { $ref: `#/components/schemas/${slug}` }
|
|
1215
|
-
}
|
|
1216
|
-
}
|
|
1217
|
-
},
|
|
1218
|
-
400: { description: "Required transition input is missing" },
|
|
1219
|
-
403: { description: "Transition capability denied" },
|
|
1220
|
-
409: { description: "Invalid state or stale revision" }
|
|
1221
|
-
}
|
|
1222
|
-
}
|
|
1223
|
-
};
|
|
1224
|
-
spec.paths[`${path}/{id}/workflow-history`] = {
|
|
1225
|
-
get: {
|
|
1226
|
-
tags: ["Workflows"],
|
|
1227
|
-
summary: `Get ${labels.singular} workflow history`,
|
|
1228
|
-
parameters: [
|
|
1229
|
-
{
|
|
1230
|
-
name: "id",
|
|
1231
|
-
in: "path",
|
|
1232
|
-
required: true,
|
|
1233
|
-
schema: { type: "string" }
|
|
1234
|
-
},
|
|
1235
|
-
{
|
|
1236
|
-
name: "limit",
|
|
1237
|
-
in: "query",
|
|
1238
|
-
schema: { type: "integer", default: 50, maximum: 100 }
|
|
1239
|
-
}
|
|
1240
|
-
],
|
|
1241
|
-
responses: {
|
|
1242
|
-
200: {
|
|
1243
|
-
description: "Workflow transition history",
|
|
1244
|
-
content: {
|
|
1245
|
-
"application/json": {
|
|
1246
|
-
schema: {
|
|
1247
|
-
type: "object",
|
|
1248
|
-
properties: {
|
|
1249
|
-
docs: {
|
|
1250
|
-
type: "array",
|
|
1251
|
-
items: {
|
|
1252
|
-
$ref: "#/components/schemas/WorkflowHistoryEntry"
|
|
1253
|
-
}
|
|
1254
|
-
},
|
|
1255
|
-
total: { type: "integer" },
|
|
1256
|
-
limit: { type: "integer" },
|
|
1257
|
-
page: { type: "integer" }
|
|
1258
|
-
}
|
|
1259
|
-
}
|
|
1260
|
-
}
|
|
1261
|
-
}
|
|
1262
|
-
},
|
|
1263
|
-
403: { description: "Collection read access denied" }
|
|
1264
|
-
}
|
|
1265
|
-
}
|
|
1266
|
-
};
|
|
1267
|
-
}
|
|
1268
|
-
}
|
|
1269
|
-
for (const global of config.globals) {
|
|
1270
|
-
const slug = global.slug;
|
|
1271
|
-
const path = `/api/globals/${slug}`;
|
|
1272
|
-
spec.paths[path] = {
|
|
1273
|
-
get: {
|
|
1274
|
-
tags: ["Globals"],
|
|
1275
|
-
summary: `Get ${global.label || slug}`,
|
|
1276
|
-
responses: {
|
|
1277
|
-
200: {
|
|
1278
|
-
description: "Success",
|
|
1279
|
-
content: {
|
|
1280
|
-
"application/json": {
|
|
1281
|
-
schema: { $ref: `#/components/schemas/${slug}` }
|
|
1282
|
-
}
|
|
1283
|
-
}
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
},
|
|
1287
|
-
patch: {
|
|
1288
|
-
tags: ["Globals"],
|
|
1289
|
-
summary: `Update ${global.label || slug}`,
|
|
1290
|
-
requestBody: {
|
|
1291
|
-
required: true,
|
|
1292
|
-
content: {
|
|
1293
|
-
"application/json": {
|
|
1294
|
-
schema: { $ref: `#/components/schemas/${slug}` }
|
|
1295
|
-
}
|
|
1296
|
-
}
|
|
1297
|
-
},
|
|
1298
|
-
responses: {
|
|
1299
|
-
200: {
|
|
1300
|
-
description: "Updated",
|
|
1301
|
-
content: {
|
|
1302
|
-
"application/json": {
|
|
1303
|
-
schema: { $ref: `#/components/schemas/${slug}` }
|
|
1304
|
-
}
|
|
1305
|
-
}
|
|
1306
|
-
}
|
|
1307
|
-
}
|
|
1308
|
-
}
|
|
1309
|
-
};
|
|
1310
|
-
spec.paths[`${path}/seed`] = {
|
|
1311
|
-
post: {
|
|
1312
|
-
tags: ["Globals"],
|
|
1313
|
-
summary: `Seed ${global.label || slug}`,
|
|
1314
|
-
responses: { 200: { description: "Seeded global" } }
|
|
1315
|
-
}
|
|
1316
|
-
};
|
|
1317
|
-
}
|
|
1318
|
-
if (config.storage) {
|
|
1319
|
-
spec.paths["/api/media/{filename}"] = {
|
|
1320
|
-
get: {
|
|
1321
|
-
tags: ["Media"],
|
|
1322
|
-
summary: "Serve a stored file",
|
|
1323
|
-
security: [],
|
|
1324
|
-
parameters: [
|
|
1325
|
-
{
|
|
1326
|
-
name: "filename",
|
|
1327
|
-
in: "path",
|
|
1328
|
-
required: true,
|
|
1329
|
-
schema: { type: "string" }
|
|
1330
|
-
}
|
|
1331
|
-
],
|
|
1332
|
-
responses: {
|
|
1333
|
-
200: { description: "Stored file bytes" },
|
|
1334
|
-
404: { description: "File not found" }
|
|
1335
|
-
}
|
|
1336
|
-
}
|
|
1337
|
-
};
|
|
1338
|
-
}
|
|
1339
|
-
return spec;
|
|
1340
|
-
}
|
|
1341
|
-
function collectionToSchema(collection) {
|
|
1342
|
-
const { properties, required } = fieldsToProperties(collection.fields);
|
|
1343
|
-
return {
|
|
1344
|
-
type: "object",
|
|
1345
|
-
properties: {
|
|
1346
|
-
id: { type: "string" },
|
|
1347
|
-
createdAt: { type: "string", format: "date-time" },
|
|
1348
|
-
updatedAt: { type: "string", format: "date-time" },
|
|
1349
|
-
...collection.workflow ? { _workflow: { $ref: "#/components/schemas/WorkflowMetadata" } } : {},
|
|
1350
|
-
...properties
|
|
1351
|
-
},
|
|
1352
|
-
required: ["id", ...required]
|
|
1353
|
-
};
|
|
1354
|
-
}
|
|
1355
|
-
function globalToSchema(global) {
|
|
1356
|
-
const { properties, required } = fieldsToProperties(global.fields);
|
|
1357
|
-
return {
|
|
1358
|
-
type: "object",
|
|
1359
|
-
properties,
|
|
1360
|
-
required
|
|
1361
|
-
};
|
|
1362
|
-
}
|
|
1363
|
-
function fieldsToProperties(fields) {
|
|
1364
|
-
const props = {};
|
|
1365
|
-
const required = [];
|
|
1366
|
-
for (const field of fields) {
|
|
1367
|
-
if (field.type === "row") {
|
|
1368
|
-
const nested = fieldsToProperties(field.fields || []);
|
|
1369
|
-
Object.assign(props, nested.properties);
|
|
1370
|
-
required.push(...nested.required);
|
|
1371
|
-
continue;
|
|
1372
|
-
}
|
|
1373
|
-
if (!field.name)
|
|
1374
|
-
continue;
|
|
1375
|
-
props[field.name] = fieldToSchema(field);
|
|
1376
|
-
if (field.required) {
|
|
1377
|
-
required.push(field.name);
|
|
1378
|
-
}
|
|
1379
|
-
}
|
|
1380
|
-
return { properties: props, required };
|
|
1381
|
-
}
|
|
1382
|
-
function fieldToSchema(field) {
|
|
1383
|
-
let schema = {};
|
|
1384
|
-
switch (field.type) {
|
|
1385
|
-
case "text":
|
|
1386
|
-
case "textarea":
|
|
1387
|
-
case "email":
|
|
1388
|
-
schema = { type: "string" };
|
|
1389
|
-
break;
|
|
1390
|
-
case "url":
|
|
1391
|
-
schema = {
|
|
1392
|
-
oneOf: [
|
|
1393
|
-
{ type: "string" },
|
|
1394
|
-
{ type: "object", additionalProperties: true }
|
|
1395
|
-
]
|
|
1396
|
-
};
|
|
1397
|
-
break;
|
|
1398
|
-
case "icon":
|
|
1399
|
-
schema = { type: "string" };
|
|
1400
|
-
break;
|
|
1401
|
-
case "number":
|
|
1402
|
-
schema = { type: "number" };
|
|
1403
|
-
break;
|
|
1404
|
-
case "boolean":
|
|
1405
|
-
schema = { type: "boolean" };
|
|
1406
|
-
break;
|
|
1407
|
-
case "date":
|
|
1408
|
-
schema = { type: "string", format: "date" };
|
|
1409
|
-
break;
|
|
1410
|
-
case "datetime":
|
|
1411
|
-
schema = { type: "string", format: "date-time" };
|
|
1412
|
-
break;
|
|
1413
|
-
case "time":
|
|
1414
|
-
schema = { type: "string", format: "time" };
|
|
1415
|
-
break;
|
|
1416
|
-
case "select":
|
|
1417
|
-
case "radio":
|
|
1418
|
-
schema = {
|
|
1419
|
-
type: "string",
|
|
1420
|
-
enum: Array.isArray(field.options) ? field.options.map((o) => typeof o === "string" ? o : o.value) : void 0
|
|
1421
|
-
};
|
|
1422
|
-
break;
|
|
1423
|
-
case "multiSelect":
|
|
1424
|
-
schema = {
|
|
1425
|
-
type: "array",
|
|
1426
|
-
items: {
|
|
1427
|
-
type: "string",
|
|
1428
|
-
enum: Array.isArray(field.options) ? field.options.map((o) => typeof o === "string" ? o : o.value) : void 0
|
|
1429
|
-
}
|
|
1430
|
-
};
|
|
1431
|
-
break;
|
|
1432
|
-
case "relationship":
|
|
1433
|
-
case "image": {
|
|
1434
|
-
const valueSchema = {
|
|
1435
|
-
type: "string",
|
|
1436
|
-
description: `ID of a ${field.relationTo} record`
|
|
1437
|
-
};
|
|
1438
|
-
schema = field.hasMany ? { type: "array", items: valueSchema } : valueSchema;
|
|
1439
|
-
break;
|
|
1440
|
-
}
|
|
1441
|
-
case "join":
|
|
1442
|
-
schema = {
|
|
1443
|
-
type: "array",
|
|
1444
|
-
readOnly: true,
|
|
1445
|
-
items: { type: "object", additionalProperties: true }
|
|
1446
|
-
};
|
|
1447
|
-
break;
|
|
1448
|
-
case "object": {
|
|
1449
|
-
const { properties, required } = fieldsToProperties(field.fields || []);
|
|
1450
|
-
schema = { type: "object", properties, required };
|
|
1451
|
-
break;
|
|
1452
|
-
}
|
|
1453
|
-
case "array": {
|
|
1454
|
-
const { properties, required } = fieldsToProperties(field.fields || []);
|
|
1455
|
-
schema = {
|
|
1456
|
-
type: "array",
|
|
1457
|
-
items: { type: "object", properties, required }
|
|
1458
|
-
};
|
|
1459
|
-
break;
|
|
1460
|
-
}
|
|
1461
|
-
case "json":
|
|
1462
|
-
case "richText":
|
|
1463
|
-
schema = { type: "object", additionalProperties: true };
|
|
1464
|
-
break;
|
|
1465
|
-
case "blocks":
|
|
1466
|
-
schema = {
|
|
1467
|
-
type: "array",
|
|
1468
|
-
items: {
|
|
1469
|
-
oneOf: field.blocks?.map((block) => {
|
|
1470
|
-
const { properties, required } = fieldsToProperties(block.fields);
|
|
1471
|
-
return {
|
|
1472
|
-
type: "object",
|
|
1473
|
-
properties: {
|
|
1474
|
-
blockType: { type: "string", enum: [block.slug] },
|
|
1475
|
-
...properties
|
|
1476
|
-
},
|
|
1477
|
-
required: ["blockType", ...required]
|
|
1478
|
-
};
|
|
1479
|
-
})
|
|
1480
|
-
}
|
|
1481
|
-
};
|
|
1482
|
-
break;
|
|
1483
|
-
default:
|
|
1484
|
-
schema = { type: "string" };
|
|
1485
|
-
}
|
|
1486
|
-
if (field.label)
|
|
1487
|
-
schema.description = field.label;
|
|
1488
|
-
return schema;
|
|
1489
|
-
}
|
|
1490
|
-
|
|
1491
|
-
export {
|
|
1492
|
-
WORKFLOW_HISTORY_COLLECTION,
|
|
1493
|
-
LIFECYCLE_EVENTS_COLLECTION,
|
|
1494
|
-
publishingWorkflow,
|
|
1495
|
-
workflowCapabilities,
|
|
1496
|
-
canViewWorkflowDraft,
|
|
1497
|
-
availableWorkflowTransitions,
|
|
1498
|
-
initializeWorkflowDocument,
|
|
1499
|
-
materializeWorkflowDocument,
|
|
1500
|
-
createLifecycleEvent,
|
|
1501
|
-
dispatchLifecycleEvent,
|
|
1502
|
-
dispatchPendingLifecycleEvents,
|
|
1503
|
-
saveWorkflowDraft,
|
|
1504
|
-
createWorkflowDocument,
|
|
1505
|
-
transitionWorkflow,
|
|
1506
|
-
getAdminAuthCollection,
|
|
1507
|
-
getPublicAdminAuthConfig,
|
|
1508
|
-
normalizeConfig,
|
|
1509
|
-
runCollectionHooks,
|
|
1510
|
-
executeFieldBeforeChange,
|
|
1511
|
-
executeFieldAfterRead,
|
|
1512
|
-
generateOpenApi
|
|
1513
|
-
};
|