:api-roles top-level model key
Implemented from api-roles-plan.org (D1–D10):
Compiler:
:api-rolesin*top-level-keys*;valid-api-roles(shape only — non-empty list of non-empty unique strings, no role-existence check,report-e);valid-top-level-fielduses(member :api-roles model)so an explicitnil/()is rejected while absence defaults; accessormodel-api-roles(default("logged-in")lives in the accessor).REST: the three hardcoded sites now
(require-auth (model-api-roles))(/api/types,/api/info,/api/css-variables);/api/inforemfs:api-roles;/api/public-infoadds:guest-allowed(JSON boolean viaregister-json-boolean-key);/api/css-variablesalways renders JSON — empty[]for a user with no readable settings row (was a blank body).list-result:create/:update/:deletenow AND the model capability witha:user-allowedon the type resource (user-capability); wire flags are per-user, write gates unchanged.models/todos.lisp::api-roles ("logged-in" "public")and"public"added to:todos/:tags:type-roles.Frontend
App.tsx: sharedcompleteLogin; auto-guest on mount when/api/public-infosaysguest-allowed ==true= and thedata-ui-skip-auto-guestsessionStorage flag is unset; "Continue as guest" button (clears the flag); guest logout sets the flag so the login form stays reachable.npm run builddone.Tests: new
tests/api-roles-tests.lisp(validation probes bare- behavior on
models/test/api-roles-test.lisp), registered in
data-ui.asd,run-api-roles-testshelper added torun-tests. 31/31 green.- behavior on
Docs:
docs/model-reference.md(key table, API-roles section, guest-login section fixed to point at/api/public-info, quick index) anddocs/rest.md(endpoint roles, public-info payload, css-variables always-JSON).
Live smoke: guest token on todos model → /api/types (todos,
tags), /api/info (no :api-roles key), /api/css-variables
(200 JSON), /api/list?type=todos (row present,
create/update/delete false); model without :api-roles → guest
/api/types 401. (run-tests): 1650/1651; the one failure is a
pre-existing guest-tests.lisp bug (th-ga-model passes a plist
as the :guest-allowed value), unrelated to this change.
Also marked DONE: "Sign in as guest" (absorbed here).
- Slot
- 27300
- Status
- 60 Done
- Tags
- mvp, compiler
- Contributors
- Donnie