@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,213 @@
1
+ // src/dashboard/dashboard.test-spec.ts
2
+ import { defineTestSpec } from "@contractspec/lib.contracts";
3
+ var CreateDashboardTest = defineTestSpec({
4
+ meta: {
5
+ key: "analytics.dashboard.create.test",
6
+ version: "1.0.0",
7
+ title: "Create Dashboard Test",
8
+ description: "Verifies dashboard creation flow",
9
+ owners: ["@example.analytics-dashboard"],
10
+ tags: ["analytics", "dashboard", "test"],
11
+ stability: "stable"
12
+ },
13
+ target: {
14
+ type: "operation",
15
+ operation: { key: "analytics.dashboard.create", version: "1.0.0" }
16
+ },
17
+ scenarios: [
18
+ {
19
+ key: "success",
20
+ description: "Successfully create a dashboard",
21
+ when: {
22
+ operation: { key: "analytics.dashboard.create", version: "1.0.0" },
23
+ input: {
24
+ name: "Test Dashboard",
25
+ description: "Test Description"
26
+ }
27
+ },
28
+ then: [
29
+ {
30
+ type: "expectOutput",
31
+ match: {
32
+ name: "Test Dashboard"
33
+ }
34
+ }
35
+ ]
36
+ },
37
+ {
38
+ key: "error-invalid-input",
39
+ description: "Fail to create dashboard with invalid input",
40
+ when: {
41
+ operation: { key: "analytics.dashboard.create", version: "1.0.0" },
42
+ input: {
43
+ name: ""
44
+ }
45
+ },
46
+ then: [
47
+ {
48
+ type: "expectError",
49
+ messageIncludes: "VALIDATION_ERROR"
50
+ }
51
+ ]
52
+ }
53
+ ]
54
+ });
55
+ var ListDashboardsTest = defineTestSpec({
56
+ meta: {
57
+ key: "analytics.dashboard.list.test",
58
+ version: "1.0.0",
59
+ title: "List Dashboards Test",
60
+ description: "Verifies dashboard listing",
61
+ owners: ["@example.analytics-dashboard"],
62
+ tags: ["analytics", "dashboard", "test"],
63
+ stability: "stable"
64
+ },
65
+ target: {
66
+ type: "operation",
67
+ operation: { key: "analytics.dashboard.list", version: "1.0.0" }
68
+ },
69
+ scenarios: [
70
+ {
71
+ key: "success",
72
+ description: "Successfully list dashboards",
73
+ when: {
74
+ operation: { key: "analytics.dashboard.list", version: "1.0.0" },
75
+ input: { limit: 10, offset: 0 }
76
+ },
77
+ then: [
78
+ {
79
+ type: "expectOutput",
80
+ match: {
81
+ items: [],
82
+ total: 0
83
+ }
84
+ }
85
+ ]
86
+ },
87
+ {
88
+ key: "error-invalid-format",
89
+ description: "Fail with invalid pagination",
90
+ when: {
91
+ operation: { key: "analytics.dashboard.list", version: "1.0.0" },
92
+ input: { limit: -1 }
93
+ },
94
+ then: [
95
+ {
96
+ type: "expectError",
97
+ messageIncludes: "VALIDATION_ERROR"
98
+ }
99
+ ]
100
+ }
101
+ ]
102
+ });
103
+ var GetDashboardTest = defineTestSpec({
104
+ meta: {
105
+ key: "analytics.dashboard.get.test",
106
+ version: "1.0.0",
107
+ title: "Get Dashboard Test",
108
+ description: "Verifies dashboard retrieval",
109
+ owners: ["@example.analytics-dashboard"],
110
+ tags: ["analytics", "dashboard", "test"],
111
+ stability: "stable"
112
+ },
113
+ target: {
114
+ type: "operation",
115
+ operation: { key: "analytics.dashboard.get", version: "1.0.0" }
116
+ },
117
+ scenarios: [
118
+ {
119
+ key: "success",
120
+ description: "Successfully get dashboard",
121
+ when: {
122
+ operation: { key: "analytics.dashboard.get", version: "1.0.0" },
123
+ input: { dashboardId: "dash-123" }
124
+ },
125
+ then: [
126
+ {
127
+ type: "expectOutput",
128
+ match: {
129
+ id: "dash-123"
130
+ }
131
+ }
132
+ ]
133
+ },
134
+ {
135
+ key: "error-not-found",
136
+ description: "Fail when dashboard not found",
137
+ when: {
138
+ operation: { key: "analytics.dashboard.get", version: "1.0.0" },
139
+ input: { dashboardId: "dash-999" }
140
+ },
141
+ then: [
142
+ {
143
+ type: "expectError",
144
+ messageIncludes: "NOT_FOUND"
145
+ }
146
+ ]
147
+ }
148
+ ]
149
+ });
150
+ var AddWidgetTest = defineTestSpec({
151
+ meta: {
152
+ key: "analytics.widget.add.test",
153
+ version: "1.0.0",
154
+ title: "Add Widget Test",
155
+ description: "Verifies adding widget to dashboard",
156
+ owners: ["@example.analytics-dashboard"],
157
+ tags: ["analytics", "widget", "test"],
158
+ stability: "stable"
159
+ },
160
+ target: {
161
+ type: "operation",
162
+ operation: { key: "analytics.widget.add", version: "1.0.0" }
163
+ },
164
+ scenarios: [
165
+ {
166
+ key: "success",
167
+ description: "Successfully add widget",
168
+ when: {
169
+ operation: { key: "analytics.widget.add", version: "1.0.0" },
170
+ input: {
171
+ dashboardId: "dash-123",
172
+ type: "chart",
173
+ queryId: "q-1",
174
+ config: {}
175
+ }
176
+ },
177
+ then: [
178
+ {
179
+ type: "expectOutput",
180
+ match: {
181
+ type: "chart",
182
+ dashboardId: "dash-123"
183
+ }
184
+ }
185
+ ]
186
+ },
187
+ {
188
+ key: "error-dashboard-not-found",
189
+ description: "Fail when dashboard does not exist",
190
+ when: {
191
+ operation: { key: "analytics.widget.add", version: "1.0.0" },
192
+ input: {
193
+ dashboardId: "dash-999",
194
+ type: "chart",
195
+ queryId: "q-1",
196
+ config: {}
197
+ }
198
+ },
199
+ then: [
200
+ {
201
+ type: "expectError",
202
+ messageIncludes: "NOT_FOUND"
203
+ }
204
+ ]
205
+ }
206
+ ]
207
+ });
208
+ export {
209
+ ListDashboardsTest,
210
+ GetDashboardTest,
211
+ CreateDashboardTest,
212
+ AddWidgetTest
213
+ };
@@ -0,0 +1,299 @@
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
+ WidgetTypeEnum,
286
+ WidgetModel,
287
+ RefreshIntervalEnum,
288
+ ListDashboardsOutputModel,
289
+ ListDashboardsInputModel,
290
+ ListDashboardsContract,
291
+ GetDashboardInputModel,
292
+ GetDashboardContract,
293
+ DashboardStatusEnum,
294
+ DashboardModel,
295
+ CreateDashboardInputModel,
296
+ CreateDashboardContract,
297
+ AddWidgetInputModel,
298
+ AddWidgetContract
299
+ };
@@ -0,0 +1,84 @@
1
+ // src/dashboard.feature.ts
2
+ import { defineFeature } from "@contractspec/lib.contracts";
3
+ var AnalyticsDashboardFeature = defineFeature({
4
+ meta: {
5
+ key: "analytics-dashboard",
6
+ version: "1.0.0",
7
+ title: "Analytics Dashboard",
8
+ description: "Analytics dashboards with customizable widgets and queries",
9
+ domain: "analytics",
10
+ owners: ["@analytics-dashboard"],
11
+ tags: ["analytics", "dashboards", "widgets", "queries"],
12
+ stability: "experimental"
13
+ },
14
+ operations: [
15
+ { key: "analytics.dashboard.create", version: "1.0.0" },
16
+ { key: "analytics.dashboard.list", version: "1.0.0" },
17
+ { key: "analytics.dashboard.get", version: "1.0.0" },
18
+ { key: "analytics.widget.add", version: "1.0.0" },
19
+ { key: "analytics.query.create", version: "1.0.0" },
20
+ { key: "analytics.query.execute", version: "1.0.0" }
21
+ ],
22
+ events: [
23
+ { key: "analytics.dashboard.created", version: "1.0.0" },
24
+ { key: "analytics.widget.added", version: "1.0.0" },
25
+ { key: "analytics.query.created", version: "1.0.0" }
26
+ ],
27
+ presentations: [
28
+ { key: "analytics.dashboard.viewList", version: "1.0.0" },
29
+ { key: "analytics.dashboard.view", version: "1.0.0" },
30
+ { key: "analytics.dashboard.editor", version: "1.0.0" },
31
+ { key: "analytics.query.list", version: "1.0.0" },
32
+ { key: "analytics.query.builder", version: "1.0.0" }
33
+ ],
34
+ opToPresentation: [
35
+ {
36
+ op: { key: "analytics.dashboard.list", version: "1.0.0" },
37
+ pres: { key: "analytics.dashboard.viewList", version: "1.0.0" }
38
+ },
39
+ {
40
+ op: { key: "analytics.dashboard.get", version: "1.0.0" },
41
+ pres: { key: "analytics.dashboard.view", version: "1.0.0" }
42
+ },
43
+ {
44
+ op: { key: "analytics.dashboard.create", version: "1.0.0" },
45
+ pres: { key: "analytics.dashboard.editor", version: "1.0.0" }
46
+ },
47
+ {
48
+ op: { key: "analytics.query.create", version: "1.0.0" },
49
+ pres: { key: "analytics.query.builder", version: "1.0.0" }
50
+ }
51
+ ],
52
+ presentationsTargets: [
53
+ {
54
+ key: "analytics.dashboard.viewList",
55
+ version: "1.0.0",
56
+ targets: ["react", "markdown", "application/json"]
57
+ },
58
+ {
59
+ key: "analytics.dashboard.view",
60
+ version: "1.0.0",
61
+ targets: ["react", "markdown"]
62
+ },
63
+ {
64
+ key: "analytics.dashboard.editor",
65
+ version: "1.0.0",
66
+ targets: ["react"]
67
+ },
68
+ {
69
+ key: "analytics.query.builder",
70
+ version: "1.0.0",
71
+ targets: ["react"]
72
+ }
73
+ ],
74
+ capabilities: {
75
+ requires: [
76
+ { key: "identity", version: "1.0.0" },
77
+ { key: "metering", version: "1.0.0" },
78
+ { key: "audit-trail", version: "1.0.0" }
79
+ ]
80
+ }
81
+ });
82
+ export {
83
+ AnalyticsDashboardFeature
84
+ };