dbm-graph-api 1.0.3 → 1.1.1
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 +7 -4
- package/src/dbm-graph-api/Api.js +12 -1
- package/src/dbm-graph-api/UrlRequest.js +83 -5
- package/src/dbm-graph-api/WebSocketConnection.js +36 -4
- package/src/dbm-graph-api/data/UploadS3.js +5 -0
- package/src/dbm-graph-api/data/index.js +24 -0
- package/src/dbm-graph-api/index.js +63 -2
- package/src/dbm-graph-api/range/EncodeSession.js +3 -3
- package/src/dbm-graph-api/range/Query.js +27 -1
- 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/UrlRequest.js +1 -0
- package/src/dbm-graph-api/range/encode/index.js +3 -1
- package/src/dbm-graph-api/range/select/ByObjectType.js +17 -0
- package/src/dbm-graph-api/range/select/index.js +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dbm-graph-api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -11,9 +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.0
|
|
14
|
+
"@aws-sdk/client-s3": "^3.741.0",
|
|
15
|
+
"@aws-sdk/s3-request-presigner": "^3.741.0",
|
|
16
|
+
"dbm": "^1.1.0",
|
|
17
17
|
"ws": "^8.18.0"
|
|
18
|
+
},
|
|
19
|
+
"optionalDependencies": {
|
|
20
|
+
"bufferutil": "^4.0.9"
|
|
18
21
|
}
|
|
19
22
|
}
|
package/src/dbm-graph-api/Api.js
CHANGED
|
@@ -49,7 +49,7 @@ export default class Api extends Dbm.core.BaseObject {
|
|
|
49
49
|
let user = Dbm.getInstance().repository.getItem("graphDatabase").controller.getUser(userId);
|
|
50
50
|
|
|
51
51
|
user.verifySession(value).then(function(aIsValidSession) {
|
|
52
|
-
console.log("verifySession", aIsValidSession);
|
|
52
|
+
//console.log("verifySession", aIsValidSession);
|
|
53
53
|
|
|
54
54
|
if(aIsValidSession) {
|
|
55
55
|
newWebSocketConnection.setInitialUser(userId);
|
|
@@ -69,4 +69,15 @@ export default class Api extends Dbm.core.BaseObject {
|
|
|
69
69
|
newWebSocketConnection.setInitialUser(0);
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
+
|
|
73
|
+
connectionClosed(aConnection) {
|
|
74
|
+
//console.log("connectionClosed");
|
|
75
|
+
let connections = [].concat(this.item.connections);
|
|
76
|
+
let index = connections.indexOf(aConnection.item);
|
|
77
|
+
if(index >= 0) {
|
|
78
|
+
connections.splice(index, 1);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
this.item.setValue("connections", connections);
|
|
82
|
+
}
|
|
72
83
|
}
|
|
@@ -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,25 +31,102 @@ 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;
|
|
42
120
|
}
|
|
43
121
|
|
|
44
122
|
outputEncodedData(aId, aData, aEncoding) {
|
|
45
|
-
console.log("UrlRequest::outputEncodedData");
|
|
123
|
+
//console.log("UrlRequest::outputEncodedData");
|
|
46
124
|
|
|
47
125
|
this._encodedObjects.push({"id": aId, "data": aData, "encoding": aEncoding});
|
|
48
126
|
|
|
49
127
|
}
|
|
50
128
|
|
|
51
129
|
getResponse() {
|
|
52
|
-
return {"objects": this._encodedObjects, "data": this._responseData};
|
|
130
|
+
return {"objects": this._encodedObjects, "data": this._responseData, "logs": this._logs};
|
|
53
131
|
}
|
|
54
132
|
}
|
|
@@ -8,6 +8,7 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
|
|
|
8
8
|
|
|
9
9
|
this._callback_errorBound = this._callback_error.bind(this);
|
|
10
10
|
this._callback_messageBound = this._callback_message.bind(this);
|
|
11
|
+
this._callback_closeBound = this._callback_close.bind(this);
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
setWebSocket(aWebSocket) {
|
|
@@ -32,7 +33,7 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
async _callback_message(aDataString) {
|
|
35
|
-
console.log('received: %s', aDataString);
|
|
36
|
+
//console.log('received: %s', aDataString);
|
|
36
37
|
|
|
37
38
|
let data;
|
|
38
39
|
|
|
@@ -53,6 +54,7 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
|
|
|
53
54
|
let selectQuery = new DbmGraphApi.range.Query();
|
|
54
55
|
|
|
55
56
|
let ids = [];
|
|
57
|
+
let logs = [];
|
|
56
58
|
|
|
57
59
|
{
|
|
58
60
|
let hasSelection = false;
|
|
@@ -66,6 +68,9 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
|
|
|
66
68
|
hasSelection = true;
|
|
67
69
|
await selection.controller.select(selectQuery, currentSelectData, request);
|
|
68
70
|
}
|
|
71
|
+
else {
|
|
72
|
+
logs.push("No selection named " + currentSelectType);
|
|
73
|
+
}
|
|
69
74
|
}
|
|
70
75
|
|
|
71
76
|
if(hasSelection) {
|
|
@@ -81,7 +86,7 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
|
|
|
81
86
|
}
|
|
82
87
|
}
|
|
83
88
|
else {
|
|
84
|
-
|
|
89
|
+
logs.push("No valid selections");
|
|
85
90
|
}
|
|
86
91
|
|
|
87
92
|
}
|
|
@@ -101,7 +106,7 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
|
|
|
101
106
|
encodeSession.destroy();
|
|
102
107
|
}
|
|
103
108
|
|
|
104
|
-
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}));
|
|
105
110
|
break;
|
|
106
111
|
case "data":
|
|
107
112
|
{
|
|
@@ -225,25 +230,52 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
|
|
|
225
230
|
|
|
226
231
|
this._webSocket.send(JSON.stringify({"type": "currentUser/response", "id": userId, "requestId": data["requestId"]}));
|
|
227
232
|
|
|
233
|
+
}
|
|
234
|
+
break;
|
|
235
|
+
case "heartbeat":
|
|
236
|
+
{
|
|
237
|
+
this._webSocket.send(JSON.stringify({"type": "heartbeat/response"}));
|
|
238
|
+
|
|
228
239
|
}
|
|
229
240
|
break;
|
|
230
241
|
}
|
|
231
242
|
}
|
|
232
243
|
|
|
233
244
|
_callback_error(aMessage) {
|
|
245
|
+
console.log("_callback_error");
|
|
234
246
|
console.error(aMessage);
|
|
235
247
|
}
|
|
248
|
+
|
|
249
|
+
_callback_close() {
|
|
250
|
+
//console.log("_callback_close");
|
|
251
|
+
|
|
252
|
+
if(this._webSocket) {
|
|
253
|
+
this._webSocket.off('error', this._callback_error);
|
|
254
|
+
this._webSocket.off('message', this._callback_messageBound);
|
|
255
|
+
this._webSocket.off('close', this._callback_closeBound);
|
|
256
|
+
this._webSocket = null;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
this._callback_errorBound = null;
|
|
260
|
+
this._callback_messageBound = null;
|
|
261
|
+
this._callback_closeBound = null;
|
|
262
|
+
|
|
263
|
+
this.item.api.controller.connectionClosed(this);
|
|
264
|
+
this.item.setValue("api", null);
|
|
265
|
+
this.item.setValue("controller", null);
|
|
266
|
+
}
|
|
236
267
|
|
|
237
268
|
addListeners() {
|
|
238
269
|
|
|
239
270
|
this._webSocket.on('error', this._callback_error);
|
|
240
271
|
this._webSocket.on('message', this._callback_messageBound);
|
|
272
|
+
this._webSocket.on('close', this._callback_closeBound);
|
|
241
273
|
|
|
242
274
|
return this;
|
|
243
275
|
}
|
|
244
276
|
|
|
245
277
|
outputEncodedData(aId, aData, aEncoding) {
|
|
246
|
-
console.log("WebSocketConnection::outputEncodedData");
|
|
278
|
+
//console.log("WebSocketConnection::outputEncodedData");
|
|
247
279
|
|
|
248
280
|
this._webSocket.send(JSON.stringify({"type": "updateEncodedObject", "id": aId, "data": aData, "encoding": aEncoding}));
|
|
249
281
|
|
|
@@ -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
|
}
|
|
@@ -26,6 +26,30 @@ export let createDigitalOceanSpacesUpload = function(aKeyId, aSecret, aRegion, a
|
|
|
26
26
|
newUploadS3.item.client = client;
|
|
27
27
|
newUploadS3.item.bucketName = aBucketName;
|
|
28
28
|
newUploadS3.item.publicPath = aPublicPath;
|
|
29
|
+
newUploadS3.item.publicResizePath = aPublicPath;
|
|
30
|
+
|
|
31
|
+
newUploadS3.item.additionalHeaders = {'x-amz-acl': 'public-read'};
|
|
32
|
+
|
|
33
|
+
return newUploadS3;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export let createCloudflareR2Upload = function(aAccountId, aAccessKeyId, aSecretAccessKeyId, aBucketName, aPublicPath) {
|
|
37
|
+
|
|
38
|
+
let client = new S3Client({
|
|
39
|
+
endpoint: "https://" + aAccountId + ".r2.cloudflarestorage.com",
|
|
40
|
+
forcePathStyle: false,
|
|
41
|
+
region: "auto",
|
|
42
|
+
credentials: {
|
|
43
|
+
accessKeyId: aAccessKeyId,
|
|
44
|
+
secretAccessKey: aSecretAccessKeyId
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
let newUploadS3 = new UploadS3();
|
|
49
|
+
newUploadS3.item.client = client;
|
|
50
|
+
newUploadS3.item.bucketName = aBucketName;
|
|
51
|
+
newUploadS3.item.publicPath = aPublicPath;
|
|
52
|
+
newUploadS3.item.publicResizePath = aPublicPath + "cdn-cgi/image/{scale}/";
|
|
29
53
|
|
|
30
54
|
return newUploadS3;
|
|
31
55
|
}
|
|
@@ -18,6 +18,12 @@ let fullSelectSetup = function() {
|
|
|
18
18
|
let currentSelect = new DbmGraphApi.range.select.IdSelection();
|
|
19
19
|
currentSelect.item.register(selectPrefix + name);
|
|
20
20
|
}
|
|
21
|
+
|
|
22
|
+
{
|
|
23
|
+
let name = "byObjectType";
|
|
24
|
+
let currentSelect = new DbmGraphApi.range.select.ByObjectType();
|
|
25
|
+
currentSelect.item.register(selectPrefix + name);
|
|
26
|
+
}
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
export {fullSelectSetup};
|
|
@@ -72,6 +78,20 @@ let fullEncodeSetup = function() {
|
|
|
72
78
|
currentEncode.item.register(encodePrefix + name);
|
|
73
79
|
currentEncode.item.setValue("encodingType", name);
|
|
74
80
|
}
|
|
81
|
+
|
|
82
|
+
{
|
|
83
|
+
let name = "breadcrumb";
|
|
84
|
+
let currentEncode = new DbmGraphApi.range.encode.Breadcrumb();
|
|
85
|
+
currentEncode.item.register(encodePrefix + name);
|
|
86
|
+
currentEncode.item.setValue("encodingType", name);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
{
|
|
90
|
+
let name = "navigationName";
|
|
91
|
+
let currentEncode = new DbmGraphApi.range.encode.NavigationName();
|
|
92
|
+
currentEncode.item.register(encodePrefix + name);
|
|
93
|
+
currentEncode.item.setValue("encodingType", name);
|
|
94
|
+
}
|
|
75
95
|
}
|
|
76
96
|
|
|
77
97
|
export {fullEncodeSetup};
|
|
@@ -191,9 +211,50 @@ let setupEndpoints = function(aServer) {
|
|
|
191
211
|
return request.getResponse();
|
|
192
212
|
});
|
|
193
213
|
|
|
194
|
-
|
|
214
|
+
aServer.get('/api/range/:selects/:encodes', async function handler (aRequest, aReply) {
|
|
215
|
+
|
|
216
|
+
let params = {...aRequest.query};
|
|
217
|
+
let selectIds = aRequest.params.selects.split(",");
|
|
218
|
+
let selects = new Array(selectIds.length);
|
|
219
|
+
let encodes = aRequest.params.encodes.split(",");
|
|
220
|
+
|
|
221
|
+
{
|
|
222
|
+
let currentArray = selectIds;
|
|
223
|
+
let currentArrayLength = currentArray.length;
|
|
224
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
225
|
+
selects[i] = {...params, type: currentArray[i]};
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
let request = new UrlRequest();
|
|
230
|
+
|
|
231
|
+
await request.requestRange(selects, encodes, params);
|
|
232
|
+
|
|
233
|
+
return request.getResponse();
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
aServer.get('/api/item/:id/:encodes', async function handler (aRequest, aReply) {
|
|
237
|
+
|
|
238
|
+
let itemId = 1*aRequest.params.id;
|
|
239
|
+
let encodes = aRequest.params.encodes.split(",");
|
|
240
|
+
|
|
241
|
+
let request = new UrlRequest();
|
|
242
|
+
|
|
243
|
+
await request.requestItem(itemId, encodes);
|
|
244
|
+
|
|
245
|
+
return request.getResponse();
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
aServer.get('/api/data/:functionName', async function handler (aRequest, aReply) {
|
|
249
|
+
let params = {...aRequest.query};
|
|
250
|
+
let request = new UrlRequest();
|
|
251
|
+
|
|
252
|
+
await request.requestData(aRequest.params.functionName, params);
|
|
253
|
+
|
|
254
|
+
return request.getResponse();
|
|
255
|
+
});
|
|
256
|
+
|
|
195
257
|
//METODO: setup edit
|
|
196
|
-
//METODO: setup data
|
|
197
258
|
//METODO: setup actions
|
|
198
259
|
//METODO: setup cron
|
|
199
260
|
|
|
@@ -22,10 +22,10 @@ export default class EncodeSession extends Dbm.core.BaseObject {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
_encodeSingleNoAwait(aId, aType) {
|
|
25
|
-
console.log("_encodeSingleNoAwait");
|
|
25
|
+
//console.log("_encodeSingleNoAwait");
|
|
26
26
|
|
|
27
27
|
let shouldEncode = this._readyToEncode(aId, aType);
|
|
28
|
-
console.log(shouldEncode, aId, aType);
|
|
28
|
+
//console.log(shouldEncode, aId, aType);
|
|
29
29
|
if(shouldEncode) {
|
|
30
30
|
let encoding = Dbm.getInstance().repository.getItemIfExists("graphApi/range/encode/" + aType);
|
|
31
31
|
if(encoding) {
|
|
@@ -35,7 +35,7 @@ export default class EncodeSession extends Dbm.core.BaseObject {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
async encodeSingle(aId, aType) {
|
|
38
|
-
console.log("encodeSingle");
|
|
38
|
+
//console.log("encodeSingle");
|
|
39
39
|
|
|
40
40
|
await this._encodeSingleNoAwait(aId, aType);
|
|
41
41
|
}
|
|
@@ -4,10 +4,23 @@ 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"];
|
|
9
11
|
}
|
|
10
12
|
|
|
13
|
+
async setObjectType(aName) {
|
|
14
|
+
let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
|
|
15
|
+
|
|
16
|
+
let objectType = await database.getObjectType(aName);
|
|
17
|
+
|
|
18
|
+
this._joins.push("INNER JOIN ObjectTypesLink ON Objects.id = ObjectTypesLink.id");
|
|
19
|
+
this._whereStatements.push("ObjectTypesLink.type = " + objectType);
|
|
20
|
+
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
|
|
11
24
|
includeOnly(aIds) {
|
|
12
25
|
if(!this._includeOnly) {
|
|
13
26
|
this._includeOnly = aIds;
|
|
@@ -21,14 +34,20 @@ export default class Query extends Dbm.core.BaseObject {
|
|
|
21
34
|
|
|
22
35
|
includeNone() {
|
|
23
36
|
this._includeOnly = [];
|
|
37
|
+
|
|
38
|
+
return this;
|
|
24
39
|
}
|
|
25
40
|
|
|
26
41
|
async getIds() {
|
|
27
42
|
let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
|
|
28
43
|
|
|
29
44
|
let query = "SELECT Objects.id as id FROM Objects";
|
|
45
|
+
|
|
46
|
+
if(this._joins.length) {
|
|
47
|
+
query += " " + this._joins.join(" ");
|
|
48
|
+
}
|
|
30
49
|
|
|
31
|
-
let whereStatements = [];
|
|
50
|
+
let whereStatements = [].concat(this._whereStatements);
|
|
32
51
|
if(this._includeOnly !== null) {
|
|
33
52
|
if(this._includeOnly.length === 0) {
|
|
34
53
|
return [];
|
|
@@ -53,4 +72,11 @@ export default class Query extends Dbm.core.BaseObject {
|
|
|
53
72
|
|
|
54
73
|
return returnArray;
|
|
55
74
|
}
|
|
75
|
+
|
|
76
|
+
async getObjects() {
|
|
77
|
+
let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
|
|
78
|
+
let ids = await this.getIds();
|
|
79
|
+
|
|
80
|
+
return database.getObjects(ids);
|
|
81
|
+
}
|
|
56
82
|
}
|
|
@@ -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
|
+
}
|
|
@@ -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,6 @@ 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";
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
await aQuery.setObjectType(aData["objectType"]);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async filter(aIds, aData, aRequest) {
|
|
15
|
+
return aIds;
|
|
16
|
+
}
|
|
17
|
+
}
|