-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Components - gem #15763
Open
luancazarine
wants to merge
6
commits into
master
Choose a base branch
from
issue-15752
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
New Components - gem #15763
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ceca95f
gem init
luancazarine d9002fb
[Components] gem #15752
luancazarine 4c59ee9
pnpm update
luancazarine c46e779
pnpm update
luancazarine 0a024a5
Merge branch 'master' into issue-15752
luancazarine f64ac07
pnpm update
luancazarine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
171 changes: 171 additions & 0 deletions
171
components/gem/actions/create-candidate/create-candidate.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,171 @@ | ||||||||||||||||||||||||||
import { SOURCED_FROM } from "../../common/constants.mjs"; | ||||||||||||||||||||||||||
import gem from "../../gem.app.mjs"; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
export default { | ||||||||||||||||||||||||||
key: "gem-create-candidate", | ||||||||||||||||||||||||||
name: "Create Candidate", | ||||||||||||||||||||||||||
description: "Creates a new candidate in Gem. [See the documentation](https://api.gem.com/v0/reference#tag/Candidates/paths/~1v0~1candidates/post)", | ||||||||||||||||||||||||||
version: "0.0.1", | ||||||||||||||||||||||||||
type: "action", | ||||||||||||||||||||||||||
props: { | ||||||||||||||||||||||||||
gem, | ||||||||||||||||||||||||||
createdBy: { | ||||||||||||||||||||||||||
propDefinition: [ | ||||||||||||||||||||||||||
gem, | ||||||||||||||||||||||||||
"createdBy", | ||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||
firstName: { | ||||||||||||||||||||||||||
type: "string", | ||||||||||||||||||||||||||
label: "First Name", | ||||||||||||||||||||||||||
description: "Candidate's first name", | ||||||||||||||||||||||||||
optional: true, | ||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||
lastName: { | ||||||||||||||||||||||||||
type: "string", | ||||||||||||||||||||||||||
label: "Last Name", | ||||||||||||||||||||||||||
description: "Candidate's last name", | ||||||||||||||||||||||||||
optional: true, | ||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||
nickname: { | ||||||||||||||||||||||||||
type: "string", | ||||||||||||||||||||||||||
label: "Nickname", | ||||||||||||||||||||||||||
description: "Candidate's nickname", | ||||||||||||||||||||||||||
optional: true, | ||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||
primaryEmail: { | ||||||||||||||||||||||||||
type: "string", | ||||||||||||||||||||||||||
label: "Primary Email Address", | ||||||||||||||||||||||||||
description: "Candidate's primary email address", | ||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||
additionalEmails: { | ||||||||||||||||||||||||||
type: "string[]", | ||||||||||||||||||||||||||
label: "Email Addresses", | ||||||||||||||||||||||||||
description: "List of candidate's additional email addresses", | ||||||||||||||||||||||||||
optional: true, | ||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||
linkedInHandle: { | ||||||||||||||||||||||||||
type: "string", | ||||||||||||||||||||||||||
label: "LinkedIn Handle", | ||||||||||||||||||||||||||
description: "If `LinkedIn Handle` is provided, candidate creation will be de-duplicated. If a candidate with the provided `LinkedIn Handle already exists, a 400 error will be returned with `errors` containing information on the existing candidate in this shape: `{\"errors\": { \"duplicate_candidate\": { \"id\": \"string\", \"linked_in_handle\": \"string\" }}}`.", | ||||||||||||||||||||||||||
optional: true, | ||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||
title: { | ||||||||||||||||||||||||||
type: "string", | ||||||||||||||||||||||||||
label: "Title", | ||||||||||||||||||||||||||
description: "Candidate's job title", | ||||||||||||||||||||||||||
optional: true, | ||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||
company: { | ||||||||||||||||||||||||||
type: "string", | ||||||||||||||||||||||||||
label: "Company", | ||||||||||||||||||||||||||
description: "Candidate's company name", | ||||||||||||||||||||||||||
optional: true, | ||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||
location: { | ||||||||||||||||||||||||||
type: "string", | ||||||||||||||||||||||||||
label: "Location", | ||||||||||||||||||||||||||
description: "Candidate's location", | ||||||||||||||||||||||||||
optional: true, | ||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||
school: { | ||||||||||||||||||||||||||
type: "string", | ||||||||||||||||||||||||||
label: "School", | ||||||||||||||||||||||||||
description: "Candidate's school", | ||||||||||||||||||||||||||
optional: true, | ||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||
educationalInfo: { | ||||||||||||||||||||||||||
type: "string[]", | ||||||||||||||||||||||||||
label: "Educational Info", | ||||||||||||||||||||||||||
description: "A list of objects containing candidate's educational information. **Format: [{\"school\": \"string\", \"parsed_university\": \"string\", \"parsed_school\": \"string\", \"start_date\": \"string\", \"end_date\": \"string\", \"field_of_study\": \"string\", \"parsed_major_1\": \"string\", \"parsed_major_2\": \"string\", \"degree\": \"string\"}]**. [See the documentation](https://api.gem.com/v0/reference#tag/Candidates/paths/~1v0~1candidates/post) for further details.", | ||||||||||||||||||||||||||
optional: true, | ||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||
workInfo: { | ||||||||||||||||||||||||||
type: "string", | ||||||||||||||||||||||||||
label: "Work Info", | ||||||||||||||||||||||||||
description: "A list of objects containing candidate's work information. **Format: [{\"company\": \"string\", \"title\": \"string\", \"work_start_date\": \"string\", \"work_end_date\": \"string\", \"is_current\": \"string\"}]**. [See the documentation](https://api.gem.com/v0/reference#tag/Candidates/paths/~1v0~1candidates/post) for further details.", | ||||||||||||||||||||||||||
optional: true, | ||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||
profileUrls: { | ||||||||||||||||||||||||||
type: "string[]", | ||||||||||||||||||||||||||
label: "Profile URLs", | ||||||||||||||||||||||||||
description: "If `Profile URLs` is provided with an array of urls, social `profiles` will be generated based on the provided urls and attached to the candidate", | ||||||||||||||||||||||||||
optional: true, | ||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||
phoneNumber: { | ||||||||||||||||||||||||||
type: "string", | ||||||||||||||||||||||||||
label: "Phone Number", | ||||||||||||||||||||||||||
description: "Candidate's phone number", | ||||||||||||||||||||||||||
optional: true, | ||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||
projectIds: { | ||||||||||||||||||||||||||
propDefinition: [ | ||||||||||||||||||||||||||
gem, | ||||||||||||||||||||||||||
"projectIds", | ||||||||||||||||||||||||||
], | ||||||||||||||||||||||||||
optional: true, | ||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||
customFields: { | ||||||||||||||||||||||||||
type: "string[]", | ||||||||||||||||||||||||||
label: "Custom Fields", | ||||||||||||||||||||||||||
description: "Array of objects containing new custom field values. Only custom fields specified in the array are updated. **Format: [{\"custom_field_id\": \"string\", \"value\": \"string\"}]**. [See the documentation](https://api.gem.com/v0/reference#tag/Candidates/paths/~1v0~1candidates/post) for further details.", | ||||||||||||||||||||||||||
optional: true, | ||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||
sourcedFrom: { | ||||||||||||||||||||||||||
type: "string", | ||||||||||||||||||||||||||
label: "Sourced From", | ||||||||||||||||||||||||||
description: "Where the candidate was sourced from", | ||||||||||||||||||||||||||
options: SOURCED_FROM, | ||||||||||||||||||||||||||
optional: true, | ||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||
autofill: { | ||||||||||||||||||||||||||
type: "boolean", | ||||||||||||||||||||||||||
label: "Autofill", | ||||||||||||||||||||||||||
description: "Requires `Linked In Handle` to be non-null. Attempts to fill in any missing fields.", | ||||||||||||||||||||||||||
optional: true, | ||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||
async run({ $ }) { | ||||||||||||||||||||||||||
const emails = [ | ||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||
email_address: this.primaryEmail, | ||||||||||||||||||||||||||
is_primary: true, | ||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||
]; | ||||||||||||||||||||||||||
if (this.additionalEmails) emails.push(...this.additionalEmails.map((email) => ({ | ||||||||||||||||||||||||||
email_address: email, | ||||||||||||||||||||||||||
is_primary: false, | ||||||||||||||||||||||||||
}))); | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
if (emails.length === 0) { | ||||||||||||||||||||||||||
throw new Error("Primary Email Address is required"); | ||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||
const candidate = await this.gem.createCandidate({ | ||||||||||||||||||||||||||
$, | ||||||||||||||||||||||||||
data: { | ||||||||||||||||||||||||||
created_by: this.createdBy, | ||||||||||||||||||||||||||
first_name: this.firstName, | ||||||||||||||||||||||||||
last_name: this.lastName, | ||||||||||||||||||||||||||
nickname: this.nickname, | ||||||||||||||||||||||||||
emails, | ||||||||||||||||||||||||||
linked_in_handle: this.linkedInHandle, | ||||||||||||||||||||||||||
title: this.title, | ||||||||||||||||||||||||||
company: this.company, | ||||||||||||||||||||||||||
location: this.location, | ||||||||||||||||||||||||||
school: this.school, | ||||||||||||||||||||||||||
educational_info: this.educationalInfo, | ||||||||||||||||||||||||||
work_info: this.workInfo, | ||||||||||||||||||||||||||
profile_urls: this.profileUrls, | ||||||||||||||||||||||||||
phone_number: this.phoneNumber, | ||||||||||||||||||||||||||
project_ids: this.projectIds, | ||||||||||||||||||||||||||
custom_fields: this.customFields, | ||||||||||||||||||||||||||
Comment on lines
+156
to
+161
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should create a utils function to parse the JSON in
Suggested change
|
||||||||||||||||||||||||||
sourced_from: this.sourcedFrom, | ||||||||||||||||||||||||||
autofill: this.autofill, | ||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||
$.export( | ||||||||||||||||||||||||||
"$summary", `Created candidate ${candidate.first_name} ${candidate.last_name} with ID: ${candidate.id}`, | ||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||
return candidate; | ||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export const LIMIT = 100; | ||
|
||
export const SOURCED_FROM = [ | ||
"SeekOut", | ||
"hireEZ", | ||
"Starcircle", | ||
"Censia", | ||
"Consider", | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,120 @@ | ||
import { axios } from "@pipedream/platform"; | ||
import { LIMIT } from "./common/constants.mjs"; | ||
|
||
export default { | ||
type: "app", | ||
app: "gem", | ||
propDefinitions: {}, | ||
propDefinitions: { | ||
createdBy: { | ||
type: "string", | ||
label: "Created By", | ||
description: "Who the candidate was created by", | ||
async options({ page }) { | ||
const data = await this.listUsers({ | ||
params: { | ||
page: page + 1, | ||
page_size: LIMIT, | ||
}, | ||
}); | ||
|
||
return data.map(({ | ||
id: value, email: label, | ||
}) => ({ | ||
label, | ||
value, | ||
})); | ||
}, | ||
}, | ||
projectIds: { | ||
type: "string[]", | ||
label: "Project Ids", | ||
description: "If `Project Ids` is provided with an array of project ids, the candidate will be added into the projects once they are created.", | ||
async options({ page }) { | ||
const data = await this.listProjects({ | ||
params: { | ||
page: page + 1, | ||
page_size: LIMIT, | ||
}, | ||
}); | ||
|
||
return data.map(({ | ||
id: value, name: label, | ||
}) => ({ | ||
label, | ||
value, | ||
})); | ||
}, | ||
}, | ||
}, | ||
methods: { | ||
// this.$auth contains connected account data | ||
authKeys() { | ||
console.log(Object.keys(this.$auth)); | ||
_baseUrl() { | ||
return "https://api.gem.com/v0"; | ||
}, | ||
_headers() { | ||
return { | ||
"x-api-key": `${this.$auth.api_key}`, | ||
"content-type": "application/json", | ||
}; | ||
}, | ||
_makeRequest({ | ||
$ = this, path, ...opts | ||
}) { | ||
return axios($, { | ||
url: this._baseUrl() + path, | ||
headers: this._headers(), | ||
...opts, | ||
}); | ||
}, | ||
listCandidates(opts = {}) { | ||
return this._makeRequest({ | ||
path: "/candidates", | ||
...opts, | ||
}); | ||
}, | ||
listProjects(opts = {}) { | ||
return this._makeRequest({ | ||
path: "/projects", | ||
...opts, | ||
}); | ||
}, | ||
listUsers(opts = {}) { | ||
return this._makeRequest({ | ||
path: "/users", | ||
...opts, | ||
}); | ||
}, | ||
createCandidate(opts = {}) { | ||
return this._makeRequest({ | ||
method: "POST", | ||
path: "/candidates", | ||
...opts, | ||
}); | ||
}, | ||
async *paginate({ | ||
fn, params = {}, maxResults = null, ...opts | ||
}) { | ||
let hasMore = false; | ||
let count = 0; | ||
let page = 0; | ||
|
||
do { | ||
params.page = ++page; | ||
params.page_size = LIMIT; | ||
const data = await fn({ | ||
params, | ||
...opts, | ||
}); | ||
for (const d of data) { | ||
yield d; | ||
|
||
if (maxResults && ++count === maxResults) { | ||
return count; | ||
} | ||
} | ||
|
||
hasMore = data.length === LIMIT; | ||
|
||
} while (hasMore); | ||
}, | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@pipedream/gem", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Pipedream Gem Components", | ||
"main": "gem.app.mjs", | ||
"keywords": [ | ||
|
@@ -11,5 +11,8 @@ | |
"author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@pipedream/platform": "^3.0.3" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; | ||
import gem from "../../gem.app.mjs"; | ||
import sampleEmit from "./test-event.mjs"; | ||
|
||
export default { | ||
key: "gem-new-candidate", | ||
name: "New Candidate Added", | ||
description: "Emit new event when a candidate is added in Gem. [See the documentation](https://api.gem.com/v0/reference#tag/Candidates/paths/~1v0~1candidates/get)", | ||
version: "0.0.1", | ||
type: "source", | ||
dedupe: "unique", | ||
props: { | ||
gem, | ||
db: "$.service.db", | ||
timer: { | ||
type: "$.interface.timer", | ||
default: { | ||
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, | ||
}, | ||
}, | ||
}, | ||
methods: { | ||
_getLastDate() { | ||
return this.db.get("lastDate") || 1; | ||
}, | ||
_setLastDate(lastDate) { | ||
this.db.set("lastDate", lastDate); | ||
}, | ||
async emitEvent(maxResults = false) { | ||
const lastDate = this._getLastDate(); | ||
|
||
const response = this.gem.paginate({ | ||
fn: this.gem.listCandidates, | ||
params: { | ||
created_after: lastDate, | ||
}, | ||
}); | ||
|
||
let responseArray = []; | ||
for await (const item of response) { | ||
responseArray.push(item); | ||
} | ||
|
||
if (responseArray.length) { | ||
if (maxResults && (responseArray.length > maxResults)) { | ||
responseArray.length = maxResults; | ||
} | ||
this._setLastDate(responseArray[0].created_at); | ||
} | ||
|
||
for (const item of responseArray.reverse()) { | ||
this.$emit(item, { | ||
id: item.id, | ||
summary: `New Candidate with ID: ${item.id}`, | ||
ts: item.created_at, | ||
}); | ||
} | ||
}, | ||
}, | ||
hooks: { | ||
async deploy() { | ||
await this.emitEvent(25); | ||
}, | ||
}, | ||
async run() { | ||
await this.emitEvent(); | ||
}, | ||
sampleEmit, | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The description says
workInfo
is a list of objects. Should the type bestring[]
?