@diagonal-hq/cli 0.12.4 → 0.12.5
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 +2 -1
- package/dist/cli.mjs +12 -0
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -60,6 +60,7 @@ The build reads each file with a parser. It runs only the workflow tests.
|
|
|
60
60
|
- 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`. Workflow scripts can also import `@diagonal/workflow` and `@diagonal/workflow/workspace`. Other external imports in these source files are rejected.
|
|
61
61
|
- The second argument of `definePage`, and the default export of a layout or component file, must be one function.
|
|
62
62
|
- Each page has a key that is unique in the workspace: a camelCase name of at most 64 letters and digits, such as `members`. The page's id comes from the key. Without a `key` option, the key comes from the file path below `pages/`: `pages/members/[id].tsx` is `membersId`, `pages/404.tsx` is `page404`, and `pages/index.tsx` is `home`. Set `key` when the page must keep its identity and its `Pages.<key>` links after a file move. Two pages with the same key fail at the second file.
|
|
63
|
+
- Each page also has a `uid`. See [Definition uids and slugs](#definition-uids-and-slugs). Nothing reads it yet: the key still gives the page its id.
|
|
63
64
|
- Pages, layouts, and components link to a page with `Pages.<key>`: `Pages.members.url()`, `Pages.member.url({ id })`, and `Pages.members.navigate()`. `Pages` needs no import, and `import { Pages } from '@diagonal/pages'` also works. The check fails at an unknown key and at a call without the route parameters of the page.
|
|
64
65
|
- 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 names a resource by slug, for example `Sdk.resource(Resources.Members.slug)`.
|
|
65
66
|
- Each `workflows/<name>.ts` is a script workflow. It has one `export const config = { uid, title, trigger, runAs? } satisfies WorkflowConfig` and one `export default defineWorkflow(...)`. The config must be a static literal. 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 paths of `workflowEvent` triggers, and the run-as rules. A `recordEvent`, `recordSchedule`, `scheduled`, or `workflowEvent` workflow needs `runAs`.
|
|
@@ -72,7 +73,7 @@ The build reads each file with a parser. It runs only the workflow tests.
|
|
|
72
73
|
|
|
73
74
|
## Definition uids and slugs
|
|
74
75
|
|
|
75
|
-
A definition can have two identity options. A resource, a workflow `config`, and the front matter of a skill file have a `uid`. No definition uses `slug` yet.
|
|
76
|
+
A definition can have two identity options. A resource, a page, a workflow `config`, and the front matter of a skill file have a `uid`. No definition uses `slug` yet.
|
|
76
77
|
|
|
77
78
|
- `uid` is the stable identity of the definition. Its value is a lowercase UUID string literal, such as `uid: '3f2b8c1e-7d4a-4e9b-a6c5-1d0e9f8a7b6c'`. In skill front matter, it is a YAML string, such as `uid: 3f2b8c1e-7d4a-4e9b-a6c5-1d0e9f8a7b6c`. A file move, a file rename, or a name change keeps the uid. Do not change a uid.
|
|
78
79
|
- `slug` is the editable, user-facing name of the definition. It is kebab-case: lowercase letters and digits in groups that one `-` joins, such as `job-postings`. A slug change keeps the uid.
|
package/dist/cli.mjs
CHANGED
|
@@ -300015,6 +300015,7 @@ function derivedPageKey(path) {
|
|
|
300015
300015
|
var COMPONENT_NAME_PATTERN = /^[A-Z][A-Za-z0-9]*$/;
|
|
300016
300016
|
var PAGE_AUTHORIZERS = /* @__PURE__ */ new Set(["authenticated"]);
|
|
300017
300017
|
var PAGE_KEYS = /* @__PURE__ */ new Set([
|
|
300018
|
+
"uid",
|
|
300018
300019
|
"key",
|
|
300019
300020
|
"route",
|
|
300020
300021
|
"name",
|
|
@@ -302961,6 +302962,11 @@ function uidDefinitionNodes(kind, ast) {
|
|
|
302961
302962
|
const platform = node.type === "ObjectExpression" && node.properties.some((property) => property.type === "ObjectProperty" && propertyKey(property) === "platform");
|
|
302962
302963
|
return platform ? [] : [{ type: "resource", node }];
|
|
302963
302964
|
}
|
|
302965
|
+
case "page": {
|
|
302966
|
+
const { declaration } = defaultExportOf(ast, { helpers: "anywhere", allowAppImports: true });
|
|
302967
|
+
const [node] = expectDefineCall(declaration, "definePage", 2);
|
|
302968
|
+
return [{ type: "page", node }];
|
|
302969
|
+
}
|
|
302964
302970
|
case "workflow": {
|
|
302965
302971
|
const node = workflowConfigObject(ast);
|
|
302966
302972
|
return node === null ? [] : [{ type: "workflow", node }];
|
|
@@ -303063,6 +303069,9 @@ function buildWorkspace(root, { assetCatalog = null, writeSource = false } = {})
|
|
|
303063
303069
|
case "page": {
|
|
303064
303070
|
const page = buildPage(path, source, ast, root, resourcesBinding(ast, names2));
|
|
303065
303071
|
output.pages.push(page);
|
|
303072
|
+
for (const { type, node } of uidDefinitionNodes(kind, ast)) {
|
|
303073
|
+
uidPositions.set(path, uidDefinitions.push({ type, path, source, node }) - 1);
|
|
303074
|
+
}
|
|
303066
303075
|
diagnostics.push(...slugStringWarnings(path, page.resourceNodes.meta, names2));
|
|
303067
303076
|
uiEntries.push({ path, source, ast });
|
|
303068
303077
|
break;
|
|
@@ -303126,6 +303135,9 @@ function buildWorkspace(root, { assetCatalog = null, writeSource = false } = {})
|
|
|
303126
303135
|
for (const resource of output.resources) {
|
|
303127
303136
|
resource.uid = uidCheck.uids[uidPositions.get(resource.path)];
|
|
303128
303137
|
}
|
|
303138
|
+
for (const page of output.pages) {
|
|
303139
|
+
page.uid = uidCheck.uids[uidPositions.get(page.path)];
|
|
303140
|
+
}
|
|
303129
303141
|
if (output.config === null && !diagnostics.some((diagnostic2) => diagnostic2.path === CONFIG_PATH)) {
|
|
303130
303142
|
diagnostics.push(diagnosticAt(CONFIG_PATH, null, "The workspace has no diagonal.config.ts"));
|
|
303131
303143
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -251,7 +251,7 @@ export type PageAuthorizer =
|
|
|
251
251
|
permissions?: readonly string[];
|
|
252
252
|
};
|
|
253
253
|
|
|
254
|
-
export type PageDefinition = {
|
|
254
|
+
export type PageDefinition = UidOption & {
|
|
255
255
|
/**
|
|
256
256
|
* The page's identity, unique in the workspace: a camelCase name of at most
|
|
257
257
|
* 64 letters and digits that starts with a lowercase letter, such as
|