dbm-graph-api 1.1.58 → 1.1.60

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dbm-graph-api",
3
- "version": "1.1.58",
3
+ "version": "1.1.60",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -13,7 +13,7 @@
13
13
  "dependencies": {
14
14
  "@aws-sdk/client-s3": "^3.984.0",
15
15
  "@aws-sdk/s3-request-presigner": "^3.984.0",
16
- "dbm": "^1.4.13",
16
+ "dbm": "^1.4.14",
17
17
  "html-to-text": "^9.0.5",
18
18
  "mime": "^4.1.0",
19
19
  "node-cron": "^4.2.1",
@@ -38,7 +38,7 @@ export default class AddAndProcessAction extends Dbm.core.BaseObject {
38
38
  }
39
39
 
40
40
  let processingActionStatus = await database.getTypeObject("status/actionStatus", "processing");
41
- await action.replaceIncomingRelation(processingActionStatus, "for", "status/actionStatus");
41
+ await action.incomingRelations.replace(processingActionStatus, "for", "status/actionStatus");
42
42
 
43
43
  let processActionItem = Dbm.getInstance().repository.getItemIfExists("graphApi/processAction/" + type);
44
44
 
@@ -47,11 +47,11 @@ export default class AddAndProcessAction extends Dbm.core.BaseObject {
47
47
  await processActionItem.controller.process(action);
48
48
 
49
49
  let doneActionStatus = await database.getTypeObject("status/actionStatus", "done");
50
- await action.replaceIncomingRelation(doneActionStatus, "for", "status/actionStatus");
50
+ await action.incomingRelations.replace(doneActionStatus, "for", "status/actionStatus");
51
51
  }
52
52
  else {
53
53
  let doneActionStatus = await database.getTypeObject("status/actionStatus", "noAction");
54
- await action.replaceIncomingRelation(doneActionStatus, "for", "status/actionStatus");
54
+ await action.incomingRelations.replace(doneActionStatus, "for", "status/actionStatus");
55
55
  }
56
56
  }
57
57
 
@@ -7,6 +7,6 @@ export default class ReplaceIncomigRelation extends EditBaseObject {
7
7
  }
8
8
 
9
9
  async performChange(aObject, aData, aRequest) {
10
- await aObject.replaceIncomingRelation(aData["value"], aData["type"], aData["objectType"]);
10
+ await aObject.incomingRelations.replace(aData["value"], aData["type"], aData["objectType"]);
11
11
  }
12
12
  }
@@ -7,6 +7,6 @@ export default class ReplaceMultipleIncomingRelations extends EditBaseObject {
7
7
  }
8
8
 
9
9
  async performChange(aObject, aData, aRequest) {
10
- await aObject.replaceMultipleIncomingRelations(aData["value"], aData["type"], aData["objectType"]);
10
+ await aObject.incomingRelations.replaceMultiple(aData["value"], aData["type"], aData["objectType"]);
11
11
  }
12
12
  }
@@ -7,6 +7,6 @@ export default class ReplaceMultipleOutgoingRelations extends EditBaseObject {
7
7
  }
8
8
 
9
9
  async performChange(aObject, aData, aRequest) {
10
- await aObject.replaceMultipleOutgoingRelations(aData["value"], aData["type"]), aData["objectType"];
10
+ await aObject.outgoingRelations.replaceMultiple(aData["value"], aData["type"]), aData["objectType"];
11
11
  }
12
12
  }
@@ -7,6 +7,6 @@ export default class ReplaceOutgoingRelation extends EditBaseObject {
7
7
  }
8
8
 
9
9
  async performChange(aObject, aData, aRequest) {
10
- await aObject.replaceOutgoingRelation(aData["value"], aData["type"], aData["objectType"]);
10
+ await aObject.outgoingRelations.replace(aData["value"], aData["type"], aData["objectType"]);
11
11
  }
12
12
  }
@@ -190,6 +190,9 @@ export const fullEncodeSetup = function() {
190
190
  registerEncoding("menuItem", new DbmGraphApi.range.encode.MenuItem());
191
191
 
192
192
  registerEncoding("action", new DbmGraphApi.range.encode.Action());
193
+
194
+ registerEncoding("review", new DbmGraphApi.range.encode.Review());
195
+ registerEncoding("reviewSource", new DbmGraphApi.range.encode.ReviewSource());
193
196
  }
194
197
 
