@pattern-stack/codegen 0.15.0 → 0.15.2
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 +111 -0
- package/dist/chunk-24CWKBK5.js +94 -0
- package/dist/chunk-24CWKBK5.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-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-4MVGAMUA.js +40 -0
- package/dist/chunk-4MVGAMUA.js.map +1 -0
- package/dist/chunk-4OMHBMZJ.js +75 -0
- package/dist/chunk-4OMHBMZJ.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-7LKAMLV4.js +92 -0
- package/dist/chunk-7LKAMLV4.js.map +1 -0
- package/dist/chunk-7RELQJIN.js +22 -0
- package/dist/chunk-7RELQJIN.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-COGHTKXY.js +84 -0
- package/dist/chunk-COGHTKXY.js.map +1 -0
- package/dist/chunk-DCCZB4UC.js +100 -0
- package/dist/chunk-DCCZB4UC.js.map +1 -0
- package/dist/chunk-DKKFTHHI.js +53 -0
- package/dist/chunk-DKKFTHHI.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-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-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-I6MG4M3F.js +201 -0
- package/dist/chunk-I6MG4M3F.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-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-JRQO2IOF.js +65 -0
- package/dist/chunk-JRQO2IOF.js.map +1 -0
- package/dist/chunk-JRVNVKN6.js +212 -0
- package/dist/chunk-JRVNVKN6.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-KMZCQASO.js +111 -0
- package/dist/chunk-KMZCQASO.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-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-OZZJDRGW.js +122 -0
- package/dist/chunk-OZZJDRGW.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-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-T6C4LFLC.js +112 -0
- package/dist/chunk-T6C4LFLC.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-WEVWJKOW.js +81 -0
- package/dist/chunk-WEVWJKOW.js.map +1 -0
- package/dist/chunk-WL67FZGF.js +21 -0
- package/dist/chunk-WL67FZGF.js.map +1 -0
- package/dist/chunk-WPXNN6QS.js +290 -0
- package/dist/chunk-WPXNN6QS.js.map +1 -0
- package/dist/chunk-WRUUSZDJ.js +29 -0
- package/dist/chunk-WRUUSZDJ.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-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/{job-orchestrator.protocol-CARhMLCO.d.ts → job-orchestrator.protocol-DubMVbm9.d.ts} +1 -1
- 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.d.ts +2 -2
- 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.d.ts +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.d.ts +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.d.ts +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.d.ts +2 -2
- 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.protocol.d.ts +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.d.ts +2 -2
- 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.d.ts +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.d.ts +2 -2
- 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.d.ts +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/event-registry.d.ts +77 -0
- package/dist/runtime/subsystems/events/event-registry.js +1 -0
- package/dist/runtime/subsystems/events/event-registry.js.map +1 -0
- 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.d.ts +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 +2 -2
- package/dist/runtime/subsystems/index.js +171 -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.js +4 -89
- package/dist/runtime/subsystems/integration/poll-change-source.js.map +1 -1
- 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.d.ts +2 -2
- 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.d.ts +2 -2
- 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.d.ts +2 -2
- 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.d.ts +2 -2
- 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.d.ts +2 -2
- 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-orchestrator.protocol.d.ts +2 -2
- package/dist/runtime/subsystems/jobs/job-run-keyset-cursor.d.ts +2 -2
- 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.d.ts +2 -2
- 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.d.ts +2 -2
- 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-run-service.protocol.d.ts +2 -2
- 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.d.ts +2 -2
- 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.d.ts +2 -2
- 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.d.ts +2 -2
- 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.d.ts +2 -2
- 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.d.ts +2 -2
- 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.protocol.d.ts +2 -2
- package/dist/runtime/subsystems/observability/observability.service.d.ts +2 -2
- 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.d.ts +2 -2
- 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.d.ts +2 -2
- 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 +653 -5444
- 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-delivery-handler.ts +1 -1
- package/runtime/subsystems/bridge/bridge-outbox-drain-hook.ts +45 -22
- package/runtime/subsystems/bridge/bridge.protocol.ts +1 -1
- package/runtime/subsystems/bridge/event-flow.service.ts +1 -1
- package/runtime/subsystems/events/event-registry.ts +77 -0
- package/runtime/subsystems/events/index.ts +12 -0
- package/runtime/subsystems/jobs/job-handler.base.ts +1 -1
- package/runtime/subsystems/jobs/job-worker.ts +17 -11
|
@@ -1,827 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
12
|
-
|
|
13
|
-
// runtime/subsystems/jobs/job-orchestrator.memory-backend.ts
|
|
14
|
-
import { randomUUID as randomUUID2 } from "crypto";
|
|
15
|
-
import { Inject as Inject2, Injectable as Injectable2, Logger, Optional } from "@nestjs/common";
|
|
16
|
-
import { ModuleRef } from "@nestjs/core";
|
|
17
|
-
|
|
18
|
-
// runtime/subsystems/token-key.ts
|
|
19
|
-
var PKG = "@pattern-stack/codegen";
|
|
20
|
-
var tokenKey = (area, name) => `${PKG}.${area}.${name}`;
|
|
21
|
-
|
|
22
|
-
// runtime/subsystems/jobs/job-handler.base.ts
|
|
23
|
-
var JOB_HANDLER_REGISTRY = /* @__PURE__ */ new Map();
|
|
24
|
-
var JOB_HANDLER_METADATA_KEY = Symbol.for(tokenKey("jobs", "handler-metadata"));
|
|
25
|
-
var HandlerRegistry;
|
|
26
|
-
((HandlerRegistry2) => {
|
|
27
|
-
function getAll() {
|
|
28
|
-
return Array.from(JOB_HANDLER_REGISTRY.values());
|
|
29
|
-
}
|
|
30
|
-
HandlerRegistry2.getAll = getAll;
|
|
31
|
-
function get(type) {
|
|
32
|
-
return JOB_HANDLER_REGISTRY.get(type);
|
|
33
|
-
}
|
|
34
|
-
HandlerRegistry2.get = get;
|
|
35
|
-
})(HandlerRegistry || (HandlerRegistry = {}));
|
|
36
|
-
|
|
37
|
-
// runtime/subsystems/jobs/jobs-errors.ts
|
|
38
|
-
var JobTypeNotFoundError = class extends Error {
|
|
39
|
-
constructor(jobType) {
|
|
40
|
-
super(`No job definition registered for type '${jobType}'.`);
|
|
41
|
-
this.jobType = jobType;
|
|
42
|
-
}
|
|
43
|
-
jobType;
|
|
44
|
-
name = "JobTypeNotFoundError";
|
|
45
|
-
};
|
|
46
|
-
var JobCollisionError = class extends Error {
|
|
47
|
-
constructor(jobType, concurrencyKey, incumbent) {
|
|
48
|
-
super(
|
|
49
|
-
`Job type '${jobType}' has an in-flight run with concurrency_key '${concurrencyKey}' (incumbent ${incumbent.id}); collision_mode=reject.`
|
|
50
|
-
);
|
|
51
|
-
this.jobType = jobType;
|
|
52
|
-
this.concurrencyKey = concurrencyKey;
|
|
53
|
-
this.incumbent = incumbent;
|
|
54
|
-
}
|
|
55
|
-
jobType;
|
|
56
|
-
concurrencyKey;
|
|
57
|
-
incumbent;
|
|
58
|
-
name = "JobCollisionError";
|
|
59
|
-
};
|
|
60
|
-
var JobNotReplayableError = class extends Error {
|
|
61
|
-
constructor(runId, currentStatus) {
|
|
62
|
-
super(
|
|
63
|
-
`Run ${runId} is not replayable from status '${currentStatus}'. Only 'completed', 'failed', 'timed_out', and 'canceled' are eligible.`
|
|
64
|
-
);
|
|
65
|
-
this.runId = runId;
|
|
66
|
-
this.currentStatus = currentStatus;
|
|
67
|
-
}
|
|
68
|
-
runId;
|
|
69
|
-
currentStatus;
|
|
70
|
-
name = "JobNotReplayableError";
|
|
71
|
-
};
|
|
72
|
-
var JobTemplateFieldMissingError = class extends Error {
|
|
73
|
-
constructor(template, field) {
|
|
74
|
-
super(
|
|
75
|
-
`Template '${template}' references input field '${field}' which is missing or undefined on the payload.`
|
|
76
|
-
);
|
|
77
|
-
this.template = template;
|
|
78
|
-
this.field = field;
|
|
79
|
-
}
|
|
80
|
-
template;
|
|
81
|
-
field;
|
|
82
|
-
name = "JobTemplateFieldMissingError";
|
|
83
|
-
};
|
|
84
|
-
var MissingTenantIdError = class extends Error {
|
|
85
|
-
constructor(method) {
|
|
86
|
-
super(
|
|
87
|
-
`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.`
|
|
88
|
-
);
|
|
89
|
-
this.method = method;
|
|
90
|
-
}
|
|
91
|
-
method;
|
|
92
|
-
name = "MissingTenantIdError";
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
// runtime/subsystems/jobs/memory-job-store.ts
|
|
96
|
-
var MemoryJobStore = class {
|
|
97
|
-
/** Runs keyed by `id` (single source of truth for status/scope/lineage). */
|
|
98
|
-
runs = /* @__PURE__ */ new Map();
|
|
99
|
-
/** Steps keyed by `job_run_id`; array order matches insertion order. */
|
|
100
|
-
steps = /* @__PURE__ */ new Map();
|
|
101
|
-
/** Job definitions keyed by `type` — memory mirror of the `job` table. */
|
|
102
|
-
jobs = /* @__PURE__ */ new Map();
|
|
103
|
-
/** Reset everything. Tests call this in `beforeEach`. */
|
|
104
|
-
clear() {
|
|
105
|
-
this.runs.clear();
|
|
106
|
-
this.steps.clear();
|
|
107
|
-
this.jobs.clear();
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
// runtime/subsystems/jobs/job-step-service.memory-backend.ts
|
|
112
|
-
import { randomUUID } from "crypto";
|
|
113
|
-
import { Inject, Injectable } from "@nestjs/common";
|
|
114
|
-
var MemoryJobStepService = class {
|
|
115
|
-
// ADR-037 (package-mode DI): explicit `@Inject(MemoryJobStore)` — the
|
|
116
|
-
// published bundle carries no `design:paramtypes`, so a by-type inject
|
|
117
|
-
// would resolve to `undefined` in package mode.
|
|
118
|
-
constructor(store) {
|
|
119
|
-
this.store = store;
|
|
120
|
-
}
|
|
121
|
-
store;
|
|
122
|
-
async findStep(runId, stepId) {
|
|
123
|
-
const rows = this.store.steps.get(runId);
|
|
124
|
-
if (!rows) return null;
|
|
125
|
-
const match = rows.find(
|
|
126
|
-
(r) => r.stepId === stepId && r.status === "completed"
|
|
127
|
-
);
|
|
128
|
-
return match ?? null;
|
|
129
|
-
}
|
|
130
|
-
async recordStep(input) {
|
|
131
|
-
const rows = this.getOrCreateRows(input.jobRunId);
|
|
132
|
-
const existingIdx = rows.findIndex((r) => r.stepId === input.stepId);
|
|
133
|
-
const normalisedInput = input.input ?? null;
|
|
134
|
-
const normalisedOutput = input.output ?? null;
|
|
135
|
-
if (existingIdx >= 0) {
|
|
136
|
-
const prev = rows[existingIdx];
|
|
137
|
-
const next = {
|
|
138
|
-
...prev,
|
|
139
|
-
status: input.status,
|
|
140
|
-
input: normalisedInput ?? prev.input,
|
|
141
|
-
output: normalisedOutput ?? prev.output,
|
|
142
|
-
error: input.error ?? prev.error,
|
|
143
|
-
attempts: input.attempts ?? prev.attempts,
|
|
144
|
-
startedAt: input.startedAt ?? prev.startedAt,
|
|
145
|
-
finishedAt: input.finishedAt ?? prev.finishedAt
|
|
146
|
-
};
|
|
147
|
-
rows[existingIdx] = next;
|
|
148
|
-
return next;
|
|
149
|
-
}
|
|
150
|
-
const seq = input.seq ?? this.nextSeq(rows);
|
|
151
|
-
const row = {
|
|
152
|
-
id: randomUUID(),
|
|
153
|
-
jobRunId: input.jobRunId,
|
|
154
|
-
stepId: input.stepId,
|
|
155
|
-
kind: input.kind,
|
|
156
|
-
seq,
|
|
157
|
-
status: input.status,
|
|
158
|
-
input: normalisedInput,
|
|
159
|
-
output: normalisedOutput,
|
|
160
|
-
error: input.error ?? null,
|
|
161
|
-
attempts: input.attempts ?? 0,
|
|
162
|
-
startedAt: input.startedAt ?? null,
|
|
163
|
-
finishedAt: input.finishedAt ?? null
|
|
164
|
-
};
|
|
165
|
-
rows.push(row);
|
|
166
|
-
return row;
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Replay helper — wipe every step row for a run. Mirrors the `scratch`
|
|
170
|
-
* replay mode of the Drizzle backend (`DELETE FROM job_step WHERE job_run_id = …`).
|
|
171
|
-
*/
|
|
172
|
-
clearStepsForRun(runId) {
|
|
173
|
-
this.store.steps.delete(runId);
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Remove every non-`completed` row for the run. Memoized (`completed`)
|
|
177
|
-
* rows are preserved — this is the `last_checkpoint` / `last_step`
|
|
178
|
-
* semantics the Drizzle backend implements via
|
|
179
|
-
* `DELETE … WHERE status != 'completed'`. Both replay modes route here
|
|
180
|
-
* (Phase 1 collapses `last_step` onto this behaviour; see JOB-3 notes).
|
|
181
|
-
*/
|
|
182
|
-
clearIncompleteSteps(runId) {
|
|
183
|
-
const rows = this.store.steps.get(runId);
|
|
184
|
-
if (!rows) return;
|
|
185
|
-
const kept = rows.filter((r) => r.status === "completed");
|
|
186
|
-
if (kept.length === 0) {
|
|
187
|
-
this.store.steps.delete(runId);
|
|
188
|
-
} else {
|
|
189
|
-
this.store.steps.set(runId, kept);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
getOrCreateRows(runId) {
|
|
193
|
-
let rows = this.store.steps.get(runId);
|
|
194
|
-
if (!rows) {
|
|
195
|
-
rows = [];
|
|
196
|
-
this.store.steps.set(runId, rows);
|
|
197
|
-
}
|
|
198
|
-
return rows;
|
|
199
|
-
}
|
|
200
|
-
nextSeq(rows) {
|
|
201
|
-
let max = 0;
|
|
202
|
-
for (const r of rows) {
|
|
203
|
-
if (r.seq > max) max = r.seq;
|
|
204
|
-
}
|
|
205
|
-
return max + 1;
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
MemoryJobStepService = __decorateClass([
|
|
209
|
-
Injectable(),
|
|
210
|
-
__decorateParam(0, Inject(MemoryJobStore))
|
|
211
|
-
], MemoryJobStepService);
|
|
212
|
-
|
|
213
|
-
// runtime/subsystems/jobs/jobs-domain.tokens.ts
|
|
214
|
-
var JOB_ORCHESTRATOR = Symbol.for(tokenKey("jobs", "orchestrator"));
|
|
215
|
-
var JOB_RUN_SERVICE = Symbol.for(tokenKey("jobs", "run-service"));
|
|
216
|
-
var JOB_STEP_SERVICE = Symbol.for(tokenKey("jobs", "step-service"));
|
|
217
|
-
var JOBS_MULTI_TENANT = Symbol.for(tokenKey("jobs", "multi-tenant"));
|
|
218
|
-
|
|
219
|
-
// runtime/subsystems/jobs/job-orchestrator.memory-backend.ts
|
|
220
|
-
var QUEUED_RUN_AT = /* @__PURE__ */ new Date(864e13);
|
|
221
|
-
var TERMINAL_STATUSES = [
|
|
222
|
-
"completed",
|
|
223
|
-
"failed",
|
|
224
|
-
"timed_out",
|
|
225
|
-
"canceled"
|
|
226
|
-
];
|
|
227
|
-
var DEDUPE_EXCLUDED_STATUSES = ["canceled", "failed"];
|
|
228
|
-
var IN_FLIGHT_STATUSES = ["pending", "running"];
|
|
229
|
-
function isTerminal(status) {
|
|
230
|
-
return TERMINAL_STATUSES.includes(status);
|
|
231
|
-
}
|
|
232
|
-
function evaluateKeyTemplate(template, input) {
|
|
233
|
-
return template.replace(
|
|
234
|
-
/\{\{\s*([a-zA-Z0-9_]+)\s*\}\}/g,
|
|
235
|
-
(_m, field) => {
|
|
236
|
-
const value = input[field];
|
|
237
|
-
if (value === void 0 || value === null) {
|
|
238
|
-
throw new JobTemplateFieldMissingError(template, field);
|
|
239
|
-
}
|
|
240
|
-
return String(value);
|
|
241
|
-
}
|
|
242
|
-
);
|
|
243
|
-
}
|
|
244
|
-
var PromiseMutex = class {
|
|
245
|
-
queue = Promise.resolve();
|
|
246
|
-
async run(fn) {
|
|
247
|
-
const next = this.queue.then(() => fn());
|
|
248
|
-
this.queue = next.then(
|
|
249
|
-
() => void 0,
|
|
250
|
-
() => void 0
|
|
251
|
-
);
|
|
252
|
-
return next;
|
|
253
|
-
}
|
|
254
|
-
};
|
|
255
|
-
var MemoryJobOrchestrator = class {
|
|
256
|
-
constructor(store, stepService, multiTenant, moduleRef) {
|
|
257
|
-
this.store = store;
|
|
258
|
-
this.stepService = stepService;
|
|
259
|
-
this.multiTenant = multiTenant;
|
|
260
|
-
this.moduleRef = moduleRef;
|
|
261
|
-
}
|
|
262
|
-
store;
|
|
263
|
-
stepService;
|
|
264
|
-
multiTenant;
|
|
265
|
-
moduleRef;
|
|
266
|
-
logger = new Logger(MemoryJobOrchestrator.name);
|
|
267
|
-
mutex = new PromiseMutex();
|
|
268
|
-
handlerRegistry = /* @__PURE__ */ new Map();
|
|
269
|
-
/**
|
|
270
|
-
* `runId → dependent runId[]` — when a run with `concurrencyKey = K`
|
|
271
|
-
* blocks on an incumbent, its id is added here under the incumbent's id.
|
|
272
|
-
* On incumbent terminal transition we advance every dependent's `runAt`
|
|
273
|
-
* back to `now()` so it becomes claimable.
|
|
274
|
-
*/
|
|
275
|
-
queueBlockers = /* @__PURE__ */ new Map();
|
|
276
|
-
/**
|
|
277
|
-
* JOB-8 — mirror of the Drizzle backend's `resolveTenantId`. Returns the
|
|
278
|
-
* value to stamp on `tenant_id` / compare against in memory predicates.
|
|
279
|
-
* Off → always `null`. On + `undefined` → throw. On + `null`/string → pass.
|
|
280
|
-
*/
|
|
281
|
-
resolveTenantId(method, tenantId) {
|
|
282
|
-
if (!this.multiTenant) return null;
|
|
283
|
-
if (tenantId === void 0) throw new MissingTenantIdError(method);
|
|
284
|
-
return tenantId;
|
|
285
|
-
}
|
|
286
|
-
// ==========================================================================
|
|
287
|
-
// registerHandler — replaces Drizzle's `job` table upsert
|
|
288
|
-
// ==========================================================================
|
|
289
|
-
/**
|
|
290
|
-
* Populate the in-memory job definition row plus handler class lookup.
|
|
291
|
-
* Called by `JobWorkerModule.onModuleInit` in memory mode, or directly by
|
|
292
|
-
* unit tests that want to seed the registry without NestJS.
|
|
293
|
-
*/
|
|
294
|
-
registerHandler(type, meta, handlerClass) {
|
|
295
|
-
const concurrencyKeyTemplate = meta.concurrency?.key ?? null;
|
|
296
|
-
const dedupeKeyTemplate = meta.dedupe?.key ?? null;
|
|
297
|
-
const dedupeWindowMs = meta.dedupe?.windowMs ?? null;
|
|
298
|
-
const now = /* @__PURE__ */ new Date();
|
|
299
|
-
const def = {
|
|
300
|
-
type,
|
|
301
|
-
version: 1,
|
|
302
|
-
pool: meta.pool ?? "batch",
|
|
303
|
-
scopeEntityType: meta.scope?.entity ?? null,
|
|
304
|
-
retryPolicy: meta.retry ?? {
|
|
305
|
-
attempts: 1,
|
|
306
|
-
backoff: "fixed",
|
|
307
|
-
baseMs: 0
|
|
308
|
-
},
|
|
309
|
-
timeoutMs: meta.timeoutMs ?? null,
|
|
310
|
-
concurrencyKeyTemplate: typeof concurrencyKeyTemplate === "string" ? concurrencyKeyTemplate : null,
|
|
311
|
-
collisionMode: meta.concurrency?.collisionMode ?? "queue",
|
|
312
|
-
dedupeKeyTemplate: typeof dedupeKeyTemplate === "string" ? dedupeKeyTemplate : null,
|
|
313
|
-
dedupeWindowMs,
|
|
314
|
-
priorityDefault: 0,
|
|
315
|
-
replayFrom: meta.replayFrom ?? "last_checkpoint",
|
|
316
|
-
createdAt: now,
|
|
317
|
-
updatedAt: now
|
|
318
|
-
};
|
|
319
|
-
this.store.jobs.set(type, def);
|
|
320
|
-
this.handlerRegistry.set(type, {
|
|
321
|
-
type,
|
|
322
|
-
meta,
|
|
323
|
-
handlerClass
|
|
324
|
-
});
|
|
325
|
-
}
|
|
326
|
-
/** Test helper — look up a registered handler without exposing the map. */
|
|
327
|
-
getHandlerRegistration(type) {
|
|
328
|
-
return this.handlerRegistry.get(type);
|
|
329
|
-
}
|
|
330
|
-
/**
|
|
331
|
-
* Boot-time upsert per `IJobOrchestrator.upsertJobRows`. Memory backend
|
|
332
|
-
* just funnels each entry through `registerHandler`. The validator is
|
|
333
|
-
* skipped entirely in memory mode (Q4 resolution 2026-04-19), so the
|
|
334
|
-
* orphaned list is always empty — there are no DB rows to compare against.
|
|
335
|
-
*/
|
|
336
|
-
async upsertJobRows(entries, poolConfig) {
|
|
337
|
-
void poolConfig;
|
|
338
|
-
for (const entry of entries) {
|
|
339
|
-
this.registerHandler(
|
|
340
|
-
entry.type,
|
|
341
|
-
entry.meta,
|
|
342
|
-
entry.handlerClass
|
|
343
|
-
);
|
|
344
|
-
}
|
|
345
|
-
return { orphaned: [] };
|
|
346
|
-
}
|
|
347
|
-
// ==========================================================================
|
|
348
|
-
// start
|
|
349
|
-
// ==========================================================================
|
|
350
|
-
async start(type, input, opts = {}, _tx) {
|
|
351
|
-
const tenantId = this.resolveTenantId("start", opts.tenantId);
|
|
352
|
-
return this.mutex.run(async () => {
|
|
353
|
-
const payload = input ?? {};
|
|
354
|
-
const definition = this.store.jobs.get(type);
|
|
355
|
-
if (!definition) throw new JobTypeNotFoundError(type);
|
|
356
|
-
if (definition.dedupeKeyTemplate && definition.dedupeWindowMs) {
|
|
357
|
-
const dedupeKey2 = evaluateKeyTemplate(
|
|
358
|
-
definition.dedupeKeyTemplate,
|
|
359
|
-
payload
|
|
360
|
-
);
|
|
361
|
-
const windowStart = Date.now() - definition.dedupeWindowMs;
|
|
362
|
-
const existing = this.findDedupeCandidate(type, dedupeKey2, windowStart);
|
|
363
|
-
if (existing) return existing;
|
|
364
|
-
}
|
|
365
|
-
let concurrencyKey = null;
|
|
366
|
-
let queueBlockedBy = null;
|
|
367
|
-
if (definition.concurrencyKeyTemplate) {
|
|
368
|
-
concurrencyKey = evaluateKeyTemplate(
|
|
369
|
-
definition.concurrencyKeyTemplate,
|
|
370
|
-
payload
|
|
371
|
-
);
|
|
372
|
-
const incumbent = this.findInFlightByConcurrencyKey(concurrencyKey);
|
|
373
|
-
if (incumbent) {
|
|
374
|
-
switch (definition.collisionMode) {
|
|
375
|
-
case "reject":
|
|
376
|
-
throw new JobCollisionError(type, concurrencyKey, incumbent);
|
|
377
|
-
case "replace":
|
|
378
|
-
this.cancelLocked(
|
|
379
|
-
incumbent.id,
|
|
380
|
-
{ cascade: true, reason: "replaced" },
|
|
381
|
-
incumbent.tenantId
|
|
382
|
-
);
|
|
383
|
-
break;
|
|
384
|
-
case "queue":
|
|
385
|
-
queueBlockedBy = incumbent.id;
|
|
386
|
-
break;
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
const newId = randomUUID2();
|
|
391
|
-
let rootRunId = newId;
|
|
392
|
-
if (opts.parentRunId) {
|
|
393
|
-
const parent = this.store.runs.get(opts.parentRunId);
|
|
394
|
-
if (!parent) {
|
|
395
|
-
throw new Error(
|
|
396
|
-
`parentRunId ${opts.parentRunId} does not reference an existing job_run`
|
|
397
|
-
);
|
|
398
|
-
}
|
|
399
|
-
rootRunId = parent.rootRunId;
|
|
400
|
-
}
|
|
401
|
-
const dedupeKey = definition.dedupeKeyTemplate ? evaluateKeyTemplate(definition.dedupeKeyTemplate, payload) : null;
|
|
402
|
-
const now = /* @__PURE__ */ new Date();
|
|
403
|
-
const runAt = queueBlockedBy ? QUEUED_RUN_AT : opts.runAt ?? now;
|
|
404
|
-
const row = {
|
|
405
|
-
id: newId,
|
|
406
|
-
jobType: type,
|
|
407
|
-
jobVersion: definition.version,
|
|
408
|
-
parentRunId: opts.parentRunId ?? null,
|
|
409
|
-
rootRunId,
|
|
410
|
-
parentClosePolicy: opts.parentClosePolicy ?? "terminate",
|
|
411
|
-
scopeEntityType: opts.scope?.entityType ?? null,
|
|
412
|
-
scopeEntityId: opts.scope?.entityId ?? null,
|
|
413
|
-
tenantId,
|
|
414
|
-
tags: opts.tags ?? {},
|
|
415
|
-
pool: opts.pool ?? definition.pool,
|
|
416
|
-
priority: opts.priority ?? definition.priorityDefault,
|
|
417
|
-
concurrencyKey,
|
|
418
|
-
dedupeKey,
|
|
419
|
-
status: "pending",
|
|
420
|
-
input: payload,
|
|
421
|
-
output: null,
|
|
422
|
-
error: null,
|
|
423
|
-
triggerSource: opts.triggerSource ?? "manual",
|
|
424
|
-
triggerRef: opts.triggerRef ?? null,
|
|
425
|
-
runAt,
|
|
426
|
-
startedAt: null,
|
|
427
|
-
finishedAt: null,
|
|
428
|
-
claimedAt: null,
|
|
429
|
-
attempts: 0,
|
|
430
|
-
waitKind: null,
|
|
431
|
-
resumeToken: null,
|
|
432
|
-
waitDeadline: null,
|
|
433
|
-
createdAt: now,
|
|
434
|
-
updatedAt: now
|
|
435
|
-
};
|
|
436
|
-
this.store.runs.set(newId, row);
|
|
437
|
-
if (queueBlockedBy) {
|
|
438
|
-
const list = this.queueBlockers.get(queueBlockedBy) ?? [];
|
|
439
|
-
list.push(newId);
|
|
440
|
-
this.queueBlockers.set(queueBlockedBy, list);
|
|
441
|
-
}
|
|
442
|
-
return row;
|
|
443
|
-
});
|
|
444
|
-
}
|
|
445
|
-
// ==========================================================================
|
|
446
|
-
// cancel
|
|
447
|
-
// ==========================================================================
|
|
448
|
-
async cancel(runId, opts = {}) {
|
|
449
|
-
const tenantId = this.resolveTenantId("cancel", opts.tenantId);
|
|
450
|
-
await this.mutex.run(async () => {
|
|
451
|
-
this.cancelLocked(runId, opts, tenantId);
|
|
452
|
-
});
|
|
453
|
-
}
|
|
454
|
-
/**
|
|
455
|
-
* Internal cancel that assumes the caller already holds the mutex.
|
|
456
|
-
* Synchronous because all store ops are in-memory. Idempotent.
|
|
457
|
-
*
|
|
458
|
-
* `tenantForGate` is the already-validated tenant id (or `null`). When
|
|
459
|
-
* non-null it gates the initial cancellation to that tenant's run; the
|
|
460
|
-
* cascade step then sweeps descendants on the same `rootRunId` without
|
|
461
|
-
* re-checking — children of a tenant-gated parent always share the
|
|
462
|
-
* tenant (enforced at `start` time).
|
|
463
|
-
*/
|
|
464
|
-
cancelLocked(runId, opts, tenantForGate) {
|
|
465
|
-
const run = this.store.runs.get(runId);
|
|
466
|
-
if (!run) return;
|
|
467
|
-
if (this.multiTenant && run.tenantId !== tenantForGate) return;
|
|
468
|
-
if (isTerminal(run.status)) return;
|
|
469
|
-
const now = /* @__PURE__ */ new Date();
|
|
470
|
-
const descendants = opts.cascade === false ? [] : Array.from(this.store.runs.values()).filter(
|
|
471
|
-
(r) => r.rootRunId === run.rootRunId && r.id !== runId && !isTerminal(r.status)
|
|
472
|
-
);
|
|
473
|
-
const terminateChildren = descendants.filter(
|
|
474
|
-
(d) => d.parentClosePolicy === "terminate" /* Terminate */
|
|
475
|
-
);
|
|
476
|
-
const cancelChildren = descendants.filter(
|
|
477
|
-
(d) => d.parentClosePolicy === "cancel" /* Cancel */
|
|
478
|
-
);
|
|
479
|
-
for (const child of terminateChildren) {
|
|
480
|
-
this.transitionToCanceled(child.id, now);
|
|
481
|
-
}
|
|
482
|
-
for (const child of cancelChildren) {
|
|
483
|
-
this.transitionToCanceled(child.id, now);
|
|
484
|
-
}
|
|
485
|
-
this.transitionToCanceled(runId, now);
|
|
486
|
-
void opts.reason;
|
|
487
|
-
}
|
|
488
|
-
transitionToCanceled(runId, at) {
|
|
489
|
-
const run = this.store.runs.get(runId);
|
|
490
|
-
if (!run) return;
|
|
491
|
-
if (isTerminal(run.status)) return;
|
|
492
|
-
const next = {
|
|
493
|
-
...run,
|
|
494
|
-
status: "canceled",
|
|
495
|
-
finishedAt: at,
|
|
496
|
-
updatedAt: at
|
|
497
|
-
};
|
|
498
|
-
this.store.runs.set(runId, next);
|
|
499
|
-
this.unblockQueuedDependents(runId);
|
|
500
|
-
}
|
|
501
|
-
/**
|
|
502
|
-
* When `runId` transitions to a terminal state, advance every dependent
|
|
503
|
-
* `queue`-blocked run's `run_at` back to `now()` so `claimNext` picks
|
|
504
|
-
* them up.
|
|
505
|
-
*/
|
|
506
|
-
unblockQueuedDependents(runId) {
|
|
507
|
-
const dependents = this.queueBlockers.get(runId);
|
|
508
|
-
if (!dependents || dependents.length === 0) return;
|
|
509
|
-
const now = /* @__PURE__ */ new Date();
|
|
510
|
-
for (const dep of dependents) {
|
|
511
|
-
const depRun = this.store.runs.get(dep);
|
|
512
|
-
if (!depRun) continue;
|
|
513
|
-
if (depRun.status !== "pending") continue;
|
|
514
|
-
this.store.runs.set(dep, { ...depRun, runAt: now, updatedAt: now });
|
|
515
|
-
}
|
|
516
|
-
this.queueBlockers.delete(runId);
|
|
517
|
-
}
|
|
518
|
-
// ==========================================================================
|
|
519
|
-
// claimNext — consumed by JobWorker in memory mode (tests exercise directly)
|
|
520
|
-
// ==========================================================================
|
|
521
|
-
async claimNext(pool) {
|
|
522
|
-
return this.mutex.run(async () => {
|
|
523
|
-
const now = Date.now();
|
|
524
|
-
const candidates = Array.from(this.store.runs.values()).filter(
|
|
525
|
-
(r) => r.status === "pending" && r.pool === pool && r.runAt.getTime() <= now
|
|
526
|
-
);
|
|
527
|
-
if (candidates.length === 0) return null;
|
|
528
|
-
candidates.sort((a, b) => {
|
|
529
|
-
if (a.priority !== b.priority) return b.priority - a.priority;
|
|
530
|
-
return a.runAt.getTime() - b.runAt.getTime();
|
|
531
|
-
});
|
|
532
|
-
const winner = candidates[0];
|
|
533
|
-
const claimedAt = /* @__PURE__ */ new Date();
|
|
534
|
-
const next = {
|
|
535
|
-
...winner,
|
|
536
|
-
status: "running",
|
|
537
|
-
claimedAt,
|
|
538
|
-
startedAt: claimedAt,
|
|
539
|
-
updatedAt: claimedAt
|
|
540
|
-
};
|
|
541
|
-
this.store.runs.set(winner.id, next);
|
|
542
|
-
return next;
|
|
543
|
-
});
|
|
544
|
-
}
|
|
545
|
-
// ==========================================================================
|
|
546
|
-
// replay
|
|
547
|
-
// ==========================================================================
|
|
548
|
-
async replay(runId) {
|
|
549
|
-
return this.mutex.run(async () => {
|
|
550
|
-
const run = this.store.runs.get(runId);
|
|
551
|
-
if (!run) throw new Error(`replay: run ${runId} not found`);
|
|
552
|
-
if (!isTerminal(run.status)) {
|
|
553
|
-
throw new JobNotReplayableError(runId, run.status);
|
|
554
|
-
}
|
|
555
|
-
const def = this.store.jobs.get(run.jobType);
|
|
556
|
-
if (!def) throw new JobTypeNotFoundError(run.jobType);
|
|
557
|
-
const mode = def.replayFrom;
|
|
558
|
-
if (mode === "scratch") {
|
|
559
|
-
this.stepService.clearStepsForRun(runId);
|
|
560
|
-
} else {
|
|
561
|
-
this.stepService.clearIncompleteSteps(runId);
|
|
562
|
-
}
|
|
563
|
-
const now = /* @__PURE__ */ new Date();
|
|
564
|
-
const next = {
|
|
565
|
-
...run,
|
|
566
|
-
status: "pending",
|
|
567
|
-
attempts: 0,
|
|
568
|
-
runAt: now,
|
|
569
|
-
startedAt: null,
|
|
570
|
-
finishedAt: null,
|
|
571
|
-
claimedAt: null,
|
|
572
|
-
error: null,
|
|
573
|
-
output: null,
|
|
574
|
-
updatedAt: now
|
|
575
|
-
};
|
|
576
|
-
this.store.runs.set(runId, next);
|
|
577
|
-
return next;
|
|
578
|
-
});
|
|
579
|
-
}
|
|
580
|
-
// ==========================================================================
|
|
581
|
-
// tick — used by unit tests + memory-mode JobWorker
|
|
582
|
-
// ==========================================================================
|
|
583
|
-
/**
|
|
584
|
-
* Execute a single claimed run to completion, retry, or failure. Not on
|
|
585
|
-
* `IJobOrchestrator` — it's the memory equivalent of the Drizzle
|
|
586
|
-
* `JobWorker.processRun` code path. The unit tests drive it directly so
|
|
587
|
-
* they can assert memoization across ticks without spinning up a worker.
|
|
588
|
-
*/
|
|
589
|
-
async tick(runId) {
|
|
590
|
-
const run = this.store.runs.get(runId);
|
|
591
|
-
if (!run) throw new Error(`tick: run ${runId} not found`);
|
|
592
|
-
if (run.status !== "running") {
|
|
593
|
-
throw new Error(
|
|
594
|
-
`tick: run ${runId} must be 'running' (got '${run.status}')`
|
|
595
|
-
);
|
|
596
|
-
}
|
|
597
|
-
const registration = this.handlerRegistry.get(run.jobType);
|
|
598
|
-
if (!registration) {
|
|
599
|
-
await this.markFailed(run, new Error(
|
|
600
|
-
`No handler registered for jobType='${run.jobType}'`
|
|
601
|
-
), (run.attempts ?? 0) + 1);
|
|
602
|
-
return;
|
|
603
|
-
}
|
|
604
|
-
const meta = registration.meta;
|
|
605
|
-
const HandlerClass = registration.handlerClass;
|
|
606
|
-
const handler = this.moduleRef ? this.moduleRef.get(
|
|
607
|
-
HandlerClass,
|
|
608
|
-
{ strict: false }
|
|
609
|
-
) : new HandlerClass();
|
|
610
|
-
const ctx = {
|
|
611
|
-
input: run.input,
|
|
612
|
-
run,
|
|
613
|
-
step: this.makeStepFn(run),
|
|
614
|
-
spawnChild: this.makeSpawnFn(run),
|
|
615
|
-
logger: new Logger(`JobRun:${run.id}`)
|
|
616
|
-
};
|
|
617
|
-
const attemptsBefore = run.attempts ?? 0;
|
|
618
|
-
try {
|
|
619
|
-
const output = await handler.run(ctx);
|
|
620
|
-
await this.markCompleted(run, output ?? {}, attemptsBefore + 1);
|
|
621
|
-
} catch (err) {
|
|
622
|
-
const policy = meta.retry;
|
|
623
|
-
const decision = classifyError(err, policy, attemptsBefore);
|
|
624
|
-
const nextAttempts = attemptsBefore + 1;
|
|
625
|
-
if (decision === "retry" && policy) {
|
|
626
|
-
const delay = computeBackoff(policy, nextAttempts);
|
|
627
|
-
await this.rescheduleForRetry(run, err, nextAttempts, delay);
|
|
628
|
-
} else {
|
|
629
|
-
await this.markFailed(run, err, nextAttempts);
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
makeStepFn(run) {
|
|
634
|
-
return async (stepId, fn, _opts) => {
|
|
635
|
-
void _opts;
|
|
636
|
-
const existing = await this.stepService.findStep(run.id, stepId);
|
|
637
|
-
if (existing?.status === "completed") {
|
|
638
|
-
return existing.output;
|
|
639
|
-
}
|
|
640
|
-
const seq = this.nextStepSeq(run.id);
|
|
641
|
-
const startedAt = /* @__PURE__ */ new Date();
|
|
642
|
-
const nextAttempts = (existing?.attempts ?? 0) + 1;
|
|
643
|
-
await this.stepService.recordStep({
|
|
644
|
-
jobRunId: run.id,
|
|
645
|
-
stepId,
|
|
646
|
-
kind: "task",
|
|
647
|
-
seq,
|
|
648
|
-
status: "running",
|
|
649
|
-
startedAt,
|
|
650
|
-
attempts: nextAttempts
|
|
651
|
-
});
|
|
652
|
-
try {
|
|
653
|
-
const output = await fn();
|
|
654
|
-
await this.stepService.recordStep({
|
|
655
|
-
jobRunId: run.id,
|
|
656
|
-
stepId,
|
|
657
|
-
kind: "task",
|
|
658
|
-
seq,
|
|
659
|
-
status: "completed",
|
|
660
|
-
output,
|
|
661
|
-
finishedAt: /* @__PURE__ */ new Date(),
|
|
662
|
-
attempts: nextAttempts
|
|
663
|
-
});
|
|
664
|
-
return output;
|
|
665
|
-
} catch (err) {
|
|
666
|
-
await this.stepService.recordStep({
|
|
667
|
-
jobRunId: run.id,
|
|
668
|
-
stepId,
|
|
669
|
-
kind: "task",
|
|
670
|
-
seq,
|
|
671
|
-
status: "failed",
|
|
672
|
-
error: serialiseError(err, nextAttempts, false),
|
|
673
|
-
finishedAt: /* @__PURE__ */ new Date(),
|
|
674
|
-
attempts: nextAttempts
|
|
675
|
-
});
|
|
676
|
-
throw err;
|
|
677
|
-
}
|
|
678
|
-
};
|
|
679
|
-
}
|
|
680
|
-
makeSpawnFn(run) {
|
|
681
|
-
return async (type, input, opts) => {
|
|
682
|
-
return this.start(type, input, {
|
|
683
|
-
parentRunId: run.id,
|
|
684
|
-
parentClosePolicy: opts?.closePolicy,
|
|
685
|
-
runAt: opts?.runAt,
|
|
686
|
-
priority: opts?.priority,
|
|
687
|
-
tags: opts?.tags,
|
|
688
|
-
triggerSource: "parent",
|
|
689
|
-
triggerRef: run.id
|
|
690
|
-
});
|
|
691
|
-
};
|
|
692
|
-
}
|
|
693
|
-
nextStepSeq(runId) {
|
|
694
|
-
const rows = this.store.steps.get(runId);
|
|
695
|
-
if (!rows || rows.length === 0) return 1;
|
|
696
|
-
let max = 0;
|
|
697
|
-
for (const r of rows) if (r.seq > max) max = r.seq;
|
|
698
|
-
return max + 1;
|
|
699
|
-
}
|
|
700
|
-
async markCompleted(run, output, attempts) {
|
|
701
|
-
await this.mutex.run(async () => {
|
|
702
|
-
const current = this.store.runs.get(run.id);
|
|
703
|
-
if (!current || isTerminal(current.status)) return;
|
|
704
|
-
const now = /* @__PURE__ */ new Date();
|
|
705
|
-
this.store.runs.set(run.id, {
|
|
706
|
-
...current,
|
|
707
|
-
status: "completed",
|
|
708
|
-
output,
|
|
709
|
-
finishedAt: now,
|
|
710
|
-
updatedAt: now,
|
|
711
|
-
attempts
|
|
712
|
-
});
|
|
713
|
-
this.unblockQueuedDependents(run.id);
|
|
714
|
-
});
|
|
715
|
-
}
|
|
716
|
-
async markFailed(run, err, attempts) {
|
|
717
|
-
await this.mutex.run(async () => {
|
|
718
|
-
const current = this.store.runs.get(run.id);
|
|
719
|
-
if (!current || isTerminal(current.status)) return;
|
|
720
|
-
const now = /* @__PURE__ */ new Date();
|
|
721
|
-
this.store.runs.set(run.id, {
|
|
722
|
-
...current,
|
|
723
|
-
status: "failed",
|
|
724
|
-
finishedAt: now,
|
|
725
|
-
updatedAt: now,
|
|
726
|
-
attempts,
|
|
727
|
-
error: serialiseError(err, attempts, false)
|
|
728
|
-
});
|
|
729
|
-
this.unblockQueuedDependents(run.id);
|
|
730
|
-
});
|
|
731
|
-
if (run.parentClosePolicy === "terminate") {
|
|
732
|
-
try {
|
|
733
|
-
await this.cancel(run.id, {
|
|
734
|
-
cascade: true,
|
|
735
|
-
reason: "parent-failed",
|
|
736
|
-
tenantId: run.tenantId
|
|
737
|
-
});
|
|
738
|
-
} catch (cascadeErr) {
|
|
739
|
-
this.logger.warn(
|
|
740
|
-
`cascade on failed run ${run.id}: ${cascadeErr.message}`
|
|
741
|
-
);
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
async rescheduleForRetry(run, err, attempts, delayMs) {
|
|
746
|
-
await this.mutex.run(async () => {
|
|
747
|
-
const current = this.store.runs.get(run.id);
|
|
748
|
-
if (!current || isTerminal(current.status)) return;
|
|
749
|
-
const now = /* @__PURE__ */ new Date();
|
|
750
|
-
this.store.runs.set(run.id, {
|
|
751
|
-
...current,
|
|
752
|
-
status: "pending",
|
|
753
|
-
attempts,
|
|
754
|
-
runAt: new Date(Date.now() + delayMs),
|
|
755
|
-
startedAt: null,
|
|
756
|
-
claimedAt: null,
|
|
757
|
-
updatedAt: now,
|
|
758
|
-
error: serialiseError(err, attempts, true)
|
|
759
|
-
});
|
|
760
|
-
});
|
|
761
|
-
}
|
|
762
|
-
// ==========================================================================
|
|
763
|
-
// Internal queries — used by start / cancel
|
|
764
|
-
// ==========================================================================
|
|
765
|
-
findDedupeCandidate(jobType, dedupeKey, windowStartMs) {
|
|
766
|
-
let best = null;
|
|
767
|
-
for (const r of this.store.runs.values()) {
|
|
768
|
-
if (r.jobType !== jobType) continue;
|
|
769
|
-
if (r.dedupeKey !== dedupeKey) continue;
|
|
770
|
-
if (DEDUPE_EXCLUDED_STATUSES.includes(r.status)) continue;
|
|
771
|
-
if (r.createdAt.getTime() <= windowStartMs) continue;
|
|
772
|
-
if (!best || r.createdAt.getTime() > best.createdAt.getTime()) {
|
|
773
|
-
best = r;
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
return best;
|
|
777
|
-
}
|
|
778
|
-
findInFlightByConcurrencyKey(key) {
|
|
779
|
-
for (const r of this.store.runs.values()) {
|
|
780
|
-
if (r.concurrencyKey !== key) continue;
|
|
781
|
-
if (!IN_FLIGHT_STATUSES.includes(r.status)) continue;
|
|
782
|
-
return r;
|
|
783
|
-
}
|
|
784
|
-
return null;
|
|
785
|
-
}
|
|
786
|
-
};
|
|
787
|
-
MemoryJobOrchestrator = __decorateClass([
|
|
788
|
-
Injectable2(),
|
|
789
|
-
__decorateParam(0, Inject2(MemoryJobStore)),
|
|
790
|
-
__decorateParam(1, Inject2(MemoryJobStepService)),
|
|
791
|
-
__decorateParam(2, Inject2(JOBS_MULTI_TENANT)),
|
|
792
|
-
__decorateParam(3, Optional()),
|
|
793
|
-
__decorateParam(3, Inject2(ModuleRef))
|
|
794
|
-
], MemoryJobOrchestrator);
|
|
795
|
-
function classifyError(err, policy, currentAttempts) {
|
|
796
|
-
if (!policy) return "fail";
|
|
797
|
-
const errObj = err;
|
|
798
|
-
const name = errObj?.name;
|
|
799
|
-
const code = errObj?.code;
|
|
800
|
-
const nonRetryable = policy.nonRetryableErrors ?? [];
|
|
801
|
-
if (nonRetryable.some((n) => n === name || n === code)) return "fail";
|
|
802
|
-
if (currentAttempts + 1 >= policy.attempts) return "fail";
|
|
803
|
-
return "retry";
|
|
804
|
-
}
|
|
805
|
-
function computeBackoff(policy, attempts) {
|
|
806
|
-
const base = Math.max(policy.baseMs, 0);
|
|
807
|
-
if (policy.backoff === "fixed") return base;
|
|
808
|
-
const exponent = Math.max(attempts - 1, 0);
|
|
809
|
-
if (exponent >= 53) return Number.MAX_SAFE_INTEGER;
|
|
810
|
-
const raw = base * Math.pow(2, exponent);
|
|
811
|
-
if (!Number.isFinite(raw) || raw >= Number.MAX_SAFE_INTEGER) {
|
|
812
|
-
return Number.MAX_SAFE_INTEGER;
|
|
813
|
-
}
|
|
814
|
-
return raw;
|
|
815
|
-
}
|
|
816
|
-
function serialiseError(err, attempt, retryable) {
|
|
817
|
-
const e = err;
|
|
818
|
-
return {
|
|
819
|
-
message: e?.message ?? String(err),
|
|
820
|
-
stack: e?.stack,
|
|
821
|
-
retryable,
|
|
822
|
-
attempt
|
|
823
|
-
};
|
|
824
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
MemoryJobOrchestrator
|
|
3
|
+
} from "../../../chunk-4RFHUZXU.js";
|
|
4
|
+
import "../../../chunk-PNZSGAB2.js";
|
|
5
|
+
import "../../../chunk-SNQ3TOWP.js";
|
|
6
|
+
import "../../../chunk-T4BIIU5E.js";
|
|
7
|
+
import "../../../chunk-CO6LUM72.js";
|
|
8
|
+
import "../../../chunk-BIO6F7YI.js";
|
|
9
|
+
import "../../../chunk-GYGNEQSC.js";
|
|
10
|
+
import "../../../chunk-2E224ZSN.js";
|
|
825
11
|
export {
|
|
826
12
|
MemoryJobOrchestrator
|
|
827
13
|
};
|