Skip to content

Update to @haverstack/core 0.8.0, simplify attachment routes#30

Merged
cuibonobo merged 3 commits into
mainfrom
claude/pensive-mayer-a0jeaf
Jun 25, 2026
Merged

Update to @haverstack/core 0.8.0, simplify attachment routes#30
cuibonobo merged 3 commits into
mainfrom
claude/pensive-mayer-a0jeaf

Conversation

@cuibonobo

Copy link
Copy Markdown
Member

Summary

  • Bump @haverstack/core to ^0.8.0 (adds getAttachment/deleteAttachment to StackClient, Stack, and ScopedStack; exports StackConflictError)
  • Simplify GET and DELETE attachment routes to delegate to the new SDK methods instead of reimplementing the logic inline
  • Add StackConflictError → 409 to the error middleware

Route changes

GET /attachments/:fileId — replaces the standalone isAttachmentAccessible helper (~30 lines) with a single ScopedStack.getAttachment() call. Access control logic (owner / referencing record / uploader) now lives in core.

DELETE /attachments/:fileId — replaces the manual meta-record query, reference check, hard-delete loop, and adapter call (~20 lines) with a single stack.deleteAttachment() call. StackNotFoundError and StackConflictError bubble up to the error middleware.

POST /attachments — unchanged; still calls adapter.putAttachment() directly for the raw byte upload.

Test plan

  • GET attachment as owner returns bytes
  • GET attachment as entity with a referencing record returns bytes
  • GET attachment as uploader (unassociated) returns bytes
  • GET attachment as unauthorized entity returns 401
  • DELETE unreferenced attachment returns 204
  • DELETE referenced attachment returns 409
  • DELETE nonexistent attachment returns 404

🤖 Generated with Claude Code

https://claude.ai/code/session_01PrLzbXMVj16yzEH6SjJkhA


Generated by Claude Code

claude added 3 commits June 25, 2026 13:17
Bump @haverstack/core dependency to 0.7.0 and simplify the GET and DELETE
attachment routes to delegate to the new Stack/ScopedStack methods instead
of reimplementing the access control and cleanup logic inline.

- GET /attachments/:fileId now uses ScopedStack.getAttachment(), removing
  the standalone isAttachmentAccessible helper (~30 lines)
- DELETE /attachments/:fileId now uses Stack.deleteAttachment(), collapsing
  ~20 lines of query/check/loop logic into a single call
- Add StackConflictError → 409 to the error middleware

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Picks up the StackConflictError public export fix.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cuibonobo cuibonobo merged commit c79a850 into main Jun 25, 2026
4 checks passed
@cuibonobo cuibonobo deleted the claude/pensive-mayer-a0jeaf branch June 25, 2026 13:56
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.

2 participants