@contractspec/example.analytics-dashboard 3.9.9 → 3.9.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/dashboard/dashboard.enum.js +1 -34
- package/dist/browser/dashboard/dashboard.operation.js +1 -289
- package/dist/browser/dashboard/dashboard.presentation.js +1 -200
- package/dist/browser/dashboard/dashboard.schema.js +1 -126
- package/dist/browser/dashboard/dashboard.test-spec.js +1 -213
- package/dist/browser/dashboard/index.js +1 -299
- package/dist/browser/dashboard.feature.js +1 -683
- package/dist/browser/datasource/posthog-datasource.js +4 -289
- package/dist/browser/docs/analytics-dashboard.docblock.js +5 -49
- package/dist/browser/docs/index.js +5 -49
- package/dist/browser/events.js +1 -81
- package/dist/browser/example.js +1 -42
- package/dist/browser/handlers/analytics.handlers.js +4 -278
- package/dist/browser/handlers/index.js +7 -571
- package/dist/browser/handlers/query.handlers.js +4 -294
- package/dist/browser/index.js +12 -2317
- package/dist/browser/query/index.js +1 -159
- package/dist/browser/query/query.enum.js +1 -11
- package/dist/browser/query/query.operation.js +1 -154
- package/dist/browser/query/query.presentation.js +1 -122
- package/dist/browser/query/query.schema.js +1 -70
- package/dist/browser/query/query.test-spec.js +1 -113
- package/dist/browser/query-engine/index.js +4 -491
- package/dist/browser/seeders/index.js +2 -20
- package/dist/browser/ui/AnalyticsDashboard.js +1 -1115
- package/dist/browser/ui/AnalyticsDashboard.widgets.js +1 -94
- package/dist/browser/ui/AnalyticsQueriesTable.js +1 -188
- package/dist/browser/ui/hooks/index.js +1 -660
- package/dist/browser/ui/hooks/useAnalyticsData.js +1 -657
- package/dist/browser/ui/index.js +5 -1283
- package/dist/browser/ui/renderers/analytics.markdown.js +5 -756
- package/dist/browser/ui/renderers/index.js +5 -756
- package/dist/browser/visualizations/catalog.js +1 -457
- package/dist/browser/visualizations/index.js +1 -611
- package/dist/browser/visualizations/specs.breakdown.js +1 -140
- package/dist/browser/visualizations/specs.performance.js +1 -198
- package/dist/browser/visualizations/widgets.js +1 -595
- package/dist/dashboard/dashboard.enum.js +1 -34
- package/dist/dashboard/dashboard.operation.js +1 -289
- package/dist/dashboard/dashboard.presentation.js +1 -200
- package/dist/dashboard/dashboard.schema.js +1 -126
- package/dist/dashboard/dashboard.test-spec.js +1 -213
- package/dist/dashboard/index.js +1 -299
- package/dist/dashboard.feature.js +1 -683
- package/dist/datasource/posthog-datasource.js +4 -289
- package/dist/docs/analytics-dashboard.docblock.js +5 -49
- package/dist/docs/index.js +5 -49
- package/dist/events.js +1 -81
- package/dist/example.js +1 -42
- package/dist/handlers/analytics.handlers.js +4 -278
- package/dist/handlers/index.js +7 -571
- package/dist/handlers/query.handlers.js +4 -294
- package/dist/index.js +12 -2317
- package/dist/node/dashboard/dashboard.enum.js +1 -34
- package/dist/node/dashboard/dashboard.operation.js +1 -289
- package/dist/node/dashboard/dashboard.presentation.js +1 -200
- package/dist/node/dashboard/dashboard.schema.js +1 -126
- package/dist/node/dashboard/dashboard.test-spec.js +1 -213
- package/dist/node/dashboard/index.js +1 -299
- package/dist/node/dashboard.feature.js +1 -683
- package/dist/node/datasource/posthog-datasource.js +4 -289
- package/dist/node/docs/analytics-dashboard.docblock.js +5 -49
- package/dist/node/docs/index.js +5 -49
- package/dist/node/events.js +1 -81
- package/dist/node/example.js +1 -42
- package/dist/node/handlers/analytics.handlers.js +4 -278
- package/dist/node/handlers/index.js +7 -571
- package/dist/node/handlers/query.handlers.js +4 -294
- package/dist/node/index.js +12 -2317
- package/dist/node/query/index.js +1 -159
- package/dist/node/query/query.enum.js +1 -11
- package/dist/node/query/query.operation.js +1 -154
- package/dist/node/query/query.presentation.js +1 -122
- package/dist/node/query/query.schema.js +1 -70
- package/dist/node/query/query.test-spec.js +1 -113
- package/dist/node/query-engine/index.js +4 -491
- package/dist/node/seeders/index.js +2 -20
- package/dist/node/ui/AnalyticsDashboard.js +1 -1115
- package/dist/node/ui/AnalyticsDashboard.widgets.js +1 -94
- package/dist/node/ui/AnalyticsQueriesTable.js +1 -188
- package/dist/node/ui/hooks/index.js +1 -660
- package/dist/node/ui/hooks/useAnalyticsData.js +1 -657
- package/dist/node/ui/index.js +5 -1283
- package/dist/node/ui/renderers/analytics.markdown.js +5 -756
- package/dist/node/ui/renderers/index.js +5 -756
- package/dist/node/visualizations/catalog.js +1 -457
- package/dist/node/visualizations/index.js +1 -611
- package/dist/node/visualizations/specs.breakdown.js +1 -140
- package/dist/node/visualizations/specs.performance.js +1 -198
- package/dist/node/visualizations/widgets.js +1 -595
- package/dist/query/index.js +1 -159
- package/dist/query/query.enum.js +1 -11
- package/dist/query/query.operation.js +1 -154
- package/dist/query/query.presentation.js +1 -122
- package/dist/query/query.schema.js +1 -70
- package/dist/query/query.test-spec.js +1 -113
- package/dist/query-engine/index.js +4 -491
- package/dist/seeders/index.js +2 -20
- package/dist/ui/AnalyticsDashboard.js +1 -1115
- package/dist/ui/AnalyticsDashboard.widgets.js +1 -94
- package/dist/ui/AnalyticsQueriesTable.js +1 -188
- package/dist/ui/hooks/index.js +1 -660
- package/dist/ui/hooks/useAnalyticsData.js +1 -657
- package/dist/ui/index.js +5 -1283
- package/dist/ui/renderers/analytics.markdown.js +5 -756
- package/dist/ui/renderers/index.js +5 -756
- package/dist/visualizations/catalog.js +1 -457
- package/dist/visualizations/index.js +1 -611
- package/dist/visualizations/specs.breakdown.js +1 -140
- package/dist/visualizations/specs.performance.js +1 -198
- package/dist/visualizations/widgets.js +1 -595
- package/package.json +10 -10
|
@@ -1,213 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { defineTestSpec } from "@contractspec/lib.contracts-spec/tests";
|
|
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
|
-
};
|
|
1
|
+
import{defineTestSpec as g}from"@contractspec/lib.contracts-spec/tests";var j=g({meta:{key:"analytics.dashboard.create.test",version:"1.0.0",title:"Create Dashboard Test",description:"Verifies dashboard creation flow",owners:["@example.analytics-dashboard"],tags:["analytics","dashboard","test"],stability:"stable"},target:{type:"operation",operation:{key:"analytics.dashboard.create",version:"1.0.0"}},scenarios:[{key:"success",description:"Successfully create a dashboard",when:{operation:{key:"analytics.dashboard.create",version:"1.0.0"},input:{name:"Test Dashboard",description:"Test Description"}},then:[{type:"expectOutput",match:{name:"Test Dashboard"}}]},{key:"error-invalid-input",description:"Fail to create dashboard with invalid input",when:{operation:{key:"analytics.dashboard.create",version:"1.0.0"},input:{name:""}},then:[{type:"expectError",messageIncludes:"VALIDATION_ERROR"}]}]}),k=g({meta:{key:"analytics.dashboard.list.test",version:"1.0.0",title:"List Dashboards Test",description:"Verifies dashboard listing",owners:["@example.analytics-dashboard"],tags:["analytics","dashboard","test"],stability:"stable"},target:{type:"operation",operation:{key:"analytics.dashboard.list",version:"1.0.0"}},scenarios:[{key:"success",description:"Successfully list dashboards",when:{operation:{key:"analytics.dashboard.list",version:"1.0.0"},input:{limit:10,offset:0}},then:[{type:"expectOutput",match:{items:[],total:0}}]},{key:"error-invalid-format",description:"Fail with invalid pagination",when:{operation:{key:"analytics.dashboard.list",version:"1.0.0"},input:{limit:-1}},then:[{type:"expectError",messageIncludes:"VALIDATION_ERROR"}]}]}),m=g({meta:{key:"analytics.dashboard.get.test",version:"1.0.0",title:"Get Dashboard Test",description:"Verifies dashboard retrieval",owners:["@example.analytics-dashboard"],tags:["analytics","dashboard","test"],stability:"stable"},target:{type:"operation",operation:{key:"analytics.dashboard.get",version:"1.0.0"}},scenarios:[{key:"success",description:"Successfully get dashboard",when:{operation:{key:"analytics.dashboard.get",version:"1.0.0"},input:{dashboardId:"dash-123"}},then:[{type:"expectOutput",match:{id:"dash-123"}}]},{key:"error-not-found",description:"Fail when dashboard not found",when:{operation:{key:"analytics.dashboard.get",version:"1.0.0"},input:{dashboardId:"dash-999"}},then:[{type:"expectError",messageIncludes:"NOT_FOUND"}]}]}),q=g({meta:{key:"analytics.widget.add.test",version:"1.0.0",title:"Add Widget Test",description:"Verifies adding widget to dashboard",owners:["@example.analytics-dashboard"],tags:["analytics","widget","test"],stability:"stable"},target:{type:"operation",operation:{key:"analytics.widget.add",version:"1.0.0"}},scenarios:[{key:"success",description:"Successfully add widget",when:{operation:{key:"analytics.widget.add",version:"1.0.0"},input:{dashboardId:"dash-123",type:"chart",queryId:"q-1",config:{}}},then:[{type:"expectOutput",match:{type:"chart",dashboardId:"dash-123"}}]},{key:"error-dashboard-not-found",description:"Fail when dashboard does not exist",when:{operation:{key:"analytics.widget.add",version:"1.0.0"},input:{dashboardId:"dash-999",type:"chart",queryId:"q-1",config:{}}},then:[{type:"expectError",messageIncludes:"NOT_FOUND"}]}]});export{k as ListDashboardsTest,m as GetDashboardTest,j as CreateDashboardTest,q as AddWidgetTest};
|
|
@@ -1,299 +1 @@
|
|
|
1
|
-
|
|
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-spec/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
|
-
};
|
|
1
|
+
import{defineEnum as k}from"@contractspec/lib.schema";var G=k("DashboardStatus",["DRAFT","PUBLISHED","ARCHIVED"]),L=k("WidgetType",["LINE_CHART","BAR_CHART","PIE_CHART","AREA_CHART","SCATTER_PLOT","METRIC","TABLE","HEATMAP","FUNNEL","MAP","TEXT","EMBED"]),j=k("RefreshInterval",["NONE","MINUTE","FIVE_MINUTES","FIFTEEN_MINUTES","HOUR","DAY"]);import{defineSchemaModel as C,ScalarTypeEnum as x}from"@contractspec/lib.schema";var D=C({name:"WidgetModel",fields:{id:{type:x.String_unsecure(),isOptional:!1},dashboardId:{type:x.String_unsecure(),isOptional:!1},name:{type:x.String_unsecure(),isOptional:!1},type:{type:L,isOptional:!1},gridX:{type:x.Int_unsecure(),isOptional:!1},gridY:{type:x.Int_unsecure(),isOptional:!1},gridWidth:{type:x.Int_unsecure(),isOptional:!1},gridHeight:{type:x.Int_unsecure(),isOptional:!1},queryId:{type:x.String_unsecure(),isOptional:!0},config:{type:x.JSON(),isOptional:!0}}}),w=C({name:"DashboardModel",fields:{id:{type:x.String_unsecure(),isOptional:!1},name:{type:x.String_unsecure(),isOptional:!1},slug:{type:x.String_unsecure(),isOptional:!1},description:{type:x.String_unsecure(),isOptional:!0},status:{type:G,isOptional:!1},refreshInterval:{type:j,isOptional:!1},isPublic:{type:x.Boolean(),isOptional:!1},widgets:{type:D,isArray:!0,isOptional:!0},createdAt:{type:x.DateTime(),isOptional:!1}}}),q=C({name:"CreateDashboardInput",fields:{name:{type:x.NonEmptyString(),isOptional:!1},slug:{type:x.NonEmptyString(),isOptional:!1},description:{type:x.String_unsecure(),isOptional:!0},refreshInterval:{type:j,isOptional:!0},dateRange:{type:x.JSON(),isOptional:!0}}}),z=C({name:"AddWidgetInput",fields:{dashboardId:{type:x.String_unsecure(),isOptional:!1},name:{type:x.NonEmptyString(),isOptional:!1},type:{type:L,isOptional:!1},gridX:{type:x.Int_unsecure(),isOptional:!0},gridY:{type:x.Int_unsecure(),isOptional:!0},gridWidth:{type:x.Int_unsecure(),isOptional:!0},gridHeight:{type:x.Int_unsecure(),isOptional:!0},queryId:{type:x.String_unsecure(),isOptional:!0},config:{type:x.JSON(),isOptional:!0}}}),B=C({name:"ListDashboardsInput",fields:{status:{type:G,isOptional:!0},search:{type:x.String_unsecure(),isOptional:!0},limit:{type:x.Int_unsecure(),isOptional:!0,defaultValue:20},offset:{type:x.Int_unsecure(),isOptional:!0,defaultValue:0}}}),F=C({name:"ListDashboardsOutput",fields:{dashboards:{type:w,isArray:!0,isOptional:!1},total:{type:x.Int_unsecure(),isOptional:!1}}}),H=C({name:"GetDashboardInput",fields:{dashboardId:{type:x.String_unsecure(),isOptional:!0},slug:{type:x.String_unsecure(),isOptional:!0},shareToken:{type:x.String_unsecure(),isOptional:!0}}});import{defineCommand as J,defineQuery as K}from"@contractspec/lib.contracts-spec/operations";var A=["@example.analytics-dashboard"],P=J({meta:{key:"analytics.dashboard.create",version:"1.0.0",stability:"stable",owners:[...A],tags:["analytics","dashboard","create"],description:"Create a new analytics dashboard.",goal:"Allow users to create custom dashboards.",context:"Dashboard management."},io:{input:q,output:w},policy:{auth:"user"},sideEffects:{emits:[{key:"analytics.dashboard.created",version:"1.0.0",stability:"stable",owners:[...A],tags:["analytics","dashboard","created"],when:"Dashboard created",payload:w}],audit:["analytics.dashboard.created"]},acceptance:{scenarios:[{key:"create-dashboard-happy-path",given:["User is authenticated"],when:["User submits valid dashboard configuration"],then:["Dashboard is created","DashboardCreated event is emitted"]}],examples:[{key:"create-basic",input:{name:"Revenue Dashboard",description:"Monthly revenue metrics"},output:{id:"dash-123",name:"Revenue Dashboard",widgets:[]}}]}}),U=J({meta:{key:"analytics.widget.add",version:"1.0.0",stability:"stable",owners:[...A],tags:["analytics","widget","add"],description:"Add a widget to a dashboard.",goal:"Allow users to add visualizations.",context:"Dashboard editor."},io:{input:z,output:D},policy:{auth:"user"},sideEffects:{emits:[{key:"analytics.widget.added",version:"1.0.0",stability:"stable",owners:[...A],tags:["analytics","widget","added"],when:"Widget added",payload:D}]},acceptance:{scenarios:[{key:"add-widget-happy-path",given:["Dashboard exists"],when:["User adds widget to dashboard"],then:["Widget is created","WidgetAdded event is emitted"]}],examples:[{key:"add-chart-widget",input:{dashboardId:"dash-123",type:"chart",queryId:"query-456",config:{chartType:"bar"}},output:{id:"widget-789",type:"chart",dashboardId:"dash-123"}}]}}),V=K({meta:{key:"analytics.dashboard.list",version:"1.0.0",stability:"stable",owners:[...A],tags:["analytics","dashboard","list"],description:"List dashboards.",goal:"Browse available dashboards.",context:"Dashboard listing."},io:{input:B,output:F},policy:{auth:"user"},acceptance:{scenarios:[{key:"list-dashboards-happy-path",given:["User has dashboards"],when:["User lists dashboards"],then:["Paginated list of dashboards is returned"]}],examples:[{key:"list-basic",input:{limit:10,offset:0},output:{items:[],total:0,hasMore:!1}}]}}),X=K({meta:{key:"analytics.dashboard.get",version:"1.0.0",stability:"stable",owners:[...A],tags:["analytics","dashboard","get"],description:"Get a dashboard with widgets.",goal:"Load dashboard for viewing.",context:"Dashboard view."},io:{input:H,output:w},policy:{auth:"anonymous"},acceptance:{scenarios:[{key:"get-dashboard-happy-path",given:["Dashboard exists"],when:["User requests dashboard by ID"],then:["Dashboard with widgets is returned"]}],examples:[{key:"get-basic",input:{dashboardId:"dash-123"},output:{id:"dash-123",name:"Revenue Dashboard",widgets:[]}}]}});export{L as WidgetTypeEnum,D as WidgetModel,j as RefreshIntervalEnum,F as ListDashboardsOutputModel,B as ListDashboardsInputModel,V as ListDashboardsContract,H as GetDashboardInputModel,X as GetDashboardContract,G as DashboardStatusEnum,w as DashboardModel,q as CreateDashboardInputModel,P as CreateDashboardContract,z as AddWidgetInputModel,U as AddWidgetContract};
|