Skip to Content
⚠️Active Development Notice: TimeTiles is under active development. Information may be placeholder content or not up-to-date.

web


web / lib/utils/event-filters

lib/utils/event-filters

Shared utilities for building event filter objects with access control.

This module consolidates the filter building logic used across event API routes. It handles catalog access control, ensuring users can only query catalogs they have permission to access.

Interfaces

EventFilters

Event filters for SQL/Drizzle queries.

Properties

catalogId?

optional catalogId: number

Single catalog ID when user has access

catalogIds?

optional catalogIds: number[]

Multiple catalog IDs when filtering by accessible catalogs

datasets?

optional datasets: number[]

Array of dataset IDs to filter by

startDate?

optional startDate: null | string

Start date for temporal filtering

endDate?

optional endDate: null | string

End date for temporal filtering

bounds?

optional bounds: object

Geographic bounds for spatial filtering

minLng

minLng: number

maxLng

maxLng: number

minLat

minLat: number

maxLat

maxLat: number


BuildFiltersOptions

Options for building event filters.

Properties

parameters

parameters: BaseEventParameters

Event parameters from request

accessibleCatalogIds

accessibleCatalogIds: number[]

Catalog IDs the user has access to

bounds?

optional bounds: null | MapBounds

Optional geographic bounds

parseDatasetIds?

optional parseDatasetIds: boolean

Parse dataset IDs as integers (default: true)

Functions

buildEventFilters()

buildEventFilters(options): EventFilters

Build event filters with access control logic.

This function handles the common pattern of:

  1. If a specific catalog is requested and user has access, filter by that catalog
  2. If a specific catalog is requested but user lacks access, filter by all accessible catalogs
  3. If no catalog is specified, filter by all accessible catalogs

Parameters

options

BuildFiltersOptions

Filter building options

Returns

EventFilters

Event filters with access control applied


buildMapClusterFilters()

buildMapClusterFilters(parameters, accessibleCatalogIds): Record<string, unknown>

Build filters for map clusters query (uses string catalog, not parsed).

This is a specialized version for the map-clusters endpoint which passes catalog as a string to the cluster_events SQL function.

Parameters

parameters

BaseEventParameters

Event parameters from request

accessibleCatalogIds

number[]

Catalog IDs the user has access to

Returns

Record<string, unknown>

Filters with catalog as string for SQL function

Last updated on