@contractspec/example.analytics-dashboard 1.56.1 → 1.58.0

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 (171) hide show
  1. package/dist/browser/dashboard/dashboard.enum.js +34 -0
  2. package/dist/browser/dashboard/dashboard.operation.js +289 -0
  3. package/dist/browser/dashboard/dashboard.presentation.js +197 -0
  4. package/dist/browser/dashboard/dashboard.schema.js +126 -0
  5. package/dist/browser/dashboard/dashboard.test-spec.js +213 -0
  6. package/dist/browser/dashboard/index.js +299 -0
  7. package/dist/browser/dashboard.feature.js +84 -0
  8. package/dist/browser/datasource/posthog-datasource.js +289 -0
  9. package/dist/browser/docs/analytics-dashboard.docblock.js +103 -0
  10. package/dist/browser/docs/index.js +103 -0
  11. package/dist/browser/events.js +81 -0
  12. package/dist/browser/example.js +42 -0
  13. package/dist/browser/handlers/analytics.handlers.js +278 -0
  14. package/dist/browser/handlers/index.js +571 -0
  15. package/dist/browser/handlers/query.handlers.js +294 -0
  16. package/dist/browser/index.js +1677 -0
  17. package/dist/browser/query/index.js +159 -0
  18. package/dist/browser/query/query.enum.js +11 -0
  19. package/dist/browser/query/query.operation.js +154 -0
  20. package/dist/browser/query/query.presentation.js +119 -0
  21. package/dist/browser/query/query.schema.js +70 -0
  22. package/dist/browser/query/query.test-spec.js +113 -0
  23. package/dist/browser/query-engine/index.js +491 -0
  24. package/dist/browser/seeders/index.js +20 -0
  25. package/dist/browser/ui/AnalyticsDashboard.js +394 -0
  26. package/dist/browser/ui/hooks/index.js +69 -0
  27. package/dist/browser/ui/hooks/useAnalyticsData.js +66 -0
  28. package/dist/browser/ui/index.js +671 -0
  29. package/dist/browser/ui/renderers/analytics.markdown.js +275 -0
  30. package/dist/browser/ui/renderers/index.js +275 -0
  31. package/dist/dashboard/dashboard.enum.d.ts +3 -8
  32. package/dist/dashboard/dashboard.enum.d.ts.map +1 -1
  33. package/dist/dashboard/dashboard.enum.js +31 -39
  34. package/dist/dashboard/dashboard.operation.d.ts +444 -450
  35. package/dist/dashboard/dashboard.operation.d.ts.map +1 -1
  36. package/dist/dashboard/dashboard.operation.js +284 -207
  37. package/dist/dashboard/dashboard.presentation.d.ts +3 -8
  38. package/dist/dashboard/dashboard.presentation.d.ts.map +1 -1
  39. package/dist/dashboard/dashboard.presentation.js +193 -85
  40. package/dist/dashboard/dashboard.schema.d.ts +289 -294
  41. package/dist/dashboard/dashboard.schema.d.ts.map +1 -1
  42. package/dist/dashboard/dashboard.schema.js +119 -228
  43. package/dist/dashboard/dashboard.test-spec.d.ts +4 -9
  44. package/dist/dashboard/dashboard.test-spec.d.ts.map +1 -1
  45. package/dist/dashboard/dashboard.test-spec.js +209 -228
  46. package/dist/dashboard/index.d.ts +7 -4
  47. package/dist/dashboard/index.d.ts.map +1 -0
  48. package/dist/dashboard/index.js +299 -4
  49. package/dist/dashboard.feature.d.ts +1 -7
  50. package/dist/dashboard.feature.d.ts.map +1 -1
  51. package/dist/dashboard.feature.js +83 -175
  52. package/dist/datasource/posthog-datasource.d.ts +18 -0
  53. package/dist/datasource/posthog-datasource.d.ts.map +1 -0
  54. package/dist/datasource/posthog-datasource.js +290 -0
  55. package/dist/docs/analytics-dashboard.docblock.d.ts +2 -1
  56. package/dist/docs/analytics-dashboard.docblock.d.ts.map +1 -0
  57. package/dist/docs/analytics-dashboard.docblock.js +46 -56
  58. package/dist/docs/index.d.ts +2 -1
  59. package/dist/docs/index.d.ts.map +1 -0
  60. package/dist/docs/index.js +104 -1
  61. package/dist/events.d.ts +109 -115
  62. package/dist/events.d.ts.map +1 -1
  63. package/dist/events.js +74 -120
  64. package/dist/example.d.ts +2 -6
  65. package/dist/example.d.ts.map +1 -1
  66. package/dist/example.js +40 -55
  67. package/dist/handlers/analytics.handlers.d.ts +110 -110
  68. package/dist/handlers/analytics.handlers.d.ts.map +1 -1
  69. package/dist/handlers/analytics.handlers.js +267 -298
  70. package/dist/handlers/index.d.ts +3 -2
  71. package/dist/handlers/index.d.ts.map +1 -0
  72. package/dist/handlers/index.js +571 -2
  73. package/dist/handlers/query.handlers.d.ts +9 -0
  74. package/dist/handlers/query.handlers.d.ts.map +1 -0
  75. package/dist/handlers/query.handlers.js +295 -0
  76. package/dist/index.d.ts +12 -12
  77. package/dist/index.d.ts.map +1 -0
  78. package/dist/index.js +1678 -13
  79. package/dist/node/dashboard/dashboard.enum.js +34 -0
  80. package/dist/node/dashboard/dashboard.operation.js +289 -0
  81. package/dist/node/dashboard/dashboard.presentation.js +197 -0
  82. package/dist/node/dashboard/dashboard.schema.js +126 -0
  83. package/dist/node/dashboard/dashboard.test-spec.js +213 -0
  84. package/dist/node/dashboard/index.js +299 -0
  85. package/dist/node/dashboard.feature.js +84 -0
  86. package/dist/node/datasource/posthog-datasource.js +289 -0
  87. package/dist/node/docs/analytics-dashboard.docblock.js +103 -0
  88. package/dist/node/docs/index.js +103 -0
  89. package/dist/node/events.js +81 -0
  90. package/dist/node/example.js +42 -0
  91. package/dist/node/handlers/analytics.handlers.js +278 -0
  92. package/dist/node/handlers/index.js +571 -0
  93. package/dist/node/handlers/query.handlers.js +294 -0
  94. package/dist/node/index.js +1677 -0
  95. package/dist/node/query/index.js +159 -0
  96. package/dist/node/query/query.enum.js +11 -0
  97. package/dist/node/query/query.operation.js +154 -0
  98. package/dist/node/query/query.presentation.js +119 -0
  99. package/dist/node/query/query.schema.js +70 -0
  100. package/dist/node/query/query.test-spec.js +113 -0
  101. package/dist/node/query-engine/index.js +491 -0
  102. package/dist/node/seeders/index.js +20 -0
  103. package/dist/node/ui/AnalyticsDashboard.js +394 -0
  104. package/dist/node/ui/hooks/index.js +69 -0
  105. package/dist/node/ui/hooks/useAnalyticsData.js +66 -0
  106. package/dist/node/ui/index.js +671 -0
  107. package/dist/node/ui/renderers/analytics.markdown.js +275 -0
  108. package/dist/node/ui/renderers/index.js +275 -0
  109. package/dist/query/index.d.ts +7 -4
  110. package/dist/query/index.d.ts.map +1 -0
  111. package/dist/query/index.js +159 -4
  112. package/dist/query/query.enum.d.ts +1 -6
  113. package/dist/query/query.enum.d.ts.map +1 -1
  114. package/dist/query/query.enum.js +10 -14
  115. package/dist/query/query.operation.d.ts +148 -154
  116. package/dist/query/query.operation.d.ts.map +1 -1
  117. package/dist/query/query.operation.js +151 -109
  118. package/dist/query/query.presentation.d.ts +2 -7
  119. package/dist/query/query.presentation.d.ts.map +1 -1
  120. package/dist/query/query.presentation.js +116 -56
  121. package/dist/query/query.schema.d.ts +121 -126
  122. package/dist/query/query.schema.d.ts.map +1 -1
  123. package/dist/query/query.schema.js +66 -152
  124. package/dist/query/query.test-spec.d.ts +2 -7
  125. package/dist/query/query.test-spec.d.ts.map +1 -1
  126. package/dist/query/query.test-spec.js +111 -121
  127. package/dist/query-engine/index.d.ts +84 -86
  128. package/dist/query-engine/index.d.ts.map +1 -1
  129. package/dist/query-engine/index.js +490 -187
  130. package/dist/seeders/index.d.ts +4 -8
  131. package/dist/seeders/index.d.ts.map +1 -1
  132. package/dist/seeders/index.js +18 -16
  133. package/dist/ui/AnalyticsDashboard.d.ts +1 -6
  134. package/dist/ui/AnalyticsDashboard.d.ts.map +1 -1
  135. package/dist/ui/AnalyticsDashboard.js +389 -259
  136. package/dist/ui/hooks/index.d.ts +2 -2
  137. package/dist/ui/hooks/index.d.ts.map +1 -0
  138. package/dist/ui/hooks/index.js +69 -4
  139. package/dist/ui/hooks/useAnalyticsData.d.ts +16 -20
  140. package/dist/ui/hooks/useAnalyticsData.d.ts.map +1 -1
  141. package/dist/ui/hooks/useAnalyticsData.js +63 -69
  142. package/dist/ui/index.d.ts +7 -6
  143. package/dist/ui/index.d.ts.map +1 -0
  144. package/dist/ui/index.js +671 -5
  145. package/dist/ui/renderers/analytics.markdown.d.ts +13 -15
  146. package/dist/ui/renderers/analytics.markdown.d.ts.map +1 -1
  147. package/dist/ui/renderers/analytics.markdown.js +266 -254
  148. package/dist/ui/renderers/index.d.ts +2 -2
  149. package/dist/ui/renderers/index.d.ts.map +1 -0
  150. package/dist/ui/renderers/index.js +275 -2
  151. package/package.json +329 -62
  152. package/dist/dashboard/dashboard.enum.js.map +0 -1
  153. package/dist/dashboard/dashboard.operation.js.map +0 -1
  154. package/dist/dashboard/dashboard.presentation.js.map +0 -1
  155. package/dist/dashboard/dashboard.schema.js.map +0 -1
  156. package/dist/dashboard/dashboard.test-spec.js.map +0 -1
  157. package/dist/dashboard.feature.js.map +0 -1
  158. package/dist/docs/analytics-dashboard.docblock.js.map +0 -1
  159. package/dist/events.js.map +0 -1
  160. package/dist/example.js.map +0 -1
  161. package/dist/handlers/analytics.handlers.js.map +0 -1
  162. package/dist/query/query.enum.js.map +0 -1
  163. package/dist/query/query.operation.js.map +0 -1
  164. package/dist/query/query.presentation.js.map +0 -1
  165. package/dist/query/query.schema.js.map +0 -1
  166. package/dist/query/query.test-spec.js.map +0 -1
  167. package/dist/query-engine/index.js.map +0 -1
  168. package/dist/seeders/index.js.map +0 -1
  169. package/dist/ui/AnalyticsDashboard.js.map +0 -1
  170. package/dist/ui/hooks/useAnalyticsData.js.map +0 -1
  171. package/dist/ui/renderers/analytics.markdown.js.map +0 -1
