@nest-batch/core 0.2.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/LICENSE +21 -0
- package/README.md +368 -0
- package/dist/src/adapters/in-process.adapter.d.ts +140 -0
- package/dist/src/adapters/in-process.adapter.d.ts.map +1 -0
- package/dist/src/adapters/in-process.adapter.js +86 -0
- package/dist/src/adapters/in-process.adapter.js.map +1 -0
- package/dist/src/adapters/index.d.ts +18 -0
- package/dist/src/adapters/index.d.ts.map +1 -0
- package/dist/src/adapters/index.js +35 -0
- package/dist/src/adapters/index.js.map +1 -0
- package/dist/src/builder/batch-builder.d.ts +26 -0
- package/dist/src/builder/batch-builder.d.ts.map +1 -0
- package/dist/src/builder/batch-builder.js +25 -0
- package/dist/src/builder/batch-builder.js.map +1 -0
- package/dist/src/builder/flow-builder.d.ts +59 -0
- package/dist/src/builder/flow-builder.d.ts.map +1 -0
- package/dist/src/builder/flow-builder.js +115 -0
- package/dist/src/builder/flow-builder.js.map +1 -0
- package/dist/src/builder/index.d.ts +5 -0
- package/dist/src/builder/index.d.ts.map +1 -0
- package/dist/src/builder/index.js +23 -0
- package/dist/src/builder/index.js.map +1 -0
- package/dist/src/builder/job-builder.d.ts +76 -0
- package/dist/src/builder/job-builder.d.ts.map +1 -0
- package/dist/src/builder/job-builder.js +166 -0
- package/dist/src/builder/job-builder.js.map +1 -0
- package/dist/src/builder/step-builder.d.ts +74 -0
- package/dist/src/builder/step-builder.d.ts.map +1 -0
- package/dist/src/builder/step-builder.js +144 -0
- package/dist/src/builder/step-builder.js.map +1 -0
- package/dist/src/compiler/builder-types.d.ts +20 -0
- package/dist/src/compiler/builder-types.d.ts.map +1 -0
- package/dist/src/compiler/builder-types.js +6 -0
- package/dist/src/compiler/builder-types.js.map +1 -0
- package/dist/src/compiler/definition-compiler.d.ts +99 -0
- package/dist/src/compiler/definition-compiler.d.ts.map +1 -0
- package/dist/src/compiler/definition-compiler.js +257 -0
- package/dist/src/compiler/definition-compiler.js.map +1 -0
- package/dist/src/compiler/index.d.ts +3 -0
- package/dist/src/compiler/index.d.ts.map +1 -0
- package/dist/src/compiler/index.js +21 -0
- package/dist/src/compiler/index.js.map +1 -0
- package/dist/src/core/errors.d.ts +77 -0
- package/dist/src/core/errors.d.ts.map +1 -0
- package/dist/src/core/errors.js +170 -0
- package/dist/src/core/errors.js.map +1 -0
- package/dist/src/core/execution-context/index.d.ts +4 -0
- package/dist/src/core/execution-context/index.d.ts.map +1 -0
- package/dist/src/core/execution-context/index.js +22 -0
- package/dist/src/core/execution-context/index.js.map +1 -0
- package/dist/src/core/execution-context/json-value.d.ts +5 -0
- package/dist/src/core/execution-context/json-value.d.ts.map +1 -0
- package/dist/src/core/execution-context/json-value.js +6 -0
- package/dist/src/core/execution-context/json-value.js.map +1 -0
- package/dist/src/core/execution-context/serializer.d.ts +4 -0
- package/dist/src/core/execution-context/serializer.d.ts.map +1 -0
- package/dist/src/core/execution-context/serializer.js +34 -0
- package/dist/src/core/execution-context/serializer.js.map +1 -0
- package/dist/src/core/execution-context/validator.d.ts +18 -0
- package/dist/src/core/execution-context/validator.d.ts.map +1 -0
- package/dist/src/core/execution-context/validator.js +90 -0
- package/dist/src/core/execution-context/validator.js.map +1 -0
- package/dist/src/core/index.d.ts +8 -0
- package/dist/src/core/index.d.ts.map +1 -0
- package/dist/src/core/index.js +26 -0
- package/dist/src/core/index.js.map +1 -0
- package/dist/src/core/ir/decider-definition.d.ts +20 -0
- package/dist/src/core/ir/decider-definition.d.ts.map +1 -0
- package/dist/src/core/ir/decider-definition.js +6 -0
- package/dist/src/core/ir/decider-definition.js.map +1 -0
- package/dist/src/core/ir/index.d.ts +8 -0
- package/dist/src/core/ir/index.d.ts.map +1 -0
- package/dist/src/core/ir/index.js +26 -0
- package/dist/src/core/ir/index.js.map +1 -0
- package/dist/src/core/ir/job-definition.d.ts +15 -0
- package/dist/src/core/ir/job-definition.d.ts.map +1 -0
- package/dist/src/core/ir/job-definition.js +6 -0
- package/dist/src/core/ir/job-definition.js.map +1 -0
- package/dist/src/core/ir/listener-definition.d.ts +10 -0
- package/dist/src/core/ir/listener-definition.d.ts.map +1 -0
- package/dist/src/core/ir/listener-definition.js +6 -0
- package/dist/src/core/ir/listener-definition.js.map +1 -0
- package/dist/src/core/ir/policy-config.d.ts +24 -0
- package/dist/src/core/ir/policy-config.d.ts.map +1 -0
- package/dist/src/core/ir/policy-config.js +6 -0
- package/dist/src/core/ir/policy-config.js.map +1 -0
- package/dist/src/core/ir/refs.d.ts +42 -0
- package/dist/src/core/ir/refs.d.ts.map +1 -0
- package/dist/src/core/ir/refs.js +18 -0
- package/dist/src/core/ir/refs.js.map +1 -0
- package/dist/src/core/ir/step-definition.d.ts +59 -0
- package/dist/src/core/ir/step-definition.d.ts.map +1 -0
- package/dist/src/core/ir/step-definition.js +6 -0
- package/dist/src/core/ir/step-definition.js.map +1 -0
- package/dist/src/core/ir/transition-definition.d.ts +8 -0
- package/dist/src/core/ir/transition-definition.d.ts.map +1 -0
- package/dist/src/core/ir/transition-definition.js +6 -0
- package/dist/src/core/ir/transition-definition.js.map +1 -0
- package/dist/src/core/item/index.d.ts +2 -0
- package/dist/src/core/item/index.d.ts.map +1 -0
- package/dist/src/core/item/index.js +20 -0
- package/dist/src/core/item/index.js.map +1 -0
- package/dist/src/core/item/interfaces.d.ts +64 -0
- package/dist/src/core/item/interfaces.d.ts.map +1 -0
- package/dist/src/core/item/interfaces.js +6 -0
- package/dist/src/core/item/interfaces.js.map +1 -0
- package/dist/src/core/repository/index.d.ts +3 -0
- package/dist/src/core/repository/index.d.ts.map +1 -0
- package/dist/src/core/repository/index.js +21 -0
- package/dist/src/core/repository/index.js.map +1 -0
- package/dist/src/core/repository/job-repository.d.ts +60 -0
- package/dist/src/core/repository/job-repository.d.ts.map +1 -0
- package/dist/src/core/repository/job-repository.js +27 -0
- package/dist/src/core/repository/job-repository.js.map +1 -0
- package/dist/src/core/repository/types.d.ts +84 -0
- package/dist/src/core/repository/types.d.ts.map +1 -0
- package/dist/src/core/repository/types.js +6 -0
- package/dist/src/core/repository/types.js.map +1 -0
- package/dist/src/core/status.d.ts +29 -0
- package/dist/src/core/status.d.ts.map +1 -0
- package/dist/src/core/status.js +58 -0
- package/dist/src/core/status.js.map +1 -0
- package/dist/src/core/transaction/index.d.ts +2 -0
- package/dist/src/core/transaction/index.d.ts.map +1 -0
- package/dist/src/core/transaction/index.js +20 -0
- package/dist/src/core/transaction/index.js.map +1 -0
- package/dist/src/core/transaction/transaction-manager.d.ts +8 -0
- package/dist/src/core/transaction/transaction-manager.d.ts.map +1 -0
- package/dist/src/core/transaction/transaction-manager.js +14 -0
- package/dist/src/core/transaction/transaction-manager.js.map +1 -0
- package/dist/src/core/validation/definition-validator.d.ts +46 -0
- package/dist/src/core/validation/definition-validator.d.ts.map +1 -0
- package/dist/src/core/validation/definition-validator.js +177 -0
- package/dist/src/core/validation/definition-validator.js.map +1 -0
- package/dist/src/core/validation/index.d.ts +2 -0
- package/dist/src/core/validation/index.d.ts.map +1 -0
- package/dist/src/core/validation/index.js +20 -0
- package/dist/src/core/validation/index.js.map +1 -0
- package/dist/src/decorators/constants.d.ts +10 -0
- package/dist/src/decorators/constants.d.ts.map +1 -0
- package/dist/src/decorators/constants.js +50 -0
- package/dist/src/decorators/constants.js.map +1 -0
- package/dist/src/decorators/flow.decorator.d.ts +25 -0
- package/dist/src/decorators/flow.decorator.d.ts.map +1 -0
- package/dist/src/decorators/flow.decorator.js +19 -0
- package/dist/src/decorators/flow.decorator.js.map +1 -0
- package/dist/src/decorators/index.d.ts +8 -0
- package/dist/src/decorators/index.d.ts.map +1 -0
- package/dist/src/decorators/index.js +26 -0
- package/dist/src/decorators/index.js.map +1 -0
- package/dist/src/decorators/item.decorators.d.ts +32 -0
- package/dist/src/decorators/item.decorators.d.ts.map +1 -0
- package/dist/src/decorators/item.decorators.js +40 -0
- package/dist/src/decorators/item.decorators.js.map +1 -0
- package/dist/src/decorators/job.decorator.d.ts +11 -0
- package/dist/src/decorators/job.decorator.d.ts.map +1 -0
- package/dist/src/decorators/job.decorator.js +17 -0
- package/dist/src/decorators/job.decorator.js.map +1 -0
- package/dist/src/decorators/listener.decorators.d.ts +56 -0
- package/dist/src/decorators/listener.decorators.d.ts.map +1 -0
- package/dist/src/decorators/listener.decorators.js +157 -0
- package/dist/src/decorators/listener.decorators.js.map +1 -0
- package/dist/src/decorators/step.decorator.d.ts +25 -0
- package/dist/src/decorators/step.decorator.d.ts.map +1 -0
- package/dist/src/decorators/step.decorator.js +21 -0
- package/dist/src/decorators/step.decorator.js.map +1 -0
- package/dist/src/decorators/tasklet.decorator.d.ts +7 -0
- package/dist/src/decorators/tasklet.decorator.d.ts.map +1 -0
- package/dist/src/decorators/tasklet.decorator.js +21 -0
- package/dist/src/decorators/tasklet.decorator.js.map +1 -0
- package/dist/src/execution/batch-worker-runner.d.ts +27 -0
- package/dist/src/execution/batch-worker-runner.d.ts.map +1 -0
- package/dist/src/execution/batch-worker-runner.js +147 -0
- package/dist/src/execution/batch-worker-runner.js.map +1 -0
- package/dist/src/execution/chunk-step-executor.d.ts +86 -0
- package/dist/src/execution/chunk-step-executor.d.ts.map +1 -0
- package/dist/src/execution/chunk-step-executor.js +482 -0
- package/dist/src/execution/chunk-step-executor.js.map +1 -0
- package/dist/src/execution/execution-strategy.d.ts +110 -0
- package/dist/src/execution/execution-strategy.d.ts.map +1 -0
- package/dist/src/execution/execution-strategy.js +13 -0
- package/dist/src/execution/execution-strategy.js.map +1 -0
- package/dist/src/execution/external-task-execution-strategy.d.ts +36 -0
- package/dist/src/execution/external-task-execution-strategy.d.ts.map +1 -0
- package/dist/src/execution/external-task-execution-strategy.js +97 -0
- package/dist/src/execution/external-task-execution-strategy.js.map +1 -0
- package/dist/src/execution/in-process-execution-strategy.d.ts +129 -0
- package/dist/src/execution/in-process-execution-strategy.d.ts.map +1 -0
- package/dist/src/execution/in-process-execution-strategy.js +141 -0
- package/dist/src/execution/in-process-execution-strategy.js.map +1 -0
- package/dist/src/execution/index.d.ts +14 -0
- package/dist/src/execution/index.d.ts.map +1 -0
- package/dist/src/execution/index.js +32 -0
- package/dist/src/execution/index.js.map +1 -0
- package/dist/src/execution/job-executor.d.ts +145 -0
- package/dist/src/execution/job-executor.d.ts.map +1 -0
- package/dist/src/execution/job-executor.js +475 -0
- package/dist/src/execution/job-executor.js.map +1 -0
- package/dist/src/execution/job-explorer.d.ts +15 -0
- package/dist/src/execution/job-explorer.d.ts.map +1 -0
- package/dist/src/execution/job-explorer.js +84 -0
- package/dist/src/execution/job-explorer.js.map +1 -0
- package/dist/src/execution/job-key.d.ts +3 -0
- package/dist/src/execution/job-key.d.ts.map +1 -0
- package/dist/src/execution/job-key.js +43 -0
- package/dist/src/execution/job-key.js.map +1 -0
- package/dist/src/execution/job-launcher.d.ts +75 -0
- package/dist/src/execution/job-launcher.d.ts.map +1 -0
- package/dist/src/execution/job-launcher.js +112 -0
- package/dist/src/execution/job-launcher.js.map +1 -0
- package/dist/src/execution/job-operator.d.ts +22 -0
- package/dist/src/execution/job-operator.d.ts.map +1 -0
- package/dist/src/execution/job-operator.js +125 -0
- package/dist/src/execution/job-operator.js.map +1 -0
- package/dist/src/execution/listener-invoker.d.ts +164 -0
- package/dist/src/execution/listener-invoker.d.ts.map +1 -0
- package/dist/src/execution/listener-invoker.js +246 -0
- package/dist/src/execution/listener-invoker.js.map +1 -0
- package/dist/src/execution/ref-resolver.d.ts +40 -0
- package/dist/src/execution/ref-resolver.d.ts.map +1 -0
- package/dist/src/execution/ref-resolver.js +41 -0
- package/dist/src/execution/ref-resolver.js.map +1 -0
- package/dist/src/execution/tasklet-step-executor.d.ts +79 -0
- package/dist/src/execution/tasklet-step-executor.d.ts.map +1 -0
- package/dist/src/execution/tasklet-step-executor.js +138 -0
- package/dist/src/execution/tasklet-step-executor.js.map +1 -0
- package/dist/src/explorer/batch-explorer.d.ts +138 -0
- package/dist/src/explorer/batch-explorer.d.ts.map +1 -0
- package/dist/src/explorer/batch-explorer.js +167 -0
- package/dist/src/explorer/batch-explorer.js.map +1 -0
- package/dist/src/explorer/index.d.ts +2 -0
- package/dist/src/explorer/index.d.ts.map +1 -0
- package/dist/src/explorer/index.js +20 -0
- package/dist/src/explorer/index.js.map +1 -0
- package/dist/src/flow/flow-evaluator.d.ts +30 -0
- package/dist/src/flow/flow-evaluator.d.ts.map +1 -0
- package/dist/src/flow/flow-evaluator.js +80 -0
- package/dist/src/flow/flow-evaluator.js.map +1 -0
- package/dist/src/flow/index.d.ts +2 -0
- package/dist/src/flow/index.d.ts.map +1 -0
- package/dist/src/flow/index.js +20 -0
- package/dist/src/flow/index.js.map +1 -0
- package/dist/src/index.d.ts +18 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +90 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/io/checkpoint.d.ts +7 -0
- package/dist/src/io/checkpoint.d.ts.map +1 -0
- package/dist/src/io/checkpoint.js +56 -0
- package/dist/src/io/checkpoint.js.map +1 -0
- package/dist/src/io/database.d.ts +50 -0
- package/dist/src/io/database.d.ts.map +1 -0
- package/dist/src/io/database.js +108 -0
- package/dist/src/io/database.js.map +1 -0
- package/dist/src/io/file-readers.d.ts +54 -0
- package/dist/src/io/file-readers.d.ts.map +1 -0
- package/dist/src/io/file-readers.js +167 -0
- package/dist/src/io/file-readers.js.map +1 -0
- package/dist/src/io/file-writers.d.ts +31 -0
- package/dist/src/io/file-writers.d.ts.map +1 -0
- package/dist/src/io/file-writers.js +80 -0
- package/dist/src/io/file-writers.js.map +1 -0
- package/dist/src/io/index.d.ts +6 -0
- package/dist/src/io/index.d.ts.map +1 -0
- package/dist/src/io/index.js +24 -0
- package/dist/src/io/index.js.map +1 -0
- package/dist/src/io/s3.d.ts +50 -0
- package/dist/src/io/s3.d.ts.map +1 -0
- package/dist/src/io/s3.js +96 -0
- package/dist/src/io/s3.js.map +1 -0
- package/dist/src/listeners/builtin-listeners.d.ts +77 -0
- package/dist/src/listeners/builtin-listeners.d.ts.map +1 -0
- package/dist/src/listeners/builtin-listeners.js +108 -0
- package/dist/src/listeners/builtin-listeners.js.map +1 -0
- package/dist/src/listeners/index.d.ts +8 -0
- package/dist/src/listeners/index.d.ts.map +1 -0
- package/dist/src/listeners/index.js +25 -0
- package/dist/src/listeners/index.js.map +1 -0
- package/dist/src/module/adapter-options.d.ts +39 -0
- package/dist/src/module/adapter-options.d.ts.map +1 -0
- package/dist/src/module/adapter-options.js +34 -0
- package/dist/src/module/adapter-options.js.map +1 -0
- package/dist/src/module/adapter.d.ts +157 -0
- package/dist/src/module/adapter.d.ts.map +1 -0
- package/dist/src/module/adapter.js +80 -0
- package/dist/src/module/adapter.js.map +1 -0
- package/dist/src/module/batch-schedule-registry.d.ts +110 -0
- package/dist/src/module/batch-schedule-registry.d.ts.map +1 -0
- package/dist/src/module/batch-schedule-registry.js +0 -0
- package/dist/src/module/batch-schedule-registry.js.map +1 -0
- package/dist/src/module/index.d.ts +14 -0
- package/dist/src/module/index.d.ts.map +1 -0
- package/dist/src/module/index.js +31 -0
- package/dist/src/module/index.js.map +1 -0
- package/dist/src/module/nest-batch.module.d.ts +236 -0
- package/dist/src/module/nest-batch.module.d.ts.map +1 -0
- package/dist/src/module/nest-batch.module.js +475 -0
- package/dist/src/module/nest-batch.module.js.map +1 -0
- package/dist/src/module/tokens.d.ts +83 -0
- package/dist/src/module/tokens.d.ts.map +1 -0
- package/dist/src/module/tokens.js +58 -0
- package/dist/src/module/tokens.js.map +1 -0
- package/dist/src/observability/event-types.d.ts +55 -0
- package/dist/src/observability/event-types.d.ts.map +1 -0
- package/dist/src/observability/event-types.js +36 -0
- package/dist/src/observability/event-types.js.map +1 -0
- package/dist/src/observability/exporters.d.ts +35 -0
- package/dist/src/observability/exporters.d.ts.map +1 -0
- package/dist/src/observability/exporters.js +93 -0
- package/dist/src/observability/exporters.js.map +1 -0
- package/dist/src/observability/index.d.ts +3 -0
- package/dist/src/observability/index.d.ts.map +1 -0
- package/dist/src/observability/index.js +21 -0
- package/dist/src/observability/index.js.map +1 -0
- package/dist/src/partition-helpers.d.ts +127 -0
- package/dist/src/partition-helpers.d.ts.map +1 -0
- package/dist/src/partition-helpers.js +136 -0
- package/dist/src/partition-helpers.js.map +1 -0
- package/dist/src/policies/backoff.d.ts +3 -0
- package/dist/src/policies/backoff.d.ts.map +1 -0
- package/dist/src/policies/backoff.js +34 -0
- package/dist/src/policies/backoff.js.map +1 -0
- package/dist/src/policies/index.d.ts +4 -0
- package/dist/src/policies/index.d.ts.map +1 -0
- package/dist/src/policies/index.js +22 -0
- package/dist/src/policies/index.js.map +1 -0
- package/dist/src/policies/retry-policy.d.ts +13 -0
- package/dist/src/policies/retry-policy.d.ts.map +1 -0
- package/dist/src/policies/retry-policy.js +55 -0
- package/dist/src/policies/retry-policy.js.map +1 -0
- package/dist/src/policies/skip-policy.d.ts +12 -0
- package/dist/src/policies/skip-policy.d.ts.map +1 -0
- package/dist/src/policies/skip-policy.js +44 -0
- package/dist/src/policies/skip-policy.js.map +1 -0
- package/dist/src/registry/index.d.ts +2 -0
- package/dist/src/registry/index.d.ts.map +1 -0
- package/dist/src/registry/index.js +20 -0
- package/dist/src/registry/index.js.map +1 -0
- package/dist/src/registry/job-registry.d.ts +16 -0
- package/dist/src/registry/job-registry.d.ts.map +1 -0
- package/dist/src/registry/job-registry.js +50 -0
- package/dist/src/registry/job-registry.js.map +1 -0
- package/dist/src/repository/id-generator.d.ts +18 -0
- package/dist/src/repository/id-generator.d.ts.map +1 -0
- package/dist/src/repository/id-generator.js +37 -0
- package/dist/src/repository/id-generator.js.map +1 -0
- package/dist/src/repository/in-memory/in-memory-job-repository.d.ts +49 -0
- package/dist/src/repository/in-memory/in-memory-job-repository.d.ts.map +1 -0
- package/dist/src/repository/in-memory/in-memory-job-repository.js +291 -0
- package/dist/src/repository/in-memory/in-memory-job-repository.js.map +1 -0
- package/dist/src/repository/in-memory/index.d.ts +2 -0
- package/dist/src/repository/in-memory/index.d.ts.map +1 -0
- package/dist/src/repository/in-memory/index.js +20 -0
- package/dist/src/repository/in-memory/index.js.map +1 -0
- package/dist/src/repository/index.d.ts +4 -0
- package/dist/src/repository/index.d.ts.map +1 -0
- package/dist/src/repository/index.js +22 -0
- package/dist/src/repository/index.js.map +1 -0
- package/dist/src/repository/uuid-v7.d.ts +20 -0
- package/dist/src/repository/uuid-v7.d.ts.map +1 -0
- package/dist/src/repository/uuid-v7.js +31 -0
- package/dist/src/repository/uuid-v7.js.map +1 -0
- package/dist/src/scheduling/batch-scheduled.d.ts +87 -0
- package/dist/src/scheduling/batch-scheduled.d.ts.map +1 -0
- package/dist/src/scheduling/batch-scheduled.js +170 -0
- package/dist/src/scheduling/batch-scheduled.js.map +1 -0
- package/dist/src/transaction/in-memory-transaction-manager.d.ts +16 -0
- package/dist/src/transaction/in-memory-transaction-manager.d.ts.map +1 -0
- package/dist/src/transaction/in-memory-transaction-manager.js +33 -0
- package/dist/src/transaction/in-memory-transaction-manager.js.map +1 -0
- package/dist/src/transaction/index.d.ts +2 -0
- package/dist/src/transaction/index.d.ts.map +1 -0
- package/dist/src/transaction/index.js +20 -0
- package/dist/src/transaction/index.js.map +1 -0
- package/dist/tests/contracts/index.d.ts +26 -0
- package/dist/tests/contracts/index.d.ts.map +1 -0
- package/dist/tests/contracts/index.js +37 -0
- package/dist/tests/contracts/index.js.map +1 -0
- package/dist/tests/contracts/job-repository.contract.d.ts +46 -0
- package/dist/tests/contracts/job-repository.contract.d.ts.map +1 -0
- package/dist/tests/contracts/job-repository.contract.js +644 -0
- package/dist/tests/contracts/job-repository.contract.js.map +1 -0
- package/package.json +80 -0
- package/src/adapters/in-process.adapter.ts +182 -0
- package/src/adapters/index.ts +17 -0
- package/src/builder/batch-builder.ts +32 -0
- package/src/builder/flow-builder.ts +141 -0
- package/src/builder/index.ts +4 -0
- package/src/builder/job-builder.ts +206 -0
- package/src/builder/step-builder.ts +190 -0
- package/src/compiler/builder-types.ts +27 -0
- package/src/compiler/definition-compiler.ts +325 -0
- package/src/compiler/index.ts +2 -0
- package/src/core/errors.ts +125 -0
- package/src/core/execution-context/index.ts +3 -0
- package/src/core/execution-context/json-value.ts +3 -0
- package/src/core/execution-context/serializer.ts +21 -0
- package/src/core/execution-context/validator.ts +103 -0
- package/src/core/index.ts +7 -0
- package/src/core/ir/decider-definition.ts +25 -0
- package/src/core/ir/index.ts +7 -0
- package/src/core/ir/job-definition.ts +15 -0
- package/src/core/ir/listener-definition.ts +19 -0
- package/src/core/ir/policy-config.ts +19 -0
- package/src/core/ir/refs.ts +42 -0
- package/src/core/ir/step-definition.ts +62 -0
- package/src/core/ir/transition-definition.ts +9 -0
- package/src/core/item/index.ts +1 -0
- package/src/core/item/interfaces.ts +70 -0
- package/src/core/repository/index.ts +2 -0
- package/src/core/repository/job-repository.ts +100 -0
- package/src/core/repository/types.ts +91 -0
- package/src/core/status.ts +31 -0
- package/src/core/transaction/index.ts +1 -0
- package/src/core/transaction/transaction-manager.ts +8 -0
- package/src/core/validation/definition-validator.ts +215 -0
- package/src/core/validation/index.ts +1 -0
- package/src/decorators/constants.ts +9 -0
- package/src/decorators/flow.decorator.ts +31 -0
- package/src/decorators/index.ts +7 -0
- package/src/decorators/item.decorators.ts +51 -0
- package/src/decorators/job.decorator.ts +16 -0
- package/src/decorators/listener.decorators.ts +142 -0
- package/src/decorators/step.decorator.ts +33 -0
- package/src/decorators/tasklet.decorator.ts +14 -0
- package/src/execution/batch-worker-runner.ts +142 -0
- package/src/execution/chunk-step-executor.ts +594 -0
- package/src/execution/execution-strategy.ts +115 -0
- package/src/execution/external-task-execution-strategy.ts +104 -0
- package/src/execution/in-process-execution-strategy.ts +207 -0
- package/src/execution/index.ts +13 -0
- package/src/execution/job-executor.ts +553 -0
- package/src/execution/job-explorer.ts +73 -0
- package/src/execution/job-key.ts +35 -0
- package/src/execution/job-launcher.ts +132 -0
- package/src/execution/job-operator.ts +127 -0
- package/src/execution/listener-invoker.ts +389 -0
- package/src/execution/ref-resolver.ts +64 -0
- package/src/execution/tasklet-step-executor.ts +182 -0
- package/src/explorer/batch-explorer.ts +251 -0
- package/src/explorer/index.ts +1 -0
- package/src/flow/flow-evaluator.ts +89 -0
- package/src/flow/index.ts +1 -0
- package/src/index.ts +24 -0
- package/src/io/checkpoint.ts +47 -0
- package/src/io/database.ts +114 -0
- package/src/io/file-readers.ts +191 -0
- package/src/io/file-writers.ts +99 -0
- package/src/io/index.ts +5 -0
- package/src/io/s3.ts +117 -0
- package/src/listeners/builtin-listeners.ts +151 -0
- package/src/listeners/index.ts +7 -0
- package/src/module/adapter-options.ts +38 -0
- package/src/module/adapter.ts +160 -0
- package/src/module/batch-schedule-registry.ts +0 -0
- package/src/module/index.ts +13 -0
- package/src/module/nest-batch.module.ts +674 -0
- package/src/module/tokens.ts +95 -0
- package/src/observability/event-types.ts +61 -0
- package/src/observability/exporters.ts +96 -0
- package/src/observability/index.ts +2 -0
- package/src/partition-helpers.ts +204 -0
- package/src/policies/backoff.ts +22 -0
- package/src/policies/index.ts +3 -0
- package/src/policies/retry-policy.ts +57 -0
- package/src/policies/skip-policy.ts +51 -0
- package/src/registry/index.ts +1 -0
- package/src/registry/job-registry.ts +42 -0
- package/src/repository/id-generator.ts +25 -0
- package/src/repository/in-memory/in-memory-job-repository.ts +334 -0
- package/src/repository/in-memory/index.ts +1 -0
- package/src/repository/index.ts +3 -0
- package/src/repository/uuid-v7.ts +40 -0
- package/src/scheduling/batch-scheduled.ts +257 -0
- package/src/transaction/in-memory-transaction-manager.ts +23 -0
- package/src/transaction/index.ts +1 -0
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
get InMemoryJobRepository () {
|
|
13
|
+
return InMemoryJobRepository;
|
|
14
|
+
},
|
|
15
|
+
get RESTARTABLE_DEFAULT_INMEMORY () {
|
|
16
|
+
return RESTARTABLE_DEFAULT_INMEMORY;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
const _common = require("@nestjs/common");
|
|
20
|
+
const _core = require("@nest-batch/core");
|
|
21
|
+
const _idgenerator = require("../id-generator");
|
|
22
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
23
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
24
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
25
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
26
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
27
|
+
}
|
|
28
|
+
function _ts_metadata(k, v) {
|
|
29
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
30
|
+
}
|
|
31
|
+
function deepClone(value) {
|
|
32
|
+
if (value === null || typeof value !== 'object') return value;
|
|
33
|
+
if (value instanceof Date) return new Date(value.getTime());
|
|
34
|
+
if (Array.isArray(value)) return value.map((v)=>deepClone(v));
|
|
35
|
+
const out = {};
|
|
36
|
+
for (const k of Object.keys(value)){
|
|
37
|
+
out[k] = deepClone(value[k]);
|
|
38
|
+
}
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
function scopeKey(scope) {
|
|
42
|
+
if ('jobExecutionId' in scope) return `job::${scope.jobExecutionId}`;
|
|
43
|
+
return `step::${scope.stepExecutionId}`;
|
|
44
|
+
}
|
|
45
|
+
let InMemoryJobRepository = class InMemoryJobRepository extends _core.JobRepository {
|
|
46
|
+
idGen;
|
|
47
|
+
state = {
|
|
48
|
+
instances: new Map(),
|
|
49
|
+
instancesByKey: new Map(),
|
|
50
|
+
executions: new Map(),
|
|
51
|
+
stepExecutions: new Map(),
|
|
52
|
+
contexts: new Map()
|
|
53
|
+
};
|
|
54
|
+
/** Promise-chain lock to serialize getOrCreateJobInstance calls. */ lock = Promise.resolve();
|
|
55
|
+
constructor(idGen = new _idgenerator.UuidIdGenerator()){
|
|
56
|
+
super(), this.idGen = idGen;
|
|
57
|
+
}
|
|
58
|
+
async withLock(fn) {
|
|
59
|
+
const prev = this.lock;
|
|
60
|
+
let release;
|
|
61
|
+
this.lock = new Promise((resolve)=>{
|
|
62
|
+
release = resolve;
|
|
63
|
+
});
|
|
64
|
+
try {
|
|
65
|
+
await prev;
|
|
66
|
+
return await fn();
|
|
67
|
+
} finally{
|
|
68
|
+
release();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async getOrCreateJobInstance(name, jobKey) {
|
|
72
|
+
return this.withLock(async ()=>{
|
|
73
|
+
const key = `${name}::${jobKey}`;
|
|
74
|
+
const existing = this.state.instancesByKey.get(key);
|
|
75
|
+
if (existing) return deepClone(existing);
|
|
76
|
+
const inst = {
|
|
77
|
+
id: this.idGen.next(),
|
|
78
|
+
jobName: name,
|
|
79
|
+
jobKey,
|
|
80
|
+
createdAt: new Date()
|
|
81
|
+
};
|
|
82
|
+
this.state.instances.set(inst.id, inst);
|
|
83
|
+
this.state.instancesByKey.set(key, inst);
|
|
84
|
+
return deepClone(inst);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
async createJobExecution(jobInstanceId, params) {
|
|
88
|
+
return this.withLock(async ()=>{
|
|
89
|
+
const exec = {
|
|
90
|
+
id: this.idGen.next(),
|
|
91
|
+
jobInstanceId,
|
|
92
|
+
status: _core.JobStatus.STARTING,
|
|
93
|
+
startTime: null,
|
|
94
|
+
endTime: null,
|
|
95
|
+
exitCode: '',
|
|
96
|
+
exitMessage: '',
|
|
97
|
+
params: deepClone(params)
|
|
98
|
+
};
|
|
99
|
+
this.state.executions.set(exec.id, exec);
|
|
100
|
+
return deepClone(exec);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
async createExecutionAtomic(name, jobKey, params) {
|
|
104
|
+
return this.withLock(async ()=>{
|
|
105
|
+
const key = `${name}::${jobKey}`;
|
|
106
|
+
let instance = this.state.instancesByKey.get(key);
|
|
107
|
+
if (!instance) {
|
|
108
|
+
instance = {
|
|
109
|
+
id: this.idGen.next(),
|
|
110
|
+
jobName: name,
|
|
111
|
+
jobKey,
|
|
112
|
+
createdAt: new Date()
|
|
113
|
+
};
|
|
114
|
+
this.state.instances.set(instance.id, instance);
|
|
115
|
+
this.state.instancesByKey.set(key, instance);
|
|
116
|
+
}
|
|
117
|
+
for (const exec of this.state.executions.values()){
|
|
118
|
+
if (exec.jobInstanceId === instance.id && (exec.status === _core.JobStatus.STARTING || exec.status === _core.JobStatus.STARTED)) {
|
|
119
|
+
throw new _core.JobExecutionAlreadyRunningError(exec.id);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const exec = {
|
|
123
|
+
id: this.idGen.next(),
|
|
124
|
+
jobInstanceId: instance.id,
|
|
125
|
+
status: _core.JobStatus.STARTING,
|
|
126
|
+
startTime: null,
|
|
127
|
+
endTime: null,
|
|
128
|
+
exitCode: '',
|
|
129
|
+
exitMessage: '',
|
|
130
|
+
params: deepClone(params)
|
|
131
|
+
};
|
|
132
|
+
this.state.executions.set(exec.id, exec);
|
|
133
|
+
return deepClone(exec);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
async getRunningJobExecution(jobInstanceId) {
|
|
137
|
+
return this.withLock(async ()=>{
|
|
138
|
+
for (const exec of this.state.executions.values()){
|
|
139
|
+
if (exec.jobInstanceId === jobInstanceId && (exec.status === _core.JobStatus.STARTING || exec.status === _core.JobStatus.STARTED)) {
|
|
140
|
+
return deepClone(exec);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return null;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
async updateJobExecution(executionId, patch) {
|
|
147
|
+
const cur = this.state.executions.get(executionId);
|
|
148
|
+
if (!cur) throw new Error(`JobExecution not found: ${executionId}`);
|
|
149
|
+
const next = {
|
|
150
|
+
...cur,
|
|
151
|
+
...patch,
|
|
152
|
+
startTime: patch.startTime === undefined ? cur.startTime : patch.startTime,
|
|
153
|
+
endTime: patch.endTime === undefined ? cur.endTime : patch.endTime
|
|
154
|
+
};
|
|
155
|
+
this.state.executions.set(executionId, next);
|
|
156
|
+
}
|
|
157
|
+
async getJobExecution(executionId) {
|
|
158
|
+
const e = this.state.executions.get(executionId);
|
|
159
|
+
return e ? deepClone(e) : null;
|
|
160
|
+
}
|
|
161
|
+
async getJobInstance(jobInstanceId) {
|
|
162
|
+
const instance = this.state.instances.get(jobInstanceId);
|
|
163
|
+
return instance ? deepClone(instance) : null;
|
|
164
|
+
}
|
|
165
|
+
async findJobInstances(filter = {}) {
|
|
166
|
+
const rows = [];
|
|
167
|
+
for (const instance of this.state.instances.values()){
|
|
168
|
+
if (filter.jobName !== undefined && instance.jobName !== filter.jobName) continue;
|
|
169
|
+
if (filter.jobKey !== undefined && instance.jobKey !== filter.jobKey) continue;
|
|
170
|
+
rows.push(deepClone(instance));
|
|
171
|
+
}
|
|
172
|
+
return rows;
|
|
173
|
+
}
|
|
174
|
+
async findJobExecutions(filter = {}) {
|
|
175
|
+
let statuses;
|
|
176
|
+
if (filter.status !== undefined) {
|
|
177
|
+
const statusFilter = filter.status;
|
|
178
|
+
const statusList = Array.isArray(statusFilter) ? statusFilter : [
|
|
179
|
+
statusFilter
|
|
180
|
+
];
|
|
181
|
+
statuses = new Set(statusList);
|
|
182
|
+
}
|
|
183
|
+
const rows = [];
|
|
184
|
+
for (const execution of this.state.executions.values()){
|
|
185
|
+
if (filter.jobInstanceId !== undefined && execution.jobInstanceId !== filter.jobInstanceId) {
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
if (statuses !== undefined && !statuses.has(execution.status)) continue;
|
|
189
|
+
if (filter.startedAfter !== undefined && (execution.startTime === null || execution.startTime < filter.startedAfter)) {
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
if (filter.startedBefore !== undefined && (execution.startTime === null || execution.startTime > filter.startedBefore)) {
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
rows.push(deepClone(execution));
|
|
196
|
+
}
|
|
197
|
+
return rows;
|
|
198
|
+
}
|
|
199
|
+
async createStepExecution(jobExecutionId, stepName) {
|
|
200
|
+
const step = {
|
|
201
|
+
id: this.idGen.next(),
|
|
202
|
+
jobExecutionId,
|
|
203
|
+
stepName,
|
|
204
|
+
status: _core.StepStatus.STARTING,
|
|
205
|
+
readCount: 0,
|
|
206
|
+
writeCount: 0,
|
|
207
|
+
skipCount: 0,
|
|
208
|
+
rollbackCount: 0,
|
|
209
|
+
commitCount: 0,
|
|
210
|
+
startTime: null,
|
|
211
|
+
endTime: null,
|
|
212
|
+
exitCode: '',
|
|
213
|
+
exitMessage: ''
|
|
214
|
+
};
|
|
215
|
+
this.state.stepExecutions.set(step.id, step);
|
|
216
|
+
return deepClone(step);
|
|
217
|
+
}
|
|
218
|
+
async updateStepExecution(stepExecutionId, patch) {
|
|
219
|
+
const cur = this.state.stepExecutions.get(stepExecutionId);
|
|
220
|
+
if (!cur) throw new Error(`StepExecution not found: ${stepExecutionId}`);
|
|
221
|
+
const next = {
|
|
222
|
+
...cur,
|
|
223
|
+
...patch
|
|
224
|
+
};
|
|
225
|
+
this.state.stepExecutions.set(stepExecutionId, next);
|
|
226
|
+
}
|
|
227
|
+
async getStepExecution(stepExecutionId) {
|
|
228
|
+
const s = this.state.stepExecutions.get(stepExecutionId);
|
|
229
|
+
return s ? deepClone(s) : null;
|
|
230
|
+
}
|
|
231
|
+
async findStepExecutions(jobExecutionId) {
|
|
232
|
+
const rows = [];
|
|
233
|
+
for (const step of this.state.stepExecutions.values()){
|
|
234
|
+
if (step.jobExecutionId === jobExecutionId) {
|
|
235
|
+
rows.push(deepClone(step));
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return rows;
|
|
239
|
+
}
|
|
240
|
+
async getExecutionContext(scope) {
|
|
241
|
+
const ctx = this.state.contexts.get(scopeKey(scope));
|
|
242
|
+
if (ctx) return {
|
|
243
|
+
data: deepClone(ctx.data),
|
|
244
|
+
version: ctx.version
|
|
245
|
+
};
|
|
246
|
+
return {
|
|
247
|
+
data: null,
|
|
248
|
+
version: 0
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
async saveExecutionContext(scope, ctx, version) {
|
|
252
|
+
// Validate JSON-serializability (per ExecutionContext contract)
|
|
253
|
+
(0, _core.assertJsonSerializable)(ctx.data);
|
|
254
|
+
const current = this.state.contexts.get(scopeKey(scope));
|
|
255
|
+
const nextVersion = version !== undefined ? version : (current?.version ?? 0) + 1;
|
|
256
|
+
this.state.contexts.set(scopeKey(scope), {
|
|
257
|
+
data: deepClone(ctx.data),
|
|
258
|
+
version: nextVersion
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Returns the most recently created StepExecution for the given
|
|
263
|
+
* (jobExecutionId, stepName) pair, or `null` if none exists. Insertion
|
|
264
|
+
* order over `Map` is stable (ES2015+), so a reverse scan picks the
|
|
265
|
+
* latest entry that matches the filter. The restart path filters the
|
|
266
|
+
* result further by status (FAILED) at the call site.
|
|
267
|
+
*/ async findLatestStepExecution(jobExecutionId, stepName) {
|
|
268
|
+
let latest = null;
|
|
269
|
+
for (const step of this.state.stepExecutions.values()){
|
|
270
|
+
if (step.jobExecutionId === jobExecutionId && step.stepName === stepName) {
|
|
271
|
+
if (!latest) {
|
|
272
|
+
latest = step;
|
|
273
|
+
}
|
|
274
|
+
// No monotonic timestamp on StepExecution itself; rely on Map
|
|
275
|
+
// insertion order: later-created entries override earlier ones.
|
|
276
|
+
latest = step;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return latest ? deepClone(latest) : null;
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
InMemoryJobRepository = _ts_decorate([
|
|
283
|
+
(0, _common.Injectable)(),
|
|
284
|
+
_ts_metadata("design:type", Function),
|
|
285
|
+
_ts_metadata("design:paramtypes", [
|
|
286
|
+
typeof IdGenerator === "undefined" ? Object : IdGenerator
|
|
287
|
+
])
|
|
288
|
+
], InMemoryJobRepository);
|
|
289
|
+
const RESTARTABLE_DEFAULT_INMEMORY = false;
|
|
290
|
+
|
|
291
|
+
//# sourceMappingURL=in-memory-job-repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/repository/in-memory/in-memory-job-repository.ts"],"sourcesContent":["import { Injectable } from '@nestjs/common';\nimport { JobRepository } from '@nest-batch/core';\nimport type {\n JobInstance,\n JobExecution,\n JobExecutionPatch,\n JobParameters,\n StepExecution,\n StepExecutionPatch,\n ExecutionContext,\n ExecutionScope,\n JobInstanceFilter,\n JobExecutionFilter,\n} from '@nest-batch/core';\nimport { JobStatus, StepStatus } from '@nest-batch/core';\nimport { JobExecutionAlreadyRunningError } from '@nest-batch/core';\nimport { assertJsonSerializable } from '@nest-batch/core';\nimport type { IdGenerator } from '../id-generator';\nimport { UuidIdGenerator } from '../id-generator';\n\nfunction deepClone<T>(value: T): T {\n if (value === null || typeof value !== 'object') return value;\n if (value instanceof Date) return new Date(value.getTime()) as unknown as T;\n if (Array.isArray(value)) return value.map((v) => deepClone(v)) as unknown as T;\n const out: Record<string, unknown> = {};\n for (const k of Object.keys(value as Record<string, unknown>)) {\n out[k] = deepClone((value as Record<string, unknown>)[k]);\n }\n return out as T;\n}\n\ninterface InMemoryState {\n instances: Map<string, JobInstance>; // key: instanceId\n instancesByKey: Map<string, JobInstance>; // key: `${name}::${jobKey}`\n executions: Map<string, JobExecution>;\n stepExecutions: Map<string, StepExecution>;\n contexts: Map<string, ExecutionContext>; // key: serialized ExecutionScope\n}\n\nfunction scopeKey(scope: ExecutionScope): string {\n if ('jobExecutionId' in scope) return `job::${scope.jobExecutionId}`;\n return `step::${scope.stepExecutionId}`;\n}\n\n/**\n * In-memory JobRepository with real-repo semantics:\n * - deterministic IDs (configurable via IdGenerator)\n * - deep clone on reads/writes to prevent mutation leaks\n * - async signatures\n * - uniqueness on (jobName, jobKey)\n * - getOrCreateJobInstance / createJobExecution / getRunningJobExecution\n * share a single promise-chain lock, so the check-then-create sequence\n * used by JobLauncher is race-safe\n *\n * restartable: false by default (per Metis directive: in-memory repo is non-restartable\n * because contexts are lost on process restart).\n */\n@Injectable()\nexport class InMemoryJobRepository extends JobRepository {\n private readonly state: InMemoryState = {\n instances: new Map(),\n instancesByKey: new Map(),\n executions: new Map(),\n stepExecutions: new Map(),\n contexts: new Map(),\n };\n /** Promise-chain lock to serialize getOrCreateJobInstance calls. */\n private lock: Promise<unknown> = Promise.resolve();\n\n constructor(private readonly idGen: IdGenerator = new UuidIdGenerator()) {\n super();\n }\n\n private async withLock<T>(fn: () => Promise<T>): Promise<T> {\n const prev = this.lock;\n let release!: () => void;\n this.lock = new Promise<void>((resolve) => {\n release = resolve;\n });\n try {\n await prev;\n return await fn();\n } finally {\n release();\n }\n }\n\n async getOrCreateJobInstance(name: string, jobKey: string): Promise<JobInstance> {\n return this.withLock(async () => {\n const key = `${name}::${jobKey}`;\n const existing = this.state.instancesByKey.get(key);\n if (existing) return deepClone(existing);\n const inst: JobInstance = {\n id: this.idGen.next(),\n jobName: name,\n jobKey,\n createdAt: new Date(),\n };\n this.state.instances.set(inst.id, inst);\n this.state.instancesByKey.set(key, inst);\n return deepClone(inst);\n });\n }\n\n async createJobExecution(jobInstanceId: string, params: JobParameters): Promise<JobExecution> {\n return this.withLock(async () => {\n const exec: JobExecution = {\n id: this.idGen.next(),\n jobInstanceId,\n status: JobStatus.STARTING,\n startTime: null,\n endTime: null,\n exitCode: '',\n exitMessage: '',\n params: deepClone(params),\n };\n this.state.executions.set(exec.id, exec);\n return deepClone(exec);\n });\n }\n\n async createExecutionAtomic(\n name: string,\n jobKey: string,\n params: JobParameters,\n ): Promise<JobExecution> {\n return this.withLock(async () => {\n const key = `${name}::${jobKey}`;\n let instance = this.state.instancesByKey.get(key);\n if (!instance) {\n instance = {\n id: this.idGen.next(),\n jobName: name,\n jobKey,\n createdAt: new Date(),\n };\n this.state.instances.set(instance.id, instance);\n this.state.instancesByKey.set(key, instance);\n }\n for (const exec of this.state.executions.values()) {\n if (\n exec.jobInstanceId === instance.id &&\n (exec.status === JobStatus.STARTING || exec.status === JobStatus.STARTED)\n ) {\n throw new JobExecutionAlreadyRunningError(exec.id);\n }\n }\n const exec: JobExecution = {\n id: this.idGen.next(),\n jobInstanceId: instance.id,\n status: JobStatus.STARTING,\n startTime: null,\n endTime: null,\n exitCode: '',\n exitMessage: '',\n params: deepClone(params),\n };\n this.state.executions.set(exec.id, exec);\n return deepClone(exec);\n });\n }\n\n async getRunningJobExecution(jobInstanceId: string): Promise<JobExecution | null> {\n return this.withLock(async () => {\n for (const exec of this.state.executions.values()) {\n if (\n exec.jobInstanceId === jobInstanceId &&\n (exec.status === JobStatus.STARTING || exec.status === JobStatus.STARTED)\n ) {\n return deepClone(exec);\n }\n }\n return null;\n });\n }\n\n async updateJobExecution(executionId: string, patch: JobExecutionPatch): Promise<void> {\n const cur = this.state.executions.get(executionId);\n if (!cur) throw new Error(`JobExecution not found: ${executionId}`);\n const next: JobExecution = {\n ...cur,\n ...patch,\n startTime: patch.startTime === undefined ? cur.startTime : patch.startTime,\n endTime: patch.endTime === undefined ? cur.endTime : patch.endTime,\n };\n this.state.executions.set(executionId, next);\n }\n\n async getJobExecution(executionId: string): Promise<JobExecution | null> {\n const e = this.state.executions.get(executionId);\n return e ? deepClone(e) : null;\n }\n\n override async getJobInstance(jobInstanceId: string): Promise<JobInstance | null> {\n const instance = this.state.instances.get(jobInstanceId);\n return instance ? deepClone(instance) : null;\n }\n\n override async findJobInstances(filter: JobInstanceFilter = {}): Promise<JobInstance[]> {\n const rows: JobInstance[] = [];\n for (const instance of this.state.instances.values()) {\n if (filter.jobName !== undefined && instance.jobName !== filter.jobName) continue;\n if (filter.jobKey !== undefined && instance.jobKey !== filter.jobKey) continue;\n rows.push(deepClone(instance));\n }\n return rows;\n }\n\n override async findJobExecutions(filter: JobExecutionFilter = {}): Promise<JobExecution[]> {\n let statuses: Set<JobStatus> | undefined;\n if (filter.status !== undefined) {\n const statusFilter = filter.status;\n const statusList: readonly JobStatus[] = Array.isArray(statusFilter)\n ? statusFilter\n : [statusFilter];\n statuses = new Set<JobStatus>(statusList);\n }\n\n const rows: JobExecution[] = [];\n for (const execution of this.state.executions.values()) {\n if (\n filter.jobInstanceId !== undefined &&\n execution.jobInstanceId !== filter.jobInstanceId\n ) {\n continue;\n }\n if (statuses !== undefined && !statuses.has(execution.status)) continue;\n if (\n filter.startedAfter !== undefined &&\n (execution.startTime === null || execution.startTime < filter.startedAfter)\n ) {\n continue;\n }\n if (\n filter.startedBefore !== undefined &&\n (execution.startTime === null || execution.startTime > filter.startedBefore)\n ) {\n continue;\n }\n rows.push(deepClone(execution));\n }\n return rows;\n }\n\n async createStepExecution(jobExecutionId: string, stepName: string): Promise<StepExecution> {\n const step: StepExecution = {\n id: this.idGen.next(),\n jobExecutionId,\n stepName,\n status: StepStatus.STARTING,\n readCount: 0,\n writeCount: 0,\n skipCount: 0,\n rollbackCount: 0,\n commitCount: 0,\n startTime: null,\n endTime: null,\n exitCode: '',\n exitMessage: '',\n };\n this.state.stepExecutions.set(step.id, step);\n return deepClone(step);\n }\n\n async updateStepExecution(stepExecutionId: string, patch: StepExecutionPatch): Promise<void> {\n const cur = this.state.stepExecutions.get(stepExecutionId);\n if (!cur) throw new Error(`StepExecution not found: ${stepExecutionId}`);\n const next: StepExecution = { ...cur, ...patch };\n this.state.stepExecutions.set(stepExecutionId, next);\n }\n\n async getStepExecution(stepExecutionId: string): Promise<StepExecution | null> {\n const s = this.state.stepExecutions.get(stepExecutionId);\n return s ? deepClone(s) : null;\n }\n\n override async findStepExecutions(jobExecutionId: string): Promise<StepExecution[]> {\n const rows: StepExecution[] = [];\n for (const step of this.state.stepExecutions.values()) {\n if (step.jobExecutionId === jobExecutionId) {\n rows.push(deepClone(step));\n }\n }\n return rows;\n }\n\n async getExecutionContext(scope: ExecutionScope): Promise<ExecutionContext> {\n const ctx = this.state.contexts.get(scopeKey(scope));\n if (ctx) return { data: deepClone(ctx.data), version: ctx.version };\n return { data: null, version: 0 };\n }\n\n async saveExecutionContext(\n scope: ExecutionScope,\n ctx: ExecutionContext,\n version?: number,\n ): Promise<void> {\n // Validate JSON-serializability (per ExecutionContext contract)\n assertJsonSerializable(ctx.data);\n const current = this.state.contexts.get(scopeKey(scope));\n const nextVersion = version !== undefined ? version : (current?.version ?? 0) + 1;\n this.state.contexts.set(scopeKey(scope), {\n data: deepClone(ctx.data),\n version: nextVersion,\n });\n }\n\n /**\n * Returns the most recently created StepExecution for the given\n * (jobExecutionId, stepName) pair, or `null` if none exists. Insertion\n * order over `Map` is stable (ES2015+), so a reverse scan picks the\n * latest entry that matches the filter. The restart path filters the\n * result further by status (FAILED) at the call site.\n */\n async findLatestStepExecution(\n jobExecutionId: string,\n stepName: string,\n ): Promise<StepExecution | null> {\n let latest: StepExecution | null = null;\n for (const step of this.state.stepExecutions.values()) {\n if (step.jobExecutionId === jobExecutionId && step.stepName === stepName) {\n if (!latest) {\n latest = step;\n }\n // No monotonic timestamp on StepExecution itself; rely on Map\n // insertion order: later-created entries override earlier ones.\n latest = step;\n }\n }\n return latest ? deepClone(latest) : null;\n }\n}\n\nexport const RESTARTABLE_DEFAULT_INMEMORY = false;\n"],"names":["InMemoryJobRepository","RESTARTABLE_DEFAULT_INMEMORY","deepClone","value","Date","getTime","Array","isArray","map","v","out","k","Object","keys","scopeKey","scope","jobExecutionId","stepExecutionId","JobRepository","state","instances","Map","instancesByKey","executions","stepExecutions","contexts","lock","Promise","resolve","idGen","UuidIdGenerator","withLock","fn","prev","release","getOrCreateJobInstance","name","jobKey","key","existing","get","inst","id","next","jobName","createdAt","set","createJobExecution","jobInstanceId","params","exec","status","JobStatus","STARTING","startTime","endTime","exitCode","exitMessage","createExecutionAtomic","instance","values","STARTED","JobExecutionAlreadyRunningError","getRunningJobExecution","updateJobExecution","executionId","patch","cur","Error","undefined","getJobExecution","e","getJobInstance","findJobInstances","filter","rows","push","findJobExecutions","statuses","statusFilter","statusList","Set","execution","has","startedAfter","startedBefore","createStepExecution","stepName","step","StepStatus","readCount","writeCount","skipCount","rollbackCount","commitCount","updateStepExecution","getStepExecution","s","findStepExecutions","getExecutionContext","ctx","data","version","saveExecutionContext","assertJsonSerializable","current","nextVersion","findLatestStepExecution","latest"],"mappings":";;;;;;;;;;;QA0DaA;eAAAA;;QAmRAC;eAAAA;;;wBA7Uc;sBACG;6BAiBE;;;;;;;;;;AAEhC,SAASC,UAAaC,KAAQ;IAC5B,IAAIA,UAAU,QAAQ,OAAOA,UAAU,UAAU,OAAOA;IACxD,IAAIA,iBAAiBC,MAAM,OAAO,IAAIA,KAAKD,MAAME,OAAO;IACxD,IAAIC,MAAMC,OAAO,CAACJ,QAAQ,OAAOA,MAAMK,GAAG,CAAC,CAACC,IAAMP,UAAUO;IAC5D,MAAMC,MAA+B,CAAC;IACtC,KAAK,MAAMC,KAAKC,OAAOC,IAAI,CAACV,OAAmC;QAC7DO,GAAG,CAACC,EAAE,GAAGT,UAAU,AAACC,KAAiC,CAACQ,EAAE;IAC1D;IACA,OAAOD;AACT;AAUA,SAASI,SAASC,KAAqB;IACrC,IAAI,oBAAoBA,OAAO,OAAO,CAAC,KAAK,EAAEA,MAAMC,cAAc,EAAE;IACpE,OAAO,CAAC,MAAM,EAAED,MAAME,eAAe,EAAE;AACzC;AAgBO,IAAA,AAAMjB,wBAAN,MAAMA,8BAA8BkB,mBAAa;;IACrCC,QAAuB;QACtCC,WAAW,IAAIC;QACfC,gBAAgB,IAAID;QACpBE,YAAY,IAAIF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AC7C,IAAIqF,KAAK,OAAO;YAAEC,MAAMnG,UAAUkG,IAAIC,IAAI;YAAGC,SAASF,IAAIE,OAAO;QAAC;QAClE,OAAO;YAAED,MAAM;YAAMC,SAAS;QAAE;IAClC;IAEA,MAAMC,qBACJxF,KAAqB,EACrBqF,GAAqB,EACrBE,OAAgB,EACD;QACf,gEAAgE;QAChEE,IAAAA,4BAAsB,EAACJ,IAAIC,IAAI;QAC/B,MAAMI,UAAU,IAAI,CAACtF,KAAK,CAACM,QAAQ,CAACe,GAAG,CAAC1B,SAASC;QACjD,MAAM2F,cAAcJ,YAAYjC,YAAYiC,UAAU,AAACG,CAAAA,SAASH,WAAW,CAAA,IAAK;QAChF,IAAI,CAACnF,KAAK,CAACM,QAAQ,CAACqB,GAAG,CAAChC,SAASC,QAAQ;YACvCsF,MAAMnG,UAAUkG,IAAIC,IAAI;YACxBC,SAASI;QACX;IACF;IAEA;;;;;;GAMC,GACD,MAAMC,wBACJ3F,cAAsB,EACtBuE,QAAgB,EACe;QAC/B,IAAIqB,SAA+B;QACnC,KAAK,MAAMpB,QAAQ,IAAI,CAACrE,KAAK,CAACK,cAAc,CAACoC,MAAM,GAAI;YACrD,IAAI4B,KAAKxE,cAAc,KAAKA,kBAAkBwE,KAAKD,QAAQ,KAAKA,UAAU;gBACxE,IAAI,CAACqB,QAAQ;oBACXA,SAASpB;gBACX;gBACA,8DAA8D;gBAC9D,gEAAgE;gBAChEoB,SAASpB;YACX;QACF;QACA,OAAOoB,SAAS1G,UAAU0G,UAAU;IACtC;AACF;;;;;;;;AAEO,MAAM3G,+BAA+B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/repository/in-memory/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./in-memory-job-repository"), exports);
|
|
6
|
+
function _export_star(from, to) {
|
|
7
|
+
Object.keys(from).forEach(function(k) {
|
|
8
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
9
|
+
Object.defineProperty(to, k, {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function() {
|
|
12
|
+
return from[k];
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return from;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/repository/in-memory/index.ts"],"sourcesContent":["export * from './in-memory-job-repository';\n"],"names":[],"mappings":";;;;qBAAc"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/repository/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
_export_star(require("./id-generator"), exports);
|
|
6
|
+
_export_star(require("./uuid-v7"), exports);
|
|
7
|
+
_export_star(require("./in-memory"), exports);
|
|
8
|
+
function _export_star(from, to) {
|
|
9
|
+
Object.keys(from).forEach(function(k) {
|
|
10
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
11
|
+
Object.defineProperty(to, k, {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function() {
|
|
14
|
+
return from[k];
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
return from;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/repository/index.ts"],"sourcesContent":["export * from './id-generator';\nexport * from './uuid-v7';\nexport * from './in-memory';\n"],"names":[],"mappings":";;;;qBAAc;qBACA;qBACA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UUID v7 generator — time-sortable IDs (first 48 bits are unix time ms).
|
|
3
|
+
*
|
|
4
|
+
* Suitable for execution IDs (JobExecution, StepExecution) where
|
|
5
|
+
* chronological ordering is useful — e.g., grouping recent runs in a
|
|
6
|
+
* log dashboard or in a B-tree keyed persistence layer.
|
|
7
|
+
*
|
|
8
|
+
* Layout per RFC 9562 §5.7:
|
|
9
|
+
* xxxxxxxx-xxxx-7xxx-yxxx-xxxxxxxxxxxx
|
|
10
|
+
* ^ts hi ^ts lo ^rand ^rand ^rand
|
|
11
|
+
* where:
|
|
12
|
+
* - positions 0-11 = 48-bit unix-ms timestamp (sortable)
|
|
13
|
+
* - position 14 = version nibble '7'
|
|
14
|
+
* - position 19 = variant nibble ∈ {8, 9, a, b} (top 2 bits = 10)
|
|
15
|
+
* - remaining 62 = random bits from `crypto.randomBytes(10)`
|
|
16
|
+
*/
|
|
17
|
+
export declare class UuidV7IdGenerator {
|
|
18
|
+
next(): string;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=uuid-v7.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uuid-v7.d.ts","sourceRoot":"","sources":["../../../src/repository/uuid-v7.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,iBAAiB;IAC5B,IAAI,IAAI,MAAM;CAoBf"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "UuidV7IdGenerator", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return UuidV7IdGenerator;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _crypto = require("crypto");
|
|
12
|
+
let UuidV7IdGenerator = class UuidV7IdGenerator {
|
|
13
|
+
next() {
|
|
14
|
+
// 48-bit timestamp in hex (12 chars) — Date.now() is bounded to ~2^41
|
|
15
|
+
// today, so padStart keeps it stable-width for predictable sorting.
|
|
16
|
+
const ts = Date.now().toString(16).padStart(12, '0');
|
|
17
|
+
// 80 random bits (10 bytes). We use byte 0's top nibble as the
|
|
18
|
+
// variant and place it explicitly in group 4; the remaining 9
|
|
19
|
+
// bytes (18 hex chars) fill the rest of the random slots.
|
|
20
|
+
const rand = (0, _crypto.randomBytes)(10);
|
|
21
|
+
// RFC 9562 §4.1 variant: top 2 bits of the variant nibble must be `10`.
|
|
22
|
+
// `& 0x3f` clears the top 2 bits, then `| 0x80` sets them to `10`,
|
|
23
|
+
// yielding a value in [0x80, 0xbf] whose hex first digit ∈ {8,9,a,b}.
|
|
24
|
+
const variantNibble = ((rand[0] ?? 0) & 0x3f | 0x80).toString(16)[0];
|
|
25
|
+
// 18 hex chars of pure random from the remaining 9 bytes.
|
|
26
|
+
const rest = rand.subarray(1).toString('hex');
|
|
27
|
+
return `${ts.slice(0, 8)}-${ts.slice(8, 12)}-7${rest.slice(0, 3)}-${variantNibble}${rest.slice(3, 6)}-${rest.slice(6, 18)}`;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=uuid-v7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/repository/uuid-v7.ts"],"sourcesContent":["import { randomBytes } from 'crypto';\n\n/**\n * UUID v7 generator — time-sortable IDs (first 48 bits are unix time ms).\n *\n * Suitable for execution IDs (JobExecution, StepExecution) where\n * chronological ordering is useful — e.g., grouping recent runs in a\n * log dashboard or in a B-tree keyed persistence layer.\n *\n * Layout per RFC 9562 §5.7:\n * xxxxxxxx-xxxx-7xxx-yxxx-xxxxxxxxxxxx\n * ^ts hi ^ts lo ^rand ^rand ^rand\n * where:\n * - positions 0-11 = 48-bit unix-ms timestamp (sortable)\n * - position 14 = version nibble '7'\n * - position 19 = variant nibble ∈ {8, 9, a, b} (top 2 bits = 10)\n * - remaining 62 = random bits from `crypto.randomBytes(10)`\n */\nexport class UuidV7IdGenerator {\n next(): string {\n // 48-bit timestamp in hex (12 chars) — Date.now() is bounded to ~2^41\n // today, so padStart keeps it stable-width for predictable sorting.\n const ts = Date.now().toString(16).padStart(12, '0');\n\n // 80 random bits (10 bytes). We use byte 0's top nibble as the\n // variant and place it explicitly in group 4; the remaining 9\n // bytes (18 hex chars) fill the rest of the random slots.\n const rand = randomBytes(10);\n\n // RFC 9562 §4.1 variant: top 2 bits of the variant nibble must be `10`.\n // `& 0x3f` clears the top 2 bits, then `| 0x80` sets them to `10`,\n // yielding a value in [0x80, 0xbf] whose hex first digit ∈ {8,9,a,b}.\n const variantNibble = ((((rand[0] ?? 0) & 0x3f) | 0x80).toString(16) as string)[0];\n\n // 18 hex chars of pure random from the remaining 9 bytes.\n const rest = rand.subarray(1).toString('hex');\n\n return `${ts.slice(0, 8)}-${ts.slice(8, 12)}-7${rest.slice(0, 3)}-${variantNibble}${rest.slice(3, 6)}-${rest.slice(6, 18)}`;\n }\n}\n"],"names":["UuidV7IdGenerator","next","ts","Date","now","toString","padStart","rand","randomBytes","variantNibble","rest","subarray","slice"],"mappings":";;;;+BAkBaA;;;eAAAA;;;wBAlBe;AAkBrB,IAAA,AAAMA,oBAAN,MAAMA;IACXC,OAAe;QACb,sEAAsE;QACtE,oEAAoE;QACpE,MAAMC,KAAKC,KAAKC,GAAG,GAAGC,QAAQ,CAAC,IAAIC,QAAQ,CAAC,IAAI;QAEhD,+DAA+D;QAC/D,8DAA8D;QAC9D,0DAA0D;QAC1D,MAAMC,OAAOC,IAAAA,mBAAW,EAAC;QAEzB,wEAAwE;QACxE,mEAAmE;QACnE,sEAAsE;QACtE,MAAMC,gBAAgB,AAAC,AAAC,CAAA,AAAEF,CAAAA,IAAI,CAAC,EAAE,IAAI,CAAA,IAAK,OAAQ,IAAG,EAAGF,QAAQ,CAAC,GAAc,CAAC,EAAE;QAElF,0DAA0D;QAC1D,MAAMK,OAAOH,KAAKI,QAAQ,CAAC,GAAGN,QAAQ,CAAC;QAEvC,OAAO,GAAGH,GAAGU,KAAK,CAAC,GAAG,GAAG,CAAC,EAAEV,GAAGU,KAAK,CAAC,GAAG,IAAI,EAAE,EAAEF,KAAKE,KAAK,CAAC,GAAG,GAAG,CAAC,EAAEH,gBAAgBC,KAAKE,KAAK,CAAC,GAAG,GAAG,CAAC,EAAEF,KAAKE,KAAK,CAAC,GAAG,KAAK;IAC7H;AACF"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
export declare const BATCH_SCHEDULED_OPTIONS = "nest-batch:scheduled";
|
|
3
|
+
/**
|
|
4
|
+
* Overlap policies for cron-scheduled jobs:
|
|
5
|
+
*
|
|
6
|
+
* - `'skip'` — drop the new tick if the previous run is still in flight.
|
|
7
|
+
* - `'queue'` — buffer the new tick and start it after the current one ends.
|
|
8
|
+
* - `'parallel'` — start the new tick alongside the current one.
|
|
9
|
+
*
|
|
10
|
+
* The runtime scheduler (the future `@nest-batch/bullmq` cron strategy)
|
|
11
|
+
* reads this value off the stored metadata and applies the policy at
|
|
12
|
+
* dispatch time. The decorator itself MUST NOT silently default the
|
|
13
|
+
* policy to `'skip'` on the user's behalf — leaving it `undefined` here
|
|
14
|
+
* is the contract: the runtime applies the default.
|
|
15
|
+
*/
|
|
16
|
+
export type BatchOverlapPolicy = 'skip' | 'queue' | 'parallel';
|
|
17
|
+
/**
|
|
18
|
+
* Decorator-facing options for `@BatchScheduled`.
|
|
19
|
+
*
|
|
20
|
+
* - `name` — required, unique per job (used as the scheduling key).
|
|
21
|
+
* - `timezone` — required, IANA zone (e.g. `'UTC'`, `'Asia/Seoul'`).
|
|
22
|
+
* - `overlap` — optional, see `BatchOverlapPolicy`. Default applied at
|
|
23
|
+
* runtime, never silently here.
|
|
24
|
+
* - `startAt` — optional, absolute lower bound. Preserved by reference.
|
|
25
|
+
* - `endAt` — optional, absolute upper bound. Preserved by reference.
|
|
26
|
+
* - `inert` — optional, hints the runtime scheduler to skip actual
|
|
27
|
+
* registration. The decorator stamps this by reading
|
|
28
|
+
* `process.env.BATCH_SCHEDULED_DISABLE` at decoration time
|
|
29
|
+
* so the runtime never has to re-evaluate the env.
|
|
30
|
+
*/
|
|
31
|
+
export interface BatchScheduledOptions {
|
|
32
|
+
name: string;
|
|
33
|
+
timezone: string;
|
|
34
|
+
overlap?: BatchOverlapPolicy;
|
|
35
|
+
startAt?: Date;
|
|
36
|
+
endAt?: Date;
|
|
37
|
+
inert?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The shape stored under the `BATCH_SCHEDULED_OPTIONS` metadata key on
|
|
41
|
+
* the decorated method function. The runtime scheduler (the future
|
|
42
|
+
* `@nest-batch/bullmq` cron strategy) reads this verbatim to register
|
|
43
|
+
* the job with the underlying scheduler.
|
|
44
|
+
*
|
|
45
|
+
* Note: `inert` lives at the top level (not inside `options`) on
|
|
46
|
+
* purpose. It is a *runtime* flag captured at decoration time from
|
|
47
|
+
* `process.env.BATCH_SCHEDULED_DISABLE`; it is not a user-facing
|
|
48
|
+
* knob in `BatchScheduledOptions`. (The `inert?: boolean` slot on
|
|
49
|
+
* `BatchScheduledOptions` is the user-facing counterpart — see the
|
|
50
|
+
* GREEN half of Task 13 to wire it up.)
|
|
51
|
+
*/
|
|
52
|
+
export interface BatchScheduledMetadata {
|
|
53
|
+
cron: string;
|
|
54
|
+
options: BatchScheduledOptions;
|
|
55
|
+
inert: boolean;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Thrown by `@BatchScheduled` when the cron expression fails the
|
|
59
|
+
* shape check (5/6 fields, non-whitespace tokens). The `.message`
|
|
60
|
+
* includes the invalid value and the failure reason so the error
|
|
61
|
+
* is greppable in logs and pinned in test assertions.
|
|
62
|
+
*
|
|
63
|
+
* Exported from the module barrel so adapter packages (e.g. the
|
|
64
|
+
* BullMQ runtime) can `instanceof`-check it without reaching into
|
|
65
|
+
* the decorator's internal helper.
|
|
66
|
+
*/
|
|
67
|
+
export declare class InvalidBatchScheduledCronError extends Error {
|
|
68
|
+
readonly cron: string;
|
|
69
|
+
readonly reason: string;
|
|
70
|
+
constructor(cron: string, reason: string);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Thrown by `@BatchScheduled` when the IANA timezone fails the
|
|
74
|
+
* platform check. The `.message` embeds the invalid value and the
|
|
75
|
+
* failure reason.
|
|
76
|
+
*
|
|
77
|
+
* Exported from the module barrel so adapter packages can
|
|
78
|
+
* `instanceof`-check it without reaching into the decorator's
|
|
79
|
+
* internal helper.
|
|
80
|
+
*/
|
|
81
|
+
export declare class InvalidBatchScheduledTimezoneError extends Error {
|
|
82
|
+
readonly timezone: string;
|
|
83
|
+
readonly reason: string;
|
|
84
|
+
constructor(timezone: string, reason: string);
|
|
85
|
+
}
|
|
86
|
+
export declare function BatchScheduled(cronExpression: string, options: BatchScheduledOptions): MethodDecorator;
|
|
87
|
+
//# sourceMappingURL=batch-scheduled.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch-scheduled.d.ts","sourceRoot":"","sources":["../../../src/scheduling/batch-scheduled.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAK1B,eAAO,MAAM,uBAAuB,yBAAgB,CAAC;AAErD;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC;AAE/D;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,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