@hasna/analytics 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.
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Analytics CRUD operations — KPIs, Dashboards, Reports
3
+ */
4
+ export interface Kpi {
5
+ id: string;
6
+ name: string;
7
+ category: string | null;
8
+ value: number;
9
+ period: string | null;
10
+ source_service: string | null;
11
+ metadata: Record<string, unknown>;
12
+ recorded_at: string;
13
+ }
14
+ export interface Dashboard {
15
+ id: string;
16
+ name: string;
17
+ description: string | null;
18
+ widgets: unknown[];
19
+ created_at: string;
20
+ }
21
+ export type ReportType = "daily" | "weekly" | "monthly" | "quarterly" | "annual" | "custom";
22
+ export interface Report {
23
+ id: string;
24
+ name: string;
25
+ type: ReportType;
26
+ content: string | null;
27
+ period: string | null;
28
+ generated_at: string;
29
+ metadata: Record<string, unknown>;
30
+ }
31
+ export interface RecordKpiInput {
32
+ name: string;
33
+ value: number;
34
+ category?: string;
35
+ source_service?: string;
36
+ period?: string;
37
+ metadata?: Record<string, unknown>;
38
+ }
39
+ export declare function recordKpi(input: RecordKpiInput): Kpi;
40
+ export declare function getKpiById(id: string): Kpi | null;
41
+ export declare function getKpi(name: string, period?: string): Kpi | null;
42
+ export declare function getKpiTrend(name: string, days?: number): Kpi[];
43
+ export interface ListKpisOptions {
44
+ category?: string;
45
+ source_service?: string;
46
+ limit?: number;
47
+ offset?: number;
48
+ }
49
+ export declare function listKpis(options?: ListKpisOptions): Kpi[];
50
+ export declare function getLatestKpis(): Kpi[];
51
+ export declare function deleteKpi(id: string): boolean;
52
+ export interface CreateDashboardInput {
53
+ name: string;
54
+ description?: string;
55
+ widgets?: unknown[];
56
+ }
57
+ export declare function createDashboard(input: CreateDashboardInput): Dashboard;
58
+ export declare function getDashboard(id: string): Dashboard | null;
59
+ export declare function listDashboards(): Dashboard[];
60
+ export interface UpdateDashboardInput {
61
+ name?: string;
62
+ description?: string;
63
+ widgets?: unknown[];
64
+ }
65
+ export declare function updateDashboard(id: string, input: UpdateDashboardInput): Dashboard | null;
66
+ export declare function deleteDashboard(id: string): boolean;
67
+ export interface GenerateReportInput {
68
+ name: string;
69
+ type: ReportType;
70
+ period?: string;
71
+ metadata?: Record<string, unknown>;
72
+ }
73
+ export declare function generateReport(input: GenerateReportInput): Report;
74
+ export declare function getReport(id: string): Report | null;
75
+ export interface ListReportsOptions {
76
+ type?: ReportType;
77
+ limit?: number;
78
+ offset?: number;
79
+ }
80
+ export declare function listReports(options?: ListReportsOptions): Report[];
81
+ export declare function deleteReport(id: string): boolean;
82
+ export interface BusinessHealth {
83
+ total_kpis: number;
84
+ categories: {
85
+ category: string;
86
+ count: number;
87
+ latest_value: number;
88
+ }[];
89
+ latest_kpis: Kpi[];
90
+ report_count: number;
91
+ dashboard_count: number;
92
+ }
93
+ export declare function getBusinessHealth(): BusinessHealth;
94
+ export declare function generateExecutiveSummary(): Promise<string>;
95
+ //# sourceMappingURL=analytics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../src/db/analytics.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,MAAM,WAAW,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,WAAW,EAAE,MAAM,CAAC;CACrB;AAsBD,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,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M,CAAC;CACjB;AAED,wBAAgB,WAAW,CAAC,OAAO,GAAE,kBAAuB,GAAG,MAAM,EAAE,CA2BtE;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAIhD;AAID,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACxE,WAAW,EAAE,GAAG,EAAE,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,wBAAgB,iBAAiB,IAAI,cAAc,CAmDlD;AAID,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,MAAM,CAAC,CAiHhE"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Database connection for open-analytics
3
+ */
4
+ import type { Database } from "bun:sqlite";
5
+ export declare function getDatabase(): Database;
6
+ export declare function closeDatabase(): void;
7
+ //# sourceMappingURL=database.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/db/database.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAmB3C,wBAAgB,WAAW,IAAI,QAAQ,CA+CtC;AAED,wBAAgB,aAAa,IAAI,IAAI,CAKpC"}
@@ -0,0 +1,7 @@
1
+ export interface MigrationEntry {
2
+ id: number;
3
+ name: string;
4
+ sql: string;
5
+ }
6
+ export declare const MIGRATIONS: MigrationEntry[];
7
+ //# sourceMappingURL=migrations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../src/db/migrations.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb;AAED,eAAO,MAAM,UAAU,EAAE,cAAc,EA2CtC,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * open-analytics — Business analytics for AI agents
3
+ */
4
+ export { recordKpi, getKpiById, getKpi, getKpiTrend, listKpis, getLatestKpis, deleteKpi, createDashboard, getDashboard, listDashboards, updateDashboard, deleteDashboard, generateReport, getReport, listReports, deleteReport, getBusinessHealth, generateExecutiveSummary, type Kpi, type RecordKpiInput, type ListKpisOptions, type Dashboard, type CreateDashboardInput, type UpdateDashboardInput, type Report, type ReportType, type GenerateReportInput, type ListReportsOptions, type BusinessHealth, } from "./db/analytics.js";
5
+ export { getDatabase, closeDatabase } from "./db/database.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,SAAS,EACT,UAAU,EACV,MAAM,EACN,WAAW,EACX,QAAQ,EACR,aAAa,EACb,SAAS,EACT,eAAe,EACf,YAAY,EACZ,cAAc,EACd,eAAe,EACf,eAAe,EACf,cAAc,EACd,SAAS,EACT,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,wBAAwB,EACxB,KAAK,GAAG,EACR,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,MAAM,EACX,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,cAAc,GACpB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}