- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.5k
[Components] homerun #15500
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
[Components] homerun #15500
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import app from "../../homerun.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "homerun-add-candidate-note", | ||
| name: "Add Candidate Note", | ||
| description: "Adds a note to a candidate's profile in Homerun. [See the documentation](https://developers.homerun.co/#tag/Job-Application-Notes/operation/job-applications.job-application-id.notes.post).", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| jobApplicationId: { | ||
| propDefinition: [ | ||
| app, | ||
| "jobApplicationId", | ||
| ], | ||
| }, | ||
| note: { | ||
| type: "string", | ||
| label: "Note Content", | ||
| description: "The content of the note to add.", | ||
| }, | ||
| displayName: { | ||
| type: "string", | ||
| label: "Display Name", | ||
| description: "Name of the note's author.", | ||
| }, | ||
| }, | ||
| methods: { | ||
| addCandidateNote({ | ||
| jobApplicationId, ...args | ||
| } = {}) { | ||
| return this.app.post({ | ||
| path: `/job-applications/${jobApplicationId}/notes`, | ||
| ...args, | ||
| }); | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| addCandidateNote, | ||
| jobApplicationId, | ||
| note, | ||
| displayName, | ||
| } = this; | ||
|  | ||
| const response = await addCandidateNote({ | ||
| $, | ||
| jobApplicationId, | ||
| data: { | ||
| note, | ||
| display_name: displayName, | ||
| }, | ||
| }); | ||
|  | ||
| $.export("$summary", "Successfully added a note."); | ||
| return response; | ||
| }, | ||
| }; | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,144 @@ | ||
| import app from "../../homerun.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "homerun-create-job-application", | ||
| name: "Create Job Application", | ||
| description: "Creates a new job application. [See the documentation](https://developers.homerun.co/#tag/Job-Applications/operation/job-applications.post).", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| firstName: { | ||
| type: "string", | ||
| label: "First Name", | ||
| description: "The first name of the applicant. Make sure you don't include numbers or special characters.", | ||
| }, | ||
| lastName: { | ||
| type: "string", | ||
| label: "Last Name", | ||
| description: "The last name of the applicant. Make sure you don't include numbers or special characters.", | ||
| }, | ||
| email: { | ||
| type: "string", | ||
| label: "Email", | ||
| description: "The email of the applicant.", | ||
| }, | ||
| dateOfBirth: { | ||
| type: "string", | ||
| label: "Date of Birth", | ||
| description: "The date of birth of the applicant in the format of `YYYY-MM-DD`.", | ||
| optional: true, | ||
| }, | ||
| vacancyId: { | ||
| optional: true, | ||
| propDefinition: [ | ||
| app, | ||
| "vacancyId", | ||
| ], | ||
| }, | ||
| phoneNumber: { | ||
| type: "string", | ||
| label: "Phone Number", | ||
| description: "The phone number of the applicant.", | ||
| optional: true, | ||
| }, | ||
| photo: { | ||
| type: "string", | ||
| label: "Photo", | ||
| description: "The URL of the applicant's photo.", | ||
| optional: true, | ||
| }, | ||
| experience: { | ||
| type: "string", | ||
| label: "Experience", | ||
| description: "The experience of the applicant.", | ||
| optional: true, | ||
| }, | ||
| education: { | ||
| type: "string", | ||
| label: "Education", | ||
| description: "The education of the applicant.", | ||
| optional: true, | ||
| }, | ||
| facebook: { | ||
| type: "string", | ||
| label: "Facebook", | ||
| description: "The Facebook URL of the applicant. eg. `https://facebook.com/username`", | ||
| optional: true, | ||
| }, | ||
| twitter: { | ||
| type: "string", | ||
| label: "X", | ||
| description: "The X URL of the applicant. eg. `https://x.com/username`", | ||
| optional: true, | ||
| }, | ||
| linkedin: { | ||
| type: "string", | ||
| label: "LinkedIn", | ||
| description: "The LinkedIn URL of the applicant. eg. `https://linkedin.com/in/username`", | ||
| optional: true, | ||
| }, | ||
| github: { | ||
| type: "string", | ||
| label: "GitHub", | ||
| description: "The GitHub URL of the applicant. eg. `https://github.com/username`", | ||
| optional: true, | ||
| }, | ||
| website: { | ||
| type: "string", | ||
| label: "Website", | ||
| description: "The website URL of the applicant. eg. `https://username.com`", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| methods: { | ||
| createJobApplication(args = {}) { | ||
| return this.app.post({ | ||
| path: "/job-applications", | ||
| ...args, | ||
| }); | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| createJobApplication, | ||
| firstName, | ||
| lastName, | ||
| email, | ||
| dateOfBirth, | ||
| vacancyId, | ||
| phoneNumber, | ||
| photo, | ||
| experience, | ||
| education, | ||
| facebook, | ||
| twitter, | ||
| linkedin, | ||
| github, | ||
| website, | ||
| } = this; | ||
|  | ||
| const response = await createJobApplication({ | ||
| $, | ||
| data: { | ||
| vacancyId, | ||
| first_name: firstName, | ||
| last_name: lastName, | ||
| email, | ||
| date_of_birth: dateOfBirth, | ||
| phone_number: phoneNumber, | ||
| photo, | ||
| experience, | ||
| education, | ||
| facebook, | ||
| twitter, | ||
| linkedin, | ||
| github, | ||
| website, | ||
| }, | ||
| }); | ||
|  | ||
| $.export("$summary", "Successfully created a job application."); | ||
| return response; | ||
| }, | ||
| }; | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| const BASE_URL = "https://api.homerun.co"; | ||
| const VERSION_PATH = "/v2"; | ||
| const DEFAULT_LIMIT = 100; | ||
| const DEFAULT_MAX = 1000; | ||
|  | ||
| const LAST_DATE_AT = "lastDateAt"; | ||
|  | ||
| export default { | ||
| BASE_URL, | ||
| VERSION_PATH, | ||
| DEFAULT_LIMIT, | ||
| DEFAULT_MAX, | ||
| LAST_DATE_AT, | ||
| }; | 
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| async function iterate(iterations) { | ||
| const items = []; | ||
| for await (const item of iterations) { | ||
| items.push(item); | ||
| } | ||
| return items; | ||
| } | ||
|  | ||
| function getNestedProperty(obj, propertyString) { | ||
| const properties = propertyString.split("."); | ||
| return properties.reduce((prev, curr) => prev?.[curr], obj); | ||
| } | ||
|  | ||
| export default { | ||
| iterate, | ||
| getNestedProperty, | ||
| }; | 
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,11 +1,143 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||
| import { axios } from "@pipedream/platform"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| import constants from "./common/constants.mjs"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| import utils from "./common/utils.mjs"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||||||||||||||||||||
| export default { | ||||||||||||||||||||||||||||||||||||||||||||||||
| type: "app", | ||||||||||||||||||||||||||||||||||||||||||||||||
| app: "homerun", | ||||||||||||||||||||||||||||||||||||||||||||||||
| propDefinitions: {}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| propDefinitions: { | ||||||||||||||||||||||||||||||||||||||||||||||||
| vacancyId: { | ||||||||||||||||||||||||||||||||||||||||||||||||
| type: "string", | ||||||||||||||||||||||||||||||||||||||||||||||||
| label: "Vacancy ID", | ||||||||||||||||||||||||||||||||||||||||||||||||
| description: "The ID of the vacancy.", | ||||||||||||||||||||||||||||||||||||||||||||||||
| async options({ page }) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| const { data } = await this.listVacancies({ | ||||||||||||||||||||||||||||||||||||||||||||||||
| params: { | ||||||||||||||||||||||||||||||||||||||||||||||||
| page: page + 1, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||
| return data.map(({ | ||||||||||||||||||||||||||||||||||||||||||||||||
| id: value, | ||||||||||||||||||||||||||||||||||||||||||||||||
| title: label, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }) => ({ | ||||||||||||||||||||||||||||||||||||||||||||||||
| label, | ||||||||||||||||||||||||||||||||||||||||||||||||
| value, | ||||||||||||||||||||||||||||||||||||||||||||||||
| })); | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| jobApplicationId: { | ||||||||||||||||||||||||||||||||||||||||||||||||
| type: "string", | ||||||||||||||||||||||||||||||||||||||||||||||||
| label: "Job Application ID", | ||||||||||||||||||||||||||||||||||||||||||||||||
| description: "The ID of the job application.", | ||||||||||||||||||||||||||||||||||||||||||||||||
| async options({ page }) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| const { data } = await this.listJobApplications({ | ||||||||||||||||||||||||||||||||||||||||||||||||
| params: { | ||||||||||||||||||||||||||||||||||||||||||||||||
| page: page + 1, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||
| return data.map(({ | ||||||||||||||||||||||||||||||||||||||||||||||||
| id: value, | ||||||||||||||||||||||||||||||||||||||||||||||||
| personal_info: { | ||||||||||||||||||||||||||||||||||||||||||||||||
| first_name: firstName, | ||||||||||||||||||||||||||||||||||||||||||||||||
| last_name: lastName, | ||||||||||||||||||||||||||||||||||||||||||||||||
| email, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }) => ({ | ||||||||||||||||||||||||||||||||||||||||||||||||
| label: `${firstName} ${lastName} (${email})`, | ||||||||||||||||||||||||||||||||||||||||||||||||
| value, | ||||||||||||||||||||||||||||||||||||||||||||||||
| })); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 
      Comment on lines
    
      +38
     to 
      +48
    
   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. Remove email from the job application label to protect PII. The label construction exposes personal information (email) in the UI. Consider removing the email to protect candidate privacy. -          label: `${firstName} ${lastName} (${email})`,
+          label: `${firstName} ${lastName}`,📝 Committable suggestion
 
        Suggested change
       
 | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| methods: { | ||||||||||||||||||||||||||||||||||||||||||||||||
| // this.$auth contains connected account data | ||||||||||||||||||||||||||||||||||||||||||||||||
| authKeys() { | ||||||||||||||||||||||||||||||||||||||||||||||||
| console.log(Object.keys(this.$auth)); | ||||||||||||||||||||||||||||||||||||||||||||||||
| getUrl(path) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return `${constants.BASE_URL}${constants.VERSION_PATH}${path}`; | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| getHeaders(headers) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return { | ||||||||||||||||||||||||||||||||||||||||||||||||
| Authorization: `Bearer ${this.$auth.api_key}`, | ||||||||||||||||||||||||||||||||||||||||||||||||
| ...headers, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| _makeRequest({ | ||||||||||||||||||||||||||||||||||||||||||||||||
| $ = this, path, headers, ...args | ||||||||||||||||||||||||||||||||||||||||||||||||
| } = {}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return axios($, { | ||||||||||||||||||||||||||||||||||||||||||||||||
| ...args, | ||||||||||||||||||||||||||||||||||||||||||||||||
| url: this.getUrl(path), | ||||||||||||||||||||||||||||||||||||||||||||||||
| headers: this.getHeaders(headers), | ||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||
|         
                  jcortes marked this conversation as resolved.
              Show resolved
            Hide resolved | ||||||||||||||||||||||||||||||||||||||||||||||||
| post(args = {}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return this._makeRequest({ | ||||||||||||||||||||||||||||||||||||||||||||||||
| method: "POST", | ||||||||||||||||||||||||||||||||||||||||||||||||
| ...args, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| listVacancies(args = {}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return this._makeRequest({ | ||||||||||||||||||||||||||||||||||||||||||||||||
| path: "/vacancies", | ||||||||||||||||||||||||||||||||||||||||||||||||
| ...args, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| listJobApplications(args = {}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return this._makeRequest({ | ||||||||||||||||||||||||||||||||||||||||||||||||
| path: "/job-applications", | ||||||||||||||||||||||||||||||||||||||||||||||||
| ...args, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| async *getIterations({ | ||||||||||||||||||||||||||||||||||||||||||||||||
| resourcesFn, resourcesFnArgs, resourceName, | ||||||||||||||||||||||||||||||||||||||||||||||||
| lastDateAt, dateField, | ||||||||||||||||||||||||||||||||||||||||||||||||
| max = constants.DEFAULT_MAX, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| let page = 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
| let resourcesCount = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||||||||||||||||||||
| while (true) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| const response = | ||||||||||||||||||||||||||||||||||||||||||||||||
| await resourcesFn({ | ||||||||||||||||||||||||||||||||||||||||||||||||
| ...resourcesFnArgs, | ||||||||||||||||||||||||||||||||||||||||||||||||
| params: { | ||||||||||||||||||||||||||||||||||||||||||||||||
| ...resourcesFnArgs?.params, | ||||||||||||||||||||||||||||||||||||||||||||||||
| page, | ||||||||||||||||||||||||||||||||||||||||||||||||
| perPage: constants.DEFAULT_LIMIT, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||||||||||||||||||||
| const nextResources = utils.getNestedProperty(response, resourceName); | ||||||||||||||||||||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||||||||||||||||||||
| if (!nextResources?.length) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| console.log("No more resources found"); | ||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||||||||||||||||||||
| for (const resource of nextResources) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| const isDateGreaterThanLasDate = | ||||||||||||||||||||||||||||||||||||||||||||||||
| lastDateAt | ||||||||||||||||||||||||||||||||||||||||||||||||
| && Date.parse(resource[dateField]) > Date.parse(lastDateAt); | ||||||||||||||||||||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||||||||||||||||||||
| if (!lastDateAt || isDateGreaterThanLasDate) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| yield resource; | ||||||||||||||||||||||||||||||||||||||||||||||||
| resourcesCount += 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||||||||||||||||||||
| if (resourcesCount >= max) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| console.log("Reached max resources"); | ||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||||||||||||||||||||
| if (nextResources.length < constants.DEFAULT_LIMIT) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| console.log("No next page found"); | ||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||||||||||||||||||||
| page += 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| paginate(args = {}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return utils.iterate(this.getIterations(args)); | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||
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.
🛠️ Refactor suggestion
Add error handling to options methods.
Both
vacancyIdandjobApplicationIdoptions methods should handle API errors gracefully to prevent UI disruption.async options({ page }) { + try { const { data } = await this.listVacancies({ params: { page: page + 1, }, }); return data.map(({ id: value, title: label, }) => ({ label, value, })); + } catch (error) { + console.error('Failed to fetch vacancies:', error); + return []; + } },Also applies to: 32-49