@pattern-stack/codegen 0.15.1 → 0.15.3
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/CHANGELOG.md +85 -0
- package/dist/chunk-27ETSJ2X.js +84 -0
- package/dist/chunk-27ETSJ2X.js.map +1 -0
- package/dist/chunk-2E224ZSN.js +20 -0
- package/dist/chunk-2E224ZSN.js.map +1 -0
- package/dist/chunk-2FTZLDBP.js +179 -0
- package/dist/chunk-2FTZLDBP.js.map +1 -0
- package/dist/chunk-2N4UG4VD.js +20 -0
- package/dist/chunk-2N4UG4VD.js.map +1 -0
- package/dist/chunk-2TVVBC53.js +92 -0
- package/dist/chunk-2TVVBC53.js.map +1 -0
- package/dist/chunk-2VHZ7EKC.js +37 -0
- package/dist/chunk-2VHZ7EKC.js.map +1 -0
- package/dist/chunk-32BMMV4H.js +109 -0
- package/dist/chunk-32BMMV4H.js.map +1 -0
- package/dist/chunk-32DOFN3T.js +4042 -0
- package/dist/chunk-32DOFN3T.js.map +1 -0
- package/dist/chunk-36U5UGIO.js +107 -0
- package/dist/chunk-36U5UGIO.js.map +1 -0
- package/dist/chunk-3CJFPU6Q.js +14 -0
- package/dist/chunk-3CJFPU6Q.js.map +1 -0
- package/dist/chunk-3NMCDN7L.js +90 -0
- package/dist/chunk-3NMCDN7L.js.map +1 -0
- package/dist/chunk-3SZFUTXE.js +62 -0
- package/dist/chunk-3SZFUTXE.js.map +1 -0
- package/dist/chunk-4DOJBQTP.js +117 -0
- package/dist/chunk-4DOJBQTP.js.map +1 -0
- package/dist/chunk-4H3PETLM.js +290 -0
- package/dist/chunk-4H3PETLM.js.map +1 -0
- package/dist/chunk-4JLJYWJC.js +308 -0
- package/dist/chunk-4JLJYWJC.js.map +1 -0
- package/dist/chunk-4KNXX6TI.js +29 -0
- package/dist/chunk-4KNXX6TI.js.map +1 -0
- package/dist/chunk-4LH67P4U.js +17 -0
- package/dist/chunk-4LH67P4U.js.map +1 -0
- package/dist/chunk-4MF3HKJA.js +94 -0
- package/dist/chunk-4MF3HKJA.js.map +1 -0
- package/dist/chunk-4MVGAMUA.js +40 -0
- package/dist/chunk-4MVGAMUA.js.map +1 -0
- package/dist/chunk-4RFHUZXU.js +635 -0
- package/dist/chunk-4RFHUZXU.js.map +1 -0
- package/dist/chunk-5A432NZJ.js +7 -0
- package/dist/chunk-5A432NZJ.js.map +1 -0
- package/dist/chunk-5Y7W3XR6.js +356 -0
- package/dist/chunk-5Y7W3XR6.js.map +1 -0
- package/dist/chunk-6DWFJNIK.js +15 -0
- package/dist/chunk-6DWFJNIK.js.map +1 -0
- package/dist/chunk-6I7ULIN6.js +15 -0
- package/dist/chunk-6I7ULIN6.js.map +1 -0
- package/dist/chunk-6XY6ZMMD.js +25 -0
- package/dist/chunk-6XY6ZMMD.js.map +1 -0
- package/dist/chunk-7B3RYX45.js +63 -0
- package/dist/chunk-7B3RYX45.js.map +1 -0
- package/dist/chunk-7C3FOSDI.js +1 -0
- package/dist/chunk-7C3FOSDI.js.map +1 -0
- package/dist/chunk-7KOW6PU6.js +59 -0
- package/dist/chunk-7KOW6PU6.js.map +1 -0
- package/dist/chunk-7RELQJIN.js +22 -0
- package/dist/chunk-7RELQJIN.js.map +1 -0
- package/dist/chunk-7YGORYZD.js +112 -0
- package/dist/chunk-7YGORYZD.js.map +1 -0
- package/dist/chunk-AHV4GDYM.js +63 -0
- package/dist/chunk-AHV4GDYM.js.map +1 -0
- package/dist/chunk-AQFQ4BYM.js +81 -0
- package/dist/chunk-AQFQ4BYM.js.map +1 -0
- package/dist/chunk-AS3NAZB6.js +14 -0
- package/dist/chunk-AS3NAZB6.js.map +1 -0
- package/dist/chunk-BGULBWKJ.js +88 -0
- package/dist/chunk-BGULBWKJ.js.map +1 -0
- package/dist/chunk-BIO6F7YI.js +17 -0
- package/dist/chunk-BIO6F7YI.js.map +1 -0
- package/dist/chunk-BOPZWRJK.js +36 -0
- package/dist/chunk-BOPZWRJK.js.map +1 -0
- package/dist/chunk-BPARRK6F.js +14 -0
- package/dist/chunk-BPARRK6F.js.map +1 -0
- package/dist/chunk-CO6LUM72.js +59 -0
- package/dist/chunk-CO6LUM72.js.map +1 -0
- package/dist/chunk-DCCZB4UC.js +100 -0
- package/dist/chunk-DCCZB4UC.js.map +1 -0
- package/dist/chunk-DV4RV2DC.js +59 -0
- package/dist/chunk-DV4RV2DC.js.map +1 -0
- package/dist/chunk-EDKJU5BO.js +11 -0
- package/dist/chunk-EDKJU5BO.js.map +1 -0
- package/dist/chunk-EO2QPOKH.js +116 -0
- package/dist/chunk-EO2QPOKH.js.map +1 -0
- package/dist/chunk-EOLLMEAH.js +155 -0
- package/dist/chunk-EOLLMEAH.js.map +1 -0
- package/dist/chunk-EWYCWP4H.js +14 -0
- package/dist/chunk-EWYCWP4H.js.map +1 -0
- package/dist/chunk-EXVDJMIY.js +33 -0
- package/dist/chunk-EXVDJMIY.js.map +1 -0
- package/dist/chunk-FASRXRX5.js +19 -0
- package/dist/chunk-FASRXRX5.js.map +1 -0
- package/dist/chunk-FBGHYQIZ.js +201 -0
- package/dist/chunk-FBGHYQIZ.js.map +1 -0
- package/dist/chunk-FI34KYZ5.js +1 -0
- package/dist/chunk-FI34KYZ5.js.map +1 -0
- package/dist/chunk-FN2PYDPP.js +1 -0
- package/dist/chunk-FN2PYDPP.js.map +1 -0
- package/dist/chunk-GCYKMF22.js +81 -0
- package/dist/chunk-GCYKMF22.js.map +1 -0
- package/dist/chunk-GM3RMJIJ.js +92 -0
- package/dist/chunk-GM3RMJIJ.js.map +1 -0
- package/dist/chunk-GYGNEQSC.js +9 -0
- package/dist/chunk-GYGNEQSC.js.map +1 -0
- package/dist/chunk-H5NH7KPE.js +21 -0
- package/dist/chunk-H5NH7KPE.js.map +1 -0
- package/dist/chunk-HNWZFNKP.js +168 -0
- package/dist/chunk-HNWZFNKP.js.map +1 -0
- package/dist/chunk-HUH73XGI.js +1 -0
- package/dist/chunk-HUH73XGI.js.map +1 -0
- package/dist/chunk-I6MVCB5A.js +39 -0
- package/dist/chunk-I6MVCB5A.js.map +1 -0
- package/dist/chunk-IBGER4YK.js +12 -0
- package/dist/chunk-IBGER4YK.js.map +1 -0
- package/dist/chunk-IF5I3DAA.js +92 -0
- package/dist/chunk-IF5I3DAA.js.map +1 -0
- package/dist/chunk-IP4OO26U.js +54 -0
- package/dist/chunk-IP4OO26U.js.map +1 -0
- package/dist/chunk-IWAOY6KC.js +1 -0
- package/dist/chunk-IWAOY6KC.js.map +1 -0
- package/dist/chunk-IYNSRIGR.js +122 -0
- package/dist/chunk-IYNSRIGR.js.map +1 -0
- package/dist/chunk-J37YWU7Y.js +19 -0
- package/dist/chunk-J37YWU7Y.js.map +1 -0
- package/dist/chunk-J6KZS54B.js +269 -0
- package/dist/chunk-J6KZS54B.js.map +1 -0
- package/dist/chunk-J6MN42LG.js +19 -0
- package/dist/chunk-J6MN42LG.js.map +1 -0
- package/dist/chunk-J7JMVS2B.js +53 -0
- package/dist/chunk-J7JMVS2B.js.map +1 -0
- package/dist/chunk-JRQO2IOF.js +65 -0
- package/dist/chunk-JRQO2IOF.js.map +1 -0
- package/dist/chunk-JWNHNUYL.js +96 -0
- package/dist/chunk-JWNHNUYL.js.map +1 -0
- package/dist/chunk-K2I6XIK5.js +122 -0
- package/dist/chunk-K2I6XIK5.js.map +1 -0
- package/dist/chunk-KVOWSC5S.js +1 -0
- package/dist/chunk-KVOWSC5S.js.map +1 -0
- package/dist/chunk-KYR3B3OW.js +79 -0
- package/dist/chunk-KYR3B3OW.js.map +1 -0
- package/dist/chunk-L3LZWWSX.js +61 -0
- package/dist/chunk-L3LZWWSX.js.map +1 -0
- package/dist/chunk-L4SDDEEU.js +1 -0
- package/dist/chunk-L4SDDEEU.js.map +1 -0
- package/dist/chunk-L6FTY45T.js +13 -0
- package/dist/chunk-L6FTY45T.js.map +1 -0
- package/dist/chunk-L7BNNRGI.js +134 -0
- package/dist/chunk-L7BNNRGI.js.map +1 -0
- package/dist/chunk-LG57S2SC.js +150 -0
- package/dist/chunk-LG57S2SC.js.map +1 -0
- package/dist/chunk-M6QLSLPO.js +97 -0
- package/dist/chunk-M6QLSLPO.js.map +1 -0
- package/dist/chunk-MZ6GV4YF.js +21 -0
- package/dist/chunk-MZ6GV4YF.js.map +1 -0
- package/dist/chunk-N5OTOWTP.js +55 -0
- package/dist/chunk-N5OTOWTP.js.map +1 -0
- package/dist/chunk-NN7XZEGF.js +14 -0
- package/dist/chunk-NN7XZEGF.js.map +1 -0
- package/dist/chunk-NPFPZ2HO.js +13 -0
- package/dist/chunk-NPFPZ2HO.js.map +1 -0
- package/dist/chunk-NXXDZ6ZF.js +42 -0
- package/dist/chunk-NXXDZ6ZF.js.map +1 -0
- package/dist/chunk-NYBCQZC7.js +11 -0
- package/dist/chunk-NYBCQZC7.js.map +1 -0
- package/dist/chunk-O37C3YE6.js +111 -0
- package/dist/chunk-O37C3YE6.js.map +1 -0
- package/dist/chunk-OFRRBC7M.js +78 -0
- package/dist/chunk-OFRRBC7M.js.map +1 -0
- package/dist/chunk-OGIZXGPY.js +222 -0
- package/dist/chunk-OGIZXGPY.js.map +1 -0
- package/dist/chunk-OKXZ63IA.js +168 -0
- package/dist/chunk-OKXZ63IA.js.map +1 -0
- package/dist/chunk-OSQRXVG2.js +58 -0
- package/dist/chunk-OSQRXVG2.js.map +1 -0
- package/dist/chunk-OTDN3OUQ.js +215 -0
- package/dist/chunk-OTDN3OUQ.js.map +1 -0
- package/dist/chunk-PNZSGAB2.js +114 -0
- package/dist/chunk-PNZSGAB2.js.map +1 -0
- package/dist/chunk-PRWIX6UW.js +21 -0
- package/dist/chunk-PRWIX6UW.js.map +1 -0
- package/dist/chunk-PSXUNOVU.js +7 -0
- package/dist/chunk-PSXUNOVU.js.map +1 -0
- package/dist/chunk-QLTJSCE6.js +44 -0
- package/dist/chunk-QLTJSCE6.js.map +1 -0
- package/dist/chunk-RC23QROE.js +447 -0
- package/dist/chunk-RC23QROE.js.map +1 -0
- package/dist/chunk-RDVTWIYY.js +212 -0
- package/dist/chunk-RDVTWIYY.js.map +1 -0
- package/dist/chunk-RFH7N6EP.js +36 -0
- package/dist/chunk-RFH7N6EP.js.map +1 -0
- package/dist/chunk-RHVN6NA7.js +134 -0
- package/dist/chunk-RHVN6NA7.js.map +1 -0
- package/dist/chunk-S7C6TIIF.js +21 -0
- package/dist/chunk-S7C6TIIF.js.map +1 -0
- package/dist/chunk-SNQ3TOWP.js +20 -0
- package/dist/chunk-SNQ3TOWP.js.map +1 -0
- package/dist/chunk-SOVM2VEK.js +14 -0
- package/dist/chunk-SOVM2VEK.js.map +1 -0
- package/dist/chunk-SQDOBLBP.js +13 -0
- package/dist/chunk-SQDOBLBP.js.map +1 -0
- package/dist/chunk-SR7F3TJY.js +130 -0
- package/dist/chunk-SR7F3TJY.js.map +1 -0
- package/dist/chunk-SZVPIHWE.js +129 -0
- package/dist/chunk-SZVPIHWE.js.map +1 -0
- package/dist/chunk-T4BIIU5E.js +89 -0
- package/dist/chunk-T4BIIU5E.js.map +1 -0
- package/dist/chunk-T6SCOJF4.js +92 -0
- package/dist/chunk-T6SCOJF4.js.map +1 -0
- package/dist/chunk-TNXH7BJS.js +48 -0
- package/dist/chunk-TNXH7BJS.js.map +1 -0
- package/dist/chunk-U64T4YZE.js +9 -0
- package/dist/chunk-U64T4YZE.js.map +1 -0
- package/dist/chunk-UQ5EHOH2.js +39 -0
- package/dist/chunk-UQ5EHOH2.js.map +1 -0
- package/dist/chunk-UTN4GBPQ.js +1 -0
- package/dist/chunk-UTN4GBPQ.js.map +1 -0
- package/dist/chunk-V4AF6DI4.js +16 -0
- package/dist/chunk-V4AF6DI4.js.map +1 -0
- package/dist/chunk-W72PRNJY.js +126 -0
- package/dist/chunk-W72PRNJY.js.map +1 -0
- package/dist/chunk-WL67FZGF.js +21 -0
- package/dist/chunk-WL67FZGF.js.map +1 -0
- package/dist/chunk-WWGYCIJX.js +29 -0
- package/dist/chunk-WWGYCIJX.js.map +1 -0
- package/dist/chunk-X2GMTYPA.js +50 -0
- package/dist/chunk-X2GMTYPA.js.map +1 -0
- package/dist/chunk-XCEI7NUH.js +41 -0
- package/dist/chunk-XCEI7NUH.js.map +1 -0
- package/dist/chunk-Y7GDG744.js +88 -0
- package/dist/chunk-Y7GDG744.js.map +1 -0
- package/dist/chunk-Y7RRSEOC.js +9 -0
- package/dist/chunk-Y7RRSEOC.js.map +1 -0
- package/dist/chunk-YLPAPPLW.js +75 -0
- package/dist/chunk-YLPAPPLW.js.map +1 -0
- package/dist/chunk-YPWODKD5.js +184 -0
- package/dist/chunk-YPWODKD5.js.map +1 -0
- package/dist/chunk-YSLTTQLC.js +25 -0
- package/dist/chunk-YSLTTQLC.js.map +1 -0
- package/dist/chunk-YTN6BKWA.js +121 -0
- package/dist/chunk-YTN6BKWA.js.map +1 -0
- package/dist/chunk-Z7PQCAVK.js +200 -0
- package/dist/chunk-Z7PQCAVK.js.map +1 -0
- package/dist/chunk-ZUKFQL6E.js +47 -0
- package/dist/chunk-ZUKFQL6E.js.map +1 -0
- package/dist/chunk-ZUMULSEQ.js +1 -0
- package/dist/chunk-ZUMULSEQ.js.map +1 -0
- package/dist/runtime/analytics/index.js +8 -41
- package/dist/runtime/analytics/index.js.map +1 -1
- package/dist/runtime/analytics/types.js +8 -41
- package/dist/runtime/analytics/types.js.map +1 -1
- package/dist/runtime/base-classes/activity-entity-repository.js +6 -312
- package/dist/runtime/base-classes/activity-entity-repository.js.map +1 -1
- package/dist/runtime/base-classes/activity-entity-service.js +6 -212
- package/dist/runtime/base-classes/activity-entity-service.js.map +1 -1
- package/dist/runtime/base-classes/base-read-use-cases.js +5 -27
- package/dist/runtime/base-classes/base-read-use-cases.js.map +1 -1
- package/dist/runtime/base-classes/base-repository.js +5 -277
- package/dist/runtime/base-classes/base-repository.js.map +1 -1
- package/dist/runtime/base-classes/base-service.js +5 -184
- package/dist/runtime/base-classes/base-service.js.map +1 -1
- package/dist/runtime/base-classes/index.js +59 -1076
- package/dist/runtime/base-classes/index.js.map +1 -1
- package/dist/runtime/base-classes/integrated-entity-repository.js +6 -486
- package/dist/runtime/base-classes/integrated-entity-repository.js.map +1 -1
- package/dist/runtime/base-classes/integrated-entity-service.js +6 -213
- package/dist/runtime/base-classes/integrated-entity-service.js.map +1 -1
- package/dist/runtime/base-classes/junction-integration-repository.js +8 -448
- package/dist/runtime/base-classes/junction-integration-repository.js.map +1 -1
- package/dist/runtime/base-classes/knowledge-entity-repository.js +6 -283
- package/dist/runtime/base-classes/knowledge-entity-repository.js.map +1 -1
- package/dist/runtime/base-classes/knowledge-entity-service.js +6 -190
- package/dist/runtime/base-classes/knowledge-entity-service.js.map +1 -1
- package/dist/runtime/base-classes/lifecycle-events.js +8 -70
- package/dist/runtime/base-classes/lifecycle-events.js.map +1 -1
- package/dist/runtime/base-classes/metadata-entity-repository.js +6 -330
- package/dist/runtime/base-classes/metadata-entity-repository.js.map +1 -1
- package/dist/runtime/base-classes/metadata-entity-service.js +6 -212
- package/dist/runtime/base-classes/metadata-entity-service.js.map +1 -1
- package/dist/runtime/base-classes/tenant-context.js +10 -36
- package/dist/runtime/base-classes/tenant-context.js.map +1 -1
- package/dist/runtime/base-classes/with-analytics.js +4 -7
- package/dist/runtime/base-classes/with-analytics.js.map +1 -1
- package/dist/runtime/constants/tokens.js +5 -3
- package/dist/runtime/constants/tokens.js.map +1 -1
- package/dist/runtime/eav-helpers.js +2 -0
- package/dist/runtime/eav-helpers.js.map +1 -1
- package/dist/runtime/pipes/zod-validation.pipe.js +3 -10
- package/dist/runtime/pipes/zod-validation.pipe.js.map +1 -1
- package/dist/runtime/shared/openapi/error-response.dto.js +5 -8
- package/dist/runtime/shared/openapi/error-response.dto.js.map +1 -1
- package/dist/runtime/shared/openapi/errors.js +5 -19
- package/dist/runtime/shared/openapi/errors.js.map +1 -1
- package/dist/runtime/shared/openapi/index.js +15 -106
- package/dist/runtime/shared/openapi/index.js.map +1 -1
- package/dist/runtime/shared/openapi/registry.js +6 -103
- package/dist/runtime/shared/openapi/registry.js.map +1 -1
- package/dist/runtime/shared/openapi/registry.tokens.js +4 -2
- package/dist/runtime/shared/openapi/registry.tokens.js.map +1 -1
- package/dist/runtime/subsystems/analytics/analytics.module.js +8 -117
- package/dist/runtime/subsystems/analytics/analytics.module.js.map +1 -1
- package/dist/runtime/subsystems/analytics/analytics.tokens.js +7 -8
- package/dist/runtime/subsystems/analytics/analytics.tokens.js.map +1 -1
- package/dist/runtime/subsystems/analytics/cube-backend.js +6 -71
- package/dist/runtime/subsystems/analytics/cube-backend.js.map +1 -1
- package/dist/runtime/subsystems/analytics/index.js +16 -117
- package/dist/runtime/subsystems/analytics/index.js.map +1 -1
- package/dist/runtime/subsystems/analytics/noop-backend.js +4 -21
- package/dist/runtime/subsystems/analytics/noop-backend.js.map +1 -1
- package/dist/runtime/subsystems/auth/auth-oauth-state.schema.js +4 -8
- package/dist/runtime/subsystems/auth/auth-oauth-state.schema.js.map +1 -1
- package/dist/runtime/subsystems/auth/auth.module.js +12 -359
- package/dist/runtime/subsystems/auth/auth.module.js.map +1 -1
- package/dist/runtime/subsystems/auth/auth.tokens.js +12 -13
- package/dist/runtime/subsystems/auth/auth.tokens.js.map +1 -1
- package/dist/runtime/subsystems/auth/backends/encryption-key/env.js +4 -49
- package/dist/runtime/subsystems/auth/backends/encryption-key/env.js.map +1 -1
- package/dist/runtime/subsystems/auth/backends/state-store.drizzle-backend.js +6 -64
- package/dist/runtime/subsystems/auth/backends/state-store.drizzle-backend.js.map +1 -1
- package/dist/runtime/subsystems/auth/backends/state-store.memory-backend.js +5 -47
- package/dist/runtime/subsystems/auth/backends/state-store.memory-backend.js.map +1 -1
- package/dist/runtime/subsystems/auth/controllers/auth.controller.js +5 -139
- package/dist/runtime/subsystems/auth/controllers/auth.controller.js.map +1 -1
- package/dist/runtime/subsystems/auth/index.js +53 -542
- package/dist/runtime/subsystems/auth/index.js.map +1 -1
- package/dist/runtime/subsystems/auth/middleware/requester-context.js +9 -65
- package/dist/runtime/subsystems/auth/middleware/requester-context.js.map +1 -1
- package/dist/runtime/subsystems/auth/protocols/oauth-state-store.js +4 -9
- package/dist/runtime/subsystems/auth/protocols/oauth-state-store.js.map +1 -1
- package/dist/runtime/subsystems/auth/runtime/connection-broken.error.js +4 -15
- package/dist/runtime/subsystems/auth/runtime/connection-broken.error.js.map +1 -1
- package/dist/runtime/subsystems/auth/runtime/oauth2-refresh.strategy.js +5 -104
- package/dist/runtime/subsystems/auth/runtime/oauth2-refresh.strategy.js.map +1 -1
- package/dist/runtime/subsystems/auth/runtime/session-expired.error.js +5 -16
- package/dist/runtime/subsystems/auth/runtime/session-expired.error.js.map +1 -1
- package/dist/runtime/subsystems/auth/runtime/with-auth-retry.js +5 -29
- package/dist/runtime/subsystems/auth/runtime/with-auth-retry.js.map +1 -1
- package/dist/runtime/subsystems/bridge/assert-tenant-id.js +5 -18
- package/dist/runtime/subsystems/bridge/assert-tenant-id.js.map +1 -1
- package/dist/runtime/subsystems/bridge/bridge-delivery-handler.js +12 -184
- package/dist/runtime/subsystems/bridge/bridge-delivery-handler.js.map +1 -1
- package/dist/runtime/subsystems/bridge/bridge-delivery.drizzle-backend.js +10 -448
- package/dist/runtime/subsystems/bridge/bridge-delivery.drizzle-backend.js.map +1 -1
- package/dist/runtime/subsystems/bridge/bridge-delivery.memory-backend.js +5 -126
- package/dist/runtime/subsystems/bridge/bridge-delivery.memory-backend.js.map +1 -1
- package/dist/runtime/subsystems/bridge/bridge-delivery.schema.js +6 -308
- package/dist/runtime/subsystems/bridge/bridge-delivery.schema.js.map +1 -1
- package/dist/runtime/subsystems/bridge/bridge-errors.js +6 -35
- package/dist/runtime/subsystems/bridge/bridge-errors.js.map +1 -1
- package/dist/runtime/subsystems/bridge/bridge-outbox-drain-hook.js +14 -606
- package/dist/runtime/subsystems/bridge/bridge-outbox-drain-hook.js.map +1 -1
- package/dist/runtime/subsystems/bridge/bridge.module.js +35 -3476
- package/dist/runtime/subsystems/bridge/bridge.module.js.map +1 -1
- package/dist/runtime/subsystems/bridge/bridge.tokens.js +9 -7
- package/dist/runtime/subsystems/bridge/bridge.tokens.js.map +1 -1
- package/dist/runtime/subsystems/bridge/event-flow.service.js +11 -137
- package/dist/runtime/subsystems/bridge/event-flow.service.js.map +1 -1
- package/dist/runtime/subsystems/bridge/generated/registry.js +4 -2
- package/dist/runtime/subsystems/bridge/generated/registry.js.map +1 -1
- package/dist/runtime/subsystems/bridge/index.js +60 -3470
- package/dist/runtime/subsystems/bridge/index.js.map +1 -1
- package/dist/runtime/subsystems/bridge/reserved-pools.js +4 -6
- package/dist/runtime/subsystems/bridge/reserved-pools.js.map +1 -1
- package/dist/runtime/subsystems/cache/cache.drizzle-backend.js +10 -133
- package/dist/runtime/subsystems/cache/cache.drizzle-backend.js.map +1 -1
- package/dist/runtime/subsystems/cache/cache.memory-backend.js +6 -101
- package/dist/runtime/subsystems/cache/cache.memory-backend.js.map +1 -1
- package/dist/runtime/subsystems/cache/cache.module.js +10 -278
- package/dist/runtime/subsystems/cache/cache.module.js.map +1 -1
- package/dist/runtime/subsystems/cache/cache.schema.js +4 -14
- package/dist/runtime/subsystems/cache/cache.schema.js.map +1 -1
- package/dist/runtime/subsystems/cache/cache.tokens.js +6 -7
- package/dist/runtime/subsystems/cache/cache.tokens.js.map +1 -1
- package/dist/runtime/subsystems/cache/index.js +20 -278
- package/dist/runtime/subsystems/cache/index.js.map +1 -1
- package/dist/runtime/subsystems/events/domain-events.schema.js +3 -72
- package/dist/runtime/subsystems/events/domain-events.schema.js.map +1 -1
- package/dist/runtime/subsystems/events/event-bus.drizzle-backend.js +9 -413
- package/dist/runtime/subsystems/events/event-bus.drizzle-backend.js.map +1 -1
- package/dist/runtime/subsystems/events/event-bus.memory-backend.js +7 -235
- package/dist/runtime/subsystems/events/event-bus.memory-backend.js.map +1 -1
- package/dist/runtime/subsystems/events/event-bus.redis-backend.js +8 -20
- package/dist/runtime/subsystems/events/event-bus.redis-backend.js.map +1 -1
- package/dist/runtime/subsystems/events/event-keyset-cursor.js +8 -30
- package/dist/runtime/subsystems/events/event-keyset-cursor.js.map +1 -1
- package/dist/runtime/subsystems/events/event-read.protocol.js +2 -0
- package/dist/runtime/subsystems/events/event-read.protocol.js.map +1 -1
- package/dist/runtime/subsystems/events/events-errors.js +4 -11
- package/dist/runtime/subsystems/events/events-errors.js.map +1 -1
- package/dist/runtime/subsystems/events/events.module.js +15 -949
- package/dist/runtime/subsystems/events/events.module.js.map +1 -1
- package/dist/runtime/subsystems/events/events.tokens.js +10 -11
- package/dist/runtime/subsystems/events/events.tokens.js.map +1 -1
- package/dist/runtime/subsystems/events/generated/bus.js +9 -240
- package/dist/runtime/subsystems/events/generated/bus.js.map +1 -1
- package/dist/runtime/subsystems/events/generated/index.js +23 -240
- package/dist/runtime/subsystems/events/generated/index.js.map +1 -1
- package/dist/runtime/subsystems/events/generated/registry.js +5 -82
- package/dist/runtime/subsystems/events/generated/registry.js.map +1 -1
- package/dist/runtime/subsystems/events/generated/schemas.js +12 -52
- package/dist/runtime/subsystems/events/generated/schemas.js.map +1 -1
- package/dist/runtime/subsystems/events/generated/types.js +1 -0
- package/dist/runtime/subsystems/events/index.js +32 -949
- package/dist/runtime/subsystems/events/index.js.map +1 -1
- package/dist/runtime/subsystems/index.d.ts +5 -1
- package/dist/runtime/subsystems/index.js +182 -5912
- package/dist/runtime/subsystems/index.js.map +1 -1
- package/dist/runtime/subsystems/integration/build-change-source.js +6 -178
- package/dist/runtime/subsystems/integration/build-change-source.js.map +1 -1
- package/dist/runtime/subsystems/integration/deep-equal.differ.js +4 -109
- package/dist/runtime/subsystems/integration/deep-equal.differ.js.map +1 -1
- package/dist/runtime/subsystems/integration/detection-config.schema.js +11 -78
- package/dist/runtime/subsystems/integration/detection-config.schema.js.map +1 -1
- package/dist/runtime/subsystems/integration/entity-change-source-registry.memory.js +5 -30
- package/dist/runtime/subsystems/integration/entity-change-source-registry.memory.js.map +1 -1
- package/dist/runtime/subsystems/integration/entity-change-source-registry.protocol.js +4 -9
- package/dist/runtime/subsystems/integration/entity-change-source-registry.protocol.js.map +1 -1
- package/dist/runtime/subsystems/integration/execute-integration.use-case.js +6 -239
- package/dist/runtime/subsystems/integration/execute-integration.use-case.js.map +1 -1
- package/dist/runtime/subsystems/integration/incremental-read.js +5 -144
- package/dist/runtime/subsystems/integration/incremental-read.js.map +1 -1
- package/dist/runtime/subsystems/integration/index.js +83 -1352
- package/dist/runtime/subsystems/integration/index.js.map +1 -1
- package/dist/runtime/subsystems/integration/integration-audit.schema.js +10 -155
- package/dist/runtime/subsystems/integration/integration-audit.schema.js.map +1 -1
- package/dist/runtime/subsystems/integration/integration-cursor-store.drizzle-backend.js +7 -270
- package/dist/runtime/subsystems/integration/integration-cursor-store.drizzle-backend.js.map +1 -1
- package/dist/runtime/subsystems/integration/integration-cursor-store.memory-backend.js +4 -65
- package/dist/runtime/subsystems/integration/integration-cursor-store.memory-backend.js.map +1 -1
- package/dist/runtime/subsystems/integration/integration-errors.js +5 -15
- package/dist/runtime/subsystems/integration/integration-errors.js.map +1 -1
- package/dist/runtime/subsystems/integration/integration-field-diff.protocol.js +5 -7
- package/dist/runtime/subsystems/integration/integration-field-diff.protocol.js.map +1 -1
- package/dist/runtime/subsystems/integration/integration-run-recorder.drizzle-backend.js +8 -303
- package/dist/runtime/subsystems/integration/integration-run-recorder.drizzle-backend.js.map +1 -1
- package/dist/runtime/subsystems/integration/integration-run-recorder.memory-backend.js +5 -125
- package/dist/runtime/subsystems/integration/integration-run-recorder.memory-backend.js.map +1 -1
- package/dist/runtime/subsystems/integration/integration.module.js +13 -700
- package/dist/runtime/subsystems/integration/integration.module.js.map +1 -1
- package/dist/runtime/subsystems/integration/integration.tokens.js +11 -9
- package/dist/runtime/subsystems/integration/integration.tokens.js.map +1 -1
- package/dist/runtime/subsystems/integration/loopback.middleware.js +4 -16
- package/dist/runtime/subsystems/integration/loopback.middleware.js.map +1 -1
- package/dist/runtime/subsystems/integration/poll-change-source.d.ts +1 -1
- package/dist/runtime/subsystems/integration/poll-change-source.js +4 -89
- package/dist/runtime/subsystems/integration/poll-change-source.js.map +1 -1
- package/dist/runtime/subsystems/integration/webhook-change-source.d.ts +4 -3
- package/dist/runtime/subsystems/integration/webhook-change-source.js +4 -70
- package/dist/runtime/subsystems/integration/webhook-change-source.js.map +1 -1
- package/dist/runtime/subsystems/jobs/bullmq.config.js +9 -140
- package/dist/runtime/subsystems/jobs/bullmq.config.js.map +1 -1
- package/dist/runtime/subsystems/jobs/index.js +88 -2691
- package/dist/runtime/subsystems/jobs/index.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-handler.base.js +10 -49
- package/dist/runtime/subsystems/jobs/job-handler.base.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-orchestration.schema.js +13 -152
- package/dist/runtime/subsystems/jobs/job-orchestration.schema.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-orchestrator.bullmq-backend.js +36 -699
- package/dist/runtime/subsystems/jobs/job-orchestrator.bullmq-backend.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-orchestrator.drizzle-backend.js +10 -564
- package/dist/runtime/subsystems/jobs/job-orchestrator.drizzle-backend.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-orchestrator.memory-backend.js +10 -824
- package/dist/runtime/subsystems/jobs/job-orchestrator.memory-backend.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-run-keyset-cursor.js +9 -51
- package/dist/runtime/subsystems/jobs/job-run-keyset-cursor.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-run-service.drizzle-backend.js +9 -416
- package/dist/runtime/subsystems/jobs/job-run-service.drizzle-backend.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-run-service.memory-backend.js +9 -290
- package/dist/runtime/subsystems/jobs/job-run-service.memory-backend.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-step-service.drizzle-backend.js +5 -213
- package/dist/runtime/subsystems/jobs/job-step-service.drizzle-backend.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-step-service.memory-backend.js +5 -131
- package/dist/runtime/subsystems/jobs/job-step-service.memory-backend.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-worker.bullmq-backend.js +9 -175
- package/dist/runtime/subsystems/jobs/job-worker.bullmq-backend.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-worker.js +14 -613
- package/dist/runtime/subsystems/jobs/job-worker.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-worker.module.js +23 -2647
- package/dist/runtime/subsystems/jobs/job-worker.module.js.map +1 -1
- package/dist/runtime/subsystems/jobs/jobs-domain.module.js +19 -1897
- package/dist/runtime/subsystems/jobs/jobs-domain.module.js.map +1 -1
- package/dist/runtime/subsystems/jobs/jobs-domain.tokens.js +8 -9
- package/dist/runtime/subsystems/jobs/jobs-domain.tokens.js.map +1 -1
- package/dist/runtime/subsystems/jobs/jobs-errors.js +10 -78
- package/dist/runtime/subsystems/jobs/jobs-errors.js.map +1 -1
- package/dist/runtime/subsystems/jobs/memory-job-store.js +4 -15
- package/dist/runtime/subsystems/jobs/memory-job-store.js.map +1 -1
- package/dist/runtime/subsystems/jobs/pool-config.loader.js +9 -124
- package/dist/runtime/subsystems/jobs/pool-config.loader.js.map +1 -1
- package/dist/runtime/subsystems/observability/index.js +21 -310
- package/dist/runtime/subsystems/observability/index.js.map +1 -1
- package/dist/runtime/subsystems/observability/observability-errors.js +4 -9
- package/dist/runtime/subsystems/observability/observability-errors.js.map +1 -1
- package/dist/runtime/subsystems/observability/observability.module.js +11 -300
- package/dist/runtime/subsystems/observability/observability.module.js.map +1 -1
- package/dist/runtime/subsystems/observability/observability.service.js +9 -197
- package/dist/runtime/subsystems/observability/observability.service.js.map +1 -1
- package/dist/runtime/subsystems/observability/observability.tokens.js +5 -3
- package/dist/runtime/subsystems/observability/observability.tokens.js.map +1 -1
- package/dist/runtime/subsystems/observability/reporters/bridge-metrics.reporter.js +4 -84
- package/dist/runtime/subsystems/observability/reporters/bridge-metrics.reporter.js.map +1 -1
- package/dist/runtime/subsystems/observability/reporters/index.js +5 -84
- package/dist/runtime/subsystems/observability/reporters/index.js.map +1 -1
- package/dist/runtime/subsystems/storage/index.js +15 -200
- package/dist/runtime/subsystems/storage/index.js.map +1 -1
- package/dist/runtime/subsystems/storage/storage.local-backend.js +4 -103
- package/dist/runtime/subsystems/storage/storage.local-backend.js.map +1 -1
- package/dist/runtime/subsystems/storage/storage.memory-backend.js +5 -68
- package/dist/runtime/subsystems/storage/storage.memory-backend.js.map +1 -1
- package/dist/runtime/subsystems/storage/storage.module.js +8 -200
- package/dist/runtime/subsystems/storage/storage.module.js.map +1 -1
- package/dist/runtime/subsystems/storage/storage.tokens.js +5 -6
- package/dist/runtime/subsystems/storage/storage.tokens.js.map +1 -1
- package/dist/runtime/subsystems/storage/storage.utils.js +4 -14
- package/dist/runtime/subsystems/storage/storage.utils.js.map +1 -1
- package/dist/runtime/subsystems/token-key.js +5 -3
- package/dist/runtime/subsystems/token-key.js.map +1 -1
- package/dist/src/cli/index.js +637 -5454
- package/dist/src/cli/index.js.map +1 -1
- package/dist/src/index.js +68 -4170
- package/dist/src/index.js.map +1 -1
- package/package.json +1 -1
- package/runtime/subsystems/bridge/bridge-outbox-drain-hook.ts +44 -21
- package/runtime/subsystems/index.ts +27 -0
- package/runtime/subsystems/integration/poll-change-source.ts +10 -7
- package/runtime/subsystems/integration/webhook-change-source.ts +12 -8
- package/runtime/subsystems/jobs/job-worker.ts +17 -11
|
@@ -1,696 +1,33 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
4
|
-
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
5
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
6
|
-
if (decorator = decorators[i])
|
|
7
|
-
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
8
|
-
if (kind && result) __defProp(target, key, result);
|
|
9
|
-
return result;
|
|
10
|
-
};
|
|
11
|
-
var __decorateParam = (index2, decorator) => (target, key) => decorator(target, key, index2);
|
|
12
|
-
|
|
13
|
-
// runtime/subsystems/jobs/job-orchestrator.bullmq-backend.ts
|
|
14
|
-
import { createHash } from "crypto";
|
|
15
|
-
import { Inject as Inject2, Injectable as Injectable2, Logger as Logger2, Optional } from "@nestjs/common";
|
|
16
|
-
import { eq as eq2 } from "drizzle-orm";
|
|
17
|
-
|
|
18
|
-
// runtime/constants/tokens.ts
|
|
19
|
-
var DRIZZLE = "DRIZZLE";
|
|
20
|
-
|
|
21
|
-
// runtime/subsystems/jobs/job-orchestration.schema.ts
|
|
22
1
|
import {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"completed",
|
|
48
|
-
"failed",
|
|
49
|
-
"skipped"
|
|
50
|
-
]);
|
|
51
|
-
var collisionModeEnum = pgEnum("job_collision_mode", [
|
|
52
|
-
"queue",
|
|
53
|
-
"reject",
|
|
54
|
-
"replace"
|
|
55
|
-
]);
|
|
56
|
-
var replayFromEnum = pgEnum("job_replay_from", [
|
|
57
|
-
"scratch",
|
|
58
|
-
"last_step",
|
|
59
|
-
"last_checkpoint"
|
|
60
|
-
]);
|
|
61
|
-
var parentClosePolicyEnum = pgEnum("job_parent_close_policy", [
|
|
62
|
-
"terminate",
|
|
63
|
-
"cancel",
|
|
64
|
-
"abandon"
|
|
65
|
-
]);
|
|
66
|
-
var waitKindEnum = pgEnum("job_wait_kind", ["signal"]);
|
|
67
|
-
var triggerSourceEnum = pgEnum("job_trigger_source", [
|
|
68
|
-
"manual",
|
|
69
|
-
"schedule",
|
|
70
|
-
"event",
|
|
71
|
-
"parent"
|
|
72
|
-
]);
|
|
73
|
-
var jobs = pgTable("job", {
|
|
74
|
-
type: text("type").primaryKey(),
|
|
75
|
-
version: integer("version").notNull().default(1),
|
|
76
|
-
pool: text("pool").notNull(),
|
|
77
|
-
scopeEntityType: text("scope_entity_type"),
|
|
78
|
-
retryPolicy: jsonb("retry_policy").notNull().$type(),
|
|
79
|
-
timeoutMs: integer("timeout_ms"),
|
|
80
|
-
concurrencyKeyTemplate: text("concurrency_key_template"),
|
|
81
|
-
collisionMode: collisionModeEnum("collision_mode").notNull().default("queue"),
|
|
82
|
-
dedupeKeyTemplate: text("dedupe_key_template"),
|
|
83
|
-
dedupeWindowMs: integer("dedupe_window_ms"),
|
|
84
|
-
priorityDefault: integer("priority_default").notNull().default(0),
|
|
85
|
-
replayFrom: replayFromEnum("replay_from").notNull().default("last_checkpoint"),
|
|
86
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
87
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
88
|
-
});
|
|
89
|
-
var jobRuns = pgTable(
|
|
90
|
-
"job_run",
|
|
91
|
-
{
|
|
92
|
-
id: uuid("id").primaryKey().defaultRandom(),
|
|
93
|
-
jobType: text("job_type").notNull().references(() => jobs.type),
|
|
94
|
-
jobVersion: integer("job_version").notNull(),
|
|
95
|
-
parentRunId: uuid("parent_run_id").references(() => jobRuns.id),
|
|
96
|
-
/**
|
|
97
|
-
* Service generates `id` client-side via randomUUID() and sets
|
|
98
|
-
* root_run_id = id for root runs (single INSERT, no self-FK race).
|
|
99
|
-
*/
|
|
100
|
-
rootRunId: uuid("root_run_id").notNull(),
|
|
101
|
-
parentClosePolicy: parentClosePolicyEnum("parent_close_policy").notNull().default("terminate"),
|
|
102
|
-
scopeEntityType: text("scope_entity_type"),
|
|
103
|
-
scopeEntityId: text("scope_entity_id"),
|
|
104
|
-
tenantId: text("tenant_id"),
|
|
105
|
-
tags: jsonb("tags").notNull().default({}).$type(),
|
|
106
|
-
pool: text("pool").notNull(),
|
|
107
|
-
priority: integer("priority").notNull().default(0),
|
|
108
|
-
concurrencyKey: text("concurrency_key"),
|
|
109
|
-
dedupeKey: text("dedupe_key"),
|
|
110
|
-
status: jobRunStatusEnum("status").notNull().default("pending"),
|
|
111
|
-
input: jsonb("input").notNull().$type(),
|
|
112
|
-
output: jsonb("output").$type(),
|
|
113
|
-
error: jsonb("error").$type(),
|
|
114
|
-
triggerSource: triggerSourceEnum("trigger_source").notNull(),
|
|
115
|
-
triggerRef: text("trigger_ref"),
|
|
116
|
-
runAt: timestamp("run_at", { withTimezone: true }).notNull().defaultNow(),
|
|
117
|
-
startedAt: timestamp("started_at", { withTimezone: true }),
|
|
118
|
-
finishedAt: timestamp("finished_at", { withTimezone: true }),
|
|
119
|
-
claimedAt: timestamp("claimed_at", { withTimezone: true }),
|
|
120
|
-
attempts: integer("attempts").notNull().default(0),
|
|
121
|
-
// Phase 3 placeholder — see ADR-025
|
|
122
|
-
waitKind: waitKindEnum("wait_kind"),
|
|
123
|
-
// Phase 3 placeholder — see ADR-025
|
|
124
|
-
resumeToken: text("resume_token"),
|
|
125
|
-
// Phase 3 placeholder — see ADR-025
|
|
126
|
-
waitDeadline: timestamp("wait_deadline", { withTimezone: true }),
|
|
127
|
-
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
128
|
-
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
129
|
-
},
|
|
130
|
-
(t) => ({
|
|
131
|
-
/** Claim query: ORDER BY priority DESC, run_at ASC. */
|
|
132
|
-
idxJobRunClaim: index("idx_job_run_claim").on(t.status, t.pool, t.runAt),
|
|
133
|
-
/** Tree traversal / cascade cancel. */
|
|
134
|
-
idxJobRunRoot: index("idx_job_run_root").on(t.rootRunId),
|
|
135
|
-
/** listForScope query. */
|
|
136
|
-
idxJobRunScope: index("idx_job_run_scope").on(t.scopeEntityType, t.scopeEntityId),
|
|
137
|
-
/** Idempotency collapse — partial index. */
|
|
138
|
-
idxJobRunDedupe: index("idx_job_run_dedupe").on(t.jobType, t.dedupeKey).where(sql`${t.dedupeKey} IS NOT NULL`),
|
|
139
|
-
/** Collision check — partial index. */
|
|
140
|
-
idxJobRunConcurrency: index("idx_job_run_concurrency").on(t.concurrencyKey).where(
|
|
141
|
-
sql`${t.concurrencyKey} IS NOT NULL AND ${t.status} IN ('pending','running')`
|
|
142
|
-
)
|
|
143
|
-
})
|
|
144
|
-
);
|
|
145
|
-
var jobSteps = pgTable(
|
|
146
|
-
"job_step",
|
|
147
|
-
{
|
|
148
|
-
id: uuid("id").primaryKey().defaultRandom(),
|
|
149
|
-
jobRunId: uuid("job_run_id").notNull().references(() => jobRuns.id),
|
|
150
|
-
stepId: text("step_id").notNull(),
|
|
151
|
-
kind: jobStepKindEnum("kind").notNull().default("task"),
|
|
152
|
-
/**
|
|
153
|
-
* Monotonic within run. integer (max ~2B per run) is sufficient —
|
|
154
|
-
* downgraded from ADR-022's bigint; revisit only if a single run
|
|
155
|
-
* ever exceeds 2 billion steps.
|
|
156
|
-
*/
|
|
157
|
-
seq: integer("seq").notNull(),
|
|
158
|
-
status: jobStepStatusEnum("status").notNull().default("pending"),
|
|
159
|
-
input: jsonb("input").$type(),
|
|
160
|
-
/** Memoised on success for replay. */
|
|
161
|
-
output: jsonb("output").$type(),
|
|
162
|
-
error: jsonb("error").$type(),
|
|
163
|
-
attempts: integer("attempts").notNull().default(0),
|
|
164
|
-
startedAt: timestamp("started_at", { withTimezone: true }),
|
|
165
|
-
finishedAt: timestamp("finished_at", { withTimezone: true })
|
|
166
|
-
},
|
|
167
|
-
(t) => ({
|
|
168
|
-
/** No duplicate step IDs per run. */
|
|
169
|
-
idxJobStepRunStep: uniqueIndex("idx_job_step_run_step").on(t.jobRunId, t.stepId),
|
|
170
|
-
/** Ordered timeline reads. */
|
|
171
|
-
idxJobStepTimeline: index("idx_job_step_timeline").on(t.jobRunId, t.seq)
|
|
172
|
-
})
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
// runtime/subsystems/jobs/job-orchestrator.drizzle-backend.ts
|
|
176
|
-
import { randomUUID } from "crypto";
|
|
177
|
-
import { Inject, Injectable, Logger } from "@nestjs/common";
|
|
178
|
-
import { and, desc, eq, gt, inArray, isNotNull, ne, notInArray, sql as sql2 } from "drizzle-orm";
|
|
179
|
-
|
|
180
|
-
// runtime/subsystems/jobs/jobs-errors.ts
|
|
181
|
-
var JobTypeNotFoundError = class extends Error {
|
|
182
|
-
constructor(jobType) {
|
|
183
|
-
super(`No job definition registered for type '${jobType}'.`);
|
|
184
|
-
this.jobType = jobType;
|
|
185
|
-
}
|
|
186
|
-
jobType;
|
|
187
|
-
name = "JobTypeNotFoundError";
|
|
188
|
-
};
|
|
189
|
-
var JobCollisionError = class extends Error {
|
|
190
|
-
constructor(jobType, concurrencyKey, incumbent) {
|
|
191
|
-
super(
|
|
192
|
-
`Job type '${jobType}' has an in-flight run with concurrency_key '${concurrencyKey}' (incumbent ${incumbent.id}); collision_mode=reject.`
|
|
193
|
-
);
|
|
194
|
-
this.jobType = jobType;
|
|
195
|
-
this.concurrencyKey = concurrencyKey;
|
|
196
|
-
this.incumbent = incumbent;
|
|
197
|
-
}
|
|
198
|
-
jobType;
|
|
199
|
-
concurrencyKey;
|
|
200
|
-
incumbent;
|
|
201
|
-
name = "JobCollisionError";
|
|
202
|
-
};
|
|
203
|
-
var JobNotReplayableError = class extends Error {
|
|
204
|
-
constructor(runId, currentStatus) {
|
|
205
|
-
super(
|
|
206
|
-
`Run ${runId} is not replayable from status '${currentStatus}'. Only 'completed', 'failed', 'timed_out', and 'canceled' are eligible.`
|
|
207
|
-
);
|
|
208
|
-
this.runId = runId;
|
|
209
|
-
this.currentStatus = currentStatus;
|
|
210
|
-
}
|
|
211
|
-
runId;
|
|
212
|
-
currentStatus;
|
|
213
|
-
name = "JobNotReplayableError";
|
|
214
|
-
};
|
|
215
|
-
var JobTemplateFieldMissingError = class extends Error {
|
|
216
|
-
constructor(template, field) {
|
|
217
|
-
super(
|
|
218
|
-
`Template '${template}' references input field '${field}' which is missing or undefined on the payload.`
|
|
219
|
-
);
|
|
220
|
-
this.template = template;
|
|
221
|
-
this.field = field;
|
|
222
|
-
}
|
|
223
|
-
template;
|
|
224
|
-
field;
|
|
225
|
-
name = "JobTemplateFieldMissingError";
|
|
226
|
-
};
|
|
227
|
-
var MissingTenantIdError = class extends Error {
|
|
228
|
-
constructor(method) {
|
|
229
|
-
super(
|
|
230
|
-
`MissingTenantIdError: JobsDomainModule was configured with multiTenant=true but ${method} was called without tenantId (undefined). Pass an explicit tenantId, or pass null for cross-tenant work.`
|
|
231
|
-
);
|
|
232
|
-
this.method = method;
|
|
233
|
-
}
|
|
234
|
-
method;
|
|
235
|
-
name = "MissingTenantIdError";
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
// runtime/subsystems/token-key.ts
|
|
239
|
-
var PKG = "@pattern-stack/codegen";
|
|
240
|
-
var tokenKey = (area, name) => `${PKG}.${area}.${name}`;
|
|
241
|
-
|
|
242
|
-
// runtime/subsystems/jobs/jobs-domain.tokens.ts
|
|
243
|
-
var JOB_ORCHESTRATOR = Symbol.for(tokenKey("jobs", "orchestrator"));
|
|
244
|
-
var JOB_RUN_SERVICE = Symbol.for(tokenKey("jobs", "run-service"));
|
|
245
|
-
var JOB_STEP_SERVICE = Symbol.for(tokenKey("jobs", "step-service"));
|
|
246
|
-
var JOBS_MULTI_TENANT = Symbol.for(tokenKey("jobs", "multi-tenant"));
|
|
247
|
-
|
|
248
|
-
// runtime/subsystems/jobs/job-orchestrator.drizzle-backend.ts
|
|
249
|
-
var TERMINAL_STATUSES = [
|
|
250
|
-
"completed",
|
|
251
|
-
"failed",
|
|
252
|
-
"timed_out",
|
|
253
|
-
"canceled"
|
|
254
|
-
];
|
|
255
|
-
var DEDUPE_EXCLUDED_STATUSES = ["canceled", "failed"];
|
|
256
|
-
var IN_FLIGHT_STATUSES = ["pending", "running"];
|
|
257
|
-
function evaluateKeyTemplate(template, input) {
|
|
258
|
-
return template.replace(/\{\{\s*([a-zA-Z0-9_]+)\s*\}\}/g, (_match, field) => {
|
|
259
|
-
const value = input[field];
|
|
260
|
-
if (value === void 0 || value === null) {
|
|
261
|
-
throw new JobTemplateFieldMissingError(template, field);
|
|
262
|
-
}
|
|
263
|
-
return String(value);
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
var DrizzleJobOrchestrator = class {
|
|
267
|
-
constructor(db, multiTenant) {
|
|
268
|
-
this.db = db;
|
|
269
|
-
this.multiTenant = multiTenant;
|
|
270
|
-
}
|
|
271
|
-
db;
|
|
272
|
-
multiTenant;
|
|
273
|
-
// TODO(logging-subsystem): swap to ILogger once ADR-028 lands
|
|
274
|
-
logger = new Logger(DrizzleJobOrchestrator.name);
|
|
275
|
-
/**
|
|
276
|
-
* JOB-8 — resolve `tenantId` for a mutating / targeted-read call.
|
|
277
|
-
* Returns the tenant value that should be written to the row (or compared
|
|
278
|
-
* against in a WHERE clause). When `multiTenant` is off, the column is
|
|
279
|
-
* forced to `null` regardless of what callers pass. When on, `undefined`
|
|
280
|
-
* throws; `null` and strings pass through untouched.
|
|
281
|
-
*/
|
|
282
|
-
resolveTenantId(method, tenantId) {
|
|
283
|
-
if (!this.multiTenant) return null;
|
|
284
|
-
if (tenantId === void 0) throw new MissingTenantIdError(method);
|
|
285
|
-
return tenantId;
|
|
286
|
-
}
|
|
287
|
-
// ==========================================================================
|
|
288
|
-
// start
|
|
289
|
-
// ==========================================================================
|
|
290
|
-
async start(type, input, opts = {}, tx) {
|
|
291
|
-
const payload = input ?? {};
|
|
292
|
-
const tenantId = this.resolveTenantId("start", opts.tenantId);
|
|
293
|
-
const client = tx ?? this.db;
|
|
294
|
-
const [def] = await client.select().from(jobs).where(eq(jobs.type, type)).limit(1);
|
|
295
|
-
if (!def) throw new JobTypeNotFoundError(type);
|
|
296
|
-
const definition = def;
|
|
297
|
-
if (definition.dedupeKeyTemplate && definition.dedupeWindowMs) {
|
|
298
|
-
const dedupeKey2 = evaluateKeyTemplate(definition.dedupeKeyTemplate, payload);
|
|
299
|
-
const windowStart = new Date(Date.now() - definition.dedupeWindowMs);
|
|
300
|
-
const existing = await client.select().from(jobRuns).where(
|
|
301
|
-
and(
|
|
302
|
-
eq(jobRuns.jobType, type),
|
|
303
|
-
eq(jobRuns.dedupeKey, dedupeKey2),
|
|
304
|
-
gt(jobRuns.createdAt, windowStart),
|
|
305
|
-
// status NOT IN ('canceled', 'failed')
|
|
306
|
-
notInStatus(DEDUPE_EXCLUDED_STATUSES)
|
|
307
|
-
)
|
|
308
|
-
).orderBy(desc(jobRuns.createdAt)).limit(1);
|
|
309
|
-
if (existing.length > 0) {
|
|
310
|
-
return existing[0];
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
let concurrencyKey = null;
|
|
314
|
-
if (definition.concurrencyKeyTemplate) {
|
|
315
|
-
concurrencyKey = evaluateKeyTemplate(
|
|
316
|
-
definition.concurrencyKeyTemplate,
|
|
317
|
-
payload
|
|
318
|
-
);
|
|
319
|
-
const inFlight = await client.select().from(jobRuns).where(
|
|
320
|
-
and(
|
|
321
|
-
eq(jobRuns.concurrencyKey, concurrencyKey),
|
|
322
|
-
inArray(jobRuns.status, IN_FLIGHT_STATUSES)
|
|
323
|
-
)
|
|
324
|
-
).limit(1);
|
|
325
|
-
if (inFlight.length > 0) {
|
|
326
|
-
const incumbent = inFlight[0];
|
|
327
|
-
switch (definition.collisionMode) {
|
|
328
|
-
case "reject":
|
|
329
|
-
throw new JobCollisionError(type, concurrencyKey, incumbent);
|
|
330
|
-
case "replace":
|
|
331
|
-
await this.cancel(incumbent.id, {
|
|
332
|
-
cascade: true,
|
|
333
|
-
reason: "replaced",
|
|
334
|
-
tenantId: incumbent.tenantId
|
|
335
|
-
});
|
|
336
|
-
break;
|
|
337
|
-
case "queue":
|
|
338
|
-
break;
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
const newId = randomUUID();
|
|
343
|
-
let rootRunId = newId;
|
|
344
|
-
if (opts.parentRunId) {
|
|
345
|
-
const [parent] = await client.select({ rootRunId: jobRuns.rootRunId }).from(jobRuns).where(eq(jobRuns.id, opts.parentRunId)).limit(1);
|
|
346
|
-
if (!parent) {
|
|
347
|
-
throw new Error(
|
|
348
|
-
`parentRunId ${opts.parentRunId} does not reference an existing job_run`
|
|
349
|
-
);
|
|
350
|
-
}
|
|
351
|
-
rootRunId = parent.rootRunId;
|
|
352
|
-
}
|
|
353
|
-
const dedupeKey = definition.dedupeKeyTemplate ? evaluateKeyTemplate(definition.dedupeKeyTemplate, payload) : null;
|
|
354
|
-
const [inserted] = await client.insert(jobRuns).values({
|
|
355
|
-
id: newId,
|
|
356
|
-
jobType: type,
|
|
357
|
-
jobVersion: definition.version,
|
|
358
|
-
parentRunId: opts.parentRunId ?? null,
|
|
359
|
-
rootRunId,
|
|
360
|
-
parentClosePolicy: opts.parentClosePolicy ?? "terminate",
|
|
361
|
-
scopeEntityType: opts.scope?.entityType ?? null,
|
|
362
|
-
scopeEntityId: opts.scope?.entityId ?? null,
|
|
363
|
-
tenantId,
|
|
364
|
-
tags: opts.tags ?? {},
|
|
365
|
-
pool: opts.pool ?? definition.pool,
|
|
366
|
-
priority: opts.priority ?? definition.priorityDefault,
|
|
367
|
-
concurrencyKey,
|
|
368
|
-
dedupeKey,
|
|
369
|
-
status: "pending",
|
|
370
|
-
input: payload,
|
|
371
|
-
output: null,
|
|
372
|
-
error: null,
|
|
373
|
-
triggerSource: opts.triggerSource ?? "manual",
|
|
374
|
-
triggerRef: opts.triggerRef ?? null,
|
|
375
|
-
runAt: opts.runAt ?? /* @__PURE__ */ new Date(),
|
|
376
|
-
startedAt: null,
|
|
377
|
-
finishedAt: null,
|
|
378
|
-
claimedAt: null,
|
|
379
|
-
attempts: 0
|
|
380
|
-
}).returning();
|
|
381
|
-
return inserted;
|
|
382
|
-
}
|
|
383
|
-
// ==========================================================================
|
|
384
|
-
// cancel
|
|
385
|
-
// ==========================================================================
|
|
386
|
-
async cancel(runId, opts = {}) {
|
|
387
|
-
const tenantId = this.resolveTenantId("cancel", opts.tenantId);
|
|
388
|
-
const [target] = await this.db.select().from(jobRuns).where(eq(jobRuns.id, runId)).limit(1);
|
|
389
|
-
if (!target) return;
|
|
390
|
-
if (this.multiTenant && target.tenantId !== tenantId) return;
|
|
391
|
-
if (TERMINAL_STATUSES.includes(target.status)) {
|
|
392
|
-
return;
|
|
393
|
-
}
|
|
394
|
-
const [cancelled] = await this.db.update(jobRuns).set({
|
|
395
|
-
status: "canceled",
|
|
396
|
-
finishedAt: /* @__PURE__ */ new Date(),
|
|
397
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
398
|
-
}).where(
|
|
399
|
-
and(eq(jobRuns.id, runId), notInStatus([...TERMINAL_STATUSES]))
|
|
400
|
-
).returning();
|
|
401
|
-
if (!cancelled) return;
|
|
402
|
-
if (opts.cascade === false) return;
|
|
403
|
-
const descendants = await this.db.select().from(jobRuns).where(
|
|
404
|
-
and(
|
|
405
|
-
eq(jobRuns.rootRunId, target.rootRunId),
|
|
406
|
-
ne(jobRuns.id, runId),
|
|
407
|
-
notInStatus([...TERMINAL_STATUSES])
|
|
408
|
-
)
|
|
409
|
-
);
|
|
410
|
-
for (const child of descendants) {
|
|
411
|
-
const policy = child.parentClosePolicy;
|
|
412
|
-
if (policy === "abandon") continue;
|
|
413
|
-
await this.db.update(jobRuns).set({
|
|
414
|
-
status: "canceled",
|
|
415
|
-
finishedAt: /* @__PURE__ */ new Date(),
|
|
416
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
417
|
-
}).where(
|
|
418
|
-
and(
|
|
419
|
-
eq(jobRuns.id, child.id),
|
|
420
|
-
notInStatus([...TERMINAL_STATUSES])
|
|
421
|
-
)
|
|
422
|
-
);
|
|
423
|
-
}
|
|
424
|
-
void opts.reason;
|
|
425
|
-
}
|
|
426
|
-
// ==========================================================================
|
|
427
|
-
// replay
|
|
428
|
-
// ==========================================================================
|
|
429
|
-
async replay(runId) {
|
|
430
|
-
const [target] = await this.db.select().from(jobRuns).where(eq(jobRuns.id, runId)).limit(1);
|
|
431
|
-
if (!target) {
|
|
432
|
-
throw new Error(`replay: run ${runId} not found`);
|
|
433
|
-
}
|
|
434
|
-
const run = target;
|
|
435
|
-
if (!TERMINAL_STATUSES.includes(run.status)) {
|
|
436
|
-
throw new JobNotReplayableError(runId, run.status);
|
|
437
|
-
}
|
|
438
|
-
const [def] = await this.db.select().from(jobs).where(eq(jobs.type, run.jobType)).limit(1);
|
|
439
|
-
if (!def) throw new JobTypeNotFoundError(run.jobType);
|
|
440
|
-
const mode = def.replayFrom;
|
|
441
|
-
const result = await this.db.transaction(async (tx) => {
|
|
442
|
-
if (mode === "scratch") {
|
|
443
|
-
await tx.delete(jobSteps).where(eq(jobSteps.jobRunId, runId));
|
|
444
|
-
} else if (mode === "last_step") {
|
|
445
|
-
await tx.delete(jobSteps).where(
|
|
446
|
-
and(eq(jobSteps.jobRunId, runId), ne(jobSteps.status, "completed"))
|
|
447
|
-
);
|
|
448
|
-
} else {
|
|
449
|
-
await tx.delete(jobSteps).where(
|
|
450
|
-
and(eq(jobSteps.jobRunId, runId), ne(jobSteps.status, "completed"))
|
|
451
|
-
);
|
|
452
|
-
}
|
|
453
|
-
const [updated] = await tx.update(jobRuns).set({
|
|
454
|
-
status: "pending",
|
|
455
|
-
attempts: 0,
|
|
456
|
-
runAt: /* @__PURE__ */ new Date(),
|
|
457
|
-
startedAt: null,
|
|
458
|
-
finishedAt: null,
|
|
459
|
-
claimedAt: null,
|
|
460
|
-
error: null,
|
|
461
|
-
output: null,
|
|
462
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
463
|
-
}).where(eq(jobRuns.id, runId)).returning();
|
|
464
|
-
return updated;
|
|
465
|
-
});
|
|
466
|
-
return result;
|
|
467
|
-
}
|
|
468
|
-
// ==========================================================================
|
|
469
|
-
// upsertJobRows — boot-time materialisation of `job` definitions
|
|
470
|
-
// ==========================================================================
|
|
471
|
-
/**
|
|
472
|
-
* Hash-gated `INSERT … ON CONFLICT (type) DO UPDATE … WHERE` per Q3
|
|
473
|
-
* resolution (2026-04-19): the `UPDATE` branch executes only when one
|
|
474
|
-
* of the persisted metadata fields differs from the incoming payload;
|
|
475
|
-
* `version` bumps only on real change; concurrent boots with identical
|
|
476
|
-
* content are idempotent no-ops.
|
|
477
|
-
*
|
|
478
|
-
* Why this shape (not `DO NOTHING`, not advisory locks):
|
|
479
|
-
* - `DO NOTHING` would let an old-version instance leave a stale row
|
|
480
|
-
* that a new-version instance can't overwrite during a rolling deploy.
|
|
481
|
-
* - Advisory locks add latency and leak risk under crashes.
|
|
482
|
-
* - The `WHERE … IS DISTINCT FROM …` clause makes the conditional
|
|
483
|
-
* atomic — no read-modify-write race on `version` between concurrent
|
|
484
|
-
* boots.
|
|
485
|
-
*
|
|
486
|
-
* Orphan detection: a single `SELECT type FROM job WHERE type NOT IN (...)`
|
|
487
|
-
* returns the types present in DB but absent from `entries`. Caller (boot
|
|
488
|
-
* validator) decides whether to throw `BootValidationError`.
|
|
489
|
-
*/
|
|
490
|
-
async upsertJobRows(entries, poolConfig) {
|
|
491
|
-
void poolConfig;
|
|
492
|
-
for (const entry of entries) {
|
|
493
|
-
const meta = entry.meta;
|
|
494
|
-
const pool = meta.pool ?? "batch";
|
|
495
|
-
const retryPolicy = meta.retry ?? {
|
|
496
|
-
attempts: 1,
|
|
497
|
-
backoff: "fixed",
|
|
498
|
-
baseMs: 0
|
|
499
|
-
};
|
|
500
|
-
const concurrencyKeyTemplate = meta.concurrency?.key;
|
|
501
|
-
const concurrencyKeyTemplateStr = typeof concurrencyKeyTemplate === "string" ? concurrencyKeyTemplate : null;
|
|
502
|
-
const collisionMode = meta.concurrency?.collisionMode ?? "queue";
|
|
503
|
-
const dedupeKeyTemplate = meta.dedupe?.key;
|
|
504
|
-
const dedupeKeyTemplateStr = typeof dedupeKeyTemplate === "string" ? dedupeKeyTemplate : null;
|
|
505
|
-
const dedupeWindowMs = meta.dedupe?.windowMs ?? null;
|
|
506
|
-
const timeoutMs = meta.timeoutMs ?? null;
|
|
507
|
-
const replayFrom = meta.replayFrom ?? "last_checkpoint";
|
|
508
|
-
const scopeEntityType = meta.scope?.entity ?? null;
|
|
509
|
-
const priorityDefault = 0;
|
|
510
|
-
await this.db.insert(jobs).values({
|
|
511
|
-
type: entry.type,
|
|
512
|
-
version: 1,
|
|
513
|
-
pool,
|
|
514
|
-
scopeEntityType,
|
|
515
|
-
retryPolicy,
|
|
516
|
-
timeoutMs,
|
|
517
|
-
concurrencyKeyTemplate: concurrencyKeyTemplateStr,
|
|
518
|
-
collisionMode,
|
|
519
|
-
dedupeKeyTemplate: dedupeKeyTemplateStr,
|
|
520
|
-
dedupeWindowMs,
|
|
521
|
-
priorityDefault,
|
|
522
|
-
replayFrom
|
|
523
|
-
}).onConflictDoUpdate({
|
|
524
|
-
target: jobs.type,
|
|
525
|
-
set: {
|
|
526
|
-
pool: sql2`EXCLUDED.pool`,
|
|
527
|
-
scopeEntityType: sql2`EXCLUDED.scope_entity_type`,
|
|
528
|
-
retryPolicy: sql2`EXCLUDED.retry_policy`,
|
|
529
|
-
timeoutMs: sql2`EXCLUDED.timeout_ms`,
|
|
530
|
-
concurrencyKeyTemplate: sql2`EXCLUDED.concurrency_key_template`,
|
|
531
|
-
collisionMode: sql2`EXCLUDED.collision_mode`,
|
|
532
|
-
dedupeKeyTemplate: sql2`EXCLUDED.dedupe_key_template`,
|
|
533
|
-
dedupeWindowMs: sql2`EXCLUDED.dedupe_window_ms`,
|
|
534
|
-
priorityDefault: sql2`EXCLUDED.priority_default`,
|
|
535
|
-
replayFrom: sql2`EXCLUDED.replay_from`,
|
|
536
|
-
version: sql2`${jobs.version} + 1`,
|
|
537
|
-
updatedAt: sql2`now()`
|
|
538
|
-
},
|
|
539
|
-
// The hash gate: every field listed in the Q3 resolution appears
|
|
540
|
-
// here. `IS DISTINCT FROM` is the null-safe inequality operator;
|
|
541
|
-
// jsonb cast to text gives stable comparison without invoking a
|
|
542
|
-
// dedicated hash column (avoids a JOB-1 schema migration).
|
|
543
|
-
setWhere: sql2`
|
|
544
|
-
${jobs.pool} IS DISTINCT FROM EXCLUDED.pool OR
|
|
545
|
-
${jobs.retryPolicy}::text IS DISTINCT FROM EXCLUDED.retry_policy::text OR
|
|
546
|
-
${jobs.timeoutMs} IS DISTINCT FROM EXCLUDED.timeout_ms OR
|
|
547
|
-
${jobs.concurrencyKeyTemplate} IS DISTINCT FROM EXCLUDED.concurrency_key_template OR
|
|
548
|
-
${jobs.collisionMode} IS DISTINCT FROM EXCLUDED.collision_mode OR
|
|
549
|
-
${jobs.dedupeKeyTemplate} IS DISTINCT FROM EXCLUDED.dedupe_key_template OR
|
|
550
|
-
${jobs.dedupeWindowMs} IS DISTINCT FROM EXCLUDED.dedupe_window_ms OR
|
|
551
|
-
${jobs.priorityDefault} IS DISTINCT FROM EXCLUDED.priority_default OR
|
|
552
|
-
${jobs.replayFrom} IS DISTINCT FROM EXCLUDED.replay_from OR
|
|
553
|
-
${jobs.scopeEntityType} IS DISTINCT FROM EXCLUDED.scope_entity_type
|
|
554
|
-
`
|
|
555
|
-
});
|
|
556
|
-
}
|
|
557
|
-
const types = entries.map((e) => e.type);
|
|
558
|
-
const orphans = types.length === 0 ? await this.db.select({ type: jobs.type }).from(jobs) : await this.db.select({ type: jobs.type }).from(jobs).where(notInArray(jobs.type, types));
|
|
559
|
-
return { orphaned: orphans.map((o) => o.type) };
|
|
560
|
-
}
|
|
561
|
-
};
|
|
562
|
-
DrizzleJobOrchestrator = __decorateClass([
|
|
563
|
-
Injectable(),
|
|
564
|
-
__decorateParam(0, Inject(DRIZZLE)),
|
|
565
|
-
__decorateParam(1, Inject(JOBS_MULTI_TENANT))
|
|
566
|
-
], DrizzleJobOrchestrator);
|
|
567
|
-
function notInStatus(statuses) {
|
|
568
|
-
const negated = statuses.map((s) => ne(jobRuns.status, s));
|
|
569
|
-
return and(...negated);
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
// runtime/subsystems/jobs/pool-config.loader.ts
|
|
573
|
-
import { existsSync, readFileSync } from "fs";
|
|
574
|
-
import { resolve } from "path";
|
|
575
|
-
import { parse as parseYaml } from "yaml";
|
|
576
|
-
var FRAMEWORK_POOLS = Object.freeze({
|
|
577
|
-
events_inbound: Object.freeze({
|
|
578
|
-
queue: "jobs-events-inbound",
|
|
579
|
-
concurrency: 20,
|
|
580
|
-
reserved: true,
|
|
581
|
-
description: "Inbound events drain (events subsystem outbox)."
|
|
582
|
-
}),
|
|
583
|
-
events_change: Object.freeze({
|
|
584
|
-
queue: "jobs-events-change",
|
|
585
|
-
concurrency: 30,
|
|
586
|
-
reserved: true,
|
|
587
|
-
description: "Change events drain (events subsystem outbox)."
|
|
588
|
-
}),
|
|
589
|
-
events_outbound: Object.freeze({
|
|
590
|
-
queue: "jobs-events-outbound",
|
|
591
|
-
concurrency: 10,
|
|
592
|
-
reserved: true,
|
|
593
|
-
description: "Outbound events drain (events subsystem outbox)."
|
|
594
|
-
}),
|
|
595
|
-
interactive: Object.freeze({
|
|
596
|
-
queue: "jobs-interactive",
|
|
597
|
-
concurrency: 20,
|
|
598
|
-
reserved: false,
|
|
599
|
-
description: "User-facing latency-sensitive jobs."
|
|
600
|
-
}),
|
|
601
|
-
batch: Object.freeze({
|
|
602
|
-
queue: "jobs-batch",
|
|
603
|
-
concurrency: 5,
|
|
604
|
-
reserved: false,
|
|
605
|
-
description: "Default pool for background jobs."
|
|
606
|
-
})
|
|
607
|
-
});
|
|
608
|
-
var RESERVED_POOL_NAMES = new Set(
|
|
609
|
-
Object.entries(FRAMEWORK_POOLS).filter(([, def]) => def.reserved).map(([name]) => name)
|
|
610
|
-
);
|
|
611
|
-
var cache = /* @__PURE__ */ new Map();
|
|
612
|
-
function loadPoolConfig(configPath) {
|
|
613
|
-
const resolved = resolve(configPath ?? `${process.cwd()}/codegen.config.yaml`);
|
|
614
|
-
const cached = cache.get(resolved);
|
|
615
|
-
if (cached) return cached;
|
|
616
|
-
const merged = /* @__PURE__ */ new Map();
|
|
617
|
-
for (const [name, def] of Object.entries(FRAMEWORK_POOLS)) {
|
|
618
|
-
merged.set(name, { ...def });
|
|
619
|
-
}
|
|
620
|
-
if (!existsSync(resolved)) {
|
|
621
|
-
cache.set(resolved, merged);
|
|
622
|
-
return merged;
|
|
623
|
-
}
|
|
624
|
-
let raw;
|
|
625
|
-
try {
|
|
626
|
-
raw = parseYaml(readFileSync(resolved, "utf8"));
|
|
627
|
-
} catch (err) {
|
|
628
|
-
throw new Error(
|
|
629
|
-
`pool-config.loader: failed to parse YAML at ${resolved}: ${err.message}`
|
|
630
|
-
);
|
|
631
|
-
}
|
|
632
|
-
const userPools = extractUserPools(raw);
|
|
633
|
-
for (const [name, userDef] of Object.entries(userPools)) {
|
|
634
|
-
const existing = merged.get(name);
|
|
635
|
-
if (existing) {
|
|
636
|
-
const next = {
|
|
637
|
-
queue: existing.queue,
|
|
638
|
-
concurrency: typeof userDef.concurrency === "number" ? userDef.concurrency : existing.concurrency,
|
|
639
|
-
reserved: existing.reserved,
|
|
640
|
-
description: userDef.description ?? existing.description
|
|
641
|
-
};
|
|
642
|
-
merged.set(name, next);
|
|
643
|
-
continue;
|
|
644
|
-
}
|
|
645
|
-
if (typeof userDef.queue !== "string" || userDef.queue.length === 0) {
|
|
646
|
-
throw new Error(
|
|
647
|
-
`pool-config.loader: pool '${name}' must declare a non-empty 'queue'.`
|
|
648
|
-
);
|
|
649
|
-
}
|
|
650
|
-
if (typeof userDef.concurrency !== "number" || userDef.concurrency <= 0) {
|
|
651
|
-
throw new Error(
|
|
652
|
-
`pool-config.loader: pool '${name}' must declare a positive 'concurrency'.`
|
|
653
|
-
);
|
|
654
|
-
}
|
|
655
|
-
if (userDef.reserved === true) {
|
|
656
|
-
throw new Error(
|
|
657
|
-
`pool-config.loader: user-defined pool '${name}' cannot set 'reserved: true' \u2014 reserved is framework-only.`
|
|
658
|
-
);
|
|
659
|
-
}
|
|
660
|
-
merged.set(name, {
|
|
661
|
-
queue: userDef.queue,
|
|
662
|
-
concurrency: userDef.concurrency,
|
|
663
|
-
reserved: false,
|
|
664
|
-
description: userDef.description
|
|
665
|
-
});
|
|
666
|
-
}
|
|
667
|
-
cache.set(resolved, merged);
|
|
668
|
-
return merged;
|
|
669
|
-
}
|
|
670
|
-
function extractUserPools(raw) {
|
|
671
|
-
if (!raw || typeof raw !== "object") return {};
|
|
672
|
-
const jobs2 = raw.jobs;
|
|
673
|
-
if (!jobs2 || typeof jobs2 !== "object") return {};
|
|
674
|
-
const pools = jobs2.pools;
|
|
675
|
-
if (!pools || typeof pools !== "object") return {};
|
|
676
|
-
const out = {};
|
|
677
|
-
for (const [name, def] of Object.entries(pools)) {
|
|
678
|
-
if (!def || typeof def !== "object") continue;
|
|
679
|
-
out[name] = def;
|
|
680
|
-
}
|
|
681
|
-
return out;
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
// runtime/subsystems/jobs/bullmq.config.ts
|
|
685
|
-
var BULLMQ_CONNECTION = Symbol.for(tokenKey("jobs", "bullmq-connection"));
|
|
686
|
-
var BULLMQ_RESOLVED_CONFIG = Symbol.for(tokenKey("jobs", "bullmq-resolved-config"));
|
|
687
|
-
function resolvePoolQueueName(pool, config, poolConfig = loadPoolConfig()) {
|
|
688
|
-
const alias = poolConfig.get(pool)?.queue ?? pool;
|
|
689
|
-
const prefix = config?.queuePrefix;
|
|
690
|
-
return prefix ? `${prefix}:${alias}` : alias;
|
|
691
|
-
}
|
|
2
|
+
BULLMQ_CONNECTION,
|
|
3
|
+
BULLMQ_RESOLVED_CONFIG,
|
|
4
|
+
resolvePoolQueueName
|
|
5
|
+
} from "../../../chunk-I6MVCB5A.js";
|
|
6
|
+
import "../../../chunk-RHVN6NA7.js";
|
|
7
|
+
import {
|
|
8
|
+
DrizzleJobOrchestrator
|
|
9
|
+
} from "../../../chunk-5Y7W3XR6.js";
|
|
10
|
+
import "../../../chunk-T4BIIU5E.js";
|
|
11
|
+
import {
|
|
12
|
+
JOBS_MULTI_TENANT
|
|
13
|
+
} from "../../../chunk-BIO6F7YI.js";
|
|
14
|
+
import {
|
|
15
|
+
jobRuns,
|
|
16
|
+
jobs
|
|
17
|
+
} from "../../../chunk-OKXZ63IA.js";
|
|
18
|
+
import "../../../chunk-GYGNEQSC.js";
|
|
19
|
+
import {
|
|
20
|
+
DRIZZLE
|
|
21
|
+
} from "../../../chunk-U64T4YZE.js";
|
|
22
|
+
import {
|
|
23
|
+
__decorateClass,
|
|
24
|
+
__decorateParam
|
|
25
|
+
} from "../../../chunk-2E224ZSN.js";
|
|
692
26
|
|
|
693
27
|
// runtime/subsystems/jobs/job-orchestrator.bullmq-backend.ts
|
|
28
|
+
import { createHash } from "crypto";
|
|
29
|
+
import { Inject, Injectable, Logger, Optional } from "@nestjs/common";
|
|
30
|
+
import { eq } from "drizzle-orm";
|
|
694
31
|
function sha1JobId(idempotencyKey) {
|
|
695
32
|
return createHash("sha1").update(idempotencyKey).digest("hex");
|
|
696
33
|
}
|
|
@@ -704,7 +41,7 @@ var BullMQJobOrchestrator = class extends DrizzleJobOrchestrator {
|
|
|
704
41
|
connection;
|
|
705
42
|
bullConfig;
|
|
706
43
|
// TODO(logging-subsystem): swap to ILogger once ADR-028 lands
|
|
707
|
-
bullLogger = new
|
|
44
|
+
bullLogger = new Logger(BullMQJobOrchestrator.name);
|
|
708
45
|
/** Lazily-opened `Queue` handles, one per pool. */
|
|
709
46
|
queues = /* @__PURE__ */ new Map();
|
|
710
47
|
/** Single FlowProducer for parent/child hierarchies. Lazily opened. */
|
|
@@ -863,7 +200,7 @@ var BullMQJobOrchestrator = class extends DrizzleJobOrchestrator {
|
|
|
863
200
|
await this.loadBullMq();
|
|
864
201
|
await this.removeFromQueue(target);
|
|
865
202
|
if (opts.cascade === false) return;
|
|
866
|
-
const descendants = await this.bullDb.select().from(jobRuns).where(
|
|
203
|
+
const descendants = await this.bullDb.select().from(jobRuns).where(eq(jobRuns.rootRunId, target.rootRunId));
|
|
867
204
|
for (const child of descendants) {
|
|
868
205
|
if (child.id === runId) continue;
|
|
869
206
|
await this.removeFromQueue(child);
|
|
@@ -892,14 +229,14 @@ var BullMQJobOrchestrator = class extends DrizzleJobOrchestrator {
|
|
|
892
229
|
// Internals
|
|
893
230
|
// ==========================================================================
|
|
894
231
|
async loadDefinition(type) {
|
|
895
|
-
const [def] = await this.bullDb.select().from(jobs).where(
|
|
232
|
+
const [def] = await this.bullDb.select().from(jobs).where(eq(jobs.type, type)).limit(1);
|
|
896
233
|
if (!def) {
|
|
897
234
|
throw new Error(`BullMQJobOrchestrator: no job definition for '${type}'`);
|
|
898
235
|
}
|
|
899
236
|
return def;
|
|
900
237
|
}
|
|
901
238
|
async loadRun(id) {
|
|
902
|
-
const [row] = await this.bullDb.select().from(jobRuns).where(
|
|
239
|
+
const [row] = await this.bullDb.select().from(jobRuns).where(eq(jobRuns.id, id)).limit(1);
|
|
903
240
|
return row ?? null;
|
|
904
241
|
}
|
|
905
242
|
/** Close all open queue + flow connections. Called on module destroy. */
|
|
@@ -915,12 +252,12 @@ var BullMQJobOrchestrator = class extends DrizzleJobOrchestrator {
|
|
|
915
252
|
}
|
|
916
253
|
};
|
|
917
254
|
BullMQJobOrchestrator = __decorateClass([
|
|
918
|
-
|
|
919
|
-
__decorateParam(0,
|
|
920
|
-
__decorateParam(1,
|
|
921
|
-
__decorateParam(2,
|
|
255
|
+
Injectable(),
|
|
256
|
+
__decorateParam(0, Inject(DRIZZLE)),
|
|
257
|
+
__decorateParam(1, Inject(JOBS_MULTI_TENANT)),
|
|
258
|
+
__decorateParam(2, Inject(BULLMQ_CONNECTION)),
|
|
922
259
|
__decorateParam(3, Optional()),
|
|
923
|
-
__decorateParam(3,
|
|
260
|
+
__decorateParam(3, Inject(BULLMQ_RESOLVED_CONFIG))
|
|
924
261
|
], BullMQJobOrchestrator);
|
|
925
262
|
export {
|
|
926
263
|
BullMQJobOrchestrator,
|