Skip to content

refactor: プロジェクトファイル関連の型と関数をdomainディレクトリの外に出す - #2680

Merged
sigprogramming merged 7 commits into
VOICEVOX:mainfrom
sigprogramming:refactor_around_project
Jun 26, 2025
Merged

refactor: プロジェクトファイル関連の型と関数をdomainディレクトリの外に出す#2680
sigprogramming merged 7 commits into
VOICEVOX:mainfrom
sigprogramming:refactor_around_project

Conversation

@sigprogramming

@sigprogramming sigprogramming commented Jun 22, 2025

Copy link
Copy Markdown
Collaborator

内容

現在のmainブランチでは、プロジェクトファイル(永続化)に関わる型と関数がdomainディレクトリ内で定義されていますが、関心の分離が守られていない(ドメインレイヤー内に永続化に関する知識が入っている)という問題があります。
プロジェクトファイル関連の型と関数をdomainディレクトリの外に出し、それらがドメインに依存するようにして、この問題を解決します。

具体的には、以下を行います。

  • ドメインの型とプロジェクトファイルの型を別ファイルに分離
    • ドメインの型(src/store/type.tsで定義されていた型)はsrc/domain/project/type.ts
    • プロジェクトファイルのスキーマはsrc/infrastructures/projectFile/schema.ts
      • スキーマの名前もprojectSchemaからprojectFileSchemaに変更
    • プロジェクトファイルの型はsrc/infrastructures/projectFile/type.ts
  • プロジェクトファイルのマイグレーションとバリデーションの処理を別ファイルに分離
    • マイグレーションはsrc/infrastructures/projectFile/migration.ts
    • バリデーションはsrc/infrastructures/projectFile/validation.ts
  • ソングのトラックのみプロジェクトファイル用の型を定義
    • プロジェクトファイル用のトラックの型をSerializableTrackとして定義
  • トラックの変換処理を関数化するTODOコメントを追加

新規追加の判定になっているファイルがいくつかありますが、追加したのはSerializableTrackのみで、それ以外は移動です。

関連 Issue

その他

typoのマイグレーションを行っているところでtypoのエラーが出ています…
(たぶんファイルを変更したから出たんだと思います)

@sigprogramming
sigprogramming requested a review from a team as a code owner June 22, 2025 13:10
@sigprogramming
sigprogramming requested review from Hiroshiba and sevenc-nanashi and removed request for a team June 22, 2025 13:10
@voicevox-preview-pages

voicevox-preview-pages Bot commented Jun 22, 2025

Copy link
Copy Markdown

🚀 プレビュー用ページを作成しました 🚀

更新時点でのコミットハッシュ:1caf0ab

@Hiroshiba
Hiroshiba requested a review from Copilot June 23, 2025 04:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 separates project file (persistence) types and functions from the domain layer into a dedicated infrastructure layer and keeps the domain layer free of persistence concerns. Key changes:

  • Moved domain-level types to src/domain/project/type.ts and updated schemas in src/domain/project/schema.ts
  • Added infrastructure files under src/infrastructures/projectFile/ for schema, types, migration, and validation
  • Updated imports across store modules, sing logic, and components to use the new domain and infrastructure types

Reviewed Changes

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

File Description
src/domain/project/type.ts Introduce Note, Singer, Tempo, TimeSignature, Track, and related types
src/infrastructures/projectFile/schema.ts Define projectFileSchema and serializableTrackSchema
src/infrastructures/projectFile/migration.ts Refactor migration to use projectFileSchema and ProjectFileFormatError
Various src/... import updates Switched imports from @/store/type/@/domain/project to new domain/infrastructure types

Comment thread src/store/singing.ts
throw new Error("Track not found.");
}
const rawTrack = toRaw(selectedTrack);
// TODO: トラックの変換処理を関数化する

Copilot AI Jun 23, 2025

Copy link

Choose a reason for hiding this comment

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

The track conversion logic is duplicated in multiple places and marked with TODO. Extract this into a shared utility function (e.g. convertDomainTrackToSerializable) to reduce repetition and improve maintainability.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

これは別PRで行います。

Comment thread src/infrastructures/projectFile/validation.ts
Comment thread src/sing/songTrackRendering.ts Outdated

@sevenc-nanashi sevenc-nanashi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

typosが通ればあとは大丈夫だとおもいます。

chore: typos:ignore-next-lineで無視できるようにする
@sigprogramming

sigprogramming commented Jun 25, 2025

Copy link
Copy Markdown
Collaborator Author

typosのPRありがとうございます!マージしました!

@Hiroshiba Hiroshiba left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!!

設計に関してはゴールがわからないのですが、ソングメンバーと僕と @sevenc-nanashi さんでなんか良い落とし所を探っていきたいですね・・・!

1点コメントしてますが、もし同感であれば変更いただければという感じです!
そのままマージしても、変更したあとにマージボタン押していただいても、どちらでも・・・!


📝 メモ

↑のissueではprojectFileをsrc/domainにまとめる案を書いてましたが、確かにインフラ層においたほうが良さそう・・・かも!!

でもたぶん、たぶんだけど、DDDアーキテクチャはクリエイター向けソフトウェアに合わないので、VSCodeのようにbase/platform/editor/workbenchに分けても良さそう。
そのときはどちらにせよbaseに移動になりそう!

Comment thread src/infrastructures/projectFile/schema.ts Outdated
@sigprogramming

Copy link
Copy Markdown
Collaborator Author

レビューありがとうございます!マージします!

@sigprogramming
sigprogramming enabled auto-merge June 26, 2025 15:24
@sigprogramming
sigprogramming added this pull request to the merge queue Jun 26, 2025
Merged via the queue into VOICEVOX:main with commit 2679d1c Jun 26, 2025
@sigprogramming
sigprogramming deleted the refactor_around_project branch June 27, 2025 15:10
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