@diagonal-hq/cli 0.20.2 → 0.20.4

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
@@ -37,7 +37,7 @@ From the workspace root, run:
37
37
  diagonal make:migration backfill_post_slug
38
38
  ```
39
39
 
40
- The command creates `migrations/YYYYMMDDHHmmss_backfill_post_slug.ts` with the current timestamp. In a workspace template, run `npm run migration -- backfill_post_slug` for the same result. Edit the generated workflow, then run `diagonal check` before publishing. Keep deployed files unchanged. Use a new migration filename for a correction.
40
+ The command creates `migrations/YYYYMMDDHHmmss_backfill_post_slug.ts` with the current timestamp. In a workspace template, run `npm run migration -- backfill_post_slug` for the same result. Edit the generated workflow, then run `diagonal check` before committing. Keep deployed files unchanged. Use a new migration filename for a correction.
41
41
 
42
42
  ## Workspace API credentials
43
43
 
@@ -69,7 +69,7 @@ The build reads each file with a parser. It runs only the workflow and migration
69
69
 
70
70
  - `defineConfig`, `defineResource`, and the first argument of `definePage` must be static literals. `diagonal.config.ts` goes through the checks in [Workspace config](#workspace-config). The `field.<type>({...})` calls are the only calls that the build accepts in this data. The `seo` values of a page are the one exception: a `seo` value can be a one-expression function. See [Page bindings and seo](#page-bindings-and-seo).
71
71
  - Each `resources/*.ts` file goes through the resource checks in [Resources and fields](#resources-and-fields).
72
- - The build removes imports from `@diagonal-hq/cli`. Pages, layouts, components, and workflow scripts can import workspace files through `@app/`. A resource file can import only `@app/generated/resources` and `@app/generated/pages`. A notification type, template, or schedule file can import only `@app/generated/resources`, `@app/generated/notification-types`, and `@app/generated/email-layouts`, and an email layout file only `@app/generated/resources`. Workflow scripts can also import `@diagonal/workflow` and `@diagonal/workflow/workspace`. Other external imports in these source files are rejected.
72
+ - The build removes imports from `@diagonal-hq/cli`. Pages, layouts, components, and workflow scripts can import workspace files through `@app/`. A resource file can import only `@app/generated/resources`, `@app/generated/pages`, and `@app/generated/record-bindings`. A notification type, template, or schedule file can import only `@app/generated/resources`, `@app/generated/notification-types`, `@app/generated/email-layouts`, and `@app/generated/record-bindings`, and an email layout file only `@app/generated/resources` and `@app/generated/record-bindings`. `diagonal.config.ts` and each `workspace-fields/` file can also import `@app/generated/record-bindings`. Write `RecordBindings.<Name>.reference` from that module where a value needs a live record ID that each workspace selects. Workflow scripts can also import `@diagonal/workflow` and `@diagonal/workflow/workspace`. Other external imports in these source files are rejected.
73
73
  - The second argument of `definePage`, and the default export of a layout or component file, must be one function. A page imports a layout and passes it as `layout: AppLayout`, and imports a component and renders it as `<ClassCard />`. A string `layout` and `Sdk.Custom.<Name>` fail with the import to write. A component is any `.tsx` module that a page or layout reaches and that default-exports a PascalCase function, directly or as `export default Name` for a `const` function or arrow function of the file. It can also have named exports. It gets the page lint and type check at its own path.
74
74
  - Each page has one name: the studly case of each folder and file name below `pages/`, joined with `_`, without `.tsx`. A route parameter segment such as `[id]` gets the prefix `$`. `pages/sign-in.tsx` is `Pages.SignIn`, `pages/members/[id].tsx` is `Pages.Members_$Id`, `pages/index.tsx` is `Pages.Index`, and `pages/classes/index.tsx` is `Pages.Classes_Index`. A name that starts with a digit gets the prefix `Page`, so `pages/404.tsx` is `Pages.Page404`. Two page files with one name, such as `pages/members-list.tsx` and `pages/members_list.tsx`, fail at the second file: `The page files A and B both have the name Pages.Members_$Id. Rename one of the files`. `definePage` has no `key` option. The check refuses it with `Unknown page option "key"`.
75
75
  - Each page also has a `uid`. See [Definition uids and slugs](#definition-uids-and-slugs). The uid is the identity of the page. A file move or rename changes the page name, but the uid stays. Settings that store the uid still resolve. Resource capability settings name a page by this uid.
@@ -84,7 +84,7 @@ The build reads each file with a parser. It runs only the workflow and migration
84
84
  - `migrations/<id>.test.ts` tests `migrations/<id>.ts` in the same way that a workflow test tests its workflow. It imports the migration, and `runWorkflow` from `@diagonal/workflow/testing`.
85
85
  - The build ignores the files at the root other than `diagonal.config.ts`, `assets.ts`, and `redirects.ts`, dotfiles, and `node_modules`. A `permissions.ts` or `roles.ts` at the root is an error. It does not build the files in `generated/`. It writes `generated/resources.ts`, `generated/workflows.ts`, `generated/notification-types.ts`, and `generated/email-layouts.ts` in every build, `generated/workspace-fields.ts` when the workspace has a file in `workspace-fields/`, `generated/permissions.ts` when the workspace has a file in `permissions/`, `generated/roles.ts` when it has a file in `roles/`, and `generated/assets.ts` when it has `assets.ts`. See [Permissions](#permissions) and [Roles](#roles).
86
86
 
87
- - The build reads each `notifications/<folder>/type.ts` as a notification type, each `notifications/<folder>/<name>.template.ts` as a notification template, each `notifications/<folder>/<handle>.schedule.ts` as a notification schedule, and each `email-layouts/<folder>/layout.ts` as an email layout. Each file must have a default export of its `defineX({...})` call. Its imports follow the rule above: a type, template, or schedule file can import `@app/generated/resources`, `@app/generated/notification-types`, and `@app/generated/email-layouts`, and an email layout file only `@app/generated/resources`. The build checks the types, templates, layouts, and schedules against each other and against the resources. It ignores the other files in `notifications/` and `email-layouts/`, such as `.liquid` files, `fixtures/` folders, and a definition at another path. A publish writes each type, template, layout, and schedule into the workspace. See [Notifications](#notifications).
87
+ - The build reads each `notifications/<folder>/type.ts` as a notification type, each `notifications/<folder>/<name>.template.ts` as a notification template, each `notifications/<folder>/<handle>.schedule.ts` as a notification schedule, and each `email-layouts/<folder>/layout.ts` as an email layout. Each file must have a default export of its `defineX({...})` call. Its imports follow the rule above: a type, template, or schedule file can import `@app/generated/resources`, `@app/generated/notification-types`, `@app/generated/email-layouts`, and `@app/generated/record-bindings`, and an email layout file only `@app/generated/resources` and `@app/generated/record-bindings`. The build checks the types, templates, layouts, and schedules against each other and against the resources. It ignores the other files in `notifications/` and `email-layouts/`, such as `.liquid` files, `fixtures/` folders, and a definition at another path. A publish writes each type, template, layout, and schedule into the workspace. See [Notifications](#notifications).
88
88
 
89
89
  ## Definition uids and slugs
90
90
 
@@ -290,7 +290,7 @@ export default defineConfig({
290
290
  - An image is an Application Asset: import `Assets` from `@app/generated/assets` and write `Assets.<Name>.key`, as in a page `seo.image`, or `null` for no image. `<Name>` is the studly case of the key in `assets.ts`. The check refuses a string, an unknown asset name, and an asset that is not an image, at its line. Application Assets are public, so a Brand Kit image is always public. The Brand Kit stores the version of each image, and `/files/<version>` links to it. A logo or a favicon that one mode omits falls back to the other mode, as in the admin Brand Kit.
291
291
  - The check refuses an unknown section, mode, token, or logo variant, a font or a radius that is not in the catalog, and a shadow that is not a preset, at the line of the error.
292
292
  - `brand` is the whole Brand Kit, not a change to the stored one. Each deploy writes it to the `brand_kit` workspace setting. A token, an image, or a section that leaves the file leaves the workspace on the next deploy. A file without `brand` gives the platform default Brand Kit.
293
- - In a file-based workspace, the AI does not offer its Brand Kit tools. Change `brand` and publish instead.
293
+ - In a file-based workspace, the AI does not offer its Brand Kit tools. Change `brand` and commit it instead. The commit deploys.
294
294
 
295
295
  `brand-kit.generated.d.ts` declares the `BrandKit` type, and `brand-kit-catalog.json` lists the tokens, the choices, the presets, and the limits. `npm run generate-types` generates both from the Brand Kit schema. Do not edit them.
296
296
 
@@ -327,7 +327,8 @@ export default defineWorkspaceField({
327
327
  - `definition` is a `field.<type>({...})` builder. A workspace field takes `label`, `description`, `required`, `guard`, and `settings`. It cannot be a `relation`, and the builder has no `uid`, `unique`, `index`, `computed`, `getter`, or `setter`.
328
328
  - `value` is the value of the field. It is required: write `null` for a field without a value. The type of `value` follows the field type. The file owns the value.
329
329
  - The build does not use `default`. A `default` in `definition` gives a warning at the `default`, and the field takes its value from `value`.
330
- - The check refuses a value that does not match its definition at the line of the value. The deploy checks each value again with the `guard` rules of the field.
330
+ - The check refuses a value that does not match its definition at the line of the value. The deploy checks each literal value again with the `guard` rules of the field.
331
+ - A value can contain `RecordBindings.<Name>.reference` from `@app/generated/record-bindings`, for example as the value of a UUID field. The deploy stores the reference and does not check it with the `guard` rules. Each read resolves the reference to the record that the workspace selects, and then checks the resolved value with the `guard` rules. A missing selection, a missing or archived record, or a failed guard rule gives a setup error when a page or workflow reads that field. The other fields stay available.
331
332
  - Each deploy writes the definition and the value to the workspace settings collection. The API, `WorkspaceStore`, and the Page SDK read them. A redeploy with a changed value, label, setting, key, or file name updates the same field. A key change moves the value to the new key, and each Liquid template or string that names the old key stops finding it. A field keeps its type: give the file a new uid to make a new field with another type.
332
333
  - A removed file archives its field on the next deploy, and a file with the same uid restores it. A field that something still uses, such as a workflow, stops the deploy with the message of the entity graph.
333
334
  - A deploy refuses a field without a `uid`. Run `diagonal check` to write one.
@@ -519,7 +520,7 @@ A notification has a type, one or more templates, and optionally an email layout
519
520
 
520
521
  Each type, template, and layout has a `uid` and a `slug`. See [Definition uids and slugs](#definition-uids-and-slugs).
521
522
 
522
- - `uid` is the stable identity of the definition. `diagonal check` writes it. A publish writes the definition into the row with this uid, so the row keeps its id when you change the slug, rename the definition, or move the file.
523
+ - `uid` is the stable identity of the definition. `diagonal check` writes it. A deploy writes the definition into the row with this uid, so the row keeps its id when you change the slug, rename the definition, or move the file.
523
524
  - `slug` is optional. Without it, the slug is the name of the definition's folder or file, for example `'member-welcome'` for `notifications/member-welcome/type.ts` and `'standard'` for `standard.template.ts`. A `slug` option can differ from the path, and a rename of the folder or file then keeps it. It follows the slug rule and has at most 64 characters, and so does a folder or file name that gives the slug. The generated names come from the paths, so a rename changes them, and the check reports each reference that the rename breaks.
524
525
 
525
526
  A schedule has a `uid` with the same rules, but no `slug`, because no file refers to a schedule.
@@ -665,7 +666,7 @@ This sends the Standard welcome 7 days after each active member's `joined_on`.
665
666
 
666
667
  A deployed schedule is a System Notification. It sends with no staff identity, and `filters` decides who gets it. A file cannot name a person to send as. Staff actions on one generated notification, such as **Send now** or an edit, still act as the person who clicks.
667
668
 
668
- A publish writes the schedule into the workspace and makes its upcoming notifications. A later publish updates the same schedule. An offset that stays in the list keeps its notifications, with their edits and holds. When the file is gone, the publish deletes the schedule, as **Delete** on the schedule page does: the notifications that were not sent are archived, and the send history stays. A publish never pauses or enables a schedule. Staff can still pause it on the schedule page, which shows the other fields as read-only, with the path of the file.
669
+ A deploy writes the schedule into the workspace and makes its upcoming notifications. A later deploy updates the same schedule. An offset that stays in the list keeps its notifications, with their edits and holds. When the file is gone, the publish deletes the schedule, as **Delete** on the schedule page does: the notifications that were not sent are archived, and the send history stays. A publish never pauses or enables a schedule. Staff can still pause it on the schedule page, which shows the other fields as read-only, with the path of the file.
669
670
 
670
671
  ### Send from a workflow
671
672
 
@@ -725,7 +726,7 @@ The editor checks the shape of each definition. `diagonal check` and the build a
725
726
  - A schedule's `recipient` path reaches the type's recipient resource through relations that each hold one record. Without `recipient`, the source resource is the recipient resource.
726
727
  - Each key of a schedule's `variables` is a variable of the type, and each path reaches a field of the source record or of a record that its single-record relations reach. A record variable maps to the id of a record of its resource, for example `'first_event.id'`. Each required variable is mapped.
727
728
 
728
- A publish writes each type, template, layout, and schedule into the workspace, matched by its uid, and removes each one that no file declares. A later publish that adds a removed uid again restores the same definition. A publish fails, and changes nothing, when:
729
+ A deploy writes each type, template, layout, and schedule into the workspace, matched by its uid, and removes each one that no file declares. A later deploy that adds a removed uid again restores the same definition. A deploy fails, and changes nothing, when:
729
730
 
730
731
  - A definition has no uid. Run `diagonal check` to write one.
731
732
  - A template keeps its uid but names another type. A template cannot move to another type. To use another type, create the template in a new file without a uid, update its references, and remove the old file in the same save.
@@ -735,8 +736,8 @@ A publish writes each type, template, layout, and schedule into the workspace, m
735
736
  These rules need server data, so the check does not check them yet:
736
737
 
737
738
  - A built-in `recipient` resource can receive notifications.
738
- - The fields of a built-in resource. The publish checks them.
739
- - The field paths of a schedule's `filters`. The publish does not check them either: a filter that names a field that does not exist deploys.
739
+ - The fields of a built-in resource. The deploy checks them.
740
+ - The field paths of a schedule's `filters`. The deploy does not check them either: a filter that names a field that does not exist deploys.
740
741
 
741
742
  ### Fixtures
742
743
 
@@ -805,7 +806,7 @@ export default defineResource({
805
806
  - After the deploy, the platform runs the same provisioning as the resource builder. It creates the system fields of a Subscription, the accounting entity fields, the billing relations, the record indexes, and the booking and schedule setup. For an Authenticatable resource, it creates the Role and Permission resources, so members can sign in.
806
807
  - A setting that provisioning fills can be left out. A Subscription starts from the builder's default settings, so set only the defaults that change.
807
808
  - Provisioning can create a field, for example `accounting_entity`. The files cannot declare a field with the same key later. Use another key.
808
- - The resource builder and the API refuse a capability change in a file-based workspace. Change the resource file, then publish.
809
+ - The resource builder and the API refuse a capability change in a file-based workspace. Change the resource file, then commit it. The commit deploys.
809
810
 
810
811
  ### Page reference settings
811
812