@hasna/logs 0.3.23 → 0.3.24

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 (47) hide show
  1. package/LICENSE +1 -2
  2. package/README.md +3 -22
  3. package/bun.lock +7 -14
  4. package/dist/cli/index.js +2 -2
  5. package/dist/{index-t97ttm0a.js → index-75dwghvv.js} +88 -6
  6. package/dist/{index-1f2ghyhm.js → index-g8f8kep6.js} +93 -8
  7. package/dist/{index-zmayq5kj.js → index-pf8hpweg.js} +2 -2
  8. package/dist/{index-2sbhn1ye.js → index-w24zm361.js} +2 -2
  9. package/dist/mcp/index.js +23801 -8266
  10. package/dist/server/index.js +2 -2
  11. package/package.json +4 -3
  12. package/sdk/package.json +4 -9
  13. package/src/cli/entrypoints.test.ts +1 -1
  14. package/src/db/index.ts +1 -1
  15. package/src/lib/cloud-sync.ts +167 -0
  16. package/src/lib/ingest.ts +3 -3
  17. package/src/lib/remote-storage.ts +45 -0
  18. package/src/mcp/index.ts +30 -34
  19. package/dist/export-yjaar93b.js +0 -10
  20. package/dist/health-9792c1rc.js +0 -8
  21. package/dist/health-egdb00st.js +0 -8
  22. package/dist/http-0wsh40x1.js +0 -1240
  23. package/dist/index-14dvwcf1.js +0 -45
  24. package/dist/index-4ba0sabv.js +0 -1241
  25. package/dist/index-4hj4sakk.js +0 -1241
  26. package/dist/index-5cj74qka.js +0 -10803
  27. package/dist/index-5qwba140.js +0 -1241
  28. package/dist/index-5tvnhvgr.js +0 -536
  29. package/dist/index-6y8pmes4.js +0 -45
  30. package/dist/index-6zrkek5y.js +0 -9454
  31. package/dist/index-7qhh666n.js +0 -1241
  32. package/dist/index-86j0hn03.js +0 -540
  33. package/dist/index-exeq2gs6.js +0 -79
  34. package/dist/index-fzmz9aqs.js +0 -1241
  35. package/dist/index-g8dczzvv.js +0 -30
  36. package/dist/index-hjzbctgt.js +0 -5868
  37. package/dist/index-rbrsvsyh.js +0 -88
  38. package/dist/index-vmr85wa1.js +0 -9579
  39. package/dist/index-wbsq8qjd.js +0 -1241
  40. package/dist/index-xjn8gam3.js +0 -39
  41. package/dist/index-yb8yd4j6.js +0 -39
  42. package/dist/jobs-02z4fzsn.js +0 -22
  43. package/dist/query-6s5gqkck.js +0 -15
  44. package/dist/query-shjjj67k.js +0 -14
  45. package/dist/query-tcg3bm9s.js +0 -14
  46. package/src/mcp/http.test.ts +0 -92
  47. package/src/mcp/http.ts +0 -135
@@ -1,45 +0,0 @@
1
- // @bun
2
- import {
3
- parseTime
4
- } from "./index-997bkzr2.js";
5
-
6
- // src/lib/count.ts
7
- function countLogs(db, opts) {
8
- const conditions = [];
9
- const params = {};
10
- if (opts.project_id) {
11
- conditions.push("project_id = $p");
12
- params.$p = opts.project_id;
13
- }
14
- if (opts.service) {
15
- conditions.push("service = $service");
16
- params.$service = opts.service;
17
- }
18
- if (opts.level) {
19
- conditions.push("level = $level");
20
- params.$level = opts.level;
21
- }
22
- const since = parseTime(opts.since);
23
- const until = parseTime(opts.until);
24
- if (since) {
25
- conditions.push("timestamp >= $since");
26
- params.$since = since;
27
- }
28
- if (until) {
29
- conditions.push("timestamp <= $until");
30
- params.$until = until;
31
- }
32
- const where = conditions.length ? `WHERE ${conditions.join(" AND ")}` : "";
33
- const byLevel = db.prepare(`SELECT level, COUNT(*) as c FROM logs ${where} GROUP BY level`).all(params);
34
- const by_level = Object.fromEntries(byLevel.map((r) => [r.level, r.c]));
35
- const total = byLevel.reduce((s, r) => s + r.c, 0);
36
- return {
37
- total,
38
- errors: by_level["error"] ?? 0,
39
- warns: by_level["warn"] ?? 0,
40
- fatals: by_level["fatal"] ?? 0,
41
- by_level
42
- };
43
- }
44
-
45
- export { countLogs };