Skip to content

refactor: newtyped ID and nice session parsing#639

Merged
PonponJuice merged 27 commits intodevelopfrom
refactor/newtype-id
Feb 16, 2026
Merged

refactor: newtyped ID and nice session parsing#639
PonponJuice merged 27 commits intodevelopfrom
refactor/newtype-id

Conversation

@comavius
Copy link
Member

@comavius comavius commented Feb 14, 2026

関連Issue

  • close #

概要

IDのnewtypeパターン使用と、それに伴うsession周りのインターフェースの変更

domain/modelとbackend_app/extractorの変更をアプリケーション全体に反映しました

@comavius comavius requested a review from PonponJuice February 14, 2026 05:32
@comavius comavius changed the title Refactor/newtype refactor: newtyped ID and nice session parsing Feb 14, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces newtyped identifiers (e.g., ProblemId, UserDisplayId, SubmissionId, etc.) and refactors session handling to pass a parsed SessionUser through the application (via a new Axum extractor), propagating these interface changes across domain, infra, usecase, and backend_app layers.

Changes:

  • Introduce/propagate ID newtypes across domain models, repositories, infra adapters, and usecase DTOs/services.
  • Replace “session_id string lookup” patterns with SessionUser (and add ExtractedSessionUser for handlers).
  • Update backend_app request/response conversions and tests to match the new types.

Reviewed changes

