Skip to content

client SDK: add approvals namespace; remove dead workflow surface (ADR-0019)#1516

Merged
os-zhuang merged 1 commit into
mainfrom
claude/peaceful-allen-aZ1ir
Jun 2, 2026
Merged

client SDK: add approvals namespace; remove dead workflow surface (ADR-0019)#1516
os-zhuang merged 1 commit into
mainfrom
claude/peaceful-allen-aZ1ir

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Summary

ADR-0019 collapsed approval into Flow: approval is no longer a workflow step but a first-class flow node that opens a request and suspends the run, with a human decision resuming the flow down the matching approve / reject edge. The server already exposes this as a dedicated /api/v1/approvals surface (registerApprovalsEndpoints), but the client SDK still carried the old approval-on-workflow methods — which pointed at /api/v1/workflow/.../approve routes that never existed server-side.

This PR brings the client SDK in line with ADR-0019.

Add: client.approvals namespace

Backed by the real REST surface under /api/v1/approvals:

Method Route
approvals.listRequests(filter?) GET /requests — the "my approvals" inbox (filter by status (single or array), object, recordId, approverId, submitterId)
approvals.getRequest(id) GET /requests/:id
approvals.approve(id, { actorId?, comment? }) POST /requests/:id/approve
approvals.reject(id, { actorId?, comment? }) POST /requests/:id/reject
approvals.listActions(id) GET /requests/:id/actions — audit trail

The approval runtime types (ApprovalRequestRow, ApprovalActionRow, ApprovalStatus, ApprovalDecisionInput, ApprovalDecisionResult) are re-exported from @objectstack/client so consumers can type the namespace without reaching into @objectstack/spec.

Remove: dead workflow approve/reject surface

ADR-0019 orphaned the approval-on-workflow surface. Removed end-to-end:

  • client.workflow.approve / client.workflow.reject
  • WorkflowApprove{Request,Response}Schema / WorkflowReject{Request,Response}Schema + inferred types (protocol.zod.ts)
  • workflowApprove / workflowReject on the IProtocolService interface + the protocol function map
  • the /:object/:recordId/{approve,reject} entries in DEFAULT_WORKFLOW_ROUTES

workflow is reclaimed for state machines (ADR-0019 §Context, ADR-0020), so getConfig / getState / transition are intentionally left intact — the IWorkflowService contract is a state machine with no approve/reject.

Discovery advertises the new route key: ApiRoutesSchema.approvals.

Test plan

  • @objectstack/spec full suite: 6608 passed (incl. updated protocol.test.ts, plugin-rest-api.test.ts).
  • @objectstack/client client.test.ts: 79 passed, including a new "Approvals namespace (ADR-0019)" block covering list (with single + array status filters), get, approve, reject, and the audit trail.
  • @objectstack/client builds clean (DTS typecheck green).

The 3 client integration suites (client.msw, client.hono, client.environment-scoping) fail to import in this environment due to an unrelated unbuilt-workspace issue (@objectstack/types / @objectstack/objectql dist not present) — not a regression from this change.

https://claude.ai/code/session_01TkMt3gAmWgYv9z1LQVYK1a


Generated by Claude Code

…ADR-0019)

ADR-0019 collapsed approval into Flow — approval is a first-class flow node,
not a workflow step. The server exposes a dedicated `/api/v1/approvals` surface,
but the client SDK still carried the old approval-on-`workflow` methods pointing
at routes that never existed.

- `@objectstack/client`: add a `client.approvals` namespace backed by the real
  REST surface — `listRequests` (the "my approvals" inbox), `getRequest`,
  `approve` / `reject` (record a decision, resume the owning flow), and
  `listActions` (audit trail). Re-export the approval runtime types.
- Remove the dead workflow approve/reject surface: `client.workflow.approve` /
  `reject`, the `WorkflowApprove*` / `WorkflowReject*` protocol schemas, types,
  `IProtocolService` methods, and the `/approve` / `/reject` entries in
  `DEFAULT_WORKFLOW_ROUTES`. `workflow` is reclaimed for state machines, so
  `getConfig` / `getState` / `transition` are unchanged.
- Discovery advertises the new `approvals` route key.
@vercel

vercel Bot commented Jun 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jun 2, 2026 4:29am

Request Review

@github-actions github-actions Bot added documentation Improvements or additions to documentation tests tooling size/m labels Jun 2, 2026
@os-zhuang os-zhuang marked this pull request as ready for review June 2, 2026 05:01
@os-zhuang os-zhuang merged commit 2170ad9 into main Jun 2, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants