@bonnard/cli 0.1.11 → 0.1.12

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.
@@ -41,65 +41,81 @@ If the test fails, common issues:
41
41
 
42
42
  ## Phase 2: Explore the Data
43
43
 
44
- Use `bon preview` to understand what tables and columns are available:
44
+ Use `bon preview` to understand what tables and columns are available.
45
+ **Always run this before creating cubes** — use the results to decide which
46
+ tables to model and what columns to expose.
45
47
 
46
48
  ```bash
47
- # List tables (Postgres)
49
+ # List tables — use the schema from the datasource config
50
+ # For demo data (contoso schema):
51
+ bon preview contoso_demo "SELECT table_name FROM information_schema.tables WHERE table_schema = 'contoso'"
52
+
53
+ # For user's own data (typically public schema):
48
54
  bon preview <datasource> "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'"
49
55
 
50
- # List tables (Snowflake)
56
+ # Snowflake:
51
57
  bon preview <datasource> "SHOW TABLES"
52
58
 
53
- # Sample a table
54
- bon preview <datasource> "SELECT * FROM orders" --limit 10
59
+ # Then sample the key tables to see columns and data:
60
+ bon preview contoso_demo "SELECT * FROM contoso.fact_sales" --limit 10
61
+ bon preview contoso_demo "SELECT * FROM contoso.dim_product" --limit 10
55
62
  ```
56
63
 
57
- This helps you understand the schema before writing cubes.
64
+ Note the table names, column names, and data types — you'll use these in Phase 3.
58
65
 
59
66
  ## Phase 3: Create Your First Cube
60
67
 
61
- Create a file in `bonnard/cubes/` for the most important table. A cube
62
- typically maps directly to a database table — define measures for the metrics
63
- you want to track and dimensions for the attributes you want to filter and
64
- group by.
68
+ Based on what you found in Phase 2, create a file in `bonnard/cubes/` for
69
+ the most important table. A cube maps directly to a database table — define
70
+ measures for the metrics you want to track and dimensions for the attributes
71
+ you want to filter and group by. **Use the actual table and column names from
72
+ Phase 2, not placeholder names.**
65
73
 
66
- Example — `bonnard/cubes/orders.yaml`:
74
+ Example using demo data — `bonnard/cubes/sales.yaml`:
67
75
 
68
76
  ```yaml
69
77
  cubes:
70
- - name: orders
71
- sql_table: public.orders
78
+ - name: sales
79
+ sql_table: contoso.fact_sales
80
+ data_source: contoso_demo
72
81
 
73
82
  measures:
74
83
  - name: count
75
84
  type: count
76
- description: Total number of orders
85
+ description: Total number of sales transactions
77
86
 
78
87
  - name: total_revenue
79
88
  type: sum
80
- sql: amount
81
- description: Sum of order amounts
89
+ sql: sales_amount
90
+ description: Sum of sales revenue
91
+
92
+ - name: total_cost
93
+ type: sum
94
+ sql: total_cost
95
+ description: Sum of product costs
82
96
 
83
97
  dimensions:
84
- - name: id
98
+ - name: sales_key
85
99
  type: number
86
- sql: id
100
+ sql: sales_key
87
101
  primary_key: true
88
102
 
89
- - name: status
90
- type: string
91
- sql: status
92
- description: Order status (pending, completed, cancelled)
93
-
94
- - name: created_at
103
+ - name: date
95
104
  type: time
96
- sql: created_at
97
- description: When the order was placed
105
+ sql: date_key
106
+ description: Sale date
107
+
108
+ - name: sales_quantity
109
+ type: number
110
+ sql: sales_quantity
111
+ description: Number of units sold
98
112
  ```
99
113
 
100
114
  Key rules:
101
115
  - Every cube needs a `primary_key` dimension
102
116
  - Every measure and dimension should have a `description`
117
+ - Set `data_source` to match the datasource name from Phase 1
118
+ - Use `sql_table` with the full `schema.table` path
103
119
  - Use `sql_table` for simple table references, `sql` for complex queries
104
120
 
105
121
  Use `bon docs cubes` for the full reference, `bon docs cubes.measures.types`
@@ -108,21 +124,22 @@ for all 12 measure types, `bon docs cubes.dimensions.types` for dimension types.
108
124
  ## Phase 4: Create a View
109
125
 
110
126
  Views expose a curated subset of measures and dimensions for consumers.
