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