orangeslice 1.7.18 → 1.7.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/expansion.js +3 -79
- package/package.json +1 -1
package/dist/expansion.js
CHANGED
|
@@ -22,13 +22,6 @@ function extractLinkedinUsername(url) {
|
|
|
22
22
|
const slug = match[1].trim();
|
|
23
23
|
return slug.length > 0 ? slug : undefined;
|
|
24
24
|
}
|
|
25
|
-
function extractLinkedinCompanySlug(url) {
|
|
26
|
-
const match = url.match(/linkedin\.com\/company\/([^/?#]+)/i);
|
|
27
|
-
if (!match?.[1])
|
|
28
|
-
return undefined;
|
|
29
|
-
const slug = match[1].trim().toLowerCase();
|
|
30
|
-
return slug.length > 0 ? slug : undefined;
|
|
31
|
-
}
|
|
32
25
|
async function personLinkedinFindUrl(params) {
|
|
33
26
|
return (0, api_1.post)("linkedin/find-profile-url", params, { direct: true });
|
|
34
27
|
}
|
|
@@ -106,78 +99,9 @@ async function companyLinkedinEnrich(params) {
|
|
|
106
99
|
return data.rows?.[0] ?? null;
|
|
107
100
|
}
|
|
108
101
|
async function companyGetEmployeesFromLinkedin(params) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const titleVariations = Array.isArray(params.titleVariations)
|
|
113
|
-
? params.titleVariations
|
|
114
|
-
.filter((v) => typeof v === "string" && v.trim().length > 0)
|
|
115
|
-
.map((v) => v.trim())
|
|
116
|
-
: [];
|
|
117
|
-
const titleSqlFilterRaw = typeof params.titleSqlFilter === "string" ? params.titleSqlFilter.trim() : "";
|
|
118
|
-
const titleSqlFilter = titleSqlFilterRaw.replace(/\bpos\./g, "lp.");
|
|
119
|
-
const limit = typeof params.limit === "number" && Number.isFinite(params.limit)
|
|
120
|
-
? Math.max(1, Math.min(200, Math.floor(params.limit)))
|
|
121
|
-
: 50;
|
|
122
|
-
const offset = typeof params.offset === "number" && Number.isFinite(params.offset) && params.offset >= 0
|
|
123
|
-
? Math.floor(params.offset)
|
|
124
|
-
: 0;
|
|
125
|
-
const minConnections = typeof params.minConnections === "number" && Number.isFinite(params.minConnections)
|
|
126
|
-
? Math.max(0, Math.floor(params.minConnections))
|
|
127
|
-
: 20;
|
|
128
|
-
const usOnly = params.usOnly === undefined ? true : params.usOnly === true;
|
|
129
|
-
if (!companySlug) {
|
|
130
|
-
throw new Error("[orangeslice] company.getEmployeesFromLinkedin: provide linkedinUrl or companySlug");
|
|
131
|
-
}
|
|
132
|
-
const filters = [
|
|
133
|
-
`lp.linkedin_company_id = tc.linkedin_company_id`,
|
|
134
|
-
`COALESCE(lp.connections, 0) >= ${minConnections}`,
|
|
135
|
-
];
|
|
136
|
-
if (usOnly)
|
|
137
|
-
filters.push(`COALESCE(lp.location_country_code, '') = 'US'`);
|
|
138
|
-
if (titleSqlFilter) {
|
|
139
|
-
filters.push(`(${titleSqlFilter})`);
|
|
140
|
-
}
|
|
141
|
-
else if (titleVariations.length > 0) {
|
|
142
|
-
const or = titleVariations
|
|
143
|
-
.map((title) => `lower(COALESCE(lp.title, '')) LIKE ${sqlString(`%${title.toLowerCase()}%`)}`)
|
|
144
|
-
.join(" OR ");
|
|
145
|
-
filters.push(`(${or})`);
|
|
146
|
-
}
|
|
147
|
-
const sql = `WITH tc AS (
|
|
148
|
-
SELECT linkedin_company_id
|
|
149
|
-
FROM linkedin_company_slug
|
|
150
|
-
WHERE slug_key64 = key64(${sqlString(companySlug)})
|
|
151
|
-
LIMIT 1
|
|
152
|
-
)
|
|
153
|
-
SELECT
|
|
154
|
-
lp.first_name AS lp_first_name,
|
|
155
|
-
lp.last_name AS lp_last_name,
|
|
156
|
-
lp.formatted_name AS lp_formatted_name,
|
|
157
|
-
lp.headline AS lp_headline,
|
|
158
|
-
lp.location_name AS lp_location_name,
|
|
159
|
-
COALESCE(lp.public_profile_url, lp.standard_profile_url) AS lp_public_profile_url,
|
|
160
|
-
lp.title AS lp_title,
|
|
161
|
-
lp.org AS lp_company_name,
|
|
162
|
-
lp.connections AS lp_connections,
|
|
163
|
-
COUNT(*) OVER() AS _total
|
|
164
|
-
FROM linkedin_profile lp
|
|
165
|
-
JOIN tc ON true
|
|
166
|
-
WHERE ${filters.join(" AND ")}
|
|
167
|
-
ORDER BY lp.connections DESC NULLS LAST, lp.updated_at DESC NULLS LAST
|
|
168
|
-
LIMIT ${limit} OFFSET ${offset}`;
|
|
169
|
-
const data = await (0, api_1.post)("b2b", { sql }, { direct: true });
|
|
170
|
-
const rows = data.rows ?? [];
|
|
171
|
-
const total = rows.length > 0 ? Number(rows[0]._total ?? 0) : 0;
|
|
172
|
-
const employees = rows.map((row) => {
|
|
173
|
-
const { _total, ...rest } = row;
|
|
174
|
-
return rest;
|
|
175
|
-
});
|
|
176
|
-
return {
|
|
177
|
-
employees,
|
|
178
|
-
nextPage: employees.length === limit && offset + limit < total ? offset + limit : null,
|
|
179
|
-
totalResults: total,
|
|
180
|
-
};
|
|
102
|
+
// Route through the dedicated backend function, which uses optimized query plans.
|
|
103
|
+
// The raw SQL fallback can hit 60s statement timeouts on large companies.
|
|
104
|
+
return (0, api_1.post)("b2b-get-employees-for-company", params);
|
|
181
105
|
}
|
|
182
106
|
async function geoParseAddress(params) {
|
|
183
107
|
return (0, api_1.post)("geo", params);
|