Skip to content

refactor!: 大学組織構造の型をランタイム定義から導出する設計に変更#111

Merged
KinjiKawaguchi merged 5 commits intodevelopfrom
refactor/university-structure-value-first
Mar 24, 2026
Merged

refactor!: 大学組織構造の型をランタイム定義から導出する設計に変更#111
KinjiKawaguchi merged 5 commits intodevelopfrom
refactor/university-structure-value-first

Conversation

@KinjiKawaguchi
Copy link
Copy Markdown
Member

@KinjiKawaguchi KinjiKawaguchi commented Mar 24, 2026

Summary

  • universityStructure.tsをランタイムデータ→型導出(as const + typeof)に再設計
  • 3ファイル(型定義・部分型・ランタイムデータ ~700行)→ 1ファイルに統合
  • 文字列リテラルの二重管理を解消(値を1箇所で定義し、型は自動導出)
  • getAffiliationSteps(): 学部ごとに異なる所属階層の動的ステップ生成関数を追加
  • PartialAffiliation型も同一データから導出
  • 課程ラベルを正式名称(学士課程/修士課程/博士課程/専門職学位課程)に変更

What

  • as const でランタイムデータを定義し、分配条件型(distributive conditional types)で学部ごとの学科制約を維持したまま型を導出
  • keysOf() ヘルパーで Object.keys のリテラル型を維持
  • CourseType 型を導入しヘルパー関数を型安全に(stringkeyof typeof UNIVERSITY_STRUCTURE
  • facultiesinstitutionsdepartmentssubdivisions にリネームし学部/研究科の意味的曖昧さを解消
  • 修士/博士/専門職のステップで field: "school" を使用(ドメインモデルと一致)
  • 理学部の学科とコース(創造理学コース)を排他的な別ステップに分離

Why

型定義とランタイムデータで同じ組織名を手書きしていた(DRY違反)。
値を先に定義し型を導出することで、1箇所の変更で型もUIデータも更新される。

Test plan

  • npm run typecheck が成功すること
  • npm run build が成功すること
  • npm run lint が成功すること
  • Affiliation型の互換性が保たれていること
  • getAffiliationSteps が全課程・学部で正しいステップを返すこと

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings March 24, 2026 03:54

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

ランタイムデータを単一の情報源とし、型を自動導出するように変更。
3ファイル(型定義・部分型・ランタイムデータ)を1ファイルに統合。

- as const + typeof で文字列リテラルの二重管理を解消
- 分配条件型により学部ごとの学科制約を維持
- getAffiliationSteps(): 学部ごとの動的階層ステップ生成関数を追加
- PartialAffiliation型もランタイムデータから導出
- 課程ラベルを正式名称(学士課程/修士課程/博士課程/専門職学位課程)に変更

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@KinjiKawaguchi KinjiKawaguchi force-pushed the refactor/university-structure-value-first branch from 4071429 to 8b3629e Compare March 24, 2026 03:58
@KinjiKawaguchi KinjiKawaguchi changed the title refactor!: 大学組織構造を値ファーストに再設計 refactor!: 大学組織構造の型をランタイム定義から導出する設計に変更 Mar 24, 2026
devin-ai-integration[bot]

This comment was marked as resolved.

KinjiKawaguchi and others added 2 commits March 24, 2026 13:36
- field: "school" に修正(修士/博士/専門職のステップ)
- 理学部の学科とコースを別ステップに分離
- CourseType 型を導入しヘルパー関数を型安全に
- keysOf ヘルパーで Object.keys のリテラル型を維持
- getMaxYear の戻り値型を厳密化
- getDepartments → getSubdivisions にリネーム、JSDocで制限を明記
- faculties → institutions にリネーム(学部/研究科の汎用名)
- getAffiliationSteps で不正courseTypeをexhaustiveに処理

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
devin-ai-integration[bot]

This comment was marked as resolved.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
devin-ai-integration[bot]

This comment was marked as resolved.

元のファイルにあった各フィールドの日本語注釈(/** 学部 */, /** 学科 */, etc.)
と型ごとの@seeリンク、セクションコメントを復元。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@KinjiKawaguchi KinjiKawaguchi merged commit 018d3e5 into develop Mar 24, 2026
4 checks passed
@KinjiKawaguchi KinjiKawaguchi deleted the refactor/university-structure-value-first branch March 24, 2026 05:07
KinjiKawaguchi added a commit that referenced this pull request Mar 24, 2026
## Summary
- Karte集約のドメインモデル、アプリケーション層(ユースケース)、インフラ層(Drizzleリポジトリ)を追加
- ConsultedAt型で日時精度(年/年月/日/日時)に対応

## Dependencies
このPRは以下がマージ済みであることを前提とします:
- #111 大学組織構造の型をランタイム定義から導出する設計に変更
- #112 ドメイン定数を追加し型をランタイム定義から導出

## What
- **ドメイン層**: Karte集約(Karte, ConsultedAt, Assignee, SupportRecord,
Consultation)
- **アプリケーション層**: Create/Correct/Get/Import/List カルテユースケース
- **インフラ層**: DrizzleKarteRepository、DBスキーマ(kartes, karte_assignees,
karte_consultation_categories)
- **ファクトリ**: createKarteUseCases

## Test plan
- [ ] `npm run typecheck` が成功すること(依存PR マージ後)
- [ ] `npm run test` が成功すること
- [ ] Karteの作成・取得・一覧が動作すること

🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- devin-review-badge-begin -->

---

<a href="https://app.devin.ai/review/su-its/core/pull/103"
target="_blank">
  <picture>
<source media="(prefers-color-scheme: dark)"
srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1">
<img
src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1"
alt="Open with Devin">
  </picture>
</a>
<!-- devin-review-badge-end -->

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

2 participants