@contractspec/example.analytics-dashboard 1.57.0 → 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.
- package/dist/browser/dashboard/dashboard.enum.js +34 -0
- package/dist/browser/dashboard/dashboard.operation.js +289 -0
- package/dist/browser/dashboard/dashboard.presentation.js +197 -0
- package/dist/browser/dashboard/dashboard.schema.js +126 -0
- package/dist/browser/dashboard/dashboard.test-spec.js +213 -0
- package/dist/browser/dashboard/index.js +299 -0
- package/dist/browser/dashboard.feature.js +84 -0
- package/dist/browser/datasource/posthog-datasource.js +289 -0
- package/dist/browser/docs/analytics-dashboard.docblock.js +103 -0
- package/dist/browser/docs/index.js +103 -0
- package/dist/browser/events.js +81 -0
- package/dist/browser/example.js +42 -0
- package/dist/browser/handlers/analytics.handlers.js +278 -0
- package/dist/browser/handlers/index.js +571 -0
- package/dist/browser/handlers/query.handlers.js +294 -0
- package/dist/browser/index.js +1677 -0
- package/dist/browser/query/index.js +159 -0
- package/dist/browser/query/query.enum.js +11 -0
- package/dist/browser/query/query.operation.js +154 -0
- package/dist/browser/query/query.presentation.js +119 -0
- package/dist/browser/query/query.schema.js +70 -0
- package/dist/browser/query/query.test-spec.js +113 -0
- package/dist/browser/query-engine/index.js +491 -0
- package/dist/browser/seeders/index.js +20 -0
- package/dist/browser/ui/AnalyticsDashboard.js +394 -0
- package/dist/browser/ui/hooks/index.js +69 -0
- package/dist/browser/ui/hooks/useAnalyticsData.js +66 -0
- package/dist/browser/ui/index.js +671 -0
- package/dist/browser/ui/renderers/analytics.markdown.js +275 -0
- package/dist/browser/ui/renderers/index.js +275 -0
- package/dist/dashboard/dashboard.enum.d.ts +3 -8
- package/dist/dashboard/dashboard.enum.d.ts.map +1 -1
- package/dist/dashboard/dashboard.enum.js +31 -39
- package/dist/dashboard/dashboard.operation.d.ts +444 -450
- package/dist/dashboard/dashboard.operation.d.ts.map +1 -1
- package/dist/dashboard/dashboard.operation.js +284 -207
- package/dist/dashboard/dashboard.presentation.d.ts +3 -8
- package/dist/dashboard/dashboard.presentation.d.ts.map +1 -1
- package/dist/dashboard/dashboard.presentation.js +193 -85
- package/dist/dashboard/dashboard.schema.d.ts +289 -294
- package/dist/dashboard/dashboard.schema.d.ts.map +1 -1
- package/dist/dashboard/dashboard.schema.js +119 -228
- package/dist/dashboard/dashboard.test-spec.d.ts +4 -9
- package/dist/dashboard/dashboard.test-spec.d.ts.map +1 -1
- package/dist/dashboard/dashboard.test-spec.js +209 -228
- package/dist/dashboard/index.d.ts +7 -4
- package/dist/dashboard/index.d.ts.map +1 -0
- package/dist/dashboard/index.js +299 -4
- package/dist/dashboard.feature.d.ts +1 -6
- package/dist/dashboard.feature.d.ts.map +1 -1
- package/dist/dashboard.feature.js +83 -175
- package/dist/datasource/posthog-datasource.d.ts +15 -19
- package/dist/datasource/posthog-datasource.d.ts.map +1 -1
- package/dist/datasource/posthog-datasource.js +274 -238
- package/dist/docs/analytics-dashboard.docblock.d.ts +2 -1
- package/dist/docs/analytics-dashboard.docblock.d.ts.map +1 -0
- package/dist/docs/analytics-dashboard.docblock.js +45 -56
- package/dist/docs/index.d.ts +2 -1
- package/dist/docs/index.d.ts.map +1 -0
- package/dist/docs/index.js +104 -1
- package/dist/events.d.ts +109 -115
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +74 -120
- package/dist/example.d.ts +2 -6
- package/dist/example.d.ts.map +1 -1
- package/dist/example.js +41 -55
- package/dist/handlers/analytics.handlers.d.ts +110 -109
- package/dist/handlers/analytics.handlers.d.ts.map +1 -1
- package/dist/handlers/analytics.handlers.js +267 -298
- package/dist/handlers/index.d.ts +3 -3
- package/dist/handlers/index.d.ts.map +1 -0
- package/dist/handlers/index.js +571 -3
- package/dist/handlers/query.handlers.d.ts +7 -11
- package/dist/handlers/query.handlers.d.ts.map +1 -1
- package/dist/handlers/query.handlers.js +292 -7
- package/dist/index.d.ts +12 -13
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1678 -14
- package/dist/node/dashboard/dashboard.enum.js +34 -0
- package/dist/node/dashboard/dashboard.operation.js +289 -0
- package/dist/node/dashboard/dashboard.presentation.js +197 -0
- package/dist/node/dashboard/dashboard.schema.js +126 -0
- package/dist/node/dashboard/dashboard.test-spec.js +213 -0
- package/dist/node/dashboard/index.js +299 -0
- package/dist/node/dashboard.feature.js +84 -0
- package/dist/node/datasource/posthog-datasource.js +289 -0
- package/dist/node/docs/analytics-dashboard.docblock.js +103 -0
- package/dist/node/docs/index.js +103 -0
- package/dist/node/events.js +81 -0
- package/dist/node/example.js +42 -0
- package/dist/node/handlers/analytics.handlers.js +278 -0
- package/dist/node/handlers/index.js +571 -0
- package/dist/node/handlers/query.handlers.js +294 -0
- package/dist/node/index.js +1677 -0
- package/dist/node/query/index.js +159 -0
- package/dist/node/query/query.enum.js +11 -0
- package/dist/node/query/query.operation.js +154 -0
- package/dist/node/query/query.presentation.js +119 -0
- package/dist/node/query/query.schema.js +70 -0
- package/dist/node/query/query.test-spec.js +113 -0
- package/dist/node/query-engine/index.js +491 -0
- package/dist/node/seeders/index.js +20 -0
- package/dist/node/ui/AnalyticsDashboard.js +394 -0
- package/dist/node/ui/hooks/index.js +69 -0
- package/dist/node/ui/hooks/useAnalyticsData.js +66 -0
- package/dist/node/ui/index.js +671 -0
- package/dist/node/ui/renderers/analytics.markdown.js +275 -0
- package/dist/node/ui/renderers/index.js +275 -0
- package/dist/query/index.d.ts +7 -4
- package/dist/query/index.d.ts.map +1 -0
- package/dist/query/index.js +159 -4
- package/dist/query/query.enum.d.ts +1 -6
- package/dist/query/query.enum.d.ts.map +1 -1
- package/dist/query/query.enum.js +10 -14
- package/dist/query/query.operation.d.ts +148 -154
- package/dist/query/query.operation.d.ts.map +1 -1
- package/dist/query/query.operation.js +151 -109
- package/dist/query/query.presentation.d.ts +2 -7
- package/dist/query/query.presentation.d.ts.map +1 -1
- package/dist/query/query.presentation.js +116 -56
- package/dist/query/query.schema.d.ts +121 -126
- package/dist/query/query.schema.d.ts.map +1 -1
- package/dist/query/query.schema.js +66 -152
- package/dist/query/query.test-spec.d.ts +2 -7
- package/dist/query/query.test-spec.d.ts.map +1 -1
- package/dist/query/query.test-spec.js +111 -121
- package/dist/query-engine/index.d.ts +84 -88
- package/dist/query-engine/index.d.ts.map +1 -1
- package/dist/query-engine/index.js +489 -188
- package/dist/seeders/index.d.ts +4 -8
- package/dist/seeders/index.d.ts.map +1 -1
- package/dist/seeders/index.js +18 -16
- package/dist/ui/AnalyticsDashboard.d.ts +1 -6
- package/dist/ui/AnalyticsDashboard.d.ts.map +1 -1
- package/dist/ui/AnalyticsDashboard.js +389 -259
- package/dist/ui/hooks/index.d.ts +2 -2
- package/dist/ui/hooks/index.d.ts.map +1 -0
- package/dist/ui/hooks/index.js +69 -4
- package/dist/ui/hooks/useAnalyticsData.d.ts +16 -20
- package/dist/ui/hooks/useAnalyticsData.d.ts.map +1 -1
- package/dist/ui/hooks/useAnalyticsData.js +63 -69
- package/dist/ui/index.d.ts +7 -6
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +671 -5
- package/dist/ui/renderers/analytics.markdown.d.ts +13 -14
- package/dist/ui/renderers/analytics.markdown.d.ts.map +1 -1
- package/dist/ui/renderers/analytics.markdown.js +266 -254
- package/dist/ui/renderers/index.d.ts +2 -2
- package/dist/ui/renderers/index.d.ts.map +1 -0
- package/dist/ui/renderers/index.js +275 -2
- package/package.json +328 -67
- package/dist/dashboard/dashboard.enum.js.map +0 -1
- package/dist/dashboard/dashboard.operation.js.map +0 -1
- package/dist/dashboard/dashboard.presentation.js.map +0 -1
- package/dist/dashboard/dashboard.schema.js.map +0 -1
- package/dist/dashboard/dashboard.test-spec.js.map +0 -1
- package/dist/dashboard.feature.js.map +0 -1
- package/dist/datasource/posthog-datasource.js.map +0 -1
- package/dist/docs/analytics-dashboard.docblock.js.map +0 -1
- package/dist/events.js.map +0 -1
- package/dist/example.js.map +0 -1
- package/dist/handlers/analytics.handlers.js.map +0 -1
- package/dist/handlers/query.handlers.js.map +0 -1
- package/dist/query/query.enum.js.map +0 -1
- package/dist/query/query.operation.js.map +0 -1
- package/dist/query/query.presentation.js.map +0 -1
- package/dist/query/query.schema.js.map +0 -1
- package/dist/query/query.test-spec.js.map +0 -1
- package/dist/query-engine/index.js.map +0 -1
- package/dist/seeders/index.js.map +0 -1
- package/dist/ui/AnalyticsDashboard.js.map +0 -1
- package/dist/ui/hooks/useAnalyticsData.js.map +0 -1
- 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
|
+
};
|