@plusscommunities/pluss-core-aws 1.4.12-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.
@@ -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
- const logId = log("deleteRef", "Params", JSON.stringify(params));
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
  });
@@ -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
- const logId = log("editRef", "Params", { table, keyCol, id, updates });
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) => {
@@ -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
  });
@@ -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
- const logId = log("indexQuery", "Query", JSON.stringify(query));
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
- const logId = log("updateAttribute", "Params", params);
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
  });
@@ -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
- const logId = log("updateRef", "Params", params);
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
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plusscommunities/pluss-core-aws",
3
- "version": "1.4.12-beta.0",
3
+ "version": "1.4.13-beta.0",
4
4
  "description": "Core extension package for Pluss Communities platform",
5
5
  "scripts": {
6
6
  "betapatch": "npm version prepatch --preid=beta",