@bonnard/cli 0.2.7 → 0.2.9
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/LICENSE +21 -0
- package/README.md +10 -8
- package/dist/bin/bon.mjs +3 -3
- package/dist/docs/topics/cli.md +16 -0
- package/dist/docs/topics/dashboards.components.md +102 -12
- package/dist/docs/topics/dashboards.examples.md +163 -6
- package/dist/docs/topics/dashboards.inputs.md +179 -0
- package/dist/docs/topics/dashboards.md +39 -5
- package/dist/docs/topics/dashboards.queries.md +7 -5
- package/dist/docs/topics/views.md +1 -1
- package/dist/templates/claude/skills/bonnard-design-guide/SKILL.md +5 -4
- package/dist/templates/cursor/rules/bonnard-design-guide.mdc +5 -4
- package/package.json +7 -2
- package/dist/docs/topics/features.catalog.md +0 -31
- package/dist/docs/topics/features.cli.md +0 -59
- package/dist/docs/topics/features.context-graph.md +0 -18
- package/dist/docs/topics/features.governance.md +0 -83
- package/dist/docs/topics/features.mcp.md +0 -48
- package/dist/docs/topics/features.md +0 -15
- package/dist/docs/topics/features.sdk.md +0 -53
- package/dist/docs/topics/features.semantic-layer.md +0 -56
- package/dist/docs/topics/features.slack-teams.md +0 -18
- package/dist/docs/topics/workflow.deploy.md +0 -193
- package/dist/docs/topics/workflow.mcp.md +0 -179
- package/dist/docs/topics/workflow.md +0 -165
- package/dist/docs/topics/workflow.query.md +0 -198
- package/dist/docs/topics/workflow.validate.md +0 -125
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
# Query
|
|
2
|
-
|
|
3
|
-
> Query your deployed semantic layer using the Bonnard REST API. Send JSON query objects or SQL strings to retrieve measures and dimensions with filtering, grouping, and time ranges.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
After deploying with `bon deploy`, you can query the semantic layer using `bon query`. This tests that your cubes and views work correctly and returns data from your warehouse through Bonnard.
|
|
8
|
-
|
|
9
|
-
## Query Formats
|
|
10
|
-
|
|
11
|
-
Bonnard supports two query formats:
|
|
12
|
-
|
|
13
|
-
### JSON Format (Default)
|
|
14
|
-
|
|
15
|
-
The JSON format uses the REST API structure:
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
bon query '{"measures": ["orders.count"]}'
|
|
19
|
-
|
|
20
|
-
bon 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 cubes |
|
|
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 the SQL API, where cubes are tables:
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
bon query --sql "SELECT status, MEASURE(count) FROM orders GROUP BY 1"
|
|
61
|
-
|
|
62
|
-
bon 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 query '{"measures": ["orders.count"]}'
|
|
101
|
-
|
|
102
|
-
# SQL format
|
|
103
|
-
bon query --sql "SELECT MEASURE(count) FROM orders"
|
|
104
|
-
|
|
105
|
-
# Limit rows
|
|
106
|
-
bon query '{"measures": ["orders.count"], "dimensions": ["orders.city"]}' --limit 10
|
|
107
|
-
|
|
108
|
-
# JSON output (instead of table)
|
|
109
|
-
bon 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 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 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 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 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 cube
|
|
188
|
-
- Run `bon deploy` if cubes changed
|
|
189
|
-
|
|
190
|
-
**"Not logged in"**
|
|
191
|
-
- Run `bon login` first
|
|
192
|
-
|
|
193
|
-
## See Also
|
|
194
|
-
|
|
195
|
-
- [workflow.deploy](workflow.deploy) - Deploy before querying
|
|
196
|
-
- [cubes.measures](cubes.measures) - Define measures
|
|
197
|
-
- [cubes.dimensions](cubes.dimensions) - Define dimensions
|
|
198
|
-
- [views](views) - Create focused query interfaces
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
# Validate
|
|
2
|
-
|
|
3
|
-
> Run validation checks on your cubes and views before deploying to catch YAML syntax errors, missing references, circular joins, and other issues. Use `bon validate` from the CLI.
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
The `bon validate` command checks your YAML cubes and views for syntax errors and schema violations. Run this before deploying to catch issues early.
|
|
8
|
-
|
|
9
|
-
## Usage
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
bon validate
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## What Gets Validated
|
|
16
|
-
|
|
17
|
-
### YAML Syntax
|
|
18
|
-
|
|
19
|
-
- Valid YAML format
|
|
20
|
-
- Proper indentation
|
|
21
|
-
- Correct quoting
|
|
22
|
-
|
|
23
|
-
### Schema Compliance
|
|
24
|
-
|
|
25
|
-
- Required fields present (name, type, sql)
|
|
26
|
-
- Valid field values (known measure types, relationship types)
|
|
27
|
-
- Consistent naming conventions
|
|
28
|
-
|
|
29
|
-
### Reference Integrity
|
|
30
|
-
|
|
31
|
-
- Referenced cubes exist
|
|
32
|
-
- Referenced members exist
|
|
33
|
-
- Join relationships are valid
|
|
34
|
-
|
|
35
|
-
## Example Output
|
|
36
|
-
|
|
37
|
-
### Success
|
|
38
|
-
|
|
39
|
-
```
|
|
40
|
-
✓ Validating YAML syntax...
|
|
41
|
-
✓ Checking bonnard/cubes/orders.yaml
|
|
42
|
-
✓ Checking bonnard/cubes/users.yaml
|
|
43
|
-
✓ Checking bonnard/views/orders_overview.yaml
|
|
44
|
-
|
|
45
|
-
All cubes and views valid.
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### Errors
|
|
49
|
-
|
|
50
|
-
```
|
|
51
|
-
✗ Validating YAML syntax...
|
|
52
|
-
|
|
53
|
-
bonnard/cubes/orders.yaml:15:5
|
|
54
|
-
error: Unknown measure type "counts"
|
|
55
|
-
|
|
56
|
-
Did you mean "count"?
|
|
57
|
-
|
|
58
|
-
14: measures:
|
|
59
|
-
15: - name: order_count
|
|
60
|
-
16: type: counts <-- here
|
|
61
|
-
17: sql: id
|
|
62
|
-
|
|
63
|
-
1 error found.
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## Common Errors
|
|
67
|
-
|
|
68
|
-
### Missing Required Field
|
|
69
|
-
|
|
70
|
-
```yaml
|
|
71
|
-
# Error: "sql" is required
|
|
72
|
-
measures:
|
|
73
|
-
- name: count
|
|
74
|
-
type: count
|
|
75
|
-
# Missing: sql: id
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
### Invalid Type
|
|
79
|
-
|
|
80
|
-
```yaml
|
|
81
|
-
# Error: Unknown dimension type "text"
|
|
82
|
-
dimensions:
|
|
83
|
-
- name: status
|
|
84
|
-
type: text # Should be: string
|
|
85
|
-
sql: status
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### Reference Not Found
|
|
89
|
-
|
|
90
|
-
```yaml
|
|
91
|
-
# Error: Cube "user" not found (did you mean "users"?)
|
|
92
|
-
joins:
|
|
93
|
-
- name: user
|
|
94
|
-
relationship: many_to_one
|
|
95
|
-
sql: "{CUBE}.user_id = {user.id}"
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
### YAML Syntax
|
|
99
|
-
|
|
100
|
-
```yaml
|
|
101
|
-
# Error: Bad indentation
|
|
102
|
-
measures:
|
|
103
|
-
- name: count # Should be indented
|
|
104
|
-
type: count
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
## Exit Codes
|
|
108
|
-
|
|
109
|
-
| Code | Meaning |
|
|
110
|
-
|------|---------|
|
|
111
|
-
| 0 | All validations passed |
|
|
112
|
-
| 1 | Validation errors found |
|
|
113
|
-
|
|
114
|
-
## Best Practices
|
|
115
|
-
|
|
116
|
-
1. **Run before every deploy** — `bon validate && bon deploy`
|
|
117
|
-
2. **Add to CI/CD** — validate on pull requests
|
|
118
|
-
3. **Fix errors first** — don't deploy with validation errors
|
|
119
|
-
4. **Test connections** — connections are tested automatically during `bon deploy`
|
|
120
|
-
|
|
121
|
-
## See Also
|
|
122
|
-
|
|
123
|
-
- workflow
|
|
124
|
-
- workflow.deploy
|
|
125
|
-
- syntax
|