Skip to content

Commit 0a024a5

Browse files
committed
Merge branch 'master' into issue-15752
2 parents c46e779 + 335ff74 commit 0a024a5

File tree

71 files changed

+1731
-228
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+1731
-228
lines changed
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import { defineApp } from "@pipedream/types";
2-
3-
export default defineApp({
1+
export default {
42
type: "app",
5-
app: "elastic_email",
3+
app: "alibaba_cloud",
64
propDefinitions: {},
75
methods: {
86
// this.$auth contains connected account data
97
authKeys() {
108
console.log(Object.keys(this.$auth));
119
},
1210
},
13-
});
11+
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "@pipedream/alibaba_cloud",
3+
"version": "0.0.1",
4+
"description": "Pipedream Alibaba Cloud Components",
5+
"main": "alibaba_cloud.app.mjs",
6+
"keywords": [
7+
"pipedream",
8+
"alibaba_cloud"
9+
],
10+
"homepage": "https://pipedream.com/apps/alibaba_cloud",
11+
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
12+
"publishConfig": {
13+
"access": "public"
14+
}
15+
}

components/aws/actions/s3-upload-file-tmp/s3-upload-file-tmp.mjs

Lines changed: 51 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import { ConfigurationError } from "@pipedream/platform";
77
export default {
88
...common,
99
key: "aws-s3-upload-file-tmp",
10-
name: "S3 - Upload File - /tmp",
10+
name: "S3 - Upload Files - /tmp",
1111
description: toSingleLineString(`
1212
Accepts a file path or folder path starting from /tmp, then uploads the contents to S3.
1313
[See the docs](https://docs.aws.amazon.com/AmazonS3/latest/userguide/upload-objects.html)
1414
`),
15-
version: "1.0.2",
15+
version: "1.0.3",
1616
type: "action",
1717
props: {
1818
aws: common.props.aws,
@@ -25,15 +25,8 @@ export default {
2525
},
2626
path: {
2727
type: "string",
28-
label: "File Path",
29-
description: "A path starting from `/tmp`, i.e. `/tmp/some_text_file.txt`",
30-
optional: true,
31-
},
32-
folderPath: {
33-
type: "string",
34-
label: "Folder Path",
35-
description: "A path starting from `/tmp`, i.e. `/tmp/some_folder`. If provided, all the files inside this path will be uploaded. This will override the `Filename Key` and `File Path` props.",
36-
optional: true,
28+
label: "File Or Folder Path",
29+
description: "Path starting from `/tmp`. If it's a directory, all files will be uploaded.",
3730
},
3831
customFilename: {
3932
type: common.props.key.type,
@@ -44,58 +37,83 @@ export default {
4437
},
4538
methods: {
4639
...common.methods,
47-
async uploadFolderFiles($) {
40+
getFilesRecursive(dir) {
41+
let results = [];
42+
const items = fs.readdirSync(dir);
43+
for (const item of items) {
44+
const itemPath = join(dir, item);
45+
const stat = fs.statSync(itemPath);
46+
if (stat.isDirectory()) {
47+
results = results.concat(this.getFilesRecursive(itemPath));
48+
} else {
49+
results.push(itemPath);
50+
}
51+
}
52+
return results;
53+
},
54+
async uploadFolderFiles($, folderPath) {
4855
const {
4956
uploadFile,
5057
bucket,
51-
folderPath,
5258
prefix,
5359
} = this;
54-
55-
const files = fs.readdirSync(folderPath);
56-
const promises = [];
57-
for (const filename of files) {
58-
const fileContent = fs.readFileSync(join(folderPath, filename), {
60+
const files = this.getFilesRecursive(folderPath);
61+
const response = await Promise.all(files.map(async (filePath) => {
62+
const fileContent = fs.readFileSync(filePath, {
5963
encoding: "base64",
6064
});
61-
promises.push(uploadFile({
65+
const relativePath = filePath.substring(folderPath.length + 1);
66+
const s3Key = join(prefix, relativePath);
67+
68+
await uploadFile({
6269
Bucket: bucket,
63-
Key: join(prefix, filename),
70+
Key: s3Key,
6471
Body: Buffer.from(fileContent, "base64"),
65-
}));
66-
}
67-
const response = await Promise.all(promises);
72+
});
73+
return {
74+
filePath,
75+
s3Key,
76+
status: "uploaded",
77+
};
78+
}));
6879
$.export("$summary", `Uploaded all files from ${folderPath} to S3`);
6980
return response;
7081
},
71-
async uploadSingleFile($) {
82+
async uploadSingleFile($, filePath) {
7283
const {
7384
uploadFile,
7485
bucket,
75-
path,
7686
prefix,
7787
customFilename,
7888
} = this;
7989

80-
if (!path) {
81-
throw new ConfigurationError("File Path is required");
82-
}
83-
const file = fs.readFileSync(path, {
90+
const file = fs.readFileSync(filePath, {
8491
encoding: "base64",
8592
});
86-
const filename = customFilename || path.split("/").pop();
93+
const filename = customFilename || filePath.split("/").pop();
94+
8795
const response = await uploadFile({
8896
Bucket: bucket,
8997
Key: join(prefix, filename),
9098
Body: Buffer.from(file, "base64"),
9199
});
100+
92101
$.export("$summary", `Uploaded file ${filename} to S3`);
93102
return response;
94103
},
95104
},
96105
async run({ $ }) {
97-
return this.folderPath
98-
? await this.uploadFolderFiles($)
99-
: await this.uploadSingleFile($);
106+
const {
107+
uploadSingleFile,
108+
uploadFolderFiles,
109+
path,
110+
} = this;
111+
if (!fs.existsSync(path)) {
112+
throw new ConfigurationError(`The file or directory path \`${path}\` does not exist. Please verify the path and include the leading /tmp if needed.`);
113+
}
114+
const stat = fs.statSync(path);
115+
return stat.isDirectory()
116+
? await uploadFolderFiles($, path)
117+
: await uploadSingleFile($, path);
100118
},
101119
};

components/aws/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/aws",
3-
"version": "0.7.4",
3+
"version": "0.7.5",
44
"description": "Pipedream Aws Components",
55
"main": "aws.app.mjs",
66
"keywords": [

components/egestor/egestor.app.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export default {
2+
type: "app",
3+
app: "egestor",
4+
propDefinitions: {},
5+
methods: {
6+
// this.$auth contains connected account data
7+
authKeys() {
8+
console.log(Object.keys(this.$auth));
9+
},
10+
},
11+
};

components/egestor/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "@pipedream/egestor",
3+
"version": "0.0.1",
4+
"description": "Pipedream eGestor Components",
5+
"main": "egestor.app.mjs",
6+
"keywords": [
7+
"pipedream",
8+
"egestor"
9+
],
10+
"homepage": "https://pipedream.com/apps/egestor",
11+
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
12+
"publishConfig": {
13+
"access": "public"
14+
}
15+
}

components/elastic_email/.gitignore

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import { ConfigurationError } from "@pipedream/platform";
2+
import {
3+
CONSENT_TRACKING_OPTIONS,
4+
STATUS_OPTIONS,
5+
} from "../../common/constants.mjs";
6+
import { parseObject } from "../../common/utils.mjs";
7+
import app from "../../elastic_email.app.mjs";
8+
9+
export default {
10+
key: "elastic_email-add-contact",
11+
name: "Add Contact to Mailing List",
12+
description: "Adds a new contact to a mailing list. [See the documentation](https://elasticemail.com/developers/api-documentation/rest-api#operation/contactsPost)",
13+
version: "0.0.1",
14+
type: "action",
15+
props: {
16+
app,
17+
email: {
18+
propDefinition: [
19+
app,
20+
"email",
21+
],
22+
},
23+
listNames: {
24+
propDefinition: [
25+
app,
26+
"listNames",
27+
],
28+
optional: true,
29+
},
30+
status: {
31+
type: "string",
32+
label: "Status",
33+
description: "The initial status of the contact.",
34+
options: STATUS_OPTIONS,
35+
optional: true,
36+
},
37+
firstName: {
38+
type: "string",
39+
label: "First Name",
40+
description: "The contact's first name.",
41+
optional: true,
42+
},
43+
lastName: {
44+
type: "string",
45+
label: "Last Name",
46+
description: "The contact's last name.",
47+
optional: true,
48+
},
49+
customFields: {
50+
type: "object",
51+
label: "Custom Fields",
52+
description: "A key-value collection of custom contact fields which can be used in the system. Only already existing custom fields will be saved.",
53+
optional: true,
54+
},
55+
consentIP: {
56+
type: "string",
57+
label: "Consent IP",
58+
description: "IP address of consent to send this contact(s) your email. If not provided your current public IP address is used for consent.",
59+
optional: true,
60+
},
61+
consentDate: {
62+
type: "string",
63+
label: "Consent Date",
64+
description: "Date of consent to send this contact(s) your email. If not provided current date is used for consent.",
65+
optional: true,
66+
},
67+
consentTracking: {
68+
type: "string",
69+
label: "Consent Tracking",
70+
description: "Tracking of consent to send this contact(s) your email. Defaults to \"Unknown\".",
71+
options: CONSENT_TRACKING_OPTIONS,
72+
optional: true,
73+
},
74+
},
75+
async run({ $ }) {
76+
const response = await this.app.addContact({
77+
$,
78+
params: {
79+
listnames: parseObject(this.listNames),
80+
},
81+
data: [
82+
{
83+
Email: this.email,
84+
Status: this.status,
85+
FirstName: this.firstName,
86+
LastName: this.lastName,
87+
CustomFields: parseObject(this.customFields),
88+
Consent: {
89+
ConsentIP: this.consentIP,
90+
ConsentDate: this.consentDate,
91+
ConsentTracking: this.consentTracking,
92+
},
93+
},
94+
],
95+
});
96+
97+
if (("success" in response) && response.success === "false") {
98+
throw new ConfigurationError(response.error);
99+
}
100+
101+
$.export("$summary", `Successfully added contact ${this.email} to the mailing list`);
102+
return response;
103+
},
104+
};

0 commit comments

Comments
 (0)