@contractspec/example.analytics-dashboard 3.7.6 → 3.9.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 +66 -271
- package/dist/browser/dashboard.feature.js +592 -0
- package/dist/browser/docs/analytics-dashboard.docblock.js +2 -1
- package/dist/browser/docs/index.js +2 -1
- package/dist/browser/events.js +1 -1
- package/dist/browser/index.js +1260 -627
- package/dist/browser/ui/AnalyticsDashboard.js +915 -194
- package/dist/browser/ui/AnalyticsDashboard.widgets.js +94 -0
- package/dist/browser/ui/AnalyticsQueriesTable.js +188 -0
- package/dist/browser/ui/hooks/index.js +594 -3
- package/dist/browser/ui/hooks/useAnalyticsData.js +594 -3
- package/dist/browser/ui/index.js +1053 -440
- package/dist/browser/ui/renderers/analytics.markdown.js +620 -138
- package/dist/browser/ui/renderers/index.js +620 -138
- package/dist/browser/visualizations/catalog.js +457 -0
- package/dist/browser/visualizations/index.js +611 -0
- package/dist/browser/visualizations/specs.breakdown.js +140 -0
- package/dist/browser/visualizations/specs.performance.js +198 -0
- package/dist/browser/visualizations/widgets.js +595 -0
- package/dist/dashboard/index.d.ts +3 -3
- package/dist/dashboard.feature.js +592 -0
- package/dist/docs/analytics-dashboard.docblock.js +2 -1
- package/dist/docs/index.js +2 -1
- package/dist/events.js +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +1260 -627
- package/dist/node/dashboard.feature.js +592 -0
- package/dist/node/docs/analytics-dashboard.docblock.js +2 -1
- package/dist/node/docs/index.js +2 -1
- package/dist/node/events.js +1 -1
- package/dist/node/index.js +1260 -627
- package/dist/node/ui/AnalyticsDashboard.js +915 -194
- package/dist/node/ui/AnalyticsDashboard.widgets.js +94 -0
- package/dist/node/ui/AnalyticsQueriesTable.js +188 -0
- package/dist/node/ui/hooks/index.js +594 -3
- package/dist/node/ui/hooks/useAnalyticsData.js +594 -3
- package/dist/node/ui/index.js +1053 -440
- package/dist/node/ui/renderers/analytics.markdown.js +620 -138
- package/dist/node/ui/renderers/index.js +620 -138
- package/dist/node/visualizations/catalog.js +457 -0
- package/dist/node/visualizations/index.js +611 -0
- package/dist/node/visualizations/specs.breakdown.js +140 -0
- package/dist/node/visualizations/specs.performance.js +198 -0
- package/dist/node/visualizations/widgets.js +595 -0
- package/dist/query/index.d.ts +1 -1
- package/dist/query-engine/index.d.ts +1 -1
- package/dist/ui/AnalyticsDashboard.js +915 -194
- package/dist/ui/AnalyticsDashboard.widgets.d.ts +5 -0
- package/dist/ui/AnalyticsDashboard.widgets.js +95 -0
- package/dist/ui/AnalyticsQueriesTable.d.ts +4 -0
- package/dist/ui/AnalyticsQueriesTable.js +189 -0
- package/dist/ui/AnalyticsQueriesTable.smoke.test.d.ts +1 -0
- package/dist/ui/hooks/index.d.ts +1 -1
- package/dist/ui/hooks/index.js +594 -3
- package/dist/ui/hooks/useAnalyticsData.js +594 -3
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +1053 -440
- package/dist/ui/renderers/analytics.markdown.d.ts +0 -9
- package/dist/ui/renderers/analytics.markdown.js +620 -138
- package/dist/ui/renderers/index.js +620 -138
- package/dist/visualizations/catalog.d.ts +9 -0
- package/dist/visualizations/catalog.js +458 -0
- package/dist/visualizations/index.d.ts +4 -0
- package/dist/visualizations/index.js +612 -0
- package/dist/visualizations/specs.breakdown.d.ts +4 -0
- package/dist/visualizations/specs.breakdown.js +141 -0
- package/dist/visualizations/specs.performance.d.ts +5 -0
- package/dist/visualizations/specs.performance.js +199 -0
- package/dist/visualizations/widgets.d.ts +24 -0
- package/dist/visualizations/widgets.js +596 -0
- package/dist/visualizations/widgets.test.d.ts +1 -0
- package/package.json +111 -11
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/ui/AnalyticsDashboard.widgets.tsx
|
|
3
|
+
import {
|
|
4
|
+
ComparisonView,
|
|
5
|
+
TimelineView,
|
|
6
|
+
VisualizationCard,
|
|
7
|
+
VisualizationGrid
|
|
8
|
+
} from "@contractspec/lib.design-system";
|
|
9
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
10
|
+
"use client";
|
|
11
|
+
function AnalyticsWidgetBoard({
|
|
12
|
+
dashboardName,
|
|
13
|
+
widgets
|
|
14
|
+
}) {
|
|
15
|
+
if (!widgets.length) {
|
|
16
|
+
return /* @__PURE__ */ jsxDEV("div", {
|
|
17
|
+
className: "rounded-lg border border-dashed p-10 text-center text-muted-foreground",
|
|
18
|
+
children: [
|
|
19
|
+
'No visualization widgets configured for "',
|
|
20
|
+
dashboardName,
|
|
21
|
+
'".'
|
|
22
|
+
]
|
|
23
|
+
}, undefined, true, undefined, this);
|
|
24
|
+
}
|
|
25
|
+
return /* @__PURE__ */ jsxDEV("div", {
|
|
26
|
+
children: [
|
|
27
|
+
/* @__PURE__ */ jsxDEV("h3", {
|
|
28
|
+
className: "mb-4 font-semibold text-lg",
|
|
29
|
+
children: [
|
|
30
|
+
'Widgets in "',
|
|
31
|
+
dashboardName,
|
|
32
|
+
'"'
|
|
33
|
+
]
|
|
34
|
+
}, undefined, true, undefined, this),
|
|
35
|
+
/* @__PURE__ */ jsxDEV(VisualizationGrid, {
|
|
36
|
+
children: widgets.map((widget) => /* @__PURE__ */ jsxDEV("div", {
|
|
37
|
+
className: gridSpanClass(widget.gridWidth),
|
|
38
|
+
children: renderVisualizationWidget(widget)
|
|
39
|
+
}, widget.id, false, undefined, this))
|
|
40
|
+
}, undefined, false, undefined, this)
|
|
41
|
+
]
|
|
42
|
+
}, undefined, true, undefined, this);
|
|
43
|
+
}
|
|
44
|
+
function renderVisualizationWidget(widget) {
|
|
45
|
+
const footer = /* @__PURE__ */ jsxDEV("span", {
|
|
46
|
+
className: "text-muted-foreground text-xs",
|
|
47
|
+
children: [
|
|
48
|
+
"Position: (",
|
|
49
|
+
widget.gridX,
|
|
50
|
+
", ",
|
|
51
|
+
widget.gridY,
|
|
52
|
+
") \u2022 ",
|
|
53
|
+
widget.gridWidth,
|
|
54
|
+
"x",
|
|
55
|
+
widget.gridHeight
|
|
56
|
+
]
|
|
57
|
+
}, undefined, true, undefined, this);
|
|
58
|
+
if (widget.layout === "comparison") {
|
|
59
|
+
return /* @__PURE__ */ jsxDEV(ComparisonView, {
|
|
60
|
+
description: widget.description,
|
|
61
|
+
items: widget.bindings.map((binding2) => ({ ...binding2, footer })),
|
|
62
|
+
title: widget.name
|
|
63
|
+
}, undefined, false, undefined, this);
|
|
64
|
+
}
|
|
65
|
+
if (widget.layout === "timeline") {
|
|
66
|
+
return /* @__PURE__ */ jsxDEV(TimelineView, {
|
|
67
|
+
description: widget.description,
|
|
68
|
+
items: widget.bindings.map((binding2) => ({ ...binding2, footer })),
|
|
69
|
+
title: widget.name
|
|
70
|
+
}, undefined, false, undefined, this);
|
|
71
|
+
}
|
|
72
|
+
const binding = widget.bindings[0];
|
|
73
|
+
if (!binding)
|
|
74
|
+
return null;
|
|
75
|
+
return /* @__PURE__ */ jsxDEV(VisualizationCard, {
|
|
76
|
+
data: binding.data,
|
|
77
|
+
description: widget.description ?? binding.description,
|
|
78
|
+
footer,
|
|
79
|
+
height: binding.height,
|
|
80
|
+
spec: binding.spec,
|
|
81
|
+
title: widget.name
|
|
82
|
+
}, undefined, false, undefined, this);
|
|
83
|
+
}
|
|
84
|
+
function gridSpanClass(gridWidth) {
|
|
85
|
+
if (gridWidth >= 12)
|
|
86
|
+
return "md:col-span-2 xl:col-span-3";
|
|
87
|
+
if (gridWidth >= 8)
|
|
88
|
+
return "xl:col-span-2";
|
|
89
|
+
if (gridWidth >= 6)
|
|
90
|
+
return "md:col-span-2";
|
|
91
|
+
return "";
|
|
92
|
+
}
|
|
93
|
+
export {
|
|
94
|
+
AnalyticsWidgetBoard
|
|
95
|
+
};
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/ui/AnalyticsQueriesTable.tsx
|
|
3
|
+
import { DataTable } from "@contractspec/lib.design-system";
|
|
4
|
+
import { useContractTable } from "@contractspec/lib.presentation-runtime-react";
|
|
5
|
+
import { Badge } from "@contractspec/lib.ui-kit-web/ui/badge";
|
|
6
|
+
import { HStack, VStack } from "@contractspec/lib.ui-kit-web/ui/stack";
|
|
7
|
+
import { Text } from "@contractspec/lib.ui-kit-web/ui/text";
|
|
8
|
+
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
9
|
+
"use client";
|
|
10
|
+
var QUERY_TYPE_COLORS = {
|
|
11
|
+
SQL: "default",
|
|
12
|
+
METRIC: "secondary",
|
|
13
|
+
AGGREGATION: "secondary",
|
|
14
|
+
CUSTOM: "outline"
|
|
15
|
+
};
|
|
16
|
+
function formatJson(value) {
|
|
17
|
+
return JSON.stringify(value, null, 2);
|
|
18
|
+
}
|
|
19
|
+
function AnalyticsQueriesTable({ queries }) {
|
|
20
|
+
const controller = useContractTable({
|
|
21
|
+
data: queries,
|
|
22
|
+
columns: [
|
|
23
|
+
{
|
|
24
|
+
id: "query",
|
|
25
|
+
header: "Query",
|
|
26
|
+
label: "Query",
|
|
27
|
+
accessor: (query) => query.name,
|
|
28
|
+
cell: ({ item }) => /* @__PURE__ */ jsxDEV(VStack, {
|
|
29
|
+
gap: "xs",
|
|
30
|
+
children: [
|
|
31
|
+
/* @__PURE__ */ jsxDEV(Text, {
|
|
32
|
+
className: "font-medium text-sm",
|
|
33
|
+
children: item.name
|
|
34
|
+
}, undefined, false, undefined, this),
|
|
35
|
+
/* @__PURE__ */ jsxDEV(Text, {
|
|
36
|
+
className: "text-muted-foreground text-xs",
|
|
37
|
+
children: [
|
|
38
|
+
"Updated ",
|
|
39
|
+
item.updatedAt.toLocaleDateString()
|
|
40
|
+
]
|
|
41
|
+
}, undefined, true, undefined, this)
|
|
42
|
+
]
|
|
43
|
+
}, undefined, true, undefined, this),
|
|
44
|
+
size: 240,
|
|
45
|
+
minSize: 180,
|
|
46
|
+
canSort: true,
|
|
47
|
+
canPin: true,
|
|
48
|
+
canResize: true
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: "description",
|
|
52
|
+
header: "Description",
|
|
53
|
+
label: "Description",
|
|
54
|
+
accessor: (query) => query.description ?? "",
|
|
55
|
+
cell: ({ value }) => /* @__PURE__ */ jsxDEV(Text, {
|
|
56
|
+
className: "line-clamp-2 text-muted-foreground text-sm",
|
|
57
|
+
children: String(value || "No description")
|
|
58
|
+
}, undefined, false, undefined, this),
|
|
59
|
+
size: 300,
|
|
60
|
+
minSize: 220,
|
|
61
|
+
canSort: false,
|
|
62
|
+
canHide: true,
|
|
63
|
+
canResize: true
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: "type",
|
|
67
|
+
header: "Type",
|
|
68
|
+
label: "Type",
|
|
69
|
+
accessorKey: "type",
|
|
70
|
+
cell: ({ value }) => /* @__PURE__ */ jsxDEV(Badge, {
|
|
71
|
+
variant: QUERY_TYPE_COLORS[String(value)],
|
|
72
|
+
children: String(value)
|
|
73
|
+
}, undefined, false, undefined, this),
|
|
74
|
+
size: 150,
|
|
75
|
+
canSort: true,
|
|
76
|
+
canHide: true,
|
|
77
|
+
canResize: true
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
id: "cacheTtlSeconds",
|
|
81
|
+
header: "Cache TTL",
|
|
82
|
+
label: "Cache TTL",
|
|
83
|
+
accessorKey: "cacheTtlSeconds",
|
|
84
|
+
cell: ({ value }) => `${String(value)}s`,
|
|
85
|
+
align: "right",
|
|
86
|
+
size: 140,
|
|
87
|
+
canSort: true,
|
|
88
|
+
canResize: true
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
id: "isShared",
|
|
92
|
+
header: "Shared",
|
|
93
|
+
label: "Shared",
|
|
94
|
+
accessorKey: "isShared",
|
|
95
|
+
cell: ({ value }) => /* @__PURE__ */ jsxDEV(Badge, {
|
|
96
|
+
variant: value ? "default" : "outline",
|
|
97
|
+
children: value ? "Shared" : "Private"
|
|
98
|
+
}, undefined, false, undefined, this),
|
|
99
|
+
size: 140,
|
|
100
|
+
canSort: true,
|
|
101
|
+
canHide: true,
|
|
102
|
+
canResize: true
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
initialState: {
|
|
106
|
+
pagination: { pageIndex: 0, pageSize: 3 },
|
|
107
|
+
columnVisibility: { description: false },
|
|
108
|
+
columnPinning: { left: ["query"], right: [] }
|
|
109
|
+
},
|
|
110
|
+
renderExpandedContent: (query) => /* @__PURE__ */ jsxDEV(VStack, {
|
|
111
|
+
gap: "sm",
|
|
112
|
+
className: "py-2",
|
|
113
|
+
children: [
|
|
114
|
+
/* @__PURE__ */ jsxDEV(VStack, {
|
|
115
|
+
gap: "xs",
|
|
116
|
+
children: [
|
|
117
|
+
/* @__PURE__ */ jsxDEV(Text, {
|
|
118
|
+
className: "font-medium text-sm",
|
|
119
|
+
children: "Description"
|
|
120
|
+
}, undefined, false, undefined, this),
|
|
121
|
+
/* @__PURE__ */ jsxDEV(Text, {
|
|
122
|
+
className: "text-muted-foreground text-sm",
|
|
123
|
+
children: query.description ?? "No description"
|
|
124
|
+
}, undefined, false, undefined, this)
|
|
125
|
+
]
|
|
126
|
+
}, undefined, true, undefined, this),
|
|
127
|
+
query.sql ? /* @__PURE__ */ jsxDEV(VStack, {
|
|
128
|
+
gap: "xs",
|
|
129
|
+
children: [
|
|
130
|
+
/* @__PURE__ */ jsxDEV(Text, {
|
|
131
|
+
className: "font-medium text-sm",
|
|
132
|
+
children: "SQL"
|
|
133
|
+
}, undefined, false, undefined, this),
|
|
134
|
+
/* @__PURE__ */ jsxDEV("pre", {
|
|
135
|
+
className: "overflow-auto rounded-md bg-muted/40 p-3 text-xs",
|
|
136
|
+
children: query.sql
|
|
137
|
+
}, undefined, false, undefined, this)
|
|
138
|
+
]
|
|
139
|
+
}, undefined, true, undefined, this) : null,
|
|
140
|
+
/* @__PURE__ */ jsxDEV(VStack, {
|
|
141
|
+
gap: "xs",
|
|
142
|
+
children: [
|
|
143
|
+
/* @__PURE__ */ jsxDEV(Text, {
|
|
144
|
+
className: "font-medium text-sm",
|
|
145
|
+
children: "Definition"
|
|
146
|
+
}, undefined, false, undefined, this),
|
|
147
|
+
/* @__PURE__ */ jsxDEV("pre", {
|
|
148
|
+
className: "overflow-auto rounded-md bg-muted/40 p-3 text-xs",
|
|
149
|
+
children: formatJson(query.definition)
|
|
150
|
+
}, undefined, false, undefined, this)
|
|
151
|
+
]
|
|
152
|
+
}, undefined, true, undefined, this)
|
|
153
|
+
]
|
|
154
|
+
}, undefined, true, undefined, this),
|
|
155
|
+
getCanExpand: () => true
|
|
156
|
+
});
|
|
157
|
+
return /* @__PURE__ */ jsxDEV(DataTable, {
|
|
158
|
+
controller,
|
|
159
|
+
title: "Saved Queries",
|
|
160
|
+
description: "Client-mode table using the shared ContractSpec controller and renderer.",
|
|
161
|
+
toolbar: /* @__PURE__ */ jsxDEV(HStack, {
|
|
162
|
+
gap: "sm",
|
|
163
|
+
className: "flex-wrap",
|
|
164
|
+
children: [
|
|
165
|
+
/* @__PURE__ */ jsxDEV(Text, {
|
|
166
|
+
className: "text-muted-foreground text-sm",
|
|
167
|
+
children: [
|
|
168
|
+
queries.length,
|
|
169
|
+
" queries"
|
|
170
|
+
]
|
|
171
|
+
}, undefined, true, undefined, this),
|
|
172
|
+
/* @__PURE__ */ jsxDEV(Text, {
|
|
173
|
+
className: "text-muted-foreground text-sm",
|
|
174
|
+
children: [
|
|
175
|
+
queries.filter((query) => query.isShared).length,
|
|
176
|
+
" shared"
|
|
177
|
+
]
|
|
178
|
+
}, undefined, true, undefined, this)
|
|
179
|
+
]
|
|
180
|
+
}, undefined, true, undefined, this),
|
|
181
|
+
emptyState: /* @__PURE__ */ jsxDEV("div", {
|
|
182
|
+
className: "rounded-md border border-dashed p-8 text-center text-muted-foreground text-sm",
|
|
183
|
+
children: "No queries saved"
|
|
184
|
+
}, undefined, false, undefined, this)
|
|
185
|
+
}, undefined, false, undefined, this);
|
|
186
|
+
}
|
|
187
|
+
export {
|
|
188
|
+
AnalyticsQueriesTable
|
|
189
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/ui/hooks/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { type AnalyticsStats, useAnalyticsData } from './useAnalyticsData';
|