@plusscommunities/pluss-core-aws 1.4.10-beta.0 → 1.4.13-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/aws/sendEmail.js +2 -1
- package/db/common/deleteRef.js +4 -3
- package/db/common/editRef.js +7 -6
- package/db/common/getRef.js +2 -2
- package/db/common/indexQuery.js +4 -3
- package/db/common/updateAttribute.js +4 -3
- package/db/common/updateRef.js +4 -3
- package/db/scheduledActions/updateActionQueue.js +1 -2
- package/helper/sendEmail.js +9 -4
- package/package.json +1 -1
package/aws/sendEmail.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const AWS = require("aws-sdk");
|
|
2
2
|
const { getConfig } = require("../config");
|
|
3
3
|
|
|
4
|
-
module.exports = (from, to, subject, content, access = null) => {
|
|
4
|
+
module.exports = (from, to, subject, content, access = null, bcc = null) => {
|
|
5
5
|
return new Promise((resolve, reject) => {
|
|
6
6
|
const { serverlessConfig } = getConfig();
|
|
7
7
|
AWS.config.update({
|
|
@@ -25,6 +25,7 @@ module.exports = (from, to, subject, content, access = null) => {
|
|
|
25
25
|
},
|
|
26
26
|
Destination: {
|
|
27
27
|
ToAddresses: to.split(",").map((i) => i.trim()),
|
|
28
|
+
BccAddresses: bcc ? bcc.split(",").map((i) => i.trim()) : [],
|
|
28
29
|
},
|
|
29
30
|
FromEmailAddress: from,
|
|
30
31
|
};
|
package/db/common/deleteRef.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
const AWS = require("aws-sdk");
|
|
2
2
|
const dynamoDb = new AWS.DynamoDB.DocumentClient({ convertEmptyValues: true });
|
|
3
|
-
const { log } = require("../../helper");
|
|
3
|
+
const { log, generateLogId } = require("../../helper");
|
|
4
4
|
|
|
5
5
|
module.exports = async (table, key, value) => {
|
|
6
6
|
return new Promise((resolve, reject) => {
|
|
7
|
+
const logId = generateLogId();
|
|
7
8
|
const params = {
|
|
8
9
|
TableName: `${process.env.tablePrefix}${table}`,
|
|
9
10
|
Key: {},
|
|
10
11
|
};
|
|
11
12
|
params.Key[key] = value;
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
// log("deleteRef", "Params", JSON.stringify(params), logId);
|
|
14
15
|
|
|
15
16
|
// write the todo to the database
|
|
16
17
|
dynamoDb.delete(params, (error, data) => {
|
|
@@ -20,7 +21,7 @@ module.exports = async (table, key, value) => {
|
|
|
20
21
|
reject(error);
|
|
21
22
|
return;
|
|
22
23
|
}
|
|
23
|
-
log("deleteRef", "Success", "Deleted item", logId);
|
|
24
|
+
// log("deleteRef", "Success", "Deleted item", logId);
|
|
24
25
|
resolve(data);
|
|
25
26
|
return;
|
|
26
27
|
});
|
package/db/common/editRef.js
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
const _ = require("lodash");
|
|
2
2
|
const getRef = require("./getRef");
|
|
3
3
|
const updateRef = require("./updateRef");
|
|
4
|
-
const { log } = require("../../helper");
|
|
4
|
+
const { log, generateLogId } = require("../../helper");
|
|
5
5
|
|
|
6
6
|
module.exports = async (table, keyCol, id, updates) => {
|
|
7
7
|
const cloneUpdates = _.cloneDeep(updates);
|
|
8
8
|
|
|
9
9
|
return new Promise((resolve, reject) => {
|
|
10
|
+
const logId = generateLogId();
|
|
10
11
|
updates[keyCol] = id;
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
// log("editRef", "Params", { table, keyCol, id, updates }, logId);
|
|
13
14
|
getRef(table, keyCol, id)
|
|
14
15
|
.then((item) => {
|
|
15
|
-
log("editRef", "GotItem", item);
|
|
16
|
+
// log("editRef", "GotItem", item);
|
|
16
17
|
Object.keys(cloneUpdates).forEach((key) => {
|
|
17
18
|
item[key] = cloneUpdates[key];
|
|
18
19
|
});
|
|
19
20
|
updateRef(table, item)
|
|
20
21
|
.then((res) => {
|
|
21
|
-
log("editRef", "Result", res, logId);
|
|
22
|
+
// log("editRef", "Result", res, logId);
|
|
22
23
|
resolve(res);
|
|
23
24
|
})
|
|
24
25
|
.catch((error) => {
|
|
@@ -27,13 +28,13 @@ module.exports = async (table, keyCol, id, updates) => {
|
|
|
27
28
|
});
|
|
28
29
|
})
|
|
29
30
|
.catch((error) => {
|
|
30
|
-
log("editRef", "NoEntry", "Existing entry doesn't exist", logId);
|
|
31
|
+
// log("editRef", "NoEntry", "Existing entry doesn't exist", logId);
|
|
31
32
|
cloneUpdates[keyCol] = id;
|
|
32
33
|
|
|
33
34
|
// insert if doesn't exit
|
|
34
35
|
updateRef(table, cloneUpdates)
|
|
35
36
|
.then((res) => {
|
|
36
|
-
log("editRef", "Result", res, logId);
|
|
37
|
+
// log("editRef", "Result", res, logId);
|
|
37
38
|
resolve(res);
|
|
38
39
|
})
|
|
39
40
|
.catch((error) => {
|
package/db/common/getRef.js
CHANGED
|
@@ -12,7 +12,7 @@ module.exports = async (table, key, value) => {
|
|
|
12
12
|
};
|
|
13
13
|
query.Key[key] = value;
|
|
14
14
|
|
|
15
|
-
log("getRef", "Query", query, logId);
|
|
15
|
+
// log("getRef", "Query", query, logId);
|
|
16
16
|
|
|
17
17
|
dynamoDb.get(query, (error, data) => {
|
|
18
18
|
if (error) {
|
|
@@ -20,7 +20,7 @@ module.exports = async (table, key, value) => {
|
|
|
20
20
|
reject(error);
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
|
-
log("getRef", "Success", data.Item, logId);
|
|
23
|
+
// log("getRef", "Success", data.Item, logId);
|
|
24
24
|
resolve(data.Item);
|
|
25
25
|
return;
|
|
26
26
|
});
|
package/db/common/indexQuery.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
const AWS = require("aws-sdk");
|
|
2
2
|
const dynamoDb = new AWS.DynamoDB.DocumentClient({ convertEmptyValues: true });
|
|
3
|
-
const { log } = require("../../helper");
|
|
3
|
+
const { log, generateLogId } = require("../../helper");
|
|
4
4
|
|
|
5
5
|
module.exports = async (table, query) => {
|
|
6
6
|
return new Promise((resolve, reject) => {
|
|
7
|
+
const logId = generateLogId();
|
|
7
8
|
query.TableName = `${process.env.tablePrefix}${table}`;
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
// log("indexQuery", "Query", JSON.stringify(query), logId);
|
|
10
11
|
|
|
11
12
|
// write the todo to the database
|
|
12
13
|
dynamoDb.query(query, (error, data) => {
|
|
@@ -16,7 +17,7 @@ module.exports = async (table, query) => {
|
|
|
16
17
|
reject(error);
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
19
|
-
log("indexQuery", "ResultLength", data.Items.length, logId);
|
|
20
|
+
// log("indexQuery", "ResultLength", data.Items.length, logId);
|
|
20
21
|
resolve(data);
|
|
21
22
|
return;
|
|
22
23
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const AWS = require("aws-sdk");
|
|
2
2
|
const dynamoDb = new AWS.DynamoDB.DocumentClient({ convertEmptyValues: true });
|
|
3
|
-
const { log } = require("../../helper");
|
|
3
|
+
const { log, generateLogId } = require("../../helper");
|
|
4
4
|
|
|
5
5
|
module.exports = (
|
|
6
6
|
table,
|
|
@@ -11,6 +11,7 @@ module.exports = (
|
|
|
11
11
|
action
|
|
12
12
|
) => {
|
|
13
13
|
return new Promise((resolve, reject) => {
|
|
14
|
+
const logId = generateLogId();
|
|
14
15
|
const params = {
|
|
15
16
|
TableName: `${process.env.tablePrefix}${table}`,
|
|
16
17
|
Key: {
|
|
@@ -20,14 +21,14 @@ module.exports = (
|
|
|
20
21
|
[attributeKey]: { Action: action, Value: attributeValue },
|
|
21
22
|
},
|
|
22
23
|
};
|
|
23
|
-
|
|
24
|
+
// log("updateAttribute", "Params", params, logId);
|
|
24
25
|
|
|
25
26
|
dynamoDb.update(params, (err, data) => {
|
|
26
27
|
if (err) {
|
|
27
28
|
log("updateAttribute", "Error", err, logId);
|
|
28
29
|
return reject(err);
|
|
29
30
|
}
|
|
30
|
-
log("updateAttribute", "Success", data, logId);
|
|
31
|
+
// log("updateAttribute", "Success", data, logId);
|
|
31
32
|
return resolve(data);
|
|
32
33
|
});
|
|
33
34
|
});
|
package/db/common/updateRef.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
const AWS = require("aws-sdk");
|
|
2
2
|
const dynamoDb = new AWS.DynamoDB.DocumentClient({ convertEmptyValues: true });
|
|
3
|
-
const { log } = require("../../helper");
|
|
3
|
+
const { log, generateLogId } = require("../../helper");
|
|
4
4
|
|
|
5
5
|
module.exports = async (table, data) => {
|
|
6
6
|
return new Promise((resolve, reject) => {
|
|
7
|
+
const logId = generateLogId();
|
|
7
8
|
const params = {
|
|
8
9
|
TableName: `${process.env.tablePrefix}${table}`,
|
|
9
10
|
Item: data,
|
|
10
11
|
};
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
// log("updateRef", "Params", params, logId);
|
|
13
14
|
|
|
14
15
|
// write the todo to the database
|
|
15
16
|
dynamoDb.put(params, (error) => {
|
|
@@ -19,7 +20,7 @@ module.exports = async (table, data) => {
|
|
|
19
20
|
reject(error);
|
|
20
21
|
return;
|
|
21
22
|
}
|
|
22
|
-
log("updateRef", "Result", data, logId);
|
|
23
|
+
// log("updateRef", "Result", data, logId);
|
|
23
24
|
resolve(data);
|
|
24
25
|
return;
|
|
25
26
|
});
|
|
@@ -6,7 +6,7 @@ module.exports = (rowId, update) => {
|
|
|
6
6
|
return new Promise(async (resolve, reject) => {
|
|
7
7
|
try {
|
|
8
8
|
const now = moment().valueOf();
|
|
9
|
-
const { Created, Updated, TriggerAt, Status, Recipients
|
|
9
|
+
const { Created, Updated, TriggerAt, Status, Recipients } = update;
|
|
10
10
|
if (!rowId) {
|
|
11
11
|
rowId = uuid.v1();
|
|
12
12
|
if (!Created) update.Created = now;
|
|
@@ -14,7 +14,6 @@ module.exports = (rowId, update) => {
|
|
|
14
14
|
} else {
|
|
15
15
|
if (!Updated) update.Updated = now;
|
|
16
16
|
}
|
|
17
|
-
update.EntityId = `${rowId}${Site}`;
|
|
18
17
|
if (TriggerAt) {
|
|
19
18
|
update.TriggerAt =
|
|
20
19
|
typeof TriggerAt === "string"
|
package/helper/sendEmail.js
CHANGED
|
@@ -8,9 +8,12 @@ module.exports = async (
|
|
|
8
8
|
subject,
|
|
9
9
|
content,
|
|
10
10
|
useTemplate,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
{
|
|
12
|
+
fromEmail = null,
|
|
13
|
+
excludeClientBranding = false,
|
|
14
|
+
brandingImage = null,
|
|
15
|
+
bcc = null,
|
|
16
|
+
}
|
|
14
17
|
) => {
|
|
15
18
|
const { communityConfig, serverlessConfig } = getConfig();
|
|
16
19
|
|
|
@@ -47,6 +50,7 @@ module.exports = async (
|
|
|
47
50
|
fromEmail ||
|
|
48
51
|
`"${communityConfig.name}" noreply@${communityConfig.subdomain}.plusscommunities.com'`,
|
|
49
52
|
to: toEmail,
|
|
53
|
+
bcc,
|
|
50
54
|
subject,
|
|
51
55
|
text: content,
|
|
52
56
|
html: content,
|
|
@@ -67,7 +71,8 @@ module.exports = async (
|
|
|
67
71
|
mailOptions.to,
|
|
68
72
|
mailOptions.subject,
|
|
69
73
|
mailOptions.html,
|
|
70
|
-
serverlessConfig
|
|
74
|
+
serverlessConfig,
|
|
75
|
+
mailOptions.bcc
|
|
71
76
|
);
|
|
72
77
|
console.log("Email success", toEmail, subject, result);
|
|
73
78
|
} catch (error) {
|
package/package.json
CHANGED