@bonnard/cli 0.1.3 → 0.1.4

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.
Files changed (49) hide show
  1. package/dist/bin/bon.mjs +1838 -100
  2. package/dist/bin/models-IsV2sX74.mjs +76 -0
  3. package/dist/bin/{validate-Bd1D39Bj.mjs → validate-C4EHvJzJ.mjs} +47 -4
  4. package/dist/docs/README.md +82 -0
  5. package/dist/docs/_index.md +69 -0
  6. package/dist/docs/topics/cubes.data-source.md +96 -0
  7. package/dist/docs/topics/cubes.dimensions.format.md +199 -0
  8. package/dist/docs/topics/cubes.dimensions.md +188 -0
  9. package/dist/docs/topics/cubes.dimensions.primary-key.md +110 -0
  10. package/dist/docs/topics/cubes.dimensions.sub-query.md +178 -0
  11. package/dist/docs/topics/cubes.dimensions.time.md +115 -0
  12. package/dist/docs/topics/cubes.dimensions.types.md +111 -0
  13. package/dist/docs/topics/cubes.extends.md +153 -0
  14. package/dist/docs/topics/cubes.hierarchies.md +178 -0
  15. package/dist/docs/topics/cubes.joins.md +119 -0
  16. package/dist/docs/topics/cubes.md +121 -0
  17. package/dist/docs/topics/cubes.measures.calculated.md +103 -0
  18. package/dist/docs/topics/cubes.measures.drill-members.md +162 -0
  19. package/dist/docs/topics/cubes.measures.filters.md +90 -0
  20. package/dist/docs/topics/cubes.measures.format.md +157 -0
  21. package/dist/docs/topics/cubes.measures.md +166 -0
  22. package/dist/docs/topics/cubes.measures.rolling.md +123 -0
  23. package/dist/docs/topics/cubes.measures.types.md +126 -0
  24. package/dist/docs/topics/cubes.public.md +176 -0
  25. package/dist/docs/topics/cubes.refresh-key.md +157 -0
  26. package/dist/docs/topics/cubes.segments.md +125 -0
  27. package/dist/docs/topics/cubes.sql.md +65 -0
  28. package/dist/docs/topics/pre-aggregations.md +130 -0
  29. package/dist/docs/topics/pre-aggregations.rollup.md +166 -0
  30. package/dist/docs/topics/syntax.context-variables.md +157 -0
  31. package/dist/docs/topics/syntax.md +137 -0
  32. package/dist/docs/topics/syntax.references.md +178 -0
  33. package/dist/docs/topics/views.cubes.md +166 -0
  34. package/dist/docs/topics/views.folders.md +158 -0
  35. package/dist/docs/topics/views.includes.md +143 -0
  36. package/dist/docs/topics/views.md +142 -0
  37. package/dist/docs/topics/workflow.deploy.md +132 -0
  38. package/dist/docs/topics/workflow.md +151 -0
  39. package/dist/docs/topics/workflow.query.md +203 -0
  40. package/dist/docs/topics/workflow.validate.md +156 -0
  41. package/dist/templates/claude/rules/bonnard.md +15 -0
  42. package/dist/templates/claude/settings.json +7 -0
  43. package/dist/templates/claude/skills/bonnard-cli/SKILL.md +59 -0
  44. package/dist/templates/claude/skills/bonnard-queries/SKILL.md +68 -0
  45. package/dist/templates/cursor/rules/bonnard-cli.mdc +47 -0
  46. package/dist/templates/cursor/rules/bonnard-queries.mdc +49 -0
  47. package/dist/templates/cursor/rules/bonnard.mdc +20 -0
  48. package/dist/templates/shared/bonnard.md +81 -0
  49. package/package.json +13 -8
