@contractspec/example.analytics-dashboard 1.57.0 → 1.59.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 (173) 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 -6
  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 +15 -19
  53. package/dist/datasource/posthog-datasource.d.ts.map +1 -1
  54. package/dist/datasource/posthog-datasource.js +274 -238
  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 +45 -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 +41 -55
  67. package/dist/handlers/analytics.handlers.d.ts +110 -109
  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 -3
  71. package/dist/handlers/index.d.ts.map +1 -0
  72. package/dist/handlers/index.js +571 -3
  73. package/dist/handlers/query.handlers.d.ts +7 -11
  74. package/dist/handlers/query.handlers.d.ts.map +1 -1
  75. package/dist/handlers/query.handlers.js +292 -7
  76. package/dist/index.d.ts +12 -13
  77. package/dist/index.d.ts.map +1 -0
  78. package/dist/index.js +1678 -14
  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 -88
  128. package/dist/query-engine/index.d.ts.map +1 -1
  129. package/dist/query-engine/index.js +489 -188
  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 -14
  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 +328 -67
  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/datasource/posthog-datasource.js.map +0 -1
  159. package/dist/docs/analytics-dashboard.docblock.js.map +0 -1
  160. package/dist/events.js.map +0 -1
  161. package/dist/example.js.map +0 -1
  162. package/dist/handlers/analytics.handlers.js.map +0 -1
  163. package/dist/handlers/query.handlers.js.map +0 -1
  164. package/dist/query/query.enum.js.map +0 -1
  165. package/dist/query/query.operation.js.map +0 -1
  166. package/dist/query/query.presentation.js.map +0 -1
  167. package/dist/query/query.schema.js.map +0 -1
  168. package/dist/query/query.test-spec.js.map +0 -1
  169. package/dist/query-engine/index.js.map +0 -1
  170. package/dist/seeders/index.js.map +0 -1
  171. package/dist/ui/AnalyticsDashboard.js.map +0 -1
  172. package/dist/ui/hooks/useAnalyticsData.js.map +0 -1
  173. package/dist/ui/renderers/analytics.markdown.js.map +0 -1
