diff --git a/components/taleez/actions/add-candidate-to-job/add-candidate-to-job.mjs b/components/taleez/actions/add-candidate-to-job/add-candidate-to-job.mjs new file mode 100644 index 0000000000000..26acaba9a6892 --- /dev/null +++ b/components/taleez/actions/add-candidate-to-job/add-candidate-to-job.mjs @@ -0,0 +1,37 @@ +import taleez from "../../taleez.app.mjs"; + +export default { + key: "taleez-add-candidate-to-job", + name: "Add Candidate to Job", + description: "Links an existing candidate to a job offer. [See the documentation](https://api.taleez.com/swagger-ui/index.html#/jobs/addCandidate_1)", + version: "0.0.1", + type: "action", + props: { + taleez, + candidateId: { + propDefinition: [ + taleez, + "candidateId", + ], + }, + jobId: { + propDefinition: [ + taleez, + "jobId", + ], + }, + }, + async run({ $ }) { + const response = await this.taleez.linkCandidateToJob({ + $, + jobId: this.jobId, + data: { + ids: [ + this.candidateId, + ], + }, + }); + $.export("$summary", `Linked candidate ${this.candidateId} to job ${this.jobId} successfully`); + return response; + }, +}; diff --git a/components/taleez/actions/create-candidate/create-candidate.mjs b/components/taleez/actions/create-candidate/create-candidate.mjs new file mode 100644 index 0000000000000..3ba20b075a2cd --- /dev/null +++ b/components/taleez/actions/create-candidate/create-candidate.mjs @@ -0,0 +1,60 @@ +import taleez from "../../taleez.app.mjs"; + +export default { + key: "taleez-create-candidate", + name: "Create Candidate", + description: "Creates a new candidate in Taleez. [See the documentation](https://api.taleez.com/swagger-ui/index.html#/candidates/create_1)", + version: "0.0.1", + type: "action", + props: { + taleez, + firstName: { + type: "string", + label: "First Name", + description: "First name of the candidate", + }, + lastName: { + type: "string", + label: "Last Name", + description: "Last name of the candidate", + }, + email: { + type: "string", + label: "Email", + description: "Candidate email address. Must be unique in your company", + }, + phone: { + type: "string", + label: "Phone", + description: "Candidate phone (formats : 0611223344, +33611223344, 00336112233). Ignored if not valid.", + optional: true, + }, + unitId: { + propDefinition: [ + taleez, + "unitId", + ], + }, + recruiterId: { + propDefinition: [ + taleez, + "recruiterId", + ], + }, + }, + async run({ $ }) { + const response = await this.taleez.createCandidate({ + $, + data: { + firstName: this.firstName, + lastName: this.lastName, + mail: this.email, + phone: this.phone, + unitId: this.unitId, + recruiterId: this.recruiterId, + }, + }); + $.export("$summary", `Created candidate ${this.firstName} ${this.lastName} successfully`); + return response; + }, +}; diff --git a/components/taleez/actions/list-jobs/list-jobs.mjs b/components/taleez/actions/list-jobs/list-jobs.mjs new file mode 100644 index 0000000000000..5f4225d9ac017 --- /dev/null +++ b/components/taleez/actions/list-jobs/list-jobs.mjs @@ -0,0 +1,74 @@ +import taleez from "../../taleez.app.mjs"; + +export default { + key: "taleez-list-jobs", + name: "List Jobs", + description: "Retrieves a list of jobs in your company. [See the documentation](https://api.taleez.com/swagger-ui/index.html#/jobs/list_3)", + version: "0.0.1", + type: "action", + props: { + taleez, + unitId: { + propDefinition: [ + taleez, + "unitId", + ], + }, + status: { + propDefinition: [ + taleez, + "status", + ], + }, + contract: { + propDefinition: [ + taleez, + "contract", + ], + }, + city: { + propDefinition: [ + taleez, + "city", + ], + }, + companyLabel: { + propDefinition: [ + taleez, + "companyLabel", + ], + }, + tag: { + propDefinition: [ + taleez, + "tag", + ], + }, + maxResults: { + type: "integer", + label: "Max Results", + description: "The maximum number of jobs to retrieve. Default: `100`", + optional: true, + }, + }, + async run({ $ }) { + const { list: jobs } = await this.taleez.listJobs({ + $, + params: { + unitId: this.unitId, + status: this.status, + contract: this.contract, + city: this.city, + companyLabel: this.companyLabel, + tag: this.tag, + pageSize: this.maxResults, + withDetails: true, + withProps: true, + }, + }); + $.export("$summary", `Successfully retrieved ${jobs?.length} job${jobs?.length === 1 + ? "" + : "s"}`); + return jobs; + }, +}; diff --git a/components/taleez/package.json b/components/taleez/package.json index 0ff7931f6cb1d..23c7cf61d9646 100644 --- a/components/taleez/package.json +++ b/components/taleez/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/taleez", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Taleez Components", "main": "taleez.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.0.3" } -} \ No newline at end of file +} diff --git a/components/taleez/sources/common/base.mjs b/components/taleez/sources/common/base.mjs new file mode 100644 index 0000000000000..18e388b92402e --- /dev/null +++ b/components/taleez/sources/common/base.mjs @@ -0,0 +1,72 @@ +import taleez from "../../taleez.app.mjs"; +import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; + +export default { + props: { + taleez, + db: "$.service.db", + timer: { + type: "$.interface.timer", + default: { + intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, + }, + }, + }, + methods: { + _getLastTs() { + return this.db.get("lastTs") || 0; + }, + _setLastTs(lastTs) { + this.db.set("lastTs", lastTs); + }, + emitEvent(item) { + const meta = this.generateMeta(item); + this.$emit(item, meta); + }, + async processEvent(max) { + const lastTs = this._getLastTs(); + let maxTs = lastTs; + const tsField = this.getTsField(); + + const results = this.taleez.paginate({ + fn: this.getResourceFn(), + args: this.getArgs(), + max, + }); + + for await (const item of results) { + if (tsField) { + const ts = item[tsField]; + if (ts > lastTs) { + this.emitEvent(item); + maxTs = Math.max(ts, maxTs); + } + } else { + this.emitEvent(item); + } + } + + this._setLastTs(maxTs); + }, + getArgs() { + return {}; + }, + getTsField() { + return undefined; + }, + getResourceFn() { + throw new Error("getResourceFn is not implemented"); + }, + generateMeta() { + throw new Error("generateMeta is not implemented"); + }, + }, + hooks: { + async deploy() { + await this.processEvent(25); + }, + }, + async run() { + await this.processEvent(); + }, +}; diff --git a/components/taleez/sources/new-candidate-created/new-candidate-created.mjs b/components/taleez/sources/new-candidate-created/new-candidate-created.mjs new file mode 100644 index 0000000000000..37f3978ddf081 --- /dev/null +++ b/components/taleez/sources/new-candidate-created/new-candidate-created.mjs @@ -0,0 +1,34 @@ +import common from "../common/base.mjs"; + +export default { + ...common, + key: "taleez-new-candidate-created", + name: "New Candidate Created", + description: "Emit new event when a candidate is added in Taleez. [See the documentation](https://api.taleez.com/swagger-ui/index.html#/candidates/list_4)", + version: "0.0.1", + type: "source", + dedupe: "unique", + methods: { + ...common.methods, + getResourceFn() { + return this.taleez.listCandidates; + }, + getArgs() { + return { + params: { + withProps: true, + }, + }; + }, + getTsField() { + return "dateCreation"; + }, + generateMeta(candidate) { + return { + id: candidate.id, + summary: `New Candidate: ${candidate.firstName} ${candidate.lastName}`, + ts: candidate.dateCreation, + }; + }, + }, +}; diff --git a/components/taleez/sources/new-job-listed/new-job-listed.mjs b/components/taleez/sources/new-job-listed/new-job-listed.mjs new file mode 100644 index 0000000000000..22d293d974ca5 --- /dev/null +++ b/components/taleez/sources/new-job-listed/new-job-listed.mjs @@ -0,0 +1,77 @@ +import common from "../common/base.mjs"; + +export default { + ...common, + key: "taleez-new-job-listed", + name: "New Job Listing Created", + description: "Emit new event when a job listing is created in Taleez. [See the documentation](https://api.taleez.com/swagger-ui/index.html#/jobs/list_3)", + version: "0.0.1", + type: "source", + dedupe: "unique", + props: { + ...common.props, + unitId: { + propDefinition: [ + common.props.taleez, + "unitId", + ], + }, + status: { + propDefinition: [ + common.props.taleez, + "status", + ], + }, + contract: { + propDefinition: [ + common.props.taleez, + "contract", + ], + }, + city: { + propDefinition: [ + common.props.taleez, + "city", + ], + }, + companyLabel: { + propDefinition: [ + common.props.taleez, + "companyLabel", + ], + }, + tag: { + propDefinition: [ + common.props.taleez, + "tag", + ], + }, + }, + methods: { + ...common.methods, + getResourceFn() { + return this.taleez.listJobs; + }, + getArgs() { + return { + params: { + unitId: this.unitId, + status: this.status, + contract: this.contract, + city: this.city, + companyLabel: this.companyLabel, + tag: this.tag, + withDetails: true, + withProps: true, + }, + }; + }, + generateMeta(job) { + return { + id: job.id, + summary: `New Job: ${job.label}`, + ts: job.dateCreation, + }; + }, + }, +}; diff --git a/components/taleez/taleez.app.mjs b/components/taleez/taleez.app.mjs index cbeddc24988b6..d42464cd5e69b 100644 --- a/components/taleez/taleez.app.mjs +++ b/components/taleez/taleez.app.mjs @@ -1,11 +1,225 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "taleez", - propDefinitions: {}, + propDefinitions: { + jobId: { + type: "string", + label: "Job Listing ID", + description: "The ID of the job listing", + async options({ page }) { + const { list } = await this.listJobs({ + params: { + page, + }, + }); + return list?.map(({ + id: value, label, + }) => ({ + label, + value, + })); + }, + }, + candidateId: { + type: "string", + label: "Candidate ID", + description: "The ID of the candidate to link", + async options({ page }) { + const { list } = await this.listCandidates({ + params: { + page, + }, + }); + return list?.map(({ + id: value, firstName, lastName, + }) => ({ + label: `${firstName} ${lastName}`, + value, + })); + }, + }, + unitId: { + type: "string", + label: "Unit ID", + description: "Filter by unit ID", + optional: true, + async options({ page }) { + const { list } = await this.listUnits({ + params: { + page, + }, + }); + return list?.map(({ + id: value, publicName: label, + }) => ({ + label, + value, + })); + }, + }, + recruiterId: { + type: "string", + label: "Recruiter ID", + description: "The ID of the recruiter adding this candidate", + optional: true, + async options({ page }) { + const { list } = await this.listRecruiters({ + params: { + page, + }, + }); + return list?.map(({ + id: value, firstName, lastName, + }) => ({ + label: `${firstName} ${lastName}`, + value, + })); + }, + }, + status: { + type: "string", + label: "Status", + description: "Filter by job status", + options: [ + "DRAFT", + "PUBLISHED", + "DONE", + "SUSPENDED", + ], + optional: true, + }, + contract: { + type: "string", + label: "Contract", + description: "Filter by job contract", + options: [ + "CDI", + "CDD", + "INTERIM", + "FREELANCE", + "INTERNSHIP", + "APPRENTICESHIP", + "STUDENT", + "VIE", + "FRANCHISE", + "STATUTE", + "VACATAIRE", + "LIBERAL", + "CDI_CHANTIER", + "INTERMITTENT", + "SEASON", + "OTHER", + "VOLUNTEER", + "PERMANENT", + "FIXEDTERM", + ], + optional: true, + }, + city: { + type: "string", + label: "City", + description: "Filter by job city", + optional: true, + }, + companyLabel: { + type: "string", + label: "Company Label", + description: "Filter by company label", + optional: true, + }, + tag: { + type: "string", + label: "Tag", + description: "Filter by job tag", + optional: true, + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://api.taleez.com/0"; + }, + _makeRequest({ + $ = this, + path, + ...otherOpts + }) { + return axios($, { + ...otherOpts, + url: `${this._baseUrl()}${path}`, + headers: { + "x-taleez-api-secret": this.$auth.secret_key, + }, + }); + }, + listJobs(opts = {}) { + return this._makeRequest({ + path: "/jobs", + ...opts, + }); + }, + listCandidates(opts = {}) { + return this._makeRequest({ + path: "/candidates", + ...opts, + }); + }, + listUnits(opts = {}) { + return this._makeRequest({ + path: "/units", + ...opts, + }); + }, + listRecruiters(opts = {}) { + return this._makeRequest({ + path: "/recruiters", + ...opts, + }); + }, + createCandidate(opts = {}) { + return this._makeRequest({ + method: "POST", + path: "/candidates", + ...opts, + }); + }, + linkCandidateToJob({ + jobId, ...opts + }) { + return this._makeRequest({ + method: "POST", + path: `/jobs/${jobId}/candidates`, + ...opts, + }); + }, + async *paginate({ + fn, args = {}, max, + }) { + let hasMorePages = true; + let page = 0; + let count = 0; + + while (hasMorePages) { + const { + list, hasMore, + } = await fn({ + ...args, + params: { + ...args?.params, + page, + pageSize: 1000, + }, + }); + for (const item of list) { + yield item; + if (max && ++count >= max) { + return; + } + } + hasMorePages = hasMore; + page++; + } }, }, }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 16f3248d4750f..489738a44fe1e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -94,8 +94,8 @@ importers: specifier: ^12.3.4 version: 12.5.0(enquirer@2.4.1) pnpm: - specifier: 9.14.3 - version: 9.14.3 + specifier: 9.14.2 + version: 9.14.2 putout: specifier: '>=36' version: 36.13.1(eslint@8.57.1)(typescript@5.6.3) @@ -8669,8 +8669,7 @@ importers: specifier: ^1.5.1 version: 1.6.6 - components/richpanel: - specifiers: {} + components/richpanel: {} components/ringcentral: dependencies: @@ -10239,7 +10238,11 @@ importers: components/taggun: {} - components/taleez: {} + components/taleez: + dependencies: + '@pipedream/platform': + specifier: ^3.0.3 + version: 3.0.3 components/talend: {} @@ -23115,8 +23118,8 @@ packages: resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==} engines: {node: '>=4'} - pnpm@9.14.3: - resolution: {integrity: sha512-wPU+6ZR37ZabgrKJrQEaXRa/FiPJV+fynqvo0MALV0wpuMf1T2xn7nEMc/KFyBVNB85EtG/iwO60dqkEQbrDcQ==} + pnpm@9.14.2: + resolution: {integrity: sha512-biuvd9Brk2IpQVLIUcTyeO3jerHro6Vf2jF6SheyCfTbuXP7JQp3q8Rjo0H8sfF/F8+iQJHE6zGc2g2bhCeDhw==} engines: {node: '>=18.12'} hasBin: true @@ -24576,22 +24579,22 @@ packages: superagent@3.8.1: resolution: {integrity: sha512-VMBFLYgFuRdfeNQSMLbxGSLfmXL/xc+OO+BZp41Za/NRDBet/BNbkRJrYzCUu0u4GU0i/ml2dtT8b9qgkw9z6Q==} engines: {node: '>= 4.0'} - deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net + deprecated: Please upgrade to v7.0.2+ of superagent. We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing. See the releases tab for more information at . superagent@4.1.0: resolution: {integrity: sha512-FT3QLMasz0YyCd4uIi5HNe+3t/onxMyEho7C3PSqmti3Twgy2rXT4fmkTz6wRL6bTF4uzPcfkUCa8u4JWHw8Ag==} engines: {node: '>= 6.0'} - deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net + deprecated: Please upgrade to v7.0.2+ of superagent. We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing. See the releases tab for more information at . superagent@5.3.1: resolution: {integrity: sha512-wjJ/MoTid2/RuGCOFtlacyGNxN9QLMgcpYLDQlWFIhhdJ93kNscFonGvrpAHSCVjRVj++DGCglocF7Aej1KHvQ==} engines: {node: '>= 7.0.0'} - deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net + deprecated: Please upgrade to v7.0.2+ of superagent. We have fixed numerous issues with streams, form-data, attach(), filesystem errors not bubbling up (ENOENT on attach()), and all tests are now passing. See the releases tab for more information at . superagent@7.1.6: resolution: {integrity: sha512-gZkVCQR1gy/oUXr+kxJMLDjla434KmSOKbx5iGD30Ql+AkJQ/YlPKECJy2nhqOsHLjGHzoDTXNSjhnvWhzKk7g==} engines: {node: '>=6.4.0 <13 || >=14'} - deprecated: Please upgrade to v9.0.0+ as we have fixed a public vulnerability with formidable dependency. Note that v9.0.0+ requires Node.js v14.18.0+. See https://github.com/ladjs/superagent/pull/1800 for insight. This project is supported and maintained by the team at Forward Email @ https://forwardemail.net + deprecated: Please downgrade to v7.1.5 if you need IE/ActiveXObject support OR upgrade to v8.0.0 as we no longer support IE and published an incorrect patch version (see https://github.com/visionmedia/superagent/issues/1731) supports-color@2.0.0: resolution: {integrity: sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==} @@ -40515,7 +40518,7 @@ snapshots: pluralize@8.0.0: {} - pnpm@9.14.3: {} + pnpm@9.14.2: {} points-on-curve@0.2.0: {}