mirror of https://github.com/buster-so/buster.git
Add version number search params validation to route files
Co-authored-by: natemkelley <natemkelley@gmail.com>
This commit is contained in:
parent
e33f52a8a1
commit
080dcc8cf5
|
@ -1,8 +1,22 @@
|
||||||
import { createFileRoute } from '@tanstack/react-router'
|
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(
|
export const Route = createFileRoute(
|
||||||
'/app/chats/$chatId/dashboard/$dashboardId/metrics/$metricId',
|
'/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,
|
component: RouteComponent,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,18 @@
|
||||||
import { createFileRoute } from '@tanstack/react-router'
|
import { createFileRoute } from '@tanstack/react-router'
|
||||||
|
|
||||||
|
// Search params interface for type safety
|
||||||
|
interface RouteSearch {
|
||||||
|
dashboard_version_number?: number
|
||||||
|
}
|
||||||
|
|
||||||
export const Route = createFileRoute(
|
export const Route = createFileRoute(
|
||||||
'/app/chats/$chatId/dashboard/$dashboardId',
|
'/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,
|
component: RouteComponent,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,16 @@
|
||||||
import { createFileRoute } from '@tanstack/react-router'
|
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')({
|
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,
|
component: RouteComponent,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,22 @@
|
||||||
import { createFileRoute } from '@tanstack/react-router'
|
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(
|
export const Route = createFileRoute(
|
||||||
'/app/chats/$chatId/report/$reportId/metrics/$metricId',
|
'/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,
|
component: RouteComponent,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,16 @@
|
||||||
import { createFileRoute } from '@tanstack/react-router'
|
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')({
|
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,
|
component: RouteComponent,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,22 @@
|
||||||
import { createFileRoute } from '@tanstack/react-router'
|
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(
|
export const Route = createFileRoute(
|
||||||
'/app/collections/$collectionId/chats/$chatId/dashboards/$dashboardId/metrics/$metricId',
|
'/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,
|
component: RouteComponent,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,18 @@
|
||||||
import { createFileRoute } from '@tanstack/react-router'
|
import { createFileRoute } from '@tanstack/react-router'
|
||||||
|
|
||||||
|
// Search params interface for type safety
|
||||||
|
interface RouteSearch {
|
||||||
|
dashboard_version_number?: number
|
||||||
|
}
|
||||||
|
|
||||||
export const Route = createFileRoute(
|
export const Route = createFileRoute(
|
||||||
'/app/collections/$collectionId/chats/$chatId/dashboards/$dashboardId',
|
'/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,
|
component: RouteComponent,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,18 @@
|
||||||
import { createFileRoute } from '@tanstack/react-router'
|
import { createFileRoute } from '@tanstack/react-router'
|
||||||
|
|
||||||
|
// Search params interface for type safety
|
||||||
|
interface RouteSearch {
|
||||||
|
metric_version_number?: number
|
||||||
|
}
|
||||||
|
|
||||||
export const Route = createFileRoute(
|
export const Route = createFileRoute(
|
||||||
'/app/collections/$collectionId/chats/$chatId/metrics/$metricId',
|
'/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,
|
component: RouteComponent,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,22 @@
|
||||||
import { createFileRoute } from '@tanstack/react-router'
|
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(
|
export const Route = createFileRoute(
|
||||||
'/app/collections/$collectionId/dashboard/$dashboardId/metrics/$metricId',
|
'/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,
|
component: RouteComponent,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,18 @@
|
||||||
import { createFileRoute } from '@tanstack/react-router'
|
import { createFileRoute } from '@tanstack/react-router'
|
||||||
|
|
||||||
|
// Search params interface for type safety
|
||||||
|
interface RouteSearch {
|
||||||
|
dashboard_version_number?: number
|
||||||
|
}
|
||||||
|
|
||||||
export const Route = createFileRoute(
|
export const Route = createFileRoute(
|
||||||
'/app/collections/$collectionId/dashboard/$dashboardId',
|
'/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,
|
component: RouteComponent,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,18 @@
|
||||||
import { createFileRoute } from '@tanstack/react-router'
|
import { createFileRoute } from '@tanstack/react-router'
|
||||||
|
|
||||||
|
// Search params interface for type safety
|
||||||
|
interface RouteSearch {
|
||||||
|
metric_version_number?: number
|
||||||
|
}
|
||||||
|
|
||||||
export const Route = createFileRoute(
|
export const Route = createFileRoute(
|
||||||
'/app/collections/$collectionId/metrics/$metricId',
|
'/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,
|
component: RouteComponent,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,16 @@
|
||||||
import { createFileRoute } from '@tanstack/react-router';
|
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')({
|
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,
|
component: RouteComponent,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,16 @@
|
||||||
import { createFileRoute } from '@tanstack/react-router';
|
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')({
|
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,
|
component: RouteComponent,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue