Skip to content

feat: コンテンツAPI POSTとPUTで isClosed オプションをつけると公開終了ステータスで登録できる#101

Merged
nemuvski merged 3 commits intomainfrom
add-status-pattern
Apr 13, 2026
Merged

feat: コンテンツAPI POSTとPUTで isClosed オプションをつけると公開終了ステータスで登録できる#101
nemuvski merged 3 commits intomainfrom
add-status-pattern

Conversation

@nemuvski
Copy link
Copy Markdown
Member

@nemuvski nemuvski commented Apr 13, 2026

  • CreateRequestに isClosed オプションを追加
  • isClosedisDraft が両方とも立っている場合はエラーとする
  • ユニットテスト追記

Summary by CodeRabbit

  • 新機能

    • コンテンツを「公開終了(closed)」状態で登録できるようになりました。指定したIDで公開終了として作成することも可能です。
  • ドキュメント

    • README(日本語版含む)に公開終了状態での登録例と注意事項を追記しました。
  • テスト

    • 新しい状態フラグの組み合わせ検証とクエリ挙動をカバーするテストを追加しました。

@nemuvski nemuvski self-assigned this Apr 13, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3d2e7f2c-50fe-4858-8a97-dfafc85e5a61

📥 Commits

Reviewing files that changed from the base of the PR and between 757a327 and e8cc3c6.

📒 Files selected for processing (2)
  • README.md
  • README_jp.md
✅ Files skipped from review due to trivial changes (1)
  • README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • README_jp.md

Walkthrough

create メソッドにオプション isClosed?: boolean を追加し、isClosed が true の場合にクエリを status=closed として送信するようにした。isClosedisDraft が同時に true の場合はエラーを返すバリデーションを追加した。README(英日)とテストを更新。

Changes

Cohort / File(s) Summary
ドキュメント更新
README.md, README_jp.md
「コンテンツの登録」セクションに isClosed: true を使った登録例を2パターン(指定IDあり/なし)追記。isDraftisClosed の同時 true を SDK が拒否する旨の注記を追加。
型定義
src/types.ts
export interface CreateRequest<T>isClosed?: boolean を追加。
クライアント実装
src/createClient.ts
create メソッドで isClosed を受け入れるように変更。isClosedisDraft の同時 true を検出してエラーを返すバリデーションを追加し、status クエリを条件的に 'draft'/'closed'/未設定 に設定するロジックへ変更。
テスト
tests/createClient.test.ts
client.create() の新規テスト追加:isClosedisDraft の排他チェックの期待、各フラグ組合せで送信される POST URL の status クエリ(draftclosed/未設定)を検証。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed プルリクエストのタイトルは、コンテンツAPI POSTとPUTで isClosed オプションを使用して公開終了ステータスで登録できる機能を追加することを正確に説明しており、変更セットの主要な目的と完全に一致している。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-status-pattern

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

@nemuvski nemuvski marked this pull request as ready for review April 13, 2026 02:54
@nemuvski nemuvski requested a review from Sinhalite April 13, 2026 02:58
Copy link
Copy Markdown

@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: 1

🧹 Nitpick comments (1)
tests/createClient.test.ts (1)

262-313: PUT パス(contentId 指定時)の isClosed もテスト追加したいです。

現状は POST のみ検証されています。PR目的どおりにするなら、contentId ありのときに status=closed が付与され、メソッドが PUT になるケースも1本あると安心です。

✅ 追加テスト例
+    test('Sends `status=closed` with PUT when `contentId` is specified', async () => {
+      let requestUrl = '';
+      let requestMethod = '';
+      server.use(
+        http.put(`${testBaseUrl}/list-type/foo`, ({ request }) => {
+          requestUrl = request.url;
+          requestMethod = request.method;
+          return HttpResponse.json({ id: 'foo' });
+        }),
+      );
+
+      await client.create({
+        endpoint: 'list-type',
+        contentId: 'foo',
+        content: { title: 'test' },
+        isClosed: true,
+      });
+
+      expect(requestMethod).toBe('PUT');
+      expect(new URL(requestUrl).searchParams.get('status')).toBe('closed');
+    });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/createClient.test.ts` around lines 262 - 313, Add a new test that calls
client.create with a contentId (to force a PUT) and isClosed: true, capture the
incoming request in the mock handler, and assert that request.method is "PUT"
and new URL(request.url).searchParams.get('status') === 'closed'; use the same
pattern as the existing tests (server.use(http.post/handler) but change to
http.put or capture method from the request) and reference client.create, the
endpoint 'list-type', and the contentId property to locate where to add the
test.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@README.md`:
- Around line 347-382: The README examples for client.create (the "Create closed
content" and "Create closed content with specified ID" sections) lack the
constraint that isDraft and isClosed cannot be set simultaneously; add a clear
note near those sections stating that the properties isDraft and isClosed are
mutually exclusive and passing both as true will cause a runtime error, and
update or annotate the example calls (the client.create usage) to either
explicitly show only isClosed or to include a short remark that isDraft must be
false/omitted when isClosed is true.

---

Nitpick comments:
In `@tests/createClient.test.ts`:
- Around line 262-313: Add a new test that calls client.create with a contentId
(to force a PUT) and isClosed: true, capture the incoming request in the mock
handler, and assert that request.method is "PUT" and new
URL(request.url).searchParams.get('status') === 'closed'; use the same pattern
as the existing tests (server.use(http.post/handler) but change to http.put or
capture method from the request) and reference client.create, the endpoint
'list-type', and the contentId property to locate where to add the test.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b9413f32-f6fc-47eb-94e4-ebf442f79a5a

📥 Commits

Reviewing files that changed from the base of the PR and between a091b59 and 757a327.

📒 Files selected for processing (5)
  • README.md
  • README_jp.md
  • src/createClient.ts
  • src/types.ts
  • tests/createClient.test.ts

Comment thread README.md
@nemuvski nemuvski requested a review from dc7290 April 13, 2026 03:09
Copy link
Copy Markdown
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.

良さそうです!

Copy link
Copy Markdown
Contributor

@Sinhalite Sinhalite left a comment

Choose a reason for hiding this comment

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

LGTMです!

@nemuvski nemuvski merged commit ff1f798 into main Apr 13, 2026
6 checks passed
@nemuvski nemuvski deleted the add-status-pattern branch April 13, 2026 04:09
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