@diagonal-hq/cli 0.16.0 → 0.17.1
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/README.md +4 -1
- package/dist/cli.mjs +12974 -602
- package/dist/index.d.ts +3 -2
- package/dist/sdk-contract.d.ts +1 -1
- package/dist/workflow/generated/capabilities.d.ts +177 -9
- package/dist/workflow/index.d.ts +4 -0
- package/dist/workflow/workspace-values.d.ts +36 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -449,11 +449,13 @@ export default definePage(
|
|
|
449
449
|
|
|
450
450
|
The build reads `Permissions.<Name>.uid` and `SystemPermissions.<Name>.uid` like literals. It refuses a slug, an unknown uid, and another property, such as `Permissions.ManageBookings.slug`. A menu checks a permission with its uid, for example `ctx.can(Permissions.ManageBookings.uid)`. A slug string, such as `ctx.can('manage_bookings')`, still works, with a warning. A policy `authorizer` that filters on `permission_slugs` uses the slug, because it filters a stored field.
|
|
451
451
|
|
|
452
|
+
Page code reads one member of `Permissions` at a time, such as `Permissions.ManageBookings.uid`. The build replaces each member reference with its value. A page cannot use `Permissions` as a whole, for example in `Object.keys(Permissions)` or `Object.values(Permissions)`. A dynamic import of `@app/generated/permissions` and a re-export of `Permissions` also fail the build. To list some permissions, write an array of member references, such as `[Permissions.ManageBookings.uid, Permissions.ManageEvents.uid]`.
|
|
453
|
+
|
|
452
454
|
The deploy writes every system permission and each permission of `permissions/` as the records of the platform Permissions resource, each with its uid as its record id. Then the resource is locked: the Security admin shows the permissions read-only, and every other write to them is refused. A new system permission appears on the next deploy with no change to the files. The System Administrator role holds every permission. A deploy that removes a permission that a role other than System Administrator grants is refused: remove the grant first.
|
|
453
455
|
|
|
454
456
|
The first deploy of a workspace matches each seeded system permission by its slug. It changes the id of the stored record to the uid and rewrites the role grants, so the roles keep their permissions. The deploy does not take over a custom permission that the workspace created. A declared permission whose slug a stored record already has blocks the deploy: delete that record, or remove the declaration. A stored custom permission that `permissions/` does not declare also blocks that deploy: declare it with its current record id as its `uid`, or delete it first. To get the record id, open the actions of the permission in the Security admin and select **Copy Permission ID**. Declare the permission with that `uid` in the file of its current slug, so it keeps its id and its role grants. Do not let `diagonal check` generate a new uid for it, because a new uid blocks the deploy.
|
|
455
457
|
|
|
456
|
-
A new repository declares its staff resource in a resource file, such as `resources/staff.ts`, with fields and the Authenticatable capability. The deploy owns that resource like any other resource file. Name it in `diagonal.config.ts` with `staffResource: Resources.Staff.slug`. The build refuses a `staffResource` that is not an Authenticatable resource file. After the first deploy, the platform adds the default administrator to that resource.
|
|
458
|
+
A new repository declares its staff resource in a resource file, such as `resources/staff.ts`, with fields and the Authenticatable capability. The deploy owns that resource like any other resource file. Name it in `diagonal.config.ts` with `staffResource: { resource: Resources.Staff.slug }`. The build refuses a `staffResource` that is not an Authenticatable resource file. After the first deploy, the platform adds the default administrator to that resource.
|
|
457
459
|
|
|
458
460
|
## Roles
|
|
459
461
|
|
|
@@ -480,6 +482,7 @@ export default defineRole({
|
|
|
480
482
|
- `permissions` lists the permissions that the role grants, as `Permissions.<Name>.uid` or `SystemPermissions.<Name>.uid`. Use `[]` for a role that grants none. The build refuses an unknown uid, a slug, and a permission that the list names twice.
|
|
481
483
|
- The build refuses two roles with one uid, one slug, one name, or one `Roles` name, and a role with the uid, the slug, or the name of a system role.
|
|
482
484
|
- The build writes `generated/roles.ts`. It exports `Roles`: the `uid`, the `slug`, and the `name` of each role, by the studly case of its file name, so `front_desk.ts` is `Roles.FrontDesk`.
|
|
485
|
+
- Page code reads one member of `Roles` at a time, such as `Roles.FrontDesk.uid`. The build replaces each member reference with its value. A page cannot use `Roles` as a whole, for example in `Object.keys(Roles)` or `Object.values(Roles)`. A dynamic import of `@app/generated/roles` and a re-export of `Roles` also fail the build. To list some roles, write an array of member references, such as `[Roles.FrontDesk.uid, Roles.Manager.uid]`.
|
|
483
486
|
- `@diagonal-hq/cli` exports `SystemRoles`. The platform declares `SystemRoles.SystemAdministrator`, with a fixed `uid`. That role holds every permission, declared and system, so `roles/` cannot declare or change it.
|
|
484
487
|
- A `roles.ts` file at the root is an error: move each role to `roles/<slug>.ts`.
|
|
485
488
|
|