Skip to content

Commit a6f711a

Browse files
committed
chore(changeset): @objectstack/cli minor for the widened hook-body capability union
Claude-Session: https://claude.ai/code/session_01ADHkmSwS4mQyXWrddL4r6B Co-authored-by: Claude <noreply@anthropic.com>
1 parent 6c67329 commit a6f711a

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'@objectstack/cli': minor
3+
---
4+
5+
feat(cli): a lowered hook or action handler is granted `api.transaction` when it calls `ctx.api.transaction(…)`, and `api.read` when it reads through a bound object handle
6+
7+
Clause-②: yes (widening)
8+
Metadata-protocol: none
9+
10+
`os build` lowers an inline hook `handler` or action `target` function to a `js` body and infers the body's `capabilities` from the calls in its source. Two calls the sandbox gates were never inferred, so a lowered handler making them was refused at the call (403 INSUFFICIENT_PRIVILEGES) on every run:
11+
12+
- `ctx.api.transaction(fn)` — now infers `api.transaction`, whether it is called on `ctx.api`, on a local bound to `ctx.api` (`const api = ctx.api`), with `?.`, or after destructuring the member (`const { transaction } = ctx.api`). `api.write` stays its own grant, inferred from the writes inside the callback.
13+
- a read through a bound handle — `const rows = ctx.api.object('x'); … rows.find(…)` — now infers `api.read`, the same way a write through a bound handle already inferred `api.write`. The other read shapes the direct pattern missed (`?.` before the leaf, an object argument holding a call) are read too.
14+
15+
`ExtractedBody.capabilities`, published from `@objectstack/cli/hook-body`, widens to include `'api.transaction'` (seven tokens, the `HookBodyCapability` set of `@objectstack/spec`). A dependent with an exhaustive `switch` over the union gains one case to handle; nothing that was accepted before is refused.

0 commit comments

Comments
 (0)