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