Kaizen
Browse modulesInsightsinsights/serverClasses

Class: ModelService

Defined in: server/insights/services/model-service.ts:19

Read-only projections of the reporting model — metadata only, never physical bindings. Safe to expose to a consumer's router that serves the builder and dashboards.

Constructors

Constructor

new ModelService(model: ReportingModel): ModelService;

Defined in: server/insights/services/model-service.ts:20

Parameters

ParameterType
modelReportingModel

Returns

ModelService

Methods

getCannedReport()

getCannedReport(key: string): ResolvedCannedReport;

Defined in: server/insights/services/model-service.ts:37

A canned report by key, or throw UnknownCannedReportError — resolved through the model's own O(1) map rather than scanning the metadata list.

Parameters

ParameterType
keystring

Returns

ResolvedCannedReport


getDashboardDefinition()

getDashboardDefinition(key: string): {
  filters?: (
     | {
     field: string;
     id: string;
     kind: "date-range";
     label: string;
   }
     | {
     field: string;
     id: string;
     kind: "select";
     label: string;
     multiple?: boolean;
     searchable?: boolean;
   }
     | {
     defaultOperator?: "gt" | "lt" | "gte" | "lte" | "eq";
     field: string;
     format?: "number" | "currency";
     id: string;
     kind: "measure";
     label: string;
     operators?: ("gt" | "lt" | "gte" | "lte" | "eq")[];
   }
     | {
     field: string;
     id: string;
     kind: "search";
     label: string;
  })[];
  key: string;
  label: string;
  tiles: (
     | {
     id: string;
     kind: "metric" | "canned-report";
     layout: {
        h: number;
        w: number;
        x: number;
        y: number;
     };
     ref: string;
     visualization?:   | {
        format?: {
           compact?: boolean;
           dateStyle?: "short" | "long" | "medium";
           maximumFractionDigits?: number;
           wholeNumberTicks?: boolean;
        };
        grid?: boolean;
        kind: "metric";
        legend?: boolean;
        summary?: {
           field: string;
           fn: "min" | "max" | "count" | "avg" | "sum" | "last";
           label?: string;
        };
        ticker?: {
           colorCoded?: boolean;
           invertColors?: boolean;
           label?: string;
           value: string;
        };
        tickers?: {
           colorCoded?: boolean;
           invertColors?: boolean;
           label?: string;
           value: string;
        }[];
        value: string;
      }
        | {
        category: string;
        facet?: {
           field: string;
           scales?: "shared" | "independent";
        };
        format?: {
           compact?: boolean;
           dateStyle?: "short" | "long" | "medium";
           maximumFractionDigits?: number;
           wholeNumberTicks?: boolean;
        };
        grid?: boolean;
        kind: "bar";
        legend?: boolean;
        mode?: "percent" | "stacked" | "grouped" | "diverging";
        orientation?: "vertical" | "horizontal";
        series: {
           colorSlot?: number;
           field: string;
           label?: string;
        }[];
        summary?: {
           field: string;
           fn: "min" | "max" | "count" | "avg" | "sum" | "last";
           label?: string;
        };
      }
        | {
        bars: {
           colorSlot?: number;
           field: string;
           label?: string;
        }[];
        curve?: "linear" | "monotone";
        format?: {
           compact?: boolean;
           dateStyle?: "short" | "long" | "medium";
           maximumFractionDigits?: number;
           wholeNumberTicks?: boolean;
        };
        grid?: boolean;
        kind: "combo";
        legend?: boolean;
        lines: {
           colorSlot?: number;
           field: string;
           label?: string;
        }[];
        summary?: {
           field: string;
           fn: "min" | "max" | "count" | "avg" | "sum" | "last";
           label?: string;
        };
        x: string;
      }
        | {
        format?: {
           compact?: boolean;
           dateStyle?: "short" | "long" | "medium";
           maximumFractionDigits?: number;
           wholeNumberTicks?: boolean;
        };
        grid?: boolean;
        kind: "gauge";
        legend?: boolean;
        limit?: number;
        limitField?: string;
        summary?: {
           field: string;
           fn: "min" | "max" | "count" | "avg" | "sum" | "last";
           label?: string;
        };
        sweep?: 180 | 270 | 360;
        thresholds?: {
           color: "success" | "warning" | "danger";
           label?: string;
           value: number;
        }[];
        value: string;
      }
        | {
        area?: boolean;
        compact?: boolean;
        curve?: "linear" | "monotone";
        facet?: {
           field: string;
           scales?: "shared" | "independent";
        };
        format?: {
           compact?: boolean;
           dateStyle?: "short" | "long" | "medium";
           maximumFractionDigits?: number;
           wholeNumberTicks?: boolean;
        };
        grid?: boolean;
        kind: "line";
        legend?: boolean;
        points?: boolean;
        series: {
           colorSlot?: number;
           field: string;
           label?: string;
        }[];
        stack?: "none" | "absolute" | "percent";
        summary?: {
           field: string;
           fn: "min" | "max" | "count" | "avg" | "sum" | "last";
           label?: string;
        };
        x: string;
      }
        | {
        category: string;
        format?: {
           compact?: boolean;
           dateStyle?: "short" | "long" | "medium";
           maximumFractionDigits?: number;
           wholeNumberTicks?: boolean;
        };
        grid?: boolean;
        innerRadiusRatio?: number;
        kind: "pie";
        legend?: boolean;
        summary?: {
           field: string;
           fn: "min" | "max" | "count" | "avg" | "sum" | "last";
           label?: string;
        };
        value: string;
      }
        | {
        facet?: {
           field: string;
           scales?: "shared" | "independent";
        };
        format?: {
           compact?: boolean;
           dateStyle?: "short" | "long" | "medium";
           maximumFractionDigits?: number;
           wholeNumberTicks?: boolean;
        };
        grid?: boolean;
        group?: string;
        kind: "scatter";
        label?: string;
        legend?: boolean;
        size?: string;
        summary?: {
           field: string;
           fn: "min" | "max" | "count" | "avg" | "sum" | "last";
           label?: string;
        };
        x: string;
        y: string;
      }
        | {
        bins?: number;
        format?: {
           compact?: boolean;
           dateStyle?: "short" | "long" | "medium";
           maximumFractionDigits?: number;
           wholeNumberTicks?: boolean;
        };
        grid?: boolean;
        kind: "histogram";
        legend?: boolean;
        summary?: {
           field: string;
           fn: "min" | "max" | "count" | "avg" | "sum" | "last";
           label?: string;
        };
        value: string;
      }
        | {
        color?: "diverging" | "sequential";
        format?: {
           compact?: boolean;
           dateStyle?: "short" | "long" | "medium";
           maximumFractionDigits?: number;
           wholeNumberTicks?: boolean;
        };
        grid?: boolean;
        kind: "heatmap";
        legend?: boolean;
        summary?: {
           field: string;
           fn: "min" | "max" | "count" | "avg" | "sum" | "last";
           label?: string;
        };
        value: string;
        x: string;
        y: string;
      }
        | {
        after: string;
        before: string;
        category: string;
        format?: {
           compact?: boolean;
           dateStyle?: "short" | "long" | "medium";
           maximumFractionDigits?: number;
           wholeNumberTicks?: boolean;
        };
        grid?: boolean;
        kind: "dumbbell";
        legend?: boolean;
        summary?: {
           field: string;
           fn: "min" | "max" | "count" | "avg" | "sum" | "last";
           label?: string;
        };
      }
        | {
        category: string;
        change: string;
        format?: {
           compact?: boolean;
           dateStyle?: "short" | "long" | "medium";
           maximumFractionDigits?: number;
           wholeNumberTicks?: boolean;
        };
        grid?: boolean;
        kind: "waterfall";
        legend?: boolean;
        summary?: {
           field: string;
           fn: "min" | "max" | "count" | "avg" | "sum" | "last";
           label?: string;
        };
        total?: string;
      }
        | {
        conversion?: "previous" | "first";
        format?: {
           compact?: boolean;
           dateStyle?: "short" | "long" | "medium";
           maximumFractionDigits?: number;
           wholeNumberTicks?: boolean;
        };
        grid?: boolean;
        kind: "funnel";
        legend?: boolean;
        stage: string;
        summary?: {
           field: string;
           fn: "min" | "max" | "count" | "avg" | "sum" | "last";
           label?: string;
        };
        value: string;
      }
        | {
        color?: "diverging" | "sequential";
        format?: {
           compact?: boolean;
           dateStyle?: "short" | "long" | "medium";
           maximumFractionDigits?: number;
           wholeNumberTicks?: boolean;
        };
        grid?: boolean;
        kind: "us-map";
        label?: string;
        latitude: string;
        legend?: boolean;
        longitude: string;
        state: string;
        summary?: {
           field: string;
           fn: "min" | "max" | "count" | "avg" | "sum" | "last";
           label?: string;
        };
        value: string;
      }
        | {
        color?: "diverging" | "sequential";
        format?: {
           compact?: boolean;
           dateStyle?: "short" | "long" | "medium";
           maximumFractionDigits?: number;
           wholeNumberTicks?: boolean;
        };
        grid?: boolean;
        kind: "choropleth";
        legend?: boolean;
        region: string;
        summary?: {
           field: string;
           fn: "min" | "max" | "count" | "avg" | "sum" | "last";
           label?: string;
        };
        value: string;
      }
        | {
        kind: "table";
      };
   }
     | {
     background?: boolean;
     id: string;
     kind: "text-cell";
     layout: {
        h: number;
        w: number;
        x: number;
        y: number;
     };
     ref?: undefined;
     text: string;
     variant: "body" | "heading-1" | "heading-2";
     visualization?: undefined;
  })[];
};

