@debugkit/dashboard 0.0.0-stage → 0.3.1
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.
- package/.env.example +30 -0
- package/dist/client/assets/_authed-Bi62GTX3.js +7 -0
- package/dist/client/assets/_authed-mWCAMokt.js +1 -0
- package/dist/client/assets/charts-C76vsG2N.js +55 -0
- package/dist/client/assets/index-D7uhDdvA.js +12 -0
- package/dist/client/assets/issues._fingerprint-fVGLnT37.js +1 -0
- package/dist/client/assets/login-MqvT094Y.js +1 -0
- package/dist/client/assets/styles-CZZRuG1z.css +2 -0
- package/dist/client/assets/ui-Bj6uJIr8.js +1 -0
- package/dist/server/assets/_authed-BaehIntL.js +40 -0
- package/dist/server/assets/_authed-ClbGOSDJ.js +484 -0
- package/dist/server/assets/_tanstack-start-manifest_v-eNUCOzFz.js +40 -0
- package/dist/server/assets/charts-CNlV7Pga.js +221 -0
- package/dist/server/assets/demo-DTdlXNgj.js +333 -0
- package/dist/server/assets/dynamodb-DejcakaF.js +187 -0
- package/dist/server/assets/empty-plugin-adapters-BsRz-CQL.js +4 -0
- package/dist/server/assets/firestore-BH-gx9no.js +112 -0
- package/dist/server/assets/fns-CgB12FUN.js +31 -0
- package/dist/server/assets/fns-Yg8sT1Cb.js +87 -0
- package/dist/server/assets/issues._fingerprint-D78dy5os.js +255 -0
- package/dist/server/assets/login-h3B5Vdhl.js +107 -0
- package/dist/server/assets/memory-4DwW5cTO.js +59 -0
- package/dist/server/assets/queries-DIVV-5j6.js +4274 -0
- package/dist/server/assets/rollups-JXbazRNh.js +22 -0
- package/dist/server/assets/router-DqTf7XfT.js +222 -0
- package/dist/server/assets/src-D5jyi_C4.js +235 -0
- package/dist/server/assets/start-t09PGpZL.js +3 -0
- package/dist/server/assets/ui-Lv-KcOoP.js +131 -0
- package/dist/server/server.js +7825 -0
- package/package.json +52 -3
- package/scripts/hash-password.mjs +17 -0
- package/server.mjs +50 -0
- package/README.md +0 -3
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { r as Logo } from "./ui-Lv-KcOoP.js";
|
|
2
|
+
import { a as login } from "./fns-CgB12FUN.js";
|
|
3
|
+
import { i as Route } from "./router-DqTf7XfT.js";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { useRouter } from "@tanstack/react-router";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
// src/routes/login.tsx?tsr-split=component
|
|
8
|
+
function LoginPage() {
|
|
9
|
+
const info = Route.useLoaderData();
|
|
10
|
+
const router = useRouter();
|
|
11
|
+
const [email, setEmail] = useState(info.demo?.email ?? "");
|
|
12
|
+
const [password, setPassword] = useState(info.demo?.password ?? "");
|
|
13
|
+
const [error, setError] = useState(null);
|
|
14
|
+
const [busy, setBusy] = useState(false);
|
|
15
|
+
async function submit(e) {
|
|
16
|
+
e.preventDefault();
|
|
17
|
+
setBusy(true);
|
|
18
|
+
setError(null);
|
|
19
|
+
try {
|
|
20
|
+
const res = await login({ data: {
|
|
21
|
+
email,
|
|
22
|
+
password
|
|
23
|
+
} });
|
|
24
|
+
if (!res.ok) return setError(res.error);
|
|
25
|
+
await router.invalidate();
|
|
26
|
+
await router.navigate({ to: "/" });
|
|
27
|
+
} catch {
|
|
28
|
+
setError("Could not reach the dashboard server.");
|
|
29
|
+
} finally {
|
|
30
|
+
setBusy(false);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return /* @__PURE__ */ jsx("main", {
|
|
34
|
+
className: "flex min-h-screen items-center justify-center px-4",
|
|
35
|
+
children: /* @__PURE__ */ jsxs("form", {
|
|
36
|
+
onSubmit: submit,
|
|
37
|
+
className: "w-full max-w-sm rounded-xl border border-line bg-panel p-6 shadow-sm",
|
|
38
|
+
children: [
|
|
39
|
+
/* @__PURE__ */ jsx(Logo, {}),
|
|
40
|
+
/* @__PURE__ */ jsx("h1", {
|
|
41
|
+
className: "mt-6 text-xl font-semibold",
|
|
42
|
+
children: "Sign in"
|
|
43
|
+
}),
|
|
44
|
+
/* @__PURE__ */ jsxs("p", {
|
|
45
|
+
className: "mt-1 text-sm text-muted",
|
|
46
|
+
children: [
|
|
47
|
+
"This dashboard runs on your infrastructure and reads from your",
|
|
48
|
+
" ",
|
|
49
|
+
info.store === "demo" ? "demo dataset" : info.store === "memory" ? "in-memory store on this machine" : info.store === "firestore" ? "Firestore" : "DynamoDB",
|
|
50
|
+
"."
|
|
51
|
+
]
|
|
52
|
+
}),
|
|
53
|
+
info.demo && /* @__PURE__ */ jsxs("p", {
|
|
54
|
+
className: "mt-4 rounded-md bg-accent-soft px-3 py-2 text-xs text-ink",
|
|
55
|
+
children: [
|
|
56
|
+
"Demo mode: sign in with ",
|
|
57
|
+
/* @__PURE__ */ jsx("b", { children: info.demo.email }),
|
|
58
|
+
" / ",
|
|
59
|
+
/* @__PURE__ */ jsx("b", { children: info.demo.password }),
|
|
60
|
+
". Set ",
|
|
61
|
+
/* @__PURE__ */ jsx("code", { children: "DEBUG_DASHBOARD_USERS" }),
|
|
62
|
+
" to require real accounts."
|
|
63
|
+
]
|
|
64
|
+
}),
|
|
65
|
+
/* @__PURE__ */ jsx("label", {
|
|
66
|
+
className: "mt-5 block text-sm font-medium",
|
|
67
|
+
htmlFor: "email",
|
|
68
|
+
children: "Email"
|
|
69
|
+
}),
|
|
70
|
+
/* @__PURE__ */ jsx("input", {
|
|
71
|
+
id: "email",
|
|
72
|
+
type: "email",
|
|
73
|
+
autoComplete: "username",
|
|
74
|
+
required: true,
|
|
75
|
+
value: email,
|
|
76
|
+
onChange: (e) => setEmail(e.target.value),
|
|
77
|
+
className: "mt-1 w-full rounded-md border border-line bg-bg px-3 py-2 text-sm outline-none focus:border-accent"
|
|
78
|
+
}),
|
|
79
|
+
/* @__PURE__ */ jsx("label", {
|
|
80
|
+
className: "mt-4 block text-sm font-medium",
|
|
81
|
+
htmlFor: "password",
|
|
82
|
+
children: "Password"
|
|
83
|
+
}),
|
|
84
|
+
/* @__PURE__ */ jsx("input", {
|
|
85
|
+
id: "password",
|
|
86
|
+
type: "password",
|
|
87
|
+
autoComplete: "current-password",
|
|
88
|
+
required: true,
|
|
89
|
+
value: password,
|
|
90
|
+
onChange: (e) => setPassword(e.target.value),
|
|
91
|
+
className: "mt-1 w-full rounded-md border border-line bg-bg px-3 py-2 text-sm outline-none focus:border-accent"
|
|
92
|
+
}),
|
|
93
|
+
error && /* @__PURE__ */ jsx("p", {
|
|
94
|
+
role: "alert",
|
|
95
|
+
className: "mt-3 text-sm text-sev-critical",
|
|
96
|
+
children: error
|
|
97
|
+
}),
|
|
98
|
+
/* @__PURE__ */ jsx("button", {
|
|
99
|
+
disabled: busy,
|
|
100
|
+
className: "mt-5 w-full rounded-md bg-ink px-3 py-2 text-sm font-medium text-bg disabled:opacity-60",
|
|
101
|
+
children: busy ? "Signing in…" : "Sign in"
|
|
102
|
+
})
|
|
103
|
+
]
|
|
104
|
+
})
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
export { LoginPage as component };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { n as rollupId, t as coalesceRollups } from "./rollups-JXbazRNh.js";
|
|
2
|
+
// ../../packages/adapters/src/memory.ts
|
|
3
|
+
/** In-process store for tests and the dashboard's demo mode. */
|
|
4
|
+
var MemoryStore = class {
|
|
5
|
+
apps = /* @__PURE__ */ new Set();
|
|
6
|
+
events = [];
|
|
7
|
+
issues = /* @__PURE__ */ new Map();
|
|
8
|
+
rollups = /* @__PURE__ */ new Map();
|
|
9
|
+
async registerApp(app) {
|
|
10
|
+
this.apps.add(app);
|
|
11
|
+
}
|
|
12
|
+
async writeEvents(events) {
|
|
13
|
+
this.events.push(...events);
|
|
14
|
+
}
|
|
15
|
+
async upsertIssues(updates) {
|
|
16
|
+
for (const u of updates) {
|
|
17
|
+
const k = `${u.app}/${u.fingerprint}`;
|
|
18
|
+
const cur = this.issues.get(k);
|
|
19
|
+
this.issues.set(k, {
|
|
20
|
+
app: u.app,
|
|
21
|
+
fingerprint: u.fingerprint,
|
|
22
|
+
title: u.title,
|
|
23
|
+
culprit: u.culprit,
|
|
24
|
+
flow: u.flow,
|
|
25
|
+
firstSeen: cur && cur.firstSeen < u.firstTs ? cur.firstSeen : u.firstTs,
|
|
26
|
+
lastSeen: cur && cur.lastSeen > u.ts ? cur.lastSeen : u.ts,
|
|
27
|
+
count: (cur?.count ?? 0) + u.by,
|
|
28
|
+
lastEvent: cur && cur.lastSeen > u.ts ? cur.lastEvent : u.lastEvent
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async incrementRollups(incs) {
|
|
33
|
+
for (const r of coalesceRollups(incs)) {
|
|
34
|
+
const k = `${r.app}/${rollupId(r)}`;
|
|
35
|
+
const cur = this.rollups.get(k);
|
|
36
|
+
this.rollups.set(k, cur ? {
|
|
37
|
+
...cur,
|
|
38
|
+
errors: cur.errors + r.errors,
|
|
39
|
+
events: cur.events + r.events
|
|
40
|
+
} : r);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async listApps() {
|
|
44
|
+
return [...this.apps].sort();
|
|
45
|
+
}
|
|
46
|
+
async listIssues(app, { limit = 200 } = {}) {
|
|
47
|
+
return [...this.issues.values()].filter((i) => i.app === app).sort((a, b) => b.lastSeen.localeCompare(a.lastSeen)).slice(0, limit);
|
|
48
|
+
}
|
|
49
|
+
async getIssue(app, fp) {
|
|
50
|
+
return this.issues.get(`${app}/${fp}`) ?? null;
|
|
51
|
+
}
|
|
52
|
+
async getRollups(app, dimension, fromDay, toDay) {
|
|
53
|
+
return [...this.rollups.values()].filter((r) => r.app === app && r.dimension === dimension && r.day >= fromDay && r.day <= toDay);
|
|
54
|
+
}
|
|
55
|
+
async listIssueEvents(app, fp, { limit = 50 } = {}) {
|
|
56
|
+
return this.events.filter((e) => e.app === app && e.fingerprint === fp).sort((a, b) => b.event.ts.localeCompare(a.event.ts)).slice(0, limit);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
export { MemoryStore };
|