@@ -0,0 +1,275 @@
1
+ // src/ui/renderers/analytics.markdown.ts
2
+ var mockDashboards = [
3
+ {
4
+ id: "dash-1",
5
+ name: "Sales Overview",
6
+ slug: "sales-overview",
7
+ status: "PUBLISHED",
8
+ widgetCount: 8,
9
+ viewCount: 1250,
10
+ lastViewedAt: "2024-01-16T12:00:00Z"
11
+ },
12
+ {
13
+ id: "dash-2",
14
+ name: "User Engagement",
15
+ slug: "user-engagement",
16
+ status: "PUBLISHED",
17
+ widgetCount: 6,
18
+ viewCount: 890,
19
+ lastViewedAt: "2024-01-16T10:00:00Z"
20
+ },
21
+ {
22
+ id: "dash-3",
23
+ name: "Product Analytics",
24
+ slug: "product-analytics",
25
+ status: "PUBLISHED",
26
+ widgetCount: 10,
27
+ viewCount: 560,
28
+ lastViewedAt: "2024-01-15T14:00:00Z"
29
+ },
30
+ {
31
+ id: "dash-4",
32
+ name: "Finance Report",
33
+ slug: "finance-report",
34
+ status: "DRAFT",
35
+ widgetCount: 4,
36
+ viewCount: 0,
37
+ lastViewedAt: null
38
+ }
39
+ ];
40
+ var mockWidgets = [
41
+ {
42
+ id: "w-1",
43
+ dashboardId: "dash-1",
44
+ name: "Total Revenue",
45
+ type: "METRIC",
46
+ value: 125000,
47
+ change: 12.5
48
+ },
49
+ {
50
+ id: "w-2",
51
+ dashboardId: "dash-1",
52
+ name: "Active Users",
53
+ type: "METRIC",
54
+ value: 4500,
55
+ change: 8.2
56
+ },
57
+ {
58
+ id: "w-3",
59
+ dashboardId: "dash-1",
60
+ name: "Revenue Trend",
61
+ type: "LINE_CHART",
62
+ dataPoints: 30
63
+ },
64
+ {
65
+ id: "w-4",
66
+ dashboardId: "dash-1",
67
+ name: "Top Products",
68
+ type: "BAR_CHART",
69
+ dataPoints: 10
70
+ },
71
+ {
72
+ id: "w-5",
73
+ dashboardId: "dash-2",
74
+ name: "Daily Active Users",
75
+ type: "LINE_CHART",
76
+ dataPoints: 30
77
+ },
78
+ {
79
+ id: "w-6",
80
+ dashboardId: "dash-2",
81
+ name: "Session Duration",
82
+ type: "METRIC",
83
+ value: 245,
84
+ change: -3.1
85
+ }
86
+ ];
87
+ var mockQueries = [
88
+ {
89
+ id: "q-1",
90
+ name: "Monthly Revenue",
91
+ type: "AGGREGATION",
92
+ isShared: true,
93
+ executionCount: 1500
94
+ },
95
+ {
96
+ id: "q-2",
97
+ name: "User Growth",
98
+ type: "METRIC",
99
+ isShared: true,
100
+ executionCount: 890
101
+ },
102
+ {
103
+ id: "q-3",
104
+ name: "Product Sales",
105
+ type: "SQL",
106
+ isShared: false,
107
+ executionCount: 340
108
+ },
109
+ {
110
+ id: "q-4",
111
+ name: "Conversion Funnel",
112
+ type: "AGGREGATION",
113
+ isShared: true,
114
+ executionCount: 450
115
+ }
116
+ ];
117
+ function formatNumber(value) {
118
+ if (value >= 1e6) {
119
+ return `${(value / 1e6).toFixed(1)}M`;
120
+ }
121
+ if (value >= 1000) {
122
+ return `${(value / 1000).toFixed(1)}K`;
123
+ }
124
+ return value.toString();
125
+ }
126
+ function formatChange(change) {
127
+ const icon = change >= 0 ? "\uD83D\uDCC8" : "\uD83D\uDCC9";
128
+ const sign = change >= 0 ? "+" : "";
129
+ return `${icon} ${sign}${change.toFixed(1)}%`;
130
+ }
131
+ var analyticsDashboardMarkdownRenderer = {
132
+ target: "markdown",
133
+ render: async (desc) => {
134
+ if (desc.source.type !== "component" || desc.source.componentKey !== "AnalyticsDashboard") {
135
+ throw new Error("analyticsDashboardMarkdownRenderer: not AnalyticsDashboard");
136
+ }
137
+ const dashboards = mockDashboards;
138
+ const widgets = mockWidgets;
139
+ const queries = mockQueries;
140
+ const dashboard = dashboards[0];
141
+ if (!dashboard) {
142
+ return {
143
+ mimeType: "text/markdown",
144
+ body: `# No Dashboards
145
+
146
+ No dashboards available.`
147
+ };
148
+ }
149
+ const dashboardWidgets = widgets.filter((w) => w.dashboardId === dashboard.id);
150
+ const publishedDashboards = dashboards.filter((d) => d.status === "PUBLISHED");
151
+ const totalViews = dashboards.reduce((sum, d) => sum + d.viewCount, 0);
152
+ const sharedQueries = queries.filter((q) => q.isShared);
153
+ const lines = [
154
+ `# ${dashboard.name}`,
155
+ "",
156
+ "> Analytics dashboard overview",
157
+ "",
158
+ "## Key Metrics",
159
+ ""
160
+ ];
161
+ const metricWidgets = dashboardWidgets.filter((w) => w.type === "METRIC");
162
+ for (const widget of metricWidgets) {
163
+ const w = widget;
164
+ lines.push(`### ${w.name}`);
165
+ lines.push(`**${formatNumber(w.value)}** ${formatChange(w.change)}`);
166
+ lines.push("");
167
+ }
168
+ lines.push("## Visualizations");
169
+ lines.push("");
170
+ const chartWidgets = dashboardWidgets.filter((w) => w.type !== "METRIC");
171
+ for (const widget of chartWidgets) {
172
+ const w = widget;
173
+ lines.push(`- **${w.name}** (${w.type.replace("_", " ")}) - ${w.dataPoints} data points`);
174
+ }
175
+ lines.push("");
176
+ lines.push("## Dashboard Stats");
177
+ lines.push("");
178
+ lines.push("| Metric | Value |");
179
+ lines.push("|--------|-------|");
180
+ lines.push(`| Total Dashboards | ${dashboards.length} |`);
181
+ lines.push(`| Published | ${publishedDashboards.length} |`);
182
+ lines.push(`| Total Views | ${totalViews.toLocaleString()} |`);
183
+ lines.push(`| Shared Queries | ${sharedQueries.length} |`);
184
+ return {
185
+ mimeType: "text/markdown",
186
+ body: lines.join(`
187
+ `)
188
+ };
189
+ }
190
+ };
191
+ var dashboardListMarkdownRenderer = {
192
+ target: "markdown",
193
+ render: async (desc) => {
194
+ if (desc.source.type !== "component" || desc.source.componentKey !== "DashboardList") {
195
+ throw new Error("dashboardListMarkdownRenderer: not DashboardList");
196
+ }
197
+ const dashboards = mockDashboards;
198
+ const lines = [
199
+ "# Dashboards",
200
+ "",
201
+ "> Browse and manage analytics dashboards",
202
+ "",
203
+ "| Dashboard | Widgets | Views | Status | Last Viewed |",
204
+ "|-----------|---------|-------|--------|-------------|"
205
+ ];
206
+ for (const dashboard of dashboards) {
207
+ const lastViewed = dashboard.lastViewedAt ? new Date(dashboard.lastViewedAt).toLocaleDateString() : "Never";
208
+ const statusIcon = dashboard.status === "PUBLISHED" ? "\uD83D\uDFE2" : "⚫";
209
+ lines.push(`| [${dashboard.name}](/dashboards/${dashboard.slug}) | ${dashboard.widgetCount} | ${dashboard.viewCount.toLocaleString()} | ${statusIcon} ${dashboard.status} | ${lastViewed} |`);
210
+ }
211
+ lines.push("");
212
+ lines.push("## Quick Actions");
213
+ lines.push("");
214
+ lines.push("- **Create Dashboard** - Start with a blank canvas");
215
+ lines.push("- **Import Template** - Use a pre-built template");
216
+ lines.push("- **Clone Dashboard** - Duplicate an existing dashboard");
217
+ return {
218
+ mimeType: "text/markdown",
219
+ body: lines.join(`
220
+ `)
221
+ };
222
+ }
223
+ };
224
+ var queryBuilderMarkdownRenderer = {
225
+ target: "markdown",
226
+ render: async (desc) => {
227
+ if (desc.source.type !== "component" || desc.source.componentKey !== "QueryBuilder") {
228
+ throw new Error("queryBuilderMarkdownRenderer: not QueryBuilder");
229
+ }
230
+ const queries = mockQueries;
231
+ const lines = [
232
+ "# Query Builder",
233
+ "",
234
+ "> Create and manage data queries",
235
+ "",
236
+ "## Saved Queries",
237
+ "",
238
+ "| Query | Type | Shared | Executions |",
239
+ "|-------|------|--------|------------|"
240
+ ];
241
+ for (const query of queries) {
242
+ const sharedIcon = query.isShared ? "\uD83C\uDF10" : "\uD83D\uDD12";
243
+ lines.push(`| ${query.name} | ${query.type} | ${sharedIcon} | ${query.executionCount.toLocaleString()} |`);
244
+ }
245
+ lines.push("");
246
+ lines.push("## Query Types");
247
+ lines.push("");
248
+ lines.push("### METRIC");
249
+ lines.push("Query usage metrics from the metering system.");
250
+ lines.push("");
251
+ lines.push("### AGGREGATION");
252
+ lines.push("Build aggregations with measures and dimensions without writing SQL.");
253
+ lines.push("");
254
+ lines.push("### SQL");
255
+ lines.push("Write custom SQL queries for advanced analysis.");
256
+ lines.push("");
257
+ lines.push("## Features");
258
+ lines.push("");
259
+ lines.push("- Visual query builder");
260
+ lines.push("- Auto-complete for fields and functions");
261
+ lines.push("- Query validation and optimization");
262
+ lines.push("- Result caching");
263
+ lines.push("- Query sharing and collaboration");
264
+ return {
265
+ mimeType: "text/markdown",
266
+ body: lines.join(`
267
+ `)
268
+ };
269
+ }
270
+ };
271
+ export {
272
+ queryBuilderMarkdownRenderer,
273
+ dashboardListMarkdownRenderer,
274
+ analyticsDashboardMarkdownRenderer
275
+ };
@@ -0,0 +1,275 @@
1
+ // src/ui/renderers/analytics.markdown.ts
2
+ var mockDashboards = [
3
+ {
4
+ id: "dash-1",
5
+ name: "Sales Overview",
6
+ slug: "sales-overview",
7
+ status: "PUBLISHED",
8
+ widgetCount: 8,
9
+ viewCount: 1250,
10
+ lastViewedAt: "2024-01-16T12:00:00Z"
11
+ },
12
+ {
13
+ id: "dash-2",
14
+ name: "User Engagement",
15
+ slug: "user-engagement",
16
+ status: "PUBLISHED",
17
+ widgetCount: 6,
18
+ viewCount: 890,
19
+ lastViewedAt: "2024-01-16T10:00:00Z"
20
+ },
21
+ {
22
+ id: "dash-3",
23
+ name: "Product Analytics",
24
+ slug: "product-analytics",
25
+ status: "PUBLISHED",
26
+ widgetCount: 10,
27
+ viewCount: 560,
28
+ lastViewedAt: "2024-01-15T14:00:00Z"
29
+ },
30
+ {
31
+ id: "dash-4",
32
+ name: "Finance Report",
33
+ slug: "finance-report",
34
+ status: "DRAFT",
35
+ widgetCount: 4,
36
+ viewCount: 0,
37
+ lastViewedAt: null
38
+ }
39
+ ];
40
+ var mockWidgets = [
41
+ {
42
+ id: "w-1",
43
+ dashboardId: "dash-1",
44
+ name: "Total Revenue",
45
+ type: "METRIC",
46
+ value: 125000,
47
+ change: 12.5
48
+ },
49
+ {
50
+ id: "w-2",
51
+ dashboardId: "dash-1",
52
+ name: "Active Users",
53
+ type: "METRIC",
54
+ value: 4500,
55
+ change: 8.2
56
+ },
57
+ {
58
+ id: "w-3",
59
+ dashboardId: "dash-1",
60
+ name: "Revenue Trend",
61
+ type: "LINE_CHART",
62
+ dataPoints: 30
63
+ },
64
+ {
65
+ id: "w-4",
66
+ dashboardId: "dash-1",
67
+ name: "Top Products",
68
+ type: "BAR_CHART",
69
+ dataPoints: 10
70
+ },
71
+ {
72
+ id: "w-5",
73
+ dashboardId: "dash-2",
74
+ name: "Daily Active Users",
75
+ type: "LINE_CHART",
76
+ dataPoints: 30
77
+ },
78
+ {
79
+ id: "w-6",
80
+ dashboardId: "dash-2",
81
+ name: "Session Duration",
82
+ type: "METRIC",
83
+ value: 245,
84
+ change: -3.1
85
+ }
86
+ ];
87
+ var mockQueries = [
88
+ {
89
+ id: "q-1",
90
+ name: "Monthly Revenue",
91
+ type: "AGGREGATION",
92
+ isShared: true,
93
+ executionCount: 1500
94
+ },
95
+ {
96
+ id: "q-2",
97
+ name: "User Growth",
98
+ type: "METRIC",
99
+ isShared: true,
100
+ executionCount: 890
101
+ },
102
+ {
103
+ id: "q-3",
104
+ name: "Product Sales",
105
+ type: "SQL",
106
+ isShared: false,
107
+ executionCount: 340
108
+ },
109
+ {
110
+ id: "q-4",
111
+ name: "Conversion Funnel",
112
+ type: "AGGREGATION",
113
+ isShared: true,
114
+ executionCount: 450
115
+ }
116
+ ];
117
+ function formatNumber(value) {
118
+ if (value >= 1e6) {
119
+ return `${(value / 1e6).toFixed(1)}M`;
120
+ }
121
+ if (value >= 1000) {
122
+ return `${(value / 1000).toFixed(1)}K`;
123
+ }
124
+ return value.toString();
125
+ }
126
+ function formatChange(change) {
127
+ const icon = change >= 0 ? "\uD83D\uDCC8" : "\uD83D\uDCC9";
128
+ const sign = change >= 0 ? "+" : "";
129
+ return `${icon} ${sign}${change.toFixed(1)}%`;
130
+ }
131
+ var analyticsDashboardMarkdownRenderer = {
132
+ target: "markdown",
133
+ render: async (desc) => {
134
+ if (desc.source.type !== "component" || desc.source.componentKey !== "AnalyticsDashboard") {
135
+ throw new Error("analyticsDashboardMarkdownRenderer: not AnalyticsDashboard");
136
+ }
137
+ const dashboards = mockDashboards;
138
+ const widgets = mockWidgets;
139
+ const queries = mockQueries;
140
+ const dashboard = dashboards[0];
141
+ if (!dashboard) {
142
+ return {
143
+ mimeType: "text/markdown",
144
+ body: `# No Dashboards
145
+
146
+ No dashboards available.`
147
+ };
148
+ }
149
+ const dashboardWidgets = widgets.filter((w) => w.dashboardId === dashboard.id);
150
+ const publishedDashboards = dashboards.filter((d) => d.status === "PUBLISHED");
151
+ const totalViews = dashboards.reduce((sum, d) => sum + d.viewCount, 0);
152
+ const sharedQueries = queries.filter((q) => q.isShared);
153
+ const lines = [
154
+ `# ${dashboard.name}`,
155
+ "",
156
+ "> Analytics dashboard overview",
157
+ "",
158
+ "## Key Metrics",
159
+ ""
160
+ ];
161
+ const metricWidgets = dashboardWidgets.filter((w) => w.type === "METRIC");
162
+ for (const widget of metricWidgets) {
163
+ const w = widget;
164
+ lines.push(`### ${w.name}`);
165
+ lines.push(`**${formatNumber(w.value)}** ${formatChange(w.change)}`);
166
+ lines.push("");
167
+ }
168
+ lines.push("## Visualizations");
169
+ lines.push("");
170
+ const chartWidgets = dashboardWidgets.filter((w) => w.type !== "METRIC");
171
+ for (const widget of chartWidgets) {
172
+ const w = widget;
173
+ lines.push(`- **${w.name}** (${w.type.replace("_", " ")}) - ${w.dataPoints} data points`);
174
+ }
175
+ lines.push("");
176
+ lines.push("## Dashboard Stats");
177
+ lines.push("");
178
+ lines.push("| Metric | Value |");
179
+ lines.push("|--------|-------|");
180
+ lines.push(`| Total Dashboards | ${dashboards.length} |`);
181
+ lines.push(`| Published | ${publishedDashboards.length} |`);
182
+ lines.push(`| Total Views | ${totalViews.toLocaleString()} |`);
183
+ lines.push(`| Shared Queries | ${sharedQueries.length} |`);
184
+ return {
185
+ mimeType: "text/markdown",
186
+ body: lines.join(`
187
+ `)
188
+ };
189
+ }
190
+ };
191
+ var dashboardListMarkdownRenderer = {
192
+ target: "markdown",
193
+ render: async (desc) => {
194
+ if (desc.source.type !== "component" || desc.source.componentKey !== "DashboardList") {
195
+ throw new Error("dashboardListMarkdownRenderer: not DashboardList");
196
+ }
197
+ const dashboards = mockDashboards;
198
+ const lines = [
199
+ "# Dashboards",
200
+ "",
201
+ "> Browse and manage analytics dashboards",
202
+ "",
203
+ "| Dashboard | Widgets | Views | Status | Last Viewed |",
204
+ "|-----------|---------|-------|--------|-------------|"
205
+ ];
206
+ for (const dashboard of dashboards) {
207
+ const lastViewed = dashboard.lastViewedAt ? new Date(dashboard.lastViewedAt).toLocaleDateString() : "Never";
208
+ const statusIcon = dashboard.status === "PUBLISHED" ? "\uD83D\uDFE2" : "⚫";
209
+ lines.push(`| [${dashboard.name}](/dashboards/${dashboard.slug}) | ${dashboard.widgetCount} | ${dashboard.viewCount.toLocaleString()} | ${statusIcon} ${dashboard.status} | ${lastViewed} |`);
210
+ }
211
+ lines.push("");
212
+ lines.push("## Quick Actions");
213
+ lines.push("");
214
+ lines.push("- **Create Dashboard** - Start with a blank canvas");
215
+ lines.push("- **Import Template** - Use a pre-built template");
216
+ lines.push("- **Clone Dashboard** - Duplicate an existing dashboard");
217
+ return {
218
+ mimeType: "text/markdown",
219
+ body: lines.join(`
220
+ `)
221
+ };
222
+ }
223
+ };
224
+ var queryBuilderMarkdownRenderer = {
225
+ target: "markdown",
226
+ render: async (desc) => {
227
+ if (desc.source.type !== "component" || desc.source.componentKey !== "QueryBuilder") {
228
+ throw new Error("queryBuilderMarkdownRenderer: not QueryBuilder");
229
+ }
230
+ const queries = mockQueries;
231
+ const lines = [
232
+ "# Query Builder",
233
+ "",
234
+ "> Create and manage data queries",
235
+ "",
236
+ "## Saved Queries",
237
+ "",
238
+ "| Query | Type | Shared | Executions |",
239
+ "|-------|------|--------|------------|"
240
+ ];
241
+ for (const query of queries) {
242
+ const sharedIcon = query.isShared ? "\uD83C\uDF10" : "\uD83D\uDD12";
243
+ lines.push(`| ${query.name} | ${query.type} | ${sharedIcon} | ${query.executionCount.toLocaleString()} |`);
244
+ }
245
+ lines.push("");
246
+ lines.push("## Query Types");
247
+ lines.push("");
248
+ lines.push("### METRIC");
249
+ lines.push("Query usage metrics from the metering system.");
250
+ lines.push("");
251
+ lines.push("### AGGREGATION");
252
+ lines.push("Build aggregations with measures and dimensions without writing SQL.");
253
+ lines.push("");
254
+ lines.push("### SQL");
255
+ lines.push("Write custom SQL queries for advanced analysis.");
256
+ lines.push("");
257
+ lines.push("## Features");
258
+ lines.push("");
259
+ lines.push("- Visual query builder");
260
+ lines.push("- Auto-complete for fields and functions");
261
+ lines.push("- Query validation and optimization");
262
+ lines.push("- Result caching");
263
+ lines.push("- Query sharing and collaboration");
264
+ return {
265
+ mimeType: "text/markdown",
266
+ body: lines.join(`
267
+ `)
268
+ };
269
+ }
270
+ };
271
+ export {
272
+ queryBuilderMarkdownRenderer,
273
+ dashboardListMarkdownRenderer,
274
+ analyticsDashboardMarkdownRenderer
275
+ };
@@ -1,18 +1,13 @@
1
- import * as _contractspec_lib_schema115 from "@contractspec/lib.schema";
2
-
3
- //#region src/dashboard/dashboard.enum.d.ts
4
1
  /**
5
2
  * Dashboard status enum.
6
3
  */
