@decaf-ts/core 0.17.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/auth/constants.cjs +2 -2
- package/lib/cjs/auth/constants.cjs.map +1 -0
- package/lib/cjs/auth/decorators.cjs +1 -0
- package/lib/cjs/auth/decorators.cjs.map +1 -0
- package/lib/cjs/auth/index.cjs +1 -0
- package/lib/cjs/auth/index.cjs.map +1 -0
- package/lib/cjs/fs/FilesystemAdapter.cjs +40 -39
- package/lib/cjs/fs/FilesystemAdapter.cjs.map +1 -0
- package/lib/cjs/fs/FsDispatch.cjs +3 -2
- package/lib/cjs/fs/FsDispatch.cjs.map +1 -0
- package/lib/cjs/fs/helpers.cjs +1 -0
- package/lib/cjs/fs/helpers.cjs.map +1 -0
- package/lib/cjs/fs/index.cjs +1 -0
- package/lib/cjs/fs/index.cjs.map +1 -0
- package/lib/cjs/fs/indexStore.cjs +8 -7
- package/lib/cjs/fs/indexStore.cjs.map +1 -0
- package/lib/cjs/fs/locks/FilesystemLock.cjs +3 -2
- package/lib/cjs/fs/locks/FilesystemLock.cjs.map +1 -0
- package/lib/cjs/fs/locks/FilesystemMultiLock.cjs +5 -4
- package/lib/cjs/fs/locks/FilesystemMultiLock.cjs.map +1 -0
- package/lib/cjs/fs/types.cjs +1 -0
- package/lib/cjs/fs/types.cjs.map +1 -0
- package/lib/cjs/identity/decorators.cjs +11 -10
- package/lib/cjs/identity/decorators.cjs.map +1 -0
- package/lib/cjs/identity/index.cjs +1 -0
- package/lib/cjs/identity/index.cjs.map +1 -0
- package/lib/cjs/index.cjs +4 -3
- package/lib/cjs/index.cjs.map +1 -0
- package/lib/cjs/interfaces/ContextuallyLogged.cjs +1 -0
- package/lib/cjs/interfaces/ContextuallyLogged.cjs.map +1 -0
- package/lib/cjs/interfaces/ErrorParser.cjs +1 -0
- package/lib/cjs/interfaces/ErrorParser.cjs.map +1 -0
- package/lib/cjs/interfaces/Executor.cjs +1 -0
- package/lib/cjs/interfaces/Executor.cjs.map +1 -0
- package/lib/cjs/interfaces/Observable.cjs +1 -0
- package/lib/cjs/interfaces/Observable.cjs.map +1 -0
- package/lib/cjs/interfaces/Observer.cjs +1 -0
- package/lib/cjs/interfaces/Observer.cjs.map +1 -0
- package/lib/cjs/interfaces/Paginatable.cjs +1 -0
- package/lib/cjs/interfaces/Paginatable.cjs.map +1 -0
- package/lib/cjs/interfaces/Queriable.cjs +1 -0
- package/lib/cjs/interfaces/Queriable.cjs.map +1 -0
- package/lib/cjs/interfaces/RawExecutor.cjs +1 -0
- package/lib/cjs/interfaces/RawExecutor.cjs.map +1 -0
- package/lib/cjs/interfaces/SequenceOptions.cjs +1 -0
- package/lib/cjs/interfaces/SequenceOptions.cjs.map +1 -0
- package/lib/cjs/interfaces/index.cjs +1 -0
- package/lib/cjs/interfaces/index.cjs.map +1 -0
- package/lib/cjs/migrations/Migration.cjs +16 -15
- package/lib/cjs/migrations/Migration.cjs.map +1 -0
- package/lib/cjs/migrations/MigrationService.cjs +38 -37
- package/lib/cjs/migrations/MigrationService.cjs.map +1 -0
- package/lib/cjs/migrations/MigrationTaskBuilder.cjs +3 -2
- package/lib/cjs/migrations/MigrationTaskBuilder.cjs.map +1 -0
- package/lib/cjs/migrations/MigrationTasks.cjs +22 -17
- package/lib/cjs/migrations/MigrationTasks.cjs.map +1 -0
- package/lib/cjs/migrations/MigrationVersioning.cjs +1 -0
- package/lib/cjs/migrations/MigrationVersioning.cjs.map +1 -0
- package/lib/cjs/migrations/SemverMigrationVersioning.cjs +1 -0
- package/lib/cjs/migrations/SemverMigrationVersioning.cjs.map +1 -0
- package/lib/cjs/migrations/StandardMigrationVersioning.cjs +1 -0
- package/lib/cjs/migrations/StandardMigrationVersioning.cjs.map +1 -0
- package/lib/cjs/migrations/constants.cjs +3 -2
- package/lib/cjs/migrations/constants.cjs.map +1 -0
- package/lib/cjs/migrations/decorators.cjs +10 -9
- package/lib/cjs/migrations/decorators.cjs.map +1 -0
- package/lib/cjs/migrations/index.cjs +6 -5
- package/lib/cjs/migrations/index.cjs.map +1 -0
- package/lib/cjs/migrations/types.cjs +1 -0
- package/lib/cjs/migrations/types.cjs.map +1 -0
- package/lib/cjs/model/BaseModel.cjs +14 -8
- package/lib/cjs/model/BaseModel.cjs.map +1 -0
- package/lib/cjs/model/SequenceModel.cjs +19 -13
- package/lib/cjs/model/SequenceModel.cjs.map +1 -0
- package/lib/cjs/model/construction.cjs +27 -26
- package/lib/cjs/model/construction.cjs.map +1 -0
- package/lib/cjs/model/decorators.cjs +48 -47
- package/lib/cjs/model/decorators.cjs.map +1 -0
- package/lib/cjs/model/index.cjs +1 -0
- package/lib/cjs/model/index.cjs.map +1 -0
- package/lib/cjs/model/indexing.cjs +6 -5
- package/lib/cjs/model/indexing.cjs.map +1 -0
- package/lib/cjs/model/types.cjs +1 -0
- package/lib/cjs/model/types.cjs.map +1 -0
- package/lib/cjs/overrides/Metadata.cjs +1 -0
- package/lib/cjs/overrides/Metadata.cjs.map +1 -0
- package/lib/cjs/overrides/Model.cjs +1 -0
- package/lib/cjs/overrides/Model.cjs.map +1 -0
- package/lib/cjs/overrides/ModelBuilder.cjs +1 -0
- package/lib/cjs/overrides/ModelBuilder.cjs.map +1 -0
- package/lib/cjs/overrides/index.cjs +1 -0
- package/lib/cjs/overrides/index.cjs.map +1 -0
- package/lib/cjs/overrides/injectables.cjs +1 -0
- package/lib/cjs/overrides/injectables.cjs.map +1 -0
- package/lib/cjs/overrides/overrides.cjs +22 -21
- package/lib/cjs/overrides/overrides.cjs.map +1 -0
- package/lib/cjs/persistence/Adapter.cjs +47 -41
- package/lib/cjs/persistence/Adapter.cjs.map +1 -0
- package/lib/cjs/persistence/Context.cjs +10 -7
- package/lib/cjs/persistence/Context.cjs.map +1 -0
- package/lib/cjs/persistence/ContextLock.cjs +1 -0
- package/lib/cjs/persistence/ContextLock.cjs.map +1 -0
- package/lib/cjs/persistence/Dispatch.cjs +15 -14
- package/lib/cjs/persistence/Dispatch.cjs.map +1 -0
- package/lib/cjs/persistence/ObserverHandler.cjs +3 -2
- package/lib/cjs/persistence/ObserverHandler.cjs.map +1 -0
- package/lib/cjs/persistence/Sequence.cjs +19 -18
- package/lib/cjs/persistence/Sequence.cjs.map +1 -0
- package/lib/cjs/persistence/constants.cjs +14 -21
- package/lib/cjs/persistence/constants.cjs.map +1 -0
- package/lib/cjs/persistence/decorators.cjs +6 -5
- package/lib/cjs/persistence/decorators.cjs.map +1 -0
- package/lib/cjs/persistence/errors.cjs +1 -0
- package/lib/cjs/persistence/errors.cjs.map +1 -0
- package/lib/cjs/persistence/event-filters.cjs +5 -4
- package/lib/cjs/persistence/event-filters.cjs.map +1 -0
- package/lib/cjs/persistence/generators.cjs +1 -0
- package/lib/cjs/persistence/generators.cjs.map +1 -0
- package/lib/cjs/persistence/index.cjs +1 -0
- package/lib/cjs/persistence/index.cjs.map +1 -0
- package/lib/cjs/persistence/transactions.cjs +9 -8
- package/lib/cjs/persistence/transactions.cjs.map +1 -0
- package/lib/cjs/persistence/types.cjs +1 -0
- package/lib/cjs/persistence/types.cjs.map +1 -0
- package/lib/cjs/query/Condition.cjs +173 -165
- package/lib/cjs/query/Condition.cjs.map +1 -0
- package/lib/cjs/query/MethodQueryBuilder.cjs +37 -34
- package/lib/cjs/query/MethodQueryBuilder.cjs.map +1 -0
- package/lib/cjs/query/Paginator.cjs +28 -27
- package/lib/cjs/query/Paginator.cjs.map +1 -0
- package/lib/cjs/query/Statement.cjs +90 -84
- package/lib/cjs/query/Statement.cjs.map +1 -0
- package/lib/cjs/query/constants.cjs +5 -21
- package/lib/cjs/query/constants.cjs.map +1 -0
- package/lib/cjs/query/decorators.cjs +16 -15
- package/lib/cjs/query/decorators.cjs.map +1 -0
- package/lib/cjs/query/errors.cjs +1 -0
- package/lib/cjs/query/errors.cjs.map +1 -0
- package/lib/cjs/query/index.cjs +1 -0
- package/lib/cjs/query/index.cjs.map +1 -0
- package/lib/cjs/query/options.cjs +1 -0
- package/lib/cjs/query/options.cjs.map +1 -0
- package/lib/cjs/query/selectors.cjs +1 -0
- package/lib/cjs/query/selectors.cjs.map +1 -0
- package/lib/cjs/query/types.cjs +2 -13
- package/lib/cjs/query/types.cjs.map +1 -0
- package/lib/cjs/query/utils.cjs +10 -9
- package/lib/cjs/query/utils.cjs.map +1 -0
- package/lib/cjs/ram/RamAdapter.cjs +21 -20
- package/lib/cjs/ram/RamAdapter.cjs.map +1 -0
- package/lib/cjs/ram/RamPaginator.cjs +3 -2
- package/lib/cjs/ram/RamPaginator.cjs.map +1 -0
- package/lib/cjs/ram/RamStatement.cjs +38 -37
- package/lib/cjs/ram/RamStatement.cjs.map +1 -0
- package/lib/cjs/ram/constants.cjs +1 -0
- package/lib/cjs/ram/constants.cjs.map +1 -0
- package/lib/cjs/ram/handlers.cjs +3 -2
- package/lib/cjs/ram/handlers.cjs.map +1 -0
- package/lib/cjs/ram/index.cjs +8 -7
- package/lib/cjs/ram/index.cjs.map +1 -0
- package/lib/cjs/ram/types.cjs +1 -0
- package/lib/cjs/ram/types.cjs.map +1 -0
- package/lib/cjs/repository/Repository.cjs +85 -79
- package/lib/cjs/repository/Repository.cjs.map +1 -0
- package/lib/cjs/repository/constants.cjs +5 -20
- package/lib/cjs/repository/constants.cjs.map +1 -0
- package/lib/cjs/repository/decorators.cjs +7 -6
- package/lib/cjs/repository/decorators.cjs.map +1 -0
- package/lib/cjs/repository/errors.cjs +1 -0
- package/lib/cjs/repository/errors.cjs.map +1 -0
- package/lib/cjs/repository/index.cjs +1 -0
- package/lib/cjs/repository/index.cjs.map +1 -0
- package/lib/cjs/repository/injectables.cjs +14 -13
- package/lib/cjs/repository/injectables.cjs.map +1 -0
- package/lib/cjs/repository/types.cjs +1 -0
- package/lib/cjs/repository/types.cjs.map +1 -0
- package/lib/cjs/repository/utils.cjs +3 -2
- package/lib/cjs/repository/utils.cjs.map +1 -0
- package/lib/cjs/services/ModelService.cjs +36 -30
- package/lib/cjs/services/ModelService.cjs.map +1 -0
- package/lib/cjs/services/PersistenceService.cjs +9 -8
- package/lib/cjs/services/PersistenceService.cjs.map +1 -0
- package/lib/cjs/services/index.cjs +1 -0
- package/lib/cjs/services/index.cjs.map +1 -0
- package/lib/cjs/services/services.cjs +37 -31
- package/lib/cjs/services/services.cjs.map +1 -0
- package/lib/cjs/tasks/CleanUpTask.cjs +30 -24
- package/lib/cjs/tasks/CleanUpTask.cjs.map +1 -0
- package/lib/cjs/tasks/TaskContext.cjs +16 -15
- package/lib/cjs/tasks/TaskContext.cjs.map +1 -0
- package/lib/cjs/tasks/TaskEngine.cjs +112 -111
- package/lib/cjs/tasks/TaskEngine.cjs.map +1 -0
- package/lib/cjs/tasks/TaskErrors.cjs +1 -0
- package/lib/cjs/tasks/TaskErrors.cjs.map +1 -0
- package/lib/cjs/tasks/TaskEventBus.cjs +7 -6
- package/lib/cjs/tasks/TaskEventBus.cjs.map +1 -0
- package/lib/cjs/tasks/TaskEventService.cjs +8 -7
- package/lib/cjs/tasks/TaskEventService.cjs.map +1 -0
- package/lib/cjs/tasks/TaskHandler.cjs +5 -4
- package/lib/cjs/tasks/TaskHandler.cjs.map +1 -0
- package/lib/cjs/tasks/TaskHandlerRegistry.cjs +1 -0
- package/lib/cjs/tasks/TaskHandlerRegistry.cjs.map +1 -0
- package/lib/cjs/tasks/TaskService.cjs +43 -37
- package/lib/cjs/tasks/TaskService.cjs.map +1 -0
- package/lib/cjs/tasks/TaskStateChangeError.cjs +1 -0
- package/lib/cjs/tasks/TaskStateChangeError.cjs.map +1 -0
- package/lib/cjs/tasks/TaskTracker.cjs +62 -61
- package/lib/cjs/tasks/TaskTracker.cjs.map +1 -0
- package/lib/cjs/tasks/builder.cjs +30 -24
- package/lib/cjs/tasks/builder.cjs.map +1 -0
- package/lib/cjs/tasks/constants.cjs +6 -10
- package/lib/cjs/tasks/constants.cjs.map +1 -0
- package/lib/cjs/tasks/decorators.cjs +5 -4
- package/lib/cjs/tasks/decorators.cjs.map +1 -0
- package/lib/cjs/tasks/index.cjs +6 -5
- package/lib/cjs/tasks/index.cjs.map +1 -0
- package/lib/cjs/tasks/logging.cjs +12 -11
- package/lib/cjs/tasks/logging.cjs.map +1 -0
- package/lib/cjs/tasks/models/TaskBackoffModel.cjs +16 -10
- package/lib/cjs/tasks/models/TaskBackoffModel.cjs.map +1 -0
- package/lib/cjs/tasks/models/TaskErrorModel.cjs +11 -5
- package/lib/cjs/tasks/models/TaskErrorModel.cjs.map +1 -0
- package/lib/cjs/tasks/models/TaskEventModel.cjs +29 -23
- package/lib/cjs/tasks/models/TaskEventModel.cjs.map +1 -0
- package/lib/cjs/tasks/models/TaskIOSerializer.cjs +4 -3
- package/lib/cjs/tasks/models/TaskIOSerializer.cjs.map +1 -0
- package/lib/cjs/tasks/models/TaskLogEntryModel.cjs +11 -5
- package/lib/cjs/tasks/models/TaskLogEntryModel.cjs.map +1 -0
- package/lib/cjs/tasks/models/TaskModel.cjs +72 -66
- package/lib/cjs/tasks/models/TaskModel.cjs.map +1 -0
- package/lib/cjs/tasks/models/TaskStepResultModel.cjs +14 -8
- package/lib/cjs/tasks/models/TaskStepResultModel.cjs.map +1 -0
- package/lib/cjs/tasks/models/TaskStepSpecModel.cjs +11 -5
- package/lib/cjs/tasks/models/TaskStepSpecModel.cjs.map +1 -0
- package/lib/cjs/tasks/models/index.cjs +1 -0
- package/lib/cjs/tasks/models/index.cjs.map +1 -0
- package/lib/cjs/tasks/types.cjs +1 -0
- package/lib/cjs/tasks/types.cjs.map +1 -0
- package/lib/cjs/tasks/utils.cjs +6 -5
- package/lib/cjs/tasks/utils.cjs.map +1 -0
- package/lib/cjs/utils/ContextualLoggedClass.cjs +5 -4
- package/lib/cjs/utils/ContextualLoggedClass.cjs.map +1 -0
- package/lib/cjs/utils/decorators.cjs +9 -8
- package/lib/cjs/utils/decorators.cjs.map +1 -0
- package/lib/cjs/utils/errors.cjs +1 -0
- package/lib/cjs/utils/errors.cjs.map +1 -0
- package/lib/cjs/utils/index.cjs +1 -0
- package/lib/cjs/utils/index.cjs.map +1 -0
- package/lib/cjs/utils/throttling.cjs +4 -3
- package/lib/cjs/utils/throttling.cjs.map +1 -0
- package/lib/cjs/utils/types.cjs +1 -0
- package/lib/cjs/utils/types.cjs.map +1 -0
- package/lib/cjs/utils/utils.cjs +3 -2
- package/lib/cjs/utils/utils.cjs.map +1 -0
- package/lib/cjs/workers/TaskEngine.cjs +30 -29
- package/lib/cjs/workers/TaskEngine.cjs.map +1 -0
- package/lib/cjs/workers/WorkThreadEnvironment.cjs +1 -0
- package/lib/cjs/workers/WorkThreadEnvironment.cjs.map +1 -0
- package/lib/cjs/workers/index.cjs +1 -0
- package/lib/cjs/workers/index.cjs.map +1 -0
- package/lib/cjs/workers/messages.cjs +1 -0
- package/lib/cjs/workers/messages.cjs.map +1 -0
- package/lib/cjs/workers/types.cjs +1 -0
- package/lib/cjs/workers/types.cjs.map +1 -0
- package/lib/cjs/workers/workerThread.cjs +18 -17
- package/lib/cjs/workers/workerThread.cjs.map +1 -0
- package/lib/esm/index.js +1 -1
- package/lib/types/auth/constants.d.cts +5 -0
- package/lib/types/auth/constants.d.mts +5 -0
- package/lib/types/auth/decorators.d.cts +5 -0
- package/lib/types/auth/decorators.d.mts +5 -0
- package/lib/types/auth/index.d.cts +2 -0
- package/lib/types/auth/index.d.mts +2 -0
- package/lib/types/fs/FilesystemAdapter.d.cts +70 -0
- package/lib/types/fs/FilesystemAdapter.d.mts +70 -0
- package/lib/types/fs/FsDispatch.d.cts +7 -0
- package/lib/types/fs/FsDispatch.d.mts +7 -0
- package/lib/types/fs/helpers.d.cts +17 -0
- package/lib/types/fs/helpers.d.mts +17 -0
- package/lib/types/fs/index.d.cts +4 -0
- package/lib/types/fs/index.d.mts +4 -0
- package/lib/types/fs/indexStore.d.cts +28 -0
- package/lib/types/fs/indexStore.d.mts +28 -0
- package/lib/types/fs/locks/FilesystemLock.d.cts +13 -0
- package/lib/types/fs/locks/FilesystemLock.d.mts +13 -0
- package/lib/types/fs/locks/FilesystemMultiLock.d.cts +8 -0
- package/lib/types/fs/locks/FilesystemMultiLock.d.mts +8 -0
- package/lib/types/fs/types.d.cts +40 -0
- package/lib/types/fs/types.d.mts +40 -0
- package/lib/types/identity/decorators.d.cts +72 -0
- package/lib/types/identity/decorators.d.mts +72 -0
- package/lib/types/identity/index.d.cts +6 -0
- package/lib/types/identity/index.d.mts +6 -0
- package/lib/types/index.d.cts +34 -0
- package/lib/types/index.d.mts +34 -0
- package/lib/types/index.d.ts +1 -1
- package/lib/types/interfaces/ContextuallyLogged.d.cts +8 -0
- package/lib/types/interfaces/ContextuallyLogged.d.mts +8 -0
- package/lib/types/interfaces/ErrorParser.d.cts +16 -0
- package/lib/types/interfaces/ErrorParser.d.mts +16 -0
- package/lib/types/interfaces/Executor.d.cts +16 -0
- package/lib/types/interfaces/Executor.d.mts +16 -0
- package/lib/types/interfaces/Observable.d.cts +33 -0
- package/lib/types/interfaces/Observable.d.mts +33 -0
- package/lib/types/interfaces/Observer.d.cts +15 -0
- package/lib/types/interfaces/Observer.d.mts +15 -0
- package/lib/types/interfaces/Paginatable.d.cts +20 -0
- package/lib/types/interfaces/Paginatable.d.mts +20 -0
- package/lib/types/interfaces/Queriable.d.cts +47 -0
- package/lib/types/interfaces/Queriable.d.mts +47 -0
- package/lib/types/interfaces/RawExecutor.d.cts +28 -0
- package/lib/types/interfaces/RawExecutor.d.mts +28 -0
- package/lib/types/interfaces/SequenceOptions.d.cts +79 -0
- package/lib/types/interfaces/SequenceOptions.d.mts +79 -0
- package/lib/types/interfaces/index.d.cts +12 -0
- package/lib/types/interfaces/index.d.mts +12 -0
- package/lib/types/migrations/Migration.d.cts +19 -0
- package/lib/types/migrations/Migration.d.mts +19 -0
- package/lib/types/migrations/MigrationService.d.cts +63 -0
- package/lib/types/migrations/MigrationService.d.mts +63 -0
- package/lib/types/migrations/MigrationTaskBuilder.d.cts +10 -0
- package/lib/types/migrations/MigrationTaskBuilder.d.mts +10 -0
- package/lib/types/migrations/MigrationTasks.d.cts +9 -0
- package/lib/types/migrations/MigrationTasks.d.mts +9 -0
- package/lib/types/migrations/MigrationVersioning.d.cts +7 -0
- package/lib/types/migrations/MigrationVersioning.d.mts +7 -0
- package/lib/types/migrations/SemverMigrationVersioning.d.cts +10 -0
- package/lib/types/migrations/SemverMigrationVersioning.d.mts +10 -0
- package/lib/types/migrations/StandardMigrationVersioning.d.cts +12 -0
- package/lib/types/migrations/StandardMigrationVersioning.d.mts +12 -0
- package/lib/types/migrations/constants.d.cts +2 -0
- package/lib/types/migrations/constants.d.mts +2 -0
- package/lib/types/migrations/decorators.d.cts +12 -0
- package/lib/types/migrations/decorators.d.mts +12 -0
- package/lib/types/migrations/index.d.cts +15 -0
- package/lib/types/migrations/index.d.mts +15 -0
- package/lib/types/migrations/types.d.cts +46 -0
- package/lib/types/migrations/types.d.mts +46 -0
- package/lib/types/model/BaseModel.d.cts +37 -0
- package/lib/types/model/BaseModel.d.mts +37 -0
- package/lib/types/model/SequenceModel.d.cts +32 -0
- package/lib/types/model/SequenceModel.d.mts +32 -0
- package/lib/types/model/construction.d.cts +455 -0
- package/lib/types/model/construction.d.mts +455 -0
- package/lib/types/model/decorators.d.cts +237 -0
- package/lib/types/model/decorators.d.mts +237 -0
- package/lib/types/model/index.d.cts +11 -0
- package/lib/types/model/index.d.mts +11 -0
- package/lib/types/model/indexing.d.cts +20 -0
- package/lib/types/model/indexing.d.mts +20 -0
- package/lib/types/model/types.d.cts +60 -0
- package/lib/types/model/types.d.mts +60 -0
- package/lib/types/overrides/Metadata.d.cts +22 -0
- package/lib/types/overrides/Metadata.d.mts +22 -0
- package/lib/types/overrides/Model.d.cts +94 -0
- package/lib/types/overrides/Model.d.mts +94 -0
- package/lib/types/overrides/ModelBuilder.d.cts +31 -0
- package/lib/types/overrides/ModelBuilder.d.mts +31 -0
- package/lib/types/overrides/index.d.cts +11 -0
- package/lib/types/overrides/index.d.mts +11 -0
- package/lib/types/overrides/injectables.d.cts +10 -0
- package/lib/types/overrides/injectables.d.mts +10 -0
- package/lib/types/overrides/overrides.d.cts +1 -0
- package/lib/types/overrides/overrides.d.mts +1 -0
- package/lib/types/persistence/Adapter.d.cts +469 -0
- package/lib/types/persistence/Adapter.d.mts +469 -0
- package/lib/types/persistence/Context.d.cts +16 -0
- package/lib/types/persistence/Context.d.mts +16 -0
- package/lib/types/persistence/ContextLock.d.cts +18 -0
- package/lib/types/persistence/ContextLock.d.mts +18 -0
- package/lib/types/persistence/Dispatch.d.cts +128 -0
- package/lib/types/persistence/Dispatch.d.mts +128 -0
- package/lib/types/persistence/ObserverHandler.d.cts +111 -0
- package/lib/types/persistence/ObserverHandler.d.mts +111 -0
- package/lib/types/persistence/Sequence.d.cts +126 -0
- package/lib/types/persistence/Sequence.d.mts +126 -0
- package/lib/types/persistence/constants.d.cts +74 -0
- package/lib/types/persistence/constants.d.mts +74 -0
- package/lib/types/persistence/decorators.d.cts +28 -0
- package/lib/types/persistence/decorators.d.mts +28 -0
- package/lib/types/persistence/errors.d.cts +33 -0
- package/lib/types/persistence/errors.d.mts +33 -0
- package/lib/types/persistence/event-filters.d.cts +20 -0
- package/lib/types/persistence/event-filters.d.mts +20 -0
- package/lib/types/persistence/generators.d.cts +14 -0
- package/lib/types/persistence/generators.d.mts +14 -0
- package/lib/types/persistence/index.d.cts +18 -0
- package/lib/types/persistence/index.d.mts +18 -0
- package/lib/types/persistence/transactions.d.cts +4 -0
- package/lib/types/persistence/transactions.d.mts +4 -0
- package/lib/types/persistence/types.d.cts +86 -0
- package/lib/types/persistence/types.d.mts +86 -0
- package/lib/types/query/Condition.d.cts +131 -0
- package/lib/types/query/Condition.d.mts +131 -0
- package/lib/types/query/MethodQueryBuilder.d.cts +185 -0
- package/lib/types/query/MethodQueryBuilder.d.mts +185 -0
- package/lib/types/query/Paginator.d.cts +105 -0
- package/lib/types/query/Paginator.d.mts +105 -0
- package/lib/types/query/Statement.d.cts +136 -0
- package/lib/types/query/Statement.d.mts +136 -0
- package/lib/types/query/constants.d.cts +69 -0
- package/lib/types/query/constants.d.mts +69 -0
- package/lib/types/query/decorators.d.cts +8 -0
- package/lib/types/query/decorators.d.mts +8 -0
- package/lib/types/query/errors.d.cts +21 -0
- package/lib/types/query/errors.d.mts +21 -0
- package/lib/types/query/index.d.cts +16 -0
- package/lib/types/query/index.d.mts +16 -0
- package/lib/types/query/options.d.cts +393 -0
- package/lib/types/query/options.d.mts +393 -0
- package/lib/types/query/selectors.d.cts +39 -0
- package/lib/types/query/selectors.d.mts +39 -0
- package/lib/types/query/types.d.cts +158 -0
- package/lib/types/query/types.d.mts +158 -0
- package/lib/types/query/utils.d.cts +40 -0
- package/lib/types/query/utils.d.mts +40 -0
- package/lib/types/ram/RamAdapter.d.cts +341 -0
- package/lib/types/ram/RamAdapter.d.mts +341 -0
- package/lib/types/ram/RamPaginator.d.cts +54 -0
- package/lib/types/ram/RamPaginator.d.mts +54 -0
- package/lib/types/ram/RamStatement.d.cts +92 -0
- package/lib/types/ram/RamStatement.d.mts +92 -0
- package/lib/types/ram/constants.d.cts +8 -0
- package/lib/types/ram/constants.d.mts +8 -0
- package/lib/types/ram/handlers.d.cts +24 -0
- package/lib/types/ram/handlers.d.mts +24 -0
- package/lib/types/ram/index.d.cts +12 -0
- package/lib/types/ram/index.d.mts +12 -0
- package/lib/types/ram/types.d.cts +50 -0
- package/lib/types/ram/types.d.mts +50 -0
- package/lib/types/repository/Repository.d.cts +501 -0
- package/lib/types/repository/Repository.d.mts +501 -0
- package/lib/types/repository/constants.d.cts +36 -0
- package/lib/types/repository/constants.d.mts +36 -0
- package/lib/types/repository/decorators.d.cts +30 -0
- package/lib/types/repository/decorators.d.mts +30 -0
- package/lib/types/repository/errors.d.cts +19 -0
- package/lib/types/repository/errors.d.mts +19 -0
- package/lib/types/repository/index.d.cts +12 -0
- package/lib/types/repository/index.d.mts +12 -0
- package/lib/types/repository/injectables.d.cts +95 -0
- package/lib/types/repository/injectables.d.mts +95 -0
- package/lib/types/repository/types.d.cts +28 -0
- package/lib/types/repository/types.d.mts +28 -0
- package/lib/types/repository/utils.d.cts +36 -0
- package/lib/types/repository/utils.d.mts +36 -0
- package/lib/types/services/ModelService.d.cts +45 -0
- package/lib/types/services/ModelService.d.mts +45 -0
- package/lib/types/services/PersistenceService.d.cts +17 -0
- package/lib/types/services/PersistenceService.d.mts +17 -0
- package/lib/types/services/index.d.cts +8 -0
- package/lib/types/services/index.d.mts +8 -0
- package/lib/types/services/services.d.cts +96 -0
- package/lib/types/services/services.d.mts +96 -0
- package/lib/types/tasks/CleanUpTask.d.cts +15 -0
- package/lib/types/tasks/CleanUpTask.d.mts +15 -0
- package/lib/types/tasks/TaskContext.d.cts +30 -0
- package/lib/types/tasks/TaskContext.d.mts +30 -0
- package/lib/types/tasks/TaskEngine.d.cts +97 -0
- package/lib/types/tasks/TaskEngine.d.mts +97 -0
- package/lib/types/tasks/TaskErrors.d.cts +65 -0
- package/lib/types/tasks/TaskErrors.d.mts +65 -0
- package/lib/types/tasks/TaskEventBus.d.cts +17 -0
- package/lib/types/tasks/TaskEventBus.d.mts +17 -0
- package/lib/types/tasks/TaskEventService.d.cts +7 -0
- package/lib/types/tasks/TaskEventService.d.mts +7 -0
- package/lib/types/tasks/TaskHandler.d.cts +12 -0
- package/lib/types/tasks/TaskHandler.d.mts +12 -0
- package/lib/types/tasks/TaskHandlerRegistry.d.cts +8 -0
- package/lib/types/tasks/TaskHandlerRegistry.d.mts +8 -0
- package/lib/types/tasks/TaskService.d.cts +65 -0
- package/lib/types/tasks/TaskService.d.mts +65 -0
- package/lib/types/tasks/TaskStateChangeError.d.cts +11 -0
- package/lib/types/tasks/TaskStateChangeError.d.mts +11 -0
- package/lib/types/tasks/TaskTracker.d.cts +47 -0
- package/lib/types/tasks/TaskTracker.d.mts +47 -0
- package/lib/types/tasks/builder.d.cts +72 -0
- package/lib/types/tasks/builder.d.mts +72 -0
- package/lib/types/tasks/constants.d.cts +31 -0
- package/lib/types/tasks/constants.d.mts +31 -0
- package/lib/types/tasks/decorators.d.cts +4 -0
- package/lib/types/tasks/decorators.d.mts +4 -0
- package/lib/types/tasks/index.d.cts +23 -0
- package/lib/types/tasks/index.d.mts +23 -0
- package/lib/types/tasks/logging.d.cts +31 -0
- package/lib/types/tasks/logging.d.mts +31 -0
- package/lib/types/tasks/models/TaskBackoffModel.d.cts +9 -0
- package/lib/types/tasks/models/TaskBackoffModel.d.mts +9 -0
- package/lib/types/tasks/models/TaskErrorModel.d.cts +8 -0
- package/lib/types/tasks/models/TaskErrorModel.d.mts +8 -0
- package/lib/types/tasks/models/TaskEventModel.d.cts +11 -0
- package/lib/types/tasks/models/TaskEventModel.d.mts +11 -0
- package/lib/types/tasks/models/TaskIOSerializer.d.cts +33 -0
- package/lib/types/tasks/models/TaskIOSerializer.d.mts +33 -0
- package/lib/types/tasks/models/TaskLogEntryModel.d.cts +10 -0
- package/lib/types/tasks/models/TaskLogEntryModel.d.mts +10 -0
- package/lib/types/tasks/models/TaskModel.d.cts +43 -0
- package/lib/types/tasks/models/TaskModel.d.mts +43 -0
- package/lib/types/tasks/models/TaskStepResultModel.d.cts +9 -0
- package/lib/types/tasks/models/TaskStepResultModel.d.mts +9 -0
- package/lib/types/tasks/models/TaskStepSpecModel.d.cts +9 -0
- package/lib/types/tasks/models/TaskStepSpecModel.d.mts +9 -0
- package/lib/types/tasks/models/index.d.cts +8 -0
- package/lib/types/tasks/models/index.d.mts +8 -0
- package/lib/types/tasks/types.d.cts +71 -0
- package/lib/types/tasks/types.d.mts +71 -0
- package/lib/types/tasks/utils.d.cts +5 -0
- package/lib/types/tasks/utils.d.mts +5 -0
- package/lib/types/utils/ContextualLoggedClass.d.cts +37 -0
- package/lib/types/utils/ContextualLoggedClass.d.mts +37 -0
- package/lib/types/utils/decorators.d.cts +27 -0
- package/lib/types/utils/decorators.d.mts +27 -0
- package/lib/types/utils/errors.d.cts +56 -0
- package/lib/types/utils/errors.d.mts +56 -0
- package/lib/types/utils/index.d.cts +11 -0
- package/lib/types/utils/index.d.mts +11 -0
- package/lib/types/utils/throttling.d.cts +9 -0
- package/lib/types/utils/throttling.d.mts +9 -0
- package/lib/types/utils/types.d.cts +23 -0
- package/lib/types/utils/types.d.mts +23 -0
- package/lib/types/utils/utils.d.cts +22 -0
- package/lib/types/utils/utils.d.mts +22 -0
- package/lib/types/workers/TaskEngine.d.cts +40 -0
- package/lib/types/workers/TaskEngine.d.mts +40 -0
- package/lib/types/workers/WorkThreadEnvironment.d.cts +35 -0
- package/lib/types/workers/WorkThreadEnvironment.d.mts +35 -0
- package/lib/types/workers/index.d.cts +5 -0
- package/lib/types/workers/index.d.mts +5 -0
- package/lib/types/workers/messages.d.cts +69 -0
- package/lib/types/workers/messages.d.mts +69 -0
- package/lib/types/workers/types.d.cts +41 -0
- package/lib/types/workers/types.d.mts +41 -0
- package/lib/types/workers/workerThread.d.cts +1 -0
- package/lib/types/workers/workerThread.d.mts +1 -0
- package/package.json +4 -4
- package/lib/cjs/auth/constants.js.map +0 -1
- package/lib/cjs/auth/decorators.js.map +0 -1
- package/lib/cjs/auth/index.js.map +0 -1
- package/lib/cjs/fs/FilesystemAdapter.js.map +0 -1
- package/lib/cjs/fs/FsDispatch.js.map +0 -1
- package/lib/cjs/fs/helpers.js.map +0 -1
- package/lib/cjs/fs/index.js.map +0 -1
- package/lib/cjs/fs/indexStore.js.map +0 -1
- package/lib/cjs/fs/locks/FilesystemLock.js.map +0 -1
- package/lib/cjs/fs/locks/FilesystemMultiLock.js.map +0 -1
- package/lib/cjs/fs/types.js.map +0 -1
- package/lib/cjs/identity/decorators.js.map +0 -1
- package/lib/cjs/identity/index.js.map +0 -1
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/interfaces/ContextuallyLogged.js.map +0 -1
- package/lib/cjs/interfaces/ErrorParser.js.map +0 -1
- package/lib/cjs/interfaces/Executor.js.map +0 -1
- package/lib/cjs/interfaces/Observable.js.map +0 -1
- package/lib/cjs/interfaces/Observer.js.map +0 -1
- package/lib/cjs/interfaces/Paginatable.js.map +0 -1
- package/lib/cjs/interfaces/Queriable.js.map +0 -1
- package/lib/cjs/interfaces/RawExecutor.js.map +0 -1
- package/lib/cjs/interfaces/SequenceOptions.js.map +0 -1
- package/lib/cjs/interfaces/index.js.map +0 -1
- package/lib/cjs/migrations/Migration.js.map +0 -1
- package/lib/cjs/migrations/MigrationService.js.map +0 -1
- package/lib/cjs/migrations/MigrationTaskBuilder.js.map +0 -1
- package/lib/cjs/migrations/MigrationTasks.js.map +0 -1
- package/lib/cjs/migrations/MigrationVersioning.js.map +0 -1
- package/lib/cjs/migrations/SemverMigrationVersioning.js.map +0 -1
- package/lib/cjs/migrations/StandardMigrationVersioning.js.map +0 -1
- package/lib/cjs/migrations/constants.js.map +0 -1
- package/lib/cjs/migrations/decorators.js.map +0 -1
- package/lib/cjs/migrations/index.js.map +0 -1
- package/lib/cjs/migrations/types.js.map +0 -1
- package/lib/cjs/model/BaseModel.js.map +0 -1
- package/lib/cjs/model/SequenceModel.js.map +0 -1
- package/lib/cjs/model/construction.js.map +0 -1
- package/lib/cjs/model/decorators.js.map +0 -1
- package/lib/cjs/model/index.js.map +0 -1
- package/lib/cjs/model/indexing.js.map +0 -1
- package/lib/cjs/model/types.js.map +0 -1
- package/lib/cjs/overrides/Metadata.js.map +0 -1
- package/lib/cjs/overrides/Model.js.map +0 -1
- package/lib/cjs/overrides/ModelBuilder.js.map +0 -1
- package/lib/cjs/overrides/index.js.map +0 -1
- package/lib/cjs/overrides/injectables.js.map +0 -1
- package/lib/cjs/overrides/overrides.js.map +0 -1
- package/lib/cjs/persistence/Adapter.js.map +0 -1
- package/lib/cjs/persistence/Context.js.map +0 -1
- package/lib/cjs/persistence/ContextLock.js.map +0 -1
- package/lib/cjs/persistence/Dispatch.js.map +0 -1
- package/lib/cjs/persistence/ObserverHandler.js.map +0 -1
- package/lib/cjs/persistence/Sequence.js.map +0 -1
- package/lib/cjs/persistence/constants.js.map +0 -1
- package/lib/cjs/persistence/decorators.js.map +0 -1
- package/lib/cjs/persistence/errors.js.map +0 -1
- package/lib/cjs/persistence/event-filters.js.map +0 -1
- package/lib/cjs/persistence/generators.js.map +0 -1
- package/lib/cjs/persistence/index.js.map +0 -1
- package/lib/cjs/persistence/transactions.js.map +0 -1
- package/lib/cjs/persistence/types.js.map +0 -1
- package/lib/cjs/query/Condition.js.map +0 -1
- package/lib/cjs/query/MethodQueryBuilder.js.map +0 -1
- package/lib/cjs/query/Paginator.js.map +0 -1
- package/lib/cjs/query/Statement.js.map +0 -1
- package/lib/cjs/query/constants.js.map +0 -1
- package/lib/cjs/query/decorators.js.map +0 -1
- package/lib/cjs/query/errors.js.map +0 -1
- package/lib/cjs/query/index.js.map +0 -1
- package/lib/cjs/query/options.js.map +0 -1
- package/lib/cjs/query/selectors.js.map +0 -1
- package/lib/cjs/query/types.js.map +0 -1
- package/lib/cjs/query/utils.js.map +0 -1
- package/lib/cjs/ram/RamAdapter.js.map +0 -1
- package/lib/cjs/ram/RamPaginator.js.map +0 -1
- package/lib/cjs/ram/RamStatement.js.map +0 -1
- package/lib/cjs/ram/constants.js.map +0 -1
- package/lib/cjs/ram/handlers.js.map +0 -1
- package/lib/cjs/ram/index.js.map +0 -1
- package/lib/cjs/ram/types.js.map +0 -1
- package/lib/cjs/repository/Repository.js.map +0 -1
- package/lib/cjs/repository/constants.js.map +0 -1
- package/lib/cjs/repository/decorators.js.map +0 -1
- package/lib/cjs/repository/errors.js.map +0 -1
- package/lib/cjs/repository/index.js.map +0 -1
- package/lib/cjs/repository/injectables.js.map +0 -1
- package/lib/cjs/repository/types.js.map +0 -1
- package/lib/cjs/repository/utils.js.map +0 -1
- package/lib/cjs/services/ModelService.js.map +0 -1
- package/lib/cjs/services/PersistenceService.js.map +0 -1
- package/lib/cjs/services/index.js.map +0 -1
- package/lib/cjs/services/services.js.map +0 -1
- package/lib/cjs/tasks/CleanUpTask.js.map +0 -1
- package/lib/cjs/tasks/TaskContext.js.map +0 -1
- package/lib/cjs/tasks/TaskEngine.js.map +0 -1
- package/lib/cjs/tasks/TaskErrors.js.map +0 -1
- package/lib/cjs/tasks/TaskEventBus.js.map +0 -1
- package/lib/cjs/tasks/TaskEventService.js.map +0 -1
- package/lib/cjs/tasks/TaskHandler.js.map +0 -1
- package/lib/cjs/tasks/TaskHandlerRegistry.js.map +0 -1
- package/lib/cjs/tasks/TaskService.js.map +0 -1
- package/lib/cjs/tasks/TaskStateChangeError.js.map +0 -1
- package/lib/cjs/tasks/TaskTracker.js.map +0 -1
- package/lib/cjs/tasks/builder.js.map +0 -1
- package/lib/cjs/tasks/constants.js.map +0 -1
- package/lib/cjs/tasks/decorators.js.map +0 -1
- package/lib/cjs/tasks/index.js.map +0 -1
- package/lib/cjs/tasks/logging.js.map +0 -1
- package/lib/cjs/tasks/models/TaskBackoffModel.js.map +0 -1
- package/lib/cjs/tasks/models/TaskErrorModel.js.map +0 -1
- package/lib/cjs/tasks/models/TaskEventModel.js.map +0 -1
- package/lib/cjs/tasks/models/TaskIOSerializer.js.map +0 -1
- package/lib/cjs/tasks/models/TaskLogEntryModel.js.map +0 -1
- package/lib/cjs/tasks/models/TaskModel.js.map +0 -1
- package/lib/cjs/tasks/models/TaskStepResultModel.js.map +0 -1
- package/lib/cjs/tasks/models/TaskStepSpecModel.js.map +0 -1
- package/lib/cjs/tasks/models/index.js.map +0 -1
- package/lib/cjs/tasks/types.js.map +0 -1
- package/lib/cjs/tasks/utils.js.map +0 -1
- package/lib/cjs/utils/ContextualLoggedClass.js.map +0 -1
- package/lib/cjs/utils/decorators.js.map +0 -1
- package/lib/cjs/utils/errors.js.map +0 -1
- package/lib/cjs/utils/index.js.map +0 -1
- package/lib/cjs/utils/throttling.js.map +0 -1
- package/lib/cjs/utils/types.js.map +0 -1
- package/lib/cjs/utils/utils.js.map +0 -1
- package/lib/cjs/workers/TaskEngine.js.map +0 -1
- package/lib/cjs/workers/WorkThreadEnvironment.js.map +0 -1
- package/lib/cjs/workers/index.js.map +0 -1
- package/lib/cjs/workers/messages.js.map +0 -1
- package/lib/cjs/workers/types.js.map +0 -1
- package/lib/cjs/workers/workerThread.js.map +0 -1
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TaskEngine = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
4
|
+
const TaskModel_js_1 = require("./models/TaskModel.cjs");
|
|
5
|
+
const TaskEventModel_js_1 = require("./models/TaskEventModel.cjs");
|
|
6
|
+
const TaskHandlerRegistry_js_1 = require("./TaskHandlerRegistry.cjs");
|
|
7
|
+
const TaskEventBus_js_1 = require("./TaskEventBus.cjs");
|
|
8
|
+
const Condition_js_1 = require("./../query/Condition.cjs");
|
|
9
|
+
const TaskStepResultModel_js_1 = require("./models/TaskStepResultModel.cjs");
|
|
10
|
+
const TaskLogEntryModel_js_1 = require("./models/TaskLogEntryModel.cjs");
|
|
11
|
+
const TaskBackoffModel_js_1 = require("./models/TaskBackoffModel.cjs");
|
|
12
|
+
const TaskStepSpecModel_js_1 = require("./models/TaskStepSpecModel.cjs");
|
|
13
|
+
const constants_js_1 = require("./constants.cjs");
|
|
14
14
|
const logging_1 = require("@decaf-ts/logging");
|
|
15
|
-
const
|
|
15
|
+
const ContextualLoggedClass_js_1 = require("./../utils/ContextualLoggedClass.cjs");
|
|
16
16
|
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
17
|
+
const utils_js_1 = require("./utils.cjs");
|
|
18
|
+
const TaskContext_js_1 = require("./TaskContext.cjs");
|
|
19
|
+
const TaskStateChangeError_js_1 = require("./TaskStateChangeError.cjs");
|
|
20
|
+
const logging_js_1 = require("./logging.cjs");
|
|
21
|
+
const TaskErrorModel_js_1 = require("./models/TaskErrorModel.cjs");
|
|
22
|
+
const TaskTracker_js_1 = require("./TaskTracker.cjs");
|
|
23
23
|
const transactional_decorators_1 = require("@decaf-ts/transactional-decorators");
|
|
24
|
-
const
|
|
25
|
-
class TaskEngine extends
|
|
24
|
+
const index_js_1 = require("./../persistence/index.cjs");
|
|
25
|
+
class TaskEngine extends ContextualLoggedClass_js_1.AbsContextual {
|
|
26
26
|
get Context() {
|
|
27
|
-
return
|
|
27
|
+
return TaskContext_js_1.TaskContext;
|
|
28
28
|
}
|
|
29
29
|
get adapter() {
|
|
30
30
|
if (!this._adapter) {
|
|
@@ -43,7 +43,7 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
43
43
|
get tasks() {
|
|
44
44
|
if (this._tasks)
|
|
45
45
|
return this._tasks;
|
|
46
|
-
this._tasks = new (this.adapter.repository())(this.adapter,
|
|
46
|
+
this._tasks = new (this.adapter.repository())(this.adapter, TaskModel_js_1.TaskModel, true).override({
|
|
47
47
|
afterQueryHandlers: true,
|
|
48
48
|
});
|
|
49
49
|
return this._tasks;
|
|
@@ -51,13 +51,13 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
51
51
|
get events() {
|
|
52
52
|
if (this._events)
|
|
53
53
|
return this._events;
|
|
54
|
-
this._events = new (this.adapter.repository())(this.adapter,
|
|
54
|
+
this._events = new (this.adapter.repository())(this.adapter, TaskEventModel_js_1.TaskEventModel, true).override({
|
|
55
55
|
afterQueryHandlers: true,
|
|
56
56
|
});
|
|
57
57
|
return this._events;
|
|
58
58
|
}
|
|
59
59
|
static createTaskContext(base, overrides) {
|
|
60
|
-
const ctx = new
|
|
60
|
+
const ctx = new TaskContext_js_1.TaskContext(base);
|
|
61
61
|
if (overrides && Object.keys(overrides).length) {
|
|
62
62
|
return ctx.accumulate(overrides);
|
|
63
63
|
}
|
|
@@ -68,11 +68,11 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
68
68
|
this.config = config;
|
|
69
69
|
this.lock = new transactional_decorators_1.Lock();
|
|
70
70
|
this.running = false;
|
|
71
|
-
const autoShutdown = Object.assign({},
|
|
72
|
-
this.config = Object.assign({},
|
|
71
|
+
const autoShutdown = Object.assign({}, constants_js_1.DefaultTaskEngineConfig.autoShutdown, config.autoShutdown);
|
|
72
|
+
this.config = Object.assign({}, constants_js_1.DefaultTaskEngineConfig, config, {
|
|
73
73
|
autoShutdown,
|
|
74
|
-
bus: config.bus || new
|
|
75
|
-
registry: config.registry || new
|
|
74
|
+
bus: config.bus || new TaskEventBus_js_1.TaskEventBus(),
|
|
75
|
+
registry: config.registry || new TaskHandlerRegistry_js_1.TaskHandlerRegistry(),
|
|
76
76
|
});
|
|
77
77
|
this.idleDelayMs = this.config.pollMsIdle;
|
|
78
78
|
}
|
|
@@ -83,14 +83,14 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
83
83
|
log.info(`${task.classification} task registered under ${t.id}`);
|
|
84
84
|
if (!track)
|
|
85
85
|
return t;
|
|
86
|
-
const tracker = new
|
|
86
|
+
const tracker = new TaskTracker_js_1.TaskTracker(this.bus, t);
|
|
87
87
|
return { task: t, tracker };
|
|
88
88
|
}
|
|
89
89
|
schedule(task, track = false, ...args) {
|
|
90
90
|
return {
|
|
91
91
|
for: async (when) => {
|
|
92
92
|
const scheduledTo = when instanceof Date ? when : when.build();
|
|
93
|
-
task.status =
|
|
93
|
+
task.status = constants_js_1.TaskStatus.SCHEDULED;
|
|
94
94
|
task.scheduledTo = scheduledTo;
|
|
95
95
|
task.nextRunAt = undefined;
|
|
96
96
|
task.leaseOwner = undefined;
|
|
@@ -105,17 +105,17 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
105
105
|
let task = await this.tasks.read(id, ctx);
|
|
106
106
|
task = await this.ensureTaskError(task, ctx);
|
|
107
107
|
log.info(`${task.classification} task found with id ${id}`);
|
|
108
|
-
const tracker = new
|
|
108
|
+
const tracker = new TaskTracker_js_1.TaskTracker(this.bus, task);
|
|
109
109
|
return { task, tracker };
|
|
110
110
|
}
|
|
111
111
|
async ensureTaskError(task, ctx) {
|
|
112
|
-
if (![
|
|
112
|
+
if (![constants_js_1.TaskStatus.FAILED, constants_js_1.TaskStatus.CANCELED].includes(task.status) ||
|
|
113
113
|
task.error) {
|
|
114
114
|
return task;
|
|
115
115
|
}
|
|
116
116
|
let current = task;
|
|
117
117
|
for (let attempt = 0; attempt < 6; attempt += 1) {
|
|
118
|
-
await (0,
|
|
118
|
+
await (0, utils_js_1.sleep)(20);
|
|
119
119
|
try {
|
|
120
120
|
const latest = await this.tasks.read(current.id, ctx);
|
|
121
121
|
if (latest.error)
|
|
@@ -131,10 +131,10 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
131
131
|
async cancel(id, ...args) {
|
|
132
132
|
const { ctx } = (await this.logCtx(args, "cancel", true)).for(this.cancel);
|
|
133
133
|
const t = await this.tasks.read(id, ctx);
|
|
134
|
-
if (t.status ===
|
|
134
|
+
if (t.status === constants_js_1.TaskStatus.SUCCEEDED || t.status === constants_js_1.TaskStatus.FAILED)
|
|
135
135
|
return t;
|
|
136
|
-
t.status =
|
|
137
|
-
const cancelError = new
|
|
136
|
+
t.status = constants_js_1.TaskStatus.CANCELED;
|
|
137
|
+
const cancelError = new TaskErrorModel_js_1.TaskErrorModel({
|
|
138
138
|
message: `Task ${t.id} canceled`,
|
|
139
139
|
code: 400,
|
|
140
140
|
});
|
|
@@ -144,7 +144,7 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
144
144
|
t.nextRunAt = undefined;
|
|
145
145
|
t.scheduledTo = undefined;
|
|
146
146
|
const saved = await this.tasks.update(t, ctx);
|
|
147
|
-
await this.emitStatus(ctx, saved,
|
|
147
|
+
await this.emitStatus(ctx, saved, constants_js_1.TaskStatus.CANCELED, cancelError);
|
|
148
148
|
return saved;
|
|
149
149
|
}
|
|
150
150
|
async isRunning() {
|
|
@@ -164,7 +164,7 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
164
164
|
void this.loop(ctx);
|
|
165
165
|
}
|
|
166
166
|
async stop(...args) {
|
|
167
|
-
const { ctx, log } = (await this.logCtx(args,
|
|
167
|
+
const { ctx, log } = (await this.logCtx(args, index_js_1.PersistenceKeys.SHUTDOWN, true)).for(this.stop);
|
|
168
168
|
await this.lock.acquire();
|
|
169
169
|
if (!this.running)
|
|
170
170
|
log.warn(`stop method called when task engine was not running`);
|
|
@@ -172,7 +172,7 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
172
172
|
this.lock.release();
|
|
173
173
|
const runningTasks = await this.tasks
|
|
174
174
|
.select(["id"])
|
|
175
|
-
.where(
|
|
175
|
+
.where(Condition_js_1.Condition.attr("status").eq(constants_js_1.TaskStatus.RUNNING))
|
|
176
176
|
.execute(ctx);
|
|
177
177
|
const timeout = ctx.getOrUndefined?.("gracefulShutdownMsTimeout") ??
|
|
178
178
|
this.config.gracefulShutdownMsTimeout;
|
|
@@ -233,7 +233,7 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
233
233
|
this.idleDelayMs = this.config.pollMsIdle;
|
|
234
234
|
}
|
|
235
235
|
const waitMs = idle ? this.idleDelayMs : this.config.pollMsBusy;
|
|
236
|
-
await (0,
|
|
236
|
+
await (0, utils_js_1.sleep)(Math.max(waitMs, 0));
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
async claimBatch(ctx) {
|
|
@@ -243,16 +243,16 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
243
243
|
// - PENDING
|
|
244
244
|
// - WAITING_RETRY with nextRunAt <= now
|
|
245
245
|
// - RUNNING with expired lease (recovery)
|
|
246
|
-
const condPending =
|
|
247
|
-
const condRetry =
|
|
248
|
-
.eq(
|
|
249
|
-
.and(
|
|
250
|
-
const condLeaseExpired =
|
|
251
|
-
.eq(
|
|
252
|
-
.and(
|
|
253
|
-
const condScheduled =
|
|
254
|
-
.eq(
|
|
255
|
-
.and(
|
|
246
|
+
const condPending = Condition_js_1.Condition.attribute("status").eq(constants_js_1.TaskStatus.PENDING);
|
|
247
|
+
const condRetry = Condition_js_1.Condition.attribute("status")
|
|
248
|
+
.eq(constants_js_1.TaskStatus.WAITING_RETRY)
|
|
249
|
+
.and(Condition_js_1.Condition.attribute("nextRunAt").lte(now));
|
|
250
|
+
const condLeaseExpired = Condition_js_1.Condition.attribute("status")
|
|
251
|
+
.eq(constants_js_1.TaskStatus.RUNNING)
|
|
252
|
+
.and(Condition_js_1.Condition.attribute("leaseExpiry").lte(now));
|
|
253
|
+
const condScheduled = Condition_js_1.Condition.attribute("status")
|
|
254
|
+
.eq(constants_js_1.TaskStatus.SCHEDULED)
|
|
255
|
+
.and(Condition_js_1.Condition.attribute("scheduledTo").lte(now));
|
|
256
256
|
const runnable = condPending
|
|
257
257
|
.or(condRetry)
|
|
258
258
|
.or(condLeaseExpired)
|
|
@@ -288,9 +288,9 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
288
288
|
const runnable = await this.isRunnable(source, ctx);
|
|
289
289
|
if (!runnable)
|
|
290
290
|
return null;
|
|
291
|
-
const claimed = new
|
|
291
|
+
const claimed = new TaskModel_js_1.TaskModel({
|
|
292
292
|
...source,
|
|
293
|
-
status:
|
|
293
|
+
status: constants_js_1.TaskStatus.RUNNING,
|
|
294
294
|
leaseOwner: this.config.workerId.toString(),
|
|
295
295
|
leaseExpiry: new Date(now + (parseInt(this.config.leaseMs.toString()) || 60_000)),
|
|
296
296
|
scheduledTo: undefined,
|
|
@@ -307,9 +307,9 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
307
307
|
}
|
|
308
308
|
isTaskFinished(status) {
|
|
309
309
|
return [
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
310
|
+
constants_js_1.TaskStatus.SUCCEEDED,
|
|
311
|
+
constants_js_1.TaskStatus.FAILED,
|
|
312
|
+
constants_js_1.TaskStatus.CANCELED,
|
|
313
313
|
].includes(status);
|
|
314
314
|
}
|
|
315
315
|
parseTaskDependency(value) {
|
|
@@ -397,7 +397,7 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
397
397
|
return true;
|
|
398
398
|
}
|
|
399
399
|
getStepLock(task, stepIndex) {
|
|
400
|
-
if (task.atomicity !==
|
|
400
|
+
if (task.atomicity !== constants_js_1.TaskType.COMPOSITE)
|
|
401
401
|
return undefined;
|
|
402
402
|
const steps = this.normalizeSteps(task.steps);
|
|
403
403
|
if (!steps.length)
|
|
@@ -415,7 +415,7 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
415
415
|
return false;
|
|
416
416
|
const runningTasks = await this.tasks
|
|
417
417
|
.select()
|
|
418
|
-
.where(
|
|
418
|
+
.where(Condition_js_1.Condition.attribute("status").eq(constants_js_1.TaskStatus.RUNNING))
|
|
419
419
|
.execute(ctx);
|
|
420
420
|
for (const running of runningTasks) {
|
|
421
421
|
if (running.id === task.id)
|
|
@@ -435,7 +435,7 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
435
435
|
const dependenciesSatisfied = await this.areDependenciesSatisfied(dependencies, ctx);
|
|
436
436
|
if (!dependenciesSatisfied)
|
|
437
437
|
return false;
|
|
438
|
-
const stepIndex = task.atomicity ===
|
|
438
|
+
const stepIndex = task.atomicity === constants_js_1.TaskType.COMPOSITE
|
|
439
439
|
? (task.currentStep ?? 0)
|
|
440
440
|
: undefined;
|
|
441
441
|
return !(await this.hasLockConflict(task, stepIndex, ctx));
|
|
@@ -448,9 +448,9 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
448
448
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
449
449
|
const engine = this;
|
|
450
450
|
let logPipeQueue = Promise.resolve();
|
|
451
|
-
const taskCtx = new
|
|
451
|
+
const taskCtx = new TaskContext_js_1.TaskContext(ctx).accumulate({
|
|
452
452
|
taskId: task.id,
|
|
453
|
-
logger: new
|
|
453
|
+
logger: new logging_js_1.TaskLogger(log, this.config.streamBufferSize, this.config.maxLoggingBuffer),
|
|
454
454
|
attempt: task.attempt,
|
|
455
455
|
resultCache: { "task.attempt": task.attempt },
|
|
456
456
|
pipe: async function (...args) {
|
|
@@ -485,12 +485,12 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
485
485
|
}
|
|
486
486
|
},
|
|
487
487
|
});
|
|
488
|
-
await this.emitStatus(taskCtx, task,
|
|
488
|
+
await this.emitStatus(taskCtx, task, constants_js_1.TaskStatus.RUNNING);
|
|
489
489
|
let activeHandler;
|
|
490
490
|
let activeInput;
|
|
491
491
|
try {
|
|
492
492
|
let output;
|
|
493
|
-
if (task.atomicity ===
|
|
493
|
+
if (task.atomicity === constants_js_1.TaskType.COMPOSITE) {
|
|
494
494
|
output = await this.runComposite(task, taskCtx);
|
|
495
495
|
try {
|
|
496
496
|
const latest = await this.tasks.read(task.id, taskCtx);
|
|
@@ -517,7 +517,7 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
517
517
|
await taskCtx.flush();
|
|
518
518
|
log.verbose(`handler finished for ${task.id}`);
|
|
519
519
|
}
|
|
520
|
-
task.status =
|
|
520
|
+
task.status = constants_js_1.TaskStatus.SUCCEEDED;
|
|
521
521
|
task.output = output;
|
|
522
522
|
task.error = undefined;
|
|
523
523
|
task.leaseOwner = undefined;
|
|
@@ -526,7 +526,7 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
526
526
|
Object.assign(task, persisted);
|
|
527
527
|
taskCtx.logger.info(`task ${task.id} success state ${task.status}`);
|
|
528
528
|
log.info(`task ${task.id} success state ${task.status} attempt ${task.attempt}`);
|
|
529
|
-
await this.emitStatus(taskCtx, task,
|
|
529
|
+
await this.emitStatus(taskCtx, task, constants_js_1.TaskStatus.SUCCEEDED, output);
|
|
530
530
|
}
|
|
531
531
|
catch (err) {
|
|
532
532
|
// Ensure buffered handler logs are persisted before we emit any engine-generated logs/events.
|
|
@@ -544,7 +544,7 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
544
544
|
catch {
|
|
545
545
|
// keep best-effort task state for retries/failures
|
|
546
546
|
}
|
|
547
|
-
if (err instanceof
|
|
547
|
+
if (err instanceof TaskStateChangeError_js_1.TaskStateChangeError) {
|
|
548
548
|
await this.handleTaskStateChange(err.request, task, taskCtx);
|
|
549
549
|
return;
|
|
550
550
|
}
|
|
@@ -555,22 +555,22 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
555
555
|
log.error("task handler catch() hook failed", catchErr);
|
|
556
556
|
}
|
|
557
557
|
log.error("task execution error", err);
|
|
558
|
-
if (task.atomicity ===
|
|
558
|
+
if (task.atomicity === constants_js_1.TaskType.COMPOSITE) {
|
|
559
559
|
const normalizedResults = this.normalizeStepResults(task.stepResults);
|
|
560
560
|
task.stepResults = normalizedResults;
|
|
561
561
|
if (task.currentStep == null) {
|
|
562
|
-
const failedIdx = normalizedResults.findIndex((step) => step.status ===
|
|
562
|
+
const failedIdx = normalizedResults.findIndex((step) => step.status === constants_js_1.TaskStatus.FAILED);
|
|
563
563
|
if (failedIdx >= 0)
|
|
564
564
|
task.currentStep = failedIdx;
|
|
565
565
|
}
|
|
566
566
|
}
|
|
567
567
|
const nextAttempt = (task.attempt ?? 0) + 1;
|
|
568
|
-
const serialized = (0,
|
|
568
|
+
const serialized = (0, utils_js_1.serializeError)(err);
|
|
569
569
|
if (nextAttempt < task.maxAttempts) {
|
|
570
|
-
const delay = (0,
|
|
570
|
+
const delay = (0, utils_js_1.computeBackoffMs)(nextAttempt, this.normalizeBackoff(task.backoff));
|
|
571
571
|
const nextRunAt = new Date(Date.now() + delay);
|
|
572
572
|
task.attempt = nextAttempt;
|
|
573
|
-
task.status =
|
|
573
|
+
task.status = constants_js_1.TaskStatus.WAITING_RETRY;
|
|
574
574
|
task.nextRunAt = nextRunAt;
|
|
575
575
|
task.error = serialized;
|
|
576
576
|
task.leaseOwner = undefined;
|
|
@@ -583,11 +583,11 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
583
583
|
delayMs: delay,
|
|
584
584
|
attempt: nextAttempt,
|
|
585
585
|
});
|
|
586
|
-
await this.emitStatus(taskCtx, task,
|
|
586
|
+
await this.emitStatus(taskCtx, task, constants_js_1.TaskStatus.WAITING_RETRY, serialized, err);
|
|
587
587
|
}
|
|
588
588
|
else {
|
|
589
589
|
task.attempt = nextAttempt;
|
|
590
|
-
task.status =
|
|
590
|
+
task.status = constants_js_1.TaskStatus.FAILED;
|
|
591
591
|
task.error = serialized;
|
|
592
592
|
task.leaseOwner = undefined;
|
|
593
593
|
task.leaseExpiry = undefined;
|
|
@@ -597,7 +597,7 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
597
597
|
await taskCtx.pipe(logging_1.LogLevel.error, `Task failed (max attempts reached)`, {
|
|
598
598
|
maxAttempts: task.maxAttempts,
|
|
599
599
|
});
|
|
600
|
-
await this.emitStatus(taskCtx, task,
|
|
600
|
+
await this.emitStatus(taskCtx, task, constants_js_1.TaskStatus.FAILED, serialized, err);
|
|
601
601
|
}
|
|
602
602
|
}
|
|
603
603
|
}
|
|
@@ -605,38 +605,38 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
605
605
|
task.leaseOwner = undefined;
|
|
606
606
|
task.leaseExpiry = undefined;
|
|
607
607
|
switch (request.status) {
|
|
608
|
-
case
|
|
608
|
+
case constants_js_1.TaskStatus.CANCELED: {
|
|
609
609
|
const cancelError = request.error ??
|
|
610
|
-
new
|
|
610
|
+
new TaskErrorModel_js_1.TaskErrorModel({
|
|
611
611
|
message: `Task ${task.id} canceled`,
|
|
612
612
|
});
|
|
613
|
-
task.status =
|
|
613
|
+
task.status = constants_js_1.TaskStatus.CANCELED;
|
|
614
614
|
task.error = cancelError;
|
|
615
615
|
task.nextRunAt = undefined;
|
|
616
616
|
task.scheduledTo = undefined;
|
|
617
617
|
task = await this.tasks.update(task, ctx);
|
|
618
|
-
await this.emitStatus(ctx, task,
|
|
618
|
+
await this.emitStatus(ctx, task, constants_js_1.TaskStatus.CANCELED, cancelError);
|
|
619
619
|
await ctx.pipe(logging_1.LogLevel.warn, `Task canceled via context`);
|
|
620
620
|
return;
|
|
621
621
|
}
|
|
622
|
-
case
|
|
622
|
+
case constants_js_1.TaskStatus.WAITING_RETRY: {
|
|
623
623
|
const nextAttempt = (task.attempt ?? 0) + 1;
|
|
624
624
|
const backoff = this.normalizeBackoff(task.backoff);
|
|
625
|
-
const delay = (0,
|
|
625
|
+
const delay = (0, utils_js_1.computeBackoffMs)(nextAttempt, backoff);
|
|
626
626
|
const nextRunAt = request.scheduledTo instanceof Date
|
|
627
627
|
? request.scheduledTo
|
|
628
628
|
: new Date(Date.now() + delay);
|
|
629
629
|
const retryError = request.error ??
|
|
630
|
-
new
|
|
630
|
+
new TaskErrorModel_js_1.TaskErrorModel({
|
|
631
631
|
message: `Task ${task.id} requested retry`,
|
|
632
632
|
});
|
|
633
|
-
task.status =
|
|
633
|
+
task.status = constants_js_1.TaskStatus.WAITING_RETRY;
|
|
634
634
|
task.attempt = nextAttempt;
|
|
635
635
|
task.error = retryError;
|
|
636
636
|
task.nextRunAt = nextRunAt;
|
|
637
637
|
task.scheduledTo = undefined;
|
|
638
638
|
task = await this.tasks.update(task, ctx);
|
|
639
|
-
await this.emitStatus(ctx, task,
|
|
639
|
+
await this.emitStatus(ctx, task, constants_js_1.TaskStatus.WAITING_RETRY, retryError);
|
|
640
640
|
await ctx.pipe(logging_1.LogLevel.warn, `Retry requested`, {
|
|
641
641
|
nextRunAt,
|
|
642
642
|
delayMs: delay,
|
|
@@ -644,19 +644,19 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
644
644
|
});
|
|
645
645
|
return;
|
|
646
646
|
}
|
|
647
|
-
case
|
|
647
|
+
case constants_js_1.TaskStatus.SCHEDULED: {
|
|
648
648
|
if (!request.scheduledTo)
|
|
649
649
|
throw new db_decorators_1.InternalError("Scheduled state requires a target date");
|
|
650
650
|
const rescheduleError = request.error ??
|
|
651
|
-
new
|
|
651
|
+
new TaskErrorModel_js_1.TaskErrorModel({
|
|
652
652
|
message: `Task ${task.id} rescheduled`,
|
|
653
653
|
});
|
|
654
|
-
task.status =
|
|
654
|
+
task.status = constants_js_1.TaskStatus.SCHEDULED;
|
|
655
655
|
task.scheduledTo = request.scheduledTo;
|
|
656
656
|
task.error = rescheduleError;
|
|
657
657
|
task.nextRunAt = undefined;
|
|
658
658
|
task = await this.tasks.update(task, ctx);
|
|
659
|
-
await this.emitStatus(ctx, task,
|
|
659
|
+
await this.emitStatus(ctx, task, constants_js_1.TaskStatus.SCHEDULED, rescheduleError);
|
|
660
660
|
await ctx.pipe(logging_1.LogLevel.info, `Task rescheduled`, {
|
|
661
661
|
scheduledTo: request.scheduledTo.toISOString(),
|
|
662
662
|
});
|
|
@@ -673,13 +673,13 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
673
673
|
const results = this.normalizeStepResults(task.stepResults);
|
|
674
674
|
const cacheResult = (key, value) => {
|
|
675
675
|
context.cacheResult(key, value);
|
|
676
|
-
if (ctx instanceof
|
|
676
|
+
if (ctx instanceof TaskContext_js_1.TaskContext && ctx !== context) {
|
|
677
677
|
ctx.cacheResult(key, value);
|
|
678
678
|
}
|
|
679
679
|
};
|
|
680
680
|
for (let i = 0; i < results.length; i += 1) {
|
|
681
681
|
const existing = results[i];
|
|
682
|
-
if (existing?.status ===
|
|
682
|
+
if (existing?.status === constants_js_1.TaskStatus.SUCCEEDED) {
|
|
683
683
|
const prevStep = steps[i];
|
|
684
684
|
if (!prevStep)
|
|
685
685
|
continue;
|
|
@@ -722,7 +722,7 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
722
722
|
const persisted = await this.tasks.update(task, context);
|
|
723
723
|
Object.assign(task, persisted);
|
|
724
724
|
steps = this.normalizeSteps(task.steps);
|
|
725
|
-
const updateEvent = await this.persistEvent(context, task.id,
|
|
725
|
+
const updateEvent = await this.persistEvent(context, task.id, constants_js_1.TaskEventType.UPDATE, {
|
|
726
726
|
status: "update",
|
|
727
727
|
currentStep: stepIndex,
|
|
728
728
|
totalSteps: steps.length,
|
|
@@ -742,8 +742,8 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
742
742
|
// Ensure step-tagged logs are flushed before advancing the step pointer.
|
|
743
743
|
await context.flush();
|
|
744
744
|
const now = new Date();
|
|
745
|
-
results[stepIndex] = new
|
|
746
|
-
status:
|
|
745
|
+
results[stepIndex] = new TaskStepResultModel_js_1.TaskStepResultModel({
|
|
746
|
+
status: constants_js_1.TaskStatus.SUCCEEDED,
|
|
747
747
|
output: out,
|
|
748
748
|
createdAt: now,
|
|
749
749
|
updatedAt: now,
|
|
@@ -772,15 +772,15 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
772
772
|
});
|
|
773
773
|
}
|
|
774
774
|
const now = new Date();
|
|
775
|
-
results[idx] = new
|
|
776
|
-
status:
|
|
777
|
-
error: (0,
|
|
775
|
+
results[idx] = new TaskStepResultModel_js_1.TaskStepResultModel({
|
|
776
|
+
status: constants_js_1.TaskStatus.FAILED,
|
|
777
|
+
error: (0, utils_js_1.serializeError)(err),
|
|
778
778
|
createdAt: now,
|
|
779
779
|
updatedAt: now,
|
|
780
780
|
});
|
|
781
781
|
task.stepResults = results;
|
|
782
782
|
task.currentStep = idx;
|
|
783
|
-
task.error = (0,
|
|
783
|
+
task.error = (0, utils_js_1.serializeError)(err);
|
|
784
784
|
// persist failure context before throwing (retry logic happens outside)
|
|
785
785
|
const persisted = await this.tasks.update(task);
|
|
786
786
|
Object.assign(task, persisted);
|
|
@@ -790,7 +790,7 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
790
790
|
return { stepResults: results };
|
|
791
791
|
}
|
|
792
792
|
normalizeBackoff(backoff) {
|
|
793
|
-
if (backoff instanceof
|
|
793
|
+
if (backoff instanceof TaskBackoffModel_js_1.TaskBackoffModel)
|
|
794
794
|
return backoff;
|
|
795
795
|
let payload = backoff ?? {};
|
|
796
796
|
if (typeof payload === "string") {
|
|
@@ -801,7 +801,7 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
801
801
|
payload = {};
|
|
802
802
|
}
|
|
803
803
|
}
|
|
804
|
-
return new
|
|
804
|
+
return new TaskBackoffModel_js_1.TaskBackoffModel(payload);
|
|
805
805
|
}
|
|
806
806
|
normalizeSteps(steps) {
|
|
807
807
|
if (!steps)
|
|
@@ -820,7 +820,7 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
820
820
|
if (!Array.isArray(payload))
|
|
821
821
|
return [];
|
|
822
822
|
return payload.map((step) => {
|
|
823
|
-
if (step instanceof
|
|
823
|
+
if (step instanceof TaskStepSpecModel_js_1.TaskStepSpecModel)
|
|
824
824
|
return step;
|
|
825
825
|
let value = step;
|
|
826
826
|
if (typeof value === "string") {
|
|
@@ -831,7 +831,7 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
831
831
|
value = {};
|
|
832
832
|
}
|
|
833
833
|
}
|
|
834
|
-
return new
|
|
834
|
+
return new TaskStepSpecModel_js_1.TaskStepSpecModel(value);
|
|
835
835
|
});
|
|
836
836
|
}
|
|
837
837
|
normalizeStepResults(results) {
|
|
@@ -851,7 +851,7 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
851
851
|
if (!Array.isArray(payload))
|
|
852
852
|
return [];
|
|
853
853
|
return payload.map((result) => {
|
|
854
|
-
if (result instanceof
|
|
854
|
+
if (result instanceof TaskStepResultModel_js_1.TaskStepResultModel)
|
|
855
855
|
return result;
|
|
856
856
|
let value = result;
|
|
857
857
|
if (typeof value === "string") {
|
|
@@ -862,7 +862,7 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
862
862
|
value = {};
|
|
863
863
|
}
|
|
864
864
|
}
|
|
865
|
-
return new
|
|
865
|
+
return new TaskStepResultModel_js_1.TaskStepResultModel(value);
|
|
866
866
|
});
|
|
867
867
|
}
|
|
868
868
|
// -------------------------
|
|
@@ -870,13 +870,13 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
870
870
|
// -------------------------
|
|
871
871
|
async appendLog(ctx, task, logEntries) {
|
|
872
872
|
const isMulti = Array.isArray(logEntries) && Array.isArray(logEntries[0]);
|
|
873
|
-
const step = task.atomicity ===
|
|
874
|
-
? ctx instanceof
|
|
873
|
+
const step = task.atomicity === constants_js_1.TaskType.COMPOSITE
|
|
874
|
+
? ctx instanceof TaskContext_js_1.TaskContext
|
|
875
875
|
? (ctx.step ?? task.currentStep)
|
|
876
876
|
: task.currentStep
|
|
877
877
|
: undefined;
|
|
878
878
|
const entries = (isMulti ? logEntries : [logEntries]).map(([level, msg, meta]) => {
|
|
879
|
-
return new
|
|
879
|
+
return new TaskLogEntryModel_js_1.TaskLogEntryModel({
|
|
880
880
|
level,
|
|
881
881
|
msg,
|
|
882
882
|
meta,
|
|
@@ -893,11 +893,11 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
893
893
|
}
|
|
894
894
|
}
|
|
895
895
|
async emitStatus(ctx, task, status, outputOrError, originalError) {
|
|
896
|
-
if (ctx instanceof
|
|
896
|
+
if (ctx instanceof TaskContext_js_1.TaskContext) {
|
|
897
897
|
await ctx.flush();
|
|
898
898
|
}
|
|
899
899
|
const payload = { status };
|
|
900
|
-
if (outputOrError && outputOrError instanceof
|
|
900
|
+
if (outputOrError && outputOrError instanceof TaskErrorModel_js_1.TaskErrorModel)
|
|
901
901
|
payload.error = outputOrError;
|
|
902
902
|
else if (outputOrError)
|
|
903
903
|
payload.output = outputOrError;
|
|
@@ -905,18 +905,18 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
905
905
|
payload.nextRunAt = task.nextRunAt;
|
|
906
906
|
if (task.scheduledTo)
|
|
907
907
|
payload.scheduledTo = task.scheduledTo;
|
|
908
|
-
const persisted = await this.persistEvent(ctx, task.id,
|
|
908
|
+
const persisted = await this.persistEvent(ctx, task.id, constants_js_1.TaskEventType.STATUS, payload);
|
|
909
909
|
const emittedPayload = originalError !== undefined
|
|
910
910
|
? Object.assign({}, payload, { originalError })
|
|
911
911
|
: payload;
|
|
912
|
-
const emitted = new
|
|
912
|
+
const emitted = new TaskEventModel_js_1.TaskEventModel({
|
|
913
913
|
...persisted,
|
|
914
914
|
payload: emittedPayload,
|
|
915
915
|
});
|
|
916
916
|
this.bus.emit(emitted, ctx);
|
|
917
917
|
}
|
|
918
918
|
async emitLog(ctx, taskId, entries) {
|
|
919
|
-
const evt = await this.persistEvent(ctx, taskId,
|
|
919
|
+
const evt = await this.persistEvent(ctx, taskId, constants_js_1.TaskEventType.LOG, entries.map((e) => ({
|
|
920
920
|
ts: e.ts,
|
|
921
921
|
level: e.level,
|
|
922
922
|
msg: e.msg,
|
|
@@ -946,11 +946,11 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
946
946
|
return [[level, msg, meta]];
|
|
947
947
|
}
|
|
948
948
|
async emitProgress(ctx, taskId, data) {
|
|
949
|
-
const evt = await this.persistEvent(ctx, taskId,
|
|
949
|
+
const evt = await this.persistEvent(ctx, taskId, constants_js_1.TaskEventType.PROGRESS, data);
|
|
950
950
|
this.bus.emit(evt, ctx);
|
|
951
951
|
}
|
|
952
952
|
async persistEvent(ctx, taskId, type, payload) {
|
|
953
|
-
const evt = new
|
|
953
|
+
const evt = new TaskEventModel_js_1.TaskEventModel({ taskId, classification: type, payload });
|
|
954
954
|
const created = await this.events.create(evt, ctx);
|
|
955
955
|
return created;
|
|
956
956
|
}
|
|
@@ -958,8 +958,9 @@ class TaskEngine extends ContextualLoggedClass_1.AbsContextual {
|
|
|
958
958
|
return `TaskEngine<${this.config.adapter.alias}>`;
|
|
959
959
|
}
|
|
960
960
|
async context(operation, overrides, ...args) {
|
|
961
|
-
return this.adapter.context(operation, overrides,
|
|
961
|
+
return this.adapter.context(operation, overrides, TaskModel_js_1.TaskModel, ...args);
|
|
962
962
|
}
|
|
963
963
|
}
|
|
964
964
|
exports.TaskEngine = TaskEngine;
|
|
965
|
+
//# sourceMappingURL=TaskEngine.js.map
|
|
965
966
|
//# sourceMappingURL=TaskEngine.js.map
|