@twentyhq/people-data-labs 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/manifest.json +11504 -0
- package/package.json +1 -1
- package/src/front-components/enrich-companies-component-effect.mjs +73 -0
- package/src/front-components/enrich-companies-component-effect.mjs.map +7 -0
- package/src/front-components/enrich-people-component-effect.mjs +73 -0
- package/src/front-components/enrich-people-component-effect.mjs.map +7 -0
- package/src/logic-functions/enrich-companies.function.mjs +6134 -0
- package/src/logic-functions/enrich-companies.function.mjs.map +7 -0
- package/src/logic-functions/enrich-company.function.mjs +6219 -0
- package/src/logic-functions/enrich-company.function.mjs.map +7 -0
- package/src/logic-functions/enrich-people.function.mjs +6836 -0
- package/src/logic-functions/enrich-people.function.mjs.map +7 -0
- package/src/logic-functions/enrich-person.function.mjs +6922 -0
- package/src/logic-functions/enrich-person.function.mjs.map +7 -0
- package/src/logic-functions/post-install.function.mjs +48 -0
- package/src/logic-functions/post-install.function.mjs.map +7 -0
- package/.claude/settings.local.json +0 -7
- package/.nvmrc +0 -1
- package/.oxlintrc.json +0 -58
- package/.yarnrc.yml +0 -1
- package/README.md +0 -16
- package/src/__tests__/global-setup.ts +0 -87
- package/src/__tests__/people-data-labs.integration-test.ts +0 -25
- package/src/application-config.ts +0 -18
- package/src/command-menu-items/enrich-companies.ts +0 -14
- package/src/command-menu-items/enrich-people.ts +0 -14
- package/src/constants/__tests__/select-option-constants.spec.ts +0 -142
- package/src/constants/billing-margin-multiplier.ts +0 -1
- package/src/constants/company-match-cost-dollars.ts +0 -1
- package/src/constants/company-type-options.ts +0 -46
- package/src/constants/enrichment-status-options.ts +0 -19
- package/src/constants/enrichment-workflow-seeds.ts +0 -27
- package/src/constants/funding-stage-options.ts +0 -195
- package/src/constants/industry-options.ts +0 -1033
- package/src/constants/inferred-salary-options.ts +0 -81
- package/src/constants/job-role-options.ts +0 -172
- package/src/constants/job-title-class-options.ts +0 -39
- package/src/constants/job-title-sub-role-options.ts +0 -746
- package/src/constants/location-continent-options.ts +0 -53
- package/src/constants/metro-options.ts +0 -2692
- package/src/constants/mic-exchange-options.ts +0 -494
- package/src/constants/micro-credits-per-dollar.ts +0 -1
- package/src/constants/pdl-base-url.ts +0 -1
- package/src/constants/person-match-cost-dollars.ts +0 -1
- package/src/constants/seniority-options.ts +0 -74
- package/src/constants/sex-options.ts +0 -18
- package/src/constants/size-options.ts +0 -60
- package/src/constants/universal-identifiers.ts +0 -1516
- package/src/constants/update-fields-option-values.ts +0 -5
- package/src/constants/update-fields-options.ts +0 -7
- package/src/fields/company/pdl-affiliated-profiles.field.ts +0 -20
- package/src/fields/company/pdl-alternative-domains.field.ts +0 -20
- package/src/fields/company/pdl-alternative-names.field.ts +0 -20
- package/src/fields/company/pdl-company-type.field.ts +0 -28
- package/src/fields/company/pdl-employee-count-by-country.field.ts +0 -21
- package/src/fields/company/pdl-employee-count.field.ts +0 -19
- package/src/fields/company/pdl-enrichment-status.field.ts +0 -29
- package/src/fields/company/pdl-facebook-url.field.ts +0 -19
- package/src/fields/company/pdl-founded-year.field.ts +0 -19
- package/src/fields/company/pdl-funding-stages.field.ts +0 -28
- package/src/fields/company/pdl-headline.field.ts +0 -19
- package/src/fields/company/pdl-id.field.ts +0 -19
- package/src/fields/company/pdl-industry-detail.field.ts +0 -20
- package/src/fields/company/pdl-industry.field.ts +0 -28
- package/src/fields/company/pdl-last-enriched-at.field.ts +0 -20
- package/src/fields/company/pdl-last-funding-date.field.ts +0 -20
- package/src/fields/company/pdl-latest-funding-stage.field.ts +0 -29
- package/src/fields/company/pdl-legal-name.field.ts +0 -19
- package/src/fields/company/pdl-linkedin-id.field.ts +0 -19
- package/src/fields/company/pdl-location-continent.field.ts +0 -29
- package/src/fields/company/pdl-location-metro.field.ts +0 -28
- package/src/fields/company/pdl-mic-exchange.field.ts +0 -28
- package/src/fields/company/pdl-naics.field.ts +0 -19
- package/src/fields/company/pdl-number-funding-rounds.field.ts +0 -20
- package/src/fields/company/pdl-raw-payload.field.ts +0 -19
- package/src/fields/company/pdl-sic.field.ts +0 -19
- package/src/fields/company/pdl-size-range.field.ts +0 -28
- package/src/fields/company/pdl-summary.field.ts +0 -19
- package/src/fields/company/pdl-tags.field.ts +0 -19
- package/src/fields/company/pdl-ticker.field.ts +0 -19
- package/src/fields/company/pdl-total-funding.field.ts +0 -19
- package/src/fields/company/pdl-twitter-url.field.ts +0 -19
- package/src/fields/person/pdl-birth-date.field.ts +0 -19
- package/src/fields/person/pdl-birth-year.field.ts +0 -19
- package/src/fields/person/pdl-certifications.field.ts +0 -19
- package/src/fields/person/pdl-education.field.ts +0 -19
- package/src/fields/person/pdl-enrichment-status.field.ts +0 -29
- package/src/fields/person/pdl-experience.field.ts +0 -19
- package/src/fields/person/pdl-facebook-url.field.ts +0 -19
- package/src/fields/person/pdl-github-url.field.ts +0 -19
- package/src/fields/person/pdl-headline.field.ts +0 -19
- package/src/fields/person/pdl-id.field.ts +0 -19
- package/src/fields/person/pdl-industry.field.ts +0 -28
- package/src/fields/person/pdl-inferred-salary.field.ts +0 -28
- package/src/fields/person/pdl-interests.field.ts +0 -19
- package/src/fields/person/pdl-job-onet-code.field.ts +0 -19
- package/src/fields/person/pdl-job-role.field.ts +0 -28
- package/src/fields/person/pdl-job-start-date.field.ts +0 -19
- package/src/fields/person/pdl-job-summary.field.ts +0 -19
- package/src/fields/person/pdl-job-title-class.field.ts +0 -28
- package/src/fields/person/pdl-job-title-sub-role.field.ts +0 -29
- package/src/fields/person/pdl-languages.field.ts +0 -19
- package/src/fields/person/pdl-last-enriched-at.field.ts +0 -19
- package/src/fields/person/pdl-likelihood.field.ts +0 -19
- package/src/fields/person/pdl-linkedin-connections.field.ts +0 -20
- package/src/fields/person/pdl-linkedin-username.field.ts +0 -20
- package/src/fields/person/pdl-location-metro.field.ts +0 -28
- package/src/fields/person/pdl-location.field.ts +0 -19
- package/src/fields/person/pdl-name-aliases.field.ts +0 -19
- package/src/fields/person/pdl-profiles.field.ts +0 -19
- package/src/fields/person/pdl-raw-payload.field.ts +0 -19
- package/src/fields/person/pdl-seniority.field.ts +0 -28
- package/src/fields/person/pdl-sex.field.ts +0 -28
- package/src/fields/person/pdl-skills.field.ts +0 -19
- package/src/fields/person/pdl-summary.field.ts +0 -19
- package/src/fields/person/pdl-twitter-url.field.ts +0 -19
- package/src/fields/person/pdl-years-experience.field.ts +0 -21
- package/src/front-components/enrich-companies-component-effect.tsx +0 -21
- package/src/front-components/enrich-people-component-effect.tsx +0 -21
- package/src/front-components/utils/call-enrich-logic-function.utils.ts +0 -21
- package/src/logic-functions/__mocks__/company-node.mock.ts +0 -11
- package/src/logic-functions/__mocks__/create-core-api-client-mock.ts +0 -35
- package/src/logic-functions/__mocks__/pdl-company-data.mock.ts +0 -27
- package/src/logic-functions/__mocks__/pdl-person-data.mock.ts +0 -23
- package/src/logic-functions/__mocks__/person-node.mock.ts +0 -12
- package/src/logic-functions/enrich-companies.function.ts +0 -76
- package/src/logic-functions/enrich-company.function.ts +0 -73
- package/src/logic-functions/enrich-people.function.ts +0 -76
- package/src/logic-functions/enrich-person.function.ts +0 -73
- package/src/logic-functions/errors/__tests__/pdl-config-error.spec.ts +0 -16
- package/src/logic-functions/errors/__tests__/pdl-invalid-input-error.spec.ts +0 -16
- package/src/logic-functions/errors/__tests__/pdl-operation-error.spec.ts +0 -16
- package/src/logic-functions/errors/__tests__/pdl-record-not-found-error.spec.ts +0 -21
- package/src/logic-functions/errors/pdl-config-error.ts +0 -8
- package/src/logic-functions/errors/pdl-error-code.ts +0 -8
- package/src/logic-functions/errors/pdl-error.ts +0 -12
- package/src/logic-functions/errors/pdl-invalid-input-error.ts +0 -8
- package/src/logic-functions/errors/pdl-operation-error.ts +0 -8
- package/src/logic-functions/errors/pdl-record-not-found-error.ts +0 -22
- package/src/logic-functions/handlers/__tests__/enrich-companies.spec.ts +0 -159
- package/src/logic-functions/handlers/__tests__/enrich-company.spec.ts +0 -147
- package/src/logic-functions/handlers/__tests__/enrich-people.spec.ts +0 -313
- package/src/logic-functions/handlers/__tests__/enrich-person.spec.ts +0 -198
- package/src/logic-functions/handlers/__tests__/post-install.spec.ts +0 -153
- package/src/logic-functions/handlers/company-enrichment-adapter.ts +0 -42
- package/src/logic-functions/handlers/company-single-enrichment-adapter.ts +0 -15
- package/src/logic-functions/handlers/enrich-companies.ts +0 -15
- package/src/logic-functions/handlers/enrich-company.ts +0 -19
- package/src/logic-functions/handlers/enrich-people.ts +0 -15
- package/src/logic-functions/handlers/enrich-person.ts +0 -19
- package/src/logic-functions/handlers/person-enrichment-adapter.ts +0 -29
- package/src/logic-functions/handlers/person-single-enrichment-adapter.ts +0 -15
- package/src/logic-functions/handlers/post-install.ts +0 -69
- package/src/logic-functions/post-install.function.ts +0 -17
- package/src/logic-functions/utils/__tests__/aggregate-bulk-enrich-result.spec.ts +0 -52
- package/src/logic-functions/utils/__tests__/build-address.spec.ts +0 -30
- package/src/logic-functions/utils/__tests__/build-allowed-values.spec.ts +0 -16
- package/src/logic-functions/utils/__tests__/build-bulk-records-trigger.spec.ts +0 -26
- package/src/logic-functions/utils/__tests__/build-company-create-data.spec.ts +0 -37
- package/src/logic-functions/utils/__tests__/build-company-match-keys.spec.ts +0 -35
- package/src/logic-functions/utils/__tests__/build-company-matched-data.spec.ts +0 -56
- package/src/logic-functions/utils/__tests__/build-currency-from-usd.spec.ts +0 -17
- package/src/logic-functions/utils/__tests__/build-emails.spec.ts +0 -23
- package/src/logic-functions/utils/__tests__/build-error-result.spec.ts +0 -16
- package/src/logic-functions/utils/__tests__/build-full-name.spec.ts +0 -64
- package/src/logic-functions/utils/__tests__/build-links.spec.ts +0 -25
- package/src/logic-functions/utils/__tests__/build-logic-function-step.spec.ts +0 -33
- package/src/logic-functions/utils/__tests__/build-matched-result.spec.ts +0 -33
- package/src/logic-functions/utils/__tests__/build-not-found-result.spec.ts +0 -15
- package/src/logic-functions/utils/__tests__/build-person-matched-data.spec.ts +0 -117
- package/src/logic-functions/utils/__tests__/build-person-name-param.spec.ts +0 -17
- package/src/logic-functions/utils/__tests__/build-phones.spec.ts +0 -32
- package/src/logic-functions/utils/__tests__/build-skipped-result.spec.ts +0 -17
- package/src/logic-functions/utils/__tests__/capitalize-name.spec.ts +0 -26
- package/src/logic-functions/utils/__tests__/capitalize-name.test.ts +0 -17
- package/src/logic-functions/utils/__tests__/charge-matched-enrichments.spec.ts +0 -56
- package/src/logic-functions/utils/__tests__/chunk.spec.ts +0 -25
- package/src/logic-functions/utils/__tests__/enrich-companies.spec.ts +0 -26
- package/src/logic-functions/utils/__tests__/enrich-company.spec.ts +0 -54
- package/src/logic-functions/utils/__tests__/enrich-people.spec.ts +0 -32
- package/src/logic-functions/utils/__tests__/enrich-person.spec.ts +0 -62
- package/src/logic-functions/utils/__tests__/extract-company-match-params.spec.ts +0 -86
- package/src/logic-functions/utils/__tests__/extract-pdl-error-message.spec.ts +0 -17
- package/src/logic-functions/utils/__tests__/extract-person-match-params.spec.ts +0 -75
- package/src/logic-functions/utils/__tests__/extract-record-ids.spec.ts +0 -32
- package/src/logic-functions/utils/__tests__/find-company-id-by-filter.spec.ts +0 -42
- package/src/logic-functions/utils/__tests__/find-company-id.spec.ts +0 -118
- package/src/logic-functions/utils/__tests__/find-existing-workflow-id.spec.ts +0 -26
- package/src/logic-functions/utils/__tests__/find-or-create-current-company.spec.ts +0 -203
- package/src/logic-functions/utils/__tests__/get-pdl-api-key.spec.ts +0 -38
- package/src/logic-functions/utils/__tests__/is-empty-address.spec.ts +0 -20
- package/src/logic-functions/utils/__tests__/is-empty-emails.spec.ts +0 -14
- package/src/logic-functions/utils/__tests__/is-empty-full-name.spec.ts +0 -14
- package/src/logic-functions/utils/__tests__/is-empty-links.spec.ts +0 -14
- package/src/logic-functions/utils/__tests__/is-empty-phones.spec.ts +0 -14
- package/src/logic-functions/utils/__tests__/is-empty-text.spec.ts +0 -15
- package/src/logic-functions/utils/__tests__/map-company.spec.ts +0 -48
- package/src/logic-functions/utils/__tests__/map-person.spec.ts +0 -81
- package/src/logic-functions/utils/__tests__/normalize-domain.spec.ts +0 -19
- package/src/logic-functions/utils/__tests__/normalize-linkedin-url.spec.ts +0 -22
- package/src/logic-functions/utils/__tests__/now-iso.spec.ts +0 -9
- package/src/logic-functions/utils/__tests__/parse-geo.spec.ts +0 -21
- package/src/logic-functions/utils/__tests__/parse-partial-date.spec.ts +0 -29
- package/src/logic-functions/utils/__tests__/parse-pdl-item.spec.ts +0 -88
- package/src/logic-functions/utils/__tests__/pick-multi-select.spec.ts +0 -28
- package/src/logic-functions/utils/__tests__/pick-select.spec.ts +0 -38
- package/src/logic-functions/utils/__tests__/pick-writable-standard.spec.ts +0 -37
- package/src/logic-functions/utils/__tests__/post-pdl-enrich.spec.ts +0 -192
- package/src/logic-functions/utils/__tests__/post-pdl-single-enrich.spec.ts +0 -172
- package/src/logic-functions/utils/__tests__/read-companies.spec.ts +0 -39
- package/src/logic-functions/utils/__tests__/read-people.spec.ts +0 -40
- package/src/logic-functions/utils/__tests__/resolve-logic-function-id.spec.ts +0 -25
- package/src/logic-functions/utils/__tests__/resolve-update-fields-mode.spec.ts +0 -34
- package/src/logic-functions/utils/__tests__/run-batch-enrichment.spec.ts +0 -524
- package/src/logic-functions/utils/__tests__/salary-transform.spec.ts +0 -15
- package/src/logic-functions/utils/__tests__/seed-enrichment-workflow.spec.ts +0 -136
- package/src/logic-functions/utils/__tests__/size-transform.spec.ts +0 -18
- package/src/logic-functions/utils/__tests__/to-json-array.spec.ts +0 -16
- package/src/logic-functions/utils/__tests__/to-json-object.spec.ts +0 -18
- package/src/logic-functions/utils/__tests__/to-number.spec.ts +0 -17
- package/src/logic-functions/utils/__tests__/to-string-array.spec.ts +0 -17
- package/src/logic-functions/utils/__tests__/to-text.spec.ts +0 -20
- package/src/logic-functions/utils/__tests__/update-companies-status.spec.ts +0 -32
- package/src/logic-functions/utils/__tests__/update-company-record.spec.ts +0 -25
- package/src/logic-functions/utils/__tests__/update-people-status.spec.ts +0 -32
- package/src/logic-functions/utils/__tests__/update-person-record.spec.ts +0 -25
- package/src/logic-functions/utils/aggregate-bulk-enrich-result.ts +0 -21
- package/src/logic-functions/utils/build-address.ts +0 -40
- package/src/logic-functions/utils/build-allowed-values.ts +0 -5
- package/src/logic-functions/utils/build-bulk-records-trigger.ts +0 -25
- package/src/logic-functions/utils/build-company-create-data.ts +0 -35
- package/src/logic-functions/utils/build-company-match-keys.ts +0 -16
- package/src/logic-functions/utils/build-company-matched-data.ts +0 -56
- package/src/logic-functions/utils/build-currency-from-usd.ts +0 -16
- package/src/logic-functions/utils/build-emails.ts +0 -34
- package/src/logic-functions/utils/build-error-result.ts +0 -18
- package/src/logic-functions/utils/build-full-name.ts +0 -38
- package/src/logic-functions/utils/build-links.ts +0 -23
- package/src/logic-functions/utils/build-logic-function-step.ts +0 -30
- package/src/logic-functions/utils/build-matched-result.ts +0 -21
- package/src/logic-functions/utils/build-not-found-result.ts +0 -9
- package/src/logic-functions/utils/build-person-matched-data.ts +0 -78
- package/src/logic-functions/utils/build-person-name-param.ts +0 -19
- package/src/logic-functions/utils/build-phones.ts +0 -40
- package/src/logic-functions/utils/build-skipped-result.ts +0 -15
- package/src/logic-functions/utils/capitalize-name.ts +0 -8
- package/src/logic-functions/utils/charge-matched-enrichments.ts +0 -29
- package/src/logic-functions/utils/chunk.ts +0 -18
- package/src/logic-functions/utils/enrich-chunk.ts +0 -361
- package/src/logic-functions/utils/enrich-companies.ts +0 -21
- package/src/logic-functions/utils/enrich-company.ts +0 -23
- package/src/logic-functions/utils/enrich-people.ts +0 -22
- package/src/logic-functions/utils/enrich-person.ts +0 -24
- package/src/logic-functions/utils/extract-company-match-params.ts +0 -52
- package/src/logic-functions/utils/extract-pdl-error-message.ts +0 -47
- package/src/logic-functions/utils/extract-person-match-params.ts +0 -59
- package/src/logic-functions/utils/extract-record-ids.ts +0 -18
- package/src/logic-functions/utils/find-company-id-by-filter.ts +0 -28
- package/src/logic-functions/utils/find-company-id.ts +0 -59
- package/src/logic-functions/utils/find-existing-workflow-id.ts +0 -18
- package/src/logic-functions/utils/find-or-create-current-company.ts +0 -108
- package/src/logic-functions/utils/get-pdl-api-key.ts +0 -15
- package/src/logic-functions/utils/internal-field-names.ts +0 -6
- package/src/logic-functions/utils/is-empty-address.ts +0 -20
- package/src/logic-functions/utils/is-empty-emails.ts +0 -13
- package/src/logic-functions/utils/is-empty-full-name.ts +0 -13
- package/src/logic-functions/utils/is-empty-links.ts +0 -13
- package/src/logic-functions/utils/is-empty-phones.ts +0 -13
- package/src/logic-functions/utils/is-empty-text.ts +0 -4
- package/src/logic-functions/utils/map-company.ts +0 -115
- package/src/logic-functions/utils/map-person.ts +0 -136
- package/src/logic-functions/utils/normalize-domain.ts +0 -22
- package/src/logic-functions/utils/normalize-linkedin-url.ts +0 -23
- package/src/logic-functions/utils/now-iso.ts +0 -1
- package/src/logic-functions/utils/parse-geo.ts +0 -33
- package/src/logic-functions/utils/parse-partial-date.ts +0 -33
- package/src/logic-functions/utils/parse-pdl-item.ts +0 -82
- package/src/logic-functions/utils/pick-multi-select.ts +0 -32
- package/src/logic-functions/utils/pick-select.ts +0 -30
- package/src/logic-functions/utils/pick-writable-standard.ts +0 -27
- package/src/logic-functions/utils/post-pdl-enrich.ts +0 -89
- package/src/logic-functions/utils/post-pdl-single-enrich.ts +0 -59
- package/src/logic-functions/utils/read-companies.ts +0 -53
- package/src/logic-functions/utils/read-people.ts +0 -48
- package/src/logic-functions/utils/resolve-logic-function-id.ts +0 -11
- package/src/logic-functions/utils/resolve-min-likelihood.ts +0 -12
- package/src/logic-functions/utils/resolve-update-fields-mode.ts +0 -16
- package/src/logic-functions/utils/run-batch-enrichment.ts +0 -50
- package/src/logic-functions/utils/run-single-enrichment.ts +0 -44
- package/src/logic-functions/utils/salary-transform.ts +0 -18
- package/src/logic-functions/utils/seed-enrichment-workflow.ts +0 -131
- package/src/logic-functions/utils/size-transform.ts +0 -15
- package/src/logic-functions/utils/to-bulk-enrich-input.ts +0 -14
- package/src/logic-functions/utils/to-json-array.ts +0 -4
- package/src/logic-functions/utils/to-json-object.ts +0 -22
- package/src/logic-functions/utils/to-number.ts +0 -4
- package/src/logic-functions/utils/to-string-array.ts +0 -28
- package/src/logic-functions/utils/to-text.ts +0 -11
- package/src/logic-functions/utils/update-companies-status.ts +0 -18
- package/src/logic-functions/utils/update-company-record.ts +0 -15
- package/src/logic-functions/utils/update-people-status.ts +0 -18
- package/src/logic-functions/utils/update-person-record.ts +0 -15
- package/src/roles/default-function.role.ts +0 -41
- package/src/types/address-parts.ts +0 -9
- package/src/types/address-value.ts +0 -10
- package/src/types/batch-enrichment-adapter.ts +0 -43
- package/src/types/bulk-enrich-input.ts +0 -9
- package/src/types/bulk-enrich-result.ts +0 -11
- package/src/types/company-id-by-match-key-cache.ts +0 -1
- package/src/types/company-match-keys.ts +0 -6
- package/src/types/company-node.ts +0 -16
- package/src/types/currency-value.ts +0 -4
- package/src/types/emails-value.ts +0 -4
- package/src/types/enrich-result.ts +0 -11
- package/src/types/enrich-status.ts +0 -1
- package/src/types/enrichment-workflow-seed.ts +0 -9
- package/src/types/full-name-value.ts +0 -4
- package/src/types/links-value.ts +0 -5
- package/src/types/mapped-record.ts +0 -4
- package/src/types/pdl-company-data.ts +0 -50
- package/src/types/pdl-company-enrich-params.ts +0 -7
- package/src/types/pdl-enrich-result.ts +0 -4
- package/src/types/pdl-person-data.ts +0 -65
- package/src/types/pdl-person-enrich-params.ts +0 -8
- package/src/types/person-node.ts +0 -11
- package/src/types/phones-value.ts +0 -12
- package/src/types/post-install-result.ts +0 -5
- package/src/types/seed-enrichment-workflow-result.ts +0 -7
- package/src/types/select-option-meta.ts +0 -9
- package/src/types/single-enrich-input.ts +0 -7
- package/src/types/tag-color.ts +0 -26
- package/src/types/update-fields-option.ts +0 -4
- package/src/types/workflow-bulk-records-trigger.ts +0 -15
- package/src/types/workflow-logic-function-step.ts +0 -18
- package/src/utils/__tests__/build-select-options.spec.ts +0 -20
- package/src/utils/__tests__/is-defined.spec.ts +0 -16
- package/src/utils/__tests__/is-unique-violation-error.spec.ts +0 -71
- package/src/utils/__tests__/normalize-enum-value.spec.ts +0 -28
- package/src/utils/__tests__/prune-undefined.spec.ts +0 -22
- package/src/utils/__tests__/strip-separators.spec.ts +0 -13
- package/src/utils/__tests__/to-error-message.spec.ts +0 -13
- package/src/utils/build-select-options.ts +0 -16
- package/src/utils/is-defined.ts +0 -5
- package/src/utils/is-unique-violation-error.ts +0 -74
- package/src/utils/normalize-enum-value.ts +0 -15
- package/src/utils/prune-undefined.ts +0 -15
- package/src/utils/strip-separators.ts +0 -4
- package/src/utils/to-error-message.ts +0 -2
- package/src/views/enriched-companies.view.ts +0 -69
- package/src/views/enriched-people.view.ts +0 -74
- package/tsconfig.json +0 -42
- package/tsconfig.spec.json +0 -9
- package/vitest.config.ts +0 -31
- package/vitest.unit.config.ts +0 -14
|
@@ -1,524 +0,0 @@
|
|
|
1
|
-
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
-
import { type CoreApiClient } from 'twenty-client-sdk/core';
|
|
3
|
-
import { chargeCredits } from 'twenty-sdk/billing';
|
|
4
|
-
|
|
5
|
-
import { UPDATE_FIELDS_OPTIONS } from 'src/constants/update-fields-options';
|
|
6
|
-
import { runBatchEnrichment } from 'src/logic-functions/utils/run-batch-enrichment';
|
|
7
|
-
import { type BatchEnrichmentAdapter } from 'src/types/batch-enrichment-adapter';
|
|
8
|
-
import { type PdlEnrichResult } from 'src/types/pdl-enrich-result';
|
|
9
|
-
|
|
10
|
-
vi.mock('twenty-sdk/billing', () => ({
|
|
11
|
-
chargeCredits: vi.fn(async () => undefined),
|
|
12
|
-
}));
|
|
13
|
-
|
|
14
|
-
const FAKE_COST_PER_MATCH_DOLLARS = 0.1;
|
|
15
|
-
const FAKE_CREDITS_PER_MATCH_MICRO = 120_000;
|
|
16
|
-
|
|
17
|
-
type FakeNode = {
|
|
18
|
-
id: string;
|
|
19
|
-
hasIdentifier: boolean;
|
|
20
|
-
};
|
|
21
|
-
type FakeData = { id: string };
|
|
22
|
-
type FakeParams = { id: string };
|
|
23
|
-
|
|
24
|
-
type BuildMatchedDataArgs = Parameters<
|
|
25
|
-
BatchEnrichmentAdapter<FakeNode, FakeData, FakeParams>['buildMatchedData']
|
|
26
|
-
>[0];
|
|
27
|
-
|
|
28
|
-
type RecordConfig = {
|
|
29
|
-
id: string;
|
|
30
|
-
exists?: boolean;
|
|
31
|
-
hasIdentifier?: boolean;
|
|
32
|
-
outcome?: PdlEnrichResult<FakeData>;
|
|
33
|
-
updateFails?: boolean;
|
|
34
|
-
buildFails?: boolean;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const CLIENT = {} as CoreApiClient;
|
|
38
|
-
|
|
39
|
-
const buildHarness = (configs: RecordConfig[]) => {
|
|
40
|
-
const byId = new Map(configs.map((config) => [config.id, config]));
|
|
41
|
-
|
|
42
|
-
const readRecords = vi.fn(
|
|
43
|
-
async ({
|
|
44
|
-
recordIds,
|
|
45
|
-
}: {
|
|
46
|
-
client: CoreApiClient;
|
|
47
|
-
recordIds: string[];
|
|
48
|
-
}): Promise<FakeNode[]> =>
|
|
49
|
-
recordIds
|
|
50
|
-
.map((id) => byId.get(id))
|
|
51
|
-
.filter(
|
|
52
|
-
(config): config is RecordConfig =>
|
|
53
|
-
isPresent(config) && config.exists !== false,
|
|
54
|
-
)
|
|
55
|
-
.map((config) => ({
|
|
56
|
-
id: config.id,
|
|
57
|
-
hasIdentifier: config.hasIdentifier !== false,
|
|
58
|
-
})),
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
const enrichBatch = vi.fn(
|
|
62
|
-
async (params: FakeParams[]): Promise<PdlEnrichResult<FakeData>[]> =>
|
|
63
|
-
params.map(
|
|
64
|
-
(param) =>
|
|
65
|
-
byId.get(param.id)?.outcome ?? {
|
|
66
|
-
outcome: 'matched',
|
|
67
|
-
httpStatus: 200,
|
|
68
|
-
data: { id: param.id },
|
|
69
|
-
},
|
|
70
|
-
),
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
const updateOne = vi.fn(
|
|
74
|
-
async ({
|
|
75
|
-
recordId,
|
|
76
|
-
}: {
|
|
77
|
-
client: CoreApiClient;
|
|
78
|
-
recordId: string;
|
|
79
|
-
data: Record<string, unknown>;
|
|
80
|
-
}) => {
|
|
81
|
-
if (byId.get(recordId)?.updateFails === true) {
|
|
82
|
-
throw new Error('update failed');
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
const updateManyStatus = vi.fn(async () => undefined);
|
|
88
|
-
|
|
89
|
-
const buildMatchedData = vi.fn(
|
|
90
|
-
async ({
|
|
91
|
-
node,
|
|
92
|
-
}: BuildMatchedDataArgs): Promise<{
|
|
93
|
-
mappedData: Record<string, unknown>;
|
|
94
|
-
persistData: Record<string, unknown>;
|
|
95
|
-
}> => {
|
|
96
|
-
if (byId.get(node.id)?.buildFails === true) {
|
|
97
|
-
throw new Error('build failed');
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return { mappedData: { mapped: node.id }, persistData: { value: node.id } };
|
|
101
|
-
},
|
|
102
|
-
);
|
|
103
|
-
|
|
104
|
-
const adapter: BatchEnrichmentAdapter<FakeNode, FakeData, FakeParams> = {
|
|
105
|
-
objectNameSingular: 'Test',
|
|
106
|
-
noIdentifierMessage: 'no identifier',
|
|
107
|
-
costPerMatchDollars: FAKE_COST_PER_MATCH_DOLLARS,
|
|
108
|
-
readRecords,
|
|
109
|
-
getNodeId: (node) => node.id,
|
|
110
|
-
extractParams: ({ node }) =>
|
|
111
|
-
node.hasIdentifier ? { id: node.id } : undefined,
|
|
112
|
-
enrichBatch,
|
|
113
|
-
buildMatchedData,
|
|
114
|
-
updateOne,
|
|
115
|
-
updateManyStatus,
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
return {
|
|
119
|
-
adapter,
|
|
120
|
-
readRecords,
|
|
121
|
-
enrichBatch,
|
|
122
|
-
updateOne,
|
|
123
|
-
updateManyStatus,
|
|
124
|
-
buildMatchedData,
|
|
125
|
-
};
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
const isPresent = <TValue>(value: TValue | undefined): value is TValue =>
|
|
129
|
-
value !== undefined;
|
|
130
|
-
|
|
131
|
-
const records = (...ids: string[]) => ids.map((id) => ({ id }));
|
|
132
|
-
|
|
133
|
-
describe('runBatchEnrichment', () => {
|
|
134
|
-
beforeEach(() => {
|
|
135
|
-
vi.mocked(chargeCredits).mockClear();
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it('reads every id in one call and enriches the set in one batch', async () => {
|
|
139
|
-
const harness = buildHarness([{ id: 'a' }, { id: 'b' }]);
|
|
140
|
-
|
|
141
|
-
const result = await runBatchEnrichment({
|
|
142
|
-
client: CLIENT,
|
|
143
|
-
input: { records: records('a', 'b') },
|
|
144
|
-
adapter: harness.adapter,
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
expect(harness.readRecords).toHaveBeenCalledTimes(1);
|
|
148
|
-
expect(harness.readRecords).toHaveBeenCalledWith({
|
|
149
|
-
client: CLIENT,
|
|
150
|
-
recordIds: ['a', 'b'],
|
|
151
|
-
});
|
|
152
|
-
expect(harness.enrichBatch).toHaveBeenCalledTimes(1);
|
|
153
|
-
expect(harness.enrichBatch).toHaveBeenCalledWith([{ id: 'a' }, { id: 'b' }]);
|
|
154
|
-
expect(harness.updateOne).toHaveBeenCalledTimes(2);
|
|
155
|
-
expect(result).toMatchObject({
|
|
156
|
-
total: 2,
|
|
157
|
-
matched: 2,
|
|
158
|
-
errored: 0,
|
|
159
|
-
success: true,
|
|
160
|
-
});
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it('writes NOT_FOUND and ERROR statuses with batched status updates', async () => {
|
|
164
|
-
const harness = buildHarness([
|
|
165
|
-
{ id: 'a', outcome: { outcome: 'not_found', httpStatus: 404 } },
|
|
166
|
-
{ id: 'b', outcome: { outcome: 'not_found', httpStatus: 404 } },
|
|
167
|
-
{ id: 'c', outcome: { outcome: 'error', httpStatus: 500, message: 'boom' } },
|
|
168
|
-
]);
|
|
169
|
-
|
|
170
|
-
const result = await runBatchEnrichment({
|
|
171
|
-
client: CLIENT,
|
|
172
|
-
input: { records: records('a', 'b', 'c') },
|
|
173
|
-
adapter: harness.adapter,
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
expect(harness.updateOne).not.toHaveBeenCalled();
|
|
177
|
-
expect(harness.updateManyStatus).toHaveBeenCalledWith({
|
|
178
|
-
client: CLIENT,
|
|
179
|
-
recordIds: ['c'],
|
|
180
|
-
data: {
|
|
181
|
-
pdlEnrichmentStatus: 'ERROR',
|
|
182
|
-
pdlLastEnrichedAt: expect.any(String),
|
|
183
|
-
},
|
|
184
|
-
});
|
|
185
|
-
expect(harness.updateManyStatus).toHaveBeenCalledWith({
|
|
186
|
-
client: CLIENT,
|
|
187
|
-
recordIds: ['a', 'b'],
|
|
188
|
-
data: {
|
|
189
|
-
pdlEnrichmentStatus: 'NOT_FOUND',
|
|
190
|
-
pdlLastEnrichedAt: expect.any(String),
|
|
191
|
-
},
|
|
192
|
-
});
|
|
193
|
-
expect(result).toMatchObject({ notFound: 2, errored: 1, matched: 0 });
|
|
194
|
-
expect(result.results.find((entry) => entry.recordId === 'c')?.error).toBe(
|
|
195
|
-
'boom',
|
|
196
|
-
);
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
it('skips no-identifier records before the PDL call', async () => {
|
|
200
|
-
const harness = buildHarness([{ id: 'a', hasIdentifier: false }, { id: 'b' }]);
|
|
201
|
-
|
|
202
|
-
const result = await runBatchEnrichment({
|
|
203
|
-
client: CLIENT,
|
|
204
|
-
input: { records: records('a', 'b') },
|
|
205
|
-
adapter: harness.adapter,
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
expect(harness.enrichBatch).toHaveBeenCalledWith([{ id: 'b' }]);
|
|
209
|
-
expect(result).toMatchObject({ skipped: 1, matched: 1 });
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
it('maps "Yes and overwrite" to overrideExistingValues and persisting', async () => {
|
|
213
|
-
const harness = buildHarness([{ id: 'a' }]);
|
|
214
|
-
|
|
215
|
-
await runBatchEnrichment({
|
|
216
|
-
client: CLIENT,
|
|
217
|
-
input: { records: records('a'), updateFields: UPDATE_FIELDS_OPTIONS.overwrite },
|
|
218
|
-
adapter: harness.adapter,
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
expect(harness.buildMatchedData).toHaveBeenCalledWith(
|
|
222
|
-
expect.objectContaining({ overrideExistingValues: true, shouldPersist: true }),
|
|
223
|
-
);
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
it('defaults to fill-empty persisting when updateFields is omitted', async () => {
|
|
227
|
-
const harness = buildHarness([{ id: 'a' }]);
|
|
228
|
-
|
|
229
|
-
await runBatchEnrichment({
|
|
230
|
-
client: CLIENT,
|
|
231
|
-
input: { records: records('a') },
|
|
232
|
-
adapter: harness.adapter,
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
expect(harness.buildMatchedData).toHaveBeenCalledWith(
|
|
236
|
-
expect.objectContaining({
|
|
237
|
-
overrideExistingValues: false,
|
|
238
|
-
shouldPersist: true,
|
|
239
|
-
}),
|
|
240
|
-
);
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
it('returns mapped data without writing anything when updateFields is "No"', async () => {
|
|
244
|
-
const harness = buildHarness([
|
|
245
|
-
{ id: 'a' },
|
|
246
|
-
{ id: 'b', outcome: { outcome: 'not_found', httpStatus: 404 } },
|
|
247
|
-
]);
|
|
248
|
-
|
|
249
|
-
const result = await runBatchEnrichment({
|
|
250
|
-
client: CLIENT,
|
|
251
|
-
input: { records: records('a', 'b'), updateFields: UPDATE_FIELDS_OPTIONS.no },
|
|
252
|
-
adapter: harness.adapter,
|
|
253
|
-
});
|
|
254
|
-
|
|
255
|
-
expect(harness.buildMatchedData).toHaveBeenCalledWith(
|
|
256
|
-
expect.objectContaining({ shouldPersist: false }),
|
|
257
|
-
);
|
|
258
|
-
expect(harness.updateOne).not.toHaveBeenCalled();
|
|
259
|
-
expect(harness.updateManyStatus).not.toHaveBeenCalled();
|
|
260
|
-
|
|
261
|
-
const matched = result.results.find((entry) => entry.recordId === 'a');
|
|
262
|
-
expect(matched?.status).toBe('MATCHED');
|
|
263
|
-
expect(matched?.updatedFields).toEqual([]);
|
|
264
|
-
expect(matched?.data).toEqual({ mapped: 'a' });
|
|
265
|
-
expect(result).toMatchObject({ matched: 1, notFound: 1 });
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
it('marks missing records as ERROR without enriching them', async () => {
|
|
269
|
-
const harness = buildHarness([{ id: 'a' }, { id: 'b', exists: false }]);
|
|
270
|
-
|
|
271
|
-
const result = await runBatchEnrichment({
|
|
272
|
-
client: CLIENT,
|
|
273
|
-
input: { records: records('a', 'b') },
|
|
274
|
-
adapter: harness.adapter,
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
expect(harness.enrichBatch).toHaveBeenCalledWith([{ id: 'a' }]);
|
|
278
|
-
expect(result.results.find((entry) => entry.recordId === 'b')).toMatchObject({
|
|
279
|
-
status: 'ERROR',
|
|
280
|
-
error: 'Test b not found',
|
|
281
|
-
});
|
|
282
|
-
expect(result).toMatchObject({ matched: 1, errored: 1 });
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
it('isolates a per-record matched update failure', async () => {
|
|
286
|
-
const harness = buildHarness([{ id: 'a' }, { id: 'b', updateFails: true }]);
|
|
287
|
-
|
|
288
|
-
const result = await runBatchEnrichment({
|
|
289
|
-
client: CLIENT,
|
|
290
|
-
input: { records: records('a', 'b') },
|
|
291
|
-
adapter: harness.adapter,
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
expect(
|
|
295
|
-
result.results.find((entry) => entry.recordId === 'a')?.status,
|
|
296
|
-
).toBe('MATCHED');
|
|
297
|
-
expect(result.results.find((entry) => entry.recordId === 'b')).toMatchObject({
|
|
298
|
-
status: 'ERROR',
|
|
299
|
-
error: 'update failed',
|
|
300
|
-
});
|
|
301
|
-
expect(harness.updateManyStatus).toHaveBeenCalledWith({
|
|
302
|
-
client: CLIENT,
|
|
303
|
-
recordIds: ['b'],
|
|
304
|
-
data: {
|
|
305
|
-
pdlEnrichmentStatus: 'ERROR',
|
|
306
|
-
pdlLastEnrichedAt: expect.any(String),
|
|
307
|
-
},
|
|
308
|
-
});
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
it('marks all attempted records as ERROR and writes the status when the batch PDL call rejects', async () => {
|
|
312
|
-
const harness = buildHarness([{ id: 'a' }, { id: 'b' }]);
|
|
313
|
-
harness.enrichBatch.mockRejectedValueOnce(new Error('pdl down'));
|
|
314
|
-
|
|
315
|
-
const result = await runBatchEnrichment({
|
|
316
|
-
client: CLIENT,
|
|
317
|
-
input: { records: records('a', 'b') },
|
|
318
|
-
adapter: harness.adapter,
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
expect(result).toMatchObject({ errored: 2, matched: 0 });
|
|
322
|
-
expect(result.results[0].error).toBe('pdl down');
|
|
323
|
-
expect(harness.updateOne).not.toHaveBeenCalled();
|
|
324
|
-
expect(harness.updateManyStatus).toHaveBeenCalledWith({
|
|
325
|
-
client: CLIENT,
|
|
326
|
-
recordIds: ['a', 'b'],
|
|
327
|
-
data: {
|
|
328
|
-
pdlEnrichmentStatus: 'ERROR',
|
|
329
|
-
pdlLastEnrichedAt: expect.any(String),
|
|
330
|
-
},
|
|
331
|
-
});
|
|
332
|
-
});
|
|
333
|
-
|
|
334
|
-
it('isolates a record whose matched-data build throws', async () => {
|
|
335
|
-
const harness = buildHarness([{ id: 'a' }, { id: 'b', buildFails: true }]);
|
|
336
|
-
|
|
337
|
-
const result = await runBatchEnrichment({
|
|
338
|
-
client: CLIENT,
|
|
339
|
-
input: { records: records('a', 'b') },
|
|
340
|
-
adapter: harness.adapter,
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
expect(
|
|
344
|
-
result.results.find((entry) => entry.recordId === 'a')?.status,
|
|
345
|
-
).toBe('MATCHED');
|
|
346
|
-
expect(result.results.find((entry) => entry.recordId === 'b')).toMatchObject({
|
|
347
|
-
status: 'ERROR',
|
|
348
|
-
error: 'build failed',
|
|
349
|
-
});
|
|
350
|
-
expect(harness.updateOne).toHaveBeenCalledTimes(1);
|
|
351
|
-
expect(harness.updateManyStatus).toHaveBeenCalledWith({
|
|
352
|
-
client: CLIENT,
|
|
353
|
-
recordIds: ['b'],
|
|
354
|
-
data: {
|
|
355
|
-
pdlEnrichmentStatus: 'ERROR',
|
|
356
|
-
pdlLastEnrichedAt: expect.any(String),
|
|
357
|
-
},
|
|
358
|
-
});
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
it('produces exactly one result per record with counts summing to the total', async () => {
|
|
362
|
-
const harness = buildHarness([
|
|
363
|
-
{ id: 'matched' },
|
|
364
|
-
{ id: 'notfound', outcome: { outcome: 'not_found', httpStatus: 404 } },
|
|
365
|
-
{ id: 'errored', outcome: { outcome: 'error', httpStatus: 500, message: 'x' } },
|
|
366
|
-
{ id: 'skipped', hasIdentifier: false },
|
|
367
|
-
{ id: 'missing', exists: false },
|
|
368
|
-
]);
|
|
369
|
-
|
|
370
|
-
const result = await runBatchEnrichment({
|
|
371
|
-
client: CLIENT,
|
|
372
|
-
input: {
|
|
373
|
-
records: records('matched', 'notfound', 'errored', 'skipped', 'missing'),
|
|
374
|
-
},
|
|
375
|
-
adapter: harness.adapter,
|
|
376
|
-
});
|
|
377
|
-
|
|
378
|
-
const recordIds = result.results.map((entry) => entry.recordId);
|
|
379
|
-
expect(new Set(recordIds).size).toBe(recordIds.length);
|
|
380
|
-
expect(result.results).toHaveLength(result.total);
|
|
381
|
-
expect(
|
|
382
|
-
result.matched + result.notFound + result.skipped + result.errored,
|
|
383
|
-
).toBe(result.total);
|
|
384
|
-
expect(result).toMatchObject({
|
|
385
|
-
total: 5,
|
|
386
|
-
matched: 1,
|
|
387
|
-
notFound: 1,
|
|
388
|
-
errored: 2,
|
|
389
|
-
skipped: 1,
|
|
390
|
-
success: false,
|
|
391
|
-
});
|
|
392
|
-
});
|
|
393
|
-
|
|
394
|
-
it('deduplicates record ids', async () => {
|
|
395
|
-
const harness = buildHarness([{ id: 'a' }]);
|
|
396
|
-
|
|
397
|
-
const result = await runBatchEnrichment({
|
|
398
|
-
client: CLIENT,
|
|
399
|
-
input: { records: records('a', 'a') },
|
|
400
|
-
adapter: harness.adapter,
|
|
401
|
-
});
|
|
402
|
-
|
|
403
|
-
expect(harness.enrichBatch).toHaveBeenCalledWith([{ id: 'a' }]);
|
|
404
|
-
expect(result.total).toBe(1);
|
|
405
|
-
});
|
|
406
|
-
|
|
407
|
-
it('chunks large id sets into separate read and PDL calls', async () => {
|
|
408
|
-
const ids = Array.from({ length: 150 }, (_unused, index) => `r${index}`);
|
|
409
|
-
const harness = buildHarness(ids.map((id) => ({ id })));
|
|
410
|
-
|
|
411
|
-
const result = await runBatchEnrichment({
|
|
412
|
-
client: CLIENT,
|
|
413
|
-
input: { records: ids.map((id) => ({ id })) },
|
|
414
|
-
adapter: harness.adapter,
|
|
415
|
-
});
|
|
416
|
-
|
|
417
|
-
expect(harness.readRecords).toHaveBeenCalledTimes(2);
|
|
418
|
-
expect(harness.enrichBatch).toHaveBeenCalledTimes(2);
|
|
419
|
-
expect(result.matched).toBe(150);
|
|
420
|
-
});
|
|
421
|
-
|
|
422
|
-
it('bills only matched outcomes after the PDL call', async () => {
|
|
423
|
-
const harness = buildHarness([
|
|
424
|
-
{ id: 'a' },
|
|
425
|
-
{ id: 'b' },
|
|
426
|
-
{ id: 'c', outcome: { outcome: 'not_found', httpStatus: 404 } },
|
|
427
|
-
{ id: 'd', outcome: { outcome: 'error', httpStatus: 500, message: 'x' } },
|
|
428
|
-
{ id: 'e', hasIdentifier: false },
|
|
429
|
-
]);
|
|
430
|
-
|
|
431
|
-
await runBatchEnrichment({
|
|
432
|
-
client: CLIENT,
|
|
433
|
-
input: { records: records('a', 'b', 'c', 'd', 'e') },
|
|
434
|
-
adapter: harness.adapter,
|
|
435
|
-
});
|
|
436
|
-
|
|
437
|
-
expect(chargeCredits).toHaveBeenCalledExactlyOnceWith({
|
|
438
|
-
creditsUsedMicro: 2 * FAKE_CREDITS_PER_MATCH_MICRO,
|
|
439
|
-
operationType: 'CODE_EXECUTION',
|
|
440
|
-
quantity: 2,
|
|
441
|
-
resourceContext: 'pdl/test',
|
|
442
|
-
});
|
|
443
|
-
});
|
|
444
|
-
|
|
445
|
-
it('does not bill when no record matches', async () => {
|
|
446
|
-
const harness = buildHarness([
|
|
447
|
-
{ id: 'a', outcome: { outcome: 'not_found', httpStatus: 404 } },
|
|
448
|
-
{ id: 'b', hasIdentifier: false },
|
|
449
|
-
]);
|
|
450
|
-
|
|
451
|
-
await runBatchEnrichment({
|
|
452
|
-
client: CLIENT,
|
|
453
|
-
input: { records: records('a', 'b') },
|
|
454
|
-
adapter: harness.adapter,
|
|
455
|
-
});
|
|
456
|
-
|
|
457
|
-
expect(chargeCredits).not.toHaveBeenCalled();
|
|
458
|
-
});
|
|
459
|
-
|
|
460
|
-
it('still bills a match whose record write fails', async () => {
|
|
461
|
-
const harness = buildHarness([{ id: 'a', updateFails: true }]);
|
|
462
|
-
|
|
463
|
-
await runBatchEnrichment({
|
|
464
|
-
client: CLIENT,
|
|
465
|
-
input: { records: records('a') },
|
|
466
|
-
adapter: harness.adapter,
|
|
467
|
-
});
|
|
468
|
-
|
|
469
|
-
expect(chargeCredits).toHaveBeenCalledExactlyOnceWith(
|
|
470
|
-
expect.objectContaining({
|
|
471
|
-
creditsUsedMicro: FAKE_CREDITS_PER_MATCH_MICRO,
|
|
472
|
-
quantity: 1,
|
|
473
|
-
}),
|
|
474
|
-
);
|
|
475
|
-
});
|
|
476
|
-
|
|
477
|
-
it('bills each chunk separately', async () => {
|
|
478
|
-
const ids = Array.from({ length: 150 }, (_unused, index) => `r${index}`);
|
|
479
|
-
const harness = buildHarness(ids.map((id) => ({ id })));
|
|
480
|
-
|
|
481
|
-
await runBatchEnrichment({
|
|
482
|
-
client: CLIENT,
|
|
483
|
-
input: { records: ids.map((id) => ({ id })) },
|
|
484
|
-
adapter: harness.adapter,
|
|
485
|
-
});
|
|
486
|
-
|
|
487
|
-
expect(chargeCredits).toHaveBeenCalledTimes(2);
|
|
488
|
-
expect(chargeCredits).toHaveBeenNthCalledWith(
|
|
489
|
-
1,
|
|
490
|
-
expect.objectContaining({
|
|
491
|
-
creditsUsedMicro: 100 * FAKE_CREDITS_PER_MATCH_MICRO,
|
|
492
|
-
quantity: 100,
|
|
493
|
-
}),
|
|
494
|
-
);
|
|
495
|
-
expect(chargeCredits).toHaveBeenNthCalledWith(
|
|
496
|
-
2,
|
|
497
|
-
expect.objectContaining({
|
|
498
|
-
creditsUsedMicro: 50 * FAKE_CREDITS_PER_MATCH_MICRO,
|
|
499
|
-
quantity: 50,
|
|
500
|
-
}),
|
|
501
|
-
);
|
|
502
|
-
});
|
|
503
|
-
|
|
504
|
-
it('returns an empty summary when there are no records', async () => {
|
|
505
|
-
const harness = buildHarness([]);
|
|
506
|
-
|
|
507
|
-
const result = await runBatchEnrichment({
|
|
508
|
-
client: CLIENT,
|
|
509
|
-
input: { records: [] },
|
|
510
|
-
adapter: harness.adapter,
|
|
511
|
-
});
|
|
512
|
-
|
|
513
|
-
expect(harness.readRecords).not.toHaveBeenCalled();
|
|
514
|
-
expect(result).toEqual({
|
|
515
|
-
success: true,
|
|
516
|
-
total: 0,
|
|
517
|
-
matched: 0,
|
|
518
|
-
notFound: 0,
|
|
519
|
-
skipped: 0,
|
|
520
|
-
errored: 0,
|
|
521
|
-
results: [],
|
|
522
|
-
});
|
|
523
|
-
});
|
|
524
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import { salaryTransform } from 'src/logic-functions/utils/salary-transform';
|
|
4
|
-
|
|
5
|
-
describe('salaryTransform', () => {
|
|
6
|
-
it('maps PDL salary ranges to option values', () => {
|
|
7
|
-
expect(salaryTransform('<20,000')).toBe('UNDER_20000');
|
|
8
|
-
expect(salaryTransform('45,000-55,000')).toBe('FROM_45000_TO_55000');
|
|
9
|
-
expect(salaryTransform('>250,000')).toBe('OVER_250000');
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('returns undefined for an unknown range', () => {
|
|
13
|
-
expect(salaryTransform('weird')).toBeUndefined();
|
|
14
|
-
});
|
|
15
|
-
});
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import { createCoreApiClientMock } from 'src/logic-functions/__mocks__/create-core-api-client-mock';
|
|
4
|
-
import { seedEnrichmentWorkflow } from 'src/logic-functions/utils/seed-enrichment-workflow';
|
|
5
|
-
import { type EnrichmentWorkflowSeed } from 'src/types/enrichment-workflow-seed';
|
|
6
|
-
|
|
7
|
-
const SEED: EnrichmentWorkflowSeed = {
|
|
8
|
-
objectNameSingular: 'company',
|
|
9
|
-
workflowName: 'Enrich companies with People Data Labs',
|
|
10
|
-
triggerName: 'When companies are selected',
|
|
11
|
-
icon: 'IconSparkles',
|
|
12
|
-
stepName: 'Enrich with People Data Labs',
|
|
13
|
-
logicFunctionUniversalIdentifier: 'lf-universal-id',
|
|
14
|
-
logicFunctionInput: { records: '{{trigger.companies}}' },
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
type AnyRequest = Record<string, any>;
|
|
18
|
-
|
|
19
|
-
describe('seedEnrichmentWorkflow', () => {
|
|
20
|
-
it('creates, configures and activates a new workflow', async () => {
|
|
21
|
-
const mutations: AnyRequest[] = [];
|
|
22
|
-
|
|
23
|
-
const client = createCoreApiClientMock({
|
|
24
|
-
queryResult: (request: unknown) => {
|
|
25
|
-
const req = request as AnyRequest;
|
|
26
|
-
if ('workflows' in req) {
|
|
27
|
-
return { workflows: { edges: [] } };
|
|
28
|
-
}
|
|
29
|
-
if ('workflowVersions' in req) {
|
|
30
|
-
return {
|
|
31
|
-
workflowVersions: {
|
|
32
|
-
edges: [{ node: { id: 'version-1', status: 'DRAFT' } }],
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
return {};
|
|
37
|
-
},
|
|
38
|
-
mutationResult: (request: unknown) =>
|
|
39
|
-
'createWorkflow' in (request as AnyRequest)
|
|
40
|
-
? { createWorkflow: { id: 'workflow-1' } }
|
|
41
|
-
: {},
|
|
42
|
-
onMutation: (request) => mutations.push(request as AnyRequest),
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
const result = await seedEnrichmentWorkflow({
|
|
46
|
-
client,
|
|
47
|
-
logicFunctionId: 'logic-function-1',
|
|
48
|
-
seed: SEED,
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
expect(result).toEqual({
|
|
52
|
-
objectNameSingular: 'company',
|
|
53
|
-
workflowName: SEED.workflowName,
|
|
54
|
-
status: 'created',
|
|
55
|
-
workflowId: 'workflow-1',
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
const createRequest = mutations.find(
|
|
59
|
-
(request) => 'createWorkflow' in request,
|
|
60
|
-
);
|
|
61
|
-
expect(createRequest?.createWorkflow.__args.data).toEqual({
|
|
62
|
-
name: SEED.workflowName,
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
const updateRequest = mutations.find(
|
|
66
|
-
(request) => 'updateWorkflowVersion' in request,
|
|
67
|
-
);
|
|
68
|
-
const { id, data } = updateRequest?.updateWorkflowVersion.__args ?? {};
|
|
69
|
-
expect(id).toBe('version-1');
|
|
70
|
-
|
|
71
|
-
expect(data.trigger.type).toBe('MANUAL');
|
|
72
|
-
expect(data.trigger.settings.availability).toEqual({
|
|
73
|
-
type: 'BULK_RECORDS',
|
|
74
|
-
objectNameSingular: 'company',
|
|
75
|
-
});
|
|
76
|
-
expect(data.trigger.settings.objectType).toBe('company');
|
|
77
|
-
expect(data.trigger.nextStepIds).toEqual([]);
|
|
78
|
-
expect(data.steps).toBeUndefined();
|
|
79
|
-
|
|
80
|
-
const createStepRequest = mutations.find(
|
|
81
|
-
(request) => 'createWorkflowVersionStep' in request,
|
|
82
|
-
);
|
|
83
|
-
const createStepInput =
|
|
84
|
-
createStepRequest?.createWorkflowVersionStep.__args.input;
|
|
85
|
-
expect(createStepInput.workflowVersionId).toBe('version-1');
|
|
86
|
-
expect(createStepInput.stepType).toBe('LOGIC_FUNCTION');
|
|
87
|
-
expect(createStepInput.parentStepId).toBe('trigger');
|
|
88
|
-
expect(createStepInput.defaultSettings.input.logicFunctionId).toBe(
|
|
89
|
-
'logic-function-1',
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
const updateStepRequest = mutations.find(
|
|
93
|
-
(request) => 'updateWorkflowVersionStep' in request,
|
|
94
|
-
);
|
|
95
|
-
const updateStepInput =
|
|
96
|
-
updateStepRequest?.updateWorkflowVersionStep.__args.input;
|
|
97
|
-
expect(updateStepInput.workflowVersionId).toBe('version-1');
|
|
98
|
-
expect(updateStepInput.step.id).toBe(createStepInput.id);
|
|
99
|
-
expect(updateStepInput.step.type).toBe('LOGIC_FUNCTION');
|
|
100
|
-
expect(updateStepInput.step.settings.input.logicFunctionId).toBe(
|
|
101
|
-
'logic-function-1',
|
|
102
|
-
);
|
|
103
|
-
expect(updateStepInput.step.settings.input.logicFunctionInput).toEqual({
|
|
104
|
-
records: '{{trigger.companies}}',
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
const activateRequest = mutations.find(
|
|
108
|
-
(request) => 'activateWorkflowVersion' in request,
|
|
109
|
-
);
|
|
110
|
-
expect(
|
|
111
|
-
activateRequest?.activateWorkflowVersion.__args.workflowVersionId,
|
|
112
|
-
).toBe('version-1');
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it('skips creation when a workflow with the same name already exists', async () => {
|
|
116
|
-
const mutations: AnyRequest[] = [];
|
|
117
|
-
|
|
118
|
-
const client = createCoreApiClientMock({
|
|
119
|
-
queryResult: (request: unknown) =>
|
|
120
|
-
'workflows' in (request as AnyRequest)
|
|
121
|
-
? { workflows: { edges: [{ node: { id: 'existing-1' } }] } }
|
|
122
|
-
: {},
|
|
123
|
-
onMutation: (request) => mutations.push(request as AnyRequest),
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
const result = await seedEnrichmentWorkflow({
|
|
127
|
-
client,
|
|
128
|
-
logicFunctionId: 'logic-function-1',
|
|
129
|
-
seed: SEED,
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
expect(result.status).toBe('skipped');
|
|
133
|
-
expect(result.workflowId).toBe('existing-1');
|
|
134
|
-
expect(mutations).toHaveLength(0);
|
|
135
|
-
});
|
|
136
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import { sizeTransform } from 'src/logic-functions/utils/size-transform';
|
|
4
|
-
|
|
5
|
-
describe('sizeTransform', () => {
|
|
6
|
-
it('maps PDL size ranges to option values', () => {
|
|
7
|
-
expect(sizeTransform('1-10')).toBe('ONE_TO_TEN');
|
|
8
|
-
expect(sizeTransform('10001+')).toBe('TEN_THOUSAND_ONE_PLUS');
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it('tolerates spacing variants', () => {
|
|
12
|
-
expect(sizeTransform('51 - 200')).toBe('FIFTY_ONE_TO_TWO_HUNDRED');
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it('returns undefined for an unknown range', () => {
|
|
16
|
-
expect(sizeTransform('weird')).toBeUndefined();
|
|
17
|
-
});
|
|
18
|
-
});
|