File tree Expand file tree Collapse file tree
packages/client/src/actions Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import { unwrap } from '@polymarket/types';
1010import { z } from 'zod' ;
1111import { parseUserInput } from '../input' ;
1212import type { PolymarketClient } from '../PolymarketClient' ;
13- import { toDataSearchParams } from './dataParams ' ;
13+ import { toDataSearchParams } from './params ' ;
1414
1515const ActivitySortBySchema = z . enum ( [ 'TIMESTAMP' , 'TOKENS' , 'CASH' ] ) ;
1616const SortDirectionSchema = z . enum ( [ 'ASC' , 'DESC' ] ) ;
Load diff This file was deleted.
Original file line number Diff line number Diff line change @@ -17,8 +17,7 @@ import { unwrap } from '@polymarket/types';
1717import { z } from 'zod' ;
1818import { parseUserInput } from '../input' ;
1919import type { PolymarketClient } from '../PolymarketClient' ;
20- import { toDataSearchParams } from './dataParams' ;
21- import { snakeCase , toSearchParams } from './params' ;
20+ import { snakeCase , toDataSearchParams , toSearchParams } from './params' ;
2221
2322const ListEventsRequestSchema = z . object ( {
2423 ascending : z . boolean ( ) . optional ( ) ,
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ import { unwrap } from '@polymarket/types';
1313import { z } from 'zod' ;
1414import { parseUserInput } from '../input' ;
1515import type { PolymarketClient } from '../PolymarketClient' ;
16- import { toDataSearchParams } from './dataParams ' ;
16+ import { toDataSearchParams } from './params ' ;
1717
1818const ListBuilderLeaderboardRequestSchema = z . object ( {
1919 timePeriod : TimePeriodSchema . optional ( ) ,
Original file line number Diff line number Diff line change @@ -18,8 +18,7 @@ import { unwrap } from '@polymarket/types';
1818import { z } from 'zod' ;
1919import { parseUserInput } from '../input' ;
2020import type { PolymarketClient } from '../PolymarketClient' ;
21- import { toDataSearchParams } from './dataParams' ;
22- import { snakeCase , toSearchParams } from './params' ;
21+ import { snakeCase , toDataSearchParams , toSearchParams } from './params' ;
2322
2423// The public markets endpoint forces active=true and archived=false server-side.
2524const ListMarketsRequestSchema = z . object ( {
Original file line number Diff line number Diff line change @@ -57,6 +57,30 @@ export function snakeCase<TParams extends SearchParamsInput>(
5757 } ;
5858}
5959
60+ /**
61+ * Data endpoints use camelCase query keys and comma-separated arrays.
62+ */
63+ export function toDataSearchParams < TParams extends SearchParamsInput > (
64+ params : TParams ,
65+ ) : URLSearchParams {
66+ const searchParams = new URLSearchParams ( ) ;
67+
68+ for ( const [ key , value ] of Object . entries ( params ) ) {
69+ if ( value === undefined ) {
70+ continue ;
71+ }
72+
73+ if ( Array . isArray ( value ) ) {
74+ searchParams . append ( key , value . map ( toSearchParamValue ) . join ( ',' ) ) ;
75+ continue ;
76+ }
77+
78+ searchParams . append ( key , toSearchParamValue ( value as SearchParamPrimitive ) ) ;
79+ }
80+
81+ return searchParams ;
82+ }
83+
6084function isSnakeCaseSearchParamMappings (
6185 mappings :
6286 | SearchParamMappings < SearchParamsInput >
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import { unwrap } from '@polymarket/types';
1212import { z } from 'zod' ;
1313import { parseUserInput } from '../input' ;
1414import type { PolymarketClient } from '../PolymarketClient' ;
15- import { toDataSearchParams } from './dataParams ' ;
15+ import { toDataSearchParams } from './params ' ;
1616
1717const PositionSortBySchema = z . enum ( [
1818 'CURRENT' ,
You can’t perform that action at this time.
0 commit comments