@plusscommunities/pluss-core-aws 2.0.25-auth.0 → 2.0.25-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.
Files changed (90) hide show
  1. package/aws/getDefaultEmailAddress.js +21 -21
  2. package/aws/getEmailService.js +16 -16
  3. package/aws/getEmailServiceInfo.js +26 -26
  4. package/aws/sendEmail.js +31 -31
  5. package/config.js +1 -1
  6. package/db/activity/publishActivity.js +22 -22
  7. package/db/analytics/checkActivityExists.js +15 -15
  8. package/db/analytics/logAnalyticsActivity.js +69 -37
  9. package/db/analytics/scheduleOldAggregation.js +14 -14
  10. package/db/auth/getSiteSetting.js +12 -12
  11. package/db/auth/getSiteUserTypes.js +16 -16
  12. package/db/auth/getUserAuth.js +13 -13
  13. package/db/automatedactions/getActionBySiteTrigger.js +9 -9
  14. package/db/common/deleteRef.js +21 -21
  15. package/db/common/editRef.js +36 -36
  16. package/db/common/getRef.js +23 -23
  17. package/db/common/getTableCount.js +18 -18
  18. package/db/common/indexQuery.js +17 -17
  19. package/db/common/indexQueryRecursive.js +20 -20
  20. package/db/common/scanRef.js +18 -18
  21. package/db/common/scanRefRecursive.js +20 -20
  22. package/db/common/updateAttribute.js +27 -27
  23. package/db/common/updateRef.js +20 -20
  24. package/db/linkedUsers/getLinkedBy.js +21 -21
  25. package/db/linkedUsers/getLinkedTo.js +21 -21
  26. package/db/notifications/deleteNotificationsByEntity.js +21 -21
  27. package/db/notifications/getNotificationSetting.js +14 -14
  28. package/db/notifications/publishNotifications.js +39 -39
  29. package/db/scheduledActions/deleteActionQueue.js +1 -1
  30. package/db/scheduledActions/getActionQueueByEntityId.js +10 -10
  31. package/db/scheduledActions/getActionQueueByEntityKey.js +9 -9
  32. package/db/scheduledActions/getActionQueueById.js +9 -9
  33. package/db/scheduledActions/getActionQueueByTriggerAt.js +14 -14
  34. package/db/scheduledActions/updateActionQueue.js +29 -29
  35. package/db/strings/getString.js +20 -20
  36. package/db/strings/logUpdate.js +18 -18
  37. package/db/templates/getTemplateById.js +1 -1
  38. package/db/templates/getTemplatesList.js +10 -10
  39. package/db/templates/updateTemplate.js +9 -9
  40. package/db/users/getRole.js +1 -1
  41. package/db/users/getUser.js +9 -9
  42. package/db/users/getUserByEmail.js +17 -17
  43. package/helper/audience/filterByAudienceType.js +27 -27
  44. package/helper/audience/filterOnAudienceType.js +26 -26
  45. package/helper/audience/getAudience.js +187 -187
  46. package/helper/audience/getMatchingAudienceTypes.js +21 -21
  47. package/helper/audience/getMatchingAudienceTypesFromPreview.js +60 -60
  48. package/helper/audience/getMatchingTags.js +15 -15
  49. package/helper/audience/isValidAudience.js +20 -20
  50. package/helper/auth/checkTokenBlacklist.js +17 -17
  51. package/helper/auth/getApiKeyFromReq.js +2 -2
  52. package/helper/auth/getSessionUser.js +70 -85
  53. package/helper/auth/getSessionUserFromReq.js +2 -2
  54. package/helper/auth/getSessionUserFromReqAuthKey.js +11 -11
  55. package/helper/auth/validateApiKey.js +32 -32
  56. package/helper/auth/validateMasterAuth.js +174 -174
  57. package/helper/auth/validateSiteAccess.js +12 -12
  58. package/helper/auth/validateSiteSetting.js +7 -7
  59. package/helper/auth/validateUserLoggedIn.js +19 -19
  60. package/helper/createGuid.js +5 -5
  61. package/helper/generateJsonResponse.js +27 -27
  62. package/helper/getUserPreview.js +57 -57
  63. package/helper/getUserPreviewFromHeader.js +17 -17
  64. package/helper/getUserPreviewFromReq.js +17 -17
  65. package/helper/hqPublishing.js +45 -0
  66. package/helper/index.js +28 -28
  67. package/helper/notifySiteConfigs.js +132 -0
  68. package/helper/opengraph/getOpenGraph.js +12 -12
  69. package/helper/rates/checkRateLimit.js +38 -38
  70. package/helper/requestToSource.js +10 -10
  71. package/helper/sendEmail.js +120 -120
  72. package/helper/templates/replacePlaceHolders.js +29 -29
  73. package/helper/time/getLocalTimestamp.js +18 -18
  74. package/helper/time/getSiteTimezone.js +11 -11
  75. package/helper/triggerAutomatedAction.js +25 -25
  76. package/helper/userToUserPreview.js +23 -23
  77. package/helper/users/getUserTypesByPermission.js +24 -24
  78. package/helper/users/getUsersByPermission.js +20 -20
  79. package/notification/prepNotification.js +144 -144
  80. package/notification/sendNotifications.js +166 -166
  81. package/package.json +35 -40
  82. package/templates/supportTicketEmails.js +8 -8
  83. package/helper/auth/context/AuthenticationContext.js +0 -50
  84. package/helper/auth/context/AuthenticationStrategy.js +0 -20
  85. package/helper/auth/context/auth0/Strategy.js +0 -12
  86. package/helper/auth/context/auth0/functions/decodeAccessToken.js +0 -102
  87. package/helper/auth/context/auth0/functions/getSessionUser.js +0 -21
  88. package/helper/auth/context/boltonclarke/Strategy.js +0 -10
  89. package/helper/auth/context/cognito/Strategy.js +0 -12
  90. package/helper/auth/context/cognito/functions/getSessionUser.js +0 -76
