dbm-graph-api 1.1.42 → 1.1.44

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dbm-graph-api",
3
- "version": "1.1.42",
3
+ "version": "1.1.44",
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.4.1",
16
+ "dbm": "^1.4.3",
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");
@@ -22,12 +22,13 @@ export default class ProcessActions extends Dbm.core.BaseObject {
22
22
  let actionType = await action.getSingleLinkedType("type/actionType");
23
23
 
24
24
  let processActionItem = Dbm.getInstance().repository.getItemIfExists("graphApi/processAction/" + actionType);
25
-
25
+
26
26
  if(processActionItem) {
27
27
  await processActionItem.controller.process(action);
28
28
  await action.changeLinkedType("status/actionStatus", "done");
29
29
  }
30
30
  else {
31
+ console.warn("No action of type", actionType);
31
32
  await action.changeLinkedType("status/actionStatus", "noAction");
32
33
  }
33
34
 
@@ -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";
@@ -8,6 +8,7 @@ export {default as Breadcrumb} from "./Breadcrumb.js";
8
8
  export {default as Question} from "./Question.js";
9
9
 
10
10
  export * as server from "./server/index.js";
11
+ export * as actions from "./actions/index.js";
11
12
 
12
13
  import UploadS3 from "./UploadS3.js";
13
14
 
@@ -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());
@@ -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.getInstance().repository.getItem("formHandlers/" + formName);
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 SendEmail extends Dbm.core.BaseObject {
4
+ _construct() {
5
+ super._construct();
6
+ }
7
+
8
+ async process(aAction) {
9
+ //console.log("SendEmail:process");
10
+ //console.log(aAction);
11
+
12
+ let fields = await aAction.getFields();
13
+ let data = fields["data"];
14
+
15
+ let message = this.item.client.controller.createMessage();
16
+
17
+ message.setTo(data["to"]);
18
+ if(data["from"]) {
19
+ message.setFrom(data["from"]);
20
+ }
21
+
22
+ message.setSubject(data["subject"]);
23
+ message.setTextContent(data["textContent"]);
24
+ message.setHtmlContent(data["htmlContent"]);
25
+
26
+ await message.send();
27
+ }
28
+ }
@@ -0,0 +1,13 @@
1
+ export {default as SendEmail} from "./SendEmail.js";
2
+ import DbmGraphApi from "../../../../index.js";
3
+
4
+ export const setupEmail = function(aClient) {
5
+ //console.log("setupEmail");
6
+
7
+ let action = new DbmGraphApi.processAction.communication.SendEmail();
8
+ action.item.setValue("client", aClient);
9
+
10
+ DbmGraphApi.registerProcessActionFunction("sendEmail", action);
11
+
12
+ return action;
13
+ }
@@ -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,7 @@
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";
4
+ export * as communication from "./communication/index.js";
2
5
 
3
6
  export {default as Example} from "./Example.js";
4
7
  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.getInstance().repository.getItem("graphDatabase").controller;
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");