@@ -0,0 +1,34 @@
1
+ // src/dashboard/dashboard.enum.ts
2
+ import { defineEnum } from "@contractspec/lib.schema";
3
+ var DashboardStatusEnum = defineEnum("DashboardStatus", [
4
+ "DRAFT",
5
+ "PUBLISHED",
6
+ "ARCHIVED"
7
+ ]);
8
+ var WidgetTypeEnum = defineEnum("WidgetType", [
9
+ "LINE_CHART",
10
+ "BAR_CHART",
11
+ "PIE_CHART",
12
+ "AREA_CHART",
13
+ "SCATTER_PLOT",
14
+ "METRIC",
15
+ "TABLE",
16
+ "HEATMAP",
17
+ "FUNNEL",
18
+ "MAP",
19
+ "TEXT",
20
+ "EMBED"
21
+ ]);
22
+ var RefreshIntervalEnum = defineEnum("RefreshInterval", [
23
+ "NONE",
24
+ "MINUTE",
25
+ "FIVE_MINUTES",
26
+ "FIFTEEN_MINUTES",
27
+ "HOUR",
28
+ "DAY"
29
+ ]);
30
+ export {
31
+ WidgetTypeEnum,
32
+ RefreshIntervalEnum,
33
+ DashboardStatusEnum
34
+ };
@@ -0,0 +1,289 @@
1
+ // src/dashboard/dashboard.enum.ts
2
+ import { defineEnum } from "@contractspec/lib.schema";
3
+ var DashboardStatusEnum = defineEnum("DashboardStatus", [
4
+ "DRAFT",
5
+ "PUBLISHED",
6
+ "ARCHIVED"
7
+ ]);
8
+ var WidgetTypeEnum = defineEnum("WidgetType", [
9
+ "LINE_CHART",
10
+ "BAR_CHART",
11
+ "PIE_CHART",
12
+ "AREA_CHART",
13
+ "SCATTER_PLOT",
14
+ "METRIC",
15
+ "TABLE",
16
+ "HEATMAP",
17
+ "FUNNEL",
18
+ "MAP",
19
+ "TEXT",
20
+ "EMBED"
21
+ ]);
22
+ var RefreshIntervalEnum = defineEnum("RefreshInterval", [
23
+ "NONE",
24
+ "MINUTE",
25
+ "FIVE_MINUTES",
26
+ "FIFTEEN_MINUTES",
27
+ "HOUR",
28
+ "DAY"
29
+ ]);
30
+
31
+ // src/dashboard/dashboard.schema.ts
32
+ import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
33
+ var WidgetModel = defineSchemaModel({
34
+ name: "WidgetModel",
35
+ fields: {
36
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
37
+ dashboardId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
38
+ name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
39
+ type: { type: WidgetTypeEnum, isOptional: false },
40
+ gridX: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
41
+ gridY: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
42
+ gridWidth: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
43
+ gridHeight: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
44
+ queryId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
45
+ config: { type: ScalarTypeEnum.JSON(), isOptional: true }
46
+ }
47
+ });
48
+ var DashboardModel = defineSchemaModel({
49
+ name: "DashboardModel",
50
+ fields: {
51
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
52
+ name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
53
+ slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
54
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
55
+ status: { type: DashboardStatusEnum, isOptional: false },
56
+ refreshInterval: { type: RefreshIntervalEnum, isOptional: false },
57
+ isPublic: { type: ScalarTypeEnum.Boolean(), isOptional: false },
58
+ widgets: { type: WidgetModel, isArray: true, isOptional: true },
59
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
60
+ }
61
+ });
62
+ var CreateDashboardInputModel = defineSchemaModel({
63
+ name: "CreateDashboardInput",
64
+ fields: {
65
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
66
+ slug: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
67
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
68
+ refreshInterval: { type: RefreshIntervalEnum, isOptional: true },
69
+ dateRange: { type: ScalarTypeEnum.JSON(), isOptional: true }
70
+ }
71
+ });
72
+ var AddWidgetInputModel = defineSchemaModel({
73
+ name: "AddWidgetInput",
74
+ fields: {
75
+ dashboardId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
76
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
77
+ type: { type: WidgetTypeEnum, isOptional: false },
78
+ gridX: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
79
+ gridY: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
80
+ gridWidth: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
81
+ gridHeight: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
82
+ queryId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
83
+ config: { type: ScalarTypeEnum.JSON(), isOptional: true }
84
+ }
85
+ });
86
+ var ListDashboardsInputModel = defineSchemaModel({
87
+ name: "ListDashboardsInput",
88
+ fields: {
89
+ status: { type: DashboardStatusEnum, isOptional: true },
90
+ search: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
91
+ limit: {
92
+ type: ScalarTypeEnum.Int_unsecure(),
93
+ isOptional: true,
94
+ defaultValue: 20
95
+ },
96
+ offset: {
97
+ type: ScalarTypeEnum.Int_unsecure(),
98
+ isOptional: true,
99
+ defaultValue: 0
100
+ }
101
+ }
102
+ });
103
+ var ListDashboardsOutputModel = defineSchemaModel({
104
+ name: "ListDashboardsOutput",
105
+ fields: {
106
+ dashboards: { type: DashboardModel, isArray: true, isOptional: false },
107
+ total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
108
+ }
109
+ });
110
+ var GetDashboardInputModel = defineSchemaModel({
111
+ name: "GetDashboardInput",
112
+ fields: {
113
+ dashboardId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
114
+ slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
115
+ shareToken: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
116
+ }
117
+ });
118
+
119
+ // src/dashboard/dashboard.operation.ts
120
+ import {
121
+ defineCommand,
122
+ defineQuery
123
+ } from "@contractspec/lib.contracts/operations";
124
+ var OWNERS = ["@example.analytics-dashboard"];
125
+ var CreateDashboardContract = defineCommand({
126
+ meta: {
127
+ key: "analytics.dashboard.create",
128
+ version: "1.0.0",
129
+ stability: "stable",
130
+ owners: [...OWNERS],
131
+ tags: ["analytics", "dashboard", "create"],
132
+ description: "Create a new analytics dashboard.",
133
+ goal: "Allow users to create custom dashboards.",
134
+ context: "Dashboard management."
135
+ },
136
+ io: { input: CreateDashboardInputModel, output: DashboardModel },
137
+ policy: { auth: "user" },
138
+ sideEffects: {
139
+ emits: [
140
+ {
141
+ key: "analytics.dashboard.created",
142
+ version: "1.0.0",
143
+ stability: "stable",
144
+ owners: [...OWNERS],
145
+ tags: ["analytics", "dashboard", "created"],
146
+ when: "Dashboard created",
147
+ payload: DashboardModel
148
+ }
149
+ ],
150
+ audit: ["analytics.dashboard.created"]
151
+ },
152
+ acceptance: {
153
+ scenarios: [
154
+ {
155
+ key: "create-dashboard-happy-path",
156
+ given: ["User is authenticated"],
157
+ when: ["User submits valid dashboard configuration"],
158
+ then: ["Dashboard is created", "DashboardCreated event is emitted"]
159
+ }
160
+ ],
161
+ examples: [
162
+ {
163
+ key: "create-basic",
164
+ input: {
165
+ name: "Revenue Dashboard",
166
+ description: "Monthly revenue metrics"
167
+ },
168
+ output: { id: "dash-123", name: "Revenue Dashboard", widgets: [] }
169
+ }
170
+ ]
171
+ }
172
+ });
173
+ var AddWidgetContract = defineCommand({
174
+ meta: {
175
+ key: "analytics.widget.add",
176
+ version: "1.0.0",
177
+ stability: "stable",
178
+ owners: [...OWNERS],
179
+ tags: ["analytics", "widget", "add"],
180
+ description: "Add a widget to a dashboard.",
181
+ goal: "Allow users to add visualizations.",
182
+ context: "Dashboard editor."
183
+ },
184
+ io: { input: AddWidgetInputModel, output: WidgetModel },
185
+ policy: { auth: "user" },
186
+ sideEffects: {
187
+ emits: [
188
+ {
189
+ key: "analytics.widget.added",
190
+ version: "1.0.0",
191
+ stability: "stable",
192
+ owners: [...OWNERS],
193
+ tags: ["analytics", "widget", "added"],
194
+ when: "Widget added",
195
+ payload: WidgetModel
196
+ }
197
+ ]
198
+ },
199
+ acceptance: {
200
+ scenarios: [
201
+ {
202
+ key: "add-widget-happy-path",
203
+ given: ["Dashboard exists"],
204
+ when: ["User adds widget to dashboard"],
205
+ then: ["Widget is created", "WidgetAdded event is emitted"]
206
+ }
207
+ ],
208
+ examples: [
209
+ {
210
+ key: "add-chart-widget",
211
+ input: {
212
+ dashboardId: "dash-123",
213
+ type: "chart",
214
+ queryId: "query-456",
215
+ config: { chartType: "bar" }
216
+ },
217
+ output: { id: "widget-789", type: "chart", dashboardId: "dash-123" }
218
+ }
219
+ ]
220
+ }
221
+ });
222
+ var ListDashboardsContract = defineQuery({
223
+ meta: {
224
+ key: "analytics.dashboard.list",
225
+ version: "1.0.0",
226
+ stability: "stable",
227
+ owners: [...OWNERS],
228
+ tags: ["analytics", "dashboard", "list"],
229
+ description: "List dashboards.",
230
+ goal: "Browse available dashboards.",
231
+ context: "Dashboard listing."
232
+ },
233
+ io: { input: ListDashboardsInputModel, output: ListDashboardsOutputModel },
234
+ policy: { auth: "user" },
235
+ acceptance: {
236
+ scenarios: [
237
+ {
238
+ key: "list-dashboards-happy-path",
239
+ given: ["User has dashboards"],
240
+ when: ["User lists dashboards"],
241
+ then: ["Paginated list of dashboards is returned"]
242
+ }
243
+ ],
244
+ examples: [
245
+ {
246
+ key: "list-basic",
247
+ input: { limit: 10, offset: 0 },
248
+ output: { items: [], total: 0, hasMore: false }
249
+ }
250
+ ]
251
+ }
252
+ });
253
+ var GetDashboardContract = defineQuery({
254
+ meta: {
255
+ key: "analytics.dashboard.get",
256
+ version: "1.0.0",
257
+ stability: "stable",
258
+ owners: [...OWNERS],
259
+ tags: ["analytics", "dashboard", "get"],
260
+ description: "Get a dashboard with widgets.",
261
+ goal: "Load dashboard for viewing.",
262
+ context: "Dashboard view."
263
+ },
264
+ io: { input: GetDashboardInputModel, output: DashboardModel },
265
+ policy: { auth: "anonymous" },
266
+ acceptance: {
267
+ scenarios: [
268
+ {
269
+ key: "get-dashboard-happy-path",
270
+ given: ["Dashboard exists"],
271
+ when: ["User requests dashboard by ID"],
272
+ then: ["Dashboard with widgets is returned"]
273
+ }
274
+ ],
275
+ examples: [
276
+ {
277
+ key: "get-basic",
278
+ input: { dashboardId: "dash-123" },
279
+ output: { id: "dash-123", name: "Revenue Dashboard", widgets: [] }
280
+ }
281
+ ]
282
+ }
283
+ });
284
+ export {
285
+ ListDashboardsContract,
286
+ GetDashboardContract,
287
+ CreateDashboardContract,
288
+ AddWidgetContract
289
+ };
@@ -0,0 +1,197 @@
1
+ // src/dashboard/dashboard.enum.ts
2
+ import { defineEnum } from "@contractspec/lib.schema";
3
+ var DashboardStatusEnum = defineEnum("DashboardStatus", [
4
+ "DRAFT",
5
+ "PUBLISHED",
6
+ "ARCHIVED"
7
+ ]);
8
+ var WidgetTypeEnum = defineEnum("WidgetType", [
9
+ "LINE_CHART",
10
+ "BAR_CHART",
11
+ "PIE_CHART",
12
+ "AREA_CHART",
13
+ "SCATTER_PLOT",
14
+ "METRIC",
15
+ "TABLE",
16
+ "HEATMAP",
17
+ "FUNNEL",
18
+ "MAP",
19
+ "TEXT",
20
+ "EMBED"
21
+ ]);
22
+ var RefreshIntervalEnum = defineEnum("RefreshInterval", [
23
+ "NONE",
24
+ "MINUTE",
25
+ "FIVE_MINUTES",
26
+ "FIFTEEN_MINUTES",
27
+ "HOUR",
28
+ "DAY"
29
+ ]);
30
+
31
+ // src/dashboard/dashboard.schema.ts
32
+ import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
33
+ var WidgetModel = defineSchemaModel({
34
+ name: "WidgetModel",
35
+ fields: {
36
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
37
+ dashboardId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
38
+ name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
39
+ type: { type: WidgetTypeEnum, isOptional: false },
40
+ gridX: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
41
+ gridY: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
42
+ gridWidth: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
43
+ gridHeight: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
44
+ queryId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
45
+ config: { type: ScalarTypeEnum.JSON(), isOptional: true }
46
+ }
47
+ });
48
+ var DashboardModel = defineSchemaModel({
49
+ name: "DashboardModel",
50
+ fields: {
51
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
52
+ name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
53
+ slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
54
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
55
+ status: { type: DashboardStatusEnum, isOptional: false },
56
+ refreshInterval: { type: RefreshIntervalEnum, isOptional: false },
57
+ isPublic: { type: ScalarTypeEnum.Boolean(), isOptional: false },
58
+ widgets: { type: WidgetModel, isArray: true, isOptional: true },
59
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
60
+ }
61
+ });
62
+ var CreateDashboardInputModel = defineSchemaModel({
63
+ name: "CreateDashboardInput",
64
+ fields: {
65
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
66
+ slug: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
67
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
68
+ refreshInterval: { type: RefreshIntervalEnum, isOptional: true },
69
+ dateRange: { type: ScalarTypeEnum.JSON(), isOptional: true }
70
+ }
71
+ });
72
+ var AddWidgetInputModel = defineSchemaModel({
73
+ name: "AddWidgetInput",
74
+ fields: {
75
+ dashboardId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
76
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
77
+ type: { type: WidgetTypeEnum, isOptional: false },
78
+ gridX: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
79
+ gridY: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
80
+ gridWidth: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
81
+ gridHeight: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
82
+ queryId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
83
+ config: { type: ScalarTypeEnum.JSON(), isOptional: true }
84
+ }
85
+ });
86
+ var ListDashboardsInputModel = defineSchemaModel({
87
+ name: "ListDashboardsInput",
88
+ fields: {
89
+ status: { type: DashboardStatusEnum, isOptional: true },
90
+ search: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
91
+ limit: {
92
+ type: ScalarTypeEnum.Int_unsecure(),
93
+ isOptional: true,
94
+ defaultValue: 20
95
+ },
96
+ offset: {
97
+ type: ScalarTypeEnum.Int_unsecure(),
98
+ isOptional: true,
99
+ defaultValue: 0
100
+ }
101
+ }
102
+ });
103
+ var ListDashboardsOutputModel = defineSchemaModel({
104
+ name: "ListDashboardsOutput",
105
+ fields: {
106
+ dashboards: { type: DashboardModel, isArray: true, isOptional: false },
107
+ total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
108
+ }
109
+ });
110
+ var GetDashboardInputModel = defineSchemaModel({
111
+ name: "GetDashboardInput",
112
+ fields: {
113
+ dashboardId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
114
+ slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
115
+ shareToken: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
116
+ }
117
+ });
118
+
119
+ // src/dashboard/dashboard.presentation.ts
120
+ import { definePresentation, StabilityEnum } from "@contractspec/lib.contracts";
121
+ var DashboardsListPresentation = definePresentation({
122
+ meta: {
123
+ key: "analytics.dashboard.viewList",
124
+ version: "1.0.0",
125
+ title: "Dashboards List",
126
+ description: "List of analytics dashboards",
127
+ domain: "analytics",
128
+ owners: ["@analytics-dashboard"],
129
+ tags: ["analytics", "dashboards", "list"],
130
+ stability: StabilityEnum.Experimental,
131
+ goal: "Show users available analytics dashboards.",
132
+ context: "The main dashboard management view."
133
+ },
134
+ source: {
135
+ type: "component",
136
+ framework: "react",
137
+ componentKey: "DashboardsList",
138
+ props: DashboardModel
139
+ },
140
+ targets: ["react", "markdown", "application/json"],
141
+ policy: {
142
+ flags: ["analytics.dashboards.enabled"]
143
+ }
144
+ });
145
+ var DashboardViewPresentation = definePresentation({
146
+ meta: {
147
+ key: "analytics.dashboard.view",
148
+ version: "1.0.0",
149
+ title: "Dashboard View",
150
+ description: "View a single dashboard with widgets",
151
+ domain: "analytics",
152
+ owners: ["@analytics-dashboard"],
153
+ tags: ["analytics", "dashboard", "view"],
154
+ stability: StabilityEnum.Experimental,
155
+ goal: "Render a dashboard with its visualizations and data.",
156
+ context: "The interactive viewing interface."
157
+ },
158
+ source: {
159
+ type: "component",
160
+ framework: "react",
161
+ componentKey: "DashboardView",
162
+ props: DashboardModel
163
+ },
164
+ targets: ["react", "markdown"],
165
+ policy: {
166
+ flags: ["analytics.dashboards.enabled"]
167
+ }
168
+ });
169
+ var DashboardEditorPresentation = definePresentation({
170
+ meta: {
171
+ key: "analytics.dashboard.editor",
172
+ version: "1.0.0",
173
+ title: "Dashboard Editor",
174
+ description: "Edit dashboard configuration and widgets",
175
+ domain: "analytics",
176
+ owners: ["@analytics-dashboard"],
177
+ tags: ["analytics", "dashboard", "editor"],
178
+ stability: StabilityEnum.Experimental,
179
+ goal: "Configure dashboard layout and widget settings.",
180
+ context: "Management tool for analysts."
181
+ },
182
+ source: {
183
+ type: "component",
184
+ framework: "react",
185
+ componentKey: "DashboardEditor",
186
+ props: DashboardModel
187
+ },
188
+ targets: ["react"],
189
+ policy: {
190
+ flags: ["analytics.dashboards.enabled"]
191
+ }
192
+ });
193
+ export {
194
+ DashboardsListPresentation,
195
+ DashboardViewPresentation,
196
+ DashboardEditorPresentation
197
+ };
@@ -0,0 +1,126 @@
1
+ // src/dashboard/dashboard.enum.ts
2
+ import { defineEnum } from "@contractspec/lib.schema";
3
+ var DashboardStatusEnum = defineEnum("DashboardStatus", [
4
+ "DRAFT",
5
+ "PUBLISHED",
6
+ "ARCHIVED"
7
+ ]);
8
+ var WidgetTypeEnum = defineEnum("WidgetType", [
9
+ "LINE_CHART",
10
+ "BAR_CHART",
11
+ "PIE_CHART",
12
+ "AREA_CHART",
13
+ "SCATTER_PLOT",
14
+ "METRIC",
15
+ "TABLE",
16
+ "HEATMAP",
17
+ "FUNNEL",
18
+ "MAP",
19
+ "TEXT",
20
+ "EMBED"
21
+ ]);
22
+ var RefreshIntervalEnum = defineEnum("RefreshInterval", [
23
+ "NONE",
24
+ "MINUTE",
25
+ "FIVE_MINUTES",
26
+ "FIFTEEN_MINUTES",
27
+ "HOUR",
28
+ "DAY"
29
+ ]);
30
+
31
+ // src/dashboard/dashboard.schema.ts
32
+ import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
33
+ var WidgetModel = defineSchemaModel({
34
+ name: "WidgetModel",
35
+ fields: {
36
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
37
+ dashboardId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
38
+ name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
39
+ type: { type: WidgetTypeEnum, isOptional: false },
40
+ gridX: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
41
+ gridY: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
42
+ gridWidth: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
43
+ gridHeight: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
44
+ queryId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
45
+ config: { type: ScalarTypeEnum.JSON(), isOptional: true }
46
+ }
47
+ });
48
+ var DashboardModel = defineSchemaModel({
49
+ name: "DashboardModel",
50
+ fields: {
51
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
52
+ name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
53
+ slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
54
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
55
+ status: { type: DashboardStatusEnum, isOptional: false },
56
+ refreshInterval: { type: RefreshIntervalEnum, isOptional: false },
57
+ isPublic: { type: ScalarTypeEnum.Boolean(), isOptional: false },
58
+ widgets: { type: WidgetModel, isArray: true, isOptional: true },
59
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
60
+ }
61
+ });
62
+ var CreateDashboardInputModel = defineSchemaModel({
63
+ name: "CreateDashboardInput",
64
+ fields: {
65
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
66
+ slug: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
67
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
68
+ refreshInterval: { type: RefreshIntervalEnum, isOptional: true },
69
+ dateRange: { type: ScalarTypeEnum.JSON(), isOptional: true }
70
+ }
71
+ });
72
+ var AddWidgetInputModel = defineSchemaModel({
73
+ name: "AddWidgetInput",
74
+ fields: {
75
+ dashboardId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
76
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
77
+ type: { type: WidgetTypeEnum, isOptional: false },
78
+ gridX: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
79
+ gridY: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
80
+ gridWidth: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
81
+ gridHeight: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
82
+ queryId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
83
+ config: { type: ScalarTypeEnum.JSON(), isOptional: true }
84
+ }
85
+ });
86
+ var ListDashboardsInputModel = defineSchemaModel({
87
+ name: "ListDashboardsInput",
88
+ fields: {
89
+ status: { type: DashboardStatusEnum, isOptional: true },
90
+ search: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
91
+ limit: {
92
+ type: ScalarTypeEnum.Int_unsecure(),
93
+ isOptional: true,
94
+ defaultValue: 20
95
+ },
96
+ offset: {
97
+ type: ScalarTypeEnum.Int_unsecure(),
98
+ isOptional: true,
99
+ defaultValue: 0
100
+ }
101
+ }
102
+ });
103
+ var ListDashboardsOutputModel = defineSchemaModel({
104
+ name: "ListDashboardsOutput",
105
+ fields: {
106
+ dashboards: { type: DashboardModel, isArray: true, isOptional: false },
107
+ total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
108
+ }
109
+ });
110
+ var GetDashboardInputModel = defineSchemaModel({
111
+ name: "GetDashboardInput",
112
+ fields: {
113
+ dashboardId: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
114
+ slug: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
115
+ shareToken: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
116
+ }
117
+ });
118
+ export {
119
+ WidgetModel,
120
+ ListDashboardsOutputModel,
121
+ ListDashboardsInputModel,
122
+ GetDashboardInputModel,
123
+ DashboardModel,
124
+ CreateDashboardInputModel,
125
+ AddWidgetInputModel
126
+ };