111
- Create a file in `bonnard/views/`:
127
+ Create a file in `bonnard/views/` that references the cube from Phase 3.
112
128
 
113
- Example — `bonnard/views/orders_overview.yaml`:
129
+ Example using demo data — `bonnard/views/sales_overview.yaml`:
114
130
 
115
131
  ```yaml
116
132
  views:
117
- - name: orders_overview
118
- description: High-level order metrics and attributes
133
+ - name: sales_overview
134
+ description: High-level sales metrics and attributes
119
135
  cubes:
120
- - join_path: orders
136
+ - join_path: sales
121
137
  includes:
122
138
  - count
123
139
  - total_revenue
124
- - status
125
- - created_at
140
+ - total_cost
141
+ - date
142
+ - sales_quantity
126
143
  ```
127
144
 
128
145
  Use `bon docs views` for the full reference.
@@ -160,17 +177,17 @@ credentials (encrypted) to Bonnard.
160
177
 
161
178
  ## Phase 7: Test with a Query
162
179
 
163
- Verify the deployment works:
180
+ Verify the deployment works using the cube name from Phase 3:
164
181
 
165
182
  ```bash
166
183
  # Simple count
167
- bon query '{"measures": ["orders.count"]}'
184
+ bon query '{"measures": ["sales.count"]}'
168
185
 
169
- # Group by a dimension
170
- bon query '{"measures": ["orders.count"], "dimensions": ["orders.status"]}'
186
+ # With a dimension
187
+ bon query '{"measures": ["sales.total_revenue"], "dimensions": ["sales.date"]}'
171
188
 
172
189
  # SQL format
173
- bon query --sql "SELECT status, MEASURE(count) FROM orders GROUP BY 1"
190
+ bon query --sql "SELECT MEASURE(total_revenue) FROM sales"
174
191
  ```
175
192
 
176
193
  ## Phase 8: Connect AI Agents (Optional)
@@ -40,65 +40,81 @@ If the test fails, common issues:
40
40
 
41
41
  ## Phase 2: Explore the Data
42
42
 
43
- Use `bon preview` to understand what tables and columns are available:
43
+ Use `bon preview` to understand what tables and columns are available.
44
+ **Always run this before creating cubes** — use the results to decide which
45
+ tables to model and what columns to expose.
44
46
 
45
47
  ```bash
46
- # List tables (Postgres)
48
+ # List tables — use the schema from the datasource config
49
+ # For demo data (contoso schema):
50
+ bon preview contoso_demo "SELECT table_name FROM information_schema.tables WHERE table_schema = 'contoso'"
51
+
52
+ # For user's own data (typically public schema):
47
53
  bon preview <datasource> "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'"
48
54
 
49
- # List tables (Snowflake)
55
+ # Snowflake:
50
56
  bon preview <datasource> "SHOW TABLES"
51
57
 
52
- # Sample a table
53
- bon preview <datasource> "SELECT * FROM orders" --limit 10
58
+ # Then sample the key tables to see columns and data:
59
+ bon preview contoso_demo "SELECT * FROM contoso.fact_sales" --limit 10
60
+ bon preview contoso_demo "SELECT * FROM contoso.dim_product" --limit 10
54
61
  ```
55
62
 
56
- This helps you understand the schema before writing cubes.
63
+ Note the table names, column names, and data types — you'll use these in Phase 3.
57
64
 
58
65
  ## Phase 3: Create Your First Cube
59
66
 
60
- Create a file in `bonnard/cubes/` for the most important table. A cube
61
- typically maps directly to a database table — define measures for the metrics
62
- you want to track and dimensions for the attributes you want to filter and
63
- group by.
67
+ Based on what you found in Phase 2, create a file in `bonnard/cubes/` for
68
+ the most important table. A cube maps directly to a database table — define
69
+ measures for the metrics you want to track and dimensions for the attributes
70
+ you want to filter and group by. **Use the actual table and column names from
71
+ Phase 2, not placeholder names.**
64
72
 
65
- Example — `bonnard/cubes/orders.yaml`:
73
+ Example using demo data — `bonnard/cubes/sales.yaml`:
66
74
 
