@diagonal-hq/cli 0.20.3 → 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
@@ -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
 
@@ -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.