@d-dash/builder 0.0.1 → 0.0.2
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/README.md +77 -0
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# @d-dash/builder
|
|
2
|
+
|
|
3
|
+
Type-safe fluent SDK for constructing d-dash dashboards and widgets.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The `builder` package provides a developer-friendly API to create dashboard JSON models that are guaranteed to satisfy the d-dash schema. It eliminates manual object literal construction and provides IDE autocompletion for visualization options and datasource queries.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @d-dash/builder @d-dash/core
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
### Building a Dashboard
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { DashboardBuilder, WidgetBuilder } from "@d-dash/builder";
|
|
21
|
+
|
|
22
|
+
const dashboard = new DashboardBuilder()
|
|
23
|
+
.setTitle("System Overview")
|
|
24
|
+
.setDescription("Production cluster metrics")
|
|
25
|
+
.addVariable({
|
|
26
|
+
name: "host",
|
|
27
|
+
type: "custom",
|
|
28
|
+
options: ["web-1", "web-2"],
|
|
29
|
+
default: "web-1"
|
|
30
|
+
})
|
|
31
|
+
.addWidget(
|
|
32
|
+
new WidgetBuilder()
|
|
33
|
+
.setId("cpu-usage")
|
|
34
|
+
.setTitle("CPU Usage")
|
|
35
|
+
.setDatasource("metrics")
|
|
36
|
+
.setQuery({
|
|
37
|
+
metric: "cpu.utilization",
|
|
38
|
+
filters: { host: "$host" }
|
|
39
|
+
})
|
|
40
|
+
.setVisualization({
|
|
41
|
+
type: "timeseries",
|
|
42
|
+
options: { showLegend: true }
|
|
43
|
+
})
|
|
44
|
+
.setLayout({ x: 0, y: 0, w: 6, h: 4 })
|
|
45
|
+
)
|
|
46
|
+
.build();
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Features
|
|
50
|
+
|
|
51
|
+
- **Fluent API**: Chain methods to configure dashboard properties.
|
|
52
|
+
- **Validation**: Throws errors early if required fields (like title or ID) are missing.
|
|
53
|
+
- **Experimental Support**: Includes builders for template variables and layout configurations.
|
|
54
|
+
|
|
55
|
+
## API Reference
|
|
56
|
+
|
|
57
|
+
### `DashboardBuilder`
|
|
58
|
+
Root builder for the dashboard model.
|
|
59
|
+
- `setTitle(string)`
|
|
60
|
+
- `setDescription(string)`
|
|
61
|
+
- `addVariable(Variable)`
|
|
62
|
+
- `addWidget(WidgetBuilder | Widget)`
|
|
63
|
+
- `build()`: Returns a validated `Dashboard` object.
|
|
64
|
+
|
|
65
|
+
### `WidgetBuilder`
|
|
66
|
+
Builder for individual widgets.
|
|
67
|
+
- `setId(string)`
|
|
68
|
+
- `setTitle(string)`
|
|
69
|
+
- `setDatasource(string)`
|
|
70
|
+
- `setQuery(any)`
|
|
71
|
+
- `setVisualization(Visualization)`
|
|
72
|
+
- `setLayout(Layout)`
|
|
73
|
+
- `build()`: Returns a validated `Widget` object.
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
LGPL-3.0-or-later
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d-dash/builder",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Fluent TypeScript SDK for building d-dash dashboards programmatically",
|
|
5
5
|
"license": "LGPL-3.0-or-later",
|
|
6
6
|
"repository": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"d-dash"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@d-dash/core": "^0.3.
|
|
36
|
+
"@d-dash/core": "^0.3.1"
|
|
37
37
|
},
|
|
38
38
|
"files": [
|
|
39
39
|
"dist",
|