@@ -158,9 +158,21 @@ import type {
158158import { toGetAgentStatisticsQueryParams , toListAgentRunsQueryParams } from './types' ;
159159import { buildURL } from './utils' ;
160160
161- const maybeParseDate = ( val : JSONValue ) => {
162- if ( typeof val === 'string' ) {
163- const re = / 2 \d { 3 } - [ 0 - 1 ] \d - [ 0 - 3 ] \d T [ 0 - 2 ] \d : [ 0 - 6 ] \d : [ 0 - 6 ] \d \. \d + ( \+ 0 0 0 0 | Z ) / ;
161+ const maybeParseDate = ( key : string , val : JSONValue ) => {
162+ const dateKeys = [
163+ 'after' ,
164+ 'before' ,
165+ 'createdTime' ,
166+ 'createdTimeAfter' ,
167+ 'createdTimeBefore' ,
168+ 'timestamp' ,
169+ 'updatedTime' ,
170+ 'updatedTimeAfter' ,
171+ 'updatedTimeBefore' ,
172+ ] ;
173+
174+ if ( dateKeys . includes ( key ) && typeof val === 'string' ) {
175+ const re = / ^ 2 \d { 3 } - [ 0 - 1 ] \d - [ 0 - 3 ] \d T [ 0 - 2 ] \d : [ 0 - 6 ] \d : [ 0 - 6 ] \d \. \d + ( \+ 0 0 0 0 | Z ) $ / ;
164176 if ( val . match ( re ) ) {
165177 return new Date ( val ) ;
166178 }
@@ -1586,7 +1598,7 @@ export class Client {
15861598 }
15871599
15881600 const result = await axiosFn < T > ( endpoint , config ) ;
1589- return JSON . parse ( JSON . stringify ( result . data ) , ( key , val ) => maybeParseDate ( val ) ) ;
1601+ return JSON . parse ( JSON . stringify ( result . data ) , ( key , val ) => maybeParseDate ( key , val ) ) ;
15901602 }
15911603
15921604 /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
@@ -1600,7 +1612,7 @@ export class Client {
16001612 }
16011613
16021614 const result = await axiosFn < T > ( endpoint , body , config ) ;
1603- return JSON . parse ( JSON . stringify ( result . data ) , ( key , val ) => maybeParseDate ( val ) ) ;
1615+ return JSON . parse ( JSON . stringify ( result . data ) , ( key , val ) => maybeParseDate ( key , val ) ) ;
16041616 }
16051617
16061618 private async getAuthorizationHeaders ( ) : Promise < AuthorizationHeaders > {
0 commit comments