nuxt-observe 0.0.2

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 (435) hide show
  1. package/README.md +92 -0
  2. package/dist/module.d.mts +7 -0
  3. package/dist/module.json +9 -0
  4. package/dist/module.mjs +393 -0
  5. package/dist/runtime/app/assets/css/main.css +1 -0
  6. package/dist/runtime/app/components/ObserveActivityFeed.d.vue.ts +13 -0
  7. package/dist/runtime/app/components/ObserveActivityFeed.vue +77 -0
  8. package/dist/runtime/app/components/ObserveActivityFeed.vue.d.ts +13 -0
  9. package/dist/runtime/app/components/ObserveActivityTable.d.vue.ts +30 -0
  10. package/dist/runtime/app/components/ObserveActivityTable.vue +187 -0
  11. package/dist/runtime/app/components/ObserveActivityTable.vue.d.ts +30 -0
  12. package/dist/runtime/app/components/ObserveCan.d.vue.ts +27 -0
  13. package/dist/runtime/app/components/ObserveCan.vue +16 -0
  14. package/dist/runtime/app/components/ObserveCan.vue.d.ts +27 -0
  15. package/dist/runtime/app/components/ObserveErrorsTable.d.vue.ts +19 -0
  16. package/dist/runtime/app/components/ObserveErrorsTable.vue +105 -0
  17. package/dist/runtime/app/components/ObserveErrorsTable.vue.d.ts +19 -0
  18. package/dist/runtime/app/components/ObserveHealthHero.d.vue.ts +16 -0
  19. package/dist/runtime/app/components/ObserveHealthHero.vue +114 -0
  20. package/dist/runtime/app/components/ObserveHealthHero.vue.d.ts +16 -0
  21. package/dist/runtime/app/components/ObserveJourneySearch.d.vue.ts +13 -0
  22. package/dist/runtime/app/components/ObserveJourneySearch.vue +55 -0
  23. package/dist/runtime/app/components/ObserveJourneySearch.vue.d.ts +13 -0
  24. package/dist/runtime/app/components/ObserveJourneyTimeline.d.vue.ts +14 -0
  25. package/dist/runtime/app/components/ObserveJourneyTimeline.vue +119 -0
  26. package/dist/runtime/app/components/ObserveJourneyTimeline.vue.d.ts +14 -0
  27. package/dist/runtime/app/components/ObserveLogDetail.d.vue.ts +12 -0
  28. package/dist/runtime/app/components/ObserveLogDetail.vue +187 -0
  29. package/dist/runtime/app/components/ObserveLogDetail.vue.d.ts +12 -0
  30. package/dist/runtime/app/components/ObserveLogLevelBadge.d.vue.ts +10 -0
  31. package/dist/runtime/app/components/ObserveLogLevelBadge.vue +29 -0
  32. package/dist/runtime/app/components/ObserveLogLevelBadge.vue.d.ts +10 -0
  33. package/dist/runtime/app/components/ObserveLogsFilterBar.d.vue.ts +20 -0
  34. package/dist/runtime/app/components/ObserveLogsFilterBar.vue +134 -0
  35. package/dist/runtime/app/components/ObserveLogsFilterBar.vue.d.ts +20 -0
  36. package/dist/runtime/app/components/ObserveLogsTable.d.vue.ts +20 -0
  37. package/dist/runtime/app/components/ObserveLogsTable.vue +92 -0
  38. package/dist/runtime/app/components/ObserveLogsTable.vue.d.ts +20 -0
  39. package/dist/runtime/app/components/ObservePeriodSelector.d.vue.ts +3 -0
  40. package/dist/runtime/app/components/ObservePeriodSelector.vue +22 -0
  41. package/dist/runtime/app/components/ObservePeriodSelector.vue.d.ts +3 -0
  42. package/dist/runtime/app/components/ObserveRegressionAlert.d.vue.ts +12 -0
  43. package/dist/runtime/app/components/ObserveRegressionAlert.vue +27 -0
  44. package/dist/runtime/app/components/ObserveRegressionAlert.vue.d.ts +12 -0
  45. package/dist/runtime/app/components/ObserveServiceSwitcher.d.vue.ts +3 -0
  46. package/dist/runtime/app/components/ObserveServiceSwitcher.vue +49 -0
  47. package/dist/runtime/app/components/ObserveServiceSwitcher.vue.d.ts +3 -0
  48. package/dist/runtime/app/components/ObserveServicesTable.d.vue.ts +15 -0
  49. package/dist/runtime/app/components/ObserveServicesTable.vue +109 -0
  50. package/dist/runtime/app/components/ObserveServicesTable.vue.d.ts +15 -0
  51. package/dist/runtime/app/components/ObserveStatCard.d.vue.ts +14 -0
  52. package/dist/runtime/app/components/ObserveStatCard.vue +34 -0
  53. package/dist/runtime/app/components/ObserveStatCard.vue.d.ts +14 -0
  54. package/dist/runtime/app/components/charts/ObserveErrorRateChart.client.d.vue.ts +15 -0
  55. package/dist/runtime/app/components/charts/ObserveErrorRateChart.client.vue +170 -0
  56. package/dist/runtime/app/components/charts/ObserveErrorRateChart.client.vue.d.ts +15 -0
  57. package/dist/runtime/app/components/charts/ObserveServiceBreakdownChart.client.d.vue.ts +17 -0
  58. package/dist/runtime/app/components/charts/ObserveServiceBreakdownChart.client.vue +208 -0
  59. package/dist/runtime/app/components/charts/ObserveServiceBreakdownChart.client.vue.d.ts +17 -0
  60. package/dist/runtime/app/components/charts/ObserveVersionAdoptionChart.client.d.vue.ts +14 -0
  61. package/dist/runtime/app/components/charts/ObserveVersionAdoptionChart.client.vue +208 -0
  62. package/dist/runtime/app/components/charts/ObserveVersionAdoptionChart.client.vue.d.ts +14 -0
  63. package/dist/runtime/app/components/charts/ObserveVersionCompareChart.client.d.vue.ts +14 -0
  64. package/dist/runtime/app/components/charts/ObserveVersionCompareChart.client.vue +190 -0
  65. package/dist/runtime/app/components/charts/ObserveVersionCompareChart.client.vue.d.ts +14 -0
  66. package/dist/runtime/app/components/charts/ObserveVolumeChart.client.d.vue.ts +16 -0
  67. package/dist/runtime/app/components/charts/ObserveVolumeChart.client.vue +199 -0
  68. package/dist/runtime/app/components/charts/ObserveVolumeChart.client.vue.d.ts +16 -0
  69. package/dist/runtime/app/components/charts/chart-core.d.ts +64 -0
  70. package/dist/runtime/app/components/charts/chart-core.js +136 -0
  71. package/dist/runtime/app/components/settings/ObserveApiKeyPanel.d.vue.ts +8 -0
  72. package/dist/runtime/app/components/settings/ObserveApiKeyPanel.vue +145 -0
  73. package/dist/runtime/app/components/settings/ObserveApiKeyPanel.vue.d.ts +8 -0
  74. package/dist/runtime/app/components/settings/ObserveApiKeyRevealModal.d.vue.ts +19 -0
  75. package/dist/runtime/app/components/settings/ObserveApiKeyRevealModal.vue +106 -0
  76. package/dist/runtime/app/components/settings/ObserveApiKeyRevealModal.vue.d.ts +19 -0
  77. package/dist/runtime/app/components/settings/ObserveAssignmentEditor.d.vue.ts +12 -0
  78. package/dist/runtime/app/components/settings/ObserveAssignmentEditor.vue +67 -0
  79. package/dist/runtime/app/components/settings/ObserveAssignmentEditor.vue.d.ts +12 -0
  80. package/dist/runtime/app/components/settings/ObserveGroupFormModal.d.vue.ts +18 -0
  81. package/dist/runtime/app/components/settings/ObserveGroupFormModal.vue +60 -0
  82. package/dist/runtime/app/components/settings/ObserveGroupFormModal.vue.d.ts +18 -0
  83. package/dist/runtime/app/components/settings/ObserveGroupMembershipEditor.d.vue.ts +20 -0
  84. package/dist/runtime/app/components/settings/ObserveGroupMembershipEditor.vue +21 -0
  85. package/dist/runtime/app/components/settings/ObserveGroupMembershipEditor.vue.d.ts +20 -0
  86. package/dist/runtime/app/components/settings/ObserveOriginAllowlistEditor.d.vue.ts +15 -0
  87. package/dist/runtime/app/components/settings/ObserveOriginAllowlistEditor.vue +63 -0
  88. package/dist/runtime/app/components/settings/ObserveOriginAllowlistEditor.vue.d.ts +15 -0
  89. package/dist/runtime/app/components/settings/ObserveServiceEditForm.d.vue.ts +38 -0
  90. package/dist/runtime/app/components/settings/ObserveServiceEditForm.vue +216 -0
  91. package/dist/runtime/app/components/settings/ObserveServiceEditForm.vue.d.ts +38 -0
  92. package/dist/runtime/app/components/settings/ObserveServiceFormModal.d.vue.ts +37 -0
  93. package/dist/runtime/app/components/settings/ObserveServiceFormModal.vue +192 -0
  94. package/dist/runtime/app/components/settings/ObserveServiceFormModal.vue.d.ts +37 -0
  95. package/dist/runtime/app/components/settings/ObserveServiceTypeBadge.d.vue.ts +11 -0
  96. package/dist/runtime/app/components/settings/ObserveServiceTypeBadge.vue +18 -0
  97. package/dist/runtime/app/components/settings/ObserveServiceTypeBadge.vue.d.ts +11 -0
  98. package/dist/runtime/app/components/settings/ObserveSettingsServicesTable.d.vue.ts +19 -0
  99. package/dist/runtime/app/components/settings/ObserveSettingsServicesTable.vue +132 -0
  100. package/dist/runtime/app/components/settings/ObserveSettingsServicesTable.vue.d.ts +19 -0
  101. package/dist/runtime/app/components/settings/ObserveUserFormModal.d.vue.ts +27 -0
  102. package/dist/runtime/app/components/settings/ObserveUserFormModal.vue +108 -0
  103. package/dist/runtime/app/components/settings/ObserveUserFormModal.vue.d.ts +27 -0
  104. package/dist/runtime/app/components/settings/ObserveVersionTrackingField.d.vue.ts +17 -0
  105. package/dist/runtime/app/components/settings/ObserveVersionTrackingField.vue +20 -0
  106. package/dist/runtime/app/components/settings/ObserveVersionTrackingField.vue.d.ts +17 -0
  107. package/dist/runtime/app/composables/useObserveAbility.d.ts +15 -0
  108. package/dist/runtime/app/composables/useObserveAbility.js +20 -0
  109. package/dist/runtime/app/composables/useObserveActivity.d.ts +22 -0
  110. package/dist/runtime/app/composables/useObserveActivity.js +44 -0
  111. package/dist/runtime/app/composables/useObserveApiKeys.d.ts +15 -0
  112. package/dist/runtime/app/composables/useObserveApiKeys.js +19 -0
  113. package/dist/runtime/app/composables/useObserveAssignments.d.ts +19 -0
  114. package/dist/runtime/app/composables/useObserveAssignments.js +16 -0
  115. package/dist/runtime/app/composables/useObserveErrors.d.ts +33 -0
  116. package/dist/runtime/app/composables/useObserveErrors.js +85 -0
  117. package/dist/runtime/app/composables/useObserveGroups.d.ts +27 -0
  118. package/dist/runtime/app/composables/useObserveGroups.js +33 -0
  119. package/dist/runtime/app/composables/useObserveJourney.d.ts +19 -0
  120. package/dist/runtime/app/composables/useObserveJourney.js +19 -0
  121. package/dist/runtime/app/composables/useObserveLogFacets.d.ts +11 -0
  122. package/dist/runtime/app/composables/useObserveLogFacets.js +21 -0
  123. package/dist/runtime/app/composables/useObserveLogs.d.ts +28 -0
  124. package/dist/runtime/app/composables/useObserveLogs.js +100 -0
  125. package/dist/runtime/app/composables/useObserveMigrations.d.ts +17 -0
  126. package/dist/runtime/app/composables/useObserveMigrations.js +49 -0
  127. package/dist/runtime/app/composables/useObserveOverview.d.ts +14 -0
  128. package/dist/runtime/app/composables/useObserveOverview.js +23 -0
  129. package/dist/runtime/app/composables/useObservePeriod.d.ts +11 -0
  130. package/dist/runtime/app/composables/useObservePeriod.js +18 -0
  131. package/dist/runtime/app/composables/useObserveRollout.d.ts +20 -0
  132. package/dist/runtime/app/composables/useObserveRollout.js +55 -0
  133. package/dist/runtime/app/composables/useObserveScope.d.ts +13 -0
  134. package/dist/runtime/app/composables/useObserveScope.js +17 -0
  135. package/dist/runtime/app/composables/useObserveServices.d.ts +26 -0
  136. package/dist/runtime/app/composables/useObserveServices.js +33 -0
  137. package/dist/runtime/app/composables/useObserveStats.d.ts +14 -0
  138. package/dist/runtime/app/composables/useObserveStats.js +23 -0
  139. package/dist/runtime/app/composables/useObserveUsers.d.ts +29 -0
  140. package/dist/runtime/app/composables/useObserveUsers.js +33 -0
  141. package/dist/runtime/app/layouts/observe.d.vue.ts +13 -0
  142. package/dist/runtime/app/layouts/observe.vue +138 -0
  143. package/dist/runtime/app/layouts/observe.vue.d.ts +13 -0
  144. package/dist/runtime/app/middleware/observe-auth.global.d.ts +9 -0
  145. package/dist/runtime/app/middleware/observe-auth.global.js +8 -0
  146. package/dist/runtime/app/pages/activity.d.vue.ts +3 -0
  147. package/dist/runtime/app/pages/activity.vue +54 -0
  148. package/dist/runtime/app/pages/activity.vue.d.ts +3 -0
  149. package/dist/runtime/app/pages/error-detail.d.vue.ts +3 -0
  150. package/dist/runtime/app/pages/error-detail.vue +190 -0
  151. package/dist/runtime/app/pages/error-detail.vue.d.ts +3 -0
  152. package/dist/runtime/app/pages/errors.d.vue.ts +3 -0
  153. package/dist/runtime/app/pages/errors.vue +47 -0
  154. package/dist/runtime/app/pages/errors.vue.d.ts +3 -0
  155. package/dist/runtime/app/pages/journey.d.vue.ts +3 -0
  156. package/dist/runtime/app/pages/journey.vue +96 -0
  157. package/dist/runtime/app/pages/journey.vue.d.ts +3 -0
  158. package/dist/runtime/app/pages/log-detail.d.vue.ts +3 -0
  159. package/dist/runtime/app/pages/log-detail.vue +35 -0
  160. package/dist/runtime/app/pages/log-detail.vue.d.ts +3 -0
  161. package/dist/runtime/app/pages/login.d.vue.ts +3 -0
  162. package/dist/runtime/app/pages/login.vue +69 -0
  163. package/dist/runtime/app/pages/login.vue.d.ts +3 -0
  164. package/dist/runtime/app/pages/logs.d.vue.ts +3 -0
  165. package/dist/runtime/app/pages/logs.vue +36 -0
  166. package/dist/runtime/app/pages/logs.vue.d.ts +3 -0
  167. package/dist/runtime/app/pages/metrics.d.vue.ts +3 -0
  168. package/dist/runtime/app/pages/metrics.vue +68 -0
  169. package/dist/runtime/app/pages/metrics.vue.d.ts +3 -0
  170. package/dist/runtime/app/pages/overview.d.vue.ts +3 -0
  171. package/dist/runtime/app/pages/overview.vue +65 -0
  172. package/dist/runtime/app/pages/overview.vue.d.ts +3 -0
  173. package/dist/runtime/app/pages/rollout.d.vue.ts +3 -0
  174. package/dist/runtime/app/pages/rollout.vue +188 -0
  175. package/dist/runtime/app/pages/rollout.vue.d.ts +3 -0
  176. package/dist/runtime/app/pages/settings/group-detail.d.vue.ts +3 -0
  177. package/dist/runtime/app/pages/settings/group-detail.vue +149 -0
  178. package/dist/runtime/app/pages/settings/group-detail.vue.d.ts +3 -0
  179. package/dist/runtime/app/pages/settings/groups.d.vue.ts +3 -0
  180. package/dist/runtime/app/pages/settings/groups.vue +107 -0
  181. package/dist/runtime/app/pages/settings/groups.vue.d.ts +3 -0
  182. package/dist/runtime/app/pages/settings/index.d.vue.ts +3 -0
  183. package/dist/runtime/app/pages/settings/index.vue +47 -0
  184. package/dist/runtime/app/pages/settings/index.vue.d.ts +3 -0
  185. package/dist/runtime/app/pages/settings/migrations.d.vue.ts +3 -0
  186. package/dist/runtime/app/pages/settings/migrations.vue +275 -0
  187. package/dist/runtime/app/pages/settings/migrations.vue.d.ts +3 -0
  188. package/dist/runtime/app/pages/settings/service-detail.d.vue.ts +3 -0
  189. package/dist/runtime/app/pages/settings/service-detail.vue +133 -0
  190. package/dist/runtime/app/pages/settings/service-detail.vue.d.ts +3 -0
  191. package/dist/runtime/app/pages/settings/services.d.vue.ts +3 -0
  192. package/dist/runtime/app/pages/settings/services.vue +66 -0
  193. package/dist/runtime/app/pages/settings/services.vue.d.ts +3 -0
  194. package/dist/runtime/app/pages/settings/users/[id].d.vue.ts +3 -0
  195. package/dist/runtime/app/pages/settings/users/[id].vue +243 -0
  196. package/dist/runtime/app/pages/settings/users/[id].vue.d.ts +3 -0
  197. package/dist/runtime/app/pages/settings/users/index.d.vue.ts +3 -0
  198. package/dist/runtime/app/pages/settings/users/index.vue +129 -0
  199. package/dist/runtime/app/pages/settings/users/index.vue.d.ts +3 -0
  200. package/dist/runtime/options.d.ts +1 -0
  201. package/dist/runtime/options.js +1 -0
  202. package/dist/runtime/server/api/observe/activity.get.d.ts +3 -0
  203. package/dist/runtime/server/api/observe/activity.get.js +30 -0
  204. package/dist/runtime/server/api/observe/auth/login.post.d.ts +4 -0
  205. package/dist/runtime/server/api/observe/auth/login.post.js +13 -0
  206. package/dist/runtime/server/api/observe/auth/logout.post.d.ts +4 -0
  207. package/dist/runtime/server/api/observe/auth/logout.post.js +6 -0
  208. package/dist/runtime/server/api/observe/auth/me.get.d.ts +2 -0
  209. package/dist/runtime/server/api/observe/auth/me.get.js +3 -0
  210. package/dist/runtime/server/api/observe/errors/[fingerprint].get.d.ts +3 -0
  211. package/dist/runtime/server/api/observe/errors/[fingerprint].get.js +56 -0
  212. package/dist/runtime/server/api/observe/errors/index.get.d.ts +3 -0
  213. package/dist/runtime/server/api/observe/errors/index.get.js +41 -0
  214. package/dist/runtime/server/api/observe/facets.get.d.ts +8 -0
  215. package/dist/runtime/server/api/observe/facets.get.js +12 -0
  216. package/dist/runtime/server/api/observe/groups/[id]/assignments.put.d.ts +3 -0
  217. package/dist/runtime/server/api/observe/groups/[id]/assignments.put.js +12 -0
  218. package/dist/runtime/server/api/observe/groups/[id]/services.put.d.ts +5 -0
  219. package/dist/runtime/server/api/observe/groups/[id]/services.put.js +13 -0
  220. package/dist/runtime/server/api/observe/groups/[id].delete.d.ts +5 -0
  221. package/dist/runtime/server/api/observe/groups/[id].delete.js +11 -0
  222. package/dist/runtime/server/api/observe/groups/[id].get.d.ts +6 -0
  223. package/dist/runtime/server/api/observe/groups/[id].get.js +14 -0
  224. package/dist/runtime/server/api/observe/groups/[id].patch.d.ts +3 -0
  225. package/dist/runtime/server/api/observe/groups/[id].patch.js +12 -0
  226. package/dist/runtime/server/api/observe/groups/index.get.d.ts +3 -0
  227. package/dist/runtime/server/api/observe/groups/index.get.js +7 -0
  228. package/dist/runtime/server/api/observe/groups/index.post.d.ts +3 -0
  229. package/dist/runtime/server/api/observe/groups/index.post.js +11 -0
  230. package/dist/runtime/server/api/observe/health.get.d.ts +6 -0
  231. package/dist/runtime/server/api/observe/health.get.js +10 -0
  232. package/dist/runtime/server/api/observe/ingest/frogger.d.ts +5 -0
  233. package/dist/runtime/server/api/observe/ingest/frogger.js +42 -0
  234. package/dist/runtime/server/api/observe/ingest.d.ts +5 -0
  235. package/dist/runtime/server/api/observe/ingest.js +38 -0
  236. package/dist/runtime/server/api/observe/journey.get.d.ts +9 -0
  237. package/dist/runtime/server/api/observe/journey.get.js +31 -0
  238. package/dist/runtime/server/api/observe/logs/[id].get.d.ts +3 -0
  239. package/dist/runtime/server/api/observe/logs/[id].get.js +19 -0
  240. package/dist/runtime/server/api/observe/logs.get.d.ts +3 -0
  241. package/dist/runtime/server/api/observe/logs.get.js +54 -0
  242. package/dist/runtime/server/api/observe/migrations/index.get.d.ts +9 -0
  243. package/dist/runtime/server/api/observe/migrations/index.get.js +14 -0
  244. package/dist/runtime/server/api/observe/migrations/run.post.d.ts +13 -0
  245. package/dist/runtime/server/api/observe/migrations/run.post.js +35 -0
  246. package/dist/runtime/server/api/observe/overview.get.d.ts +3 -0
  247. package/dist/runtime/server/api/observe/overview.get.js +19 -0
  248. package/dist/runtime/server/api/observe/rollout/compare.get.d.ts +3 -0
  249. package/dist/runtime/server/api/observe/rollout/compare.get.js +24 -0
  250. package/dist/runtime/server/api/observe/rollout/regressions.get.d.ts +3 -0
  251. package/dist/runtime/server/api/observe/rollout/regressions.get.js +31 -0
  252. package/dist/runtime/server/api/observe/rollout/versions.get.d.ts +3 -0
  253. package/dist/runtime/server/api/observe/rollout/versions.get.js +20 -0
  254. package/dist/runtime/server/api/observe/services/[id]/assignments.put.d.ts +7 -0
  255. package/dist/runtime/server/api/observe/services/[id]/assignments.put.js +12 -0
  256. package/dist/runtime/server/api/observe/services/[id]/keys/[keyId]/rotate.post.d.ts +4 -0
  257. package/dist/runtime/server/api/observe/services/[id]/keys/[keyId]/rotate.post.js +14 -0
  258. package/dist/runtime/server/api/observe/services/[id]/keys/[keyId].delete.d.ts +4 -0
  259. package/dist/runtime/server/api/observe/services/[id]/keys/[keyId].delete.js +14 -0
  260. package/dist/runtime/server/api/observe/services/[id]/keys/index.get.d.ts +3 -0
  261. package/dist/runtime/server/api/observe/services/[id]/keys/index.get.js +10 -0
  262. package/dist/runtime/server/api/observe/services/[id]/keys/index.post.d.ts +3 -0
  263. package/dist/runtime/server/api/observe/services/[id]/keys/index.post.js +11 -0
  264. package/dist/runtime/server/api/observe/services/[id]/restore.post.d.ts +4 -0
  265. package/dist/runtime/server/api/observe/services/[id]/restore.post.js +11 -0
  266. package/dist/runtime/server/api/observe/services/[id].delete.d.ts +11 -0
  267. package/dist/runtime/server/api/observe/services/[id].delete.js +11 -0
  268. package/dist/runtime/server/api/observe/services/[id].get.d.ts +3 -0
  269. package/dist/runtime/server/api/observe/services/[id].get.js +12 -0
  270. package/dist/runtime/server/api/observe/services/[id].patch.d.ts +3 -0
  271. package/dist/runtime/server/api/observe/services/[id].patch.js +13 -0
  272. package/dist/runtime/server/api/observe/services/index.get.d.ts +3 -0
  273. package/dist/runtime/server/api/observe/services/index.get.js +7 -0
  274. package/dist/runtime/server/api/observe/services/index.post.d.ts +3 -0
  275. package/dist/runtime/server/api/observe/services/index.post.js +16 -0
  276. package/dist/runtime/server/api/observe/stats.get.d.ts +3 -0
  277. package/dist/runtime/server/api/observe/stats.get.js +28 -0
  278. package/dist/runtime/server/api/observe/users/[id]/assignments.put.d.ts +3 -0
  279. package/dist/runtime/server/api/observe/users/[id]/assignments.put.js +14 -0
  280. package/dist/runtime/server/api/observe/users/[id].delete.d.ts +4 -0
  281. package/dist/runtime/server/api/observe/users/[id].delete.js +15 -0
  282. package/dist/runtime/server/api/observe/users/[id].get.d.ts +3 -0
  283. package/dist/runtime/server/api/observe/users/[id].get.js +11 -0
  284. package/dist/runtime/server/api/observe/users/[id].patch.d.ts +3 -0
  285. package/dist/runtime/server/api/observe/users/[id].patch.js +25 -0
  286. package/dist/runtime/server/api/observe/users/index.get.d.ts +8 -0
  287. package/dist/runtime/server/api/observe/users/index.get.js +7 -0
  288. package/dist/runtime/server/api/observe/users/index.post.d.ts +3 -0
  289. package/dist/runtime/server/api/observe/users/index.post.js +29 -0
  290. package/dist/runtime/server/auth/authorization.d.ts +7 -0
  291. package/dist/runtime/server/auth/authorization.js +5 -0
  292. package/dist/runtime/server/auth/provider.d.ts +17 -0
  293. package/dist/runtime/server/auth/provider.js +44 -0
  294. package/dist/runtime/server/auth/providers/config-provider.d.ts +18 -0
  295. package/dist/runtime/server/auth/providers/config-provider.js +54 -0
  296. package/dist/runtime/server/auth/providers/db-provider.d.ts +16 -0
  297. package/dist/runtime/server/auth/providers/db-provider.js +42 -0
  298. package/dist/runtime/server/auth/providers/jwt-provider.d.ts +24 -0
  299. package/dist/runtime/server/auth/providers/jwt-provider.js +72 -0
  300. package/dist/runtime/server/migrations/0001-services-kind.d.ts +8 -0
  301. package/dist/runtime/server/migrations/0001-services-kind.js +14 -0
  302. package/dist/runtime/server/migrations/0002-services-type.d.ts +7 -0
  303. package/dist/runtime/server/migrations/0002-services-type.js +14 -0
  304. package/dist/runtime/server/migrations/0003-services-deleted-at.d.ts +6 -0
  305. package/dist/runtime/server/migrations/0003-services-deleted-at.js +14 -0
  306. package/dist/runtime/server/migrations/0004-logs-error-fingerprint.d.ts +11 -0
  307. package/dist/runtime/server/migrations/0004-logs-error-fingerprint.js +15 -0
  308. package/dist/runtime/server/migrations/0005-users-columns.d.ts +9 -0
  309. package/dist/runtime/server/migrations/0005-users-columns.js +25 -0
  310. package/dist/runtime/server/migrations/index.d.ts +13 -0
  311. package/dist/runtime/server/migrations/index.js +13 -0
  312. package/dist/runtime/server/migrations/types.d.ts +15 -0
  313. package/dist/runtime/server/migrations/types.js +0 -0
  314. package/dist/runtime/server/plugins/observe-migrate.server.d.ts +2 -0
  315. package/dist/runtime/server/plugins/observe-migrate.server.js +18 -0
  316. package/dist/runtime/server/tasks/backfill-fingerprints.d.ts +11 -0
  317. package/dist/runtime/server/tasks/backfill-fingerprints.js +41 -0
  318. package/dist/runtime/server/tasks/purge.d.ts +5 -0
  319. package/dist/runtime/server/tasks/purge.js +12 -0
  320. package/dist/runtime/server/tsconfig.json +3 -0
  321. package/dist/runtime/server/utils/activity-query.d.ts +28 -0
  322. package/dist/runtime/server/utils/activity-query.js +70 -0
  323. package/dist/runtime/server/utils/api-keys.d.ts +48 -0
  324. package/dist/runtime/server/utils/api-keys.js +67 -0
  325. package/dist/runtime/server/utils/authz.d.ts +50 -0
  326. package/dist/runtime/server/utils/authz.js +60 -0
  327. package/dist/runtime/server/utils/db/users.d.ts +91 -0
  328. package/dist/runtime/server/utils/db/users.js +128 -0
  329. package/dist/runtime/server/utils/db.d.ts +10 -0
  330. package/dist/runtime/server/utils/db.js +5 -0
  331. package/dist/runtime/server/utils/frogger-adapter.d.ts +40 -0
  332. package/dist/runtime/server/utils/frogger-adapter.js +97 -0
  333. package/dist/runtime/server/utils/groups.d.ts +35 -0
  334. package/dist/runtime/server/utils/groups.js +59 -0
  335. package/dist/runtime/server/utils/ingest-cors.d.ts +23 -0
  336. package/dist/runtime/server/utils/ingest-cors.js +27 -0
  337. package/dist/runtime/server/utils/journey.d.ts +20 -0
  338. package/dist/runtime/server/utils/journey.js +44 -0
  339. package/dist/runtime/server/utils/logs.d.ts +50 -0
  340. package/dist/runtime/server/utils/logs.js +154 -0
  341. package/dist/runtime/server/utils/loop-guard.d.ts +11 -0
  342. package/dist/runtime/server/utils/loop-guard.js +11 -0
  343. package/dist/runtime/server/utils/migrate.d.ts +21 -0
  344. package/dist/runtime/server/utils/migrate.js +144 -0
  345. package/dist/runtime/server/utils/migration-runner.d.ts +42 -0
  346. package/dist/runtime/server/utils/migration-runner.js +129 -0
  347. package/dist/runtime/server/utils/observe-errors.d.ts +58 -0
  348. package/dist/runtime/server/utils/observe-errors.js +206 -0
  349. package/dist/runtime/server/utils/overview.d.ts +20 -0
  350. package/dist/runtime/server/utils/overview.js +119 -0
  351. package/dist/runtime/server/utils/provisioning.d.ts +62 -0
  352. package/dist/runtime/server/utils/provisioning.js +299 -0
  353. package/dist/runtime/server/utils/rate-limit.d.ts +11 -0
  354. package/dist/runtime/server/utils/rate-limit.js +22 -0
  355. package/dist/runtime/server/utils/require-observe-session.d.ts +15 -0
  356. package/dist/runtime/server/utils/require-observe-session.js +25 -0
  357. package/dist/runtime/server/utils/rollout.d.ts +19 -0
  358. package/dist/runtime/server/utils/rollout.js +56 -0
  359. package/dist/runtime/server/utils/scope.d.ts +14 -0
  360. package/dist/runtime/server/utils/scope.js +28 -0
  361. package/dist/runtime/server/utils/seed.d.ts +18 -0
  362. package/dist/runtime/server/utils/seed.js +70 -0
  363. package/dist/runtime/server/utils/services.d.ts +91 -0
  364. package/dist/runtime/server/utils/services.js +142 -0
  365. package/dist/runtime/server/utils/stats-query.d.ts +40 -0
  366. package/dist/runtime/server/utils/stats-query.js +104 -0
  367. package/dist/runtime/shared/auth/roles.d.ts +34 -0
  368. package/dist/runtime/shared/auth/roles.js +6 -0
  369. package/dist/runtime/shared/auth/schema.d.ts +85 -0
  370. package/dist/runtime/shared/auth/schema.js +41 -0
  371. package/dist/runtime/shared/auth/types.d.ts +68 -0
  372. package/dist/runtime/shared/auth/types.js +0 -0
  373. package/dist/runtime/shared/rbac/capabilities.d.ts +46 -0
  374. package/dist/runtime/shared/rbac/capabilities.js +48 -0
  375. package/dist/runtime/shared/schema/activity.d.ts +77 -0
  376. package/dist/runtime/shared/schema/activity.js +22 -0
  377. package/dist/runtime/shared/schema/adapters/frogger.d.ts +52 -0
  378. package/dist/runtime/shared/schema/adapters/frogger.js +17 -0
  379. package/dist/runtime/shared/schema/batch.d.ts +33 -0
  380. package/dist/runtime/shared/schema/batch.js +9 -0
  381. package/dist/runtime/shared/schema/error-fingerprint.d.ts +53 -0
  382. package/dist/runtime/shared/schema/error-fingerprint.js +47 -0
  383. package/dist/runtime/shared/schema/errors-query.d.ts +136 -0
  384. package/dist/runtime/shared/schema/errors-query.js +47 -0
  385. package/dist/runtime/shared/schema/event.d.ts +48 -0
  386. package/dist/runtime/shared/schema/event.js +41 -0
  387. package/dist/runtime/shared/schema/frogger-map.d.ts +62 -0
  388. package/dist/runtime/shared/schema/frogger-map.js +30 -0
  389. package/dist/runtime/shared/schema/index.d.ts +17 -0
  390. package/dist/runtime/shared/schema/index.js +17 -0
  391. package/dist/runtime/shared/schema/journey.d.ts +99 -0
  392. package/dist/runtime/shared/schema/journey.js +96 -0
  393. package/dist/runtime/shared/schema/levels.d.ts +37 -0
  394. package/dist/runtime/shared/schema/levels.js +72 -0
  395. package/dist/runtime/shared/schema/log-row.d.ts +31 -0
  396. package/dist/runtime/shared/schema/log-row.js +0 -0
  397. package/dist/runtime/shared/schema/logs-query.d.ts +91 -0
  398. package/dist/runtime/shared/schema/logs-query.js +72 -0
  399. package/dist/runtime/shared/schema/migrations.d.ts +34 -0
  400. package/dist/runtime/shared/schema/migrations.js +0 -0
  401. package/dist/runtime/shared/schema/overview.d.ts +78 -0
  402. package/dist/runtime/shared/schema/overview.js +9 -0
  403. package/dist/runtime/shared/schema/provisioning.d.ts +230 -0
  404. package/dist/runtime/shared/schema/provisioning.js +52 -0
  405. package/dist/runtime/shared/schema/registry.d.ts +115 -0
  406. package/dist/runtime/shared/schema/registry.js +27 -0
  407. package/dist/runtime/shared/schema/rollout.d.ts +103 -0
  408. package/dist/runtime/shared/schema/rollout.js +66 -0
  409. package/dist/runtime/shared/schema/stats.d.ts +64 -0
  410. package/dist/runtime/shared/schema/stats.js +15 -0
  411. package/dist/runtime/shared/schema/tiers.d.ts +5 -0
  412. package/dist/runtime/shared/schema/tiers.js +9 -0
  413. package/dist/runtime/shared/types/module-options.d.ts +119 -0
  414. package/dist/runtime/shared/types/module-options.js +13 -0
  415. package/dist/runtime/shared/types/storage.d.ts +31 -0
  416. package/dist/runtime/shared/types/storage.js +0 -0
  417. package/dist/runtime/shared/utils/format-relative.d.ts +7 -0
  418. package/dist/runtime/shared/utils/format-relative.js +11 -0
  419. package/dist/runtime/shared/utils/frogger-snippet.d.ts +19 -0
  420. package/dist/runtime/shared/utils/frogger-snippet.js +33 -0
  421. package/dist/runtime/shared/utils/observe-config.d.ts +9 -0
  422. package/dist/runtime/shared/utils/observe-config.js +17 -0
  423. package/dist/runtime/shared/utils/period.d.ts +13 -0
  424. package/dist/runtime/shared/utils/period.js +15 -0
  425. package/dist/runtime/shared/utils/slug.d.ts +1 -0
  426. package/dist/runtime/shared/utils/slug.js +5 -0
  427. package/dist/runtime/shared/utils/uuid.d.ts +187 -0
  428. package/dist/runtime/shared/utils/uuid.js +345 -0
  429. package/dist/runtime/types/nuxt-auth-utils-imports.d.ts +25 -0
  430. package/dist/runtime/types/observe-app-imports.d.ts +20 -0
  431. package/dist/runtime/types/session.d.ts +17 -0
  432. package/dist/schema.d.mts +1318 -0
  433. package/dist/schema.mjs +629 -0
  434. package/dist/types.d.mts +3 -0
  435. package/package.json +93 -0
