dbm-graph-api 1.0.4 → 1.1.2
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 +5 -5
- package/src/dbm-graph-api/UrlRequest.js +96 -4
- package/src/dbm-graph-api/WebSocketConnection.js +21 -2
- package/src/dbm-graph-api/action/Example.js +15 -0
- package/src/dbm-graph-api/action/IncomingWebhook.js +35 -0
- package/src/dbm-graph-api/action/cron/ProcessActions.js +49 -0
- package/src/dbm-graph-api/action/cron/index.js +1 -0
- package/src/dbm-graph-api/action/index.js +4 -0
- package/src/dbm-graph-api/admin/edit/AddIncomingRelation.js +2 -2
- package/src/dbm-graph-api/admin/edit/AddOutgoingRelation.js +2 -2
- package/src/dbm-graph-api/admin/edit/EditBaseObject.js +1 -1
- package/src/dbm-graph-api/admin/edit/PurgeCache.js +13 -0
- package/src/dbm-graph-api/admin/edit/SetField.js +2 -2
- package/src/dbm-graph-api/admin/edit/SetUrl.js +2 -2
- package/src/dbm-graph-api/data/SeoSummary.js +58 -0
- package/src/dbm-graph-api/data/UploadS3.js +5 -0
- package/src/dbm-graph-api/data/index.js +25 -0
- package/src/dbm-graph-api/index.js +142 -4
- package/src/dbm-graph-api/processAction/Example.js +11 -0
- package/src/dbm-graph-api/processAction/index.js +1 -0
- package/src/dbm-graph-api/range/EncodeSession.js +6 -5
- package/src/dbm-graph-api/range/Query.js +89 -2
- package/src/dbm-graph-api/range/encode/Breadcrumb.js +50 -0
- package/src/dbm-graph-api/range/encode/NavigationName.js +20 -0
- package/src/dbm-graph-api/range/encode/Type.js +20 -0
- package/src/dbm-graph-api/range/encode/UrlRequest.js +1 -0
- package/src/dbm-graph-api/range/encode/index.js +4 -1
- package/src/dbm-graph-api/range/select/ByObjectType.js +22 -0
- package/src/dbm-graph-api/range/select/IdSelection.js +1 -1
- package/src/dbm-graph-api/range/select/IncludePrivate.js +18 -0
- package/src/dbm-graph-api/range/select/index.js +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dbm-graph-api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"description": "",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@aws-sdk/client-s3": "^3.
|
|
15
|
-
"@aws-sdk/s3-request-presigner": "^3.
|
|
16
|
-
"dbm": "^1.
|
|
14
|
+
"@aws-sdk/client-s3": "^3.741.0",
|
|
15
|
+
"@aws-sdk/s3-request-presigner": "^3.741.0",
|
|
16
|
+
"dbm": "^1.1.1",
|
|
17
17
|
"ws": "^8.18.0"
|
|
18
18
|
},
|
|
19
19
|
"optionalDependencies": {
|
|
20
|
-
"bufferutil": "^4.0.
|
|
20
|
+
"bufferutil": "^4.0.9"
|
|
21
21
|
}
|
|
22
22
|
}
|
|
@@ -5,6 +5,7 @@ export default class UrlRequest extends Dbm.core.BaseObject {
|
|
|
5
5
|
_construct() {
|
|
6
6
|
super._construct();
|
|
7
7
|
|
|
8
|
+
this._logs = [];
|
|
8
9
|
this._encodedObjects = [];
|
|
9
10
|
this._responseData = null;
|
|
10
11
|
}
|
|
@@ -30,15 +31,106 @@ export default class UrlRequest extends Dbm.core.BaseObject {
|
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
async requestRange(aSelects, aEncodes, aData) {
|
|
33
|
-
|
|
34
|
+
|
|
35
|
+
let request = {}; //METODO
|
|
36
|
+
|
|
37
|
+
request.connection = this;
|
|
38
|
+
|
|
39
|
+
let selectQuery = new DbmGraphApi.range.Query();
|
|
40
|
+
|
|
41
|
+
let ids = [];
|
|
42
|
+
let logs = [];
|
|
43
|
+
|
|
44
|
+
{
|
|
45
|
+
let hasSelection = false;
|
|
46
|
+
let currentArray = aSelects;
|
|
47
|
+
let currentArrayLength = currentArray.length;
|
|
48
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
49
|
+
let currentSelectData = currentArray[i];
|
|
50
|
+
let currentSelectType = currentSelectData["type"];
|
|
51
|
+
let selection = Dbm.getInstance().repository.getItemIfExists("graphApi/range/select/" + currentSelectType);
|
|
52
|
+
if(selection) {
|
|
53
|
+
hasSelection = true;
|
|
54
|
+
await selection.controller.select(selectQuery, currentSelectData, request);
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
this._logs.push("No selection named " + currentSelectType);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if(hasSelection) {
|
|
62
|
+
ids = await selectQuery.getIds();
|
|
63
|
+
|
|
64
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
65
|
+
let currentSelectData = currentArray[i];
|
|
66
|
+
let currentSelectType = currentSelectData["type"];
|
|
67
|
+
let selection = Dbm.getInstance().repository.getItemIfExists("graphApi/range/select/" + currentSelectType);
|
|
68
|
+
if(selection) {
|
|
69
|
+
ids = await selection.controller.filter(ids, currentSelectData, request);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
this._logs.push("No valid selections");
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
{
|
|
80
|
+
let encodeSession = new DbmGraphApi.range.EncodeSession();
|
|
81
|
+
encodeSession.outputController = this;
|
|
82
|
+
|
|
83
|
+
let currentArray = aEncodes;
|
|
84
|
+
let currentArrayLength = currentArray.length;
|
|
85
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
86
|
+
let currentType = currentArray[i];
|
|
87
|
+
|
|
88
|
+
await encodeSession.encode(ids, currentType);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
encodeSession.destroy();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
this._responseData = {"ids": ids};
|
|
34
95
|
}
|
|
35
96
|
|
|
36
97
|
async requestItem(aId, aEncodes) {
|
|
37
|
-
|
|
98
|
+
let encodeSession = new DbmGraphApi.range.EncodeSession();
|
|
99
|
+
encodeSession.outputController = this;
|
|
100
|
+
|
|
101
|
+
await encodeSession.encodeSingleWithTypes(aId, aEncodes);
|
|
102
|
+
|
|
103
|
+
encodeSession.destroy();
|
|
104
|
+
|
|
105
|
+
this._responseData = {"id": aId};
|
|
38
106
|
}
|
|
39
107
|
|
|
40
108
|
async requestData(aFunctionName, aData) {
|
|
41
|
-
|
|
109
|
+
let encodeSession = new DbmGraphApi.range.EncodeSession();
|
|
110
|
+
encodeSession.outputController = this;
|
|
111
|
+
|
|
112
|
+
let dataFunctionItem = Dbm.getInstance().repository.getItemIfExists("graphApi/data/" + aFunctionName);
|
|
113
|
+
|
|
114
|
+
let returnData = null;
|
|
115
|
+
if(dataFunctionItem) {
|
|
116
|
+
returnData = await dataFunctionItem.controller.getData(aData, encodeSession);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
this._responseData = returnData;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
async performAction(aFunctionName, aData) {
|
|
123
|
+
let encodeSession = new DbmGraphApi.range.EncodeSession();
|
|
124
|
+
encodeSession.outputController = this;
|
|
125
|
+
|
|
126
|
+
let dataFunctionItem = Dbm.getInstance().repository.getItemIfExists("graphApi/action/" + aFunctionName);
|
|
127
|
+
|
|
128
|
+
let returnData = null;
|
|
129
|
+
if(dataFunctionItem) {
|
|
130
|
+
returnData = await dataFunctionItem.controller.performAction(aData, encodeSession);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
this._responseData = returnData;
|
|
42
134
|
}
|
|
43
135
|
|
|
44
136
|
outputEncodedData(aId, aData, aEncoding) {
|
|
@@ -49,6 +141,6 @@ export default class UrlRequest extends Dbm.core.BaseObject {
|
|
|
49
141
|
}
|
|
50
142
|
|
|
51
143
|
getResponse() {
|
|
52
|
-
return {"objects": this._encodedObjects, "data": this._responseData};
|
|
144
|
+
return {"objects": this._encodedObjects, "data": this._responseData, "logs": this._logs};
|
|
53
145
|
}
|
|
54
146
|
}
|
|
@@ -54,6 +54,7 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
|
|
|
54
54
|
let selectQuery = new DbmGraphApi.range.Query();
|
|
55
55
|
|
|
56
56
|
let ids = [];
|
|
57
|
+
let logs = [];
|
|
57
58
|
|
|
58
59
|
{
|
|
59
60
|
let hasSelection = false;
|
|
@@ -67,6 +68,9 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
|
|
|
67
68
|
hasSelection = true;
|
|
68
69
|
await selection.controller.select(selectQuery, currentSelectData, request);
|
|
69
70
|
}
|
|
71
|
+
else {
|
|
72
|
+
logs.push("No selection named " + currentSelectType);
|
|
73
|
+
}
|
|
70
74
|
}
|
|
71
75
|
|
|
72
76
|
if(hasSelection) {
|
|
@@ -82,7 +86,7 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
|
|
|
82
86
|
}
|
|
83
87
|
}
|
|
84
88
|
else {
|
|
85
|
-
|
|
89
|
+
logs.push("No valid selections");
|
|
86
90
|
}
|
|
87
91
|
|
|
88
92
|
}
|
|
@@ -102,7 +106,7 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
|
|
|
102
106
|
encodeSession.destroy();
|
|
103
107
|
}
|
|
104
108
|
|
|
105
|
-
this._webSocket.send(JSON.stringify({"type": "range/response", "ids": ids, "requestId": data["requestId"]}));
|
|
109
|
+
this._webSocket.send(JSON.stringify({"type": "range/response", "ids": ids, "requestId": data["requestId"], "logs": logs}));
|
|
106
110
|
break;
|
|
107
111
|
case "data":
|
|
108
112
|
{
|
|
@@ -119,6 +123,21 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
|
|
|
119
123
|
this._webSocket.send(JSON.stringify({"type": "data/response", "data": returnData, "requestId": data["requestId"]}));
|
|
120
124
|
}
|
|
121
125
|
break;
|
|
126
|
+
case "action":
|
|
127
|
+
{
|
|
128
|
+
let encodeSession = new DbmGraphApi.range.EncodeSession();
|
|
129
|
+
encodeSession.outputController = this;
|
|
130
|
+
|
|
131
|
+
let dataFunctionItem = Dbm.getInstance().repository.getItemIfExists("graphApi/action/" + data['functionName']);
|
|
132
|
+
|
|
133
|
+
let returnData = null;
|
|
134
|
+
if(dataFunctionItem) {
|
|
135
|
+
returnData = await dataFunctionItem.controller.performAction(data['data'], encodeSession);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
this._webSocket.send(JSON.stringify({"type": "data/response", "data": returnData, "requestId": data["requestId"]}));
|
|
139
|
+
}
|
|
140
|
+
break;
|
|
122
141
|
case "item":
|
|
123
142
|
{
|
|
124
143
|
let id = data['id'];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
|
|
3
|
+
export default class Example extends Dbm.core.BaseObject {
|
|
4
|
+
_construct() {
|
|
5
|
+
super._construct();
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
async performAction(aData, aEncodeSession) {
|
|
9
|
+
let returnObject = {};
|
|
10
|
+
|
|
11
|
+
returnObject["example"] = "This is an example of an action";
|
|
12
|
+
|
|
13
|
+
return returnObject;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
|
|
3
|
+
export default class IncomingWebhook extends Dbm.core.BaseObject {
|
|
4
|
+
_construct() {
|
|
5
|
+
super._construct();
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
async performAction(aData, aEncodeSession) {
|
|
9
|
+
let returnObject = {};
|
|
10
|
+
|
|
11
|
+
let type = aData['type'];
|
|
12
|
+
let data = aData;
|
|
13
|
+
|
|
14
|
+
let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
|
|
15
|
+
|
|
16
|
+
let webhookType = await database.getTypeObject("type/webhookType", type);
|
|
17
|
+
|
|
18
|
+
let incomingWebhook = await database.createObject("private", ["incomingWebhook"]);
|
|
19
|
+
await incomingWebhook.updateField("data", data);
|
|
20
|
+
await incomingWebhook.addIncomingRelation(webhookType, "for");
|
|
21
|
+
|
|
22
|
+
let actionType = await database.getTypeObject("type/actionType", "incomingWebhook/" + type);
|
|
23
|
+
let actionStatus = await database.getTypeObject("status/actionStatus", "readyToProcess");
|
|
24
|
+
|
|
25
|
+
let action = await database.createObject("private", ["action"]);
|
|
26
|
+
await action.addIncomingRelation(actionType, "for");
|
|
27
|
+
await action.addIncomingRelation(incomingWebhook, "from");
|
|
28
|
+
await action.addIncomingRelation(actionStatus, "for");
|
|
29
|
+
|
|
30
|
+
returnObject["id"] = incomingWebhook.id;
|
|
31
|
+
returnObject["action"] = action.id;
|
|
32
|
+
|
|
33
|
+
return returnObject;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
|
|
3
|
+
export default class ProcessActions extends Dbm.core.BaseObject {
|
|
4
|
+
_construct() {
|
|
5
|
+
super._construct();
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
async performAction(aData, aEncodeSession) {
|
|
9
|
+
let returnObject = {};
|
|
10
|
+
|
|
11
|
+
let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
|
|
12
|
+
|
|
13
|
+
let actionStatus = await database.getTypeObject("status/actionStatus", "readyToProcess");
|
|
14
|
+
let actions = await actionStatus.objectRelationQuery("out:for:action");
|
|
15
|
+
|
|
16
|
+
if(actions.length) {
|
|
17
|
+
let action = actions[0];
|
|
18
|
+
returnObject["processed"] = action.id;
|
|
19
|
+
|
|
20
|
+
let processingActionStatus = await database.getTypeObject("status/actionStatus", "processing");
|
|
21
|
+
await action.replaceIncomingRelation(processingActionStatus, "for", "status/actionStatus");
|
|
22
|
+
|
|
23
|
+
let actionType = await (await action.singleObjectRelationQuery("in:for:type/actionType")).getIdentifier();
|
|
24
|
+
console.log(actionType);
|
|
25
|
+
|
|
26
|
+
let processActionItem = Dbm.getInstance().repository.getItemIfExists("graphApi/procesAction/" + actionType);
|
|
27
|
+
|
|
28
|
+
if(processActionItem) {
|
|
29
|
+
|
|
30
|
+
await processActionItem.controller.process(action);
|
|
31
|
+
|
|
32
|
+
let doneActionStatus = await database.getTypeObject("status/actionStatus", "done");
|
|
33
|
+
await action.replaceIncomingRelation(doneActionStatus, "for", "status/actionStatus");
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
let doneActionStatus = await database.getTypeObject("status/actionStatus", "noAction");
|
|
37
|
+
await action.replaceIncomingRelation(doneActionStatus, "for", "status/actionStatus");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
returnObject["remaining"] = actions.length-1;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
returnObject["processed"] = 0;
|
|
44
|
+
returnObject["remaining"] = 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return returnObject;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default as ProcessActions} from "./ProcessActions.js";
|
|
@@ -6,7 +6,7 @@ export default class AddIncomigRelation extends EditBaseObject {
|
|
|
6
6
|
super._construct();
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
performChange(aObject, aData, aRequest) {
|
|
10
|
-
aObject.addIncomingRelation(aData["value"], aData["type"]);
|
|
9
|
+
async performChange(aObject, aData, aRequest) {
|
|
10
|
+
await aObject.addIncomingRelation(aData["value"], aData["type"]);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -6,7 +6,7 @@ export default class AddOutgoingRelation extends EditBaseObject {
|
|
|
6
6
|
super._construct();
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
performChange(aObject, aData, aRequest) {
|
|
10
|
-
aObject.addOutgoingRelation(aData["value"], aData["type"]);
|
|
9
|
+
async performChange(aObject, aData, aRequest) {
|
|
10
|
+
await aObject.addOutgoingRelation(aData["value"], aData["type"]);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
import EditBaseObject from "./EditBaseObject.js";
|
|
3
|
+
|
|
4
|
+
export default class PurgeCache extends EditBaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
async performChange(aObject, aData, aRequest) {
|
|
10
|
+
let url = await aObject.getUrl();
|
|
11
|
+
console.log(url);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -6,7 +6,7 @@ export default class SetField extends EditBaseObject {
|
|
|
6
6
|
super._construct();
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
performChange(aObject, aData, aRequest) {
|
|
10
|
-
aObject.updateField(aData["field"], aData["value"]);
|
|
9
|
+
async performChange(aObject, aData, aRequest) {
|
|
10
|
+
await aObject.updateField(aData["field"], aData["value"]);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
|
|
3
|
+
export default class SeoSummary extends Dbm.core.BaseObject {
|
|
4
|
+
_construct() {
|
|
5
|
+
super._construct();
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
async getData(aData, aEncodeSession) {
|
|
9
|
+
let returnObject = {};
|
|
10
|
+
|
|
11
|
+
let content = aData["value"];
|
|
12
|
+
returnObject["content"] = content;
|
|
13
|
+
|
|
14
|
+
let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
|
|
15
|
+
let item = await database.createObject("private", ["aiGeneratedSeoSummary"]);
|
|
16
|
+
await item.updateField("content", content);
|
|
17
|
+
returnObject["id"] = item.id;
|
|
18
|
+
|
|
19
|
+
let contentString = JSON.stringify(content);
|
|
20
|
+
|
|
21
|
+
let instructions = "Generate an seo description for the page data provided by the user, with a max character count of 155. {additionalInstructions} Respond with only a json object {seoSummary: string}, no markdown.";
|
|
22
|
+
instructions = instructions.split("{data}").join(contentString);
|
|
23
|
+
|
|
24
|
+
let additionalInstructions = "";
|
|
25
|
+
instructions = instructions.split("{additionalInstructions}").join(additionalInstructions);
|
|
26
|
+
|
|
27
|
+
let body = {
|
|
28
|
+
"model": "gpt-4o-mini",
|
|
29
|
+
"messages": [
|
|
30
|
+
{"role":"system","content": instructions},
|
|
31
|
+
{"role": "user", "content": contentString}
|
|
32
|
+
],
|
|
33
|
+
"temperature": 0.7
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let headers = {
|
|
37
|
+
"Content-Type": "application/json",
|
|
38
|
+
'Authorization': 'Bearer ' + Dbm.getInstance().repository.getItem("openAi").token
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
let response = await fetch('https://api.openai.com/v1/chat/completions', {
|
|
42
|
+
method: "POST",
|
|
43
|
+
headers: headers,
|
|
44
|
+
body: JSON.stringify(body),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
let data = await response.json();
|
|
48
|
+
await item.updateField("response", data);
|
|
49
|
+
|
|
50
|
+
let message = data.choices[0].message;
|
|
51
|
+
let responseContent = JSON.parse(message.content);
|
|
52
|
+
console.log(responseContent);
|
|
53
|
+
|
|
54
|
+
returnObject["seoSummary"] = responseContent["seoSummary"];
|
|
55
|
+
|
|
56
|
+
return returnObject;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -12,7 +12,9 @@ export default class UploadS3 extends Dbm.core.BaseObject {
|
|
|
12
12
|
this.item.requireProperty("bucketName");
|
|
13
13
|
this.item.requireProperty("path", "content/{year}/{month}/{date}/{generatedId}/");
|
|
14
14
|
this.item.requireProperty("publicPath", "");
|
|
15
|
+
this.item.requireProperty("publicResizePath", "");
|
|
15
16
|
this.item.requireProperty("acl", "public-read");
|
|
17
|
+
this.item.requireProperty("additionalHeaders", {});
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
async getData(aData, aEncodeSession) {
|
|
@@ -58,9 +60,12 @@ export default class UploadS3 extends Dbm.core.BaseObject {
|
|
|
58
60
|
|
|
59
61
|
let presignedUrl = await getSignedUrl(this.item.client, command, { expiresIn: 360 });
|
|
60
62
|
|
|
63
|
+
returnObject["identifier"] = generatedId;
|
|
61
64
|
returnObject["url"] = presignedUrl;
|
|
62
65
|
returnObject["publicUrl"] = this.item.publicPath + fileName;
|
|
66
|
+
returnObject["publicResizeUrl"] = this.item.publicResizePath + fileName;
|
|
63
67
|
returnObject["acl"] = acl;
|
|
68
|
+
returnObject["additionalHeaders"] = this.item.additionalHeaders;
|
|
64
69
|
|
|
65
70
|
return returnObject;
|
|
66
71
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export {default as Example} from "./Example.js";
|
|
2
2
|
export {default as UploadS3} from "./UploadS3.js";
|
|
3
3
|
export {default as FreeUrl} from "./FreeUrl.js";
|
|
4
|
+
export {default as SeoSummary} from "./SeoSummary.js";
|
|
4
5
|
|
|
5
6
|
import UploadS3 from "./UploadS3.js";
|
|
6
7
|
|
|
@@ -26,6 +27,30 @@ export let createDigitalOceanSpacesUpload = function(aKeyId, aSecret, aRegion, a
|
|
|
26
27
|
newUploadS3.item.client = client;
|
|
27
28
|
newUploadS3.item.bucketName = aBucketName;
|
|
28
29
|
newUploadS3.item.publicPath = aPublicPath;
|
|
30
|
+
newUploadS3.item.publicResizePath = aPublicPath;
|
|
31
|
+
|
|
32
|
+
newUploadS3.item.additionalHeaders = {'x-amz-acl': 'public-read'};
|
|
33
|
+
|
|
34
|
+
return newUploadS3;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export let createCloudflareR2Upload = function(aAccountId, aAccessKeyId, aSecretAccessKeyId, aBucketName, aPublicPath) {
|
|
38
|
+
|
|
39
|
+
let client = new S3Client({
|
|
40
|
+
endpoint: "https://" + aAccountId + ".r2.cloudflarestorage.com",
|
|
41
|
+
forcePathStyle: false,
|
|
42
|
+
region: "auto",
|
|
43
|
+
credentials: {
|
|
44
|
+
accessKeyId: aAccessKeyId,
|
|
45
|
+
secretAccessKey: aSecretAccessKeyId
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
let newUploadS3 = new UploadS3();
|
|
50
|
+
newUploadS3.item.client = client;
|
|
51
|
+
newUploadS3.item.bucketName = aBucketName;
|
|
52
|
+
newUploadS3.item.publicPath = aPublicPath;
|
|
53
|
+
newUploadS3.item.publicResizePath = aPublicPath + "cdn-cgi/image/{scale}/";
|
|
29
54
|
|
|
30
55
|
return newUploadS3;
|
|
31
56
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Dbm from "dbm";
|
|
2
2
|
import crypto from "node:crypto";
|
|
3
|
+
import url from "node:url";
|
|
3
4
|
|
|
4
5
|
import DbmGraphApi from "../../index.js";
|
|
5
6
|
import Api from "./Api.js";
|
|
@@ -10,6 +11,8 @@ export {Api};
|
|
|
10
11
|
export * as range from "./range/index.js";
|
|
11
12
|
export * as admin from "./admin/index.js";
|
|
12
13
|
export * as data from "./data/index.js";
|
|
14
|
+
export * as action from "./action/index.js";
|
|
15
|
+
export * as processAction from "./processAction/index.js";
|
|
13
16
|
|
|
14
17
|
let fullSelectSetup = function() {
|
|
15
18
|
let selectPrefix = "graphApi/range/select/";
|
|
@@ -18,6 +21,18 @@ let fullSelectSetup = function() {
|
|
|
18
21
|
let currentSelect = new DbmGraphApi.range.select.IdSelection();
|
|
19
22
|
currentSelect.item.register(selectPrefix + name);
|
|
20
23
|
}
|
|
24
|
+
|
|
25
|
+
{
|
|
26
|
+
let name = "byObjectType";
|
|
27
|
+
let currentSelect = new DbmGraphApi.range.select.ByObjectType();
|
|
28
|
+
currentSelect.item.register(selectPrefix + name);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
{
|
|
32
|
+
let name = "includePrivate";
|
|
33
|
+
let currentSelect = new DbmGraphApi.range.select.IncludePrivate();
|
|
34
|
+
currentSelect.item.register(selectPrefix + name);
|
|
35
|
+
}
|
|
21
36
|
}
|
|
22
37
|
|
|
23
38
|
export {fullSelectSetup};
|
|
@@ -72,6 +87,27 @@ let fullEncodeSetup = function() {
|
|
|
72
87
|
currentEncode.item.register(encodePrefix + name);
|
|
73
88
|
currentEncode.item.setValue("encodingType", name);
|
|
74
89
|
}
|
|
90
|
+
|
|
91
|
+
{
|
|
92
|
+
let name = "breadcrumb";
|
|
93
|
+
let currentEncode = new DbmGraphApi.range.encode.Breadcrumb();
|
|
94
|
+
currentEncode.item.register(encodePrefix + name);
|
|
95
|
+
currentEncode.item.setValue("encodingType", name);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
{
|
|
99
|
+
let name = "navigationName";
|
|
100
|
+
let currentEncode = new DbmGraphApi.range.encode.NavigationName();
|
|
101
|
+
currentEncode.item.register(encodePrefix + name);
|
|
102
|
+
currentEncode.item.setValue("encodingType", name);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
{
|
|
106
|
+
let name = "type";
|
|
107
|
+
let currentEncode = new DbmGraphApi.range.encode.Type();
|
|
108
|
+
currentEncode.item.register(encodePrefix + name);
|
|
109
|
+
currentEncode.item.setValue("encodingType", name);
|
|
110
|
+
}
|
|
75
111
|
}
|
|
76
112
|
|
|
77
113
|
export {fullEncodeSetup};
|
|
@@ -87,15 +123,48 @@ export let registerDataFunction = function(aName, aDataFunction) {
|
|
|
87
123
|
let fullDataSetup = function() {
|
|
88
124
|
registerDataFunction("example", new DbmGraphApi.data.Example());
|
|
89
125
|
registerDataFunction("admin/freeUrl", new DbmGraphApi.data.FreeUrl());
|
|
126
|
+
registerDataFunction("admin/seoSummary", new DbmGraphApi.data.SeoSummary());
|
|
90
127
|
}
|
|
91
128
|
|
|
92
129
|
export {fullDataSetup};
|
|
93
130
|
|
|
131
|
+
export let registerActionFunction = function(aName, aDataFunction) {
|
|
132
|
+
|
|
133
|
+
aDataFunction.item.register("graphApi/action/" + aName);
|
|
134
|
+
aDataFunction.item.setValue("functionName", aName);
|
|
135
|
+
|
|
136
|
+
return aDataFunction;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
let fullActionSetup = function() {
|
|
140
|
+
registerActionFunction("example", new DbmGraphApi.action.Example());
|
|
141
|
+
registerActionFunction("incomingWebhook", new DbmGraphApi.action.IncomingWebhook());
|
|
142
|
+
registerActionFunction("cron/processActions", new DbmGraphApi.action.cron.ProcessActions());
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export {fullActionSetup};
|
|
146
|
+
|
|
147
|
+
export let registerProcessActionFunction = function(aName, aDataFunction) {
|
|
148
|
+
|
|
149
|
+
aDataFunction.item.register("graphApi/processAction/" + aName);
|
|
150
|
+
aDataFunction.item.setValue("functionName", aName);
|
|
151
|
+
|
|
152
|
+
return aDataFunction;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
let fullProcessActionSetup = function() {
|
|
156
|
+
registerProcessActionFunction("example", new DbmGraphApi.processAction.Example());
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export {fullProcessActionSetup};
|
|
160
|
+
|
|
94
161
|
let fullSetup = function() {
|
|
95
162
|
|
|
96
163
|
fullSelectSetup();
|
|
97
164
|
fullEncodeSetup();
|
|
98
165
|
fullDataSetup();
|
|
166
|
+
fullActionSetup();
|
|
167
|
+
fullProcessActionSetup()
|
|
99
168
|
|
|
100
169
|
DbmGraphApi.admin.edit.fullSetup();
|
|
101
170
|
}
|
|
@@ -191,11 +260,80 @@ let setupEndpoints = function(aServer) {
|
|
|
191
260
|
return request.getResponse();
|
|
192
261
|
});
|
|
193
262
|
|
|
194
|
-
|
|
263
|
+
aServer.get('/api/range/:selects/:encodes', async function handler (aRequest, aReply) {
|
|
264
|
+
|
|
265
|
+
let params = {...aRequest.query};
|
|
266
|
+
let selectIds = aRequest.params.selects.split(",");
|
|
267
|
+
let selects = new Array(selectIds.length);
|
|
268
|
+
let encodes = aRequest.params.encodes.split(",");
|
|
269
|
+
|
|
270
|
+
{
|
|
271
|
+
let currentArray = selectIds;
|
|
272
|
+
let currentArrayLength = currentArray.length;
|
|
273
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
274
|
+
selects[i] = {...params, type: currentArray[i]};
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
let request = new UrlRequest();
|
|
279
|
+
|
|
280
|
+
await request.requestRange(selects, encodes, params);
|
|
281
|
+
|
|
282
|
+
return request.getResponse();
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
aServer.get('/api/item/:id/:encodes', async function handler (aRequest, aReply) {
|
|
286
|
+
|
|
287
|
+
let itemId = 1*aRequest.params.id;
|
|
288
|
+
let encodes = aRequest.params.encodes.split(",");
|
|
289
|
+
|
|
290
|
+
let request = new UrlRequest();
|
|
291
|
+
|
|
292
|
+
await request.requestItem(itemId, encodes);
|
|
293
|
+
|
|
294
|
+
return request.getResponse();
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
aServer.get('/api/data/*', async function handler (aRequest, aReply) {
|
|
298
|
+
let params = {...aRequest.query};
|
|
299
|
+
let request = new UrlRequest();
|
|
300
|
+
|
|
301
|
+
let currentUrl = url.parse(aRequest.url);
|
|
302
|
+
let functionName = currentUrl.pathname.substring("/api/data/".length);
|
|
303
|
+
|
|
304
|
+
await request.requestData(functionName, params);
|
|
305
|
+
|
|
306
|
+
return request.getResponse();
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
aServer.get('/api/action/*', async function handler (aRequest, aReply) {
|
|
310
|
+
|
|
311
|
+
let params = {...aRequest.query};
|
|
312
|
+
let request = new UrlRequest();
|
|
313
|
+
|
|
314
|
+
let currentUrl = url.parse(aRequest.url);
|
|
315
|
+
let functionName = currentUrl.pathname.substring("/api/action/".length);
|
|
316
|
+
|
|
317
|
+
await request.performAction(functionName, params);
|
|
318
|
+
|
|
319
|
+
return request.getResponse();
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
aServer.post('/api/action/*', async function handler (aRequest, aReply) {
|
|
323
|
+
let params = {...aRequest.body};
|
|
324
|
+
let request = new UrlRequest();
|
|
325
|
+
|
|
326
|
+
let currentUrl = url.parse(aRequest.url);
|
|
327
|
+
let functionName = currentUrl.pathname.substring("/api/action/".length);
|
|
328
|
+
|
|
329
|
+
await request.performAction(functionName, params);
|
|
330
|
+
|
|
331
|
+
return request.getResponse();
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
//METODO: setup raw data posts
|
|
335
|
+
|
|
195
336
|
//METODO: setup edit
|
|
196
|
-
//METODO: setup data
|
|
197
|
-
//METODO: setup actions
|
|
198
|
-
//METODO: setup cron
|
|
199
337
|
|
|
200
338
|
aServer.get('/api/', async function handler (aRequest, aResponse) {
|
|
201
339
|
return { version: Dbm.getInstance().repository.getItem("site").version };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default as Example} from "./Example.js";
|
|
@@ -6,6 +6,8 @@ export default class EncodeSession extends Dbm.core.BaseObject {
|
|
|
6
6
|
|
|
7
7
|
this._encodings = {};
|
|
8
8
|
this.outputController = null;
|
|
9
|
+
|
|
10
|
+
//METODO: add cache of database objects
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
_readyToEncode(aId, aType) {
|
|
@@ -22,10 +24,10 @@ export default class EncodeSession extends Dbm.core.BaseObject {
|
|
|
22
24
|
}
|
|
23
25
|
|
|
24
26
|
_encodeSingleNoAwait(aId, aType) {
|
|
25
|
-
console.log("_encodeSingleNoAwait");
|
|
27
|
+
//console.log("_encodeSingleNoAwait");
|
|
26
28
|
|
|
27
29
|
let shouldEncode = this._readyToEncode(aId, aType);
|
|
28
|
-
console.log(shouldEncode, aId, aType);
|
|
30
|
+
//console.log(shouldEncode, aId, aType);
|
|
29
31
|
if(shouldEncode) {
|
|
30
32
|
let encoding = Dbm.getInstance().repository.getItemIfExists("graphApi/range/encode/" + aType);
|
|
31
33
|
if(encoding) {
|
|
@@ -35,7 +37,7 @@ export default class EncodeSession extends Dbm.core.BaseObject {
|
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
async encodeSingle(aId, aType) {
|
|
38
|
-
console.log("encodeSingle");
|
|
40
|
+
//console.log("encodeSingle");
|
|
39
41
|
|
|
40
42
|
await this._encodeSingleNoAwait(aId, aType);
|
|
41
43
|
}
|
|
@@ -54,7 +56,6 @@ export default class EncodeSession extends Dbm.core.BaseObject {
|
|
|
54
56
|
async encode(aIds, aType) {
|
|
55
57
|
let currentArray = aIds;
|
|
56
58
|
let currentArrayLength = currentArray.length;
|
|
57
|
-
let ids = new Array(currentArrayLength);
|
|
58
59
|
let promises = new Array(currentArrayLength);
|
|
59
60
|
for(let i = 0; i < currentArrayLength; i++) {
|
|
60
61
|
let id = currentArray[i];
|
|
@@ -63,7 +64,7 @@ export default class EncodeSession extends Dbm.core.BaseObject {
|
|
|
63
64
|
|
|
64
65
|
await Promise.all(promises);
|
|
65
66
|
|
|
66
|
-
return
|
|
67
|
+
return aIds;
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
async encodeObjectOrNull(aObject, aType) {
|
|
@@ -4,8 +4,22 @@ export default class Query extends Dbm.core.BaseObject {
|
|
|
4
4
|
_construct() {
|
|
5
5
|
super._construct();
|
|
6
6
|
|
|
7
|
+
this._joins = [];
|
|
8
|
+
this._whereStatements = [];
|
|
7
9
|
this._includeOnly = null;
|
|
8
10
|
this._visibilities = ["public"];
|
|
11
|
+
this._skipVisibility = false;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async setObjectType(aName) {
|
|
15
|
+
let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
|
|
16
|
+
|
|
17
|
+
let objectType = await database.getObjectType(aName);
|
|
18
|
+
|
|
19
|
+
this._joins.push("INNER JOIN ObjectTypesLink ON Objects.id = ObjectTypesLink.id");
|
|
20
|
+
this._whereStatements.push("ObjectTypesLink.type = " + objectType);
|
|
21
|
+
|
|
22
|
+
return this;
|
|
9
23
|
}
|
|
10
24
|
|
|
11
25
|
includeOnly(aIds) {
|
|
@@ -21,14 +35,58 @@ export default class Query extends Dbm.core.BaseObject {
|
|
|
21
35
|
|
|
22
36
|
includeNone() {
|
|
23
37
|
this._includeOnly = [];
|
|
38
|
+
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
includePrivate() {
|
|
43
|
+
this._visibilities.push("private");
|
|
44
|
+
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
includeDraft() {
|
|
49
|
+
this._visibilities.push("draft");
|
|
50
|
+
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
includeAnyStatus() {
|
|
55
|
+
this._skipVisibility = true;
|
|
56
|
+
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
addFieldQuery(aKey, aValue) {
|
|
61
|
+
|
|
62
|
+
let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
|
|
63
|
+
|
|
64
|
+
this._joins.push("INNER JOIN Fields ON Objects.id = Fields.object");
|
|
65
|
+
this._whereStatements.push("Fields.name = " + database.connection.escape(aKey));
|
|
66
|
+
this._whereStatements.push("Fields.value = " + database.connection.escape(JSON.stringify(aValue)));
|
|
67
|
+
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
withIdentifier(aIdentifier) {
|
|
72
|
+
let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
|
|
73
|
+
|
|
74
|
+
this._joins.push("INNER JOIN Identifiers ON Objects.id = Identifiers.object");
|
|
75
|
+
this._whereStatements.push("Identifiers.identifier = " + database.connection.escape(aIdentifier));
|
|
76
|
+
|
|
77
|
+
return this;
|
|
24
78
|
}
|
|
25
79
|
|
|
26
80
|
async getIds() {
|
|
27
81
|
let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
|
|
28
82
|
|
|
29
83
|
let query = "SELECT Objects.id as id FROM Objects";
|
|
84
|
+
|
|
85
|
+
if(this._joins.length) {
|
|
86
|
+
query += " " + this._joins.join(" ");
|
|
87
|
+
}
|
|
30
88
|
|
|
31
|
-
let whereStatements = [];
|
|
89
|
+
let whereStatements = [].concat(this._whereStatements);
|
|
32
90
|
if(this._includeOnly !== null) {
|
|
33
91
|
if(this._includeOnly.length === 0) {
|
|
34
92
|
return [];
|
|
@@ -36,7 +94,17 @@ export default class Query extends Dbm.core.BaseObject {
|
|
|
36
94
|
whereStatements.push("Objects.id IN (" + this._includeOnly.join(",") + ")");
|
|
37
95
|
}
|
|
38
96
|
|
|
39
|
-
|
|
97
|
+
if(!this._skipVisibility) {
|
|
98
|
+
let visibilityIds = [];
|
|
99
|
+
let currentArray = this._visibilities;
|
|
100
|
+
let currentArrayLength = currentArray.length;
|
|
101
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
102
|
+
let currentId = await database.getVisibilityType(currentArray[i]);
|
|
103
|
+
visibilityIds.push(currentId);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
whereStatements.push("Objects.visibility IN (" + visibilityIds.join(",") + ")");
|
|
107
|
+
}
|
|
40
108
|
|
|
41
109
|
if(whereStatements.length) {
|
|
42
110
|
query += " WHERE " + whereStatements.join(" AND ");
|
|
@@ -53,4 +121,23 @@ export default class Query extends Dbm.core.BaseObject {
|
|
|
53
121
|
|
|
54
122
|
return returnArray;
|
|
55
123
|
}
|
|
124
|
+
|
|
125
|
+
async getObjects() {
|
|
126
|
+
let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
|
|
127
|
+
let ids = await this.getIds();
|
|
128
|
+
|
|
129
|
+
return database.getObjects(ids);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async getObject() {
|
|
133
|
+
let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
|
|
134
|
+
let ids = await this.getIds();
|
|
135
|
+
|
|
136
|
+
if(ids.length) {
|
|
137
|
+
//METODO: warning if more than 1
|
|
138
|
+
return database.getObject(ids[0]);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
56
143
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
import EncodeBaseObject from "./EncodeBaseObject.js";
|
|
3
|
+
|
|
4
|
+
export default class Breadcrumb extends EncodeBaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
async getEncodedData(aId, aEncodingSession) {
|
|
10
|
+
console.log("Breadcrumb::getEncodedData");
|
|
11
|
+
|
|
12
|
+
let returnObject = {};
|
|
13
|
+
|
|
14
|
+
let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
|
|
15
|
+
let object = database.getObject(aId);
|
|
16
|
+
|
|
17
|
+
let url = await object.getUrl();
|
|
18
|
+
|
|
19
|
+
if(url) {
|
|
20
|
+
let parts = url.split("/");
|
|
21
|
+
parts.pop(); //MENOTE: remove trailing slash
|
|
22
|
+
let ids = [];
|
|
23
|
+
|
|
24
|
+
let currentArrayLength = parts.length;
|
|
25
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
26
|
+
let currentUrl = parts.join("/") + "/";
|
|
27
|
+
|
|
28
|
+
let currentObject = await database.getObjectByUrl(currentUrl);
|
|
29
|
+
if(currentObject) {
|
|
30
|
+
await aEncodingSession.encodeSingle(currentObject.id, "title");
|
|
31
|
+
await aEncodingSession.encodeSingle(currentObject.id, "url");
|
|
32
|
+
await aEncodingSession.encodeSingle(currentObject.id, "navigationName");
|
|
33
|
+
ids.push(currentObject.id);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
parts.pop();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
ids.reverse();
|
|
40
|
+
|
|
41
|
+
returnObject["breadcrumbs"] = ids;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
returnObject["breadcrumbs"] = [];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
return returnObject;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
import EncodeBaseObject from "./EncodeBaseObject.js";
|
|
3
|
+
|
|
4
|
+
export default class NavigationName 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["navigationName"] = fields["navigationName"] ? fields["navigationName"] : null;
|
|
17
|
+
|
|
18
|
+
return returnObject;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
import EncodeBaseObject from "./EncodeBaseObject.js";
|
|
3
|
+
|
|
4
|
+
export default class Type 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, "identifier");
|
|
16
|
+
await aEncodingSession.encodeSingle(aId, "name");
|
|
17
|
+
|
|
18
|
+
return returnObject;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -16,6 +16,7 @@ export default class UrlRequest extends EncodeBaseObject {
|
|
|
16
16
|
await aEncodingSession.encodeSingle(aId, "title");
|
|
17
17
|
await aEncodingSession.encodeSingle(aId, "content");
|
|
18
18
|
await aEncodingSession.encodeSingle(aId, "url");
|
|
19
|
+
await aEncodingSession.encodeSingle(aId, "navigationName");
|
|
19
20
|
|
|
20
21
|
let fields = await object.getFields();
|
|
21
22
|
returnObject["meta/description"] = fields["meta/description"] ? fields["meta/description"] : null;
|
|
@@ -6,4 +6,7 @@ export {default as Name} from "./Name.js";
|
|
|
6
6
|
export {default as Content} from "./Content.js";
|
|
7
7
|
export {default as Title} from "./Title.js";
|
|
8
8
|
export {default as UrlRequest} from "./UrlRequest.js";
|
|
9
|
-
export {default as Url} from "./Url.js";
|
|
9
|
+
export {default as Url} from "./Url.js";
|
|
10
|
+
export {default as Breadcrumb} from "./Breadcrumb.js";
|
|
11
|
+
export {default as NavigationName} from "./NavigationName.js";
|
|
12
|
+
export {default as Type} from "./Type.js";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
|
|
3
|
+
import SelectBaseObject from "./SelectBaseObject.js";
|
|
4
|
+
|
|
5
|
+
export default class ByObjectType extends SelectBaseObject {
|
|
6
|
+
_construct() {
|
|
7
|
+
super._construct();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async select(aQuery, aData, aRequest) {
|
|
11
|
+
|
|
12
|
+
if(!aData["objectType"]) {
|
|
13
|
+
throw("Parameter objectType not set");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
await aQuery.setObjectType(aData["objectType"]);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async filter(aIds, aData, aRequest) {
|
|
20
|
+
return aIds;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -8,7 +8,7 @@ export default class IdSelection extends SelectBaseObject {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
async select(aQuery, aData, aRequest) {
|
|
11
|
-
aQuery.includeOnly(aData["ids"]);
|
|
11
|
+
aQuery.includeOnly(Dbm.utils.ArrayFunctions.arrayOrSeparatedString(aData["ids"]));
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
async filter(aIds, aData, aRequest) {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
|
|
3
|
+
import SelectBaseObject from "./SelectBaseObject.js";
|
|
4
|
+
|
|
5
|
+
export default class IncludePrivate extends SelectBaseObject {
|
|
6
|
+
_construct() {
|
|
7
|
+
super._construct();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async select(aQuery, aData, aRequest) {
|
|
11
|
+
//METODO: check that we are allowed
|
|
12
|
+
aQuery.includePrivate();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async filter(aIds, aData, aRequest) {
|
|
16
|
+
return aIds;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export {default as SelectBaseObject} from "./SelectBaseObject.js";
|
|
2
|
-
export {default as IdSelection} from "./IdSelection.js";
|
|
2
|
+
export {default as IdSelection} from "./IdSelection.js";
|
|
3
|
+
export {default as ByObjectType} from "./ByObjectType.js";
|
|
4
|
+
export {default as IncludePrivate} from "./IncludePrivate.js";
|