Skip to content

Commit e25420f

Browse files
committed
taleez init
1 parent e6e6ffe commit e25420f

File tree

7 files changed

+657
-3
lines changed

7 files changed

+657
-3
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import taleez from "../../taleez.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "taleez-add-candidate-to-job",
6+
name: "Add Candidate to Job",
7+
description: "Links an existing candidate to a job offer. [See the documentation]()",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
taleez,
12+
candidateId: {
13+
propDefinition: [
14+
taleez,
15+
"candidateId",
16+
],
17+
},
18+
jobId: {
19+
propDefinition: [
20+
taleez,
21+
"jobId",
22+
],
23+
},
24+
},
25+
async run({ $ }) {
26+
const response = await this.taleez.linkCandidateToJobOffer({
27+
data: {
28+
candidate_id: this.candidateId,
29+
job_id: this.jobId,
30+
},
31+
});
32+
$.export("$summary", `Linked candidate ${this.candidateId} to job ${this.jobId} successfully`);
33+
return response;
34+
},
35+
};
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import taleez from "../../taleez.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "taleez-create-candidate",
6+
name: "Create Candidate",
7+
description: "Creates a new candidate in Taleez. [See the documentation]()",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
taleez,
12+
candidateName: {
13+
propDefinition: [
14+
taleez,
15+
"candidateName",
16+
],
17+
},
18+
email: {
19+
propDefinition: [
20+
taleez,
21+
"email",
22+
],
23+
},
24+
jobListingId: {
25+
propDefinition: [
26+
taleez,
27+
"jobListingId",
28+
],
29+
},
30+
resume: {
31+
propDefinition: [
32+
taleez,
33+
"resume",
34+
],
35+
optional: true,
36+
},
37+
coverLetter: {
38+
propDefinition: [
39+
taleez,
40+
"coverLetter",
41+
],
42+
optional: true,
43+
},
44+
},
45+
async run({ $ }) {
46+
const response = await this.taleez.createCandidate();
47+
$.export("$summary", `Created candidate ${this.candidateName} successfully`);
48+
return response;
49+
},
50+
};
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import taleez from "../../taleez.app.mjs";
2+
import { axios } from "@pipedream/platform";
3+
4+
export default {
5+
key: "taleez-create-job",
6+
name: "Create Job Listing",
7+
description: "Creates a new job listing. [See the documentation]()",
8+
version: "0.0.{{ts}}",
9+
type: "action",
10+
props: {
11+
taleez,
12+
jobTitle: {
13+
propDefinition: [
14+
taleez,
15+
"jobTitle",
16+
],
17+
},
18+
department: {
19+
propDefinition: [
20+
taleez,
21+
"department",
22+
],
23+
},
24+
jobDescription: {
25+
propDefinition: [
26+
taleez,
27+
"jobDescription",
28+
],
29+
},
30+
jobLocation: {
31+
propDefinition: [
32+
taleez,
33+
"jobLocation",
34+
],
35+
optional: true,
36+
},
37+
jobType: {
38+
propDefinition: [
39+
taleez,
40+
"jobType",
41+
],
42+
optional: true,
43+
},
44+
applicationDeadline: {
45+
propDefinition: [
46+
taleez,
47+
"applicationDeadline",
48+
],
49+
optional: true,
50+
},
51+
},
52+
async run({ $ }) {
53+
const response = await this.taleez.createJobListing();
54+
$.export("$summary", `Job "${this.jobTitle}" created with ID ${response.id}`);
55+
return response;
56+
},
57+
};

