dbm-graph-api 1.1.23 → 1.1.25
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/action/admin/AddAndProcessAction.js +1 -0
- package/src/dbm-graph-api/action/admin/AddUser.js +51 -0
- package/src/dbm-graph-api/action/admin/index.js +1 -0
- package/src/dbm-graph-api/index.js +36 -8
- package/src/dbm-graph-api/range/encode/UrlRequest.js +14 -0
- package/src/dbm-graph-api/range/encode/admin/User.js +26 -0
- package/src/dbm-graph-api/range/encode/admin/index.js +2 -1
- package/src/dbm-graph-api/schema/JsonLdGenerator.js +10 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dbm-graph-api",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.25",
|
|
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.20",
|
|
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
|
+
}
|
|
@@ -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());
|
|
@@ -763,7 +771,7 @@ export const setupSite = function(aServer) {
|
|
|
763
771
|
|
|
764
772
|
returnString += `<link rel="stylesheet" type="text/css" href="${assetsUri}css/main.css?version=${version}" />
|
|
765
773
|
|
|
766
|
-
<link rel="icon" type="image/png" href="${assetsUri}img/favicon.png">`;
|
|
774
|
+
<link rel="icon" type="image/png" href="${baseUrl}${assetsUri}img/favicon.png">`;
|
|
767
775
|
|
|
768
776
|
if(fields['meta/description']) {
|
|
769
777
|
returnString += `
|
|
@@ -779,15 +787,35 @@ export const setupSite = function(aServer) {
|
|
|
779
787
|
<meta property="og:url" content="${fullUrl}" />
|
|
780
788
|
`;
|
|
781
789
|
|
|
790
|
+
if(fields["lastModified"]) {
|
|
791
|
+
returnString += `<meta property="article:modified_time" content="${fields["lastModified"]}" />\n`;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
let image = await urlObject.singleObjectRelationQuery("in:isMainImageFor:image");
|
|
795
|
+
if(image) {
|
|
796
|
+
let imageFields = await image.getFields();
|
|
797
|
+
|
|
798
|
+
if(imageFields["resizeUrl"]) {
|
|
799
|
+
let imageUrl = imageFields["resizeUrl"];
|
|
800
|
+
let scaleString = "width=1200,height=630,fit=cover,format=jpeg";
|
|
801
|
+
imageUrl = imageUrl.split("{scale}").join(scaleString);
|
|
802
|
+
|
|
803
|
+
returnString += `<meta property="og:image" content="${imageUrl}" />\n`;
|
|
804
|
+
returnString += `<meta property="og:image:width" content="1200" />\n`;
|
|
805
|
+
returnString += `<meta property="og:image:height" content="630" />\n`;
|
|
806
|
+
returnString += `<meta property="og:image:type" content="image/jpeg" />\n`;
|
|
807
|
+
returnString += `<meta property="twitter:card" content="summary_large_image" />\n`;
|
|
808
|
+
}
|
|
809
|
+
else {
|
|
810
|
+
let imageUrl = imageFields["url"];
|
|
811
|
+
returnString += `<meta property="og:image" content="${imageUrl}" />\n`;
|
|
812
|
+
returnString += `<meta property="twitter:card" content="summary_large_image" />\n`;
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
|
|
782
816
|
/*
|
|
783
817
|
<meta property="article:publisher" content="https://sv-se.facebook.com/..." />
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
<meta property="og:image" content="https://..." />
|
|
787
|
-
<meta property="og:image:width" content="1024" />
|
|
788
|
-
<meta property="og:image:height" content="683" />
|
|
789
|
-
<meta property="og:image:type" content="image/jpeg" />
|
|
790
|
-
<meta name="twitter:card" content="summary_large_image" />
|
|
818
|
+
|
|
791
819
|
*/
|
|
792
820
|
|
|
793
821
|
returnString += `</head>
|
|
@@ -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
|
|