ddd-ts-kit 0.100.0 → 0.102.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/CHANGELOG.md +104 -0
- package/README.fr.md +17 -10
- package/README.md +16 -9
- package/dist/build/emitted-place.d.ts +1 -2
- package/dist/build/emitted-place.d.ts.map +1 -1
- package/dist/build/emitted-specifier.d.ts +7 -1
- package/dist/build/emitted-specifier.d.ts.map +1 -1
- package/dist/build/emitted-specifier.js +5 -6
- package/dist/build/emitted-specifier.js.map +1 -1
- package/dist/build/emitted-target.d.ts +6 -5
- package/dist/build/emitted-target.d.ts.map +1 -1
- package/dist/build/emitted-target.js +5 -9
- package/dist/build/emitted-target.js.map +1 -1
- package/dist/build/rewrite-aliases.d.ts.map +1 -1
- package/dist/build/rewrite-aliases.js +4 -5
- package/dist/build/rewrite-aliases.js.map +1 -1
- package/dist/build/rewrite-specifiers.d.ts +7 -6
- package/dist/build/rewrite-specifiers.d.ts.map +1 -1
- package/dist/build/rewrite-specifiers.js +6 -4
- package/dist/build/rewrite-specifiers.js.map +1 -1
- package/dist/build/unresolved-problem.d.ts +2 -1
- package/dist/build/unresolved-problem.d.ts.map +1 -1
- package/dist/build/unresolved-problem.js +2 -2
- package/dist/build/unresolved-problem.js.map +1 -1
- package/dist/check/business-names/parameter-lists.js +1 -3
- package/dist/check/business-names/parameter-lists.js.map +1 -1
- package/dist/check/engine/run-check.d.ts +3 -0
- package/dist/check/engine/run-check.d.ts.map +1 -1
- package/dist/check/engine/run-check.js +1 -1
- package/dist/check/engine/run-check.js.map +1 -1
- package/dist/check/explain/tenancy-docs.d.ts.map +1 -1
- package/dist/check/explain/tenancy-docs.js +13 -3
- package/dist/check/explain/tenancy-docs.js.map +1 -1
- package/dist/check/fixtures/conjunct-cases.d.ts +11 -0
- package/dist/check/fixtures/conjunct-cases.d.ts.map +1 -0
- package/dist/check/fixtures/conjunct-cases.js +19 -0
- package/dist/check/fixtures/conjunct-cases.js.map +1 -0
- package/dist/check/fixtures/privacy-fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/privacy-fixtures.js +22 -0
- package/dist/check/fixtures/privacy-fixtures.js.map +1 -1
- package/dist/check/fixtures/run-fixture.d.ts +3 -2
- package/dist/check/fixtures/run-fixture.d.ts.map +1 -1
- package/dist/check/fixtures/run-fixture.js +3 -3
- package/dist/check/fixtures/run-fixture.js.map +1 -1
- package/dist/check/fixtures/run-self-check.js +1 -1
- package/dist/check/fixtures/run-self-check.js.map +1 -1
- package/dist/check/fixtures/tenancy-conjunct-drizzle-fixtures.d.ts +3 -0
- package/dist/check/fixtures/tenancy-conjunct-drizzle-fixtures.d.ts.map +1 -0
- package/dist/check/fixtures/tenancy-conjunct-drizzle-fixtures.js +33 -0
- package/dist/check/fixtures/tenancy-conjunct-drizzle-fixtures.js.map +1 -0
- package/dist/check/fixtures/tenancy-conjunct-fixtures.d.ts +4 -0
- package/dist/check/fixtures/tenancy-conjunct-fixtures.d.ts.map +1 -0
- package/dist/check/fixtures/tenancy-conjunct-fixtures.js +12 -0
- package/dist/check/fixtures/tenancy-conjunct-fixtures.js.map +1 -0
- package/dist/check/fixtures/tenancy-conjunct-knex-fixtures.d.ts +3 -0
- package/dist/check/fixtures/tenancy-conjunct-knex-fixtures.d.ts.map +1 -0
- package/dist/check/fixtures/tenancy-conjunct-knex-fixtures.js +49 -0
- package/dist/check/fixtures/tenancy-conjunct-knex-fixtures.js.map +1 -0
- package/dist/check/fixtures/tenancy-conjunct-prisma-fixtures.d.ts +3 -0
- package/dist/check/fixtures/tenancy-conjunct-prisma-fixtures.d.ts.map +1 -0
- package/dist/check/fixtures/tenancy-conjunct-prisma-fixtures.js +32 -0
- package/dist/check/fixtures/tenancy-conjunct-prisma-fixtures.js.map +1 -0
- package/dist/check/fixtures/tenancy-conjunct-typeorm-fixtures.d.ts +3 -0
- package/dist/check/fixtures/tenancy-conjunct-typeorm-fixtures.d.ts.map +1 -0
- package/dist/check/fixtures/tenancy-conjunct-typeorm-fixtures.js +34 -0
- package/dist/check/fixtures/tenancy-conjunct-typeorm-fixtures.js.map +1 -0
- package/dist/check/fixtures/tenancy-fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/tenancy-fixtures.js +2 -0
- package/dist/check/fixtures/tenancy-fixtures.js.map +1 -1
- package/dist/check/privacy/published-events-of.d.ts.map +1 -1
- package/dist/check/privacy/published-events-of.js +4 -2
- package/dist/check/privacy/published-events-of.js.map +1 -1
- package/dist/check/rules/clean-one-export-per-file.js +1 -0
- package/dist/check/rules/clean-one-export-per-file.js.map +1 -1
- package/dist/check/rules/schema-no-duplicate-shape.js +1 -3
- package/dist/check/rules/schema-no-duplicate-shape.js.map +1 -1
- package/dist/check/rules/tenancy-scoped-statement.js +2 -2
- package/dist/check/rules/tenancy-scoped-statement.js.map +1 -1
- package/dist/check/schemas/class-shapes.d.ts.map +1 -1
- package/dist/check/schemas/class-shapes.js +5 -26
- package/dist/check/schemas/class-shapes.js.map +1 -1
- package/dist/check/structure/class-statements.d.ts +13 -0
- package/dist/check/structure/class-statements.d.ts.map +1 -0
- package/dist/check/structure/class-statements.js +34 -0
- package/dist/check/structure/class-statements.js.map +1 -0
- package/dist/check/structure/property-of.d.ts +13 -0
- package/dist/check/structure/property-of.d.ts.map +1 -0
- package/dist/check/structure/property-of.js +23 -0
- package/dist/check/structure/property-of.js.map +1 -0
- package/dist/check/tenancy/arguments-of-call.d.ts +3 -0
- package/dist/check/tenancy/arguments-of-call.d.ts.map +1 -0
- package/dist/check/tenancy/arguments-of-call.js +11 -0
- package/dist/check/tenancy/arguments-of-call.js.map +1 -0
- package/dist/check/tenancy/bare-expression.d.ts +3 -0
- package/dist/check/tenancy/bare-expression.d.ts.map +1 -0
- package/dist/check/tenancy/bare-expression.js +9 -0
- package/dist/check/tenancy/bare-expression.js.map +1 -0
- package/dist/check/tenancy/bracket-depth.d.ts +3 -0
- package/dist/check/tenancy/bracket-depth.d.ts.map +1 -0
- package/dist/check/tenancy/bracket-depth.js +10 -0
- package/dist/check/tenancy/bracket-depth.js.map +1 -0
- package/dist/check/tenancy/chain-links.d.ts +17 -0
- package/dist/check/tenancy/chain-links.d.ts.map +1 -0
- package/dist/check/tenancy/chain-links.js +24 -0
- package/dist/check/tenancy/chain-links.js.map +1 -0
- package/dist/check/tenancy/choice-branches.d.ts +3 -0
- package/dist/check/tenancy/choice-branches.d.ts.map +1 -0
- package/dist/check/tenancy/choice-branches.js +39 -0
- package/dist/check/tenancy/choice-branches.js.map +1 -0
- package/dist/check/tenancy/declaration-before.d.ts +12 -0
- package/dist/check/tenancy/declaration-before.d.ts.map +1 -0
- package/dist/check/tenancy/declaration-before.js +11 -0
- package/dist/check/tenancy/declaration-before.js.map +1 -0
- package/dist/check/tenancy/declaration-of.d.ts +1 -5
- package/dist/check/tenancy/declaration-of.d.ts.map +1 -1
- package/dist/check/tenancy/declaration-of.js +3 -8
- package/dist/check/tenancy/declaration-of.js.map +1 -1
- package/dist/check/tenancy/drizzle-unscoped.d.ts.map +1 -1
- package/dist/check/tenancy/drizzle-unscoped.js +16 -3
- package/dist/check/tenancy/drizzle-unscoped.js.map +1 -1
- package/dist/check/tenancy/enclosed-by.d.ts +3 -0
- package/dist/check/tenancy/enclosed-by.d.ts.map +1 -0
- package/dist/check/tenancy/enclosed-by.js +6 -0
- package/dist/check/tenancy/enclosed-by.js.map +1 -0
- package/dist/check/tenancy/end-of-enclosing.d.ts +7 -0
- package/dist/check/tenancy/end-of-enclosing.d.ts.map +1 -0
- package/dist/check/tenancy/end-of-enclosing.js +18 -0
- package/dist/check/tenancy/end-of-enclosing.js.map +1 -0
- package/dist/check/tenancy/holds-condition.d.ts +14 -0
- package/dist/check/tenancy/holds-condition.d.ts.map +1 -0
- package/dist/check/tenancy/holds-condition.js +26 -0
- package/dist/check/tenancy/holds-condition.js.map +1 -0
- package/dist/check/tenancy/is-conjunct.d.ts +8 -0
- package/dist/check/tenancy/is-conjunct.d.ts.map +1 -0
- package/dist/check/tenancy/is-conjunct.js +17 -0
- package/dist/check/tenancy/is-conjunct.js.map +1 -0
- package/dist/check/tenancy/is-or-link.d.ts +4 -0
- package/dist/check/tenancy/is-or-link.d.ts.map +1 -0
- package/dist/check/tenancy/is-or-link.js +7 -0
- package/dist/check/tenancy/is-or-link.js.map +1 -0
- package/dist/check/tenancy/knex-links-outside-condition.d.ts +11 -0
- package/dist/check/tenancy/knex-links-outside-condition.d.ts.map +1 -0
- package/dist/check/tenancy/knex-links-outside-condition.js +108 -0
- package/dist/check/tenancy/knex-links-outside-condition.js.map +1 -0
- package/dist/check/tenancy/knex-unscoped.d.ts +3 -1
- package/dist/check/tenancy/knex-unscoped.d.ts.map +1 -1
- package/dist/check/tenancy/knex-unscoped.js +12 -2
- package/dist/check/tenancy/knex-unscoped.js.map +1 -1
- package/dist/check/tenancy/prisma-unscoped.d.ts.map +1 -1
- package/dist/check/tenancy/prisma-unscoped.js +15 -10
- package/dist/check/tenancy/prisma-unscoped.js.map +1 -1
- package/dist/check/tenancy/spreads-at-top.d.ts +9 -0
- package/dist/check/tenancy/spreads-at-top.d.ts.map +1 -0
- package/dist/check/tenancy/spreads-at-top.js +49 -0
- package/dist/check/tenancy/spreads-at-top.js.map +1 -0
- package/dist/check/tenancy/top-level-parts.d.ts +3 -0
- package/dist/check/tenancy/top-level-parts.d.ts.map +1 -0
- package/dist/check/tenancy/top-level-parts.js +13 -0
- package/dist/check/tenancy/top-level-parts.js.map +1 -0
- package/dist/check/tenancy/typeorm-unscoped.d.ts.map +1 -1
- package/dist/check/tenancy/typeorm-unscoped.js +30 -16
- package/dist/check/tenancy/typeorm-unscoped.js.map +1 -1
- package/dist/check/tenancy/unconfined-where.d.ts +11 -0
- package/dist/check/tenancy/unconfined-where.d.ts.map +1 -0
- package/dist/check/tenancy/unconfined-where.js +18 -0
- package/dist/check/tenancy/unconfined-where.js.map +1 -0
- package/dist/config/read-config.d.ts.map +1 -1
- package/dist/config/read-config.js +20 -0
- package/dist/config/read-config.js.map +1 -1
- package/dist/declared/render-declarations.js +1 -3
- package/dist/declared/render-declarations.js.map +1 -1
- package/dist/describe/read-controllers.d.ts.map +1 -1
- package/dist/describe/read-controllers.js +18 -2
- package/dist/describe/read-controllers.js.map +1 -1
- package/dist/describe/read-event-definitions.d.ts +2 -0
- package/dist/describe/read-event-definitions.d.ts.map +1 -1
- package/dist/describe/read-event-definitions.js +1 -0
- package/dist/describe/read-event-definitions.js.map +1 -1
- package/dist/describe/schema-class-of.js +8 -1
- package/dist/describe/schema-class-of.js.map +1 -1
- package/dist/digest/tree-at.d.ts.map +1 -1
- package/dist/digest/tree-at.js +2 -0
- package/dist/digest/tree-at.js.map +1 -1
- package/dist/docs/context-sections.js +3 -7
- package/dist/docs/context-sections.js.map +1 -1
- package/dist/docs/personal-event-lines.d.ts +7 -0
- package/dist/docs/personal-event-lines.d.ts.map +1 -0
- package/dist/docs/personal-event-lines.js +34 -0
- package/dist/docs/personal-event-lines.js.map +1 -0
- package/dist/docs/write-docs.d.ts.map +1 -1
- package/dist/docs/write-docs.js +2 -0
- package/dist/docs/write-docs.js.map +1 -1
- package/dist/docs/write-personal-events.d.ts +11 -0
- package/dist/docs/write-personal-events.d.ts.map +1 -0
- package/dist/docs/write-personal-events.js +28 -0
- package/dist/docs/write-personal-events.js.map +1 -0
- package/dist/generate/flags-of.d.ts +4 -0
- package/dist/generate/flags-of.d.ts.map +1 -0
- package/dist/generate/flags-of.js +6 -0
- package/dist/generate/flags-of.js.map +1 -0
- package/dist/generate/held-to-glossary.d.ts +9 -0
- package/dist/generate/held-to-glossary.d.ts.map +1 -0
- package/dist/generate/held-to-glossary.js +11 -0
- package/dist/generate/held-to-glossary.js.map +1 -0
- package/dist/generate/kind-help.d.ts +2 -0
- package/dist/generate/kind-help.d.ts.map +1 -1
- package/dist/generate/kind-help.js +2 -0
- package/dist/generate/kind-help.js.map +1 -1
- package/dist/generate/kinds/adapter-kind.js +1 -1
- package/dist/generate/kinds/adapter-kind.js.map +1 -1
- package/dist/generate/kinds/assert-event-store.d.ts +5 -1
- package/dist/generate/kinds/assert-event-store.d.ts.map +1 -1
- package/dist/generate/kinds/assert-event-store.js +11 -5
- package/dist/generate/kinds/assert-event-store.js.map +1 -1
- package/dist/generate/kinds/background/background-job-vars.js +4 -2
- package/dist/generate/kinds/background/background-job-vars.js.map +1 -1
- package/dist/generate/kinds/background/class-payload-schema.js +3 -3
- package/dist/generate/kinds/background/class-payload-schema.js.map +1 -1
- package/dist/generate/kinds/background-job-kind.js +1 -1
- package/dist/generate/kinds/background-job-kind.js.map +1 -1
- package/dist/generate/kinds/builder-kind.js +1 -1
- package/dist/generate/kinds/builder-kind.js.map +1 -1
- package/dist/generate/kinds/command-kind.js +1 -1
- package/dist/generate/kinds/command-kind.js.map +1 -1
- package/dist/generate/kinds/declarations-of.d.ts +11 -0
- package/dist/generate/kinds/declarations-of.d.ts.map +1 -0
- package/dist/generate/kinds/declarations-of.js +17 -0
- package/dist/generate/kinds/declarations-of.js.map +1 -0
- package/dist/generate/kinds/e2e-kind.js +1 -1
- package/dist/generate/kinds/e2e-kind.js.map +1 -1
- package/dist/generate/kinds/erasure-handler-kind.js +1 -1
- package/dist/generate/kinds/erasure-handler-kind.js.map +1 -1
- package/dist/generate/kinds/event-type-as-published.d.ts +11 -0
- package/dist/generate/kinds/event-type-as-published.d.ts.map +1 -0
- package/dist/generate/kinds/event-type-as-published.js +17 -0
- package/dist/generate/kinds/event-type-as-published.js.map +1 -0
- package/dist/generate/kinds/form-kind.js +1 -1
- package/dist/generate/kinds/form-kind.js.map +1 -1
- package/dist/generate/kinds/generate-event-sourced-repository.js +8 -1
- package/dist/generate/kinds/generate-event-sourced-repository.js.map +1 -1
- package/dist/generate/kinds/integration-event-kind.d.ts.map +1 -1
- package/dist/generate/kinds/integration-event-kind.js +2 -9
- package/dist/generate/kinds/integration-event-kind.js.map +1 -1
- package/dist/generate/kinds/integration-handler-kind.d.ts.map +1 -1
- package/dist/generate/kinds/integration-handler-kind.js +30 -14
- package/dist/generate/kinds/integration-handler-kind.js.map +1 -1
- package/dist/generate/kinds/job-kind.js +1 -1
- package/dist/generate/kinds/job-kind.js.map +1 -1
- package/dist/generate/kinds/module-kind.js +1 -1
- package/dist/generate/kinds/module-kind.js.map +1 -1
- package/dist/generate/kinds/parse-version.d.ts +3 -0
- package/dist/generate/kinds/parse-version.d.ts.map +1 -0
- package/dist/generate/kinds/parse-version.js +9 -0
- package/dist/generate/kinds/parse-version.js.map +1 -0
- package/dist/generate/kinds/pick-declaration.d.ts +9 -0
- package/dist/generate/kinds/pick-declaration.d.ts.map +1 -0
- package/dist/generate/kinds/pick-declaration.js +14 -0
- package/dist/generate/kinds/pick-declaration.js.map +1 -0
- package/dist/generate/kinds/presentation/controller-of.d.ts.map +1 -1
- package/dist/generate/kinds/presentation/controller-of.js +15 -5
- package/dist/generate/kinds/presentation/controller-of.js.map +1 -1
- package/dist/generate/kinds/projection-kind.d.ts.map +1 -1
- package/dist/generate/kinds/projection-kind.js +21 -12
- package/dist/generate/kinds/projection-kind.js.map +1 -1
- package/dist/generate/kinds/property-kind.js +1 -1
- package/dist/generate/kinds/property-kind.js.map +1 -1
- package/dist/generate/kinds/refuse-unpublished-version.d.ts +7 -0
- package/dist/generate/kinds/refuse-unpublished-version.d.ts.map +1 -0
- package/dist/generate/kinds/refuse-unpublished-version.js +15 -0
- package/dist/generate/kinds/refuse-unpublished-version.js.map +1 -0
- package/dist/generate/kinds/repository-kind.js +1 -1
- package/dist/generate/kinds/repository-kind.js.map +1 -1
- package/dist/generate/kinds/representation-kind.js +1 -1
- package/dist/generate/kinds/representation-kind.js.map +1 -1
- package/dist/generate/kinds/route/controller-vars.js +1 -1
- package/dist/generate/kinds/route/controller-vars.js.map +1 -1
- package/dist/generate/kinds/route/message-call.d.ts +6 -2
- package/dist/generate/kinds/route/message-call.d.ts.map +1 -1
- package/dist/generate/kinds/route/message-call.js +2 -1
- package/dist/generate/kinds/route/message-call.js.map +1 -1
- package/dist/generate/kinds/route/message-vars.d.ts.map +1 -1
- package/dist/generate/kinds/route/message-vars.js +5 -2
- package/dist/generate/kinds/route/message-vars.js.map +1 -1
- package/dist/generate/kinds/route/route-vars.js +1 -1
- package/dist/generate/kinds/route/route-vars.js.map +1 -1
- package/dist/generate/kinds/route/spec-vars.d.ts +2 -1
- package/dist/generate/kinds/route/spec-vars.d.ts.map +1 -1
- package/dist/generate/kinds/route/spec-vars.js +26 -7
- package/dist/generate/kinds/route/spec-vars.js.map +1 -1
- package/dist/generate/kinds/route/standard-schema-of.d.ts +2 -1
- package/dist/generate/kinds/route/standard-schema-of.d.ts.map +1 -1
- package/dist/generate/kinds/route/standard-schema-of.js +2 -4
- package/dist/generate/kinds/route/standard-schema-of.js.map +1 -1
- package/dist/generate/kinds/route-group-kind.js +1 -1
- package/dist/generate/kinds/route-group-kind.js.map +1 -1
- package/dist/generate/kinds/route-kind.js +2 -2
- package/dist/generate/kinds/route-kind.js.map +1 -1
- package/dist/generate/kinds/service-kind.js +1 -1
- package/dist/generate/kinds/service-kind.js.map +1 -1
- package/dist/generate/kinds/state-machine-kind.js +1 -1
- package/dist/generate/kinds/state-machine-kind.js.map +1 -1
- package/dist/generate/kinds/wanted-event.d.ts +6 -0
- package/dist/generate/kinds/wanted-event.d.ts.map +1 -0
- package/dist/generate/kinds/wanted-event.js +2 -0
- package/dist/generate/kinds/wanted-event.js.map +1 -0
- package/dist/generate/refuse-undeclared-flags.d.ts.map +1 -1
- package/dist/generate/refuse-undeclared-flags.js +9 -2
- package/dist/generate/refuse-undeclared-flags.js.map +1 -1
- package/dist/generator-lock/unreadable-lock-refusal.d.ts +4 -0
- package/dist/generator-lock/unreadable-lock-refusal.d.ts.map +1 -0
- package/dist/generator-lock/unreadable-lock-refusal.js +7 -0
- package/dist/generator-lock/unreadable-lock-refusal.js.map +1 -0
- package/dist/generator-lock/with-generator-lock.d.ts.map +1 -1
- package/dist/generator-lock/with-generator-lock.js +8 -7
- package/dist/generator-lock/with-generator-lock.js.map +1 -1
- package/dist/help/kind-help-text.d.ts.map +1 -1
- package/dist/help/kind-help-text.js +24 -13
- package/dist/help/kind-help-text.js.map +1 -1
- package/dist/init/files/platform-files.d.ts.map +1 -1
- package/dist/init/files/platform-files.js +14 -0
- package/dist/init/files/platform-files.js.map +1 -1
- package/dist/init/files/privacy-files.d.ts +2 -2
- package/dist/init/files/privacy-files.d.ts.map +1 -1
- package/dist/init/files/privacy-files.js +3 -2
- package/dist/init/files/privacy-files.js.map +1 -1
- package/dist/init/manifest/versions.js +24 -24
- package/dist/init/stack/http-cache-misfit.d.ts +4 -0
- package/dist/init/stack/http-cache-misfit.d.ts.map +1 -0
- package/dist/init/stack/http-cache-misfit.js +21 -0
- package/dist/init/stack/http-cache-misfit.js.map +1 -0
- package/dist/init/stack/resolve-stack.d.ts.map +1 -1
- package/dist/init/stack/resolve-stack.js +2 -1
- package/dist/init/stack/resolve-stack.js.map +1 -1
- package/dist/measures/timeline-of.js +1 -0
- package/dist/measures/timeline-of.js.map +1 -1
- package/dist/progress/format-progress.js +1 -0
- package/dist/progress/format-progress.js.map +1 -1
- package/dist/sdk/planned-clients.d.ts +2 -2
- package/dist/sdk/planned-clients.d.ts.map +1 -1
- package/dist/sdk/planned-clients.js +2 -6
- package/dist/sdk/planned-clients.js.map +1 -1
- package/dist/sdk/set-up-sdk.d.ts.map +1 -1
- package/dist/sdk/set-up-sdk.js +3 -2
- package/dist/sdk/set-up-sdk.js.map +1 -1
- package/dist/stack/stack-vars.js +12 -3
- package/dist/stack/stack-vars.js.map +1 -1
- package/dist/stories/forecast-merge.js +1 -0
- package/dist/stories/forecast-merge.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worker/format-resume.d.ts.map +1 -1
- package/dist/worker/format-resume.js +5 -0
- package/dist/worker/format-resume.js.map +1 -1
- package/dist/worker/format-workers.js +5 -0
- package/dist/worker/format-workers.js.map +1 -1
- package/dist/worker/progress-of.d.ts +8 -3
- package/dist/worker/progress-of.d.ts.map +1 -1
- package/dist/worker/progress-of.js +2 -16
- package/dist/worker/progress-of.js.map +1 -1
- package/dist/worker/read-agent-record.d.ts.map +1 -1
- package/dist/worker/read-agent-record.js +15 -3
- package/dist/worker/read-agent-record.js.map +1 -1
- package/dist/worker/read-workers.js +2 -2
- package/dist/worker/read-workers.js.map +1 -1
- package/dist/worker/readable-progress.d.ts +5 -0
- package/dist/worker/readable-progress.d.ts.map +1 -0
- package/dist/worker/readable-progress.js +16 -0
- package/dist/worker/readable-progress.js.map +1 -0
- package/dist/worker/resume-worker.d.ts.map +1 -1
- package/dist/worker/resume-worker.js +4 -5
- package/dist/worker/resume-worker.js.map +1 -1
- package/dist/worker/worker-progress.d.ts +2 -1
- package/dist/worker/worker-progress.d.ts.map +1 -1
- package/dist/workspace/real-path-of.d.ts +2 -2
- package/dist/workspace/real-path-of.d.ts.map +1 -1
- package/dist/workspace/real-path-of.js +15 -10
- package/dist/workspace/real-path-of.js.map +1 -1
- package/package.json +5 -5
- package/templates/controller/controller.spec.ts.tpl +19 -0
- package/templates/docs/privacy-register.md.tpl +2 -0
- package/templates/init/README.md.tpl +13 -4
- package/templates/init/docker/env.example.tpl +8 -0
- package/templates/init/main.ts.tpl +3 -0
- package/templates/init/platform/audit/create-audit.ts.tpl +12 -6
- package/templates/init/platform/composition/compose-application.manual.ts.tpl +36 -0
- package/templates/init/platform/composition/compose-application.tsyringe.ts.tpl +7 -0
- package/templates/init/platform/composition/lay-foundations.manual.ts.tpl +1 -1
- package/templates/init/platform/composition/lay-foundations.tsyringe.ts.tpl +1 -1
- package/templates/init/platform/composition/platform-options.manual.ts.tpl +7 -0
- package/templates/init/platform/composition/platform.manual.ts.tpl +7 -0
- package/templates/init/platform/composition/platform.module.tsyringe.ts.tpl +7 -0
- package/templates/init/platform/config/app-config.ts.tpl +7 -0
- package/templates/init/platform/config/load-config.ts.tpl +22 -0
- package/templates/init/platform/database/persistence.contract.spec.ts.tpl +14 -3
- package/templates/init/platform/event-sourcing/create-event-sourcing.ts.tpl +5 -1
- package/templates/init/platform/jobs/create-background-work.ts.tpl +12 -0
- package/templates/init/platform/jobs/days-before.ts.tpl +8 -0
- package/templates/init/platform/jobs/housekeeping.module.tsyringe.ts.tpl +46 -0
- package/templates/init/platform/jobs/housekeeping.ts.tpl +24 -0
- package/templates/init/platform/jobs/job-settings.ts.tpl +6 -0
- package/templates/init/platform/privacy/personal-events.ts.tpl +11 -0
- package/templates/init/platform/privacy/run-erasure.manual.ts.tpl +69 -19
- package/templates/init/platform/privacy/run-erasure.tsyringe.ts.tpl +69 -8
- package/templates/init/platform/privacy/run-export.manual.ts.tpl +2 -2
- package/templates/init/platform/privacy/run-export.tsyringe.ts.tpl +4 -2
- package/templates/init/platform/privacy/run-purge.manual.ts.tpl +3 -2
- package/templates/init/platform/privacy/run-purge.tsyringe.ts.tpl +4 -2
- package/templates/init/rules/infrastructure.md.tpl +1 -1
- package/templates/init/scripts/privacy-erase.manual.ts.tpl +52 -7
- package/templates/init/scripts/privacy-erase.tsyringe.ts.tpl +52 -7
- package/templates/init/scripts/privacy-export.manual.ts.tpl +4 -0
- package/templates/init/scripts/privacy-export.tsyringe.ts.tpl +4 -0
- package/templates/init/scripts/privacy-purge.manual.ts.tpl +4 -0
- package/templates/init/scripts/privacy-purge.tsyringe.ts.tpl +4 -0
- package/templates/integration-event/payload.class-validator.ts.tpl +2 -2
- package/templates/nest-controller/controller.spec.ts.tpl +25 -0
- package/templates/pipeline/package-scripts.json +1 -1
- package/templates/pipeline/stryker.config.mjs.tpl +4 -0
- package/templates/presets/identity/context/presentation/http/accounts/deactivate-account/deactivate-account.accepted.class-validator.per-route.ts.tpl +1 -1
- package/templates/presets/identity/context/presentation/http/accounts/provision-account/provision-account.accepted.class-validator.per-route.ts.tpl +1 -1
- package/templates/presets/identity/context/presentation/http/accounts/provision-account/provision-account.body.class-validator.ts.tpl +1 -1
- package/templates/presets/identity/context/presentation/http/invitations/accept-invitation/accept-invitation.accepted.class-validator.per-route.ts.tpl +1 -1
- package/templates/presets/identity/context/presentation/http/invitations/accept-invitation/accept-invitation.body.class-validator.per-route.ts.tpl +1 -1
- package/templates/presets/identity/context/presentation/http/invitations/decline-invitation/decline-invitation.accepted.class-validator.per-route.ts.tpl +1 -1
- package/templates/presets/identity/context/presentation/http/invitations/decline-invitation/decline-invitation.body.class-validator.per-route.ts.tpl +1 -1
- package/templates/presets/identity/context/presentation/http/organisations/change-member-role/change-member-role.accepted.class-validator.per-route.ts.tpl +1 -1
- package/templates/presets/identity/context/presentation/http/organisations/change-member-role/change-member-role.body.class-validator.ts.tpl +1 -1
- package/templates/presets/identity/context/presentation/http/organisations/change-member-role/change-member-role.params.class-validator.ts.tpl +2 -2
- package/templates/presets/identity/context/presentation/http/organisations/grant-delegation/grant-delegation.accepted.class-validator.per-route.ts.tpl +1 -1
- package/templates/presets/identity/context/presentation/http/organisations/grant-delegation/grant-delegation.body.class-validator.ts.tpl +4 -4
- package/templates/presets/identity/context/presentation/http/organisations/grant-delegation/grant-delegation.params.class-validator.ts.tpl +1 -1
- package/templates/presets/identity/context/presentation/http/organisations/invite-member/invite-member.accepted.class-validator.ts.tpl +2 -2
- package/templates/presets/identity/context/presentation/http/organisations/invite-member/invite-member.body.class-validator.ts.tpl +2 -2
- package/templates/presets/identity/context/presentation/http/organisations/invite-member/invite-member.params.class-validator.ts.tpl +1 -1
- package/templates/presets/identity/context/presentation/http/organisations/open-organisation/open-organisation.accepted.class-validator.per-route.ts.tpl +1 -1
- package/templates/presets/identity/context/presentation/http/organisations/open-organisation/open-organisation.body.class-validator.ts.tpl +2 -2
- package/templates/presets/identity/context/presentation/http/organisations/remove-member/remove-member.accepted.class-validator.per-route.ts.tpl +1 -1
- package/templates/presets/identity/context/presentation/http/organisations/remove-member/remove-member.params.class-validator.ts.tpl +2 -2
- package/templates/presets/identity/context/presentation/http/organisations/revoke-delegation/revoke-delegation.accepted.class-validator.per-route.ts.tpl +1 -1
- package/templates/presets/identity/context/presentation/http/organisations/revoke-delegation/revoke-delegation.params.class-validator.ts.tpl +2 -2
- package/templates/presets/identity/context/presentation/http/organisations/revoke-invitation/revoke-invitation.accepted.class-validator.per-route.ts.tpl +1 -1
- package/templates/presets/identity/context/presentation/http/organisations/revoke-invitation/revoke-invitation.params.class-validator.ts.tpl +2 -2
- package/templates/presets/identity/context/presentation/http/organisations/search-members/search-members.line.class-validator.ts.tpl +6 -6
- package/templates/presets/identity/context/presentation/http/organisations/search-members/search-members.params.class-validator.ts.tpl +1 -1
- package/templates/presets/identity/context/presentation/http/shared/invitation-token.schema.class-validator.shared.ts.tpl +1 -1
- package/templates/presets/identity/context/published-language/account-deactivated.v1.payload.class-validator.ts.tpl +1 -1
- package/templates/presets/identity/context/published-language/delegation-granted.v1.payload.class-validator.ts.tpl +7 -7
- package/templates/presets/identity/context/published-language/delegation-revoked.v1.payload.class-validator.ts.tpl +4 -4
- package/templates/presets/identity/context/published-language/member-joined.v1.payload.class-validator.ts.tpl +4 -4
- package/templates/presets/identity/context/published-language/member-removed.v1.payload.class-validator.ts.tpl +4 -4
- package/templates/presets/identity/context/published-language/member-role-changed.v1.payload.class-validator.ts.tpl +6 -6
- package/templates/presets/identity/context/published-language/organisation-opened.v1.payload.class-validator.ts.tpl +3 -3
- package/templates/route/dto.accepted.ts.tpl +1 -1
- package/templates/route/dto.answer.ts.tpl +1 -1
- package/templates/route/dto.body.ts.tpl +1 -1
- package/templates/route/dto.line.ts.tpl +2 -2
- package/templates/route/route.spec.ts.tpl +19 -0
- package/templates/schema/schema.class-validator.ts.tpl +1 -1
- package/templates/worker/main.ts.tpl +3 -0
- package/dist/generate/kinds/find-event-declaration.d.ts +0 -8
- package/dist/generate/kinds/find-event-declaration.d.ts.map +0 -1
- package/dist/generate/kinds/find-event-declaration.js +0 -27
- package/dist/generate/kinds/find-event-declaration.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"real-path-of.d.ts","sourceRoot":"","sources":["../../src/workspace/real-path-of.ts"],"names":[],"mappings":"AAGA,yIAAyI;AACzI,eAAO,MAAM,OAAO,eAAoB,CAAC;AAEzC
|
|
1
|
+
{"version":3,"file":"real-path-of.d.ts","sourceRoot":"","sources":["../../src/workspace/real-path-of.ts"],"names":[],"mappings":"AAGA,yIAAyI;AACzI,eAAO,MAAM,OAAO,eAAoB,CAAC;AAEzC,mGAAmG;AACnG,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,OAAO,OAAO,GAAG,SAAS,CAAC;AAE3D;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,SAAI,GAAG,QAAQ,CAS/D"}
|
|
@@ -6,16 +6,26 @@ export const BLOCKED = Symbol('blocked');
|
|
|
6
6
|
* The real path `absolute` is written at: a link in its place followed to where it points, then
|
|
7
7
|
* the real path of the deepest part that exists, the parts below it appended as they are;
|
|
8
8
|
* `BLOCKED` when what stands there is no folder above the target, or no file nor folder at the
|
|
9
|
-
* end of a link; undefined
|
|
9
|
+
* end of a link; undefined past the links it follows, which a loop of links never ends.
|
|
10
10
|
*/
|
|
11
11
|
export function realPathOf(absolute, hops = 0) {
|
|
12
12
|
const at = path.resolve(absolute);
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const link = linkAt(at);
|
|
14
|
+
if (link !== undefined) {
|
|
15
|
+
return hops > 32 ? undefined : linkedPathOf(at, link, hops);
|
|
15
16
|
}
|
|
16
17
|
return existingRealPathOf(at);
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
+
/** Where the link at `absolute` points; undefined when what stands there is no link. */
|
|
20
|
+
function linkAt(absolute) {
|
|
21
|
+
try {
|
|
22
|
+
return fs.readlinkSync(absolute);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function linkedPathOf(at, link, hops) {
|
|
19
29
|
try {
|
|
20
30
|
const target = fs.statSync(at);
|
|
21
31
|
if (!target.isFile() && !target.isDirectory()) {
|
|
@@ -25,12 +35,7 @@ function linkedPathOf(at, hops) {
|
|
|
25
35
|
}
|
|
26
36
|
catch {
|
|
27
37
|
// A link to nothing: the write creates its target, wherever it points.
|
|
28
|
-
|
|
29
|
-
return realPathOf(path.resolve(path.dirname(at), fs.readlinkSync(at)), hops + 1);
|
|
30
|
-
}
|
|
31
|
-
catch {
|
|
32
|
-
return undefined;
|
|
33
|
-
}
|
|
38
|
+
return realPathOf(path.resolve(path.dirname(at), link), hops + 1);
|
|
34
39
|
}
|
|
35
40
|
}
|
|
36
41
|
function existingRealPathOf(absolute) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"real-path-of.js","sourceRoot":"","sources":["../../src/workspace/real-path-of.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,yIAAyI;AACzI,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;AAKzC;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,QAAgB,EAAE,IAAI,GAAG,CAAC;IACnD,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"real-path-of.js","sourceRoot":"","sources":["../../src/workspace/real-path-of.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,yIAAyI;AACzI,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;AAKzC;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,QAAgB,EAAE,IAAI,GAAG,CAAC;IACnD,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;IAExB,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,kBAAkB,CAAC,EAAE,CAAC,CAAC;AAChC,CAAC;AAED,wFAAwF;AACxF,SAAS,MAAM,CAAC,QAAgB;IAC9B,IAAI,CAAC;QACH,OAAO,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,EAAU,EAAE,IAAY,EAAE,IAAY;IAC1D,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAE/B,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,EAAE,CAAC;YAC9C,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,OAAO,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,uEAAuE;QACvE,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC;IACpE,CAAC;AACH,CAAC;AAED,SAAS,kBAAkB,CAAC,QAAgB;IAC1C,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,IAAI,EAAE,GAAG,QAAQ,CAAC;IAElB,OAAO,OAAO,CAAC,EAAE,CAAC,KAAK,SAAS,IAAI,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC;QAC5D,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;QACnC,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACxB,CAAC;IAED,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;QAEjC,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,OAAO,CAAC,CAAC;IACxG,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAS,OAAO,CAAC,QAAgB;IAC/B,IAAI,CAAC;QACH,OAAO,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ddd-ts-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.102.0",
|
|
4
4
|
"description": "Bootstrap, scaffold and verify Domain-Driven Design (DDD), Clean Architecture and hexagonal TypeScript backends on Node.js: project and code generators, architecture checks, OpenAPI and AsyncAPI documents, for developers and AI coding agents (Claude Code, Codex, GitHub Copilot).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ddd",
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
"clean:packages": "node dist/bin.js check --clean-only ../kernel/src ../validation/src ../http/src ../tracing/src ../di/src ../events/src ../testing/src ../s3/src ../drizzle/src ../knex/src ../prisma/src ../typeorm/src ../aspects/src ../rabbitmq/src ../auth/src ../audit/src ../redis/src ../scheduling/src ../pino/src ../winston/src ../sentry/src ../kafka/src ../nats/src ../eslint-plugin/src"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@ddd-ts-kit/audit": "^0.
|
|
56
|
-
"@ddd-ts-kit/auth": "^0.
|
|
57
|
-
"@ddd-ts-kit/events": "^0.
|
|
58
|
-
"@ddd-ts-kit/kernel": "^0.
|
|
55
|
+
"@ddd-ts-kit/audit": "^0.102.0",
|
|
56
|
+
"@ddd-ts-kit/auth": "^0.102.0",
|
|
57
|
+
"@ddd-ts-kit/events": "^0.102.0",
|
|
58
|
+
"@ddd-ts-kit/kernel": "^0.102.0",
|
|
59
59
|
"@types/pg": "^8.23.1",
|
|
60
60
|
"pg": "^8.23.1"
|
|
61
61
|
}
|
|
@@ -18,6 +18,25 @@ describe('{{route.method}} {{route.path}}', () => {
|
|
|
18
18
|
{{route.messageExpectation}}
|
|
19
19
|
expect(route.path).toBe('{{route.path}}');
|
|
20
20
|
});
|
|
21
|
+
{{#if route.refusesMissing}}
|
|
22
|
+
|
|
23
|
+
it('refuses a body without `{{route.missingField}}` with 422, naming the field', async () => {
|
|
24
|
+
const {{route.bus}} = new {{route.recordingBus}}();
|
|
25
|
+
const { send } = routeOf(new {{name.pascal}}Controller({{route.specArguments}}));
|
|
26
|
+
|
|
27
|
+
const response = await send({{route.missingRequest}});
|
|
28
|
+
|
|
29
|
+
expect(response).toMatchObject({
|
|
30
|
+
status: 422,
|
|
31
|
+
body: {
|
|
32
|
+
code: 'VALIDATION_FAILED',
|
|
33
|
+
issues: expect.arrayContaining([expect.objectContaining({ path: 'body.{{route.missingField}}' })]),
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
expect({{route.bus}}.executed).toEqual([]);
|
|
38
|
+
});
|
|
39
|
+
{{/if}}
|
|
21
40
|
|
|
22
41
|
// TODO(domain): replace each entry below by a test of the same shape, through the same `routeOf` (`{ caller }` names another one, `anonymousActor()` of the kernel nobody); the guards of the controller stand before it, so a route behind a role is sent by an actor that has it.
|
|
23
42
|
it.todo('refuses an input that does not have the expected shape with 422');
|
|
@@ -22,4 +22,6 @@ TODO(domain): the processors and the third parties that receive personal data (m
|
|
|
22
22
|
|
|
23
23
|
## What the code does not purge
|
|
24
24
|
|
|
25
|
+
`npm run privacy:erase` reaches the declared copies, the records of the outbox of the events listed above and the jobs enqueued with the person as `subject`. It does not reach what the code cannot name: a message already delivered to a broker or a consumer, a field of a payload that no `personal` option lists, a job that holds a person in its payload and names no `subject`. The jobs `events.purge-published` and `jobs.purge-finished` drop what the platform is done with past `OUTBOX_RETENTION_DAYS` and `BACKGROUND_JOBS_RETENTION_DAYS`; dead events and dead jobs wait for an operator.
|
|
26
|
+
|
|
25
27
|
TODO(domain): how long the backups, the logs, the files and the archives of the audit trail keep personal data, and who deletes them.
|
|
@@ -289,7 +289,7 @@ and their lines here. Two scripts answer the requests of a person, on the source
|
|
|
289
289
|
variables of `.env`:
|
|
290
290
|
|
|
291
291
|
```bash
|
|
292
|
-
npm run privacy:erase -- <subject-id> --operator <who-asks> # {{#if eventSourcing.on}}the key, then {{/if}}every declared copy{{#if tenancy.any}}, in each tenant of TENANTS{{/if}}
|
|
292
|
+
npm run privacy:erase -- <subject-id> --operator <who-asks> # {{#if eventSourcing.on}}the key, then {{/if}}every declared copy{{#if tenancy.any}}, in each tenant of TENANTS{{/if}}{{#if housekeeping.any}}, then what the platform keeps of the person{{/if}}
|
|
293
293
|
npm run privacy:export -- <subject-id> > export.json # one dated document of every declared record{{#if audit.on}}, audited{{/if}}
|
|
294
294
|
npm run privacy:purge # what outlived its retention, as the nightly job does
|
|
295
295
|
```
|
|
@@ -298,9 +298,18 @@ A declaration with `retention` (`generate repository ... --retention ended_at:36
|
|
|
298
298
|
03:00 UTC by the job `privacy.purge-expired`{{#if audit.on}}, each purge recorded in the audit trail{{/if}}; `JOB_PRIVACY_PURGE_EXPIRED_ENABLED=false`
|
|
299
299
|
switches it off in one environment. How long is your decision: write it in your register with its reason.
|
|
300
300
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
301
|
+
An erasure that reached nothing is refused with exit code 1 and announced to nobody: a mistyped id{{#if tenancy.any}}, a tenant
|
|
302
|
+
`TENANTS` does not list{{/if}}, or a person already erased. `--rerun` says it is expected, and announces the erasure again, which
|
|
303
|
+
completes one that failed half way.{{#if audit.on}} Every run of either script is recorded in the audit trail, operator
|
|
304
|
+
included, a trial too: try them on a test subject, never on a real person.{{/if}}
|
|
305
|
+
{{#if housekeeping.any}}
|
|
306
|
+
The platform keeps its own traces of a person for a while: {{#if events.outbox}}a record of the outbox holds its payload for `OUTBOX_RETENTION_DAYS` once
|
|
307
|
+
published (`events.purge-published`, every night){{/if}}{{#if events.outbox}}{{#if queue.stored}}, {{/if}}{{/if}}{{#if queue.stored}}a finished job for `BACKGROUND_JOBS_RETENTION_DAYS` (`jobs.purge-finished`){{/if}}. An erasure reaches them earlier:
|
|
308
|
+
{{#if events.outbox}}the fields the `personal` option of an event lists, in `{{config.platformDir}}/privacy/personal-events.ts`, which `ddd-ts-kit docs` writes{{/if}}{{#if events.outbox}}{{#if queue.stored}}, and {{/if}}{{/if}}{{#if queue.stored}}the jobs enqueued with
|
|
309
|
+
the person as `subject`{{/if}}.
|
|
310
|
+
|
|
311
|
+
{{/if}}
|
|
312
|
+
Neither script reaches backups, logs, exports or a copy no context declared{{#if housekeeping.any}}, nor a message already delivered, an event with no `personal` option or a job enqueued without `subject`{{/if}}: say so in your register{{#if eventSourcing.on}}, and keep the keys in a
|
|
304
313
|
store of their own in production, with a shorter backup retention than the events
|
|
305
314
|
(docs/concepts/event-sourcing.md of ddd-ts-kit, "Personal data"){{/if}}.
|
|
306
315
|
|
|
@@ -29,6 +29,14 @@ LOG_LEVEL=info
|
|
|
29
29
|
{{#if worker.on}}
|
|
30
30
|
# RUN_JOBS=false
|
|
31
31
|
{{/if}}
|
|
32
|
+
{{#if events.outbox}}
|
|
33
|
+
# Days a published event stays in the outbox, its payload with it, before the job events.purge-published drops it.
|
|
34
|
+
# OUTBOX_RETENTION_DAYS=30
|
|
35
|
+
{{/if}}
|
|
36
|
+
{{#if queue.stored}}
|
|
37
|
+
# Days a job that succeeded or was cancelled stays in its store, before the job jobs.purge-finished drops it.
|
|
38
|
+
# BACKGROUND_JOBS_RETENTION_DAYS=30
|
|
39
|
+
{{/if}}
|
|
32
40
|
{{#if database.postgres}}
|
|
33
41
|
|
|
34
42
|
POSTGRES_USER=app
|
|
@@ -54,6 +54,9 @@ const application = composeApplication(
|
|
|
54
54
|
traceConsumers: config.tracing.consumers,
|
|
55
55
|
resilience: config.resilience,
|
|
56
56
|
jobs: { start: config.runJobs, settings: jobSettings(process.env) },
|
|
57
|
+
{{#if housekeeping.any}}
|
|
58
|
+
housekeeping: config.housekeeping,
|
|
59
|
+
{{/if}}
|
|
57
60
|
{{#if tenancy.any}}
|
|
58
61
|
tenants: config.tenants,
|
|
59
62
|
{{/if}}
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
auditGuardRefusals,
|
|
8
8
|
auditIntegrationEvents,
|
|
9
9
|
auditMiddleware,
|
|
10
|
+
logLostRecords,
|
|
10
11
|
type ArchivableAuditTrail,
|
|
11
12
|
type AuditReader,
|
|
12
13
|
type AuditSource,
|
|
@@ -24,6 +25,7 @@ import {
|
|
|
24
25
|
auditGuardRefusals,
|
|
25
26
|
auditIntegrationEvents,
|
|
26
27
|
auditMiddleware,
|
|
28
|
+
logLostRecords,
|
|
27
29
|
type ArchivableAuditTrail,
|
|
28
30
|
type AuditReader,
|
|
29
31
|
type AuditSource,
|
|
@@ -45,7 +47,7 @@ import { TypeOrmAuditTrail } from '@ddd-ts-kit/audit/typeorm';
|
|
|
45
47
|
{{/if}}
|
|
46
48
|
import type { OnDecision } from '@ddd-ts-kit/auth';
|
|
47
49
|
import type { EventSubscription } from '@ddd-ts-kit/events';
|
|
48
|
-
import type { BusMiddleware } from '@ddd-ts-kit/kernel';
|
|
50
|
+
import type { AuditRecord, BusMiddleware, Logger } from '@ddd-ts-kit/kernel';
|
|
49
51
|
import type { Persistence } from '{{alias.platform}}/database/persistence{{alias.ext}}';
|
|
50
52
|
{{#if audit.schemaFile}}
|
|
51
53
|
import { AUDIT_SCHEMA } from '{{alias.platform}}/database/schema{{alias.ext}}';
|
|
@@ -89,11 +91,14 @@ export interface Audit {
|
|
|
89
91
|
readonly subscriptions: readonly EventSubscription[];
|
|
90
92
|
/** The name those subscriptions listen under. */
|
|
91
93
|
readonly consumer: string;
|
|
94
|
+
/** What a source outside this file passes on: a failure whose entry could not be written is told to the log. */
|
|
95
|
+
readonly onLostRecord: (error: unknown, record: AuditRecord | undefined) => void;
|
|
92
96
|
}
|
|
93
97
|
|
|
94
|
-
export function createAudit(persistence: Persistence, source: AuditSource): Audit {
|
|
98
|
+
export function createAudit(persistence: Persistence, source: AuditSource, logger: Logger): Audit {
|
|
95
99
|
const trail = createAuditTrail({{#if audit.sql}}persistence{{/if}});
|
|
96
100
|
const { unitOfWork, processedEvents } = persistence;
|
|
101
|
+
const onLostRecord = logLostRecords(logger);
|
|
97
102
|
|
|
98
103
|
return {
|
|
99
104
|
trail,
|
|
@@ -104,14 +109,14 @@ export function createAudit(persistence: Persistence, source: AuditSource): Audi
|
|
|
104
109
|
{{#if audit.route}}
|
|
105
110
|
decisions: auditDecisions(trail, { ...source, sensitivePermissions: [auditPermissions['trail.read'].id] }),
|
|
106
111
|
// TODO(platform): declare what may go into `changes` with `fields: [auditedFields(SomeCommand, ['status'])]`; by default an entry carries identifiers and codes only.
|
|
107
|
-
commands: auditMiddleware(trail, { ...source, unitOfWork }),
|
|
108
|
-
queries: auditMiddleware(trail, { ...source, queries: [SearchAuditEntriesQuery] }),
|
|
112
|
+
commands: auditMiddleware(trail, { ...source, unitOfWork, onLostRecord }),
|
|
113
|
+
queries: auditMiddleware(trail, { ...source, queries: [SearchAuditEntriesQuery], onLostRecord }),
|
|
109
114
|
{{/if}}
|
|
110
115
|
{{#unless audit.route}}
|
|
111
116
|
decisions: auditDecisions(trail, source),
|
|
112
117
|
// TODO(platform): declare what may go into `changes` with `fields: [auditedFields(SomeCommand, ['status'])]`; by default an entry carries identifiers and codes only.
|
|
113
|
-
commands: auditMiddleware(trail, { ...source, unitOfWork }),
|
|
114
|
-
queries: auditMiddleware(trail, source),
|
|
118
|
+
commands: auditMiddleware(trail, { ...source, unitOfWork, onLostRecord }),
|
|
119
|
+
queries: auditMiddleware(trail, { ...source, onLostRecord }),
|
|
115
120
|
{{/unless}}
|
|
116
121
|
subscriptions: auditIntegrationEvents(trail, {
|
|
117
122
|
registry: auditedEvents,
|
|
@@ -123,6 +128,7 @@ export function createAudit(persistence: Persistence, source: AuditSource): Audi
|
|
|
123
128
|
consumer,
|
|
124
129
|
}),
|
|
125
130
|
consumer,
|
|
131
|
+
onLostRecord,
|
|
126
132
|
};
|
|
127
133
|
}
|
|
128
134
|
|
|
@@ -60,6 +60,10 @@ import { fileRoutes } from '{{alias.platform}}/files/file-routes{{alias.ext}}';
|
|
|
60
60
|
{{/if}}
|
|
61
61
|
import type { Platform } from '{{alias.platform}}/composition/platform{{alias.ext}}';
|
|
62
62
|
import type { PlatformOptions } from '{{alias.platform}}/composition/platform-options{{alias.ext}}';
|
|
63
|
+
{{#if housekeeping.any}}
|
|
64
|
+
import { daysBefore } from '{{alias.platform}}/jobs/days-before{{alias.ext}}';
|
|
65
|
+
import { DEFAULT_HOUSEKEEPING } from '{{alias.platform}}/jobs/housekeeping{{alias.ext}}';
|
|
66
|
+
{{/if}}
|
|
63
67
|
{{#if privacy.on}}
|
|
64
68
|
import { runPurge } from '{{alias.platform}}/privacy/run-purge{{alias.ext}}';
|
|
65
69
|
{{/if}}
|
|
@@ -324,6 +328,12 @@ function registerPlatformJobs(platform: Platform, options: ApplicationOptions):
|
|
|
324
328
|
{{#if privacy.on}}
|
|
325
329
|
purgeExpiredEveryNight(platform);
|
|
326
330
|
{{/if}}
|
|
331
|
+
{{#if events.outbox}}
|
|
332
|
+
purgePublishedEvents(platform, options);
|
|
333
|
+
{{/if}}
|
|
334
|
+
{{#if queue.stored}}
|
|
335
|
+
purgeFinishedJobs(platform, options);
|
|
336
|
+
{{/if}}
|
|
327
337
|
}
|
|
328
338
|
{{/if}}
|
|
329
339
|
{{#if files.any}}
|
|
@@ -360,6 +370,32 @@ function purgeExpiredEveryNight(platform: Platform): void {
|
|
|
360
370
|
});
|
|
361
371
|
}
|
|
362
372
|
{{/if}}
|
|
373
|
+
{{#if events.outbox}}
|
|
374
|
+
|
|
375
|
+
/** The records of what was published, their payload with them, dropped every night at 03:30 UTC past the days they are kept. */
|
|
376
|
+
function purgePublishedEvents(platform: Platform, { housekeeping = DEFAULT_HOUSEKEEPING }: ApplicationOptions): void {
|
|
377
|
+
platform.jobs.register({
|
|
378
|
+
name: 'events.purge-published',
|
|
379
|
+
schedule: { cron: '30 3 * * *' },
|
|
380
|
+
run: async () => {
|
|
381
|
+
await platform.persistence.outbox.purgePublished(daysBefore(platform.clock, housekeeping.publishedEventsDays));
|
|
382
|
+
},
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
{{/if}}
|
|
386
|
+
{{#if queue.stored}}
|
|
387
|
+
|
|
388
|
+
/** The jobs that succeeded or were cancelled, their payload with them, dropped every night at 03:45 UTC past the days they are kept. */
|
|
389
|
+
function purgeFinishedJobs(platform: Platform, { housekeeping = DEFAULT_HOUSEKEEPING }: ApplicationOptions): void {
|
|
390
|
+
platform.jobs.register({
|
|
391
|
+
name: 'jobs.purge-finished',
|
|
392
|
+
schedule: { cron: '45 3 * * *' },
|
|
393
|
+
run: async () => {
|
|
394
|
+
await platform.jobStore.purgeFinished(daysBefore(platform.clock, housekeeping.finishedJobsDays));
|
|
395
|
+
},
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
{{/if}}
|
|
363
399
|
{{#if routes.nest}}
|
|
364
400
|
|
|
365
401
|
/** The Nest controllers of the contexts: their routes now, their instances built by Nest when the server starts, with the buses of the platform. */
|
|
@@ -90,6 +90,10 @@ import { fileRoutes } from '{{alias.platform}}/files/file-routes{{alias.ext}}';
|
|
|
90
90
|
{{#if files.any}}
|
|
91
91
|
import { filesModule } from '{{alias.platform}}/files/files.module{{alias.ext}}';
|
|
92
92
|
{{/if}}
|
|
93
|
+
{{#if housekeeping.any}}
|
|
94
|
+
import { DEFAULT_HOUSEKEEPING } from '{{alias.platform}}/jobs/housekeeping{{alias.ext}}';
|
|
95
|
+
import { housekeepingModule } from '{{alias.platform}}/jobs/housekeeping.module{{alias.ext}}';
|
|
96
|
+
{{/if}}
|
|
93
97
|
{{#if privacy.on}}
|
|
94
98
|
import { privacyModule } from '{{alias.platform}}/privacy/privacy.module{{alias.ext}}';
|
|
95
99
|
{{/if}}
|
|
@@ -226,6 +230,9 @@ export function composeApplication(
|
|
|
226
230
|
{{/if}}
|
|
227
231
|
{{#if privacy.on}}
|
|
228
232
|
privacyModule({ jobs: options.platformJobs !== false }),
|
|
233
|
+
{{/if}}
|
|
234
|
+
{{#if housekeeping.any}}
|
|
235
|
+
housekeepingModule(options.housekeeping ?? DEFAULT_HOUSEKEEPING, { jobs: options.platformJobs !== false }),
|
|
229
236
|
{{/if}}
|
|
230
237
|
...contexts.modules,
|
|
231
238
|
],
|
|
@@ -79,7 +79,7 @@ export function layFoundations(persistence: Persistence, options: PlatformOption
|
|
|
79
79
|
const lock = new InMemoryLock(clock);
|
|
80
80
|
{{/unless}}
|
|
81
81
|
{{#if audit.on}}
|
|
82
|
-
const audit = createAudit(persistence, { scope, clock, ids });
|
|
82
|
+
const audit = createAudit(persistence, { scope, clock, ids }, logger);
|
|
83
83
|
{{/if}}
|
|
84
84
|
|
|
85
85
|
{{#if tenancy.any}}
|
|
@@ -64,7 +64,7 @@ export function layFoundations(persistence: Persistence, options: Observed): Fou
|
|
|
64
64
|
const ids = new UuidGenerator();
|
|
65
65
|
const logger = createLogger(scope, options.log);
|
|
66
66
|
{{#if audit.on}}
|
|
67
|
-
const audit = createAudit(persistence, { scope, clock, ids });
|
|
67
|
+
const audit = createAudit(persistence, { scope, clock, ids }, logger);
|
|
68
68
|
{{/if}}
|
|
69
69
|
|
|
70
70
|
return {
|
|
@@ -17,6 +17,9 @@ import type { JobSettings } from '@ddd-ts-kit/kernel';
|
|
|
17
17
|
import type { QueueWorkerOptions } from '@ddd-ts-kit/scheduling';
|
|
18
18
|
import type { ConsumerTrace } from '@ddd-ts-kit/tracing';
|
|
19
19
|
import type { EventProvider } from '{{alias.platform}}/events/event-provider{{alias.ext}}';
|
|
20
|
+
{{#if housekeeping.any}}
|
|
21
|
+
import type { Housekeeping } from '{{alias.platform}}/jobs/housekeeping{{alias.ext}}';
|
|
22
|
+
{{/if}}
|
|
20
23
|
import type { LogSettings } from '{{alias.platform}}/observability/create-logger{{alias.ext}}';
|
|
21
24
|
{{#if cache.redis}}
|
|
22
25
|
import type { RedisServices } from '{{alias.platform}}/redis/open-redis{{alias.ext}}';
|
|
@@ -35,6 +38,10 @@ export interface PlatformOptions {
|
|
|
35
38
|
readonly events: EventProvider;
|
|
36
39
|
/** Where log entries go; left out, the application writes nothing. */
|
|
37
40
|
readonly log?: LogSettings;
|
|
41
|
+
{{#if housekeeping.any}}
|
|
42
|
+
/** How long the platform keeps what it is done with, in days: the configuration in `main.ts`; left out (the tools, the tests), thirty. */
|
|
43
|
+
readonly housekeeping?: Housekeeping;
|
|
44
|
+
{{/if}}
|
|
38
45
|
{{#if errors.sentry}}
|
|
39
46
|
/** Where unexpected failures are reported: the reporter of `errors.ts` in `main.ts`; left out (the tools, the tests), nowhere. */
|
|
40
47
|
readonly errors?: ErrorReporter;
|
|
@@ -26,6 +26,9 @@ import type {
|
|
|
26
26
|
RateLimiter,
|
|
27
27
|
{{/if}}
|
|
28
28
|
} from '@ddd-ts-kit/kernel';
|
|
29
|
+
{{#if queue.stored}}
|
|
30
|
+
import type { JobStore } from '@ddd-ts-kit/scheduling';
|
|
31
|
+
{{/if}}
|
|
29
32
|
{{#if audit.on}}
|
|
30
33
|
import type { Audit } from '{{alias.platform}}/audit/create-audit{{alias.ext}}';
|
|
31
34
|
{{/if}}
|
|
@@ -89,6 +92,10 @@ export interface Platform {
|
|
|
89
92
|
readonly jobs: JobScheduler;
|
|
90
93
|
/** What a use case enqueues through: a background job is written with its command and run later by the worker, as the actor that enqueued it. */
|
|
91
94
|
readonly jobQueue: JobQueue;
|
|
95
|
+
{{#if queue.stored}}
|
|
96
|
+
/** Where the jobs wait: what the purge of what finished and the erasure of a person reach. */
|
|
97
|
+
readonly jobStore: JobStore;
|
|
98
|
+
{{/if}}
|
|
92
99
|
/** Where a context registers its background jobs; the application starts it when this process runs the jobs. */
|
|
93
100
|
readonly backgroundJobs: BackgroundJobs;
|
|
94
101
|
/** Runs the steps of the process managers, in the unit of work of the step, and delivers their timeouts through the queue. */
|
|
@@ -83,6 +83,9 @@ import type { Persistence } from '{{alias.platform}}/database/persistence{{alias
|
|
|
83
83
|
import { platformErrorMapper } from '{{alias.platform}}/composition/platform-error-mapper{{alias.ext}}';
|
|
84
84
|
{{/if}}
|
|
85
85
|
import type { EventProvider } from '{{alias.platform}}/events/event-provider{{alias.ext}}';
|
|
86
|
+
{{#if housekeeping.any}}
|
|
87
|
+
import type { Housekeeping } from '{{alias.platform}}/jobs/housekeeping{{alias.ext}}';
|
|
88
|
+
{{/if}}
|
|
86
89
|
import type { LogSettings } from '{{alias.platform}}/observability/create-logger{{alias.ext}}';
|
|
87
90
|
{{#if cache.redis}}
|
|
88
91
|
import type { RedisServices } from '{{alias.platform}}/redis/open-redis{{alias.ext}}';
|
|
@@ -105,6 +108,10 @@ export interface PlatformOptions {
|
|
|
105
108
|
{{/if}}
|
|
106
109
|
/** Where log entries go; left out, the application writes nothing. */
|
|
107
110
|
readonly log?: LogSettings;
|
|
111
|
+
{{#if housekeeping.any}}
|
|
112
|
+
/** How long the platform keeps what it is done with, in days: the configuration in `main.ts`; left out (the tools, the tests), thirty. */
|
|
113
|
+
readonly housekeeping?: Housekeeping;
|
|
114
|
+
{{/if}}
|
|
108
115
|
/** The policy around every adapter that leaves the process; left out, `resilience/default-resilience-settings.ts`. */
|
|
109
116
|
readonly resilience?: ResilienceSettings;
|
|
110
117
|
/** Whether a consumed event continues the trace of its publication (the default) or starts one linked to it. */
|
|
@@ -9,6 +9,9 @@ import type { ResilienceSettings } from '{{alias.platform}}/resilience/resilienc
|
|
|
9
9
|
import type { FilesConfig } from '{{alias.platform}}/config/read-files{{alias.ext}}';
|
|
10
10
|
{{/if}}
|
|
11
11
|
import type { TracingConfig } from '{{alias.platform}}/config/read-tracing{{alias.ext}}';
|
|
12
|
+
{{#if housekeeping.any}}
|
|
13
|
+
import type { Housekeeping } from '{{alias.platform}}/jobs/housekeeping{{alias.ext}}';
|
|
14
|
+
{{/if}}
|
|
12
15
|
|
|
13
16
|
/** The validated configuration of the process: `loadConfig` is the only reader of the environment. */
|
|
14
17
|
export interface AppConfig {
|
|
@@ -36,6 +39,10 @@ export interface AppConfig {
|
|
|
36
39
|
{{#if events.outbox}}
|
|
37
40
|
readonly outboxRelayIntervalMs: number;
|
|
38
41
|
{{/if}}
|
|
42
|
+
{{#if housekeeping.any}}
|
|
43
|
+
/** How long the platform keeps what it is done with, in days (`OUTBOX_RETENTION_DAYS`, `BACKGROUND_JOBS_RETENTION_DAYS`). */
|
|
44
|
+
readonly housekeeping: Housekeeping;
|
|
45
|
+
{{/if}}
|
|
39
46
|
{{#if docs.any}}
|
|
40
47
|
readonly docsEnabled: boolean;
|
|
41
48
|
{{/if}}
|
|
@@ -15,6 +15,9 @@ import { Environment, type Variables } from '{{alias.platform}}/config/environme
|
|
|
15
15
|
import { readFiles } from '{{alias.platform}}/config/read-files{{alias.ext}}';
|
|
16
16
|
{{/if}}
|
|
17
17
|
import { readTracing } from '{{alias.platform}}/config/read-tracing{{alias.ext}}';
|
|
18
|
+
{{#if housekeeping.any}}
|
|
19
|
+
import { DEFAULT_HOUSEKEEPING, type Housekeeping } from '{{alias.platform}}/jobs/housekeeping{{alias.ext}}';
|
|
20
|
+
{{/if}}
|
|
18
21
|
|
|
19
22
|
const environments = ['development', 'test', 'production'] as const;
|
|
20
23
|
{{#if http.any}}
|
|
@@ -62,6 +65,9 @@ export function loadConfig(variables: Variables): AppConfig {
|
|
|
62
65
|
{{#if events.outbox}}
|
|
63
66
|
outboxRelayIntervalMs: env.integer('OUTBOX_RELAY_INTERVAL_MS', { fallback: 500, min: 10, max: 60000 }),
|
|
64
67
|
{{/if}}
|
|
68
|
+
{{#if housekeeping.any}}
|
|
69
|
+
housekeeping: readHousekeeping(env),
|
|
70
|
+
{{/if}}
|
|
65
71
|
{{#if docs.any}}
|
|
66
72
|
docsEnabled: env.flag('API_DOCS', environment !== 'production'),
|
|
67
73
|
{{/if}}
|
|
@@ -110,6 +116,22 @@ export function loadConfig(variables: Variables): AppConfig {
|
|
|
110
116
|
return config;
|
|
111
117
|
}
|
|
112
118
|
|
|
119
|
+
{{#if housekeeping.any}}
|
|
120
|
+
/** How long the platform keeps what it is done with, in days; past that, the nightly purges drop it. */
|
|
121
|
+
function readHousekeeping(env: Environment): Housekeeping {
|
|
122
|
+
const days = (name: string, fallback: number): number => env.integer(name, { fallback, min: 1, max: 3650 });
|
|
123
|
+
|
|
124
|
+
return {
|
|
125
|
+
{{#if events.outbox}}
|
|
126
|
+
publishedEventsDays: days('OUTBOX_RETENTION_DAYS', DEFAULT_HOUSEKEEPING.publishedEventsDays),
|
|
127
|
+
{{/if}}
|
|
128
|
+
{{#if queue.stored}}
|
|
129
|
+
finishedJobsDays: days('BACKGROUND_JOBS_RETENTION_DAYS', DEFAULT_HOUSEKEEPING.finishedJobsDays),
|
|
130
|
+
{{/if}}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
{{/if}}
|
|
113
135
|
{{#if tenancy.any}}
|
|
114
136
|
/** `TENANTS=acme,globex`: each id in the grammar of a tenant id. */
|
|
115
137
|
function readTenants(env: Environment): readonly string[] {
|
|
@@ -5,7 +5,7 @@ import { FixedExecutionScope, executionContext, systemActor } from '@ddd-ts-kit/
|
|
|
5
5
|
{{#unless queue.processTable}}
|
|
6
6
|
{{#if tenancy.any}}
|
|
7
7
|
{{#if eventSourcing.on}}
|
|
8
|
-
import { FixedExecutionScope } from '@ddd-ts-kit/kernel';
|
|
8
|
+
import { FixedExecutionScope, executionContext, systemActor } from '@ddd-ts-kit/kernel';
|
|
9
9
|
{{/if}}
|
|
10
10
|
{{/if}}
|
|
11
11
|
{{/unless}}
|
|
@@ -74,8 +74,8 @@ processedEventStoreContract(runner, {
|
|
|
74
74
|
eventStoreContract(runner, {
|
|
75
75
|
name: 'The event store of the platform',
|
|
76
76
|
{{#if tenancy.any}}
|
|
77
|
-
createStore: async () => (await emptied()).eventSourcing(
|
|
78
|
-
createCompanions: async () => (await emptied()).eventSourcing(
|
|
77
|
+
createStore: async () => (await emptied()).eventSourcing(inOneTenant()).events,
|
|
78
|
+
createCompanions: async () => (await emptied()).eventSourcing(inOneTenant()),
|
|
79
79
|
createTenantStore: async () => {
|
|
80
80
|
const scope = new FixedExecutionScope();
|
|
81
81
|
|
|
@@ -129,3 +129,14 @@ async function emptied(): Promise<Persistence> {
|
|
|
129
129
|
|
|
130
130
|
return database.persistence;
|
|
131
131
|
}
|
|
132
|
+
{{#if tenancy.any}}
|
|
133
|
+
{{#if eventSourcing.on}}
|
|
134
|
+
|
|
135
|
+
/** A scope in one tenant: the event store refuses work that names none, and its stream suites run in this one. */
|
|
136
|
+
function inOneTenant(): FixedExecutionScope {
|
|
137
|
+
return new FixedExecutionScope(
|
|
138
|
+
executionContext({ correlationId: 'contract', actor: systemActor('contract'), origin: 'test', tenantId: 'acme' }),
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
{{/if}}
|
|
142
|
+
{{/if}}
|
|
@@ -28,7 +28,11 @@ export function createEventSourcing(persistence: Persistence, audit: Audit, sour
|
|
|
28
28
|
{{#unless tenancy.any}}
|
|
29
29
|
const stores = persistence.eventSourcing;
|
|
30
30
|
{{/unless}}
|
|
31
|
-
|
|
31
|
+
|
|
32
|
+
const subjectKeys = auditedSubjectKeys(stores.subjectKeys, audit.trail, {
|
|
33
|
+
...source,
|
|
34
|
+
onLostRecord: audit.onLostRecord,
|
|
35
|
+
});
|
|
32
36
|
|
|
33
37
|
return { ...stores, subjectKeys, cipher: new PersonalDataCipher(subjectKeys) };
|
|
34
38
|
}
|
|
@@ -40,6 +40,10 @@ import type { BackgroundJobs } from '{{alias.platform}}/jobs/background-jobs{{al
|
|
|
40
40
|
export interface BackgroundWork {
|
|
41
41
|
/** What a use case enqueues through, in the transaction of its command when the store shares it. */
|
|
42
42
|
readonly jobQueue: JobQueue;
|
|
43
|
+
{{#if queue.stored}}
|
|
44
|
+
/** Where the jobs wait: what the purge of what finished and the erasure of a person reach. */
|
|
45
|
+
readonly jobStore: JobStore;
|
|
46
|
+
{{/if}}
|
|
43
47
|
readonly backgroundJobs: BackgroundJobs;
|
|
44
48
|
/** Runs the steps of the process managers and delivers their timeouts. */
|
|
45
49
|
readonly processes: ProcessRunner;
|
|
@@ -82,10 +86,18 @@ export function createBackgroundWork({
|
|
|
82
86
|
{{#if queue.memory}}
|
|
83
87
|
const store = new InMemoryJobStore();
|
|
84
88
|
{{/if}}
|
|
89
|
+
{{#if tenancy.any}}
|
|
90
|
+
const jobQueue = new StoredJobQueue({ store, clock, ids, scope, tenant: true, traceparent: traced.traceparent });
|
|
91
|
+
{{/if}}
|
|
92
|
+
{{#unless tenancy.any}}
|
|
85
93
|
const jobQueue = new StoredJobQueue({ store, clock, ids, scope, traceparent: traced.traceparent });
|
|
94
|
+
{{/unless}}
|
|
86
95
|
|
|
87
96
|
return {
|
|
88
97
|
jobQueue,
|
|
98
|
+
{{#if queue.stored}}
|
|
99
|
+
jobStore: store,
|
|
100
|
+
{{/if}}
|
|
89
101
|
backgroundJobs: backgroundJobsOn(workerOn(store, options, foundations), traced),
|
|
90
102
|
processes: new StoredProcessRunner({
|
|
91
103
|
{{#if queue.processTable}}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Clock } from '@ddd-ts-kit/kernel';
|
|
2
|
+
|
|
3
|
+
const DAY_MS = 86_400_000;
|
|
4
|
+
|
|
5
|
+
/** The instant before which a purge reaches what finished. */
|
|
6
|
+
export function daysBefore(clock: Clock, days: number): Date {
|
|
7
|
+
return new Date(clock.now().getTime() - days * DAY_MS);
|
|
8
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { defineContextModule, type ContextModule } from '@ddd-ts-kit/di';
|
|
2
|
+
{{#if events.outbox}}
|
|
3
|
+
import { OutboxStore } from '@ddd-ts-kit/events';
|
|
4
|
+
{{/if}}
|
|
5
|
+
import { Clock } from '@ddd-ts-kit/kernel';
|
|
6
|
+
{{#if queue.stored}}
|
|
7
|
+
import { JobStore } from '@ddd-ts-kit/scheduling';
|
|
8
|
+
{{/if}}
|
|
9
|
+
import { daysBefore } from '{{alias.platform}}/jobs/days-before{{alias.ext}}';
|
|
10
|
+
import type { Housekeeping } from '{{alias.platform}}/jobs/housekeeping{{alias.ext}}';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* What the platform is done with, purged every night{{#if events.outbox}}: `events.purge-published` at 03:30 UTC (switched off in
|
|
14
|
+
* one environment with `JOB_EVENTS_PURGE_PUBLISHED_ENABLED=false`){{/if}}{{#if queue.stored}}{{#if events.outbox}},{{/if}}{{#unless events.outbox}}:{{/unless}} `jobs.purge-finished` at 03:45 UTC
|
|
15
|
+
* (`JOB_JOBS_PURGE_FINISHED_ENABLED=false`){{/if}}. A record and a job row keep their payload until then.
|
|
16
|
+
*/
|
|
17
|
+
export function housekeepingModule(
|
|
18
|
+
retention: Housekeeping,
|
|
19
|
+
{ jobs = true }: { readonly jobs?: boolean } = {},
|
|
20
|
+
): ContextModule {
|
|
21
|
+
return defineContextModule({
|
|
22
|
+
name: 'housekeeping',
|
|
23
|
+
register(builder) {
|
|
24
|
+
// Registered by the process that runs the jobs of the platform; a service of the deployment passes `jobs: false`.
|
|
25
|
+
if (!jobs) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
{{#if events.outbox}}
|
|
29
|
+
|
|
30
|
+
builder.job('events.purge-published', { cron: '30 3 * * *', tenancy: 'global' }).handledByFactory((resolve) => ({
|
|
31
|
+
run: async () => {
|
|
32
|
+
await resolve(OutboxStore).purgePublished(daysBefore(resolve(Clock), retention.publishedEventsDays));
|
|
33
|
+
},
|
|
34
|
+
}));
|
|
35
|
+
{{/if}}
|
|
36
|
+
{{#if queue.stored}}
|
|
37
|
+
|
|
38
|
+
builder.job('jobs.purge-finished', { cron: '45 3 * * *', tenancy: 'global' }).handledByFactory((resolve) => ({
|
|
39
|
+
run: async () => {
|
|
40
|
+
await resolve(JobStore).purgeFinished(daysBefore(resolve(Clock), retention.finishedJobsDays));
|
|
41
|
+
},
|
|
42
|
+
}));
|
|
43
|
+
{{/if}}
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How long the platform keeps what it is done with, in days, read from the environment by
|
|
3
|
+
* `load-config.ts`. A row holds what its payload held: {{#if events.outbox}}`events.purge-published` drops the records of the
|
|
4
|
+
* outbox past that age{{/if}}{{#if events.outbox}}{{#if queue.stored}}, {{/if}}{{/if}}{{#if queue.stored}}`jobs.purge-finished` the jobs that succeeded or were cancelled{{/if}}, every night. What failed for
|
|
5
|
+
* good stays until an operator decides.
|
|
6
|
+
*/
|
|
7
|
+
export interface Housekeeping {
|
|
8
|
+
{{#if events.outbox}}
|
|
9
|
+
readonly publishedEventsDays: number;
|
|
10
|
+
{{/if}}
|
|
11
|
+
{{#if queue.stored}}
|
|
12
|
+
readonly finishedJobsDays: number;
|
|
13
|
+
{{/if}}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Left out (the tools, the tests), thirty days of each. */
|
|
17
|
+
export const DEFAULT_HOUSEKEEPING: Housekeeping = {
|
|
18
|
+
{{#if events.outbox}}
|
|
19
|
+
publishedEventsDays: 30,
|
|
20
|
+
{{/if}}
|
|
21
|
+
{{#if queue.stored}}
|
|
22
|
+
finishedJobsDays: 30,
|
|
23
|
+
{{/if}}
|
|
24
|
+
};
|