@diagonal-hq/cli 0.38.3 → 0.39.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/README.md +40 -9
- package/dist/check-data.json +1 -1
- package/dist/{cli-check-data-GHZW7MSI.mjs → cli-check-data-IITXQPIR.mjs} +2 -2
- package/dist/{cli-chunk-IJTP2OMH.mjs → cli-chunk-U2ET6LQJ.mjs} +65 -0
- package/dist/{cli-workflows-E2QBBI3W.mjs → cli-workflows-CK5ZVNYR.mjs} +1 -1
- package/dist/cli.mjs +186 -21
- package/dist/index.d.ts +14 -3
- package/dist/sdk-contract.d.ts +1 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -7,6 +7,7 @@ This package is the authoring SDK for file-based workspaces. A workspace reposit
|
|
|
7
7
|
- Editor types for the workflow script SDK: `@diagonal/workflow`, `@diagonal/workflow/testing`, and `@diagonal/workflow/workspace`.
|
|
8
8
|
- The `diagonal check` command. It runs the same build and checks that a platform deploy runs, including the workflow tests. It also writes `generated/resources.ts`, `generated/pages.ts`, `generated/workflows.ts`, `generated/assets.ts`, `generated/catalog.d.ts`, and the missing definition uids.
|
|
9
9
|
- The `diagonal make:migration <name>` command. It creates an ordinary workflow in `migrations/` with a timestamped filename. Every migration runs as system.
|
|
10
|
+
- The `diagonal update` command. It updates the `@diagonal-hq` packages of the workspace and installs them.
|
|
10
11
|
- The `diagonal assets upload` and `diagonal assets list` commands. They upload Application Assets, update `assets.ts`, and list immutable references.
|
|
11
12
|
- The `diagonal workflows`, `diagonal run`, and `diagonal logs` commands. They list the deployed workflows, run a manual workflow by its file path, and print recent runs with the error of each failed run.
|
|
12
13
|
|
|
@@ -14,10 +15,10 @@ This package is the authoring SDK for file-based workspaces. A workspace reposit
|
|
|
14
15
|
|
|
15
16
|
```bash
|
|
16
17
|
npm install
|
|
17
|
-
|
|
18
|
+
npx diagonal check
|
|
18
19
|
```
|
|
19
20
|
|
|
20
|
-
`npm
|
|
21
|
+
`npx` runs the `diagonal` binary that `npm install` installed in `node_modules/.bin`, so a workspace needs no `package.json` scripts for these commands. The command options are:
|
|
21
22
|
|
|
22
23
|
```text
|
|
23
24
|
diagonal check [dir] [--fix] [--json]
|
|
@@ -34,10 +35,25 @@ Each diagnostic prints as `path:line:column severity message`. The command exits
|
|
|
34
35
|
From the workspace root, run:
|
|
35
36
|
|
|
36
37
|
```bash
|
|
37
|
-
diagonal make:migration backfill_post_slug
|
|
38
|
+
npx diagonal make:migration backfill_post_slug
|
|
38
39
|
```
|
|
39
40
|
|
|
40
|
-
The command creates `migrations/YYYYMMDDHHmmss_backfill_post_slug.ts` with the current timestamp.
|
|
41
|
+
The command creates `migrations/YYYYMMDDHHmmss_backfill_post_slug.ts` with the current timestamp. Edit the generated workflow, then run `diagonal check` before committing. Keep deployed files unchanged. Use a new migration filename for a correction.
|
|
42
|
+
|
|
43
|
+
## Update the SDK packages
|
|
44
|
+
|
|
45
|
+
From the workspace root, run:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npx diagonal update
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The command reads each `@diagonal-hq` package in `dependencies` and `devDependencies` of `package.json`:
|
|
52
|
+
|
|
53
|
+
- A `file:` tarball, such as `file:../scripts/dist/npm/diagonal-hq-cli-0.35.6.tgz`, moves to the tarball of that package with the highest version in the same directory. A `file:` path that is not a tarball stays. For a `@diagonal-hq/cli` tarball, the command also points the `@diagonal-hq/workflow-script-compiler-*` overrides at the compiler tarballs that the new CLI needs in that directory. Then it removes the `@diagonal-hq` entries from `package-lock.json` and `node_modules`, because a rebuilt tarball keeps its file name.
|
|
54
|
+
- Every other specifier installs `<package>@latest` from npm. npm writes the new range into `package.json`.
|
|
55
|
+
|
|
56
|
+
Then the command runs `npm install`. It exits with 1 when a tarball directory has no tarball of a package or `npm install` fails, and with 2 for a usage error. Run `npx diagonal check` after an update. A CLI version without this command needs one manual install first, for example `npm install -D @diagonal-hq/cli@latest`.
|
|
41
57
|
|
|
42
58
|
## Workspace API credentials
|
|
43
59
|
|
|
@@ -650,7 +666,7 @@ export default defineNotificationTemplate({
|
|
|
650
666
|
|
|
651
667
|
The deploy stores each reference as the template editor stores it, so a send renders the same link. The page id of a page file is its uid, and the workflow id comes from the active deployment.
|
|
652
668
|
|
|
653
|
-
An email layout is the frame that templates fill in. Each field is a slot that a template fills with Liquid.
|
|
669
|
+
An email layout is the frame that templates fill in. Each field is a slot that a template fills with Liquid. A field with a `type` (`'text'`, `'url'`, `'email'`, or `'phone'`) holds a value of that type. A template fills it with Liquid text, or binds it to a value of the send with `{ variable: '<path>' }`.
|
|
654
670
|
|
|
655
671
|
```ts
|
|
656
672
|
import { defineEmailLayout } from '@diagonal-hq/cli';
|
|
@@ -661,11 +677,26 @@ export default defineEmailLayout({
|
|
|
661
677
|
body: { file: './body.liquid' },
|
|
662
678
|
fields: {
|
|
663
679
|
heading: { label: 'Heading', required: true },
|
|
664
|
-
body: { label: 'Body', required: true }
|
|
680
|
+
body: { label: 'Body', required: true },
|
|
681
|
+
action_url: { label: 'Action URL', type: 'url' }
|
|
665
682
|
}
|
|
666
683
|
});
|
|
667
684
|
```
|
|
668
685
|
|
|
686
|
+
A template binds a typed field to a variable. The send reads the value at the path and checks it against the type of the field. It does not render the value as Liquid.
|
|
687
|
+
|
|
688
|
+
```ts
|
|
689
|
+
email: {
|
|
690
|
+
subject: 'Your invoice',
|
|
691
|
+
layout: EmailLayouts.Standard.uid,
|
|
692
|
+
fields: {
|
|
693
|
+
heading: 'Thank you for your payment',
|
|
694
|
+
body: { file: './receipt.email.liquid' },
|
|
695
|
+
action_url: { variable: 'invoice_url' }
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
```
|
|
699
|
+
|
|
669
700
|
### NotificationTypes and EmailLayouts
|
|
670
701
|
|
|
671
702
|
The build writes `generated/notification-types.ts`, which exports `NotificationTypes`, and `generated/email-layouts.ts`, which exports `EmailLayouts`. `diagonal check` writes them too. Import them from `@app/generated/notification-types` and `@app/generated/email-layouts`.
|
|
@@ -674,7 +705,7 @@ Each name comes from a path, not from the file, as `Workflows` and `Skills` do:
|
|
|
674
705
|
|
|
675
706
|
- `notifications/member-welcome/type.ts` is `NotificationTypes.MemberWelcome`, the studly case of the folder name. An entry holds `uid`, `slug`, `name`, `variables` (by key, with the same metadata as a resource field), and `templates`.
|
|
676
707
|
- `notifications/member-welcome/standard.template.ts` is `NotificationTypes.MemberWelcome.templates.Standard`, the studly case of the file name. An entry holds `uid`, `slug`, `name`, and `channels: { email, sms }`.
|
|
677
|
-
- `email-layouts/standard/layout.ts` is `EmailLayouts.Standard`, the studly case of the folder name. An entry holds `uid`, `slug`, `name`, and `fields` (by key, each with `key`, `label`, `description`, and `required`).
|
|
708
|
+
- `email-layouts/standard/layout.ts` is `EmailLayouts.Standard`, the studly case of the folder name. An entry holds `uid`, `slug`, `name`, and `fields` (by key, each with `key`, `label`, `description`, and `required`, and `type` for a typed field).
|
|
678
709
|
|
|
679
710
|
The modules hold no subject, Liquid, or layout body, because a page that reads an entry ships it to every viewer. A folder or file name whose studly case is not an identifier, such as `2nd-reminder`, and two names with the same studly case, are errors. The built-in layout `'default'` has no entry: write `'default'`, or leave `layout` out.
|
|
680
711
|
|
|
@@ -773,10 +804,10 @@ The editor checks the shape of each definition. `diagonal check` and the build a
|
|
|
773
804
|
- Each path in a type's `recipient.relations` follows relation fields from the recipient resource, for example `'account'` or `'account.owner'`. Each path in a record variable's `relations` follows relation fields from the variable's resource in the same way. A path has at most 5 relations and passes through a resource only once; only its last relation can return to a resource that the path already reached. Each list has at most 100 paths, and no path twice.
|
|
774
805
|
- A type's `recipient` resource declares the Notifiable capability. When a template of the type has an email, the resource maps `email_field`. When a template has an SMS, the resource maps `phone_field`. The resource check makes sure that `email_field` names an `email` field and `phone_field` names a `phone` or `text` field.
|
|
775
806
|
- A type has at least one template, and its `defaultTemplate` names one of them.
|
|
776
|
-
- A template's folder has a `type.ts`. A template has no `type`. A template has an email, an SMS, or both. An email `subject` has 1 to 10,000 characters. `email.layout` names a layout of the workspace files, or `'default'`. An email's `fields` match the fields of its layout and fill each required field. A layout field key differs from `record` and from each variable key of the template's type. The built-in layout has the field `content`. An SMS `body` is not empty.
|
|
807
|
+
- A template's folder has a `type.ts`. A template has no `type`. A template has an email, an SMS, or both. An email `subject` has 1 to 10,000 characters. `email.layout` names a layout of the workspace files, or `'default'`. An email's `fields` match the fields of its layout and fill each required field. Only a field with a `type` takes `{ variable }`, and the first segment of its path is a variable of the type, `record` when the type has a `recipient`, or `workspace`. A `text` or `url` field can also read `ref.<key>` of a `page.url` reference of the template. A layout field key differs from `record` and from each variable key of the template's type. The built-in layout has the field `content`. An SMS `body` is not empty.
|
|
777
808
|
- A template has at most 50 references. A reference key starts with a lowercase letter, has only a-z, 0-9, and `_`, and has at most 64 characters. A label has at most 255 characters.
|
|
778
809
|
- A `page.url` or `workflow.url` reference names a page or a workflow of the workspace. An unknown `Pages` or `Workflows` name is an error at its line and column. `params` has a value for each required route parameter of the page or workflow and no other name. A `workflow.url` workflow has a `request` trigger. A `calendar.generate_link` resource has the `eventable` capability. The first segment of a `{ variable }` path is a variable of the type, or `record` when the type has a `recipient`.
|
|
779
|
-
- A layout's slug and its folder name are not `default`, and its `body` is not empty. A layout field key starts with a letter or `_` and has only letters, digits, and `_`. Each field has a `label` of at most 255 characters.
|
|
810
|
+
- A layout's slug and its folder name are not `default`, and its `body` is not empty. A layout field key starts with a letter or `_` and has only letters, digits, and `_`. Each field has a `label` of at most 255 characters. A field `type` is `'text'`, `'url'`, `'email'`, or `'phone'`. Leave it out for a Liquid field.
|
|
780
811
|
- A schedule has a `name` of 1 to 255 characters. Its `type` names a type of the workspace files that has a `recipient`, and its `template` names a template of that type that has an email. `source.resource` is a resource of the workspace. A schedule's `filters` is a filter tree with a known operator in each condition.
|
|
781
812
|
- A schedule's `dateField` is a date, datetime, or event schedule field of the source resource. Exact timing needs a datetime or event schedule field. `offsets` holds 1 to 30 distinct durations.
|
|
782
813
|
- 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.
|