Skip to content

Commit 68b2549

Browse files
committed
fix: make parseQuery parameters optional with defaults
- Change query parameter to optional (query?: Record<string, unknown> | null) - Add default empty string for idProp parameter (idProp: string = '') - Allows calling parseQuery() without arguments (returns null) - Maintains backward compatibility and proper error handling
1 parent a017b64 commit 68b2549

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/utils/parse-query.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ const specialQueryHandlers: Record<string, QueryHandler> = {
118118
* @returns Parsed Elasticsearch query or null if empty
119119
*/
120120
export function parseQuery(
121-
query: Record<string, unknown>,
122-
idProp: string,
121+
query?: Record<string, unknown> | null,
122+
idProp: string = '',
123123
maxDepth: number = 50,
124124
currentDepth: number = 0
125125
): ESQuery | null {

test/utils/parse-query.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { expect } from 'chai'
22
import errors from '@feathersjs/errors'
3-
43
import { parseQuery } from '../../lib/utils/index.js'
54

65
export default function parseQueryTests() {

0 commit comments

Comments
 (0)