Copilot reviewed 69 out of 70 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
lib/backend_usecase/src/service/user.rs Accept SessionUser/newtyped IDs in user usecases
lib/backend_usecase/src/service/traq_oauth2.rs Use get_session_user() for session resolution
lib/backend_usecase/src/service/testcase.rs Use newtyped IDs; remove session repo dependency
lib/backend_usecase/src/service/submission.rs Use newtyped IDs; pass SessionUser through
lib/backend_usecase/src/service/problem.rs Use ProblemId + SessionUser authorization
lib/backend_usecase/src/service/icon.rs IconId-based icon retrieval
lib/backend_usecase/src/service/google_oauth2.rs Use get_session_user() for user_id
lib/backend_usecase/src/service/github_oauth2.rs Use get_session_user() for user_id
lib/backend_usecase/src/service/editorial.rs Switch to newtyped IDs + SessionUser checks
lib/backend_usecase/src/service/auth.rs Update tests/constructors to newtyped IDs
lib/backend_usecase/src/model/user.rs DTOs now expose newtyped IDs (UserId, UserDisplayId, IconId)
lib/backend_usecase/src/model/testcase.rs DTOs now expose TestcaseId
lib/backend_usecase/src/model/submission.rs DTOs/query data updated to newtyped IDs
lib/backend_usecase/src/model/problem.rs DTOs/query data updated to ProblemId/UserDisplayId
lib/backend_usecase/src/model/editorial.rs DTOs updated to EditorialId/ProblemId/UserDisplayId
lib/backend_usecase/Cargo.toml Move uuid to dev-dependencies
lib/backend_infra_mock/src/auth.rs Update mock tests for new UserId construction
lib/backend_infra_mock/examples/basic_usage.rs Update example printing for newtyped UserId
lib/backend_infra/src/repository/user.rs Repository API now uses UserDisplayId/new conversions
lib/backend_infra/src/repository/testcase.rs Repository API now uses ProblemId/TestcaseId
lib/backend_infra/src/repository/submission.rs Repository API now uses SubmissionId/ProblemId/UserDisplayId
lib/backend_infra/src/repository/session.rs Introduce get_session_user() returning SessionUser
lib/backend_infra/src/repository/procedure.rs Procedure repo now keyed by ProblemId
lib/backend_infra/src/repository/problem.rs Problem repo now uses ProblemId/UserDisplayId
lib/backend_infra/src/repository/icon.rs Icon repo now uses IconId + returns IconId on create
lib/backend_infra/src/repository/editorial.rs Editorial repo now uses EditorialId/ProblemId/UserDisplayId
lib/backend_infra/src/repository/dep_name.rs DepName repository now keyed by ProblemId
lib/backend_infra/src/repository/auth.rs Update UserId mapping to newtype conversions
lib/backend_infra/src/model/user.rs Map DB rows into newtyped IDs
lib/backend_infra/src/model/testcase.rs Map DB rows into TestcaseId/ProblemId
lib/backend_infra/src/model/submission.rs Map DB rows into newtyped IDs
lib/backend_infra/src/model/problem.rs Map DB rows into ProblemId/UserDisplayId
lib/backend_infra/src/model/icon.rs Map DB rows into IconId
lib/backend_infra/src/model/editorial.rs Map DB rows into newtyped IDs
lib/backend_domain/src/repository/user.rs Domain repo traits updated for newtyped IDs
lib/backend_domain/src/repository/testcase.rs Domain repo traits updated for newtyped IDs
lib/backend_domain/src/repository/submission.rs Domain repo traits updated for newtyped IDs
lib/backend_domain/src/repository/session.rs Replace APIs with get_session_user()
lib/backend_domain/src/repository/procedure.rs Domain procedure repo keyed by ProblemId
lib/backend_domain/src/repository/problem.rs Domain problem repo keyed by ProblemId
lib/backend_domain/src/repository/icon.rs Icon repo uses IconId/CreateIcon
lib/backend_domain/src/repository/editorial.rs Editorial repo uses EditorialId
lib/backend_domain/src/model/user.rs Add UserDisplayId + make UserId field private
lib/backend_domain/src/model/testcase.rs Add TestcaseId newtype
lib/backend_domain/src/model/submission.rs Add SubmissionId + typed query fields
lib/backend_domain/src/model/session.rs New SessionUser model
lib/backend_domain/src/model/problem.rs Add ProblemId newtype + typed query fields
lib/backend_domain/src/model/jwt.rs JWT user_id now uses UserDisplayId
lib/backend_domain/src/model/icon.rs Add IconId + CreateIcon
lib/backend_domain/src/model/editorial.rs Add EditorialId + typed fields
lib/backend_domain/src/model.rs Export new session module
app/backend_app/tests/users/put_users.rs Update tests to use UserDisplayId newtype
app/backend_app/tests/users/get_users.rs Update tests to use UserDisplayId newtype
app/backend_app/src/model/users.rs Response mapping for newtyped display IDs
app/backend_app/src/model/testcase.rs Response mapping for TestcaseId
app/backend_app/src/model/submissions.rs Response + query parsing to newtyped IDs
app/backend_app/src/model/problems.rs Response mapping for ProblemId/UserDisplayId
app/backend_app/src/model/editorials.rs Response mapping for EditorialId
app/backend_app/src/lib.rs Export new extractor module
app/backend_app/src/handler/users.rs Switch handlers to ExtractedSessionUser
app/backend_app/src/handler/testcase.rs Switch handlers to ExtractedSessionUser + typed IDs
app/backend_app/src/handler/submissions.rs Switch handlers to ExtractedSessionUser + typed IDs
app/backend_app/src/handler/problems.rs Switch handlers to ExtractedSessionUser + typed IDs
app/backend_app/src/handler/icon.rs Parse UUID to IconId before calling usecase
app/backend_app/src/handler/editorial.rs Switch handlers to ExtractedSessionUser + typed IDs
app/backend_app/src/extractor/session.rs New extractor that resolves SessionUser from cookie
app/backend_app/src/extractor.rs New extractor module root
app/backend_app/src/di.rs Store session repository in DI; remove from some services
Cargo.toml Enable axum-extra cookie feature
Cargo.lock Add cookie crate dependency

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

comavius and others added 2 commits February 14, 2026 14:50
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 69 out of 70 changed files in this pull request and generated 8 comments.

Comments suppressed due to low confidence (1)

lib/backend_usecase/src/service/editorial.rs:19

  • After switching the service APIs to accept session_user: Option<SessionUser>, EditorialService no longer reads from the injected session_repository anywhere. Consider removing the SessionRepository generic/field (and updating new + DI) to avoid dead/unused wiring and potential dead_code warnings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI commented Feb 14, 2026

@comavius I've opened a new pull request, #641, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

Copilot AI commented Feb 14, 2026

@comavius I've opened a new pull request, #642, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

Copilot AI commented Feb 14, 2026

@comavius I've opened a new pull request, #643, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

Copilot AI commented Feb 14, 2026

@comavius I've opened a new pull request, #644, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

Copilot AI commented Feb 14, 2026

@comavius I've opened a new pull request, #645, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

Copilot AI commented Feb 14, 2026

@comavius I've opened a new pull request, #646, to work on those changes. Once the pull request is ready, I'll request review from you.

@comavius
Copy link
Member Author

そうなるのか

Copy link
Collaborator

@PonponJuice PonponJuice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

よさそう

@PonponJuice PonponJuice merged commit 517016d into develop Feb 16, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants