ddd-ts-kit 0.14.0 → 0.16.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 +31 -2
- package/dist/check/catalogue/architecture-rules.d.ts.map +1 -1
- package/dist/check/catalogue/architecture-rules.js +2 -0
- package/dist/check/catalogue/architecture-rules.js.map +1 -1
- package/dist/check/explain/domain-docs.d.ts +3 -0
- package/dist/check/explain/domain-docs.d.ts.map +1 -0
- package/dist/check/explain/domain-docs.js +30 -0
- package/dist/check/explain/domain-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/explain/tenancy-docs.d.ts.map +1 -1
- package/dist/check/explain/tenancy-docs.js +3 -1
- package/dist/check/explain/tenancy-docs.js.map +1 -1
- package/dist/check/fixtures/fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/fixtures.js +4 -0
- package/dist/check/fixtures/fixtures.js.map +1 -1
- package/dist/check/fixtures/model-function-fixtures.d.ts +4 -0
- package/dist/check/fixtures/model-function-fixtures.d.ts.map +1 -0
- package/dist/check/fixtures/model-function-fixtures.js +52 -0
- package/dist/check/fixtures/model-function-fixtures.js.map +1 -0
- package/dist/check/fixtures/tenancy-fixtures.d.ts.map +1 -1
- package/dist/check/fixtures/tenancy-fixtures.js +28 -0
- package/dist/check/fixtures/tenancy-fixtures.js.map +1 -1
- package/dist/check/fixtures/value-object-file-fixtures.d.ts +4 -0
- package/dist/check/fixtures/value-object-file-fixtures.d.ts.map +1 -0
- package/dist/check/fixtures/value-object-file-fixtures.js +54 -0
- package/dist/check/fixtures/value-object-file-fixtures.js.map +1 -0
- package/dist/check/fixtures/value-object-files.d.ts +34 -0
- package/dist/check/fixtures/value-object-files.d.ts.map +1 -0
- package/dist/check/fixtures/value-object-files.js +46 -0
- package/dist/check/fixtures/value-object-files.js.map +1 -0
- package/dist/check/rules/domain-value-object-class.d.ts +3 -0
- package/dist/check/rules/domain-value-object-class.d.ts.map +1 -0
- package/dist/check/rules/domain-value-object-class.js +21 -0
- package/dist/check/rules/domain-value-object-class.js.map +1 -0
- package/dist/check/structure/class-body-brace.d.ts +6 -0
- package/dist/check/structure/class-body-brace.d.ts.map +1 -0
- package/dist/check/structure/class-body-brace.js +22 -0
- package/dist/check/structure/class-body-brace.js.map +1 -0
- package/dist/check/structure/read-structure.d.ts.map +1 -1
- package/dist/check/structure/read-structure.js +3 -1
- package/dist/check/structure/read-structure.js.map +1 -1
- package/dist/check/tenancy/knex-unscoped.d.ts +6 -1
- package/dist/check/tenancy/knex-unscoped.d.ts.map +1 -1
- package/dist/check/tenancy/knex-unscoped.js +19 -6
- package/dist/check/tenancy/knex-unscoped.js.map +1 -1
- package/dist/check/tenancy/raw-reaches-rows.d.ts +8 -0
- package/dist/check/tenancy/raw-reaches-rows.d.ts.map +1 -0
- package/dist/check/tenancy/raw-reaches-rows.js +91 -0
- package/dist/check/tenancy/raw-reaches-rows.js.map +1 -0
- package/dist/check/tenancy/raw-sql-text.d.ts +9 -0
- package/dist/check/tenancy/raw-sql-text.d.ts.map +1 -0
- package/dist/check/tenancy/raw-sql-text.js +29 -0
- package/dist/check/tenancy/raw-sql-text.js.map +1 -0
- package/dist/check/values/answered-literals.d.ts +8 -0
- package/dist/check/values/answered-literals.d.ts.map +1 -0
- package/dist/check/values/answered-literals.js +20 -0
- package/dist/check/values/answered-literals.js.map +1 -0
- package/dist/check/values/arrow-body.d.ts +4 -0
- package/dist/check/values/arrow-body.d.ts.map +1 -0
- package/dist/check/values/arrow-body.js +52 -0
- package/dist/check/values/arrow-body.js.map +1 -0
- package/dist/check/values/entry-role.d.ts +10 -0
- package/dist/check/values/entry-role.d.ts.map +1 -0
- package/dist/check/values/entry-role.js +40 -0
- package/dist/check/values/entry-role.js.map +1 -0
- package/dist/check/values/exported-function-body.d.ts +9 -0
- package/dist/check/values/exported-function-body.d.ts.map +1 -0
- package/dist/check/values/exported-function-body.js +29 -0
- package/dist/check/values/exported-function-body.js.map +1 -0
- package/dist/check/values/exported-values.d.ts +9 -0
- package/dist/check/values/exported-values.d.ts.map +1 -0
- package/dist/check/values/exported-values.js +48 -0
- package/dist/check/values/exported-values.js.map +1 -0
- package/dist/check/values/extends-value-object.d.ts +9 -0
- package/dist/check/values/extends-value-object.d.ts.map +1 -0
- package/dist/check/values/extends-value-object.js +25 -0
- package/dist/check/values/extends-value-object.js.map +1 -0
- package/dist/check/values/function-body.d.ts +10 -0
- package/dist/check/values/function-body.d.ts.map +1 -0
- package/dist/check/values/function-body.js +2 -0
- package/dist/check/values/function-body.js.map +1 -0
- package/dist/check/values/generate-hint.d.ts +4 -0
- package/dist/check/values/generate-hint.d.ts.map +1 -0
- package/dist/check/values/generate-hint.js +8 -0
- package/dist/check/values/generate-hint.js.map +1 -0
- package/dist/check/values/initializer-of.d.ts +3 -0
- package/dist/check/values/initializer-of.d.ts.map +1 -0
- package/dist/check/values/initializer-of.js +15 -0
- package/dist/check/values/initializer-of.js.map +1 -0
- package/dist/check/values/is-model-file.d.ts +8 -0
- package/dist/check/values/is-model-file.d.ts.map +1 -0
- package/dist/check/values/is-model-file.js +15 -0
- package/dist/check/values/is-model-file.js.map +1 -0
- package/dist/check/values/is-value-object-file.d.ts +7 -0
- package/dist/check/values/is-value-object-file.d.ts.map +1 -0
- package/dist/check/values/is-value-object-file.js +14 -0
- package/dist/check/values/is-value-object-file.js.map +1 -0
- package/dist/check/values/javascript-globals.d.ts +3 -0
- package/dist/check/values/javascript-globals.d.ts.map +1 -0
- package/dist/check/values/javascript-globals.js +22 -0
- package/dist/check/values/javascript-globals.js.map +1 -0
- package/dist/check/values/literal-at.d.ts +3 -0
- package/dist/check/values/literal-at.d.ts.map +1 -0
- package/dist/check/values/literal-at.js +7 -0
- package/dist/check/values/literal-at.js.map +1 -0
- package/dist/check/values/local-declaration.d.ts +8 -0
- package/dist/check/values/local-declaration.d.ts.map +1 -0
- package/dist/check/values/local-declaration.js +31 -0
- package/dist/check/values/local-declaration.js.map +1 -0
- package/dist/check/values/nested-bodies.d.ts +8 -0
- package/dist/check/values/nested-bodies.d.ts.map +1 -0
- package/dist/check/values/nested-bodies.js +28 -0
- package/dist/check/values/nested-bodies.js.map +1 -0
- package/dist/check/values/plain-value-functions.d.ts +10 -0
- package/dist/check/values/plain-value-functions.d.ts.map +1 -0
- package/dist/check/values/plain-value-functions.js +33 -0
- package/dist/check/values/plain-value-functions.js.map +1 -0
- package/dist/check/values/returns-package-type.d.ts +9 -0
- package/dist/check/values/returns-package-type.d.ts.map +1 -0
- package/dist/check/values/returns-package-type.js +12 -0
- package/dist/check/values/returns-package-type.js.map +1 -0
- package/dist/check/values/stands-for-a-value.d.ts +9 -0
- package/dist/check/values/stands-for-a-value.d.ts.map +1 -0
- package/dist/check/values/stands-for-a-value.js +28 -0
- package/dist/check/values/stands-for-a-value.js.map +1 -0
- package/dist/check/values/value-object-file-findings.d.ts +5 -0
- package/dist/check/values/value-object-file-findings.d.ts.map +1 -0
- package/dist/check/values/value-object-file-findings.js +96 -0
- package/dist/check/values/value-object-file-findings.js.map +1 -0
- package/dist/commands/generate.js +2 -0
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +12 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +1 -1
- package/dist/config/index.js.map +1 -1
- package/dist/config/parse-stack.d.ts.map +1 -1
- package/dist/config/parse-stack.js +2 -1
- package/dist/config/parse-stack.js.map +1 -1
- package/dist/config/stack.d.ts +8 -0
- package/dist/config/stack.d.ts.map +1 -1
- package/dist/config/stack.js +1 -0
- package/dist/config/stack.js.map +1 -1
- package/dist/declared/injection/laid-out-calls.d.ts +7 -0
- package/dist/declared/injection/laid-out-calls.d.ts.map +1 -0
- package/dist/declared/injection/laid-out-calls.js +14 -0
- package/dist/declared/injection/laid-out-calls.js.map +1 -0
- package/dist/declared/render-barrel.d.ts.map +1 -1
- package/dist/declared/render-barrel.js +2 -1
- package/dist/declared/render-barrel.js.map +1 -1
- package/dist/declared/render-dependencies-file.d.ts.map +1 -1
- package/dist/declared/render-dependencies-file.js +2 -1
- package/dist/declared/render-dependencies-file.js.map +1 -1
- package/dist/generate/kind.d.ts +2 -0
- package/dist/generate/kind.d.ts.map +1 -1
- package/dist/generate/kinds/context-kind.d.ts.map +1 -1
- package/dist/generate/kinds/context-kind.js +13 -6
- package/dist/generate/kinds/context-kind.js.map +1 -1
- package/dist/generate/kinds/next-adr-number.d.ts +4 -0
- package/dist/generate/kinds/next-adr-number.d.ts.map +1 -0
- package/dist/generate/kinds/next-adr-number.js +7 -0
- package/dist/generate/kinds/next-adr-number.js.map +1 -0
- package/dist/generate/kinds/write-adr.js +3 -6
- package/dist/generate/kinds/write-adr.js.map +1 -1
- package/dist/help/usage.d.ts +1 -1
- package/dist/help/usage.d.ts.map +1 -1
- package/dist/help/usage.js +2 -2
- package/dist/init/manifest/versions.js +24 -24
- package/dist/init/run-init.d.ts +2 -0
- package/dist/init/run-init.d.ts.map +1 -1
- package/dist/init/run-init.js +15 -1
- package/dist/init/run-init.js.map +1 -1
- package/dist/init/stack/resolve-stack.d.ts.map +1 -1
- package/dist/init/stack/resolve-stack.js +3 -1
- package/dist/init/stack/resolve-stack.js.map +1 -1
- package/dist/init/stack/stack-options.d.ts +2 -0
- package/dist/init/stack/stack-options.d.ts.map +1 -1
- package/dist/presets/apply-preset.d.ts +15 -0
- package/dist/presets/apply-preset.d.ts.map +1 -0
- package/dist/presets/apply-preset.js +94 -0
- package/dist/presets/apply-preset.js.map +1 -0
- package/dist/presets/grant-to-signed-in.d.ts +9 -0
- package/dist/presets/grant-to-signed-in.d.ts.map +1 -0
- package/dist/presets/grant-to-signed-in.js +61 -0
- package/dist/presets/grant-to-signed-in.js.map +1 -0
- package/dist/presets/identity-preset.d.ts +9 -0
- package/dist/presets/identity-preset.d.ts.map +1 -0
- package/dist/presets/identity-preset.js +44 -0
- package/dist/presets/identity-preset.js.map +1 -0
- package/dist/presets/identity-refusal.d.ts +5 -0
- package/dist/presets/identity-refusal.d.ts.map +1 -0
- package/dist/presets/identity-refusal.js +29 -0
- package/dist/presets/identity-refusal.js.map +1 -0
- package/dist/presets/identity-terms.d.ts +4 -0
- package/dist/presets/identity-terms.d.ts.map +1 -0
- package/dist/presets/identity-terms.js +57 -0
- package/dist/presets/identity-terms.js.map +1 -0
- package/dist/presets/no-flags.d.ts +4 -0
- package/dist/presets/no-flags.d.ts.map +1 -0
- package/dist/presets/no-flags.js +18 -0
- package/dist/presets/no-flags.js.map +1 -0
- package/dist/presets/organisations-as-tenants.d.ts +9 -0
- package/dist/presets/organisations-as-tenants.d.ts.map +1 -0
- package/dist/presets/organisations-as-tenants.js +43 -0
- package/dist/presets/organisations-as-tenants.js.map +1 -0
- package/dist/presets/preset-decision.d.ts +8 -0
- package/dist/presets/preset-decision.d.ts.map +1 -0
- package/dist/presets/preset-decision.js +19 -0
- package/dist/presets/preset-decision.js.map +1 -0
- package/dist/presets/preset-file.d.ts +13 -0
- package/dist/presets/preset-file.d.ts.map +1 -0
- package/dist/presets/preset-file.js +2 -0
- package/dist/presets/preset-file.js.map +1 -0
- package/dist/presets/preset-files.d.ts +9 -0
- package/dist/presets/preset-files.d.ts.map +1 -0
- package/dist/presets/preset-files.js +34 -0
- package/dist/presets/preset-files.js.map +1 -0
- package/dist/presets/preset-named.d.ts +3 -0
- package/dist/presets/preset-named.d.ts.map +1 -0
- package/dist/presets/preset-named.js +12 -0
- package/dist/presets/preset-named.js.map +1 -0
- package/dist/presets/preset-refusal.d.ts +6 -0
- package/dist/presets/preset-refusal.d.ts.map +1 -0
- package/dist/presets/preset-refusal.js +2 -0
- package/dist/presets/preset-refusal.js.map +1 -0
- package/dist/presets/preset-step.d.ts +8 -0
- package/dist/presets/preset-step.d.ts.map +1 -0
- package/dist/presets/preset-step.js +2 -0
- package/dist/presets/preset-step.js.map +1 -0
- package/dist/presets/preset.d.ts +36 -0
- package/dist/presets/preset.d.ts.map +1 -0
- package/dist/presets/preset.js +2 -0
- package/dist/presets/preset.js.map +1 -0
- package/dist/presets/with-authorizer-import.d.ts +6 -0
- package/dist/presets/with-authorizer-import.d.ts.map +1 -0
- package/dist/presets/with-authorizer-import.js +27 -0
- package/dist/presets/with-authorizer-import.js.map +1 -0
- package/dist/stack/stack-vars.js +2 -1
- package/dist/stack/stack-vars.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/workspace/workspace.d.ts +2 -0
- package/dist/workspace/workspace.d.ts.map +1 -1
- package/dist/workspace/workspace.js +4 -0
- package/dist/workspace/workspace.js.map +1 -1
- package/package.json +2 -2
- package/templates/init/rules/domain.md.tpl +1 -1
- package/templates/pipeline/package-scripts.json +1 -1
- package/templates/presets/identity/context/application/authorization/__context__.permissions.ts.tpl +23 -0
- package/templates/presets/identity/context/application/authorization/change-member-roles.policy.ts.tpl +17 -0
- package/templates/presets/identity/context/application/authorization/grant-delegations.policy.ts.tpl +17 -0
- package/templates/presets/identity/context/application/authorization/invite-members.policy.ts.tpl +17 -0
- package/templates/presets/identity/context/application/authorization/read-members.policy.ts.tpl +17 -0
- package/templates/presets/identity/context/application/authorization/remove-members.policy.ts.tpl +17 -0
- package/templates/presets/identity/context/application/authorization/revoke-delegations.policy.ts.tpl +17 -0
- package/templates/presets/identity/context/application/authorization/revoke-invitations.policy.ts.tpl +17 -0
- package/templates/presets/identity/context/application/commands/accept-invitation/accept-invitation.command.ts.tpl +14 -0
- package/templates/presets/identity/context/application/commands/accept-invitation/accept-invitation.handler.ts.tpl +56 -0
- package/templates/presets/identity/context/application/commands/change-member-role/change-member-role.command.ts.tpl +17 -0
- package/templates/presets/identity/context/application/commands/change-member-role/change-member-role.handler.ts.tpl +82 -0
- package/templates/presets/identity/context/application/commands/deactivate-account/deactivate-account.command.ts.tpl +7 -0
- package/templates/presets/identity/context/application/commands/deactivate-account/deactivate-account.handler.ts.tpl +69 -0
- package/templates/presets/identity/context/application/commands/decline-invitation/decline-invitation.command.ts.tpl +14 -0
- package/templates/presets/identity/context/application/commands/decline-invitation/decline-invitation.handler.ts.tpl +36 -0
- package/templates/presets/identity/context/application/commands/grant-delegation/grant-delegation.command.ts.tpl +21 -0
- package/templates/presets/identity/context/application/commands/grant-delegation/grant-delegation.handler.ts.tpl +43 -0
- package/templates/presets/identity/context/application/commands/invite-member/invite-member.command.ts.tpl +16 -0
- package/templates/presets/identity/context/application/commands/invite-member/invite-member.handler.ts.tpl +53 -0
- package/templates/presets/identity/context/application/commands/open-organisation/open-organisation.command.ts.tpl +14 -0
- package/templates/presets/identity/context/application/commands/open-organisation/open-organisation.handler.ts.tpl +50 -0
- package/templates/presets/identity/context/application/commands/provision-account/provision-account.command.ts.tpl +14 -0
- package/templates/presets/identity/context/application/commands/provision-account/provision-account.handler.ts.tpl +41 -0
- package/templates/presets/identity/context/application/commands/remove-member/remove-member.command.ts.tpl +15 -0
- package/templates/presets/identity/context/application/commands/remove-member/remove-member.handler.ts.tpl +79 -0
- package/templates/presets/identity/context/application/commands/revoke-delegation/revoke-delegation.command.ts.tpl +15 -0
- package/templates/presets/identity/context/application/commands/revoke-delegation/revoke-delegation.handler.ts.tpl +39 -0
- package/templates/presets/identity/context/application/commands/revoke-invitation/revoke-invitation.command.ts.tpl +15 -0
- package/templates/presets/identity/context/application/commands/revoke-invitation/revoke-invitation.handler.ts.tpl +42 -0
- package/templates/presets/identity/context/application/integration/handlers/account-deactivated.integration-handler.ts.tpl +19 -0
- package/templates/presets/identity/context/application/integration/handlers/member-joined.integration-handler.ts.tpl +33 -0
- package/templates/presets/identity/context/application/integration/handlers/member-removed.integration-handler.ts.tpl +30 -0
- package/templates/presets/identity/context/application/integration/handlers/organisation-opened.integration-handler.ts.tpl +19 -0
- package/templates/presets/identity/context/application/integration/publishers/account-deactivated.publisher.ts.tpl +24 -0
- package/templates/presets/identity/context/application/integration/publishers/delegation-granted.publisher.ts.tpl +36 -0
- package/templates/presets/identity/context/application/integration/publishers/delegation-revoked.publisher.ts.tpl +33 -0
- package/templates/presets/identity/context/application/integration/publishers/member-joined.publisher.ts.tpl +33 -0
- package/templates/presets/identity/context/application/integration/publishers/member-removed.publisher.ts.tpl +33 -0
- package/templates/presets/identity/context/application/integration/publishers/member-role-changed.publisher.ts.tpl +35 -0
- package/templates/presets/identity/context/application/integration/publishers/organisation-opened.publisher.ts.tpl +32 -0
- package/templates/presets/identity/context/application/ports/identity-provider-admin.port.ts.tpl +17 -0
- package/templates/presets/identity/context/application/ports/identity-provider-connection.port.ts.tpl +14 -0
- package/templates/presets/identity/context/application/ports/invitation-tokens.port.ts.tpl +7 -0
- package/templates/presets/identity/context/application/ports/search-members-reader.port.ts.tpl +10 -0
- package/templates/presets/identity/context/application/queries/search-members/search-members.handler.ts.tpl +33 -0
- package/templates/presets/identity/context/application/queries/search-members/search-members.query.ts.tpl +19 -0
- package/templates/presets/identity/context/application/queries/search-members/search-members.result.ts.tpl +17 -0
- package/templates/presets/identity/context/domain/aggregates/account.aggregate.ts.tpl +92 -0
- package/templates/presets/identity/context/domain/aggregates/delegation.aggregate.ts.tpl +117 -0
- package/templates/presets/identity/context/domain/aggregates/invitation.aggregate.ts.tpl +128 -0
- package/templates/presets/identity/context/domain/aggregates/member.aggregate.ts.tpl +149 -0
- package/templates/presets/identity/context/domain/aggregates/organisation.aggregate.ts.tpl +52 -0
- package/templates/presets/identity/context/domain/errors/account.error.ts.tpl +40 -0
- package/templates/presets/identity/context/domain/errors/delegation.error.ts.tpl +45 -0
- package/templates/presets/identity/context/domain/errors/invitation.error.ts.tpl +30 -0
- package/templates/presets/identity/context/domain/errors/member.error.ts.tpl +50 -0
- package/templates/presets/identity/context/domain/errors/organisation.error.ts.tpl +32 -0
- package/templates/presets/identity/context/domain/events/account-deactivated.event.ts.tpl +13 -0
- package/templates/presets/identity/context/domain/events/account-provisioned.event.ts.tpl +17 -0
- package/templates/presets/identity/context/domain/events/delegation-granted.event.ts.tpl +22 -0
- package/templates/presets/identity/context/domain/events/delegation-revoked.event.ts.tpl +18 -0
- package/templates/presets/identity/context/domain/events/invitation-accepted.event.ts.tpl +17 -0
- package/templates/presets/identity/context/domain/events/invitation-declined.event.ts.tpl +16 -0
- package/templates/presets/identity/context/domain/events/invitation-issued.event.ts.tpl +22 -0
- package/templates/presets/identity/context/domain/events/invitation-revoked.event.ts.tpl +16 -0
- package/templates/presets/identity/context/domain/events/member-joined.event.ts.tpl +19 -0
- package/templates/presets/identity/context/domain/events/member-removed.event.ts.tpl +19 -0
- package/templates/presets/identity/context/domain/events/member-role-changed.event.ts.tpl +22 -0
- package/templates/presets/identity/context/domain/events/organisation-opened.event.ts.tpl +17 -0
- package/templates/presets/identity/context/domain/repositories/account.repository.ts.tpl +5 -0
- package/templates/presets/identity/context/domain/repositories/delegation.repository.ts.tpl +10 -0
- package/templates/presets/identity/context/domain/repositories/invitation.repository.ts.tpl +7 -0
- package/templates/presets/identity/context/domain/repositories/member.repository.ts.tpl +13 -0
- package/templates/presets/identity/context/domain/repositories/organisation.repository.ts.tpl +5 -0
- package/templates/presets/identity/context/domain/services/role-rights.service.ts.tpl +59 -0
- package/templates/presets/identity/context/domain/value-objects/delegation-period.vo.ts.tpl +42 -0
- package/templates/presets/identity/context/domain/value-objects/display-name.vo.ts.tpl +29 -0
- package/templates/presets/identity/context/domain/value-objects/email-address.vo.ts.tpl +31 -0
- package/templates/presets/identity/context/domain/value-objects/organisation-name.vo.ts.tpl +29 -0
- package/templates/presets/identity/context/domain/value-objects/organisation-rights.vo.ts.tpl +43 -0
- package/templates/presets/identity/context/domain/value-objects/organisation-slug.vo.ts.tpl +30 -0
- package/templates/presets/identity/context/domain/vocabularies/account-status.vocabulary.ts.tpl +7 -0
- package/templates/presets/identity/context/domain/vocabularies/invitation-status.vocabulary.ts.tpl +9 -0
- package/templates/presets/identity/context/domain/vocabularies/member-right.vocabulary.ts.tpl +9 -0
- package/templates/presets/identity/context/domain/vocabularies/member-role.vocabulary.ts.tpl +8 -0
- package/templates/presets/identity/context/infrastructure/external/crypto-invitation-tokens.adapter.ts.tpl +20 -0
- package/templates/presets/identity/context/infrastructure/external/environment-identity-provider-connection.adapter.ts.tpl +37 -0
- package/templates/presets/identity/context/infrastructure/external/keycloak-identity-provider-admin.adapter.ts.tpl +149 -0
- package/templates/presets/identity/context/infrastructure/persistence/__context__.schema.drizzle.ts.tpl +102 -0
- package/templates/presets/identity/context/infrastructure/persistence/account-row.schema.knex.ts.tpl +15 -0
- package/templates/presets/identity/context/infrastructure/persistence/account.mapper.drizzle.ts.tpl +38 -0
- package/templates/presets/identity/context/infrastructure/persistence/account.mapper.knex.ts.tpl +33 -0
- package/templates/presets/identity/context/infrastructure/persistence/create-__context__-tables.schema.knex.ts.tpl +107 -0
- package/templates/presets/identity/context/infrastructure/persistence/delegation-row.schema.knex.ts.tpl +17 -0
- package/templates/presets/identity/context/infrastructure/persistence/delegation.mapper.drizzle.ts.tpl +50 -0
- package/templates/presets/identity/context/infrastructure/persistence/delegation.mapper.knex.ts.tpl +45 -0
- package/templates/presets/identity/context/infrastructure/persistence/drizzle-account.repository.drizzle.ts.tpl +59 -0
- package/templates/presets/identity/context/infrastructure/persistence/drizzle-delegation.repository.drizzle.ts.tpl +77 -0
- package/templates/presets/identity/context/infrastructure/persistence/drizzle-invitation.repository.drizzle.ts.tpl +65 -0
- package/templates/presets/identity/context/infrastructure/persistence/drizzle-member.repository.drizzle.ts.tpl +84 -0
- package/templates/presets/identity/context/infrastructure/persistence/drizzle-organisation.repository.drizzle.ts.tpl +59 -0
- package/templates/presets/identity/context/infrastructure/persistence/drizzle-search-members-reader.repository.drizzle.ts.tpl +53 -0
- package/templates/presets/identity/context/infrastructure/persistence/invitation-row.schema.knex.ts.tpl +20 -0
- package/templates/presets/identity/context/infrastructure/persistence/invitation.mapper.drizzle.ts.tpl +45 -0
- package/templates/presets/identity/context/infrastructure/persistence/invitation.mapper.knex.ts.tpl +40 -0
- package/templates/presets/identity/context/infrastructure/persistence/knex-account.repository.knex.ts.tpl +61 -0
- package/templates/presets/identity/context/infrastructure/persistence/knex-delegation.repository.knex.ts.tpl +80 -0
- package/templates/presets/identity/context/infrastructure/persistence/knex-invitation.repository.knex.ts.tpl +67 -0
- package/templates/presets/identity/context/infrastructure/persistence/knex-member.repository.knex.ts.tpl +82 -0
- package/templates/presets/identity/context/infrastructure/persistence/knex-organisation.repository.knex.ts.tpl +61 -0
- package/templates/presets/identity/context/infrastructure/persistence/knex-search-members-reader.repository.knex.ts.tpl +77 -0
- package/templates/presets/identity/context/infrastructure/persistence/member-row.schema.knex.ts.tpl +15 -0
- package/templates/presets/identity/context/infrastructure/persistence/member.mapper.drizzle.ts.tpl +36 -0
- package/templates/presets/identity/context/infrastructure/persistence/member.mapper.knex.ts.tpl +31 -0
- package/templates/presets/identity/context/infrastructure/persistence/organisation-row.schema.knex.ts.tpl +12 -0
- package/templates/presets/identity/context/infrastructure/persistence/organisation.mapper.drizzle.ts.tpl +28 -0
- package/templates/presets/identity/context/infrastructure/persistence/organisation.mapper.knex.ts.tpl +26 -0
- package/templates/presets/identity/context/presentation/http/accounts/deactivate-account/deactivate-account.accepted.class-validator.per-route.ts.tpl +6 -0
- package/templates/presets/identity/context/presentation/http/accounts/deactivate-account/deactivate-account.controller.ts.tpl +71 -0
- package/templates/presets/identity/context/presentation/http/accounts/provision-account/provision-account.accepted.class-validator.per-route.ts.tpl +6 -0
- package/templates/presets/identity/context/presentation/http/accounts/provision-account/provision-account.body.class-validator.ts.tpl +9 -0
- package/templates/presets/identity/context/presentation/http/accounts/provision-account/provision-account.controller.ts.tpl +85 -0
- package/templates/presets/identity/context/presentation/http/accounts.routes.ts.tpl +5 -0
- package/templates/presets/identity/context/presentation/http/invitations/accept-invitation/accept-invitation.accepted.class-validator.per-route.ts.tpl +6 -0
- package/templates/presets/identity/context/presentation/http/invitations/accept-invitation/accept-invitation.body.class-validator.per-route.ts.tpl +8 -0
- package/templates/presets/identity/context/presentation/http/invitations/accept-invitation/accept-invitation.controller.ts.tpl +100 -0
- package/templates/presets/identity/context/presentation/http/invitations/decline-invitation/decline-invitation.accepted.class-validator.per-route.ts.tpl +6 -0
- package/templates/presets/identity/context/presentation/http/invitations/decline-invitation/decline-invitation.body.class-validator.per-route.ts.tpl +8 -0
- package/templates/presets/identity/context/presentation/http/invitations/decline-invitation/decline-invitation.controller.ts.tpl +98 -0
- package/templates/presets/identity/context/presentation/http/invitations.routes.ts.tpl +5 -0
- package/templates/presets/identity/context/presentation/http/organisations/change-member-role/change-member-role.accepted.class-validator.per-route.ts.tpl +6 -0
- package/templates/presets/identity/context/presentation/http/organisations/change-member-role/change-member-role.body.class-validator.ts.tpl +7 -0
- package/templates/presets/identity/context/presentation/http/organisations/change-member-role/change-member-role.controller.ts.tpl +83 -0
- package/templates/presets/identity/context/presentation/http/organisations/change-member-role/change-member-role.params.class-validator.ts.tpl +11 -0
- package/templates/presets/identity/context/presentation/http/organisations/grant-delegation/grant-delegation.accepted.class-validator.per-route.ts.tpl +6 -0
- package/templates/presets/identity/context/presentation/http/organisations/grant-delegation/grant-delegation.body.class-validator.ts.tpl +18 -0
- package/templates/presets/identity/context/presentation/http/organisations/grant-delegation/grant-delegation.controller.ts.tpl +103 -0
- package/templates/presets/identity/context/presentation/http/organisations/grant-delegation/grant-delegation.params.class-validator.ts.tpl +7 -0
- package/templates/presets/identity/context/presentation/http/organisations/invite-member/invite-member.accepted.class-validator.ts.tpl +10 -0
- package/templates/presets/identity/context/presentation/http/organisations/invite-member/invite-member.body.class-validator.ts.tpl +10 -0
- package/templates/presets/identity/context/presentation/http/organisations/invite-member/invite-member.controller.ts.tpl +65 -0
- package/templates/presets/identity/context/presentation/http/organisations/invite-member/invite-member.params.class-validator.ts.tpl +7 -0
- package/templates/presets/identity/context/presentation/http/organisations/open-organisation/open-organisation.accepted.class-validator.per-route.ts.tpl +6 -0
- package/templates/presets/identity/context/presentation/http/organisations/open-organisation/open-organisation.body.class-validator.ts.tpl +12 -0
- package/templates/presets/identity/context/presentation/http/organisations/open-organisation/open-organisation.controller.ts.tpl +79 -0
- package/templates/presets/identity/context/presentation/http/organisations/remove-member/remove-member.accepted.class-validator.per-route.ts.tpl +6 -0
- package/templates/presets/identity/context/presentation/http/organisations/remove-member/remove-member.controller.ts.tpl +73 -0
- package/templates/presets/identity/context/presentation/http/organisations/remove-member/remove-member.params.class-validator.ts.tpl +11 -0
- package/templates/presets/identity/context/presentation/http/organisations/revoke-delegation/revoke-delegation.accepted.class-validator.per-route.ts.tpl +6 -0
- package/templates/presets/identity/context/presentation/http/organisations/revoke-delegation/revoke-delegation.controller.ts.tpl +73 -0
- package/templates/presets/identity/context/presentation/http/organisations/revoke-delegation/revoke-delegation.params.class-validator.ts.tpl +11 -0
- package/templates/presets/identity/context/presentation/http/organisations/revoke-invitation/revoke-invitation.accepted.class-validator.per-route.ts.tpl +6 -0
- package/templates/presets/identity/context/presentation/http/organisations/revoke-invitation/revoke-invitation.controller.ts.tpl +73 -0
- package/templates/presets/identity/context/presentation/http/organisations/revoke-invitation/revoke-invitation.params.class-validator.ts.tpl +11 -0
- package/templates/presets/identity/context/presentation/http/organisations/search-members/search-members.controller.ts.tpl +86 -0
- package/templates/presets/identity/context/presentation/http/organisations/search-members/search-members.line.class-validator.ts.tpl +22 -0
- package/templates/presets/identity/context/presentation/http/organisations/search-members/search-members.params.class-validator.ts.tpl +7 -0
- package/templates/presets/identity/context/presentation/http/organisations.routes.ts.tpl +5 -0
- package/templates/presets/identity/context/presentation/http/shared/invitation-token.schema.class-validator.shared.ts.tpl +9 -0
- package/templates/presets/identity/context/presentation/http/shared/invitation-token.schema.zod.shared.ts.tpl +9 -0
- package/templates/presets/identity/context/published-language/account-deactivated.v1.integration-event.ts.tpl +33 -0
- package/templates/presets/identity/context/published-language/account-deactivated.v1.payload.class-validator.ts.tpl +7 -0
- package/templates/presets/identity/context/published-language/delegation-granted.v1.integration-event.ts.tpl +39 -0
- package/templates/presets/identity/context/published-language/delegation-granted.v1.payload.class-validator.ts.tpl +28 -0
- package/templates/presets/identity/context/published-language/delegation-revoked.v1.integration-event.ts.tpl +36 -0
- package/templates/presets/identity/context/published-language/delegation-revoked.v1.payload.class-validator.ts.tpl +16 -0
- package/templates/presets/identity/context/published-language/member-joined.v1.integration-event.ts.tpl +36 -0
- package/templates/presets/identity/context/published-language/member-joined.v1.payload.class-validator.ts.tpl +16 -0
- package/templates/presets/identity/context/published-language/member-removed.v1.integration-event.ts.tpl +36 -0
- package/templates/presets/identity/context/published-language/member-removed.v1.payload.class-validator.ts.tpl +18 -0
- package/templates/presets/identity/context/published-language/member-role-changed.v1.integration-event.ts.tpl +38 -0
- package/templates/presets/identity/context/published-language/member-role-changed.v1.payload.class-validator.ts.tpl +24 -0
- package/templates/presets/identity/context/published-language/organisation-opened.v1.integration-event.ts.tpl +35 -0
- package/templates/presets/identity/context/published-language/organisation-opened.v1.payload.class-validator.ts.tpl +13 -0
- package/templates/presets/identity/context/test/builders/account.builder.ts.tpl +59 -0
- package/templates/presets/identity/context/test/builders/delegation.builder.ts.tpl +67 -0
- package/templates/presets/identity/context/test/builders/invitation.builder.ts.tpl +60 -0
- package/templates/presets/identity/context/test/builders/member.builder.ts.tpl +59 -0
- package/templates/presets/identity/context/test/builders/organisation.builder.ts.tpl +44 -0
- package/templates/presets/identity/context/test/fakes/account.repository.fake.ts.tpl +10 -0
- package/templates/presets/identity/context/test/fakes/delegation.repository.fake.ts.tpl +26 -0
- package/templates/presets/identity/context/test/fakes/identity-provider-admin.fake.ts.tpl +41 -0
- package/templates/presets/identity/context/test/fakes/invitation-tokens.fake.ts.tpl +18 -0
- package/templates/presets/identity/context/test/fakes/invitation.repository.fake.ts.tpl +14 -0
- package/templates/presets/identity/context/test/fakes/member.repository.fake.ts.tpl +29 -0
- package/templates/presets/identity/context/test/fakes/organisation.repository.fake.ts.tpl +10 -0
- package/templates/presets/identity/context/test/fakes/search-members-reader.fake.ts.tpl +25 -0
- package/templates/presets/identity/context/test/integration/account.repository.contract.spec.ts.tpl +48 -0
- package/templates/presets/identity/context/test/integration/delegation.repository.contract.spec.ts.tpl +84 -0
- package/templates/presets/identity/context/test/integration/invitation.repository.contract.spec.ts.tpl +76 -0
- package/templates/presets/identity/context/test/integration/keycloak-identity-provider-admin.adapter.spec.ts.tpl +123 -0
- package/templates/presets/identity/context/test/integration/member.repository.contract.spec.ts.tpl +92 -0
- package/templates/presets/identity/context/test/integration/organisation.repository.contract.spec.ts.tpl +46 -0
- package/templates/presets/identity/context/test/integration/search-members-reader.spec.ts.tpl +86 -0
- package/templates/presets/identity/context/test/unit/accept-invitation.controller.spec.ts.tpl +57 -0
- package/templates/presets/identity/context/test/unit/accept-invitation.handler.spec.ts.tpl +69 -0
- package/templates/presets/identity/context/test/unit/account-deactivated.integration-handler.spec.ts.tpl +24 -0
- package/templates/presets/identity/context/test/unit/account-deactivated.publisher.spec.ts.tpl +25 -0
- package/templates/presets/identity/context/test/unit/account.aggregate.spec.ts.tpl +72 -0
- package/templates/presets/identity/context/test/unit/change-member-role.controller.spec.ts.tpl +57 -0
- package/templates/presets/identity/context/test/unit/change-member-role.handler.spec.ts.tpl +135 -0
- package/templates/presets/identity/context/test/unit/crypto-invitation-tokens.adapter.spec.ts.tpl +15 -0
- package/templates/presets/identity/context/test/unit/deactivate-account.controller.spec.ts.tpl +44 -0
- package/templates/presets/identity/context/test/unit/deactivate-account.handler.spec.ts.tpl +106 -0
- package/templates/presets/identity/context/test/unit/decline-invitation.controller.spec.ts.tpl +57 -0
- package/templates/presets/identity/context/test/unit/decline-invitation.handler.spec.ts.tpl +40 -0
- package/templates/presets/identity/context/test/unit/delegation-granted.publisher.spec.ts.tpl +36 -0
- package/templates/presets/identity/context/test/unit/delegation-period.vo.spec.ts.tpl +32 -0
- package/templates/presets/identity/context/test/unit/delegation-revoked.publisher.spec.ts.tpl +35 -0
- package/templates/presets/identity/context/test/unit/delegation.aggregate.spec.ts.tpl +111 -0
- package/templates/presets/identity/context/test/unit/display-name.vo.spec.ts.tpl +13 -0
- package/templates/presets/identity/context/test/unit/email-address.vo.spec.ts.tpl +24 -0
- package/templates/presets/identity/context/test/unit/environment-identity-provider-connection.adapter.spec.ts.tpl +41 -0
- package/templates/presets/identity/context/test/unit/grant-delegation.controller.spec.ts.tpl +57 -0
- package/templates/presets/identity/context/test/unit/grant-delegation.handler.spec.ts.tpl +66 -0
- package/templates/presets/identity/context/test/unit/identity-application.ts.tpl +79 -0
- package/templates/presets/identity/context/test/unit/invitation.aggregate.spec.ts.tpl +118 -0
- package/templates/presets/identity/context/test/unit/invite-member.controller.spec.ts.tpl +57 -0
- package/templates/presets/identity/context/test/unit/invite-member.handler.spec.ts.tpl +110 -0
- package/templates/presets/identity/context/test/unit/member-joined.integration-handler.spec.ts.tpl +38 -0
- package/templates/presets/identity/context/test/unit/member-joined.publisher.spec.ts.tpl +36 -0
- package/templates/presets/identity/context/test/unit/member-removed.integration-handler.spec.ts.tpl +45 -0
- package/templates/presets/identity/context/test/unit/member-removed.publisher.spec.ts.tpl +35 -0
- package/templates/presets/identity/context/test/unit/member-role-changed.publisher.spec.ts.tpl +36 -0
- package/templates/presets/identity/context/test/unit/member.aggregate.spec.ts.tpl +142 -0
- package/templates/presets/identity/context/test/unit/open-organisation.controller.spec.ts.tpl +57 -0
- package/templates/presets/identity/context/test/unit/open-organisation.handler.spec.ts.tpl +52 -0
- package/templates/presets/identity/context/test/unit/organisation-name.vo.spec.ts.tpl +13 -0
- package/templates/presets/identity/context/test/unit/organisation-opened.integration-handler.spec.ts.tpl +24 -0
- package/templates/presets/identity/context/test/unit/organisation-opened.publisher.spec.ts.tpl +35 -0
- package/templates/presets/identity/context/test/unit/organisation-rights.vo.spec.ts.tpl +23 -0
- package/templates/presets/identity/context/test/unit/organisation-slug.vo.spec.ts.tpl +17 -0
- package/templates/presets/identity/context/test/unit/organisation.aggregate.spec.ts.tpl +33 -0
- package/templates/presets/identity/context/test/unit/provision-account.controller.spec.ts.tpl +73 -0
- package/templates/presets/identity/context/test/unit/provision-account.handler.spec.ts.tpl +65 -0
- package/templates/presets/identity/context/test/unit/remove-member.controller.spec.ts.tpl +44 -0
- package/templates/presets/identity/context/test/unit/remove-member.handler.spec.ts.tpl +125 -0
- package/templates/presets/identity/context/test/unit/revoke-delegation.controller.spec.ts.tpl +44 -0
- package/templates/presets/identity/context/test/unit/revoke-delegation.handler.spec.ts.tpl +51 -0
- package/templates/presets/identity/context/test/unit/revoke-invitation.controller.spec.ts.tpl +44 -0
- package/templates/presets/identity/context/test/unit/revoke-invitation.handler.spec.ts.tpl +44 -0
- package/templates/presets/identity/context/test/unit/role-rights.service.spec.ts.tpl +54 -0
- package/templates/presets/identity/context/test/unit/search-members.controller.spec.ts.tpl +43 -0
- package/templates/presets/identity/context/test/unit/search-members.handler.spec.ts.tpl +38 -0
- package/templates/presets/identity/decision.md.tpl +37 -0
- package/templates/presets/identity/design.md.tpl +71 -0
- package/templates/presets/signed-in-grants.ts.tpl +12 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Organisation } from '{{alias.context}}/domain/aggregates/organisation.aggregate{{alias.ext}}';
|
|
2
|
+
import { OrganisationName } from '{{alias.context}}/domain/value-objects/organisation-name.vo{{alias.ext}}';
|
|
3
|
+
import type {
|
|
4
|
+
OrganisationColumns,
|
|
5
|
+
OrganisationRow,
|
|
6
|
+
} from '{{alias.context}}/infrastructure/persistence/organisation-row.schema{{alias.ext}}';
|
|
7
|
+
|
|
8
|
+
export const OrganisationMapper = {
|
|
9
|
+
toDomain(row: OrganisationRow): Organisation {
|
|
10
|
+
const loaded = Organisation.rehydrate(row.id, {
|
|
11
|
+
name: OrganisationName.create(row.name),
|
|
12
|
+
openedBy: row.opened_by,
|
|
13
|
+
openedAt: row.opened_at,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
loaded.version = row.version;
|
|
17
|
+
|
|
18
|
+
return loaded;
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
toRow(saved: Organisation): OrganisationColumns {
|
|
22
|
+
const state = saved.toState();
|
|
23
|
+
|
|
24
|
+
return { id: saved.id, name: state.name.value, opened_by: state.openedBy, opened_at: state.openedAt };
|
|
25
|
+
},
|
|
26
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{{#if validation.classValidator}}
|
|
2
|
+
{{#if schemas.shared}}
|
|
3
|
+
import { acceptedSchema, Controller, type Accepted, type HttpRequest } from '@ddd-ts-kit/http';
|
|
4
|
+
{{/if}}
|
|
5
|
+
{{#if schemas.perRoute}}
|
|
6
|
+
import { Controller, type HttpRequest } from '@ddd-ts-kit/http';
|
|
7
|
+
{{/if}}
|
|
8
|
+
import type { CommandBus } from '@ddd-ts-kit/kernel';
|
|
9
|
+
{{#if schemas.perRoute}}
|
|
10
|
+
import { classSchema } from '@ddd-ts-kit/validation/class-validator';
|
|
11
|
+
{{/if}}
|
|
12
|
+
import { DeactivateAccountCommand } from '{{alias.context}}/application/commands/deactivate-account/deactivate-account.command{{alias.ext}}';
|
|
13
|
+
{{#if schemas.perRoute}}
|
|
14
|
+
import { DeactivateAccountAccepted } from '{{alias.context}}/presentation/http/accounts/deactivate-account/deactivate-account.accepted{{alias.ext}}';
|
|
15
|
+
{{/if}}
|
|
16
|
+
import { AccountsRoutes } from '{{alias.context}}/presentation/http/accounts.routes{{alias.ext}}';
|
|
17
|
+
{{/if}}
|
|
18
|
+
{{#if validation.zod}}
|
|
19
|
+
{{#if schemas.perRoute}}
|
|
20
|
+
import { z } from 'zod';
|
|
21
|
+
{{/if}}
|
|
22
|
+
{{#if schemas.shared}}
|
|
23
|
+
import { acceptedSchema, Controller, type Accepted, type HttpRequest } from '@ddd-ts-kit/http';
|
|
24
|
+
{{/if}}
|
|
25
|
+
{{#if schemas.perRoute}}
|
|
26
|
+
import { Controller, type HttpRequest } from '@ddd-ts-kit/http';
|
|
27
|
+
{{/if}}
|
|
28
|
+
import type { CommandBus } from '@ddd-ts-kit/kernel';
|
|
29
|
+
{{#if schemas.perRoute}}
|
|
30
|
+
import type { Infer } from '@ddd-ts-kit/validation';
|
|
31
|
+
{{/if}}
|
|
32
|
+
{{#if schemas.perRoute}}
|
|
33
|
+
import { zodSchema } from '@ddd-ts-kit/validation/zod';
|
|
34
|
+
{{/if}}
|
|
35
|
+
import { DeactivateAccountCommand } from '{{alias.context}}/application/commands/deactivate-account/deactivate-account.command{{alias.ext}}';
|
|
36
|
+
import { AccountsRoutes } from '{{alias.context}}/presentation/http/accounts.routes{{alias.ext}}';
|
|
37
|
+
{{/if}}
|
|
38
|
+
|
|
39
|
+
{{#if validation.classValidator}}
|
|
40
|
+
{{#if schemas.perRoute}}
|
|
41
|
+
const accepted = classSchema(DeactivateAccountAccepted);
|
|
42
|
+
{{/if}}
|
|
43
|
+
{{/if}}
|
|
44
|
+
{{#if validation.zod}}
|
|
45
|
+
{{#if schemas.perRoute}}
|
|
46
|
+
const accepted = zodSchema(z.object({ id: z.string() }), { io: 'output' });
|
|
47
|
+
{{/if}}
|
|
48
|
+
{{/if}}
|
|
49
|
+
|
|
50
|
+
@Controller({
|
|
51
|
+
group: AccountsRoutes,
|
|
52
|
+
method: 'POST',
|
|
53
|
+
path: '/me/deactivation',
|
|
54
|
+
summary: 'Deactivate my account',
|
|
55
|
+
response: { status: 200, description: 'The account is deactivated; the body carries its identifier.', body: {{#if schemas.shared}}acceptedSchema{{/if}}{{#if schemas.perRoute}}accepted{{/if}} },
|
|
56
|
+
errors: ['ACCOUNT_NOT_FOUND', 'ACCOUNT_ALREADY_DEACTIVATED', 'ORGANISATION_NOT_FOUND', 'LAST_OWNER'],
|
|
57
|
+
})
|
|
58
|
+
export class DeactivateAccountController {
|
|
59
|
+
constructor(private readonly commands: CommandBus) {}
|
|
60
|
+
|
|
61
|
+
{{#if validation.classValidator}}
|
|
62
|
+
async handle(request: HttpRequest<object>): Promise<{{#if schemas.shared}}Accepted{{/if}}{{#if schemas.perRoute}}DeactivateAccountAccepted{{/if}}> {
|
|
63
|
+
{{/if}}
|
|
64
|
+
{{#if validation.zod}}
|
|
65
|
+
async handle(request: HttpRequest<object>): Promise<{{#if schemas.shared}}Accepted{{/if}}{{#if schemas.perRoute}}Infer<typeof accepted>{{/if}}> {
|
|
66
|
+
{{/if}}
|
|
67
|
+
const id = await this.commands.execute(new DeactivateAccountCommand(request.actor));
|
|
68
|
+
|
|
69
|
+
return { id };
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IsNotEmpty, IsOptional, IsString } from 'class-validator';
|
|
2
|
+
|
|
3
|
+
export class ProvisionAccountBody {
|
|
4
|
+
/** Left out, the name the token gives; the email address is always the one of the token. */
|
|
5
|
+
@IsOptional()
|
|
6
|
+
@IsString()
|
|
7
|
+
@IsNotEmpty()
|
|
8
|
+
displayName?: string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{{#if validation.classValidator}}
|
|
2
|
+
{{#if schemas.shared}}
|
|
3
|
+
import { acceptedSchema, Controller, type Accepted, type HttpRequest } from '@ddd-ts-kit/http';
|
|
4
|
+
{{/if}}
|
|
5
|
+
{{#if schemas.perRoute}}
|
|
6
|
+
import { Controller, type HttpRequest } from '@ddd-ts-kit/http';
|
|
7
|
+
{{/if}}
|
|
8
|
+
import type { Actor, CommandBus } from '@ddd-ts-kit/kernel';
|
|
9
|
+
import { classSchema } from '@ddd-ts-kit/validation/class-validator';
|
|
10
|
+
import { ProvisionAccountCommand } from '{{alias.context}}/application/commands/provision-account/provision-account.command{{alias.ext}}';
|
|
11
|
+
import { ProvisionAccountBody } from '{{alias.context}}/presentation/http/accounts/provision-account/provision-account.body{{alias.ext}}';
|
|
12
|
+
{{#if schemas.perRoute}}
|
|
13
|
+
import { ProvisionAccountAccepted } from '{{alias.context}}/presentation/http/accounts/provision-account/provision-account.accepted{{alias.ext}}';
|
|
14
|
+
{{/if}}
|
|
15
|
+
import { AccountsRoutes } from '{{alias.context}}/presentation/http/accounts.routes{{alias.ext}}';
|
|
16
|
+
{{/if}}
|
|
17
|
+
{{#if validation.zod}}
|
|
18
|
+
import { z } from 'zod';
|
|
19
|
+
{{#if schemas.shared}}
|
|
20
|
+
import { acceptedSchema, Controller, type Accepted, type HttpRequest } from '@ddd-ts-kit/http';
|
|
21
|
+
{{/if}}
|
|
22
|
+
{{#if schemas.perRoute}}
|
|
23
|
+
import { Controller, type HttpRequest } from '@ddd-ts-kit/http';
|
|
24
|
+
{{/if}}
|
|
25
|
+
import type { Actor, CommandBus } from '@ddd-ts-kit/kernel';
|
|
26
|
+
import type { Infer } from '@ddd-ts-kit/validation';
|
|
27
|
+
import { zodSchema } from '@ddd-ts-kit/validation/zod';
|
|
28
|
+
import { ProvisionAccountCommand } from '{{alias.context}}/application/commands/provision-account/provision-account.command{{alias.ext}}';
|
|
29
|
+
import { AccountsRoutes } from '{{alias.context}}/presentation/http/accounts.routes{{alias.ext}}';
|
|
30
|
+
{{/if}}
|
|
31
|
+
|
|
32
|
+
{{#if validation.classValidator}}
|
|
33
|
+
const body = classSchema(ProvisionAccountBody);
|
|
34
|
+
{{#if schemas.perRoute}}
|
|
35
|
+
const accepted = classSchema(ProvisionAccountAccepted);
|
|
36
|
+
{{/if}}
|
|
37
|
+
{{/if}}
|
|
38
|
+
{{#if validation.zod}}
|
|
39
|
+
const body = zodSchema(
|
|
40
|
+
z.object({
|
|
41
|
+
displayName: z.string().min(1).optional(),
|
|
42
|
+
}),
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
{{#if schemas.perRoute}}
|
|
46
|
+
const accepted = zodSchema(z.object({ id: z.string() }), { io: 'output' });
|
|
47
|
+
{{/if}}
|
|
48
|
+
{{/if}}
|
|
49
|
+
|
|
50
|
+
@Controller({
|
|
51
|
+
group: AccountsRoutes,
|
|
52
|
+
method: 'PUT',
|
|
53
|
+
path: '/me',
|
|
54
|
+
summary: 'Provision my account',
|
|
55
|
+
body,
|
|
56
|
+
response: { status: 200, description: 'The account, provisioned or refreshed; the body carries its identifier.', body: {{#if schemas.shared}}acceptedSchema{{/if}}{{#if schemas.perRoute}}accepted{{/if}} },
|
|
57
|
+
errors: ['EMAIL_NOT_VERIFIED', 'INVALID_EMAIL_ADDRESS', 'INVALID_DISPLAY_NAME', 'ACCOUNT_DEACTIVATED'],
|
|
58
|
+
})
|
|
59
|
+
export class ProvisionAccountController {
|
|
60
|
+
constructor(private readonly commands: CommandBus) {}
|
|
61
|
+
|
|
62
|
+
{{#if validation.classValidator}}
|
|
63
|
+
async handle(request: HttpRequest<{ body: ProvisionAccountBody }>): Promise<{{#if schemas.shared}}Accepted{{/if}}{{#if schemas.perRoute}}ProvisionAccountAccepted{{/if}}> {
|
|
64
|
+
{{/if}}
|
|
65
|
+
{{#if validation.zod}}
|
|
66
|
+
async handle(request: HttpRequest<{ body: Infer<typeof body> }>): Promise<{{#if schemas.shared}}Accepted{{/if}}{{#if schemas.perRoute}}Infer<typeof accepted>{{/if}}> {
|
|
67
|
+
{{/if}}
|
|
68
|
+
const id = await this.commands.execute(new ProvisionAccountCommand(request.actor, profileOf(request.actor, request.body.displayName)));
|
|
69
|
+
|
|
70
|
+
return { id };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The token is the authority on who the person is: their address comes from it, never from the
|
|
76
|
+
* body, and with whether the provider verified it (`email_verified`), so that nobody accepts an
|
|
77
|
+
* invitation sent to someone else by registering their address unverified.
|
|
78
|
+
*/
|
|
79
|
+
function profileOf(actor: Actor, displayName: string | undefined): ProvisionAccountCommand['profile'] {
|
|
80
|
+
const { email, emailVerified, username } = actor.attributes;
|
|
81
|
+
const address = typeof email === 'string' ? email : '';
|
|
82
|
+
const named = displayName ?? (typeof username === 'string' ? username : address);
|
|
83
|
+
|
|
84
|
+
return { email: address, emailVerified: emailVerified === true, displayName: named };
|
|
85
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Authenticated, RouteGroup } from '@ddd-ts-kit/http';
|
|
2
|
+
|
|
3
|
+
/** The account of the person who calls: every route is about the caller, named by their token. */
|
|
4
|
+
@RouteGroup({ prefix: '/accounts', tags: ['{{context.kebab}}'], guards: [Authenticated], errors: ['FORBIDDEN'] })
|
|
5
|
+
export class AccountsRoutes {}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
{{#if validation.classValidator}}
|
|
2
|
+
{{#if schemas.shared}}
|
|
3
|
+
import { acceptedSchema, Controller, type Accepted, type HttpRequest } from '@ddd-ts-kit/http';
|
|
4
|
+
{{/if}}
|
|
5
|
+
{{#if schemas.perRoute}}
|
|
6
|
+
import { Controller, type HttpRequest } from '@ddd-ts-kit/http';
|
|
7
|
+
{{/if}}
|
|
8
|
+
import type { CommandBus } from '@ddd-ts-kit/kernel';
|
|
9
|
+
import { classSchema } from '@ddd-ts-kit/validation/class-validator';
|
|
10
|
+
import { AcceptInvitationCommand } from '{{alias.context}}/application/commands/accept-invitation/accept-invitation.command{{alias.ext}}';
|
|
11
|
+
{{#if schemas.shared}}
|
|
12
|
+
import { InvitationToken } from '{{alias.context}}/presentation/http/shared/invitation-token.schema{{alias.ext}}';
|
|
13
|
+
{{/if}}
|
|
14
|
+
{{#if schemas.perRoute}}
|
|
15
|
+
import { AcceptInvitationBody } from '{{alias.context}}/presentation/http/invitations/accept-invitation/accept-invitation.body{{alias.ext}}';
|
|
16
|
+
{{/if}}
|
|
17
|
+
{{#if schemas.perRoute}}
|
|
18
|
+
import { AcceptInvitationAccepted } from '{{alias.context}}/presentation/http/invitations/accept-invitation/accept-invitation.accepted{{alias.ext}}';
|
|
19
|
+
{{/if}}
|
|
20
|
+
import { InvitationsRoutes } from '{{alias.context}}/presentation/http/invitations.routes{{alias.ext}}';
|
|
21
|
+
{{/if}}
|
|
22
|
+
{{#if validation.zod}}
|
|
23
|
+
{{#if schemas.perRoute}}
|
|
24
|
+
import { z } from 'zod';
|
|
25
|
+
{{/if}}
|
|
26
|
+
{{#if schemas.shared}}
|
|
27
|
+
import { acceptedSchema, Controller, type Accepted, type HttpRequest } from '@ddd-ts-kit/http';
|
|
28
|
+
{{/if}}
|
|
29
|
+
{{#if schemas.perRoute}}
|
|
30
|
+
import { Controller, type HttpRequest } from '@ddd-ts-kit/http';
|
|
31
|
+
{{/if}}
|
|
32
|
+
import type { CommandBus } from '@ddd-ts-kit/kernel';
|
|
33
|
+
import type { Infer } from '@ddd-ts-kit/validation';
|
|
34
|
+
import { zodSchema } from '@ddd-ts-kit/validation/zod';
|
|
35
|
+
import { AcceptInvitationCommand } from '{{alias.context}}/application/commands/accept-invitation/accept-invitation.command{{alias.ext}}';
|
|
36
|
+
{{#if schemas.shared}}
|
|
37
|
+
import { invitationTokenSchema } from '{{alias.context}}/presentation/http/shared/invitation-token.schema{{alias.ext}}';
|
|
38
|
+
{{/if}}
|
|
39
|
+
import { InvitationsRoutes } from '{{alias.context}}/presentation/http/invitations.routes{{alias.ext}}';
|
|
40
|
+
{{/if}}
|
|
41
|
+
|
|
42
|
+
{{#if validation.classValidator}}
|
|
43
|
+
{{#if schemas.shared}}
|
|
44
|
+
const body = classSchema(InvitationToken, { shared: true });
|
|
45
|
+
{{/if}}
|
|
46
|
+
{{#if schemas.perRoute}}
|
|
47
|
+
const body = classSchema(AcceptInvitationBody);
|
|
48
|
+
{{/if}}
|
|
49
|
+
{{#if schemas.perRoute}}
|
|
50
|
+
const accepted = classSchema(AcceptInvitationAccepted);
|
|
51
|
+
{{/if}}
|
|
52
|
+
{{/if}}
|
|
53
|
+
{{#if validation.zod}}
|
|
54
|
+
{{#if schemas.shared}}
|
|
55
|
+
const body = zodSchema(invitationTokenSchema);
|
|
56
|
+
{{/if}}
|
|
57
|
+
{{#if schemas.perRoute}}
|
|
58
|
+
const body = zodSchema(
|
|
59
|
+
z.object({
|
|
60
|
+
token: z.string().min(1),
|
|
61
|
+
}),
|
|
62
|
+
);
|
|
63
|
+
{{/if}}
|
|
64
|
+
|
|
65
|
+
{{#if schemas.perRoute}}
|
|
66
|
+
const accepted = zodSchema(z.object({ id: z.string() }), { io: 'output' });
|
|
67
|
+
{{/if}}
|
|
68
|
+
{{/if}}
|
|
69
|
+
|
|
70
|
+
@Controller({
|
|
71
|
+
group: InvitationsRoutes,
|
|
72
|
+
method: 'POST',
|
|
73
|
+
path: '/acceptance',
|
|
74
|
+
summary: 'Accept an invitation',
|
|
75
|
+
body,
|
|
76
|
+
response: { status: 200, description: 'Accepted; the caller is a member, the body carries the identifier of the invitation.', body: {{#if schemas.shared}}acceptedSchema{{/if}}{{#if schemas.perRoute}}accepted{{/if}} },
|
|
77
|
+
errors: [
|
|
78
|
+
'INVITATION_NOT_FOUND',
|
|
79
|
+
'ACCOUNT_NOT_FOUND',
|
|
80
|
+
'ACCOUNT_DEACTIVATED',
|
|
81
|
+
'INVITATION_NOT_PENDING',
|
|
82
|
+
'INVITATION_EXPIRED',
|
|
83
|
+
'INVITATION_ADDRESSED_TO_ANOTHER',
|
|
84
|
+
'ALREADY_MEMBER',
|
|
85
|
+
],
|
|
86
|
+
})
|
|
87
|
+
export class AcceptInvitationController {
|
|
88
|
+
constructor(private readonly commands: CommandBus) {}
|
|
89
|
+
|
|
90
|
+
{{#if validation.classValidator}}
|
|
91
|
+
async handle(request: HttpRequest<{ body: {{#if schemas.shared}}InvitationToken{{/if}}{{#if schemas.perRoute}}AcceptInvitationBody{{/if}} }>): Promise<{{#if schemas.shared}}Accepted{{/if}}{{#if schemas.perRoute}}AcceptInvitationAccepted{{/if}}> {
|
|
92
|
+
{{/if}}
|
|
93
|
+
{{#if validation.zod}}
|
|
94
|
+
async handle(request: HttpRequest<{ body: Infer<typeof body> }>): Promise<{{#if schemas.shared}}Accepted{{/if}}{{#if schemas.perRoute}}Infer<typeof accepted>{{/if}}> {
|
|
95
|
+
{{/if}}
|
|
96
|
+
const id = await this.commands.execute(new AcceptInvitationCommand(request.actor, request.body.token));
|
|
97
|
+
|
|
98
|
+
return { id };
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
{{#if validation.classValidator}}
|
|
2
|
+
{{#if schemas.shared}}
|
|
3
|
+
import { acceptedSchema, Controller, type Accepted, type HttpRequest } from '@ddd-ts-kit/http';
|
|
4
|
+
{{/if}}
|
|
5
|
+
{{#if schemas.perRoute}}
|
|
6
|
+
import { Controller, type HttpRequest } from '@ddd-ts-kit/http';
|
|
7
|
+
{{/if}}
|
|
8
|
+
import type { CommandBus } from '@ddd-ts-kit/kernel';
|
|
9
|
+
import { classSchema } from '@ddd-ts-kit/validation/class-validator';
|
|
10
|
+
import { DeclineInvitationCommand } from '{{alias.context}}/application/commands/decline-invitation/decline-invitation.command{{alias.ext}}';
|
|
11
|
+
{{#if schemas.shared}}
|
|
12
|
+
import { InvitationToken } from '{{alias.context}}/presentation/http/shared/invitation-token.schema{{alias.ext}}';
|
|
13
|
+
{{/if}}
|
|
14
|
+
{{#if schemas.perRoute}}
|
|
15
|
+
import { DeclineInvitationBody } from '{{alias.context}}/presentation/http/invitations/decline-invitation/decline-invitation.body{{alias.ext}}';
|
|
16
|
+
{{/if}}
|
|
17
|
+
{{#if schemas.perRoute}}
|
|
18
|
+
import { DeclineInvitationAccepted } from '{{alias.context}}/presentation/http/invitations/decline-invitation/decline-invitation.accepted{{alias.ext}}';
|
|
19
|
+
{{/if}}
|
|
20
|
+
import { InvitationsRoutes } from '{{alias.context}}/presentation/http/invitations.routes{{alias.ext}}';
|
|
21
|
+
{{/if}}
|
|
22
|
+
{{#if validation.zod}}
|
|
23
|
+
{{#if schemas.perRoute}}
|
|
24
|
+
import { z } from 'zod';
|
|
25
|
+
{{/if}}
|
|
26
|
+
{{#if schemas.shared}}
|
|
27
|
+
import { acceptedSchema, Controller, type Accepted, type HttpRequest } from '@ddd-ts-kit/http';
|
|
28
|
+
{{/if}}
|
|
29
|
+
{{#if schemas.perRoute}}
|
|
30
|
+
import { Controller, type HttpRequest } from '@ddd-ts-kit/http';
|
|
31
|
+
{{/if}}
|
|
32
|
+
import type { CommandBus } from '@ddd-ts-kit/kernel';
|
|
33
|
+
import type { Infer } from '@ddd-ts-kit/validation';
|
|
34
|
+
import { zodSchema } from '@ddd-ts-kit/validation/zod';
|
|
35
|
+
import { DeclineInvitationCommand } from '{{alias.context}}/application/commands/decline-invitation/decline-invitation.command{{alias.ext}}';
|
|
36
|
+
{{#if schemas.shared}}
|
|
37
|
+
import { invitationTokenSchema } from '{{alias.context}}/presentation/http/shared/invitation-token.schema{{alias.ext}}';
|
|
38
|
+
{{/if}}
|
|
39
|
+
import { InvitationsRoutes } from '{{alias.context}}/presentation/http/invitations.routes{{alias.ext}}';
|
|
40
|
+
{{/if}}
|
|
41
|
+
|
|
42
|
+
{{#if validation.classValidator}}
|
|
43
|
+
{{#if schemas.shared}}
|
|
44
|
+
const body = classSchema(InvitationToken, { shared: true });
|
|
45
|
+
{{/if}}
|
|
46
|
+
{{#if schemas.perRoute}}
|
|
47
|
+
const body = classSchema(DeclineInvitationBody);
|
|
48
|
+
{{/if}}
|
|
49
|
+
{{#if schemas.perRoute}}
|
|
50
|
+
const accepted = classSchema(DeclineInvitationAccepted);
|
|
51
|
+
{{/if}}
|
|
52
|
+
{{/if}}
|
|
53
|
+
{{#if validation.zod}}
|
|
54
|
+
{{#if schemas.shared}}
|
|
55
|
+
const body = zodSchema(invitationTokenSchema);
|
|
56
|
+
{{/if}}
|
|
57
|
+
{{#if schemas.perRoute}}
|
|
58
|
+
const body = zodSchema(
|
|
59
|
+
z.object({
|
|
60
|
+
token: z.string().min(1),
|
|
61
|
+
}),
|
|
62
|
+
);
|
|
63
|
+
{{/if}}
|
|
64
|
+
|
|
65
|
+
{{#if schemas.perRoute}}
|
|
66
|
+
const accepted = zodSchema(z.object({ id: z.string() }), { io: 'output' });
|
|
67
|
+
{{/if}}
|
|
68
|
+
{{/if}}
|
|
69
|
+
|
|
70
|
+
@Controller({
|
|
71
|
+
group: InvitationsRoutes,
|
|
72
|
+
method: 'POST',
|
|
73
|
+
path: '/declination',
|
|
74
|
+
summary: 'Decline an invitation',
|
|
75
|
+
body,
|
|
76
|
+
response: { status: 200, description: 'Declined; the body carries the identifier of the invitation.', body: {{#if schemas.shared}}acceptedSchema{{/if}}{{#if schemas.perRoute}}accepted{{/if}} },
|
|
77
|
+
errors: [
|
|
78
|
+
'INVITATION_NOT_FOUND',
|
|
79
|
+
'ACCOUNT_NOT_FOUND',
|
|
80
|
+
'INVITATION_NOT_PENDING',
|
|
81
|
+
'INVITATION_EXPIRED',
|
|
82
|
+
'INVITATION_ADDRESSED_TO_ANOTHER',
|
|
83
|
+
],
|
|
84
|
+
})
|
|
85
|
+
export class DeclineInvitationController {
|
|
86
|
+
constructor(private readonly commands: CommandBus) {}
|
|
87
|
+
|
|
88
|
+
{{#if validation.classValidator}}
|
|
89
|
+
async handle(request: HttpRequest<{ body: {{#if schemas.shared}}InvitationToken{{/if}}{{#if schemas.perRoute}}DeclineInvitationBody{{/if}} }>): Promise<{{#if schemas.shared}}Accepted{{/if}}{{#if schemas.perRoute}}DeclineInvitationAccepted{{/if}}> {
|
|
90
|
+
{{/if}}
|
|
91
|
+
{{#if validation.zod}}
|
|
92
|
+
async handle(request: HttpRequest<{ body: Infer<typeof body> }>): Promise<{{#if schemas.shared}}Accepted{{/if}}{{#if schemas.perRoute}}Infer<typeof accepted>{{/if}}> {
|
|
93
|
+
{{/if}}
|
|
94
|
+
const id = await this.commands.execute(new DeclineInvitationCommand(request.actor, request.body.token));
|
|
95
|
+
|
|
96
|
+
return { id };
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Authenticated, RouteGroup } from '@ddd-ts-kit/http';
|
|
2
|
+
|
|
3
|
+
/** The answers of a person to an invitation sent to them, by its token. */
|
|
4
|
+
@RouteGroup({ prefix: '/invitations', tags: ['{{context.kebab}}'], guards: [Authenticated], errors: ['FORBIDDEN'] })
|
|
5
|
+
export class InvitationsRoutes {}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{{#if validation.classValidator}}
|
|
2
|
+
{{#if schemas.shared}}
|
|
3
|
+
import { acceptedSchema, Controller, type Accepted, type HttpRequest } from '@ddd-ts-kit/http';
|
|
4
|
+
{{/if}}
|
|
5
|
+
{{#if schemas.perRoute}}
|
|
6
|
+
import { Controller, type HttpRequest } from '@ddd-ts-kit/http';
|
|
7
|
+
{{/if}}
|
|
8
|
+
import type { CommandBus } from '@ddd-ts-kit/kernel';
|
|
9
|
+
import { classSchema } from '@ddd-ts-kit/validation/class-validator';
|
|
10
|
+
import { ChangeMemberRoleCommand } from '{{alias.context}}/application/commands/change-member-role/change-member-role.command{{alias.ext}}';
|
|
11
|
+
import { ChangeMemberRoleParams } from '{{alias.context}}/presentation/http/organisations/change-member-role/change-member-role.params{{alias.ext}}';
|
|
12
|
+
import { ChangeMemberRoleBody } from '{{alias.context}}/presentation/http/organisations/change-member-role/change-member-role.body{{alias.ext}}';
|
|
13
|
+
{{#if schemas.perRoute}}
|
|
14
|
+
import { ChangeMemberRoleAccepted } from '{{alias.context}}/presentation/http/organisations/change-member-role/change-member-role.accepted{{alias.ext}}';
|
|
15
|
+
{{/if}}
|
|
16
|
+
import { OrganisationsRoutes } from '{{alias.context}}/presentation/http/organisations.routes{{alias.ext}}';
|
|
17
|
+
{{/if}}
|
|
18
|
+
{{#if validation.zod}}
|
|
19
|
+
import { z } from 'zod';
|
|
20
|
+
{{#if schemas.shared}}
|
|
21
|
+
import { acceptedSchema, Controller, type Accepted, type HttpRequest } from '@ddd-ts-kit/http';
|
|
22
|
+
{{/if}}
|
|
23
|
+
{{#if schemas.perRoute}}
|
|
24
|
+
import { Controller, type HttpRequest } from '@ddd-ts-kit/http';
|
|
25
|
+
{{/if}}
|
|
26
|
+
import type { CommandBus } from '@ddd-ts-kit/kernel';
|
|
27
|
+
import type { Infer } from '@ddd-ts-kit/validation';
|
|
28
|
+
import { zodSchema } from '@ddd-ts-kit/validation/zod';
|
|
29
|
+
import { ChangeMemberRoleCommand } from '{{alias.context}}/application/commands/change-member-role/change-member-role.command{{alias.ext}}';
|
|
30
|
+
import { MemberRole } from '{{alias.context}}/domain/vocabularies/member-role.vocabulary{{alias.ext}}';
|
|
31
|
+
import { OrganisationsRoutes } from '{{alias.context}}/presentation/http/organisations.routes{{alias.ext}}';
|
|
32
|
+
{{/if}}
|
|
33
|
+
|
|
34
|
+
{{#if validation.classValidator}}
|
|
35
|
+
const params = classSchema(ChangeMemberRoleParams);
|
|
36
|
+
const body = classSchema(ChangeMemberRoleBody);
|
|
37
|
+
{{#if schemas.perRoute}}
|
|
38
|
+
const accepted = classSchema(ChangeMemberRoleAccepted);
|
|
39
|
+
{{/if}}
|
|
40
|
+
{{/if}}
|
|
41
|
+
{{#if validation.zod}}
|
|
42
|
+
const params = zodSchema(
|
|
43
|
+
z.object({
|
|
44
|
+
organisationId: z.string().min(1),
|
|
45
|
+
accountId: z.string().min(1),
|
|
46
|
+
}),
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
const body = zodSchema(
|
|
50
|
+
z.object({
|
|
51
|
+
role: z.enum(MemberRole),
|
|
52
|
+
}),
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
{{#if schemas.perRoute}}
|
|
56
|
+
const accepted = zodSchema(z.object({ id: z.string() }), { io: 'output' });
|
|
57
|
+
{{/if}}
|
|
58
|
+
{{/if}}
|
|
59
|
+
|
|
60
|
+
@Controller({
|
|
61
|
+
group: OrganisationsRoutes,
|
|
62
|
+
method: 'PUT',
|
|
63
|
+
path: '/:organisationId/members/:accountId/role',
|
|
64
|
+
summary: 'Change the role of a member',
|
|
65
|
+
params,
|
|
66
|
+
body,
|
|
67
|
+
response: { status: 200, description: 'Changed; the body carries the identifier of the membership.', body: {{#if schemas.shared}}acceptedSchema{{/if}}{{#if schemas.perRoute}}accepted{{/if}} },
|
|
68
|
+
errors: ['ORGANISATION_NOT_FOUND', 'MEMBER_NOT_FOUND', 'OWN_ROLE', 'ABOVE_OWN_ROLE', 'OWNERS_ONLY', 'LAST_OWNER'],
|
|
69
|
+
})
|
|
70
|
+
export class ChangeMemberRoleController {
|
|
71
|
+
constructor(private readonly commands: CommandBus) {}
|
|
72
|
+
|
|
73
|
+
{{#if validation.classValidator}}
|
|
74
|
+
async handle(request: HttpRequest<{ params: ChangeMemberRoleParams; body: ChangeMemberRoleBody }>): Promise<{{#if schemas.shared}}Accepted{{/if}}{{#if schemas.perRoute}}ChangeMemberRoleAccepted{{/if}}> {
|
|
75
|
+
{{/if}}
|
|
76
|
+
{{#if validation.zod}}
|
|
77
|
+
async handle(request: HttpRequest<{ params: Infer<typeof params>; body: Infer<typeof body> }>): Promise<{{#if schemas.shared}}Accepted{{/if}}{{#if schemas.perRoute}}Infer<typeof accepted>{{/if}}> {
|
|
78
|
+
{{/if}}
|
|
79
|
+
const id = await this.commands.execute(new ChangeMemberRoleCommand(request.actor, request.params.organisationId, request.params.accountId, request.body.role));
|
|
80
|
+
|
|
81
|
+
return { id };
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IsArray, IsISO8601, IsIn, IsNotEmpty, IsString } from 'class-validator';
|
|
2
|
+
import { MemberRight } from '{{alias.context}}/domain/vocabularies/member-right.vocabulary{{alias.ext}}';
|
|
3
|
+
|
|
4
|
+
export class GrantDelegationBody {
|
|
5
|
+
@IsString()
|
|
6
|
+
@IsNotEmpty()
|
|
7
|
+
delegateId = '';
|
|
8
|
+
|
|
9
|
+
@IsArray()
|
|
10
|
+
@IsIn(Object.values(MemberRight), { each: true })
|
|
11
|
+
rights: MemberRight[] = [];
|
|
12
|
+
|
|
13
|
+
@IsISO8601()
|
|
14
|
+
startsAt = '';
|
|
15
|
+
|
|
16
|
+
@IsISO8601()
|
|
17
|
+
endsAt = '';
|
|
18
|
+
}
|