Skip to content

feat: archive, recover and delete item versions#13

Merged
ABujalance merged 3 commits into
mainfrom
feat/delete-versions
May 4, 2026
Merged

feat: archive, recover and delete item versions#13
ABujalance merged 3 commits into
mainfrom
feat/delete-versions

Conversation

@ABujalance

Copy link
Copy Markdown
Contributor

Summary

Mirrors the new backend endpoints for per-version lifecycle management so SDK consumers (cloud components, CLI, ad-hoc scripts) can archive, recover, list and permanently delete versions of an item without crafting URLs by hand.

Changes

  • New methods on EngineServicesClient:
    • listVersions(itemId, { archived })GET /item/:itemId/versions. archived: true returns only archived, false returns only active, omitting it returns both.
    • archiveVersion(itemId, versionTag)PUT /item/:itemId/version/:versionTag/archive.
    • recoverVersion(itemId, versionTag)PUT /item/:itemId/version/:versionTag/recover.
    • deleteVersion(itemId, versionTag)DELETE /item/:itemId/version/:versionTag. Backend rejects unless the version is already archived.
  • All four go through the existing #requestApi helper, so both auth modes (accessToken in query string and Bearer header for PlatformClient) work without extra wiring.
  • Tests added in client.test.ts covering HTTP method, path, query params, bearer header behaviour and error propagation.

Considerations

  • No type changes — the existing ItemVersion type already extends a Base that has archived?: boolean, so the response shape is unchanged.
  • The deletion endpoint is a soft contract: callers must call archiveVersion first, otherwise the backend returns 400. Tested via the error-handling case.
  • Follow-up: when the matching backend PR ships and a release is cut, consumers (backend-api, cloud component templates) will pick this up via the normal version bump.

ABujalance added 2 commits May 3, 2026 17:19
Mirrors the new backend endpoints so SDK consumers (cloud components,
CLI, scripts) can manage version lifecycle without crafting URLs.

- listVersions(itemId, { archived })
- archiveVersion(itemId, versionTag)
- recoverVersion(itemId, versionTag)
- deleteVersion(itemId, versionTag) — requires the version to be
  archived first; backend rejects otherwise

Both auth modes (accessToken query param and Bearer header) work
through the existing requestApi helper. HTTP-contract tests added.

@smoratino-apogea smoratino-apogea left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Comment thread src/core/client.ts
* @returns The archived version.
*/
async archiveVersion(itemId: string, versionTag: string) {
return await this.#requestApi<ItemVersion>(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think encodeURIComponent() is missing in archiveVersion, recoverVersion, and deleteVersion

Addresses Sergio's review: archiveVersion, recoverVersion, deleteVersion
and listVersions interpolated itemId / versionTag straight into the URL,
so any tag with /, ?, # or whitespace would corrupt the path.
@ABujalance ABujalance merged commit 9f124f1 into main May 4, 2026
1 check passed
@agviegas agviegas deleted the feat/delete-versions branch June 4, 2026 21:52
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