feat(profile): add learner public/private profile schema - #119
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #83
Adds a
LearnerProfilemodel separate fromUser's private/account fields, with a modeled visibility system and tiered serializers.Schema:
LearnerProfile(1:1 withUser) —displayName,bio,avatarUrl,country,timezone,languages[],level,interests[],goals[],visibility. Indexed oncountry,level,visibility(the consented/searchable fields). Account status/verification remain onUser, not duplicated here.Visibility: single ranked
visibilityfield (private < employer < public,VISIBILITY_RANKinsrc/types/profile.types.ts)Serializers (
src/services/profile-serializer.ts, pure functions, no I/O):toOwnerProfile— full record + computed completion, always (ignores visibility — it's the owner's own view)toEmployerProfile— full field set ifvisibility >= employer, else{ id, visible: false }toPublicProfile— narrower public-safe subset ifvisibility === public, else redactedtoPrivateProfile— internal-only; joinsstatus/isVerified/phoneVerifiedAtfromUser. Never wired to a public or employer route.Verification evidence
Schema:
prisma/schema.prisma—LearnerProfilemodel.Migration:
prisma/migrations/20260730120000_add_learner_profiles/migration.sql.Leakage tests:
tests/profile-serializer.test.ts— redaction below each visibility tier, and explicit assertions that employer/public views never carry the private account fields.Service tests:
tests/profile.service.test.ts— upsert defaults, partial updates, null-safe view fetching.Controller tests:
tests/profile.controller.test.ts— auth gating, validation (closed schema, enum checks), owner/employer/public routing by caller identity.Privacy doc:
docs/decisions/0002-learner-profile-visibility.md.37 new tests added, full suite passing (475 passed, 3 pre-existing DB-integration tests skipped as before — unrelated to this change).