@diagonal-hq/cli 0.42.11 → 0.42.12

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
@@ -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)), 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.
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 request workflow takes `authorizer`, as a page does: `'authenticated'`, or `{ resource, permissions }` with an authenticatable resource as `Resources.<Name>.slug` and permission uids as `Permissions.<Name>.uid` or `SystemPermissions.<Name>.uid`. A caller needs any one of the permissions. The build refuses a resource that is not authenticatable and a permission that the workspace does not declare. A request workflow without `authorizer` is public. 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.
@@ -469,7 +469,7 @@ export default definePermission({
469
469
  - A `permissions.ts` file at the root is an error: move each permission to `permissions/<slug>.ts`.
470
470
  - `@diagonal-hq/cli` exports `SystemPermissions`: the fixed `uid`, the `slug`, and the `name` of each system permission, such as `SystemPermissions.ManagePages`.
471
471
 
472
- A page authorizer names permissions by uid. A viewer needs one of them:
472
+ A page authorizer and a request workflow authorizer name permissions by uid. A viewer or a caller needs one of them:
473
473
 
474
474
  ```tsx
475
475
  import { Permissions } from '@app/generated/permissions';