@contractspec/example.analytics-dashboard 1.57.0 → 1.59.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/dist/browser/dashboard/dashboard.enum.js +34 -0
  2. package/dist/browser/dashboard/dashboard.operation.js +289 -0
  3. package/dist/browser/dashboard/dashboard.presentation.js +197 -0
  4. package/dist/browser/dashboard/dashboard.schema.js +126 -0
  5. package/dist/browser/dashboard/dashboard.test-spec.js +213 -0
  6. package/dist/browser/dashboard/index.js +299 -0
  7. package/dist/browser/dashboard.feature.js +84 -0
  8. package/dist/browser/datasource/posthog-datasource.js +289 -0
  9. package/dist/browser/docs/analytics-dashboard.docblock.js +103 -0
  10. package/dist/browser/docs/index.js +103 -0
  11. package/dist/browser/events.js +81 -0
  12. package/dist/browser/example.js +42 -0
  13. package/dist/browser/handlers/analytics.handlers.js +278 -0
  14. package/dist/browser/handlers/index.js +571 -0
  15. package/dist/browser/handlers/query.handlers.js +294 -0
  16. package/dist/browser/index.js +1677 -0
  17. package/dist/browser/query/index.js +159 -0
  18. package/dist/browser/query/query.enum.js +11 -0
  19. package/dist/browser/query/query.operation.js +154 -0
  20. package/dist/browser/query/query.presentation.js +119 -0
  21. package/dist/browser/query/query.schema.js +70 -0
  22. package/dist/browser/query/query.test-spec.js +113 -0
  23. package/dist/browser/query-engine/index.js +491 -0
  24. package/dist/browser/seeders/index.js +20 -0
  25. package/dist/browser/ui/AnalyticsDashboard.js +394 -0
  26. package/dist/browser/ui/hooks/index.js +69 -0
  27. package/dist/browser/ui/hooks/useAnalyticsData.js +66 -0
  28. package/dist/browser/ui/index.js +671 -0
  29. package/dist/browser/ui/renderers/analytics.markdown.js +275 -0
  30. package/dist/browser/ui/renderers/index.js +275 -0
  31. package/dist/dashboard/dashboard.enum.d.ts +3 -8
  32. package/dist/dashboard/dashboard.enum.d.ts.map +1 -1
  33. package/dist/dashboard/dashboard.enum.js +31 -39
  34. package/dist/dashboard/dashboard.operation.d.ts +444 -450
  35. package/dist/dashboard/dashboard.operation.d.ts.map +1 -1
  36. package/dist/dashboard/dashboard.operation.js +284 -207
  37. package/dist/dashboard/dashboard.presentation.d.ts +3 -8
  38. package/dist/dashboard/dashboard.presentation.d.ts.map +1 -1
  39. package/dist/dashboard/dashboard.presentation.js +193 -85
  40. package/dist/dashboard/dashboard.schema.d.ts +289 -294
  41. package/dist/dashboard/dashboard.schema.d.ts.map +1 -1
  42. package/dist/dashboard/dashboard.schema.js +119 -228
  43. package/dist/dashboard/dashboard.test-spec.d.ts +4 -9
  44. package/dist/dashboard/dashboard.test-spec.d.ts.map +1 -1
  45. package/dist/dashboard/dashboard.test-spec.js +209 -228
  46. package/dist/dashboard/index.d.ts +7 -4
  47. package/dist/dashboard/index.d.ts.map +1 -0
  48. package/dist/dashboard/index.js +299 -4
  49. package/dist/dashboard.feature.d.ts +1 -6
  50. package/dist/dashboard.feature.d.ts.map +1 -1
  51. package/dist/dashboard.feature.js +83 -175
  52. package/dist/datasource/posthog-datasource.d.ts +15 -19
  53. package/dist/datasource/posthog-datasource.d.ts.map +1 -1
  54. package/dist/datasource/posthog-datasource.js +274 -238
  55. package/dist/docs/analytics-dashboard.docblock.d.ts +2 -1
  56. package/dist/docs/analytics-dashboard.docblock.d.ts.map +1 -0
  57. package/dist/docs/analytics-dashboard.docblock.js +45 -56
  58. package/dist/docs/index.d.ts +2 -1
  59. package/dist/docs/index.d.ts.map +1 -0
  60. package/dist/docs/index.js +104 -1
  61. package/dist/events.d.ts +109 -115
  62. package/dist/events.d.ts.map +1 -1
  63. package/dist/events.js +74 -120
  64. package/dist/example.d.ts +2 -6
  65. package/dist/example.d.ts.map +1 -1
  66. package/dist/example.js +41 -55
  67. package/dist/handlers/analytics.handlers.d.ts +110 -109
  68. package/dist/handlers/analytics.handlers.d.ts.map +1 -1
  69. package/dist/handlers/analytics.handlers.js +267 -298
  70. package/dist/handlers/index.d.ts +3 -3
  71. package/dist/handlers/index.d.ts.map +1 -0
  72. package/dist/handlers/index.js +571 -3
  73. package/dist/handlers/query.handlers.d.ts +7 -11
  74. package/dist/handlers/query.handlers.d.ts.map +1 -1
  75. package/dist/handlers/query.handlers.js +292 -7
  76. package/dist/index.d.ts +12 -13
  77. package/dist/index.d.ts.map +1 -0
  78. package/dist/index.js +1678 -14
  79. package/dist/node/dashboard/dashboard.enum.js +34 -0
  80. package/dist/node/dashboard/dashboard.operation.js +289 -0
  81. package/dist/node/dashboard/dashboard.presentation.js +197 -0
  82. package/dist/node/dashboard/dashboard.schema.js +126 -0
  83. package/dist/node/dashboard/dashboard.test-spec.js +213 -0
  84. package/dist/node/dashboard/index.js +299 -0
  85. package/dist/node/dashboard.feature.js +84 -0
  86. package/dist/node/datasource/posthog-datasource.js +289 -0
  87. package/dist/node/docs/analytics-dashboard.docblock.js +103 -0
  88. package/dist/node/docs/index.js +103 -0
  89. package/dist/node/events.js +81 -0
  90. package/dist/node/example.js +42 -0
  91. package/dist/node/handlers/analytics.handlers.js +278 -0
  92. package/dist/node/handlers/index.js +571 -0
  93. package/dist/node/handlers/query.handlers.js +294 -0
  94. package/dist/node/index.js +1677 -0
  95. package/dist/node/query/index.js +159 -0
  96. package/dist/node/query/query.enum.js +11 -0
  97. package/dist/node/query/query.operation.js +154 -0
  98. package/dist/node/query/query.presentation.js +119 -0
  99. package/dist/node/query/query.schema.js +70 -0
  100. package/dist/node/query/query.test-spec.js +113 -0
  101. package/dist/node/query-engine/index.js +491 -0
  102. package/dist/node/seeders/index.js +20 -0
  103. package/dist/node/ui/AnalyticsDashboard.js +394 -0
  104. package/dist/node/ui/hooks/index.js +69 -0
  105. package/dist/node/ui/hooks/useAnalyticsData.js +66 -0
  106. package/dist/node/ui/index.js +671 -0
  107. package/dist/node/ui/renderers/analytics.markdown.js +275 -0
  108. package/dist/node/ui/renderers/index.js +275 -0
  109. package/dist/query/index.d.ts +7 -4
  110. package/dist/query/index.d.ts.map +1 -0
  111. package/dist/query/index.js +159 -4
  112. package/dist/query/query.enum.d.ts +1 -6
  113. package/dist/query/query.enum.d.ts.map +1 -1
  114. package/dist/query/query.enum.js +10 -14
  115. package/dist/query/query.operation.d.ts +148 -154
  116. package/dist/query/query.operation.d.ts.map +1 -1
  117. package/dist/query/query.operation.js +151 -109
  118. package/dist/query/query.presentation.d.ts +2 -7
  119. package/dist/query/query.presentation.d.ts.map +1 -1
  120. package/dist/query/query.presentation.js +116 -56
  121. package/dist/query/query.schema.d.ts +121 -126
  122. package/dist/query/query.schema.d.ts.map +1 -1
  123. package/dist/query/query.schema.js +66 -152
  124. package/dist/query/query.test-spec.d.ts +2 -7
  125. package/dist/query/query.test-spec.d.ts.map +1 -1
  126. package/dist/query/query.test-spec.js +111 -121
  127. package/dist/query-engine/index.d.ts +84 -88
  128. package/dist/query-engine/index.d.ts.map +1 -1
  129. package/dist/query-engine/index.js +489 -188
  130. package/dist/seeders/index.d.ts +4 -8
  131. package/dist/seeders/index.d.ts.map +1 -1
  132. package/dist/seeders/index.js +18 -16
  133. package/dist/ui/AnalyticsDashboard.d.ts +1 -6
  134. package/dist/ui/AnalyticsDashboard.d.ts.map +1 -1
  135. package/dist/ui/AnalyticsDashboard.js +389 -259
  136. package/dist/ui/hooks/index.d.ts +2 -2
  137. package/dist/ui/hooks/index.d.ts.map +1 -0
  138. package/dist/ui/hooks/index.js +69 -4
  139. package/dist/ui/hooks/useAnalyticsData.d.ts +16 -20
  140. package/dist/ui/hooks/useAnalyticsData.d.ts.map +1 -1
  141. package/dist/ui/hooks/useAnalyticsData.js +63 -69
  142. package/dist/ui/index.d.ts +7 -6
  143. package/dist/ui/index.d.ts.map +1 -0
  144. package/dist/ui/index.js +671 -5
  145. package/dist/ui/renderers/analytics.markdown.d.ts +13 -14
  146. package/dist/ui/renderers/analytics.markdown.d.ts.map +1 -1
  147. package/dist/ui/renderers/analytics.markdown.js +266 -254
  148. package/dist/ui/renderers/index.d.ts +2 -2
  149. package/dist/ui/renderers/index.d.ts.map +1 -0
  150. package/dist/ui/renderers/index.js +275 -2
  151. package/package.json +328 -67
  152. package/dist/dashboard/dashboard.enum.js.map +0 -1
  153. package/dist/dashboard/dashboard.operation.js.map +0 -1
  154. package/dist/dashboard/dashboard.presentation.js.map +0 -1
  155. package/dist/dashboard/dashboard.schema.js.map +0 -1
  156. package/dist/dashboard/dashboard.test-spec.js.map +0 -1
  157. package/dist/dashboard.feature.js.map +0 -1
  158. package/dist/datasource/posthog-datasource.js.map +0 -1
  159. package/dist/docs/analytics-dashboard.docblock.js.map +0 -1
  160. package/dist/events.js.map +0 -1
  161. package/dist/example.js.map +0 -1
  162. package/dist/handlers/analytics.handlers.js.map +0 -1
  163. package/dist/handlers/query.handlers.js.map +0 -1
  164. package/dist/query/query.enum.js.map +0 -1
  165. package/dist/query/query.operation.js.map +0 -1
  166. package/dist/query/query.presentation.js.map +0 -1
  167. package/dist/query/query.schema.js.map +0 -1
  168. package/dist/query/query.test-spec.js.map +0 -1
  169. package/dist/query-engine/index.js.map +0 -1
  170. package/dist/seeders/index.js.map +0 -1
  171. package/dist/ui/AnalyticsDashboard.js.map +0 -1
  172. package/dist/ui/hooks/useAnalyticsData.js.map +0 -1
  173. package/dist/ui/renderers/analytics.markdown.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"dashboard.operation.d.ts","names":[],"sources":["../../src/dashboard/dashboard.operation.ts"],"mappings":";;;;;;;cAmBa,uBAAA,+BAAuB,aAAA,2BAAA,WAAA;;UA+ClC,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;UA/CkC,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAoDvB,iBAAA,+BAAiB,aAAA,2BAAA,WAAA;;UAgD5B,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAhD4B,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAqDjB,sBAAA,+BAAsB,aAAA,2BAAA,WAAA;;UA8BjC,yBAAA,CAAA,QAAA;;;;;;;;;;;;;;;;;;;;;cA9BiC,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmCtB,oBAAA,+BAAoB,aAAA,2BAAA,WAAA;;UA8B/B,yBAAA,CAAA,SAAA;;;;;;;;;;;;;UA9B+B,yBAAA,CAAA,SAAA"}
