@memberjunction/actions-peopledatalabs 0.0.0 → 6.2.0-edge.4
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/LICENSE +183 -0
- package/README.md +90 -43
- package/dist/PDLEnrichPeopleAction.d.ts +20 -0
- package/dist/PDLEnrichPeopleAction.d.ts.map +1 -0
- package/dist/PDLEnrichPeopleAction.js +104 -0
- package/dist/PDLEnrichPeopleAction.js.map +1 -0
- package/dist/PDLPersonClient.d.ts +164 -0
- package/dist/PDLPersonClient.d.ts.map +1 -0
- package/dist/PDLPersonClient.js +257 -0
- package/dist/PDLPersonClient.js.map +1 -0
- package/dist/config.d.ts +7 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +7 -0
- package/dist/config.js.map +1 -0
- package/dist/credentials.d.ts +32 -0
- package/dist/credentials.d.ts.map +1 -0
- package/dist/credentials.js +121 -0
- package/dist/credentials.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/params.d.ts +18 -0
- package/dist/params.d.ts.map +1 -0
- package/dist/params.js +50 -0
- package/dist/params.js.map +1 -0
- package/dist/pdl.types.d.ts +108 -0
- package/dist/pdl.types.d.ts.map +1 -0
- package/dist/pdl.types.js +10 -0
- package/dist/pdl.types.js.map +1 -0
- package/package.json +30 -8
package/LICENSE
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
License text copyright (c) 2024 MariaDB plc, All Rights Reserved.
|
|
4
|
+
"Business Source License" is a trademark of MariaDB plc.
|
|
5
|
+
|
|
6
|
+
-----------------------------------------------------------------------------
|
|
7
|
+
|
|
8
|
+
Parameters
|
|
9
|
+
|
|
10
|
+
Licensor: Blue Cypress, Inc.
|
|
11
|
+
|
|
12
|
+
Licensed Work: MemberJunction.
|
|
13
|
+
The Licensed Work is (c) 2023-2026 Blue Cypress, Inc.
|
|
14
|
+
|
|
15
|
+
Additional Use Grant: Subject to the terms of this License, Licensor grants
|
|
16
|
+
you the following additional rights to make Production
|
|
17
|
+
Use of the Licensed Work.
|
|
18
|
+
|
|
19
|
+
1. Internal Use
|
|
20
|
+
|
|
21
|
+
You may make production use of the Licensed Work for
|
|
22
|
+
your own internal business or organizational operations.
|
|
23
|
+
|
|
24
|
+
2. Nonprofit Use
|
|
25
|
+
|
|
26
|
+
If you are a Nonprofit, you may make production use of
|
|
27
|
+
the Licensed Work for the operations and activities of
|
|
28
|
+
your Organizational Family.
|
|
29
|
+
|
|
30
|
+
3. MemberJunction Certified Program Use
|
|
31
|
+
|
|
32
|
+
If you are authorized by Licensor under the
|
|
33
|
+
MemberJunction Certified Program to provide professional
|
|
34
|
+
services using the Licensed Work, you may make
|
|
35
|
+
production use of the Licensed Work in providing such
|
|
36
|
+
professional services to a client, provided that:
|
|
37
|
+
|
|
38
|
+
(a) the Licensed Work is deployed in, and the applicable
|
|
39
|
+
production use occurs within, an environment owned,
|
|
40
|
+
leased, licensed, subscribed to, or otherwise controlled
|
|
41
|
+
by that client; and
|
|
42
|
+
|
|
43
|
+
(b) the production use is for that client's own internal
|
|
44
|
+
business or organizational operations or is otherwise
|
|
45
|
+
independently permitted to that client under this
|
|
46
|
+
Additional Use Grant.
|
|
47
|
+
|
|
48
|
+
4. Definitions Applicable to the Additional Use Grant
|
|
49
|
+
|
|
50
|
+
"Affiliate" means, with respect to a specified Person,
|
|
51
|
+
any other Person that directly or indirectly Controls,
|
|
52
|
+
is Controlled by, or is under common Control with such
|
|
53
|
+
specified Person.
|
|
54
|
+
|
|
55
|
+
"Control" (including the terms "Controls," "Controlled
|
|
56
|
+
by," and "under common Control with") means the direct
|
|
57
|
+
or indirect possession of the power to direct or cause
|
|
58
|
+
the direction of the management and policies of a
|
|
59
|
+
Person, whether through ownership of voting interests,
|
|
60
|
+
by contract, or otherwise.
|
|
61
|
+
|
|
62
|
+
"Organizational Family" means, with respect to a Person,
|
|
63
|
+
(a) such Person and its Affiliates, and (b) any
|
|
64
|
+
nonprofit organization, governmental entity, chapter,
|
|
65
|
+
division, local affiliate, regional affiliate, state
|
|
66
|
+
affiliate, national affiliate, or other entity that is
|
|
67
|
+
formally affiliated with such Person through governing
|
|
68
|
+
documents, a charter, bylaws, a membership agreement, or
|
|
69
|
+
another written organizational instrument, and is
|
|
70
|
+
recognized under such documents as part of the same
|
|
71
|
+
organizational structure.
|
|
72
|
+
|
|
73
|
+
"Nonprofit" means a Person recognized by the Internal
|
|
74
|
+
Revenue Service as exempt from federal income taxation
|
|
75
|
+
under Section 501(c)(3), 501(c)(4), 501(c)(5), or
|
|
76
|
+
501(c)(6) of the Internal Revenue Code, or a foreign
|
|
77
|
+
organization recognized under substantially equivalent
|
|
78
|
+
laws.
|
|
79
|
+
|
|
80
|
+
A Person claiming eligibility as a Nonprofit shall, upon
|
|
81
|
+
Licensor's reasonable request, provide documentation
|
|
82
|
+
reasonably sufficient to demonstrate that it qualifies
|
|
83
|
+
as a Nonprofit. If such Person materially misrepresents,
|
|
84
|
+
or is unable to demonstrate, its qualification as a
|
|
85
|
+
Nonprofit, the rights granted to such Person under
|
|
86
|
+
Section 2 of this Additional Use Grant shall terminate.
|
|
87
|
+
|
|
88
|
+
"MemberJunction Certified Program" means Licensor's
|
|
89
|
+
then-current program for certifying and authorizing a
|
|
90
|
+
Person to provide professional services using the
|
|
91
|
+
Licensed Work.
|
|
92
|
+
|
|
93
|
+
"Person" means any individual, corporation, limited
|
|
94
|
+
liability company, partnership, association, nonprofit
|
|
95
|
+
organization, governmental entity, or other legal or
|
|
96
|
+
organizational entity.
|
|
97
|
+
|
|
98
|
+
Change Date: Four (4) years from the date the Licensed Work is first
|
|
99
|
+
made available.
|
|
100
|
+
|
|
101
|
+
Change License: MIT License.
|
|
102
|
+
|
|
103
|
+
For information about alternative licensing arrangements for the Licensed
|
|
104
|
+
Work, please contact Blue Cypress, Inc.
|
|
105
|
+
|
|
106
|
+
-----------------------------------------------------------------------------
|
|
107
|
+
|
|
108
|
+
Terms
|
|
109
|
+
|
|
110
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
111
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
112
|
+
Licensor may make an Additional Use Grant, above, permitting limited
|
|
113
|
+
production use.
|
|
114
|
+
|
|
115
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
116
|
+
available distribution of a specific version of the Licensed Work under this
|
|
117
|
+
License, whichever comes first, the Licensor hereby grants you rights under
|
|
118
|
+
the terms of the Change License, and the rights granted in the paragraph
|
|
119
|
+
above terminate.
|
|
120
|
+
|
|
121
|
+
If your use of the Licensed Work does not comply with the requirements
|
|
122
|
+
currently in effect as described in this License, you must purchase a
|
|
123
|
+
commercial license from the Licensor, its affiliated entities, or authorized
|
|
124
|
+
resellers, or you must refrain from using the Licensed Work.
|
|
125
|
+
|
|
126
|
+
All copies of the original and modified Licensed Work, and derivative works
|
|
127
|
+
of the Licensed Work, are subject to this License. This License applies
|
|
128
|
+
separately for each version of the Licensed Work and the Change Date may vary
|
|
129
|
+
for each version of the Licensed Work released by Licensor.
|
|
130
|
+
|
|
131
|
+
You must conspicuously display this License on each original or modified copy
|
|
132
|
+
of the Licensed Work. If you receive the Licensed Work in original or
|
|
133
|
+
modified form from a third party, the terms and conditions set forth in this
|
|
134
|
+
License apply to your use of that work.
|
|
135
|
+
|
|
136
|
+
Any use of the Licensed Work in violation of this License will automatically
|
|
137
|
+
terminate your rights under this License for the current and all other
|
|
138
|
+
versions of the Licensed Work.
|
|
139
|
+
|
|
140
|
+
This License does not grant you any right in any trademark or logo of
|
|
141
|
+
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
142
|
+
Licensor as expressly required by this License).
|
|
143
|
+
|
|
144
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
145
|
+
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
146
|
+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
147
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
148
|
+
TITLE.
|
|
149
|
+
|
|
150
|
+
MariaDB hereby grants you permission to use this License's text to license
|
|
151
|
+
your works, and to refer to it using the trademark "Business Source License",
|
|
152
|
+
as long as you comply with the Covenants of Licensor below.
|
|
153
|
+
|
|
154
|
+
-----------------------------------------------------------------------------
|
|
155
|
+
|
|
156
|
+
Covenants of Licensor
|
|
157
|
+
|
|
158
|
+
In consideration of the right to use this License's text and the "Business
|
|
159
|
+
Source License" name and trademark, Licensor covenants to MariaDB, and to all
|
|
160
|
+
other recipients of the licensed work to be provided by Licensor:
|
|
161
|
+
|
|
162
|
+
1. To specify as the Change License the GPL Version 2.0 or any later version,
|
|
163
|
+
or a license that is compatible with GPL Version 2.0 or a later version,
|
|
164
|
+
where "compatible" means that software provided under the Change License
|
|
165
|
+
can be included in a program with software provided under GPL Version 2.0
|
|
166
|
+
or a later version. Licensor may specify additional Change Licenses without
|
|
167
|
+
limitation.
|
|
168
|
+
|
|
169
|
+
2. To either: (a) specify an additional grant of rights to use that does not
|
|
170
|
+
impose any additional restriction on the right granted in this License, as
|
|
171
|
+
the Additional Use Grant; or (b) insert the text "None".
|
|
172
|
+
|
|
173
|
+
3. To specify a Change Date.
|
|
174
|
+
|
|
175
|
+
4. Not to modify this License in any other way.
|
|
176
|
+
|
|
177
|
+
-----------------------------------------------------------------------------
|
|
178
|
+
|
|
179
|
+
Notice
|
|
180
|
+
|
|
181
|
+
The Business Source License (this document, or the "License") is not an Open
|
|
182
|
+
Source license. However, the Licensed Work will eventually be made available
|
|
183
|
+
under an Open Source License, as stated in this License.
|
package/README.md
CHANGED
|
@@ -1,45 +1,92 @@
|
|
|
1
1
|
# @memberjunction/actions-peopledatalabs
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
3
|
+
A table-agnostic [People Data Labs](https://www.peopledatalabs.com/) client plus one thin Action.
|
|
4
|
+
The client fetches and returns normalized person data; it never writes to the database, and it never
|
|
5
|
+
returns emails, phone numbers or addresses. The Action exists for agents and workflows. Code that
|
|
6
|
+
needs PDL data calls the client directly, never the Action.
|
|
7
|
+
|
|
8
|
+
## What it covers
|
|
9
|
+
|
|
10
|
+
| Surface | PDL endpoint | Billing (confirmed 2026-10-12) |
|
|
11
|
+
|---|---|---|
|
|
12
|
+
| `PDLPersonClient.BulkEnrich` | `POST /v5/person/bulk` | 1 credit per matched person; misses are free |
|
|
13
|
+
| `PDLPersonClient.SearchPeople` | `POST /v5/person/search` | 1 credit per record returned |
|
|
14
|
+
| `PDLPersonClient.CountPeople` | `POST /v5/person/search` with `size: 1` | 1 credit when anything matches |
|
|
15
|
+
| `PDLPersonClient.SuggestSchools` | `GET /v5/autocomplete?field=school` | free, rate-limited |
|
|
16
|
+
| `PDLPersonClient.CleanSchool` | `GET /v5/school/clean` | free, rate-limited |
|
|
17
|
+
|
|
18
|
+
## Credentials
|
|
19
|
+
|
|
20
|
+
Two paths, in order:
|
|
21
|
+
|
|
22
|
+
1. A `CompanyID` resolves that company's active `People Data Labs` row in `MJ: Company Integrations`,
|
|
23
|
+
then its `CredentialID` in `MJ: Credentials`, whose `Values` hold `{ "apiKey": "…" }`.
|
|
24
|
+
2. The `PDL_API_KEY` environment variable.
|
|
25
|
+
|
|
26
|
+
`CompanyIntegration.APIKey` is never read: it is not decrypt-on-read, so a synced value comes back as
|
|
27
|
+
ciphertext and PDL answers 401. A credential that exists but is malformed throws rather than falling
|
|
28
|
+
back to the environment.
|
|
29
|
+
|
|
30
|
+
The `MJ: Integrations` row named `People Data Labs` ships in `metadata/integrations/`.
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import { PDLPersonClient } from '@memberjunction/actions-peopledatalabs';
|
|
36
|
+
|
|
37
|
+
const resolved = await PDLPersonClient.ForCompany(companyID, contextUser);
|
|
38
|
+
if (!resolved) throw new Error('no PDL key');
|
|
39
|
+
const result = await resolved.Client.BulkEnrich([
|
|
40
|
+
{ Key: personID, Email: 'someone@example.org' },
|
|
41
|
+
{ Key: otherID, FirstName: 'Ada', LastName: 'Lovelace', Company: 'analytical.example' },
|
|
42
|
+
], { MinLikelihood: 6 });
|
|
43
|
+
for (const match of result.Matches) {
|
|
44
|
+
// match.Matched, match.PDLID, match.Likelihood (1..10), match.LinkedInURL,
|
|
45
|
+
// match.Education[] { SchoolName, SchoolID, Degrees, Majors, StartDate, EndDate }
|
|
46
|
+
// match.Experience[] { CompanyName, CompanyDomain, Title, StartDate, EndDate, IsCurrent }
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Rules the client enforces:
|
|
51
|
+
|
|
52
|
+
- At most 100 inputs per call, and every input needs an identifying field: `PDLID`, `Email`,
|
|
53
|
+
`LinkedInURL`, or first name plus last name plus company. Both checks run before any HTTP call.
|
|
54
|
+
- `min_likelihood` is sent inside each request's `params`. At the request level PDL silently ignores
|
|
55
|
+
it and returns low-likelihood guesses.
|
|
56
|
+
- Results are correlated by position and checked against the echoed `metadata.key`. A mismatch
|
|
57
|
+
throws rather than attaching one person's history to another.
|
|
58
|
+
- Per item: 200 is a match, 404 a miss (free, not an error), anything else sets `ErrorMessage` on
|
|
59
|
+
that item only.
|
|
60
|
+
- Top level: 401 and 403 become `PDLAuthError`, 402 `PDLCreditsExhaustedError`, 429
|
|
61
|
+
`PDLRateLimitError` with `RetryAfterSeconds` from `x-ratelimit-reset`, anything else
|
|
62
|
+
`PDLRequestError`. The client never sleeps.
|
|
63
|
+
- Dates arrive as `YYYY`, `YYYY-MM` or `YYYY-MM-DD` and are normalized to the first day of the year
|
|
64
|
+
or month.
|
|
65
|
+
- `Required` and `DataInclude` are passed through when set, but PDL did not apply them on the plan
|
|
66
|
+
this was built against. The field mapping here is the real minimization.
|
|
67
|
+
|
|
68
|
+
A note on schools: PDL may file a degree under the parent university. A Harvard Kennedy School
|
|
69
|
+
master's came back as `school.name = "harvard university"` with major `public administration`.
|
|
70
|
+
`CleanSchool` is not reliable alone (it mapped "John F. Kennedy School of Government" to
|
|
71
|
+
`john f. kennedy school`); clean, then confirm with `SuggestSchools`, which returns ids and counts.
|
|
72
|
+
|
|
73
|
+
## The Action
|
|
74
|
+
|
|
75
|
+
`People Data Labs - Enrich People` (`DriverClass` `PDLEnrichPeopleAction`), category Data Enrichment.
|
|
76
|
+
|
|
77
|
+
| Param | Type | Notes |
|
|
78
|
+
|---|---|---|
|
|
79
|
+
| People | Input, required | JSON array (or JSON string) of `{ Email, LinkedInURL, FirstName, LastName, Company, PDLID, Key }`, at most 100 |
|
|
80
|
+
| MinLikelihood | Input | 1 to 10, default 6 |
|
|
81
|
+
| CompanyID | Input | Per-company credential, as above |
|
|
82
|
+
| Matches | Output | The normalized `PDLPersonMatch[]`, in input order |
|
|
83
|
+
| MatchedCount, CreditsConsumed, KeySource | Output | |
|
|
84
|
+
|
|
85
|
+
Result codes: `SUCCESS`, `NO_MATCHES` (a success), `RATE_LIMITED`, `CREDITS_EXHAUSTED`,
|
|
86
|
+
`CREDENTIALS_NOT_FOUND`, `CONFIGURATION_ERROR`, `VALIDATION_ERROR`, `ERROR`.
|
|
87
|
+
|
|
88
|
+
## Tests
|
|
89
|
+
|
|
90
|
+
`pnpm test`. Every test uses an injected fetch and the redacted fixtures under
|
|
91
|
+
`src/__tests__/fixtures/`, captured from live responses on 2026-10-12. Nothing reaches PDL from a
|
|
92
|
+
test.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `People Data Labs - Enrich People`: a thin Action for agents and workflows. It resolves a key,
|
|
3
|
+
* calls `PDLPersonClient.BulkEnrich` for up to 100 people, and returns the normalized matches. It
|
|
4
|
+
* writes nothing to the database; code that needs PDL data calls the client directly, never this
|
|
5
|
+
* Action (MJ/packages/Actions/CLAUDE.md: code-to-code calls never go through Actions).
|
|
6
|
+
*/
|
|
7
|
+
import { BaseAction } from '@memberjunction/actions';
|
|
8
|
+
import type { ActionResultSimple, RunActionParams } from '@memberjunction/actions-base';
|
|
9
|
+
import { PDLPersonClient } from './PDLPersonClient.js';
|
|
10
|
+
export type PDLEnrichPeopleResultCode = 'SUCCESS' | 'NO_MATCHES' | 'RATE_LIMITED' | 'CREDITS_EXHAUSTED' | 'CREDENTIALS_NOT_FOUND' | 'CONFIGURATION_ERROR' | 'VALIDATION_ERROR' | 'ERROR';
|
|
11
|
+
export declare class PDLEnrichPeopleAction extends BaseAction {
|
|
12
|
+
/** Seam for tests: swap the client without touching the network. */
|
|
13
|
+
protected CreateClient(apiKey: string): PDLPersonClient;
|
|
14
|
+
protected InternalRunAction(params: RunActionParams): Promise<ActionResultSimple>;
|
|
15
|
+
private resolveClient;
|
|
16
|
+
private enrich;
|
|
17
|
+
private failure;
|
|
18
|
+
}
|
|
19
|
+
export declare function LoadPDLEnrichPeopleAction(): void;
|
|
20
|
+
//# sourceMappingURL=PDLEnrichPeopleAction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PDLEnrichPeopleAction.d.ts","sourceRoot":"","sources":["../src/PDLEnrichPeopleAction.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAMxF,OAAO,EAA4B,eAAe,EAA0C,MAAM,sBAAsB,CAAC;AAEzH,MAAM,MAAM,yBAAyB,GAC/B,SAAS,GACT,YAAY,GACZ,cAAc,GACd,mBAAmB,GACnB,uBAAuB,GACvB,qBAAqB,GACrB,kBAAkB,GAClB,OAAO,CAAC;AAId,qBACa,qBAAsB,SAAQ,UAAU;IACjD,oEAAoE;IACpE,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,eAAe;cAIvC,iBAAiB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,kBAAkB,CAAC;YAazE,aAAa;YAYb,MAAM;IAiBpB,OAAO,CAAC,OAAO;CASlB;AAkBD,wBAAgB,yBAAyB,IAAI,IAAI,CAEhD"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* `People Data Labs - Enrich People`: a thin Action for agents and workflows. It resolves a key,
|
|
9
|
+
* calls `PDLPersonClient.BulkEnrich` for up to 100 people, and returns the normalized matches. It
|
|
10
|
+
* writes nothing to the database; code that needs PDL data calls the client directly, never this
|
|
11
|
+
* Action (MJ/packages/Actions/CLAUDE.md: code-to-code calls never go through Actions).
|
|
12
|
+
*/
|
|
13
|
+
import { BaseAction } from '@memberjunction/actions';
|
|
14
|
+
import { LogError } from '@memberjunction/core';
|
|
15
|
+
import { RegisterClass } from '@memberjunction/global';
|
|
16
|
+
import { DefaultMinLikelihood } from './config.js';
|
|
17
|
+
import { NO_PDL_KEY_MESSAGE, ResolvePDLAPIKey } from './credentials.js';
|
|
18
|
+
import { GetParam, GetParamRaw, ParseObjectArrayParam, ParseOptionalIntegerParam } from './params.js';
|
|
19
|
+
import { PDLCreditsExhaustedError, PDLPersonClient, PDLRateLimitError } from './PDLPersonClient.js';
|
|
20
|
+
const PERSON_FIELDS = ['Key', 'PDLID', 'Email', 'LinkedInURL', 'FirstName', 'LastName', 'Company'];
|
|
21
|
+
let PDLEnrichPeopleAction = class PDLEnrichPeopleAction extends BaseAction {
|
|
22
|
+
/** Seam for tests: swap the client without touching the network. */
|
|
23
|
+
CreateClient(apiKey) {
|
|
24
|
+
return new PDLPersonClient(apiKey);
|
|
25
|
+
}
|
|
26
|
+
async InternalRunAction(params) {
|
|
27
|
+
const people = ParseObjectArrayParam(GetParamRaw(params, 'People'), 'People');
|
|
28
|
+
if (people.error)
|
|
29
|
+
return Fail('VALIDATION_ERROR', people.error);
|
|
30
|
+
if (!people.value || people.value.length === 0)
|
|
31
|
+
return Fail('VALIDATION_ERROR', 'People is required: a JSON array of { Email, LinkedInURL, FirstName, LastName, Company }.');
|
|
32
|
+
if (people.value.length > PDLPersonClient.MaxBatchSize)
|
|
33
|
+
return Fail('VALIDATION_ERROR', `People holds ${people.value.length} entries; at most ${PDLPersonClient.MaxBatchSize} per call.`);
|
|
34
|
+
const likelihood = ParseOptionalIntegerParam(GetParamRaw(params, 'MinLikelihood'), 'MinLikelihood', { min: 1, max: 10 });
|
|
35
|
+
if (likelihood.error)
|
|
36
|
+
return Fail('VALIDATION_ERROR', likelihood.error);
|
|
37
|
+
const inputs = people.value.map(ToInput);
|
|
38
|
+
const resolved = await this.resolveClient(params);
|
|
39
|
+
if ('error' in resolved)
|
|
40
|
+
return resolved.error;
|
|
41
|
+
return this.enrich(params, resolved.client, resolved.key, inputs, likelihood.value ?? DefaultMinLikelihood);
|
|
42
|
+
}
|
|
43
|
+
async resolveClient(params) {
|
|
44
|
+
let key;
|
|
45
|
+
try {
|
|
46
|
+
key = await ResolvePDLAPIKey(GetParam(params, 'CompanyID'), params.ContextUser);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
// A credential that exists but is malformed: say so, never fall back to another company's key.
|
|
50
|
+
return { error: Fail('CONFIGURATION_ERROR', error instanceof Error ? error.message : String(error)) };
|
|
51
|
+
}
|
|
52
|
+
if (!key)
|
|
53
|
+
return { error: Fail('CREDENTIALS_NOT_FOUND', NO_PDL_KEY_MESSAGE) };
|
|
54
|
+
return { client: this.CreateClient(key.apiKey), key };
|
|
55
|
+
}
|
|
56
|
+
async enrich(params, client, key, inputs, minLikelihood) {
|
|
57
|
+
try {
|
|
58
|
+
const result = await client.BulkEnrich(inputs, { MinLikelihood: minLikelihood });
|
|
59
|
+
const matched = result.Matches.filter((match) => match.Matched).length;
|
|
60
|
+
params.Params.push({ Name: 'Matches', Type: 'Output', Value: result.Matches }, { Name: 'MatchedCount', Type: 'Output', Value: matched }, { Name: 'CreditsConsumed', Type: 'Output', Value: result.CreditsConsumed }, { Name: 'KeySource', Type: 'Output', Value: key.source });
|
|
61
|
+
const code = matched > 0 ? 'SUCCESS' : 'NO_MATCHES';
|
|
62
|
+
return { Success: true, ResultCode: code, Message: `People Data Labs: ${matched} of ${inputs.length} matched, ${result.CreditsConsumed} credits.`, Params: params.Params };
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
return this.failure(error);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
failure(error) {
|
|
69
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
70
|
+
LogError(`PDLEnrichPeople: ${message}`);
|
|
71
|
+
if (error instanceof PDLRateLimitError)
|
|
72
|
+
return Fail('RATE_LIMITED', message);
|
|
73
|
+
if (error instanceof PDLCreditsExhaustedError)
|
|
74
|
+
return Fail('CREDITS_EXHAUSTED', message);
|
|
75
|
+
if (error instanceof Error && error.name === 'PDLAuthError')
|
|
76
|
+
return Fail('CREDENTIALS_NOT_FOUND', message);
|
|
77
|
+
if (error instanceof Error && !error.name.startsWith('PDL'))
|
|
78
|
+
return Fail('VALIDATION_ERROR', message);
|
|
79
|
+
return Fail('ERROR', `Error enriching people through People Data Labs: ${message}`);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
PDLEnrichPeopleAction = __decorate([
|
|
83
|
+
RegisterClass(BaseAction, 'PDLEnrichPeopleAction')
|
|
84
|
+
], PDLEnrichPeopleAction);
|
|
85
|
+
export { PDLEnrichPeopleAction };
|
|
86
|
+
function Fail(code, message) {
|
|
87
|
+
return { Success: false, ResultCode: code, Message: message };
|
|
88
|
+
}
|
|
89
|
+
/** Accepts the documented field names in any casing; the Key defaults to the row's position. */
|
|
90
|
+
function ToInput(row, index) {
|
|
91
|
+
const input = { Key: String(index) };
|
|
92
|
+
for (const field of PERSON_FIELDS) {
|
|
93
|
+
const entry = Object.entries(row).find(([name]) => name.toLowerCase() === field.toLowerCase());
|
|
94
|
+
const value = entry?.[1];
|
|
95
|
+
if (value === undefined || value === null || String(value).trim() === '')
|
|
96
|
+
continue;
|
|
97
|
+
input[field] = String(value).trim();
|
|
98
|
+
}
|
|
99
|
+
return input;
|
|
100
|
+
}
|
|
101
|
+
export function LoadPDLEnrichPeopleAction() {
|
|
102
|
+
// Referenced by consumers to keep the registration from being tree-shaken.
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=PDLEnrichPeopleAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PDLEnrichPeopleAction.js","sourceR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AAG,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;IACrD,KAAK,MAAM,KAAK,IAAI,aAAa,EAAE,CAAC;QAChC,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;QAC/F,MAAM,KAAK,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;QACzB,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE;YAAE,SAAS;QACnF,KAAK,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;IACxC,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,yBAAyB;IACrC,2EAA2E;AAC/E,CAAC"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A table-agnostic People Data Labs client: bulk person enrichment, person search, a size-1 count,
|
|
3
|
+
* and the free school lookups. It fetches and returns normalized data and writes nothing. Only the
|
|
4
|
+
* fields below are mapped; emails, phones, addresses and everything else PDL returns never leave
|
|
5
|
+
* this module unless `IncludeRaw` is set for debugging.
|
|
6
|
+
*/
|
|
7
|
+
import { type UserInfo } from '@memberjunction/core';
|
|
8
|
+
export interface PDLPersonInput {
|
|
9
|
+
/** Correlation key; common passes the Person ID. Echoed back by PDL as `metadata.key`. */
|
|
10
|
+
Key: string;
|
|
11
|
+
/** Exact re-match when known; sent as `pdl_id`. */
|
|
12
|
+
PDLID?: string;
|
|
13
|
+
Email?: string;
|
|
14
|
+
/** Sent as PDL's `profile` param. */
|
|
15
|
+
LinkedInURL?: string;
|
|
16
|
+
FirstName?: string;
|
|
17
|
+
LastName?: string;
|
|
18
|
+
/** Employer name or domain. */
|
|
19
|
+
Company?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface PDLEducationEntry {
|
|
22
|
+
SchoolName: string;
|
|
23
|
+
SchoolID: string | null;
|
|
24
|
+
Degrees: string[];
|
|
25
|
+
Majors: string[];
|
|
26
|
+
/** Normalized 'YYYY-MM-DD'. */
|
|
27
|
+
StartDate: string | null;
|
|
28
|
+
EndDate: string | null;
|
|
29
|
+
}
|
|
30
|
+
export interface PDLExperienceEntry {
|
|
31
|
+
CompanyName: string;
|
|
32
|
+
/** Host of `company.website`, normalized. */
|
|
33
|
+
CompanyDomain: string | null;
|
|
34
|
+
Title: string | null;
|
|
35
|
+
StartDate: string | null;
|
|
36
|
+
EndDate: string | null;
|
|
37
|
+
IsCurrent: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface PDLPersonMatch {
|
|
40
|
+
Key: string;
|
|
41
|
+
Matched: boolean;
|
|
42
|
+
PDLID: string | null;
|
|
43
|
+
/** 1..10 */
|
|
44
|
+
Likelihood: number | null;
|
|
45
|
+
LinkedInURL: string | null;
|
|
46
|
+
Education: PDLEducationEntry[];
|
|
47
|
+
Experience: PDLExperienceEntry[];
|
|
48
|
+
/** Set when this one item failed (non-200, non-404). */
|
|
49
|
+
ErrorMessage: string | null;
|
|
50
|
+
/** Only with IncludeRaw; never persist. */
|
|
51
|
+
Raw?: Record<string, unknown>;
|
|
52
|
+
}
|
|
53
|
+
export interface PDLBulkOptions {
|
|
54
|
+
/** Default 6, PDL's recommended value. Sent inside each request's `params`; at the request level PDL ignores it. */
|
|
55
|
+
MinLikelihood?: number;
|
|
56
|
+
/** e.g. 'education'. Accepted but not applied on every plan; never rely on it. */
|
|
57
|
+
Required?: string;
|
|
58
|
+
/** Not applied on every plan; the mapping above is the real minimization. */
|
|
59
|
+
DataInclude?: string[];
|
|
60
|
+
IncludeRaw?: boolean;
|
|
61
|
+
}
|
|
62
|
+
export interface PDLBulkResult {
|
|
63
|
+
/** Same length and order as the input. */
|
|
64
|
+
Matches: PDLPersonMatch[];
|
|
65
|
+
/** From `x-call-credits-spent` when PDL sends it, else the count of per-item 200s. */
|
|
66
|
+
CreditsConsumed: number;
|
|
67
|
+
}
|
|
68
|
+
/** A typed subset of PDL's Elasticsearch query. Built from clauses, so no value is ever spliced into query text. */
|
|
69
|
+
export type PDLQueryClause = {
|
|
70
|
+
term: Record<string, string>;
|
|
71
|
+
} | {
|
|
72
|
+
terms: Record<string, string[]>;
|
|
73
|
+
} | {
|
|
74
|
+
match: Record<string, string>;
|
|
75
|
+
} | {
|
|
76
|
+
range: Record<string, {
|
|
77
|
+
gte?: string;
|
|
78
|
+
lte?: string;
|
|
79
|
+
}>;
|
|
80
|
+
} | PDLBoolQuery;
|
|
81
|
+
export interface PDLBoolQuery {
|
|
82
|
+
bool: {
|
|
83
|
+
must?: PDLQueryClause[];
|
|
84
|
+
should?: PDLQueryClause[];
|
|
85
|
+
minimum_should_match?: number;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
export interface PDLPersonSearchRequest {
|
|
89
|
+
Query: PDLBoolQuery;
|
|
90
|
+
/** 1..100 */
|
|
91
|
+
Size: number;
|
|
92
|
+
/** From the previous page. */
|
|
93
|
+
ScrollToken?: string;
|
|
94
|
+
}
|
|
95
|
+
export interface PDLPersonSearchPage {
|
|
96
|
+
/** PDL's total for the query. */
|
|
97
|
+
Total: number;
|
|
98
|
+
/** Normalized like BulkEnrich; Key = PDL person id, Matched = true. */
|
|
99
|
+
People: PDLPersonMatch[];
|
|
100
|
+
/** Null on the last page. */
|
|
101
|
+
ScrollToken: string | null;
|
|
102
|
+
/** Records returned, which is what PDL bills for a search. */
|
|
103
|
+
CreditsConsumed: number;
|
|
104
|
+
}
|
|
105
|
+
export interface PDLSchoolSuggestion {
|
|
106
|
+
Name: string;
|
|
107
|
+
SchoolID: string | null;
|
|
108
|
+
/** Autocomplete's per-suggestion count; null from the cleaner. */
|
|
109
|
+
Count: number | null;
|
|
110
|
+
}
|
|
111
|
+
export interface PDLPersonClientOptions {
|
|
112
|
+
/** Injected fetch, for tests. Tests must never reach api.peopledatalabs.com. */
|
|
113
|
+
FetchImpl?: typeof fetch;
|
|
114
|
+
BaseURL?: string;
|
|
115
|
+
}
|
|
116
|
+
export declare class PDLRateLimitError extends Error {
|
|
117
|
+
readonly RetryAfterSeconds: number | null;
|
|
118
|
+
constructor(message: string, retryAfterSeconds: number | null);
|
|
119
|
+
}
|
|
120
|
+
export declare class PDLCreditsExhaustedError extends Error {
|
|
121
|
+
constructor(message: string);
|
|
122
|
+
}
|
|
123
|
+
export declare class PDLAuthError extends Error {
|
|
124
|
+
readonly Status: number;
|
|
125
|
+
constructor(message: string, status: number);
|
|
126
|
+
}
|
|
127
|
+
export declare class PDLRequestError extends Error {
|
|
128
|
+
readonly Status: number;
|
|
129
|
+
readonly Body: string;
|
|
130
|
+
constructor(message: string, status: number, body: string);
|
|
131
|
+
}
|
|
132
|
+
export declare class PDLPersonClient {
|
|
133
|
+
static readonly MaxBatchSize = 100;
|
|
134
|
+
static readonly MaxSearchPageSize = 100;
|
|
135
|
+
private readonly apiKey;
|
|
136
|
+
private readonly fetchImpl;
|
|
137
|
+
private readonly baseURL;
|
|
138
|
+
constructor(apiKey: string, options?: PDLPersonClientOptions);
|
|
139
|
+
/** Resolve the key through the credentials path (company credential, then PDL_API_KEY), then construct a client. */
|
|
140
|
+
static ForCompany(companyID: string | null, contextUser: UserInfo | undefined, options?: PDLPersonClientOptions): Promise<{
|
|
141
|
+
Client: PDLPersonClient;
|
|
142
|
+
KeySource: 'credential' | 'environment';
|
|
143
|
+
} | null>;
|
|
144
|
+
BulkEnrich(inputs: PDLPersonInput[], options?: PDLBulkOptions): Promise<PDLBulkResult>;
|
|
145
|
+
/** One page of Person Search. Billed per record returned. A no-records response is `Total: 0`, not an error. */
|
|
146
|
+
SearchPeople(request: PDLPersonSearchRequest): Promise<PDLPersonSearchPage>;
|
|
147
|
+
/** A size-1 search that returns only the total; the one record is discarded unmapped. */
|
|
148
|
+
CountPeople(query: PDLBoolQuery): Promise<{
|
|
149
|
+
Total: number;
|
|
150
|
+
CreditsConsumed: number;
|
|
151
|
+
}>;
|
|
152
|
+
/** Autocomplete on `field=school`. Free of credits; rate-limited only. */
|
|
153
|
+
SuggestSchools(text: string, size?: number): Promise<PDLSchoolSuggestion[]>;
|
|
154
|
+
/** School Cleaner. Free of credits. Returns null when PDL can't resolve the name. Not trustworthy alone: confirm with SuggestSchools. */
|
|
155
|
+
CleanSchool(name: string): Promise<PDLSchoolSuggestion | null>;
|
|
156
|
+
private request;
|
|
157
|
+
}
|
|
158
|
+
/** `YYYY`, `YYYY-MM` and `YYYY-MM-DD` to the first day of the year or month; anything else to null. */
|
|
159
|
+
/** Strips trailing slashes without a regex: `/\/+$/` is quadratic on a long run of slashes (CodeQL js/polynomial-redos). */
|
|
160
|
+
export declare function TrimTrailingSlashes(value: string): string;
|
|
161
|
+
export declare function NormalizeDate(value: string | null | undefined): string | null;
|
|
162
|
+
/** Bare host of a website or domain value. */
|
|
163
|
+
export declare function DomainOf(value: string | null | undefined): string | null;
|
|
164
|
+
//# sourceMappingURL=PDLPersonClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PDLPersonClient.d.ts","sourceRoot":"","sources":["../src/PDLPersonClient.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAY,KAAK,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAe/D,MAAM,WAAW,cAAc;IAC3B,0FAA0F;IAC1F,GAAG,EAAE,MAAM,CAAC;IACZ,mDAAmD;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qCAAqC;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+BAA+B;IAC/B,OAAO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