dbm-graph-api 1.1.17 → 1.1.18

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.17",
3
+ "version": "1.1.18",
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.12",
16
+ "dbm": "^1.1.13",
17
17
  "mime": "^4.0.6",
18
18
  "sharp": "^0.33.5",
19
19
  "ws": "^8.18.0"
@@ -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
+ }
@@ -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";