dbm-graph-api 1.1.17 → 1.1.19
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 +2 -2
- package/src/dbm-graph-api/data/HelpSectionSuggestions.js +1 -1
- package/src/dbm-graph-api/index.js +16 -0
- package/src/dbm-graph-api/range/encode/AtLocation.js +23 -0
- package/src/dbm-graph-api/range/encode/HelpSection.js +10 -0
- package/src/dbm-graph-api/range/encode/Location.js +30 -0
- package/src/dbm-graph-api/range/encode/MainImage.js +21 -0
- package/src/dbm-graph-api/range/encode/index.js +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dbm-graph-api",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.19",
|
|
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.
|
|
16
|
+
"dbm": "^1.1.14",
|
|
17
17
|
"mime": "^4.0.6",
|
|
18
18
|
"sharp": "^0.33.5",
|
|
19
19
|
"ws": "^8.18.0"
|
|
@@ -27,7 +27,7 @@ export default class HelpSectionSuggestions extends Dbm.core.BaseObject {
|
|
|
27
27
|
|
|
28
28
|
let contentString = JSON.stringify(content);
|
|
29
29
|
|
|
30
|
-
let instructions = "
|
|
30
|
+
let instructions = "Summarize what this page is about and generate sections for faq of what this page answers. Write the answer in an active tone of voice, call the company we and the user you. {additionalInstructions} Respond with only a json object {summary: string, questions: [{question: string, oneLineAnswer: string, answer: string, readMoreLinkText: string}]}, no markdown.";
|
|
31
31
|
instructions = instructions.split("{data}").join(contentString);
|
|
32
32
|
|
|
33
33
|
let additionalInstructions = "";
|
|
@@ -59,8 +59,20 @@ let fullSelectSetup = function() {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
|
|
63
|
+
|
|
62
64
|
export {fullSelectSetup};
|
|
63
65
|
|
|
66
|
+
let registerEncoding = function(aName, aEncoder) {
|
|
67
|
+
let encodePrefix = "graphApi/range/encode/";
|
|
68
|
+
aEncoder.item.register(encodePrefix + aName);
|
|
69
|
+
aEncoder.item.setValue("encodingType", aName);
|
|
70
|
+
|
|
71
|
+
return aEncoder;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export {registerEncoding};
|
|
75
|
+
|
|
64
76
|
let fullEncodeSetup = function() {
|
|
65
77
|
let encodePrefix = "graphApi/range/encode/";
|
|
66
78
|
{
|
|
@@ -188,6 +200,10 @@ let fullEncodeSetup = function() {
|
|
|
188
200
|
currentEncode.item.register(encodePrefix + name);
|
|
189
201
|
currentEncode.item.setValue("encodingType", name);
|
|
190
202
|
}
|
|
203
|
+
|
|
204
|
+
registerEncoding("atLocation", new DbmGraphApi.range.encode.AtLocation());
|
|
205
|
+
registerEncoding("location", new DbmGraphApi.range.encode.Location());
|
|
206
|
+
registerEncoding("mainImage", new DbmGraphApi.range.encode.MainImage());
|
|
191
207
|
}
|
|
192
208
|
|
|
193
209
|
export {fullEncodeSetup};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
import EncodeBaseObject from "./EncodeBaseObject.js";
|
|
3
|
+
|
|
4
|
+
export default class MainImage 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
|
+
{
|
|
16
|
+
let relatedItem = await object.singleObjectRelationQuery("out:at:location");
|
|
17
|
+
returnObject["location"] = await aEncodingSession.encodeObjectOrNull(relatedItem, "location");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
return returnObject;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -13,8 +13,18 @@ export default class HelpSection extends EncodeBaseObject {
|
|
|
13
13
|
let object = Dbm.getInstance().repository.getItem("graphDatabase").controller.getObject(aId);
|
|
14
14
|
|
|
15
15
|
let fields = await object.getFields();
|
|
16
|
+
returnObject["question"] = fields["question"] !== null ? fields["question"] : null;
|
|
16
17
|
returnObject["title"] = fields["title"] !== null ? fields["title"] : null;
|
|
17
18
|
returnObject["link"] = fields["link"] !== null ? fields["link"] : null;
|
|
19
|
+
returnObject["content"] = fields["content"] !== null ? fields["content"] : null;
|
|
20
|
+
returnObject["linkText"] = fields["linkText"] !== null ? fields["linkText"] : null;
|
|
21
|
+
|
|
22
|
+
{
|
|
23
|
+
let relatedItem = await object.singleObjectRelationQuery("out:for:page");
|
|
24
|
+
|
|
25
|
+
returnObject["page"] = await aEncodingSession.encodeObjectOrNull(relatedItem, "url");
|
|
26
|
+
await aEncodingSession.encodeObjectOrNull(relatedItem, "title");
|
|
27
|
+
}
|
|
18
28
|
|
|
19
29
|
return returnObject;
|
|
20
30
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
import EncodeBaseObject from "./EncodeBaseObject.js";
|
|
3
|
+
|
|
4
|
+
export default class Location 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["street"] = fields["street"] ? fields["street"] : null;
|
|
17
|
+
returnObject["postCode"] = fields["postCode"] ? fields["postCode"] : null;
|
|
18
|
+
returnObject["city"] = fields["city"] ? fields["city"] : null;
|
|
19
|
+
returnObject["country"] = fields["country"] ? fields["country"] : null;
|
|
20
|
+
|
|
21
|
+
if(fields["latitude"]) {
|
|
22
|
+
returnObject["coordinates"] = {latitude: fields["latitude"], longitude: fields["longitude"]};
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
returnObject["coordinates"] = null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return returnObject;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
import EncodeBaseObject from "./EncodeBaseObject.js";
|
|
3
|
+
|
|
4
|
+
export default class MainImage 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 representingPage = await object.singleObjectRelationQuery("in:isMainImageFor:image");
|
|
16
|
+
|
|
17
|
+
returnObject["image"] = await aEncodingSession.encodeObjectOrNull(representingPage, "image");
|
|
18
|
+
|
|
19
|
+
return returnObject;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -17,5 +17,8 @@ export {default as ObjectTypes} from "./ObjectTypes.js";
|
|
|
17
17
|
export {default as RepresentingPage} from "./RepresentingPage.js";
|
|
18
18
|
export {default as PageRepresentation} from "./PageRepresentation.js";
|
|
19
19
|
export {default as HelpSection} from "./HelpSection.js";
|
|
20
|
+
export {default as MainImage} from "./MainImage.js";
|
|
21
|
+
export {default as Location} from "./Location.js";
|
|
22
|
+
export {default as AtLocation} from "./AtLocation.js";
|
|
20
23
|
|
|
21
24
|
export * as admin from "./admin/index.js";
|