dbm-graph-api 1.1.16 → 1.1.17

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.16",
3
+ "version": "1.1.17",
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.1.11",
16
+ "dbm": "^1.1.12",
17
17
  "mime": "^4.0.6",
18
18
  "sharp": "^0.33.5",
19
19
  "ws": "^8.18.0"
@@ -0,0 +1,12 @@
1
+ import Dbm from "dbm";
2
+ import EditBaseObject from "./EditBaseObject.js";
3
+
4
+ export default class AddObjectType extends EditBaseObject {
5
+ _construct() {
6
+ super._construct();
7
+ }
8
+
9
+ async performChange(aObject, aData, aRequest) {
10
+ await aObject.addObjectType(aData["value"]);
11
+ }
12
+ }
@@ -0,0 +1,12 @@
1
+ import Dbm from "dbm";
2
+ import EditBaseObject from "./EditBaseObject.js";
3
+
4
+ export default class AddObjectType extends EditBaseObject {
5
+ _construct() {
6
+ super._construct();
7
+ }
8
+
9
+ async performChange(aObject, aData, aRequest) {
10
+ await aObject.removeObjectType(aData["value"]);
11
+ }
12
+ }
@@ -0,0 +1,12 @@
1
+ import Dbm from "dbm";
2
+ import EditBaseObject from "./EditBaseObject.js";
3
+
4
+ export default class ReplaceMultipleIncomingRelations extends EditBaseObject {
5
+ _construct() {
6
+ super._construct();
7
+ }
8
+
9
+ async performChange(aObject, aData, aRequest) {
10
+ await aObject.replaceMultipleIncomingRelations(aData["value"], aData["type"], aData["objectType"]);
11
+ }
12
+ }
@@ -0,0 +1,12 @@
1
+ import Dbm from "dbm";
2
+ import EditBaseObject from "./EditBaseObject.js";
3
+
4
+ export default class ReplaceMultipleOutgoingRelations extends EditBaseObject {
5
+ _construct() {
6
+ super._construct();
7
+ }
8
+
9
+ async performChange(aObject, aData, aRequest) {
10
+ await aObject.replaceMultipleOutgoingRelations(aData["value"], aData["type"]), aData["objectType"];
11
+ }
12
+ }
@@ -10,6 +10,11 @@ export {default as AddOutgoingRelation} from "./AddOutgoingRelation.js";
10
10
  export {default as ClearCloudflareCache} from "./ClearCloudflareCache.js";
11
11
  export {default as ReplaceIncomingRelation} from "./ReplaceIncomingRelation.js";
12
12
  export {default as ReplaceOutgoingRelation} from "./ReplaceOutgoingRelation.js";
13
+ export {default as ReplaceMultipleIncomingRelations} from "./ReplaceMultipleIncomingRelations.js";
14
+ export {default as ReplaceMultipleOutgoingRelations} from "./ReplaceMultipleOutgoingRelations.js";
15
+ export {default as AddObjectType} from "./AddObjectType.js";
16
+ export {default as RemoveObjectType} from "./RemoveObjectType.js";
17
+
13
18
 
14
19
  export const fullSetup = function() {
15
20
  let prefix = "graphApi/admin/edit/";
@@ -61,9 +66,33 @@ export const fullSetup = function() {
61
66
  currentSelect.item.register(prefix + name);
62
67
  }
63
68
 
69
+ {
70
+ let name = "replaceMultipleIncomingRelations";
71
+ let currentSelect = new DbmGraphApi.admin.edit.ReplaceMultipleIncomingRelations();
72
+ currentSelect.item.register(prefix + name);
73
+ }
74
+
75
+ {
76
+ let name = "replaceMultipleOutgoingRelations";
77
+ let currentSelect = new DbmGraphApi.admin.edit.ReplaceMultipleOutgoingRelations();
78
+ currentSelect.item.register(prefix + name);
79
+ }
80
+
64
81
  {
65
82
  let name = "clearCache";
66
83
  let currentSelect = new DbmGraphApi.admin.edit.ClearCloudflareCache();
67
84
  currentSelect.item.register(prefix + name);
68
85
  }
86
+
87
+ {
88
+ let name = "addObjectType";
89
+ let currentSelect = new DbmGraphApi.admin.edit.AddObjectType();
90
+ currentSelect.item.register(prefix + name);
91
+ }
92
+
93
+ {
94
+ let name = "removeObjectType";
95
+ let currentSelect = new DbmGraphApi.admin.edit.RemoveObjectType();
96
+ currentSelect.item.register(prefix + name);
97
+ }
69
98
  }