Defined in: server/insights/services/model-service.ts:44

A dashboard definition by key, or throw UnknownDashboardError.

Parameters

ParameterType
keystring

Returns

filters?
optional filters?: (
  | {
  field: string;
  id: string;
  kind: "date-range";
  label: string;
}
  | {
  field: string;
  id: string;
  kind: "select";
  label: string;
  multiple?: boolean;
  searchable?: boolean;
}
  | {
  defaultOperator?: "gt" | "lt" | "gte" | "lte" | "eq";
  field: string;
  format?: "number" | "currency";
  id: string;
  kind: "measure";
  label: string;
  operators?: ("gt" | "lt" | "gte" | "lte" | "eq")[];
}
  | {
  field: string;
  id: string;
  kind: "search";
  label: string;
})[];

Interactive filter controls rendered above the grid. Each narrows every tile whose subject carries the targeted field; a tile whose subject lacks it is unaffected. Optional — a dashboard with no filters is static, as before. See types/dashboard-filter.ts.

key
key: string;
label
label: string;
tiles
tiles: (
  | {
  id: string;
  kind: "metric" | "canned-report";
  layout: {
     h: number;
     w: number;
     x: number;
     y: number;
  };
  ref: string;
  visualization?:   | {
     format?: {
        compact?: boolean;
        dateStyle?: "short" | "long" | "medium";
        maximumFractionDigits?: number;
        wholeNumberTicks?: boolean;
     };
     grid?: boolean;
     kind: "metric";
     legend?: boolean;
     summary?: {
        field: string;
        fn: "min" | "max" | "count" | "avg" | "sum" | "last";
        label?: string;
     };
     ticker?: {
        colorCoded?: boolean;
        invertColors?: boolean;
        label?: string;
        value: string;
     };
     tickers?: {
        colorCoded?: boolean;
        invertColors?: boolean;
        label?: string;
        value: string;
     }[];
     value: string;
   }
     | {
     category: string;
     facet?: {
        field: string;
        scales?: "shared" | "independent";
     };
     format?: {
        compact?: boolean;
        dateStyle?: "short" | "long" | "medium";
        maximumFractionDigits?: number;
        wholeNumberTicks?: boolean;
     };
     grid?: boolean;
     kind: "bar";
     legend?: boolean;
     mode?: "percent" | "stacked" | "grouped" | "diverging";
     orientation?: "vertical" | "horizontal";
     series: {
        colorSlot?: number;
        field: string;
        label?: string;
     }[];
     summary?: {
        field: string;
        fn: "min" | "max" | "count" | "avg" | "sum" | "last";
        label?: string;
     };
   }
     | {
     bars: {
        colorSlot?: number;
        field: string;
        label?: string;
     }[];
     curve?: "linear" | "monotone";
     format?: {
        compact?: boolean;
        dateStyle?: "short" | "long" | "medium";
        maximumFractionDigits?: number;
        wholeNumberTicks?: boolean;
     };
     grid?: boolean;
     kind: "combo";
     legend?: boolean;
     lines: {
        colorSlot?: number;
        field: string;
        label?: string;
     }[];
     summary?: {
        field: string;
        fn: "min" | "max" | "count" | "avg" | "sum" | "last";
        label?: string;
     };
     x: string;
   }
     | {
     format?: {
        compact?: boolean;
        dateStyle?: "short" | "long" | "medium";
        maximumFractionDigits?: number;
        wholeNumberTicks?: boolean;
     };
     grid?: boolean;
     kind: "gauge";
     legend?: boolean;
     limit?: number;
     limitField?: string;
     summary?: {
        field: string;
        fn: "min" | "max" | "count" | "avg" | "sum" | "last";
        label?: string;
     };
     sweep?: 180 | 270 | 360;
     thresholds?: {
        color: "success" | "warning" | "danger";
        label?: string;
        value: number;
     }[];
     value: string;
   }
     | {
     area?: boolean;
     compact?: boolean;
     curve?: "linear" | "monotone";
     facet?: {
        field: string;
        scales?: "shared" | "independent";
     };
     format?: {
        compact?: boolean;
        dateStyle?: "short" | "long" | "medium";
        maximumFractionDigits?: number;
        wholeNumberTicks?: boolean;
     };
     grid?: boolean;
     kind: "line";
     legend?: boolean;
     points?: boolean;
     series: {
        colorSlot?: number;
        field: string;
        label?: string;
     }[];
     stack?: "none" | "absolute" | "percent";
     summary?: {
        field: string;
        fn: "min" | "max" | "count" | "avg" | "sum" | "last";
        label?: string;
     };
     x: string;
   }
     | {
     category: string;
     format?: {
        compact?: boolean;
        dateStyle?: "short" | "long" | "medium";
        maximumFractionDigits?: number;
        wholeNumberTicks?: boolean;
     };
     grid?: boolean;
     innerRadiusRatio?: number;
     kind: "pie";
     legend?: boolean;
     summary?: {
        field: string;
        fn: "min" | "max" | "count" | "avg" | "sum" | "last";
        label?: string;
     };
     value: string;
   }
     | {
     facet?: {
        field: string;
        scales?: "shared" | "independent";
     };
     format?: {
        compact?: boolean;
        dateStyle?: "short" | "long" | "medium";
        maximumFractionDigits?: number;
        wholeNumberTicks?: boolean;
     };
     grid?: boolean;
     group?: string;
     kind: "scatter";
     label?: string;
     legend?: boolean;
     size?: string;
     summary?: {
        field: string;
        fn: "min" | "max" | "count" | "avg" | "sum" | "last";
        label?: string;
     };
     x: string;
     y: string;
   }
     | {
     bins?: number;
     format?: {
        compact?: boolean;
        dateStyle?: "short" | "long" | "medium";
        maximumFractionDigits?: number;
        wholeNumberTicks?: boolean;
     };
     grid?: boolean;
     kind: "histogram";
     legend?: boolean;
     summary?: {
        field: string;
        fn: "min" | "max" | "count" | "avg" | "sum" | "last";
        label?: string;
     };
     value: string;
   }
     | {
     color?: "diverging" | "sequential";
     format?: {
        compact?: boolean;
        dateStyle?: "short" | "long" | "medium";
        maximumFractionDigits?: number;
        wholeNumberTicks?: boolean;
     };
     grid?: boolean;
     kind: "heatmap";
     legend?: boolean;
     summary?: {
        field: string;
        fn: "min" | "max" | "count" | "avg" | "sum" | "last";
        label?: string;
     };
     value: string;
     x: string;
     y: string;
   }
     | {
     after: string;
     before: string;
     category: string;
     format?: {
        compact?: boolean;
        dateStyle?: "short" | "long" | "medium";
        maximumFractionDigits?: number;
        wholeNumberTicks?: boolean;
     };
     grid?: boolean;
     kind: "dumbbell";
     legend?: boolean;
     summary?: {
        field: string;
        fn: "min" | "max" | "count" | "avg" | "sum" | "last";
        label?: string;
     };
   }
     | {
     category: string;
     change: string;
     format?: {
        compact?: boolean;
        dateStyle?: "short" | "long" | "medium";
        maximumFractionDigits?: number;
        wholeNumberTicks?: boolean;
     };
     grid?: boolean;
     kind: "waterfall";
     legend?: boolean;
     summary?: {
        field: string;
        fn: "min" | "max" | "count" | "avg" | "sum" | "last";
        label?: string;
     };
     total?: string;
   }
     | {
     conversion?: "previous" | "first";
     format?: {
        compact?: boolean;
        dateStyle?: "short" | "long" | "medium";
        maximumFractionDigits?: number;
        wholeNumberTicks?: boolean;
     };
     grid?: boolean;
     kind: "funnel";
     legend?: boolean;
     stage: string;
     summary?: {
        field: string;
        fn: "min" | "max" | "count" | "avg" | "sum" | "last";
        label?: string;
     };
     value: string;
   }
     | {
     color?: "diverging" | "sequential";
     format?: {
        compact?: boolean;
        dateStyle?: "short" | "long" | "medium";
        maximumFractionDigits?: number;
        wholeNumberTicks?: boolean;
     };
     grid?: boolean;
     kind: "us-map";
     label?: string;
     latitude: string;
     legend?: boolean;
     longitude: string;
     state: string;
     summary?: {
        field: string;
        fn: "min" | "max" | "count" | "avg" | "sum" | "last";
        label?: string;
     };
     value: string;
   }
     | {
     color?: "diverging" | "sequential";
     format?: {
        compact?: boolean;
        dateStyle?: "short" | "long" | "medium";
        maximumFractionDigits?: number;
        wholeNumberTicks?: boolean;
     };
     grid?: boolean;
     kind: "choropleth";
     legend?: boolean;
     region: string;
     summary?: {
        field: string;
        fn: "min" | "max" | "count" | "avg" | "sum" | "last";
        label?: string;
     };
     value: string;
   }
     | {
     kind: "table";
   };
}
  | {
  background?: boolean;
  id: string;
  kind: "text-cell";
  layout: {
     h: number;
     w: number;
     x: number;
     y: number;
  };
  ref?: undefined;
  text: string;
  variant: "body" | "heading-1" | "heading-2";
  visualization?: undefined;
})[];

