@diagonal-hq/cli 0.37.0 → 0.37.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 CHANGED
@@ -914,6 +914,7 @@ export default defineResource<'members'>({
914
914
 
915
915
  - The build accepts only a field key whose field type the setting allows. For example, `notifiable.email_field` accepts only an `email` field. With the folder type argument, such as `defineResource<'members'>({...})`, the editor checks the key after the build generates the types of the folder. Without the argument, the editor accepts any key.
916
916
  - A file cannot declare `role` or `permission`. Authorization provisioning owns the Role and Permission resources. It also maps `authenticatable.roles_field`, so a file cannot set it.
917
+ - The Page SDK types of an authenticatable resource include the provisioned `roles` relation: `resource()` exposes `fields.roles`, and `useRecords`, `search`, and `useResourceDataTable` accept `relations: ['roles']` and type `record.roles`. Role records have a string `id` and loosely typed fields, like other records of `Resources.Roles`. A resource file that declares its own `roles` field keeps that field's type. If the resource ever had another field with the key `roles`, provisioning names the relation `roles_2`, but the page types still say `roles`. Page bindings (`bindings.<name>.relations`, the page props, and the `seo` context) and workflow data calls do not type this provisioned relation, because they read `generated/resources.ts`.
917
918
  - A page reference setting names a page file by its uid, as `Pages.<Name>.uid` from `@app/generated/pages`. These settings are `authenticatable.login_page`, `authenticatable.login_redirect`, and `schedulable.calendar_connections_page`. See [Page reference settings](#page-reference-settings).
918
919
  - The build checks the setting names, the required settings, the select values, and each field reference. A relation path, such as an Itemizable offering path, names a relation of each resource on the way.
919
920
  - Each field reference is stored as the field id, as the resource builder stores it. This includes a nested reference, such as an Eventable excluded field, and each key of a relation path.
package/dist/cli.mjs CHANGED
@@ -107130,6 +107130,8 @@ var LINE_MESSAGE = /^Line (\d+):(\d+) — (.*)$/;
107130
107130
  var TRAILING_POSITION = /\((\d+):(\d+)\)$/;
107131
107131
  var SCOPE_STAGE = "Lint error";
107132
107132
  var UNDEFINED_NAME = /^'([^']+)' is not defined$/;
107133
+ var ROLES_FIELD_KEY = "roles";
107134
+ var ROLES_RESOURCE_SLUG = "roles";
107133
107135
  function resourceCatalog2(resources) {
107134
107136
  const catalog = {};
107135
107137
  for (const resource of resources) {
@@ -107144,6 +107146,15 @@ function resourceCatalog2(resources) {
107144
107146
  settings: field2.type === "relation" ? { ...settings, resource_id: resource2 } : settings
107145
107147
  };
107146
107148
  }
107149
+ if (Object.hasOwn(resource.capabilities ?? {}, "authenticatable") && !Object.hasOwn(fields, ROLES_FIELD_KEY)) {
107150
+ fields[ROLES_FIELD_KEY] = {
107151
+ key: ROLES_FIELD_KEY,
107152
+ type: "relation",
107153
+ label: "Roles",
107154
+ is_required: false,
107155
+ settings: { type: "belongs_to_many", resource_id: ROLES_RESOURCE_SLUG, nullable: true }
107156
+ };
107157
+ }
107147
107158
  catalog[resource.slug] = {
107148
107159
  id: resource.slug,
107149
107160
  slug: resource.slug,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diagonal-hq/cli",
3
- "version": "0.37.0",
3
+ "version": "0.37.1",
4
4
  "description": "The diagonal CLI and the configuration helpers for file-based Diagonal workspaces.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {