@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,475 @@
|
|
|
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 BatchBootstrapper () {
|
|
13
|
+
return BatchBootstrapper;
|
|
14
|
+
},
|
|
15
|
+
get IN_PROCESS_EXECUTION_STRATEGY_PROVIDER () {
|
|
16
|
+
return _inprocessexecutionstrategy.IN_PROCESS_EXECUTION_STRATEGY_PROVIDER;
|
|
17
|
+
},
|
|
18
|
+
get InProcessExecutionStrategy () {
|
|
19
|
+
return _inprocessexecutionstrategy.InProcessExecutionStrategy;
|
|
20
|
+
},
|
|
21
|
+
get NestBatchModule () {
|
|
22
|
+
return NestBatchModule;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
const _common = require("@nestjs/common");
|
|
26
|
+
const _core = require("@nestjs/core");
|
|
27
|
+
const _definitioncompiler = require("../compiler/definition-compiler");
|
|
28
|
+
const _batchexplorer = require("../explorer/batch-explorer");
|
|
29
|
+
const _jobregistry = require("../registry/job-registry");
|
|
30
|
+
const _jobexecutor = require("../execution/job-executor");
|
|
31
|
+
const _chunkstepexecutor = require("../execution/chunk-step-executor");
|
|
32
|
+
const _taskletstepexecutor = require("../execution/tasklet-step-executor");
|
|
33
|
+
const _listenerinvoker = require("../execution/listener-invoker");
|
|
34
|
+
const _joblauncher = require("../execution/job-launcher");
|
|
35
|
+
const _jobexplorer = require("../execution/job-explorer");
|
|
36
|
+
const _joboperator = require("../execution/job-operator");
|
|
37
|
+
const _batchworkerrunner = require("../execution/batch-worker-runner");
|
|
38
|
+
const _inprocessexecutionstrategy = require("../execution/in-process-execution-strategy");
|
|
39
|
+
const _flowevaluator = require("../flow/flow-evaluator");
|
|
40
|
+
const _constants = require("../decorators/constants");
|
|
41
|
+
const _batchscheduleregistry = require("./batch-schedule-registry");
|
|
42
|
+
const _tokens = require("./tokens");
|
|
43
|
+
const _jobrepository = require("../core/repository/job-repository");
|
|
44
|
+
const _transactionmanager = require("../core/transaction/transaction-manager");
|
|
45
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
46
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
47
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
48
|
+
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;
|
|
49
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
50
|
+
}
|
|
51
|
+
function _ts_metadata(k, v) {
|
|
52
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Sentinel provider token used by `forRootAsync` to plumb the user's
|
|
56
|
+
* `useFactory` through DI. The factory is registered under this
|
|
57
|
+
* token, and `MODULE_OPTIONS_TOKEN` resolves to its output via a
|
|
58
|
+
* follow-up `useFactory` provider.
|
|
59
|
+
*
|
|
60
|
+
* `Symbol.for(...)` makes the token stable across module boundaries:
|
|
61
|
+
* tooling or sibling packages that know the description string can
|
|
62
|
+
* resolve the same symbol without importing this file. Matches the
|
|
63
|
+
* convention used by `BATCH_SCHEDULE_REGISTRY`, `MODULE_OPTIONS_TOKEN`,
|
|
64
|
+
* `JOB_REPOSITORY_TOKEN`, etc. in `./tokens.ts`.
|
|
65
|
+
*/ const OPTIONS_FACTORY = Symbol.for('@nest-batch/core/OPTIONS_FACTORY');
|
|
66
|
+
let BatchBootstrapper = class BatchBootstrapper {
|
|
67
|
+
explorer;
|
|
68
|
+
compiler;
|
|
69
|
+
registry;
|
|
70
|
+
scheduleRegistry;
|
|
71
|
+
logger = new _common.Logger(BatchBootstrapper.name);
|
|
72
|
+
constructor(explorer, compiler, registry, scheduleRegistry){
|
|
73
|
+
this.explorer = explorer;
|
|
74
|
+
this.compiler = compiler;
|
|
75
|
+
this.registry = registry;
|
|
76
|
+
this.scheduleRegistry = scheduleRegistry;
|
|
77
|
+
}
|
|
78
|
+
onApplicationBootstrap() {
|
|
79
|
+
// 1. Compile + register every discovered job.
|
|
80
|
+
for (const discovered of this.explorer.getDiscovered()){
|
|
81
|
+
const jobId = discovered.jobOptions.id;
|
|
82
|
+
try {
|
|
83
|
+
const def = this.compiler.compileFromDiscovered(discovered);
|
|
84
|
+
this.registry.register(def);
|
|
85
|
+
this.logger.log(`Registered job "${jobId}"`);
|
|
86
|
+
} catch (err) {
|
|
87
|
+
this.logger.error(`Failed to register job "${jobId}": ${err.message}`);
|
|
88
|
+
throw err;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// 2. Walk the same discovered set for @BatchScheduled metadata
|
|
92
|
+
// and populate BatchScheduleRegistry. The metadata is stamped
|
|
93
|
+
// by the decorator via `SetMetadata(KEY, value)`, which Nest
|
|
94
|
+
// writes to the *function reference* of the decorated method
|
|
95
|
+
// (not to the prototype+name slot). We therefore read it from
|
|
96
|
+
// `prototype[name]` (the function), not from the (proto, name)
|
|
97
|
+
// tuple.
|
|
98
|
+
for (const discovered of this.explorer.getDiscovered()){
|
|
99
|
+
const jobId = discovered.jobOptions.id;
|
|
100
|
+
const prototype = discovered.classRef.prototype;
|
|
101
|
+
for (const name of this.allMethodNames(prototype)){
|
|
102
|
+
const fn = prototype[name];
|
|
103
|
+
if (typeof fn !== 'function') continue;
|
|
104
|
+
const meta = Reflect.getMetadata(_constants.BATCH_SCHEDULED_OPTIONS, fn);
|
|
105
|
+
if (!meta) continue;
|
|
106
|
+
const entry = {
|
|
107
|
+
jobId,
|
|
108
|
+
methodName: name,
|
|
109
|
+
cron: meta.cron,
|
|
110
|
+
timezone: meta.options.timezone,
|
|
111
|
+
overlap: meta.options.overlap,
|
|
112
|
+
startAt: meta.options.startAt,
|
|
113
|
+
endAt: meta.options.endAt,
|
|
114
|
+
inert: meta.inert
|
|
115
|
+
};
|
|
116
|
+
try {
|
|
117
|
+
this.scheduleRegistry.register(entry);
|
|
118
|
+
this.logger.log(`Registered schedule for job "${jobId}"::${name} (cron="${meta.cron}", tz="${meta.options.timezone}")`);
|
|
119
|
+
} catch (err) {
|
|
120
|
+
this.logger.error(`Failed to register schedule for job "${jobId}"::${name}: ${err.message}`);
|
|
121
|
+
throw err;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Walk the prototype chain and return every own method name
|
|
128
|
+
* (excluding `constructor`) up to (but not including)
|
|
129
|
+
* `Object.prototype`. Same shape as `BatchExplorer.allMethodNames` —
|
|
130
|
+
* we duplicate the walker here so the bootstrapper remains
|
|
131
|
+
* independent of the explorer's internals.
|
|
132
|
+
*/ allMethodNames(prototype) {
|
|
133
|
+
const names = new Set();
|
|
134
|
+
let proto = prototype;
|
|
135
|
+
while(proto && proto !== Object.prototype){
|
|
136
|
+
for (const name of Object.getOwnPropertyNames(proto)){
|
|
137
|
+
if (name === 'constructor') continue;
|
|
138
|
+
names.add(name);
|
|
139
|
+
}
|
|
140
|
+
proto = Object.getPrototypeOf(proto);
|
|
141
|
+
}
|
|
142
|
+
return names;
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
BatchBootstrapper = _ts_decorate([
|
|
146
|
+
(0, _common.Injectable)(),
|
|
147
|
+
_ts_metadata("design:type", Function),
|
|
148
|
+
_ts_metadata("design:paramtypes", [
|
|
149
|
+
typeof _batchexplorer.BatchExplorer === "undefined" ? Object : _batchexplorer.BatchExplorer,
|
|
150
|
+
typeof _definitioncompiler.DefinitionCompiler === "undefined" ? Object : _definitioncompiler.DefinitionCompiler,
|
|
151
|
+
typeof _jobregistry.JobRegistry === "undefined" ? Object : _jobregistry.JobRegistry,
|
|
152
|
+
typeof _batchscheduleregistry.BatchScheduleRegistry === "undefined" ? Object : _batchscheduleregistry.BatchScheduleRegistry
|
|
153
|
+
])
|
|
154
|
+
], BatchBootstrapper);
|
|
155
|
+
let NestBatchModule = class NestBatchModule {
|
|
156
|
+
/**
|
|
157
|
+
* Build a provider list from an adapter's `globalProviders`,
|
|
158
|
+
* automatically aliasing the abstract `JobRepository` class to
|
|
159
|
+
* `JOB_REPOSITORY_TOKEN` when the symbol is present but the class
|
|
160
|
+
* itself is not directly provided.
|
|
161
|
+
*
|
|
162
|
+
* This fixes the NestJS DI resolution gap: `JobExecutor`,
|
|
163
|
+
* `JobLauncher`, and `InProcessExecutionStrategy` all inject the
|
|
164
|
+
* abstract `JobRepository`, but adapters typically bind their
|
|
165
|
+
* concrete implementation to `JOB_REPOSITORY_TOKEN`. NestJS cannot
|
|
166
|
+
* resolve abstract class → concrete subclass automatically, so we
|
|
167
|
+
* inject the alias here.
|
|
168
|
+
*
|
|
169
|
+
* Idempotent: if `JobRepository` is already directly provided (e.g.
|
|
170
|
+
* `{ provide: JobRepository, useClass: MyRepo }`), no extra alias is
|
|
171
|
+
* added.
|
|
172
|
+
*/ static buildProviders(adapterGlobalProviders) {
|
|
173
|
+
const providers = [
|
|
174
|
+
...adapterGlobalProviders
|
|
175
|
+
];
|
|
176
|
+
const hasJobRepositoryToken = providers.some((p)=>typeof p === 'object' && p !== null && 'provide' in p && p.provide === _tokens.JOB_REPOSITORY_TOKEN);
|
|
177
|
+
const hasJobRepositoryClass = providers.some((p)=>p === _jobrepository.JobRepository || typeof p === 'object' && p !== null && 'provide' in p && p.provide === _jobrepository.JobRepository);
|
|
178
|
+
if (hasJobRepositoryToken && !hasJobRepositoryClass) {
|
|
179
|
+
providers.push({
|
|
180
|
+
provide: _jobrepository.JobRepository,
|
|
181
|
+
useExisting: _tokens.JOB_REPOSITORY_TOKEN
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
const hasTransactionManagerToken = providers.some((p)=>typeof p === 'object' && p !== null && 'provide' in p && p.provide === _tokens.TRANSACTION_MANAGER_TOKEN);
|
|
185
|
+
const hasTransactionManagerClass = providers.some((p)=>p === _transactionmanager.TransactionManager || typeof p === 'object' && p !== null && 'provide' in p && p.provide === _transactionmanager.TransactionManager);
|
|
186
|
+
if (hasTransactionManagerToken && !hasTransactionManagerClass) {
|
|
187
|
+
providers.push({
|
|
188
|
+
provide: _transactionmanager.TransactionManager,
|
|
189
|
+
useExisting: _tokens.TRANSACTION_MANAGER_TOKEN
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
return providers;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Best-effort resolution of `inject` tokens by reading the
|
|
196
|
+
* `providers` metadata of modules listed in `imports`. This lets
|
|
197
|
+
* `forRootAsync` evaluate a synchronous `useFactory` even when it
|
|
198
|
+
* declares `inject` deps, provided those deps are `useValue`
|
|
199
|
+
* providers exported by an imported module.
|
|
200
|
+
*
|
|
201
|
+
* Only `useValue` providers can be resolved this way — `useClass`
|
|
202
|
+
* and `useFactory` providers need Nest's DI container and are
|
|
203
|
+
* skipped.
|
|
204
|
+
*/ static resolveInjectValues(imports, inject) {
|
|
205
|
+
if (!inject || inject.length === 0) return [];
|
|
206
|
+
const values = [];
|
|
207
|
+
for (const token of inject){
|
|
208
|
+
let resolved = undefined;
|
|
209
|
+
for (const mod of imports ?? []){
|
|
210
|
+
if (!mod) continue;
|
|
211
|
+
let providers;
|
|
212
|
+
if (typeof mod === 'object' && 'module' in mod) {
|
|
213
|
+
const dynamicMod = mod;
|
|
214
|
+
providers = dynamicMod.providers;
|
|
215
|
+
if (!providers && dynamicMod.module) {
|
|
216
|
+
try {
|
|
217
|
+
providers = Reflect.getMetadata('providers', dynamicMod.module);
|
|
218
|
+
} catch {
|
|
219
|
+
/* ignore metadata read failures */ }
|
|
220
|
+
}
|
|
221
|
+
} else if (typeof mod === 'function') {
|
|
222
|
+
try {
|
|
223
|
+
providers = Reflect.getMetadata('providers', mod);
|
|
224
|
+
} catch {
|
|
225
|
+
/* ignore metadata read failures */ }
|
|
226
|
+
}
|
|
227
|
+
for (const p of providers ?? []){
|
|
228
|
+
if (typeof p === 'object' && p !== null && 'provide' in p && p.provide === token && 'useValue' in p) {
|
|
229
|
+
resolved = p.useValue;
|
|
230
|
+
break;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (resolved !== undefined) break;
|
|
234
|
+
}
|
|
235
|
+
values.push(resolved);
|
|
236
|
+
}
|
|
237
|
+
return values;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Static (synchronous) configuration.
|
|
241
|
+
*
|
|
242
|
+
* Takes the resolved `BatchAdaptersConfig` and builds a
|
|
243
|
+
* `global: true` `DynamicModule` that:
|
|
244
|
+
*
|
|
245
|
+
* 1. imports each adapter's `DynamicModule`
|
|
246
|
+
* (`adapters.persistence.module` and `adapters.transport.module`);
|
|
247
|
+
* 2. imports `DiscoveryModule` from `@nestjs/core` so the explorer
|
|
248
|
+
* can use Nest's `DiscoveryService`;
|
|
249
|
+
* 3. registers core's own providers — `JobRegistry`,
|
|
250
|
+
* `DefinitionCompiler`, `BatchExplorer`, `FlowEvaluator`,
|
|
251
|
+
* `BatchScheduleRegistry`, `BatchBootstrapper` — and the
|
|
252
|
+
* executor subgraph (`JobExecutor`, `ChunkStepExecutor`,
|
|
253
|
+
* `TaskletStepExecutor`, `ListenerInvoker`) so the host
|
|
254
|
+
* does not have to wire them by hand;
|
|
255
|
+
* 4. registers each adapter's `globalProviders` (e.g. the
|
|
256
|
+
* `JobRepository` / `TransactionManager` implementations
|
|
257
|
+
* from a persistence adapter) so the host can inject them
|
|
258
|
+
* too;
|
|
259
|
+
* 5. binds the `BatchAdaptersConfig` to `MODULE_OPTIONS_TOKEN`
|
|
260
|
+
* via a value provider for adapter introspection.
|
|
261
|
+
*/ static forRoot(options) {
|
|
262
|
+
const { adapters } = options;
|
|
263
|
+
const persistenceProviders = NestBatchModule.buildProviders(adapters.persistence.globalProviders ?? []);
|
|
264
|
+
const transportProviders = NestBatchModule.buildProviders(adapters.transport.globalProviders ?? []);
|
|
265
|
+
return {
|
|
266
|
+
module: NestBatchModule,
|
|
267
|
+
global: true,
|
|
268
|
+
imports: [
|
|
269
|
+
adapters.persistence.module,
|
|
270
|
+
adapters.transport.module,
|
|
271
|
+
_core.DiscoveryModule
|
|
272
|
+
],
|
|
273
|
+
providers: [
|
|
274
|
+
// Core classes (discovery + compile + register).
|
|
275
|
+
_jobregistry.JobRegistry,
|
|
276
|
+
_definitioncompiler.DefinitionCompiler,
|
|
277
|
+
_batchexplorer.BatchExplorer,
|
|
278
|
+
_flowevaluator.FlowEvaluator,
|
|
279
|
+
_batchscheduleregistry.BatchScheduleRegistry,
|
|
280
|
+
BatchBootstrapper,
|
|
281
|
+
// Executor subgraph (JobExecutor → Chunk/Tasklet/Listener).
|
|
282
|
+
_jobexecutor.JobExecutor,
|
|
283
|
+
_chunkstepexecutor.ChunkStepExecutor,
|
|
284
|
+
_taskletstepexecutor.TaskletStepExecutor,
|
|
285
|
+
_listenerinvoker.ListenerInvoker,
|
|
286
|
+
_joblauncher.JobLauncher,
|
|
287
|
+
_jobexplorer.JobExplorer,
|
|
288
|
+
_joboperator.JobOperator,
|
|
289
|
+
_batchworkerrunner.BatchWorkerRunner,
|
|
290
|
+
// Resolved options bag for adapter introspection.
|
|
291
|
+
{
|
|
292
|
+
provide: _tokens.MODULE_OPTIONS_TOKEN,
|
|
293
|
+
useValue: adapters
|
|
294
|
+
},
|
|
295
|
+
// Schedule registry symbol alias — the symbol itself
|
|
296
|
+
// must be a provider (not just a class export) so the
|
|
297
|
+
// `exports` entry below resolves through Nest's DI
|
|
298
|
+
// validation.
|
|
299
|
+
{
|
|
300
|
+
provide: _tokens.BATCH_SCHEDULE_REGISTRY,
|
|
301
|
+
useExisting: _batchscheduleregistry.BatchScheduleRegistry
|
|
302
|
+
},
|
|
303
|
+
// Adapter-supplied global providers (e.g. JobRepository
|
|
304
|
+
// / TransactionManager implementations).
|
|
305
|
+
...persistenceProviders,
|
|
306
|
+
...transportProviders
|
|
307
|
+
],
|
|
308
|
+
exports: [
|
|
309
|
+
// Core classes — exported so sibling packages and the
|
|
310
|
+
// host app can resolve them from the global module chain.
|
|
311
|
+
_jobregistry.JobRegistry,
|
|
312
|
+
_definitioncompiler.DefinitionCompiler,
|
|
313
|
+
_batchexplorer.BatchExplorer,
|
|
314
|
+
_flowevaluator.FlowEvaluator,
|
|
315
|
+
_batchscheduleregistry.BatchScheduleRegistry,
|
|
316
|
+
BatchBootstrapper,
|
|
317
|
+
// Tokens — exported so adapters can bind to them via
|
|
318
|
+
// `@Inject(MODULE_OPTIONS_TOKEN)` and host code can read
|
|
319
|
+
// the schedule registry by its stable symbol.
|
|
320
|
+
_tokens.BATCH_SCHEDULE_REGISTRY,
|
|
321
|
+
_tokens.MODULE_OPTIONS_TOKEN,
|
|
322
|
+
// Executor subgraph — exported so adapters (e.g. the
|
|
323
|
+
// `InProcessExecutionStrategy`) and host code can inject
|
|
324
|
+
// them.
|
|
325
|
+
_jobexecutor.JobExecutor,
|
|
326
|
+
_chunkstepexecutor.ChunkStepExecutor,
|
|
327
|
+
_taskletstepexecutor.TaskletStepExecutor,
|
|
328
|
+
_listenerinvoker.ListenerInvoker,
|
|
329
|
+
_joblauncher.JobLauncher,
|
|
330
|
+
_jobexplorer.JobExplorer,
|
|
331
|
+
_joboperator.JobOperator,
|
|
332
|
+
_batchworkerrunner.BatchWorkerRunner,
|
|
333
|
+
// Adapter-supplied global providers — re-exported so the
|
|
334
|
+
// host can resolve the persistence + transport bindings
|
|
335
|
+
// from the global module chain.
|
|
336
|
+
...persistenceProviders,
|
|
337
|
+
...transportProviders
|
|
338
|
+
]
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Async configuration — useful when the adapter set comes from a
|
|
343
|
+
* config service or another async source.
|
|
344
|
+
*
|
|
345
|
+
* Mirrors the `BullmqBatchModule.forRootAsync` pattern: the user's
|
|
346
|
+
* `useFactory` is registered as a sentinel provider under
|
|
347
|
+
* `OPTIONS_FACTORY`, and `MODULE_OPTIONS_TOKEN` is bound to its
|
|
348
|
+
* resolved `BatchAdaptersConfig` via a follow-up `useFactory`
|
|
349
|
+
* provider. The user's `imports` + `inject` are forwarded as-is
|
|
350
|
+
* so the factory can pull from `ConfigService` or any other
|
|
351
|
+
* DI-bound dependency.
|
|
352
|
+
*
|
|
353
|
+
* See the `NestBatchModuleAsyncOptions` JSDoc for the adapter
|
|
354
|
+
* module merging caveat — the async path does not auto-merge
|
|
355
|
+
* the adapter modules' `globalProviders`. The adapter
|
|
356
|
+
* `DynamicModule`s must be passed in the caller's `imports`
|
|
357
|
+
* array so Nest sees them in the module graph; the factory's
|
|
358
|
+
* return value is used only for `MODULE_OPTIONS_TOKEN`.
|
|
359
|
+
*/ static forRootAsync(options) {
|
|
360
|
+
const { imports = [], inject = [], useFactory } = options;
|
|
361
|
+
// Try to evaluate the factory synchronously so we can merge
|
|
362
|
+
// adapter `globalProviders` at module-build time (mirroring
|
|
363
|
+
// what `forRoot` does). If the factory is async or needs
|
|
364
|
+
// injected deps we can't resolve, fall back to the pure
|
|
365
|
+
// sentinel-factory path.
|
|
366
|
+
const injectValues = NestBatchModule.resolveInjectValues(imports, inject);
|
|
367
|
+
const factoryResult = useFactory(...injectValues);
|
|
368
|
+
if (factoryResult instanceof Promise) {
|
|
369
|
+
return factoryResult.then((adapters)=>NestBatchModule.buildAsyncModule(options, adapters));
|
|
370
|
+
}
|
|
371
|
+
return NestBatchModule.buildAsyncModule(options, factoryResult);
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Shared module builder used by both the sync and async branches
|
|
375
|
+
* of `forRootAsync`. When the factory result is available
|
|
376
|
+
* synchronously we merge adapter `globalProviders` (plus the
|
|
377
|
+
* `JobRepository` alias) into core's own provider list, exactly
|
|
378
|
+
* like `forRoot` does.
|
|
379
|
+
*/ static buildAsyncModule(options, adapters) {
|
|
380
|
+
const { imports = [], inject = [], useFactory } = options;
|
|
381
|
+
const persistenceProviders = NestBatchModule.buildProviders(adapters.persistence.globalProviders ?? []);
|
|
382
|
+
const transportProviders = NestBatchModule.buildProviders(adapters.transport.globalProviders ?? []);
|
|
383
|
+
// Sentinel factory provider: holds the user's `useFactory` and
|
|
384
|
+
// any `inject` deps. Other providers can pull the resolved
|
|
385
|
+
// `BatchAdaptersConfig` via `@Inject(OPTIONS_FACTORY)` if they
|
|
386
|
+
// need to.
|
|
387
|
+
const factoryProvider = {
|
|
388
|
+
provide: OPTIONS_FACTORY,
|
|
389
|
+
useFactory: useFactory,
|
|
390
|
+
inject: [
|
|
391
|
+
...inject
|
|
392
|
+
]
|
|
393
|
+
};
|
|
394
|
+
// Options provider: bridges the sentinel factory to the
|
|
395
|
+
// canonical `MODULE_OPTIONS_TOKEN` so adapters + host code can
|
|
396
|
+
// read the resolved config by its stable symbol.
|
|
397
|
+
const optionsProvider = {
|
|
398
|
+
provide: _tokens.MODULE_OPTIONS_TOKEN,
|
|
399
|
+
useFactory: (fromFactory)=>fromFactory,
|
|
400
|
+
inject: [
|
|
401
|
+
OPTIONS_FACTORY
|
|
402
|
+
]
|
|
403
|
+
};
|
|
404
|
+
return {
|
|
405
|
+
module: NestBatchModule,
|
|
406
|
+
global: true,
|
|
407
|
+
imports: [
|
|
408
|
+
...imports,
|
|
409
|
+
adapters.persistence.module,
|
|
410
|
+
adapters.transport.module,
|
|
411
|
+
_core.DiscoveryModule
|
|
412
|
+
],
|
|
413
|
+
providers: [
|
|
414
|
+
// Core classes (discovery + compile + register).
|
|
415
|
+
_jobregistry.JobRegistry,
|
|
416
|
+
_definitioncompiler.DefinitionCompiler,
|
|
417
|
+
_batchexplorer.BatchExplorer,
|
|
418
|
+
_flowevaluator.FlowEvaluator,
|
|
419
|
+
_batchscheduleregistry.BatchScheduleRegistry,
|
|
420
|
+
BatchBootstrapper,
|
|
421
|
+
// Executor subgraph (JobExecutor → Chunk/Tasklet/Listener).
|
|
422
|
+
_jobexecutor.JobExecutor,
|
|
423
|
+
_chunkstepexecutor.ChunkStepExecutor,
|
|
424
|
+
_taskletstepexecutor.TaskletStepExecutor,
|
|
425
|
+
_listenerinvoker.ListenerInvoker,
|
|
426
|
+
_joblauncher.JobLauncher,
|
|
427
|
+
_jobexplorer.JobExplorer,
|
|
428
|
+
_joboperator.JobOperator,
|
|
429
|
+
_batchworkerrunner.BatchWorkerRunner,
|
|
430
|
+
{
|
|
431
|
+
provide: _tokens.BATCH_SCHEDULE_REGISTRY,
|
|
432
|
+
useExisting: _batchscheduleregistry.BatchScheduleRegistry
|
|
433
|
+
},
|
|
434
|
+
// Adapter-supplied global providers (e.g. JobRepository
|
|
435
|
+
// / TransactionManager implementations).
|
|
436
|
+
...persistenceProviders,
|
|
437
|
+
...transportProviders,
|
|
438
|
+
// Sentinel factory + options provider (the async path).
|
|
439
|
+
factoryProvider,
|
|
440
|
+
optionsProvider
|
|
441
|
+
],
|
|
442
|
+
exports: [
|
|
443
|
+
// Core classes.
|
|
444
|
+
_jobregistry.JobRegistry,
|
|
445
|
+
_definitioncompiler.DefinitionCompiler,
|
|
446
|
+
_batchexplorer.BatchExplorer,
|
|
447
|
+
_flowevaluator.FlowEvaluator,
|
|
448
|
+
_batchscheduleregistry.BatchScheduleRegistry,
|
|
449
|
+
BatchBootstrapper,
|
|
450
|
+
// Tokens.
|
|
451
|
+
_tokens.BATCH_SCHEDULE_REGISTRY,
|
|
452
|
+
_tokens.MODULE_OPTIONS_TOKEN,
|
|
453
|
+
// Executor subgraph.
|
|
454
|
+
_jobexecutor.JobExecutor,
|
|
455
|
+
_chunkstepexecutor.ChunkStepExecutor,
|
|
456
|
+
_taskletstepexecutor.TaskletStepExecutor,
|
|
457
|
+
_listenerinvoker.ListenerInvoker,
|
|
458
|
+
_joblauncher.JobLauncher,
|
|
459
|
+
_jobexplorer.JobExplorer,
|
|
460
|
+
_joboperator.JobOperator,
|
|
461
|
+
_batchworkerrunner.BatchWorkerRunner,
|
|
462
|
+
// Adapter-supplied global providers — re-exported so the
|
|
463
|
+
// host can resolve the persistence + transport bindings
|
|
464
|
+
// from the global module chain.
|
|
465
|
+
...persistenceProviders,
|
|
466
|
+
...transportProviders
|
|
467
|
+
]
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
NestBatchModule = _ts_decorate([
|
|
472
|
+
(0, _common.Module)({})
|
|
473
|
+
], NestBatchModule);
|
|
474
|
+
|
|
475
|
+
//# sourceMappingURL=nest-batch.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/module/nest-batch.module.ts"],"sourcesContent":["import {\n DynamicModule,\n Injectable,\n Logger,\n Module,\n OnApplicationBootstrap,\n Provider,\n} from '@nestjs/common';\nimport { DiscoveryModule } from '@nestjs/core';\n\nimport type { BatchAdaptersConfig } from './adapter';\nimport { DefinitionCompiler } from '../compiler/definition-compiler';\nimport { BatchExplorer } from '../explorer/batch-explorer';\nimport { JobRegistry } from '../registry/job-registry';\nimport { JobExecutor } from '../execution/job-executor';\nimport { ChunkStepExecutor } from '../execution/chunk-step-executor';\nimport { TaskletStepExecutor } from '../execution/tasklet-step-executor';\nimport { ListenerInvoker } from '../execution/listener-invoker';\nimport { JobLauncher } from '../execution/job-launcher';\nimport { JobExplorer } from '../execution/job-explorer';\nimport { JobOperator } from '../execution/job-operator';\nimport { BatchWorkerRunner } from '../execution/batch-worker-runner';\nimport {\n InProcessExecutionStrategy,\n IN_PROCESS_EXECUTION_STRATEGY_PROVIDER,\n} from '../execution/in-process-execution-strategy';\nimport { FlowEvaluator } from '../flow/flow-evaluator';\nimport { BATCH_SCHEDULED_OPTIONS } from '../decorators/constants';\nimport type { BatchScheduledMetadata } from '../scheduling/batch-scheduled';\nimport {\n BatchScheduleRegistry,\n type BatchScheduleEntry,\n} from './batch-schedule-registry';\nimport {\n BATCH_SCHEDULE_REGISTRY,\n JOB_REPOSITORY_TOKEN,\n MODULE_OPTIONS_TOKEN,\n TRANSACTION_MANAGER_TOKEN,\n} from './tokens';\nimport { JobRepository } from '../core/repository/job-repository';\nimport { TransactionManager } from '../core/transaction/transaction-manager';\n\n/**\n * Re-export the default in-process strategy and its token binding so\n * the host app can wire them up alongside the rest of the batch\n * engine. The strategy is *not* auto-registered by\n * `NestBatchModule.forRoot()` because its constructor requires\n * `JobRepository` and `JobExecutor` — runtime deps the host\n * supplies. The T4 `InProcessAdapter` factory does the wiring through\n * the adapter's own `DynamicModule.exports` so the runtime\n * resolution chain works without the core module having to know which\n * adapter is active.\n *\n * ```ts\n * import { InProcessAdapter, MikroOrmAdapter, NestBatchModule } from '@nest-batch/core';\n *\n * @Module({\n * imports: [\n * NestBatchModule.forRoot({\n * adapters: {\n * persistence: MikroOrmAdapter,\n * transport: InProcessAdapter,\n * },\n * }),\n * ],\n * })\n * class AppModule {}\n * ```\n */\nexport { InProcessExecutionStrategy, IN_PROCESS_EXECUTION_STRATEGY_PROVIDER };\n\n/**\n * Options for `NestBatchModule.forRoot()`.\n *\n * The whole configuration is the pair of adapters (persistence +\n * transport) the host picked. Both are required — the compiler\n * will reject an `adapters` bag that is missing one — and each\n * adapter is a self-contained `DynamicModule` core will import.\n * Sibling packages can no longer extend the options shape via\n * interface merging: the old `AdapterOptions` extension point is\n * gone because every adapter now owns its own `DynamicModule`\n * (and therefore its own config). Adapter authors that want\n * type-safe factory arguments should expose them on their own\n * adapter factory (e.g. `MikroOrmAdapter.forRoot({ ... })`).\n *\n * - `adapters.persistence` — the adapter that owns the\n * `JobRepository` + `TransactionManager` bindings (e.g.\n * `MikroOrmAdapter`, `TypeOrmAdapter`).\n * - `adapters.transport` — the adapter that owns the\n * `IExecutionStrategy` binding (e.g. `InProcessAdapter`,\n * `BullmqAdapter`).\n */\nexport interface NestBatchModuleOptions {\n readonly adapters: BatchAdaptersConfig;\n}\n\n/**\n * Options for `NestBatchModule.forRootAsync()`.\n *\n * `imports` + `inject` + `useFactory` mirror the standard\n * `ConfigurableModuleBuilder` shape. The factory is registered as a\n * sentinel provider under `OPTIONS_FACTORY` (a `Symbol.for` token\n * stable across module boundaries), and `MODULE_OPTIONS_TOKEN` is\n * bound to its resolved `BatchAdaptersConfig` via a follow-up\n * `useFactory` provider.\n *\n * **Note on adapter module merging.** NestJS cannot dynamically\n * import a `DynamicModule` at module-build time, so the\n * `forRootAsync` path does NOT auto-merge the adapter modules'\n * `globalProviders` into the core module's `providers` list the way\n * `forRoot` does. Two consequences for the async path:\n *\n * 1. The adapter `DynamicModule`s must be passed in the caller's\n * `imports` array directly (e.g.\n * `imports: [MikroOrmAdapter.module, InProcessAdapter.module]`)\n * so Nest sees them in the module graph.\n * 2. The factory's return value is used only for the\n * `MODULE_OPTIONS_TOKEN` binding (adapters introspection);\n * sibling packages and the host can read the resolved config\n * via `@Inject(MODULE_OPTIONS_TOKEN)`.\n *\n * For the full auto-merge (adapter modules + `globalProviders`\n * registered into core's own DI scope), prefer `forRoot` with a\n * pre-resolved `BatchAdaptersConfig`. The async path is for\n * adapters whose factory needs to consult a config service or\n * another async provider to decide which adapter to plug in.\n */\nexport interface NestBatchModuleAsyncOptions {\n imports?: DynamicModule['imports'];\n useFactory: (\n ...args: unknown[]\n ) => Promise<BatchAdaptersConfig> | BatchAdaptersConfig;\n inject?: readonly unknown[];\n}\n\n/**\n * Sentinel provider token used by `forRootAsync` to plumb the user's\n * `useFactory` through DI. The factory is registered under this\n * token, and `MODULE_OPTIONS_TOKEN` resolves to its output via a\n * follow-up `useFactory` provider.\n *\n * `Symbol.for(...)` makes the token stable across module boundaries:\n * tooling or sibling packages that know the description string can\n * resolve the same symbol without importing this file. Matches the\n * convention used by `BATCH_SCHEDULE_REGISTRY`, `MODULE_OPTIONS_TOKEN`,\n * `JOB_REPOSITORY_TOKEN`, etc. in `./tokens.ts`.\n */\nconst OPTIONS_FACTORY: symbol = Symbol.for('@nest-batch/core/OPTIONS_FACTORY');\n\n/**\n * Hook that runs on `OnApplicationBootstrap` to wire together the\n * discovery → compile → register pipeline.\n *\n * Why a separate provider and not a method on `JobRegistry` or\n * `DefinitionCompiler`?\n * - `BatchExplorer.onModuleInit` populates the discovered\n * list once the DI container is ready. Compilation needs every\n * `@Jobable` provider to be instantiated, so it must run *after*\n * `onModuleInit`.\n * - `OnApplicationBootstrap` is the latest point in Nest's lifecycle\n * before the app actually starts handling requests, so all of:\n * `forRoot` / `forRootAsync` providers, custom `useFactory` results,\n * and user-supplied job classes, are guaranteed to be live.\n * - Keeping the wire-up in a dedicated `BatchBootstrapper` means the\n * explorer/compiler/registry stay pure (no `onApplicationBootstrap`\n * coupling) and are independently testable.\n *\n * The bootstrapper also walks every discovered job for\n * `@BatchScheduled` metadata and registers the corresponding entries\n * into the `BatchScheduleRegistry` so the (future) runtime scheduler\n * has a single, stable place to read them from. Today, the registry is\n * metadata-only — no timers are installed.\n */\n@Injectable()\nexport class BatchBootstrapper implements OnApplicationBootstrap {\n private readonly logger = new Logger(BatchBootstrapper.name);\n\n constructor(\n private readonly explorer: BatchExplorer,\n private readonly compiler: DefinitionCompiler,\n private readonly registry: JobRegistry,\n private readonly scheduleRegistry: BatchScheduleRegistry,\n ) {}\n\n onApplicationBootstrap(): void {\n // 1. Compile + register every discovered job.\n for (const discovered of this.explorer.getDiscovered()) {\n const jobId = discovered.jobOptions.id;\n try {\n const def = this.compiler.compileFromDiscovered(discovered);\n this.registry.register(def);\n this.logger.log(`Registered job \"${jobId}\"`);\n } catch (err) {\n this.logger.error(\n `Failed to register job \"${jobId}\": ${(err as Error).message}`,\n );\n throw err;\n }\n }\n\n // 2. Walk the same discovered set for @BatchScheduled metadata\n // and populate BatchScheduleRegistry. The metadata is stamped\n // by the decorator via `SetMetadata(KEY, value)`, which Nest\n // writes to the *function reference* of the decorated method\n // (not to the prototype+name slot). We therefore read it from\n // `prototype[name]` (the function), not from the (proto, name)\n // tuple.\n for (const discovered of this.explorer.getDiscovered()) {\n const jobId = discovered.jobOptions.id;\n const prototype = discovered.classRef.prototype as Record<string, unknown>;\n for (const name of this.allMethodNames(prototype)) {\n const fn = prototype[name];\n if (typeof fn !== 'function') continue;\n const meta = Reflect.getMetadata(\n BATCH_SCHEDULED_OPTIONS,\n fn,\n ) as BatchScheduledMetadata | undefined;\n if (!meta) continue;\n const entry: BatchScheduleEntry = {\n jobId,\n methodName: name,\n cron: meta.cron,\n timezone: meta.options.timezone,\n overlap: meta.options.overlap,\n startAt: meta.options.startAt,\n endAt: meta.options.endAt,\n inert: meta.inert,\n };\n try {\n this.scheduleRegistry.register(entry);\n this.logger.log(\n `Registered schedule for job \"${jobId}\"::${name} (cron=\"${meta.cron}\", tz=\"${meta.options.timezone}\")`,\n );\n } catch (err) {\n this.logger.error(\n `Failed to register schedule for job \"${jobId}\"::${name}: ${\n (err as Error).message\n }`,\n );\n throw err;\n }\n }\n }\n }\n\n /**\n * Walk the prototype chain and return every own method name\n * (excluding `constructor`) up to (but not including)\n * `Object.prototype`. Same shape as `BatchExplorer.allMethodNames` —\n * we duplicate the walker here so the bootstrapper remains\n * independent of the explorer's internals.\n */\n private allMethodNames(prototype: object): Set<string> {\n const names = new Set<string>();\n let proto: object | null = prototype;\n while (proto && proto !== Object.prototype) {\n for (const name of Object.getOwnPropertyNames(proto)) {\n if (name === 'constructor') continue;\n names.add(name);\n }\n proto = Object.getPrototypeOf(proto);\n }\n return names;\n }\n}\n\n/**\n * Public Nest module that wires up the @nest-batch/core library.\n *\n * The module is a `global: true` `DynamicModule` whose `imports`,\n * `providers`, and `exports` are assembled at the call site by\n * `forRoot` (synchronous) or `forRootAsync` (sentinel-factory\n * pattern). In both paths the core providers and the executor\n * subgraph are auto-registered so the host does not have to wire\n * them by hand; adapter modules are imported as part of the same\n * `DynamicModule` so Nest's discovery phase sees every job class.\n *\n * @see {@link NestBatchModuleOptions} for the synchronous options shape\n * @see {@link NestBatchModuleAsyncOptions} for the async options shape\n * @see {@link BatchAdaptersConfig} for the adapter contract\n */\n@Module({})\nexport class NestBatchModule {\n /**\n * Build a provider list from an adapter's `globalProviders`,\n * automatically aliasing the abstract `JobRepository` class to\n * `JOB_REPOSITORY_TOKEN` when the symbol is present but the class\n * itself is not directly provided.\n *\n * This fixes the NestJS DI resolution gap: `JobExecutor`,\n * `JobLauncher`, and `InProcessExecutionStrategy` all inject the\n * abstract `JobRepository`, but adapters typically bind their\n * concrete implementation to `JOB_REPOSITORY_TOKEN`. NestJS cannot\n * resolve abstract class → concrete subclass automatically, so we\n * inject the alias here.\n *\n * Idempotent: if `JobRepository` is already directly provided (e.g.\n * `{ provide: JobRepository, useClass: MyRepo }`), no extra alias is\n * added.\n */\n private static buildProviders(adapterGlobalProviders: readonly Provider[]): Provider[] {\n const providers = [...adapterGlobalProviders];\n\n const hasJobRepositoryToken = providers.some(\n (p) =>\n typeof p === 'object' &&\n p !== null &&\n 'provide' in p &&\n p.provide === JOB_REPOSITORY_TOKEN,\n );\n\n const hasJobRepositoryClass = providers.some(\n (p) =>\n p === JobRepository ||\n (typeof p === 'object' &&\n p !== null &&\n 'provide' in p &&\n p.provide === JobRepository),\n );\n\n if (hasJobRepositoryToken && !hasJobRepositoryClass) {\n providers.push({\n provide: JobRepository,\n useExisting: JOB_REPOSITORY_TOKEN,\n });\n }\n\n const hasTransactionManagerToken = providers.some(\n (p) =>\n typeof p === 'object' &&\n p !== null &&\n 'provide' in p &&\n p.provide === TRANSACTION_MANAGER_TOKEN,\n );\n\n const hasTransactionManagerClass = providers.some(\n (p) =>\n p === TransactionManager ||\n (typeof p === 'object' &&\n p !== null &&\n 'provide' in p &&\n p.provide === TransactionManager),\n );\n\n if (hasTransactionManagerToken && !hasTransactionManagerClass) {\n providers.push({\n provide: TransactionManager,\n useExisting: TRANSACTION_MANAGER_TOKEN,\n });\n }\n\n return providers;\n }\n\n /**\n * Best-effort resolution of `inject` tokens by reading the\n * `providers` metadata of modules listed in `imports`. This lets\n * `forRootAsync` evaluate a synchronous `useFactory` even when it\n * declares `inject` deps, provided those deps are `useValue`\n * providers exported by an imported module.\n *\n * Only `useValue` providers can be resolved this way — `useClass`\n * and `useFactory` providers need Nest's DI container and are\n * skipped.\n */\n private static resolveInjectValues(\n imports: NestBatchModuleAsyncOptions['imports'],\n inject: readonly unknown[],\n ): unknown[] {\n if (!inject || inject.length === 0) return [];\n\n const values: unknown[] = [];\n for (const token of inject) {\n let resolved: unknown = undefined;\n for (const mod of imports ?? []) {\n if (!mod) continue;\n\n let providers: Provider[] | undefined;\n\n if (typeof mod === 'object' && 'module' in mod) {\n const dynamicMod = mod as DynamicModule;\n providers = dynamicMod.providers;\n if (!providers && dynamicMod.module) {\n try {\n providers = Reflect.getMetadata('providers', dynamicMod.module);\n } catch {\n /* ignore metadata read failures */\n }\n }\n } else if (typeof mod === 'function') {\n try {\n providers = Reflect.getMetadata('providers', mod);\n } catch {\n /* ignore metadata read failures */\n }\n }\n\n for (const p of providers ?? []) {\n if (\n typeof p === 'object' &&\n p !== null &&\n 'provide' in p &&\n p.provide === token &&\n 'useValue' in p\n ) {\n resolved = p.useValue;\n break;\n }\n }\n if (resolved !== undefined) break;\n }\n values.push(resolved);\n }\n return values;\n }\n\n /**\n * Static (synchronous) configuration.\n *\n * Takes the resolved `BatchAdaptersConfig` and builds a\n * `global: true` `DynamicModule` that:\n *\n * 1. imports each adapter's `DynamicModule`\n * (`adapters.persistence.module` and `adapters.transport.module`);\n * 2. imports `DiscoveryModule` from `@nestjs/core` so the explorer\n * can use Nest's `DiscoveryService`;\n * 3. registers core's own providers — `JobRegistry`,\n * `DefinitionCompiler`, `BatchExplorer`, `FlowEvaluator`,\n * `BatchScheduleRegistry`, `BatchBootstrapper` — and the\n * executor subgraph (`JobExecutor`, `ChunkStepExecutor`,\n * `TaskletStepExecutor`, `ListenerInvoker`) so the host\n * does not have to wire them by hand;\n * 4. registers each adapter's `globalProviders` (e.g. the\n * `JobRepository` / `TransactionManager` implementations\n * from a persistence adapter) so the host can inject them\n * too;\n * 5. binds the `BatchAdaptersConfig` to `MODULE_OPTIONS_TOKEN`\n * via a value provider for adapter introspection.\n */\n static forRoot(options: NestBatchModuleOptions): DynamicModule {\n const { adapters } = options;\n const persistenceProviders = NestBatchModule.buildProviders(\n adapters.persistence.globalProviders ?? [],\n );\n const transportProviders = NestBatchModule.buildProviders(\n adapters.transport.globalProviders ?? [],\n );\n\n return {\n module: NestBatchModule,\n global: true,\n imports: [\n adapters.persistence.module,\n adapters.transport.module,\n DiscoveryModule,\n ],\n providers: [\n // Core classes (discovery + compile + register).\n JobRegistry,\n DefinitionCompiler,\n BatchExplorer,\n FlowEvaluator,\n BatchScheduleRegistry,\n BatchBootstrapper,\n // Executor subgraph (JobExecutor → Chunk/Tasklet/Listener).\n JobExecutor,\n ChunkStepExecutor,\n TaskletStepExecutor,\n ListenerInvoker,\n JobLauncher,\n JobExplorer,\n JobOperator,\n BatchWorkerRunner,\n // Resolved options bag for adapter introspection.\n {\n provide: MODULE_OPTIONS_TOKEN,\n useValue: adapters,\n },\n // Schedule registry symbol alias — the symbol itself\n // must be a provider (not just a class export) so the\n // `exports` entry below resolves through Nest's DI\n // validation.\n {\n provide: BATCH_SCHEDULE_REGISTRY,\n useExisting: BatchScheduleRegistry,\n },\n // Adapter-supplied global providers (e.g. JobRepository\n // / TransactionManager implementations).\n ...persistenceProviders,\n ...transportProviders,\n ],\n exports: [\n // Core classes — exported so sibling packages and the\n // host app can resolve them from the global module chain.\n JobRegistry,\n DefinitionCompiler,\n BatchExplorer,\n FlowEvaluator,\n BatchScheduleRegistry,\n BatchBootstrapper,\n // Tokens — exported so adapters can bind to them via\n // `@Inject(MODULE_OPTIONS_TOKEN)` and host code can read\n // the schedule registry by its stable symbol.\n BATCH_SCHEDULE_REGISTRY,\n MODULE_OPTIONS_TOKEN,\n // Executor subgraph — exported so adapters (e.g. the\n // `InProcessExecutionStrategy`) and host code can inject\n // them.\n JobExecutor,\n ChunkStepExecutor,\n TaskletStepExecutor,\n ListenerInvoker,\n JobLauncher,\n JobExplorer,\n JobOperator,\n BatchWorkerRunner,\n // Adapter-supplied global providers — re-exported so the\n // host can resolve the persistence + transport bindings\n // from the global module chain.\n ...persistenceProviders,\n ...transportProviders,\n ],\n };\n }\n\n /**\n * Async configuration — useful when the adapter set comes from a\n * config service or another async source.\n *\n * Mirrors the `BullmqBatchModule.forRootAsync` pattern: the user's\n * `useFactory` is registered as a sentinel provider under\n * `OPTIONS_FACTORY`, and `MODULE_OPTIONS_TOKEN` is bound to its\n * resolved `BatchAdaptersConfig` via a follow-up `useFactory`\n * provider. The user's `imports` + `inject` are forwarded as-is\n * so the factory can pull from `ConfigService` or any other\n * DI-bound dependency.\n *\n * See the `NestBatchModuleAsyncOptions` JSDoc for the adapter\n * module merging caveat — the async path does not auto-merge\n * the adapter modules' `globalProviders`. The adapter\n * `DynamicModule`s must be passed in the caller's `imports`\n * array so Nest sees them in the module graph; the factory's\n * return value is used only for `MODULE_OPTIONS_TOKEN`.\n */\n static forRootAsync(\n options: NestBatchModuleAsyncOptions,\n ): DynamicModule | Promise<DynamicModule> {\n const { imports = [], inject = [], useFactory } = options;\n\n // Try to evaluate the factory synchronously so we can merge\n // adapter `globalProviders` at module-build time (mirroring\n // what `forRoot` does). If the factory is async or needs\n // injected deps we can't resolve, fall back to the pure\n // sentinel-factory path.\n const injectValues = NestBatchModule.resolveInjectValues(imports, inject);\n const factoryResult = useFactory(...injectValues);\n\n if (factoryResult instanceof Promise) {\n return factoryResult.then((adapters) =>\n NestBatchModule.buildAsyncModule(options, adapters),\n );\n }\n\n return NestBatchModule.buildAsyncModule(options, factoryResult);\n }\n\n /**\n * Shared module builder used by both the sync and async branches\n * of `forRootAsync`. When the factory result is available\n * synchronously we merge adapter `globalProviders` (plus the\n * `JobRepository` alias) into core's own provider list, exactly\n * like `forRoot` does.\n */\n private static buildAsyncModule(\n options: NestBatchModuleAsyncOptions,\n adapters: BatchAdaptersConfig,\n ): DynamicModule {\n const { imports = [], inject = [], useFactory } = options;\n\n const persistenceProviders = NestBatchModule.buildProviders(\n adapters.persistence.globalProviders ?? [],\n );\n const transportProviders = NestBatchModule.buildProviders(\n adapters.transport.globalProviders ?? [],\n );\n\n // Sentinel factory provider: holds the user's `useFactory` and\n // any `inject` deps. Other providers can pull the resolved\n // `BatchAdaptersConfig` via `@Inject(OPTIONS_FACTORY)` if they\n // need to.\n const factoryProvider: Provider = {\n provide: OPTIONS_FACTORY,\n useFactory: useFactory as (...args: unknown[]) => unknown,\n inject: [...inject] as Array<string | symbol | Function>,\n };\n\n // Options provider: bridges the sentinel factory to the\n // canonical `MODULE_OPTIONS_TOKEN` so adapters + host code can\n // read the resolved config by its stable symbol.\n const optionsProvider: Provider = {\n provide: MODULE_OPTIONS_TOKEN,\n useFactory: (\n fromFactory: BatchAdaptersConfig | undefined,\n ): BatchAdaptersConfig | undefined => fromFactory,\n inject: [OPTIONS_FACTORY],\n };\n\n return {\n module: NestBatchModule,\n global: true,\n imports: [\n ...imports,\n adapters.persistence.module,\n adapters.transport.module,\n DiscoveryModule,\n ],\n providers: [\n // Core classes (discovery + compile + register).\n JobRegistry,\n DefinitionCompiler,\n BatchExplorer,\n FlowEvaluator,\n BatchScheduleRegistry,\n BatchBootstrapper,\n // Executor subgraph (JobExecutor → Chunk/Tasklet/Listener).\n JobExecutor,\n ChunkStepExecutor,\n TaskletStepExecutor,\n ListenerInvoker,\n JobLauncher,\n JobExplorer,\n JobOperator,\n BatchWorkerRunner,\n {\n provide: BATCH_SCHEDULE_REGISTRY,\n useExisting: BatchScheduleRegistry,\n },\n // Adapter-supplied global providers (e.g. JobRepository\n // / TransactionManager implementations).\n ...persistenceProviders,\n ...transportProviders,\n // Sentinel factory + options provider (the async path).\n factoryProvider,\n optionsProvider,\n ],\n exports: [\n // Core classes.\n JobRegistry,\n DefinitionCompiler,\n BatchExplorer,\n FlowEvaluator,\n BatchScheduleRegistry,\n BatchBootstrapper,\n // Tokens.\n BATCH_SCHEDULE_REGISTRY,\n MODULE_OPTIONS_TOKEN,\n // Executor subgraph.\n JobExecutor,\n ChunkStepExecutor,\n TaskletStepExecutor,\n ListenerInvoker,\n JobLauncher,\n JobExplorer,\n JobOperator,\n BatchWorkerRunner,\n // Adapter-supplied global providers — re-exported so the\n // host can resolve the persistence + transport bindings\n // from the global module chain.\n ...persistenceProviders,\n ...transportProviders,\n ],\n };\n }\n}\n"],"names":["BatchBootstrapper","IN_PROCESS_EXECUTION_STRATEGY_PROVIDER","InProcessExecutionStrategy","NestBatchModule","OPTIONS_FACTORY","Symbol","for","logger","Logger","name","explorer","compiler","registry","scheduleRegistry","onApplicationBootstrap","discovered","getDiscovered","jobId","jobOptions","id","def","compileFromDiscovered","register","log","err","error","message","prototype","classRef","allMethodNames","fn","meta","Reflect","getMetadata","BATCH_SCHEDULED_OPTIONS","entry","methodName","cron","timezone","options","overlap","startAt","endAt","inert","names","Set","proto","Object","getOwnPropertyNames","add","getPrototypeOf","buildProviders","adapterGlobalProviders","providers","hasJobRepositoryToken","some","p","provide","JOB_REPOSITORY_TOKEN","hasJobRepositoryClass","JobRepository","push","useExisting","hasTransactionManagerToken","TRANSACTION_MANAGER_TOKEN","hasTransactionManagerClass","TransactionManager","resolveInjectValues","imports","inject","length","values","token","resolved","undefined","mod","dynamicMod","module","useValue","forRoot","adapters","persistenceProviders","persistence","globalProviders","transportProviders","transport","global","DiscoveryModule","JobRegistry","DefinitionCompiler","BatchExplorer","FlowEvaluator","BatchScheduleRegistry","JobExecutor","ChunkStepExecutor","TaskletStepExecutor","ListenerInvoker","JobLauncher","JobExplorer","JobOperator","BatchWorkerRunner","MODULE_OPTIONS_TOKEN","BATCH_SCHEDULE_REGISTRY","exports","forRootAsync","useFactory","injectValues","factoryResult","Promise","then","buildAsyncModule","factoryProvider","optionsProvider","fromFactory"],"mappings":";;;;;;;;;;;QA8KaA;eAAAA;;QAzGwBC;eAAAA,kEAAsC;;QAAlEC;eAAAA,sDAA0B;;QAqNtBC;eAAAA;;;wBAnRN;sBACyB;oCAGG;+BACL;6BACF;6BACA;mCACM;qCACE;iCACJ;6BACJ;6BACA;6BACA;mCACM;4CAI3B;+BACuB;2BACU;uCAKjC;wBAMA;+BACuB;oCACK;;;;;;;;;;AA+FnC;;;;;;;;;;;CAWC,GACD,MAAMC,kBAA0BC,OAAOC,GAAG,CAAC;AA2BpC,IAAA,AAAMN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5F;gBACA,UAAU;gBACVsG,+BAAuB;gBACvBD,4BAAoB;gBACpB,qBAAqB;gBACrBR,wBAAW;gBACXC,oCAAiB;gBACjBC,wCAAmB;gBACnBC,gCAAe;gBACfC,wBAAW;gBACXC,wBAAW;gBACXC,wBAAW;gBACXC,oCAAiB;gBACjB,yDAAyD;gBACzD,wDAAwD;gBACxD,gCAAgC;mBAC7BnB;mBACAG;aACJ;QACH;IACF;AACF"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public injection tokens for the `@nest-batch/core` module surface.
|
|
3
|
+
*
|
|
4
|
+
* These tokens are the stable, package-scoped identifiers sibling packages
|
|
5
|
+
* (e.g. `@nest-batch/mikro-orm`, `@nest-batch/typeorm`, `@nest-batch/bullmq`)
|
|
6
|
+
* use to bind their own providers into the core DI graph. They are
|
|
7
|
+
* registered in the global `Symbol.for` registry under stable, package-
|
|
8
|
+
* scoped keys so they are unique across the host process even if the
|
|
9
|
+
* package is loaded multiple times.
|
|
10
|
+
*
|
|
11
|
+
* Why symbols and not string tokens?
|
|
12
|
+
* - Symbols cannot collide with a user string by accident.
|
|
13
|
+
* - `Symbol.for(key)` gives us cross-realm uniqueness without the
|
|
14
|
+
* caller having to thread the token through `import` chains — a
|
|
15
|
+
* host can resolve any of these tokens by reaching into
|
|
16
|
+
* `Symbol.for('...description...')` and getting the same value.
|
|
17
|
+
* - Symbols are erased from emitted JavaScript, so they do not
|
|
18
|
+
* pollute production bundles with debug strings.
|
|
19
|
+
*
|
|
20
|
+
* Why a stable description (not `Symbol(description)`)?
|
|
21
|
+
* - `Symbol.for('k')` only works if the *same* string is passed both
|
|
22
|
+
* times. Hard-coding a `description` lets future sibling packages
|
|
23
|
+
* resolve the token without importing this file (useful for tooling
|
|
24
|
+
* and for ad-hoc cross-package debugging).
|
|
25
|
+
*/
|
|
26
|
+
import { EXECUTION_STRATEGY } from '../execution/execution-strategy';
|
|
27
|
+
/**
|
|
28
|
+
* Injection token for the `JobRepository` implementation.
|
|
29
|
+
*
|
|
30
|
+
* Adapter packages (`@nest-batch/mikro-orm`, `@nest-batch/typeorm`, ...)
|
|
31
|
+
* bind their `JobRepository` subclass to this token. By default the host
|
|
32
|
+
* app is expected to register its own `JobRepository` provider — core
|
|
33
|
+
* does NOT ship a default binding because the choice of persistence
|
|
34
|
+
* backend is the host's decision.
|
|
35
|
+
*/
|
|
36
|
+
export declare const JOB_REPOSITORY_TOKEN: symbol;
|
|
37
|
+
/**
|
|
38
|
+
* Injection token for the `TransactionManager` implementation.
|
|
39
|
+
*
|
|
40
|
+
* Adapter packages bind their transaction manager to this token. The
|
|
41
|
+
* `JobRepository` implementation is expected to participate in the same
|
|
42
|
+
* transaction (e.g. share the same `EntityManager` / `DataSource`).
|
|
43
|
+
*/
|
|
44
|
+
export declare const TRANSACTION_MANAGER_TOKEN: symbol;
|
|
45
|
+
/**
|
|
46
|
+
* Injection token for the `BatchScheduleRegistry` provider.
|
|
47
|
+
*
|
|
48
|
+
* The `BatchExplorer` populates this registry with `@BatchScheduled`
|
|
49
|
+
* metadata it discovers on `@Jobable` classes. The future runtime
|
|
50
|
+
* scheduler (the `@nest-batch/bullmq` cron strategy, or a sibling
|
|
51
|
+
* scheduling package) reads from this registry to install the actual
|
|
52
|
+
* timers. Keeping the registry as a stable token means adapters can
|
|
53
|
+
* inject it (for introspection / health checks) without depending on
|
|
54
|
+
* the explorer's internal state.
|
|
55
|
+
*/
|
|
56
|
+
export declare const BATCH_SCHEDULE_REGISTRY: symbol;
|
|
57
|
+
/**
|
|
58
|
+
* Injection token for the module's resolved options bag.
|
|
59
|
+
*
|
|
60
|
+
* Backs the post-`useFactory` options read (T2 will wire the async
|
|
61
|
+
* factory provider to write into this slot). Sibling packages and the
|
|
62
|
+
* host app can read the resolved options by injecting this token. The
|
|
63
|
+
* shape is the union of `NestBatchModuleOptions` plus whatever an
|
|
64
|
+
* adapter's own config contributed, so the value is a
|
|
65
|
+
* `Record<string, unknown>` at runtime.
|
|
66
|
+
*
|
|
67
|
+
* The previous `'BATCH_OPTIONS'` string alias was removed in the
|
|
68
|
+
* T1 type-contract refactor — hosts that need the options bag should
|
|
69
|
+
* inject `MODULE_OPTIONS_TOKEN` instead.
|
|
70
|
+
*/
|
|
71
|
+
export declare const MODULE_OPTIONS_TOKEN: symbol;
|
|
72
|
+
/**
|
|
73
|
+
* Polymorphic execution strategy token.
|
|
74
|
+
*
|
|
75
|
+
* Re-exported here from `execution/execution-strategy.ts` so that the
|
|
76
|
+
* module surface is the single import path for downstream packages.
|
|
77
|
+
* Apps that want the default in-process strategy wire up
|
|
78
|
+
* `IN_PROCESS_EXECUTION_STRATEGY_PROVIDER`; sibling packages (e.g.
|
|
79
|
+
* `@nest-batch/bullmq`) provide a custom binding under this same
|
|
80
|
+
* token.
|
|
81
|
+
*/
|
|
82
|
+
export { EXECUTION_STRATEGY };
|
|
83
|
+
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../../src/module/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAElC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,EAAE,MAEvC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB,EAAE,MAErC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAElC,CAAC;AAEF;;;;;;;;;GASG;AACH,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|