@@ -411,82 +411,95 @@ export const PeopleDataLabsBlock: BlockConfig<PdlPersonEnrichResponse> = {
411411 } ,
412412 params : ( params ) => {
413413 const result : Record < string , unknown > = { ...params }
414+ const op = params . operation
414415
415- if ( params . company_profile !== undefined ) {
416- result . profile = params . company_profile
417- result . company_profile = undefined
418- }
419- if ( params . company_location !== undefined ) {
420- result . location = params . company_location
421- result . company_location = undefined
416+ // Strip alternate-operation aliases so stale values from prior operations
417+ // can't leak into the current request.
418+ result . company_profile = undefined
419+ result . company_location = undefined
420+ result . autocomplete_size = undefined
421+ result . identify_locality = undefined
422+ result . identify_region = undefined
423+ result . identify_country = undefined
424+ result . identify_postal_code = undefined
425+ result . identify_birth_date = undefined
426+ result . bulk_person_requests = undefined
427+ result . bulk_person_required = undefined
428+ result . bulk_company_requests = undefined
429+ result . bulk_company_required = undefined
430+ result . clean_location_input = undefined
431+ result . school_name = undefined
432+ result . school_website = undefined
433+ result . school_profile = undefined
434+
435+ // Company Enrich uses company_* aliases for shared fields (profile, location)
436+ if ( op === 'pdl_company_enrich' ) {
437+ if ( params . company_profile !== undefined ) result . profile = params . company_profile
438+ if ( params . company_location !== undefined ) result . location = params . company_location
422439 }
423- if ( params . autocomplete_size !== undefined ) {
424- result . size = Number ( params . autocomplete_size )
425- result . autocomplete_size = undefined
440+ // Company Cleaner only accepts profile (LinkedIn URL) of the company aliases
441+ if ( op === 'pdl_clean_company' ) {
442+ if ( params . company_profile !== undefined ) result . profile = params . company_profile
426443 }
427- if ( params . size !== undefined ) {
444+
445+ // Autocomplete: use autocomplete_size, ignore stale search size
446+ if ( op === 'pdl_autocomplete' ) {
447+ if ( params . autocomplete_size !== undefined ) {
448+ result . size = Number ( params . autocomplete_size )
449+ } else {
450+ result . size = undefined
451+ }
452+ } else if ( params . size !== undefined ) {
428453 result . size = Number ( params . size )
429454 }
430- if ( params . min_likelihood !== undefined ) {
431- result . min_likelihood = Number ( params . min_likelihood )
432- }
433455
434- // Person Identify field renames
435- if ( params . identify_locality !== undefined ) {
436- result . locality = params . identify_locality
437- result . identify_locality = undefined
438- }
439- if ( params . identify_region !== undefined ) {
440- result . region = params . identify_region
441- result . identify_region = undefined
442- }
443- if ( params . identify_country !== undefined ) {
444- result . country = params . identify_country
445- result . identify_country = undefined
446- }
447- if ( params . identify_postal_code !== undefined ) {
448- result . postal_code = params . identify_postal_code
449- result . identify_postal_code = undefined
450- }
451- if ( params . identify_birth_date !== undefined ) {
452- result . birth_date = params . identify_birth_date
453- result . identify_birth_date = undefined
456+ // min_likelihood is only honored by enrich endpoints
457+ if ( op === 'pdl_person_enrich' || op === 'pdl_company_enrich' ) {
458+ if ( params . min_likelihood !== undefined ) {
459+ result . min_likelihood = Number ( params . min_likelihood )
460+ }
461+ } else {
462+ result . min_likelihood = undefined
454463 }
455464
456- // Bulk renames
457- if ( params . bulk_person_requests !== undefined ) {
458- result . requests = params . bulk_person_requests
459- result . bulk_person_requests = undefined
460- }
461- if ( params . bulk_person_required !== undefined ) {
462- result . required = params . bulk_person_required
463- result . bulk_person_required = undefined
464- }
465- if ( params . bulk_company_requests !== undefined ) {
466- result . requests = params . bulk_company_requests
467- result . bulk_company_requests = undefined
468- }
469- if ( params . bulk_company_required !== undefined ) {
470- result . required = params . bulk_company_required
471- result . bulk_company_required = undefined
465+ if ( op === 'pdl_person_identify' ) {
466+ if ( params . identify_locality !== undefined ) result . locality = params . identify_locality
467+ if ( params . identify_region !== undefined ) result . region = params . identify_region
468+ if ( params . identify_country !== undefined ) result . country = params . identify_country
469+ if ( params . identify_postal_code !== undefined ) {
470+ result . postal_code = params . identify_postal_code
471+ }
472+ if ( params . identify_birth_date !== undefined ) {
473+ result . birth_date = params . identify_birth_date
474+ }
472475 }
473476
474- // Cleaner renames
475- if ( params . clean_location_input !== undefined ) {
476- result . location = params . clean_location_input
477- result . clean_location_input = undefined
477+ if ( op === 'pdl_bulk_person_enrich' ) {
478+ if ( params . bulk_person_requests !== undefined ) {
479+ result . requests = params . bulk_person_requests
480+ }
481+ if ( params . bulk_person_required !== undefined ) {
482+ result . required = params . bulk_person_required
483+ }
484+ } else if ( op === 'pdl_bulk_company_enrich' ) {
485+ if ( params . bulk_company_requests !== undefined ) {
486+ result . requests = params . bulk_company_requests
487+ }
488+ if ( params . bulk_company_required !== undefined ) {
489+ result . required = params . bulk_company_required
490+ }
478491 }
479- if ( params . school_name !== undefined ) {
480- result . name = params . school_name
481- result . school_name = undefined
482- }
483- if ( params . school_website !== undefined ) {
484- result . website = params . school_website
485- result . school_website = undefined
492+
493+ if ( op === 'pdl_clean_location' ) {
494+ if ( params . clean_location_input !== undefined ) {
495+ result . location = params . clean_location_input
496+ }
486497 }
487- if ( params . school_profile !== undefined ) {
488- result . profile = params . school_profile
489- result . school_profile = undefined
498+
499+ if ( op === 'pdl_clean_school' ) {
500+ if ( params . school_name !== undefined ) result . name = params . school_name
501+ if ( params . school_website !== undefined ) result . website = params . school_website
502+ if ( params . school_profile !== undefined ) result . profile = params . school_profile
490503 }
491504
492505 return result
0 commit comments