Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"vitest": "^1.4.0"
},
"peerDependencies": {
"next": "^12.0.0 || ^13.0.0 || ^14.0.0",
"next": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0",
"react": "^16.0.0 || ^17.0.0 || ^18.0.0",
"react-router-dom": "^6.0.0",
"zod": "^3.0.0"
Expand Down
27 changes: 13 additions & 14 deletions src/engine/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,7 @@ import { useCallback, useMemo } from 'react'

export type Query = Record<string, string | string[]>

export type AbstractQueryValueElement =
| string
| number
| boolean
| Date
| bigint

export type AbstractQuery = Record<
string,
AbstractQueryValueElement | AbstractQueryValueElement[]
>
export type AbstractQuery = Record<string, unknown>

/**
* Parses the query.
Expand Down Expand Up @@ -59,7 +49,7 @@ export type AbstractQueryOptions = {
/**
* How the abstract query is converted to an actual query.
*
* @default Each value that is not undefined is converted to a string by calling `.toString()`.
* @default Each value that is not undefined is converted to a string by calling `.toString()` or removed if not stringifyable.
*/
convertToQuery: (abstractQuery: Partial<AbstractQuery>) => Query
}
Expand All @@ -69,10 +59,19 @@ const DEFAULT_ABSTRACT_QUERY_OPTIONS: AbstractQueryOptions = {
const query: Query = {}
for (const [key, value] of Object.entries(abstractQuery)) {
if (Array.isArray(value)) {
query[key] = value.map((v) => v.toString())
query[key] = value.map((v: unknown) =>
typeof v?.toString === 'function'
? // eslint-disable-next-line @typescript-eslint/no-base-to-string
v.toString()
: '',
)
} else {
if (value !== undefined) {
query[key] = value.toString()
query[key] =
typeof value?.toString === 'function'
? // eslint-disable-next-line @typescript-eslint/no-base-to-string
value.toString()
: ''
}
}
}
Expand Down