@@ -1,26 +1,26 @@
1
1
  const AWS = require("aws-sdk");
2
2
 
3
3
  module.exports = (accessKey, secretKey) => {
4
- return new Promise((resolve, reject) => {
5
- if (accessKey && secretKey) {
6
- AWS.config.update({
7
- accessKeyId: accessKey,
8
- secretAccessKey: secretKey,
9
- });
4
+ return new Promise((resolve, reject) => {
5
+ if (accessKey && secretKey) {
6
+ AWS.config.update({
7
+ accessKeyId: accessKey,
8
+ secretAccessKey: secretKey,
9
+ });
10
10
 
11
- const sesv2 = new AWS.SESV2();
12
- const params = { PageSize: 1 };
13
- sesv2.listEmailIdentities(params, (err, data) => {
14
- if (err) return reject(err);
15
- const { EmailIdentities } = data;
16
- return resolve(
17
- EmailIdentities && EmailIdentities.length > 0
18
- ? EmailIdentities[0]
19
- : null
20
- );
21
- });
22
- } else {
23
- resolve(null);
24
- }
25
- });
11
+ const sesv2 = new AWS.SESV2();
12
+ const params = { PageSize: 1 };
13
+ sesv2.listEmailIdentities(params, (err, data) => {
14
+ if (err) return reject(err);
15
+ const { EmailIdentities } = data;
16
+ return resolve(
17
+ EmailIdentities && EmailIdentities.length > 0
18
+ ? EmailIdentities[0]
19
+ : null,
20
+ );
21
+ });
22
+ } else {
23
+ resolve(null);
24
+ }
25
+ });
26
26
  };
@@ -1,21 +1,21 @@
1
1
  const AWS = require("aws-sdk");
2
2
 
