Kaizen
Browse modulesInsightsinsights/sharedFunctions

Function: applicableDashboardFilterLeaves()

function applicableDashboardFilterLeaves(leaves: readonly (
  | {
  field: string;
  kind: "condition";
  operator: "eq";
  value: string | number | boolean;
}
  | {
  field: string;
  kind: "condition";
  operator: "neq";
  value: string | number | boolean;
}
  | {
  field: string;
  kind: "condition";
  operator: "gt";
  value: string | number;
}
  | {
  field: string;
  kind: "condition";
  operator: "lt";
  value: string | number;
}
  | {
  field: string;
  kind: "condition";
  operator: "gte";
  value: string | number;
}
  | {
  field: string;
  kind: "condition";
  operator: "lte";
  value: string | number;
}
  | {
  field: string;
  kind: "condition";
  operator: "contains";
  value: string;
}
  | {
  field: string;
  kind: "condition";
  operator: "in";
  value: (string | number | boolean)[];
}
  | {
  field: string;
  kind: "condition";
  operator: "between";
  value: {
     from: string | number;
     to: string | number;
  };
}
  | {
  field: string;
  kind: "condition";
  operator: "isNull";
}
  | {
  field: string;
  kind: "condition";
  operator: "isNotNull";
})[], fields: readonly {
  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";
}[]): (
  | {
  field: string;
  kind: "condition";
  operator: "eq";
  value: string | number | boolean;
}
  | {
  field: string;
  kind: "condition";
  operator: "neq";
  value: string | number | boolean;
}
  | {
  field: string;
  kind: "condition";
  operator: "gt";
  value: string | number;
}
  | {
  field: string;
  kind: "condition";
  operator: "lt";
  value: string | number;
}
  | {
  field: string;
  kind: "condition";
  operator: "gte";
  value: string | number;
}
  | {
  field: string;
  kind: "condition";
  operator: "lte";
  value: string | number;
}
  | {
  field: string;
  kind: "condition";
  operator: "contains";
  value: string;
}
  | {
  field: string;
  kind: "condition";
  operator: "in";
  value: (string | number | boolean)[];
}
  | {
  field: string;
  kind: "condition";
  operator: "between";
  value: {
     from: string | number;
     to: string | number;
  };
}
  | {
  field: string;
  kind: "condition";
  operator: "isNull";
}
  | {
  field: string;
  kind: "condition";
  operator: "isNotNull";
})[];

Defined in: shared/insights/validate-definition.ts:190

Keep only the filter leaves a subject can actually honor: the field must exist, be filterable, and permit the leaf's operator for its semantic type.

This is the per-tile gate for interactive dashboard filters — a filter targeting a field a given tile's subject lacks is silently skipped for that tile rather than failing the run. It mirrors EVERY check validateFilter makes on a leaf — filterable, the operatorAllowedForType matrix, AND the enum allowlist — so that a leaf this gate keeps can never be one validateDefinition would later reject and throw on. That last check is the load-bearing one: contains is allowed on an enum field by the operator matrix, so a search filter's partial text (or a select value that drifted from enumValues) would pass an operator-only gate and then hard-fail the whole tile at run/runMetric; screening the allowlist here keeps such a value SKIPPED, which is the contract, rather than fatal.

Lives here (not in types/dashboard-filter) so that module stays free of runtime imports and cannot form an initialization cycle with types/model-metadata.

Parameters

ParameterType
leavesreadonly ( | { field: string; kind: "condition"; operator: "eq"; value: string | number | boolean; } | { field: string; kind: "condition"; operator: "neq"; value: string | number | boolean; } | { field: string; kind: "condition"; operator: "gt"; value: string | number; } | { field: string; kind: "condition"; operator: "lt"; value: string | number; } | { field: string; kind: "condition"; operator: "gte"; value: string | number; } | { field: string; kind: "condition"; operator: "lte"; value: string | number; } | { field: string; kind: "condition"; operator: "contains"; value: string; } | { field: string; kind: "condition"; operator: "in"; value: (string | number | boolean)[]; } | { field: string; kind: "condition"; operator: "between"; value: { from: string | number; to: string | number; }; } | { field: string; kind: "condition"; operator: "isNull"; } | { field: string; kind: "condition"; operator: "isNotNull"; })[]
fieldsreadonly { 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"; }[]

Returns

( | { field: string; kind: "condition"; operator: "eq"; value: string | number | boolean; } | { field: string; kind: "condition"; operator: "neq"; value: string | number | boolean; } | { field: string; kind: "condition"; operator: "gt"; value: string | number; } | { field: string; kind: "condition"; operator: "lt"; value: string | number; } | { field: string; kind: "condition"; operator: "gte"; value: string | number; } | { field: string; kind: "condition"; operator: "lte"; value: string | number; } | { field: string; kind: "condition"; operator: "contains"; value: string; } | { field: string; kind: "condition"; operator: "in"; value: (string | number | boolean)[]; } | { field: string; kind: "condition"; operator: "between"; value: { from: string | number; to: string | number; }; } | { field: string; kind: "condition"; operator: "isNull"; } | { field: string; kind: "condition"; operator: "isNotNull"; })[]

On this page