@protobase/server 0.19.8 → 0.19.10

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.
@@ -38,9 +38,11 @@ const valueColorErrors = (view, model) => Object.entries(view.fields).flatMap(([
38
38
  if (field?.type !== "enum") return [`value colours of "${name}" need an enum field`];
39
39
  return Object.keys(hints.valueColors).filter((value) => !field.enumValues?.includes(value)).map((value) => `value colour "${value}" is not a value of "${name}"`);
40
40
  });
41
- const multilineErrors = (view, model) => Object.entries(view.fields).flatMap(([name, hints]) => {
41
+ const textHints = ["multiline", "markdown"];
42
+ const textHintErrors = (view, model) => Object.entries(view.fields).flatMap(([name, hints]) => {
42
43
  const field = model.fields[name];
43
- return hints.multiline && field && field.type !== "text" ? [`multiline "${name}" needs a text field, not ${field.type}`] : [];
44
+ if (!field || field.type === "text") return [];
45
+ return textHints.filter((hint) => hints[hint]).map((hint) => `${hint} "${name}" needs a text field, not ${field.type}`);
44
46
  });
45
47
  const linkErrors = (view, model, models, pages) => view.actions.flatMap(({ name, label, run }) => {
46
48
  if (run?.kind !== "link") return [];
@@ -54,6 +56,7 @@ const linkErrors = (view, model, models, pages) => view.actions.flatMap(({ name,
54
56
  source: model
55
57
  }).map((error) => `action "${name}": ${error}`) : [];
56
58
  });
59
+ const createErrors = (view, pages) => view.create && !pages.has(view.create.page) ? [`create: unknown page "${view.create.page}"`] : [];
57
60
  const unknownFieldErrors = (view, model) => {
58
61
  const unknown = (names, what) => names.filter((name) => !Object.hasOwn(model.fields, name)).map((name) => `${what} names field "${name}", which ${model.name} does not have`);
59
62
  return [
@@ -92,7 +95,7 @@ const listOfErrors = (model, name, models) => {
92
95
  * has a related section, a cards display's or gallery's photos or a cards display's favorite button, a `listOf`, a "Save search" button or a
93
96
  * `searchesOf` that do not fit the resources, cards
94
97
  * displays of one list that name different photos, a map that cannot show the
95
- * record's position or a map display that cannot find the records in its view, or a link to an address the app does not have.
98
+ * record's position or a map display that cannot find the records in its view, a link to an address the app does not have, or a create page that is not one of `pages`.
96
99
  */
97
100
  const checkViews = (registry, views, pages = [], fieldTypes = {}) => {
98
101
  const models = Object.fromEntries(registry.entries.map((entry) => [entry.name, entry.model]));
@@ -115,7 +118,7 @@ const checkViews = (registry, views, pages = [], fieldTypes = {}) => {
115
118
  ...unknownFieldErrors(view, model),
116
119
  ...valueLabelErrors(view, model),
117
120
  ...valueColorErrors(view, model),
118
- ...multilineErrors(view, model),
121
+ ...textHintErrors(view, model),
119
122
  ...widgetErrors(view, model, fieldTypes),
120
123
  ...related,
121
124
  ...photos,
@@ -123,7 +126,8 @@ const checkViews = (registry, views, pages = [], fieldTypes = {}) => {
123
126
  ...listOf,
124
127
  ...searches,
125
128
  ...maps,
126
- ...linkErrors(view, model, models, pageNames)
129
+ ...linkErrors(view, model, models, pageNames),
130
+ ...createErrors(view, pageNames)
127
131
  ].map((problem) => `View "${view.resource}": ${problem}`);
128
132
  });
129
133
  if (problems.length > 0) throw new Error(`The views do not match the resources:\n${problems.map((problem) => ` - ${problem}`).join("\n")}`);
@@ -195,7 +195,8 @@ const viewShape = (resource, model, models, prompted) => shapes.object({
195
195
  saveSearch: shapes.map((search) => prompted.has(search.resource) || models[search.resource] ? search : void 0),
196
196
  searchesOf: shapes.map((searches) => searchesOfFor(searches, resource, models)),
197
197
  import: shapes.data,
198
- export: shapes.data
198
+ export: shapes.data,
199
+ create: shapes.data
199
200
  });
200
201
  /**
201
202
  * The view with every reference to a field the caller cannot read removed: list columns, sort, search and displays,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/server",
3
- "version": "0.19.8",
3
+ "version": "0.19.10",
4
4
  "description": "The Protobase REST API as a Hono app, with Better Auth sign-in.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -30,9 +30,9 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "@better-auth/passkey": "^1.7.7",
33
- "@protobase/layout": "0.19.8",
34
- "@protobase/query": "0.19.8",
35
- "@protobase/schema": "0.19.8",
33
+ "@protobase/layout": "0.19.10",
34
+ "@protobase/query": "0.19.10",
35
+ "@protobase/schema": "0.19.10",
36
36
  "@react-email/render": "^2.1.0",
37
37
  "@scalar/hono-api-reference": "^0.12.10",
38
38
  "@sentry/core": "^11.7.0",