Skip to content

Commit 2c8f185

Browse files
[Components] tmetric #13315 (#19287)
* Added actions * Added actions * Update components/tmetric/sources/common/polling.mjs Co-authored-by: michelle0927 <michelle0927@users.noreply.github.com> * Update components/tmetric/sources/common/polling.mjs Co-authored-by: michelle0927 <michelle0927@users.noreply.github.com> * Update components/tmetric/tmetric.app.mjs Co-authored-by: michelle0927 <michelle0927@users.noreply.github.com> * Update components/tmetric/sources/new-task/new-task.mjs Co-authored-by: michelle0927 <michelle0927@users.noreply.github.com> * Added actions * Added actions * eslint --------- Co-authored-by: michelle0927 <michelle0927@users.noreply.github.com> Co-authored-by: Michelle Bergeron <michelle.bergeron@gmail.com>
1 parent 9e8564b commit 2c8f185

File tree

9 files changed

+427
-6
lines changed

9 files changed

+427
-6
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import app from "../../tmetric.app.mjs";
2+
3+
export default {
4+
key: "tmetric-create-time-entry",
5+
name: "Create Time Entry",
6+
description: "Create a new Time Entry. [See the documentation](https://app.tmetric.com/api-docs/?_gl=1*n76hcy*_gcl_aw*R0NMLjE3NjQwOTU2MDguQ2owS0NRaUF4SlhKQmhEX0FSSXNBSF9KR2pncU8zZzgxcHp3VUhQWGdjazEyUWFTaThXeE00ZTBUZ1hvak5ma1AzeG10a1pGYWJuek8wOGFBbC1KRUFMd193Y0I.*_gcl_au*MjU2MzU4NTI3LjE3NjQwOTU2MDg.*_ga*ODE4ODUyMDE2LjE3NjQwOTU2MDM.*_ga_66EFKVJKC5*czE3NjQwOTU2MDMkbzEkZzEkdDE3NjQwOTYyODkkajQzJGwwJGgw#/Time%20Entries/post-accounts-accountId-timeentries)",
7+
version: "0.0.1",
8+
annotations: {
9+
destructiveHint: false,
10+
openWorldHint: true,
11+
readOnlyHint: false,
12+
},
13+
type: "action",
14+
props: {
15+
app,
16+
accountId: {
17+
propDefinition: [
18+
app,
19+
"accountId",
20+
],
21+
},
22+
startTime: {
23+
propDefinition: [
24+
app,
25+
"startTime",
26+
],
27+
},
28+
endTime: {
29+
propDefinition: [
30+
app,
31+
"endTime",
32+
],
33+
},
34+
note: {
35+
propDefinition: [
36+
app,
37+
"note",
38+
],
39+
},
40+
isBillable: {
41+
propDefinition: [
42+
app,
43+
"isBillable",
44+
],
45+
},
46+
isInvoiced: {
47+
propDefinition: [
48+
app,
49+
"isInvoiced",
50+
],
51+
},
52+
},
53+
async run({ $ }) {
54+
const response = await this.app.createTimeEntry({
55+
$,
56+
accountId: this.accountId,
57+
data: {
58+
startTime: this.startTime,
59+
endTime: this.endTime,
60+
note: this.note,
61+
isBillable: this.isBillable,
62+
isInvoiced: this.isInvoiced,
63+
},
64+
});
65+
66+
const timeEntry = Array.isArray(response)
67+
? response[0]
68+
: response;
69+
70+
$.export("$summary", `Successfully created time entry with ID: ${timeEntry.id}`);
71+
72+
return response;
73+
},
74+
};
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import app from "../../tmetric.app.mjs";
2+
3+
export default {
4+
key: "tmetric-delete-time-entry",
5+
name: "Delete Time Entry",
6+
description: "Delete the specified Time Entry. [See the documentation](https://app.tmetric.com/api-docs/?_gl=1*n76hcy*_gcl_aw*R0NMLjE3NjQwOTU2MDguQ2owS0NRaUF4SlhKQmhEX0FSSXNBSF9KR2pncU8zZzgxcHp3VUhQWGdjazEyUWFTaThXeE00ZTBUZ1hvak5ma1AzeG10a1pGYWJuek8wOGFBbC1KRUFMd193Y0I.*_gcl_au*MjU2MzU4NTI3LjE3NjQwOTU2MDg.*_ga*ODE4ODUyMDE2LjE3NjQwOTU2MDM.*_ga_66EFKVJKC5*czE3NjQwOTU2MDMkbzEkZzEkdDE3NjQwOTYyODkkajQzJGwwJGgw#/Time%20Entries/delete-accounts-accountId-timeentries-timeEntryId)",
7+
version: "0.0.1",
8+
annotations: {
9+
destructiveHint: true,
10+
openWorldHint: true,
11+
readOnlyHint: false,
12+
},
13+
type: "action",
14+
props: {
15+
app,
16+
accountId: {
17+
propDefinition: [
18+
app,
19+
"accountId",
20+
],
21+
},
22+
timeEntryId: {
23+
propDefinition: [
24+
app,
25+
"timeEntryId",
26+
(c) => ({
27+
accountId: c.accountId,
28+
}),
29+
],
30+
},
31+
},
32+
async run({ $ }) {
33+
const response = await this.app.deleteTimeEntry({
34+
$,
35+
accountId: this.accountId,
36+
timeEntryId: this.timeEntryId,
37+
});
38+
39+
$.export("$summary", "Successfully deleted time entry with ID: " + this.timeEntryId);
40+
41+
return response;
42+
},
43+
};
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import app from "../../tmetric.app.mjs";
2+
3+
export default {
4+
key: "tmetric-modify-time-entry",
5+
name: "Modify Time Entry",
6+
description: "Modify the specified Time Entry. [See the documentation](https://app.tmetric.com/api-docs/?_gl=1*n76hcy*_gcl_aw*R0NMLjE3NjQwOTU2MDguQ2owS0NRaUF4SlhKQmhEX0FSSXNBSF9KR2pncU8zZzgxcHp3VUhQWGdjazEyUWFTaThXeE00ZTBUZ1hvak5ma1AzeG10a1pGYWJuek8wOGFBbC1KRUFMd193Y0I.*_gcl_au*MjU2MzU4NTI3LjE3NjQwOTU2MDg.*_ga*ODE4ODUyMDE2LjE3NjQwOTU2MDM.*_ga_66EFKVJKC5*czE3NjQwOTU2MDMkbzEkZzEkdDE3NjQwOTYyODkkajQzJGwwJGgw#/Time%20Entries/put-accounts-accountId-timeentries-timeEntryId)",
7+
version: "0.0.1",
8+
annotations: {
9+
destructiveHint: false,
10+
openWorldHint: true,
11+
readOnlyHint: false,
12+
},
13+
type: "action",
14+
props: {
15+
app,
16+
accountId: {
17+
propDefinition: [
18+
app,
19+
"accountId",
20+
],
21+
},
22+
timeEntryId: {
23+
propDefinition: [
24+
app,
25+
"timeEntryId",
26+
(c) => ({
27+
accountId: c.accountId,
28+
}),
29+
],
30+
},
31+
startTime: {
32+
propDefinition: [
33+
app,
34+
"startTime",
35+
],
36+
},
37+
endTime: {
38+
propDefinition: [
39+
app,
40+
"endTime",
41+
],
42+
},
43+
note: {
44+
propDefinition: [
45+
app,
46+
"note",
47+
],
48+
},
49+
isBillable: {
50+
propDefinition: [
51+
app,
52+
"isBillable",
53+
],
54+
},
55+
isInvoiced: {
56+
propDefinition: [
57+
app,
58+
"isInvoiced",
59+
],
60+
},
61+
},
62+
async run({ $ }) {
63+
const response = await this.app.modifyTimeEntry({
64+
$,
65+
accountId: this.accountId,
66+
timeEntryId: this.timeEntryId,
67+
data: {
68+
startTime: this.startTime ?? "",
69+
endTime: this.endTime ?? "",
70+
note: this.note,
71+
isBillable: this.isBillable,
72+
isInvoiced: this.isInvoiced,
73+
},
74+
});
75+
$.export("$summary", "Successfully modified the time entry with ID: " + this.timeEntryId);
76+
return response;
77+
},
78+
};

