feat: org-scoped manual approval handler (onecli.org.configureManualApproval)#49
Merged
Conversation
…pproval)
Adds OrgApprovalClient, a cross-project sibling of the manual-approval handler:
it polls GET /v1/org/approvals/pending with an organization API key (no
X-Project-Id), and routes each decision back to the request's own project via
the existing POST /v1/approvals/{id}/decision route with X-Project-Id. Additive
and backward-compatible - the project ApprovalClient is unchanged. An onError
hook surfaces poll failures (including gateway-URL resolution) instead of
swallowing them.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
What
Adds
onecli.org.configureManualApproval(callback, options?)— a cross-project sibling of the existingonecli.configureManualApproval. With an organization API key (oc_org_…), it watches pending manual-approval requests across every project in the organization from one handler; each request carries its ownprojectId, which the SDK uses to route the decision back to the right project.Additive and backward-compatible — the project
ApprovalClientandconfigureManualApprovalare unchanged.Why
Companion to the gateway's new org approval route (below). A supervisor with an org key previously had no SDK path to watch approvals org-wide.
How
OrgApprovalClient(src/approvals/org.ts) — pollsGET /v1/org/approvals/pendingwithAuthorization: Bearer oc_org_…and noX-Project-Id(the org is derived from the key); submits each decision to the existingPOST /v1/approvals/{id}/decisionwithX-Project-Id: request.projectId(410-tolerant).OrgApprovalRequest extends ApprovalRequest { projectId },OrgManualApprovalCallback,OrgManualApprovalOptions.OrgClientgains an optional 4th ctor arg (gatewayUrl) +configureManualApproval; the facade threads it through. Existing callers are unaffected.onErrorhook surfaces poll failures (auth, network, gateway-URL resolution) instead of the project loop's silentcatch {}.Cross-repo contract
GET /v1/org/approvals/pending· auth = org API key (key-derived, noX-Organization-Id) · items carryprojectId· decisions reusePOST /v1/approvals/{id}/decision+X-Project-Id. This SDK is inert until the gateway route ships.Merge / release order: cloud gateway (merge + deploy) → this PR (release) → onecli-docs (last).
Related PRs
Review
Process: self-review + an independent adversarial TypeScript reviewer (public-API + type-design lens), skills loaded in full.
Skills applied:
typescript-pro/typescript-advanced-types(public API type design, backward-compat, wire correctness) — 1 HIGH fix:resolveGatewayUrl()sat outside the retry loop instart(), so a gateway-URL resolution failure (the common default path) propagated out and was swallowed —onErrornever fired and the loop never retried. Moved resolution inside the loop (it caches on success) and added a regression test. Everything else clean:ApprovalClientbyte-unchanged,OrgClient4th arg optional, no cloud-private leakage (no gateway internals, noX-Organization-Id).Gates (green):
pnpm typecheck+pnpm test(91, incl. 3 org) +pnpm build(CJS/ESM/DTS).release-please:
feat:→ minor.🤖 Generated with Claude Code