dbm-graph-api 1.1.41 → 1.1.43
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/action/admin/AddAndProcessAction.js +9 -0
- package/src/dbm-graph-api/data/actions/Status.js +20 -0
- package/src/dbm-graph-api/data/actions/index.js +1 -0
- package/src/dbm-graph-api/data/index.js +1 -0
- package/src/dbm-graph-api/index.js +17 -0
- package/src/dbm-graph-api/processAction/HandleFormSubmission.js +2 -5
- package/src/dbm-graph-api/processAction/actionGroup/Process.js +49 -0
- package/src/dbm-graph-api/processAction/actionGroup/index.js +1 -0
- package/src/dbm-graph-api/processAction/httpRequests/GetRequest.js +28 -0
- package/src/dbm-graph-api/processAction/httpRequests/index.js +1 -0
- package/src/dbm-graph-api/processAction/index.js +2 -0
- package/src/dbm-graph-api/processAction/pageUpdates/ClearCloudflareCache.js +1 -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.43",
|
|
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.
|
|
16
|
+
"dbm": "^1.4.2",
|
|
17
17
|
"mime": "^4.0.6",
|
|
18
18
|
"sharp": "^0.33.5",
|
|
19
19
|
"ws": "^8.18.0"
|
|
@@ -27,6 +27,15 @@ export default class AddAndProcessAction extends Dbm.core.BaseObject {
|
|
|
27
27
|
let fromItem = database.getObject(1*aData["from"]);
|
|
28
28
|
await action.addOutgoingRelation(fromItem, "from");
|
|
29
29
|
}
|
|
30
|
+
|
|
31
|
+
let data = aData["data"];
|
|
32
|
+
if(data) {
|
|
33
|
+
if(typeof(data) === "string") {
|
|
34
|
+
data = JSON.parse(data);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
await action.updateField("data", data);
|
|
38
|
+
}
|
|
30
39
|
|
|
31
40
|
let processingActionStatus = await database.getTypeObject("status/actionStatus", "processing");
|
|
32
41
|
await action.replaceIncomingRelation(processingActionStatus, "for", "status/actionStatus");
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
|
|
3
|
+
export default class Status extends Dbm.core.BaseObject {
|
|
4
|
+
_construct() {
|
|
5
|
+
super._construct();
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
async getData(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
|
+
returnObject["queueLength"] = actions.length;
|
|
17
|
+
|
|
18
|
+
return returnObject;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default as Status} from "./Status.js";
|
|
@@ -261,6 +261,8 @@ let fullDataSetup = function() {
|
|
|
261
261
|
registerDataFunction("admin/helpSectionSuggestions", new DbmGraphApi.data.HelpSectionSuggestions());
|
|
262
262
|
registerDataFunction("admin/altText", new DbmGraphApi.data.AltText());
|
|
263
263
|
|
|
264
|
+
registerDataFunction("actions/status", new DbmGraphApi.data.actions.Status());
|
|
265
|
+
|
|
264
266
|
registerDataFunction("server/status", new DbmGraphApi.data.server.Status());
|
|
265
267
|
}
|
|
266
268
|
|
|
@@ -307,6 +309,10 @@ let fullProcessActionSetup = function() {
|
|
|
307
309
|
|
|
308
310
|
registerProcessActionFunction("handleFormSubmission", new DbmGraphApi.processAction.HandleFormSubmission());
|
|
309
311
|
|
|
312
|
+
registerProcessActionFunction("httpRequest/get", new DbmGraphApi.processAction.httpRequests.GetRequest());
|
|
313
|
+
|
|
314
|
+
registerProcessActionFunction("actionGroup/process", new DbmGraphApi.processAction.actionGroup.Process());
|
|
315
|
+
|
|
310
316
|
registerProcessActionFunction("pageUpdates/updateCategoryListing", new DbmGraphApi.processAction.pageUpdates.UpdateCategoryListing());
|
|
311
317
|
registerProcessActionFunction("pageUpdates/updateRenderedContent", new DbmGraphApi.processAction.pageUpdates.UpdateRenderedContent());
|
|
312
318
|
registerProcessActionFunction("pageUpdates/clearCache", new DbmGraphApi.processAction.pageUpdates.ClearCloudflareCache());
|
|
@@ -701,12 +707,16 @@ export const setupSite = function(aServer) {
|
|
|
701
707
|
}
|
|
702
708
|
|
|
703
709
|
let url = request.url;
|
|
710
|
+
let shouldRedirect = false;
|
|
704
711
|
let index = url.indexOf("?");
|
|
712
|
+
let queryString = null;
|
|
705
713
|
if(index >= 0) {
|
|
714
|
+
queryString = url.substring(index, url.length);
|
|
706
715
|
url = url.substring(0, index);
|
|
707
716
|
}
|
|
708
717
|
if(url[url.length-1] !== "/") {
|
|
709
718
|
url += "/";
|
|
719
|
+
shouldRedirect = true;
|
|
710
720
|
}
|
|
711
721
|
|
|
712
722
|
let urlObject = await database.getObjectByUrl(url);
|
|
@@ -715,6 +725,13 @@ export const setupSite = function(aServer) {
|
|
|
715
725
|
moduleName = request.query.forceModule;
|
|
716
726
|
}
|
|
717
727
|
|
|
728
|
+
if(urlObject && shouldRedirect) {
|
|
729
|
+
let newUrl = url;
|
|
730
|
+
if(queryString) {
|
|
731
|
+
newUrl += queryString;
|
|
732
|
+
}
|
|
733
|
+
return reply.redirect(newUrl, 301);
|
|
734
|
+
}
|
|
718
735
|
if(!urlObject) {
|
|
719
736
|
reply.code(404);
|
|
720
737
|
reply.type('text/html');
|
|
@@ -6,16 +6,13 @@ export default class HandleFormSubmission extends Dbm.core.BaseObject {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
async process(aAction) {
|
|
9
|
-
console.log("HandleFormSubmission:process");
|
|
10
|
-
console.log(aAction);
|
|
9
|
+
//console.log("HandleFormSubmission:process");
|
|
11
10
|
|
|
12
11
|
let formSubmission = await aAction.singleObjectRelationQuery("out:from:formSubmission");
|
|
13
12
|
let form = await formSubmission.singleObjectRelationQuery("in:for:form");
|
|
14
13
|
let formName = await form.getIdentifier();
|
|
15
|
-
console.log(formSubmission);
|
|
16
14
|
|
|
17
|
-
let formHandler = Dbm.
|
|
18
|
-
console.log(formHandler);
|
|
15
|
+
let formHandler = Dbm.getRepositoryItem("formHandlers/" + formName);
|
|
19
16
|
|
|
20
17
|
if(formHandler.handle) {
|
|
21
18
|
formHandler.handle(formSubmission);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
|
|
3
|
+
export default class Process extends Dbm.core.BaseObject {
|
|
4
|
+
_construct() {
|
|
5
|
+
super._construct();
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
async process(aAction) {
|
|
9
|
+
console.log("Process:process2");
|
|
10
|
+
console.log(aAction);
|
|
11
|
+
|
|
12
|
+
let database = Dbm.getRepositoryItem("graphDatabase").controller;
|
|
13
|
+
|
|
14
|
+
let fields = await aAction.getFields();
|
|
15
|
+
let data = fields["data"];
|
|
16
|
+
console.log(fields);
|
|
17
|
+
|
|
18
|
+
let actionGroup = await aAction.singleObjectRelationQuery("out:from:actionGroup");
|
|
19
|
+
console.log(actionGroup);
|
|
20
|
+
let actionGroupFields = await actionGroup.getFields();
|
|
21
|
+
console.log(actionGroupFields);
|
|
22
|
+
|
|
23
|
+
let actionName = actionGroupFields["actionName"];
|
|
24
|
+
let dataTemplate = actionGroupFields["dataTemplate"];
|
|
25
|
+
let valueField = actionGroupFields["valueField"];
|
|
26
|
+
|
|
27
|
+
let parts = actionGroupFields["parts"];
|
|
28
|
+
let index = data["index"];
|
|
29
|
+
let partId = parts[index];
|
|
30
|
+
let part = database.getObject(partId);
|
|
31
|
+
let partFields = await part.getFields();
|
|
32
|
+
let currentArray = partFields["values"];
|
|
33
|
+
console.log(parts, currentArray);
|
|
34
|
+
let currentArrayLength = currentArray.length;
|
|
35
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
36
|
+
let currentValue = currentArray[i];
|
|
37
|
+
|
|
38
|
+
let currentData = {...dataTemplate};
|
|
39
|
+
currentData[valueField] = currentValue;
|
|
40
|
+
|
|
41
|
+
await database.addActionToProcess(actionName, null, currentData);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let nextIndex = index+1
|
|
45
|
+
if(nextIndex < parts.length) {
|
|
46
|
+
await database.addActionToProcess("actionGroup/process", actionGroup, {"index": nextIndex});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default as Process} from "./Process.js";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import Dbm from "dbm";
|
|
2
|
+
|
|
3
|
+
export default class GetRequest extends Dbm.core.BaseObject {
|
|
4
|
+
_construct() {
|
|
5
|
+
super._construct();
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
async process(aAction) {
|
|
9
|
+
console.log("GetRequest:process");
|
|
10
|
+
console.log(aAction);
|
|
11
|
+
|
|
12
|
+
let fields = await aAction.getFields();
|
|
13
|
+
let data = fields["data"];
|
|
14
|
+
console.log(fields);
|
|
15
|
+
|
|
16
|
+
let headers = {}; //METODO
|
|
17
|
+
|
|
18
|
+
let response = await fetch(data["url"], {
|
|
19
|
+
method: "GET",
|
|
20
|
+
headers: headers,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
console.log(response.status)
|
|
24
|
+
|
|
25
|
+
let responseData = await response.text();
|
|
26
|
+
console.log(responseData);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default as GetRequest} from "./GetRequest.js";
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * as pageUpdates from "./pageUpdates/index.js";
|
|
2
|
+
export * as httpRequests from "./httpRequests/index.js";
|
|
3
|
+
export * as actionGroup from "./actionGroup/index.js";
|
|
2
4
|
|
|
3
5
|
export {default as Example} from "./Example.js";
|
|
4
6
|
export {default as HandleFormSubmission} from "./HandleFormSubmission.js";
|
|
@@ -9,7 +9,7 @@ export default class ClearCloudflareCache extends Dbm.core.BaseObject {
|
|
|
9
9
|
console.log("ClearCloudflareCache:process");
|
|
10
10
|
//console.log(aAction);
|
|
11
11
|
|
|
12
|
-
let database = Dbm.
|
|
12
|
+
let database = Dbm.getRepositoryItem("graphDatabase").controller;
|
|
13
13
|
let page = await aAction.singleObjectRelationQuery("out:from:page");
|
|
14
14
|
|
|
15
15
|
let cloudflare = Dbm.getInstance().repository.getItem("cloudflare");
|