The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Make People Data Labs likelihood settings user configurable (#26512)
Raphaël Boside4487a0dc05
diff --git a/packages/twenty-apps/public/people-data-labs/CHANGELOG.md b/packages/twenty-apps/public/people-data-labs/CHANGELOG.mdnew file mode 100644index 00000000000..f6536865199--- /dev/null+++ b/packages/twenty-apps/public/people-data-labs/CHANGELOG.md@@ -0,0 +1,16 @@+# Changelog++All notable changes to this application are documented in this file.++## 1.2.0++- Move the minimum match likelihoods for people and companies from server+ variables to the app settings, so workspace admins can edit them. Values set+ as server variables are not migrated and reset to the default of 2.+- Add settings for name-based people and company matches, defaulting to 6.+ Name-based matches use the higher of this setting and the people or company+ minimum.+- Add a **Minimum likelihood for name-based matches** input to the enrichment+ workflow steps. Explicit workflow inputs take precedence over the app+ settings.+- Require Twenty `>=2.36.0`: labels for app settings only exist from 2.36.diff --git a/packages/twenty-apps/public/people-data-labs/README.md b/packages/twenty-apps/public/people-data-labs/README.mdindex cac81f2d8a0..6babfc362c3 100644--- a/packages/twenty-apps/public/people-data-labs/README.md+++ b/packages/twenty-apps/public/people-data-labs/README.md@@ -6,15 +6,7 @@- **+30 rich data fields** per Person and Company — seniority, skills, firmographics, funding, socials & more- **Run it anywhere** — from the command menu, as a workflow step, or straight from AI chat-- **Smart matching** — finds the right profile from a LinkedIn, email, or domain, and only writes confident matches--## Enrichment defaults--Configure `PDL_PERSON_MIN_LIKELIHOOD` and `PDL_COMPANY_MIN_LIKELIHOOD` in the app's server variables to set the default minimum likelihood for people and companies. Each accepts an integer from 1 to 10.--Command menu items use these defaults. Single-record and bulk workflow nodes use them when their minimum likelihood input is empty; an explicit workflow value takes precedence.--When a variable is unset, enrichment uses the existing thresholds: 2 for strong identifiers (PDL ID, LinkedIn, email, or company domain) and 6 for name-based matches.+- **Smart matching** — finds the right profile from a LinkedIn, email, or domain, and only writes confident matches. Set the minimum likelihood in the app settings to adapt matching to your needs## 💳 Billingdiff --git a/packages/twenty-apps/public/people-data-labs/SETUP.md b/packages/twenty-apps/public/people-data-labs/SETUP.mdnew file mode 100644index 00000000000..f0e82fa27f5--- /dev/null+++ b/packages/twenty-apps/public/people-data-labs/SETUP.md@@ -0,0 +1,17 @@+# People Data Labs: self-hosting setup++This guide is for Twenty **server admins**. It covers the People Data Labs API+key the app needs.++## Server variables++Set this on the application registration after installing (**Settings →+Applications → People Data Labs → Application registration**, admin only):++| Server variable | Required | Purpose |+|---|---|---|+| `PDL_API_KEY` | Yes | People Data Labs API key used for person and company enrichment. |++If the key is missing, or People Data Labs rejects it or the account is out of+credits, enrichment fails with *"People Data Labs enrichment is unavailable.+Contact your workspace admin."*diff --git a/packages/twenty-apps/public/people-data-labs/package.json b/packages/twenty-apps/public/people-data-labs/package.jsonindex 8030006753d..6289bb71ae6 100644--- a/packages/twenty-apps/public/people-data-labs/package.json+++ b/packages/twenty-apps/public/people-data-labs/package.json@@ -1,13 +1,13 @@{"name": "@twentyhq/people-data-labs",- "version": "1.1.0",+ "version": "1.2.0","description": "People Data Labs enrichment app for Twenty","license": "MIT","engines": {"node": "^24.5.0","npm": "please-use-yarn","yarn": ">=4.0.2",- "twenty": ">=2.23.0"+ "twenty": ">=2.36.0"},"keywords": ["twenty-app"diff --git a/packages/twenty-apps/public/people-data-labs/src/application-config.ts b/packages/twenty-apps/public/people-data-labs/src/application-config.tsindex c195d151498..8bdfd5107f3 100644--- a/packages/twenty-apps/public/people-data-labs/src/application-config.ts+++ b/packages/twenty-apps/public/people-data-labs/src/application-config.ts@@ -1,6 +1,15 @@import { defineApplication, FieldType } from 'twenty-sdk/define';-import { APPLICATION_UNIVERSAL_IDENTIFIER } from 'src/constants/universal-identifiers';+import { DEFAULT_MIN_LIKELIHOOD } from 'src/constants/default-min-likelihood';+import { DEFAULT_WEAK_IDENTIFIER_MIN_LIKELIHOOD } from 'src/constants/default-weak-identifier-min-likelihood';+import { PDL_COMPANY_MIN_LIKELIHOOD_ENV_VAR_NAME } from 'src/constants/pdl-company-min-likelihood-env-var-name';+import { PDL_COMPANY_WEAK_IDENTIFIER_MIN_LIKELIHOOD_ENV_VAR_NAME } from 'src/constants/pdl-company-weak-identifier-min-likelihood-env-var-name';+import { PDL_PERSON_MIN_LIKELIHOOD_ENV_VAR_NAME } from 'src/constants/pdl-person-min-likelihood-env-var-name';+import { PDL_PERSON_WEAK_IDENTIFIER_MIN_LIKELIHOOD_ENV_VAR_NAME } from 'src/constants/pdl-person-weak-identifier-min-likelihood-env-var-name';+import {+ APPLICATION_UNIVERSAL_IDENTIFIER,+ PDL_APPLICATION_VARIABLE_UNIVERSAL_IDENTIFIERS,+} from 'src/constants/universal-identifiers';export default defineApplication({universalIdentifier: APPLICATION_UNIVERSAL_IDENTIFIER,@@ -14,23 +23,53 @@ export default defineApplication({description:'$0.336 per person match and $0.12 per company match. Not found and skipped records are free. Billed to your Twenty credits.',},- serverVariables: {- PDL_API_KEY: {- description: 'People Data Labs API key',- isSecret: true,- isRequired: true,+ applicationVariables: {+ [PDL_PERSON_MIN_LIKELIHOOD_ENV_VAR_NAME]: {+ universalIdentifier:+ PDL_APPLICATION_VARIABLE_UNIVERSAL_IDENTIFIERS.personMinLikelihood,+ label: 'Minimum likelihood for people',+ description:+ 'Minimum match likelihood (1-10) for people enrichment. An explicit workflow minimum likelihood takes precedence.',+ type: FieldType.NUMBER,+ isSecret: false,+ value: DEFAULT_MIN_LIKELIHOOD,},- PDL_PERSON_MIN_LIKELIHOOD: {+ [PDL_COMPANY_MIN_LIKELIHOOD_ENV_VAR_NAME]: {+ universalIdentifier:+ PDL_APPLICATION_VARIABLE_UNIVERSAL_IDENTIFIERS.companyMinLikelihood,+ label: 'Minimum likelihood for companies',description:- 'Default minimum likelihood (1-10) for people enrichment. Used by command menu items and workflow nodes without an explicit minimum likelihood. When unset, uses 2 for strong identifiers and 6 for name-based matches.',+ 'Minimum match likelihood (1-10) for company enrichment. An explicit workflow minimum likelihood takes precedence.',type: FieldType.NUMBER,isSecret: false,+ value: DEFAULT_MIN_LIKELIHOOD,},- PDL_COMPANY_MIN_LIKELIHOOD: {+ [PDL_PERSON_WEAK_IDENTIFIER_MIN_LIKELIHOOD_ENV_VAR_NAME]: {+ universalIdentifier:+ PDL_APPLICATION_VARIABLE_UNIVERSAL_IDENTIFIERS.personWeakIdentifierMinLikelihood,+ label: 'Minimum likelihood for name-based people matches',description:- 'Default minimum likelihood (1-10) for company enrichment. Used by command menu items and workflow nodes without an explicit minimum likelihood. When unset, uses 2 for strong identifiers and 6 for name-based matches.',+ 'Minimum match likelihood (1-10) when matching a person by name and company. Uses the higher of this value and the people minimum. Explicit workflow minimum likelihoods take precedence.',type: FieldType.NUMBER,isSecret: false,+ value: DEFAULT_WEAK_IDENTIFIER_MIN_LIKELIHOOD,+ },+ [PDL_COMPANY_WEAK_IDENTIFIER_MIN_LIKELIHOOD_ENV_VAR_NAME]: {+ universalIdentifier:+ PDL_APPLICATION_VARIABLE_UNIVERSAL_IDENTIFIERS.companyWeakIdentifierMinLikelihood,+ label: 'Minimum likelihood for name-based company matches',+ description:+ 'Minimum match likelihood (1-10) when matching a company by name only. Uses the higher of this value and the company minimum. Explicit workflow minimum likelihoods take precedence.',+ type: FieldType.NUMBER,+ isSecret: false,+ value: DEFAULT_WEAK_IDENTIFIER_MIN_LIKELIHOOD,+ },+ },+ serverVariables: {+ PDL_API_KEY: {+ description: 'People Data Labs API key',+ isSecret: true,+ isRequired: true,},},});diff --git a/packages/twenty-apps/public/people-data-labs/src/constants/default-min-likelihood.ts b/packages/twenty-apps/public/people-data-labs/src/constants/default-min-likelihood.tsnew file mode 100644index 00000000000..bb0528826f9--- /dev/null+++ b/packages/twenty-apps/public/people-data-labs/src/constants/default-min-likelihood.ts@@ -0,0 +1 @@+export const DEFAULT_MIN_LIKELIHOOD = 2;diff --git a/packages/twenty-apps/public/people-data-labs/src/constants/default-weak-identifier-min-likelihood.ts b/packages/twenty-apps/public/people-data-labs/src/constants/default-weak-identifier-min-likelihood.tsnew file mode 100644index 00000000000..703b2ff8858--- /dev/null+++ b/packages/twenty-apps/public/people-data-labs/src/constants/default-weak-identifier-min-likelihood.ts@@ -0,0 +1 @@+export const DEFAULT_WEAK_IDENTIFIER_MIN_LIKELIHOOD = 6;diff --git a/packages/twenty-apps/public/people-data-labs/src/constants/likelihood-range.ts b/packages/twenty-apps/public/people-data-labs/src/constants/likelihood-range.tsnew file mode 100644index 00000000000..3aa6c7ee8f2--- /dev/null+++ b/packages/twenty-apps/public/people-data-labs/src/constants/likelihood-range.ts@@ -0,0 +1 @@+export const LIKELIHOOD_RANGE = { min: 1, max: 10 } as const;diff --git a/packages/twenty-apps/public/people-data-labs/src/constants/pdl-company-min-likelihood-env-var-name.ts b/packages/twenty-apps/public/people-data-labs/src/constants/pdl-company-min-likelihood-env-var-name.tsnew file mode 100644index 00000000000..3eacf09eb60--- /dev/null+++ b/packages/twenty-apps/public/people-data-labs/src/constants/pdl-company-min-likelihood-env-var-name.ts@@ -0,0 +1,2 @@+export const PDL_COMPANY_MIN_LIKELIHOOD_ENV_VAR_NAME =+ 'PDL_COMPANY_MIN_LIKELIHOOD';diff --git a/packages/twenty-apps/public/people-data-labs/src/constants/pdl-company-weak-identifier-min-likelihood-env-var-name.ts b/packages/twenty-apps/public/people-data-labs/src/constants/pdl-company-weak-identifier-min-likelihood-env-var-name.tsnew file mode 100644index 00000000000..3aa499aa137--- /dev/null+++ b/packages/twenty-apps/public/people-data-labs/src/constants/pdl-company-weak-identifier-min-likelihood-env-var-name.ts@@ -0,0 +1,2 @@+export const PDL_COMPANY_WEAK_IDENTIFIER_MIN_LIKELIHOOD_ENV_VAR_NAME =+ 'PDL_COMPANY_WEAK_IDENTIFIER_MIN_LIKELIHOOD';diff --git a/packages/twenty-apps/public/people-data-labs/src/constants/pdl-person-min-likelihood-env-var-name.ts b/packages/twenty-apps/public/people-data-labs/src/constants/pdl-person-min-likelihood-env-var-name.tsnew file mode 100644index 00000000000..505beb7150e--- /dev/null+++ b/packages/twenty-apps/public/people-data-labs/src/constants/pdl-person-min-likelihood-env-var-name.ts@@ -0,0 +1,2 @@+export const PDL_PERSON_MIN_LIKELIHOOD_ENV_VAR_NAME =+ 'PDL_PERSON_MIN_LIKELIHOOD';diff --git a/packages/twenty-apps/public/people-data-labs/src/constants/pdl-person-weak-identifier-min-likelihood-env-var-name.ts b/packages/twenty-apps/public/people-data-labs/src/constants/pdl-person-weak-identifier-min-likelihood-env-var-name.tsnew file mode 100644index 00000000000..a5a3e1e8691--- /dev/null+++ b/packages/twenty-apps/public/people-data-labs/src/constants/pdl-person-weak-identifier-min-likelihood-env-var-name.ts@@ -0,0 +1,2 @@+export const PDL_PERSON_WEAK_IDENTIFIER_MIN_LIKELIHOOD_ENV_VAR_NAME =+ 'PDL_PERSON_WEAK_IDENTIFIER_MIN_LIKELIHOOD';diff --git a/packages/twenty-apps/public/people-data-labs/src/constants/universal-identifiers.ts b/packages/twenty-apps/public/people-data-labs/src/constants/universal-identifiers.tsindex 2073f60fa2f..96e9dd9abc4 100644--- a/packages/twenty-apps/public/people-data-labs/src/constants/universal-identifiers.ts+++ b/packages/twenty-apps/public/people-data-labs/src/constants/universal-identifiers.ts@@ -4,6 +4,13 @@ export const APPLICATION_UNIVERSAL_IDENTIFIER =export const DEFAULT_ROLE_UNIVERSAL_IDENTIFIER ='abb2aa9f-8e9c-4e8b-a336-f864ee78b7cd';+export const PDL_APPLICATION_VARIABLE_UNIVERSAL_IDENTIFIERS = {+ personMinLikelihood: 'a45f04fd-ce7b-468a-bc79-5945041dc7e8',+ companyMinLikelihood: '8301c260-5028-42f5-8f10-8b74d5d4d134',+ personWeakIdentifierMinLikelihood: '4160c7ad-fc3f-405d-87ed-7950292fbe22',+ companyWeakIdentifierMinLikelihood: '1f608910-8ab1-4546-b27f-44507eb3d6f8',+} as const;+export const PDL_LOGIC_FUNCTION_CONSTANTS = {enrichPeople: { universalIdentifier: '65356a82-6734-4fc9-8172-7d30ed1b7859', path: '/people-data-labs/enrich-people' },enrichPerson: { universalIdentifier:'864ad69b-ff9f-4635-9aed-16fd0c2ad210', path: '/people-data-labs/enrich-person' },diff --git a/packages/twenty-apps/public/people-data-labs/src/logic-functions/enrich-companies.function.ts b/packages/twenty-apps/public/people-data-labs/src/logic-functions/enrich-companies.function.tsindex a92cdeeb299..b7ff83dab87 100644--- a/packages/twenty-apps/public/people-data-labs/src/logic-functions/enrich-companies.function.ts+++ b/packages/twenty-apps/public/people-data-labs/src/logic-functions/enrich-companies.function.ts@@ -42,6 +42,10 @@ export default defineLogicFunction({type: 'number',label: 'Minimum likelihood (1-10)',},+ weakIdentifierMinLikelihood: {+ type: 'number',+ label: 'Minimum likelihood for name-based matches (1-10)',+ },},},],diff --git a/packages/twenty-apps/public/people-data-labs/src/logic-functions/enrich-company.function.ts b/packages/twenty-apps/public/people-data-labs/src/logic-functions/enrich-company.function.tsindex 3feb0e16019..53e820e4923 100644--- a/packages/twenty-apps/public/people-data-labs/src/logic-functions/enrich-company.function.ts+++ b/packages/twenty-apps/public/people-data-labs/src/logic-functions/enrich-company.function.ts@@ -36,6 +36,10 @@ export default defineLogicFunction({type: 'number',label: 'Minimum likelihood (1-10)',},+ weakIdentifierMinLikelihood: {+ type: 'number',+ label: 'Minimum likelihood for name-based matches (1-10)',+ },},},],diff --git a/packages/twenty-apps/public/people-data-labs/src/logic-functions/enrich-people.function.ts b/packages/twenty-apps/public/people-data-labs/src/logic-functions/enrich-people.function.tsindex 3bc5eecfa7e..eb5fe1fce29 100644--- a/packages/twenty-apps/public/people-data-labs/src/logic-functions/enrich-people.function.ts+++ b/packages/twenty-apps/public/people-data-labs/src/logic-functions/enrich-people.function.ts@@ -42,6 +42,10 @@ export default defineLogicFunction({type: 'number',label: 'Minimum likelihood (1-10)',},+ weakIdentifierMinLikelihood: {+ type: 'number',+ label: 'Minimum likelihood for name-based matches (1-10)',+ },},},],diff --git a/packages/twenty-apps/public/people-data-labs/src/logic-functions/enrich-person.function.ts b/packages/twenty-apps/public/people-data-labs/src/logic-functions/enrich-person.function.tsindex aaa7e31e7ac..9c2d2605308 100644--- a/packages/twenty-apps/public/people-data-labs/src/logic-functions/enrich-person.function.ts+++ b/packages/twenty-apps/public/people-data-labs/src/logic-functions/enrich-person.function.ts@@ -36,6 +36,10 @@ export default defineLogicFunction({type: 'number',label: 'Minimum likelihood (1-10)',},+ weakIdentifierMinLikelihood: {+ type: 'number',+ label: 'Minimum likelihood for name-based matches (1-10)',+ },},},],diff --git a/packages/twenty-apps/public/people-data-labs/src/logic-functions/handlers/__tests__/enrich-people.test.ts b/packages/twenty-apps/public/people-data-labs/src/logic-functions/handlers/__tests__/enrich-people.test.tsindex c9f9e1d20d6..eeb36c9934d 100644--- a/packages/twenty-apps/public/people-data-labs/src/logic-functions/handlers/__tests__/enrich-people.test.ts+++ b/packages/twenty-apps/public/people-data-labs/src/logic-functions/handlers/__tests__/enrich-people.test.ts@@ -74,20 +74,33 @@ beforeEach(() => {});describe('enrichPeopleCore', () => {- it('rejects an invalid likelihood before calling PDL or writing records', async () => {- const captured: Captured = {};- const client = buildClient({ people: [PERSON_NODE_MOCK], captured });-- await expect(- enrichPeopleCore({- input: { records: [{ id: 'p1' }], minLikelihood: 11 },- client,- }),- ).rejects.toThrow('Minimum likelihood must be an integer between 1 and 10.');-- expect(enrichPeopleMock).not.toHaveBeenCalled();- expect(captured).toEqual({});- });+ it.each([+ {+ input: { minLikelihood: 11 },+ message: 'Minimum likelihood must be an integer between 1 and 10.',+ },+ {+ input: { weakIdentifierMinLikelihood: 11 },+ message:+ 'Minimum likelihood for name-based matches must be an integer between 1 and 10.',+ },+ ])(+ 'rejects invalid likelihood input $input before calling PDL or writing records',+ async ({ input, message }) => {+ const captured: Captured = {};+ const client = buildClient({ people: [PERSON_NODE_MOCK], captured });++ await expect(+ enrichPeopleCore({+ input: { records: [{ id: 'p1' }], ...input },+ client,+ }),+ ).rejects.toThrow(message);++ expect(enrichPeopleMock).not.toHaveBeenCalled();+ expect(captured).toEqual({});+ },+ );it('fills empty standard fields and writes pdl metadata via updatePerson on a match', async () => {enrichPeopleMock.mockResolvedValue([diff --git a/packages/twenty-apps/public/people-data-labs/src/logic-functions/handlers/company-enrichment-adapter.ts b/packages/twenty-apps/public/people-data-labs/src/logic-functions/handlers/company-enrichment-adapter.tsindex b8468de7ac4..44f2c5bd8b3 100644--- a/packages/twenty-apps/public/people-data-labs/src/logic-functions/handlers/company-enrichment-adapter.ts+++ b/packages/twenty-apps/public/people-data-labs/src/logic-functions/handlers/company-enrichment-adapter.ts@@ -1,4 +1,6 @@import { COMPANY_MATCH_COST_DOLLARS } from 'src/constants/company-match-cost-dollars';+import { PDL_COMPANY_MIN_LIKELIHOOD_ENV_VAR_NAME } from 'src/constants/pdl-company-min-likelihood-env-var-name';+import { PDL_COMPANY_WEAK_IDENTIFIER_MIN_LIKELIHOOD_ENV_VAR_NAME } from 'src/constants/pdl-company-weak-identifier-min-likelihood-env-var-name';import { buildCompanyMatchedData } from 'src/logic-functions/utils/build-company-matched-data';import { enrichCompanies } from 'src/logic-functions/utils/enrich-companies';import { extractCompanyMatchParams } from 'src/logic-functions/utils/extract-company-match-params';@@ -19,6 +21,9 @@ export const companyEnrichmentAdapter: BatchEnrichmentAdapter<noIdentifierMessage:'No usable identifier (domain, LinkedIn, or name) to match against PDL.',costPerMatchDollars: COMPANY_MATCH_COST_DOLLARS,+ minLikelihoodEnvVarName: PDL_COMPANY_MIN_LIKELIHOOD_ENV_VAR_NAME,+ weakIdentifierMinLikelihoodEnvVarName:+ PDL_COMPANY_WEAK_IDENTIFIER_MIN_LIKELIHOOD_ENV_VAR_NAME,readRecords: readCompanies,getNodeId: (node) => node.id,extractParams: extractCompanyMatchParams,diff --git a/packages/twenty-apps/public/people-data-labs/src/logic-functions/handlers/person-enrichment-adapter.ts b/packages/twenty-apps/public/people-data-labs/src/logic-functions/handlers/person-enrichment-adapter.tsindex e304a57d825..b820782deb3 100644--- a/packages/twenty-apps/public/people-data-labs/src/logic-functions/handlers/person-enrichment-adapter.ts+++ b/packages/twenty-apps/public/people-data-labs/src/logic-functions/handlers/person-enrichment-adapter.ts@@ -1,3 +1,5 @@+import { PDL_PERSON_MIN_LIKELIHOOD_ENV_VAR_NAME } from 'src/constants/pdl-person-min-likelihood-env-var-name';+import { PDL_PERSON_WEAK_IDENTIFIER_MIN_LIKELIHOOD_ENV_VAR_NAME } from 'src/constants/pdl-person-weak-identifier-min-likelihood-env-var-name';import { PERSON_MATCH_COST_DOLLARS } from 'src/constants/person-match-cost-dollars';import { buildPersonMatchedData } from 'src/logic-functions/utils/build-person-matched-data';import { enrichPeople } from 'src/logic-functions/utils/enrich-people';@@ -19,6 +21,9 @@ export const personEnrichmentAdapter: BatchEnrichmentAdapter<noIdentifierMessage:'No usable identifier (email, LinkedIn, PDL id, or name paired with a company) to match against PDL.',costPerMatchDollars: PERSON_MATCH_COST_DOLLARS,+ minLikelihoodEnvVarName: PDL_PERSON_MIN_LIKELIHOOD_ENV_VAR_NAME,+ weakIdentifierMinLikelihoodEnvVarName:+ PDL_PERSON_WEAK_IDENTIFIER_MIN_LIKELIHOOD_ENV_VAR_NAME,readRecords: readPeople,getNodeId: (node) => node.id,extractParams: extractPersonMatchParams,diff --git a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/extract-company-match-params.test.ts b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/extract-company-match-params.test.tsindex 2bb7e3b94a7..d65b2023a26 100644--- a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/extract-company-match-params.test.ts+++ b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/extract-company-match-params.test.ts@@ -1,52 +1,31 @@-import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';+import { describe, expect, it } from 'vitest';import { COMPANY_NODE_MOCK } from 'src/logic-functions/__mocks__/company-node.mock';import { extractCompanyMatchParams } from 'src/logic-functions/utils/extract-company-match-params';+import { type MinLikelihoods } from 'src/types/min-likelihoods';-const INPUT = { records: [] };+const MIN_LIKELIHOODS: MinLikelihoods = {+ strongIdentifierMinLikelihood: 3,+ weakIdentifierMinLikelihood: 7,+};describe('extractCompanyMatchParams', () => {- beforeEach(() => {- vi.stubEnv('PDL_PERSON_MIN_LIKELIHOOD', undefined);- vi.stubEnv('PDL_COMPANY_MIN_LIKELIHOOD', undefined);- });-- afterEach(() => {- vi.unstubAllEnvs();- });-- it.each([- { name: 'a PDL ID', node: { ...COMPANY_NODE_MOCK, pdlId: 'pdl-c' } },- { name: 'a domain', node: COMPANY_NODE_MOCK },- {- name: 'a name only',- node: { ...COMPANY_NODE_MOCK, domainName: null, name: 'Acme' },- },- ])('uses the company default when matching by $name', ({ node }) => {- vi.stubEnv('PDL_PERSON_MIN_LIKELIHOOD', '7');- vi.stubEnv('PDL_COMPANY_MIN_LIKELIHOOD', '8');-- expect(- extractCompanyMatchParams({ node, input: INPUT }),- ).toMatchObject({ minLikelihood: 8 });- });-it('prefers an existing pdlId with the strong-identifier likelihood', () => {expect(extractCompanyMatchParams({node: { ...COMPANY_NODE_MOCK, pdlId: 'pdl-c' },- input: INPUT,+ minLikelihoods: MIN_LIKELIHOODS,}),- ).toEqual({ pdlId: 'pdl-c', minLikelihood: 2 });+ ).toEqual({ pdlId: 'pdl-c', minLikelihood: 3 });});it('uses the domain and name with the strong-identifier likelihood', () => {expect(extractCompanyMatchParams({node: { ...COMPANY_NODE_MOCK, name: 'Acme' },- input: INPUT,+ minLikelihoods: MIN_LIKELIHOODS,}),- ).toEqual({ website: 'acme.com', name: 'Acme', minLikelihood: 2 });+ ).toEqual({ website: 'acme.com', name: 'Acme', minLikelihood: 3 });});it('uses the linkedin profile as a strong identifier, stripped to the PDL path format', () => {@@ -60,12 +39,12 @@ describe('extractCompanyMatchParams', () => {},name: 'Acme',},- input: INPUT,+ minLikelihoods: MIN_LIKELIHOODS,}),).toEqual({profile: 'linkedin.com/company/acme',name: 'Acme',- minLikelihood: 2,+ minLikelihood: 3,});});@@ -77,36 +56,25 @@ describe('extractCompanyMatchParams', () => {domainName: { primaryLinkUrl: 'https://www.acme.com/' },name: 'Acme',},- input: INPUT,+ minLikelihoods: MIN_LIKELIHOODS,}),- ).toEqual({ website: 'acme.com', name: 'Acme', minLikelihood: 2 });+ ).toEqual({ website: 'acme.com', name: 'Acme', minLikelihood: 3 });});- it('raises the likelihood when only a name is available', () => {+ it('uses the weak-identifier likelihood when only a name is available', () => {expect(extractCompanyMatchParams({node: { ...COMPANY_NODE_MOCK, domainName: null, name: 'Acme' },- input: INPUT,- }),- ).toEqual({ name: 'Acme', minLikelihood: 6 });- });-- it('honors an explicit minLikelihood from the input', () => {- vi.stubEnv('PDL_COMPANY_MIN_LIKELIHOOD', '8');-- expect(- extractCompanyMatchParams({- node: { ...COMPANY_NODE_MOCK, name: 'Acme' },- input: { records: [], minLikelihood: 9 },+ minLikelihoods: MIN_LIKELIHOODS,}),- ).toMatchObject({ minLikelihood: 9 });+ ).toEqual({ name: 'Acme', minLikelihood: 7 });});it('returns undefined when there is no usable identifier', () => {expect(extractCompanyMatchParams({node: { ...COMPANY_NODE_MOCK, domainName: null, name: '' },- input: INPUT,+ minLikelihoods: MIN_LIKELIHOODS,}),).toBeUndefined();});diff --git a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/extract-person-match-params.test.ts b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/extract-person-match-params.test.tsindex f6bd58dfc64..d68a446e799 100644--- a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/extract-person-match-params.test.ts+++ b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/extract-person-match-params.test.ts@@ -1,57 +1,33 @@-import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';+import { describe, expect, it } from 'vitest';import { PERSON_NODE_MOCK } from 'src/logic-functions/__mocks__/person-node.mock';import { extractPersonMatchParams } from 'src/logic-functions/utils/extract-person-match-params';+import { type MinLikelihoods } from 'src/types/min-likelihoods';-describe('extractPersonMatchParams', () => {- beforeEach(() => {- vi.stubEnv('PDL_PERSON_MIN_LIKELIHOOD', undefined);- vi.stubEnv('PDL_COMPANY_MIN_LIKELIHOOD', undefined);- });-- afterEach(() => {- vi.unstubAllEnvs();- });-- it.each([- { name: 'a PDL ID', node: { ...PERSON_NODE_MOCK, pdlId: 'pdl-1' } },- { name: 'a LinkedIn profile', node: PERSON_NODE_MOCK },- {- name: 'a name and company',- node: {- ...PERSON_NODE_MOCK,- linkedinLink: null,- name: { firstName: 'Jane', lastName: 'Doe' },- company: { id: 'co-1', name: 'Acme' },- },- },- ])('uses the person default when matching by $name', ({ node }) => {- vi.stubEnv('PDL_PERSON_MIN_LIKELIHOOD', '7');- vi.stubEnv('PDL_COMPANY_MIN_LIKELIHOOD', '8');-- expect(- extractPersonMatchParams({ node, input: { records: [] } }),- ).toMatchObject({ minLikelihood: 7 });- });+const MIN_LIKELIHOODS: MinLikelihoods = {+ strongIdentifierMinLikelihood: 3,+ weakIdentifierMinLikelihood: 7,+};+describe('extractPersonMatchParams', () => {it('prefers an existing pdlId and uses the strong-identifier likelihood', () => {expect(extractPersonMatchParams({node: { ...PERSON_NODE_MOCK, pdlId: 'pdl-1' },- input: { records: [] },+ minLikelihoods: MIN_LIKELIHOODS,}),- ).toEqual({ pdlId: 'pdl-1', minLikelihood: 2 });+ ).toEqual({ pdlId: 'pdl-1', minLikelihood: 3 });});it('uses the linkedin profile with the strong-identifier likelihood', () => {expect(extractPersonMatchParams({node: PERSON_NODE_MOCK,- input: { records: [] },+ minLikelihoods: MIN_LIKELIHOODS,}),).toEqual({profile: 'https://linkedin.com/in/existing',- minLikelihood: 2,+ minLikelihood: 3,});});@@ -64,9 +40,9 @@ describe('extractPersonMatchParams', () => {name: { firstName: 'Jane', lastName: 'Doe' },company: { id: 'co-1', name: 'Acme' },},- input: { records: [] },+ minLikelihoods: MIN_LIKELIHOODS,}),- ).toEqual({ name: 'Jane Doe', company: 'Acme', minLikelihood: 6 });+ ).toEqual({ name: 'Jane Doe', company: 'Acme', minLikelihood: 7 });});it('returns undefined for a name with no anchoring identifier or company', () => {@@ -77,30 +53,16 @@ describe('extractPersonMatchParams', () => {linkedinLink: null,name: { firstName: 'Jane', lastName: 'Doe' },},- input: { records: [] },+ minLikelihoods: MIN_LIKELIHOODS,}),).toBeUndefined();});- it('honors an explicit minLikelihood from the input', () => {- vi.stubEnv('PDL_PERSON_MIN_LIKELIHOOD', '7');-- expect(- extractPersonMatchParams({- node: PERSON_NODE_MOCK,- input: {- records: [],- minLikelihood: 9,- },- }),- ).toMatchObject({ minLikelihood: 9 });- });-it('returns undefined when there is no usable identifier', () => {expect(extractPersonMatchParams({node: { ...PERSON_NODE_MOCK, linkedinLink: null },- input: { records: [] },+ minLikelihoods: MIN_LIKELIHOODS,}),).toBeUndefined();});diff --git a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/resolve-min-likelihood.test.ts b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/resolve-min-likelihood.test.tsdeleted file mode 100644index ad3fc97fc44..00000000000--- a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/resolve-min-likelihood.test.ts+++ /dev/null@@ -1,118 +0,0 @@-import { describe, expect, it } from 'vitest';--import { PdlConfigError } from 'src/logic-functions/errors/pdl-config-error';-import { PdlInvalidInputError } from 'src/logic-functions/errors/pdl-invalid-input-error';-import { resolveMinLikelihood } from 'src/logic-functions/utils/resolve-min-likelihood';--describe('resolveMinLikelihood', () => {- it.each([undefined, null])(- 'keeps identifier-dependent defaults when the input is %s',- (inputMinLikelihood) => {- expect(- resolveMinLikelihood({ inputMinLikelihood, hasStrongIdentifier: true }),- ).toBe(2);- expect(- resolveMinLikelihood({ inputMinLikelihood, hasStrongIdentifier: false }),- ).toBe(6);- },- );-- it.each(['', ' '])(- 'keeps identifier-dependent defaults when the configured default is %j',- (defaultMinLikelihood) => {- expect(- resolveMinLikelihood({- inputMinLikelihood: undefined,- defaultMinLikelihood,- hasStrongIdentifier: true,- }),- ).toBe(2);- expect(- resolveMinLikelihood({- inputMinLikelihood: undefined,- defaultMinLikelihood,- hasStrongIdentifier: false,- }),- ).toBe(6);- },- );-- it.each(['1', '7', '10', ' 7 '])(- 'uses the configured default of %j regardless of identifier strength',- (defaultMinLikelihood) => {- expect(- resolveMinLikelihood({- inputMinLikelihood: undefined,- defaultMinLikelihood,- hasStrongIdentifier: true,- }),- ).toBe(Number(defaultMinLikelihood));- expect(- resolveMinLikelihood({- inputMinLikelihood: null,- defaultMinLikelihood,- hasStrongIdentifier: false,- }),- ).toBe(Number(defaultMinLikelihood));- },- );-- it.each(['8', 'invalid'])(- 'uses an explicit likelihood over the configured default of %j',- (defaultMinLikelihood) => {- expect(- resolveMinLikelihood({- inputMinLikelihood: 4,- defaultMinLikelihood,- hasStrongIdentifier: true,- }),- ).toBe(4);- },- );-- it.each(['-1', '0', '11', '1.5', 'NaN', 'Infinity', '7invalid'])(- 'rejects an invalid configured default of %j',- (defaultMinLikelihood) => {- expect(() =>- resolveMinLikelihood({- inputMinLikelihood: undefined,- defaultMinLikelihood,- hasStrongIdentifier: true,- }),- ).toThrow(- new PdlConfigError(- 'Default minimum likelihood must be an integer between 1 and 10.',- ),- );- },- );-- it.each([1, 6, 10])(- 'uses an explicit likelihood of %s regardless of identifier strength',- (inputMinLikelihood) => {- expect(- resolveMinLikelihood({- inputMinLikelihood,- defaultMinLikelihood: '7',- hasStrongIdentifier: true,- }),- ).toBe(inputMinLikelihood);- expect(- resolveMinLikelihood({ inputMinLikelihood, hasStrongIdentifier: false }),- ).toBe(inputMinLikelihood);- },- );-- it.each([-1, 0, 11, 1.5, NaN, Infinity])(- 'rejects an invalid likelihood of %s',- (inputMinLikelihood) => {- expect(() =>- resolveMinLikelihood({ inputMinLikelihood, hasStrongIdentifier: true }),- ).toThrow(- new PdlInvalidInputError(- 'Minimum likelihood must be an integer between 1 and 10.',- ),- );- },- );-});diff --git a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/resolve-min-likelihoods.test.ts b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/resolve-min-likelihoods.test.tsnew file mode 100644index 00000000000..db854ef137e--- /dev/null+++ b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/resolve-min-likelihoods.test.ts@@ -0,0 +1,266 @@+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';++import { PDL_COMPANY_MIN_LIKELIHOOD_ENV_VAR_NAME } from 'src/constants/pdl-company-min-likelihood-env-var-name';+import { PDL_COMPANY_WEAK_IDENTIFIER_MIN_LIKELIHOOD_ENV_VAR_NAME } from 'src/constants/pdl-company-weak-identifier-min-likelihood-env-var-name';+import { PDL_PERSON_MIN_LIKELIHOOD_ENV_VAR_NAME } from 'src/constants/pdl-person-min-likelihood-env-var-name';+import { PDL_PERSON_WEAK_IDENTIFIER_MIN_LIKELIHOOD_ENV_VAR_NAME } from 'src/constants/pdl-person-weak-identifier-min-likelihood-env-var-name';+import { PdlConfigError } from 'src/logic-functions/errors/pdl-config-error';+import { PdlInvalidInputError } from 'src/logic-functions/errors/pdl-invalid-input-error';+import { resolveMinLikelihoods } from 'src/logic-functions/utils/resolve-min-likelihoods';++const PERSON_ENV_VAR_NAMES = {+ minLikelihoodEnvVarName: PDL_PERSON_MIN_LIKELIHOOD_ENV_VAR_NAME,+ weakIdentifierMinLikelihoodEnvVarName:+ PDL_PERSON_WEAK_IDENTIFIER_MIN_LIKELIHOOD_ENV_VAR_NAME,+};++const COMPANY_ENV_VAR_NAMES = {+ minLikelihoodEnvVarName: PDL_COMPANY_MIN_LIKELIHOOD_ENV_VAR_NAME,+ weakIdentifierMinLikelihoodEnvVarName:+ PDL_COMPANY_WEAK_IDENTIFIER_MIN_LIKELIHOOD_ENV_VAR_NAME,+};++const INVALID_CONFIGURED_VALUES = [+ '-1',+ '0',+ '11',+ '1.5',+ 'NaN',+ 'Infinity',+ '7invalid',+];++const INVALID_INPUT_VALUES = [-1, 0, 11, 1.5, NaN, Infinity];++const INVALID_SETTING_ERROR = new PdlConfigError(+ 'Each minimum likelihood setting must be an integer between 1 and 10.',+);++describe('resolveMinLikelihoods', () => {+ beforeEach(() => {+ for (const envVarName of [+ PDL_PERSON_MIN_LIKELIHOOD_ENV_VAR_NAME,+ PDL_PERSON_WEAK_IDENTIFIER_MIN_LIKELIHOOD_ENV_VAR_NAME,+ PDL_COMPANY_MIN_LIKELIHOOD_ENV_VAR_NAME,+ PDL_COMPANY_WEAK_IDENTIFIER_MIN_LIKELIHOOD_ENV_VAR_NAME,+ ]) {+ vi.stubEnv(envVarName, undefined);+ }+ });++ afterEach(() => {+ vi.unstubAllEnvs();+ });++ describe.each([+ { objectName: 'people', envVarNames: PERSON_ENV_VAR_NAMES },+ { objectName: 'companies', envVarNames: COMPANY_ENV_VAR_NAMES },+ ])('settings for $objectName', ({ envVarNames }) => {+ const { minLikelihoodEnvVarName, weakIdentifierMinLikelihoodEnvVarName } =+ envVarNames;++ it.each([undefined, '', ' '])(+ 'uses the default likelihoods when the settings are %j',+ (configuredValue) => {+ vi.stubEnv(minLikelihoodEnvVarName, configuredValue);+ vi.stubEnv(weakIdentifierMinLikelihoodEnvVarName, configuredValue);++ expect(resolveMinLikelihoods({ input: {}, ...envVarNames })).toEqual({+ strongIdentifierMinLikelihood: 2,+ weakIdentifierMinLikelihood: 6,+ });+ },+ );++ it.each([+ { configuredValue: '1', weakIdentifierMinLikelihood: 6 },+ { configuredValue: '7', weakIdentifierMinLikelihood: 7 },+ { configuredValue: '10', weakIdentifierMinLikelihood: 10 },+ { configuredValue: ' 7 ', weakIdentifierMinLikelihood: 7 },+ ])(+ 'uses a configured minimum of $configuredValue with the name-based setting as a floor',+ ({ configuredValue, weakIdentifierMinLikelihood }) => {+ vi.stubEnv(minLikelihoodEnvVarName, configuredValue);++ expect(resolveMinLikelihoods({ input: {}, ...envVarNames })).toEqual({+ strongIdentifierMinLikelihood: Number(configuredValue),+ weakIdentifierMinLikelihood,+ });+ },+ );++ it.each(INVALID_CONFIGURED_VALUES)(+ 'rejects a configured minimum of %j',+ (configuredValue) => {+ vi.stubEnv(minLikelihoodEnvVarName, configuredValue);++ expect(() =>+ resolveMinLikelihoods({ input: {}, ...envVarNames }),+ ).toThrow(INVALID_SETTING_ERROR);+ },+ );++ it.each(INVALID_CONFIGURED_VALUES)(+ 'rejects a configured name-based minimum of %j',+ (configuredValue) => {+ vi.stubEnv(weakIdentifierMinLikelihoodEnvVarName, configuredValue);++ expect(() =>+ resolveMinLikelihoods({ input: {}, ...envVarNames }),+ ).toThrow(INVALID_SETTING_ERROR);+ },+ );+ });++ it.each([+ {+ configuredValue: '2',+ configuredWeakValue: '3',+ weakIdentifierMinLikelihood: 3,+ },+ {+ configuredValue: '2',+ configuredWeakValue: '9',+ weakIdentifierMinLikelihood: 9,+ },+ {+ configuredValue: '8',+ configuredWeakValue: '3',+ weakIdentifierMinLikelihood: 8,+ },+ ])(+ 'uses $weakIdentifierMinLikelihood for name-based matches with settings $configuredValue and $configuredWeakValue',+ ({ configuredValue, configuredWeakValue, weakIdentifierMinLikelihood }) => {+ vi.stubEnv(PDL_PERSON_MIN_LIKELIHOOD_ENV_VAR_NAME, configuredValue);+ vi.stubEnv(+ PDL_PERSON_WEAK_IDENTIFIER_MIN_LIKELIHOOD_ENV_VAR_NAME,+ configuredWeakValue,+ );++ expect(+ resolveMinLikelihoods({ input: {}, ...PERSON_ENV_VAR_NAMES }),+ ).toMatchObject({ weakIdentifierMinLikelihood });+ },+ );++ it('reads only the settings it is given', () => {+ vi.stubEnv(PDL_PERSON_MIN_LIKELIHOOD_ENV_VAR_NAME, '3');+ vi.stubEnv(PDL_PERSON_WEAK_IDENTIFIER_MIN_LIKELIHOOD_ENV_VAR_NAME, '9');+ vi.stubEnv(PDL_COMPANY_MIN_LIKELIHOOD_ENV_VAR_NAME, '4');+ vi.stubEnv(PDL_COMPANY_WEAK_IDENTIFIER_MIN_LIKELIHOOD_ENV_VAR_NAME, '10');++ expect(+ resolveMinLikelihoods({ input: {}, ...PERSON_ENV_VAR_NAMES }),+ ).toEqual({+ strongIdentifierMinLikelihood: 3,+ weakIdentifierMinLikelihood: 9,+ });+ expect(+ resolveMinLikelihoods({ input: {}, ...COMPANY_ENV_VAR_NAMES }),+ ).toEqual({+ strongIdentifierMinLikelihood: 4,+ weakIdentifierMinLikelihood: 10,+ });+ });++ it.each([+ {+ input: { minLikelihood: 3 },+ expected: {+ strongIdentifierMinLikelihood: 3,+ weakIdentifierMinLikelihood: 3,+ },+ },+ {+ input: { weakIdentifierMinLikelihood: 4 },+ expected: {+ strongIdentifierMinLikelihood: 8,+ weakIdentifierMinLikelihood: 4,+ },+ },+ {+ input: { minLikelihood: 3, weakIdentifierMinLikelihood: 4 },+ expected: {+ strongIdentifierMinLikelihood: 3,+ weakIdentifierMinLikelihood: 4,+ },+ },+ {+ input: { minLikelihood: 9, weakIdentifierMinLikelihood: 4 },+ expected: {+ strongIdentifierMinLikelihood: 9,+ weakIdentifierMinLikelihood: 4,+ },+ },+ {+ input: { minLikelihood: null, weakIdentifierMinLikelihood: null },+ expected: {+ strongIdentifierMinLikelihood: 8,+ weakIdentifierMinLikelihood: 8,+ },+ },+ ])(+ 'gives explicit workflow inputs $input precedence over the settings',+ ({ input, expected }) => {+ vi.stubEnv(PDL_PERSON_MIN_LIKELIHOOD_ENV_VAR_NAME, '8');+ vi.stubEnv(PDL_PERSON_WEAK_IDENTIFIER_MIN_LIKELIHOOD_ENV_VAR_NAME, '7');++ expect(resolveMinLikelihoods({ input, ...PERSON_ENV_VAR_NAMES })).toEqual(+ expected,+ );+ },+ );++ it.each([1, 6, 10])(+ 'uses an explicit minimum of %s without reading invalid settings',+ (minLikelihood) => {+ vi.stubEnv(PDL_PERSON_MIN_LIKELIHOOD_ENV_VAR_NAME, 'invalid');+ vi.stubEnv(+ PDL_PERSON_WEAK_IDENTIFIER_MIN_LIKELIHOOD_ENV_VAR_NAME,+ 'invalid',+ );++ expect(+ resolveMinLikelihoods({+ input: { minLikelihood },+ ...PERSON_ENV_VAR_NAMES,+ }),+ ).toEqual({+ strongIdentifierMinLikelihood: minLikelihood,+ weakIdentifierMinLikelihood: minLikelihood,+ });+ },+ );++ it.each(INVALID_INPUT_VALUES)(+ 'rejects an input minimum of %s',+ (minLikelihood) => {+ expect(() =>+ resolveMinLikelihoods({+ input: { minLikelihood },+ ...PERSON_ENV_VAR_NAMES,+ }),+ ).toThrow(+ new PdlInvalidInputError(+ 'Minimum likelihood must be an integer between 1 and 10.',+ ),+ );+ },+ );++ it.each(INVALID_INPUT_VALUES)(+ 'rejects an input name-based minimum of %s',+ (weakIdentifierMinLikelihood) => {+ expect(() =>+ resolveMinLikelihoods({+ input: { minLikelihood: 3, weakIdentifierMinLikelihood },+ ...PERSON_ENV_VAR_NAMES,+ }),+ ).toThrow(+ new PdlInvalidInputError(+ 'Minimum likelihood for name-based matches must be an integer between 1 and 10.',+ ),+ );+ },+ );+});diff --git a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/run-batch-enrichment.test.ts b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/run-batch-enrichment.test.tsindex 239fd31a334..723af4735d0 100644--- a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/run-batch-enrichment.test.ts+++ b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/run-batch-enrichment.test.ts@@ -1,12 +1,15 @@-import { beforeEach, describe, expect, it, vi } from 'vitest';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import { type CoreApiClient } from 'twenty-client-sdk/core';import { chargeCredits } from 'twenty-sdk/billing';import { PDL_ACCESS_ERROR_MESSAGE } from 'src/constants/pdl-access-error-message';+import { PDL_COMPANY_MIN_LIKELIHOOD_ENV_VAR_NAME } from 'src/constants/pdl-company-min-likelihood-env-var-name';+import { PDL_COMPANY_WEAK_IDENTIFIER_MIN_LIKELIHOOD_ENV_VAR_NAME } from 'src/constants/pdl-company-weak-identifier-min-likelihood-env-var-name';import { UPDATE_FIELDS_OPTIONS } from 'src/constants/update-fields-options';import { PdlConfigError } from 'src/logic-functions/errors/pdl-config-error';import { runBatchEnrichment } from 'src/logic-functions/utils/run-batch-enrichment';import { type BatchEnrichmentAdapter } from 'src/types/batch-enrichment-adapter';+import { type MinLikelihoods } from 'src/types/min-likelihoods';import { type PdlEnrichResult } from 'src/types/pdl-enrich-result';vi.mock('twenty-sdk/billing', () => ({@@ -88,6 +91,11 @@ const buildHarness = (configs: RecordConfig[]) => {const updateManyStatus = vi.fn(async () => undefined);+ const extractParams = vi.fn(+ ({ node }: { node: FakeNode; minLikelihoods: MinLikelihoods }) =>+ node.hasIdentifier ? { id: node.id } : undefined,+ );+const buildMatchedData = vi.fn(async ({node,@@ -107,10 +115,12 @@ const buildHarness = (configs: RecordConfig[]) => {objectNameSingular: 'Test',noIdentifierMessage: 'no identifier',costPerMatchDollars: FAKE_COST_PER_MATCH_DOLLARS,+ minLikelihoodEnvVarName: PDL_COMPANY_MIN_LIKELIHOOD_ENV_VAR_NAME,+ weakIdentifierMinLikelihoodEnvVarName:+ PDL_COMPANY_WEAK_IDENTIFIER_MIN_LIKELIHOOD_ENV_VAR_NAME,readRecords,getNodeId: (node) => node.id,- extractParams: ({ node }) =>- node.hasIdentifier ? { id: node.id } : undefined,+ extractParams,enrichBatch,buildMatchedData,updateOne,@@ -120,6 +130,7 @@ const buildHarness = (configs: RecordConfig[]) => {return {adapter,readRecords,+ extractParams,enrichBatch,updateOne,updateManyStatus,@@ -146,6 +157,61 @@ describe('runBatchEnrichment', () => {vi.mocked(chargeCredits).mockClear();});+ afterEach(() => {+ vi.unstubAllEnvs();+ });++ it('resolves the likelihoods once and passes them to every chunk', async () => {+ vi.stubEnv(PDL_COMPANY_MIN_LIKELIHOOD_ENV_VAR_NAME, '4');+ const ids = buildRecordIds(150);+ const harness = buildHarness(ids.map((id) => ({ id })));++ await runBatchEnrichment({+ client: CLIENT,+ input: {+ records: ids.map((id) => ({ id })),+ weakIdentifierMinLikelihood: 9,+ },+ adapter: harness.adapter,+ });++ expect(harness.readRecords).toHaveBeenCalledTimes(2);+ expect(harness.extractParams).toHaveBeenCalledTimes(150);+ for (const [extractParamsArgs] of harness.extractParams.mock.calls) {+ expect(extractParamsArgs.minLikelihoods).toEqual({+ strongIdentifierMinLikelihood: 4,+ weakIdentifierMinLikelihood: 9,+ });+ }+ });++ it('rejects an invalid setting before reading records or calling PDL', async () => {+ vi.stubEnv(+ PDL_COMPANY_WEAK_IDENTIFIER_MIN_LIKELIHOOD_ENV_VAR_NAME,+ 'invalid',+ );+ const ids = buildRecordIds(150);+ const harness = buildHarness(ids.map((id) => ({ id })));++ await expect(+ runBatchEnrichment({+ client: CLIENT,+ input: { records: ids.map((id) => ({ id })) },+ adapter: harness.adapter,+ }),+ ).rejects.toThrow(+ new PdlConfigError(+ 'Each minimum likelihood setting must be an integer between 1 and 10.',+ ),+ );++ expect(harness.readRecords).not.toHaveBeenCalled();+ expect(harness.enrichBatch).not.toHaveBeenCalled();+ expect(harness.updateOne).not.toHaveBeenCalled();+ expect(harness.updateManyStatus).not.toHaveBeenCalled();+ expect(chargeCredits).not.toHaveBeenCalled();+ });+it('reads every id in one call and enriches the set in one batch', async () => {const harness = buildHarness([{ id: 'a' }, { id: 'b' }]);diff --git a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/run-single-enrichment.test.ts b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/run-single-enrichment.test.tsnew file mode 100644index 00000000000..3825731fb7d--- /dev/null+++ b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/__tests__/run-single-enrichment.test.ts@@ -0,0 +1,55 @@+import { afterEach, describe, expect, it, vi } from 'vitest';++import { PDL_COMPANY_MIN_LIKELIHOOD_ENV_VAR_NAME } from 'src/constants/pdl-company-min-likelihood-env-var-name';+import { PDL_COMPANY_WEAK_IDENTIFIER_MIN_LIKELIHOOD_ENV_VAR_NAME } from 'src/constants/pdl-company-weak-identifier-min-likelihood-env-var-name';+import { UPDATE_FIELDS_OPTIONS } from 'src/constants/update-fields-options';+import { COMPANY_NODE_MOCK } from 'src/logic-functions/__mocks__/company-node.mock';+import { createCoreApiClientMock } from 'src/logic-functions/__mocks__/create-core-api-client-mock';+import { companySingleEnrichmentAdapter } from 'src/logic-functions/handlers/company-single-enrichment-adapter';+import { enrichCompany } from 'src/logic-functions/utils/enrich-company';+import { runSingleEnrichment } from 'src/logic-functions/utils/run-single-enrichment';++vi.mock('src/logic-functions/utils/enrich-company', () => ({+ enrichCompany: vi.fn(),+}));++describe('runSingleEnrichment', () => {+ afterEach(() => {+ vi.unstubAllEnvs();+ vi.clearAllMocks();+ });++ it('uses both workflow overrides for a single name-based match', async () => {+ vi.stubEnv(PDL_COMPANY_MIN_LIKELIHOOD_ENV_VAR_NAME, '8');+ vi.stubEnv(PDL_COMPANY_WEAK_IDENTIFIER_MIN_LIKELIHOOD_ENV_VAR_NAME, '10');+ vi.mocked(enrichCompany).mockResolvedValue([+ { outcome: 'not_found', httpStatus: 404 },+ ]);++ const client = createCoreApiClientMock({+ queryResult: {+ companies: {+ edges: [+ { node: { ...COMPANY_NODE_MOCK, domainName: null, name: 'Acme' } },+ ],+ },+ },+ });++ const result = await runSingleEnrichment({+ client,+ input: {+ recordId: 'c1',+ updateFields: UPDATE_FIELDS_OPTIONS.no,+ minLikelihood: 3,+ weakIdentifierMinLikelihood: 4,+ },+ adapter: companySingleEnrichmentAdapter,+ });++ expect(enrichCompany).toHaveBeenCalledExactlyOnceWith([+ { name: 'Acme', minLikelihood: 4 },+ ]);+ expect(result).toMatchObject({ recordId: 'c1', status: 'NOT_FOUND' });+ });+});diff --git a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/build-invalid-likelihood-message.ts b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/build-invalid-likelihood-message.tsnew file mode 100644index 00000000000..bfe5f08a7b1--- /dev/null+++ b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/build-invalid-likelihood-message.ts@@ -0,0 +1,4 @@+import { LIKELIHOOD_RANGE } from 'src/constants/likelihood-range';++export const buildInvalidLikelihoodMessage = (label: string): string =>+ `${label} must be an integer between ${LIKELIHOOD_RANGE.min} and ${LIKELIHOOD_RANGE.max}.`;diff --git a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/enrich-chunk.ts b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/enrich-chunk.tsindex 2cdd1d4a261..0fbc76a63b5 100644--- a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/enrich-chunk.ts+++ b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/enrich-chunk.ts@@ -17,6 +17,7 @@ import { type BulkEnrichInput } from 'src/types/bulk-enrich-input';import { type CompanyIdByMatchKeyCache } from 'src/types/company-id-by-match-key-cache';import { type EnrichChunkResult } from 'src/types/enrich-chunk-result';import { type EnrichResult } from 'src/types/enrich-result';+import { type MinLikelihoods } from 'src/types/min-likelihoods';import { type PdlEnrichResult } from 'src/types/pdl-enrich-result';import { isDefined } from 'src/utils/is-defined';import { toErrorMessage } from 'src/utils/to-error-message';@@ -180,6 +181,7 @@ export const enrichChunk = async <TNode, TData, TParams>({client,recordIds,input,+ minLikelihoods,adapter,resultById,companyIdByMatchKeyCache,@@ -187,6 +189,7 @@ export const enrichChunk = async <TNode, TData, TParams>({client: CoreApiClient;recordIds: string[];input: BulkEnrichInput;+ minLikelihoods: MinLikelihoods;adapter: BatchEnrichmentAdapter<TNode, TData, TParams>;resultById: Map<string, EnrichResult>;companyIdByMatchKeyCache: CompanyIdByMatchKeyCache;@@ -229,7 +232,10 @@ export const enrichChunk = async <TNode, TData, TParams>({continue;}- const matchParams = adapter.extractParams({ node: recordNode, input });+ const matchParams = adapter.extractParams({+ node: recordNode,+ minLikelihoods,+ });if (!isDefined(matchParams)) {resultById.set(recordId,diff --git a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/extract-company-match-params.ts b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/extract-company-match-params.tsindex bab7fb9cb78..8f745746094 100644--- a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/extract-company-match-params.ts+++ b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/extract-company-match-params.ts@@ -1,29 +1,24 @@import { normalizeDomain } from 'src/logic-functions/utils/normalize-domain';import { normalizeLinkedinUrl } from 'src/logic-functions/utils/normalize-linkedin-url';-import { resolveMinLikelihood } from 'src/logic-functions/utils/resolve-min-likelihood';import { toText } from 'src/logic-functions/utils/to-text';-import { type BulkEnrichInput } from 'src/types/bulk-enrich-input';import { type CompanyNode } from 'src/types/company-node';+import { type MinLikelihoods } from 'src/types/min-likelihoods';import { type PdlCompanyEnrichParams } from 'src/types/pdl-company-enrich-params';import { isDefined } from 'src/utils/is-defined';import { pruneUndefined } from 'src/utils/prune-undefined';export const extractCompanyMatchParams = ({node,- input,+ minLikelihoods,}: {node: CompanyNode;- input: BulkEnrichInput;+ minLikelihoods: MinLikelihoods;}): PdlCompanyEnrichParams | undefined => {const existingPdlId = toText(node.pdlId);if (isDefined(existingPdlId)) {return {pdlId: existingPdlId,- minLikelihood: resolveMinLikelihood({- inputMinLikelihood: input.minLikelihood,- defaultMinLikelihood: process.env.PDL_COMPANY_MIN_LIKELIHOOD,- hasStrongIdentifier: true,- }),+ minLikelihood: minLikelihoods.strongIdentifierMinLikelihood,};}@@ -45,10 +40,8 @@ export const extractCompanyMatchParams = ({return {...companyMatchParams,- minLikelihood: resolveMinLikelihood({- inputMinLikelihood: input.minLikelihood,- defaultMinLikelihood: process.env.PDL_COMPANY_MIN_LIKELIHOOD,- hasStrongIdentifier,- }),+ minLikelihood: hasStrongIdentifier+ ? minLikelihoods.strongIdentifierMinLikelihood+ : minLikelihoods.weakIdentifierMinLikelihood,};};diff --git a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/extract-person-match-params.ts b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/extract-person-match-params.tsindex e8a85f24c58..712a70b9a97 100644--- a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/extract-person-match-params.ts+++ b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/extract-person-match-params.ts@@ -1,7 +1,6 @@import { buildPersonNameParam } from 'src/logic-functions/utils/build-person-name-param';-import { resolveMinLikelihood } from 'src/logic-functions/utils/resolve-min-likelihood';import { toText } from 'src/logic-functions/utils/to-text';-import { type BulkEnrichInput } from 'src/types/bulk-enrich-input';+import { type MinLikelihoods } from 'src/types/min-likelihoods';import { type PdlPersonEnrichParams } from 'src/types/pdl-person-enrich-params';import { type PersonNode } from 'src/types/person-node';import { isDefined } from 'src/utils/is-defined';@@ -9,20 +8,16 @@ import { pruneUndefined } from 'src/utils/prune-undefined';export const extractPersonMatchParams = ({node,- input,+ minLikelihoods,}: {node: PersonNode;- input: BulkEnrichInput;+ minLikelihoods: MinLikelihoods;}): PdlPersonEnrichParams | undefined => {const existingPdlId = toText(node.pdlId);if (isDefined(existingPdlId)) {return {pdlId: existingPdlId,- minLikelihood: resolveMinLikelihood({- inputMinLikelihood: input.minLikelihood,- defaultMinLikelihood: process.env.PDL_PERSON_MIN_LIKELIHOOD,- hasStrongIdentifier: true,- }),+ minLikelihood: minLikelihoods.strongIdentifierMinLikelihood,};}@@ -52,10 +47,8 @@ export const extractPersonMatchParams = ({return {...personMatchParams,- minLikelihood: resolveMinLikelihood({- inputMinLikelihood: input.minLikelihood,- defaultMinLikelihood: process.env.PDL_PERSON_MIN_LIKELIHOOD,- hasStrongIdentifier,- }),+ minLikelihood: hasStrongIdentifier+ ? minLikelihoods.strongIdentifierMinLikelihood+ : minLikelihoods.weakIdentifierMinLikelihood,};};diff --git a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/get-configured-min-likelihood.ts b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/get-configured-min-likelihood.tsnew file mode 100644index 00000000000..b412161078c--- /dev/null+++ b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/get-configured-min-likelihood.ts@@ -0,0 +1,29 @@+import { PdlConfigError } from 'src/logic-functions/errors/pdl-config-error';+import { buildInvalidLikelihoodMessage } from 'src/logic-functions/utils/build-invalid-likelihood-message';+import { isValidLikelihood } from 'src/logic-functions/utils/is-valid-likelihood';+import { toText } from 'src/logic-functions/utils/to-text';+import { isDefined } from 'src/utils/is-defined';++export const getConfiguredMinLikelihood = ({+ envVarName,+ defaultValue,+}: {+ envVarName: string;+ defaultValue: number;+}): number => {+ const configuredMinLikelihood = toText(process.env[envVarName]);++ if (!isDefined(configuredMinLikelihood)) {+ return defaultValue;+ }++ const minLikelihood = Number(configuredMinLikelihood);++ if (!isValidLikelihood(minLikelihood)) {+ throw new PdlConfigError(+ buildInvalidLikelihoodMessage('Each minimum likelihood setting'),+ );+ }++ return minLikelihood;+};diff --git a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/is-valid-likelihood.ts b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/is-valid-likelihood.tsnew file mode 100644index 00000000000..df71254f1df--- /dev/null+++ b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/is-valid-likelihood.ts@@ -0,0 +1,6 @@+import { LIKELIHOOD_RANGE } from 'src/constants/likelihood-range';++export const isValidLikelihood = (likelihood: number): boolean =>+ Number.isInteger(likelihood) &&+ likelihood >= LIKELIHOOD_RANGE.min &&+ likelihood <= LIKELIHOOD_RANGE.max;diff --git a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/resolve-min-likelihood.ts b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/resolve-min-likelihood.tsdeleted file mode 100644index add30423344..00000000000--- a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/resolve-min-likelihood.ts+++ /dev/null@@ -1,51 +0,0 @@-import { PdlConfigError } from 'src/logic-functions/errors/pdl-config-error';-import { PdlInvalidInputError } from 'src/logic-functions/errors/pdl-invalid-input-error';-import { toText } from 'src/logic-functions/utils/to-text';-import { isDefined } from 'src/utils/is-defined';--const MIN_LIKELIHOOD = 1;-const MAX_LIKELIHOOD = 10;-const DEFAULT_MIN_LIKELIHOOD = 2;-const WEAK_IDENTIFIER_MIN_LIKELIHOOD = 6;--export const resolveMinLikelihood = ({- inputMinLikelihood,- defaultMinLikelihood,- hasStrongIdentifier,-}: {- inputMinLikelihood: number | null | undefined;- defaultMinLikelihood?: string;- hasStrongIdentifier: boolean;-}): number => {- const configuredDefaultMinLikelihood = toText(defaultMinLikelihood);- const minLikelihood =- inputMinLikelihood ??- (isDefined(configuredDefaultMinLikelihood)- ? Number(configuredDefaultMinLikelihood)- : undefined);-- if (!isDefined(minLikelihood)) {- return hasStrongIdentifier- ? DEFAULT_MIN_LIKELIHOOD- : WEAK_IDENTIFIER_MIN_LIKELIHOOD;- }-- const isValidLikelihood =- Number.isInteger(minLikelihood) &&- minLikelihood >= MIN_LIKELIHOOD &&- minLikelihood <= MAX_LIKELIHOOD;-- if (isValidLikelihood) {- return minLikelihood;- }-- if (isDefined(inputMinLikelihood)) {- throw new PdlInvalidInputError(- `Minimum likelihood must be an integer between ${MIN_LIKELIHOOD} and ${MAX_LIKELIHOOD}.`,- );- }-- throw new PdlConfigError(- `Default minimum likelihood must be an integer between ${MIN_LIKELIHOOD} and ${MAX_LIKELIHOOD}.`,- );-};diff --git a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/resolve-min-likelihoods.ts b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/resolve-min-likelihoods.tsnew file mode 100644index 00000000000..b71ab23b2c6--- /dev/null+++ b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/resolve-min-likelihoods.ts@@ -0,0 +1,61 @@+import { DEFAULT_MIN_LIKELIHOOD } from 'src/constants/default-min-likelihood';+import { DEFAULT_WEAK_IDENTIFIER_MIN_LIKELIHOOD } from 'src/constants/default-weak-identifier-min-likelihood';+import { PdlInvalidInputError } from 'src/logic-functions/errors/pdl-invalid-input-error';+import { buildInvalidLikelihoodMessage } from 'src/logic-functions/utils/build-invalid-likelihood-message';+import { getConfiguredMinLikelihood } from 'src/logic-functions/utils/get-configured-min-likelihood';+import { isValidLikelihood } from 'src/logic-functions/utils/is-valid-likelihood';+import { type MinLikelihoods } from 'src/types/min-likelihoods';+import { isDefined } from 'src/utils/is-defined';++export const resolveMinLikelihoods = ({+ input,+ minLikelihoodEnvVarName,+ weakIdentifierMinLikelihoodEnvVarName,+}: {+ input: {+ minLikelihood?: number | null;+ weakIdentifierMinLikelihood?: number | null;+ };+ minLikelihoodEnvVarName: string;+ weakIdentifierMinLikelihoodEnvVarName: string;+}): MinLikelihoods => {+ const inputMinLikelihood = input.minLikelihood;+ const inputWeakIdentifierMinLikelihood = input.weakIdentifierMinLikelihood;++ if (isDefined(inputMinLikelihood) && !isValidLikelihood(inputMinLikelihood)) {+ throw new PdlInvalidInputError(+ buildInvalidLikelihoodMessage('Minimum likelihood'),+ );+ }++ if (+ isDefined(inputWeakIdentifierMinLikelihood) &&+ !isValidLikelihood(inputWeakIdentifierMinLikelihood)+ ) {+ throw new PdlInvalidInputError(+ buildInvalidLikelihoodMessage(+ 'Minimum likelihood for name-based matches',+ ),+ );+ }++ const strongIdentifierMinLikelihood =+ inputMinLikelihood ??+ getConfiguredMinLikelihood({+ envVarName: minLikelihoodEnvVarName,+ defaultValue: DEFAULT_MIN_LIKELIHOOD,+ });++ const weakIdentifierMinLikelihood =+ inputWeakIdentifierMinLikelihood ??+ inputMinLikelihood ??+ Math.max(+ strongIdentifierMinLikelihood,+ getConfiguredMinLikelihood({+ envVarName: weakIdentifierMinLikelihoodEnvVarName,+ defaultValue: DEFAULT_WEAK_IDENTIFIER_MIN_LIKELIHOOD,+ }),+ );++ return { strongIdentifierMinLikelihood, weakIdentifierMinLikelihood };+};diff --git a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/run-batch-enrichment.ts b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/run-batch-enrichment.tsindex 7a1e0850334..f6d731681ab 100644--- a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/run-batch-enrichment.ts+++ b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/run-batch-enrichment.ts@@ -8,6 +8,7 @@ import {import { chunk } from 'src/logic-functions/utils/chunk';import { enrichChunk } from 'src/logic-functions/utils/enrich-chunk';import { extractRecordIds } from 'src/logic-functions/utils/extract-record-ids';+import { resolveMinLikelihoods } from 'src/logic-functions/utils/resolve-min-likelihoods';import { type BatchEnrichmentAdapter } from 'src/types/batch-enrichment-adapter';import { type BulkEnrichInput } from 'src/types/bulk-enrich-input';import { type BulkEnrichResult } from 'src/types/bulk-enrich-result';@@ -26,6 +27,12 @@ export const runBatchEnrichment = async <TNode, TData, TParams>({input: BulkEnrichInput;adapter: BatchEnrichmentAdapter<TNode, TData, TParams>;}): Promise<BulkEnrichResult> => {+ const minLikelihoods = resolveMinLikelihoods({+ input,+ minLikelihoodEnvVarName: adapter.minLikelihoodEnvVarName,+ weakIdentifierMinLikelihoodEnvVarName:+ adapter.weakIdentifierMinLikelihoodEnvVarName,+ });const recordIds = Array.from(new Set(extractRecordIds(input.records)));const resultById = new Map<string, EnrichResult>();const companyIdByMatchKeyCache: CompanyIdByMatchKeyCache = new Map();@@ -36,6 +43,7 @@ export const runBatchEnrichment = async <TNode, TData, TParams>({client,recordIds: recordIdsChunk,input,+ minLikelihoods,adapter,resultById,companyIdByMatchKeyCache,diff --git a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/run-single-enrichment.ts b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/run-single-enrichment.tsindex fba88b123e8..d8ab1b82d4b 100644--- a/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/run-single-enrichment.ts+++ b/packages/twenty-apps/public/people-data-labs/src/logic-functions/utils/run-single-enrichment.ts@@ -33,6 +33,7 @@ export const runSingleEnrichment = async <TNode, TData, TParams>({records: recordId,updateFields: input.updateFields,minLikelihood: input.minLikelihood,+ weakIdentifierMinLikelihood: input.weakIdentifierMinLikelihood,},adapter,});diff --git a/packages/twenty-apps/public/people-data-labs/src/types/batch-enrichment-adapter.ts b/packages/twenty-apps/public/people-data-labs/src/types/batch-enrichment-adapter.tsindex 5a39032d714..cd74513f68b 100644--- a/packages/twenty-apps/public/people-data-labs/src/types/batch-enrichment-adapter.ts+++ b/packages/twenty-apps/public/people-data-labs/src/types/batch-enrichment-adapter.ts@@ -1,13 +1,15 @@import { type CoreApiClient } from 'twenty-client-sdk/core';-import { type BulkEnrichInput } from 'src/types/bulk-enrich-input';import { type CompanyIdByMatchKeyCache } from 'src/types/company-id-by-match-key-cache';+import { type MinLikelihoods } from 'src/types/min-likelihoods';import { type PdlEnrichResult } from 'src/types/pdl-enrich-result';export type BatchEnrichmentAdapter<TNode, TData, TParams> = {objectNameSingular: string;noIdentifierMessage: string;costPerMatchDollars: number;+ minLikelihoodEnvVarName: string;+ weakIdentifierMinLikelihoodEnvVarName: string;readRecords: (args: {client: CoreApiClient;recordIds: string[];@@ -15,7 +17,7 @@ export type BatchEnrichmentAdapter<TNode, TData, TParams> = {getNodeId: (node: TNode) => string;extractParams: (args: {node: TNode;- input: BulkEnrichInput;+ minLikelihoods: MinLikelihoods;}) => TParams | undefined;enrichBatch: (params: TParams[]) => Promise<PdlEnrichResult<TData>[]>;buildMatchedData: (args: {diff --git a/packages/twenty-apps/public/people-data-labs/src/types/bulk-enrich-input.ts b/packages/twenty-apps/public/people-data-labs/src/types/bulk-enrich-input.tsindex 4253ed2b1a2..740e659852c 100644--- a/packages/twenty-apps/public/people-data-labs/src/types/bulk-enrich-input.ts+++ b/packages/twenty-apps/public/people-data-labs/src/types/bulk-enrich-input.ts@@ -6,4 +6,5 @@ export type BulkEnrichInput = {records: RecordInput | RecordInput[];updateFields?: UpdateFieldsOption;minLikelihood?: number;+ weakIdentifierMinLikelihood?: number;};diff --git a/packages/twenty-apps/public/people-data-labs/src/types/min-likelihoods.ts b/packages/twenty-apps/public/people-data-labs/src/types/min-likelihoods.tsnew file mode 100644index 00000000000..9c02e580560--- /dev/null+++ b/packages/twenty-apps/public/people-data-labs/src/types/min-likelihoods.ts@@ -0,0 +1,4 @@+export type MinLikelihoods = {+ strongIdentifierMinLikelihood: number;+ weakIdentifierMinLikelihood: number;+};diff --git a/packages/twenty-apps/public/people-data-labs/src/types/single-enrich-input.ts b/packages/twenty-apps/public/people-data-labs/src/types/single-enrich-input.tsindex 0cac35b1bc8..74697cfac80 100644--- a/packages/twenty-apps/public/people-data-labs/src/types/single-enrich-input.ts+++ b/packages/twenty-apps/public/people-data-labs/src/types/single-enrich-input.ts@@ -4,4 +4,5 @@ export type SingleEnrichInput = {recordId?: string;updateFields?: UpdateFieldsOption;minLikelihood?: number;+ weakIdentifierMinLikelihood?: number;};