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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state-writes.js","sourceRoot":"","sources":["../../../src/check/event-sourcing/state-writes.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,GACd,yHAAyH,CAAC;AAE5H,MAAM,SAAS,GAAG,yFAAyF,CAAC;AAE5G,MAAM,OAAO,GACX,mJAAmJ,CAAC;AAEtJ,kHAAkH;AAClH,MAAM,UAAU,WAAW,CAAC,IAAY,EAAE,IAAY,EAAE,EAAU;IAChE,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAElC,OAAO,CAAC,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC;SACpC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;SACpF,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** One `defineStoredEvent(Event, { ... })` of an event codec, as the text shows it. */
|
|
2
|
+
export interface StoredEventDeclaration {
|
|
3
|
+
/** The key it is declared under, the name the event carries; `undefined` when the key is not a string literal. */
|
|
4
|
+
readonly name: string | undefined;
|
|
5
|
+
readonly eventClass: string;
|
|
6
|
+
readonly line: number;
|
|
7
|
+
/** `undefined` when `version` is not a number literal. */
|
|
8
|
+
readonly version: number | undefined;
|
|
9
|
+
/** The versions an upcaster reads, as the keys of `upcasters` say. */
|
|
10
|
+
readonly upcasters: readonly number[];
|
|
11
|
+
/** The type `encode` answers, by name; `undefined` when its signature names none. */
|
|
12
|
+
readonly payloadType: string | undefined;
|
|
13
|
+
/** The fingerprint of that type as declared in the same file; `undefined` when it is not declared there. */
|
|
14
|
+
readonly fingerprint: string | undefined;
|
|
15
|
+
/** The named types that data reaches and the file does not declare: a change of theirs would not move the fingerprint. */
|
|
16
|
+
readonly unresolved: readonly string[];
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=stored-event-declaration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stored-event-declaration.d.ts","sourceRoot":"","sources":["../../../src/check/event-sourcing/stored-event-declaration.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,MAAM,WAAW,sBAAsB;IACrC,kHAAkH;IAClH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,0DAA0D;IAC1D,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,sEAAsE;IACtE,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,qFAAqF;IACrF,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,4GAA4G;IAC5G,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,0HAA0H;IAC1H,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stored-event-declaration.js","sourceRoot":"","sources":["../../../src/check/event-sourcing/stored-event-declaration.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { EventNameResolver } from '../events/event-name-resolver.js';
|
|
2
|
+
import type { SourceFile } from '../model/source-file.js';
|
|
3
|
+
import type { StoredEventDeclaration } from './stored-event-declaration.js';
|
|
4
|
+
/**
|
|
5
|
+
* The stored events a file declares with `defineStoredEvent`, outside tests. A key written
|
|
6
|
+
* `[InvoiceIssued.eventName]` is read through `eventNameOf`, as the name the class declares.
|
|
7
|
+
*/
|
|
8
|
+
export declare function storedEventDeclarations(file: SourceFile, eventNameOf?: EventNameResolver): StoredEventDeclaration[];
|
|
9
|
+
//# sourceMappingURL=stored-event-declarations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stored-event-declarations.d.ts","sourceRoot":"","sources":["../../../src/check/event-sourcing/stored-event-declarations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAK1D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAU5E;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,UAAU,EAChB,WAAW,GAAE,iBAAmC,GAC/C,sBAAsB,EAAE,CAgB1B"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { callArguments } from '../text/call-arguments.js';
|
|
2
|
+
import { splitTopLevel } from '../text/split-top-level.js';
|
|
3
|
+
import { readStoredShape } from './read-stored-shape.js';
|
|
4
|
+
const CALL = /(?<![\w$.])defineStoredEvent\s*(?:<[^()]*>)?\s*\(/g;
|
|
5
|
+
const IDENTIFIER = /^[A-Za-z_$][\w$]*$/;
|
|
6
|
+
const VERSION = /^version\s*:\s*(\d+)$/;
|
|
7
|
+
const UPCASTERS = /^upcasters\s*:\s*\{/;
|
|
8
|
+
const UPCASTER_KEY = /^['"]?(\d+)['"]?\s*:/;
|
|
9
|
+
const COMPUTED_NAME = /\[\s*([A-Za-z_$][\w$]*)\.eventName\s*\]\s*:\s*$/;
|
|
10
|
+
const ENCODE = /^encode\s*(?::\s*(?:async\s*)?(?:function\s*)?)?\([^()]*\)\s*:\s*([A-Za-z_$][\w$]*)/;
|
|
11
|
+
/**
|
|
12
|
+
* The stored events a file declares with `defineStoredEvent`, outside tests. A key written
|
|
13
|
+
* `[InvoiceIssued.eventName]` is read through `eventNameOf`, as the name the class declares.
|
|
14
|
+
*/
|
|
15
|
+
export function storedEventDeclarations(file, eventNameOf = () => undefined) {
|
|
16
|
+
if (file.isTest) {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
const { code } = file.scan;
|
|
20
|
+
return [...code.matchAll(CALL)].flatMap((match) => {
|
|
21
|
+
const [type, spec] = callArguments(code, match.index + match[0].length - 1);
|
|
22
|
+
if (type === undefined || !IDENTIFIER.test(type.code) || spec?.code.startsWith('{') !== true) {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
return [declarationOf(file, { at: match.index, eventClass: type.code, spec }, eventNameOf)];
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function declarationOf(file, { at, eventClass, spec }, eventNameOf) {
|
|
29
|
+
const properties = splitTopLevel(spec.code.slice(1, spec.code.lastIndexOf('}'))).map((part) => part.code);
|
|
30
|
+
const payloadType = properties.map((property) => ENCODE.exec(property)?.[1]).find((name) => name !== undefined);
|
|
31
|
+
const version = properties.map((property) => VERSION.exec(property)?.[1]).find((value) => value !== undefined);
|
|
32
|
+
const shape = payloadType === undefined ? undefined : readStoredShape(file.scan, payloadType);
|
|
33
|
+
return {
|
|
34
|
+
name: keyBefore(file, at) ?? computedKeyBefore(file, at, eventNameOf),
|
|
35
|
+
eventClass,
|
|
36
|
+
line: file.scan.lineAt(at),
|
|
37
|
+
version: version === undefined ? undefined : Number(version),
|
|
38
|
+
upcasters: upcastersOf(properties),
|
|
39
|
+
payloadType,
|
|
40
|
+
fingerprint: shape?.fingerprint,
|
|
41
|
+
unresolved: shape?.unresolved ?? [],
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** The string literal the call is the value of, as in `'billing.invoice.issued': defineStoredEvent(...)`. */
|
|
45
|
+
function keyBefore(file, at) {
|
|
46
|
+
const { code, strings } = file.scan;
|
|
47
|
+
return strings.find((literal) => literal.end <= at && /^\s*:\s*$/.test(code.slice(literal.end, at)))?.value;
|
|
48
|
+
}
|
|
49
|
+
/** The name read by a computed key, as in `[InvoiceIssued.eventName]: defineStoredEvent(...)`. */
|
|
50
|
+
function computedKeyBefore(file, at, eventNameOf) {
|
|
51
|
+
const eventClass = COMPUTED_NAME.exec(file.scan.code.slice(Math.max(0, at - 200), at))?.[1];
|
|
52
|
+
return eventClass === undefined ? undefined : eventNameOf(eventClass);
|
|
53
|
+
}
|
|
54
|
+
function upcastersOf(properties) {
|
|
55
|
+
const upcasters = properties.find((property) => UPCASTERS.test(property));
|
|
56
|
+
if (upcasters === undefined) {
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
return splitTopLevel(upcasters.slice(upcasters.indexOf('{') + 1, upcasters.lastIndexOf('}'))).flatMap((part) => {
|
|
60
|
+
const key = UPCASTER_KEY.exec(part.code)?.[1];
|
|
61
|
+
return key === undefined ? [] : [Number(key)];
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=stored-event-declarations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stored-event-declarations.js","sourceRoot":"","sources":["../../../src/check/event-sourcing/stored-event-declarations.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGzD,MAAM,IAAI,GAAG,oDAAoD,CAAC;AAClE,MAAM,UAAU,GAAG,oBAAoB,CAAC;AACxC,MAAM,OAAO,GAAG,uBAAuB,CAAC;AACxC,MAAM,SAAS,GAAG,qBAAqB,CAAC;AACxC,MAA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,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stored-events-lock-file.d.ts","sourceRoot":"","sources":["../../../src/check/event-sourcing/stored-events-lock-file.ts"],"names":[],"mappings":"AAAA,8HAA8H;AAC9H,eAAO,MAAM,kBAAkB,4BAA4B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stored-events-lock-file.js","sourceRoot":"","sources":["../../../src/check/event-sourcing/stored-events-lock-file.ts"],"names":[],"mappings":"AAAA,8HAA8H;AAC9H,MAAM,CAAC,MAAM,kBAAkB,GAAG,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** What `readStoredShape` reads of the data type of a stored event. */
|
|
2
|
+
export interface StoredShape {
|
|
3
|
+
readonly fingerprint: string;
|
|
4
|
+
/** The named types the shape reaches that the file does not declare, in the order met. */
|
|
5
|
+
readonly unresolved: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=stored-shape.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stored-shape.d.ts","sourceRoot":"","sources":["../../../src/check/event-sourcing/stored-shape.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,0FAA0F;IAC1F,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stored-shape.js","sourceRoot":"","sources":["../../../src/check/event-sourcing/stored-shape.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"words-of.d.ts","sourceRoot":"","sources":["../../../src/check/event-sourcing/words-of.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAM9C"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** The words of a PascalCase or kebab-case name, in lower case. */
|
|
2
|
+
export function wordsOf(name) {
|
|
3
|
+
return name
|
|
4
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
5
|
+
.split(/[\s\-_.]+/)
|
|
6
|
+
.filter((word) => word !== '')
|
|
7
|
+
.map((word) => word.toLowerCase());
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=words-of.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"words-of.js","sourceRoot":"","sources":["../../../src/check/event-sourcing/words-of.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,OAAO,IAAI;SACR,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC;SACtC,KAAK,CAAC,WAAW,CAAC;SAClB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC;SAC7B,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SourceFile } from '../model/source-file.js';
|
|
2
|
+
/** The name an event class declares, found by the name of the class. */
|
|
3
|
+
export type EventNameResolver = (eventClass: string) => string | undefined;
|
|
4
|
+
/** Reads `<Event>.eventName` among these files: the name the class `<Event>` declares once. */
|
|
5
|
+
export declare function eventNameResolver(files: readonly SourceFile[]): EventNameResolver;
|
|
6
|
+
//# sourceMappingURL=event-name-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-name-resolver.d.ts","sourceRoot":"","sources":["../../../src/check/events/event-name-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAG1D,wEAAwE;AACxE,MAAM,MAAM,iBAAiB,GAAG,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;AAE3E,+FAA+F;AAC/F,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,GAAG,iBAAiB,CAUjF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { nameOfEventClass } from './name-of-event-class.js';
|
|
2
|
+
/** Reads `<Event>.eventName` among these files: the name the class `<Event>` declares once. */
|
|
3
|
+
export function eventNameResolver(files) {
|
|
4
|
+
const known = new Map();
|
|
5
|
+
return (eventClass) => {
|
|
6
|
+
if (!known.has(eventClass)) {
|
|
7
|
+
known.set(eventClass, firstName(files, eventClass));
|
|
8
|
+
}
|
|
9
|
+
return known.get(eventClass);
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function firstName(files, eventClass) {
|
|
13
|
+
for (const file of files) {
|
|
14
|
+
const name = nameOfEventClass(file, eventClass);
|
|
15
|
+
if (name !== undefined) {
|
|
16
|
+
return name;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=event-name-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-name-resolver.js","sourceRoot":"","sources":["../../../src/check/events/event-name-resolver.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAK5D,+FAA+F;AAC/F,MAAM,UAAU,iBAAiB,CAAC,KAA4B;IAC5D,MAAM,KAAK,GAAG,IAAI,GAAG,EAA8B,CAAC;IAEpD,OAAO,CAAC,UAAU,EAAE,EAAE;QACpB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YAC3B,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,SAAS,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC;QACtD,CAAC;QAED,OAAO,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC/B,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,KAA4B,EAAE,UAAkB;IACjE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAEhD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-sourcing-docs.d.ts","sourceRoot":"","sources":["../../../src/check/explain/event-sourcing-docs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA4DjE,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export const EVENT_SOURCING_DOCS = {
|
|
2
|
+
'event-sourcing/state-in-apply': {
|
|
3
|
+
why: 'An event-sourced aggregate is rebuilt by replaying its events through its apply methods, so the state a command leaves must be exactly what those methods make of the events it recorded. A command that also writes the state directly produces a state no replay will ever rebuild: the aggregate behaves one way just after the command and another way once loaded. Judged: every class of domain/aggregates/ that extends EventSourcedAggregate; outside the constructor, the static methods and the apply methods (a method named apply followed by an upper-case letter, and restore, which takes the state of a snapshot), an assignment, an increment or a mutating call (push, splice, set, add, delete...) on something of this is reported, and so is this.record(..) inside an apply method, which would record the event again at each replay.',
|
|
4
|
+
bad: `// domain/aggregates/attendance-record.aggregate.ts
|
|
5
|
+
noteNoShow(appointmentId: string, now: Date): void {
|
|
6
|
+
this.state = { noShows: this.state.noShows + 1 }; // written twice: here and by the replay
|
|
7
|
+
this.record(new NoShowNoted(this.id, now, appointmentId));
|
|
8
|
+
}`,
|
|
9
|
+
good: `// domain/aggregates/attendance-record.aggregate.ts
|
|
10
|
+
noteNoShow(appointmentId: string, now: Date): void {
|
|
11
|
+
this.record(new NoShowNoted(this.id, now, appointmentId));
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
private applyNoShowNoted(event: NoShowNoted): void {
|
|
15
|
+
this.state = { noShows: this.state.noShows + 1 };
|
|
16
|
+
}`,
|
|
17
|
+
},
|
|
18
|
+
'event-sourcing/past-tense': {
|
|
19
|
+
why: 'A stored event is a fact that is kept and replayed for as long as the aggregate lives, read by people and by projections that were not written yet. A name in the present or the imperative (BookAppointment, Cancel) reads as a request that may still be refused; a name in the past tense says it happened. Judged: in a file of domain/aggregates/ holding a class that extends EventSourcedAggregate, every name imported from domain/events/. Its fact is judged, the words after the name of the aggregate when it starts with it (InvoiceIssued of Invoice: Issued), the whole name otherwise: one word of it must read as a past participle (ending in -ed, or a common irregular one such as paid, held, taken, withdrawn, sent, set, made, done, lost, won), and a participle spelled like its imperative (set, put, read, run, cut, found, left...) does not count at the head of the fact, where it reads as a command (SetPrice, ReadInvoice). The same words generate domain-event accepts.',
|
|
20
|
+
bad: `// domain/aggregates/attendance-record.aggregate.ts
|
|
21
|
+
import { NoteNoShow } from '@/contexts/scheduling/domain/events/note-no-show.event';`,
|
|
22
|
+
good: `// domain/aggregates/attendance-record.aggregate.ts
|
|
23
|
+
import { NoShowNoted } from '@/contexts/scheduling/domain/events/no-show-noted.event';`,
|
|
24
|
+
},
|
|
25
|
+
'event-sourcing/store-behind-repository': {
|
|
26
|
+
why: "The domain and the use cases see an event-sourced aggregate exactly as they see any other: loaded by its repository port, changed by its methods, saved by the same port. A handler that reads a stream itself decides how events become state, which is the aggregate's job, and binds the use case to a storage technique the next aggregate may not use. Judged: production files of domain/ and application/ of a context; importing EventStore, SnapshotStore, CheckpointStore, EventSourcedRepository, EventSerializer, CatchUpSubscription or InMemoryEventStore from @ddd-ts-kit/kernel is reported. Infrastructure, the module file and the platform are left alone.",
|
|
27
|
+
bad: `// application/commands/note-no-show/note-no-show.handler.ts
|
|
28
|
+
constructor(private readonly store: EventStore) {}
|
|
29
|
+
const events = await this.store.readStream(\`scheduling.attendance-record-\${command.patientId}\`);`,
|
|
30
|
+
good: `// application/commands/note-no-show/note-no-show.handler.ts
|
|
31
|
+
constructor(private readonly records: AttendanceRecordRepository) {}
|
|
32
|
+
const record = await this.records.findById(command.patientId);`,
|
|
33
|
+
},
|
|
34
|
+
'event-sourcing/projection-never-appends': {
|
|
35
|
+
why: "A projection turns facts into a read model; it is replayed from position zero whenever its read model is rebuilt. A projection that appends to a stream would append again at every rebuild, and makes the read side decide facts. Judged: production files of application/projections/ and any file declaring a class with @Projection; naming EventStore or EventSourcedRepository of @ddd-ts-kit/kernel is reported, and so is anything imported from domain/repositories/ in a projection declared @Projection(name, { feed: 'event-store' }). A projection fed by the dispatcher keeps the imports it had before event sourcing.",
|
|
36
|
+
bad: `// application/projections/attendance-history.projection.ts
|
|
37
|
+
@Projection('scheduling.attendance-history', { feed: 'event-store' })
|
|
38
|
+
export class AttendanceHistoryProjection {
|
|
39
|
+
constructor(private readonly history: AttendanceHistory, private readonly records: AttendanceRecordRepository) {}
|
|
40
|
+
}`,
|
|
41
|
+
good: `// application/projections/attendance-history.projection.ts
|
|
42
|
+
@Projection('scheduling.attendance-history', { feed: 'event-store' })
|
|
43
|
+
export class AttendanceHistoryProjection {
|
|
44
|
+
constructor(private readonly history: AttendanceHistory) {}
|
|
45
|
+
}`,
|
|
46
|
+
},
|
|
47
|
+
'event-sourcing/upcaster-required': {
|
|
48
|
+
why: "Stored events are never rewritten: an event stored years ago is read by today's code. Changing the type of the data of an event that is already stored breaks every replay of it, silently when the fields keep their names. The checkable criterion: the data of a stored event is a named type declared in its codec file with every named type it reaches (the kit's own PersonalValue aside), `encode` answers it, and its fingerprint (its fields and their types, the types it reaches included, layout and order aside) is recorded per version in stored-events.lock.json by `ddd-ts-kit docs --stored-events`, which never rewrites a recorded version. `ddd-ts-kit docs --check`, in the pipeline, fails while a declared version is not recorded, so no version reaches the main branch unrecorded. Reported: an encode that names no type, a type not declared in the file, a type it reaches that the file does not declare, a version above 1 without an upcaster from each version below it, a version below the last one recorded, and a recorded version whose shape changed. The lock is committed; until a version is recorded, its shape is free to change.",
|
|
49
|
+
bad: `// infrastructure/persistence/attendance-record-events.mapper.ts
|
|
50
|
+
interface NoShowNotedData { readonly appointmentId: string; readonly reason: string } // a field added in place
|
|
51
|
+
[NoShowNoted.eventName]: defineStoredEvent(NoShowNoted, { version: 1, encode: (event): NoShowNotedData => ({ ... }), decode }),`,
|
|
52
|
+
good: `// infrastructure/persistence/attendance-record-events.mapper.ts
|
|
53
|
+
interface NoShowNotedData { readonly appointmentId: string; readonly reason: string }
|
|
54
|
+
[NoShowNoted.eventName]: defineStoredEvent(NoShowNoted, {
|
|
55
|
+
version: 2,
|
|
56
|
+
encode: (event): NoShowNotedData => ({ ... }),
|
|
57
|
+
decode,
|
|
58
|
+
upcasters: { 1: (data) => ({ ...data, reason: '' }) },
|
|
59
|
+
}),`,
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=event-sourcing-docs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-sourcing-docs.js","sourceRoot":"","sources":["../../../src/check/explain/event-sourcing-docs.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,mBAAmB,GAAsC;IACpE,+BAA+B,EAAE;QAC/B,GAAG,EAAE,8zBAA8zB;QACn0B,GAAG,EAAE;;;;EAIP;QACE,IAAI,EAAE;;;;;;;EAOR;KACC;IACD,2BAA2B,EAAE;QAC3B,GAAG,EAAE,48BAA48B;QACj9B,GAAG,EAAE;qFAC4E;QACjF,IAAI,EAAE;uFAC6E;KACpF;IACD,wCAAwC,EAAE;QACxC,GAAG,EAAE,+oBAA+oB;QACppB,GAAG,EAAE;;oGAE2F;QAChG,IAAI,EAAE;;+DAEqD;KAC5D;IACD,yCAAyC,EAAE;QACzC,GAAG,EAAE,umBAAumB;QAC5mB,GAAG,EAAE;;;;EAIP;QACE,IAAI,EAAE;;;;EAIR;KACC;IACD,kCAAkC,EAAE;QAClC,GAAG,EAAE,inCAAinC;QACtnC,GAAG,EAAE;;gIAEuH;QAC5H,IAAI,EAAE;;;;;;;IAON;KACD;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle-docs.d.ts","sourceRoot":"","sources":["../../../src/check/explain/lifecycle-docs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA+B5D,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const LIFECYCLE_DOCS = {
|
|
2
|
+
'lifecycle/status-through-machine': {
|
|
3
|
+
why: 'A state machine says once which status follows which, and what refuses a forbidden transition with a static factory of the concept error. An aggregate that also writes its status by hand keeps a second, silent copy of its lifecycle: a transition the machine forbids happens anyway, and the diagram of CONTEXT.md, drawn from the machine, lies. So an aggregate whose machine exists (domain/state-machines/<aggregate>.state-machine.ts) imports it once it writes a status, and writes its status only from machine.next(..) or machine.start(..), or copies a status it read.',
|
|
4
|
+
bad: `// domain/aggregates/appointment.aggregate.ts
|
|
5
|
+
confirm(now: Date): void {
|
|
6
|
+
if (this.state.status !== 'requested') {
|
|
7
|
+
throw AppointmentError.alreadyConfirmed(this.id);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
this.state = { ...this.state, changedAt: now, status: 'booked' };
|
|
11
|
+
}`,
|
|
12
|
+
good: `// domain/aggregates/appointment.aggregate.ts
|
|
13
|
+
confirm(now: Date): void {
|
|
14
|
+
this.state = { ...this.state, changedAt: now, status: appointmentLifecycle.next(this.state.status, 'confirm') };
|
|
15
|
+
}`,
|
|
16
|
+
},
|
|
17
|
+
'process/sends-commands-only': {
|
|
18
|
+
why: 'A process manager coordinates: it reacts to events, keeps its own state and decides what happens next. When it also loads and saves aggregates, of its context or another, or calls an outside system, it becomes a use case nobody can send, with no permission, no audit, and a transaction that spans what it should only coordinate. Its steps answer a decision whose commands do the work, each in its own handler; a file of application/processes/*.process.ts imports no aggregate, entity, repository, domain service, port or infrastructure.',
|
|
19
|
+
bad: `// application/processes/appointment-reminder.process.ts
|
|
20
|
+
import { ReminderRepository } from '@/contexts/notification/domain/repositories/reminder.repository';
|
|
21
|
+
|
|
22
|
+
export class AppointmentReminderProcess {
|
|
23
|
+
constructor(private readonly reminders: ReminderRepository) {}
|
|
24
|
+
}`,
|
|
25
|
+
good: `// application/processes/appointment-reminder.process.ts
|
|
26
|
+
export class AppointmentReminderProcess implements ProcessManager<ReminderProcessState> {
|
|
27
|
+
booked(event: AppointmentBookedV1, current: ReminderProcessState | undefined) {
|
|
28
|
+
return { state: { appointmentId: event.payload.appointmentId, stage: 'waiting' }, commands: [new PlanReminderCommand(/* ... */)] };
|
|
29
|
+
}
|
|
30
|
+
}`,
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=lifecycle-docs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle-docs.js","sourceRoot":"","sources":["../../../src/check/explain/lifecycle-docs.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAsC;IAC/D,kCAAkC,EAAE;QAClC,GAAG,EAAE,yjBAAyjB;QAC9jB,GAAG,EAAE;;;;;;;EAOP;QACE,IAAI,EAAE;;;EAGR;KACC;IACD,6BAA6B,EAAE;QAC7B,GAAG,EAAE,0hBAA0hB;QAC/hB,GAAG,EAAE;;;;;EAKP;QACE,IAAI,EAAE;;;;;EAKR;KACC;CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-docs.d.ts","sourceRoot":"","sources":["../../../src/check/explain/rule-docs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"rule-docs.d.ts","sourceRoot":"","sources":["../../../src/check/explain/rule-docs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAoBpD,oGAAoG;AACpG,eAAO,MAAM,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAmBvD,CAAC"}
|
|
@@ -2,11 +2,13 @@ import { AUTHZ_DOCS } from './authz-docs.js';
|
|
|
2
2
|
import { CLEAN_DOCS } from './clean-docs.js';
|
|
3
3
|
import { CONTEXT_DOCS } from './context-docs.js';
|
|
4
4
|
import { ERRORS_DOCS } from './errors-docs.js';
|
|
5
|
+
import { EVENT_SOURCING_DOCS } from './event-sourcing-docs.js';
|
|
5
6
|
import { EVENTS_DOCS } from './events-docs.js';
|
|
6
7
|
import { IMPORTS_DOCS } from './imports-docs.js';
|
|
7
8
|
import { LANGUAGE_DOCS } from './language-docs.js';
|
|
8
9
|
import { LAYER_DOCS } from './layer-docs.js';
|
|
9
10
|
import { LAYOUT_DOCS } from './layout-docs.js';
|
|
11
|
+
import { LIFECYCLE_DOCS } from './lifecycle-docs.js';
|
|
10
12
|
import { PERSISTENCE_DOCS } from './persistence-docs.js';
|
|
11
13
|
import { PORTS_DOCS } from './ports-docs.js';
|
|
12
14
|
import { SCHEDULING_DOCS } from './scheduling-docs.js';
|
|
@@ -20,11 +22,13 @@ export const RULE_DOCS = {
|
|
|
20
22
|
...CLEAN_DOCS,
|
|
21
23
|
...CONTEXT_DOCS,
|
|
22
24
|
...ERRORS_DOCS,
|
|
25
|
+
...EVENT_SOURCING_DOCS,
|
|
23
26
|
...EVENTS_DOCS,
|
|
24
27
|
...IMPORTS_DOCS,
|
|
25
28
|
...LANGUAGE_DOCS,
|
|
26
29
|
...LAYER_DOCS,
|
|
27
30
|
...LAYOUT_DOCS,
|
|
31
|
+
...LIFECYCLE_DOCS,
|
|
28
32
|
...PERSISTENCE_DOCS,
|
|
29
33
|
...PORTS_DOCS,
|
|
30
34
|
...SCHEDULING_DOCS,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-docs.js","sourceRoot":"","sources":["../../../src/check/explain/rule-docs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,oGAAoG;A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CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,oGAAoG;AACpG,MAAM,CAAC,MAAM,SAAS,GAAsC;IAC1D,GAAG,UAAU;IACb,GAAG,UAAU;IACb,GAAG,YAAY;IACf,GAAG,WAAW;IACd,GAAG,mBAAmB;IACtB,GAAG,WAAW;IACd,GAAG,YAAY;IACf,GAAG,aAAa;IAChB,GAAG,UAAU;IACb,GAAG,WAAW;IACd,GAAG,cAAc;IACjB,GAAG,gBAAgB;IACnB,GAAG,UAAU;IACb,GAAG,eAAe;IAClB,GAAG,aAAa;IAChB,GAAG,YAAY;IACf,GAAG,SAAS;IACZ,GAAG,WAAW;CACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-sourcing-fixtures.d.ts","sourceRoot":"","sources":["../../../src/check/fixtures/event-sourcing-fixtures.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAqO5C,eAAO,MAAM,uBAAuB,EAAE,SAAS,OAAO,EAMrD,CAAC"}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { readStoredShape } from '../event-sourcing/read-stored-shape.js';
|
|
2
|
+
import { STORED_EVENTS_LOCK } from '../event-sourcing/stored-events-lock-file.js';
|
|
3
|
+
import { scan } from '../scan/scan.js';
|
|
4
|
+
import { aggregate } from './aggregate.js';
|
|
5
|
+
import { contextDoc } from './context-doc.js';
|
|
6
|
+
import { EVENT_SOURCING_PROJECTION_FIXTURES } from './event-sourcing-projection-fixtures.js';
|
|
7
|
+
import { handler } from './handler.js';
|
|
8
|
+
import { PATHS } from './paths.js';
|
|
9
|
+
import { project } from './project.js';
|
|
10
|
+
import { SAMPLES } from './samples.js';
|
|
11
|
+
import { source } from './source.js';
|
|
12
|
+
const { AGGREGATE, BILLING, EVENT, HANDLER } = PATHS;
|
|
13
|
+
const STATE = 'event-sourcing/state-in-apply';
|
|
14
|
+
const PAST = 'event-sourcing/past-tense';
|
|
15
|
+
const STORE = 'event-sourcing/store-behind-repository';
|
|
16
|
+
const UPCASTER = 'event-sourcing/upcaster-required';
|
|
17
|
+
const KERNEL = "'@ddd-ts-kit/kernel'";
|
|
18
|
+
const ISSUED_EVENT = "import { InvoiceIssued } from '@/contexts/billing/domain/events/invoice-issued.event.js';";
|
|
19
|
+
const PRESENT_EVENT = `${BILLING}/domain/events/issue-invoice.event.ts`;
|
|
20
|
+
const CODEC = `${BILLING}/infrastructure/persistence/invoice-events.mapper.ts`;
|
|
21
|
+
const STORE_ADAPTER = `${BILLING}/infrastructure/persistence/event-store-invoice.repository.ts`;
|
|
22
|
+
const EVENTS = {
|
|
23
|
+
[EVENT]: source("export class InvoiceIssued {\n readonly name = 'billing.invoice.issued';\n\n constructor(\n readonly aggregateId: string,\n readonly amount: number,\n ) {}\n}"),
|
|
24
|
+
[PRESENT_EVENT]: source("export class IssueInvoice {\n readonly name = 'billing.invoice.issued';\n\n constructor(readonly aggregateId: string) {}\n}"),
|
|
25
|
+
};
|
|
26
|
+
const RECORDING = ['this.record(new InvoiceIssued(this.id, amount));'];
|
|
27
|
+
const APPLYING = ['this.amount = event.amount;'];
|
|
28
|
+
const STATE_IN_APPLY = [
|
|
29
|
+
{
|
|
30
|
+
ruleId: STATE,
|
|
31
|
+
name: 'a command that records, an apply method and a restore that write the state',
|
|
32
|
+
expect: 'pass',
|
|
33
|
+
files: project({ ...EVENTS, ...invoice(RECORDING, APPLYING) }),
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
ruleId: STATE,
|
|
37
|
+
name: 'a command that writes the state of an event-sourced aggregate itself',
|
|
38
|
+
expect: { file: AGGREGATE },
|
|
39
|
+
files: project({ ...EVENTS, ...invoice(['this.amount += amount;', ...RECORDING], APPLYING) }),
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
ruleId: STATE,
|
|
43
|
+
name: 'an apply method that records an event',
|
|
44
|
+
expect: { file: AGGREGATE },
|
|
45
|
+
files: project({ ...EVENTS, ...invoice(RECORDING, [...APPLYING, 'this.record(event);']) }),
|
|
46
|
+
},
|
|
47
|
+
];
|
|
48
|
+
const PRICED_GLOSSARY = `${SAMPLES.GLOSSARY}\n| Price | What an invoice asks. |\n| Set | To give a value. |`;
|
|
49
|
+
const PAST_TENSE = [
|
|
50
|
+
{
|
|
51
|
+
ruleId: PAST,
|
|
52
|
+
name: 'an event-sourced aggregate recording a fact named in the past tense',
|
|
53
|
+
expect: 'pass',
|
|
54
|
+
files: project({ ...EVENTS, ...invoice(RECORDING, APPLYING) }),
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
ruleId: PAST,
|
|
58
|
+
name: 'an event-sourced aggregate recording an event named as a command',
|
|
59
|
+
expect: { file: AGGREGATE },
|
|
60
|
+
files: project({
|
|
61
|
+
...EVENTS,
|
|
62
|
+
...invoice(['this.record(new IssueInvoice(this.id));'], APPLYING, "import { IssueInvoice } from '@/contexts/billing/domain/events/issue-invoice.event.js';"),
|
|
63
|
+
}),
|
|
64
|
+
},
|
|
65
|
+
namedEvent('a command whose verb is spelled like its participle, at the head', 'SetPrice', { file: AGGREGATE }),
|
|
66
|
+
namedEvent('the same participle after the noun, a fact', 'InvoicePriceSet', 'pass'),
|
|
67
|
+
];
|
|
68
|
+
/** An event-sourced invoice recording an event of this name, declared in `domain/events/`. */
|
|
69
|
+
function namedEvent(name, eventClass, expect) {
|
|
70
|
+
const file = eventClass.replace(/(?<=[a-z])(?=[A-Z])/g, '-').toLowerCase();
|
|
71
|
+
const imported = `import { ${eventClass} } from '@/contexts/billing/domain/events/${file}.event.js';`;
|
|
72
|
+
return {
|
|
73
|
+
ruleId: PAST,
|
|
74
|
+
name,
|
|
75
|
+
expect,
|
|
76
|
+
files: project({
|
|
77
|
+
[`${BILLING}/domain/events/${file}.event.ts`]: source(`export class ${eventClass} {\n readonly name = 'billing.invoice.price-set';\n\n constructor(readonly aggregateId: string) {}\n}`),
|
|
78
|
+
...invoice([`this.record(new ${eventClass}(this.id));`], APPLYING, imported),
|
|
79
|
+
}, { [`${BILLING}/CONTEXT.md`]: contextDoc('core', undefined, PRICED_GLOSSARY) }),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const STORE_BEHIND_REPOSITORY = [
|
|
83
|
+
{
|
|
84
|
+
ruleId: STORE,
|
|
85
|
+
name: 'the event store held by the repository adapter, the handler given the repository',
|
|
86
|
+
expect: 'pass',
|
|
87
|
+
files: project({
|
|
88
|
+
...handler(source("import { InvoiceRepository } from '@/contexts/billing/domain/repositories/invoice.repository.js';", '', 'export class IssueInvoiceHandler {', ' constructor(private readonly invoices: InvoiceRepository) {}', '}')),
|
|
89
|
+
[STORE_ADAPTER]: source(`import { EventStore } from ${KERNEL};`, '', 'export class EventStoreInvoiceRepository {', ' constructor(private readonly store: EventStore) {}', '}'),
|
|
90
|
+
}),
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
ruleId: STORE,
|
|
94
|
+
name: 'a command handler reading the stream of the aggregate',
|
|
95
|
+
expect: { file: HANDLER },
|
|
96
|
+
files: project(handler(source(`import { EventStore } from ${KERNEL};`, '', 'export class IssueInvoiceHandler {', ' constructor(private readonly store: EventStore) {}', '}'))),
|
|
97
|
+
},
|
|
98
|
+
];
|
|
99
|
+
const AMOUNT = 'readonly amount: number;';
|
|
100
|
+
const ENCODE = 'encode: (event): InvoiceIssuedData => ({ amount: event.amount }),';
|
|
101
|
+
const UPCAST = 'upcasters: { 1: (data) => ({ amount: 0, ...data }) },';
|
|
102
|
+
const LINE = 'readonly line: InvoiceLineData;';
|
|
103
|
+
const LINE_DATA = 'interface InvoiceLineData {\n readonly cents: number;\n}';
|
|
104
|
+
const UPCASTER_REQUIRED = [
|
|
105
|
+
{
|
|
106
|
+
ruleId: UPCASTER,
|
|
107
|
+
name: 'version 2 read through the upcaster from version 1, its shape as recorded',
|
|
108
|
+
expect: 'pass',
|
|
109
|
+
files: project({
|
|
110
|
+
...EVENTS,
|
|
111
|
+
[CODEC]: codec(AMOUNT, ['version: 2,', ENCODE, UPCAST]),
|
|
112
|
+
...locked({ 1: fingerprintOf('readonly cents: number;'), 2: fingerprintOf(`\n ${AMOUNT} `) }),
|
|
113
|
+
}),
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
ruleId: UPCASTER,
|
|
117
|
+
name: 'version 2 without the upcaster from version 1',
|
|
118
|
+
expect: { file: CODEC },
|
|
119
|
+
files: project({ ...EVENTS, [CODEC]: codec(AMOUNT, ['version: 2,', ENCODE]) }),
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
ruleId: UPCASTER,
|
|
123
|
+
name: 'a field added to the shape of a recorded version',
|
|
124
|
+
expect: { file: CODEC },
|
|
125
|
+
files: project({
|
|
126
|
+
...EVENTS,
|
|
127
|
+
[CODEC]: codec(`${AMOUNT}\n readonly currency: string;`, ['version: 1,', ENCODE]),
|
|
128
|
+
...locked({ 1: fingerprintOf(AMOUNT) }),
|
|
129
|
+
}),
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
ruleId: UPCASTER,
|
|
133
|
+
name: 'a field added to the shape of a recorded version, the codec keyed by the name its event class declares',
|
|
134
|
+
expect: { file: CODEC },
|
|
135
|
+
files: project({
|
|
136
|
+
...EVENTS,
|
|
137
|
+
[EVENT]: source("export class InvoiceIssued {\n static readonly eventName = 'billing.invoice.issued';\n\n readonly name = InvoiceIssued.eventName;\n\n constructor(\n readonly aggregateId: string,\n readonly amount: number,\n ) {}\n}"),
|
|
138
|
+
[CODEC]: codec(`${AMOUNT}\n readonly currency: string;`, ['version: 1,', ENCODE]).replace("'billing.invoice.issued': defineStoredEvent", '[InvoiceIssued.eventName]: defineStoredEvent'),
|
|
139
|
+
...locked({ 1: fingerprintOf(AMOUNT) }),
|
|
140
|
+
}),
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
ruleId: UPCASTER,
|
|
144
|
+
name: 'an encode that names no stored type',
|
|
145
|
+
expect: { file: CODEC },
|
|
146
|
+
files: project({
|
|
147
|
+
...EVENTS,
|
|
148
|
+
[CODEC]: codec(AMOUNT, ['version: 1,', 'encode: (event) => ({ amount: event.amount }),']),
|
|
149
|
+
}),
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
ruleId: UPCASTER,
|
|
153
|
+
name: 'a recorded shape that reaches a type of the file and a sealed value of the kit, both unchanged',
|
|
154
|
+
expect: 'pass',
|
|
155
|
+
files: project({
|
|
156
|
+
...EVENTS,
|
|
157
|
+
[CODEC]: codec(`${LINE}\n readonly note: PersonalValue;`, ['version: 1,', ENCODE], LINE_DATA),
|
|
158
|
+
...locked({ 1: fingerprintOf(`${LINE}\n readonly note: PersonalValue;`, LINE_DATA) }),
|
|
159
|
+
}),
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
ruleId: UPCASTER,
|
|
163
|
+
name: 'a field added to a type of the file that a recorded shape reaches',
|
|
164
|
+
expect: { file: CODEC },
|
|
165
|
+
files: project({
|
|
166
|
+
...EVENTS,
|
|
167
|
+
[CODEC]: codec(LINE, ['version: 1,', ENCODE], LINE_DATA.replace(/}$/, ' readonly currency: string;\n}')),
|
|
168
|
+
...locked({ 1: fingerprintOf(LINE, LINE_DATA) }),
|
|
169
|
+
}),
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
ruleId: UPCASTER,
|
|
173
|
+
name: 'a stored shape that reaches a type declared in another file',
|
|
174
|
+
expect: { file: CODEC },
|
|
175
|
+
files: project({ ...EVENTS, [CODEC]: codec('readonly line: InvoiceLine;', ['version: 1,', ENCODE]) }),
|
|
176
|
+
},
|
|
177
|
+
];
|
|
178
|
+
export const EVENT_SOURCING_FIXTURES = [
|
|
179
|
+
...STATE_IN_APPLY,
|
|
180
|
+
...PAST_TENSE,
|
|
181
|
+
...STORE_BEHIND_REPOSITORY,
|
|
182
|
+
...EVENT_SOURCING_PROJECTION_FIXTURES,
|
|
183
|
+
...UPCASTER_REQUIRED,
|
|
184
|
+
];
|
|
185
|
+
/** An event-sourced invoice whose `issue` command and `applyIssued` method are the lines given. */
|
|
186
|
+
function invoice(command, apply, event = ISSUED_EVENT) {
|
|
187
|
+
return aggregate(source(`import { EventSourcedAggregate, type Appliers } from ${KERNEL};`, event, '', 'export class Invoice extends EventSourcedAggregate<InvoiceIssued> {', ' private amount = 0;', '', ' private constructor(id: string) {', ' super(id);', ' }', '', ' issue(amount: number): void {', ...command.map((line) => ` ${line}`), ' }', '', ' protected appliers(): Appliers<InvoiceIssued> {', " return { 'billing.invoice.issued': (event) => this.applyIssued(event) };", ' }', '', ' private applyIssued(event: InvoiceIssued): void {', ...apply.map((line) => ` ${line}`), ' }', '', ' private restore(amount: number): void {', ' this.amount = amount;', ' }', '}'));
|
|
188
|
+
}
|
|
189
|
+
/** The codec of the invoice: its data and the types it declares beside, then the entry of `billing.invoice.issued` with what the fixture declares. */
|
|
190
|
+
function codec(data, entry, beside = '') {
|
|
191
|
+
return source(`import { defineStoredEvent, type PersonalValue } from ${KERNEL};`, ISSUED_EVENT, '', `interface InvoiceIssuedData {\n ${data}\n}`, beside, '', 'export const invoiceEvents = {', " 'billing.invoice.issued': defineStoredEvent(InvoiceIssued, {", ...entry.map((line) => ` ${line}`), " decode: (data, { aggregateId }) => new InvoiceIssued(aggregateId, data.number('amount')),", ' }),', '};');
|
|
192
|
+
}
|
|
193
|
+
function fingerprintOf(data, beside = '') {
|
|
194
|
+
return readStoredShape(scan(codec(data, [], beside)), 'InvoiceIssuedData')?.fingerprint ?? '';
|
|
195
|
+
}
|
|
196
|
+
function locked(versions) {
|
|
197
|
+
return { [STORED_EVENTS_LOCK]: `${JSON.stringify({ 'billing.invoice.issued': versions }, null, 2)}\n` };
|
|
198
|
+
}
|
|
199
|
+
//# sourceMappingURL=event-sourcing-fixtures.js.map
|