@@ -0,0 +1,142 @@
1
+ # views
2
+
3
+ > Compose cubes into focused interfaces for specific use cases.
4
+
5
+ ## Overview
6
+
7
+ Views are facades that expose selected measures and dimensions from one or more cubes. They define which data is available to consumers, control join paths, and organize members into logical groups.
8
+
9
+ ## Example
10
+
11
+ ```yaml
12
+ views:
13
+ - name: orders_overview
14
+ cubes:
15
+ - join_path: orders
16
+ includes:
17
+ - count
18
+ - total_revenue
19
+ - status
20
+ - created_at
21
+
22
+ - join_path: orders.users
23
+ includes:
24
+ - name: name
25
+ alias: customer_name
26
+ - email
27
+ ```
28
+
29
+ ## Core Properties
30
+
31
+ | Property | Required | Description |
32
+ |----------|----------|-------------|
33
+ | `name` | Yes | Unique identifier in snake_case |
34
+ | `cubes` | Yes | List of cubes and their exposed members |
35
+ | `folders` | No | Organize members into groups |
36
+ | `title` | No | Human-readable display name |
37
+ | `description` | No | Documentation for consumers |
38
+ | `public` | No | Whether exposed in API (default: true) |
39
+
40
+ ## Why Use Views?
41
+
42
+ ### 1. Simplify Data Access
43
+
44
+ Expose only relevant members instead of entire cubes:
45
+
46
+ ```yaml
47
+ views:
48
+ - name: sales_dashboard
49
+ cubes:
50
+ - join_path: orders
51
+ includes:
52
+ - count
53
+ - total_revenue
54
+ excludes:
55
+ - internal_notes
56
+ - debug_flags
57
+ ```
58
+
59
+ ### 2. Control Join Paths
60
+
61
+ Define explicit paths through your data model:
62
+
63
+ ```yaml
64
+ views:
65
+ - name: customer_orders
66
+ cubes:
67
+ # Explicit path: orders -> users
68
+ - join_path: orders.users
69
+ includes:
70
+ - name
71
+ - email
72
+ ```
73
+
74
+ ### 3. Rename and Reorganize
75
+
76
+ Create user-friendly names and groupings:
77
+
78
+ ```yaml
79
+ views:
80
+ - name: analytics
81
+ cubes:
82
+ - join_path: orders
83
+ includes:
84
+ - name: count
85
+ alias: order_count
86
+ title: "Total Orders"
87
+
88
+ - name: total_revenue
89
+ alias: revenue
90
+ title: "Revenue"
91
+ ```
92
+
93
+ ### 4. Govern Data Access
94
+
95
+ Control what different consumers can see:
96
+
97
+ ```yaml
98
+ views:
99
+ - name: public_metrics
100
+ public: true
101
+ cubes:
102
+ - join_path: orders
103
+ includes:
104
+ - count
105
+ - total_revenue
106
+
107
+ - name: internal_metrics
108
+ public: false # Only for internal use
109
+ cubes:
110
+ - join_path: orders
111
+ includes: "*"
112
+ ```
113
+
114
+ ## File Organization
115
+
116
+ Store views in the `views/` directory:
117
+
118
+ ```
119
+ views/
120
+ ├── orders_overview.yaml
121
+ ├── sales_dashboard.yaml
122
+ └── customer_360.yaml
123
+ ```
124
+
125
+ ## Best Practices
126
+
127
+ 1. **Create purpose-specific views** — one view per dashboard/use case
128
+ 2. **Use meaningful names** — describe what the view is for
129
+ 3. **Be explicit with includes** — list members rather than using "*"
130
+ 4. **Alias for clarity** — rename members when needed
131
+ 5. **Organize with folders** — group related members together
132
+
133
+ ## See Also
134
+
135
+ - views.cubes
136
+ - views.includes
137
+ - views.folders
138
+ - cubes.joins
139
+
140
+ ## More Information
141
+
142
+ https://cube.dev/docs/reference/data-model/view
@@ -0,0 +1,132 @@
1
+ # workflow.deploy
2
+
3
+ > Push models to Bonnard for querying.
4
+
5
+ ## Overview
6
+
7
+ The `bon deploy` command uploads your cubes and views to Bonnard, making them available for querying via the API. It validates models and tests connections before deploying.
8
+
9
+ ## Usage
10
+
11
+ ```bash
12
+ # Deploy all models
13
+ bon deploy
14
+ ```
15
+
16
+ ## Prerequisites
17
+
18
+ 1. **Logged in** — run `bon login` first
19
+ 2. **Valid models** — must pass `bon validate`
20
+ 3. **Working connections** — data sources must be accessible
21
+
22
+ ## What Happens
23
+
24
+ 1. **Validates models** — checks for errors
25
+ 2. **Tests connections** — verifies data source access
26
+ 3. **Uploads models** — sends cubes and views to Bonnard
27
+ 4. **Activates** — makes models available for queries
28
+
29
+ ## Example Output
30
+
31
+ ```
32
+ bon deploy
33
+
34
+ ✓ Validating models...
35
+ ✓ models/orders.yaml
36
+ ✓ models/users.yaml
37
+ ✓ views/orders_overview.yaml
38
+
39
+ ✓ Testing connections...
40
+ ✓ datasource "default" connected
41
+
42
+ ✓ Deploying to Bonnard...
43
+ Uploading 2 cubes, 1 view...
44
+
45
+ ✓ Deploy complete!
46
+
47
+ Your models are now available at:
48
+ https://api.bonnard.dev/v1/your-org/cubejs-api
49
+ ```
50
+
51
+ ## Deploy Flow
52
+
53
+ ```
54
+ bon deploy
55
+
56
+ ├── 1. bon validate (must pass)
57
+
58
+ ├── 2. Test all datasource connections (must succeed)
59
+
60
+ ├── 3. Upload to Bonnard API
61
+ │ - cubes from models/
62
+ │ - views from views/
63
+ │ - datasource configs
64
+
65
+ └── 4. Activate deployment
66
+ ```
67
+
68
+ ## Error Handling
69
+
70
+ ### Validation Errors
71
+
72
+ ```
73
+ ✗ Validating models...
74
+
75
+ models/orders.yaml:15:5
76
+ error: Unknown measure type "counts"
77
+
78
+ Deploy aborted. Fix validation errors first.
79
+ ```
80
+
81
+ ### Connection Errors
82
+
83
+ ```
84
+ ✗ Testing connections...
85
+ ✗ datasource "analytics": Connection refused
86
+
87
+ Deploy aborted. Fix connection issues:
88
+ - Check credentials in .bon/datasources.yaml
89
+ - Verify network access to database
90
+ - Run: bon datasource test analytics
91
+ ```
92
+
93
+ ### Auth Errors
94
+
95
+ ```
96
+ ✗ Not logged in.
97
+
98
+ Run: bon login
99
+ ```
100
+
101
+ ## What Gets Deployed
102
+
103
+ | Source | Deployed |
104
+ |--------|----------|
105
+ | `models/*.yaml` | All cube definitions |
106
+ | `views/*.yaml` | All view definitions |
107
+ | `.bon/datasources.yaml` | Connection configs (credentials encrypted) |
108
+ | `bon.yaml` | Project settings |
109
+
110
+ ## Deployment Behavior
111
+
112
+ - **Replaces** previous deployment (not additive)
113
+ - **All or nothing** — partial deploys don't happen
114
+ - **Instant** — changes take effect immediately
115
+
116
+ ## Best Practices
117
+
118
+ 1. **Validate first** — run `bon validate` before deploy
119
+ 2. **Test locally** — verify queries work before deploying
120
+ 3. **Use version control** — commit models before deploying
121
+ 4. **Monitor after deploy** — check for query errors
122
+
123
+ ## See Also
124
+
125
+ - workflow
126
+ - workflow.validate
127
+ - cubes
128
+ - views
129
+
130
+ ## More Information
131
+
132
+ https://docs.bonnard.dev/cli/deploy
@@ -0,0 +1,151 @@
1
+ # workflow
2
+
3
+ > Development workflow for building and deploying Bonnard models.
4
+
5
+ ## Overview
6
+
7
+ Building semantic models with Bonnard follows a development workflow: initialize a project, connect data sources, define models, validate, and deploy.
8
+
9
+ ## Quick Start
10
+
11
+ ```bash
12
+ # 1. Initialize project
13
+ bon init
14
+
15
+ # 2. Add a data source
16
+ bon datasource add
17
+
18
+ # 3. Create models in models/ and views in views/
19
+
20
+ # 4. Validate your models
21
+ bon validate
22
+
23
+ # 5. Deploy to Bonnard
24
+ bon deploy
25
+ ```
26
+
27
+ ## Project Structure
28
+
29
+ After `bon init`, your project has:
30
+
31
+ ```
32
+ my-project/
33
+ ├── bon.yaml # Project configuration
34
+ ├── models/ # Cube definitions
35
+ │ └── orders.yaml
36
+ ├── views/ # View definitions
37
+ │ └── orders_overview.yaml
38
+ └── .bon/ # Local config (gitignored)
39
+ └── datasources.yaml # Data source credentials
40
+ ```
41
+
42
+ ## Development Cycle
43
+
44
+ ### 1. Define Models
45
+
46
+ Create cubes that map to your database tables:
47
+
48
+ ```yaml
49
+ # models/orders.yaml
50
+ cubes:
51
+ - name: orders
52
+ sql_table: public.orders
53
+
54
+ measures:
55
+ - name: count
56
+ type: count
57
+
58
+ dimensions:
59
+ - name: status
60
+ type: string
61
+ sql: status
62
+ ```
63
+
64
+ ### 2. Define Views
65
+
66
+ Create views that expose cubes to consumers:
67
+
68
+ ```yaml
69
+ # views/orders_overview.yaml
70
+ views:
71
+ - name: orders_overview
72
+ cubes:
73
+ - join_path: orders
74
+ includes:
75
+ - count
76
+ - status
77
+ ```
78
+
79
+ ### 3. Validate
80
+
81
+ Check for syntax errors and test connections:
82
+
83
+ ```yaml
84
+ bon validate
85
+ bon validate --test-connection
86
+ ```
87
+
88
+ ### 4. Deploy
89
+
90
+ Push models to Bonnard:
91
+
92
+ ```bash
93
+ bon deploy
94
+ ```
95
+
96
+ ## File Organization
97
+
98
+ ### One Cube Per File
99
+
100
+ ```
101
+ models/
102
+ ├── orders.yaml
103
+ ├── users.yaml
104
+ ├── products.yaml
105
+ └── line_items.yaml
106
+ ```
107
+
108
+ ### Related Cubes Together
109
+
110
+ ```
111
+ models/
112
+ ├── sales/
113
+ │ ├── orders.yaml
114
+ │ └── line_items.yaml
115
+ ├── users/
116
+ │ ├── users.yaml
117
+ │ └── profiles.yaml
118
+ └── products/
119
+ └── products.yaml
120
+ ```
121
+
122
+ ## Best Practices
123
+
124
+ 1. **Start simple** — begin with one cube, add complexity gradually
125
+ 2. **Validate often** — run `bon validate` after each change
126
+ 3. **Use version control** — commit models to git
127
+ 4. **Document with descriptions** — add `description` to measures/dimensions
128
+ 5. **Test with queries** — verify models produce expected results
129
+
130
+ ## Commands Reference
131
+
132
+ | Command | Description |
133
+ |---------|-------------|
134
+ | `bon init` | Create project structure |
135
+ | `bon datasource add` | Add a data source |
136
+ | `bon datasource list` | List configured sources |
137
+ | `bon datasource test <name>` | Test connection |
138
+ | `bon validate` | Check model syntax |
139
+ | `bon deploy` | Deploy to Bonnard |
140
+ | `bon docs` | Browse Cube documentation |
141
+
142
+ ## See Also
143
+
144
+ - workflow.validate
145
+ - workflow.deploy
146
+ - cubes
147
+ - views
148
+
149
+ ## More Information
150
+
151
+ https://docs.bonnard.dev/workflow
@@ -0,0 +1,203 @@
1
+ # workflow.query
2
+
3
+ > Query the deployed semantic layer using JSON or SQL.
4
+
5
+ ## Overview
6
+
7
+ After deploying models with `bon deploy`, you can query the semantic layer using `bon cube query`. This tests that your models work correctly and returns data from your warehouse through Cube.
8
+
9
+ ## Query Formats
10
+
11
+ Cube supports two query formats:
12
+
13
+ ### JSON Format (Default)
14
+
15
+ The JSON format uses Cube's REST API structure:
16
+
17
+ ```bash
18
+ bon cube query '{"measures": ["orders.count"]}'
19
+
20
+ bon cube query '{
21
+ "measures": ["orders.total_revenue"],
22
+ "dimensions": ["orders.status"],
23
+ "filters": [{
24
+ "member": "orders.created_at",
25
+ "operator": "inDateRange",
26
+ "values": ["2024-01-01", "2024-12-31"]
27
+ }]
28
+ }'
29
+ ```
30
+
31
+ **JSON Query Properties:**
32
+
33
+ | Property | Description |
34
+ |----------|-------------|
35
+ | `measures` | Array of measures to calculate (e.g., `["orders.count"]`) |
36
+ | `dimensions` | Array of dimensions to group by (e.g., `["orders.status"]`) |
37
+ | `filters` | Array of filter objects |
38
+ | `timeDimensions` | Time-based grouping with granularity |
39
+ | `segments` | Named filters defined in models |
40
+ | `limit` | Max rows to return |
41
+ | `offset` | Skip rows (pagination) |
42
+ | `order` | Sort specification |
43
+
44
+ **Filter Operators:**
45
+
46
+ | Operator | Use Case |
47
+ |----------|----------|
48
+ | `equals`, `notEquals` | Exact match |
49
+ | `contains`, `notContains` | String contains |
50
+ | `startsWith`, `endsWith` | String prefix/suffix |
51
+ | `gt`, `gte`, `lt`, `lte` | Numeric comparison |
52
+ | `inDateRange`, `beforeDate`, `afterDate` | Time filtering |
53
+ | `set`, `notSet` | NULL checks |
54
+
55
+ ### SQL Format
56
+
57
+ The SQL format uses Cube's SQL API, where cubes are tables:
58
+
59
+ ```bash
60
+ bon cube query --sql "SELECT status, MEASURE(count) FROM orders GROUP BY 1"
61
+
62
+ bon cube query --sql "SELECT
63
+ city,
64
+ MEASURE(total_revenue),
65
+ MEASURE(avg_order_value)
66
+ FROM orders
67
+ WHERE status = 'completed'
68
+ GROUP BY 1
69
+ ORDER BY 2 DESC
70
+ LIMIT 10"
71
+ ```
72
+
73
+ **SQL Syntax Rules:**
74
+
75
+ 1. **Cubes/views are tables** — `FROM orders` references the `orders` cube
76
+ 2. **Dimensions are columns** — Include in `SELECT` and `GROUP BY`
77
+ 3. **Measures use `MEASURE()`** — Or matching aggregates (`SUM`, `COUNT`, etc.)
78
+ 4. **Segments are boolean** — Filter with `WHERE is_completed IS TRUE`
79
+
80
+ **Examples:**
81
+
82
+ ```sql
83
+ -- Count orders by status
84
+ SELECT status, MEASURE(count) FROM orders GROUP BY 1
85
+
86
+ -- Revenue by city with filter
87
+ SELECT city, SUM(amount) FROM orders WHERE status = 'shipped' GROUP BY 1
88
+
89
+ -- Using time dimension with granularity
90
+ SELECT DATE_TRUNC('month', created_at), MEASURE(total_revenue)
91
+ FROM orders
92
+ GROUP BY 1
93
+ ORDER BY 1
94
+ ```
95
+
96
+ ## CLI Usage
97
+
98
+ ```bash
99
+ # JSON format (default)
100
+ bon cube query '{"measures": ["orders.count"]}'
101
+
102
+ # SQL format
103
+ bon cube query --sql "SELECT MEASURE(count) FROM orders"
104
+
105
+ # Limit rows
106
+ bon cube query '{"measures": ["orders.count"], "dimensions": ["orders.city"]}' --limit 10
107
+
108
+ # JSON output (instead of table)
109
+ bon cube query '{"measures": ["orders.count"]}' --format json
110
+ ```
111
+
112
+ ## Output Formats
113
+
114
+ ### Table Format (Default)
115
+
116
+ ```
117
+ ┌─────────┬───────────────┐
118
+ │ status │ orders.count │
119
+ ├─────────┼───────────────┤
120
+ │ pending │ 42 │
121
+ │ shipped │ 156 │
122
+ │ done │ 892 │
123
+ └─────────┴───────────────┘
124
+ ```
125
+
126
+ ### JSON Format
127
+
128
+ ```bash
129
+ bon cube query '{"measures": ["orders.count"]}' --format json
130
+ ```
131
+
132
+ ```json
133
+ [
134
+ { "orders.status": "pending", "orders.count": 42 },
135
+ { "orders.status": "shipped", "orders.count": 156 },
136
+ { "orders.status": "done", "orders.count": 892 }
137
+ ]
138
+ ```
139
+
140
+ ## Common Patterns
141
+
142
+ ### Time Series Analysis
143
+
144
+ ```bash
145
+ bon cube query '{
146
+ "measures": ["orders.total_revenue"],
147
+ "timeDimensions": [{
148
+ "dimension": "orders.created_at",
149
+ "granularity": "month",
150
+ "dateRange": ["2024-01-01", "2024-12-31"]
151
+ }]
152
+ }'
153
+ ```
154
+
155
+ ### Filtering by Dimension
156
+
157
+ ```bash
158
+ bon cube query '{
159
+ "measures": ["orders.count"],
160
+ "dimensions": ["orders.city"],
161
+ "filters": [{
162
+ "member": "orders.status",
163
+ "operator": "equals",
164
+ "values": ["completed"]
165
+ }]
166
+ }'
167
+ ```
168
+
169
+ ### Multiple Measures
170
+
171
+ ```bash
172
+ bon cube query '{
173
+ "measures": ["orders.count", "orders.total_revenue", "orders.avg_order_value"],
174
+ "dimensions": ["orders.category"]
175
+ }'
176
+ ```
177
+
178
+ ## Error Handling
179
+
180
+ ### Common Errors
181
+
182
+ **"Projection references non-aggregate values"**
183
+ - All dimensions must be in `GROUP BY`
184
+ - All measures must use `MEASURE()` or matching aggregate
185
+
186
+ **"Cube not found"**
187
+ - Check cube name matches deployed model
188
+ - Run `bon deploy` if models changed
189
+
190
+ **"Not logged in"**
191
+ - Run `bon login` first
192
+
193
+ ## See Also
194
+
195
+ - [workflow.deploy](workflow.deploy) - Deploy models before querying
196
+ - [cubes.measures](cubes.measures) - Define measures
197
+ - [cubes.dimensions](cubes.dimensions) - Define dimensions
198
+ - [views](views) - Create focused query interfaces
199
+
200
+ ## More Information
201
+
202
+ - [Cube REST API Query Format](https://cube.dev/docs/product/apis-integrations/rest-api/query-format)
203
+ - [Cube SQL API Query Format](https://cube.dev/docs/product/apis-integrations/sql-api/query-format)