-
Notifications
You must be signed in to change notification settings - Fork 29
【DO NOT MERGE】updateのリクエストにisDraft追加 #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Walkthrough更新操作にドラフト対応を追加しました。 変更内容
Sequence DiagramsequenceDiagram
participant Client
participant UpdateFn as update(...)
participant MakeReq as makeRequest
participant API
rect rgb(240,248,255)
Note over Client,API: 非ドラフト更新 (isDraft = false)
Client->>UpdateFn: update({ isDraft: false, ... })
UpdateFn->>UpdateFn: queries = {}
UpdateFn->>MakeReq: makeRequest(..., queries)
MakeReq->>API: PATCH /path
end
rect rgb(245,255,240)
Note over Client,API: ドラフト更新 (isDraft = true)
Client->>UpdateFn: update({ isDraft: true, ... })
UpdateFn->>UpdateFn: queries = { status: 'draft' }
UpdateFn->>MakeReq: makeRequest(..., queries)
MakeReq->>API: PATCH /path?status=draft
end
推定コードレビュー工数🎯 3 (Moderate) | ⏱️ ~20–30 分
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
src/createClient.ts (1)
357-383: update での isDraft 対応は create と対称で妥当ですisDraft をデフォルト false で受け取り、ドラフト時のみ
queries = { status: 'draft' }を渡す実装になっていて、既存の非ドラフト更新を壊さずに draft 対応できていると思います。create でも同じパターンを使っているので、将来的にはbuildWriteQueries(isDraft)のような小さなヘルパーに共通化しておくと重複が減って読みやすくなりそうです。tests/write.test.ts (2)
154-187: リスト更新の draft / non-draft 両方を明示的に検証できているがコメントの HTTP メソッドだけ修正余地あり非ドラフト時に第1引数 null、ドラフト時に 'draft' になることをそれぞれ
toHaveBeenCalledWithでチェックできていて、意図がかなりわかりやすいテストになっています。一方でコメントがPUT apiになっており実際のメソッドは PATCH なので、将来の混乱を避けるためコメントだけ PATCH に直しておくと良さそうです。- // Confirm PUT api was called + // Confirm PATCH api was called @@ - // Confirm PUT api was called + // Confirm PATCH api was called
189-220: オブジェクト更新の draft / non-draft テストも一貫しており、同様にコメントの PATCH 化を検討して良さそうですこちらも non-draft で第1引数 null、draft で 'draft' になることを検証しており、create・list 更新と一貫したテストパターンになっていて良いと思います。ここもコメントが
PUT apiになっているので、実際の HTTP メソッドに合わせて PATCH にしておくとさらに正確になります。- // Confirm PUT api was called + // Confirm PATCH api was called @@ - // Confirm PUT api was called + // Confirm PATCH api was called
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/createClient.ts(2 hunks)src/types.ts(1 hunks)tests/write.test.ts(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/createClient.ts (1)
src/types.ts (3)
UpdateRequest(158-164)WriteApiRequestResult(146-148)MakeRequest(88-93)
🔇 Additional comments (2)
src/types.ts (1)
158-163: UpdateRequest への isDraft 追加は CreateRequest と対称で一貫性がありますCreateRequest と同じ形で isDraft?: boolean を追加しており、update でもドラフト更新を表現できるようになっていて、型的にも挙動的にも問題ないと思います。
tests/write.test.ts (1)
133-146: update 用の MSW ハンドラで status クエリを拾う形になっていてテストしやすいですURL から
statusを取り出してモック関数の第1引数に渡しており、draft / non-draft の差分をシンプルに検証できる構造になっていて良いと思います。
dc7290
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
良さそうです!ありがとうございます!
|
TODO:APIのリリース後にマージしてPublishする |
README:isDraftに関する記述の修正
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
README_jp.md (1)
364-380: ドキュメントセクションは適切に追加されていますが、日本語表現を簡潔化できます。新しいセクション「コンテンツの下書き更新」は、既存の update メソッドドキュメントとの一貫性があり、create メソッドの下書き機能との対応も取れています。ただし、行 366 の説明文で「ことができます」という表現は冗長なため、「できます」に簡潔化することをお勧めします。
下記の修正を検討してください:
- `isDraft` プロパティを指定することで、コンテンツを下書き状態で更新することができます。 + `isDraft` プロパティを指定することで、コンテンツを下書き状態で更新できます。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
README.md(1 hunks)README_jp.md(1 hunks)
🧰 Additional context used
🪛 LanguageTool
README_jp.md
[uncategorized] ~366-~366: 「ことができる」という表現は冗長な可能性があります。
Context: ... isDraft プロパティを指定することで、コンテンツを下書き状態で更新することができます。 ```javascript client .update({ ...
(DOUSI_KOTOGADEKIRU)
🔇 Additional comments (1)
README.md (1)
364-380: ドキュメント追加は適切です。新しいセクション「Update content as draft」は既存のドキュメント構造とよく統合されており、「Create draft content」セクションとの対応も取れています。コード例も完全で正確です。
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.