195
198
  export const registerDataFunction = function(aName, aDataFunction) {
@@ -265,6 +268,8 @@ export const fullProcessActionSetup = function() {
265
268
  registerProcessActionFunction("pageUpdates/updateCategoryListing", new DbmGraphApi.processAction.pageUpdates.UpdateCategoryListing());
266
269
  registerProcessActionFunction("pageUpdates/updateRenderedContent", new DbmGraphApi.processAction.pageUpdates.UpdateRenderedContent());
267
270
  registerProcessActionFunction("pageUpdates/clearCache", new DbmGraphApi.processAction.pageUpdates.ClearCloudflareCache());
271
+
272
+ registerProcessActionFunction("googleMaps/updateReviews", new DbmGraphApi.processAction.googleMaps.UpdateReviews());
268
273
  }
269
274
 
270
275
  export const setupInternalTaskRunner = function() {
@@ -0,0 +1,54 @@
1
+ import Dbm from "dbm";
2
+
3
+ export default class UpdateReviews extends Dbm.core.BaseObject {
4
+ _construct() {
5
+ super._construct();
6
+ }
7
+
8
+ async process(aAction) {
9
+ //console.log("UpdateReviews:process");
10
+ //console.log(aAction);
11
+
12
+ let database = Dbm.node.getDatabase();
13
+
14
+ let place = await aAction.singleObjectRelationQuery("out:from:google/place");
15
+ let placeId = await place.getIdentifier();
16
+
17
+ let reviews = await Dbm.node.googlemaps.getReviews(placeId);
18
+
19
+ let currentArray = reviews;
20
+ let currentArrayLength = currentArray.length;
21
+ for(let i = 0; i < currentArrayLength; i++) {
22
+ let currentReview = currentArray[i];
23
+ let reviewId = currentReview["name"];
24
+
25
+ let reviewSource = await database.getIdentifiableObjectIfExists("reviewSource/googleReview", reviewId);
26
+ if(!reviewSource) {
27
+
28
+ reviewSource = await database.createObject("private", ["reviewSource", "reviewSource/googleReview"]);
29
+ await reviewSource.setIdentifier(reviewId);
30
+ await reviewSource.addLinkedType("type/reviewSourceType", "google");
31
+ await reviewSource.updateField("date", currentReview["publishTime"]);
32
+ await reviewSource.updateField("rating", currentReview["rating"]);
33
+ await reviewSource.updateField("description", Dbm.objectPath(currentReview, "originalText.text"));
34
+ await reviewSource.updateField("name", Dbm.objectPath(currentReview, "authorAttribution.displayName") + ", " + currentReview["rating"] + " stars, " + currentReview["publishTime"].split("T")[0]);
35
+ await reviewSource.updateField("from", Dbm.objectPath(currentReview, "authorAttribution.displayName"));
36
+ await reviewSource.updateField("imageUrl", Dbm.objectPath(currentReview, "authorAttribution.photoUri"));
37
+ await reviewSource.updateField("link", currentReview["googleMapsUri"]);
38
+
39
+ await reviewSource.outgoingRelations.add(place, "for");
40
+
41
+ let review = await database.createObject("public", ["review"]);
42
+
43
+ await review.outgoingRelations.add(reviewSource, "from");
44
+ await review.updateField("date", currentReview["publishTime"]);
45
+ await review.updateField("rating", currentReview["rating"]);
46
+ await review.updateField("description", Dbm.objectPath(currentReview, "originalText.text"));
47
+ await review.updateField("name", Dbm.objectPath(currentReview, "authorAttribution.displayName") + ", " + currentReview["rating"] + " stars, " + currentReview["publishTime"].split("T")[0]);
48
+ await review.updateField("from", Dbm.objectPath(currentReview, "authorAttribution.displayName"));
49
+
50
+ await review.addActionTrigger("review/created");
51
+ }
52
+ }
53
+ }
54
+ }
@@ -0,0 +1 @@
1
+ export {default as UpdateReviews} from "./UpdateReviews.js";
@@ -2,6 +2,7 @@ export * as pageUpdates from "./pageUpdates/index.js";
2
2
  export * as httpRequests from "./httpRequests/index.js";
3
3
  export * as actionGroup from "./actionGroup/index.js";
4
4
  export * as communication from "./communication/index.js";
5
+ export * as googleMaps from "./googleMaps/index.js";
5
6
 
6
7
  export {default as Example} from "./Example.js";
7
8
  export {default as HandleFormSubmission} from "./HandleFormSubmission.js";
@@ -0,0 +1,25 @@
1
+ import Dbm from "dbm";
2
+ import EncodeBaseObject from "./EncodeBaseObject.js";
3
+
4
+ export default class Review extends EncodeBaseObject {
5
+ _construct() {
6
+ super._construct();
7
+ }
8
+
9
+ async getEncodedData(aId, aEncodingSession) {
10
+
11
+ let returnObject = {};
12
+
13
+ let object = Dbm.getInstance().repository.getItem("graphDatabase").controller.getObject(aId);
14
+
15
+ let fields = await object.getFields();
16
+ returnObject["from"] = fields["from"];
17
+ returnObject["date"] = fields["date"];
18
+ returnObject["description"] = fields["description"];
19
+ returnObject["rating"] = fields["rating"];
20
+
21
+ returnObject["source"] = await aEncodingSession.encodeObjectOrNull(await object.singleObjectRelationQuery("out:from:reviewSource"), "reviewSource");
22
+
23
+ return returnObject;
24
+ }
25
+ }
@@ -0,0 +1,23 @@
1
+ import Dbm from "dbm";
2
+ import EncodeBaseObject from "./EncodeBaseObject.js";
3
+
4
+ export default class ReviewSource extends EncodeBaseObject {
5
+ _construct() {
6
+ super._construct();
7
+ }
8
+
9
+ async getEncodedData(aId, aEncodingSession) {
10
+
11
+ let returnObject = {};
12
+
13
+ let object = Dbm.getInstance().repository.getItem("graphDatabase").controller.getObject(aId);
14
+
15
+ let fields = await object.getFields();
16
+ returnObject["imageUrl"] = fields["imageUrl"];
17
+ returnObject["link"] = fields["link"];
18
+
19
+ returnObject["type"] = await aEncodingSession.encodeObjectOrNull(await object.singleObjectRelationQuery("in:for:type/reviewSourceType"), "type");
20
+
21
+ return returnObject;
22
+ }
23
+ }
@@ -30,5 +30,7 @@ export {default as MenuLocation} from "./MenuLocation.js";
30
30
  export {default as Menu} from "./Menu.js";
31
31
  export {default as MenuItem} from "./MenuItem.js";
32
32
  export {default as Action} from "./Action.js";
33
+ export {default as Review} from "./Review.js";
34
+ export {default as ReviewSource} from "./ReviewSource.js";
33
35
 
34
36
  export * as admin from "./admin/index.js";