Skip to content

Commit d5341a6

Browse files
authored
New Components - taleez (#15109)
* taleez init * new components * pnpm-lock.yaml * fix params
1 parent d0d8587 commit d5341a6

File tree

9 files changed

+582
-7
lines changed

9 files changed

+582
-7
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import taleez from "../../taleez.app.mjs";
2+
3+
export default {
4+
key: "taleez-add-candidate-to-job",
5+
name: "Add Candidate to Job",
6+
description: "Links an existing candidate to a job offer. [See the documentation](https://api.taleez.com/swagger-ui/index.html#/jobs/addCandidate_1)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
taleez,
11+
candidateId: {
12+
propDefinition: [
13+
taleez,
14+
"candidateId",
15+
],
16+
},
17+
jobId: {
18+
propDefinition: [
19+
taleez,
20+
"jobId",
21+
],
22+
},
23+
},
24+
async run({ $ }) {
25+
const response = await this.taleez.linkCandidateToJob({
26+
$,
27+
jobId: this.jobId,
28+
data: {
29+
ids: [
30+
this.candidateId,
31+
],
32+
},
33+
});
34+
$.export("$summary", `Linked candidate ${this.candidateId} to job ${this.jobId} successfully`);
35+
return response;
36+
},
37+
};
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import taleez from "../../taleez.app.mjs";
2+
3+
export default {
4+
key: "taleez-create-candidate",
5+
name: "Create Candidate",
6+
description: "Creates a new candidate in Taleez. [See the documentation](https://api.taleez.com/swagger-ui/index.html#/candidates/create_1)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
taleez,
11+
firstName: {
12+
type: "string",
13+
label: "First Name",
14+
description: "First name of the candidate",
15+
},
16+
lastName: {
17+
type: "string",
18+
label: "Last Name",
19+
description: "Last name of the candidate",
20+
},
21+
email: {
22+
type: "string",
23+
label: "Email",
24+
description: "Candidate email address. Must be unique in your company",
25+
},
26+
phone: {
27+
type: "string",
28+
label: "Phone",
29+
description: "Candidate phone (formats : 0611223344, +33611223344, 00336112233). Ignored if not valid.",
30+
optional: true,
31+
},
32+
unitId: {
33+
propDefinition: [
34+
taleez,
35+
"unitId",
36+
],
37+
},
38+
recruiterId: {
39+
propDefinition: [
40+
taleez,
41+
"recruiterId",
42+
],
43+
},
44+
},
45+
async run({ $ }) {
46+
const response = await this.taleez.createCandidate({
47+
$,
48+
data: {
49+
firstName: this.firstName,
50+
lastName: this.lastName,
51+
mail: this.email,
52+
phone: this.phone,
53+
unitId: this.unitId,
54+
recruiterId: this.recruiterId,
55+
},
56+
});
57+
$.export("$summary", `Created candidate ${this.firstName} ${this.lastName} successfully`);
58+
return response;
59+
},
60+
};
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import taleez from "../../taleez.app.mjs";
2+
3+
export default {
4+
key: "taleez-list-jobs",
5+
name: "List Jobs",
6+
description: "Retrieves a list of jobs in your company. [See the documentation](https://api.taleez.com/swagger-ui/index.html#/jobs/list_3)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
taleez,
11+
unitId: {
12+
propDefinition: [
13+
taleez,
14+
"unitId",
15+
],
16+
},
17+
status: {
18+
propDefinition: [
19+
taleez,
20+
"status",
21+
],
22+
},
23+
contract: {
24+
propDefinition: [
25+
taleez,
26+
"contract",
27+
],
28+
},
29+
city: {
30+
propDefinition: [
31+
taleez,
32+
"city",
33+
],
34+
},
35+
companyLabel: {
36+
propDefinition: [
37+
taleez,
38+
"companyLabel",
39+
],
40+
},
41+
tag: {
42+
propDefinition: [
43+
taleez,
44+
"tag",
45+
],
46+
},
47+
maxResults: {
48+
type: "integer",
49+
label: "Max Results",
50+
description: "The maximum number of jobs to retrieve. Default: `100`",
51+
optional: true,
52+
},
53+
},
54+
async run({ $ }) {
55+
const { list: jobs } = await this.taleez.listJobs({
56+
$,
57+
params: {
58+
unitId: this.unitId,
59+
status: this.status,
60+
contract: this.contract,
61+
city: this.city,
62+
companyLabel: this.companyLabel,
63+
tag: this.tag,
64+
pageSize: this.maxResults,
65+
withDetails: true,
66+
withProps: true,
67+
},
68+
});
69+
$.export("$summary", `Successfully retrieved ${jobs?.length} job${jobs?.length === 1
70+
? ""
71+
: "s"}`);
72+
return jobs;
73+
},
74+
};

