@contractspec/example.analytics-dashboard 3.9.8 → 3.9.10

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 (112) hide show
  1. package/dist/browser/dashboard/dashboard.enum.js +1 -34
  2. package/dist/browser/dashboard/dashboard.operation.js +1 -289
  3. package/dist/browser/dashboard/dashboard.presentation.js +1 -200
  4. package/dist/browser/dashboard/dashboard.schema.js +1 -126
  5. package/dist/browser/dashboard/dashboard.test-spec.js +1 -213
  6. package/dist/browser/dashboard/index.js +1 -299
  7. package/dist/browser/dashboard.feature.js +1 -683
  8. package/dist/browser/datasource/posthog-datasource.js +4 -289
  9. package/dist/browser/docs/analytics-dashboard.docblock.js +5 -49
  10. package/dist/browser/docs/index.js +5 -49
  11. package/dist/browser/events.js +1 -81
  12. package/dist/browser/example.js +1 -42
  13. package/dist/browser/handlers/analytics.handlers.js +4 -278
  14. package/dist/browser/handlers/index.js +7 -571
  15. package/dist/browser/handlers/query.handlers.js +4 -294
  16. package/dist/browser/index.js +12 -2317
  17. package/dist/browser/query/index.js +1 -159
  18. package/dist/browser/query/query.enum.js +1 -11
  19. package/dist/browser/query/query.operation.js +1 -154
  20. package/dist/browser/query/query.presentation.js +1 -122
  21. package/dist/browser/query/query.schema.js +1 -70
  22. package/dist/browser/query/query.test-spec.js +1 -113
  23. package/dist/browser/query-engine/index.js +4 -491
  24. package/dist/browser/seeders/index.js +2 -20
  25. package/dist/browser/ui/AnalyticsDashboard.js +1 -1115
  26. package/dist/browser/ui/AnalyticsDashboard.widgets.js +1 -94
  27. package/dist/browser/ui/AnalyticsQueriesTable.js +1 -188
  28. package/dist/browser/ui/hooks/index.js +1 -660
  29. package/dist/browser/ui/hooks/useAnalyticsData.js +1 -657
  30. package/dist/browser/ui/index.js +5 -1283
  31. package/dist/browser/ui/renderers/analytics.markdown.js +5 -756
  32. package/dist/browser/ui/renderers/index.js +5 -756
  33. package/dist/browser/visualizations/catalog.js +1 -457
  34. package/dist/browser/visualizations/index.js +1 -611
  35. package/dist/browser/visualizations/specs.breakdown.js +1 -140
  36. package/dist/browser/visualizations/specs.performance.js +1 -198
  37. package/dist/browser/visualizations/widgets.js +1 -595
  38. package/dist/dashboard/dashboard.enum.js +1 -34
  39. package/dist/dashboard/dashboard.operation.js +1 -289
  40. package/dist/dashboard/dashboard.presentation.js +1 -200
  41. package/dist/dashboard/dashboard.schema.js +1 -126
  42. package/dist/dashboard/dashboard.test-spec.js +1 -213
  43. package/dist/dashboard/index.js +1 -299
  44. package/dist/dashboard.feature.js +1 -683
  45. package/dist/datasource/posthog-datasource.js +4 -289
  46. package/dist/docs/analytics-dashboard.docblock.js +5 -49
  47. package/dist/docs/index.js +5 -49
  48. package/dist/events.js +1 -81
  49. package/dist/example.js +1 -42
  50. package/dist/handlers/analytics.handlers.js +4 -278
  51. package/dist/handlers/index.js +7 -571
  52. package/dist/handlers/query.handlers.js +4 -294
  53. package/dist/index.js +12 -2317
  54. package/dist/node/dashboard/dashboard.enum.js +1 -34
  55. package/dist/node/dashboard/dashboard.operation.js +1 -289
  56. package/dist/node/dashboard/dashboard.presentation.js +1 -200
  57. package/dist/node/dashboard/dashboard.schema.js +1 -126
  58. package/dist/node/dashboard/dashboard.test-spec.js +1 -213
  59. package/dist/node/dashboard/index.js +1 -299
  60. package/dist/node/dashboard.feature.js +1 -683
  61. package/dist/node/datasource/posthog-datasource.js +4 -289
  62. package/dist/node/docs/analytics-dashboard.docblock.js +5 -49
  63. package/dist/node/docs/index.js +5 -49
  64. package/dist/node/events.js +1 -81
  65. package/dist/node/example.js +1 -42
  66. package/dist/node/handlers/analytics.handlers.js +4 -278
  67. package/dist/node/handlers/index.js +7 -571
  68. package/dist/node/handlers/query.handlers.js +4 -294
  69. package/dist/node/index.js +12 -2317
  70. package/dist/node/query/index.js +1 -159
  71. package/dist/node/query/query.enum.js +1 -11
  72. package/dist/node/query/query.operation.js +1 -154
  73. package/dist/node/query/query.presentation.js +1 -122
  74. package/dist/node/query/query.schema.js +1 -70
  75. package/dist/node/query/query.test-spec.js +1 -113
  76. package/dist/node/query-engine/index.js +4 -491
  77. package/dist/node/seeders/index.js +2 -20
  78. package/dist/node/ui/AnalyticsDashboard.js +1 -1115
  79. package/dist/node/ui/AnalyticsDashboard.widgets.js +1 -94
  80. package/dist/node/ui/AnalyticsQueriesTable.js +1 -188
  81. package/dist/node/ui/hooks/index.js +1 -660
  82. package/dist/node/ui/hooks/useAnalyticsData.js +1 -657
  83. package/dist/node/ui/index.js +5 -1283
  84. package/dist/node/ui/renderers/analytics.markdown.js +5 -756
  85. package/dist/node/ui/renderers/index.js +5 -756
  86. package/dist/node/visualizations/catalog.js +1 -457
  87. package/dist/node/visualizations/index.js +1 -611
  88. package/dist/node/visualizations/specs.breakdown.js +1 -140
  89. package/dist/node/visualizations/specs.performance.js +1 -198
  90. package/dist/node/visualizations/widgets.js +1 -595
  91. package/dist/query/index.js +1 -159
  92. package/dist/query/query.enum.js +1 -11
  93. package/dist/query/query.operation.js +1 -154
  94. package/dist/query/query.presentation.js +1 -122
  95. package/dist/query/query.schema.js +1 -70
  96. package/dist/query/query.test-spec.js +1 -113
  97. package/dist/query-engine/index.js +4 -491
  98. package/dist/seeders/index.js +2 -20
  99. package/dist/ui/AnalyticsDashboard.js +1 -1115
  100. package/dist/ui/AnalyticsDashboard.widgets.js +1 -94
  101. package/dist/ui/AnalyticsQueriesTable.js +1 -188
  102. package/dist/ui/hooks/index.js +1 -660
  103. package/dist/ui/hooks/useAnalyticsData.js +1 -657
  104. package/dist/ui/index.js +5 -1283
  105. package/dist/ui/renderers/analytics.markdown.js +5 -756
  106. package/dist/ui/renderers/index.js +5 -756
  107. package/dist/visualizations/catalog.js +1 -457
  108. package/dist/visualizations/index.js +1 -611
  109. package/dist/visualizations/specs.breakdown.js +1 -140
  110. package/dist/visualizations/specs.performance.js +1 -198
  111. package/dist/visualizations/widgets.js +1 -595
  112. package/package.json +13 -13
