Iam account orchestration
Auto-generated from the source archive. Do not edit by hand — rerun
catalyst-changelog-syncinstead.
What changed
Section titled “What changed”IamCreateAccountHandlerandIamUpdateAccountByIdHandlerare rewritten as orchestrators. They validate uniqueness ofemail,username, andcodepre-INSERT and raise a localizedConflictException(iam.error.uniqueEmail/uniqueUsername/uniqueCode) instead of letting the database fail with a cryptic error.- The denormalized columns
dApplicationCodesanddPermissionsare now derived server-side fromclient.applicationsandroles.permissionsvia the newiamCreatePermissionsFromRoleshelper. Any values supplied by the client for these fields are overwritten — the server is the source of truth. - New no-escalation rule: a caller without
IamPermissions.SUDOcan only assign permissions it already owns, otherwise a 401ConflictException(iam.error.insufficientPermissions) is raised.hasAddChildTenants: trueexpandstenantIdswith descendants from the tenant tree. - When
payload.type === 'USER', the handler invokesIamCreateUserService.main(andIamUpdateUserByIdService.mainon update) inside the same coordinated operation, sharing anoperationIdfor a coherent audit trail. An emptypasswordon update is dropped from the user payload so passwords are never silently overwritten.
Why it matters
Section titled “Why it matters”Before this change, IamCreateAccountHandler was a thin pass-through to repository.create(payload). The nested user block was silently ignored, the two derived columns had to be invented by the frontend (with the risk of authorization inconsistencies), uniqueness failed at the DB layer with non-localized errors, and any authenticated caller with iam.account.create could escalate privileges by assigning roles it did not own. The new orchestration ports the ~225-line Aurora monolith reference (create-account.function.ts) onto catalyst’s canonical pattern — handler orchestrates injected services directly, no CommandBus/QueryBus indirection — and unblocks the rich iam/account form in the dependent frontend change. Every catalyst-scaffolded project now ships with a correct iam orchestration end to end.