1
+ {"version":3,"file":"dashboard.operation.d.ts","sourceRoot":"","sources":["../../src/dashboard/dashboard.operation.ts"],"names":[],"mappings":"AAgBA;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA+ClC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAgD5B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA8BjC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA8B/B,CAAC"}
@@ -1,213 +1,290 @@
1
- import { AddWidgetInputModel, CreateDashboardInputModel, DashboardModel, GetDashboardInputModel, ListDashboardsInputModel, ListDashboardsOutputModel, WidgetModel } from "./dashboard.schema.js";
2
- import { defineCommand, defineQuery } from "@contractspec/lib.contracts/operations";
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
+ ]);
3
31
 
4
- //#region src/dashboard/dashboard.operation.ts
5
- const OWNERS = ["@example.analytics-dashboard"];
6
- /**
7
- * Create a new analytics dashboard.
8
- */
9
- const CreateDashboardContract = defineCommand({
10
- meta: {
11
- key: "analytics.dashboard.create",
12
- version: "1.0.0",
13
- stability: "stable",
14
- owners: [...OWNERS],
15
- tags: [
16
- "analytics",
17
- "dashboard",
18
- "create"
19
- ],
20
- description: "Create a new analytics dashboard.",
21
- goal: "Allow users to create custom dashboards.",
22
- context: "Dashboard management."
23
- },
24
- io: {
25
- input: CreateDashboardInputModel,
26
- output: DashboardModel
27
- },
28
- policy: { auth: "user" },
29
- sideEffects: {
30
- emits: [{
31
- key: "analytics.dashboard.created",
32
- version: "1.0.0",
33
- stability: "stable",
34
- owners: [...OWNERS],
35
- tags: [
36
- "analytics",
37
- "dashboard",
38
- "created"
39
- ],
40
- when: "Dashboard created",
41
- payload: DashboardModel
42
- }],
43
- audit: ["analytics.dashboard.created"]
44
- },
45
- acceptance: {
46
- scenarios: [{
47
- key: "create-dashboard-happy-path",
48
- given: ["User is authenticated"],
49
- when: ["User submits valid dashboard configuration"],
50
- then: ["Dashboard is created", "DashboardCreated event is emitted"]
51
- }],
52
- examples: [{
53
- key: "create-basic",
54
- input: {
55
- name: "Revenue Dashboard",
56
- description: "Monthly revenue metrics"
57
- },
58
- output: {
59
- id: "dash-123",
60
- name: "Revenue Dashboard",
61
- widgets: []
62
- }
63
- }]
64
- }
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
+ }
65
48
  });
