Skip to content

apps/api/src/features/family-groups/family-groups.service.ts ​

Auto-generated by scripts/generate-file-docs.ts. Do not edit — overwritten on every run.

Purpose ​

FamilyGroupsService — household management. Rules (ADR 0007 + api-contracts.md §5): - Family group is the primary organizational unit; every approved adult belongs to exactly one. - Spouse adds require minister approval (SPOUSE_ADD workflow). The new spouse user is created with status=PENDING_APPROVAL and is NOT yet linked into the family — Users.familyGroupId is left null. The link is created by ApprovalService.approve() inside the same transaction that flips the workflow. - Spouse-add can only be initiated by the family's PRIMARY member. - Child adds are auto-approved (parent is already vetted) and create a PARENT_MANAGED user with an Argon2id PIN hash. Child-add can be initiated by the PRIMARY member or by an existing SPOUSE in the same household. - Members are removed via soft-delete (FamilyGroupMember.isActive=false) — never hard-deleted (preserves audit trail; ADR 0007). - Admin endpoints (DELETE members, PUT group) are gated at the router via requireRole('admin'); the service applies a defense-in-depth check against the database role (slug-form lowercase) before mutating. Argon2id parameters: 64 MiB memory, 3 iterations, parallelism 4 per auth-rbac-design. /

Exports ​

  • export interface FamilyGroupWithMembers
  • export interface ListFamilyGroupsResult
  • export class FamilyGroupsService
  • export const familyGroupsService

Imports ​

  • ../../adapters/db
  • ../../config
  • ../../lib/errors
  • ../../lib/logger
  • ../../lib/pagination
  • ../../middleware/requireAuth
  • ../members/members.service
  • @clerk/backend
  • @prisma/client
  • argon2

Imported by ​

Heritage Community Hub — Internal. Access restricted via Cloudflare Access + Entra ID.