3
3
  module.exports = (accessKey, secretKey) => {
4
- return new Promise((resolve, reject) => {
5
- if (accessKey && secretKey) {
6
- AWS.config.update({
7
- accessKeyId: accessKey,
8
- secretAccessKey: secretKey,
9
- });
4
+ return new Promise((resolve, reject) => {
5
+ if (accessKey && secretKey) {
6
+ AWS.config.update({
7
+ accessKeyId: accessKey,
8
+ secretAccessKey: secretKey,
9
+ });
10
10
 
11
- const sesv2 = new AWS.SESV2();
12
- const params = {};
13
- sesv2.getAccount(params, (err, data) => {
14
- if (err) return reject(err);
15
- return resolve(data);
16
- });
17
- } else {
18
- resolve(null);
19
- }
20
- });
11
+ const sesv2 = new AWS.SESV2();
12
+ const params = {};
13
+ sesv2.getAccount(params, (err, data) => {
14
+ if (err) return reject(err);
15
+ return resolve(data);
16
+ });
17
+ } else {
18
+ resolve(null);
19
+ }
20
+ });
21
21
  };
@@ -3,31 +3,31 @@ const getDefaultEmailAddress = require("./getDefaultEmailAddress");
3
3
  const { getConfig } = require("../config");
4
4
 
5
5
  module.exports = async (accessKey, secretKey) => {
6
- const result = {
7
- enabled: false,
8
- sender: null,
9
- };
10
- const { emailConfig } = getConfig();
11
- const service = await getEmailService(accessKey, secretKey);
12
- console.log("Amazon SES status", {
13
- service,
14
- allwoSandbox: emailConfig.allwoSandbox,
15
- forceFallback: emailConfig.forceFallback,
16
- });
17
- if (emailConfig.forceFallback) return result;
6
+ const result = {
7
+ enabled: false,
8
+ sender: null,
9
+ };
10
+ const { emailConfig } = getConfig();
11
+ const service = await getEmailService(accessKey, secretKey);
12
+ console.log("Amazon SES status", {
13
+ service,
14
+ allwoSandbox: emailConfig.allwoSandbox,
15
+ forceFallback: emailConfig.forceFallback,
16
+ });
17
+ if (emailConfig.forceFallback) return result;
18
18
 
19
- if (
20
- service &&
21
- service.SendingEnabled &&
22
- (emailConfig.allwoSandbox || service.ProductionAccessEnabled) &&
23
- service.SendQuota.Max24HourSend > service.SendQuota.SentLast24Hours
24
- ) {
25
- result.enabled = true;
26
- const sender = await getDefaultEmailAddress(accessKey, secretKey);
27
- console.log("Amazon SES sender", sender);
28
- if (sender) {
29
- result.sender = sender.IdentityName;
30
- }
31
- }
32
- return result;
19
+ if (
20
+ service &&
21
+ service.SendingEnabled &&
22
+ (emailConfig.allwoSandbox || service.ProductionAccessEnabled) &&
23
+ service.SendQuota.Max24HourSend > service.SendQuota.SentLast24Hours
24
+ ) {
25
+ result.enabled = true;
26
+ const sender = await getDefaultEmailAddress(accessKey, secretKey);
27
+ console.log("Amazon SES sender", sender);
28
+ if (sender) {
29
+ result.sender = sender.IdentityName;
30
+ }
31
+ }
32
+ return result;
33
33
  };
package/aws/sendEmail.js CHANGED
@@ -2,36 +2,36 @@ const AWS = require("aws-sdk");
2
2
  const { getConfig } = require("../config");
3
3
 
4
4
  module.exports = (from, to, subject, content, access = null, bcc = null) => {
5
- return new Promise((resolve, reject) => {
6
- const { serverlessConfig } = getConfig();
7
- AWS.config.update({
8
- accessKeyId: access ? access.key : serverlessConfig.key,
9
- secretAccessKey: access ? access.secret : serverlessConfig.secret,
10
- });
5
+ return new Promise((resolve, reject) => {
6
+ const { serverlessConfig } = getConfig();
7
+ AWS.config.update({
8
+ accessKeyId: access ? access.key : serverlessConfig.key,
9
+ secretAccessKey: access ? access.secret : serverlessConfig.secret,
10
+ });
11
11
 
12
- const sesv2 = new AWS.SESV2();
13
- const params = {
14
- Content: {
15
- Simple: {
16
- Body: {
17
- Html: {
18
- Data: content,
19
- },
20
- },
21
- Subject: {
22
- Data: subject,
23
- },
24
- },
25
- },
26
- Destination: {
27
- ToAddresses: to.split(",").map((i) => i.trim()),
28
- BccAddresses: bcc ? bcc.split(",").map((i) => i.trim()) : [],
29
- },
30
- FromEmailAddress: from,
31
- };
32
- sesv2.sendEmail(params, (err, data) => {
33
- if (err) return reject(err);
34
- return resolve(data);
35
- });
36
- });
12
+ const sesv2 = new AWS.SESV2();
13
+ const params = {
14
+ Content: {
15
+ Simple: {
16
+ Body: {
17
+ Html: {
18
+ Data: content,
19
+ },
20
+ },
21
+ Subject: {
22
+ Data: subject,
23
+ },
24
+ },
25
+ },
26
+ Destination: {
27
+ ToAddresses: to.split(",").map((i) => i.trim()),
28
+ BccAddresses: bcc ? bcc.split(",").map((i) => i.trim()) : [],
29
+ },
30
+ FromEmailAddress: from,
31
+ };
32
+ sesv2.sendEmail(params, (err, data) => {
33
+ if (err) return reject(err);
34
+ return resolve(data);
35
+ });
36
+ });
37
37
  };
package/config.js CHANGED
@@ -1,5 +1,5 @@
1
1
  let settings = {};
2
2
  exports.getConfig = () => settings;
3
3
  exports.init = (config) => {
4
- settings = config;
4
+ settings = config;
5
5
  };
@@ -1,25 +1,25 @@
1
- const moment = require('moment');
2
- const updateRef = require('../common/updateRef');
3
- const { getMultiRowId } = require('../../helper');
1
+ const moment = require("moment");
2
+ const updateRef = require("../common/updateRef");
3
+ const { getMultiRowId } = require("../../helper");
4
4
 
5
5
  module.exports = (type, site, id, user, data) => {
6
- return new Promise((resolve, reject) => {
7
- const activity = {};
8
- const timestamp = moment.utc();
9
- activity.Timestamp = timestamp.toISOString();
10
- activity.UnixTimestamp = timestamp.unix();
11
- activity.Type = type;
12
- activity.Site = site;
13
- activity.Id = id;
14
- activity.User = user;
15
- activity.RowId = getMultiRowId([site, type, id, user.id]);
16
- activity.Data = data;
17
- updateRef(`adminactivity`, activity)
18
- .then(() => {
19
- resolve();
20
- }).catch(error => {
21
- reject(error);
22
- });
23
- });
6
+ return new Promise((resolve, reject) => {
7
+ const activity = {};
8
+ const timestamp = moment.utc();
9
+ activity.Timestamp = timestamp.toISOString();
10
+ activity.UnixTimestamp = timestamp.unix();
11
+ activity.Type = type;
12
+ activity.Site = site;
13
+ activity.Id = id;
14
+ activity.User = user;
15
+ activity.RowId = getMultiRowId([site, type, id, user.id]);
16
+ activity.Data = data;
17
+ updateRef(`adminactivity`, activity)
18
+ .then(() => {
19
+ resolve();
20
+ })
21
+ .catch((error) => {
22
+ reject(error);
23
+ });
24
+ });
24
25
  };
25
-
@@ -11,19 +11,19 @@ const indexQuery = require("../common/indexQuery");
11
11
  * @returns Whether there is any matching analytics activity
12
12
  */
13
13
  module.exports = async (entityId, entityType, actionType, userId) => {
14
- const result = await indexQuery("analytics", {
15
- IndexName: "AnalyticsActivityIndex",
16
- KeyConditionExpression: "ActivityId = :activityId",
17
- ExpressionAttributeValues: {
18
- ":activityId": getMultiRowId([entityId, entityType, actionType]),
19
- },
20
- });
21
- if (result && !_.isEmpty(result.Items)) {
22
- if (userId) {
23
- // check if there is matching analytics activity for that user
24
- return result.Items.some((item) => item.UserId === userId);
25
- }
26
- return true;
27
- }
28
- return false;
14
+ const result = await indexQuery("analytics", {
15
+ IndexName: "AnalyticsActivityIndex",
16
+ KeyConditionExpression: "ActivityId = :activityId",
17
+ ExpressionAttributeValues: {
18
+ ":activityId": getMultiRowId([entityId, entityType, actionType]),
19
+ },
20
+ });
21
+ if (result && !_.isEmpty(result.Items)) {
22
+ if (userId) {
23
+ // check if there is matching analytics activity for that user
24
+ return result.Items.some((item) => item.UserId === userId);
25
+ }
26
+ return true;
27
+ }
28
+ return false;
29
29
  };
@@ -2,6 +2,7 @@ const uuid = require("uuid");
2
2
  const moment = require("moment");
3
3
  const checkActivityExists = require("./checkActivityExists");
4
4
  const updateRef = require("../common/updateRef");
5
+ const getRole = require("../users/getRole");
5
6
  const { getMultiRowId, getRowId } = require("../../helper");
6
7
 
7
8
  /**
@@ -18,44 +19,75 @@ const { getMultiRowId, getRowId } = require("../../helper");
18
19
  * @returns Whether the activity was logged
19
20
  */
20
21
  module.exports = async (
21
- actionType,
22
- entityType,
23
- site,
24
- user,
25
- entityId,
26
- data,
27
- timestamp,
28
- uniqueActivity,
29
- uniqueToUser
22
+ actionType,
23
+ entityType,
24
+ site,
25
+ user,
26
+ entityId,
27
+ data,
28
+ timestamp,
29
+ uniqueActivity,
30
+ uniqueToUser,
30
31
  ) => {
31
- // Check if the activity already exists
32
- if (uniqueActivity) {
33
- const exists = await checkActivityExists(
34
- entityId,
35
- entityType,
36
- actionType,
37
- uniqueToUser && user ? user.id : null
38
- );
39
- if (exists) {
40
- return false;
41
- }
42
- }
32
+ // Check if the activity already exists
33
+ if (uniqueActivity) {
34
+ const exists = await checkActivityExists(
35
+ entityId,
36
+ entityType,
37
+ actionType,
38
+ uniqueToUser && user ? user.id : null,
39
+ );
40
+ if (exists) {
41
+ return false;
42
+ }
43
+ }
43
44
 
44
- // Log the activity
45
- const activity = {
46
- Id: uuid.v1(),
47
- Type: actionType,
48
- Timestamp: timestamp || moment.utc().valueOf(),
49
- EntityType: entityType,
50
- SubjectId: entityId,
51
- UserId: user.id,
52
- User: user,
53
- Site: site,
54
- EntityId: getRowId(entityId, entityType),
55
- ActivityId: getMultiRowId([entityId, entityType, actionType]),
56
- Data: data,
57
- };
45
+ // Enrich analytics events with the user's site-specific role type and category.
46
+ // Always resolved here via getRole rather than expecting callers to provide them because:
47
+ // 1. Most callers can't — stream handlers only have minimal embedded objects with no
48
+ // type/category fields.
49
+ // 2. user.type only carries the primary role, not the site-specific role.
50
+ // 3. user.category doesn't exist on the user object — category (staff/primary/linked)
51
+ // lives on the role record.
52
+ // Centralising here avoids burdening call sites with role resolution and guarantees
53
+ // accuracy (always reads current role, not potentially stale caller-provided values).
54
+ // getRole is a DynamoDB point-read (~5ms) and this runs async, so no user-facing latency impact.
55
+ let userType = null;
56
+ let userCategory = null;
58
57
 
59
- await updateRef(`analytics`, activity);
60
- return true;
58
+ try {
59
+ const role = await getRole(site, user.id);
60
+ if (role) {
61
+ userType = role.type || null;
62
+ userCategory = role.category || null;
63
+ }
64
+ } catch (e) {
65
+ // getRole failed — fall through to master fallback below
66
+ }
67
+
68
+ // Best-effort fallback: user.type is set from primary role, may not always be present
69
+ if (!userType && user.type === "master") {
70
+ userType = "master";
71
+ userCategory = "master";
72
+ }
73
+
74
+ // Log the activity
75
+ const activity = {
76
+ Id: uuid.v1(),
77
+ Type: actionType,
78
+ Timestamp: timestamp || moment.utc().valueOf(),
79
+ EntityType: entityType,
80
+ SubjectId: entityId,
81
+ UserId: user.id,
82
+ User: user,
83
+ Site: site,
84
+ EntityId: getRowId(entityId, entityType),
85
+ ActivityId: getMultiRowId([entityId, entityType, actionType]),
86
+ Data: data,
87
+ userType,
88
+ userCategory,
89
+ };
90
+
91
+ await updateRef(`analytics`, activity);
92
+ return true;
61
93
  };
@@ -2,19 +2,19 @@ const updateRef = require("../common/updateRef");
2
2
  const { getRowId } = require("../../helper");
3
3
 
4
4
  module.exports = (date, site) => {
5
- return new Promise((resolve, reject) => {
6
- const schedule = {
7
- Id: getRowId(site, date),
8
- Date: date,
9
- Site: site,
10
- };
5
+ return new Promise((resolve, reject) => {
6
+ const schedule = {
7
+ Id: getRowId(site, date),
8
+ Date: date,
9
+ Site: site,
10
+ };
11
11
 
12
- updateRef(`analyticsqueue`, schedule)
13
- .then(() => {
14
- resolve();
15
- })
16
- .catch((error) => {
17
- reject(error);
18
- });
19
- });
12
+ updateRef(`analyticsqueue`, schedule)
13
+ .then(() => {
14
+ resolve();
15
+ })
16
+ .catch((error) => {
17
+ reject(error);
18
+ });
19
+ });
20
20
  };
@@ -1,16 +1,16 @@
1
1
  const getRef = require("../common/getRef");
2
2
 
3
3
  module.exports = async (site, key) => {
4
- return new Promise((resolve, reject) => {
5
- getRef("sites", "Id", site)
6
- .then((item) => {
7
- if (item && item.Settings) {
8
- return resolve(item.Settings[key]);
9
- }
10
- return resolve(undefined);
11
- })
12
- .catch((error) => {
13
- return resolve(undefined);
14
- });
15
- });
4
+ return new Promise((resolve, reject) => {
5
+ getRef("sites", "Id", site)
6
+ .then((item) => {
7
+ if (item && item.Settings) {
8
+ return resolve(item.Settings[key]);
9
+ }
10
+ return resolve(undefined);
11
+ })
12
+ .catch((error) => {
13
+ return resolve(undefined);
14
+ });
15
+ });
16
16
  };
@@ -1,21 +1,21 @@
1
1
  const indexQuery = require("../common/indexQuery");
2
2
 
3
3
  module.exports = async (site) => {
4
- return new Promise((resolve, reject) => {
5
- const query = {
6
- IndexName: "UserTypesSiteIndex",
7
- KeyConditionExpression: "site = :site",
8
- ExpressionAttributeValues: {
9
- ":site": site,
10
- },
11
- };
4
+ return new Promise((resolve, reject) => {
5
+ const query = {
6
+ IndexName: "UserTypesSiteIndex",
7
+ KeyConditionExpression: "site = :site",
8
+ ExpressionAttributeValues: {
9
+ ":site": site,
10
+ },
11
+ };
12
12
 
13
- indexQuery("usertypes", query)
14
- .then((res) => {
15
- resolve(res.Items);
16
- })
17
- .catch((error) => {
18
- reject(error);
19
- });
20
- });
13
+ indexQuery("usertypes", query)
14
+ .then((res) => {
15
+ resolve(res.Items);
16
+ })
17
+ .catch((error) => {
18
+ reject(error);
19
+ });
20
+ });
21
21
  };