getMetadata()

getMetadata(): {
  cannedReports?: {
     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;
     };
     key: string;
     name: string;
  }[];
  dashboards?: {
     filters?: (
        | {
        field: string;
        id: string;
        kind: "date-range";
        label: string;
      }
        | {
        field: string;
        id: string;
        kind: "select";
        label: string;
        multiple?: boolean;
        searchable?: boolean;
      }
        | {
        defaultOperator?: "gt" | "lt" | "gte" | "lte" | "eq";
        field: string;
        format?: "number" | "currency";
        id: string;
        kind: "measure";
        label: string;
        operators?: (... | ... | ... | ... | ...)[];
      }
        | {
        field: string;
        id: string;
        kind: "search";
        label: string;
     })[];
     key: string;
     label: string;
     tiles: (
        | {
        id: string;
        kind: "metric" | "canned-report";
        layout: {
           h: number;
           w: number;
           x: number;
           y: number;
        };
        ref: string;
        visualization?:   | {
           format?: {
              compact?: ...;
              dateStyle?: ...;
              maximumFractionDigits?: ...;
              wholeNumberTicks?: ...;
           };
           grid?: boolean;
           kind: "metric";
           legend?: boolean;
           summary?: {
              field: ...;
              fn: ...;
              label?: ...;
           };
           ticker?: {
              colorCoded?: ...;
              invertColors?: ...;
              label?: ...;
              value: ...;
           };
           tickers?: ...[];
           value: string;
         }
           | {
           category: string;
           facet?: {
              field: ...;
              scales?: ...;
           };
           format?: {
              compact?: ...;
              dateStyle?: ...;
              maximumFractionDigits?: ...;
              wholeNumberTicks?: ...;
           };
           grid?: boolean;
           kind: "bar";
           legend?: boolean;
           mode?: "percent" | "stacked" | "grouped" | "diverging";
           orientation?: "vertical" | "horizontal";
           series: {
              colorSlot?: ...;
              field: ...;
              label?: ...;
           }[];
           summary?: {
              field: ...;
              fn: ...;
              label?: ...;
           };
         }
           | {
           bars: {
              colorSlot?: ...;
              field: ...;
              label?: ...;
           }[];
           curve?: "linear" | "monotone";
           format?: {
              compact?: ...;
              dateStyle?: ...;
              maximumFractionDigits?: ...;
              wholeNumberTicks?: ...;
           };
           grid?: boolean;
           kind: "combo";
           legend?: boolean;
           lines: {
              colorSlot?: ...;
              field: ...;
              label?: ...;
           }[];
           summary?: {
              field: ...;
              fn: ...;
              label?: ...;
           };
           x: string;
         }
           | {
           format?: {
              compact?: ...;
              dateStyle?: ...;
              maximumFractionDigits?: ...;
              wholeNumberTicks?: ...;
           };
           grid?: boolean;
           kind: "gauge";
           legend?: boolean;
           limit?: number;
           limitField?: string;
           summary?: {
              field: ...;
              fn: ...;
              label?: ...;
           };
           sweep?: 180 | 270 | 360;
           thresholds?: ...[];
           value: string;
         }
           | {
           area?: boolean;
           compact?: boolean;
           curve?: "linear" | "monotone";
           facet?: {
              field: ...;
              scales?: ...;
           };
           format?: {
              compact?: ...;
              dateStyle?: ...;
              maximumFractionDigits?: ...;
              wholeNumberTicks?: ...;
           };
           grid?: boolean;
           kind: "line";
           legend?: boolean;
           points?: boolean;
           series: {
              colorSlot?: ...;
              field: ...;
              label?: ...;
           }[];
           stack?: "none" | "absolute" | "percent";
           summary?: {
              field: ...;
              fn: ...;
              label?: ...;
           };
           x: string;
         }
           | {
           category: string;
           format?: {
              compact?: ...;
              dateStyle?: ...;
              maximumFractionDigits?: ...;
              wholeNumberTicks?: ...;
           };
           grid?: boolean;
           innerRadiusRatio?: number;
           kind: "pie";
           legend?: boolean;
           summary?: {
              field: ...;
              fn: ...;
              label?: ...;
           };
           value: string;
         }
           | {
           facet?: {
              field: ...;
              scales?: ...;
           };
           format?: {
              compact?: ...;
              dateStyle?: ...;
              maximumFractionDigits?: ...;
              wholeNumberTicks?: ...;
           };
           grid?: boolean;
           group?: string;
           kind: "scatter";
           label?: string;
           legend?: boolean;
           size?: string;
           summary?: {
              field: ...;
              fn: ...;
              label?: ...;
           };
           x: string;
           y: string;
         }
           | {
           bins?: number;
           format?: {
              compact?: ...;
              dateStyle?: ...;
              maximumFractionDigits?: ...;
              wholeNumberTicks?: ...;
           };
           grid?: boolean;
           kind: "histogram";
           legend?: boolean;
           summary?: {
              field: ...;
              fn: ...;
              label?: ...;
           };
           value: string;
         }
           | {
           color?: "diverging" | "sequential";
           format?: {
              compact?: ...;
              dateStyle?: ...;
              maximumFractionDigits?: ...;
              wholeNumberTicks?: ...;
           };
           grid?: boolean;
           kind: "heatmap";
           legend?: boolean;
           summary?: {
              field: ...;
              fn: ...;
              label?: ...;
           };
           value: string;
           x: string;
           y: string;
         }
           | {
           after: string;
           before: string;
           category: string;
           format?: {
              compact?: ...;
              dateStyle?: ...;
              maximumFractionDigits?: ...;
              wholeNumberTicks?: ...;
           };
           grid?: boolean;
           kind: "dumbbell";
           legend?: boolean;
           summary?: {
              field: ...;
              fn: ...;
              label?: ...;
           };
         }
           | {
           category: string;
           change: string;
           format?: {
              compact?: ...;
              dateStyle?: ...;
              maximumFractionDigits?: ...;
              wholeNumberTicks?: ...;
           };
           grid?: boolean;
           kind: "waterfall";
           legend?: boolean;
           summary?: {
              field: ...;
              fn: ...;
              label?: ...;
           };
           total?: string;
         }
           | {
           conversion?: "previous" | "first";
           format?: {
              compact?: ...;
              dateStyle?: ...;
              maximumFractionDigits?: ...;
              wholeNumberTicks?: ...;
           };
           grid?: boolean;
           kind: "funnel";
           legend?: boolean;
           stage: string;
           summary?: {
              field: ...;
              fn: ...;
              label?: ...;
           };
           value: string;
         }
           | {
           color?: "diverging" | "sequential";
           format?: {
              compact?: ...;
              dateStyle?: ...;
              maximumFractionDigits?: ...;
              wholeNumberTicks?: ...;
           };
           grid?: boolean;
           kind: "us-map";
           label?: string;
           latitude: string;
           legend?: boolean;
           longitude: string;
           state: string;
           summary?: {
              field: ...;
              fn: ...;
              label?: ...;
           };
           value: string;
         }
           | {
           color?: "diverging" | "sequential";
           format?: {
              compact?: ...;
              dateStyle?: ...;
              maximumFractionDigits?: ...;
              wholeNumberTicks?: ...;
           };
           grid?: boolean;
           kind: "choropleth";
           legend?: boolean;
           region: string;
           summary?: {
              field: ...;
              fn: ...;
              label?: ...;
           };
           value: string;
         }
           | {
           kind: "table";
         };
      }
        | {
        background?: boolean;
        id: string;
        kind: "text-cell";
        layout: {
           h: number;
           w: number;
           x: number;
           y: number;
        };
        ref?: undefined;
        text: string;
        variant: "body" | "heading-1" | "heading-2";
        visualization?: undefined;
     })[];
  }[];
  metrics?: {
     aggregation: {
        field?: string;
        fn: "min" | "max" | "count" | "avg" | "sum";
     };
     format?: {
        money?: {
           currencyCode?: string;
           representation: "decimal" | "minorUnits";
           scale: number;
        };
        type: "string" | "number" | "boolean" | "date" | "enum" | "datetime" | "money";
     };
     key: string;
     label: string;
     subject: string;
  }[];
  subjects: {
     defaultColumns?: string[];
     fields: {
        capabilities: {
           aggregatable: boolean;
           filterable: boolean;
           groupable: boolean;
           sortable: boolean;
        };
        enumValues?: string[];
        key: string;
        label: string;
        money?: {
           currencyCode?: string;
           representation: "decimal" | "minorUnits";
           scale: number;
        };
        type: "string" | "number" | "boolean" | "date" | "enum" | "datetime" | "money";
     }[];
     key: string;
     label: string;
  }[];
};

