@@ -6,6 +6,7 @@ import { changeApplicationStageTool } from '@/tools/ashby/change_application_sta
66import { deleteApplicationTool } from '@/tools/ashby/delete_application'
77import { getApplicationTool } from '@/tools/ashby/get_application'
88import { getCandidateTool } from '@/tools/ashby/get_candidate'
9+ import { getJobTool } from '@/tools/ashby/get_job'
910import { getJobPostingTool } from '@/tools/ashby/get_job_posting'
1011import { listApplicationsTool } from '@/tools/ashby/list_applications'
1112import { listCandidatesTool } from '@/tools/ashby/list_candidates'
@@ -21,16 +22,18 @@ import { setCustomFieldValuesTool } from '@/tools/ashby/set_custom_field_values'
2122import { transferApplicationTool } from '@/tools/ashby/transfer_application'
2223import { updateCandidateTool } from '@/tools/ashby/update_candidate'
2324import { ashbyAuthHeaders } from '@/tools/ashby/utils'
24- import type { ToolConfig } from '@/tools/types'
2525
2626const respond = ( body : unknown ) => new Response ( JSON . stringify ( body ) , { status : 200 } )
2727
28- function requestBody ( tool : ToolConfig < never , never > , params : unknown ) : Record < string , unknown > {
28+ function requestBody (
29+ tool : { request ?: { body ?: unknown } } ,
30+ params : unknown
31+ ) : Record < string , unknown > {
2932 const build = tool . request ?. body as ( p : unknown ) => Record < string , unknown >
3033 return build ( params )
3134}
3235
33- async function transform ( tool : ToolConfig < never , never > , body : unknown ) {
36+ async function transform ( tool : { transformResponse ?: unknown } , body : unknown ) {
3437 const run = tool . transformResponse as ( r : Response ) => Promise < { output : Record < string , never > } >
3538 return run ( respond ( body ) )
3639}
@@ -263,6 +266,27 @@ describe('ashby request bodies', () => {
263266 expect ( body ) . not . toHaveProperty ( 'includeUnpublishedJobPostingsIds' )
264267 } )
265268
269+ it ( 'get_job sends the job.info spelling of the unpublished posting IDs flag' , ( ) => {
270+ // job.info rejects unknown keys (additionalProperties: false), so the
271+ // singular `includeUnpublishedJobPostingIds` never reached Ashby as intended.
272+ const body = requestBody ( getJobTool , {
273+ apiKey : 'k' ,
274+ jobId : ' j ' ,
275+ includeUnpublishedJobPostingIds : true ,
276+ } )
277+ expect ( body ) . toMatchObject ( { id : 'j' , includeUnpublishedJobPostingsIds : true } )
278+ 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+ }
288+ } )
289+
266290 it ( 'change_application_source sends sourceId when one is provided' , ( ) => {
267291 // Ashby requires the key to be present; omitting it is a 400 rather than
268292 // the intended write.
0 commit comments