components/taleez/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
"publishConfig": {
1313
"access": "public"
1414
}
15-
}
15+
}
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
import {
2+
axios, DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
3+
} from "@pipedream/platform";
4+
import taleez from "../../taleez.app.mjs";
5+
6+
export default {
7+
key: "taleez-new-candidate-created",
8+
name: "New Candidate Created",
9+
description: "Emit new event when a candidate is added to a job listing. [See the documentation]()",
10+
version: "0.0.{{ts}}",
11+
type: "source",
12+
dedupe: "unique",
13+
props: {
14+
taleez: {
15+
type: "app",
16+
app: "taleez",
17+
},
18+
jobListingId: {
19+
propDefinition: [
20+
"taleez",
21+
"jobListingId",
22+
],
23+
},
24+
departmentFilter: {
25+
propDefinition: [
26+
"taleez",
27+
"departmentFilter",
28+
],
29+
optional: true,
30+
},
31+
locationFilter: {
32+
propDefinition: [
33+
"taleez",
34+
"locationFilter",
35+
],
36+
optional: true,
37+
},
38+
db: {
39+
type: "$.service.db",
40+
db: "default",
41+
},
42+
timer: {
43+
type: "$.interface.timer",
44+
default: {
45+
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
46+
},
47+
},
48+
},
49+
hooks: {
50+
async deploy() {
51+
const candidates = await this.taleez.paginate(this.taleez.listCandidates, {
52+
params: {
53+
job_listing_id: this.jobListingId,
54+
department: this.departmentFilter,
55+
location: this.locationFilter,
56+
per_page: 50,
57+
},
58+
});
59+
60+
const sortedCandidates = candidates.sort((a, b) => new Date(a.created_at) - new Date(b.created_at));
61+
62+
for (const candidate of sortedCandidates) {
63+
this.$emit(
64+
candidate,
65+
{
66+
id: candidate.id || new Date(candidate.created_at).getTime(),
67+
summary: `New Candidate: ${candidate.name}`,
68+
ts: new Date(candidate.created_at).getTime(),
69+
},
70+
);
71+
}
72+
73+
if (candidates.length > 0) {
74+
const latestTimestamp = new Date(candidates[candidates.length - 1].created_at).getTime();
75+
await this.db.set("lastRunTimestamp", latestTimestamp);
76+
}
77+
},
78+
async activate() {
79+
// No webhook subscription needed for polling source
80+
},
81+
async deactivate() {
82+
// No webhook subscription to clean up for polling source
83+
},
84+
},
85+
async run() {
86+
const lastRunTimestamp = await this.db.get("lastRunTimestamp") || 0;
87+
88+
const candidates = await this.taleez.paginate(this.taleez.listCandidates, {
89+
params: {
90+
job_listing_id: this.jobListingId,
91+
department: this.departmentFilter,
92+
location: this.locationFilter,
93+
per_page: 50,
94+
},
95+
});
96+
97+
const newCandidates = candidates.filter((candidate) => new Date(candidate.created_at).getTime() > lastRunTimestamp);
98+
99+
const sortedNewCandidates = newCandidates.sort((a, b) => new Date(a.created_at) - new Date(b.created_at));
100+
101+
for (const candidate of sortedNewCandidates) {
102+
this.$emit(
103+
candidate,
104+
{
105+
id: candidate.id || new Date(candidate.created_at).getTime(),
106+
summary: `New Candidate: ${candidate.name}`,
107+
ts: new Date(candidate.created_at).getTime(),
108+
},
109+
);
110+
}
111+
112+
if (sortedNewCandidates.length > 0) {
113+
const latestTimestamp = new Date(sortedNewCandidates[sortedNewCandidates.length - 1].created_at).getTime();
114+
await this.db.set("lastRunTimestamp", latestTimestamp);
115+
}
116+
},
117+
};
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import taleez from "../../taleez.app.mjs";
2+
import {
3+
axios, DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
4+
} from "@pipedream/platform";
5+
6+
export default {
7+
key: "taleez-new-job-listed",
8+
name: "New Job Listing Created",
9+
description: "Emit a new event when a job listing is created. [See the documentation]()",
10+
version: "0.0.{{ts}}",
11+
type: "source",
12+
dedupe: "unique",
13+
props: {
14+
taleez,
15+
db: "$.service.db",
16+
timer: {
17+
type: "$.interface.timer",
18+
default: {
19+
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
20+
},
21+
},
22+
departmentFilter: {
23+
propDefinition: [
24+
taleez,
25+
"departmentFilter",
26+
],
27+
optional: true,
28+
},
29+
locationFilter: {
30+
propDefinition: [
31+
taleez,
32+
"locationFilter",
33+
],
34+
optional: true,
35+
},
36+
},
37+
hooks: {
38+
async deploy() {
39+
const jobListings = await this.taleez.listJobListings({
40+
params: {
41+
perpage: 50,
42+
sort: "created_desc",
43+
department: this.departmentFilter,
44+
location: this.locationFilter,
45+
},
46+
});
47+
48+
// Sort from oldest to newest
49+
jobListings.sort((a, b) => new Date(a.created_at) - new Date(b.created_at));
50+
51+
for (const job of jobListings) {
52+
this.$emit(job, {
53+
id: job.id,
54+
summary: `New Job Listing: ${job.title}`,
55+
ts: Date.parse(job.created_at) || Date.now(),
56+
});
57+
}
58+
59+
if (jobListings.length > 0) {
60+
const latestTs = Math.max(...jobListings.map((j) => Date.parse(j.created_at) || Date.now()));
61+
await this.db.set("last_seen_ts", latestTs);
62+
}
63+
},
64+
async activate() {
65+
await this.taleez.emitNewJobListingEvent(this.callbackUrl);
66+
},
67+
async deactivate() {
68+
await this.taleez.removeWebhook("job_listing_created");
69+
},
70+
},
71+
async run() {
72+
const lastSeenTs = (await this.db.get("last_seen_ts")) || 0;
73+
const jobListings = await this.taleez.listJobListings({
74+
params: {
75+
perpage: 100,
76+
sort: "created_asc",
77+
department: this.departmentFilter,
78+
location: this.locationFilter,
79+
},
80+
});
81+
82+
const newJobListings = jobListings.filter((job) => Date.parse(job.created_at) > lastSeenTs);
83+
84+
// Sort from oldest to newest
85+
newJobListings.sort((a, b) => new Date(a.created_at) - new Date(b.created_at));
86+
87+
for (const job of newJobListings) {
88+
this.$emit(job, {
89+
id: job.id,
90+
summary: `New Job Listing: ${job.title}`,
91+
ts: Date.parse(job.created_at) || Date.now(),
92+
});
93+
}
94+
95+
if (newJobListings.length > 0) {
96+
const latestTs = Math.max(...newJobListings.map((j) => Date.parse(j.created_at) || Date.now()));
97+
await this.db.set("last_seen_ts", latestTs);
98+
}
99+
},
100+
};

0 commit comments

Comments
 (0)