dbm-graph-api 1.1.30 → 1.1.31

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.30",
3
+ "version": "1.1.31",
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.741.0",
15
15
  "@aws-sdk/s3-request-presigner": "^3.741.0",
16
- "dbm": "^1.2.0",
16
+ "dbm": "^1.2.1",
17
17
  "mime": "^4.0.6",
18
18
  "sharp": "^0.33.5",
19
19
  "ws": "^8.18.0"
@@ -23,8 +23,8 @@ export default class AddAndProcessAction extends Dbm.core.BaseObject {
23
23
  await action.addIncomingRelation(actionType, "for");
24
24
 
25
25
  if(aData["from"]) {
26
- let fromItem = database.getItem(1*aData["from"]);
27
- await action.addIncomingRelation(fromItem, "from");
26
+ let fromItem = database.getObject(1*aData["from"]);
27
+ await action.addOutgoingRelation(fromItem, "from");
28
28
  }
29
29
 
30
30
  let processingActionStatus = await database.getTypeObject("status/actionStatus", "processing");
@@ -0,0 +1,15 @@
1
+ import Dbm from "dbm";
2
+ import EditBaseObject from "./EditBaseObject.js";
3
+
4
+ export default class AddAction extends EditBaseObject {
5
+ _construct() {
6
+ super._construct();
7
+ }
8
+
9
+ async performChange(aObject, aData, aRequest) {
10
+ let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
11
+
12
+ console.log(aData["type"], aObject);
13
+ await database.addActionToProcess(aData["type"], [aObject]);
14
+ }
15
+ }
@@ -14,6 +14,7 @@ export {default as ReplaceMultipleIncomingRelations} from "./ReplaceMultipleInco
14
14
  export {default as ReplaceMultipleOutgoingRelations} from "./ReplaceMultipleOutgoingRelations.js";
15
15
  export {default as AddObjectType} from "./AddObjectType.js";
16
16
  export {default as RemoveObjectType} from "./RemoveObjectType.js";
17
+ export {default as AddAction} from "./AddAction.js";
17
18
 
18
19
 
19
20
  export const fullSetup = function() {
@@ -95,4 +96,10 @@ export const fullSetup = function() {
95
96
  let currentSelect = new DbmGraphApi.admin.edit.RemoveObjectType();
96
97
  currentSelect.item.register(prefix + name);
97
98
  }
99
+
100
+ {
101
+ let name = "addAction";
102
+ let currentSelect = new DbmGraphApi.admin.edit.AddAction();
103
+ currentSelect.item.register(prefix + name);
104
+ }
98
105
  }
@@ -211,6 +211,8 @@ let fullEncodeSetup = function() {
211
211
  registerEncoding("atLocation", new DbmGraphApi.range.encode.AtLocation());
212
212
  registerEncoding("location", new DbmGraphApi.range.encode.Location());
213
213
  registerEncoding("mainImage", new DbmGraphApi.range.encode.MainImage());
214
+ registerEncoding("linkPreview", new DbmGraphApi.range.encode.LinkPreview());
215
+ registerEncoding("publishDate", new DbmGraphApi.range.encode.PublishDate());
214
216
  }
215
217
 
216
218
  export {fullEncodeSetup};
@@ -276,6 +278,8 @@ let fullProcessActionSetup = function() {
276
278
  registerProcessActionFunction("example", new DbmGraphApi.processAction.Example());
277
279
 
278
280
  registerProcessActionFunction("handleFormSubmission", new DbmGraphApi.processAction.HandleFormSubmission());
281
+
282
+ registerProcessActionFunction("pageUpdates/updateCategoryListing", new DbmGraphApi.processAction.pageUpdates.UpdateCategoryListing());
279
283
  }
280
284
 
281
285
  export {fullProcessActionSetup};
@@ -389,7 +393,6 @@ export const setupEndpoints = function(aServer) {
389
393
  url += "/";
390
394
  }
391
395
 
392
- console.log(url);
393
396
  //METODO: check visibility in database
394
397
  let request = new UrlRequest();
395
398
  request.setup(aRequest, aReply);
@@ -1,2 +1,4 @@
1
+ export * as pageUpdates from "./pageUpdates/index.js";
2
+
1
3
  export {default as Example} from "./Example.js";
2
4
  export {default as HandleFormSubmission} from "./HandleFormSubmission.js";
@@ -0,0 +1,71 @@
1
+ import Dbm from "dbm";
2
+
3
+ export default class UpdateCategoryListing extends Dbm.core.BaseObject {
4
+ _construct() {
5
+ super._construct();
6
+ }
7
+
8
+ async process(aAction) {
9
+ console.log("UpdateCategoryListing:process");
10
+ console.log(aAction);
11
+
12
+ let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
13
+ let page = await aAction.singleObjectRelationQuery("out:from:page");
14
+
15
+ let categories = await page.objectRelationQuery("out:in:group/pageCategory");
16
+ let links = await page.objectRelationQuery("in:for:linkPreview");
17
+
18
+ let defaultLinks = [];
19
+ {
20
+ let currentArray = links;
21
+ let currentArrayLength = currentArray.length;
22
+ for(let i = 0; i < currentArrayLength; i++) {
23
+ let currentLink = currentArray[i];
24
+
25
+ let mode = await currentLink.getSingleLinkedType("type/listUpdateMode");
26
+
27
+ if(mode === "byCategories") {
28
+ defaultLinks.push(currentLink);
29
+ }
30
+ }
31
+
32
+ if(defaultLinks.length === 0) {
33
+ let link = await database.createObject("public", ["linkPreview"]);
34
+ await link.addLinkedType("type/listUpdateMode", "byCategories");
35
+ await link.addOutgoingRelation(page, "for");
36
+
37
+ defaultLinks.push(link);
38
+ }
39
+ }
40
+
41
+ let categoryListIds = [];
42
+ {
43
+ let currentArray = categories;
44
+ let currentArrayLength = currentArray.length;
45
+ for(let i = 0; i < currentArrayLength; i++) {
46
+ let currentCategory = currentArray[i];
47
+
48
+ let list = await currentCategory.singleObjectRelationQuery("out:for:linkList");
49
+
50
+ if(!list) {
51
+ list = await database.createObject("public", ["linkList"]);
52
+ let fields = await currentCategory.getFields();
53
+ await list.updateField("name", fields["name"] + " (page category list)");
54
+ await currentCategory.addOutgoingRelation(list, "for");
55
+ }
56
+
57
+ categoryListIds.push(list.id);
58
+ }
59
+ }
60
+
61
+ {
62
+ let currentArray = defaultLinks;
63
+ let currentArrayLength = currentArray.length;
64
+ for(let i = 0; i < currentArrayLength; i++) {
65
+ let currentLink = currentArray[i];
66
+
67
+ await currentLink.replaceMultipleOutgoingRelations(categoryListIds, "in", "linkList");
68
+ }
69
+ }
70
+ }
71
+ }
@@ -0,0 +1 @@
1
+ export {default as UpdateCategoryListing} from "./UpdateCategoryListing.js";
@@ -0,0 +1,38 @@
1
+ import Dbm from "dbm";
2
+ import EncodeBaseObject from "./EncodeBaseObject.js";
3
+
4
+ export default class LinkPreview 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["title"] = fields["title"] !== undefined ? fields["title"] : null;
17
+ returnObject["description"] = fields["description"] !== undefined ? fields["description"] : null;
18
+ returnObject["linkText"] = fields["linkText"] !== undefined ? fields["linkText"] : null;
19
+
20
+ await aEncodingSession.encodeObjectOrNull(object, "mainImage");
21
+
22
+ {
23
+ let relatedItem = await object.singleObjectRelationQuery("out:for:page");
24
+
25
+ if(relatedItem) {
26
+ returnObject["page"] = await aEncodingSession.encodeObjectOrNull(relatedItem, "url");
27
+ await aEncodingSession.encodeObjectOrNull(relatedItem, "title");
28
+ await aEncodingSession.encodeObjectOrNull(relatedItem, "mainImage");
29
+ await aEncodingSession.encodeObjectOrNull(relatedItem, "publishDate");
30
+ }
31
+ else {
32
+ returnObject["link"] = fields["link"] !== undefined ? fields["link"] : null;
33
+ }
34
+ }
35
+
36
+ return returnObject;
37
+ }
38
+ }
@@ -0,0 +1,21 @@
1
+ import Dbm from "dbm";
2
+ import EncodeBaseObject from "./EncodeBaseObject.js";
3
+
4
+ export default class PublishDate 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
+
17
+ returnObject["publishDate"] = fields["publishDate"] ? fields["publishDate"] : null;
18
+
19
+ return returnObject;
20
+ }
21
+ }
@@ -7,7 +7,7 @@ export default class UrlRequest extends EncodeBaseObject {
7
7
  }
8
8
 
9
9
  async getEncodedData(aId, aEncodingSession) {
10
- console.log("UrlRequest::getEncodedData");
10
+ //console.log("UrlRequest::getEncodedData");
11
11
 
12
12
  let returnObject = {};
13
13
 
@@ -20,5 +20,7 @@ export {default as HelpSection} from "./HelpSection.js";
20
20
  export {default as MainImage} from "./MainImage.js";
21
21
  export {default as Location} from "./Location.js";
22
22
  export {default as AtLocation} from "./AtLocation.js";
23
+ export {default as LinkPreview} from "./LinkPreview.js";
24
+ export {default as PublishDate} from "./PublishDate.js";
23
25
 
24
26
  export * as admin from "./admin/index.js";