Defined in: server/insights/services/model-service.ts:23

The full physical-free metadata (subjects/metrics/canned/dashboards).

Returns

{
  cannedReports?: {
     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;
     };
     key: string;
     name: string;
  }[];
  dashboards?: {
     filters?: (
        | {
        field: string;
        id: string;
        kind: "date-range";
        label: string;
      }
        | {
        field: string;
        id: string;
        kind: "select";
        label: string;
        multiple?: boolean;
        searchable?: boolean;
      }
        | {
        defaultOperator?: "gt" | "lt" | "gte" | "lte" | "eq";
        field: string;
        format?: "number" | "currency";
        id: string;
        kind: "measure";
        label: string;
        operators?: (... | ... | ... | ... | ...)[];
      }
        | {
        field: string;
        id: string;
        kind: "search";
        label: string;
     })[];
     key: string;
     label: string;
     tiles: (
        | {
        id: string;
        kind: "metric" | "canned-report";
        layout: {
           h: number;
           w: number;
           x: number;
           y: number;
        };
        ref: string;
        visualization?:   | {
           format?: {
              compact?: ...;
              dateStyle?: ...;
              maximumFractionDigits?: ...;
              wholeNumberTicks?: ...;
           };
           grid?: boolean;
           kind: "metric";
           legend?: boolean;
           summary?: {
              field: ...;
              fn: ...;
              label?: ...;
           };
           ticker?: {
              colorCoded?: ...;
              invertColors?: ...;
              label?: ...;
              value: ...;
           };
           tickers?: ...[];
           value: string;
         }
           | {
           category: string;
           facet?: {
              field: ...;
              scales?: ...;
           };
           format?: {
              compact?: ...;
              dateStyle?: ...;
              maximumFractionDigits?: ...;
              wholeNumberTicks?: ...;
           };
           grid?: boolean;
           kind: "bar";
           legend?: boolean;
           mode?: "percent" | "stacked" | "grouped" | "diverging";
           orientation?: "vertical" | "horizontal";
           series: {
              colorSlot?: ...;
              field: ...;
              label?: ...;
           }[];
           summary?: {
              field: ...;
              fn: ...;
              label?: ...;
           };
         }
           | {
           bars: {
              colorSlot?: ...;
              field: ...;
              label?: ...;
           }[];
           curve?: "linear" | "monotone";
           format?: {
              compact?: ...;
              dateStyle?: ...;
              maximumFractionDigits?: ...;
              wholeNumberTicks?: ...;
           };
           grid?: boolean;
           kind: "combo";
           legend?: boolean;
           lines: {
              colorSlot?: ...;
              field: ...;
              label?: ...;
           }[];
           summary?: {
              field: ...;
              fn: ...;
              label?: ...;
           };
           x: string;
         }
           | {
           format?: {
              compact?: ...;
              dateStyle?: ...;
              maximumFractionDigits?: ...;
              wholeNumberTicks?: ...;
           };
           grid?: boolean;
           kind: "gauge";
           legend?: boolean;
           limit?: number;
           limitField?: string;
           summary?: {
              field: ...;
              fn: ...;
              label?: ...;
           };
           sweep?: 180 | 270 | 360;
           thresholds?: ...[];
           value: string;
         }
           | {
           area?: boolean;
           compact?: boolean;
           curve?: "linear" | "monotone";
           facet?: {
              field: ...;
              scales?: ...;
           };
           format?: {
              compact?: ...;
              dateStyle?: ...;
              maximumFractionDigits?: ...;
              wholeNumberTicks?: ...;
           };
           grid?: boolean;
           kind: "line";
           legend?: boolean;
           points?: boolean;
           series: {
              colorSlot?: ...;
              field: ...;
              label?: ...;
           }[];
           stack?: "none" | "absolute" | "percent";
           summary?: {
              field: ...;
              fn: ...;
              label?: ...;
           };
           x: string;
         }
           | {
           category: string;
           format?: {
              compact?: ...;
              dateStyle?: ...;
              maximumFractionDigits?: ...;
              wholeNumberTicks?: ...;
           };
           grid?: boolean;
           innerRadiusRatio?: number;
           kind: "pie";
           legend?: boolean;
           summary?: {
              field: ...;
              fn: ...;
              label?: ...;
           };
           value: string;
         }
           | {
           facet?: {
              field: ...;
              scales?: ...;
           };
           format?: {
              compact?: ...;
              dateStyle?: ...;
              maximumFractionDigits?: ...;
              wholeNumberTicks?: ...;
           };
           grid?: boolean;
           group?: string;
           kind: "scatter";
           label?: string;
           legend?: boolean;
           size?: string;
           summary?: {
              field: ...;
              fn: ...;
              label?: ...;
           };
           x: string;
           y: string;
         }
           | {
           bins?: number;
           format?: {
              compact?: ...;
              dateStyle?: ...;
              maximumFractionDigits?: ...;
              wholeNumberTicks?: ...;
           };
           grid?: boolean;
           kind: "histogram";
           legend?: boolean;
           summary?: {
              field: ...;
              fn: ...;
              label?: ...;
           };
           value: string;
         }
           | {
           color?: "diverging" | "sequential";
           format?: {
              compact?: ...;
              dateStyle?: ...;
              maximumFractionDigits?: ...;
              wholeNumberTicks?: ...;
           };
           grid?: boolean;
           kind: "heatmap";
           legend?: boolean;
           summary?: {
              field: ...;
              fn: ...;
              label?: ...;
           };
           value: string;
           x: string;
           y: string;
         }
           | {
           after: string;
           before: string;
           category: string;
           format?: {
              compact?: ...;
              dateStyle?: ...;
              maximumFractionDigits?: ...;
              wholeNumberTicks?: ...;
           };
           grid?: boolean;
           kind: "dumbbell";
           legend?: boolean;
           summary?: {
              field: ...;
              fn: ...;
              label?: ...;
           };
         }
           | {
           category: string;
           change: string;
           format?: {
              compact?: ...;
              dateStyle?: ...;
              maximumFractionDigits?: ...;
              wholeNumberTicks?: ...;
           };
           grid?: boolean;
           kind: "waterfall";
           legend?: boolean;
           summary?: {
              field: ...;
              fn: ...;
              label?: ...;
           };
           total?: string;
         }
           | {
           conversion?: "previous" | "first";
           format?: {
              compact?: ...;
              dateStyle?: ...;
              maximumFractionDigits?: ...;
              wholeNumberTicks?: ...;
           };
           grid?: boolean;
           kind: "funnel";
           legend?: boolean;
           stage: string;
           summary?: {
              field: ...;
              fn: ...;
              label?: ...;
           };
           value: string;
         }
           | {
           color?: "diverging" | "sequential";
           format?: {
              compact?: ...;
              dateStyle?: ...;
              maximumFractionDigits?: ...;
              wholeNumberTicks?: ...;
           };
           grid?: boolean;
           kind: "us-map";
           label?: string;
           latitude: string;
           legend?: boolean;
           longitude: string;
           state: string;
           summary?: {
              field: ...;
              fn: ...;
              label?: ...;
           };
           value: string;
         }
           | {
           color?: "diverging" | "sequential";
           format?: {
              compact?: ...;
              dateStyle?: ...;
              maximumFractionDigits?: ...;
              wholeNumberTicks?: ...;
           };
           grid?: boolean;
           kind: "choropleth";
           legend?: boolean;
           region: string;
           summary?: {
              field: ...;
              fn: ...;
              label?: ...;
           };
           value: string;
         }
           | {
           kind: "table";
         };
      }
        | {
        background?: boolean;
        id: string;
        kind: "text-cell";
        layout: {
           h: number;
           w: number;
           x: number;
           y: number;
        };
        ref?: undefined;
        text: string;
        variant: "body" | "heading-1" | "heading-2";
        visualization?: undefined;
     })[];
  }[];
  metrics?: {
     aggregation: {
        field?: string;
        fn: "min" | "max" | "count" | "avg" | "sum";
     };
     format?: {
        money?: {
           currencyCode?: string;
           representation: "decimal" | "minorUnits";
           scale: number;
        };
        type: "string" | "number" | "boolean" | "date" | "enum" | "datetime" | "money";
     };
     key: string;
     label: string;
     subject: string;
  }[];
  subjects: {
     defaultColumns?: string[];
     fields: {
        capabilities: {
           aggregatable: boolean;
           filterable: boolean;
           groupable: boolean;
           sortable: boolean;
        };
        enumValues?: string[];
        key: string;
        label: string;
        money?: {
           currencyCode?: string;
           representation: "decimal" | "minorUnits";
           scale: number;
        };
        type: "string" | "number" | "boolean" | "date" | "enum" | "datetime" | "money";
     }[];
     key: string;
     label: string;
  }[];
}
cannedReports?
optional cannedReports?: {
  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;
  };
  key: string;
  name: string;
}[];
dashboards?
optional dashboards?: {
  filters?: (
     | {
     field: string;
     id: string;
     kind: "date-range";
     label: string;
   }
     | {
     field: string;
     id: string;
     kind: "select";
     label: string;
     multiple?: boolean;
     searchable?: boolean;
   }
     | {
     defaultOperator?: "gt" | "lt" | "gte" | "lte" | "eq";
     field: string;
     format?: "number" | "currency";
     id: string;
     kind: "measure";
     label: string;
     operators?: (... | ... | ... | ... | ...)[];
   }
     | {
     field: string;
     id: string;
     kind: "search";
     label: string;
  })[];
  key: string;
  label: string;
  tiles: (
     | {
     id: string;
     kind: "metric" | "canned-report";
     layout: {
        h: number;
        w: number;
        x: number;
        y: number;
     };
     ref: string;
     visualization?:   | {
        format?: {
           compact?: ...;
           dateStyle?: ...;
           maximumFractionDigits?: ...;
           wholeNumberTicks?: ...;
        };
        grid?: boolean;
        kind: "metric";
        legend?: boolean;
        summary?: {
           field: ...;
           fn: ...;
           label?: ...;
        };
        ticker?: {
           colorCoded?: ...;
           invertColors?: ...;
           label?: ...;
           value: ...;
        };
        tickers?: ...[];
        value: string;
      }
        | {
        category: string;
        facet?: {
           field: ...;
           scales?: ...;
        };
        format?: {
           compact?: ...;
           dateStyle?: ...;
           maximumFractionDigits?: ...;
           wholeNumberTicks?: ...;
        };
        grid?: boolean;
        kind: "bar";
        legend?: boolean;
        mode?: "percent" | "stacked" | "grouped" | "diverging";
        orientation?: "vertical" | "horizontal";
        series: {
           colorSlot?: ...;
           field: ...;
           label?: ...;
        }[];
        summary?: {
           field: ...;
           fn: ...;
           label?: ...;
        };
      }
        | {
        bars: {
           colorSlot?: ...;
           field: ...;
           label?: ...;
        }[];
        curve?: "linear" | "monotone";
        format?: {
           compact?: ...;
           dateStyle?: ...;
           maximumFractionDigits?: ...;
           wholeNumberTicks?: ...;
        };
        grid?: boolean;
        kind: "combo";
        legend?: boolean;
        lines: {
           colorSlot?: ...;
           field: ...;
           label?: ...;
        }[];
        summary?: {
           field: ...;
           fn: ...;
           label?: ...;
        };
        x: string;
      }
        | {
        format?: {
           compact?: ...;
           dateStyle?: ...;
           maximumFractionDigits?: ...;
           wholeNumberTicks?: ...;
        };
        grid?: boolean;
        kind: "gauge";
        legend?: boolean;
        limit?: number;
        limitField?: string;
        summary?: {
           field: ...;
           fn: ...;
           label?: ...;
        };
        sweep?: 180 | 270 | 360;
        thresholds?: ...[];
        value: string;
      }
        | {
        area?: boolean;
        compact?: boolean;
        curve?: "linear" | "monotone";
        facet?: {
           field: ...;
           scales?: ...;
        };
        format?: {
           compact?: ...;
           dateStyle?: ...;
           maximumFractionDigits?: ...;
           wholeNumberTicks?: ...;
        };
        grid?: boolean;
        kind: "line";
        legend?: boolean;
        points?: boolean;
        series: {
           colorSlot?: ...;
           field: ...;
           label?: ...;
        }[];
        stack?: "none" | "absolute" | "percent";
        summary?: {
           field: ...;
           fn: ...;
           label?: ...;
        };
        x: string;
      }
        | {
        category: string;
        format?: {
           compact?: ...;
           dateStyle?: ...;
           maximumFractionDigits?: ...;
           wholeNumberTicks?: ...;
        };
        grid?: boolean;
        innerRadiusRatio?: number;
        kind: "pie";
        legend?: boolean;
        summary?: {
           field: ...;
           fn: ...;
           label?: ...;
        };
        value: string;
      }
        | {
        facet?: {
           field: ...;
           scales?: ...;
        };
        format?: {
           compact?: ...;
           dateStyle?: ...;
           maximumFractionDigits?: ...;
           wholeNumberTicks?: ...;
        };
        grid?: boolean;
        group?: string;
        kind: "scatter";
        label?: string;
        legend?: boolean;
        size?: string;
        summary?: {
           field: ...;
           fn: ...;
           label?: ...;
        };
        x: string;
        y: string;
      }
        | {
        bins?: number;
        format?: {
           compact?: ...;
           dateStyle?: ...;
           maximumFractionDigits?: ...;
           wholeNumberTicks?: ...;
        };
        grid?: boolean;
        kind: "histogram";
        legend?: boolean;
        summary?: {
           field: ...;
           fn: ...;
           label?: ...;
        };
        value: string;
      }
        | {
        color?: "diverging" | "sequential";
        format?: {
           compact?: ...;
           dateStyle?: ...;
           maximumFractionDigits?: ...;
           wholeNumberTicks?: ...;
        };
        grid?: boolean;
        kind: "heatmap";
        legend?: boolean;
        summary?: {
           field: ...;
           fn: ...;
           label?: ...;
        };
        value: string;
        x: string;
        y: string;
      }
        | {
        after: string;
        before: string;
        category: string;
        format?: {
           compact?: ...;
           dateStyle?: ...;
           maximumFractionDigits?: ...;
           wholeNumberTicks?: ...;
        };
        grid?: boolean;
        kind: "dumbbell";
        legend?: boolean;
        summary?: {
           field: ...;
           fn: ...;
           label?: ...;
        };
      }
        | {
        category: string;
        change: string;
        format?: {
           compact?: ...;
           dateStyle?: ...;
           maximumFractionDigits?: ...;
           wholeNumberTicks?: ...;
        };
        grid?: boolean;
        kind: "waterfall";
        legend?: boolean;
        summary?: {
           field: ...;
           fn: ...;
           label?: ...;
        };
        total?: string;
      }
        | {
        conversion?: "previous" | "first";
        format?: {
           compact?: ...;
           dateStyle?: ...;
           maximumFractionDigits?: ...;
           wholeNumberTicks?: ...;
        };
        grid?: boolean;
        kind: "funnel";
        legend?: boolean;
        stage: string;
        summary?: {
           field: ...;
           fn: ...;
           label?: ...;
        };
        value: string;
      }
        | {
        color?: "diverging" | "sequential";
        format?: {
           compact?: ...;
           dateStyle?: ...;
           maximumFractionDigits?: ...;
           wholeNumberTicks?: ...;
        };
        grid?: boolean;
        kind: "us-map";
        label?: string;
        latitude: string;
        legend?: boolean;
        longitude: string;
        state: string;
        summary?: {
           field: ...;
           fn: ...;
           label?: ...;
        };
        value: string;
      }
        | {
        color?: "diverging" | "sequential";
        format?: {
           compact?: ...;
           dateStyle?: ...;
           maximumFractionDigits?: ...;
           wholeNumberTicks?: ...;
        };
        grid?: boolean;
        kind: "choropleth";
        legend?: boolean;
        region: string;
        summary?: {
           field: ...;
           fn: ...;
           label?: ...;
        };
        value: string;
      }
        | {
        kind: "table";
      };
   }
     | {
     background?: boolean;
     id: string;
     kind: "text-cell";
     layout: {
        h: number;
        w: number;
        x: number;
        y: number;
     };
     ref?: undefined;
     text: string;
     variant: "body" | "heading-1" | "heading-2";
     visualization?: undefined;
  })[];
}[];
metrics?
optional metrics?: {
  aggregation: {
     field?: string;
     fn: "min" | "max" | "count" | "avg" | "sum";
  };
  format?: {
     money?: {
        currencyCode?: string;
        representation: "decimal" | "minorUnits";
        scale: number;
     };
     type: "string" | "number" | "boolean" | "date" | "enum" | "datetime" | "money";
  };
  key: string;
  label: string;
  subject: string;
}[];
subjects
subjects: {
  defaultColumns?: string[];
  fields: {
     capabilities: {
        aggregatable: boolean;
        filterable: boolean;
        groupable: boolean;
        sortable: boolean;
     };
     enumValues?: string[];
     key: string;
     label: string;
     money?: {
        currencyCode?: string;
        representation: "decimal" | "minorUnits";
        scale: number;
     };
     type: "string" | "number" | "boolean" | "date" | "enum" | "datetime" | "money";
  }[];
  key: string;
  label: string;
}[];