@@ -23,22 +23,22 @@ export default class HelpSectionSuggestions extends Dbm.core.BaseObject {
23
23
  "All about this section"
24
24
  ];
25
25
 
26
- let alreadyAddedString = "The page already have these titles: " + JSON.stringify(alreadyAdded);
26
+ let alreadyAddedString = "The page already have these faq sections: " + JSON.stringify(alreadyAdded);
27
27
 
28
- let contentString = "Content of the page: " + JSON.stringify(content);
28
+ let contentString = JSON.stringify(content);
29
29
 
30
- let instructions = "Analyze the content and generate a list of questions and link titles that this page answers. Do the link titles as a call to action. {additionalInstructions} Respond with only a json object {helpSectionTitles: array of {question: string, linkTitle: string}}, no markdown.";
30
+ let instructions = "Generate a seo description for the page data provided by the user. Split up the description into different lines and only keep the ones that can be used to link to this page. {additionalInstructions} Respond with only a json object {seoDescription: string, linkTitles: array of string}, no markdown.";
31
31
  instructions = instructions.split("{data}").join(contentString);
32
32
 
33
33
  let additionalInstructions = "";
34
34
  instructions = instructions.split("{additionalInstructions}").join(additionalInstructions);
35
35
 
36
36
  let body = {
37
- "model": "gpt-4o-mini",
37
+ "model": "gpt-4o",
38
38
  "response_format": { "type": "json_object" },
39
39
  "messages": [
40
40
  {"role":"system","content": instructions},
41
- {"role": "user", "content": alreadyAddedString},
41
+ /*{"role": "user", "content": alreadyAddedString},*/
42
42
  {"role": "user", "content": contentString}
43
43
  ],
44
44
  "temperature": 0.1
@@ -62,7 +62,7 @@ export default class HelpSectionSuggestions extends Dbm.core.BaseObject {
62
62
  let responseContent = JSON.parse(message.content);
63
63
  console.log(responseContent);
64
64
 
65
- returnObject["titles"] = responseContent["helpSectionTitles"];
65
+ returnObject["titles"] = responseContent;
66
66
 
67
67
  return returnObject;
68
68
  }
@@ -18,6 +18,16 @@ export default class Relations extends EncodeBaseObject {
18
18
 
19
19
  returnObject["relations"] = relations;
20
20
 
21
+ {
22
+ let ids = Dbm.utils.ArrayFunctions.mapField(relations["in"], "id");
23
+ await aEncodingSession.encodeObjects(database.getObjects(ids), "objectTypes");
24
+ }
25
+ {
26
+ let ids = Dbm.utils.ArrayFunctions.mapField(relations["out"], "id");
27
+ await aEncodingSession.encodeObjects(database.getObjects(ids), "objectTypes");
28
+ }
29
+
30
+
21
31
  return returnObject;
22
32
  }
23
33
  }
