@contractspec/example.analytics-dashboard 0.0.0-canary-20260113170453
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 +281 -0
- package/dist/dashboard/dashboard.enum.d.ts +18 -0
- package/dist/dashboard/dashboard.enum.d.ts.map +1 -0
- package/dist/dashboard/dashboard.enum.js +43 -0
- package/dist/dashboard/dashboard.enum.js.map +1 -0
- package/dist/dashboard/dashboard.operation.d.ts +537 -0
- package/dist/dashboard/dashboard.operation.d.ts.map +1 -0
- package/dist/dashboard/dashboard.operation.js +213 -0
- package/dist/dashboard/dashboard.operation.js.map +1 -0
- package/dist/dashboard/dashboard.presentation.d.ts +9 -0
- package/dist/dashboard/dashboard.presentation.d.ts.map +1 -0
- package/dist/dashboard/dashboard.presentation.js +90 -0
- package/dist/dashboard/dashboard.presentation.js.map +1 -0
- package/dist/dashboard/dashboard.schema.d.ts +333 -0
- package/dist/dashboard/dashboard.schema.d.ts.map +1 -0
- package/dist/dashboard/dashboard.schema.js +236 -0
- package/dist/dashboard/dashboard.schema.js.map +1 -0
- package/dist/dashboard/dashboard.test-spec.d.ts +10 -0
- package/dist/dashboard/dashboard.test-spec.d.ts.map +1 -0
- package/dist/dashboard/dashboard.test-spec.js +233 -0
- package/dist/dashboard/dashboard.test-spec.js.map +1 -0
- package/dist/dashboard/index.d.ts +4 -0
- package/dist/dashboard/index.js +5 -0
- package/dist/dashboard.feature.d.ts +17 -0
- package/dist/dashboard.feature.d.ts.map +1 -0
- package/dist/dashboard.feature.js +177 -0
- package/dist/dashboard.feature.js.map +1 -0
- package/dist/docs/analytics-dashboard.docblock.d.ts +1 -0
- package/dist/docs/analytics-dashboard.docblock.js +114 -0
- package/dist/docs/analytics-dashboard.docblock.js.map +1 -0
- package/dist/docs/index.d.ts +1 -0
- package/dist/docs/index.js +1 -0
- package/dist/events.d.ts +149 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +128 -0
- package/dist/events.js.map +1 -0
- package/dist/example.d.ts +7 -0
- package/dist/example.d.ts.map +1 -0
- package/dist/example.js +58 -0
- package/dist/example.js.map +1 -0
- package/dist/handlers/analytics.handlers.d.ts +122 -0
- package/dist/handlers/analytics.handlers.d.ts.map +1 -0
- package/dist/handlers/analytics.handlers.js +310 -0
- package/dist/handlers/analytics.handlers.js.map +1 -0
- package/dist/handlers/index.d.ts +2 -0
- package/dist/handlers/index.js +3 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +13 -0
- package/dist/query/index.d.ts +4 -0
- package/dist/query/index.js +5 -0
- package/dist/query/query.enum.d.ts +10 -0
- package/dist/query/query.enum.d.ts.map +1 -0
- package/dist/query/query.enum.js +16 -0
- package/dist/query/query.enum.js.map +1 -0
- package/dist/query/query.operation.d.ts +181 -0
- package/dist/query/query.operation.d.ts.map +1 -0
- package/dist/query/query.operation.js +113 -0
- package/dist/query/query.operation.js.map +1 -0
- package/dist/query/query.presentation.d.ts +8 -0
- package/dist/query/query.presentation.d.ts.map +1 -0
- package/dist/query/query.presentation.js +60 -0
- package/dist/query/query.presentation.js.map +1 -0
- package/dist/query/query.schema.d.ts +143 -0
- package/dist/query/query.schema.d.ts.map +1 -0
- package/dist/query/query.schema.js +157 -0
- package/dist/query/query.schema.js.map +1 -0
- package/dist/query/query.test-spec.d.ts +8 -0
- package/dist/query/query.test-spec.d.ts.map +1 -0
- package/dist/query/query.test-spec.js +124 -0
- package/dist/query/query.test-spec.js.map +1 -0
- package/dist/query-engine/index.d.ts +106 -0
- package/dist/query-engine/index.d.ts.map +1 -0
- package/dist/query-engine/index.js +189 -0
- package/dist/query-engine/index.js.map +1 -0
- package/dist/seeders/index.d.ts +10 -0
- package/dist/seeders/index.d.ts.map +1 -0
- package/dist/seeders/index.js +19 -0
- package/dist/seeders/index.js.map +1 -0
- package/dist/ui/AnalyticsDashboard.d.ts +7 -0
- package/dist/ui/AnalyticsDashboard.d.ts.map +1 -0
- package/dist/ui/AnalyticsDashboard.js +265 -0
- package/dist/ui/AnalyticsDashboard.js.map +1 -0
- package/dist/ui/hooks/index.d.ts +2 -0
- package/dist/ui/hooks/index.js +5 -0
- package/dist/ui/hooks/useAnalyticsData.d.ts +23 -0
- package/dist/ui/hooks/useAnalyticsData.d.ts.map +1 -0
- package/dist/ui/hooks/useAnalyticsData.js +73 -0
- package/dist/ui/hooks/useAnalyticsData.js.map +1 -0
- package/dist/ui/index.d.ts +6 -0
- package/dist/ui/index.js +6 -0
- package/dist/ui/renderers/analytics.markdown.d.ts +28 -0
- package/dist/ui/renderers/analytics.markdown.d.ts.map +1 -0
- package/dist/ui/renderers/analytics.markdown.js +264 -0
- package/dist/ui/renderers/analytics.markdown.js.map +1 -0
- package/dist/ui/renderers/index.d.ts +2 -0
- package/dist/ui/renderers/index.js +3 -0
- package/package.json +101 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example.js","names":[],"sources":["../src/example.ts"],"sourcesContent":["import { defineExample } from '@contractspec/lib.contracts';\n\nconst example = defineExample({\n meta: {\n key: 'analytics-dashboard',\n version: '1.0.0',\n title: 'Analytics Dashboard',\n description:\n 'Tenant-scoped dashboards, widgets, query builder, and scheduled reports (spec-first widgets/queries).',\n kind: 'template',\n visibility: 'public',\n stability: 'experimental',\n owners: ['@platform.core'],\n tags: ['analytics', 'dashboards', 'bi', 'queries'],\n },\n docs: {\n rootDocId: 'docs.examples.analytics-dashboard',\n goalDocId: 'docs.examples.analytics-dashboard.goal',\n usageDocId: 'docs.examples.analytics-dashboard.usage',\n constraintsDocId: 'docs.examples.analytics-dashboard.constraints',\n },\n entrypoints: {\n packageName: '@contractspec/example.analytics-dashboard',\n feature: './feature',\n contracts: './contracts',\n presentations: './presentations',\n handlers: './handlers',\n docs: './docs',\n },\n surfaces: {\n templates: true,\n sandbox: {\n enabled: true,\n modes: ['playground', 'specs', 'builder', 'markdown', 'evolution'],\n },\n studio: { enabled: true, installable: true },\n mcp: { enabled: true },\n },\n});\n\nexport default example;\n"],"mappings":";;;AAEA,MAAM,UAAU,cAAc;CAC5B,MAAM;EACJ,KAAK;EACL,SAAS;EACT,OAAO;EACP,aACE;EACF,MAAM;EACN,YAAY;EACZ,WAAW;EACX,QAAQ,CAAC,iBAAiB;EAC1B,MAAM;GAAC;GAAa;GAAc;GAAM;GAAU;EACnD;CACD,MAAM;EACJ,WAAW;EACX,WAAW;EACX,YAAY;EACZ,kBAAkB;EACnB;CACD,aAAa;EACX,aAAa;EACb,SAAS;EACT,WAAW;EACX,eAAe;EACf,UAAU;EACV,MAAM;EACP;CACD,UAAU;EACR,WAAW;EACX,SAAS;GACP,SAAS;GACT,OAAO;IAAC;IAAc;IAAS;IAAW;IAAY;IAAY;GACnE;EACD,QAAQ;GAAE,SAAS;GAAM,aAAa;GAAM;EAC5C,KAAK,EAAE,SAAS,MAAM;EACvB;CACF,CAAC;AAEF,sBAAe"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { DatabasePort } from "@contractspec/lib.runtime-sandbox";
|
|
2
|
+
|
|
3
|
+
//#region src/handlers/analytics.handlers.d.ts
|
|
4
|
+
|
|
5
|
+
interface Dashboard {
|
|
6
|
+
id: string;
|
|
7
|
+
projectId: string;
|
|
8
|
+
organizationId: string;
|
|
9
|
+
name: string;
|
|
10
|
+
slug: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
status: 'DRAFT' | 'PUBLISHED' | 'ARCHIVED';
|
|
13
|
+
refreshInterval: 'NONE' | 'MINUTE' | 'FIVE_MINUTES' | 'FIFTEEN_MINUTES' | 'HOUR' | 'DAY';
|
|
14
|
+
isPublic: boolean;
|
|
15
|
+
shareToken?: string;
|
|
16
|
+
createdAt: Date;
|
|
17
|
+
updatedAt: Date;
|
|
18
|
+
}
|
|
19
|
+
interface Widget {
|
|
20
|
+
id: string;
|
|
21
|
+
dashboardId: string;
|
|
22
|
+
name: string;
|
|
23
|
+
type: 'LINE_CHART' | 'BAR_CHART' | 'PIE_CHART' | 'AREA_CHART' | 'SCATTER_PLOT' | 'METRIC' | 'TABLE' | 'HEATMAP' | 'FUNNEL' | 'MAP' | 'TEXT' | 'EMBED';
|
|
24
|
+
gridX: number;
|
|
25
|
+
gridY: number;
|
|
26
|
+
gridWidth: number;
|
|
27
|
+
gridHeight: number;
|
|
28
|
+
queryId?: string;
|
|
29
|
+
config?: Record<string, unknown>;
|
|
30
|
+
createdAt: Date;
|
|
31
|
+
updatedAt: Date;
|
|
32
|
+
}
|
|
33
|
+
interface Query {
|
|
34
|
+
id: string;
|
|
35
|
+
projectId: string;
|
|
36
|
+
organizationId: string;
|
|
37
|
+
name: string;
|
|
38
|
+
description?: string;
|
|
39
|
+
type: 'SQL' | 'METRIC' | 'AGGREGATION' | 'CUSTOM';
|
|
40
|
+
definition: Record<string, unknown>;
|
|
41
|
+
sql?: string;
|
|
42
|
+
cacheTtlSeconds: number;
|
|
43
|
+
isShared: boolean;
|
|
44
|
+
createdAt: Date;
|
|
45
|
+
updatedAt: Date;
|
|
46
|
+
}
|
|
47
|
+
interface CreateDashboardInput {
|
|
48
|
+
name: string;
|
|
49
|
+
slug: string;
|
|
50
|
+
description?: string;
|
|
51
|
+
refreshInterval?: Dashboard['refreshInterval'];
|
|
52
|
+
}
|
|
53
|
+
interface AddWidgetInput {
|
|
54
|
+
dashboardId: string;
|
|
55
|
+
name: string;
|
|
56
|
+
type: Widget['type'];
|
|
57
|
+
gridX?: number;
|
|
58
|
+
gridY?: number;
|
|
59
|
+
gridWidth?: number;
|
|
60
|
+
gridHeight?: number;
|
|
61
|
+
queryId?: string;
|
|
62
|
+
config?: Record<string, unknown>;
|
|
63
|
+
}
|
|
64
|
+
interface CreateQueryInput {
|
|
65
|
+
name: string;
|
|
66
|
+
description?: string;
|
|
67
|
+
type: Query['type'];
|
|
68
|
+
definition: Record<string, unknown>;
|
|
69
|
+
sql?: string;
|
|
70
|
+
cacheTtlSeconds?: number;
|
|
71
|
+
isShared?: boolean;
|
|
72
|
+
}
|
|
73
|
+
interface ListDashboardsInput {
|
|
74
|
+
projectId: string;
|
|
75
|
+
status?: Dashboard['status'] | 'all';
|
|
76
|
+
search?: string;
|
|
77
|
+
limit?: number;
|
|
78
|
+
offset?: number;
|
|
79
|
+
}
|
|
80
|
+
interface ListDashboardsOutput {
|
|
81
|
+
dashboards: Dashboard[];
|
|
82
|
+
total: number;
|
|
83
|
+
}
|
|
84
|
+
interface ListQueriesInput {
|
|
85
|
+
projectId: string;
|
|
86
|
+
type?: Query['type'] | 'all';
|
|
87
|
+
isShared?: boolean;
|
|
88
|
+
search?: string;
|
|
89
|
+
limit?: number;
|
|
90
|
+
offset?: number;
|
|
91
|
+
}
|
|
92
|
+
interface ListQueriesOutput {
|
|
93
|
+
queries: Query[];
|
|
94
|
+
total: number;
|
|
95
|
+
}
|
|
96
|
+
declare function createAnalyticsHandlers(db: DatabasePort): {
|
|
97
|
+
listDashboards: (input: ListDashboardsInput) => Promise<ListDashboardsOutput>;
|
|
98
|
+
createDashboard: (input: CreateDashboardInput, context: {
|
|
99
|
+
projectId: string;
|
|
100
|
+
organizationId: string;
|
|
101
|
+
}) => Promise<Dashboard>;
|
|
102
|
+
getDashboard: (input: {
|
|
103
|
+
dashboardId?: string;
|
|
104
|
+
slug?: string;
|
|
105
|
+
shareToken?: string;
|
|
106
|
+
}) => Promise<Dashboard | null>;
|
|
107
|
+
updateDashboard: (dashboardId: string, updates: Partial<Pick<Dashboard, "name" | "description" | "status" | "refreshInterval" | "isPublic">>) => Promise<Dashboard>;
|
|
108
|
+
getWidgets: (dashboardId: string) => Promise<Widget[]>;
|
|
109
|
+
addWidget: (input: AddWidgetInput) => Promise<Widget>;
|
|
110
|
+
updateWidget: (widgetId: string, updates: Partial<Pick<Widget, "name" | "gridX" | "gridY" | "gridWidth" | "gridHeight" | "queryId" | "config">>) => Promise<Widget>;
|
|
111
|
+
deleteWidget: (widgetId: string) => Promise<void>;
|
|
112
|
+
listQueries: (input: ListQueriesInput) => Promise<ListQueriesOutput>;
|
|
113
|
+
createQuery: (input: CreateQueryInput, context: {
|
|
114
|
+
projectId: string;
|
|
115
|
+
organizationId: string;
|
|
116
|
+
}) => Promise<Query>;
|
|
117
|
+
getQuery: (queryId: string) => Promise<Query | null>;
|
|
118
|
+
};
|
|
119
|
+
type AnalyticsHandlers = ReturnType<typeof createAnalyticsHandlers>;
|
|
120
|
+
//#endregion
|
|
121
|
+
export { AddWidgetInput, AnalyticsHandlers, CreateDashboardInput, CreateQueryInput, Dashboard, ListDashboardsInput, ListDashboardsOutput, ListQueriesInput, ListQueriesOutput, Query, Widget, createAnalyticsHandlers };
|
|
122
|
+
//# sourceMappingURL=analytics.handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analytics.handlers.d.ts","names":[],"sources":["../../src/handlers/analytics.handlers.ts"],"sourcesContent":[],"mappings":";;;;AAwDa,UA5CI,SAAA,CA4CJ;EACA,EAAA,EAAA,MAAA;EAAI,SAAA,EAAA,MAAA;EAGA,cAAK,EAAA,MAAA;EAOR,IAAA,EAAA,MAAA;EAID,IAAA,EAAA,MAAA;EACA,WAAA,CAAA,EAAA,MAAA;EAAI,MAAA,EAAA,OAAA,GAAA,WAAA,GAAA,UAAA;EAGA,eAAA,EAAA,MAAoB,GAAA,QAAA,GAIjB,cAAS,GAAA,iBAAA,GAAA,MAAA,GAAA,KAAA;EAGZ,QAAA,EAAA,OAAc;EAYd,UAAA,CAAA,EAAA,MAAgB;EAUhB,SAAA,EA3EJ,IA2EI;EAQA,SAAA,EAlFJ,IAkFI;AAKjB;AASiB,UA7FA,MAAA,CA6FiB;EAyGlB,EAAA,EAAA,MAAA;EAA4B,WAAA,EAAA,MAAA;EAKjC,IAAA,EAAA,MAAA;EACE,IAAA,EAAA,YAAA,GAAA,WAAA,GAAA,WAAA,GAAA,YAAA,GAAA,cAAA,GAAA,QAAA,GAAA,OAAA,GAAA,SAAA,GAAA,QAAA,GAAA,KAAA,GAAA,MAAA,GAAA,OAA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AUH,QAAQ;sCAmDoC;uBAQtC,qBACN,QAAQ;uBA8CF;;;QAEN,QAAQ;iCAiC+B,QAAQ;;KAuBxC,iBAAA,GAAoB,kBAAkB"}
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import { web } from "@contractspec/lib.runtime-sandbox";
|
|
2
|
+
|
|
3
|
+
//#region src/handlers/analytics.handlers.ts
|
|
4
|
+
const { generateId } = web;
|
|
5
|
+
function rowToDashboard(row) {
|
|
6
|
+
return {
|
|
7
|
+
id: row.id,
|
|
8
|
+
projectId: row.projectId,
|
|
9
|
+
organizationId: row.organizationId,
|
|
10
|
+
name: row.name,
|
|
11
|
+
slug: row.slug,
|
|
12
|
+
description: row.description ?? void 0,
|
|
13
|
+
status: row.status,
|
|
14
|
+
refreshInterval: row.refreshInterval,
|
|
15
|
+
isPublic: row.isPublic === 1,
|
|
16
|
+
shareToken: row.shareToken ?? void 0,
|
|
17
|
+
createdAt: new Date(row.createdAt),
|
|
18
|
+
updatedAt: new Date(row.updatedAt)
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function rowToWidget(row) {
|
|
22
|
+
return {
|
|
23
|
+
id: row.id,
|
|
24
|
+
dashboardId: row.dashboardId,
|
|
25
|
+
name: row.name,
|
|
26
|
+
type: row.type,
|
|
27
|
+
gridX: row.gridX,
|
|
28
|
+
gridY: row.gridY,
|
|
29
|
+
gridWidth: row.gridWidth,
|
|
30
|
+
gridHeight: row.gridHeight,
|
|
31
|
+
queryId: row.queryId ?? void 0,
|
|
32
|
+
config: row.config ? JSON.parse(row.config) : void 0,
|
|
33
|
+
createdAt: new Date(row.createdAt),
|
|
34
|
+
updatedAt: new Date(row.updatedAt)
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function rowToQuery(row) {
|
|
38
|
+
return {
|
|
39
|
+
id: row.id,
|
|
40
|
+
projectId: row.projectId,
|
|
41
|
+
organizationId: row.organizationId,
|
|
42
|
+
name: row.name,
|
|
43
|
+
description: row.description ?? void 0,
|
|
44
|
+
type: row.type,
|
|
45
|
+
definition: JSON.parse(row.definition),
|
|
46
|
+
sql: row.sql ?? void 0,
|
|
47
|
+
cacheTtlSeconds: row.cacheTtlSeconds,
|
|
48
|
+
isShared: row.isShared === 1,
|
|
49
|
+
createdAt: new Date(row.createdAt),
|
|
50
|
+
updatedAt: new Date(row.updatedAt)
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function createAnalyticsHandlers(db) {
|
|
54
|
+
/**
|
|
55
|
+
* List dashboards
|
|
56
|
+
*/
|
|
57
|
+
async function listDashboards(input) {
|
|
58
|
+
const { projectId, status, search, limit = 20, offset = 0 } = input;
|
|
59
|
+
let whereClause = "WHERE projectId = ?";
|
|
60
|
+
const params = [projectId];
|
|
61
|
+
if (status && status !== "all") {
|
|
62
|
+
whereClause += " AND status = ?";
|
|
63
|
+
params.push(status);
|
|
64
|
+
}
|
|
65
|
+
if (search) {
|
|
66
|
+
whereClause += " AND (name LIKE ? OR description LIKE ?)";
|
|
67
|
+
params.push(`%${search}%`, `%${search}%`);
|
|
68
|
+
}
|
|
69
|
+
const total = (await db.query(`SELECT COUNT(*) as count FROM analytics_dashboard ${whereClause}`, params)).rows[0]?.count ?? 0;
|
|
70
|
+
return {
|
|
71
|
+
dashboards: (await db.query(`SELECT * FROM analytics_dashboard ${whereClause} ORDER BY updatedAt DESC LIMIT ? OFFSET ?`, [
|
|
72
|
+
...params,
|
|
73
|
+
limit,
|
|
74
|
+
offset
|
|
75
|
+
])).rows.map(rowToDashboard),
|
|
76
|
+
total
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Create a dashboard
|
|
81
|
+
*/
|
|
82
|
+
async function createDashboard(input, context) {
|
|
83
|
+
const id = generateId("dash");
|
|
84
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
85
|
+
await db.execute(`INSERT INTO analytics_dashboard (id, projectId, organizationId, name, slug, description, status, refreshInterval, isPublic, createdAt, updatedAt)
|
|
86
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
|
|
87
|
+
id,
|
|
88
|
+
context.projectId,
|
|
89
|
+
context.organizationId,
|
|
90
|
+
input.name,
|
|
91
|
+
input.slug,
|
|
92
|
+
input.description ?? null,
|
|
93
|
+
"DRAFT",
|
|
94
|
+
input.refreshInterval ?? "NONE",
|
|
95
|
+
0,
|
|
96
|
+
now,
|
|
97
|
+
now
|
|
98
|
+
]);
|
|
99
|
+
const rows = (await db.query(`SELECT * FROM analytics_dashboard WHERE id = ?`, [id])).rows;
|
|
100
|
+
return rowToDashboard(rows[0]);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Get a dashboard by ID or slug
|
|
104
|
+
*/
|
|
105
|
+
async function getDashboard(input) {
|
|
106
|
+
let whereClause = "";
|
|
107
|
+
const params = [];
|
|
108
|
+
if (input.dashboardId) {
|
|
109
|
+
whereClause = "WHERE id = ?";
|
|
110
|
+
params.push(input.dashboardId);
|
|
111
|
+
} else if (input.slug) {
|
|
112
|
+
whereClause = "WHERE slug = ?";
|
|
113
|
+
params.push(input.slug);
|
|
114
|
+
} else if (input.shareToken) {
|
|
115
|
+
whereClause = "WHERE shareToken = ?";
|
|
116
|
+
params.push(input.shareToken);
|
|
117
|
+
} else return null;
|
|
118
|
+
const rows = (await db.query(`SELECT * FROM analytics_dashboard ${whereClause}`, params)).rows;
|
|
119
|
+
return rows[0] ? rowToDashboard(rows[0]) : null;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Update dashboard
|
|
123
|
+
*/
|
|
124
|
+
async function updateDashboard(dashboardId, updates) {
|
|
125
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
126
|
+
const setClauses = ["updatedAt = ?"];
|
|
127
|
+
const params = [now];
|
|
128
|
+
if (updates.name !== void 0) {
|
|
129
|
+
setClauses.push("name = ?");
|
|
130
|
+
params.push(updates.name);
|
|
131
|
+
}
|
|
132
|
+
if (updates.description !== void 0) {
|
|
133
|
+
setClauses.push("description = ?");
|
|
134
|
+
params.push(updates.description);
|
|
135
|
+
}
|
|
136
|
+
if (updates.status !== void 0) {
|
|
137
|
+
setClauses.push("status = ?");
|
|
138
|
+
params.push(updates.status);
|
|
139
|
+
}
|
|
140
|
+
if (updates.refreshInterval !== void 0) {
|
|
141
|
+
setClauses.push("refreshInterval = ?");
|
|
142
|
+
params.push(updates.refreshInterval);
|
|
143
|
+
}
|
|
144
|
+
if (updates.isPublic !== void 0) {
|
|
145
|
+
setClauses.push("isPublic = ?");
|
|
146
|
+
params.push(updates.isPublic ? 1 : 0);
|
|
147
|
+
if (updates.isPublic) {
|
|
148
|
+
setClauses.push("shareToken = ?");
|
|
149
|
+
params.push(generateId("share"));
|
|
150
|
+
} else setClauses.push("shareToken = NULL");
|
|
151
|
+
}
|
|
152
|
+
params.push(dashboardId);
|
|
153
|
+
await db.execute(`UPDATE analytics_dashboard SET ${setClauses.join(", ")} WHERE id = ?`, params);
|
|
154
|
+
const rows = (await db.query(`SELECT * FROM analytics_dashboard WHERE id = ?`, [dashboardId])).rows;
|
|
155
|
+
return rowToDashboard(rows[0]);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Get widgets for a dashboard
|
|
159
|
+
*/
|
|
160
|
+
async function getWidgets(dashboardId) {
|
|
161
|
+
return (await db.query(`SELECT * FROM analytics_widget WHERE dashboardId = ? ORDER BY gridY, gridX`, [dashboardId])).rows.map(rowToWidget);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Add a widget to a dashboard
|
|
165
|
+
*/
|
|
166
|
+
async function addWidget(input) {
|
|
167
|
+
const id = generateId("widget");
|
|
168
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
169
|
+
await db.execute(`INSERT INTO analytics_widget (id, dashboardId, name, type, gridX, gridY, gridWidth, gridHeight, queryId, config, createdAt, updatedAt)
|
|
170
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
|
|
171
|
+
id,
|
|
172
|
+
input.dashboardId,
|
|
173
|
+
input.name,
|
|
174
|
+
input.type,
|
|
175
|
+
input.gridX ?? 0,
|
|
176
|
+
input.gridY ?? 0,
|
|
177
|
+
input.gridWidth ?? 6,
|
|
178
|
+
input.gridHeight ?? 4,
|
|
179
|
+
input.queryId ?? null,
|
|
180
|
+
input.config ? JSON.stringify(input.config) : null,
|
|
181
|
+
now,
|
|
182
|
+
now
|
|
183
|
+
]);
|
|
184
|
+
const rows = (await db.query(`SELECT * FROM analytics_widget WHERE id = ?`, [id])).rows;
|
|
185
|
+
return rowToWidget(rows[0]);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Update a widget
|
|
189
|
+
*/
|
|
190
|
+
async function updateWidget(widgetId, updates) {
|
|
191
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
192
|
+
const setClauses = ["updatedAt = ?"];
|
|
193
|
+
const params = [now];
|
|
194
|
+
if (updates.name !== void 0) {
|
|
195
|
+
setClauses.push("name = ?");
|
|
196
|
+
params.push(updates.name);
|
|
197
|
+
}
|
|
198
|
+
if (updates.gridX !== void 0) {
|
|
199
|
+
setClauses.push("gridX = ?");
|
|
200
|
+
params.push(updates.gridX);
|
|
201
|
+
}
|
|
202
|
+
if (updates.gridY !== void 0) {
|
|
203
|
+
setClauses.push("gridY = ?");
|
|
204
|
+
params.push(updates.gridY);
|
|
205
|
+
}
|
|
206
|
+
if (updates.gridWidth !== void 0) {
|
|
207
|
+
setClauses.push("gridWidth = ?");
|
|
208
|
+
params.push(updates.gridWidth);
|
|
209
|
+
}
|
|
210
|
+
if (updates.gridHeight !== void 0) {
|
|
211
|
+
setClauses.push("gridHeight = ?");
|
|
212
|
+
params.push(updates.gridHeight);
|
|
213
|
+
}
|
|
214
|
+
if (updates.queryId !== void 0) {
|
|
215
|
+
setClauses.push("queryId = ?");
|
|
216
|
+
params.push(updates.queryId ?? null);
|
|
217
|
+
}
|
|
218
|
+
if (updates.config !== void 0) {
|
|
219
|
+
setClauses.push("config = ?");
|
|
220
|
+
params.push(updates.config ? JSON.stringify(updates.config) : null);
|
|
221
|
+
}
|
|
222
|
+
params.push(widgetId);
|
|
223
|
+
await db.execute(`UPDATE analytics_widget SET ${setClauses.join(", ")} WHERE id = ?`, params);
|
|
224
|
+
const rows = (await db.query(`SELECT * FROM analytics_widget WHERE id = ?`, [widgetId])).rows;
|
|
225
|
+
return rowToWidget(rows[0]);
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Delete a widget
|
|
229
|
+
*/
|
|
230
|
+
async function deleteWidget(widgetId) {
|
|
231
|
+
await db.execute(`DELETE FROM analytics_widget WHERE id = ?`, [widgetId]);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* List queries
|
|
235
|
+
*/
|
|
236
|
+
async function listQueries(input) {
|
|
237
|
+
const { projectId, type, isShared, search, limit = 20, offset = 0 } = input;
|
|
238
|
+
let whereClause = "WHERE projectId = ?";
|
|
239
|
+
const params = [projectId];
|
|
240
|
+
if (type && type !== "all") {
|
|
241
|
+
whereClause += " AND type = ?";
|
|
242
|
+
params.push(type);
|
|
243
|
+
}
|
|
244
|
+
if (isShared !== void 0) {
|
|
245
|
+
whereClause += " AND isShared = ?";
|
|
246
|
+
params.push(isShared ? 1 : 0);
|
|
247
|
+
}
|
|
248
|
+
if (search) {
|
|
249
|
+
whereClause += " AND (name LIKE ? OR description LIKE ?)";
|
|
250
|
+
params.push(`%${search}%`, `%${search}%`);
|
|
251
|
+
}
|
|
252
|
+
const total = (await db.query(`SELECT COUNT(*) as count FROM analytics_query ${whereClause}`, params)).rows[0]?.count ?? 0;
|
|
253
|
+
return {
|
|
254
|
+
queries: (await db.query(`SELECT * FROM analytics_query ${whereClause} ORDER BY updatedAt DESC LIMIT ? OFFSET ?`, [
|
|
255
|
+
...params,
|
|
256
|
+
limit,
|
|
257
|
+
offset
|
|
258
|
+
])).rows.map(rowToQuery),
|
|
259
|
+
total
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Create a query
|
|
264
|
+
*/
|
|
265
|
+
async function createQuery(input, context) {
|
|
266
|
+
const id = generateId("query");
|
|
267
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
268
|
+
await db.execute(`INSERT INTO analytics_query (id, projectId, organizationId, name, description, type, definition, sql, cacheTtlSeconds, isShared, createdAt, updatedAt)
|
|
269
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
|
|
270
|
+
id,
|
|
271
|
+
context.projectId,
|
|
272
|
+
context.organizationId,
|
|
273
|
+
input.name,
|
|
274
|
+
input.description ?? null,
|
|
275
|
+
input.type,
|
|
276
|
+
JSON.stringify(input.definition),
|
|
277
|
+
input.sql ?? null,
|
|
278
|
+
input.cacheTtlSeconds ?? 300,
|
|
279
|
+
input.isShared ? 1 : 0,
|
|
280
|
+
now,
|
|
281
|
+
now
|
|
282
|
+
]);
|
|
283
|
+
const rows = (await db.query(`SELECT * FROM analytics_query WHERE id = ?`, [id])).rows;
|
|
284
|
+
return rowToQuery(rows[0]);
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Get a query by ID
|
|
288
|
+
*/
|
|
289
|
+
async function getQuery(queryId) {
|
|
290
|
+
const rows = (await db.query(`SELECT * FROM analytics_query WHERE id = ?`, [queryId])).rows;
|
|
291
|
+
return rows[0] ? rowToQuery(rows[0]) : null;
|
|
292
|
+
}
|
|
293
|
+
return {
|
|
294
|
+
listDashboards,
|
|
295
|
+
createDashboard,
|
|
296
|
+
getDashboard,
|
|
297
|
+
updateDashboard,
|
|
298
|
+
getWidgets,
|
|
299
|
+
addWidget,
|
|
300
|
+
updateWidget,
|
|
301
|
+
deleteWidget,
|
|
302
|
+
listQueries,
|
|
303
|
+
createQuery,
|
|
304
|
+
getQuery
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
//#endregion
|
|
309
|
+
export { createAnalyticsHandlers };
|
|
310
|
+
//# sourceMappingURL=analytics.handlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analytics.handlers.js","names":[],"sources":["../../src/handlers/analytics.handlers.ts"],"sourcesContent":["/**\n * Runtime-local Analytics Dashboard handlers\n *\n * Database-backed handlers for the analytics-dashboard template.\n */\nimport type { DatabasePort, DbRow } from '@contractspec/lib.runtime-sandbox';\n/* eslint-disable @typescript-eslint/no-non-null-assertion */\nimport { web } from '@contractspec/lib.runtime-sandbox';\nconst { generateId } = web;\n\n// ============ Types ============\n\nexport interface Dashboard {\n id: string;\n projectId: string;\n organizationId: string;\n name: string;\n slug: string;\n description?: string;\n status: 'DRAFT' | 'PUBLISHED' | 'ARCHIVED';\n refreshInterval:\n | 'NONE'\n | 'MINUTE'\n | 'FIVE_MINUTES'\n | 'FIFTEEN_MINUTES'\n | 'HOUR'\n | 'DAY';\n isPublic: boolean;\n shareToken?: string;\n createdAt: Date;\n updatedAt: Date;\n}\n\nexport interface Widget {\n id: string;\n dashboardId: string;\n name: string;\n type:\n | 'LINE_CHART'\n | 'BAR_CHART'\n | 'PIE_CHART'\n | 'AREA_CHART'\n | 'SCATTER_PLOT'\n | 'METRIC'\n | 'TABLE'\n | 'HEATMAP'\n | 'FUNNEL'\n | 'MAP'\n | 'TEXT'\n | 'EMBED';\n gridX: number;\n gridY: number;\n gridWidth: number;\n gridHeight: number;\n queryId?: string;\n config?: Record<string, unknown>;\n createdAt: Date;\n updatedAt: Date;\n}\n\nexport interface Query {\n id: string;\n projectId: string;\n organizationId: string;\n name: string;\n description?: string;\n type: 'SQL' | 'METRIC' | 'AGGREGATION' | 'CUSTOM';\n definition: Record<string, unknown>;\n sql?: string;\n cacheTtlSeconds: number;\n isShared: boolean;\n createdAt: Date;\n updatedAt: Date;\n}\n\nexport interface CreateDashboardInput {\n name: string;\n slug: string;\n description?: string;\n refreshInterval?: Dashboard['refreshInterval'];\n}\n\nexport interface AddWidgetInput {\n dashboardId: string;\n name: string;\n type: Widget['type'];\n gridX?: number;\n gridY?: number;\n gridWidth?: number;\n gridHeight?: number;\n queryId?: string;\n config?: Record<string, unknown>;\n}\n\nexport interface CreateQueryInput {\n name: string;\n description?: string;\n type: Query['type'];\n definition: Record<string, unknown>;\n sql?: string;\n cacheTtlSeconds?: number;\n isShared?: boolean;\n}\n\nexport interface ListDashboardsInput {\n projectId: string;\n status?: Dashboard['status'] | 'all';\n search?: string;\n limit?: number;\n offset?: number;\n}\n\nexport interface ListDashboardsOutput {\n dashboards: Dashboard[];\n total: number;\n}\n\nexport interface ListQueriesInput {\n projectId: string;\n type?: Query['type'] | 'all';\n isShared?: boolean;\n search?: string;\n limit?: number;\n offset?: number;\n}\n\nexport interface ListQueriesOutput {\n queries: Query[];\n total: number;\n}\n\n// ============ Row Types ============\n\ninterface DashboardRow {\n id: string;\n projectId: string;\n organizationId: string;\n name: string;\n slug: string;\n description: string | null;\n status: string;\n refreshInterval: string;\n isPublic: number;\n shareToken: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\ninterface WidgetRow {\n id: string;\n dashboardId: string;\n name: string;\n type: string;\n gridX: number;\n gridY: number;\n gridWidth: number;\n gridHeight: number;\n queryId: string | null;\n config: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\ninterface QueryRow {\n id: string;\n projectId: string;\n organizationId: string;\n name: string;\n description: string | null;\n type: string;\n definition: string;\n sql: string | null;\n cacheTtlSeconds: number;\n isShared: number;\n createdAt: string;\n updatedAt: string;\n}\n\nfunction rowToDashboard(row: DashboardRow): Dashboard {\n return {\n id: row.id,\n projectId: row.projectId,\n organizationId: row.organizationId,\n name: row.name,\n slug: row.slug,\n description: row.description ?? undefined,\n status: row.status as Dashboard['status'],\n refreshInterval: row.refreshInterval as Dashboard['refreshInterval'],\n isPublic: row.isPublic === 1,\n shareToken: row.shareToken ?? undefined,\n createdAt: new Date(row.createdAt),\n updatedAt: new Date(row.updatedAt),\n };\n}\n\nfunction rowToWidget(row: WidgetRow): Widget {\n return {\n id: row.id,\n dashboardId: row.dashboardId,\n name: row.name,\n type: row.type as Widget['type'],\n gridX: row.gridX,\n gridY: row.gridY,\n gridWidth: row.gridWidth,\n gridHeight: row.gridHeight,\n queryId: row.queryId ?? undefined,\n config: row.config ? JSON.parse(row.config) : undefined,\n createdAt: new Date(row.createdAt),\n updatedAt: new Date(row.updatedAt),\n };\n}\n\nfunction rowToQuery(row: QueryRow): Query {\n return {\n id: row.id,\n projectId: row.projectId,\n organizationId: row.organizationId,\n name: row.name,\n description: row.description ?? undefined,\n type: row.type as Query['type'],\n definition: JSON.parse(row.definition),\n sql: row.sql ?? undefined,\n cacheTtlSeconds: row.cacheTtlSeconds,\n isShared: row.isShared === 1,\n createdAt: new Date(row.createdAt),\n updatedAt: new Date(row.updatedAt),\n };\n}\n\n// ============ Handler Factory ============\n\nexport function createAnalyticsHandlers(db: DatabasePort) {\n /**\n * List dashboards\n */\n async function listDashboards(\n input: ListDashboardsInput\n ): Promise<ListDashboardsOutput> {\n const { projectId, status, search, limit = 20, offset = 0 } = input;\n\n let whereClause = 'WHERE projectId = ?';\n const params: (string | number)[] = [projectId];\n\n if (status && status !== 'all') {\n whereClause += ' AND status = ?';\n params.push(status);\n }\n\n if (search) {\n whereClause += ' AND (name LIKE ? OR description LIKE ?)';\n params.push(`%${search}%`, `%${search}%`);\n }\n\n const countResult = (\n await db.query(\n `SELECT COUNT(*) as count FROM analytics_dashboard ${whereClause}`,\n params\n )\n ).rows as DbRow[];\n const total = (countResult[0]?.count as number) ?? 0;\n\n const rows = (\n await db.query(\n `SELECT * FROM analytics_dashboard ${whereClause} ORDER BY updatedAt DESC LIMIT ? OFFSET ?`,\n [...params, limit, offset]\n )\n ).rows as unknown as DashboardRow[];\n\n return {\n dashboards: rows.map(rowToDashboard),\n total,\n };\n }\n\n /**\n * Create a dashboard\n */\n async function createDashboard(\n input: CreateDashboardInput,\n context: { projectId: string; organizationId: string }\n ): Promise<Dashboard> {\n const id = generateId('dash');\n const now = new Date().toISOString();\n\n await db.execute(\n `INSERT INTO analytics_dashboard (id, projectId, organizationId, name, slug, description, status, refreshInterval, isPublic, createdAt, updatedAt)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,\n [\n id,\n context.projectId,\n context.organizationId,\n input.name,\n input.slug,\n input.description ?? null,\n 'DRAFT',\n input.refreshInterval ?? 'NONE',\n 0,\n now,\n now,\n ]\n );\n\n const rows = (\n await db.query(`SELECT * FROM analytics_dashboard WHERE id = ?`, [id])\n ).rows as unknown as DashboardRow[];\n\n return rowToDashboard(rows[0]!);\n }\n\n /**\n * Get a dashboard by ID or slug\n */\n async function getDashboard(input: {\n dashboardId?: string;\n slug?: string;\n shareToken?: string;\n }): Promise<Dashboard | null> {\n let whereClause = '';\n const params: string[] = [];\n\n if (input.dashboardId) {\n whereClause = 'WHERE id = ?';\n params.push(input.dashboardId);\n } else if (input.slug) {\n whereClause = 'WHERE slug = ?';\n params.push(input.slug);\n } else if (input.shareToken) {\n whereClause = 'WHERE shareToken = ?';\n params.push(input.shareToken);\n } else {\n return null;\n }\n\n const rows = (\n await db.query(`SELECT * FROM analytics_dashboard ${whereClause}`, params)\n ).rows as unknown as DashboardRow[];\n\n return rows[0] ? rowToDashboard(rows[0]) : null;\n }\n\n /**\n * Update dashboard\n */\n async function updateDashboard(\n dashboardId: string,\n updates: Partial<\n Pick<\n Dashboard,\n 'name' | 'description' | 'status' | 'refreshInterval' | 'isPublic'\n >\n >\n ): Promise<Dashboard> {\n const now = new Date().toISOString();\n const setClauses: string[] = ['updatedAt = ?'];\n const params: (string | number)[] = [now];\n\n if (updates.name !== undefined) {\n setClauses.push('name = ?');\n params.push(updates.name);\n }\n if (updates.description !== undefined) {\n setClauses.push('description = ?');\n params.push(updates.description);\n }\n if (updates.status !== undefined) {\n setClauses.push('status = ?');\n params.push(updates.status);\n }\n if (updates.refreshInterval !== undefined) {\n setClauses.push('refreshInterval = ?');\n params.push(updates.refreshInterval);\n }\n if (updates.isPublic !== undefined) {\n setClauses.push('isPublic = ?');\n params.push(updates.isPublic ? 1 : 0);\n\n // Generate share token if making public\n if (updates.isPublic) {\n setClauses.push('shareToken = ?');\n params.push(generateId('share'));\n } else {\n setClauses.push('shareToken = NULL');\n }\n }\n\n params.push(dashboardId);\n\n await db.execute(\n `UPDATE analytics_dashboard SET ${setClauses.join(', ')} WHERE id = ?`,\n params\n );\n\n const rows = (\n await db.query(`SELECT * FROM analytics_dashboard WHERE id = ?`, [\n dashboardId,\n ])\n ).rows as unknown as DashboardRow[];\n\n return rowToDashboard(rows[0]!);\n }\n\n /**\n * Get widgets for a dashboard\n */\n async function getWidgets(dashboardId: string): Promise<Widget[]> {\n const rows = (\n await db.query(\n `SELECT * FROM analytics_widget WHERE dashboardId = ? ORDER BY gridY, gridX`,\n [dashboardId]\n )\n ).rows as unknown as WidgetRow[];\n\n return rows.map(rowToWidget);\n }\n\n /**\n * Add a widget to a dashboard\n */\n async function addWidget(input: AddWidgetInput): Promise<Widget> {\n const id = generateId('widget');\n const now = new Date().toISOString();\n\n await db.execute(\n `INSERT INTO analytics_widget (id, dashboardId, name, type, gridX, gridY, gridWidth, gridHeight, queryId, config, createdAt, updatedAt)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,\n [\n id,\n input.dashboardId,\n input.name,\n input.type,\n input.gridX ?? 0,\n input.gridY ?? 0,\n input.gridWidth ?? 6,\n input.gridHeight ?? 4,\n input.queryId ?? null,\n input.config ? JSON.stringify(input.config) : null,\n now,\n now,\n ]\n );\n\n const rows = (\n await db.query(`SELECT * FROM analytics_widget WHERE id = ?`, [id])\n ).rows as unknown as WidgetRow[];\n\n return rowToWidget(rows[0]!);\n }\n\n /**\n * Update a widget\n */\n async function updateWidget(\n widgetId: string,\n updates: Partial<\n Pick<\n Widget,\n | 'name'\n | 'gridX'\n | 'gridY'\n | 'gridWidth'\n | 'gridHeight'\n | 'queryId'\n | 'config'\n >\n >\n ): Promise<Widget> {\n const now = new Date().toISOString();\n const setClauses: string[] = ['updatedAt = ?'];\n const params: (string | number | null)[] = [now];\n\n if (updates.name !== undefined) {\n setClauses.push('name = ?');\n params.push(updates.name);\n }\n if (updates.gridX !== undefined) {\n setClauses.push('gridX = ?');\n params.push(updates.gridX);\n }\n if (updates.gridY !== undefined) {\n setClauses.push('gridY = ?');\n params.push(updates.gridY);\n }\n if (updates.gridWidth !== undefined) {\n setClauses.push('gridWidth = ?');\n params.push(updates.gridWidth);\n }\n if (updates.gridHeight !== undefined) {\n setClauses.push('gridHeight = ?');\n params.push(updates.gridHeight);\n }\n if (updates.queryId !== undefined) {\n setClauses.push('queryId = ?');\n params.push(updates.queryId ?? null);\n }\n if (updates.config !== undefined) {\n setClauses.push('config = ?');\n params.push(updates.config ? JSON.stringify(updates.config) : null);\n }\n\n params.push(widgetId);\n\n await db.execute(\n `UPDATE analytics_widget SET ${setClauses.join(', ')} WHERE id = ?`,\n params\n );\n\n const rows = (\n await db.query(`SELECT * FROM analytics_widget WHERE id = ?`, [widgetId])\n ).rows as unknown as WidgetRow[];\n\n return rowToWidget(rows[0]!);\n }\n\n /**\n * Delete a widget\n */\n async function deleteWidget(widgetId: string): Promise<void> {\n await db.execute(`DELETE FROM analytics_widget WHERE id = ?`, [widgetId]);\n }\n\n /**\n * List queries\n */\n async function listQueries(\n input: ListQueriesInput\n ): Promise<ListQueriesOutput> {\n const { projectId, type, isShared, search, limit = 20, offset = 0 } = input;\n\n let whereClause = 'WHERE projectId = ?';\n const params: (string | number)[] = [projectId];\n\n if (type && type !== 'all') {\n whereClause += ' AND type = ?';\n params.push(type);\n }\n\n if (isShared !== undefined) {\n whereClause += ' AND isShared = ?';\n params.push(isShared ? 1 : 0);\n }\n\n if (search) {\n whereClause += ' AND (name LIKE ? OR description LIKE ?)';\n params.push(`%${search}%`, `%${search}%`);\n }\n\n const countResult = (\n await db.query(\n `SELECT COUNT(*) as count FROM analytics_query ${whereClause}`,\n params\n )\n ).rows as DbRow[];\n const total = (countResult[0]?.count as number) ?? 0;\n\n const rows = (\n await db.query(\n `SELECT * FROM analytics_query ${whereClause} ORDER BY updatedAt DESC LIMIT ? OFFSET ?`,\n [...params, limit, offset]\n )\n ).rows as unknown as QueryRow[];\n\n return {\n queries: rows.map(rowToQuery),\n total,\n };\n }\n\n /**\n * Create a query\n */\n async function createQuery(\n input: CreateQueryInput,\n context: { projectId: string; organizationId: string }\n ): Promise<Query> {\n const id = generateId('query');\n const now = new Date().toISOString();\n\n await db.execute(\n `INSERT INTO analytics_query (id, projectId, organizationId, name, description, type, definition, sql, cacheTtlSeconds, isShared, createdAt, updatedAt)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,\n [\n id,\n context.projectId,\n context.organizationId,\n input.name,\n input.description ?? null,\n input.type,\n JSON.stringify(input.definition),\n input.sql ?? null,\n input.cacheTtlSeconds ?? 300,\n input.isShared ? 1 : 0,\n now,\n now,\n ]\n );\n\n const rows = (\n await db.query(`SELECT * FROM analytics_query WHERE id = ?`, [id])\n ).rows as unknown as QueryRow[];\n\n return rowToQuery(rows[0]!);\n }\n\n /**\n * Get a query by ID\n */\n async function getQuery(queryId: string): Promise<Query | null> {\n const rows = (\n await db.query(`SELECT * FROM analytics_query WHERE id = ?`, [queryId])\n ).rows as unknown as QueryRow[];\n\n return rows[0] ? rowToQuery(rows[0]) : null;\n }\n\n return {\n listDashboards,\n createDashboard,\n getDashboard,\n updateDashboard,\n getWidgets,\n addWidget,\n updateWidget,\n deleteWidget,\n listQueries,\n createQuery,\n getQuery,\n };\n}\n\nexport type AnalyticsHandlers = ReturnType<typeof createAnalyticsHandlers>;\n"],"mappings":";;;AAQA,MAAM,EAAE,eAAe;AA0KvB,SAAS,eAAe,KAA8B;AACpD,QAAO;EACL,IAAI,IAAI;EACR,WAAW,IAAI;EACf,gBAAgB,IAAI;EACpB,MAAM,IAAI;EACV,MAAM,IAAI;EACV,aAA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AAI,aAAa,QAAW;AAC1B,kBAAe;AACf,UAAO,KAAK,WAAW,IAAI,EAAE;;AAG/B,MAAI,QAAQ;AACV,kBAAe;AACf,UAAO,KAAK,IAAI,OAAO,IAAI,IAAI,OAAO,GAAG;;EAS3C,MAAM,SALJ,MAAM,GAAG,MACP,iDAAiD,eACjD,OACD,EACD,KACyB,IAAI,SAAoB;AASnD,SAAO;GACL,UAPA,MAAM,GAAG,MACP,iCAAiC,YAAY,4CAC7C;IAAC,GAAG;IAAQ;IAAO;IAAO,CAC3B,EACD,KAGc,IAAI,WAAW;GAC7B;GACD;;;;;CAMH,eAAe,YACb,OACA,SACgB;EAChB,MAAM,KAAK,WAAW,QAAQ;EAC9B,MAAM,uBAAM,IAAI,MAAM,EAAC,aAAa;AAEpC,QAAM,GAAG,QACP;qDAEA;GACE;GACA,QAAQ;GACR,QAAQ;GACR,MAAM;GACN,MAAM,eAAe;GACrB,MAAM;GACN,KAAK,UAAU,MAAM,WAAW;GAChC,MAAM,OAAO;GACb,MAAM,mBAAmB;GACzB,MAAM,WAAW,IAAI;GACrB;GACA;GACD,CACF;EAED,MAAM,QACJ,MAAM,GAAG,MAAM,8CAA8C,CAAC,GAAG,CAAC,EAClE;AAEF,SAAO,WAAW,KAAK,GAAI;;;;;CAM7B,eAAe,SAAS,SAAwC;EAC9D,MAAM,QACJ,MAAM,GAAG,MAAM,8CAA8C,CAAC,QAAQ,CAAC,EACvE;AAEF,SAAO,KAAK,KAAK,WAAW,KAAK,GAAG,GAAG;;AAGzC,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { AddWidgetInput, AnalyticsHandlers, CreateDashboardInput, CreateQueryInput, Dashboard, ListDashboardsInput, ListDashboardsOutput, ListQueriesInput, ListQueriesOutput, Query, Widget, createAnalyticsHandlers } from "./analytics.handlers.js";
|
|
2
|
+
export { AddWidgetInput, AnalyticsHandlers, CreateDashboardInput, CreateQueryInput, Dashboard, ListDashboardsInput, ListDashboardsOutput, ListQueriesInput, ListQueriesOutput, Query, Widget, createAnalyticsHandlers };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AnalyticsDashboardFeature } from "./dashboard.feature.js";
|
|
2
|
+
import { AddWidgetInput, AnalyticsHandlers, CreateDashboardInput, CreateQueryInput, Dashboard, ListDashboardsInput, ListDashboardsOutput, ListQueriesInput, ListQueriesOutput, Query, Widget, createAnalyticsHandlers } from "./handlers/analytics.handlers.js";
|
|
3
|
+
import { QueryTypeEnum } from "./query/query.enum.js";
|
|
4
|
+
import { CreateQueryInputModel, ExecuteQueryInputModel, QueryModel, QueryResultModel } from "./query/query.schema.js";
|
|
5
|
+
import { CreateQueryContract, ExecuteQueryContract } from "./query/query.operation.js";
|
|
6
|
+
import "./query/index.js";
|
|
7
|
+
import { analyticsDashboardMarkdownRenderer, dashboardListMarkdownRenderer, queryBuilderMarkdownRenderer } from "./ui/renderers/analytics.markdown.js";
|
|
8
|
+
import { AnalyticsDashboard } from "./ui/AnalyticsDashboard.js";
|
|
9
|
+
import { AnalyticsStats, useAnalyticsData } from "./ui/hooks/useAnalyticsData.js";
|
|
10
|
+
import "./ui/index.js";
|
|
11
|
+
import { AggregationDefinition, BasicQueryEngine, ColumnDefinition, CustomQueryDefinition, DimensionDefinition, FilterDefinition, IQueryCache, IQueryEngine, InMemoryQueryCache, MeasureDefinition, OrderByDefinition, QueryDefinition, QueryParameters, QueryResult, createQueryEngine } from "./query-engine/index.js";
|
|
12
|
+
export { AddWidgetInput, AggregationDefinition, AnalyticsDashboard, AnalyticsDashboardFeature, AnalyticsHandlers, AnalyticsStats, BasicQueryEngine, ColumnDefinition, CreateDashboardInput, CreateQueryContract, CreateQueryInput, CreateQueryInputModel, CustomQueryDefinition, Dashboard, DimensionDefinition, ExecuteQueryContract, ExecuteQueryInputModel, FilterDefinition, IQueryCache, IQueryEngine, InMemoryQueryCache, ListDashboardsInput, ListDashboardsOutput, ListQueriesInput, ListQueriesOutput, MeasureDefinition, OrderByDefinition, Query, QueryDefinition, QueryModel, QueryParameters, QueryResult, QueryResultModel, QueryTypeEnum, Widget, analyticsDashboardMarkdownRenderer, createAnalyticsHandlers, createQueryEngine, dashboardListMarkdownRenderer, queryBuilderMarkdownRenderer, useAnalyticsData };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AnalyticsDashboardFeature } from "./dashboard.feature.js";
|
|
2
|
+
import { QueryTypeEnum } from "./query/query.enum.js";
|
|
3
|
+
import { CreateQueryInputModel, ExecuteQueryInputModel, QueryModel, QueryResultModel } from "./query/query.schema.js";
|
|
4
|
+
import { CreateQueryContract, ExecuteQueryContract } from "./query/query.operation.js";
|
|
5
|
+
import "./query/index.js";
|
|
6
|
+
import { createAnalyticsHandlers } from "./handlers/analytics.handlers.js";
|
|
7
|
+
import { analyticsDashboardMarkdownRenderer, dashboardListMarkdownRenderer, queryBuilderMarkdownRenderer } from "./ui/renderers/analytics.markdown.js";
|
|
8
|
+
import { useAnalyticsData } from "./ui/hooks/useAnalyticsData.js";
|
|
9
|
+
import { AnalyticsDashboard } from "./ui/AnalyticsDashboard.js";
|
|
10
|
+
import "./ui/index.js";
|
|
11
|
+
import { BasicQueryEngine, InMemoryQueryCache, createQueryEngine } from "./query-engine/index.js";
|
|
12
|
+
|
|
13
|
+
export { AnalyticsDashboard, AnalyticsDashboardFeature, BasicQueryEngine, CreateQueryContract, CreateQueryInputModel, ExecuteQueryContract, ExecuteQueryInputModel, InMemoryQueryCache, QueryModel, QueryResultModel, QueryTypeEnum, analyticsDashboardMarkdownRenderer, createAnalyticsHandlers, createQueryEngine, dashboardListMarkdownRenderer, queryBuilderMarkdownRenderer, useAnalyticsData };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { QueryTypeEnum } from "./query.enum.js";
|
|
2
|
+
import { CreateQueryInputModel, ExecuteQueryInputModel, QueryModel, QueryResultModel } from "./query.schema.js";
|
|
3
|
+
import { CreateQueryContract, ExecuteQueryContract } from "./query.operation.js";
|
|
4
|
+
export { CreateQueryContract, CreateQueryInputModel, ExecuteQueryContract, ExecuteQueryInputModel, QueryModel, QueryResultModel, QueryTypeEnum };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { QueryTypeEnum } from "./query.enum.js";
|
|
2
|
+
import { CreateQueryInputModel, ExecuteQueryInputModel, QueryModel, QueryResultModel } from "./query.schema.js";
|
|
3
|
+
import { CreateQueryContract, ExecuteQueryContract } from "./query.operation.js";
|
|
4
|
+
|
|
5
|
+
export { CreateQueryContract, CreateQueryInputModel, ExecuteQueryContract, ExecuteQueryInputModel, QueryModel, QueryResultModel, QueryTypeEnum };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as _contractspec_lib_schema118 from "@contractspec/lib.schema";
|
|
2
|
+
|
|
3
|
+
//#region src/query/query.enum.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Query type enum.
|
|
6
|
+
*/
|
|
7
|
+
declare const QueryTypeEnum: _contractspec_lib_schema118.EnumType<[string, string, string, string]>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { QueryTypeEnum };
|
|
10
|
+
//# sourceMappingURL=query.enum.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.enum.d.ts","names":[],"sources":["../../src/query/query.enum.ts"],"sourcesContent":[],"mappings":";;;;;;AAKa,cAAA,aAKX,EAAA,2BAAA,CALwB,QAAA,CAAA,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineEnum } from "@contractspec/lib.schema";
|
|
2
|
+
|
|
3
|
+
//#region src/query/query.enum.ts
|
|
4
|
+
/**
|
|
5
|
+
* Query type enum.
|
|
6
|
+
*/
|
|
7
|
+
const QueryTypeEnum = defineEnum("QueryType", [
|
|
8
|
+
"SQL",
|
|
9
|
+
"METRIC",
|
|
10
|
+
"AGGREGATION",
|
|
11
|
+
"CUSTOM"
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { QueryTypeEnum };
|
|
16
|
+
//# sourceMappingURL=query.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.enum.js","names":[],"sources":["../../src/query/query.enum.ts"],"sourcesContent":["import { defineEnum } from '@contractspec/lib.schema';\n\n/**\n * Query type enum.\n */\nexport const QueryTypeEnum = defineEnum('QueryType', [\n 'SQL',\n 'METRIC',\n 'AGGREGATION',\n 'CUSTOM',\n]);\n"],"mappings":";;;;;;AAKA,MAAa,gBAAgB,WAAW,aAAa;CACnD;CACA;CACA;CACA;CACD,CAAC"}
|