@diagonal-hq/cli 0.42.2 → 0.42.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
@@ -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. `--input` gives the workflow input as a JSON object. `--json` prints the API response.
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.
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, 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 workflow that is not manual, 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?, 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 tree of a `recordEvent` trigger's `filters` (see [Policies](#policies)), and the run-as rules. A `recordEvent`, `recordSchedule`, `scheduled`, or `workflowEvent` workflow needs `runAs`.
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 tree of a `recordEvent` trigger's `filters` (see [Policies](#policies)), and the run-as rules. 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
  - 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.
96
96
  - 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.
97
97
  - Each `skills/<name>.md` is a workspace AI skill: YAML front matter with `uid`, `name`, `description`, and optionally `enabled` and `manualOnly`, then a Markdown body with its instructions. The build validates the front matter, the uid (see [Definition uids and slugs](#definition-uids-and-slugs)), and that no two skill files declare one `name`. The build writes `generated/skills.ts`, which exports `Skills`: the `uid`, `name`, and `description` of each skill, keyed by the studly case of its file name, so `skills/front-desk.md` is `Skills.FrontDesk`. It never holds the instructions. Import it from `@app/generated/skills`. The build replaces each `Skills.<Name>.<key>` reference in a page or workflow with its value, as it does for `Resources`. A file name that gives no identifier, and a second file with one name, get no entry and a warning.