Skip to content

Commit aa4b84a

Browse files
13382 components remote (#19418)
* Update Remote component to version 0.1.0 and add new actions - Bump version of @pipedream/remote to 0.1.0 - Introduce new actions: Create Expense, List Employments, Show Time Off Balance - Add prop definitions for employmentId and expenseCategorySlug in remote.app.mjs - Implement methods for creating expenses and listing employments - Add new event sources for contract amendments and custom field updates - Enhance webhook handling in common base source * pnpm update * Update test events for employment onboarding and custom field value updates - Change event types to reflect new actions: 'employment.onboarding.started' and 'custom_field.value_updated'. - Adjust employment IDs and custom field IDs in the respective test event files. * Refactor pagination and update data handling in remote components - Added a dataKey parameter to the paginate function for flexible data extraction. - Updated references in list-employments and other components to utilize the new dataKey. - Corrected employment ID references in new contract amendment and onboarding sources. - Improved descriptions in custom field value updated source for clarity. * Update ID formatting in remote sources to include timestamps - Modified ID generation in new contract amendment, custom field value updated, and employment onboarding sources to append timestamps for uniqueness. - Enhanced clarity in summary messages for better context. * minor updates --------- Co-authored-by: Michelle Bergeron <michelle.bergeron@gmail.com>
1 parent da3b9b7 commit aa4b84a

File tree

13 files changed

+534
-7
lines changed

13 files changed

+534
-7
lines changed
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
import { getFileStreamAndMetadata } from "@pipedream/platform";
2+
import remote from "../../remote.app.mjs";
3+
4+
export default {
5+
key: "remote-create-expense",
6+
name: "Create Expense",
7+
description: "Create an expense in Remote. [See the documentation](https://developer.remote.com/reference/post_create_expense)",
8+
version: "0.0.1",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: false,
13+
},
14+
type: "action",
15+
props: {
16+
remote,
17+
amount: {
18+
type: "integer",
19+
label: "Amount",
20+
description: "The amount of the expense",
21+
},
22+
currency: {
23+
type: "string",
24+
label: "Currency",
25+
description: "The currency of the expense",
26+
options: [
27+
"USD",
28+
"EUR",
29+
"CAD",
30+
],
31+
},
32+
employmentId: {
33+
propDefinition: [
34+
remote,
35+
"employmentId",
36+
],
37+
},
38+
expenseCategorySlug: {
39+
propDefinition: [
40+
remote,
41+
"expenseCategorySlug",
42+
({ employmentId }) => ({
43+
employmentId,
44+
}),
45+
],
46+
},
47+
expenseDate: {
48+
type: "string",
49+
label: "Expense Date",
50+
description: "Date of the purchase, which must be in the past. **Format: YYYY-MM-DD**",
51+
},
52+
receiptContentFilePath: {
53+
type: "string",
54+
label: "Receipt Content File Path",
55+
description: "The file of the receipt. Provide either a file URL or a path to a file in the `/tmp` directory (for example, `/tmp/myFile.pdf`)",
56+
},
57+
receiptFileName: {
58+
type: "string",
59+
label: "Receipt File Name",
60+
description: "The file name",
61+
},
62+
reviewedAt: {
63+
type: "string",
64+
label: "Reviewed At",
65+
description: "The date and time that the expense was reviewed in ISO8601 format. If not provided, it defaults to the current datetime. **Format: YYYY-MM-DDTHH:MM:SS**",
66+
},
67+
taxAmount: {
68+
type: "integer",
69+
label: "Tax Amount",
70+
description: "The tax amount of the expense",
71+
optional: true,
72+
},
73+
timezone: {
74+
type: "string",
75+
label: "Timezone",
76+
description: "The timezone of the expense. [TZ identifier](https://www.iana.org/time-zones)",
77+
optional: true,
78+
},
79+
title: {
80+
type: "string",
81+
label: "Title",
82+
description: "The title of the expense",
83+
},
84+
syncDir: {
85+
type: "dir",
86+
accessMode: "read",
87+
sync: true,
88+
},
89+
},
90+
methods: {
91+
async streamToBase64(stream) {
92+
return new Promise((resolve, reject) => {
93+
const chunks = [];
94+
95+
stream.on("data", (chunk) => {
96+
chunks.push(chunk);
97+
});
98+
99+
stream.on("end", () => {
100+
const buffer = Buffer.concat(chunks);
101+
resolve(buffer.toString("base64"));
102+
});
103+
104+
stream.on("error", (err) => {
105+
reject(err);
106+
});
107+
});
108+
},
109+
},
110+
async run({ $ }) {
111+
const {
112+
stream, metadata,
113+
} = await getFileStreamAndMetadata(this.receiptContentFilePath);
114+
const base64String = await this.streamToBase64(stream);
115+
116+
const response = await this.remote.createExpense({
117+
$,
118+
data: {
119+
amount: this.amount,
120+
currency: this.currency,
121+
employment_id: this.employmentId,
122+
expense_date: this.expenseDate,
123+
title: this.title,
124+
receipt: {
125+
content: `data:${metadata.contentType};base64,${base64String}`,
126+
name: this.receiptFileName,
127+
},
128+
expense_category_slug: this.expenseCategorySlug,
129+
reviewed_at: this.reviewedAt,
130+
tax_amount: this.taxAmount,
131+
timezone: this.timezone,
132+
},
133+
});
134+
135+
$.export("$summary", `Successfully created expense with ID: ${response?.data?.expense?.id}`);
136+
return response;
137+
},
138+
};
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import remote from "../../remote.app.mjs";
2+
3+
export default {
4+
key: "remote-list-employments",
5+
name: "List Employments",
6+
description: "List employments in Remote. [See the documentation](https://developer.remote.com/reference/get_index_employment)",
7+
version: "0.0.1",
8+
annotations: {
9+
destructiveHint: false,
10+
openWorldHint: true,
11+
readOnlyHint: true,
12+
},
13+
type: "action",
14+
props: {
15+
remote,
16+
email: {
17+
type: "string",
18+
label: "Email",
19+
description: "Filters the results by employments whose login email matches the value",
20+
optional: true,
21+
},
22+
employmentType: {
23+
type: "string",
24+
label: "Employment Type",
25+
description: "Filters the results by employments whose employment product type matches the value",
26+
optional: true,
27+
options: [
28+
"contractor",
29+
"direct_employee",
30+
"employee",
31+
],
32+
},
33+
employmentModel: {
34+
type: "string",
35+
label: "Employment Model",
36+
description: "Filters the results by employments whose employment model matches the value",
37+
optional: true,
38+
options: [
39+
"global_payroll",
40+
"peo",
41+
"eor",
42+
],
43+
},
44+
maxResults: {
45+
type: "integer",
46+
label: "Max Results",
47+
description: "The maximum number of results to return",
48+
optional: true,
49+
},
50+
},
51+
async run({ $ }) {
52+
const response = this.remote.paginate({
53+
$,
54+
dataKey: "employments",
55+
fn: this.remote.listEmployments,
56+
params: {
57+
email: this.email,
58+
employment_type: this.employmentType,
59+
employment_model: this.employmentModel,
60+
},
61+
maxResults: this.maxResults,
62+
});
63+
64+
const responseArray = [];
65+
for await (const employment of response) {
66+
responseArray.push(employment);
67+
}
68+
69+
$.export("$summary", `Successfully listed ${responseArray.length} employments`);
70+
return responseArray;
71+
},
72+
};
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import remote from "../../remote.app.mjs";
2+
3+
export default {
4+
key: "remote-show-timeoff-balance",
5+
name: "Show Time Off Balance",
6+
description: "Show the time off balance for an employment in Remote. [See the documentation](https://developer.remote.com/reference/get_show_timeoff_balance)",
7+
version: "0.0.1",
8+
annotations: {
9+
destructiveHint: false,
10+
openWorldHint: true,
11+
readOnlyHint: true,
12+
},
13+
type: "action",
14+
props: {
15+
remote,
16+
employmentId: {
17+
propDefinition: [
18+
remote,
19+
"employmentId",
20+
],
21+
},
22+
},
23+
async run({ $ }) {
24+
const response = await this.remote.showTimeoffBalance({
25+
$,
26+
employmentId: this.employmentId,
27+
});
28+
29+
$.export("$summary", `Successfully retrieved time off balance for employment with ID: ${this.employmentId}`);
30+
return response;
31+
},
32+
};

components/remote/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/remote",
3-
"version": "0.0.2",
3+
"version": "0.1.0",
44
"description": "Pipedream Remote Components",
55
"main": "remote.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
}

0 commit comments

Comments
 (0)