66
- /**
67
- * Add a widget to a dashboard.
68
- */
69
- const AddWidgetContract = defineCommand({
70
- meta: {
71
- key: "analytics.widget.add",
72
- version: "1.0.0",
73
- stability: "stable",
74
- owners: [...OWNERS],
75
- tags: [
76
- "analytics",
77
- "widget",
78
- "add"
79
- ],
80
- description: "Add a widget to a dashboard.",
81
- goal: "Allow users to add visualizations.",
82
- context: "Dashboard editor."
83
- },
84
- io: {
85
- input: AddWidgetInputModel,
86
- output: WidgetModel
87
- },
88
- policy: { auth: "user" },
89
- sideEffects: { emits: [{
90
- key: "analytics.widget.added",
91
- version: "1.0.0",
92
- stability: "stable",
93
- owners: [...OWNERS],
94
- tags: [
95
- "analytics",
96
- "widget",
97
- "added"
98
- ],
99
- when: "Widget added",
100
- payload: WidgetModel
101
- }] },
102
- acceptance: {
103
- scenarios: [{
104
- key: "add-widget-happy-path",
105
- given: ["Dashboard exists"],
106
- when: ["User adds widget to dashboard"],
107
- then: ["Widget is created", "WidgetAdded event is emitted"]
108
- }],
109
- examples: [{
110
- key: "add-chart-widget",
111
- input: {
112
- dashboardId: "dash-123",
113
- type: "chart",
114
- queryId: "query-456",
115
- config: { chartType: "bar" }
116
- },
117
- output: {
118
- id: "widget-789",
119
- type: "chart",
120
- dashboardId: "dash-123"
121
- }
122
- }]
123
- }
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
+ }
124
62
  });
