Skip to content

feat: add Workspace.getAsset for a presigned asset download URL - #62

Merged
Prashant-Surya merged 2 commits into
mainfrom
feat/workspace-get-asset
Nov 10, 2026
Merged

Prashant-Surya merged 2 commits into
mainfrom
feat/workspace-get-asset

Conversation

@akhil-vamshi-konam

@akhil-vamshi-konam akhil-vamshi-konam commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds client.workspace.getAsset(workspaceSlug, assetId), a wrapper for the existing v1 endpoint GET /api/v1/workspaces/{slug}/assets/{asset_id}/. It returns a presigned, time-limited download URL for any uploaded workspace asset, plus the asset's name and MIME type. Mirrors plane-python-sdk#78.

Why: images embedded in a work item description (<image-component src="<asset-id>">) are stored as separate ISSUE_DESCRIPTION assets. workItems.attachments.list filters on ISSUE_ATTACHMENT, so they never appear there, and the SDK had no call that could fetch them. Plane MCP needs this to let agents read inline images.

Changes

  • New method Workspace.getAsset (src/api/Workspace.ts) returning a new WorkspaceAssetDownload model (asset_id, asset_url, asset_name?, asset_type?), exported from src/models.
  • asset_url is string | null: the server answers 200 with a null url when it cannot presign the stored file, and that should not surface as an error.
  • Errors surface as HttpError like every other call (400 for an asset that is not uploaded yet, 404 for a missing asset).
  • Version bumped 0.3.1 -> 0.3.2 in package.json.
  • Regenerated scripts/__fixtures__/types-bundle-exports.snapshot.txt: one new export (WorkspaceAssetDownload) and the Workspace class hash changed because it gained a method. No other entries moved.
  • No new dependencies.

Type of Change

  • Bug fix
  • Feature (non-breaking change which adds functionality)
  • Breaking change
  • Refactor / docs

Test Scenarios

Offline, no network or credentials (tests/unit/workspace-assets.test.ts, 6 tests using nock):

  • returns the download details;
  • hits /api/v1/workspaces/{slug}/assets/{id}/ with the X-Api-Key header;
  • tolerates a null asset_url;
  • leaves optional fields undefined when omitted;
  • raises HttpError for 400 and 404.

Run locally on this branch:

  • pnpm exec jest tests/unit: 79 suites passed, 986 tests passed (51 e2e-style suites skipped without .env.test)
  • pnpm build (tsc + types bundle + export-surface check): passes
  • pnpm check:format: clean
  • pnpm check:lint: 0 errors (166 pre-existing warnings)

Summary by CodeRabbit

  • New Features
    • Added workspace asset retrieval, including download links and optional asset details. Download links may be time-limited or unavailable.
  • Bug Fixes
    • Improved handling of workspace asset responses with missing download links or optional details, and clearer errors for invalid or unavailable assets.

Wraps GET /api/v1/workspaces/{slug}/assets/{asset_id}/ and adds the
WorkspaceAssetDownload model. Mirrors plane-python-sdk#78.

Bumps version to 0.3.2.
@coderabbitai

coderabbitai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Explain Change →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 56 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ca682977-08a3-44f0-85b5-51b6b2d1d81a
Commits

Reviewing files that changed from the base of the PR and between fc7420b and 709815e.

Files selected for processing: 2

  • tests/e2e/v2/collections.e2e.test.ts
  • tests/e2e/v2/group-sync.e2e.test.ts

No actionable comments were generated in the recent review.

Walkthrough

Adds Workspace.getAsset and the public WorkspaceAssetDownload type. The method requests workspace asset details and returns the typed response.

Changes: Workspace asset downloads

Layer / File(s) Summary
Download response and method
src/models/WorkspaceAsset.ts, src/models/index.ts, src/api/Workspace.ts, scripts/__fixtures__/types-bundle-exports.snapshot.txt, package.json
Adds and exports WorkspaceAssetDownload. Workspace.getAsset requests the workspace asset endpoint and returns the response. Updates the export snapshot and package version.
Download method tests
tests/unit/workspace-assets.test.ts
Adds offline tests for returned details, the request route and API-key header, nullable and omitted fields, and 400 and 404 errors.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Suggested reviewers: prashant-surya

Merge Risk: Minimal · previous review fc742

The asset download method and nullable response handling have no established merge-blocking issues. The change is ready to merge after normal checks.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly describes the main change: adding Workspace.getAsset to retrieve a presigned asset download URL.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 4 files. (2 skipped: 2 unsupported.)

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 952bf86e-21b6-4c6c-983e-badecfe63aa7
Commits

Reviewing files that changed from the base of the PR and between 6a31147 and fc7420b.

Files selected for processing: 6

  • package.json
  • scripts/__fixtures__/types-bundle-exports.snapshot.txt
  • src/api/Workspace.ts
  • src/models/WorkspaceAsset.ts
  • src/models/index.ts
  • tests/unit/workspace-assets.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Both tests were sending payloads the server rejects with a 400:

- collections: a collection holds only workspace wiki pages, and the test
  added a project-scoped page ("Page ... is not a workspace wiki page").
  Create the page at the workspace path and archive+delete it on cleanup.
- group-sync: project roles are admin/contributor/commenter/guest; there is
  no project "member" role ("Unknown project role slug"). Use "contributor".

Test-only change; no SDK code touched.
@Prashant-Surya
Prashant-Surya merged commit 0800fdb into main Nov 10, 2026
6 of 7 checks passed
@Prashant-Surya
Prashant-Surya deleted the feat/workspace-get-asset branch November 10, 2026 05:49
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