components/taleez/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/taleez",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Taleez Components",
55
"main": "taleez.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1417
}
15-
}
18+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import taleez from "../../taleez.app.mjs";
2+
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
3+
4+
export default {
5+
props: {
6+
taleez,
7+
db: "$.service.db",
8+
timer: {
9+
type: "$.interface.timer",
10+
default: {
11+
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
12+
},
13+
},
14+
},
15+
methods: {
16+
_getLastTs() {
17+
return this.db.get("lastTs") || 0;
18+
},
19+
_setLastTs(lastTs) {
20+
this.db.set("lastTs", lastTs);
21+
},
22+
emitEvent(item) {
23+
const meta = this.generateMeta(item);
24+
this.$emit(item, meta);
25+
},
26+
async processEvent(max) {
27+
const lastTs = this._getLastTs();
28+
let maxTs = lastTs;
29+
const tsField = this.getTsField();
30+
31+
const results = this.taleez.paginate({
32+
fn: this.getResourceFn(),
33+
args: this.getArgs(),
34+
max,
35+
});
36+
37+
for await (const item of results) {
38+
if (tsField) {
39+
const ts = item[tsField];
40+
if (ts > lastTs) {
41+
this.emitEvent(item);
42+
maxTs = Math.max(ts, maxTs);
43+
}
44+
} else {
45+
this.emitEvent(item);
46+
}
47+
}
48+
49+
this._setLastTs(maxTs);
50+
},
51+
getArgs() {
52+
return {};
53+
},
54+
getTsField() {
55+
return undefined;
56+
},
57+
getResourceFn() {
58+
throw new Error("getResourceFn is not implemented");
59+
},
60+
generateMeta() {
61+
throw new Error("generateMeta is not implemented");
62+
},
63+
},
64+
hooks: {
65+
async deploy() {
66+
await this.processEvent(25);
67+
},
68+
},
69+
async run() {
70+
await this.processEvent();
71+
},
72+
};
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import common from "../common/base.mjs";
2+
3+
export default {
4+
...common,
5+
key: "taleez-new-candidate-created",
6+
name: "New Candidate Created",
7+
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)",
8+
version: "0.0.1",
9+
type: "source",
10+
dedupe: "unique",
11+
methods: {
12+
...common.methods,
13+
getResourceFn() {
14+
return this.taleez.listCandidates;
15+
},
16+
getArgs() {
17+
return {
18+
params: {
19+
withProps: true,
20+
},
21+
};
22+
},
23+
getTsField() {
24+
return "dateCreation";
25+
},
26+
generateMeta(candidate) {
27+
return {
28+
id: candidate.id,
29+
summary: `New Candidate: ${candidate.firstName} ${candidate.lastName}`,
30+
ts: candidate.dateCreation,
31+
};
32+
},
33+
},
34+
};
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import common from "../common/base.mjs";
2+
3+
export default {
4+
...common,
5+
key: "taleez-new-job-listed",
6+
name: "New Job Listing Created",
7+
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)",
8+
version: "0.0.1",
9+
type: "source",
10+
dedupe: "unique",
11+
props: {
12+
...common.props,
13+
unitId: {
14+
propDefinition: [
15+
common.props.taleez,
16+
"unitId",
17+
],
18+
},
19+
status: {
20+
propDefinition: [
21+
common.props.taleez,
22+
"status",
23+
],
24+
},
25+
contract: {
26+
propDefinition: [
27+
common.props.taleez,
28+
"contract",
29+
],
30+
},
31+
city: {
32+
propDefinition: [
33+
common.props.taleez,
34+
"city",
35+
],
36+
},
37+
companyLabel: {
38+
propDefinition: [
39+
common.props.taleez,
40+
"companyLabel",
41+
],
42+
},
43+
tag: {
44+
propDefinition: [
45+
common.props.taleez,
46+
"tag",
47+
],
48+
},
49+
},
50+
methods: {
51+
...common.methods,
52+
getResourceFn() {
53+
return this.taleez.listJobs;
54+
},
55+
getArgs() {
56+
return {
57+
params: {
58+
unitId: this.unitId,
59+
status: this.status,
60+
contract: this.contract,
61+
city: this.city,
62+
companyLabel: this.companyLabel,
63+
tag: this.tag,
64+
withDetails: true,
65+
withProps: true,
66+
},
67+
};
68+
},
69+
generateMeta(job) {
70+
return {
71+
id: job.id,
72+
summary: `New Job: ${job.label}`,
73+
ts: job.dateCreation,
74+
};
75+
},
76+
},
77+
};

0 commit comments

Comments
 (0)