@protobase/schema 0.46.3 → 0.46.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.
@@ -36,7 +36,8 @@ export declare const addressWords: {
36
36
  export declare const appPath: (address: AppAddress, basePath?: string) => string;
37
37
  /**
38
38
  * The address `pathAndQuery` (below the base path) shows, or `undefined` for anything else: the root, the app's own
39
- * pages under `/-/`, or a path that is not one. A first segment in `pages` is a composed page, otherwise a resource.
39
+ * pages under `/-/`, or a path that is not one. A first segment in `pages` is a composed page, and a second one its
40
+ * tab; otherwise it is a resource.
40
41
  */
41
42
  export declare const readAppPath: (pathAndQuery: string, pages: ReadonlySet<string>) => AppAddress | undefined;
42
43
  //#endregion
@@ -93,7 +93,7 @@ const recordQuery = (address) => {
93
93
  /** The path of `address` below `basePath` (such as `/admin`), every name and key encoded the one way the app reads them. */
94
94
  const appPath = (address, basePath = "") => {
95
95
  switch (address.kind) {
96
- case "page": return `${basePath}/${encodeURIComponent(address.page)}`;
96
+ case "page": return `${basePath}/${encodeURIComponent(address.page)}${address.tab ? `/${encodeURIComponent(address.tab)}` : ""}`;
97
97
  case "create": return `${basePath}/${encodeURIComponent(address.resource)}/${addressWords.create}${valuesQuery(address.values)}`;
98
98
  case "record": return `${basePath}/${encodeURIComponent(address.resource)}/${encodeURIComponent(encodeKey(address.key))}${recordQuery(address)}`;
99
99
  case "list": return `${basePath}/${encodeURIComponent(address.resource)}${listQuery(address)}`;
@@ -114,7 +114,8 @@ const valuesQuery = (values = {}) => {
114
114
  const filterLayout = (value) => value === "bar" || value === "panel" ? value : void 0;
115
115
  /**
116
116
  * The address `pathAndQuery` (below the base path) shows, or `undefined` for anything else: the root, the app's own
117
- * pages under `/-/`, or a path that is not one. A first segment in `pages` is a composed page, otherwise a resource.
117
+ * pages under `/-/`, or a path that is not one. A first segment in `pages` is a composed page, and a second one its
118
+ * tab; otherwise it is a resource.
118
119
  */
119
120
  const readAppPath = (pathAndQuery, pages) => {
120
121
  const url = new URL(pathAndQuery, "http://app");
@@ -122,10 +123,11 @@ const readAppPath = (pathAndQuery, pages) => {
122
123
  if (!segments || segments.length === 0 || segments.length > 2) return void 0;
123
124
  const [first, second] = segments;
124
125
  if (first === "-") return void 0;
125
- if (pages.has(first)) return second === void 0 ? {
126
+ if (pages.has(first)) return {
126
127
  kind: "page",
127
- page: first
128
- } : void 0;
128
+ page: first,
129
+ ...second !== void 0 && { tab: second }
130
+ };
129
131
  if (second === addressWords.create) {
130
132
  const values = Object.fromEntries([...url.searchParams].filter(([, value]) => value !== ""));
131
133
  return {
package/dist/model.d.ts CHANGED
@@ -270,6 +270,8 @@ export type AppAddress = {
270
270
  kind: 'page';
271
271
  /** The page's name. */
272
272
  page: string;
273
+ /** The name of the page's tab shown (`<Tab name>`); the first tab when omitted. */
274
+ tab?: string;
273
275
  };
274
276
  /**
275
277
  * How a value is shown: `badge` as a coloured badge, `code` in monospace, `percent` with a % sign; a text field's
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/schema",
3
- "version": "0.46.3",
3
+ "version": "0.46.5",
4
4
  "description": "Resource, field, view and access definitions for Protobase configs.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {