dbm-graph-api 1.1.26 → 1.1.28

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.26",
3
+ "version": "1.1.28",
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.21",
16
+ "dbm": "^1.1.23",
17
17
  "mime": "^4.0.6",
18
18
  "sharp": "^0.33.5",
19
19
  "ws": "^8.18.0"
@@ -0,0 +1,36 @@
1
+ import Dbm from "dbm";
2
+
3
+ export default class SubmitForm extends Dbm.core.BaseObject {
4
+ _construct() {
5
+ super._construct();
6
+ }
7
+
8
+ async performAction(aData, aEncodeSession) {
9
+ let returnObject = {};
10
+
11
+ let database = Dbm.getInstance().repository.getItem("graphDatabase").controller;
12
+
13
+ let typeName = aData["type"];
14
+
15
+ let formSubmission = await database.createObject("private", ["formSubmission"]);
16
+
17
+ await formSubmission.updateField("data", aData["data"]);
18
+ await formSubmission.updateField("submissionTime", (new Date()).toISOString());
19
+
20
+ let form = await database.getIdentifiableObject("form", typeName);
21
+ await formSubmission.addIncomingRelation(form, "for");
22
+
23
+ let actionType = await database.getTypeObject("type/actionType", "handleFormSubmission");
24
+
25
+ let actionStatus = await database.getTypeObject("status/actionStatus", "readyToProcess");
26
+ let action = await database.createObject("private", ["action"]);
27
+
28
+ await action.addOutgoingRelation(formSubmission, "from");
29
+ await action.addIncomingRelation(actionType, "for");
30
+ await action.addIncomingRelation(actionStatus, "for");
31
+
32
+ returnObject["id"] = formSubmission.id;
33
+
34
+ return returnObject;
35
+ }
36
+ }
@@ -1,5 +1,6 @@
1
1
  export {default as Example} from "./Example.js";
2
2
  export {default as IncomingWebhook} from "./IncomingWebhook.js";
3
+ export {default as SubmitForm} from "./SubmitForm.js";
3
4
 
4
5
  export * as cron from "./cron/index.js";
5
6
  export * as admin from "./admin/index.js";
@@ -249,6 +249,7 @@ export let registerActionFunction = function(aName, aDataFunction) {
249
249
 
250
250
  let fullActionSetup = function() {
251
251
  registerActionFunction("example", new DbmGraphApi.action.Example());
252
+ registerActionFunction("submitForm", new DbmGraphApi.action.SubmitForm());
252
253
  registerActionFunction("incomingWebhook", new DbmGraphApi.action.IncomingWebhook());
253
254
  registerActionFunction("cron/processActions", new DbmGraphApi.action.cron.ProcessActions());
254
255
  registerActionFunction("admin/addAndProcessAction", new DbmGraphApi.action.admin.AddAndProcessAction());
@@ -273,6 +274,8 @@ export let registerProcessActionFunction = function(aName, aDataFunction) {
273
274
 
274
275
  let fullProcessActionSetup = function() {
275
276
  registerProcessActionFunction("example", new DbmGraphApi.processAction.Example());
277
+
278
+ registerProcessActionFunction("handleFormSubmission", new DbmGraphApi.processAction.HandleFormSubmission());
276
279
  }
277
280
 
278
281
  export {fullProcessActionSetup};
@@ -770,16 +773,30 @@ export const setupSite = function(aServer) {
770
773
  <meta property="og:title" content="${fields.title}" />`;
771
774
 
772
775
  {
773
- let currentArray = site.injectCodeSnippets;
774
- let currentArrayLength = currentArray.length;
775
- for(let i = 0; i < currentArrayLength; i++) {
776
- returnString += currentArray[i];
777
- }
778
- }
776
+ let currentArray = site.injectCodeSnippets;
777
+ let currentArrayLength = currentArray.length;
778
+ for(let i = 0; i < currentArrayLength; i++) {
779
+ returnString += currentArray[i];
780
+ }
781
+ }
782
+
783
+ if(process.env.INLINE_STYLE_SHEET == 1) {
784
+ returnString += `<style>`;
785
+
786
+ let assetsDir = Dbm.getInstance().repository.getItem("site").assetsDir;
787
+ let cssContent = await fs.promises.readFile(assetsDir + "/css/main.css", 'utf8');
788
+
789
+ returnString += cssContent;
790
+
791
+ returnString += `</style>`;
792
+ }
793
+ else {
794
+ returnString += `<link rel="stylesheet" type="text/css" href="${assetsUri}css/main.css?version=${version}" />`;
795
+ }
779
796
 
780
- returnString += `<link rel="stylesheet" type="text/css" href="${assetsUri}css/main.css?version=${version}" />
781
797
 
782
- <link rel="icon" type="image/png" href="${baseUrl}${assetsUri}img/favicon.png">`;
798
+
799
+ returnString += `<link rel="icon" type="image/png" href="${baseUrl}${assetsUri}img/favicon.png">`;
783
800
 
784
801
  if(fields['meta/description']) {
785
802
  returnString += `
@@ -822,9 +839,8 @@ export const setupSite = function(aServer) {
822
839
  }
823
840
 
824
841
  /*
825
- <meta property="article:publisher" content="https://sv-se.facebook.com/..." />
826
-
827
- */
842
+ <meta property="article:publisher" content="https://sv-se.facebook.com/..." />
843
+ */
828
844
 
829
845
  returnString += `</head>
830
846
  <body>
@@ -0,0 +1,27 @@
1
+ import Dbm from "dbm";
2
+
3
+ export default class HandleFormSubmission extends Dbm.core.BaseObject {
4
+ _construct() {
5
+ super._construct();
6
+ }
7
+
8
+ async process(aAction) {
9
+ console.log("HandleFormSubmission:process");
10
+ console.log(aAction);
11
+
12
+ let formSubmission = await aAction.singleObjectRelationQuery("out:from:formSubmission");
13
+ let form = await formSubmission.singleObjectRelationQuery("in:for:form");
14
+ let formName = await form.getIdentifier();
15
+ console.log(formSubmission);
16
+
17
+ let formHandler = Dbm.getInstance().repository.getItem("formHandlers/" + formName);
18
+ console.log(formHandler);
19
+
20
+ if(formHandler.handle) {
21
+ formHandler.handle(formSubmission);
22
+ }
23
+ else {
24
+ //METODO: add logs
25
+ }
26
+ }
27
+ }
@@ -1 +1,2 @@
1
- export {default as Example} from "./Example.js";
1
+ export {default as Example} from "./Example.js";
2
+ export {default as HandleFormSubmission} from "./HandleFormSubmission.js";