dbm-graph-api 1.1.4 → 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 +1 -1
- package/src/dbm-graph-api/WebSocketConnection.js +54 -44
- package/src/dbm-graph-api/admin/edit/SetVisibility.js +12 -0
- package/src/dbm-graph-api/admin/edit/index.js +7 -0
- package/src/dbm-graph-api/index.js +13 -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 +0 -2
- 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": {
|
|
@@ -230,7 +230,7 @@ export default class UrlRequest extends Dbm.core.BaseObject {
|
|
|
230
230
|
let user = await this.getUser();
|
|
231
231
|
|
|
232
232
|
if(!user) {
|
|
233
|
-
throw("Only signed in users can use this endpoint");
|
|
233
|
+
throw(new Error("Only signed in users can use this endpoint"));
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
return true;
|
|
@@ -58,56 +58,61 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
|
|
|
58
58
|
let ids = [];
|
|
59
59
|
let logs = [];
|
|
60
60
|
|
|
61
|
-
{
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
let currentSelectData = currentArray[i];
|
|
67
|
-
let currentSelectType = currentSelectData["type"];
|
|
68
|
-
let selection = Dbm.getInstance().repository.getItemIfExists("graphApi/range/select/" + currentSelectType);
|
|
69
|
-
if(selection) {
|
|
70
|
-
hasSelection = true;
|
|
71
|
-
await selection.controller.select(selectQuery, currentSelectData, request);
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
logs.push("No selection named " + currentSelectType);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if(hasSelection) {
|
|
79
|
-
ids = await selectQuery.getIds();
|
|
80
|
-
|
|
61
|
+
try {
|
|
62
|
+
{
|
|
63
|
+
let hasSelection = false;
|
|
64
|
+
let currentArray = data.select;
|
|
65
|
+
let currentArrayLength = currentArray.length;
|
|
81
66
|
for(let i = 0; i < currentArrayLength; i++) {
|
|
82
67
|
let currentSelectData = currentArray[i];
|
|
83
68
|
let currentSelectType = currentSelectData["type"];
|
|
84
69
|
let selection = Dbm.getInstance().repository.getItemIfExists("graphApi/range/select/" + currentSelectType);
|
|
85
70
|
if(selection) {
|
|
86
|
-
|
|
71
|
+
hasSelection = true;
|
|
72
|
+
await selection.controller.select(selectQuery, currentSelectData, request);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
logs.push("No selection named " + currentSelectType);
|
|
87
76
|
}
|
|
88
77
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
+
|
|
92
95
|
}
|
|
93
96
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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();
|
|
106
110
|
}
|
|
107
|
-
|
|
108
|
-
encodeSession.destroy();
|
|
109
111
|
}
|
|
110
|
-
|
|
112
|
+
catch(theError) {
|
|
113
|
+
logs.push(theError.message);
|
|
114
|
+
}
|
|
115
|
+
|
|
111
116
|
this._webSocket.send(JSON.stringify({"type": "range/response", "ids": ids, "requestId": data["requestId"], "logs": logs}));
|
|
112
117
|
break;
|
|
113
118
|
case "data":
|
|
@@ -216,7 +221,7 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
|
|
|
216
221
|
}
|
|
217
222
|
|
|
218
223
|
|
|
219
|
-
this._webSocket.send(JSON.stringify({"type": "item/response", "id":
|
|
224
|
+
this._webSocket.send(JSON.stringify({"type": "item/response", "id": returnId, "requestId": data["requestId"]}));
|
|
220
225
|
}
|
|
221
226
|
break;
|
|
222
227
|
case "admin/editObject":
|
|
@@ -320,10 +325,15 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
|
|
|
320
325
|
|
|
321
326
|
setInitialUser(aId) {
|
|
322
327
|
|
|
323
|
-
|
|
328
|
+
if(aId) {
|
|
329
|
+
let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
|
|
324
330
|
|
|
325
|
-
|
|
326
|
-
|
|
331
|
+
let user = database.getUser(aId);
|
|
332
|
+
this.item.setValue("user", user);
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
this.item.setValue("user", null);
|
|
336
|
+
}
|
|
327
337
|
|
|
328
338
|
this._webSocket.send(JSON.stringify({"type": "connectionReady", "user": aId}));
|
|
329
339
|
}
|
|
@@ -336,7 +346,7 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
|
|
|
336
346
|
let user = await this.getUser();
|
|
337
347
|
|
|
338
348
|
if(!user) {
|
|
339
|
-
throw("Only signed in users can use this endpoint");
|
|
349
|
+
throw(new Error("Only signed in users can use this endpoint"));
|
|
340
350
|
}
|
|
341
351
|
|
|
342
352
|
return true;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
import EditBaseObject from "./EditBaseObject.js";
|
|
3
|
+
|
|
4
|
+
export default class SetVisibility extends EditBaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
async performChange(aObject, aData, aRequest) {
|
|
10
|
+
await aObject.setVisibility(aData["value"]);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -4,6 +4,7 @@ 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";
|
|
9
10
|
export {default as ClearCloudflareCache} from "./ClearCloudflareCache.js";
|
|
@@ -28,6 +29,12 @@ export const fullSetup = function() {
|
|
|
28
29
|
currentSelect.item.register(prefix + name);
|
|
29
30
|
}
|
|
30
31
|
|
|
32
|
+
{
|
|
33
|
+
let name = "setVisibility";
|
|
34
|
+
let currentSelect = new DbmGraphApi.admin.edit.SetVisibility();
|
|
35
|
+
currentSelect.item.register(prefix + name);
|
|
36
|
+
}
|
|
37
|
+
|
|
31
38
|
{
|
|
32
39
|
let name = "addIncomingRelation";
|
|
33
40
|
let currentSelect = new DbmGraphApi.admin.edit.AddIncomingRelation();
|
|
@@ -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};
|
|
@@ -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";
|