dbm-graph-api 1.1.24 → 1.1.26

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.24",
3
+ "version": "1.1.26",
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.19",
16
+ "dbm": "^1.1.21",
17
17
  "mime": "^4.0.6",
18
18
  "sharp": "^0.33.5",
19
19
  "ws": "^8.18.0"
@@ -8,6 +8,7 @@ export default class AddAndProcessAction extends Dbm.core.BaseObject {
8
8
  async performAction(aData, aEncodeSession) {
9
9
  let returnObject = {};
10
10
 
11
+ await aEncodeSession.outputController.requireRole("admin");
11
12
  let user = await aEncodeSession.outputController.getUser();
12
13
 
13
14
  if(user) {
@@ -0,0 +1,51 @@
1
+ import Dbm from "dbm";
2
+
3
+ export default class AddUser extends Dbm.core.BaseObject {
4
+ _construct() {
5
+ super._construct();
6
+ }
7
+
8
+ async performAction(aData, aEncodeSession) {
9
+ console.log("AddUser");
10
+ let returnObject = {};
11
+
12
+ await aEncodeSession.outputController.requireRole("admin");
13
+ let user = await aEncodeSession.outputController.getUser();
14
+
15
+ let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
16
+
17
+ if(user) {
18
+ let username = aData["username"];
19
+
20
+ if(username) {
21
+ let user = await database.getUserByUsername(username);
22
+
23
+ if(!user) {
24
+ user = await database.createUser();
25
+ returnObject["created"] = true;
26
+
27
+ await user.setUsername(username);
28
+ if(aData["password"]) {
29
+ await user.setPassword(aData["password"]);
30
+ }
31
+
32
+ if(aData["role"]) {
33
+ let role = await database.getIdentifiableObject("type/userRole", aData["role"]);
34
+ await user.addIncomingRelation(role, "for");
35
+ }
36
+ }
37
+ else {
38
+ returnObject["created"] = false;
39
+ }
40
+
41
+ returnObject["id"] = user.id;
42
+ }
43
+ else {
44
+ throw("No username");
45
+ }
46
+
47
+ }
48
+
49
+ return returnObject;
50
+ }
51
+ }
@@ -1,3 +1,4 @@
1
1
  export {default as AddAndProcessAction} from "./AddAndProcessAction.js";
2
+ export {default as AddUser} from "./AddUser.js";
2
3
 
3
4
  export * as setup from "./setup/index.js";
@@ -194,6 +194,13 @@ let fullEncodeSetup = function() {
194
194
  currentEncode.item.setValue("encodingType", name);
195
195
  }
196
196
 
197
+ {
198
+ let name = "admin_user";
199
+ let currentEncode = new DbmGraphApi.range.encode.admin.User();
200
+ currentEncode.item.register(encodePrefix + name);
201
+ currentEncode.item.setValue("encodingType", name);
202
+ }
203
+
197
204
  {
198
205
  let name = "helpSection";
199
206
  let currentEncode = new DbmGraphApi.range.encode.HelpSection();
@@ -245,6 +252,7 @@ let fullActionSetup = function() {
245
252
  registerActionFunction("incomingWebhook", new DbmGraphApi.action.IncomingWebhook());
246
253
  registerActionFunction("cron/processActions", new DbmGraphApi.action.cron.ProcessActions());
247
254
  registerActionFunction("admin/addAndProcessAction", new DbmGraphApi.action.admin.AddAndProcessAction());
255
+ registerActionFunction("admin/addUser", new DbmGraphApi.action.admin.AddUser());
248
256
 
249
257
  registerActionFunction("admin/setup/setupWebsite", new DbmGraphApi.action.admin.setup.SetupWebsite());
250
258
  registerActionFunction("admin/setup/setupOrganization", new DbmGraphApi.action.admin.setup.SetupOrganization());
@@ -712,6 +720,14 @@ export const setupSite = function(aServer) {
712
720
  }
713
721
  }
714
722
 
723
+ if(fields["contentPreloadTags"]){
724
+ let currentArray = fields["contentPreloadTags"];
725
+ let currentArrayLength = currentArray.length;
726
+ for(let i = 0; i < currentArrayLength; i++) {
727
+ returnString += currentArray[i];
728
+ }
729
+ }
730
+
715
731
  if(site.disableSearchEngines) {
716
732
  returnString += `<meta name="robots" content="noindex, nofollow" />`;
717
733
  }
@@ -20,10 +20,24 @@ export default class UrlRequest extends EncodeBaseObject {
20
20
  await aEncodingSession.encodeSingle(aId, "pageRepresentation");
21
21
 
22
22
  let fields = await object.getFields();
23
+
24
+ returnObject["publishDate"] = fields["publishDate"] ? fields["publishDate"] : null;
25
+
23
26
  returnObject["meta/description"] = fields["meta/description"] ? fields["meta/description"] : null;
24
27
  returnObject["seo/noIndex"] = fields["seo/noIndex"] ? fields["seo/noIndex"] : false;
25
28
  returnObject["seo/noFollow"] = fields["seo/noFollow"] ? fields["seo/noFollow"] : false;
26
29
 
30
+ {
31
+ let relatedItems = await object.objectRelationQuery("out:in:group/pageCategory");
32
+ returnObject["categories"] = await aEncodingSession.encodeObjects(relatedItems, "type");
33
+ }
34
+
35
+ {
36
+ let relatedItem = await object.singleObjectRelationQuery("out:in:group/pageCategory");
37
+
38
+ returnObject["category"] = await aEncodingSession.encodeObjectOrNull(relatedItem, "type");
39
+ }
40
+
27
41
  return returnObject;
28
42
  }
29
43
  }
@@ -0,0 +1,26 @@
1
+ import Dbm from "dbm";
2
+ import EncodeBaseObject from "../EncodeBaseObject.js";
3
+
4
+ export default class User extends EncodeBaseObject {
5
+ _construct() {
6
+ super._construct();
7
+ }
8
+
9
+ async getEncodedData(aId, aEncodingSession) {
10
+
11
+ let returnObject = {};
12
+
13
+ await aEncodingSession.outputController.requireRole("admin");
14
+
15
+ let object = Dbm.getInstance().repository.getItem("graphDatabase").controller.getUser(aId);
16
+
17
+ let fields = await object.getFields();
18
+ returnObject["name"] = fields["name"];
19
+ returnObject["username"] = await object.getUsername();
20
+
21
+ let relatedItems = await object.objectRelationQuery("in:for:type/userRole");
22
+ returnObject["roles"] = await aEncodingSession.encodeObjects(relatedItems, "type");
23
+
24
+ return returnObject;
25
+ }
26
+ }
@@ -1 +1,2 @@
1
- export {default as Fields} from "./Fields.js";
1
+ export {default as Fields} from "./Fields.js";
2
+ export {default as User} from "./User.js";
@@ -172,9 +172,18 @@ export default class JsonLdGenerator extends Dbm.core.BaseObject{
172
172
  "breadcrumb": {
173
173
  "@id": fullUrl +"#breadcrumb"
174
174
  },
175
-
175
+ "publisher": {
176
+ "@id": this.baseUrl + "/" + "#organization"
177
+ }
176
178
  };
177
179
 
180
+ if(fields["publishDate"]) {
181
+ pageObject["datePublished"] = fields["publishDate"];
182
+ }
183
+ if(fields["lastModified"]) {
184
+ pageObject["dateModified"] = fields["lastModified"].split("T")[0];
185
+ }
186
+
178
187
  let image = await aPage.singleObjectRelationQuery("in:isMainImageFor:image");
179
188
  if(image) {
180
189
  let fields = await image.getFields();
@@ -230,15 +239,6 @@ export default class JsonLdGenerator extends Dbm.core.BaseObject{
230
239
  returnArray.push(breadcrumbList);
231
240
 
232
241
  return returnArray;
233
-
234
-
235
-
236
-
237
- /*
238
- "primaryImageOfPage": {
239
- "@id": "https://example.com/product/acme-coffee-maker#primaryimage"
240
- }
241
- */
242
242
  }
243
243
  }
244
244