Three provider objects exported fromDocumentation Index
Fetch the complete documentation index at: https://docs.veloiq.dev/llms.txt
Use this file to discover all available pages before exploring further.
@veloiq/ui connect your React application to the VeloIQ backend: authProvider handles JWT login and session management, accessControlProvider reads role permissions and hides or disables unauthorized UI elements, and httpClient is an Axios instance that attaches the JWT to every API request. All three implement the corresponding Refine provider interfaces and are passed directly to the <Refine> component.
authProvider
authProvider implements Refine’s AuthProvider interface. It communicates with the VeloIQ backend’s /auth/ endpoints and stores credentials in localStorage.
| Method | Behaviour |
|---|---|
login({ username, password }) | Posts to POST /auth/login. On success, stores the access token under the key jm_access_token and the user profile under jm_user. Also fetches and caches role permissions (/auth/roles) and resource permissions (/auth/resource-permissions) for the access control provider. Redirects to / on success. |
logout() | Removes jm_access_token, jm_user, jm_role_permissions, and jm_resource_permissions from localStorage. Redirects to /login. |
check() | Returns { authenticated: true } when jm_access_token is present; otherwise redirects to /login. |
getIdentity() | Returns the cached user from localStorage, or fetches it from GET /auth/me using the stored token. |
getPermissions() | Returns the roles array from the cached user profile. |
onError(error) | Triggers logout and redirects to /login on HTTP 401. |
accessControlProvider
accessControlProvider implements Refine’s AccessControlProvider interface. It mirrors the backend’s three-layer permission model entirely in the browser using cached data from localStorage — no additional network request is made per permission check.
Permission layers
| Layer | Source | Description |
|---|---|---|
| 1 — Global roles | jm_role_permissions in localStorage | Actions each role may perform across all resources. Fetched from GET /auth/roles at login. Falls back to built-in Admin/Manager/Viewer defaults when absent. |
| 2 — Model-level exceptions | jm_resource_permissions in localStorage | Per-resource action overrides set by @model_access on backend models. Fetched from GET /auth/resource-permissions at login. |
| 3 — Field-level | readRoles/writeRoles in FieldDef | Handled by CanAccess wrappers in the DynamicResource components. Not passed through accessControlProvider.can(). |
Built-in fallback permissions
When no cached permissions are available (e.g. before the first login), the provider falls back to:| Role | Allowed actions |
|---|---|
Admin | list, show, create, edit, delete, clone, field |
Manager | list, show, create, edit, clone, field |
Viewer | list, show, field |
Admin users bypass all permission checks — the
can function returns { can: true } immediately for any user whose roles include "admin" (case-insensitive).buttons.hideIfUnauthorized: true, so Refine automatically hides action buttons the current user cannot access.
httpClient
httpClient is a pre-configured Axios instance with a request interceptor that reads jm_access_token from localStorage and sets the Authorization: Bearer <token> header on every outgoing request.
httpClient to @refinedev/simple-rest’s data provider to ensure all Refine data operations are authenticated:
API_URL
API_URL is the base URL constant used by the providers and the data provider. Its default value is "/api".
/api requests to the backend, or replace API_URL with your own constant:
LoginPage
LoginPage is the pre-built login page component. It renders a username/password form and delegates to authProvider.login().
Wiring providers in App.tsx
The following is the complete provider setup from the task-manager sample application.UI Overview
All exports from
@veloiq/ui at a glance.DynamicResource
Schema-driven CRUD pages and the ModelDef type reference.