linkedin-private-api-v2
Advanced tools
Comparing version
@@ -17,2 +17,19 @@ export declare type CelebrationId = string; | ||
} | ||
interface CelebrationConfirmationActionAttribute { | ||
text: string; | ||
type: 'SUCCESS'; | ||
$type: 'com.linkedin.voyager.dash.common.ux.InlineFeedbackViewModel'; | ||
} | ||
interface CelebrationMessageActionAttribute { | ||
prefilledMessage: string; | ||
$type: 'com.linkedin.voyager.dash.props.actions.MessageAction'; | ||
} | ||
interface CelebrationActionAttribute { | ||
$recipeTypes: string[]; | ||
$type: 'com.linkedin.voyager.dash.props.PropActionAttribute'; | ||
action: { | ||
confirmationAction: CelebrationConfirmationActionAttribute | null; | ||
messageAction: CelebrationMessageActionAttribute | null; | ||
}; | ||
} | ||
export interface Celebration { | ||
@@ -26,3 +43,8 @@ objectUrn: string; | ||
}; | ||
actions: CelebrationActionAttribute[]; | ||
publishedAt: number; | ||
subHeadline: { | ||
text: string; | ||
}; | ||
} | ||
export {}; |
@@ -33,1 +33,2 @@ export * from './company-search-hit.entity'; | ||
export * from './celebration.entity'; | ||
export * from './celebration-hit.entity'; |
@@ -49,2 +49,3 @@ "use strict"; | ||
__exportStar(require("./celebration.entity"), exports); | ||
__exportStar(require("./celebration-hit.entity"), exports); | ||
//# sourceMappingURL=index.js.map |
import { CelebrationEnum } from '../entities'; | ||
import { Client } from '../core/client'; | ||
import { CelebrationScroller } from '../scrollers'; | ||
export declare class CelebrationsRepository { | ||
@@ -8,10 +9,8 @@ private client; | ||
}); | ||
getCelebrations(type: CelebrationEnum, { skip, limit, }?: { | ||
getCelebrations({ type, skip, limit, }: { | ||
type: CelebrationEnum; | ||
skip?: number; | ||
limit?: number; | ||
}): Promise<{ | ||
publicIdentifier: string; | ||
profileId: string; | ||
}[]>; | ||
}): CelebrationScroller; | ||
private fetchCelebrations; | ||
} |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CelebrationsRepository = void 0; | ||
const lodash_1 = __importDefault(require("lodash")); | ||
const entities_1 = require("../entities"); | ||
const lodash_1 = __importStar(require("lodash")); | ||
const scrollers_1 = require("../scrollers"); | ||
const transformToProfileIdentifier = (actionTarget) => decodeURI(actionTarget.replace('/in/', '')); | ||
const transformToProfileId = (profilePicture) => profilePicture.replace('run:li:fsd_profile:', ''); | ||
const transformToProfileId = (profilePicture) => profilePicture.replace('urn:li:fsd_profile:', ''); | ||
class CelebrationsRepository { | ||
@@ -14,6 +36,11 @@ constructor({ client }) { | ||
} | ||
getCelebrations(type, { skip = 0, limit = 10, } = {}) { | ||
return this.fetchCelebrations(type, { limit, skip }); | ||
getCelebrations({ type = entities_1.CelebrationEnum.WORK_ANNIVERSARY, skip = 0, limit = 10, }) { | ||
return new scrollers_1.CelebrationScroller({ | ||
type, | ||
skip, | ||
limit, | ||
fetchCelebration: this.fetchCelebrations.bind(this), | ||
}); | ||
} | ||
async fetchCelebrations(type, { skip = 0, limit = 10, } = {}) { | ||
async fetchCelebrations({ type = entities_1.CelebrationEnum.WORK_ANNIVERSARY, skip = 0, limit = 10, }) { | ||
const response = await this.client.request.celebrations.getCelebrations(type, { | ||
@@ -24,14 +51,17 @@ skip, | ||
const profileIdentities = response.included.filter(item => lodash_1.default.get(item, '$type') === 'com.linkedin.voyager.dash.identity.profile.Profile'); | ||
console.log(profileIdentities); | ||
const birthdayIdentities = response.included.filter(item => lodash_1.default.get(item, '$type') === 'com.linkedin.voyager.dash.props.PropCard'); | ||
const profileUserIds = birthdayIdentities | ||
.filter(item => profileIdentities.some(id => id.entityUrn === item.headerImage.attributes[0].detailData['*profilePicture'])) | ||
.filter(item => !item.actions.some(action => { var _a; return (_a = action === null || action === void 0 ? void 0 : action.action) === null || _a === void 0 ? void 0 : _a.confirmationAction; })) | ||
.map(item => { | ||
var _a, _b; | ||
var _a, _b, _c, _d, _e, _f; | ||
return ({ | ||
publishedAt: item === null || item === void 0 ? void 0 : item.publishedAt, | ||
textDate: (_a = item === null || item === void 0 ? void 0 : item.subHeadline) === null || _a === void 0 ? void 0 : _a.text, | ||
predefinedMessage: (_d = (_c = (_b = item.actions.find(action => { var _a, _b; return (_b = (_a = action === null || action === void 0 ? void 0 : action.action) === null || _a === void 0 ? void 0 : _a.messageAction) === null || _b === void 0 ? void 0 : _b.prefilledMessage; })) === null || _b === void 0 ? void 0 : _b.action) === null || _c === void 0 ? void 0 : _c.messageAction) === null || _d === void 0 ? void 0 : _d.prefilledMessage, | ||
publicIdentifier: transformToProfileIdentifier(item.headerImage.actionTarget), | ||
profileId: transformToProfileId((_b = (_a = item.headerImage.attributes.find(attribute => attribute.$type === 'com.linkedin.voyager.dash.common.image.ImageAttribute')) === null || _a === void 0 ? void 0 : _a.detailData['*profilePicture']) !== null && _b !== void 0 ? _b : ''), | ||
profileId: transformToProfileId((_f = (_e = item.headerImage.attributes.find(attribute => attribute.$type === 'com.linkedin.voyager.dash.common.image.ImageAttribute')) === null || _e === void 0 ? void 0 : _e.detailData['*profilePicture']) !== null && _f !== void 0 ? _f : ''), | ||
}); | ||
}); | ||
return profileUserIds; | ||
return (0, lodash_1.orderBy)(profileUserIds, 'publishedAt', 'desc'); | ||
} | ||
@@ -38,0 +68,0 @@ } |
@@ -6,1 +6,2 @@ export * from './conversation.scroller'; | ||
export * from './job-search.scroller'; | ||
export * from './celebration.scroller'; |
@@ -22,2 +22,3 @@ "use strict"; | ||
__exportStar(require("./job-search.scroller"), exports); | ||
__exportStar(require("./celebration.scroller"), exports); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "linkedin-private-api-v2", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
257790
2.71%304
2.01%3668
2.86%