@@ -22,16 +22,18 @@ import { setCustomFieldValuesTool } from '@/tools/ashby/set_custom_field_values'
2222import { transferApplicationTool } from '@/tools/ashby/transfer_application'
2323import { updateCandidateTool } from '@/tools/ashby/update_candidate'
2424import { ashbyAuthHeaders } from '@/tools/ashby/utils'
25- import type { ToolConfig } from '@/tools/types'
2625
2726const respond = ( body : unknown ) => new Response ( JSON . stringify ( body ) , { status : 200 } )
2827
29- function requestBody < P , R > ( tool : ToolConfig < P , R > , params : unknown ) : Record < string , unknown > {
28+ function requestBody (
29+ tool : { request ?: { body ?: unknown } } ,
30+ params : unknown
31+ ) : Record < string , unknown > {
3032 const build = tool . request ?. body as ( p : unknown ) => Record < string , unknown >
3133 return build ( params )
3234}
3335
34- async function transform < P , R > ( tool : ToolConfig < P , R > , body : unknown ) {
36+ async function transform ( tool : { transformResponse ?: unknown } , body : unknown ) {
3537 const run = tool . transformResponse as ( r : Response ) => Promise < { output : Record < string , never > } >
3638 return run ( respond ( body ) )
3739}
@@ -274,6 +276,15 @@ describe('ashby request bodies', () => {
274276 } )
275277 expect ( body ) . toMatchObject ( { id : 'j' , includeUnpublishedJobPostingsIds : true } )
276278 expect ( body ) . not . toHaveProperty ( 'includeUnpublishedJobPostingIds' )
279+ for ( const untouched of [ null , '' ] ) {
280+ expect (
281+ requestBody ( getJobTool , {
282+ apiKey : 'k' ,
283+ jobId : 'j' ,
284+ includeUnpublishedJobPostingIds : untouched ,
285+ } )
286+ ) . toEqual ( { id : 'j' , expand : [ 'openings' , 'location' , 'compensation' ] } )
287+ }
277288 } )
278289
279290 it ( 'change_application_source sends sourceId when one is provided' , ( ) => {
0 commit comments