125
- /**
126
- * List dashboards.
127
- */
128
- const ListDashboardsContract = defineQuery({
129
- meta: {
130
- key: "analytics.dashboard.list",
131
- version: "1.0.0",
132
- stability: "stable",
133
- owners: [...OWNERS],
134
- tags: [
135
- "analytics",
136
- "dashboard",
137
- "list"
138
- ],
139
- description: "List dashboards.",
140
- goal: "Browse available dashboards.",
141
- context: "Dashboard listing."
142
- },
143
- io: {
144
- input: ListDashboardsInputModel,
145
- output: ListDashboardsOutputModel
146
- },
147
- policy: { auth: "user" },
148
- acceptance: {
149
- scenarios: [{
150
- key: "list-dashboards-happy-path",
151
- given: ["User has dashboards"],
152
- when: ["User lists dashboards"],
153
- then: ["Paginated list of dashboards is returned"]
154
- }],
155
- examples: [{
156
- key: "list-basic",
157
- input: {
158
- limit: 10,
159
- offset: 0
160
- },
161
- output: {
162
- items: [],
163
- total: 0,
164
- hasMore: false
165
- }
166
- }]
167
- }
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
+ }
168
72
  });
169
- /**
170
- * Get a dashboard with widgets.
171
- */
172
- const GetDashboardContract = defineQuery({
173
- meta: {
174
- key: "analytics.dashboard.get",
175
- version: "1.0.0",
176
- stability: "stable",
177
- owners: [...OWNERS],
178
- tags: [
179
- "analytics",
180
- "dashboard",
181
- "get"
182
- ],
183
- description: "Get a dashboard with widgets.",
184
- goal: "Load dashboard for viewing.",
185
- context: "Dashboard view."
186
- },
187
- io: {
188
- input: GetDashboardInputModel,
189
- output: DashboardModel
190
- },
191
- policy: { auth: "anonymous" },
192
- acceptance: {
193
- scenarios: [{
194
- key: "get-dashboard-happy-path",
195
- given: ["Dashboard exists"],
196
- when: ["User requests dashboard by ID"],
197
- then: ["Dashboard with widgets is returned"]
198
- }],
199
- examples: [{
200
- key: "get-basic",
201
- input: { dashboardId: "dash-123" },
202
- output: {
203
- id: "dash-123",
204
- name: "Revenue Dashboard",
205
- widgets: []
206
- }
207
- }]
208
- }
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
+ }
209
118
  });