@@ -32,28 +32,49 @@ export default class JsonLdGenerator extends Dbm.core.BaseObject{
32
32
  let site = Dbm.getInstance().repository.getItem("site");
33
33
  let fields = await aDatabaseObject.getFields();
34
34
 
35
- return {
35
+ let returnObject = {
36
36
  "@type": "Organization",
37
37
  "@id": this.baseUrl + "/" + "#organization",
38
38
  "url": this.baseUrl + "/",
39
39
  "name": fields["name"] ? fields["name"] : site.name,
40
40
  };
41
41
 
42
- //Logo
42
+ let image = await aDatabaseObject.singleObjectRelationQuery("in:isLogoFor:image");
43
+ if(image) {
44
+ let fields = await image.getFields();
45
+ returnObject["logo"] = fields["url"];
46
+ }
47
+
48
+ return returnObject;
43
49
  }
44
50
 
45
51
  async encodeLocalBusiness(aDatabaseObject) {
46
52
 
53
+
47
54
  let site = Dbm.getInstance().repository.getItem("site");
48
55
 
49
56
  let type = await aDatabaseObject.singleObjectRelationQuery("in:for:schema/type");
50
- let typeName = await type.getIdentifier();
57
+ let typeName = "LocalBusiness";
58
+ if(type) {
59
+ typeName = await type.getIdentifier();
60
+ }
61
+
51
62
  let fields = await aDatabaseObject.getFields();
52
63
 
64
+ let baseUrl = this.baseUrl;
65
+
66
+ let representingPage = await aDatabaseObject.singleObjectRelationQuery("in:pageRepresentationFor:page");
67
+ if(representingPage) {
68
+ baseUrl += await representingPage.getUrl();
69
+ }
70
+ else {
71
+ baseUrl += "/";
72
+ }
73
+
53
74
  let returnObject = {
54
75
  "@type": typeName,
55
- "@id": this.baseUrl + "/" + "#local-business",
56
- "url": this.baseUrl + "/",
76
+ "@id": baseUrl + "#local-business",
77
+ "url": baseUrl,
57
78
  "name": fields["name"] ? fields["name"] : site.name,
58
79
  "telephone": fields["phoneNumber"],
59
80
  "email": fields["email"],
@@ -93,6 +114,12 @@ export default class JsonLdGenerator extends Dbm.core.BaseObject{
93
114
  };
94
115
  }
95
116
 
117
+ let image = await aDatabaseObject.singleObjectRelationQuery("in:isMainImageFor:image");
118
+ if(image) {
119
+ let fields = await image.getFields();
120
+ returnObject["image"] = fields["url"];
121
+ }
122
+
96
123
  return returnObject;
97
124
  }
98
125
 
@@ -107,13 +134,19 @@ export default class JsonLdGenerator extends Dbm.core.BaseObject{
107
134
  returnArray.push(await this.encodeWebsiteEntity(website));
108
135
 
109
136
  let organization = await website.singleObjectRelationQuery("out:by:organization");
110
- returnArray.push(await this.encodeOrganizationEntity(organization));
111
-
112
- let currentArray = await website.objectRelationQuery("out:by:organization,in:in:localBusiness");
113
- let currentArrayLength = currentArray.length;
114
- for(let i = 0; i < currentArrayLength; i++) {
115
- let currentLocalBusiness = currentArray[i];
116
- returnArray.push(await this.encodeLocalBusiness(currentLocalBusiness));
137
+ if(organization) {
138
+ returnArray.push(await this.encodeOrganizationEntity(organization));
139
+
140
+ let currentArray = await website.objectRelationQuery("out:by:organization,in:in:localBusiness");
141
+ let currentArrayLength = currentArray.length;
142
+ for(let i = 0; i < currentArrayLength; i++) {
143
+ let currentLocalBusiness = currentArray[i];
144
+ if(currentLocalBusiness) {
145
+ console.log(currentLocalBusiness);
146
+ returnArray.push(await this.encodeLocalBusiness(currentLocalBusiness));
147
+ console.log("-");
148
+ }
149
+ }
117
150
  }
118
151
  }
119
152
 
@@ -140,7 +173,27 @@ export default class JsonLdGenerator extends Dbm.core.BaseObject{
140
173
  "@id": fullUrl +"#breadcrumb"
141
174
  },
142
175
 
143
- }
176
+ };
177
+
178
+ let image = await aPage.singleObjectRelationQuery("in:isMainImageFor:image");
179
+ if(image) {
180
+ let fields = await image.getFields();
181
+
182
+ let imageObject = {
183
+ "@type": "ImageObject",
184
+ "url": fields["url"]
185
+ };
186
+ pageObject["primaryImageOfPage"] = imageObject;
187
+ }
188
+
189
+
190
+ let representingEntity = await aPage.singleObjectRelationQuery("out:pageRepresentationFor:localBusiness");
191
+ if(representingEntity) {
192
+ pageObject["mainEntity"] = {
193
+ "@id": fullUrl + "#local-business"
194
+ }
195
+ }
196
+
144
197
  returnArray.push(pageObject);
145
198
 
146
199
  let urlParts = url.split("/");