feat(drain): list the drains of every application and add-on - #1119
Open
KannarFr wants to merge 4 commits into
Open
feat(drain): list the drains of every application and add-on#1119KannarFr wants to merge 4 commits into
KannarFr wants to merge 4 commits into
Conversation
…ation `Organisation.listOwners()` returns the owners of the current user, sorted by name and optionally restricted to the one matching an ID or a name. It holds what `Application.getAllApps()` used to do inline, so that listing resources per owner is written once. Resolving a name against the summary it already fetches also avoids a second `GET /v2/summary`. `AppConfiguration.getAppDetails()` now accepts an already loaded configuration, so a command that had to read `.clever.json` to make a decision doesn't make the directory walk happen twice. No user visible change: `getAllApps()` keeps its signature and still filters on an owner ID without failing when nothing matches. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HDddJ444c6Bgvvkw9bF6pw
|
🔎 A preview has been automatically published! If you created the alias to the preview script, you can run this command to download and install this preview: clever-preview update feat-drain-list-allYou can also run it from your local repository: ./scripts/preview.js update feat-drain-list-all
This preview will be deleted once this PR is closed. |
`clever drain` required a linked or targeted application, so there was no
way to get an overview of the drains one has. It now falls back to listing
the drains of every resource of every organisation, the personal space
included, grouped by organisation and naming the application or add-on
each drain belongs to. `--org` restricts that listing to one organisation.
Targeting a resource with `--app`, `--alias` or `--addon` is unchanged, and
a linked application still takes precedence over the new listing. Since
that application can come from a parent directory, it is now named in the
output.
`--format json` keeps printing a flat list of drains in both cases, each
one carrying the owner it belongs to, so that a script reading it doesn't
have to care how the command was targeted. An organisation whose drains
cannot be listed is reported on stderr without hiding the drains of the
other ones, unless none of them can be listed at all.
This relies on `GET /v4/drains/organisations/{ownerId}/drains`, which is
not available to regular organisation members yet: the listing cannot work
until the API side lands, it is tracked separately.
Also fixes `clever drain --app <name>` printing `[object Object]` instead
of the application name when it has no drain.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HDddJ444c6Bgvvkw9bF6pw
A tenant scoped drain, audit logs for instance, belongs to the organisation itself and has no resource: `DrainView.resourceId` is optional. The `Resource` column had nothing to fall back on and was left empty for those rows, so it now names the organisation. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HDddJ444c6Bgvvkw9bF6pw
KannarFr
force-pushed
the
feat/drain-list-all
branch
from
August 12, 2026 20:06
c59b109 to
041b853
Compare
Listing the drains of every organisation one belongs to now answers 403 for some of them: a drain recipient carries its credentials in its URL, so the API restricts reading one to the admins, managers and developers of an organisation. Nothing says so at the point where the listing is described, and the warning line the command prints for such an organisation only repeats what the API answered. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PzXTW8ZYhkWHy97YLU7NxD
Member
Author
|
Tested, it works. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1118.
Why
clever drainalways required a linked or targeted application:There was no way to get an overview of the drains one has set up.
What
clever drainnow falls back to listing the drains of every resource of every organisation, the personal space included, grouped by organisation and naming the application or add-on each drain belongs to:--org(-o,--owner) restricts the listing to one organisation, and cannot be combined with--app,--aliasor--addon--format jsonkeeps printing a flat list of drains in both cases, each one carrying itsownerId/ownerName, so a script doesn't have to care how the command was targeted/v2/summarycall the listing already makes, so naming them costs no extra requestAlso fixes
clever drain --app <name>printing[object Object]instead of the application name when it has no drain.API
The listing relies on
GET /v4/drains/organisations/{ownerId}/drains, which is now live in production — it is served to OAuth1 callers since ovd!2147, and reading a drain asks for ADMIN, MANAGER or DEVELOPER in the organisation since ovd!2150. An organisation held with another role answers 403 and is reported as unreachable without hiding the others, which is what the per-organisation failure handling above is for. The roles are now documented indocs/services-logs-drains.md.Side note, out of scope here:
src/models/send-to-api.jsmaps any 401 to "You're not logged in, use clever login command". It is misleading whenever the API means "authenticated fine, not allowed here".Testing
npm run validatepasses.Verified against production, no longer against stubs:
The add-on
realId→ name resolution is confirmed by the listing naming a PostgreSQL add-on next to its three drains, and the linked-application path by running from a directory whose.clever.jsonsits in a parent:ℹ Drains of the linked application 'billing-api' (app_5cd7548d-…), with--orgstill taking over when given.The error paths behave as intended: