@protobase/cli 0.19.15 → 0.20.0

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.
@@ -16,11 +16,30 @@ const blockSort = (node, model, view) => {
16
16
  return node.type === "RecordRow" ? listSort(model, view) : void 0;
17
17
  };
18
18
  const title = (node) => text(node.props.title) ?? text(node.props.label);
19
- /** The reads of a composed page: each block that lists records, with its filter and sort. */
19
+ const chartShape = (page, node, model) => {
20
+ const source = text(node.props.filter);
21
+ const filter = configFilter(model, source);
22
+ const groupBy = String(node.props.groupBy);
23
+ const named = title(node);
24
+ return {
25
+ resource: model.name,
26
+ request: `GET /${model.name}:aggregate?group_by=${groupBy}${source?.trim() ? `&filter=${source}` : ""}`,
27
+ from: `page "${page.name}", <Chart${named ? ` "${named}"` : ""}>`,
28
+ query: {
29
+ ...filter && { filter },
30
+ groupBy
31
+ }
32
+ };
33
+ };
34
+ /** The reads of a composed page: each block that lists records, with its filter and sort, and each chart's grouping. */
20
35
  const pageShapes = (page, models, views) => {
21
36
  const shapes = [];
22
37
  walkTree(page.tree, (node) => {
23
38
  const model = node.custom ? void 0 : models[text(node.props.resource) ?? ""];
39
+ if (model && node.type === "Chart") {
40
+ shapes.push(chartShape(page, node, model));
41
+ return;
42
+ }
24
43
  if (!model || !listing.includes(node.type) || node.type === "RecordCard" && node.props.recordKey !== void 0) return;
25
44
  const source = text(node.props.filter);
26
45
  const filter = configFilter(model, source);
@@ -1,4 +1,5 @@
1
1
  import { all, any, anyOf, compare, configFilter, configSort, isTrue, sortText } from "./shape-filters.js";
2
+ import { isGroupChart } from "@protobase/schema/internal";
2
3
  //#region src/doctor/view-shapes.ts
3
4
  const numberTypes = [
4
5
  "integer",
@@ -94,6 +95,20 @@ const displayShapes = (model, view, models) => (view.list?.displays ?? []).flatM
94
95
  query: { filter }
95
96
  }];
96
97
  }
98
+ if (display.kind === "board") {
99
+ const by = model.fields[display.by];
100
+ if (!by) return [];
101
+ const sort = listSort(model, view);
102
+ return [{
103
+ resource: model.name,
104
+ request: request(model.name, `${by.name} = …`, sort),
105
+ from: `the board display "${display.name}"`,
106
+ query: {
107
+ filter: compare(by),
108
+ sort
109
+ }
110
+ }];
111
+ }
97
112
  const photos = display.kind === "cards" ? display.photos : void 0;
98
113
  const holder = photos && models[photos.resource];
99
114
  const field = holder?.fields[photos.field];
@@ -125,6 +140,16 @@ const searchesShapes = (view, models) => {
125
140
  }
126
141
  }];
127
142
  };
143
+ const chartShapes = (model, view, list) => {
144
+ const chart = view.chart;
145
+ if (!chart || !isGroupChart(chart) || !model.fields[chart.groupBy]) return [];
146
+ return [{
147
+ resource: model.name,
148
+ request: `GET /${model.name}:aggregate?group_by=${chart.groupBy}`,
149
+ from: `${list}'s chart`,
150
+ query: { groupBy: chart.groupBy }
151
+ }];
152
+ };
128
153
  const recentShapes = (model, view) => {
129
154
  const recent = view.nav?.recent;
130
155
  if (!recent) return [];
@@ -141,8 +166,8 @@ const recentShapes = (model, view) => {
141
166
  }];
142
167
  };
143
168
  /**
144
- * The reads a view's pages make: its list in its order, the filter widgets and their counts, its displays' maps and
145
- * photos, the records of its related sections and the photos of its galleries, the recent records in the sidebar and a saved search's new records.
169
+ * The reads a view's pages make: its list in its order, the filter widgets and their counts, its chart per value, its displays' maps,
170
+ * board columns and photos, the records of its related sections and the photos of its galleries, the recent records in the sidebar and a saved search's new records.
146
171
  */
147
172
  const viewShapes = (view, models) => {
148
173
  const model = models[view.resource];
@@ -158,6 +183,7 @@ const viewShapes = (view, models) => {
158
183
  },
159
184
  ...view.filters.flatMap((widget) => widgetShapes(model, widget, `${list}'s ${widget.kind === "dateRange" ? "date range" : widget.kind} filter`)),
160
185
  ...displayShapes(model, view, models),
186
+ ...chartShapes(model, view, list),
161
187
  ...view.layout.flatMap((item) => item.kind === "related" ? relatedShapes(item, model.name, models) : item.kind === "gallery" ? galleryShapes(item, model.name, models) : []),
162
188
  ...recentShapes(model, view),
163
189
  ...searchesShapes(view, models)
package/dist/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.19.15";
2
+ var version = "0.20.0";
3
3
  //#endregion
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/cli",
3
- "version": "0.19.15",
3
+ "version": "0.20.0",
4
4
  "description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -34,11 +34,11 @@
34
34
  "dependencies": {
35
35
  "@hono/node-server": "^2.1.3",
36
36
  "@hono/vite-dev-server": "^0.26.1",
37
- "@protobase/layout": "0.19.15",
38
- "@protobase/query": "0.19.15",
39
- "@protobase/schema": "0.19.15",
40
- "@protobase/server": "0.19.15",
41
- "@protobase/ui": "0.19.15",
37
+ "@protobase/layout": "0.20.0",
38
+ "@protobase/query": "0.20.0",
39
+ "@protobase/schema": "0.20.0",
40
+ "@protobase/server": "0.20.0",
41
+ "@protobase/ui": "0.20.0",
42
42
  "@react-email/render": "^2.1.0",
43
43
  "@scalar/hono-api-reference": "^0.12.10",
44
44
  "@tailwindcss/vite": "^4.3.3",