7
- declare const DashboardStatusEnum: _contractspec_lib_schema115.EnumType<[string, string, string]>;
4
+ export declare const DashboardStatusEnum: import("@contractspec/lib.schema").EnumType<[string, string, string]>;
8
5
  /**
9
6
  * Widget type enum.
10
7
  */
11
- declare const WidgetTypeEnum: _contractspec_lib_schema115.EnumType<[string, string, string, string, string, string, string, string, string, string, string, string]>;
8
+ export declare const WidgetTypeEnum: import("@contractspec/lib.schema").EnumType<[string, string, string, string, string, string, string, string, string, string, string, string]>;
12
9
  /**
13
10
  * Refresh interval enum.
14
11
  */
15
- declare const RefreshIntervalEnum: _contractspec_lib_schema115.EnumType<[string, string, string, string, string, string]>;
16
- //#endregion
17
- export { DashboardStatusEnum, RefreshIntervalEnum, WidgetTypeEnum };
12
+ export declare const RefreshIntervalEnum: import("@contractspec/lib.schema").EnumType<[string, string, string, string, string, string]>;
18
13
  //# sourceMappingURL=dashboard.enum.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dashboard.enum.d.ts","names":[],"sources":["../../src/dashboard/dashboard.enum.ts"],"sourcesContent":[],"mappings":";;;;;;AAKa,cAAA,mBAIX,EAAA,2BAAA,CAJ8B,QAAA,CAAA,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,CAAA,CAAA;AAShC;AAkBA;;cAlBa,gBAaX,2BAAA,CAbyB;;;;cAkBd,qBAOX,2BAAA,CAP8B"}