@@ -0,0 +1,129 @@
1
+ import { createHash } from "node:crypto";
2
+ import { copyFileSync } from "node:fs";
3
+ import { MIGRATIONS } from "../migrations/index.js";
4
+ export function computeChecksum(m) {
5
+ return createHash("sha1").update(m.up.toString()).digest("hex");
6
+ }
7
+ function sortById(migrations) {
8
+ return [...migrations].sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
9
+ }
10
+ async function readLedger(db) {
11
+ const rows = await db.prepare(
12
+ "SELECT id, class, checksum, applied_at, duration_ms FROM schema_migrations"
13
+ ).all();
14
+ return new Map(rows.map((r) => [r.id, r]));
15
+ }
16
+ export async function getMigrationStatus(db, migrations = MIGRATIONS) {
17
+ const ledger = await readLedger(db);
18
+ const sorted = sortById(migrations);
19
+ const out = [];
20
+ let sawPendingDestructive = false;
21
+ for (const m of sorted) {
22
+ const row = ledger.get(m.id);
23
+ if (row) {
24
+ out.push({
25
+ id: m.id,
26
+ class: m.class,
27
+ description: m.description,
28
+ state: "applied",
29
+ applied_at: row.applied_at,
30
+ driftWarning: row.checksum !== computeChecksum(m)
31
+ });
32
+ continue;
33
+ }
34
+ if (sawPendingDestructive) {
35
+ out.push({ id: m.id, class: m.class, description: m.description, state: "blocked" });
36
+ continue;
37
+ }
38
+ out.push({ id: m.id, class: m.class, description: m.description, state: "pending" });
39
+ if (m.class === "destructive") sawPendingDestructive = true;
40
+ }
41
+ return out;
42
+ }
43
+ let _adminRunLock = false;
44
+ async function recordLedger(db, m, appliedAt, durationMs) {
45
+ await db.sql`
46
+ INSERT INTO schema_migrations (id, class, checksum, applied_at, duration_ms)
47
+ VALUES (${m.id}, ${m.class}, ${computeChecksum(m)}, ${appliedAt}, ${durationMs})
48
+ `;
49
+ }
50
+ function backupDatabase(dbPath, firstDestructiveId, log) {
51
+ if (!dbPath || dbPath === ":memory:") {
52
+ log(`[backup] skipped (no on-disk database path)`);
53
+ return;
54
+ }
55
+ const dest = `${dbPath}.bak-${firstDestructiveId}-${Date.now()}`;
56
+ copyFileSync(dbPath, dest);
57
+ log(`[backup] ${dest}`);
58
+ }
59
+ export async function runPendingMigrations(db, opts) {
60
+ const log = opts.log ?? ((line) => console.log("[observe:migrate]", line));
61
+ const registry = opts.migrations ?? MIGRATIONS;
62
+ if (opts.mode === "admin") {
63
+ if (_adminRunLock) {
64
+ log("[fail] another migration run is already in progress");
65
+ return { applied: [], skipped: [], failedAt: "__locked__" };
66
+ }
67
+ _adminRunLock = true;
68
+ }
69
+ try {
70
+ const sorted = sortById(registry);
71
+ const ledger = await readLedger(db);
72
+ const pendingOrdered = sorted.filter((m) => !ledger.has(m.id));
73
+ let targets;
74
+ if (opts.mode === "boot") {
75
+ targets = [];
76
+ for (const m of pendingOrdered) {
77
+ if (m.class === "destructive") break;
78
+ targets.push(m);
79
+ }
80
+ } else {
81
+ if (opts.ids && opts.ids.length) {
82
+ const known = new Set(sorted.map((m) => m.id));
83
+ const unknown = opts.ids.find((id) => !known.has(id));
84
+ if (unknown) {
85
+ log(`[fail] unknown migration id: ${unknown}`);
86
+ return { applied: [], skipped: [], failedAt: unknown };
87
+ }
88
+ const requested = new Set(opts.ids);
89
+ targets = pendingOrdered.filter((m) => requested.has(m.id));
90
+ const expected = pendingOrdered.slice(0, targets.length);
91
+ const outOfOrder = targets.find((m, i) => expected[i]?.id !== m.id);
92
+ if (outOfOrder) {
93
+ log(`[fail] cannot run ${outOfOrder.id} out of order; an earlier pending migration must run first`);
94
+ return { applied: [], skipped: [], failedAt: outOfOrder.id };
95
+ }
96
+ } else {
97
+ targets = pendingOrdered;
98
+ }
99
+ }
100
+ const applied = [];
101
+ const skipped = sorted.filter((m) => !targets.includes(m) && !ledger.has(m.id)).map((m) => m.id);
102
+ let backedUp = false;
103
+ for (const m of targets) {
104
+ if (m.class === "destructive" && !backedUp) {
105
+ backupDatabase(opts.dbPath, m.id, log);
106
+ backedUp = true;
107
+ }
108
+ const start = Date.now();
109
+ log(`[run] ${m.id} ${m.description}`);
110
+ try {
111
+ await db.sql`BEGIN`;
112
+ await m.up(db, log);
113
+ await recordLedger(db, m, Date.now(), Date.now() - start);
114
+ await db.sql`COMMIT`;
115
+ applied.push(m.id);
116
+ log(`[ok] ${m.id} (${Date.now() - start}ms)`);
117
+ } catch (e) {
118
+ await db.sql`ROLLBACK`.catch(() => {
119
+ });
120
+ const message = e instanceof Error ? e.message : String(e);
121
+ log(`[fail] ${m.id}: ${message}`);
122
+ return { applied, skipped, failedAt: m.id };
123
+ }
124
+ }
125
+ return { applied, skipped };
126
+ } finally {
127
+ if (opts.mode === "admin") _adminRunLock = false;
128
+ }
129
+ }
@@ -0,0 +1,58 @@
1
+ import type { LogListItem } from '../../shared/schema/logs-query.js';
2
+ import type { StatsBucket } from '../../shared/schema/stats.js';
3
+ import { type ErrorGroup, type ErrorGroupHeader, type ErrorVersionBreakdown, type ErrorServiceBreakdown, type ErrorSort, type RegressionThresholds } from '../../shared/schema/errors-query.js';
4
+ import { type Database } from './db.js';
5
+ /**
6
+ * CP14 error-grouping aggregates behind GET /api/observe/errors + /errors/:fingerprint.
7
+ * Same contract as getStats / getVersionSummary: both builders take a RESOLVED scope
8
+ * (string[] | '*'), not an event - the handler runs requireCapability /
9
+ * getAllowedServiceIds / resolveEffectiveScope first - so these stay pure and
10
+ * node-testable via `opts.db`. Scope is applied as `service_id IN (...)`: '*' = no
11
+ * restriction; an empty list short-circuits before touching the db. worst_level is
12
+ * MIN(level) because 0 = error is the MOST severe (CP14 §1.1). The regression flag is
13
+ * computed in JS from conditional aggregates, never stored (CP14 §6).
14
+ */
15
+ interface DbOpts {
16
+ db?: Database;
17
+ }
18
+ export interface ErrorFilters {
19
+ app?: string;
20
+ version?: string;
21
+ env?: string;
22
+ level?: number;
23
+ q?: string;
24
+ }
25
+ export interface ListErrorGroupsParams {
26
+ from: number;
27
+ to: number;
28
+ limit: number;
29
+ offset: number;
30
+ sort: ErrorSort;
31
+ filters?: ErrorFilters;
32
+ thresholds: RegressionThresholds;
33
+ now: number;
34
+ }
35
+ export interface GetErrorGroupParams {
36
+ from: number;
37
+ to: number;
38
+ bucketMs: number;
39
+ limit: number;
40
+ offset: number;
41
+ thresholds: RegressionThresholds;
42
+ now: number;
43
+ }
44
+ export interface ErrorGroupDetail {
45
+ header: ErrorGroupHeader;
46
+ bucketMs: number;
47
+ series: StatsBucket[];
48
+ versions: ErrorVersionBreakdown[];
49
+ services: ErrorServiceBreakdown[];
50
+ occurrences: LogListItem[];
51
+ occurrencesTotal: number;
52
+ }
53
+ export declare function listErrorGroups(params: ListErrorGroupsParams, scope: string[] | '*', opts?: DbOpts): Promise<{
54
+ groups: ErrorGroup[];
55
+ total: number;
56
+ }>;
57
+ export declare function getErrorGroup(fingerprint: string, params: GetErrorGroupParams, scope: string[] | '*', opts?: DbOpts): Promise<ErrorGroupDetail | null>;
58
+ export {};
@@ -0,0 +1,206 @@
1
+ import {
2
+ isRegressed,
3
+ splitConcat,
4
+ NULL_VERSION
5
+ } from "../../shared/schema/errors-query.js";
6
+ import { zeroFilledBuckets } from "./stats-query.js";
7
+ import { queryLogs, countLogs, escapeLike } from "./logs.js";
8
+ import { useObserveDb } from "./db.js";
9
+ const ORDER_BY = {
10
+ recent: "last_seen DESC",
11
+ count: "count DESC, last_seen DESC",
12
+ first: "first_seen DESC"
13
+ };
14
+ function scopeClause(scope, column = "service_id") {
15
+ return scope === "*" ? { clause: "", params: [] } : { clause: `AND ${column} IN (${scope.map(() => "?").join(",")})`, params: [...scope] };
16
+ }
17
+ function filterClause(filters) {
18
+ if (!filters) return { clause: "", params: [] };
19
+ const conds = [];
20
+ const params = [];
21
+ const eq = (col, val) => {
22
+ if (val !== void 0 && val !== null) {
23
+ conds.push(`AND ${col} = ?`);
24
+ params.push(val);
25
+ }
26
+ };
27
+ eq("app", filters.app);
28
+ eq("version", filters.version);
29
+ eq("env", filters.env);
30
+ eq("level", filters.level);
31
+ if (filters.q) {
32
+ conds.push(`AND error_message LIKE ? ESCAPE '\\'`);
33
+ params.push(`%${escapeLike(filters.q)}%`);
34
+ }
35
+ return { clause: conds.join(" "), params };
36
+ }
37
+ function toListItem(row) {
38
+ return {
39
+ id: row.id,
40
+ time: row.time,
41
+ level: row.level,
42
+ message: row.message,
43
+ app: row.app,
44
+ version: row.version ?? null,
45
+ env: row.env ?? null,
46
+ service_id: row.service_id ?? null,
47
+ route: row.route ?? null,
48
+ feature: row.feature ?? null,
49
+ error_name: row.error_name ?? null,
50
+ trace_id: row.trace_id ?? null
51
+ };
52
+ }
53
+ export async function listErrorGroups(params, scope, opts = {}) {
54
+ if (scope !== "*" && scope.length === 0) return { groups: [], total: 0 };
55
+ const db = opts.db ?? useObserveDb();
56
+ const { from, to, limit, offset, sort, filters, thresholds, now } = params;
57
+ const activeStart = now - thresholds.activeWindowMs;
58
+ const scoped = scopeClause(scope);
59
+ const filt = filterClause(filters);
60
+ const where = `WHERE error_fingerprint IS NOT NULL AND time >= ? AND time <= ? ${scoped.clause} ${filt.clause}`;
61
+ const whereParams = [from, to, ...scoped.params, ...filt.params];
62
+ const rows = await db.prepare(
63
+ `SELECT error_fingerprint,
64
+ COUNT(*) AS count,
65
+ MIN(time) AS first_seen,
66
+ MAX(time) AS last_seen,
67
+ MIN(level) AS worst_level,
68
+ COUNT(DISTINCT app) AS service_count,
69
+ GROUP_CONCAT(DISTINCT app) AS apps,
70
+ GROUP_CONCAT(DISTINCT version) AS versions,
71
+ MIN(CASE WHEN time >= ? THEN time END) AS first_in_active,
72
+ MAX(CASE WHEN time < ? THEN time END) AS prev_before_active
73
+ FROM logs ${where}
74
+ GROUP BY error_fingerprint
75
+ ORDER BY ${ORDER_BY[sort]}
76
+ LIMIT ? OFFSET ?`
77
+ ).all(activeStart, activeStart, ...whereParams, limit, offset);
78
+ const totalRow = await db.prepare(
79
+ `SELECT COUNT(*) AS n FROM (SELECT 1 FROM logs ${where} GROUP BY error_fingerprint)`
80
+ ).get(...whereParams);
81
+ const fps = rows.map((r) => r.error_fingerprint);
82
+ const repr = /* @__PURE__ */ new Map();
83
+ if (fps.length) {
84
+ const reprRows = await db.prepare(
85
+ `SELECT error_fingerprint, error_name, error_message, error_code
86
+ FROM logs
87
+ WHERE id IN (
88
+ SELECT MAX(id) FROM logs
89
+ WHERE error_fingerprint IN (${fps.map(() => "?").join(",")}) AND time >= ? AND time <= ? ${scoped.clause} ${filt.clause}
90
+ GROUP BY error_fingerprint
91
+ )`
92
+ ).all(...fps, from, to, ...scoped.params, ...filt.params);
93
+ for (const r of reprRows) repr.set(r.error_fingerprint, r);
94
+ }
95
+ const groups = rows.map((r) => {
96
+ const rep = repr.get(r.error_fingerprint);
97
+ return {
98
+ fingerprint: r.error_fingerprint,
99
+ count: r.count,
100
+ firstSeen: r.first_seen,
101
+ lastSeen: r.last_seen,
102
+ worstLevel: r.worst_level,
103
+ serviceCount: r.service_count,
104
+ apps: splitConcat(r.apps),
105
+ versions: splitConcat(r.versions),
106
+ name: rep?.error_name ?? null,
107
+ message: rep?.error_message ?? null,
108
+ regressed: isRegressed(
109
+ { lastSeen: r.last_seen, firstInActive: r.first_in_active, prevBeforeActive: r.prev_before_active },
110
+ thresholds,
111
+ now
112
+ )
113
+ };
114
+ });
115
+ return { groups, total: totalRow.n };
116
+ }
117
+ export async function getErrorGroup(fingerprint, params, scope, opts = {}) {
118
+ if (scope !== "*" && scope.length === 0) return null;
119
+ const db = opts.db ?? useObserveDb();
120
+ const { from, to, bucketMs, limit, offset, thresholds, now } = params;
121
+ const activeStart = now - thresholds.activeWindowMs;
122
+ const scoped = scopeClause(scope);
123
+ const base = `WHERE error_fingerprint = ? AND time >= ? AND time <= ? ${scoped.clause}`;
124
+ const baseParams = [fingerprint, from, to, ...scoped.params];
125
+ const agg = await db.prepare(
126
+ `SELECT COUNT(*) AS count,
127
+ MIN(time) AS first_seen,
128
+ MAX(time) AS last_seen,
129
+ MIN(level) AS worst_level,
130
+ COUNT(DISTINCT app) AS service_count,
131
+ GROUP_CONCAT(DISTINCT app) AS apps,
132
+ GROUP_CONCAT(DISTINCT version) AS versions,
133
+ MIN(CASE WHEN time >= ? THEN time END) AS first_in_active,
134
+ MAX(CASE WHEN time < ? THEN time END) AS prev_before_active
135
+ FROM logs ${base}`
136
+ ).get(activeStart, activeStart, ...baseParams);
137
+ if (!agg || agg.count === 0) return null;
138
+ const rep = await db.prepare(
139
+ `SELECT error_name, error_message, error_code FROM logs
140
+ WHERE id = (SELECT MAX(id) FROM logs ${base})`
141
+ ).get(...baseParams);
142
+ const header = {
143
+ fingerprint,
144
+ count: agg.count,
145
+ firstSeen: agg.first_seen,
146
+ lastSeen: agg.last_seen,
147
+ worstLevel: agg.worst_level,
148
+ serviceCount: agg.service_count,
149
+ apps: splitConcat(agg.apps),
150
+ versions: splitConcat(agg.versions),
151
+ name: rep?.error_name ?? null,
152
+ message: rep?.error_message ?? null,
153
+ code: rep?.error_code ?? null,
154
+ regressed: isRegressed(
155
+ { lastSeen: agg.last_seen, firstInActive: agg.first_in_active, prevBeforeActive: agg.prev_before_active },
156
+ thresholds,
157
+ now
158
+ )
159
+ };
160
+ const seriesRows = await db.prepare(
161
+ `SELECT CAST(time / ? AS INTEGER) AS b, COUNT(*) AS count, SUM(level = 0) AS errorCount
162
+ FROM logs ${base}
163
+ GROUP BY b ORDER BY b`
164
+ ).all(bucketMs, ...baseParams);
165
+ const series = zeroFilledBuckets(from, to, bucketMs);
166
+ const bFrom = Math.floor(from / bucketMs);
167
+ for (const row of seriesRows) {
168
+ const bucket = series[row.b - bFrom];
169
+ if (!bucket) continue;
170
+ bucket.count += row.count;
171
+ bucket.errorCount += row.errorCount ?? 0;
172
+ }
173
+ const versionRows = await db.prepare(
174
+ `SELECT COALESCE(version, '${NULL_VERSION}') AS version, COUNT(*) AS count
175
+ FROM logs ${base}
176
+ GROUP BY COALESCE(version, '${NULL_VERSION}') ORDER BY count DESC`
177
+ ).all(...baseParams);
178
+ const versions = versionRows.map((r) => ({ version: r.version, count: r.count }));
179
+ const svcScoped = scopeClause(scope, "l.service_id");
180
+ const serviceRows = await db.prepare(
181
+ `SELECT l.service_id AS serviceId, s.slug AS slug, s.name AS name, COUNT(*) AS count
182
+ FROM logs l LEFT JOIN services s ON s.id = l.service_id
183
+ WHERE l.error_fingerprint = ? AND l.time >= ? AND l.time <= ? ${svcScoped.clause}
184
+ GROUP BY l.service_id ORDER BY count DESC`
185
+ ).all(fingerprint, from, to, ...svcScoped.params);
186
+ const services = serviceRows.map((r) => ({
187
+ serviceId: r.serviceId,
188
+ slug: r.slug,
189
+ name: r.name,
190
+ count: r.count
191
+ }));
192
+ const occFilter = { errorFingerprint: fingerprint, from, to, serviceIds: scope, order: "desc", limit, offset };
193
+ const [occRows, occurrencesTotal] = await Promise.all([
194
+ queryLogs(occFilter, { db }),
195
+ countLogs(occFilter, { db })
196
+ ]);
197
+ return {
198
+ header,
199
+ bucketMs,
200
+ series,
201
+ versions,
202
+ services,
203
+ occurrences: occRows.map(toListItem),
204
+ occurrencesTotal
205
+ };
206
+ }
@@ -0,0 +1,20 @@
1
+ import type { OverviewData } from '../../shared/schema/overview.js';
2
+ import { type Database } from './db.js';
3
+ /**
4
+ * CP7 overview aggregates. Owns its SQL outright (no CP5 query layer exists — see
5
+ * docs/internals/roadmap.md: analytical helpers live with the dashboard checkpoints
6
+ * whose UI drives their shape). Takes a RESOLVED scope (string[] | '*'), not an event:
7
+ * the handler runs requireCapability/getAllowedServiceIds first, so this stays pure
8
+ * and node-testable via `opts.db` like the CP2/CP3 helpers.
9
+ *
10
+ * Every query rides idx_logs_service_time when scoped (idx_logs_time/level_time for
11
+ * admin) and parameterises every value — the scope IN (...) placeholder count always
12
+ * equals the id count.
13
+ */
14
+ interface DbOpts {
15
+ db?: Database;
16
+ }
17
+ /** Zeroed response slice for an empty scope; never touches the db. */
18
+ export declare function emptyOverview(): OverviewData;
19
+ export declare function getOverview(scope: string[] | '*', from: number, to: number, opts?: DbOpts): Promise<OverviewData>;
20
+ export {};
@@ -0,0 +1,119 @@
1
+ import { useObserveDb } from "./db.js";
2
+ export function emptyOverview() {
3
+ return {
4
+ stats: {
5
+ totalEvents: 0,
6
+ errorCount: 0,
7
+ errorRate: 0,
8
+ warnCount: 0,
9
+ activeServices: 0,
10
+ activeVersions: 0
11
+ },
12
+ services: [],
13
+ activity: []
14
+ };
15
+ }
16
+ export async function getOverview(scope, from, to, opts = {}) {
17
+ if (scope !== "*" && scope.length === 0) return emptyOverview();
18
+ const db = opts.db ?? useObserveDb();
19
+ const scoped = scope === "*" ? { clause: "", params: [] } : { clause: `AND service_id IN (${scope.map(() => "?").join(",")})`, params: [...scope] };
20
+ const timeAndScope = `WHERE time >= ? AND time <= ? ${scoped.clause}`;
21
+ const base = [from, to, ...scoped.params];
22
+ const scalars = await db.prepare(
23
+ `SELECT COUNT(*) AS total,
24
+ SUM(level = 0) AS errorCount,
25
+ SUM(level = 1) AS warnCount,
26
+ COUNT(DISTINCT service_id) AS activeServices,
27
+ COUNT(DISTINCT version) AS activeVersions
28
+ FROM logs ${timeAndScope}`
29
+ ).get(...base);
30
+ const latestError = await db.prepare(
31
+ `SELECT time, message, error_name AS name, service_id, app, route, trace_id AS traceId
32
+ FROM logs ${timeAndScope} AND level = 0
33
+ ORDER BY time DESC LIMIT 1`
34
+ ).get(...base);
35
+ const rollups = await db.prepare(
36
+ `SELECT service_id, MAX(app) AS app, COUNT(*) AS total,
37
+ SUM(level = 0) AS errorCount, SUM(level = 1) AS warnCount, MAX(time) AS lastSeen
38
+ FROM logs ${timeAndScope}
39
+ GROUP BY service_id`
40
+ ).all(...base);
41
+ const versionRows = await db.prepare(
42
+ `SELECT service_id, version FROM logs ${timeAndScope} AND version IS NOT NULL
43
+ GROUP BY service_id, version`
44
+ ).all(...base);
45
+ const activityRows = await db.prepare(
46
+ `SELECT time, level, message, service_id, app, route, session,
47
+ user_id AS user, trace_id AS traceId, error_name AS errorName
48
+ FROM logs ${timeAndScope}
49
+ ORDER BY time DESC LIMIT 50`
50
+ ).all(...base);
51
+ const idSet = /* @__PURE__ */ new Set();
52
+ for (const r of [...rollups, ...activityRows]) {
53
+ if (r.service_id) idSet.add(r.service_id);
54
+ }
55
+ if (latestError?.service_id) idSet.add(latestError.service_id);
56
+ const ids = [...idSet];
57
+ const displayRows = ids.length ? await db.prepare(
58
+ `SELECT id, slug, name, env FROM services WHERE id IN (${ids.map(() => "?").join(",")})`
59
+ ).all(...ids) : [];
60
+ const display = new Map(displayRows.map((r) => [r.id, r]));
61
+ const serviceLabel = (serviceId, app) => (serviceId ? display.get(serviceId)?.slug : void 0) ?? app ?? "unknown";
62
+ const versionsByService = /* @__PURE__ */ new Map();
63
+ for (const v of versionRows) {
64
+ if (!v.service_id) continue;
65
+ const list = versionsByService.get(v.service_id) ?? [];
66
+ list.push(v.version);
67
+ versionsByService.set(v.service_id, list);
68
+ }
69
+ const services = rollups.filter((r) => r.service_id !== null).map((r) => {
70
+ const d = display.get(r.service_id);
71
+ const errorCount2 = r.errorCount ?? 0;
72
+ return {
73
+ id: r.service_id,
74
+ slug: d?.slug ?? r.app ?? r.service_id,
75
+ name: d?.name ?? r.app ?? r.service_id,
76
+ ...d?.env ? { env: d.env } : {},
77
+ totalEvents: r.total,
78
+ errorCount: errorCount2,
79
+ errorRate: r.total ? errorCount2 / r.total : 0,
80
+ warnCount: r.warnCount ?? 0,
81
+ lastSeen: r.lastSeen,
82
+ versions: versionsByService.get(r.service_id) ?? []
83
+ };
84
+ });
85
+ const activity = activityRows.map((r) => ({
86
+ time: r.time,
87
+ level: r.level,
88
+ message: r.message ?? "",
89
+ service: serviceLabel(r.service_id, r.app),
90
+ ...r.route ? { route: r.route } : {},
91
+ ...r.session ? { session: r.session } : {},
92
+ ...r.user ? { user: r.user } : {},
93
+ ...r.traceId ? { traceId: r.traceId } : {},
94
+ ...r.errorName ? { errorName: r.errorName } : {}
95
+ }));
96
+ const errorCount = scalars.errorCount ?? 0;
97
+ return {
98
+ stats: {
99
+ totalEvents: scalars.total,
100
+ errorCount,
101
+ errorRate: scalars.total ? errorCount / scalars.total : 0,
102
+ warnCount: scalars.warnCount ?? 0,
103
+ activeServices: scalars.activeServices,
104
+ activeVersions: scalars.activeVersions,
105
+ ...latestError ? {
106
+ latestError: {
107
+ time: latestError.time,
108
+ message: latestError.message ?? "",
109
+ ...latestError.name ? { name: latestError.name } : {},
110
+ service: serviceLabel(latestError.service_id, latestError.app),
111
+ ...latestError.route ? { route: latestError.route } : {},
112
+ ...latestError.traceId ? { traceId: latestError.traceId } : {}
113
+ }
114
+ } : {}
115
+ },
116
+ services,
117
+ activity
118
+ };
119
+ }
@@ -0,0 +1,62 @@
1
+ import { type H3Event } from 'h3';
2
+ import type { Principal } from '../../shared/auth/types.js';
3
+ import type { ServiceCreate, ServiceUpdate, ServiceListItem, ServiceDetail, KeyMeta, MintedKey, GroupListItem, UserPick, UserDetail } from '../../shared/schema/provisioning.js';
4
+ import { SERVICE_DELETE_RETENTION_MS } from './services.js';
5
+ import { type GroupRow } from './groups.js';
6
+ import { type Database } from './db.js';
7
+ /**
8
+ * Thin orchestration layer over the CP2/CP6/CP10.5 helpers (services/groups/api-keys/authz).
9
+ * It maps DB rows to the framework-free wire shapes in shared/schema/provisioning.ts and
10
+ * never re-implements the underlying SQL. All DB access stays in server/utils/* so the
11
+ * experimental sqlite layer can be swapped later.
12
+ */
13
+ export { SERVICE_DELETE_RETENTION_MS };
14
+ interface Ctx {
15
+ db?: Database;
16
+ }
17
+ /**
18
+ * Scoped service list for the provisioning table. Soft-deleted services are INCLUDED
19
+ * (so the UI can render a countdown + restore) but sorted to the bottom. keyCount is an
20
+ * active-key count via a correlated subquery, avoiding an N+1 over api_keys.
21
+ */
22
+ export declare function listServicesForPrincipal(event: H3Event, principal: Principal, ctx?: Ctx): Promise<ServiceListItem[]>;
23
+ export declare function getServiceDetail(id: string, ctx?: Ctx): Promise<ServiceDetail | null>;
24
+ export declare function createServiceFromInput(input: ServiceCreate, principal: Principal, ctx?: Ctx): Promise<ServiceDetail>;
25
+ export declare function updateServiceFromInput(id: string, patch: ServiceUpdate, ctx?: Ctx): Promise<ServiceDetail | null>;
26
+ export declare function softDeleteServiceById(id: string, ctx?: Ctx): Promise<{
27
+ deletedAt: number;
28
+ purgeAt: number;
29
+ } | null>;
30
+ export declare function restoreServiceById(id: string, ctx?: Ctx): Promise<ServiceDetail | null>;
31
+ export declare function listKeyMeta(serviceId: string, ctx?: Ctx): Promise<KeyMeta[]>;
32
+ export declare function mintKey(event: H3Event, serviceId: string, label: string, ctx?: Ctx): Promise<MintedKey>;
33
+ export declare function rotateKey(event: H3Event, serviceId: string, oldKeyId: string, label: string, ctx?: Ctx): Promise<MintedKey>;
34
+ export declare function revokeKey(keyId: string, ctx?: Ctx): Promise<void>;
35
+ /** Guard: does this key belong to this service? (routes assert scope on the service, then this on the key). */
36
+ export declare function keyBelongsToService(keyId: string, serviceId: string, ctx?: Ctx): Promise<boolean>;
37
+ export declare function listGroupsForPrincipal(event: H3Event, principal: Principal, ctx?: Ctx): Promise<GroupListItem[]>;
38
+ export declare function createGroupFromInput(name: string, ctx?: Ctx): Promise<{
39
+ ok: true;
40
+ group: GroupRow;
41
+ } | {
42
+ ok: false;
43
+ conflict: true;
44
+ }>;
45
+ export declare function updateGroupById(id: string, name: string, ctx?: Ctx): Promise<GroupRow | null>;
46
+ export declare function deleteGroupById(id: string, ctx?: Ctx): Promise<boolean>;
47
+ /**
48
+ * Reconcile a group's membership to exactly `serviceIds` (direct services.group_id FK):
49
+ * detach the removed, attach the added, in one transaction.
50
+ */
51
+ export declare function setGroupMembership(groupId: string, serviceIds: string[], ctx?: Ctx): Promise<void>;
52
+ export declare function getGroupDetail(id: string, ctx?: Ctx): Promise<{
53
+ group: GroupRow;
54
+ services: ServiceListItem[];
55
+ } | null>;
56
+ /** Config-seeded users (observe.auth.users). The list surface while the config provider is active. */
57
+ export declare function listUsers(): UserPick[];
58
+ /** True when the DB provider is the active primary (drives the /users data-source switch). */
59
+ export declare function isDbProviderActive(): boolean;
60
+ /** DB-backed users -> UserPick[] (same wire shape as listUsers, slug assignment). */
61
+ export declare function listDbUsers(ctx?: Ctx): Promise<UserPick[]>;
62
+ export declare function getUserDetail(id: string, ctx?: Ctx): Promise<UserDetail | null>;