Files
supabase/apps/docs/features/docs/Troubleshooting.utils.shared.ts
T
Charis cf3ecc93eb chore(docs): turn on strictNullChecks (#36180)
strictNullChecks was off for docs, which lets errors slip through and
leads to incorrect required/optional typing on Zod-inferred types. This
PR enables strictNullChecks and fixes all the existing violations.
2025-06-04 17:05:37 -04:00

25 lines
1.0 KiB
TypeScript

import { createSerializer, parseAsArrayOf, parseAsString } from 'nuqs'
import { ITroubleshootingEntry } from './Troubleshooting.utils'
export const TROUBLESHOOTING_CONTAINER_ID = 'sb-docs-troubleshooting-container'
export const TROUBLESHOOTING_DATA_ATTRIBUTES = {
QUERY_ATTRIBUTE: 'data-sb-docs-troubleshooting',
QUERY_VALUE_ENTRY: 'entry',
PRODUCTS_LIST_ATTRIBUTE: 'data-products',
KEYWORDS_LIST_ATTRIBUTE: 'data-keywords',
ERRORS_LIST_ATTRIBUTE: 'data-errors',
}
export function formatError(error: NonNullable<ITroubleshootingEntry['data']['errors']>[number]) {
return `${error.http_status_code ?? ''}${!!error.http_status_code && !!error.code ? ' ' : ''}${error.code ?? ''}`
}
export const troubleshootingSearchParams = {
search: parseAsString.withDefault(''),
products: parseAsArrayOf(parseAsString).withDefault([]),
tags: parseAsArrayOf(parseAsString).withDefault([]),
errorCodes: parseAsArrayOf(parseAsString).withDefault([]),
}
export const serializeTroubleshootingSearchParams = createSerializer(troubleshootingSearchParams)