getMetric()

getMetric(key: string): 
  | {
  aggregation: {
     field?: string;
     fn: "min" | "max" | "count" | "avg" | "sum";
  };
  format?: {
     money?: {
        currencyCode?: string;
        representation: "decimal" | "minorUnits";
        scale: number;
     };
     type: "string" | "number" | "boolean" | "date" | "enum" | "datetime" | "money";
  };
  key: string;
  label: string;
  subject: string;
}
  | undefined;

Defined in: server/insights/services/model-service.ts:70

A metric by key, or undefined. Used to learn a metric tile's subject (metric tiles reference a metric, not a subject directly) so its fields can gate the tile's interactive filters.

Parameters

ParameterType
keystring

Returns

| { aggregation: { field?: string; fn: "min" | "max" | "count" | "avg" | "sum"; }; format?: { money?: { currencyCode?: string; representation: "decimal" | "minorUnits"; scale: number; }; type: "string" | "number" | "boolean" | "date" | "enum" | "datetime" | "money"; }; key: string; label: string; subject: string; } | undefined


getSubjectFields()

getSubjectFields(subjectKey: string): {
  capabilities: {
     aggregatable: boolean;
     filterable: boolean;
     groupable: boolean;
     sortable: boolean;
  };
  enumValues?: string[];
  key: string;
  label: string;
  money?: {
     currencyCode?: string;
     representation: "decimal" | "minorUnits";
     scale: number;
  };
  type: "string" | "number" | "boolean" | "date" | "enum" | "datetime" | "money";
}[];

Defined in: server/insights/services/model-service.ts:58

A subject's derived fields, or [] when the subject is unknown — the lookup NEVER throws, because it feeds the per-tile applicability gate for interactive dashboard filters, where an unrecognised subject simply means "no field can be honoured" rather than a run failure.

Parameters

ParameterType
subjectKeystring

Returns


listCannedReports()

listCannedReports(): {
  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;
  };
  key: string;
  name: string;
}[];

Defined in: server/insights/services/model-service.ts:28

Registered canned reports (metadata form).

Returns

{ 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; }; key: string; name: string; }[]

On this page