Skip to content

Conversation

@wato787
Copy link
Member

@wato787 wato787 commented Nov 27, 2025

Summary by CodeRabbit

  • 新機能
    • 更新操作でドラフト保存が可能になりました(isDraft フラグ指定でドラフトとして更新)。
  • パブリックAPIの変更
    • 更新リクエストにオプションの isDraft フィールドが追加され、更新呼び出しで指定可能になりました。
  • テスト
    • ドラフト/非ドラフト双方の更新フローを検証するテストを追加・更新しました。
  • ドキュメント
    • README と日本語ドキュメントに「ドラフト更新」の使用例を追加し、関連コメントを整理しました。

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 27, 2025

Walkthrough

更新操作にドラフト対応を追加しました。UpdateRequestisDraft?: boolean を追加し、createClientupdate 実装で isDraft を受け取り queries = isDraft ? { status: 'draft' } : {} を作成して makeRequest に渡すように変更。テストとドキュメントにドラフト更新の例と検証を追加しています。

変更内容

コホート / ファイル 変更サマリー
型定義
src/types.ts
UpdateRequest<T> インターフェースに isDraft?: boolean オプショナルプロパティを追加
クライアント実装
src/createClient.ts
update メソッドで isDraft = false を受け取り、queries = isDraft ? { status: 'draft' } : {} を生成して makeRequest に渡すロジックを追加
テスト更新
tests/write.test.ts
テストサーバーモックが URL の status クエリを解析して、patchListApiMockFn/patchObjectApiMockFn の第1引数に 'draft' または null を渡すよう変更。既存テストを null 呼び出しに更新し、ドラフト更新の新規テストを追加
ドキュメント
README.md, README_jp.md
「下書き更新 (isDraft)」の使用例を追加し、古い注釈(料金に関するコメント)を削除。日本語版にも同等の例を追加

Sequence Diagram

sequenceDiagram
    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
Loading

推定コードレビュー工数

🎯 3 (Moderate) | ⏱️ ~20–30 分

  • 注目ポイント:
    • src/createClient.ts: isDraft によるクエリ生成と makeRequest 呼び出しの引数整合性(既存のパス/クエリ結合ロジックとの整合)。
    • src/types.ts: public API 型の変更による影響範囲(型利用箇所の確認)。
    • tests/write.test.ts: モック呼び出しシグネチャとアサーションの適合性、ドラフトケースの網羅。

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed プルリクエストのタイトルは、UpdateRequestに isDraft パラメータを追加するという主要な変更を正確に説明しており、変更内容と完全に関連しています。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-draft-to-patch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@wato787 wato787 marked this pull request as ready for review November 27, 2025 04:51
Copy link

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 131b044 and 3a1fff0.

📒 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 の差分をシンプルに検証できる構造になっていて良いと思います。

@wato787 wato787 changed the title updateのリクエストにisDraft追加 【DO NOT MERGE】updateのリクエストにisDraft追加 Nov 27, 2025
Copy link
Member

@dc7290 dc7290 left a comment

Choose a reason for hiding this comment

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

良さそうです!ありがとうございます!

@wato787
Copy link
Member Author

wato787 commented Nov 27, 2025

TODO:APIのリリース後にマージしてPublishする

@wato787 wato787 self-assigned this Nov 28, 2025
README:isDraftに関する記述の修正
Copy link

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between b047944 and 2815b66.

📒 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」セクションとの対応も取れています。コード例も完全で正確です。

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.

3 participants