linkedin-secret-sauce 0.3.18 → 0.3.19
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/company-parser.js +41 -11
- package/package.json +1 -1
|
@@ -4,22 +4,52 @@ exports.parseCompany = parseCompany;
|
|
|
4
4
|
const image_parser_1 = require("./image-parser");
|
|
5
5
|
function parseCompany(raw) {
|
|
6
6
|
const r = raw;
|
|
7
|
+
// LinkedIn API returns nested structure with data + included array
|
|
8
|
+
const data = r?.data || r;
|
|
9
|
+
const included = Array.isArray(r?.included) ? r.included : [];
|
|
10
|
+
// Find MiniCompany in included array (contains name, logo, universalName)
|
|
11
|
+
const miniCompany = included.find(it => String(it?.entityUrn || '').includes('fs_miniCompany') ||
|
|
12
|
+
String(it?.$type || '').includes('MiniCompany'));
|
|
13
|
+
// Extract company ID from multiple possible locations
|
|
14
|
+
const extractId = (obj) => {
|
|
15
|
+
if (!obj)
|
|
16
|
+
return '';
|
|
17
|
+
const id = String(obj.id ?? obj.entityUrn ?? obj.objectUrn ?? '');
|
|
18
|
+
// Handle all URN formats: fs_miniCompany, fs_company, fsd_company
|
|
19
|
+
return id.replace(/^urn:li:(?:fsd_|fs_)?(?:miniCompany|company):/i, '');
|
|
20
|
+
};
|
|
21
|
+
// Priority: data.entityUrn > miniCompany.objectUrn > miniCompany.entityUrn > data.id
|
|
22
|
+
const companyId = extractId(data) || extractId(miniCompany) || extractId(r);
|
|
7
23
|
const company = {
|
|
8
|
-
companyId
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
24
|
+
companyId,
|
|
25
|
+
universalName: (miniCompany?.universalName || data?.universalName || r?.universalName),
|
|
26
|
+
name: (miniCompany?.name || data?.name || r?.name),
|
|
27
|
+
websiteUrl: (data?.websiteUrl || r?.websiteUrl),
|
|
28
|
+
description: (data?.description || r?.description),
|
|
29
|
+
sizeLabel: (typeof data?.employeeCountRange === 'string' ? data.employeeCountRange :
|
|
30
|
+
data?.employeeCountRange?.localizedName) ||
|
|
31
|
+
(typeof r?.employeeCountRange === 'string' ? r.employeeCountRange :
|
|
32
|
+
r?.employeeCountRange?.localizedName),
|
|
33
|
+
headquarters: data?.basicCompanyInfo?.headquarters ||
|
|
34
|
+
r?.headquarterLocation?.defaultLocalizedName ||
|
|
17
35
|
r?.headquarter?.defaultLocalizedName,
|
|
36
|
+
companyType: (data?.companyType || r?.companyType),
|
|
37
|
+
industries: (data?.industries || r?.industries),
|
|
38
|
+
specialties: (data?.specialties || r?.specialties),
|
|
39
|
+
foundedYear: data?.foundedDate?.year ||
|
|
40
|
+
r?.foundedOn?.year,
|
|
18
41
|
logoUrl: undefined,
|
|
19
42
|
coverUrl: undefined,
|
|
20
43
|
};
|
|
21
|
-
|
|
22
|
-
const
|
|
44
|
+
// Extract logo - check miniCompany first, then data, then root
|
|
45
|
+
const logoVector = miniCompany?.logo?.vectorImage ||
|
|
46
|
+
miniCompany?.logo ||
|
|
47
|
+
data?.logo?.vectorImage ||
|
|
48
|
+
r?.logo?.vectorImage ||
|
|
49
|
+
r?.logoV2?.vectorImage;
|
|
50
|
+
const coverVector = data?.coverPhoto?.vectorImage ||
|
|
51
|
+
r?.coverPhoto?.vectorImage ||
|
|
52
|
+
r?.backgroundImage?.vectorImage;
|
|
23
53
|
const logoUrl = (0, image_parser_1.selectBestImageUrl)(logoVector);
|
|
24
54
|
const coverUrl = (0, image_parser_1.selectBestImageUrl)(coverVector);
|
|
25
55
|
if (logoUrl)
|