ddd-ts-kit 0.9.0 → 0.11.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/README.md +17 -3
- package/dist/check/canonical/roles.d.ts.map +1 -1
- package/dist/check/canonical/roles.js +18 -0
- package/dist/check/canonical/roles.js.map +1 -1
- package/dist/check/catalogue/architecture-rules.d.ts.map +1 -1
- package/dist/check/catalogue/architecture-rules.js +14 -0
- package/dist/check/catalogue/architecture-rules.js.map +1 -1
- package/dist/check/event-sourcing/declared-shape.d.ts +13 -0
- package/dist/check/event-sourcing/declared-shape.d.ts.map +1 -0
- package/dist/check/event-sourcing/declared-shape.js +100 -0
- package/dist/check/event-sourcing/declared-shape.js.map +1 -0
- package/dist/check/event-sourcing/event-sourced-classes.d.ts +5 -0
- package/dist/check/event-sourcing/event-sourced-classes.d.ts.map +1 -0
- package/dist/check/event-sourcing/event-sourced-classes.js +13 -0
- package/dist/check/event-sourcing/event-sourced-classes.js.map +1 -0
- package/dist/check/event-sourcing/fact-words.d.ts +6 -0
- package/dist/check/event-sourcing/fact-words.d.ts.map +1 -0
- package/dist/check/event-sourcing/fact-words.js +10 -0
- package/dist/check/event-sourcing/fact-words.js.map +1 -0
- package/dist/check/event-sourcing/is-apply-method.d.ts +3 -0
- package/dist/check/event-sourcing/is-apply-method.d.ts.map +1 -0
- package/dist/check/event-sourcing/is-apply-method.js +6 -0
- package/dist/check/event-sourcing/is-apply-method.js.map +1 -0
- package/dist/check/event-sourcing/kernel-names.d.ts +8 -0
- package/dist/check/event-sourcing/kernel-names.d.ts.map +1 -0
- package/dist/check/event-sourcing/kernel-names.js +7 -0
- package/dist/check/event-sourcing/kernel-names.js.map +1 -0
- package/dist/check/event-sourcing/read-stored-events-lock.d.ts +5 -0
- package/dist/check/event-sourcing/read-stored-events-lock.d.ts.map +1 -0
- package/dist/check/event-sourcing/read-stored-events-lock.js +25 -0
- package/dist/check/event-sourcing/read-stored-events-lock.js.map +1 -0
- package/dist/check/event-sourcing/read-stored-shape.d.ts +12 -0
- package/dist/check/event-sourcing/read-stored-shape.d.ts.map +1 -0
- package/dist/check/event-sourcing/read-stored-shape.js +46 -0
- package/dist/check/event-sourcing/read-stored-shape.js.map +1 -0
- package/dist/check/event-sourcing/state-writes.d.ts +3 -0
- package/dist/check/event-sourcing/state-writes.d.ts.map +1 -0
- package/dist/check/event-sourcing/state-writes.js +11 -0
- package/dist/check/event-sourcing/state-writes.js.map +1 -0
- package/dist/check/event-sourcing/stored-event-declaration.d.ts +18 -0
- package/dist/check/event-sourcing/stored-event-declaration.d.ts.map +1 -0
- package/dist/check/event-sourcing/stored-event-declaration.js +2 -0
- package/dist/check/event-sourcing/stored-event-declaration.js.map +1 -0
- package/dist/check/event-sourcing/stored-event-declarations.d.ts +9 -0
- package/dist/check/event-sourcing/stored-event-declarations.d.ts.map +1 -0
- package/dist/check/event-sourcing/stored-event-declarations.js +64 -0
- package/dist/check/event-sourcing/stored-event-declarations.js.map +1 -0
- package/dist/check/event-sourcing/stored-events-lock-file.d.ts +3 -0
- package/dist/check/event-sourcing/stored-events-lock-file.d.ts.map +1 -0
- package/dist/check/event-sourcing/stored-events-lock-file.js +3 -0
- package/dist/check/event-sourcing/stored-events-lock-file.js.map +1 -0
- package/dist/check/event-sourcing/stored-shape.d.ts +7 -0
- package/dist/check/event-sourcing/stored-shape.d.ts.map +1 -0
- package/dist/check/event-sourcing/stored-shape.js +2 -0
- package/dist/check/event-sourcing/stored-shape.js.map +1 -0
- package/dist/check/event-sourcing/words-of.d.ts +3 -0
- package/dist/check/event-sourcing/words-of.d.ts.map +1 -0
- package/dist/check/event-sourcing/words-of.js +9 -0
- package/dist/check/event-sourcing/words-of.js.map +1 -0
- package/dist/check/events/event-name-resolver.d.ts +6 -0
- package/dist/check/events/event-name-resolver.d.ts.map +1 -0
- package/dist/check/events/event-name-resolver.js +21 -0
- package/dist/check/events/event-name-resolver.js.map +1 -0
- package/dist/check/explain/event-sourcing-docs.d.ts +3 -0
- package/dist/check/explain/event-sourcing-docs.d.ts.map +1 -0
- package/dist/check/explain/event-sourcing-docs.js +62 -0
- package/dist/check/explain/event-sourcing-docs.js.map +1 -0
- package/dist/check/explain/lifecycle-docs.d.ts +3 -0
- package/dist/check/explain/lifecycle-docs.d.ts.map +1 -0
- package/dist/check/explain/lifecycle-docs.js +33 -0
- package/dist/check/explain/lifecycle-docs.js.map +1 -0
- package/dist/check/explain/rule-docs.d.ts.map +1 -1
- package/dist/check/explain/rule-docs.js +4 -0
- package/dist/check/explain/rule-docs.js.map +1 -1
- package/dist/check/fixtures/event-sourcing-fixtures.d.ts +3 -0
- package/dist/check/fixtures/event-sourcing-fixtures.d.ts.map +1 -0
- package/dist/check/fixtures/event-sourcing-fixtures.js +199 -0
- package/dist/check/fixtures/event-sourcing-fixtures.js.map +1 -0
- package/dist/check/fixtures/event-sourcing-projection-fixtures.d.ts +3 -0
- package/dist/check/fixtures/event-sourcing-projection-fixtures.d.ts.map +1 -0
- package/dist/check/fixtures/event-sourcing-projection-fixtures.js +48 -0
- package/dist/check/fixtures/event-sourcing-projection-fixtures.js.map +1 -0
- package/dist/check/fixtures/fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/fixtures.js +4 -0
- package/dist/check/fixtures/fixtures.js.map +1 -1
- package/dist/check/fixtures/lifecycle-fixtures.d.ts +3 -0
- package/dist/check/fixtures/lifecycle-fixtures.d.ts.map +1 -0
- package/dist/check/fixtures/lifecycle-fixtures.js +90 -0
- package/dist/check/fixtures/lifecycle-fixtures.js.map +1 -0
- package/dist/check/lifecycle/is-aggregate-file.d.ts +4 -0
- package/dist/check/lifecycle/is-aggregate-file.d.ts.map +1 -0
- package/dist/check/lifecycle/is-aggregate-file.js +6 -0
- package/dist/check/lifecycle/is-aggregate-file.js.map +1 -0
- package/dist/check/lifecycle/machines-imported.d.ts +4 -0
- package/dist/check/lifecycle/machines-imported.d.ts.map +1 -0
- package/dist/check/lifecycle/machines-imported.js +11 -0
- package/dist/check/lifecycle/machines-imported.js.map +1 -0
- package/dist/check/lifecycle/shorthand-status-writes.d.ts +7 -0
- package/dist/check/lifecycle/shorthand-status-writes.d.ts.map +1 -0
- package/dist/check/lifecycle/shorthand-status-writes.js +34 -0
- package/dist/check/lifecycle/shorthand-status-writes.js.map +1 -0
- package/dist/check/lifecycle/status-writes.d.ts +14 -0
- package/dist/check/lifecycle/status-writes.d.ts.map +1 -0
- package/dist/check/lifecycle/status-writes.js +29 -0
- package/dist/check/lifecycle/status-writes.js.map +1 -0
- package/dist/check/rules/event-sourcing-past-tense.d.ts +3 -0
- package/dist/check/rules/event-sourcing-past-tense.d.ts.map +1 -0
- package/dist/check/rules/event-sourcing-past-tense.js +31 -0
- package/dist/check/rules/event-sourcing-past-tense.js.map +1 -0
- package/dist/check/rules/event-sourcing-projection-never-appends.d.ts +3 -0
- package/dist/check/rules/event-sourcing-projection-never-appends.d.ts.map +1 -0
- package/dist/check/rules/event-sourcing-projection-never-appends.js +54 -0
- package/dist/check/rules/event-sourcing-projection-never-appends.js.map +1 -0
- package/dist/check/rules/event-sourcing-state-in-apply.d.ts +3 -0
- package/dist/check/rules/event-sourcing-state-in-apply.d.ts.map +1 -0
- package/dist/check/rules/event-sourcing-state-in-apply.js +34 -0
- package/dist/check/rules/event-sourcing-state-in-apply.js.map +1 -0
- package/dist/check/rules/event-sourcing-store-behind-repository.d.ts +3 -0
- package/dist/check/rules/event-sourcing-store-behind-repository.d.ts.map +1 -0
- package/dist/check/rules/event-sourcing-store-behind-repository.js +34 -0
- package/dist/check/rules/event-sourcing-store-behind-repository.js.map +1 -0
- package/dist/check/rules/event-sourcing-upcaster-required.d.ts +3 -0
- package/dist/check/rules/event-sourcing-upcaster-required.d.ts.map +1 -0
- package/dist/check/rules/event-sourcing-upcaster-required.js +79 -0
- package/dist/check/rules/event-sourcing-upcaster-required.js.map +1 -0
- package/dist/check/rules/lifecycle-status-through-machine.d.ts +3 -0
- package/dist/check/rules/lifecycle-status-through-machine.d.ts.map +1 -0
- package/dist/check/rules/lifecycle-status-through-machine.js +55 -0
- package/dist/check/rules/lifecycle-status-through-machine.js.map +1 -0
- package/dist/check/rules/process-sends-commands-only.d.ts +3 -0
- package/dist/check/rules/process-sends-commands-only.d.ts.map +1 -0
- package/dist/check/rules/process-sends-commands-only.js +39 -0
- package/dist/check/rules/process-sends-commands-only.js.map +1 -0
- package/dist/commands/docs.d.ts.map +1 -1
- package/dist/commands/docs.js +44 -11
- package/dist/commands/docs.js.map +1 -1
- package/dist/commands/format-context.d.ts.map +1 -1
- package/dist/commands/format-context.js +1 -1
- package/dist/commands/format-context.js.map +1 -1
- package/dist/commands/generate.js +4 -0
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +1 -0
- package/dist/commands/init.js.map +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +1 -1
- package/dist/config/index.js.map +1 -1
- package/dist/config/parse-stack.d.ts.map +1 -1
- package/dist/config/parse-stack.js +2 -1
- package/dist/config/parse-stack.js.map +1 -1
- package/dist/config/stack.d.ts +10 -0
- package/dist/config/stack.d.ts.map +1 -1
- package/dist/config/stack.js +1 -0
- package/dist/config/stack.js.map +1 -1
- package/dist/declared/declared-role.d.ts.map +1 -1
- package/dist/declared/declared-role.js +1 -0
- package/dist/declared/declared-role.js.map +1 -1
- package/dist/describe/context-description.d.ts +8 -0
- package/dist/describe/context-description.d.ts.map +1 -1
- package/dist/describe/describe-context.d.ts.map +1 -1
- package/dist/describe/describe-context.js +4 -0
- package/dist/describe/describe-context.js.map +1 -1
- package/dist/describe/format-description.d.ts.map +1 -1
- package/dist/describe/format-description.js +17 -2
- package/dist/describe/format-description.js.map +1 -1
- package/dist/docs/background-job-facts.d.ts +7 -0
- package/dist/docs/background-job-facts.d.ts.map +1 -0
- package/dist/docs/background-job-facts.js +2 -0
- package/dist/docs/background-job-facts.js.map +1 -0
- package/dist/docs/context-facts.d.ts +11 -0
- package/dist/docs/context-facts.d.ts.map +1 -1
- package/dist/docs/declared-stored-events.d.ts +9 -0
- package/dist/docs/declared-stored-events.d.ts.map +1 -0
- package/dist/docs/declared-stored-events.js +22 -0
- package/dist/docs/declared-stored-events.js.map +1 -0
- package/dist/docs/object-properties.d.ts +11 -0
- package/dist/docs/object-properties.d.ts.map +1 -0
- package/dist/docs/object-properties.js +21 -0
- package/dist/docs/object-properties.js.map +1 -0
- package/dist/docs/process-facts.d.ts +8 -0
- package/dist/docs/process-facts.d.ts.map +1 -0
- package/dist/docs/process-facts.js +2 -0
- package/dist/docs/process-facts.js.map +1 -0
- package/dist/docs/read-background-jobs.d.ts +5 -0
- package/dist/docs/read-background-jobs.d.ts.map +1 -0
- package/dist/docs/read-background-jobs.js +16 -0
- package/dist/docs/read-background-jobs.js.map +1 -0
- package/dist/docs/read-context.d.ts.map +1 -1
- package/dist/docs/read-context.js +16 -0
- package/dist/docs/read-context.js.map +1 -1
- package/dist/docs/read-processes.d.ts +5 -0
- package/dist/docs/read-processes.d.ts.map +1 -0
- package/dist/docs/read-processes.js +22 -0
- package/dist/docs/read-processes.js.map +1 -0
- package/dist/docs/read-state-machines.d.ts +10 -0
- package/dist/docs/read-state-machines.d.ts.map +1 -0
- package/dist/docs/read-state-machines.js +81 -0
- package/dist/docs/read-state-machines.js.map +1 -0
- package/dist/docs/read-vocabularies.d.ts +4 -0
- package/dist/docs/read-vocabularies.d.ts.map +1 -0
- package/dist/docs/read-vocabularies.js +14 -0
- package/dist/docs/read-vocabularies.js.map +1 -0
- package/dist/docs/refresh-context-doc.d.ts +1 -1
- package/dist/docs/refresh-context-doc.d.ts.map +1 -1
- package/dist/docs/refresh-context-doc.js +33 -4
- package/dist/docs/refresh-context-doc.js.map +1 -1
- package/dist/docs/state-machine-facts.d.ts +18 -0
- package/dist/docs/state-machine-facts.d.ts.map +1 -0
- package/dist/docs/state-machine-facts.js +2 -0
- package/dist/docs/state-machine-facts.js.map +1 -0
- package/dist/docs/state-machine-lines.d.ts +8 -0
- package/dist/docs/state-machine-lines.d.ts.map +1 -0
- package/dist/docs/state-machine-lines.js +32 -0
- package/dist/docs/state-machine-lines.js.map +1 -0
- package/dist/docs/unrecorded-stored-events.d.ts +9 -0
- package/dist/docs/unrecorded-stored-events.d.ts.map +1 -0
- package/dist/docs/unrecorded-stored-events.js +17 -0
- package/dist/docs/unrecorded-stored-events.js.map +1 -0
- package/dist/docs/write-docs.d.ts +1 -2
- package/dist/docs/write-docs.d.ts.map +1 -1
- package/dist/docs/write-docs.js +1 -2
- package/dist/docs/write-docs.js.map +1 -1
- package/dist/docs/write-stored-events-lock.d.ts +12 -0
- package/dist/docs/write-stored-events-lock.d.ts.map +1 -0
- package/dist/docs/write-stored-events-lock.js +41 -0
- package/dist/docs/write-stored-events-lock.js.map +1 -0
- package/dist/generate/event-names.d.ts +2 -0
- package/dist/generate/event-names.d.ts.map +1 -1
- package/dist/generate/event-names.js +1 -0
- package/dist/generate/event-names.js.map +1 -1
- package/dist/generate/kind.d.ts +4 -0
- package/dist/generate/kind.d.ts.map +1 -1
- package/dist/generate/kinds/aggregate-kind.d.ts.map +1 -1
- package/dist/generate/kinds/aggregate-kind.js +8 -2
- package/dist/generate/kinds/aggregate-kind.js.map +1 -1
- package/dist/generate/kinds/background/background-job-vars.d.ts +7 -0
- package/dist/generate/kinds/background/background-job-vars.d.ts.map +1 -0
- package/dist/generate/kinds/background/background-job-vars.js +29 -0
- package/dist/generate/kinds/background/background-job-vars.js.map +1 -0
- package/dist/generate/kinds/background/job-import.d.ts +8 -0
- package/dist/generate/kinds/background/job-import.d.ts.map +1 -0
- package/dist/generate/kinds/background/job-import.js +17 -0
- package/dist/generate/kinds/background/job-import.js.map +1 -0
- package/dist/generate/kinds/background/payload-field.d.ts +18 -0
- package/dist/generate/kinds/background/payload-field.d.ts.map +1 -0
- package/dist/generate/kinds/background/payload-field.js +52 -0
- package/dist/generate/kinds/background/payload-field.js.map +1 -0
- package/dist/generate/kinds/background/require-container.d.ts +7 -0
- package/dist/generate/kinds/background/require-container.d.ts.map +1 -0
- package/dist/generate/kinds/background/require-container.js +13 -0
- package/dist/generate/kinds/background/require-container.js.map +1 -0
- package/dist/generate/kinds/background-job-kind.d.ts +3 -0
- package/dist/generate/kinds/background-job-kind.d.ts.map +1 -0
- package/dist/generate/kinds/background-job-kind.js +49 -0
- package/dist/generate/kinds/background-job-kind.js.map +1 -0
- package/dist/generate/kinds/domain-event-kind.d.ts.map +1 -1
- package/dist/generate/kinds/domain-event-kind.js +5 -2
- package/dist/generate/kinds/domain-event-kind.js.map +1 -1
- package/dist/generate/kinds/event-vars.d.ts.map +1 -1
- package/dist/generate/kinds/event-vars.js +6 -1
- package/dist/generate/kinds/event-vars.js.map +1 -1
- package/dist/generate/kinds/extend-event-sourced-aggregate.d.ts +9 -0
- package/dist/generate/kinds/extend-event-sourced-aggregate.d.ts.map +1 -0
- package/dist/generate/kinds/extend-event-sourced-aggregate.js +67 -0
- package/dist/generate/kinds/extend-event-sourced-aggregate.js.map +1 -0
- package/dist/generate/kinds/job/command-input.d.ts +11 -0
- package/dist/generate/kinds/job/command-input.d.ts.map +1 -0
- package/dist/generate/kinds/job/command-input.js +13 -0
- package/dist/generate/kinds/job/command-input.js.map +1 -0
- package/dist/generate/kinds/job/granted-in-spec.d.ts +6 -0
- package/dist/generate/kinds/job/granted-in-spec.d.ts.map +1 -0
- package/dist/generate/kinds/job/granted-in-spec.js +18 -0
- package/dist/generate/kinds/job/granted-in-spec.js.map +1 -0
- package/dist/generate/kinds/job/job-vars.d.ts.map +1 -1
- package/dist/generate/kinds/job/job-vars.js +1 -17
- package/dist/generate/kinds/job/job-vars.js.map +1 -1
- package/dist/generate/kinds/job/read-sent-command.d.ts +8 -2
- package/dist/generate/kinds/job/read-sent-command.d.ts.map +1 -1
- package/dist/generate/kinds/job/read-sent-command.js +18 -12
- package/dist/generate/kinds/job/read-sent-command.js.map +1 -1
- package/dist/generate/kinds/job/sent-command.d.ts +4 -1
- package/dist/generate/kinds/job/sent-command.d.ts.map +1 -1
- package/dist/generate/kinds/process-kind.d.ts +3 -0
- package/dist/generate/kinds/process-kind.d.ts.map +1 -0
- package/dist/generate/kinds/process-kind.js +39 -0
- package/dist/generate/kinds/process-kind.js.map +1 -0
- package/dist/generate/kinds/state-machine/parse-transitions.d.ts +4 -0
- package/dist/generate/kinds/state-machine/parse-transitions.d.ts.map +1 -0
- package/dist/generate/kinds/state-machine/parse-transitions.js +24 -0
- package/dist/generate/kinds/state-machine/parse-transitions.js.map +1 -0
- package/dist/generate/kinds/state-machine/requested-transition.d.ts +9 -0
- package/dist/generate/kinds/state-machine/requested-transition.d.ts.map +1 -0
- package/dist/generate/kinds/state-machine/requested-transition.js +2 -0
- package/dist/generate/kinds/state-machine/requested-transition.js.map +1 -0
- package/dist/generate/kinds/state-machine/state-machine-vars.d.ts +12 -0
- package/dist/generate/kinds/state-machine/state-machine-vars.d.ts.map +1 -0
- package/dist/generate/kinds/state-machine/state-machine-vars.js +44 -0
- package/dist/generate/kinds/state-machine/state-machine-vars.js.map +1 -0
- package/dist/generate/kinds/state-machine/status-vocabulary.d.ts +9 -0
- package/dist/generate/kinds/state-machine/status-vocabulary.d.ts.map +1 -0
- package/dist/generate/kinds/state-machine/status-vocabulary.js +26 -0
- package/dist/generate/kinds/state-machine/status-vocabulary.js.map +1 -0
- package/dist/generate/kinds/state-machine-kind.d.ts +3 -0
- package/dist/generate/kinds/state-machine-kind.d.ts.map +1 -0
- package/dist/generate/kinds/state-machine-kind.js +33 -0
- package/dist/generate/kinds/state-machine-kind.js.map +1 -0
- package/dist/generate/kinds/write-event-sourced-aggregate.d.ts +8 -0
- package/dist/generate/kinds/write-event-sourced-aggregate.d.ts.map +1 -0
- package/dist/generate/kinds/write-event-sourced-aggregate.js +24 -0
- package/dist/generate/kinds/write-event-sourced-aggregate.js.map +1 -0
- package/dist/generate/kinds.d.ts.map +1 -1
- package/dist/generate/kinds.js +6 -0
- package/dist/generate/kinds.js.map +1 -1
- package/dist/generate/vocabulary/held-entries.d.ts +4 -0
- package/dist/generate/vocabulary/held-entries.d.ts.map +1 -0
- package/dist/generate/vocabulary/held-entries.js +6 -0
- package/dist/generate/vocabulary/held-entries.js.map +1 -0
- package/dist/generate/vocabulary/vocabulary-text.d.ts.map +1 -1
- package/dist/generate/vocabulary/vocabulary-text.js +2 -2
- package/dist/generate/vocabulary/vocabulary-text.js.map +1 -1
- package/dist/help/notes.d.ts +1 -1
- package/dist/help/notes.d.ts.map +1 -1
- package/dist/help/notes.js +3 -0
- package/dist/help/notes.js.map +1 -1
- package/dist/help/usage.d.ts +1 -1
- package/dist/help/usage.d.ts.map +1 -1
- package/dist/help/usage.js +2 -2
- package/dist/init/manifest/dependencies-for.d.ts.map +1 -1
- package/dist/init/manifest/dependencies-for.js +2 -0
- package/dist/init/manifest/dependencies-for.js.map +1 -1
- package/dist/init/manifest/versions.js +24 -24
- package/dist/init/manifest/versions.js.map +1 -1
- package/dist/init/stack/resolve-queue.d.ts +13 -0
- package/dist/init/stack/resolve-queue.d.ts.map +1 -0
- package/dist/init/stack/resolve-queue.js +25 -0
- package/dist/init/stack/resolve-queue.js.map +1 -0
- package/dist/init/stack/resolve-stack.d.ts.map +1 -1
- package/dist/init/stack/resolve-stack.js +2 -0
- package/dist/init/stack/resolve-stack.js.map +1 -1
- package/dist/init/stack/stack-options.d.ts +2 -0
- package/dist/init/stack/stack-options.d.ts.map +1 -1
- package/dist/naming/index.d.ts +2 -0
- package/dist/naming/index.d.ts.map +1 -1
- package/dist/naming/index.js +2 -0
- package/dist/naming/index.js.map +1 -1
- package/dist/naming/is-past-fact.d.ts +7 -0
- package/dist/naming/is-past-fact.d.ts.map +1 -0
- package/dist/naming/is-past-fact.js +18 -0
- package/dist/naming/is-past-fact.js.map +1 -0
- package/dist/naming/is-past-word.d.ts +3 -0
- package/dist/naming/is-past-word.d.ts.map +1 -0
- package/dist/naming/is-past-word.js +113 -0
- package/dist/naming/is-past-word.js.map +1 -0
- package/dist/naming/looks-like-past-fact.d.ts +1 -1
- package/dist/naming/looks-like-past-fact.d.ts.map +1 -1
- package/dist/naming/looks-like-past-fact.js +3 -66
- package/dist/naming/looks-like-past-fact.js.map +1 -1
- package/dist/stack/stack-vars.d.ts.map +1 -1
- package/dist/stack/stack-vars.js +13 -0
- package/dist/stack/stack-vars.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +2 -2
- package/templates/aggregate/event-sourced.aggregate.spec.ts.tpl +26 -0
- package/templates/aggregate/event-sourced.aggregate.ts.tpl +61 -0
- package/templates/aggregate/event-sourced.events.mapper.ts.tpl +15 -0
- package/templates/background-job/background-job.declared.ts.tpl +26 -0
- package/templates/background-job/background-job.spec.ts.tpl +63 -0
- package/templates/background-job/background-job.ts.tpl +24 -0
- package/templates/background-job/wiring.tsyringe.tpl +5 -0
- package/templates/builder/event-sourced.builder.ts.tpl +36 -0
- package/templates/context/CONTEXT.md.tpl +15 -0
- package/templates/init/CLAUDE.md.tpl +1 -1
- package/templates/init/platform/database/persistence-over.drizzle.ts.tpl +20 -1
- package/templates/init/platform/database/persistence-over.knex.ts.tpl +18 -1
- package/templates/init/platform/database/persistence.orm.ts.tpl +12 -1
- package/templates/init/platform/database/schema.drizzle.ts.tpl +12 -2
- package/templates/init/platform/database/schema.knex.ts.tpl +7 -1
- package/templates/init/platform/platform.module.tsyringe.ts.tpl +43 -3
- package/templates/init/platform/redis/open-redis.ts.tpl +37 -1
- package/templates/init/rules/application.md.tpl +4 -2
- package/templates/init/rules/domain.md.tpl +2 -0
- package/templates/init/rules/infrastructure.md.tpl +1 -0
- package/templates/pipeline/package-scripts.json +1 -1
- package/templates/process/process.spec.ts.tpl +44 -0
- package/templates/process/process.ts.tpl +41 -0
- package/templates/process/timeout-job.declared.ts.tpl +18 -0
- package/templates/process/timeout-job.spec.ts.tpl +43 -0
- package/templates/process/timeout-job.ts.tpl +16 -0
- package/templates/process/timeout-job.wiring.tsyringe.tpl +5 -0
- package/templates/state-machine/state-machine.spec.ts.tpl +16 -0
- package/templates/state-machine/state-machine.ts.tpl +16 -0
|
@@ -1,17 +1,39 @@
|
|
|
1
|
-
import type { Cache, Lock, Metrics, RateLimiter } from '@ddd-ts-kit/kernel';
|
|
1
|
+
import type { Cache, {{#if queue.redis}}ErrorReporter, {{/if}}Lock, {{#if queue.redis}}Logger, {{/if}}Metrics, RateLimiter } from '@ddd-ts-kit/kernel';
|
|
2
2
|
{{#if cache.relaySignal}}
|
|
3
3
|
import {
|
|
4
4
|
RedisCache,
|
|
5
|
+
{{#if queue.redis}}
|
|
6
|
+
RedisJobStore,
|
|
7
|
+
{{/if}}
|
|
5
8
|
RedisLock,
|
|
6
9
|
RedisRateLimiter,
|
|
7
10
|
RedisRelaySignal,
|
|
8
11
|
connectRedis,
|
|
9
12
|
redisHealth,
|
|
13
|
+
{{#if queue.redis}}
|
|
14
|
+
reportLostJobs,
|
|
15
|
+
{{/if}}
|
|
10
16
|
} from '@ddd-ts-kit/redis';
|
|
11
17
|
{{/if}}
|
|
12
18
|
{{#unless cache.relaySignal}}
|
|
19
|
+
{{#if queue.redis}}
|
|
20
|
+
import {
|
|
21
|
+
RedisCache,
|
|
22
|
+
RedisJobStore,
|
|
23
|
+
RedisLock,
|
|
24
|
+
RedisRateLimiter,
|
|
25
|
+
connectRedis,
|
|
26
|
+
redisHealth,
|
|
27
|
+
reportLostJobs,
|
|
28
|
+
} from '@ddd-ts-kit/redis';
|
|
29
|
+
{{/if}}
|
|
30
|
+
{{#unless queue.redis}}
|
|
13
31
|
import { RedisCache, RedisLock, RedisRateLimiter, connectRedis, redisHealth } from '@ddd-ts-kit/redis';
|
|
14
32
|
{{/unless}}
|
|
33
|
+
{{/unless}}
|
|
34
|
+
{{#if queue.redis}}
|
|
35
|
+
import type { JobStore } from '@ddd-ts-kit/scheduling';
|
|
36
|
+
{{/if}}
|
|
15
37
|
|
|
16
38
|
/**
|
|
17
39
|
* What the platform puts on one connection to a Redis protocol server. The adapters use a common
|
|
@@ -25,6 +47,13 @@ export interface RedisServices {
|
|
|
25
47
|
readonly rateLimiter: RateLimiter;
|
|
26
48
|
/** Excludes between processes: what keeps an occurrence of a scheduled job to one instance, best effort. */
|
|
27
49
|
readonly lock: Lock;
|
|
50
|
+
{{#if queue.redis}}
|
|
51
|
+
/**
|
|
52
|
+
* The background jobs: added once the command that enqueues them committed, claimed by every
|
|
53
|
+
* worker. A write lost after the commit (the server away) is logged and reported.
|
|
54
|
+
*/
|
|
55
|
+
jobs(logger: Logger, errors?: ErrorReporter): JobStore;
|
|
56
|
+
{{/if}}
|
|
28
57
|
{{#if cache.relaySignal}}
|
|
29
58
|
/** Wakes the outbox relay of every instance as soon as a command committed; the polling interval stays as the safety net. */
|
|
30
59
|
readonly relaySignal: RedisRelaySignal;
|
|
@@ -53,6 +82,13 @@ export function openRedis({ redisUrl, serviceName }: RedisSettings): RedisServic
|
|
|
53
82
|
// While the server is away the API keeps serving, without a limit: a limiter must not take the application down.
|
|
54
83
|
rateLimiter: new RedisRateLimiter(connection.client, { namespace: serviceName + ':rate', onError: 'allow' }),
|
|
55
84
|
lock: new RedisLock(connection.client, { namespace: serviceName + ':lock' }),
|
|
85
|
+
{{#if queue.redis}}
|
|
86
|
+
jobs: (logger, errors) =>
|
|
87
|
+
new RedisJobStore(connection.client, {
|
|
88
|
+
namespace: serviceName + ':jobs',
|
|
89
|
+
onLostJob: reportLostJobs(logger, errors),
|
|
90
|
+
}),
|
|
91
|
+
{{/if}}
|
|
56
92
|
{{#if cache.relaySignal}}
|
|
57
93
|
relaySignal,
|
|
58
94
|
{{/if}}
|
|
@@ -8,9 +8,10 @@ paths:
|
|
|
8
8
|
- Imports `domain/`, `application/`, published languages, `@ddd-ts-kit/kernel` and `@ddd-ts-kit/auth` only (`layer/application-inward`): never `infrastructure/`, `presentation/`, a framework or a driver.
|
|
9
9
|
- One use case per folder, `commands/<use-case>/` or `queries/<use-case>/`: the message, its handler, a `*.result.ts` when the answer has a shape of its own. The handler has one public method, `execute` (`application/handler-shape`): it loads or builds, calls ONE intention method, `await repository.save(aggregate)`, and returns at most an identifier.
|
|
10
10
|
- Events leave with the save: never `pullEvents()`, never a `DomainEventDispatcher` here (`domain-events/dispatched-on-save`). A reaction is a class of `event-handlers/` or a publisher of `integration/publishers/`. It runs at the end of the unit of work, before the commit, and depends only on what the transaction covers (`domain-events/transactional-before-commit`): repositories, the integration event publisher, the command bus. An effect outside the database is a handler of the `after-commit` phase (`generate event-handler ... --phase after-commit`: at most once, never saves, sends a command) or, when it must not be lost, the handler of an integration event.
|
|
11
|
+
- Nothing here reads the event store: an event-sourced aggregate is loaded and saved through its repository port like any other (`event-sourcing/store-behind-repository`). A projection writes its read model and never a stream (`event-sourcing/projection-never-appends`); one fed by the store is declared `@Projection(name, { feed: 'event-store' })`.
|
|
11
12
|
{{#if style.declared}}
|
|
12
13
|
- Every command and query carries `@Requires(permission)` or `@Public()` (`authz/declared`), and the actor is in the message (`authz/actor-explicit`). Permissions live in `authorization/<context>.permissions.ts`, rules that need loaded state in `authorization/*.policy.ts`.
|
|
13
|
-
- The decorator is the registration (`declarations/role-declared`): `@CommandHandler(Message)`, `@QueryHandler(Message)`, `@DomainEventHandler(Event, { name })`, `@IntegrationEventHandler(definition, { consumer })`, `@Scheduled('<context>.<job>', schedule)`, `@Projection('<context>.<name>')`, `@Policy(permission, { name })`. Names are string literals.
|
|
14
|
+
- The decorator is the registration (`declarations/role-declared`): `@CommandHandler(Message)`, `@QueryHandler(Message)`, `@DomainEventHandler(Event, { name })`, `@IntegrationEventHandler(definition, { consumer })`, `@Scheduled('<context>.<job>', schedule)`, `@Background(options)` (the name is the static `jobName`), `@Projection('<context>.<name>')`, `@Policy(permission, { name })`. Names are string literals.
|
|
14
15
|
- The constructor is the one statement of what a class depends on (`declarations/constructor-injection`): each parameter is typed by one port class, with no `?`, default value, rest or destructuring, and no list repeats it in the decorator. To add a dependency, add the parameter: `npx ddd-ts-kit docs` reads the signature into the generated file of the context (`npm run dev` does it on every change), never edit that file.
|
|
15
16
|
{{/if}}
|
|
16
17
|
{{#if style.explicit}}
|
|
@@ -25,6 +26,7 @@ paths:
|
|
|
25
26
|
- A dependency list names port classes, imported as values, in the order of the constructor: never an adapter or a fake (`ports/value-import`, `ports/no-concrete-dependency`).
|
|
26
27
|
{{/if}}
|
|
27
28
|
- A job (`scheduling/*.job.ts`) and an integration event handler (`integration/handlers/`) only build one command and send it as a system actor; both are safe to repeat (`scheduling/job-triggers-use-case`, `events/consumer-idempotent`).
|
|
29
|
+
- Work a use case hands to a worker is a background job (`background/*.background-job.ts`, `generate background-job ... --command <UseCase>`): enqueued through `JobQueue` in the unit of work of the command, run later as the actor that enqueued it, at least once, so it sends commands safe to repeat and a long one reports its progress and saves a checkpoint. A process that waits for events and has deadlines is a process manager (`processes/*.process.ts`, `generate process`): its steps decide from its state alone and answer commands and timeouts, never write an aggregate (`process/sends-commands-only`); an event handler runs each step through `ProcessRunner`.
|
|
28
30
|
{{#if files.any}}
|
|
29
31
|
- A file arrives in the command as a `FileUpload` of its area, which the bus stages before the transaction under a key of `FileKeys` (never a name or a path from the user) and scans; the handler records `upload.file`, its `StoredFile`, on the aggregate and calls `FileStaging.promoteOnCommit`, which moves it to its key with the commit. A direct upload is confirmed from the `PendingUpload` the aggregate kept, never from a key the client sends. The ports are named here, never a connector (`files/port-not-connector`); `npx ddd-ts-kit generate file-upload` writes the slice.
|
|
30
32
|
{{/if}}
|
|
@@ -34,4 +36,4 @@ paths:
|
|
|
34
36
|
- A permission, a role or a status is read from its declaration, `billingPermissions['invoice.issue']`, `InvoiceStatus.Issued`, never written as a string (`language/declared-vocabulary`); a number has a name (`clean/no-magic-number`).
|
|
35
37
|
{{/if}}
|
|
36
38
|
- Time through `Clock`, identifiers through `IdGenerator`, no `process.env` (`purity/*`). No logging, tracing, retry or audit call: they are applied from outside (`aspects/outside-in`, `tracing/platform-only`).
|
|
37
|
-
- A whole feature with `/ddd-ts-kit:use-case`. Create with `npx ddd-ts-kit generate command|query|port|policy|job|event-handler|integration-handler ... --json`, then fill the `TODO(domain)` places.
|
|
39
|
+
- A whole feature with `/ddd-ts-kit:use-case`. Create with `npx ddd-ts-kit generate command|query|port|policy|job|background-job|process|event-handler|integration-handler ... --json`, then fill the `TODO(domain)` places.
|
|
@@ -9,6 +9,7 @@ paths:
|
|
|
9
9
|
- Imports only its own `domain/`, the shared kernel and `@ddd-ts-kit/kernel` (`layer/domain-purity`): no framework, no decorator, no validation library, no `node:` module.
|
|
10
10
|
- Names come from the glossary of `CONTEXT.md`, written first (`language/glossary-term`); no `Manager`, `Helper`, `Data`, `Info`, `Model` (`language/no-technical-name`).
|
|
11
11
|
- Aggregate: private constructor, `create` for birth, `rehydrate` for loading, state changed by methods named after the business intention, no setter, no public mutable property (`domain/aggregate-encapsulation`). One aggregate per transaction; another one is referenced by its id.
|
|
12
|
+
- A status that moves through a lifecycle is declared once as a state machine, `state-machines/<aggregate>.state-machine.ts` (`generate state-machine <context> <Aggregate> --value .. --transition ..`): the aggregate writes its status only from `machine.next(..)` or `machine.start(..)` (`lifecycle/status-through-machine`), and a forbidden transition is refused by a static factory of its error class (`refused`).
|
|
12
13
|
- Value objects are immutable, validated in `create`, compared with `equals` (`domain/value-object-immutability`). An email, an amount, a period are types, not strings.
|
|
13
14
|
{{#if literals.named}}
|
|
14
15
|
- A closed list of values (a status, a kind, a role of the model) is a vocabulary, `npx ddd-ts-kit generate vocabulary <context> <Name> --value <value>...`: code reads `AppointmentStatus.NoShow`, never the string (`language/declared-vocabulary`).
|
|
@@ -28,6 +29,7 @@ paths:
|
|
|
28
29
|
- A value object returns its refusals in the `Result` of `create`{{#if refusals.factories}}: `err(PersonError.invalidEmail(raw))`{{/if}}; the caller unwraps it with `unwrap(..)` of the kernel. `npx ddd-ts-kit value-objects` moves the project to factories that throw.
|
|
29
30
|
{{/if}}
|
|
30
31
|
- Domain events are named in the past tense, `<context>.<aggregate>.<fact>` (`events/name-format`), and recorded by the aggregate (`this.record(...)`). They leave with the save: nothing here dispatches them.
|
|
32
|
+
- An aggregate whose history is the business can be event-sourced, chosen per aggregate (`generate aggregate <context> <Name> --event-sourced`): it extends `EventSourcedAggregate`, a command checks the invariants then `this.record(...)`, and only its `apply<Fact>` methods (and `restore`, for a snapshot) change the state (`event-sourcing/state-in-apply`). Its events are named in the past tense (`event-sourcing/past-tense`). The other aggregates keep their state in tables.
|
|
31
33
|
- A repository here is a port: an abstract class extending the kernel `Repository<Aggregate>`, abstract members only (`ports/abstract-class`). A domain service is stateless.
|
|
32
34
|
- Time and identifiers come in as parameters (`purity/*`); nothing here knows the acting user or its rights (`authz/in-application`).
|
|
33
35
|
- One concept per file, with the suffix of its role: `.aggregate.ts`, `.entity.ts`, `.vo.ts`, `.vocabulary.ts`, `.event.ts`, `.error.ts`, `.repository.ts`, `.service.ts` (`naming/suffix`, `naming/one-concept-per-file`).
|
|
@@ -23,6 +23,7 @@ paths:
|
|
|
23
23
|
- Retry, timeout and cache go on the binding (`ownPolicy(retry(...), timeout(...))`) or, when the policy is part of what the adapter is, as decorators of `@ddd-ts-kit/aspects/decorators` (`aspects/outside-in`). Kinds `external` and `gateway` get the default policy of the platform otherwise. `ownPolicy` is the helper of `{{alias.platform}}/resilience/own-policy{{alias.ext}}`, which `generate adapter` writes when the platform does not have it yet.
|
|
24
24
|
{{/if}}
|
|
25
25
|
- A repository only persists: no `pullEvents()`, no dispatcher (`domain-events/dispatched-on-save`). A removal that announces an event takes the aggregate, not its id.
|
|
26
|
+
- The repository adapter of an event-sourced aggregate delegates to `EventSourcedRepository` of the kernel. Its stored events are declared in `persistence/<aggregate>-events.mapper.ts` with `defineStoredEvent` and a named type of their data; a change of that type is a new version with its upcaster, never an edit (`event-sourcing/upcaster-required`, against `stored-events.lock.json`, which `ddd-ts-kit docs --stored-events` writes once the shape of a version is final; `docs --check` fails while a version is unrecorded). Every named type the data reaches is declared in the codec file too.
|
|
26
27
|
- Infrastructure faults are plain errors (a 5xx, reported from outside); business refusals are `DomainError`s raised by the domain.
|
|
27
28
|
- Every adapter passes the contract suite of the fake of its port (`test/integration/*.contract.spec.ts`).
|
|
28
29
|
- Method: `/ddd-ts-kit:persistence`. Create with `npx ddd-ts-kit generate repository|adapter|gateway|acl ... --json`.
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@biomejs/biome": "2.5.15",
|
|
24
24
|
"@commitlint/cli": "^21.2.3",
|
|
25
25
|
"@commitlint/config-conventional": "^21.2.3",
|
|
26
|
-
"@ddd-ts-kit/eslint-plugin": "^0.
|
|
26
|
+
"@ddd-ts-kit/eslint-plugin": "^0.11.0",
|
|
27
27
|
"@eslint/js": "^10.0.1",
|
|
28
28
|
"@typescript/native": "npm:typescript@~7.0.2",
|
|
29
29
|
"@vitest/coverage-v8": "5.0.3",
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { describe, expect, it } from '{{tests.module}}';
|
|
2
|
+
import { givenProcess } from '@ddd-ts-kit/testing';
|
|
3
|
+
import { {{name.pascal}}Process } from '{{alias.context}}/application/processes/{{name.kebab}}.process{{alias.ext}}';
|
|
4
|
+
|
|
5
|
+
const deadline = new Date('2026-03-01T12:00:00.000Z');
|
|
6
|
+
const process = new {{name.pascal}}Process();
|
|
7
|
+
const waiting = { id: '{{name.kebab}}-1', deadline: deadline.toISOString() };
|
|
8
|
+
|
|
9
|
+
describe('{{name.title}}', () => {
|
|
10
|
+
it('starts and waits until its deadline', () => {
|
|
11
|
+
givenProcess<typeof waiting>(undefined)
|
|
12
|
+
.when((current) => process.started('{{name.kebab}}-1', deadline, current))
|
|
13
|
+
.thenState(waiting)
|
|
14
|
+
.thenTimeouts([{ name: 'deadline', at: deadline }])
|
|
15
|
+
.thenCommands([]);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('does not start twice', () => {
|
|
19
|
+
givenProcess(waiting)
|
|
20
|
+
.when((current) => process.started('{{name.kebab}}-1', deadline, current))
|
|
21
|
+
.thenIgnored();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('ends in time and disarms its deadline', () => {
|
|
25
|
+
givenProcess(waiting)
|
|
26
|
+
.when((current) => process.completed(current))
|
|
27
|
+
.thenCancelled(['deadline'])
|
|
28
|
+
.thenEnded();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('ends at its deadline', () => {
|
|
32
|
+
givenProcess(waiting)
|
|
33
|
+
.when((current) => (current === undefined ? undefined : process.timedOut('deadline', current)))
|
|
34
|
+
.thenEnded();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('recognises the state it saved', () => {
|
|
38
|
+
expect({{name.pascal}}Process.isState(waiting)).toBe(true);
|
|
39
|
+
expect({{name.pascal}}Process.isState({ id: 'unknown-1' })).toBe(false);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// TODO(domain): one case per step, and the commands a missed deadline sends.
|
|
43
|
+
it.todo('sends the command that answers a missed deadline');
|
|
44
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ProcessDecision, ProcessManager } from '@ddd-ts-kit/kernel';
|
|
2
|
+
|
|
3
|
+
export interface {{name.pascal}}State {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly deadline: string;
|
|
6
|
+
// TODO(domain): add what the next steps decide from, identifiers and values, never an aggregate.
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const DEADLINE = 'deadline';
|
|
10
|
+
|
|
11
|
+
export class {{name.pascal}}Process implements ProcessManager<{{name.pascal}}State> {
|
|
12
|
+
static readonly processName = '{{process.name}}';
|
|
13
|
+
|
|
14
|
+
static readonly timeoutJob = '{{process.timeoutJob}}';
|
|
15
|
+
|
|
16
|
+
static isState(value: unknown): value is {{name.pascal}}State {
|
|
17
|
+
return typeof value === 'object' && value !== null && 'id' in value && 'deadline' in value;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// TODO(domain): take the event that starts the process (`ddd-ts-kit generate event-handler {{context.kebab}} <Aggregate> <Event>`, whose handler calls this step).
|
|
21
|
+
started(id: string, deadline: Date, current: {{name.pascal}}State | undefined): ProcessDecision<{{name.pascal}}State> | undefined {
|
|
22
|
+
if (current !== undefined) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return { state: { id, deadline: deadline.toISOString() }, timeouts: [{ name: DEADLINE, at: deadline }] };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
completed(current: {{name.pascal}}State | undefined): ProcessDecision<{{name.pascal}}State> | undefined {
|
|
30
|
+
return current === undefined ? undefined : { state: current, cancel: [DEADLINE], ended: true };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
timedOut(name: string, current: {{name.pascal}}State): ProcessDecision<{{name.pascal}}State> | undefined {
|
|
34
|
+
if (name !== DEADLINE) {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// TODO(domain): send the command that answers a missed deadline, as the process: `commands: [new <UseCase>Command(systemActor({{name.pascal}}Process.processName), ...)]`.
|
|
39
|
+
return { state: current, ended: true };
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { BackgroundJob, BackgroundJobExecution, ProcessRunner, ProcessTimeoutDue } from '@ddd-ts-kit/kernel';
|
|
2
|
+
import { Background } from '@ddd-ts-kit/kernel/declarations';
|
|
3
|
+
import { {{name.pascal}}Process } from '{{alias.context}}/application/processes/{{name.kebab}}.process{{alias.ext}}';
|
|
4
|
+
|
|
5
|
+
@Background()
|
|
6
|
+
export class {{name.pascal}}TimeoutBackgroundJob implements BackgroundJob<ProcessTimeoutDue> {
|
|
7
|
+
static readonly jobName = '{{process.timeoutJob}}';
|
|
8
|
+
|
|
9
|
+
private readonly process = new {{name.pascal}}Process();
|
|
10
|
+
|
|
11
|
+
constructor(private readonly processes: ProcessRunner) {}
|
|
12
|
+
|
|
13
|
+
async run(due: ProcessTimeoutDue, execution: BackgroundJobExecution): Promise<void> {
|
|
14
|
+
const delivered = { ...due, jobId: execution.jobId };
|
|
15
|
+
|
|
16
|
+
await this.processes.timeout({{name.pascal}}Process, delivered, (current) => this.process.timedOut(due.timeout, current));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { describe, expect, it } from '{{tests.module}}';
|
|
2
|
+
import { RoleBasedAuthorizer } from '@ddd-ts-kit/auth';
|
|
3
|
+
import { authorizationModule } from '@ddd-ts-kit/auth/di';
|
|
4
|
+
{{spec.diPlain}}
|
|
5
|
+
{{spec.contextImports}}
|
|
6
|
+
import { ProcessRunner } from '@ddd-ts-kit/kernel';
|
|
7
|
+
import { platformTestModule } from '{{alias.platform}}/platform-test.module{{alias.ext}}';
|
|
8
|
+
import { {{name.pascal}}Process } from '{{alias.context}}/application/processes/{{name.kebab}}.process{{alias.ext}}';
|
|
9
|
+
|
|
10
|
+
const HOUR = 3_600_000;
|
|
11
|
+
|
|
12
|
+
const authorization = authorizationModule({ authorizer: new RoleBasedAuthorizer({ roles: {} }) });
|
|
13
|
+
|
|
14
|
+
describe('The timeout of {{name.words}}, when its job runs', () => {
|
|
15
|
+
it('runs the step of the deadline once it is due, and not before', async () => {
|
|
16
|
+
const application = {{spec.await}}arrange();
|
|
17
|
+
const deadline = new Date(application.clock.now().getTime() + HOUR);
|
|
18
|
+
const process = new {{name.pascal}}Process();
|
|
19
|
+
const id = '{{name.kebab}}-1';
|
|
20
|
+
|
|
21
|
+
await application.get(ProcessRunner).run({{name.pascal}}Process, id, (current) => process.started(id, deadline, current));
|
|
22
|
+
|
|
23
|
+
expect(await application.backgroundJobs.runDue()).toEqual([]);
|
|
24
|
+
|
|
25
|
+
application.clock.advance(HOUR);
|
|
26
|
+
|
|
27
|
+
expect(await application.backgroundJobs.runDue()).toMatchObject([
|
|
28
|
+
{ job: '{{process.timeoutJob}}', outcome: 'succeeded' },
|
|
29
|
+
]);
|
|
30
|
+
|
|
31
|
+
expect(application.processes.list()).toMatchObject([{ ended: true }]);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
{{spec.async}}function arrange() {
|
|
36
|
+
{{#if spec.assembles}}
|
|
37
|
+
const context = {{spec.context}};
|
|
38
|
+
|
|
39
|
+
{{/if}}
|
|
40
|
+
return createTestApplication({
|
|
41
|
+
modules: [{{spec.modules}}],
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { BackgroundJob, BackgroundJobExecution, ProcessRunner, ProcessTimeoutDue } from '@ddd-ts-kit/kernel';
|
|
2
|
+
import { {{name.pascal}}Process } from '{{alias.context}}/application/processes/{{name.kebab}}.process{{alias.ext}}';
|
|
3
|
+
|
|
4
|
+
export class {{name.pascal}}TimeoutBackgroundJob implements BackgroundJob<ProcessTimeoutDue> {
|
|
5
|
+
static readonly jobName = '{{process.timeoutJob}}';
|
|
6
|
+
|
|
7
|
+
private readonly process = new {{name.pascal}}Process();
|
|
8
|
+
|
|
9
|
+
constructor(private readonly processes: ProcessRunner) {}
|
|
10
|
+
|
|
11
|
+
async run(due: ProcessTimeoutDue, execution: BackgroundJobExecution): Promise<void> {
|
|
12
|
+
const delivered = { ...due, jobId: execution.jobId };
|
|
13
|
+
|
|
14
|
+
await this.processes.timeout({{name.pascal}}Process, delivered, (current) => this.process.timedOut(due.timeout, current));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
@@imports
|
|
2
|
+
import { ProcessRunner } from '@ddd-ts-kit/kernel';
|
|
3
|
+
import { {{name.pascal}}TimeoutBackgroundJob } from '{{alias.context}}/application/background/{{name.kebab}}-timeout.background-job{{alias.ext}}';
|
|
4
|
+
@@registrations
|
|
5
|
+
builder.backgroundJob({{name.pascal}}TimeoutBackgroundJob.jobName).handledBy({{name.pascal}}TimeoutBackgroundJob, [ProcessRunner]);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { describe, expect, it } from '{{tests.module}}';
|
|
2
|
+
import { {{machine.constant}} } from '{{alias.context}}/domain/state-machines/{{aggregate.kebab}}.state-machine{{alias.ext}}';
|
|
3
|
+
import { {{machine.status}} } from '{{alias.context}}/domain/vocabularies/{{machine.statusKebab}}.vocabulary{{alias.ext}}';
|
|
4
|
+
|
|
5
|
+
describe('The lifecycle of {{aggregate.article}} {{aggregate.words}}', () => {
|
|
6
|
+
it('starts in {{machine.initialValue}}', () => {
|
|
7
|
+
expect({{machine.constant}}.start({{machine.initial}})).toBe({{machine.initial}});
|
|
8
|
+
});
|
|
9
|
+
{{#if machine.hasTransitions}}
|
|
10
|
+
|
|
11
|
+
{{machine.cases}}
|
|
12
|
+
{{/if}}
|
|
13
|
+
|
|
14
|
+
// TODO(domain): once `refused` names a refusal of {{aggregate.pascal}}Error, expect its code here; add a case per guard.
|
|
15
|
+
it.todo('refuses each forbidden transition with the refusal of the aggregate');
|
|
16
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineStateMachine } from '@ddd-ts-kit/kernel';
|
|
2
|
+
import { {{machine.status}} } from '{{alias.context}}/domain/vocabularies/{{machine.statusKebab}}.vocabulary{{alias.ext}}';
|
|
3
|
+
|
|
4
|
+
export const {{machine.constant}} = defineStateMachine({
|
|
5
|
+
states: Object.values({{machine.status}}),
|
|
6
|
+
initial: [{{machine.initial}}],
|
|
7
|
+
transitions: {
|
|
8
|
+
{{#if machine.hasTransitions}}
|
|
9
|
+
{{machine.transitions}}
|
|
10
|
+
{{/if}}
|
|
11
|
+
{{#unless machine.hasTransitions}}
|
|
12
|
+
// TODO(domain): one transition per intention method of {{aggregate.pascal}}, named after it: `issue: { from: [{{machine.initial}}], to: <state> }`; a transition without `to` keeps its state, a `guard` refuses what the status alone does not decide.
|
|
13
|
+
{{/unless}}
|
|
14
|
+
},
|
|
15
|
+
// TODO(domain): refuse a forbidden transition with a static factory of {{aggregate.pascal}}Error, `refused: ({ from, transition }, context) => {{aggregate.pascal}}Error.<refusal>(...)`; until then the refusal is TransitionError.forbidden, code FORBIDDEN_TRANSITION.
|
|
16
|
+
});
|