Closed general

Write grants: page share --role, role in page shares, pkg publish --owner (adom/wiki#252)

Colby Knox · ·closed by Colby Knox

The wiki server now supports write grants (adom/wiki#252, on main, going to prod with the next tag). The CLI needs three small changes to use them.

1. page share --role

POST /api/pages/<owner>/<slug>/grants takes an optional role: read (the default, every grant made so far) or write.

adom-wiki page share <owner>/<slug> --user <handle> --role write
  • Granting again with a different role changes it. The response has changed: true and grant.role.
  • An unknown role answers 400 BAD_GRANT_ROLE with data.allowed: ["read", "write"].

2. page shares shows the role

GET /api/pages/<owner>/<slug>/grants returns role on every row, next to user_name, granted_by and created_at. Please add it as a column.

3. pkg publish --owner <handle>

A write grantee publishes into the owner's page by sending an owner multipart form field with the publish (the page's namespace). This is a form field, not a manifest key, so an owner already in someone's package.json changes nothing.

  • The page must already exist. The publish keeps its owner, org and author.
  • If the caller can't write the page, or it doesn't exist: 404 PAGE_NOT_FOUND with data: { owner, slug }.
  • If the manifest would change visibility, release_visibility, source_visibility or pkg_visibility for a write grantee: 403 MANAGER_ONLY with data.fields. The current value restated is fine.

repo push needs no change: POST /files already accepts write grantees.

Errors worth a hint

A write grantee who calls an owner-only route (visibility, grants, shares, transfer, rename, delete, purge, unpublish, withdraw, secrets) now gets 403 MANAGER_ONLY instead of the 404. The response hint says what they can and can't do; the CLI can print it as is.

1 Reply

Colby Knox ·

Shipped in adom-wiki 1.8.3.

  • page share <ref> --user <handle> --role read|write. The role is sent only when given, so a plain re-grant never downgrades a write grant. The reply notes a role change (GRANT_ROLE_CHANGED) and what a write grant allows (WRITE_GRANT).
  • page shares prints USER, ROLE, GRANTED BY and SINCE.
  • pkg publish --owner <handle> sends the owner form field. A 404 adds WRITE_GRANT_NEEDED with the page share ... --role write line to send the owner.
  • MANAGER_ONLY (including data.fields) and BAD_GRANT_ROLE map to hints. The skill has a new "Grants" section covering both roles and the grantee's publish.

Checked on staging: page shares and pkg publish --owner against a page that does not exist.

Colby Knox closed this ·

Log in to reply.