-
Notifications
You must be signed in to change notification settings - Fork 6
feat: implement delete all KV endpoint #56
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
Conversation
WalkthroughAdded a bulk-delete KV operation across the SDK: Rust client exposes Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant UI as Frontend (React)
participant API as TS API Layer
participant Server
participant Client as Rust OpenSecretClient
User->>UI: trigger "Delete All" (delAll)
UI->>API: fetchDeleteAllKV() (DELETE /protected/kv)
API->>Server: authenticated DELETE /protected/kv
Server-->>API: 200 OK
API-->>UI: resolve
Note right of UI `#D6F5D6`: UI updates state (list becomes empty)
%% Rust client flow (integration test)
Client->>Server: DELETE /protected/kv (kv_delete_all)
Server-->>Client: 200 OK
Client-->>Test: Ok(())
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
Deploying opensecret-sdk with
|
| Latest commit: |
5a43b0c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://cf81a97c.opensecret-sdk.pages.dev |
| Branch Preview URL: | https://kv-delete-all.opensecret-sdk.pages.dev |
Greptile OverviewGreptile SummaryThis PR implements the delete all KV endpoint in both Rust and TypeScript SDKs, following the established pattern from the recent delete all conversations feature. Key Changes:
The implementation is consistent with existing patterns, properly tested, and follows the same endpoint differentiation strategy (path-based vs query-based) used throughout the codebase. Confidence Score: 5/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Client as SDK Client
participant SDK as OpenSecret SDK
participant API as Encrypted API
participant KV as KV Storage
Client->>SDK: kv_delete_all() / delAll()
SDK->>API: DELETE /protected/kv
Note over SDK,API: Encrypted API call
API->>KV: Delete all user's KV pairs
KV-->>API: Success
API-->>SDK: Empty response
SDK-->>Client: Ok(()) / void
|
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.
5 files reviewed, no comments
38fb0b5 to
5a43b0c
Compare
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.
6 files reviewed, no comments
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)
src/lib/test/integration/api.test.ts (1)
452-473: Improve test isolation to prevent flakiness.The test assumes a clean KV store but doesn't isolate its test data. This could cause failures if other tests leave keys behind or run concurrently.
Consider these improvements:
- Verify the specific keys (
key1,key2,key3) exist before deletion rather than just counting (line 465)- Use unique key names (e.g., timestamp or UUID prefix) to avoid collisions
- Add a
try/finallyblock to ensure cleanup even if assertions failApply this diff to improve test isolation:
test("KV Store - Delete All", async () => { // Login first to get authenticated const { access_token, refresh_token } = await tryEmailLogin(); window.localStorage.setItem("access_token", access_token); window.localStorage.setItem("refresh_token", refresh_token); - // Add multiple keys - await fetchPut("key1", "value1"); - await fetchPut("key2", "value2"); - await fetchPut("key3", "value3"); + // Use unique keys to avoid collisions with other tests + const testPrefix = `test-${Date.now()}-`; + await fetchPut(`${testPrefix}key1`, "value1"); + await fetchPut(`${testPrefix}key2`, "value2"); + await fetchPut(`${testPrefix}key3`, "value3"); - // Verify they exist + // Verify our keys exist const listBefore = await fetchList(); - expect(listBefore.length).toBeGreaterThanOrEqual(3); + const ourKeys = listBefore.filter(item => item.key.startsWith(testPrefix)); + expect(ourKeys.length).toBe(3); // Delete all keys await fetchDeleteAllKV(); // Verify they are gone const listAfter = await fetchList(); expect(listAfter.length).toBe(0); });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
rust/src/client.rs(1 hunks)rust/tests/api_integration.rs(1 hunks)src/lib/api.ts(1 hunks)src/lib/main.tsx(3 hunks)src/lib/test/integration/ai.test.ts(2 hunks)src/lib/test/integration/api.test.ts(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
- rust/src/client.rs
- rust/tests/api_integration.rs
- src/lib/test/integration/ai.test.ts
- src/lib/api.ts
🧰 Additional context used
🧬 Code graph analysis (1)
src/lib/test/integration/api.test.ts (1)
src/lib/api.ts (3)
fetchPut(143-150)fetchList(185-192)fetchDeleteAllKV(161-168)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Cloudflare Pages
🔇 Additional comments (4)
src/lib/test/integration/api.test.ts (1)
20-23: LGTM!The imports are correctly added and align with the API exports. The addition of
setDefaultInstructionfixes a missing import for line 344, and the new KV methods support the test added below.src/lib/main.tsx (3)
198-203: LGTM!The JSDoc and type definition for
delAllare clear and consistent with the existing KV operation methods in the context.
869-869: LGTM!The default context value correctly maps
delAlltoapi.fetchDeleteAllKV, consistent with other KV operations.
1280-1280: LGTM!The provider value correctly wires
delAlltoapi.fetchDeleteAllKV, completing the integration into the OpenSecret context.
Implements the delete all KV endpoint in both Rust and TypeScript SDKs.
Summary by CodeRabbit
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.