@protobase/layout 0.23.3 → 0.23.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.
@@ -7,6 +7,8 @@ export type PageCheckInput = {
7
7
  actions: (resource: string) => ReadonlySet<string>;
8
8
  /** The composed pages' names, which links may go to; `checkPages` fills them in. */
9
9
  pages?: ReadonlySet<string>;
10
+ /** The resources whose view opens a create page, which a create link may give values of any name. */
11
+ createPages?: ReadonlySet<string>;
10
12
  };
11
13
  /** Throws one error listing every problem of every page, including names that collide with each other or a resource. */
12
14
  export declare const checkPages: (pages: PageModel[], input: PageCheckInput) => void;
@@ -24,7 +24,7 @@ const text = (value) => typeof value === "string" ? value : void 0;
24
24
  const elementResource = (node, scope) => text(node.props.resource) ?? (scope.record ? scope.resource : void 0);
25
25
  /** The record a link's `{field}` placeholders read: the one around it, when there is one. */
26
26
  const linkSource = (models, scope) => scope.record && scope.resource !== void 0 ? models[scope.resource] : void 0;
27
- const nodeProblems = (node, scope, { models, actions, pages }) => {
27
+ const nodeProblems = (node, scope, { models, actions, pages, createPages }) => {
28
28
  const problems = [];
29
29
  const resource = elementResource(node, scope);
30
30
  const own = text(node.props.resource);
@@ -75,7 +75,8 @@ const nodeProblems = (node, scope, { models, actions, pages }) => {
75
75
  if (node.props.to !== void 0) problems.push(...addressErrors(node.props.to, {
76
76
  models,
77
77
  pages,
78
- source: linkSource(models, scope)
78
+ source: linkSource(models, scope),
79
+ createPages
79
80
  }).map((error) => `to: ${error}`));
80
81
  break;
81
82
  case "Show": problems.push(...conditionProblems(String(node.props.when), scope.record ? scope.resource : void 0, models));
@@ -10,6 +10,8 @@ export type CallerAccess = {
10
10
  }>;
11
11
  /** The named actions in the caller's view of a resource. */
12
12
  actions: (resource: string) => ReadonlySet<string>;
13
+ /** The resources whose view for the caller opens a create page, which a create link may give values of any name. */
14
+ createPages?: ReadonlySet<string>;
13
15
  };
14
16
  /**
15
17
  * The page as one caller may see it, or `undefined` when its roles leave the caller out. Every element that names a
@@ -69,7 +69,8 @@ const prune = (node, scope, access) => {
69
69
  case "Action": return resource !== void 0 && model && access.actions(resource).has(String(node.props.name)) ? node : null;
70
70
  case "Link": return node.props.to === void 0 || addressErrors(node.props.to, {
71
71
  models,
72
- source: linkSource(models, scope)
72
+ source: linkSource(models, scope),
73
+ createPages: access.createPages
73
74
  }).length === 0 ? node : null;
74
75
  case "Show": {
75
76
  const parsed = parseCondition(String(node.props.when));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/layout",
3
- "version": "0.23.3",
3
+ "version": "0.23.5",
4
4
  "description": "Composed pages for Protobase, written as JSX that compiles to plain data, with its JSX runtime.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -31,7 +31,7 @@
31
31
  "access": "public"
32
32
  },
33
33
  "dependencies": {
34
- "@protobase/schema": "0.23.3",
34
+ "@protobase/schema": "0.23.5",
35
35
  "aip-parsers": "^1.0.0"
36
36
  }
37
37
  }