@florydev/linkedin-api-voyager 1.3.5

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/lib/search.js ADDED
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.search = void 0;
24
+ exports.searchPeople = searchPeople;
25
+ /* eslint-disable @typescript-eslint/no-explicit-any */
26
+ const config_1 = require("./config");
27
+ const utils_1 = require("./utils");
28
+ // Constantes
29
+ const MAX_SEARCH_COUNT = 25;
30
+ const search = (_a) => __awaiter(void 0, void 0, void 0, function* () {
31
+ var _b, _c, _d, _e, _f;
32
+ var { offset = 0, limit = MAX_SEARCH_COUNT } = _a, opts = __rest(_a, ["offset", "limit"]);
33
+ const response = {
34
+ paging: {
35
+ offset: 0,
36
+ count: 0,
37
+ total: -1,
38
+ },
39
+ results: [],
40
+ };
41
+ const params = Object.assign({ start: offset, count: Math.min(limit, MAX_SEARCH_COUNT), filters: "List()", origin: "GLOBAL_SEARCH_HEADER" }, opts);
42
+ const keywords = params.query
43
+ ? `keywords:${encodeURIComponent(params.query)},`
44
+ : "";
45
+ const uri = `graphql?variables=(start:${params.start},origin:${params.origin},` +
46
+ `query:(${keywords}flagshipSearchIntent:SEARCH_SRP,` +
47
+ `queryParameters:${params.filters},includeFiltersInResponse:false))` +
48
+ `&queryId=voyagerSearchDashClusters.bb967969ef89137e6dec45d038310505`;
49
+ const res = yield (0, config_1.fetchData)(uri);
50
+ const dataClusters = (_c = (_b = res === null || res === void 0 ? void 0 : res.data) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.searchDashClustersByAll;
51
+ if (!dataClusters)
52
+ return response;
53
+ if (dataClusters.$type !== "com.linkedin.restli.common.CollectionResponse") {
54
+ return response;
55
+ }
56
+ response.paging.count = dataClusters.paging.count;
57
+ response.paging.total = dataClusters.paging.total;
58
+ for (const element of (_d = dataClusters.elements) !== null && _d !== void 0 ? _d : []) {
59
+ if (element.$type !==
60
+ "com.linkedin.voyager.dash.search.SearchClusterViewModel") {
61
+ continue;
62
+ }
63
+ for (const it of (_e = element.items) !== null && _e !== void 0 ? _e : []) {
64
+ if (it.$type !== "com.linkedin.voyager.dash.search.SearchItem") {
65
+ continue;
66
+ }
67
+ const item = it === null || it === void 0 ? void 0 : it.item;
68
+ if (!item)
69
+ continue;
70
+ let entity = item.entityResult;
71
+ if (!entity) {
72
+ const linkedEntityUrn = item["*entityResult"];
73
+ if (!linkedEntityUrn)
74
+ continue;
75
+ entity = (_f = res.included) === null || _f === void 0 ? void 0 : _f.find((e) => e.entityUrn === linkedEntityUrn);
76
+ if (!entity)
77
+ continue;
78
+ }
79
+ if (entity.$type !==
80
+ "com.linkedin.voyager.dash.search.EntityResultViewModel") {
81
+ continue;
82
+ }
83
+ response.results.push(entity);
84
+ }
85
+ }
86
+ return response;
87
+ });
88
+ exports.search = search;
89
+ function searchPeople(queryOrParams) {
90
+ return __awaiter(this, void 0, void 0, function* () {
91
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
92
+ const _s = typeof queryOrParams === "string"
93
+ ? { query: queryOrParams }
94
+ : queryOrParams, { includePrivateProfiles = true } = _s, params = __rest(_s, ["includePrivateProfiles"]);
95
+ const filters = ["(key:resultType,value:List(PEOPLE))"];
96
+ if (params.connectionOf) {
97
+ filters.push(`(key:connectionOf,value:List(${params.connectionOf}))`);
98
+ }
99
+ if (params.networkDepths) {
100
+ const stringify = params.networkDepths.join(" | ");
101
+ filters.push(`(key:network,value:List(${stringify}))`);
102
+ }
103
+ else if (params.networkDepth) {
104
+ filters.push(`(key:network,value:List(${params.networkDepth}))`);
105
+ }
106
+ if (params.regions) {
107
+ const stringify = params.regions.join(" | ");
108
+ filters.push(`(key:geoUrn,value:List(${stringify}))`);
109
+ }
110
+ if (params.industries) {
111
+ const stringify = params.industries.join(" | ");
112
+ filters.push(`(key:industry,value:List(${stringify}))`);
113
+ }
114
+ if (params.currentCompany) {
115
+ const stringify = params.currentCompany.join(" | ");
116
+ filters.push(`(key:currentCompany,value:List(${stringify}))`);
117
+ }
118
+ if (params.pastCompanies) {
119
+ const stringify = params.pastCompanies.join(" | ");
120
+ filters.push(`(key:pastCompany,value:List(${stringify}))`);
121
+ }
122
+ if (params.profileLanguages) {
123
+ const stringify = params.profileLanguages.join(" | ");
124
+ filters.push(`(key:profileLanguage,value:List(${stringify}))`);
125
+ }
126
+ if (params.nonprofitInterests) {
127
+ const stringify = params.nonprofitInterests.join(" | ");
128
+ filters.push(`(key:nonprofitInterest,value:List(${stringify}))`);
129
+ }
130
+ if (params.schools) {
131
+ const stringify = params.schools.join(" | ");
132
+ filters.push(`(key:schools,value:List(${stringify}))`);
133
+ }
134
+ if (params.serviceCategories) {
135
+ const stringify = params.serviceCategories.join(" | ");
136
+ filters.push(`(key:serviceCategory,value:List(${stringify}))`);
137
+ }
138
+ // `Keywords` filter
139
+ const keywordTitle = (_a = params.keywordTitle) !== null && _a !== void 0 ? _a : params.title;
140
+ if (params.keywordFirstName) {
141
+ filters.push(`(key:firstName,value:List(${params.keywordFirstName}))`);
142
+ }
143
+ if (params.keywordLastName) {
144
+ filters.push(`(key:lastName,value:List(${params.keywordLastName}))`);
145
+ }
146
+ if (keywordTitle) {
147
+ filters.push(`(key:title,value:List(${keywordTitle}))`);
148
+ }
149
+ if (params.keywordCompany) {
150
+ filters.push(`(key:company,value:List(${params.keywordCompany}))`);
151
+ }
152
+ if (params.keywordSchool) {
153
+ filters.push(`(key:school,value:List(${params.keywordSchool}))`);
154
+ }
155
+ const res = yield (0, exports.search)(Object.assign({ offset: params.offset, limit: params.limit, filters: `List(${filters.join(",")})` }, (params.query && { query: params.query })));
156
+ const response = {
157
+ paging: res.paging,
158
+ results: [],
159
+ };
160
+ for (const result of res.results) {
161
+ if (!includePrivateProfiles &&
162
+ ((_b = result.entityCustomTrackingInfo) === null || _b === void 0 ? void 0 : _b.memberDistance) === "OUT_OF_NETWORK") {
163
+ continue;
164
+ }
165
+ const urnId = (0, utils_1.getIdFromUrn)((0, utils_1.getUrnFromRawUpdate)(result.entityUrn));
166
+ (0, utils_1.assert)(urnId);
167
+ const name = (_c = result.title) === null || _c === void 0 ? void 0 : _c.text;
168
+ (0, utils_1.assert)(name);
169
+ const url = (_d = result.navigationUrl) === null || _d === void 0 ? void 0 : _d.split("?")[0];
170
+ (0, utils_1.assert)(url);
171
+ response.results.push({
172
+ urnId,
173
+ name,
174
+ url,
175
+ distance: (_e = result.entityCustomTrackingInfo) === null || _e === void 0 ? void 0 : _e.memberDistance,
176
+ headline: (_f = result.primarySubtitle) === null || _f === void 0 ? void 0 : _f.text,
177
+ location: (_g = result.secondarySubtitle) === null || _g === void 0 ? void 0 : _g.text,
178
+ summary: ((_h = result.summary) === null || _h === void 0 ? void 0 : _h.text) || undefined,
179
+ image: ((_r = (_q = (_p = (_o = (_m = (_l = (_k = (_j = result.image) === null || _j === void 0 ? void 0 : _j.attributes) === null || _k === void 0 ? void 0 : _k[0]) === null || _l === void 0 ? void 0 : _l.detailData) === null || _m === void 0 ? void 0 : _m.nonEntityProfilePicture) === null || _o === void 0 ? void 0 : _o.vectorImage) === null || _p === void 0 ? void 0 : _p.artifacts) === null || _q === void 0 ? void 0 : _q[0]) === null || _r === void 0 ? void 0 : _r.fileIdentifyingUrlPathSegment) || null,
180
+ });
181
+ }
182
+ return response;
183
+ });
184
+ }
package/lib/teste.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
package/lib/teste.js ADDED
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const config_1 = require("./config");
4
+ const user_1 = require("./user");
5
+ (0, config_1.Client)({
6
+ JSESSIONID: "2687703175806319775",
7
+ li_at: "AQEDARgQ7uMA1d5dAAABmm_VFQcAAAGcT-gumU0Agr-WPhYEN-QPXcfx84Ct0mtL2WQqj9YrWiAR2onQlCPyIa9RWXygwj3JKVSY1elRE6DjH4y6nEE5I3NhxBpswfzbRBCIgKUYmKWeEblF1t9VeGDl",
8
+ });
9
+ (0, user_1.getUserMiniProfile)("wesbush")
10
+ .then((profile) => {
11
+ console.log("profile: ", profile);
12
+ })
13
+ .catch((error) => {
14
+ console.log("error: ", error);
15
+ });