@rudderjs/telescope 0.0.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/LICENSE +21 -0
- package/README.md +111 -0
- package/boost/guidelines.md +38 -0
- package/dist/api/routes.d.ts +7 -0
- package/dist/api/routes.d.ts.map +1 -0
- package/dist/api/routes.js +99 -0
- package/dist/api/routes.js.map +1 -0
- package/dist/collectors/cache.d.ts +13 -0
- package/dist/collectors/cache.d.ts.map +1 -0
- package/dist/collectors/cache.js +48 -0
- package/dist/collectors/cache.js.map +1 -0
- package/dist/collectors/event.d.ts +13 -0
- package/dist/collectors/event.d.ts.map +1 -0
- package/dist/collectors/event.js +36 -0
- package/dist/collectors/event.js.map +1 -0
- package/dist/collectors/exception.d.ts +13 -0
- package/dist/collectors/exception.d.ts.map +1 -0
- package/dist/collectors/exception.js +38 -0
- package/dist/collectors/exception.js.map +1 -0
- package/dist/collectors/job.d.ts +12 -0
- package/dist/collectors/job.d.ts.map +1 -0
- package/dist/collectors/job.js +53 -0
- package/dist/collectors/job.js.map +1 -0
- package/dist/collectors/log.d.ts +13 -0
- package/dist/collectors/log.d.ts.map +1 -0
- package/dist/collectors/log.js +35 -0
- package/dist/collectors/log.js.map +1 -0
- package/dist/collectors/mail.d.ts +12 -0
- package/dist/collectors/mail.d.ts.map +1 -0
- package/dist/collectors/mail.js +38 -0
- package/dist/collectors/mail.js.map +1 -0
- package/dist/collectors/model.d.ts +15 -0
- package/dist/collectors/model.d.ts.map +1 -0
- package/dist/collectors/model.js +49 -0
- package/dist/collectors/model.js.map +1 -0
- package/dist/collectors/notification.d.ts +12 -0
- package/dist/collectors/notification.d.ts.map +1 -0
- package/dist/collectors/notification.js +41 -0
- package/dist/collectors/notification.js.map +1 -0
- package/dist/collectors/query.d.ts +13 -0
- package/dist/collectors/query.d.ts.map +1 -0
- package/dist/collectors/query.js +45 -0
- package/dist/collectors/query.js.map +1 -0
- package/dist/collectors/request.d.ts +20 -0
- package/dist/collectors/request.d.ts.map +1 -0
- package/dist/collectors/request.js +73 -0
- package/dist/collectors/request.js.map +1 -0
- package/dist/collectors/schedule.d.ts +14 -0
- package/dist/collectors/schedule.d.ts.map +1 -0
- package/dist/collectors/schedule.js +50 -0
- package/dist/collectors/schedule.js.map +1 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +170 -0
- package/dist/index.js.map +1 -0
- package/dist/storage.d.ts +35 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +201 -0
- package/dist/storage.js.map +1 -0
- package/dist/types.d.ts +67 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +24 -0
- package/dist/types.js.map +1 -0
- package/dist/ui/layout.d.ts +11 -0
- package/dist/ui/layout.d.ts.map +1 -0
- package/dist/ui/layout.js +69 -0
- package/dist/ui/layout.js.map +1 -0
- package/dist/ui/pages.d.ts +21 -0
- package/dist/ui/pages.d.ts.map +1 -0
- package/dist/ui/pages.js +225 -0
- package/dist/ui/pages.js.map +1 -0
- package/package.json +78 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { ServiceProvider } from '@rudderjs/core';
|
|
2
|
+
import { MemoryStorage, SqliteStorage } from './storage.js';
|
|
3
|
+
import { RequestCollector } from './collectors/request.js';
|
|
4
|
+
import { QueryCollector } from './collectors/query.js';
|
|
5
|
+
import { JobCollector } from './collectors/job.js';
|
|
6
|
+
import { ExceptionCollector } from './collectors/exception.js';
|
|
7
|
+
import { LogCollector } from './collectors/log.js';
|
|
8
|
+
import { MailCollector } from './collectors/mail.js';
|
|
9
|
+
import { NotificationCollector } from './collectors/notification.js';
|
|
10
|
+
import { EventCollector } from './collectors/event.js';
|
|
11
|
+
import { CacheCollector } from './collectors/cache.js';
|
|
12
|
+
import { ScheduleCollector } from './collectors/schedule.js';
|
|
13
|
+
import { ModelCollector } from './collectors/model.js';
|
|
14
|
+
import { registerRoutes } from './api/routes.js';
|
|
15
|
+
import { defaultConfig } from './types.js';
|
|
16
|
+
export { MemoryStorage, SqliteStorage, createEntry } from './storage.js';
|
|
17
|
+
export { RequestCollector } from './collectors/request.js';
|
|
18
|
+
export { QueryCollector } from './collectors/query.js';
|
|
19
|
+
export { JobCollector } from './collectors/job.js';
|
|
20
|
+
export { ExceptionCollector } from './collectors/exception.js';
|
|
21
|
+
export { LogCollector } from './collectors/log.js';
|
|
22
|
+
export { MailCollector } from './collectors/mail.js';
|
|
23
|
+
export { NotificationCollector } from './collectors/notification.js';
|
|
24
|
+
export { EventCollector } from './collectors/event.js';
|
|
25
|
+
export { CacheCollector } from './collectors/cache.js';
|
|
26
|
+
export { ScheduleCollector } from './collectors/schedule.js';
|
|
27
|
+
export { ModelCollector } from './collectors/model.js';
|
|
28
|
+
// ─── Telescope Registry ────────────────────────────────────
|
|
29
|
+
export class TelescopeRegistry {
|
|
30
|
+
static storage = null;
|
|
31
|
+
static set(storage) { this.storage = storage; }
|
|
32
|
+
static get() { return this.storage; }
|
|
33
|
+
/** @internal — clears the registered storage. Used for testing. */
|
|
34
|
+
static reset() { this.storage = null; }
|
|
35
|
+
}
|
|
36
|
+
// ─── Telescope Facade ──────────────────────────────────────
|
|
37
|
+
export class Telescope {
|
|
38
|
+
static store() {
|
|
39
|
+
const s = TelescopeRegistry.get();
|
|
40
|
+
if (!s)
|
|
41
|
+
throw new Error('[RudderJS Telescope] No storage registered. Add telescope() to providers.');
|
|
42
|
+
return s;
|
|
43
|
+
}
|
|
44
|
+
static list(options = {}) {
|
|
45
|
+
return this.store().list(options);
|
|
46
|
+
}
|
|
47
|
+
static find(id) {
|
|
48
|
+
return this.store().find(id);
|
|
49
|
+
}
|
|
50
|
+
static count(type) {
|
|
51
|
+
return this.store().count(type);
|
|
52
|
+
}
|
|
53
|
+
static prune(type) {
|
|
54
|
+
return this.store().prune(type);
|
|
55
|
+
}
|
|
56
|
+
static record(entry) {
|
|
57
|
+
return this.store().store(entry);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// ─── Service Provider Factory ──────────────────────────────
|
|
61
|
+
/**
|
|
62
|
+
* Returns a TelescopeServiceProvider class configured for the given config.
|
|
63
|
+
*
|
|
64
|
+
* Records requests, queries, jobs, exceptions, logs, mail, notifications,
|
|
65
|
+
* events, cache operations, scheduled tasks, and model changes.
|
|
66
|
+
*
|
|
67
|
+
* Usage in bootstrap/providers.ts:
|
|
68
|
+
* import { telescope } from '@rudderjs/telescope'
|
|
69
|
+
* export default [..., telescope(configs.telescope), ...]
|
|
70
|
+
*/
|
|
71
|
+
export function telescope(config = {}) {
|
|
72
|
+
const merged = { ...defaultConfig, ...config };
|
|
73
|
+
// Strip undefined values introduced by exactOptionalPropertyTypes spread
|
|
74
|
+
const resolved = {
|
|
75
|
+
enabled: merged.enabled ?? defaultConfig.enabled,
|
|
76
|
+
path: merged.path ?? defaultConfig.path,
|
|
77
|
+
storage: merged.storage ?? defaultConfig.storage,
|
|
78
|
+
sqlitePath: merged.sqlitePath ?? defaultConfig.sqlitePath,
|
|
79
|
+
maxEntries: merged.maxEntries ?? defaultConfig.maxEntries,
|
|
80
|
+
pruneAfterHours: merged.pruneAfterHours ?? defaultConfig.pruneAfterHours,
|
|
81
|
+
recordRequests: merged.recordRequests ?? defaultConfig.recordRequests,
|
|
82
|
+
recordQueries: merged.recordQueries ?? defaultConfig.recordQueries,
|
|
83
|
+
recordJobs: merged.recordJobs ?? defaultConfig.recordJobs,
|
|
84
|
+
recordExceptions: merged.recordExceptions ?? defaultConfig.recordExceptions,
|
|
85
|
+
recordLogs: merged.recordLogs ?? defaultConfig.recordLogs,
|
|
86
|
+
recordMail: merged.recordMail ?? defaultConfig.recordMail,
|
|
87
|
+
recordNotifications: merged.recordNotifications ?? defaultConfig.recordNotifications,
|
|
88
|
+
recordEvents: merged.recordEvents ?? defaultConfig.recordEvents,
|
|
89
|
+
recordCache: merged.recordCache ?? defaultConfig.recordCache,
|
|
90
|
+
recordSchedule: merged.recordSchedule ?? defaultConfig.recordSchedule,
|
|
91
|
+
recordModels: merged.recordModels ?? defaultConfig.recordModels,
|
|
92
|
+
ignoreRequests: merged.ignoreRequests ?? defaultConfig.ignoreRequests,
|
|
93
|
+
slowQueryThreshold: merged.slowQueryThreshold ?? defaultConfig.slowQueryThreshold,
|
|
94
|
+
auth: merged.auth ?? defaultConfig.auth,
|
|
95
|
+
};
|
|
96
|
+
class TelescopeServiceProvider extends ServiceProvider {
|
|
97
|
+
register() {
|
|
98
|
+
this.publishes({
|
|
99
|
+
from: new URL('../../boost/guidelines.md', import.meta.url).pathname,
|
|
100
|
+
to: 'boost',
|
|
101
|
+
tag: 'telescope-boost',
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
async boot() {
|
|
105
|
+
if (!resolved.enabled)
|
|
106
|
+
return;
|
|
107
|
+
// ── Create storage ────────────────────────────────────
|
|
108
|
+
let storage;
|
|
109
|
+
if (resolved.storage === 'sqlite') {
|
|
110
|
+
storage = new SqliteStorage(resolved.sqlitePath);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
storage = new MemoryStorage(resolved.maxEntries);
|
|
114
|
+
}
|
|
115
|
+
TelescopeRegistry.set(storage);
|
|
116
|
+
this.app.instance('telescope', storage);
|
|
117
|
+
// ── Auto-prune on interval ────────────────────────────
|
|
118
|
+
const pruneHours = resolved.pruneAfterHours;
|
|
119
|
+
if (pruneHours > 0) {
|
|
120
|
+
const interval = Math.min(pruneHours * 60 * 60 * 1000, 3_600_000);
|
|
121
|
+
const timer = setInterval(() => {
|
|
122
|
+
const cutoff = new Date(Date.now() - pruneHours * 60 * 60 * 1000);
|
|
123
|
+
storage.pruneOlderThan(cutoff);
|
|
124
|
+
}, interval);
|
|
125
|
+
timer.unref();
|
|
126
|
+
}
|
|
127
|
+
// ── Register collectors ───────────────────────────────
|
|
128
|
+
const collectors = [];
|
|
129
|
+
const requestCollector = new RequestCollector(storage, resolved);
|
|
130
|
+
collectors.push(requestCollector);
|
|
131
|
+
if (resolved.recordQueries)
|
|
132
|
+
collectors.push(new QueryCollector(storage, resolved));
|
|
133
|
+
if (resolved.recordJobs)
|
|
134
|
+
collectors.push(new JobCollector(storage));
|
|
135
|
+
if (resolved.recordExceptions)
|
|
136
|
+
collectors.push(new ExceptionCollector(storage));
|
|
137
|
+
if (resolved.recordLogs)
|
|
138
|
+
collectors.push(new LogCollector(storage));
|
|
139
|
+
if (resolved.recordMail)
|
|
140
|
+
collectors.push(new MailCollector(storage));
|
|
141
|
+
if (resolved.recordNotifications)
|
|
142
|
+
collectors.push(new NotificationCollector(storage));
|
|
143
|
+
if (resolved.recordEvents)
|
|
144
|
+
collectors.push(new EventCollector(storage));
|
|
145
|
+
if (resolved.recordCache)
|
|
146
|
+
collectors.push(new CacheCollector(storage));
|
|
147
|
+
if (resolved.recordSchedule)
|
|
148
|
+
collectors.push(new ScheduleCollector(storage));
|
|
149
|
+
if (resolved.recordModels)
|
|
150
|
+
collectors.push(new ModelCollector(storage));
|
|
151
|
+
for (const collector of collectors) {
|
|
152
|
+
await collector.register();
|
|
153
|
+
}
|
|
154
|
+
// ── Register request middleware ───────────────────────
|
|
155
|
+
if (resolved.recordRequests) {
|
|
156
|
+
try {
|
|
157
|
+
const { router } = await import('@rudderjs/router');
|
|
158
|
+
router.use(requestCollector.middleware());
|
|
159
|
+
}
|
|
160
|
+
catch {
|
|
161
|
+
// @rudderjs/router not available — request recording disabled
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
// ── Register API routes ───────────────────────────────
|
|
165
|
+
await registerRoutes(storage, resolved);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return TelescopeServiceProvider;
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAoB,MAAM,gBAAgB,CAAA;AAClE,OA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I,CAAC,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC,CAAA;YAC/E,IAAI,QAAQ,CAAC,WAAW;gBAAW,UAAU,CAAC,IAAI,CAAC,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC,CAAA;YAC/E,IAAI,QAAQ,CAAC,cAAc;gBAAQ,UAAU,CAAC,IAAI,CAAC,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAA;YAClF,IAAI,QAAQ,CAAC,YAAY;gBAAU,UAAU,CAAC,IAAI,CAAC,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC,CAAA;YAE/E,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;gBACnC,MAAM,SAAS,CAAC,QAAQ,EAAE,CAAA;YAC5B,CAAC;YAED,yDAAyD;YACzD,IAAI,QAAQ,CAAC,cAAc,EAAE,CAAC;gBAC5B,IAAI,CAAC;oBACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAA;oBACnD,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,UAAU,EAAE,CAAC,CAAA;gBAC3C,CAAC;gBAAC,MAAM,CAAC;oBACP,8DAA8D;gBAChE,CAAC;YACH,CAAC;YAED,yDAAyD;YACzD,MAAM,cAAc,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;QACzC,CAAC;KACF;IAED,OAAO,wBAAwB,CAAA;AACjC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { TelescopeEntry, TelescopeStorage, ListOptions, EntryType } from './types.js';
|
|
2
|
+
export declare function createEntry(type: EntryType, content: Record<string, unknown>, options?: {
|
|
3
|
+
batchId?: string;
|
|
4
|
+
tags?: string[];
|
|
5
|
+
familyHash?: string;
|
|
6
|
+
}): TelescopeEntry;
|
|
7
|
+
export declare class MemoryStorage implements TelescopeStorage {
|
|
8
|
+
private readonly maxEntries;
|
|
9
|
+
private entries;
|
|
10
|
+
constructor(maxEntries?: number);
|
|
11
|
+
store(entry: TelescopeEntry): void;
|
|
12
|
+
storeBatch(entries: TelescopeEntry[]): void;
|
|
13
|
+
list(options: ListOptions): TelescopeEntry[];
|
|
14
|
+
find(id: string): TelescopeEntry | null;
|
|
15
|
+
count(type?: EntryType): number;
|
|
16
|
+
prune(type?: EntryType): void;
|
|
17
|
+
pruneOlderThan(date: Date): void;
|
|
18
|
+
}
|
|
19
|
+
export declare class SqliteStorage implements TelescopeStorage {
|
|
20
|
+
private readonly dbPath;
|
|
21
|
+
private db;
|
|
22
|
+
constructor(dbPath: string);
|
|
23
|
+
private getDb;
|
|
24
|
+
private migrate;
|
|
25
|
+
private toRow;
|
|
26
|
+
private fromRow;
|
|
27
|
+
store(entry: TelescopeEntry): void;
|
|
28
|
+
storeBatch(entries: TelescopeEntry[]): void;
|
|
29
|
+
list(options: ListOptions): TelescopeEntry[];
|
|
30
|
+
find(id: string): TelescopeEntry | null;
|
|
31
|
+
count(type?: EntryType): number;
|
|
32
|
+
prune(type?: EntryType): void;
|
|
33
|
+
pruneOlderThan(date: Date): void;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAI1F,wBAAgB,WAAW,CACzB,IAAI,EAAK,SAAS,EAClB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GACnE,cAAc,CAUhB;AAID,qBAAa,aAAc,YAAW,gBAAgB;IAGxC,OAAO,CAAC,QAAQ,CAAC,UAAU;IAFvC,OAAO,CAAC,OAAO,CAAuB;gBAET,UAAU,GAAE,MAAa;IAEtD,KAAK,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IAOlC,UAAU,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG,IAAI;IAI3C,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,cAAc,EAAE;IA2B5C,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI;IAIvC,KAAK,CAAC,IAAI,CAAC,EAAE,SAAS,GAAG,MAAM;IAK/B,KAAK,CAAC,IAAI,CAAC,EAAE,SAAS,GAAG,IAAI;IAQ7B,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;CAIjC;AAID,qBAAa,aAAc,YAAW,gBAAgB;IAGxC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAFnC,OAAO,CAAC,EAAE,CAAiD;gBAE9B,MAAM,EAAE,MAAM;IAE3C,OAAO,CAAC,KAAK;IAeb,OAAO,CAAC,OAAO;IAiBf,OAAO,CAAC,KAAK;IAYb,OAAO,CAAC,OAAO;IAYf,KAAK,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IAQlC,UAAU,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG,IAAI;IAY3C,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,cAAc,EAAE;IAwB5C,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI;IAOvC,KAAK,CAAC,IAAI,CAAC,EAAE,SAAS,GAAG,MAAM;IAQ/B,KAAK,CAAC,IAAI,CAAC,EAAE,SAAS,GAAG,IAAI;IAQ7B,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;CAGjC"}
|
package/dist/storage.js
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
// ─── Helpers ───────────────────────────────────────────────
|
|
3
|
+
export function createEntry(type, content, options) {
|
|
4
|
+
return {
|
|
5
|
+
id: randomUUID(),
|
|
6
|
+
batchId: options?.batchId ?? null,
|
|
7
|
+
type,
|
|
8
|
+
content,
|
|
9
|
+
tags: options?.tags ?? [],
|
|
10
|
+
familyHash: options?.familyHash ?? null,
|
|
11
|
+
createdAt: new Date(),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
// ─── Memory Storage ────────────────────────────────────────
|
|
15
|
+
export class MemoryStorage {
|
|
16
|
+
maxEntries;
|
|
17
|
+
entries = [];
|
|
18
|
+
constructor(maxEntries = 1000) {
|
|
19
|
+
this.maxEntries = maxEntries;
|
|
20
|
+
}
|
|
21
|
+
store(entry) {
|
|
22
|
+
this.entries.unshift(entry);
|
|
23
|
+
if (this.entries.length > this.maxEntries) {
|
|
24
|
+
this.entries.length = this.maxEntries;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
storeBatch(entries) {
|
|
28
|
+
for (const entry of entries)
|
|
29
|
+
this.store(entry);
|
|
30
|
+
}
|
|
31
|
+
list(options) {
|
|
32
|
+
let result = this.entries;
|
|
33
|
+
if (options.type) {
|
|
34
|
+
result = result.filter(e => e.type === options.type);
|
|
35
|
+
}
|
|
36
|
+
if (options.batchId) {
|
|
37
|
+
const bId = options.batchId;
|
|
38
|
+
result = result.filter(e => e.batchId === bId);
|
|
39
|
+
}
|
|
40
|
+
if (options.tag) {
|
|
41
|
+
const tag = options.tag;
|
|
42
|
+
result = result.filter(e => e.tags.includes(tag));
|
|
43
|
+
}
|
|
44
|
+
if (options.search) {
|
|
45
|
+
const s = options.search.toLowerCase();
|
|
46
|
+
result = result.filter(e => JSON.stringify(e.content).toLowerCase().includes(s));
|
|
47
|
+
}
|
|
48
|
+
const page = options.page ?? 1;
|
|
49
|
+
const perPage = options.perPage ?? 50;
|
|
50
|
+
const start = (page - 1) * perPage;
|
|
51
|
+
return result.slice(start, start + perPage);
|
|
52
|
+
}
|
|
53
|
+
find(id) {
|
|
54
|
+
return this.entries.find(e => e.id === id) ?? null;
|
|
55
|
+
}
|
|
56
|
+
count(type) {
|
|
57
|
+
if (!type)
|
|
58
|
+
return this.entries.length;
|
|
59
|
+
return this.entries.filter(e => e.type === type).length;
|
|
60
|
+
}
|
|
61
|
+
prune(type) {
|
|
62
|
+
if (!type) {
|
|
63
|
+
this.entries.length = 0;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
this.entries = this.entries.filter(e => e.type !== type);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
pruneOlderThan(date) {
|
|
70
|
+
const ts = date.getTime();
|
|
71
|
+
this.entries = this.entries.filter(e => e.createdAt.getTime() >= ts);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// ─── SQLite Storage ────────────────────────────────────────
|
|
75
|
+
export class SqliteStorage {
|
|
76
|
+
dbPath;
|
|
77
|
+
db = null;
|
|
78
|
+
constructor(dbPath) {
|
|
79
|
+
this.dbPath = dbPath;
|
|
80
|
+
}
|
|
81
|
+
getDb() {
|
|
82
|
+
if (!this.db) {
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
84
|
+
const Database = globalThis.__betterSqlite3;
|
|
85
|
+
if (!Database) {
|
|
86
|
+
throw new Error('[RudderJS Telescope] better-sqlite3 is required for SQLite storage. Run: pnpm add better-sqlite3');
|
|
87
|
+
}
|
|
88
|
+
this.db = new Database(this.dbPath);
|
|
89
|
+
this.migrate();
|
|
90
|
+
}
|
|
91
|
+
return this.db;
|
|
92
|
+
}
|
|
93
|
+
migrate() {
|
|
94
|
+
const db = this.db;
|
|
95
|
+
db.exec(`
|
|
96
|
+
CREATE TABLE IF NOT EXISTS telescope_entries (
|
|
97
|
+
id TEXT PRIMARY KEY,
|
|
98
|
+
batch_id TEXT,
|
|
99
|
+
type TEXT NOT NULL,
|
|
100
|
+
content TEXT NOT NULL,
|
|
101
|
+
tags TEXT NOT NULL DEFAULT '[]',
|
|
102
|
+
family_hash TEXT,
|
|
103
|
+
created_at TEXT NOT NULL
|
|
104
|
+
);
|
|
105
|
+
CREATE INDEX IF NOT EXISTS idx_telescope_type_created ON telescope_entries(type, created_at);
|
|
106
|
+
CREATE INDEX IF NOT EXISTS idx_telescope_batch ON telescope_entries(batch_id);
|
|
107
|
+
`);
|
|
108
|
+
}
|
|
109
|
+
toRow(entry) {
|
|
110
|
+
return {
|
|
111
|
+
id: entry.id,
|
|
112
|
+
batch_id: entry.batchId,
|
|
113
|
+
type: entry.type,
|
|
114
|
+
content: JSON.stringify(entry.content),
|
|
115
|
+
tags: JSON.stringify(entry.tags),
|
|
116
|
+
family_hash: entry.familyHash,
|
|
117
|
+
created_at: entry.createdAt.toISOString(),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
fromRow(row) {
|
|
121
|
+
return {
|
|
122
|
+
id: row['id'],
|
|
123
|
+
batchId: row['batch_id'] || null,
|
|
124
|
+
type: row['type'],
|
|
125
|
+
content: JSON.parse(row['content']),
|
|
126
|
+
tags: JSON.parse(row['tags']),
|
|
127
|
+
familyHash: row['family_hash'] || null,
|
|
128
|
+
createdAt: new Date(row['created_at']),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
store(entry) {
|
|
132
|
+
const row = this.toRow(entry);
|
|
133
|
+
this.getDb().prepare(`INSERT INTO telescope_entries (id, batch_id, type, content, tags, family_hash, created_at)
|
|
134
|
+
VALUES (@id, @batch_id, @type, @content, @tags, @family_hash, @created_at)`).run(row);
|
|
135
|
+
}
|
|
136
|
+
storeBatch(entries) {
|
|
137
|
+
const db = this.getDb();
|
|
138
|
+
const stmt = db.prepare(`INSERT INTO telescope_entries (id, batch_id, type, content, tags, family_hash, created_at)
|
|
139
|
+
VALUES (@id, @batch_id, @type, @content, @tags, @family_hash, @created_at)`);
|
|
140
|
+
const tx = db.transaction((rows) => {
|
|
141
|
+
for (const row of rows)
|
|
142
|
+
stmt.run(row);
|
|
143
|
+
});
|
|
144
|
+
tx(entries.map(e => this.toRow(e)));
|
|
145
|
+
}
|
|
146
|
+
list(options) {
|
|
147
|
+
const conditions = [];
|
|
148
|
+
const params = {};
|
|
149
|
+
if (options.type) {
|
|
150
|
+
conditions.push('type = @type');
|
|
151
|
+
params['type'] = options.type;
|
|
152
|
+
}
|
|
153
|
+
if (options.batchId) {
|
|
154
|
+
conditions.push('batch_id = @batchId');
|
|
155
|
+
params['batchId'] = options.batchId;
|
|
156
|
+
}
|
|
157
|
+
if (options.tag) {
|
|
158
|
+
conditions.push('tags LIKE @tag');
|
|
159
|
+
params['tag'] = `%${options.tag}%`;
|
|
160
|
+
}
|
|
161
|
+
if (options.search) {
|
|
162
|
+
conditions.push('content LIKE @search');
|
|
163
|
+
params['search'] = `%${options.search}%`;
|
|
164
|
+
}
|
|
165
|
+
const where = conditions.length ? `WHERE ${conditions.join(' AND ')}` : '';
|
|
166
|
+
const page = options.page ?? 1;
|
|
167
|
+
const perPage = options.perPage ?? 50;
|
|
168
|
+
const offset = (page - 1) * perPage;
|
|
169
|
+
params['limit'] = perPage;
|
|
170
|
+
params['offset'] = offset;
|
|
171
|
+
const rows = this.getDb()
|
|
172
|
+
.prepare(`SELECT * FROM telescope_entries ${where} ORDER BY created_at DESC LIMIT @limit OFFSET @offset`)
|
|
173
|
+
.all(params);
|
|
174
|
+
return rows.map(r => this.fromRow(r));
|
|
175
|
+
}
|
|
176
|
+
find(id) {
|
|
177
|
+
const row = this.getDb()
|
|
178
|
+
.prepare('SELECT * FROM telescope_entries WHERE id = ?')
|
|
179
|
+
.get(id);
|
|
180
|
+
return row ? this.fromRow(row) : null;
|
|
181
|
+
}
|
|
182
|
+
count(type) {
|
|
183
|
+
const sql = type
|
|
184
|
+
? 'SELECT COUNT(*) as cnt FROM telescope_entries WHERE type = ?'
|
|
185
|
+
: 'SELECT COUNT(*) as cnt FROM telescope_entries';
|
|
186
|
+
const row = this.getDb().prepare(sql).get(...(type ? [type] : []));
|
|
187
|
+
return row.cnt;
|
|
188
|
+
}
|
|
189
|
+
prune(type) {
|
|
190
|
+
if (type) {
|
|
191
|
+
this.getDb().prepare('DELETE FROM telescope_entries WHERE type = ?').run(type);
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
this.getDb().prepare('DELETE FROM telescope_entries').run();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
pruneOlderThan(date) {
|
|
198
|
+
this.getDb().prepare('DELETE FROM telescope_entries WHERE created_at < ?').run(date.toISOString());
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGxC,8DAA8D;AAE9D,MAAM,UAAU,WAAW,CACzB,IAAkB,EAClB,OAAgC,EAChC,OAAoE;IAEpE,OAAO;QACL,EAAE,EAAU,UAAU,EAAE;QACxB,OAAO,EAAK,OAAO,EAAE,OAAO,IAAI,IAAI;QACpC,IAAI;QACJ,OAAO;QACP,IAAI,EAAQ,OAAO,EAAE,IAAI,IAAI,EAAE;QAC/B,UAAU,EAAE,OAAO,EAAE,UAAU,IAAI,IAAI;QACvC,SAAS,EAAG,IAAI,IAAI,EAAE;KACvB,CAAA;AACH,CAAC;AAED,8DAA8D;AAE9D,MAAM,OAAO,aAAa;IAGK;IAFrB,OAAO,GAAqB,EAAE,CAAA;IAEtC,YAA6B,aAAqB,IAAI;QAAzB,eAAU,GAAV,UAAU,CAAe;IAAG,CAAC;IAE1D,KAAK,CAAC,KAAqB;QACzB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QAC3B,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;YAC1C,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,UAAU,CAAA;QACvC,CAAC;IACH,CAAC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,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;IACvC,CAAC;IAED,KAAK,CAAC,IAAgB;QACpB,MAAM,GAAG,GAAG,IAAI;YACd,CAAC,CAAC,8DAA8D;YAChE,CAAC,CAAC,+CAA+C,CAAA;QACnD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAoB,CAAA;QACrF,OAAO,GAAG,CAAC,GAAG,CAAA;IAChB,CAAC;IAED,KAAK,CAAC,IAAgB;QACpB,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,8CAA8C,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAChF,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,+BAA+B,CAAC,CAAC,GAAG,EAAE,CAAA;QAC7D,CAAC;IACH,CAAC;IAED,cAAc,CAAC,IAAU;QACvB,IAAI,CAAC,KAAK,EAAE,CAAC,OAAO,CAAC,oDAAoD,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAA;IACpG,CAAC;CACF"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export type EntryType = 'request' | 'query' | 'job' | 'exception' | 'log' | 'mail' | 'notification' | 'event' | 'cache' | 'schedule' | 'model';
|
|
2
|
+
export interface TelescopeEntry {
|
|
3
|
+
id: string;
|
|
4
|
+
batchId: string | null;
|
|
5
|
+
type: EntryType;
|
|
6
|
+
content: Record<string, unknown>;
|
|
7
|
+
tags: string[];
|
|
8
|
+
familyHash: string | null;
|
|
9
|
+
createdAt: Date;
|
|
10
|
+
}
|
|
11
|
+
export interface Collector {
|
|
12
|
+
/** Human-readable name (e.g. "Request Collector") */
|
|
13
|
+
readonly name: string;
|
|
14
|
+
/** The entry type this collector produces */
|
|
15
|
+
readonly type: EntryType;
|
|
16
|
+
/** Register hooks. Called during provider boot. */
|
|
17
|
+
register(): void | Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export interface TelescopeStorage {
|
|
20
|
+
store(entry: TelescopeEntry): void | Promise<void>;
|
|
21
|
+
storeBatch(entries: TelescopeEntry[]): void | Promise<void>;
|
|
22
|
+
/** List entries by type, with pagination and optional filters */
|
|
23
|
+
list(options: ListOptions): TelescopeEntry[] | Promise<TelescopeEntry[]>;
|
|
24
|
+
/** Get a single entry by ID */
|
|
25
|
+
find(id: string): TelescopeEntry | null | Promise<TelescopeEntry | null>;
|
|
26
|
+
/** Count entries by type */
|
|
27
|
+
count(type?: EntryType): number | Promise<number>;
|
|
28
|
+
/** Delete all entries, optionally filtered by type */
|
|
29
|
+
prune(type?: EntryType): void | Promise<void>;
|
|
30
|
+
/** Delete entries older than the given date */
|
|
31
|
+
pruneOlderThan(date: Date): void | Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
export interface ListOptions {
|
|
34
|
+
type?: EntryType | undefined;
|
|
35
|
+
page?: number | undefined;
|
|
36
|
+
perPage?: number | undefined;
|
|
37
|
+
tag?: string | undefined;
|
|
38
|
+
search?: string | undefined;
|
|
39
|
+
batchId?: string | undefined;
|
|
40
|
+
}
|
|
41
|
+
export interface TelescopeConfig {
|
|
42
|
+
enabled?: boolean | undefined;
|
|
43
|
+
path?: string | undefined;
|
|
44
|
+
storage?: 'memory' | 'sqlite' | undefined;
|
|
45
|
+
sqlitePath?: string | undefined;
|
|
46
|
+
maxEntries?: number | undefined;
|
|
47
|
+
pruneAfterHours?: number | undefined;
|
|
48
|
+
recordRequests?: boolean | undefined;
|
|
49
|
+
recordQueries?: boolean | undefined;
|
|
50
|
+
recordJobs?: boolean | undefined;
|
|
51
|
+
recordExceptions?: boolean | undefined;
|
|
52
|
+
recordLogs?: boolean | undefined;
|
|
53
|
+
recordMail?: boolean | undefined;
|
|
54
|
+
recordNotifications?: boolean | undefined;
|
|
55
|
+
recordEvents?: boolean | undefined;
|
|
56
|
+
recordCache?: boolean | undefined;
|
|
57
|
+
recordSchedule?: boolean | undefined;
|
|
58
|
+
recordModels?: boolean | undefined;
|
|
59
|
+
ignoreRequests?: string[] | undefined;
|
|
60
|
+
slowQueryThreshold?: number | undefined;
|
|
61
|
+
auth?: null | ((req: unknown) => boolean | Promise<boolean>) | undefined;
|
|
62
|
+
}
|
|
63
|
+
export declare const defaultConfig: Required<Omit<TelescopeConfig, 'auth' | 'sqlitePath'>> & {
|
|
64
|
+
auth: TelescopeConfig['auth'];
|
|
65
|
+
sqlitePath: string;
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,GACjB,SAAS,GACT,OAAO,GACP,KAAK,GACL,WAAW,GACX,KAAK,GACL,MAAM,GACN,cAAc,GACd,OAAO,GACP,OAAO,GACP,UAAU,GACV,OAAO,CAAA;AAEX,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAU,MAAM,CAAA;IAClB,OAAO,EAAK,MAAM,GAAG,IAAI,CAAA;IACzB,IAAI,EAAQ,SAAS,CAAA;IACrB,OAAO,EAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,IAAI,EAAQ,MAAM,EAAE,CAAA;IACpB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,SAAS,EAAG,IAAI,CAAA;CACjB;AAID,MAAM,WAAW,SAAS;IACxB,qDAAqD;IACrD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,6CAA6C;IAC7C,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;IACxB,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AqBvI,CAAA"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// ─── Entry Types ───────────────────────────────────────────
|
|
2
|
+
export const defaultConfig = {
|
|
3
|
+
enabled: true,
|
|
4
|
+
path: 'telescope',
|
|
5
|
+
storage: 'memory',
|
|
6
|
+
sqlitePath: '.telescope.db',
|
|
7
|
+
maxEntries: 1000,
|
|
8
|
+
pruneAfterHours: 24,
|
|
9
|
+
recordRequests: true,
|
|
10
|
+
recordQueries: true,
|
|
11
|
+
recordJobs: true,
|
|
12
|
+
recordExceptions: true,
|
|
13
|
+
recordLogs: true,
|
|
14
|
+
recordMail: true,
|
|
15
|
+
recordNotifications: true,
|
|
16
|
+
recordEvents: true,
|
|
17
|
+
recordCache: true,
|
|
18
|
+
recordSchedule: true,
|
|
19
|
+
recordModels: true,
|
|
20
|
+
ignoreRequests: ['/telescope*', '/health'],
|
|
21
|
+
slowQueryThreshold: 100,
|
|
22
|
+
auth: null,
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAwF9D,MAAM,CAAC,MAAM,aAAa,GAAmH;IAC3I,OAAO,EAAe,IAAI;IAC1B,IAAI,EAAkB,WAAW;IACjC,OAAO,EAAe,QAAQ;IAC9B,UAAU,EAAY,eAAe;IACrC,UAAU,EAAY,IAAI;IAC1B,eAAe,EAAO,EAAE;IACxB,cAAc,EAAQ,IAAI;IAC1B,aAAa,EAAS,IAAI;IAC1B,UAAU,EAAY,IAAI;IAC1B,gBAAgB,EAAM,IAAI;IAC1B,UAAU,EAAY,IAAI;IAC1B,UAAU,EAAY,IAAI;IAC1B,mBAAmB,EAAG,IAAI;IAC1B,YAAY,EAAU,IAAI;IAC1B,WAAW,EAAW,IAAI;IAC1B,cAAc,EAAQ,IAAI;IAC1B,YAAY,EAAU,IAAI;IAC1B,cAAc,EAAQ,CAAC,aAAa,EAAE,SAAS,CAAC;IAChD,kBAAkB,EAAI,GAAG;IACzB,IAAI,EAAkB,IAAI;CAC3B,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared HTML layout for Telescope UI pages.
|
|
3
|
+
* Sidebar navigation + content area. Alpine.js + Tailwind CDN.
|
|
4
|
+
*/
|
|
5
|
+
export interface NavItem {
|
|
6
|
+
label: string;
|
|
7
|
+
path: string;
|
|
8
|
+
icon: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function layout(title: string, body: string, basePath: string, activePath: string): string;
|
|
11
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../src/ui/layout.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAG,MAAM,CAAA;IACb,IAAI,EAAG,MAAM,CAAA;CACd;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAiEhG"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared HTML layout for Telescope UI pages.
|
|
3
|
+
* Sidebar navigation + content area. Alpine.js + Tailwind CDN.
|
|
4
|
+
*/
|
|
5
|
+
export function layout(title, body, basePath, activePath) {
|
|
6
|
+
const nav = [
|
|
7
|
+
{ label: 'Dashboard', path: '', icon: 'M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6' },
|
|
8
|
+
{ label: 'Requests', path: '/requests', icon: 'M13 10V3L4 14h7v7l9-11h-7z' },
|
|
9
|
+
{ label: 'Queries', path: '/queries', icon: 'M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4' },
|
|
10
|
+
{ label: 'Jobs', path: '/jobs', icon: 'M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10' },
|
|
11
|
+
{ label: 'Exceptions', path: '/exceptions', icon: 'M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z' },
|
|
12
|
+
{ label: 'Logs', path: '/logs', icon: 'M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z' },
|
|
13
|
+
{ label: 'Mail', path: '/mail', icon: 'M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z' },
|
|
14
|
+
{ label: 'Notifications', path: '/notifications', icon: 'M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9' },
|
|
15
|
+
{ label: 'Events', path: '/events', icon: 'M13 10V3L4 14h7v7l9-11h-7z' },
|
|
16
|
+
{ label: 'Cache', path: '/cache', icon: 'M5 8h14M5 8a2 2 0 110-4h14a2 2 0 110 4M5 8v10a2 2 0 002 2h10a2 2 0 002-2V8m-9 4h4' },
|
|
17
|
+
{ label: 'Schedule', path: '/schedule', icon: 'M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z' },
|
|
18
|
+
{ label: 'Models', path: '/models', icon: 'M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10' },
|
|
19
|
+
];
|
|
20
|
+
const navHtml = nav.map(n => {
|
|
21
|
+
const href = `${basePath}${n.path}`;
|
|
22
|
+
const active = activePath === n.path || (n.path === '' && activePath === '/');
|
|
23
|
+
return `<a href="${href}" class="flex items-center gap-3 px-3 py-2 text-sm rounded-lg transition ${active ? 'bg-indigo-50 text-indigo-700 font-medium' : 'text-gray-600 hover:bg-gray-50 hover:text-gray-900'}">
|
|
24
|
+
<svg class="w-4 h-4 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="${n.icon}"/></svg>
|
|
25
|
+
${n.label}
|
|
26
|
+
</a>`;
|
|
27
|
+
}).join('\n ');
|
|
28
|
+
return `<!DOCTYPE html>
|
|
29
|
+
<html lang="en">
|
|
30
|
+
<head>
|
|
31
|
+
<meta charset="UTF-8">
|
|
32
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
33
|
+
<title>${title} — Telescope</title>
|
|
34
|
+
<script src="https://cdn.tailwindcss.com"></script>
|
|
35
|
+
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
|
|
36
|
+
<style>
|
|
37
|
+
[x-cloak] { display: none !important; }
|
|
38
|
+
.badge { @apply inline-flex items-center px-2 py-0.5 rounded text-xs font-medium; }
|
|
39
|
+
</style>
|
|
40
|
+
</head>
|
|
41
|
+
<body class="bg-gray-50 text-gray-900 font-sans antialiased">
|
|
42
|
+
<div class="flex min-h-screen">
|
|
43
|
+
<!-- Sidebar -->
|
|
44
|
+
<aside class="w-56 bg-white border-r border-gray-200 flex flex-col">
|
|
45
|
+
<div class="px-4 py-5 flex items-center gap-2 border-b border-gray-100">
|
|
46
|
+
<div class="w-7 h-7 bg-violet-600 rounded-lg flex items-center justify-center">
|
|
47
|
+
<svg class="w-4 h-4 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
48
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/>
|
|
49
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"/>
|
|
50
|
+
</svg>
|
|
51
|
+
</div>
|
|
52
|
+
<span class="font-semibold text-sm">Telescope</span>
|
|
53
|
+
</div>
|
|
54
|
+
<nav class="flex-1 px-3 py-4 space-y-0.5 overflow-y-auto">
|
|
55
|
+
${navHtml}
|
|
56
|
+
</nav>
|
|
57
|
+
</aside>
|
|
58
|
+
|
|
59
|
+
<!-- Main content -->
|
|
60
|
+
<main class="flex-1 overflow-auto">
|
|
61
|
+
<div class="max-w-6xl mx-auto px-6 py-8">
|
|
62
|
+
${body}
|
|
63
|
+
</div>
|
|
64
|
+
</main>
|
|
65
|
+
</div>
|
|
66
|
+
</body>
|
|
67
|
+
</html>`;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.js","sourceRoot":"","sources":["../../src/ui/layout.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,MAAM,UAAU,MAAM,CAAC,KAAa,EAAE,IAAY,EAAE,QAAgB,EAAE,UAAkB;IACtF,MAAM,GAAG,GAAc;QACrB,EAA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