1
+ {"version":3,"file":"dashboard.enum.d.ts","sourceRoot":"","sources":["../../src/dashboard/dashboard.enum.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,mBAAmB,uEAI9B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,cAAc,+IAazB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,mBAAmB,+FAO9B,CAAC"}
@@ -1,43 +1,35 @@
1
+ // @bun
2
+ // src/dashboard/dashboard.enum.ts
1
3
  import { defineEnum } from "@contractspec/lib.schema";
2
-
3
- //#region src/dashboard/dashboard.enum.ts
4
- /**
5
- * Dashboard status enum.
6
- */
7
- const DashboardStatusEnum = defineEnum("DashboardStatus", [
8
- "DRAFT",
9
- "PUBLISHED",
10
- "ARCHIVED"
4
+ var DashboardStatusEnum = defineEnum("DashboardStatus", [
5
+ "DRAFT",
6
+ "PUBLISHED",
7
+ "ARCHIVED"
11
8
  ]);
12
- /**
13
- * Widget type enum.
14
- */
15
- const WidgetTypeEnum = defineEnum("WidgetType", [
16
- "LINE_CHART",
17
- "BAR_CHART",
18
- "PIE_CHART",
19
- "AREA_CHART",
20
- "SCATTER_PLOT",
21
- "METRIC",
22
- "TABLE",
23
- "HEATMAP",
24
- "FUNNEL",
25
- "MAP",
26
- "TEXT",
27
- "EMBED"
9
+ var WidgetTypeEnum = defineEnum("WidgetType", [
10
+ "LINE_CHART",
11
+ "BAR_CHART",
12
+ "PIE_CHART",
13
+ "AREA_CHART",
14
+ "SCATTER_PLOT",
15
+ "METRIC",
16
+ "TABLE",
17
+ "HEATMAP",
18
+ "FUNNEL",
19
+ "MAP",
20
+ "TEXT",
21
+ "EMBED"
28
22
  ]);
29
- /**
30
- * Refresh interval enum.
31
- */
32
- const RefreshIntervalEnum = defineEnum("RefreshInterval", [
33
- "NONE",
34
- "MINUTE",
35
- "FIVE_MINUTES",
36
- "FIFTEEN_MINUTES",
37
- "HOUR",
38
- "DAY"
23
+ var RefreshIntervalEnum = defineEnum("RefreshInterval", [
24
+ "NONE",
25
+ "MINUTE",
26
+ "FIVE_MINUTES",
27
+ "FIFTEEN_MINUTES",
28
+ "HOUR",
29
+ "DAY"
39
30
  ]);
40
-
41
- //#endregion
42
- export { DashboardStatusEnum, RefreshIntervalEnum, WidgetTypeEnum };
43
- //# sourceMappingURL=dashboard.enum.js.map
31
+ export {
32
+ WidgetTypeEnum,
33
+ RefreshIntervalEnum,
34
+ DashboardStatusEnum
35
+ };