From 986da39ca23a8110bc1987082fc2378a2d430c28 Mon Sep 17 00:00:00 2001 From: Joshua Tzucker Date: Sat, 19 Dec 2020 08:11:18 -0800 Subject: [PATCH] Bugfix, Release v2.1.1: Work position order (#38) - Fixes #38 - New Dash endpoint does *not* return work positions in correct order, so methods that were looking up elements by type instead of accessing via Table-of-Contents (which preserves order in arrays), were getting entities back in the correct order (was actually completely reversed for some endpoints!) - Fix is to switch to always looking up entities by ToC, for both API response types, to make sure work position order is always preserved - This affects both regular JSON Resume and vCard export, although I believe the issue filed was in reference to vCard specifically --- README.md | 11 +++++++++++ package-lock.json | 2 +- package.json | 2 +- src/main.js | 10 ++++++---- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index fd09204..316e8f8 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,7 @@ When in doubt, refresh the profile page before using this tool. ## Updates: Date | Release | Notes --- | --- | --- +12/19/2020 | 2.1.1 | Fix: Ordering of work history with new API endpoint ([#38](https://github.com/joshuatz/linkedin-to-jsonresume/issues/38)) 12/7/2020 | 2.1.0 | Fix: Issue with multilingual profile, when exporting your own profile with a different locale than your profile's default. ([#37](https://github.com/joshuatz/linkedin-to-jsonresume/pull/37)) 11/12/2020 | 2.0.0 | Support for multiple schema versions ✨ ([#34](https://github.com/joshuatz/linkedin-to-jsonresume/pull/34)) 11/8/2020 | 1.5.1 | Fix: Omit partial BDAY export in vCard ([#32](https://github.com/joshuatz/linkedin-to-jsonresume/issues/32)) @@ -136,6 +137,16 @@ li2jr.parseAndShowOutput(); If you do want to find the actual injected code of the extension in Chrome dev tools, you should be able to find it under `Sources -> Content Scripts -> top -> JSON Resume Exporter -> {main.js}` +#### Debugging Snippets +Helpful snippets (subject to change; these rely heavily on internals): + +```js +// Get main profileDB (after running extension) +var profileRes = await li2JrInstance.getParsedProfile(); +var profileDb = await li2JrInstance.internals.buildDbFromLiSchema(profileRes.liResponse); + +``` + --- ## DISCLAIMER: diff --git a/package-lock.json b/package-lock.json index c443c88..3156292 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "linkedin-to-json-resume-exporter", - "version": "2.1.0", + "version": "2.1.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 5bab75e..9f20b7b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "linkedin-to-json-resume-exporter", - "version": "2.1.0", + "version": "2.1.1", "description": "Browser tool to grab details from your open LinkedIn profile page and export to JSON Resume Schema", "private": true, "main": "src/main.js", diff --git a/src/main.js b/src/main.js index 9ffbaa8..77dd116 100644 --- a/src/main.js +++ b/src/main.js @@ -114,7 +114,8 @@ window.LinkedinToResumeJson = (() => { }); }; /** - * Get all elements that match type. Should usually just be one + * Get all elements that match type. + * WARNING: Since this gets elements directly by simply iterating through all results, not via ToC, order of entities returned is simply whatever order LI provides them in the response. Not guaranteed to be in order! Use a ToC approach if you need ordered results. * @param {string | string[]} typeStr - Type, e.g. `$com.linkedin...` * @returns {LiEntity[]} */ @@ -368,7 +369,8 @@ window.LinkedinToResumeJson = (() => { } // To make this easier to work with lookup, we'll unpack the // profile view nested object BACK into the root (ToC), so - // that lookups can be performed by key instead of type | recipe + // that subsequent lookups can be performed by key instead of type | recipe + // This is critical for lookups that require precise ordering, preserved by ToCs /** @type {LiResponse} */ const hoistedRes = { data: { @@ -504,7 +506,7 @@ window.LinkedinToResumeJson = (() => { allWorkCanBeCaptured = paging.start + paging.count >= paging.total; } if (allWorkCanBeCaptured) { - const workPositions = db.getElementsByType(_liTypeMappings.workPositions.types); + const workPositions = db.getValuesByKey(_liTypeMappings.workPositions.tocKeys); workPositions.forEach((position) => { parseAndPushPosition(position, db); }); @@ -1573,7 +1575,7 @@ window.LinkedinToResumeJson = (() => { } } // Try to get currently employed organization - const positions = profileDb.getElementsByType(_liTypeMappings.workPositions.types); + const positions = profileDb.getValuesByKey(_liTypeMappings.workPositions.tocKeys); if (positions.length) { vCard.organization = positions[0].companyName; vCard.title = positions[0].title;