67
75
  ```yaml
68
76
  cubes:
69
- - name: orders
70
- sql_table: public.orders
77
+ - name: sales
78
+ sql_table: contoso.fact_sales
79
+ data_source: contoso_demo
71
80
 
72
81
  measures:
73
82
  - name: count
74
83
  type: count
75
- description: Total number of orders
84
+ description: Total number of sales transactions
76
85
 
77
86
  - name: total_revenue
78
87
  type: sum
79
- sql: amount
80
- description: Sum of order amounts
88
+ sql: sales_amount
89
+ description: Sum of sales revenue
90
+
91
+ - name: total_cost
92
+ type: sum
93
+ sql: total_cost
94
+ description: Sum of product costs
81
95
 
82
96
  dimensions:
83
- - name: id
97
+ - name: sales_key
84
98
  type: number
85
- sql: id
99
+ sql: sales_key
86
100
  primary_key: true
87
101
 
88
- - name: status
89
- type: string
90
- sql: status
91
- description: Order status (pending, completed, cancelled)
92
-
93
- - name: created_at
102
+ - name: date
94
103
  type: time
95
- sql: created_at
96
- description: When the order was placed
104
+ sql: date_key
105
+ description: Sale date
106
+
107
+ - name: sales_quantity
108
+ type: number
109
+ sql: sales_quantity
110
+ description: Number of units sold
97
111
  ```
98
112
 
99
113
  Key rules:
100
114
  - Every cube needs a `primary_key` dimension
101
115
  - Every measure and dimension should have a `description`
116
+ - Set `data_source` to match the datasource name from Phase 1
117
+ - Use `sql_table` with the full `schema.table` path
102
118
  - Use `sql_table` for simple table references, `sql` for complex queries
103
119
 
104
120
  Use `bon docs cubes` for the full reference, `bon docs cubes.measures.types`
@@ -107,21 +123,22 @@ for all 12 measure types, `bon docs cubes.dimensions.types` for dimension types.
107
123
  ## Phase 4: Create a View
108
124
 
109
125
  Views expose a curated subset of measures and dimensions for consumers.
110
- Create a file in `bonnard/views/`:
126
+ Create a file in `bonnard/views/` that references the cube from Phase 3.
111
127
 
112
- Example — `bonnard/views/orders_overview.yaml`:
128
+ Example using demo data — `bonnard/views/sales_overview.yaml`:
113
129
 
114
130
  ```yaml
115
131
  views:
116
- - name: orders_overview
117
- description: High-level order metrics and attributes
132
+ - name: sales_overview
133
+ description: High-level sales metrics and attributes
118
134
  cubes:
119
- - join_path: orders
135
+ - join_path: sales
120
136
  includes:
121
137
  - count
122
138
  - total_revenue
123
- - status
124
- - created_at
139
+ - total_cost
140
+ - date
141
+ - sales_quantity
125
142
  ```
126
143
 
127
144
  Use `bon docs views` for the full reference.
@@ -159,17 +176,17 @@ credentials (encrypted) to Bonnard.
159
176
 
160
177
  ## Phase 7: Test with a Query
161
178
 
162
- Verify the deployment works:
179
+ Verify the deployment works using the cube name from Phase 3:
163
180
 
164
181
  ```bash
165
182
  # Simple count
166
- bon query '{"measures": ["orders.count"]}'
183
+ bon query '{"measures": ["sales.count"]}'
167
184
 
168
- # Group by a dimension
169
- bon query '{"measures": ["orders.count"], "dimensions": ["orders.status"]}'
185
+ # With a dimension
186
+ bon query '{"measures": ["sales.total_revenue"], "dimensions": ["sales.date"]}'
170
187
 
171
188
  # SQL format
172
- bon query --sql "SELECT status, MEASURE(count) FROM orders GROUP BY 1"
189
+ bon query --sql "SELECT MEASURE(total_revenue) FROM sales"
173
190
  ```
174
191
 
175
192
  ## Phase 8: Connect AI Agents (Optional)
@@ -0,0 +1,16 @@
1
+ # Bonnard datasources configuration
2
+ # This file contains credentials - add to .gitignore
3
+ # Env vars like {{ env_var('PASSWORD') }} are resolved at deploy time
4
+
5
+ datasources:
6
+ - name: contoso_demo
7
+ type: postgres
8
+ source: demo
9
+ config:
10
+ host: aws-1-eu-west-1.pooler.supabase.com
11
+ port: "5432"
12
+ database: postgres
13
+ schema: contoso
14
+ credentials:
15
+ username: demo_reader.yvbfzqogtdsqqkpyztlu
16
+ password: contoso-demo-2025!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonnard/cli",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "bon": "./dist/bin/bon.mjs"