ddd-ts-kit 0.10.0 → 0.12.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 +13 -7
- 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 +4 -0
- package/dist/check/catalogue/architecture-rules.js.map +1 -1
- package/dist/check/catalogue/eslint-only-rules.d.ts.map +1 -1
- package/dist/check/catalogue/eslint-only-rules.js +4 -0
- package/dist/check/catalogue/eslint-only-rules.js.map +1 -1
- package/dist/check/domain-events/refused-before-commit.js +1 -1
- package/dist/check/domain-events/refused-before-commit.js.map +1 -1
- package/dist/check/errors/kit-error-codes.d.ts.map +1 -1
- package/dist/check/errors/kit-error-codes.js +2 -0
- package/dist/check/errors/kit-error-codes.js.map +1 -1
- package/dist/check/explain/errors-docs.js +1 -1
- package/dist/check/explain/errors-docs.js.map +1 -1
- package/dist/check/explain/events-docs.js +1 -1
- package/dist/check/explain/events-docs.js.map +1 -1
- 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 +2 -0
- package/dist/check/explain/rule-docs.js.map +1 -1
- package/dist/check/fixtures/domain-events-fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/domain-events-fixtures.js +18 -0
- package/dist/check/fixtures/domain-events-fixtures.js.map +1 -1
- package/dist/check/fixtures/fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/fixtures.js +2 -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/fixtures/standard-fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/standard-fixtures.js +8 -0
- package/dist/check/fixtures/standard-fixtures.js.map +1 -1
- 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/domain-events-transactional-before-commit.js +1 -1
- package/dist/check/rules/domain-events-transactional-before-commit.js.map +1 -1
- 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/check/standard/parallel-names.d.ts.map +1 -1
- package/dist/check/standard/parallel-names.js +6 -0
- package/dist/check/standard/parallel-names.js.map +1 -1
- package/dist/commands/generate.js +25 -19
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +4 -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 +3 -1
- package/dist/config/parse-stack.js.map +1 -1
- package/dist/config/stack.d.ts +17 -0
- package/dist/config/stack.d.ts.map +1 -1
- package/dist/config/stack.js +2 -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 +6 -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 +3 -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 +13 -1
- 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 +9 -0
- package/dist/docs/context-facts.d.ts.map +1 -1
- 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 +6 -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 +32 -3
- 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/generate/kind.d.ts +4 -0
- package/dist/generate/kind.d.ts.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/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/route/cache-policy-text.d.ts +8 -0
- package/dist/generate/kinds/route/cache-policy-text.d.ts.map +1 -0
- package/dist/generate/kinds/route/cache-policy-text.js +41 -0
- package/dist/generate/kinds/route/cache-policy-text.js.map +1 -0
- package/dist/generate/kinds/route/controller-plan.d.ts +2 -0
- package/dist/generate/kinds/route/controller-plan.d.ts.map +1 -1
- package/dist/generate/kinds/route/controller-vars.js +4 -1
- package/dist/generate/kinds/route/controller-vars.js.map +1 -1
- package/dist/generate/kinds/route/plan-controller.d.ts.map +1 -1
- package/dist/generate/kinds/route/plan-controller.js +4 -1
- package/dist/generate/kinds/route/plan-controller.js.map +1 -1
- package/dist/generate/kinds/route-kind.d.ts.map +1 -1
- package/dist/generate/kinds/route-kind.js +8 -1
- package/dist/generate/kinds/route-kind.js.map +1 -1
- 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.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/usage.d.ts +1 -1
- package/dist/help/usage.d.ts.map +1 -1
- package/dist/help/usage.js +3 -2
- package/dist/help/usage.js.map +1 -1
- package/dist/init/files/project-files.d.ts.map +1 -1
- package/dist/init/files/project-files.js +3 -1
- package/dist/init/files/project-files.js.map +1 -1
- 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/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 +12 -1
- package/dist/init/stack/resolve-stack.js.map +1 -1
- package/dist/init/stack/stack-options.d.ts +4 -0
- package/dist/init/stack/stack-options.d.ts.map +1 -1
- package/dist/init/template-vars.js +4 -3
- package/dist/init/template-vars.js.map +1 -1
- package/dist/stack/stack-vars.d.ts.map +1 -1
- package/dist/stack/stack-vars.js +21 -1
- package/dist/stack/stack-vars.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
- 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/context/CONTEXT.md.tpl +15 -0
- package/templates/controller/controller.class-validator.ts.tpl +3 -0
- package/templates/controller/controller.none.ts.tpl +3 -0
- package/templates/controller/controller.search.ts.tpl +3 -0
- package/templates/controller/controller.standard-schema.ts.tpl +3 -0
- package/templates/controller/controller.zod.ts.tpl +3 -0
- package/templates/docs/openapi.json.tpl +9 -0
- package/templates/init/docker/docker-compose.yml.tpl +20 -0
- package/templates/init/docker/env.example.tpl +10 -0
- package/templates/init/docker/varnish.vcl.tpl +74 -0
- package/templates/init/e2e/start-application.database.ts.tpl +28 -0
- package/templates/init/e2e/start-application.memory.ts.tpl +30 -0
- package/templates/init/e2e/test-environment.ts.tpl +5 -0
- package/templates/init/main.ts.tpl +13 -0
- package/templates/init/platform/auth/http-boundary.ts.tpl +29 -0
- package/templates/init/platform/compose-application.tsyringe.ts.tpl +13 -0
- package/templates/init/platform/config/app-config.ts.tpl +6 -0
- package/templates/init/platform/config/load-config.ts.tpl +12 -0
- package/templates/init/platform/create-platform.manual.ts.tpl +31 -0
- 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.manual.ts.tpl +7 -0
- 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 +3 -2
- package/templates/init/rules/domain.md.tpl +1 -0
- package/templates/init/rules/presentation.md.tpl +2 -1
- 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/service/main.ts.tpl +13 -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}}
|
|
@@ -11,7 +11,7 @@ paths:
|
|
|
11
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' })`.
|
|
12
12
|
{{#if style.declared}}
|
|
13
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`.
|
|
14
|
-
- 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.
|
|
15
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.
|
|
16
16
|
{{/if}}
|
|
17
17
|
{{#if style.explicit}}
|
|
@@ -26,6 +26,7 @@ paths:
|
|
|
26
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`).
|
|
27
27
|
{{/if}}
|
|
28
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`.
|
|
29
30
|
{{#if files.any}}
|
|
30
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.
|
|
31
32
|
{{/if}}
|
|
@@ -35,4 +36,4 @@ paths:
|
|
|
35
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`).
|
|
36
37
|
{{/if}}
|
|
37
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`).
|
|
38
|
-
- 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`).
|
|
@@ -29,7 +29,8 @@ paths:
|
|
|
29
29
|
{{/if}}
|
|
30
30
|
- No role or ownership test in a controller or a route (`authz/in-application`): a guard of the group asks for a role at the edge, the bus asks for the permission, a policy decides on loaded state.
|
|
31
31
|
- Request and response types are presentation types, one class or schema per file next to the controller (`*.body.ts`, `*.params.ts`, `*.answer.ts`...; `*.dto.ts` for function routes and under `shared/`): never an aggregate, never a row.
|
|
32
|
+
- A read declares how caches may keep its answer in `cache` (its controller, its route group, or the spec of a function route): `private` for what a caller reads again, with `etag`; `public` only for what is the same for everybody, with `tags` naming the resources it shows. A route that knows its caller is `no-store` unless it says otherwise, and a `public` answer of such a route is refused unless `vary` names who calls (`Authorization`, `Cookie`) or the header its tenant is read from (`presentation/shared-cache-varies`, then the mount): never cache a decision of authorization across actors. A group policy reaches the reads of the group only. A write that must not overwrite a newer version declares `ifMatch` and hands `context.expectedVersion` to its command; the handler calls `expectVersion` (412). A change purges the answers it makes stale from a `before-commit` handler of its domain event, `CacheInvalidation.invalidate([cacheTag(...)])` (`platform.cacheInvalidation` on a platform wired by hand): the purge then runs after the commit, through the outbox. Every event that changes what a kept answer shows, its version included, purges it, not only the one the route is about.
|
|
32
33
|
- Never put the message of an unexpected failure in a response or a log.
|
|
33
34
|
- Files: the canonical tree of `presentation/http/` (`naming/suffix`, `tree/closed`): a folder per controller, `*.routes.ts` for the groups, `guards/`, `shared/`; function routes stay flat (`*.route.ts`, `*.dto.ts`).
|
|
34
35
|
- After a change, `npm run docs:generate` regenerates the contract, `openapi/openapi.yaml` (one file per document when `openapi.documents` of `ddd-ts-kit.config.json` splits it; JSON under `openapi.format: json`), committed with the route; CI fails on a difference. Never edit it by hand.{{#if sdk.on}} It regenerates the typed clients under `clients/` too (`npx ddd-ts-kit sdk`), committed with it.{{/if}}
|
|
35
|
-
- Contract with `/ddd-ts-kit:document`. Create with `npx ddd-ts-kit generate route <context> <UseCase> --method <M> --path <p> [--group <Name>] [--mapper] [--serializer] --json`, then `generate e2e <context> <UseCase>`; `generate route-group` and `generate guard` write a group and a guard.
|
|
36
|
+
- Contract with `/ddd-ts-kit:document`. Create with `npx ddd-ts-kit generate route <context> <UseCase> --method <M> --path <p> [--group <Name>] [--mapper] [--serializer] [--cache public|private|no-store] --json`, then `generate e2e <context> <UseCase>`; `generate route-group` and `generate guard` write a group and a guard.
|
|
@@ -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.12.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]);
|
|
@@ -4,6 +4,10 @@ import { tracing } from '{{alias.platform}}/tracing{{alias.ext}}';
|
|
|
4
4
|
// Imported second on purpose: a failure while the rest of the application loads is already reported.
|
|
5
5
|
import { errors } from '{{alias.platform}}/errors{{alias.ext}}';
|
|
6
6
|
{{/if}}
|
|
7
|
+
{{#if httpCache.varnish}}
|
|
8
|
+
import { VarnishCachePurger } from '@ddd-ts-kit/http/purgers';
|
|
9
|
+
import { PurgingPublisher } from '@ddd-ts-kit/kernel';
|
|
10
|
+
{{/if}}
|
|
7
11
|
{{#if http.any}}
|
|
8
12
|
import { createAuthenticator } from '{{alias.platform}}/auth/create-authenticator{{alias.ext}}';
|
|
9
13
|
{{/if}}
|
|
@@ -67,7 +71,16 @@ await application.start();
|
|
|
67
71
|
{{#if events.outbox}}
|
|
68
72
|
const relay = startOutboxRelay({
|
|
69
73
|
store: persistence.outbox,
|
|
74
|
+
{{#if httpCache.varnish}}
|
|
75
|
+
// The purge requests the use cases of the context wrote with their commands go to Varnish, every other event to the provider.
|
|
76
|
+
publisher: new PurgingPublisher(
|
|
77
|
+
new VarnishCachePurger({ url: config.varnishUrl, key: config.varnishPurgeKey }),
|
|
78
|
+
application.eventBus,
|
|
79
|
+
),
|
|
80
|
+
{{/if}}
|
|
81
|
+
{{#unless httpCache.varnish}}
|
|
70
82
|
publisher: application.eventBus,
|
|
83
|
+
{{/unless}}
|
|
71
84
|
intervalMs: config.outboxRelayIntervalMs,
|
|
72
85
|
logger: application.logger,
|
|
73
86
|
{{#if errors.sentry}}
|
|
@@ -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
|
+
});
|