dbm-graph-api 1.1.3 → 1.1.5
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/UrlRequest.js +92 -0
- package/src/dbm-graph-api/WebSocketConnection.js +119 -70
- package/src/dbm-graph-api/admin/edit/ClearCloudflareCache.js +41 -0
- package/src/dbm-graph-api/admin/edit/{PurgeCache.js → SetVisibility.js} +2 -3
- package/src/dbm-graph-api/admin/edit/index.js +14 -0
- package/src/dbm-graph-api/data/AltText.js +3 -0
- package/src/dbm-graph-api/data/FreeUrl.js +3 -0
- package/src/dbm-graph-api/data/SeoSummary.js +3 -0
- package/src/dbm-graph-api/data/UploadS3.js +3 -0
- package/src/dbm-graph-api/index.js +46 -0
- package/src/dbm-graph-api/range/encode/Visibility.js +19 -0
- package/src/dbm-graph-api/range/encode/index.js +2 -1
- package/src/dbm-graph-api/range/select/IncludeDraft.js +19 -0
- package/src/dbm-graph-api/range/select/IncludePrivate.js +2 -1
- 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.1.
|
|
3
|
+
"version": "1.1.5",
|
|
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.4",
|
|
17
17
|
"ws": "^8.18.0"
|
|
18
18
|
},
|
|
19
19
|
"optionalDependencies": {
|
|
@@ -8,6 +8,19 @@ export default class UrlRequest extends Dbm.core.BaseObject {
|
|
|
8
8
|
this._logs = [];
|
|
9
9
|
this._encodedObjects = [];
|
|
10
10
|
this._responseData = null;
|
|
11
|
+
|
|
12
|
+
this._request = null;
|
|
13
|
+
this._reply = null;
|
|
14
|
+
|
|
15
|
+
this.item.requireProperty("hasLoadedUser", false);
|
|
16
|
+
this.item.requireProperty("user", null);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
setup(aRequest, aReply) {
|
|
20
|
+
this._request = aRequest;
|
|
21
|
+
this._reply = aReply;
|
|
22
|
+
|
|
23
|
+
return null;
|
|
11
24
|
}
|
|
12
25
|
|
|
13
26
|
async requestUrl(aUrl) {
|
|
@@ -98,6 +111,8 @@ export default class UrlRequest extends Dbm.core.BaseObject {
|
|
|
98
111
|
let encodeSession = new DbmGraphApi.range.EncodeSession();
|
|
99
112
|
encodeSession.outputController = this;
|
|
100
113
|
|
|
114
|
+
//METODO: check visibility
|
|
115
|
+
|
|
101
116
|
await encodeSession.encodeSingleWithTypes(aId, aEncodes);
|
|
102
117
|
|
|
103
118
|
encodeSession.destroy();
|
|
@@ -132,6 +147,37 @@ export default class UrlRequest extends Dbm.core.BaseObject {
|
|
|
132
147
|
|
|
133
148
|
this._responseData = returnData;
|
|
134
149
|
}
|
|
150
|
+
|
|
151
|
+
async incomingWebhook(aWebhookType, aData) {
|
|
152
|
+
let encodeSession = new DbmGraphApi.range.EncodeSession();
|
|
153
|
+
encodeSession.outputController = this;
|
|
154
|
+
|
|
155
|
+
let returnObject = {};
|
|
156
|
+
|
|
157
|
+
let type = aWebhookType;
|
|
158
|
+
let data = aData;
|
|
159
|
+
|
|
160
|
+
let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
|
|
161
|
+
|
|
162
|
+
let webhookType = await database.getTypeObject("type/webhookType", type);
|
|
163
|
+
|
|
164
|
+
let incomingWebhook = await database.createObject("private", ["incomingWebhook"]);
|
|
165
|
+
await incomingWebhook.updateField("data", data);
|
|
166
|
+
await incomingWebhook.addIncomingRelation(webhookType, "for");
|
|
167
|
+
|
|
168
|
+
let actionType = await database.getTypeObject("type/actionType", "incomingWebhook/" + type);
|
|
169
|
+
let actionStatus = await database.getTypeObject("status/actionStatus", "readyToProcess");
|
|
170
|
+
|
|
171
|
+
let action = await database.createObject("private", ["action"]);
|
|
172
|
+
await action.addIncomingRelation(actionType, "for");
|
|
173
|
+
await action.addIncomingRelation(incomingWebhook, "from");
|
|
174
|
+
await action.addIncomingRelation(actionStatus, "for");
|
|
175
|
+
|
|
176
|
+
returnObject["id"] = incomingWebhook.id;
|
|
177
|
+
returnObject["action"] = action.id;
|
|
178
|
+
|
|
179
|
+
this._responseData = returnObject;
|
|
180
|
+
}
|
|
135
181
|
|
|
136
182
|
outputEncodedData(aId, aData, aEncoding) {
|
|
137
183
|
//console.log("UrlRequest::outputEncodedData");
|
|
@@ -143,4 +189,50 @@ export default class UrlRequest extends Dbm.core.BaseObject {
|
|
|
143
189
|
getResponse() {
|
|
144
190
|
return {"objects": this._encodedObjects, "data": this._responseData, "logs": this._logs};
|
|
145
191
|
}
|
|
192
|
+
|
|
193
|
+
async _loadUser() {
|
|
194
|
+
|
|
195
|
+
if(this._request.headers.cookie) {
|
|
196
|
+
let cookies = this._request.headers.cookie.split(";");
|
|
197
|
+
let currentArray = cookies;
|
|
198
|
+
let currentArrayLength = currentArray.length;
|
|
199
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
200
|
+
let [key, value] = currentArray[i].split("=");
|
|
201
|
+
if(key === "dbm_session" || key === " dbm_session") {
|
|
202
|
+
let userId = 1*value.split(":")[1];
|
|
203
|
+
let user = Dbm.getInstance().repository.getItem("graphDatabase").controller.getUser(userId);
|
|
204
|
+
|
|
205
|
+
let isValidSession = await user.verifySession(value);
|
|
206
|
+
|
|
207
|
+
if(isValidSession) {
|
|
208
|
+
let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
|
|
209
|
+
|
|
210
|
+
let user = database.getUser(userId);
|
|
211
|
+
this.item.setValue("user", user);
|
|
212
|
+
}
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
this.item.setValue("hasLoadedUser", true);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
async getUser() {
|
|
222
|
+
if(!this.item.hasLoadedUser) {
|
|
223
|
+
await this._loadUser();
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return this.item.user;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
async requireRole(aRole) {
|
|
230
|
+
let user = await this.getUser();
|
|
231
|
+
|
|
232
|
+
if(!user) {
|
|
233
|
+
throw(new Error("Only signed in users can use this endpoint"));
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
146
238
|
}
|
|
@@ -6,6 +6,8 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
|
|
|
6
6
|
super._construct();
|
|
7
7
|
this._webSocket = null;
|
|
8
8
|
|
|
9
|
+
this.item.requireProperty("user", null);
|
|
10
|
+
|
|
9
11
|
this._callback_errorBound = this._callback_error.bind(this);
|
|
10
12
|
this._callback_messageBound = this._callback_message.bind(this);
|
|
11
13
|
this._callback_closeBound = this._callback_close.bind(this);
|
|
@@ -56,56 +58,61 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
|
|
|
56
58
|
let ids = [];
|
|
57
59
|
let logs = [];
|
|
58
60
|
|
|
59
|
-
{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
let currentSelectData = currentArray[i];
|
|
65
|
-
let currentSelectType = currentSelectData["type"];
|
|
66
|
-
let selection = Dbm.getInstance().repository.getItemIfExists("graphApi/range/select/" + currentSelectType);
|
|
67
|
-
if(selection) {
|
|
68
|
-
hasSelection = true;
|
|
69
|
-
await selection.controller.select(selectQuery, currentSelectData, request);
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
logs.push("No selection named " + currentSelectType);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if(hasSelection) {
|
|
77
|
-
ids = await selectQuery.getIds();
|
|
78
|
-
|
|
61
|
+
try {
|
|
62
|
+
{
|
|
63
|
+
let hasSelection = false;
|
|
64
|
+
let currentArray = data.select;
|
|
65
|
+
let currentArrayLength = currentArray.length;
|
|
79
66
|
for(let i = 0; i < currentArrayLength; i++) {
|
|
80
67
|
let currentSelectData = currentArray[i];
|
|
81
68
|
let currentSelectType = currentSelectData["type"];
|
|
82
69
|
let selection = Dbm.getInstance().repository.getItemIfExists("graphApi/range/select/" + currentSelectType);
|
|
83
70
|
if(selection) {
|
|
84
|
-
|
|
71
|
+
hasSelection = true;
|
|
72
|
+
await selection.controller.select(selectQuery, currentSelectData, request);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
logs.push("No selection named " + currentSelectType);
|
|
85
76
|
}
|
|
86
77
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
78
|
+
|
|
79
|
+
if(hasSelection) {
|
|
80
|
+
ids = await selectQuery.getIds();
|
|
81
|
+
|
|
82
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
83
|
+
let currentSelectData = currentArray[i];
|
|
84
|
+
let currentSelectType = currentSelectData["type"];
|
|
85
|
+
let selection = Dbm.getInstance().repository.getItemIfExists("graphApi/range/select/" + currentSelectType);
|
|
86
|
+
if(selection) {
|
|
87
|
+
ids = await selection.controller.filter(ids, currentSelectData, request);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
logs.push("No valid selections");
|
|
93
|
+
}
|
|
94
|
+
|
|
90
95
|
}
|
|
91
96
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
97
|
+
{
|
|
98
|
+
let encodeSession = new DbmGraphApi.range.EncodeSession();
|
|
99
|
+
encodeSession.outputController = this;
|
|
100
|
+
|
|
101
|
+
let currentArray = data.encode;
|
|
102
|
+
let currentArrayLength = currentArray.length;
|
|
103
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
104
|
+
let currentType = currentArray[i];
|
|
105
|
+
|
|
106
|
+
await encodeSession.encode(ids, currentType);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
encodeSession.destroy();
|
|
104
110
|
}
|
|
105
|
-
|
|
106
|
-
encodeSession.destroy();
|
|
107
111
|
}
|
|
108
|
-
|
|
112
|
+
catch(theError) {
|
|
113
|
+
logs.push(theError.message);
|
|
114
|
+
}
|
|
115
|
+
|
|
109
116
|
this._webSocket.send(JSON.stringify({"type": "range/response", "ids": ids, "requestId": data["requestId"], "logs": logs}));
|
|
110
117
|
break;
|
|
111
118
|
case "data":
|
|
@@ -181,29 +188,40 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
|
|
|
181
188
|
break;
|
|
182
189
|
case "admin/createObject":
|
|
183
190
|
{
|
|
184
|
-
|
|
185
|
-
let
|
|
186
|
-
let
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
+
//METODO: require role
|
|
192
|
+
let returnId = 0;
|
|
193
|
+
let user = await this.getUser();
|
|
194
|
+
if(user) {
|
|
195
|
+
let types = data['types'];
|
|
196
|
+
let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
|
|
197
|
+
let visibility = data['visibility'] ? data['visibility'] : 'draft';
|
|
198
|
+
|
|
199
|
+
let draftVisibility = await database.getVisibilityType(visibility);
|
|
200
|
+
|
|
201
|
+
let newObject = await database.createObject(draftVisibility, types);
|
|
202
|
+
|
|
203
|
+
if(data.changes) {
|
|
204
|
+
await this._applyChanges(newObject, data.changes, request);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if(data.encode) {
|
|
208
|
+
|
|
209
|
+
let encodeSession = new DbmGraphApi.range.EncodeSession();
|
|
210
|
+
encodeSession.outputController = this;
|
|
211
|
+
|
|
212
|
+
await encodeSession.encodeSingleWithTypes(newObject.id, data.encode);
|
|
213
|
+
|
|
214
|
+
encodeSession.destroy();
|
|
215
|
+
}
|
|
191
216
|
|
|
192
|
-
|
|
193
|
-
await this._applyChanges(newObject, data.changes, request);
|
|
217
|
+
returnId = newObject.id;
|
|
194
218
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
let encodeSession = new DbmGraphApi.range.EncodeSession();
|
|
199
|
-
encodeSession.outputController = this;
|
|
200
|
-
|
|
201
|
-
await encodeSession.encodeSingleWithTypes(newObject.id, data.encode);
|
|
202
|
-
|
|
203
|
-
encodeSession.destroy();
|
|
219
|
+
else {
|
|
220
|
+
//METODO: add logs
|
|
204
221
|
}
|
|
205
222
|
|
|
206
|
-
|
|
223
|
+
|
|
224
|
+
this._webSocket.send(JSON.stringify({"type": "item/response", "id": returnId, "requestId": data["requestId"]}));
|
|
207
225
|
}
|
|
208
226
|
break;
|
|
209
227
|
case "admin/editObject":
|
|
@@ -212,20 +230,27 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
|
|
|
212
230
|
|
|
213
231
|
let theObject = database.getObject(data.id);
|
|
214
232
|
|
|
215
|
-
|
|
216
|
-
|
|
233
|
+
let user = await this.getUser();
|
|
234
|
+
if(user) {
|
|
235
|
+
if(data.changes) {
|
|
236
|
+
await this._applyChanges(theObject, data.changes, request);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
if(data.encode) {
|
|
240
|
+
|
|
241
|
+
let encodeSession = new DbmGraphApi.range.EncodeSession();
|
|
242
|
+
encodeSession.outputController = this;
|
|
243
|
+
|
|
244
|
+
await encodeSession.encodeSingleWithTypes(theObject.id, data.encode);
|
|
245
|
+
|
|
246
|
+
encodeSession.destroy();
|
|
247
|
+
}
|
|
217
248
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
let encodeSession = new DbmGraphApi.range.EncodeSession();
|
|
222
|
-
encodeSession.outputController = this;
|
|
223
|
-
|
|
224
|
-
await encodeSession.encodeSingleWithTypes(theObject.id, data.encode);
|
|
225
|
-
|
|
226
|
-
encodeSession.destroy();
|
|
249
|
+
else {
|
|
250
|
+
//METODO: add log
|
|
227
251
|
}
|
|
228
252
|
|
|
253
|
+
|
|
229
254
|
this._webSocket.send(JSON.stringify({"type": "item/response", "id": theObject.id, "requestId": data["requestId"]}));
|
|
230
255
|
}
|
|
231
256
|
break;
|
|
@@ -240,7 +265,9 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
|
|
|
240
265
|
let userId = 0;
|
|
241
266
|
if(isVerified) {
|
|
242
267
|
//METODO: set user for connection
|
|
268
|
+
|
|
243
269
|
userId = user.id;
|
|
270
|
+
this.item.setValue("user", user);
|
|
244
271
|
}
|
|
245
272
|
|
|
246
273
|
this._webSocket.send(JSON.stringify({"type": "currentUser/response", "id": userId, "requestId": data["requestId"]}));
|
|
@@ -298,8 +325,30 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
|
|
|
298
325
|
|
|
299
326
|
setInitialUser(aId) {
|
|
300
327
|
|
|
301
|
-
|
|
328
|
+
if(aId) {
|
|
329
|
+
let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
|
|
330
|
+
|
|
331
|
+
let user = database.getUser(aId);
|
|
332
|
+
this.item.setValue("user", user);
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
this.item.setValue("user", null);
|
|
336
|
+
}
|
|
302
337
|
|
|
303
338
|
this._webSocket.send(JSON.stringify({"type": "connectionReady", "user": aId}));
|
|
304
339
|
}
|
|
340
|
+
|
|
341
|
+
async getUser() {
|
|
342
|
+
return this.item.user;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
async requireRole(aRole) {
|
|
346
|
+
let user = await this.getUser();
|
|
347
|
+
|
|
348
|
+
if(!user) {
|
|
349
|
+
throw(new Error("Only signed in users can use this endpoint"));
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
return true;
|
|
353
|
+
}
|
|
305
354
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
import EditBaseObject from "./EditBaseObject.js";
|
|
3
|
+
|
|
4
|
+
export default class ClearCloudflareCache extends EditBaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
async performChange(aObject, aData, aRequest) {
|
|
10
|
+
|
|
11
|
+
let cloudflare = Dbm.getInstance().repository.getItem("cloudflare");
|
|
12
|
+
let url = await aObject.getUrl();
|
|
13
|
+
|
|
14
|
+
if(cloudflare.domain && cloudflare.zone) {
|
|
15
|
+
let fullUrl = cloudflare.domain + url;
|
|
16
|
+
|
|
17
|
+
let requestUrl = "https://api.cloudflare.com/client/v4/zones/" + cloudflare.zone + "/purge_cache";
|
|
18
|
+
|
|
19
|
+
let body = {
|
|
20
|
+
"files": [fullUrl]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let headers = {
|
|
24
|
+
"Content-Type": "application/json",
|
|
25
|
+
'Authorization': 'Bearer ' + cloudflare.cacheToken
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let response = await fetch(requestUrl, {
|
|
29
|
+
method: "DELETE",
|
|
30
|
+
headers: headers,
|
|
31
|
+
body: JSON.stringify(body),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
let data = await response.json();
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
//METODO: report error log
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import Dbm from "dbm";
|
|
2
2
|
import EditBaseObject from "./EditBaseObject.js";
|
|
3
3
|
|
|
4
|
-
export default class
|
|
4
|
+
export default class SetVisibility extends EditBaseObject {
|
|
5
5
|
_construct() {
|
|
6
6
|
super._construct();
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
async performChange(aObject, aData, aRequest) {
|
|
10
|
-
|
|
11
|
-
console.log(url);
|
|
10
|
+
await aObject.setVisibility(aData["value"]);
|
|
12
11
|
}
|
|
13
12
|
}
|
|
@@ -4,8 +4,10 @@ export {default as EditBaseObject} from "./EditBaseObject.js";
|
|
|
4
4
|
export {default as SetField} from "./SetField.js";
|
|
5
5
|
export {default as SetIdentifier} from "./SetIdentifier.js";
|
|
6
6
|
export {default as SetUrl} from "./SetUrl.js";
|
|
7
|
+
export {default as SetVisibility} from "./SetVisibility.js";
|
|
7
8
|
export {default as AddIncomingRelation} from "./AddIncomingRelation.js";
|
|
8
9
|
export {default as AddOutgoingRelation} from "./AddOutgoingRelation.js";
|
|
10
|
+
export {default as ClearCloudflareCache} from "./ClearCloudflareCache.js";
|
|
9
11
|
|
|
10
12
|
export const fullSetup = function() {
|
|
11
13
|
let prefix = "graphApi/admin/edit/";
|
|
@@ -27,6 +29,12 @@ export const fullSetup = function() {
|
|
|
27
29
|
currentSelect.item.register(prefix + name);
|
|
28
30
|
}
|
|
29
31
|
|
|
32
|
+
{
|
|
33
|
+
let name = "setVisibility";
|
|
34
|
+
let currentSelect = new DbmGraphApi.admin.edit.SetVisibility();
|
|
35
|
+
currentSelect.item.register(prefix + name);
|
|
36
|
+
}
|
|
37
|
+
|
|
30
38
|
{
|
|
31
39
|
let name = "addIncomingRelation";
|
|
32
40
|
let currentSelect = new DbmGraphApi.admin.edit.AddIncomingRelation();
|
|
@@ -38,4 +46,10 @@ export const fullSetup = function() {
|
|
|
38
46
|
let currentSelect = new DbmGraphApi.admin.edit.AddOutgoingRelation();
|
|
39
47
|
currentSelect.item.register(prefix + name);
|
|
40
48
|
}
|
|
49
|
+
|
|
50
|
+
{
|
|
51
|
+
let name = "clearCache";
|
|
52
|
+
let currentSelect = new DbmGraphApi.admin.edit.ClearCloudflareCache();
|
|
53
|
+
currentSelect.item.register(prefix + name);
|
|
54
|
+
}
|
|
41
55
|
}
|
|
@@ -33,6 +33,12 @@ let fullSelectSetup = function() {
|
|
|
33
33
|
let currentSelect = new DbmGraphApi.range.select.IncludePrivate();
|
|
34
34
|
currentSelect.item.register(selectPrefix + name);
|
|
35
35
|
}
|
|
36
|
+
|
|
37
|
+
{
|
|
38
|
+
let name = "includeDraft";
|
|
39
|
+
let currentSelect = new DbmGraphApi.range.select.IncludeDraft();
|
|
40
|
+
currentSelect.item.register(selectPrefix + name);
|
|
41
|
+
}
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
export {fullSelectSetup};
|
|
@@ -115,6 +121,13 @@ let fullEncodeSetup = function() {
|
|
|
115
121
|
currentEncode.item.register(encodePrefix + name);
|
|
116
122
|
currentEncode.item.setValue("encodingType", name);
|
|
117
123
|
}
|
|
124
|
+
|
|
125
|
+
{
|
|
126
|
+
let name = "visibility";
|
|
127
|
+
let currentEncode = new DbmGraphApi.range.encode.Visibility();
|
|
128
|
+
currentEncode.item.register(encodePrefix + name);
|
|
129
|
+
currentEncode.item.setValue("encodingType", name);
|
|
130
|
+
}
|
|
118
131
|
}
|
|
119
132
|
|
|
120
133
|
export {fullEncodeSetup};
|
|
@@ -262,6 +275,7 @@ let setupEndpoints = function(aServer) {
|
|
|
262
275
|
console.log(url);
|
|
263
276
|
//METODO: check visibility in database
|
|
264
277
|
let request = new UrlRequest();
|
|
278
|
+
request.setup(aRequest, aReply);
|
|
265
279
|
|
|
266
280
|
await request.requestUrl(url);
|
|
267
281
|
|
|
@@ -284,6 +298,7 @@ let setupEndpoints = function(aServer) {
|
|
|
284
298
|
}
|
|
285
299
|
|
|
286
300
|
let request = new UrlRequest();
|
|
301
|
+
request.setup(aRequest, aReply);
|
|
287
302
|
|
|
288
303
|
await request.requestRange(selects, encodes, params);
|
|
289
304
|
|
|
@@ -296,6 +311,7 @@ let setupEndpoints = function(aServer) {
|
|
|
296
311
|
let encodes = aRequest.params.encodes.split(",");
|
|
297
312
|
|
|
298
313
|
let request = new UrlRequest();
|
|
314
|
+
request.setup(aRequest, aReply);
|
|
299
315
|
|
|
300
316
|
await request.requestItem(itemId, encodes);
|
|
301
317
|
|
|
@@ -305,6 +321,7 @@ let setupEndpoints = function(aServer) {
|
|
|
305
321
|
aServer.get('/api/data/*', async function handler (aRequest, aReply) {
|
|
306
322
|
let params = {...aRequest.query};
|
|
307
323
|
let request = new UrlRequest();
|
|
324
|
+
request.setup(aRequest, aReply);
|
|
308
325
|
|
|
309
326
|
let currentUrl = url.parse(aRequest.url);
|
|
310
327
|
let functionName = currentUrl.pathname.substring("/api/data/".length);
|
|
@@ -318,6 +335,7 @@ let setupEndpoints = function(aServer) {
|
|
|
318
335
|
|
|
319
336
|
let params = {...aRequest.query};
|
|
320
337
|
let request = new UrlRequest();
|
|
338
|
+
request.setup(aRequest, aReply);
|
|
321
339
|
|
|
322
340
|
let currentUrl = url.parse(aRequest.url);
|
|
323
341
|
let functionName = currentUrl.pathname.substring("/api/action/".length);
|
|
@@ -330,6 +348,7 @@ let setupEndpoints = function(aServer) {
|
|
|
330
348
|
aServer.post('/api/action/*', async function handler (aRequest, aReply) {
|
|
331
349
|
let params = {...aRequest.body};
|
|
332
350
|
let request = new UrlRequest();
|
|
351
|
+
request.setup(aRequest, aReply);
|
|
333
352
|
|
|
334
353
|
let currentUrl = url.parse(aRequest.url);
|
|
335
354
|
let functionName = currentUrl.pathname.substring("/api/action/".length);
|
|
@@ -341,6 +360,33 @@ let setupEndpoints = function(aServer) {
|
|
|
341
360
|
|
|
342
361
|
//METODO: setup raw data posts
|
|
343
362
|
|
|
363
|
+
aServer.get('/api/webhook/*', async function handler (aRequest, aReply) {
|
|
364
|
+
|
|
365
|
+
let params = {...aRequest.query};
|
|
366
|
+
let request = new UrlRequest();
|
|
367
|
+
request.setup(aRequest, aReply);
|
|
368
|
+
|
|
369
|
+
let currentUrl = url.parse(aRequest.url);
|
|
370
|
+
let webhookType = currentUrl.pathname.substring("/api/incomingWebhook/".length);
|
|
371
|
+
|
|
372
|
+
await request.incomingWebhook(webhookType, params);
|
|
373
|
+
|
|
374
|
+
return request.getResponse();
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
aServer.post('/api/webhook/*', async function handler (aRequest, aReply) {
|
|
378
|
+
let params = {...aRequest.body};
|
|
379
|
+
let request = new UrlRequest();
|
|
380
|
+
request.setup(aRequest, aReply);
|
|
381
|
+
|
|
382
|
+
let currentUrl = url.parse(aRequest.url);
|
|
383
|
+
let webhookType = currentUrl.pathname.substring("/api/incomingWebhook/".length);
|
|
384
|
+
|
|
385
|
+
await request.incomingWebhook(webhookType, params);
|
|
386
|
+
|
|
387
|
+
return request.getResponse();
|
|
388
|
+
});
|
|
389
|
+
|
|
344
390
|
//METODO: setup edit
|
|
345
391
|
|
|
346
392
|
aServer.get('/api/', async function handler (aRequest, aResponse) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
import EncodeBaseObject from "./EncodeBaseObject.js";
|
|
3
|
+
|
|
4
|
+
export default class Visibility 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
|
+
returnObject["visibility"] = await object.getVisibility();
|
|
16
|
+
|
|
17
|
+
return returnObject;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -10,4 +10,5 @@ export {default as Url} from "./Url.js";
|
|
|
10
10
|
export {default as Breadcrumb} from "./Breadcrumb.js";
|
|
11
11
|
export {default as NavigationName} from "./NavigationName.js";
|
|
12
12
|
export {default as Type} from "./Type.js";
|
|
13
|
-
export {default as Image} from "./Image.js";
|
|
13
|
+
export {default as Image} from "./Image.js";
|
|
14
|
+
export {default as Visibility} from "./Visibility.js";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
|
|
3
|
+
import SelectBaseObject from "./SelectBaseObject.js";
|
|
4
|
+
|
|
5
|
+
export default class IncludeDraft extends SelectBaseObject {
|
|
6
|
+
_construct() {
|
|
7
|
+
super._construct();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
async select(aQuery, aData, aRequest) {
|
|
11
|
+
await aRequest.connection.requireRole("admin");
|
|
12
|
+
|
|
13
|
+
aQuery.includeDraft();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async filter(aIds, aData, aRequest) {
|
|
17
|
+
return aIds;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export {default as SelectBaseObject} from "./SelectBaseObject.js";
|
|
2
2
|
export {default as IdSelection} from "./IdSelection.js";
|
|
3
3
|
export {default as ByObjectType} from "./ByObjectType.js";
|
|
4
|
-
export {default as IncludePrivate} from "./IncludePrivate.js";
|
|
4
|
+
export {default as IncludePrivate} from "./IncludePrivate.js";
|
|
5
|
+
export {default as IncludeDraft} from "./IncludeDraft.js";
|