dbm-graph-api 1.1.31 → 1.1.32
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/WebSocketConnection.js +10 -2
- package/src/dbm-graph-api/action/admin/AddAndProcessAction.js +1 -0
- package/src/dbm-graph-api/action/admin/AddUser.js +20 -24
- package/src/dbm-graph-api/action/admin/SetPassword.js +35 -0
- package/src/dbm-graph-api/action/admin/index.js +1 -0
- package/src/dbm-graph-api/admin/edit/ReplaceOutgoingRelation.js +1 -1
- package/src/dbm-graph-api/admin/edit/SetFieldTranslation.js +12 -0
- package/src/dbm-graph-api/admin/edit/index.js +7 -0
- package/src/dbm-graph-api/index.js +18 -0
- package/src/dbm-graph-api/range/encode/SingleRelation.js +39 -0
- package/src/dbm-graph-api/range/encode/TranslatedName.js +25 -0
- package/src/dbm-graph-api/range/encode/TranslatedTitle.js +22 -0
- package/src/dbm-graph-api/range/encode/TranslationGroup.js +28 -0
- package/src/dbm-graph-api/range/encode/UrlRequest.js +7 -0
- package/src/dbm-graph-api/range/encode/admin/FieldTranslations.js +22 -0
- package/src/dbm-graph-api/range/encode/admin/index.js +2 -1
- package/src/dbm-graph-api/range/encode/index.js +4 -0
- package/src/dbm-graph-api/taskrunner/ExternalTaskRunner.js +17 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dbm-graph-api",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.32",
|
|
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.2.
|
|
16
|
+
"dbm": "^1.2.2",
|
|
17
17
|
"mime": "^4.0.6",
|
|
18
18
|
"sharp": "^0.33.5",
|
|
19
19
|
"ws": "^8.18.0"
|
|
@@ -162,11 +162,19 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
|
|
|
162
162
|
let encodeSession = new DbmGraphApi.range.EncodeSession();
|
|
163
163
|
encodeSession.outputController = this;
|
|
164
164
|
|
|
165
|
-
|
|
165
|
+
let logs = [];
|
|
166
|
+
|
|
167
|
+
try {
|
|
168
|
+
await encodeSession.encodeSingleWithTypes(id, data.encode);
|
|
169
|
+
}
|
|
170
|
+
catch(theError) {
|
|
171
|
+
logs.push(theError.message);
|
|
172
|
+
console.error(theError);
|
|
173
|
+
}
|
|
166
174
|
|
|
167
175
|
encodeSession.destroy();
|
|
168
176
|
|
|
169
|
-
this._webSocket.send(JSON.stringify({"type": "item/response", "id": id, "requestId": data["requestId"]}));
|
|
177
|
+
this._webSocket.send(JSON.stringify({"type": "item/response", "id": id, "requestId": data["requestId"], "logs": logs}));
|
|
170
178
|
}
|
|
171
179
|
break;
|
|
172
180
|
case "url":
|
|
@@ -11,6 +11,7 @@ export default class AddAndProcessAction extends Dbm.core.BaseObject {
|
|
|
11
11
|
await aEncodeSession.outputController.requireRole("admin");
|
|
12
12
|
let user = await aEncodeSession.outputController.getUser();
|
|
13
13
|
|
|
14
|
+
//METODO: check role
|
|
14
15
|
if(user) {
|
|
15
16
|
let type = aData["type"];
|
|
16
17
|
|
|
@@ -6,44 +6,40 @@ export default class AddUser extends Dbm.core.BaseObject {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
async performAction(aData, aEncodeSession) {
|
|
9
|
-
console.log("AddUser");
|
|
9
|
+
//console.log("AddUser");
|
|
10
10
|
let returnObject = {};
|
|
11
11
|
|
|
12
12
|
await aEncodeSession.outputController.requireRole("admin");
|
|
13
|
-
let user = await aEncodeSession.outputController.getUser();
|
|
14
13
|
|
|
15
14
|
let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
let username = aData["username"];
|
|
16
|
+
let username = aData["username"];
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
if(username) {
|
|
19
|
+
let user = await database.getUserByUsername(username);
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
if(!user) {
|
|
22
|
+
user = await database.createUser();
|
|
23
|
+
returnObject["created"] = true;
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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;
|
|
25
|
+
await user.setUsername(username);
|
|
26
|
+
if(aData["password"]) {
|
|
27
|
+
await user.setPassword(aData["password"]);
|
|
39
28
|
}
|
|
40
29
|
|
|
41
|
-
|
|
30
|
+
if(aData["role"]) {
|
|
31
|
+
let role = await database.getIdentifiableObject("type/userRole", aData["role"]);
|
|
32
|
+
await user.addIncomingRelation(role, "for");
|
|
33
|
+
}
|
|
42
34
|
}
|
|
43
35
|
else {
|
|
44
|
-
|
|
36
|
+
returnObject["created"] = false;
|
|
45
37
|
}
|
|
46
|
-
|
|
38
|
+
|
|
39
|
+
returnObject["id"] = user.id;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
throw("No username");
|
|
47
43
|
}
|
|
48
44
|
|
|
49
45
|
return returnObject;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
|
|
3
|
+
export default class SetPassword extends Dbm.core.BaseObject {
|
|
4
|
+
_construct() {
|
|
5
|
+
super._construct();
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
async performAction(aData, aEncodeSession) {
|
|
9
|
+
//console.log("SetPassword");
|
|
10
|
+
let returnObject = {};
|
|
11
|
+
|
|
12
|
+
await aEncodeSession.outputController.requireRole("admin");
|
|
13
|
+
|
|
14
|
+
let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
|
|
15
|
+
|
|
16
|
+
let id = aData["id"];
|
|
17
|
+
|
|
18
|
+
if(id) {
|
|
19
|
+
let user = await database.getUser(id);
|
|
20
|
+
|
|
21
|
+
if(user) {
|
|
22
|
+
await user.setPassword(aData["password"]);
|
|
23
|
+
returnObject["updated"] = true;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
throw("No user");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
throw("No id");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return returnObject;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -7,6 +7,6 @@ export default class ReplaceOutgoingRelation extends EditBaseObject {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
async performChange(aObject, aData, aRequest) {
|
|
10
|
-
await aObject.replaceOutgoingRelation(aData["value"], aData["type"]
|
|
10
|
+
await aObject.replaceOutgoingRelation(aData["value"], aData["type"], aData["objectType"]);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
import EditBaseObject from "./EditBaseObject.js";
|
|
3
|
+
|
|
4
|
+
export default class SetFieldTranslation extends EditBaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
async performChange(aObject, aData, aRequest) {
|
|
10
|
+
await aObject.updateFieldTranslation(aData["field"], aData["language"], aData["value"]);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -15,6 +15,7 @@ export {default as ReplaceMultipleOutgoingRelations} from "./ReplaceMultipleOutg
|
|
|
15
15
|
export {default as AddObjectType} from "./AddObjectType.js";
|
|
16
16
|
export {default as RemoveObjectType} from "./RemoveObjectType.js";
|
|
17
17
|
export {default as AddAction} from "./AddAction.js";
|
|
18
|
+
export {default as SetFieldTranslation} from "./SetFieldTranslation.js";
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
export const fullSetup = function() {
|
|
@@ -102,4 +103,10 @@ export const fullSetup = function() {
|
|
|
102
103
|
let currentSelect = new DbmGraphApi.admin.edit.AddAction();
|
|
103
104
|
currentSelect.item.register(prefix + name);
|
|
104
105
|
}
|
|
106
|
+
|
|
107
|
+
{
|
|
108
|
+
let name = "setFieldTranslation";
|
|
109
|
+
let currentSelect = new DbmGraphApi.admin.edit.SetFieldTranslation();
|
|
110
|
+
currentSelect.item.register(prefix + name);
|
|
111
|
+
}
|
|
105
112
|
}
|
|
@@ -73,6 +73,12 @@ let registerEncoding = function(aName, aEncoder) {
|
|
|
73
73
|
|
|
74
74
|
export {registerEncoding};
|
|
75
75
|
|
|
76
|
+
let registerEncodingClass = function(aEncoderClass) {
|
|
77
|
+
return registerEncoding(aEncoderClass.DEFAULT_ENCODING_NAME, new aEncoderClass());
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export {registerEncodingClass};
|
|
81
|
+
|
|
76
82
|
let fullEncodeSetup = function() {
|
|
77
83
|
let encodePrefix = "graphApi/range/encode/";
|
|
78
84
|
{
|
|
@@ -213,6 +219,13 @@ let fullEncodeSetup = function() {
|
|
|
213
219
|
registerEncoding("mainImage", new DbmGraphApi.range.encode.MainImage());
|
|
214
220
|
registerEncoding("linkPreview", new DbmGraphApi.range.encode.LinkPreview());
|
|
215
221
|
registerEncoding("publishDate", new DbmGraphApi.range.encode.PublishDate());
|
|
222
|
+
|
|
223
|
+
registerEncoding("title_translations", new DbmGraphApi.range.encode.TranslatedTitle());
|
|
224
|
+
registerEncoding("admin_fieldTranslations", new DbmGraphApi.range.encode.admin.FieldTranslations());
|
|
225
|
+
|
|
226
|
+
registerEncoding("language", DbmGraphApi.range.encode.SingleRelation.create("language", "in:for:language", "type"));
|
|
227
|
+
registerEncodingClass(DbmGraphApi.range.encode.TranslatedName);
|
|
228
|
+
registerEncoding("translationGroup", new DbmGraphApi.range.encode.TranslationGroup());
|
|
216
229
|
}
|
|
217
230
|
|
|
218
231
|
export {fullEncodeSetup};
|
|
@@ -256,6 +269,7 @@ let fullActionSetup = function() {
|
|
|
256
269
|
registerActionFunction("cron/processActions", new DbmGraphApi.action.cron.ProcessActions());
|
|
257
270
|
registerActionFunction("admin/addAndProcessAction", new DbmGraphApi.action.admin.AddAndProcessAction());
|
|
258
271
|
registerActionFunction("admin/addUser", new DbmGraphApi.action.admin.AddUser());
|
|
272
|
+
registerActionFunction("admin/user/setPassword", new DbmGraphApi.action.admin.SetPassword());
|
|
259
273
|
|
|
260
274
|
registerActionFunction("admin/setup/setupWebsite", new DbmGraphApi.action.admin.setup.SetupWebsite());
|
|
261
275
|
registerActionFunction("admin/setup/setupOrganization", new DbmGraphApi.action.admin.setup.SetupOrganization());
|
|
@@ -706,6 +720,10 @@ export const setupSite = function(aServer) {
|
|
|
706
720
|
reply.type('text/html');
|
|
707
721
|
|
|
708
722
|
let fields = await urlObject.getFields();
|
|
723
|
+
let languageItem = await urlObject.singleObjectRelationQuery("in:for:language");
|
|
724
|
+
if(languageItem) {
|
|
725
|
+
language = await languageItem.getIdentifier();
|
|
726
|
+
}
|
|
709
727
|
|
|
710
728
|
let baseUrl = request.protocol + "://" + request.hostname;
|
|
711
729
|
if(request.port && request.port !== 80 && request.port !== 443) {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
import EncodeBaseObject from "./EncodeBaseObject.js";
|
|
3
|
+
|
|
4
|
+
export default class Language extends EncodeBaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
this.outputFieldName = "language";
|
|
9
|
+
this.relationPath = "in:for:language";
|
|
10
|
+
this.encodeType = "type";
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
setup(aOutputFieldName, aRelationPath, aEncodeType) {
|
|
14
|
+
|
|
15
|
+
this.outputFieldName = aOutputFieldName;
|
|
16
|
+
this.relationPath = aRelationPath;
|
|
17
|
+
this.encodeType = aEncodeType;
|
|
18
|
+
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async getEncodedData(aId, aEncodingSession) {
|
|
23
|
+
|
|
24
|
+
let returnObject = {};
|
|
25
|
+
|
|
26
|
+
let object = Dbm.getRepositoryItem("graphDatabase").controller.getObject(aId);
|
|
27
|
+
|
|
28
|
+
returnObject[this.outputFieldName] = await aEncodingSession.encodeObjectOrNull(await object.singleObjectRelationQuery(this.relationPath), this.encodeType);
|
|
29
|
+
|
|
30
|
+
return returnObject;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static create(aOutputFieldName, aRelationPath, aEncodeType) {
|
|
34
|
+
let newEncoder = new Language();
|
|
35
|
+
newEncoder.setup(aOutputFieldName, aRelationPath, aEncodeType);
|
|
36
|
+
|
|
37
|
+
return newEncoder;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
import EncodeBaseObject from "./EncodeBaseObject.js";
|
|
3
|
+
|
|
4
|
+
export default class TranslatedName extends EncodeBaseObject {
|
|
5
|
+
|
|
6
|
+
static DEFAULT_ENCODING_NAME = "name_translations";
|
|
7
|
+
|
|
8
|
+
_construct() {
|
|
9
|
+
super._construct();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async getEncodedData(aId, aEncodingSession) {
|
|
13
|
+
|
|
14
|
+
let returnObject = {};
|
|
15
|
+
|
|
16
|
+
let object = Dbm.getInstance().repository.getItem("graphDatabase").controller.getObject(aId);
|
|
17
|
+
|
|
18
|
+
await aEncodingSession.encodeSingle(aId, "name");
|
|
19
|
+
|
|
20
|
+
let fieldTranslations = await object.getFieldTranslation("name");
|
|
21
|
+
returnObject["name/translations"] = fieldTranslations;
|
|
22
|
+
|
|
23
|
+
return returnObject;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
import EncodeBaseObject from "./EncodeBaseObject.js";
|
|
3
|
+
|
|
4
|
+
export default class TranslatedTitle 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
|
+
await aEncodingSession.encodeSingle(aId, "title");
|
|
16
|
+
|
|
17
|
+
let fieldTranslations = await object.getFieldTranslation("title");
|
|
18
|
+
returnObject["title/translations"] = fieldTranslations;
|
|
19
|
+
|
|
20
|
+
return returnObject;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
import EncodeBaseObject from "./EncodeBaseObject.js";
|
|
3
|
+
|
|
4
|
+
export default class TranslationGroup extends EncodeBaseObject {
|
|
5
|
+
|
|
6
|
+
static DEFAULT_ENCODING_NAME = "translationGroup";
|
|
7
|
+
|
|
8
|
+
_construct() {
|
|
9
|
+
super._construct();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async getEncodedData(aId, aEncodingSession) {
|
|
13
|
+
//console.log("TranslationGroup::getEncodedData");
|
|
14
|
+
|
|
15
|
+
let returnObject = {};
|
|
16
|
+
|
|
17
|
+
let object = Dbm.getInstance().repository.getItem("graphDatabase").controller.getObject(aId);
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
{
|
|
21
|
+
let relatedItems = await object.objectRelationQuery("in:in:page");
|
|
22
|
+
returnObject["pages"] = await aEncodingSession.encodeObjects(relatedItems, "language");
|
|
23
|
+
await aEncodingSession.encodeObjects(relatedItems, "url");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return returnObject;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -18,6 +18,7 @@ export default class UrlRequest extends EncodeBaseObject {
|
|
|
18
18
|
await aEncodingSession.encodeSingle(aId, "url");
|
|
19
19
|
await aEncodingSession.encodeSingle(aId, "navigationName");
|
|
20
20
|
await aEncodingSession.encodeSingle(aId, "pageRepresentation");
|
|
21
|
+
await aEncodingSession.encodeSingle(aId, "language");
|
|
21
22
|
|
|
22
23
|
let fields = await object.getFields();
|
|
23
24
|
|
|
@@ -38,6 +39,12 @@ export default class UrlRequest extends EncodeBaseObject {
|
|
|
38
39
|
returnObject["category"] = await aEncodingSession.encodeObjectOrNull(relatedItem, "type");
|
|
39
40
|
}
|
|
40
41
|
|
|
42
|
+
{
|
|
43
|
+
let relatedItem = await object.singleObjectRelationQuery("out:in:group/translationGroup");
|
|
44
|
+
|
|
45
|
+
returnObject["translations"] = await aEncodingSession.encodeObjectOrNull(relatedItem, "translationGroup");
|
|
46
|
+
}
|
|
47
|
+
|
|
41
48
|
return returnObject;
|
|
42
49
|
}
|
|
43
50
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
import EncodeBaseObject from "../EncodeBaseObject.js";
|
|
3
|
+
|
|
4
|
+
export default class Fields 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.getObject(aId);
|
|
16
|
+
|
|
17
|
+
let fields = await object.getAllFieldTranslations();
|
|
18
|
+
returnObject["fields/translations"] = fields;
|
|
19
|
+
|
|
20
|
+
return returnObject;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -22,5 +22,9 @@ export {default as Location} from "./Location.js";
|
|
|
22
22
|
export {default as AtLocation} from "./AtLocation.js";
|
|
23
23
|
export {default as LinkPreview} from "./LinkPreview.js";
|
|
24
24
|
export {default as PublishDate} from "./PublishDate.js";
|
|
25
|
+
export {default as SingleRelation} from "./SingleRelation.js";
|
|
26
|
+
export {default as TranslatedTitle} from "./TranslatedTitle.js";
|
|
27
|
+
export {default as TranslatedName} from "./TranslatedName.js";
|
|
28
|
+
export {default as TranslationGroup} from "./TranslationGroup.js";
|
|
25
29
|
|
|
26
30
|
export * as admin from "./admin/index.js";
|
|
@@ -45,14 +45,26 @@ export default class ExternalTaskRunner extends Dbm.core.BaseObject {
|
|
|
45
45
|
|
|
46
46
|
let response = await fetch(this.item.url, requestData);
|
|
47
47
|
|
|
48
|
-
let
|
|
48
|
+
let responseText = await response.text();
|
|
49
49
|
|
|
50
|
-
let
|
|
51
|
-
|
|
50
|
+
let data = null;
|
|
51
|
+
try {
|
|
52
|
+
data = JSON.parse(responseText);
|
|
53
|
+
}
|
|
54
|
+
catch(theError) {
|
|
55
|
+
console.error(theError);
|
|
56
|
+
console.log(responseText);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if(data) {
|
|
60
|
+
let continueData = Dbm.objectPath(data, this.item.continueField);
|
|
61
|
+
console.log(this.item.name + " " + continueData);
|
|
52
62
|
|
|
53
|
-
|
|
54
|
-
|
|
63
|
+
if(continueData > 0) {
|
|
64
|
+
runDirect = true;
|
|
65
|
+
}
|
|
55
66
|
}
|
|
67
|
+
|
|
56
68
|
}
|
|
57
69
|
catch(theError) {
|
|
58
70
|
console.log(theError);
|