linkedin-secret-sauce 0.3.19 → 0.3.21
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/dist/parsers/profile-parser.js +16 -1
- package/dist/types.d.ts +16 -4
- package/dist/utils/search-encoder.js +38 -8
- package/package.json +1 -1
|
@@ -5,7 +5,22 @@ const image_parser_1 = require("./image-parser");
|
|
|
5
5
|
function parseFullProfile(rawResponse, vanity) {
|
|
6
6
|
const rr = rawResponse;
|
|
7
7
|
const included = Array.isArray(rr?.included) ? rr.included : [];
|
|
8
|
-
|
|
8
|
+
// FIX: Match profile by publicIdentifier to handle edge case where LinkedIn API
|
|
9
|
+
// returns multiple profiles (e.g., authenticated user + requested profile)
|
|
10
|
+
const identity = included.find((it) => {
|
|
11
|
+
const rec = it;
|
|
12
|
+
const isProfile = String(rec?.$type || '').includes('identity.profile.Profile');
|
|
13
|
+
if (!isProfile)
|
|
14
|
+
return false;
|
|
15
|
+
// Match by publicIdentifier if vanity was provided
|
|
16
|
+
if (vanity) {
|
|
17
|
+
const pubId = rec.publicIdentifier?.toLowerCase();
|
|
18
|
+
const requestedVanity = String(vanity).toLowerCase();
|
|
19
|
+
return pubId === requestedVanity;
|
|
20
|
+
}
|
|
21
|
+
// Fallback: if no vanity to match, return first profile (legacy behavior for getProfileByUrn)
|
|
22
|
+
return true;
|
|
23
|
+
}) || {};
|
|
9
24
|
const profile = {
|
|
10
25
|
vanity,
|
|
11
26
|
publicIdentifier: identity.publicIdentifier,
|
package/dist/types.d.ts
CHANGED
|
@@ -207,12 +207,24 @@ export type Geo = {
|
|
|
207
207
|
export type SalesSearchFilters = {
|
|
208
208
|
company?: {
|
|
209
209
|
current?: {
|
|
210
|
-
include?: string
|
|
211
|
-
|
|
210
|
+
include?: (string | {
|
|
211
|
+
id?: string | number;
|
|
212
|
+
text?: string;
|
|
213
|
+
})[];
|
|
214
|
+
exclude?: (string | {
|
|
215
|
+
id?: string | number;
|
|
216
|
+
text?: string;
|
|
217
|
+
})[];
|
|
212
218
|
};
|
|
213
219
|
past?: {
|
|
214
|
-
include?: string
|
|
215
|
-
|
|
220
|
+
include?: (string | {
|
|
221
|
+
id?: string | number;
|
|
222
|
+
text?: string;
|
|
223
|
+
})[];
|
|
224
|
+
exclude?: (string | {
|
|
225
|
+
id?: string | number;
|
|
226
|
+
text?: string;
|
|
227
|
+
})[];
|
|
216
228
|
};
|
|
217
229
|
headcount?: {
|
|
218
230
|
include?: ("1-10" | "11-50" | "51-200" | "201-500" | "501-1000" | "1001-5000" | "5001-10000" | "10000+")[];
|
|
@@ -117,22 +117,52 @@ function buildLeadSearchQuery(keywords, filters) {
|
|
|
117
117
|
});
|
|
118
118
|
pushFilter(f, 'COMPANY_HEADCOUNT', values);
|
|
119
119
|
}
|
|
120
|
-
// CURRENT_COMPANY — accept org URN (urn:li:organization:ID), numeric ID, or text
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
120
|
+
// CURRENT_COMPANY — accept org URN (urn:li:organization:ID), numeric ID, text, or object with {id, text}
|
|
121
|
+
function encodeCompanies(arr) {
|
|
122
|
+
if (!arr || !arr.length)
|
|
123
|
+
return [];
|
|
124
|
+
return arr.map((c) => {
|
|
124
125
|
const parts = [];
|
|
125
|
-
if (
|
|
126
|
-
|
|
126
|
+
if (typeof c === 'object' && c !== null) {
|
|
127
|
+
// Handle object format: { id: 'urn:...', text: 'Company Name' }
|
|
128
|
+
if (c.id != null) {
|
|
129
|
+
const idStr = String(c.id);
|
|
130
|
+
// If numeric, convert to URN
|
|
131
|
+
if (/^\d+$/.test(idStr)) {
|
|
132
|
+
parts.push(`id:urn:li:organization:${idStr}`);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
parts.push(`id:${idStr}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (c.text) {
|
|
139
|
+
parts.push(`text:${encText(c.text)}`);
|
|
140
|
+
}
|
|
127
141
|
}
|
|
128
142
|
else {
|
|
129
|
-
|
|
143
|
+
// Handle string format (legacy)
|
|
144
|
+
const s = String(c);
|
|
145
|
+
if (/^urn:li:organization:\d+$/i.test(s)) {
|
|
146
|
+
parts.push(`id:${s}`);
|
|
147
|
+
}
|
|
148
|
+
else if (/^\d+$/.test(s)) {
|
|
149
|
+
parts.push(`id:urn:li:organization:${s}`);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
parts.push(`text:${encText(s)}`);
|
|
153
|
+
}
|
|
130
154
|
}
|
|
131
155
|
parts.push('selectionType:INCLUDED');
|
|
132
156
|
return valObj(parts);
|
|
133
157
|
});
|
|
134
|
-
pushFilter(f, 'CURRENT_COMPANY', values);
|
|
135
158
|
}
|
|
159
|
+
const curCompanies = encodeCompanies(filters?.company?.current?.include);
|
|
160
|
+
if (curCompanies.length)
|
|
161
|
+
pushFilter(f, 'CURRENT_COMPANY', curCompanies);
|
|
162
|
+
// PAST_COMPANY — same logic as current
|
|
163
|
+
const pastCompanies = encodeCompanies(filters?.company?.past?.include);
|
|
164
|
+
if (pastCompanies.length)
|
|
165
|
+
pushFilter(f, 'PAST_COMPANY', pastCompanies);
|
|
136
166
|
// COMPANY_TYPE — map to C,P,N,D,G when known; allow raw codes
|
|
137
167
|
const COMPANY_TYPE = {
|
|
138
168
|
PUBLIC: 'C',
|