components/tmetric/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/tmetric",
3-
"version": "0.0.6",
3+
"version": "0.1.0",
44
"description": "Pipedream TMetric Components",
55
"main": "tmetric.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.1.1"
1417
}
1518
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import app from "../../tmetric.app.mjs";
2+
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform";
3+
4+
export default {
5+
props: {
6+
app,
7+
db: "$.service.db",
8+
timer: {
9+
type: "$.interface.timer",
10+
label: "Polling schedule",
11+
description: "How often to poll the TMetric API",
12+
default: {
13+
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
14+
},
15+
},
16+
accountId: {
17+
propDefinition: [
18+
app,
19+
"accountId",
20+
],
21+
},
22+
},
23+
methods: {
24+
getResourceFn() {
25+
throw new Error("getResourceFn is not implemented");
26+
},
27+
generateMeta() {
28+
throw new Error("generateMeta is not implemented");
29+
},
30+
processEvent(resource) {
31+
const meta = this.generateMeta(resource);
32+
this.$emit(resource, meta);
33+
},
34+
},
35+
async run() {
36+
const resources = await this.getResourceFn()({
37+
accountId: this.accountId,
38+
});
39+
40+
resources.map(async (resource) => await this.processEvent(resource));
41+
},
42+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import common from "../common/polling.mjs";
2+
import sampleEmit from "./test-event.mjs";
3+
4+
export default {
5+
...common,
6+
key: "tmetric-new-task-created",
7+
name: "New Task Created",
8+
description: "Emit new event when a task is created. [See the docs here](https://app.tmetric.com/api-docs/?_gl=1*n76hcy*_gcl_aw*R0NMLjE3NjQwOTU2MDguQ2owS0NRaUF4SlhKQmhEX0FSSXNBSF9KR2pncU8zZzgxcHp3VUhQWGdjazEyUWFTaThXeE00ZTBUZ1hvak5ma1AzeG10a1pGYWJuek8wOGFBbC1KRUFMd193Y0I.*_gcl_au*MjU2MzU4NTI3LjE3NjQwOTU2MDg.*_ga*ODE4ODUyMDE2LjE3NjQwOTU2MDM.*_ga_66EFKVJKC5*czE3NjQwOTU2MDMkbzEkZzEkdDE3NjQwOTYyODkkajQzJGwwJGgw#/Tasks/get-accounts-accountId-tasks)",
9+
type: "source",
10+
version: "0.0.1",
11+
dedupe: "unique",
12+
methods: {
13+
...common.methods,
14+
getResourceFn() {
15+
return this.app.getTasks;
16+
},
17+
generateMeta(resource) {
18+
return {
19+
id: resource.id,
20+
ts: Date.parse(resource.created),
21+
summary: `New task created with ID: ${resource.id}`,
22+
};
23+
},
24+
},
25+
sampleEmit,
26+
};
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export default {
2+
isCompleted: false,
3+
creator: {
4+
name: 'John Doe',
5+
iconUrl: 'https://lh3.googleusercontent.com/a/ACg8ocKRyVElTYgiLSyki9Wj_5UzheDfu7eqdXQ0co1TfdAntlqfz2Mav',
6+
id: 50074
7+
},
8+
created: '2025-12-01T11:03:30.337',
9+
modified: '2025-12-01T11:03:30.337',
10+
dueDate: null,
11+
estimatedMinutes: null,
12+
id: 734199,
13+
name: 'Explore features',
14+
project: {
15+
name: 'Sample Project',
16+
iconUrl: 'https://services.tmetric.com/storage/Content/Avatars/avatar_1.svg',
17+
client: { "iconUrl": "https://services.tmetric.com/storage/Content/Avatars/avatar_5.svg", "name": "Sample Client", "id": 37523 },
18+
status: 'active',
19+
isBillable: false,
20+
id: 108268
21+
},
22+
tags: []
23+
}

0 commit comments

Comments
 (0)