210
119
 
211
- //#endregion
212
- export { AddWidgetContract, CreateDashboardContract, GetDashboardContract, ListDashboardsContract };
213
- //# sourceMappingURL=dashboard.operation.js.map
120
+ // src/dashboard/dashboard.operation.ts
121
+ import {
122
+ defineCommand,
123
+ defineQuery
124
+ } from "@contractspec/lib.contracts/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
+ };
@@ -1,9 +1,4 @@
1
- import * as _contractspec_lib_contracts0 from "@contractspec/lib.contracts";
2
-
3
- //#region src/dashboard/dashboard.presentation.d.ts
4
- declare const DashboardsListPresentation: _contractspec_lib_contracts0.PresentationSpec;
5
- declare const DashboardViewPresentation: _contractspec_lib_contracts0.PresentationSpec;
6
- declare const DashboardEditorPresentation: _contractspec_lib_contracts0.PresentationSpec;
7
- //#endregion
8
- export { DashboardEditorPresentation, DashboardViewPresentation, DashboardsListPresentation };
1
+ export declare const DashboardsListPresentation: import("@contractspec/lib.contracts").PresentationSpec;
2
+ export declare const DashboardViewPresentation: import("@contractspec/lib.contracts").PresentationSpec;
3
+ export declare const DashboardEditorPresentation: import("@contractspec/lib.contracts").PresentationSpec;
9
4
  //# sourceMappingURL=dashboard.presentation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dashboard.presentation.d.ts","names":[],"sources":["../../src/dashboard/dashboard.presentation.ts"],"mappings":";;;cAGa,0BAAA,EAuBX,4BAAA,CAvBqC,gBAAA;AAAA,cAyB1B,yBAAA,EAuBX,4BAAA,CAvBoC,gBAAA;AAAA,cAyBzB,2BAAA,EAuBX,4BAAA,CAvBsC,gBAAA"}
1
+ {"version":3,"file":"dashboard.presentation.d.ts","sourceRoot":"","sources":["../../src/dashboard/dashboard.presentation.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,0BAA0B,wDAuBrC,CAAC;AAEH,eAAO,MAAM,yBAAyB,wDAuBpC,CAAC;AAEH,eAAO,MAAM,2BAA2B,wDAuBtC,CAAC"}