@contractspec/example.analytics-dashboard 1.57.0 → 1.58.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,113 +1,155 @@
1
- import { CreateQueryInputModel, ExecuteQueryInputModel, QueryModel, QueryResultModel } from "./query.schema.js";
2
- import { defineCommand, defineQuery } from "@contractspec/lib.contracts/operations";
1
+ // @bun
2
+ // src/query/query.enum.ts
3
+ import { defineEnum } from "@contractspec/lib.schema";
4
+ var QueryTypeEnum = defineEnum("QueryType", [
5
+ "SQL",
6
+ "METRIC",
7
+ "AGGREGATION",
8
+ "CUSTOM"
9
+ ]);
3
10
 
4
- //#region src/query/query.operation.ts
5
- const OWNERS = ["@example.analytics-dashboard"];
6
- /**
7
- * Create a data query.
8
- */
9
- const CreateQueryContract = defineCommand({
10
- meta: {
11
- key: "analytics.query.create",
12
- version: "1.0.0",
13
- stability: "stable",
14
- owners: [...OWNERS],
15
- tags: [
16
- "analytics",
17
- "query",
18
- "create"
19
- ],
20
- description: "Create a data query.",
21
- goal: "Define reusable data queries.",
22
- context: "Query builder."
23
- },
24
- io: {
25
- input: CreateQueryInputModel,
26
- output: QueryModel
27
- },
28
- policy: { auth: "user" },
29
- sideEffects: {
30
- emits: [{
31
- key: "analytics.query.created",
32
- version: "1.0.0",
33
- stability: "stable",
34
- owners: [...OWNERS],
35
- tags: [
36
- "analytics",
37
- "query",
38
- "created"
39
- ],
40
- when: "Query created",
41
- payload: QueryModel
42
- }],
43
- audit: ["analytics.query.created"]
44
- },
45
- acceptance: {
46
- scenarios: [{
47
- key: "create-query-happy-path",
48
- given: ["User is authenticated"],
49
- when: ["User submits valid query definition"],
50
- then: ["Query is created", "QueryCreated event is emitted"]
51
- }],
52
- examples: [{
53
- key: "create-sql-query",
54
- input: {
55
- name: "Monthly Revenue",
56
- sql: "SELECT SUM(amount) FROM orders WHERE date >= :startDate"
57
- },
58
- output: {
59
- id: "query-123",
60
- name: "Monthly Revenue",
61
- type: "sql"
62
- }
63
- }]
64
- }
11
+ // src/query/query.schema.ts
12
+ import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
13
+ var QueryModel = defineSchemaModel({
14
+ name: "QueryModel",
15
+ fields: {
16
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
17
+ name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
18
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
19
+ type: { type: QueryTypeEnum, isOptional: false },
20
+ definition: { type: ScalarTypeEnum.JSON(), isOptional: false },
21
+ sql: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
22
+ cacheTtlSeconds: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
23
+ isShared: { type: ScalarTypeEnum.Boolean(), isOptional: false },
24
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
25
+ }
65
26
  });
66
- /**
67
- * Execute a data query.
68
- */
69
- const ExecuteQueryContract = defineQuery({
70
- meta: {
71
- key: "analytics.query.execute",
72
- version: "1.0.0",
73
- stability: "stable",
74
- owners: [...OWNERS],
75
- tags: [
76
- "analytics",
77
- "query",
78
- "execute"
79
- ],
80
- description: "Execute a data query.",
81
- goal: "Fetch data for visualizations.",
82
- context: "Dashboard rendering."
83
- },
84
- io: {
85
- input: ExecuteQueryInputModel,
86
- output: QueryResultModel
87
- },
88
- policy: { auth: "user" },
89
- acceptance: {
90
- scenarios: [{
91
- key: "execute-query-happy-path",
92
- given: ["Query exists"],
93
- when: ["User executes query with parameters"],
94
- then: ["Query results are returned"]
95
- }],
96
- examples: [{
97
- key: "execute-with-params",
98
- input: {
99
- queryId: "query-123",
100
- params: { startDate: "2025-01-01" }
101
- },
102
- output: {
103
- columns: ["total"],
104
- rows: [{ total: 5e4 }],
105
- rowCount: 1
106
- }
107
- }]
108
- }
27
+ var QueryResultModel = defineSchemaModel({
28
+ name: "QueryResultModel",
29
+ fields: {
30
+ queryId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
31
+ data: { type: ScalarTypeEnum.JSON(), isOptional: false },
32
+ columns: { type: ScalarTypeEnum.JSON(), isOptional: false },
33
+ rowCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
34
+ executionTimeMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
35
+ cachedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
36
+ error: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
37
+ }
38
+ });
39
+ var CreateQueryInputModel = defineSchemaModel({
40
+ name: "CreateQueryInput",
41
+ fields: {
42
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
43
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
44
+ type: { type: QueryTypeEnum, isOptional: false },
45
+ definition: { type: ScalarTypeEnum.JSON(), isOptional: false },
46
+ sql: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
47
+ metricIds: {
48
+ type: ScalarTypeEnum.String_unsecure(),
49
+ isArray: true,
50
+ isOptional: true
51
+ },
52
+ cacheTtlSeconds: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
53
+ isShared: { type: ScalarTypeEnum.Boolean(), isOptional: true }
54
+ }
55
+ });
56
+ var ExecuteQueryInputModel = defineSchemaModel({
57
+ name: "ExecuteQueryInput",
58
+ fields: {
59
+ queryId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
60
+ parameters: { type: ScalarTypeEnum.JSON(), isOptional: true },
61
+ dateRange: { type: ScalarTypeEnum.JSON(), isOptional: true },
62
+ filters: { type: ScalarTypeEnum.JSON(), isOptional: true },
63
+ forceRefresh: { type: ScalarTypeEnum.Boolean(), isOptional: true }
64
+ }
109
65
  });
110
66
 
111
- //#endregion
112
- export { CreateQueryContract, ExecuteQueryContract };
113
- //# sourceMappingURL=query.operation.js.map
67
+ // src/query/query.operation.ts
68
+ import {
69
+ defineCommand,
70
+ defineQuery
71
+ } from "@contractspec/lib.contracts/operations";
72
+ var OWNERS = ["@example.analytics-dashboard"];
73
+ var CreateQueryContract = defineCommand({
74
+ meta: {
75
+ key: "analytics.query.create",
76
+ version: "1.0.0",
77
+ stability: "stable",
78
+ owners: [...OWNERS],
79
+ tags: ["analytics", "query", "create"],
80
+ description: "Create a data query.",
81
+ goal: "Define reusable data queries.",
82
+ context: "Query builder."
83
+ },
84
+ io: { input: CreateQueryInputModel, output: QueryModel },
85
+ policy: { auth: "user" },
86
+ sideEffects: {
87
+ emits: [
88
+ {
89
+ key: "analytics.query.created",
90
+ version: "1.0.0",
91
+ stability: "stable",
92
+ owners: [...OWNERS],
93
+ tags: ["analytics", "query", "created"],
94
+ when: "Query created",
95
+ payload: QueryModel
96
+ }
97
+ ],
98
+ audit: ["analytics.query.created"]
99
+ },
100
+ acceptance: {
101
+ scenarios: [
102
+ {
103
+ key: "create-query-happy-path",
104
+ given: ["User is authenticated"],
105
+ when: ["User submits valid query definition"],
106
+ then: ["Query is created", "QueryCreated event is emitted"]
107
+ }
108
+ ],
109
+ examples: [
110
+ {
111
+ key: "create-sql-query",
112
+ input: {
113
+ name: "Monthly Revenue",
114
+ sql: "SELECT SUM(amount) FROM orders WHERE date >= :startDate"
115
+ },
116
+ output: { id: "query-123", name: "Monthly Revenue", type: "sql" }
117
+ }
118
+ ]
119
+ }
120
+ });
121
+ var ExecuteQueryContract = defineQuery({
122
+ meta: {
123
+ key: "analytics.query.execute",
124
+ version: "1.0.0",
125
+ stability: "stable",
126
+ owners: [...OWNERS],
127
+ tags: ["analytics", "query", "execute"],
128
+ description: "Execute a data query.",
129
+ goal: "Fetch data for visualizations.",
130
+ context: "Dashboard rendering."
131
+ },
132
+ io: { input: ExecuteQueryInputModel, output: QueryResultModel },
133
+ policy: { auth: "user" },
134
+ acceptance: {
135
+ scenarios: [
136
+ {
137
+ key: "execute-query-happy-path",
138
+ given: ["Query exists"],
139
+ when: ["User executes query with parameters"],
140
+ then: ["Query results are returned"]
141
+ }
142
+ ],
143
+ examples: [
144
+ {
145
+ key: "execute-with-params",
146
+ input: { queryId: "query-123", params: { startDate: "2025-01-01" } },
147
+ output: { columns: ["total"], rows: [{ total: 50000 }], rowCount: 1 }
148
+ }
149
+ ]
150
+ }
151
+ });
152
+ export {
153
+ ExecuteQueryContract,
154
+ CreateQueryContract
155
+ };
@@ -1,8 +1,3 @@
1
- import * as _contractspec_lib_contracts0 from "@contractspec/lib.contracts";
2
-
3
- //#region src/query/query.presentation.d.ts
4
- declare const QueriesListPresentation: _contractspec_lib_contracts0.PresentationSpec;
5
- declare const QueryBuilderPresentation: _contractspec_lib_contracts0.PresentationSpec;
6
- //#endregion
7
- export { QueriesListPresentation, QueryBuilderPresentation };
1
+ export declare const QueriesListPresentation: import("@contractspec/lib.contracts").PresentationSpec;
2
+ export declare const QueryBuilderPresentation: import("@contractspec/lib.contracts").PresentationSpec;
8
3
  //# sourceMappingURL=query.presentation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"query.presentation.d.ts","names":[],"sources":["../../src/query/query.presentation.ts"],"mappings":";;;cAGa,uBAAA,EAuBX,4BAAA,CAvBkC,gBAAA;AAAA,cAyBvB,wBAAA,EAuBX,4BAAA,CAvBmC,gBAAA"}
1
+ {"version":3,"file":"query.presentation.d.ts","sourceRoot":"","sources":["../../src/query/query.presentation.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,uBAAuB,wDAuBlC,CAAC;AAEH,eAAO,MAAM,wBAAwB,wDAuBnC,CAAC"}
@@ -1,60 +1,120 @@
1
- import { QueryModel } from "./query.schema.js";
2
- import { StabilityEnum, definePresentation } from "@contractspec/lib.contracts";
1
+ // @bun
2
+ // src/query/query.enum.ts
3
+ import { defineEnum } from "@contractspec/lib.schema";
4
+ var QueryTypeEnum = defineEnum("QueryType", [
5
+ "SQL",
6
+ "METRIC",
7
+ "AGGREGATION",
8
+ "CUSTOM"
9
+ ]);
3
10
 
4
- //#region src/query/query.presentation.ts
5
- const QueriesListPresentation = definePresentation({
6
- meta: {
7
- key: "analytics.query.list",
8
- version: "1.0.0",
9
- title: "Queries List",
10
- description: "List of saved queries",
11
- domain: "analytics",
12
- owners: ["@analytics-dashboard"],
13
- tags: [
14
- "analytics",
15
- "queries",
16
- "list"
17
- ],
18
- stability: StabilityEnum.Experimental,
19
- goal: "Browse and manage saved data queries.",
20
- context: "The library of reusable data definitions."
21
- },
22
- source: {
23
- type: "component",
24
- framework: "react",
25
- componentKey: "QueriesList",
26
- props: QueryModel
27
- },
28
- targets: ["react", "markdown"],
29
- policy: { flags: ["analytics.queries.enabled"] }
11
+ // src/query/query.schema.ts
12
+ import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
13
+ var QueryModel = defineSchemaModel({
14
+ name: "QueryModel",
15
+ fields: {
16
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
17
+ name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
18
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
19
+ type: { type: QueryTypeEnum, isOptional: false },
20
+ definition: { type: ScalarTypeEnum.JSON(), isOptional: false },
21
+ sql: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
22
+ cacheTtlSeconds: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
23
+ isShared: { type: ScalarTypeEnum.Boolean(), isOptional: false },
24
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
25
+ }
30
26
  });
31
- const QueryBuilderPresentation = definePresentation({
32
- meta: {
33
- key: "analytics.query.builder",
34
- version: "1.0.0",
35
- title: "Query Builder",
36
- description: "Visual query builder interface",
37
- domain: "analytics",
38
- owners: ["@analytics-dashboard"],
39
- tags: [
40
- "analytics",
41
- "query",
42
- "builder"
43
- ],
44
- stability: StabilityEnum.Experimental,
45
- goal: "Visually construct data queries and transformations.",
46
- context: "Developer tool for data analysis."
47
- },
48
- source: {
49
- type: "component",
50
- framework: "react",
51
- componentKey: "QueryBuilder",
52
- props: QueryModel
53
- },
54
- targets: ["react"],
55
- policy: { flags: ["analytics.queries.enabled"] }
27
+ var QueryResultModel = defineSchemaModel({
28
+ name: "QueryResultModel",
29
+ fields: {
30
+ queryId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
31
+ data: { type: ScalarTypeEnum.JSON(), isOptional: false },
32
+ columns: { type: ScalarTypeEnum.JSON(), isOptional: false },
33
+ rowCount: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
34
+ executionTimeMs: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
35
+ cachedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
36
+ error: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
37
+ }
38
+ });
39
+ var CreateQueryInputModel = defineSchemaModel({
40
+ name: "CreateQueryInput",
41
+ fields: {
42
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
43
+ description: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
44
+ type: { type: QueryTypeEnum, isOptional: false },
45
+ definition: { type: ScalarTypeEnum.JSON(), isOptional: false },
46
+ sql: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
47
+ metricIds: {
48
+ type: ScalarTypeEnum.String_unsecure(),
49
+ isArray: true,
50
+ isOptional: true
51
+ },
52
+ cacheTtlSeconds: { type: ScalarTypeEnum.Int_unsecure(), isOptional: true },
53
+ isShared: { type: ScalarTypeEnum.Boolean(), isOptional: true }
54
+ }
55
+ });
56
+ var ExecuteQueryInputModel = defineSchemaModel({
57
+ name: "ExecuteQueryInput",
58
+ fields: {
59
+ queryId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
60
+ parameters: { type: ScalarTypeEnum.JSON(), isOptional: true },
61
+ dateRange: { type: ScalarTypeEnum.JSON(), isOptional: true },
62
+ filters: { type: ScalarTypeEnum.JSON(), isOptional: true },
63
+ forceRefresh: { type: ScalarTypeEnum.Boolean(), isOptional: true }
64
+ }
56
65
  });
57
66
 
58
- //#endregion
59
- export { QueriesListPresentation, QueryBuilderPresentation };
60
- //# sourceMappingURL=query.presentation.js.map
67
+ // src/query/query.presentation.ts
68
+ import { definePresentation, StabilityEnum } from "@contractspec/lib.contracts";
69
+ var QueriesListPresentation = definePresentation({
70
+ meta: {
71
+ key: "analytics.query.list",
72
+ version: "1.0.0",
73
+ title: "Queries List",
74
+ description: "List of saved queries",
75
+ domain: "analytics",
76
+ owners: ["@analytics-dashboard"],
77
+ tags: ["analytics", "queries", "list"],
78
+ stability: StabilityEnum.Experimental,
79
+ goal: "Browse and manage saved data queries.",
80
+ context: "The library of reusable data definitions."
81
+ },
82
+ source: {
83
+ type: "component",
84
+ framework: "react",
85
+ componentKey: "QueriesList",
86
+ props: QueryModel
87
+ },
88
+ targets: ["react", "markdown"],
89
+ policy: {
90
+ flags: ["analytics.queries.enabled"]
91
+ }
92
+ });
93
+ var QueryBuilderPresentation = definePresentation({
94
+ meta: {
95
+ key: "analytics.query.builder",
96
+ version: "1.0.0",
97
+ title: "Query Builder",
98
+ description: "Visual query builder interface",
99
+ domain: "analytics",
100
+ owners: ["@analytics-dashboard"],
101
+ tags: ["analytics", "query", "builder"],
102
+ stability: StabilityEnum.Experimental,
103
+ goal: "Visually construct data queries and transformations.",
104
+ context: "Developer tool for data analysis."
105
+ },
106
+ source: {
107
+ type: "component",
108
+ framework: "react",
109
+ componentKey: "QueryBuilder",
110
+ props: QueryModel
111
+ },
112
+ targets: ["react"],
113
+ policy: {
114
+ flags: ["analytics.queries.enabled"]
115
+ }
116
+ });
117
+ export {
118
+ QueryBuilderPresentation,
119
+ QueriesListPresentation
120
+ };