@diagonal-hq/cli 0.42.9 → 0.42.11

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
@@ -9,7 +9,7 @@ This package is the authoring SDK for file-based workspaces. A workspace reposit
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
10
  - The `diagonal update` command. It updates the `@diagonal-hq` packages of the workspace and installs them.
11
11
  - The `diagonal assets upload` and `diagonal assets list` commands. They upload Application Assets, update `assets.ts`, and list immutable references.
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
+ - The `diagonal workflows`, `diagonal run`, and `diagonal logs` commands. They list the deployed workflows, run a workflow by its file path, and print recent runs with the error of each failed run.
13
13
 
14
14
  ## Check a workspace
15
15
 
@@ -73,11 +73,11 @@ diagonal logs [path | execution id] [--status <status>] [--limit <1-100>] [--jso
73
73
  ```
74
74
 
75
75
  - `diagonal workflows` prints the path, the trigger type, and the title of each workflow of the active deployment. `--json` prints the API response, which also has each workflow id and version id.
76
- - `diagonal run workflows/seed-catalog.ts` runs the manual workflow at that path in the active deployment and waits for it. It prints the terminal status, the execution id, and the output. A workflow with `executionMode: 'async'` does not wait: it prints `execution.pending` and the execution id of the queued run. Use `diagonal logs <execution id>` to read its result. `--input` gives the workflow input as a JSON object. `--json` prints the API response.
76
+ - `diagonal run workflows/seed-catalog.ts` runs the workflow at that path in the active deployment and waits for it. It prints the terminal status, the execution id, and the output. A manual or request workflow with `executionMode: 'async'` does not wait: it prints `execution.pending` and the execution id of the queued run. Use `diagonal logs <execution id>` to read its result. `--input` gives the workflow input as a JSON object. A record event, record lifecycle, or record schedule workflow runs against the record whose id `--input` gives as `record`, for example `--input '{"record":"<record id>"}'`. `--json` prints the API response.
77
77
 
78
78
  - `diagonal logs` prints the recent runs of the deployed workflows, oldest first: the start time, the status and the response status, the path, the trigger, the duration, and the execution id. Under a failed run it prints the error type and message, and each field error. A path narrows the list to one workflow. `--status` takes `success`, `error` (a declared failure or an exception), `exception`, `started`, or `pending`. `--limit` sets the number of runs (default 20). `diagonal logs <execution id>` prints one run with its full error or its output. `--json` prints the API response.
79
79
 
80
- `diagonal run` exits with 0 when the run succeeds or is queued, with 1 when the request or the run fails, and with 2 for a usage error or a missing environment variable. A workflow that is not manual, or a path that the active deployment does not have, is a request failure.
80
+ `diagonal run` exits with 0 when the run succeeds or is queued, with 1 when the request or the run fails, and with 2 for a usage error or a missing environment variable. A record workflow without a `record` in its input, a migration, or a path that the active deployment does not have, is a request failure.
81
81
 
82
82
  ## What the checks do
83
83
 
@@ -91,7 +91,7 @@ The build reads each file with a parser. It runs only the workflow and migration
91
91
  - 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.
92
92
  - Every file that names a page imports `Pages` from `@app/generated/pages`: `diagonal.config.ts`, `resource.ts` files, pages, layouts, components, and menus. There is one `Pages` object. `Pages` is not a global, and `@diagonal-hq/pages` does not export it. A file that uses `Pages` without the import fails the check with `'Pages' is not defined`. Every file names a page by its uid, `Pages.<Name>.uid`, as it names a workflow by `Workflows.<Name>.slug`. Pages, layouts, and components pass the uid to `utils` from `@diagonal-hq/pages`: `utils.page.url(Pages.Members.uid)`, `utils.page.url(Pages.Members_$Id.uid, { id })`, `utils.page.navigate(Pages.Members.uid)`, and `utils.page.navigate(Pages.Members_$Id.uid, { id }, { openInNewTab: true })`. A menu item is `{ kind: 'page', label, page: Pages.Members.uid }`. A config or resource file names a page with `Pages.<Name>.uid` too. See [Page reference settings](#page-reference-settings). The check fails at an unknown name, such as a stale name after a file move: `Unknown page "Pages.X". Each name in Pages is a file in pages/`. The type check also fails at a call without the route parameters of the page, at route parameters for a page without any, and at a menu item for a page with route parameters. The error names the page and its route, such as `Pages.Members_$Id has the route /members/{id}. Pass its route parameters as params.`
93
93
  - Pages, layouts, and components go through the page lint gate: syntax, scope, the component return shape, and a type check against the page Sdk contract and the workspace resources. A page imports the Page SDK members that it uses from `@diagonal-hq/pages`, such as `import { resource, useRecords } from '@diagonal-hq/pages'`. A page names a resource by slug, for example `resource(Resources.Members.slug)`.
94
- - Each `workflows/<name>.ts` is a script workflow. Its default export is `defineWorkflow({ uid, name, trigger, runAs?, executionMode?, input?, output?, validate? }, handler)` from `@diagonal/workflow`, the same shape as `definePage(options, component)`. The config is the first argument and must be an object literal. The build reads every option except `input`, `output`, and `validate` as static data and never runs the handler to find it. `input` is a `v.object({...})` schema, or a top-level `const` of one, which the script compiler reads. `output` is a `v` schema of the handler's return value, which the script compiler reads the same way; the API documentation of a request workflow shows it, and each run's return value is checked against it. `validate` is a function that runs after the input check and before the handler, with the same input type. It returns errors keyed by field, and any error ends the run with a 422. The editor checks the config against `WorkflowConfig` from `@diagonal-hq/cli`. The build validates it: the uid (see [Definition uids and slugs](#definition-uids-and-slugs)), the trigger fields, the resources (see [Resource references](#resource-references)), the workflow references of `workflowEvent` triggers (see [Workflow references](#workflow-references)), the filter trees of a `recordEvent` or `recordLifecycle` trigger's `filters` and `previousFilters` (see [Policies](#policies)), and the run-as rules. `previousFilters` matches the record before the change, so a trigger runs on a change from one value to another. Only the `updated` event and the `updating` hook take it. A `recordEvent`, `recordSchedule`, `scheduled`, or `workflowEvent` workflow needs `runAs`. A `manual` or `request` workflow can set `executionMode: 'async'` to run in the queue: the caller gets the queued run at once, without the output. Without it, the workflow runs synchronously, with a 55-second limit. The build refuses `executionMode` on another trigger, which has a fixed mode.
94
+ - Each `workflows/<name>.ts` is a script workflow. Its default export is `defineWorkflow({ uid, name, trigger, runAs?, executionMode?, input?, output?, validate? }, handler)` from `@diagonal/workflow`, the same shape as `definePage(options, component)`. The config is the first argument and must be an object literal. The build reads every option except `input`, `output`, and `validate` as static data and never runs the handler to find it. `input` is a `v.object({...})` schema, or a top-level `const` of one, which the script compiler reads. `output` is a `v` schema of the handler's return value, which the script compiler reads the same way; the API documentation of a request workflow shows it, and each run's return value is checked against it. `validate` is a function that runs after the input check and before the handler, with the same input type. It returns errors keyed by field, and any error ends the run with a 422. The editor checks the config against `WorkflowConfig` from `@diagonal-hq/cli`. The build validates it: the uid (see [Definition uids and slugs](#definition-uids-and-slugs)), the trigger fields, the resources (see [Resource references](#resource-references)), the workflow references of `workflowEvent` triggers (see [Workflow references](#workflow-references)), the filter trees of a `recordEvent` or `recordLifecycle` trigger's `filters` and `previousFilters` (see [Policies](#policies)), the relation paths of a `recordEvent` trigger's `relations`, and the run-as rules. `previousFilters` matches the record before the change, so a trigger runs on a change from one value to another. Only the `updated` event and the `updating` hook take it. `relations` lists the relations to load with the trigger record, such as `['member', 'member.company']`: each part of a path is the key of a relation field of the resource that the part before it relates to. The deploy checks the relations of a trigger on the Roles or Permissions resource against the stored resource. A `recordEvent`, `recordSchedule`, `scheduled`, or `workflowEvent` workflow needs `runAs`. A `manual` or `request` workflow can set `executionMode: 'async'` to run in the queue: the caller gets the queued run at once, without the output. Without it, the workflow runs synchronously, with a 55-second limit. The build refuses `executionMode` on another trigger, which has a fixed mode.
95
95
  - `paused: true` in a workflow config pauses the workflow. It deploys, but no route, trigger, or manual run starts it. A migration cannot be paused.
96
96
  - A `recordSchedule` trigger runs each offset from the `dateField` of each record. `timing` defaults to `'day'`, which runs at 8 a.m. in the workspace timezone on the day of the field plus the offset, and ignores the time of the field. Day timing takes whole-day offsets only, so the build refuses an offset such as `'-PT2H'` or `'+PT0M'`. `timing: 'exact'` runs at the time of the field plus the offset, for example 2 hours before a class with `offsets: ['-PT2H']`. Exact timing needs a datetime field.
97
97
  - A workflow with `export const config = { title, ... }` and `export default defineWorkflow(handler)` or `defineWorkflow(input, handler)` still builds. The build warns at the config export and at `title`. Move the config into the `defineWorkflow` call and rename `title` to `name`. A workflow cannot have both forms of config, or both `name` and `title`. A `validateInput` export still runs before the handler, with a warning; move it into the config as `validate`. A workflow cannot have both.