@metabase/cli 0.5.12 → 0.5.13

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/dist/cli.mjs CHANGED
@@ -527,7 +527,7 @@ function trustSystemCa() {
527
527
  //#endregion
528
528
  //#region package.json
529
529
  var name = "@metabase/cli";
530
- var version = "0.5.12";
530
+ var version = "0.5.13";
531
531
  var description = "Metabase CLI";
532
532
  //#endregion
533
533
  //#region src/runtime/command-augment.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metabase/cli",
3
- "version": "0.5.12",
3
+ "version": "0.5.13",
4
4
  "description": "Metabase CLI",
5
5
  "license": "AGPL-3.0",
6
6
  "repository": {
@@ -1,3 +1 @@
1
1
  import { defineAction } from "@metabase/embedding-sdk-react/data-app";
2
-
3
- import { schema } from "./metabase.schema";
@@ -1,3 +1 @@
1
1
  import { defineQuery } from "@metabase/embedding-sdk-react/data-app";
2
-
3
- import { schema } from "./metabase.schema";
@@ -12,16 +12,16 @@ A data app writes through **table actions**: an insert, update or delete of one
12
12
  ```ts
13
13
  import { defineAction } from "@metabase/embedding-sdk-react/data-app";
14
14
 
15
- import { schema } from "./metabase.schema";
15
+ import { orders } from "./metabase.schema";
16
16
 
17
17
  export const updateOrder = defineAction({
18
18
  entityId: "J2mXq8sLb0vT5nYcW4kRd",
19
19
  kind: "row/update",
20
- table: schema.tables.orders,
20
+ table: orders,
21
21
  });
22
22
  ```
23
23
 
24
- - `kind` is `row/create`, `row/update` or `row/delete`; `table` is a table of `schema` (`data-app-data`). The table needs exactly one primary key, and its database needs data actions turned on (_Data actions on the database_): settle both before writing the export. Show the user the table and kind and add it once they agree; a request that already names the write ("let me add a note") is that agreement.
24
+ - `kind` is `row/create`, `row/update` or `row/delete`; `table` is a table of `src/metabase.schema.ts`, imported by its name, or `schema.tables.<table>` when the file exports only `schema`. The table needs exactly one primary key, and its database needs data actions turned on (_Data actions on the database_): settle both before writing the export. Show the user the table and kind and add it once they agree; a request that already names the write ("let me add a note") is that agreement.
25
25
  - `entityId` comes from `mb nano-id`, never invented; keep it when editing the export. The export's name is the action's name in Metabase.
26
26
  - There are no query actions and no SQL: a write a table action can't do (a computed value, several rows, a row matched by another column) is out of reach for the app — say so. Never copy an action from a data actions collection.
27
27
  - To drop an action, delete its export.
@@ -32,7 +32,7 @@ When the app needs a table or metric the Library lacks, stop: name what's missin
32
32
  cd <repo> && mb data-app generate-schema <slug> --profile <name>
33
33
  ```
34
34
 
35
- From the repository root, this writes `data_apps/<slug>/src/metabase.schema.ts`: the Library's published tables with their fields, segments and measures, and the Library's metrics, each keyed by its camelCased name, with its numeric ID. It exports `schema` (`import { schema } from "./metabase.schema"`). Fetch it again after the user publishes a table or changes its metadata, then `npm run typecheck`, which catches code still using a renamed or removed field. Never edit the file.
35
+ From the repository root, this writes `data_apps/<slug>/src/metabase.schema.ts`: the Library's published tables with their fields, segments and measures, and the Library's metrics, each keyed by its camelCased name, with its numeric ID. Fetch it again after the user publishes a table or changes its metadata, then `npm run typecheck`, which catches code still using a renamed or removed table, metric or field. Never edit the file.
36
36
 
37
37
  The numeric IDs are that instance's, so the dev preview runs against it alone; a production build runs each question by its `entityId` instead, on every instance the app is imported to.
38
38
 
@@ -44,7 +44,7 @@ The file runs to thousands of lines. Every table, field, segment, measure and me
44
44
  grep -n -B2 -E 'type: "(table|segment|measure|metric)"' src/metabase.schema.ts
45
45
  ```
46
46
 
47
- Choose the definitions from this list: `schema.tables.<table>.segments.<key>`, `schema.tables.<table>.measures.<key>`, `schema.metrics.<key>`.
47
+ Choose the definitions from this list. A table or metric listed as `export const <name> = {` is its own export: import the ones the app uses by that name (`import { orders, revenue } from "./metabase.schema"`), and reach a table's segments and measures as `orders.segments.<key>` and `orders.measures.<key>`. The bundle then holds only what the app imports, while `schema`, which the file also exports, holds every table and metric: never import it. A file whose tables and metrics are listed without `export const` (`orders: {`) exports only `schema`: there, write `schema.tables.<table>` and `schema.metrics.<key>` wherever the examples below import a table or metric by name.
48
48
 
49
49
  2. Read each table or metric the question uses from its line to the next line in the list: a table's fields, each with its metadata line, or a metric's dimensions.
50
50
 
@@ -60,9 +60,7 @@ import {
60
60
  orderBy,
61
61
  } from "@metabase/embedding-sdk-react/data-app";
62
62
 
63
- import { schema } from "./metabase.schema";
64
-
65
- const orders = schema.tables.orders;
63
+ import { orders, reviews } from "./metabase.schema";
66
64
 
67
65
  export const revenueByMonth = defineQuery({
68
66
  entityId: "Vh3kq0wYc8TnS2aJm1LxR",
@@ -73,13 +71,13 @@ export const revenueByMonth = defineQuery({
73
71
 
74
72
  export const latestReviews = defineQuery({
75
73
  entityId: "pW9dE4uNq7Zb1fGhK3sTy",
76
- source: schema.tables.reviews,
77
- orderBys: [orderBy(schema.tables.reviews.fields.createdAt, "desc")],
74
+ source: reviews,
75
+ orderBys: [orderBy(reviews.fields.createdAt, "desc")],
78
76
  limit: 20,
79
77
  });
80
78
  ```
81
79
 
82
- - `source` is a table of `schema`; `aggregations`, `breakouts`, `filters`, `orderBys`, `limit` and `fields` (the columns to keep) take its fields, its segments and measures, and the metrics of `schema.metrics` as aggregations (`aggregations: [schema.metrics.revenue]`). A field that isn't the table's, or an operator its type doesn't take, fails to compile.
80
+ - `source` is a table of `src/metabase.schema.ts`; `aggregations`, `breakouts`, `filters`, `orderBys`, `limit` and `fields` (the columns to keep) take its fields, its segments and measures, and the file's metrics as aggregations (`aggregations: [revenue]`). A field that isn't the table's, or an operator its type doesn't take, fails to compile.
83
81
  - The export's name is the question's name in Metabase, as written (`customerList`).
84
82
  - Each `entityId` comes from `mb nano-id` (`mb nano-id --count <n>` for several), never invented or copied. Keep an export's `entityId` when you edit it: a new one replaces the question with another.
85
83
 
@@ -174,7 +172,7 @@ const { query } = useMetabaseQueryObject(orderRows, {
174
172
  });
175
173
  ```
176
174
 
177
- - A column is `{ type: "column", name }` with a result column's `name`, or a field of `schema`; a wrong name, or an operator its type doesn't take, fails to compile. A date breakout takes a `unit` (`day`, `week`, `month`, `quarter`, `year`).
175
+ - A column is `{ type: "column", name }` with a result column's `name`, or a table's field (`orders.fields.total`); a wrong name, or an operator its type doesn't take, fails to compile. A date breakout takes a `unit` (`day`, `week`, `month`, `quarter`, `year`).
178
176
 
179
177
  | Column type | Operators |
180
178
  | ----------- | --------------------------------------------------------------------------------------------------------------------- |