Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

ralph(M15-123): Per-module fixes: packages/core/src/modules/report - R1, R2, R13 and the findings no rule covers

ralphb6b72b9b5980
diff --git a/packages/core/src/modules/report/report.constants.ts b/packages/core/src/modules/report/report.constants.ts
index df3713ad3..287f03457 100644
--- a/packages/core/src/modules/report/report.constants.ts
+++ b/packages/core/src/modules/report/report.constants.ts
@@ -1,10 +1,8 @@
-// Moved from packages/constants/index.ts and packages/validation/src/index.ts
-// (M7-006, ADR-008's module map: report owns "C" for the chart/report/widget
-// vocabulary). Both origin files become re-export shims onto this one (same
-// shape as packages/validation/src/cohort.validation.ts since M5-003), so
-// existing packages/constants / packages/validation importers (the chart
-// engine, apps/start's report builder, packages/trpc's report/dashboard/
-// widget routers) keep resolving these symbols unchanged.
+// Ported from V1's packages/constants + packages/validation (M7-006,
+// ADR-008's module map: report owns "C" for the chart/report/widget
+// vocabulary) — neither package exists in this tree; every importer here
+// (the chart engine, apps/start's report builder) reaches these symbols
+// through this file directly.
//
// `getDefaultIntervalByDates` is REWRITTEN from date-fns
// (differenceInDays/isSameDay) to plain Date math per the module map. Every
diff --git a/packages/core/src/modules/report/report.rpc.ts b/packages/core/src/modules/report/report.rpc.ts
index 168667fef..4f1355619 100644
--- a/packages/core/src/modules/report/report.rpc.ts
+++ b/packages/core/src/modules/report/report.rpc.ts
@@ -171,34 +171,6 @@ export const reportRouter = createTRPCRouter({
return ctx.services.report.updateReportLayout({ reportId, layout });
}),
- getLayouts: protectedProcedure
- .input(
- z.object({
- dashboardId: z.string(),
- projectId: z.string(),
- })
- )
- .query(async ({ input: { dashboardId, projectId }, ctx }) => {
- await ctx.services.auth.requireProjectAccess({
- userId: ctx.session.userId,
- projectId,
- level: 'read',
- });
-
- // The access check above only proves the caller owns `projectId`. Bind
- // the caller-supplied `dashboardId` to that project as well, otherwise a
- // dashboard from another organization can be read through this handler.
- const dashboard = await ctx.services.dashboard.getDashboardById(
- dashboardId,
- projectId
- );
- if (!dashboard) {
- throw new TRPCNotFoundError('Dashboard not found');
- }
-
- return ctx.services.report.getReportLayouts({ dashboardId, projectId });
- }),
-
resetLayout: protectedProcedure
.input(
z.object({
@@ -213,8 +185,10 @@ export const reportRouter = createTRPCRouter({
level: 'write',
});
- // Same as `getLayouts`: bind the dashboard to the access-checked project
- // before deleting anything, so a foreign dashboard cannot be wiped.
+ // The access check above only proves the caller owns `projectId`. Bind
+ // the caller-supplied `dashboardId` to that project as well before
+ // deleting anything, otherwise a dashboard from another organization
+ // can be wiped through this handler.
const dashboard = await ctx.services.dashboard.getDashboardById(
dashboardId,
projectId
diff --git a/packages/core/src/modules/report/report.service.ts b/packages/core/src/modules/report/report.service.ts
index 505355d4a..7531a6c73 100644
--- a/packages/core/src/modules/report/report.service.ts
+++ b/packages/core/src/modules/report/report.service.ts
@@ -1,7 +1,7 @@
-// Moved from packages/db/src/services/reports.service.ts, plus the
-// create/update/move/delete/duplicate/layout mutation bodies
+// Ported from V1's packages/db/src/services/reports.service.ts, plus the
+// create/update/move/delete/duplicate/layout mutation bodies V1's
// packages/trpc/src/routers/report.ts held inline (M7-006, ADR-008's module
-// map: report owns "R,S,C").
+// map: report owns "R,S,C") — neither package exists in this tree.
//
// M10-003: every function takes `ServiceDeps` and reaches Postgres as
// `deps.db`; `loadDb()` and the `@openpanel/core` self-barrel import are