@@ -1,95 +1,2 @@
1
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
- };
2
+ import{ComparisonView as a,TimelineView as s,VisualizationCard as l,VisualizationGrid as d}from"@contractspec/lib.design-system";import{jsx as t,jsxs as r}from"react/jsx-runtime";function p({dashboardName:i,widgets:e}){if(!e.length)return r("div",{className:"rounded-lg border border-dashed p-10 text-center text-muted-foreground",children:['No visualization widgets configured for "',i,'".']});return r("div",{children:[r("h3",{className:"mb-4 font-semibold text-lg",children:['Widgets in "',i,'"']}),t(d,{children:e.map((n)=>t("div",{className:u(n.gridWidth),children:c(n)},n.id))})]})}function c(i){let e=r("span",{className:"text-muted-foreground text-xs",children:["Position: (",i.gridX,", ",i.gridY,") \u2022 ",i.gridWidth,"x",i.gridHeight]});if(i.layout==="comparison")return t(a,{description:i.description,items:i.bindings.map((o)=>({...o,footer:e})),title:i.name});if(i.layout==="timeline")return t(s,{description:i.description,items:i.bindings.map((o)=>({...o,footer:e})),title:i.name});let n=i.bindings[0];if(!n)return null;return t(l,{data:n.data,description:i.description??n.description,footer:e,height:n.height,spec:n.spec,title:i.name})}function u(i){if(i>=12)return"md:col-span-2 xl:col-span-3";if(i>=8)return"xl:col-span-2";if(i>=6)return"md:col-span-2";return""}export{p as AnalyticsWidgetBoard};
@@ -1,189 +1,2 @@
1
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
- };
2
+ import{DataTable as N}from"@contractspec/lib.design-system";import{useContractTable as W}from"@contractspec/lib.presentation-runtime-react";import{Badge as K}from"@contractspec/lib.ui-kit-web/ui/badge";import{HStack as X,VStack as I}from"@contractspec/lib.ui-kit-web/ui/stack";import{Text as A}from"@contractspec/lib.ui-kit-web/ui/text";import{jsx as z,jsxs as F}from"react/jsx-runtime";var Z={SQL:"default",METRIC:"secondary",AGGREGATION:"secondary",CUSTOM:"outline"};function $(G){return JSON.stringify(G,null,2)}function J({queries:G}){let M=W({data:G,columns:[{id:"query",header:"Query",label:"Query",accessor:(h)=>h.name,cell:({item:h})=>F(I,{gap:"xs",children:[z(A,{className:"font-medium text-sm",children:h.name}),F(A,{className:"text-muted-foreground text-xs",children:["Updated ",h.updatedAt.toLocaleDateString()]})]}),size:240,minSize:180,canSort:!0,canPin:!0,canResize:!0},{id:"description",header:"Description",label:"Description",accessor:(h)=>h.description??"",cell:({value:h})=>z(A,{className:"line-clamp-2 text-muted-foreground text-sm",children:String(h||"No description")}),size:300,minSize:220,canSort:!1,canHide:!0,canResize:!0},{id:"type",header:"Type",label:"Type",accessorKey:"type",cell:({value:h})=>z(K,{variant:Z[String(h)],children:String(h)}),size:150,canSort:!0,canHide:!0,canResize:!0},{id:"cacheTtlSeconds",header:"Cache TTL",label:"Cache TTL",accessorKey:"cacheTtlSeconds",cell:({value:h})=>`${String(h)}s`,align:"right",size:140,canSort:!0,canResize:!0},{id:"isShared",header:"Shared",label:"Shared",accessorKey:"isShared",cell:({value:h})=>z(K,{variant:h?"default":"outline",children:h?"Shared":"Private"}),size:140,canSort:!0,canHide:!0,canResize:!0}],initialState:{pagination:{pageIndex:0,pageSize:3},columnVisibility:{description:!1},columnPinning:{left:["query"],right:[]}},renderExpandedContent:(h)=>F(I,{gap:"sm",className:"py-2",children:[F(I,{gap:"xs",children:[z(A,{className:"font-medium text-sm",children:"Description"}),z(A,{className:"text-muted-foreground text-sm",children:h.description??"No description"})]}),h.sql?F(I,{gap:"xs",children:[z(A,{className:"font-medium text-sm",children:"SQL"}),z("pre",{className:"overflow-auto rounded-md bg-muted/40 p-3 text-xs",children:h.sql})]}):null,F(I,{gap:"xs",children:[z(A,{className:"font-medium text-sm",children:"Definition"}),z("pre",{className:"overflow-auto rounded-md bg-muted/40 p-3 text-xs",children:$(h.definition)})]})]}),getCanExpand:()=>!0});return z(N,{controller:M,title:"Saved Queries",description:"Client-mode table using the shared ContractSpec controller and renderer.",toolbar:F(X,{gap:"sm",className:"flex-wrap",children:[F(A,{className:"text-muted-foreground text-sm",children:[G.length," queries"]}),F(A,{className:"text-muted-foreground text-sm",children:[G.filter((h)=>h.isShared).length," shared"]})]}),emptyState:z("div",{className:"rounded-md border border-dashed p-8 text-center text-muted-foreground text-sm",children:"No queries saved"})})}export{J as AnalyticsQueriesTable};