Interface: SavedReport
Defined in: server/insights/saved-reports-repository.ts:34
Repository for savedReports rows — a direct copy of
DataTableViewsRepository's shape: org-scoped CRUD, per-call userId
owner checks + audit columns, visibility normalize-on-read, and
definition normalize-on-read via the shared normalizeSavedReportDefinition
(forms normalize-on-read pattern).
Extends BaseRepository so this.tx resolves to the active transaction
when a mutation is wrapped in TransactionManager.startOrUseTransaction
(ownership check + write ride one transaction) and the raw client
otherwise. All writes go to the PRIMARY ambient client (never the replica).
Properties
createdAt
createdAt: Date;Defined in: server/insights/saved-reports-repository.ts:42
createdBy
createdBy: string | null;Defined in: server/insights/saved-reports-repository.ts:44
definition
definition: {
aggregations?: {
alias: string;
field?: string;
fn: "min" | "max" | "count" | "avg" | "sum";
}[];
columns: string[];
filter?: FilterNode;
groupBy?: {
bucket?: "year" | "month" | "day" | "week" | "quarter";
field: string;
}[];
schemaVersion: 1;
sort: {
by: string;
direction: "asc" | "desc";
}[];
subject: string;
timezone: string;
totals?: boolean;
};Defined in: server/insights/saved-reports-repository.ts:40
aggregations?
optional aggregations?: {
alias: string;
field?: string;
fn: "min" | "max" | "count" | "avg" | "sum";
}[];columns
columns: string[];The SELECT list — and the ONLY source of output columns, for grouped runs
as much as detail runs: the compiler derives its projection from columns
alone and never from groupBy/aggregations. So an empty columns has no
compilable projection at all (not merely a semantically odd one), which
makes it a STRUCTURAL failure and puts the check here rather than in
validateDefinition. Keeping it in the schema also means every surface
that parses a definition — run input, saved-report create/update,
normalizeSavedReportDefinition on read, canned reports in the registry —
fails closed without having to remember a second validation pass.
filter?
optional filter?: FilterNode;groupBy?
optional groupBy?: {
bucket?: "year" | "month" | "day" | "week" | "quarter";
field: string;
}[];schemaVersion
schemaVersion: 1;sort
sort: {
by: string;
direction: "asc" | "desc";
}[];subject
subject: string;timezone
timezone: string;totals?
optional totals?: boolean;description
description: string | null;Defined in: server/insights/saved-reports-repository.ts:38
id
id: string;Defined in: server/insights/saved-reports-repository.ts:35
name
name: string;Defined in: server/insights/saved-reports-repository.ts:37
organizationId
organizationId: string;Defined in: server/insights/saved-reports-repository.ts:36
subjectKey
subjectKey: string;Defined in: server/insights/saved-reports-repository.ts:39
updatedAt
updatedAt: Date;Defined in: server/insights/saved-reports-repository.ts:43
updatedBy
updatedBy: string | null;Defined in: server/insights/saved-reports-repository.ts:45
visibility
visibility: "public" | "private";Defined in: server/insights/saved-reports-repository.ts:41