Add version number search params validation to route files

Co-authored-by: natemkelley <natemkelley@gmail.com>
This commit is contained in:
Cursor Agent 2025-08-15 05:45:46 +00:00
parent e33f52a8a1
commit 080dcc8cf5
13 changed files with 146 additions and 0 deletions

View File

@ -1,8 +1,22 @@
import { createFileRoute } from '@tanstack/react-router'
// Search params interface for type safety
interface RouteSearch {
dashboard_version_number?: number
metric_version_number?: number
}
export const Route = createFileRoute(
'/app/chats/$chatId/dashboard/$dashboardId/metrics/$metricId',
)({
validateSearch: (search: Record<string, unknown>): RouteSearch => ({
dashboard_version_number: search.dashboard_version_number
? Number(search.dashboard_version_number)
: undefined,
metric_version_number: search.metric_version_number
? Number(search.metric_version_number)
: undefined,
}),
component: RouteComponent,
})

View File

@ -1,8 +1,18 @@
import { createFileRoute } from '@tanstack/react-router'
// Search params interface for type safety
interface RouteSearch {
dashboard_version_number?: number
}
export const Route = createFileRoute(
'/app/chats/$chatId/dashboard/$dashboardId',
)({
validateSearch: (search: Record<string, unknown>): RouteSearch => ({
dashboard_version_number: search.dashboard_version_number
? Number(search.dashboard_version_number)
: undefined,
}),
component: RouteComponent,
})

View File

@ -1,6 +1,16 @@
import { createFileRoute } from '@tanstack/react-router'
// Search params interface for type safety
interface RouteSearch {
metric_version_number?: number
}
export const Route = createFileRoute('/app/chats/$chatId/metrics/$metricId')({
validateSearch: (search: Record<string, unknown>): RouteSearch => ({
metric_version_number: search.metric_version_number
? Number(search.metric_version_number)
: undefined,
}),
component: RouteComponent,
})

View File

@ -1,8 +1,22 @@
import { createFileRoute } from '@tanstack/react-router'
// Search params interface for type safety
interface RouteSearch {
report_version_number?: number
metric_version_number?: number
}
export const Route = createFileRoute(
'/app/chats/$chatId/report/$reportId/metrics/$metricId',
)({
validateSearch: (search: Record<string, unknown>): RouteSearch => ({
report_version_number: search.report_version_number
? Number(search.report_version_number)
: undefined,
metric_version_number: search.metric_version_number
? Number(search.metric_version_number)
: undefined,
}),
component: RouteComponent,
})

View File

@ -1,6 +1,16 @@
import { createFileRoute } from '@tanstack/react-router'
// Search params interface for type safety
interface RouteSearch {
report_version_number?: number
}
export const Route = createFileRoute('/app/chats/$chatId/report/$reportId')({
validateSearch: (search: Record<string, unknown>): RouteSearch => ({
report_version_number: search.report_version_number
? Number(search.report_version_number)
: undefined,
}),
component: RouteComponent,
})

View File

@ -1,8 +1,22 @@
import { createFileRoute } from '@tanstack/react-router'
// Search params interface for type safety
interface RouteSearch {
dashboard_version_number?: number
metric_version_number?: number
}
export const Route = createFileRoute(
'/app/collections/$collectionId/chats/$chatId/dashboards/$dashboardId/metrics/$metricId',
)({
validateSearch: (search: Record<string, unknown>): RouteSearch => ({
dashboard_version_number: search.dashboard_version_number
? Number(search.dashboard_version_number)
: undefined,
metric_version_number: search.metric_version_number
? Number(search.metric_version_number)
: undefined,
}),
component: RouteComponent,
})

View File

@ -1,8 +1,18 @@
import { createFileRoute } from '@tanstack/react-router'
// Search params interface for type safety
interface RouteSearch {
dashboard_version_number?: number
}
export const Route = createFileRoute(
'/app/collections/$collectionId/chats/$chatId/dashboards/$dashboardId',
)({
validateSearch: (search: Record<string, unknown>): RouteSearch => ({
dashboard_version_number: search.dashboard_version_number
? Number(search.dashboard_version_number)
: undefined,
}),
component: RouteComponent,
})

View File

@ -1,8 +1,18 @@
import { createFileRoute } from '@tanstack/react-router'
// Search params interface for type safety
interface RouteSearch {
metric_version_number?: number
}
export const Route = createFileRoute(
'/app/collections/$collectionId/chats/$chatId/metrics/$metricId',
)({
validateSearch: (search: Record<string, unknown>): RouteSearch => ({
metric_version_number: search.metric_version_number
? Number(search.metric_version_number)
: undefined,
}),
component: RouteComponent,
})

View File

@ -1,8 +1,22 @@
import { createFileRoute } from '@tanstack/react-router'
// Search params interface for type safety
interface RouteSearch {
dashboard_version_number?: number
metric_version_number?: number
}
export const Route = createFileRoute(
'/app/collections/$collectionId/dashboard/$dashboardId/metrics/$metricId',
)({
validateSearch: (search: Record<string, unknown>): RouteSearch => ({
dashboard_version_number: search.dashboard_version_number
? Number(search.dashboard_version_number)
: undefined,
metric_version_number: search.metric_version_number
? Number(search.metric_version_number)
: undefined,
}),
component: RouteComponent,
})

View File

@ -1,8 +1,18 @@
import { createFileRoute } from '@tanstack/react-router'
// Search params interface for type safety
interface RouteSearch {
dashboard_version_number?: number
}
export const Route = createFileRoute(
'/app/collections/$collectionId/dashboard/$dashboardId',
)({
validateSearch: (search: Record<string, unknown>): RouteSearch => ({
dashboard_version_number: search.dashboard_version_number
? Number(search.dashboard_version_number)
: undefined,
}),
component: RouteComponent,
})

View File

@ -1,8 +1,18 @@
import { createFileRoute } from '@tanstack/react-router'
// Search params interface for type safety
interface RouteSearch {
metric_version_number?: number
}
export const Route = createFileRoute(
'/app/collections/$collectionId/metrics/$metricId',
)({
validateSearch: (search: Record<string, unknown>): RouteSearch => ({
metric_version_number: search.metric_version_number
? Number(search.metric_version_number)
: undefined,
}),
component: RouteComponent,
})

View File

@ -1,6 +1,16 @@
import { createFileRoute } from '@tanstack/react-router';
// Search params interface for type safety
interface RouteSearch {
metric_version_number?: number;
}
export const Route = createFileRoute('/app/metrics/$metricId')({
validateSearch: (search: Record<string, unknown>): RouteSearch => ({
metric_version_number: search.metric_version_number
? Number(search.metric_version_number)
: undefined,
}),
component: RouteComponent,
});

View File

@ -1,6 +1,16 @@
import { createFileRoute } from '@tanstack/react-router';
// Search params interface for type safety
interface RouteSearch {
report_version_number?: number;
}
export const Route = createFileRoute('/app/reports/$reportId')({
validateSearch: (search: Record<string, unknown>): RouteSearch => ({
report_version_number: search.report_version_number
? Number(search.report_version_number)
: undefined,
}),
component: RouteComponent,
});