@protobase/cli 0.28.4 → 0.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
4
4
|
"description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@hono/node-server": "^2.1.3",
|
|
37
37
|
"@hono/vite-dev-server": "^0.26.1",
|
|
38
|
-
"@protobase/layout": "0.
|
|
39
|
-
"@protobase/query": "0.
|
|
40
|
-
"@protobase/schema": "0.
|
|
41
|
-
"@protobase/server": "0.
|
|
42
|
-
"@protobase/ui": "0.
|
|
38
|
+
"@protobase/layout": "0.29.0",
|
|
39
|
+
"@protobase/query": "0.29.0",
|
|
40
|
+
"@protobase/schema": "0.29.0",
|
|
41
|
+
"@protobase/server": "0.29.0",
|
|
42
|
+
"@protobase/ui": "0.29.0",
|
|
43
43
|
"@react-email/render": "^2.1.0",
|
|
44
44
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
45
45
|
"@tailwindcss/vite": "^4.3.3",
|
|
@@ -96,7 +96,9 @@ A refusal or a missing record rejects with the problem the REST API would answer
|
|
|
96
96
|
|
|
97
97
|
### Roles
|
|
98
98
|
|
|
99
|
-
`defineFunction({ roles: ['mechanic', 'desk'] }, handler)` lets in callers with at least one of those roles. Anyone else gets a `403 function-forbidden` problem before the handler runs. Finer rules belong in the resources' [access rules](../reference/access.md)), which `records` already applies.
|
|
99
|
+
`defineFunction({ roles: ['mechanic', 'desk'] }, handler)` lets in callers with at least one of those roles. `defineFunction({ capability: 'vms.update' }, handler)` lets in callers whose roles hold all of that capability ([`roles.holds`](../reference/access.md#wildcards-in-has-can-and-holds))): `*`, `vms.*` or a plain `vms.update`, but not `vms.update.own` or a `vms.update` limited to fields or rows. A wildcard means all of it, so `vms.*` needs a role that holds `vms.*` or `*`. Anyone else gets a `403 function-forbidden` problem before the handler runs. Finer rules belong in the resources' [access rules](../reference/access.md)), which `records` already applies.
|
|
100
|
+
|
|
101
|
+
In an app with [roles](../reference/access.md)) (`options: { roles }`), a function with neither is closed like a resource without a rule: only callers whose roles hold `*`, such as `admin: ['*']`, may call it, unless `defaultAccess` is `allow`. A function for everyone signed in says so with its roles. In an app without roles, every signed-in caller may call it. A `capability` needs the app's roles, and a function takes `roles` or `capability`, not both: the server refuses to start otherwise.
|
|
100
102
|
|
|
101
103
|
## Public functions and webhooks
|
|
102
104
|
|
|
@@ -12,6 +12,7 @@ Roles are defined in code ([`defineRoles`](https://docs.protobase.net/api/schema
|
|
|
12
12
|
- A project without roles (the single-admin case) is **default allow**.
|
|
13
13
|
- `defaultAccess: 'allow'` together with `roles` is an explicit opt-in. Print `accessWarnings(options)` at startup.
|
|
14
14
|
- Every request needs a token, unless the roles define [`anonymous`](#anonymous-access).
|
|
15
|
+
- An [API function](../guides/api-functions.md#roles)) without `roles` or a `capability` is closed the same way: with roles, only a caller holding `*` may call it.
|
|
15
16
|
|
|
16
17
|
## Capabilities
|
|
17
18
|
|
|
@@ -33,6 +34,13 @@ A field is readable when the role's list allows it and the field's own [rule](#f
|
|
|
33
34
|
|
|
34
35
|
**Several roles add up.** A user gets every field one of their roles lists (all of them when a role holds the plain capability) and the rows any of their roles allows. Fields and rows add up separately: someone holding both `erp_sync` and `reseller` above reads `name` on unpublished products too. With Better Auth a session acts with one [active role](auth.md#active-role)) at a time, so this only comes up with an authenticator that hands out several.
|
|
35
36
|
|
|
37
|
+
### Wildcards in has, can and holds
|
|
38
|
+
|
|
39
|
+
A wildcard in a role grants everything it stands for: `*.read` reads every resource. What a check asks for is different, so the checks take wildcards in one place only:
|
|
40
|
+
|
|
41
|
+
- `roles.has(user, 'vms.update')` and `roles.can('vms.update')` ask for one capability, in any scope or limit the role holds it. They refuse a wildcard, at compile time and when called, since `vms.*` would pass for a role holding only `vms.read`: ask for each capability instead.
|
|
42
|
+
- `roles.holds(user, 'vms.*')` asks for all of it, in every row and field: a role holding `*` or `vms.*` passes, one holding `vms.read`, `*.read`, `vms.update.own` or a `vms.update` limited to fields or rows does not. A scope asks for those rows at least: `orders.read.own` passes for a role holding `orders.read.own`, `orders.read` or `*.read`. API functions' `capability` is checked this way.
|
|
43
|
+
|
|
36
44
|
## Anonymous access
|
|
37
45
|
|
|
38
46
|
The role `anonymous` is what a request without a token acts as. A project without it answers such requests `401`, as always.
|