@@ -2,17 +2,17 @@ const getRef = require("../common/getRef");
2
2
  const _ = require("lodash");
3
3
 
4
4
  module.exports = (id) => {
5
- return new Promise((resolve, reject) => {
6
- getRef("users", "Id", id).then((data) => {
7
- if (_.isEmpty(data.Roles)) {
8
- return resolve([
9
- {
10
- site: data.site,
11
- type: data.type,
12
- },
13
- ]);
14
- }
15
- return resolve(data.Roles);
16
- });
17
- });
5
+ return new Promise((resolve, reject) => {
6
+ getRef("users", "Id", id).then((data) => {
7
+ if (_.isEmpty(data.Roles)) {
8
+ return resolve([
9
+ {
10
+ site: data.site,
11
+ type: data.type,
12
+ },
13
+ ]);
14
+ }
15
+ return resolve(data.Roles);
16
+ });
17
+ });
18
18
  };
@@ -1,14 +1,14 @@
1
1
  const indexQuery = require("../common/indexQuery");
2
2
 
3
3
  module.exports = async (site, trigger = null) => {
4
- const query = {
5
- IndexName: "SiteIndex",
6
- KeyConditionExpression: "Site = :site",
7
- ExpressionAttributeValues: {
8
- ":site": site,
9
- },
10
- };
4
+ const query = {
5
+ IndexName: "SiteIndex",
6
+ KeyConditionExpression: "Site = :site",
7
+ ExpressionAttributeValues: {
8
+ ":site": site,
9
+ },
10
+ };
11
11
 
12
- const { Items } = await indexQuery("automatedactions", query);
13
- return trigger ? Items.filter((i) => i.Trigger === trigger) : Items;
12
+ const { Items } = await indexQuery("automatedactions", query);
13
+ return trigger ? Items.filter((i) => i.Trigger === trigger) : Items;
14
14
  };
@@ -3,27 +3,27 @@ const dynamoDb = new AWS.DynamoDB.DocumentClient({ convertEmptyValues: true });
3
3
  const { log, generateLogId } = require("../../helper");
4
4
 
5
5
  module.exports = async (table, key, value) => {
6
- return new Promise((resolve, reject) => {
7
- const logId = generateLogId();
8
- const params = {
9
- TableName: `${process.env.tablePrefix}${table}`,
10
- Key: {},
11
- };
12
- params.Key[key] = value;
6
+ return new Promise((resolve, reject) => {
7
+ const logId = generateLogId();
8
+ const params = {
9
+ TableName: `${process.env.tablePrefix}${table}`,
10
+ Key: {},
11
+ };
12
+ params.Key[key] = value;
13
13
 
14
- // log("deleteRef", "Params", JSON.stringify(params), logId);
14
+ // log("deleteRef", "Params", JSON.stringify(params), logId);
15
15
 
16
- // write the todo to the database
17
- dynamoDb.delete(params, (error, data) => {
18
- // handle potential errors
19
- if (error) {
20
- log("deleteRef", "Error", error, logId);
21
- reject(error);
22
- return;
23
- }
24
- // log("deleteRef", "Success", "Deleted item", logId);
25
- resolve(data);
26
- return;
27
- });
28
- });
16
+ // write the todo to the database
17
+ dynamoDb.delete(params, (error, data) => {
18
+ // handle potential errors
19
+ if (error) {
20
+ log("deleteRef", "Error", error, logId);
21
+ reject(error);
22
+ return;
23
+ }
24
+ // log("deleteRef", "Success", "Deleted item", logId);
25
+ resolve(data);
26
+ return;
27
+ });
28
+ });
29
29
  };