@budibase/server 0.9.125-alpha.4 → 0.9.125-alpha.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.
Files changed (266) hide show
  1. package/builder/assets/{index.dc48c234.js → index.a6e64238.js} +1 -1
  2. package/builder/index.html +1 -1
  3. package/coverage/clover.xml +1659 -1493
  4. package/coverage/coverage-final.json +101 -87
  5. package/coverage/lcov-report/api/controllers/analytics.js.html +3 -3
  6. package/coverage/lcov-report/api/controllers/apikeys.js.html +6 -6
  7. package/coverage/lcov-report/api/controllers/application.js.html +39 -39
  8. package/coverage/lcov-report/api/controllers/auth.js.html +6 -6
  9. package/coverage/lcov-report/api/controllers/automation.js.html +151 -361
  10. package/coverage/lcov-report/api/controllers/backup.js.html +3 -3
  11. package/coverage/lcov-report/api/controllers/component.js.html +5 -5
  12. package/coverage/lcov-report/api/controllers/datasource.js.html +1 -1
  13. package/coverage/lcov-report/api/controllers/dev.js.html +15 -15
  14. package/coverage/lcov-report/api/controllers/hosting.js.html +8 -8
  15. package/coverage/lcov-report/api/controllers/index.html +39 -24
  16. package/coverage/lcov-report/api/controllers/integration.js.html +4 -4
  17. package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
  18. package/coverage/lcov-report/api/controllers/metadata.js.html +218 -0
  19. package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
  20. package/coverage/lcov-report/api/controllers/query.js.html +6 -12
  21. package/coverage/lcov-report/api/controllers/role.js.html +1 -1
  22. package/coverage/lcov-report/api/controllers/routing.js.html +9 -9
  23. package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
  24. package/coverage/lcov-report/api/controllers/row/index.html +20 -20
  25. package/coverage/lcov-report/api/controllers/row/index.js.html +14 -14
  26. package/coverage/lcov-report/api/controllers/row/internal.js.html +95 -62
  27. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
  28. package/coverage/lcov-report/api/controllers/row/utils.js.html +10 -10
  29. package/coverage/lcov-report/api/controllers/screen.js.html +1 -1
  30. package/coverage/lcov-report/api/controllers/script.js.html +1 -1
  31. package/coverage/lcov-report/api/controllers/table/index.html +1 -1
  32. package/coverage/lcov-report/api/controllers/table/index.js.html +24 -24
  33. package/coverage/lcov-report/api/controllers/table/utils.js.html +32 -32
  34. package/coverage/lcov-report/api/controllers/templates.js.html +5 -5
  35. package/coverage/lcov-report/api/controllers/user.js.html +1 -1
  36. package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
  37. package/coverage/lcov-report/api/controllers/view/index.html +1 -1
  38. package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
  39. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
  40. package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
  41. package/coverage/lcov-report/api/index.html +1 -1
  42. package/coverage/lcov-report/api/index.js.html +23 -23
  43. package/coverage/lcov-report/api/routes/analytics.js.html +6 -6
  44. package/coverage/lcov-report/api/routes/apikeys.js.html +8 -8
  45. package/coverage/lcov-report/api/routes/application.js.html +8 -8
  46. package/coverage/lcov-report/api/routes/auth.js.html +6 -6
  47. package/coverage/lcov-report/api/routes/automation.js.html +41 -26
  48. package/coverage/lcov-report/api/routes/backup.js.html +8 -8
  49. package/coverage/lcov-report/api/routes/component.js.html +8 -8
  50. package/coverage/lcov-report/api/routes/datasource.js.html +13 -13
  51. package/coverage/lcov-report/api/routes/deploy.js.html +8 -8
  52. package/coverage/lcov-report/api/routes/dev.js.html +11 -11
  53. package/coverage/lcov-report/api/routes/hosting.js.html +8 -8
  54. package/coverage/lcov-report/api/routes/index.html +24 -9
  55. package/coverage/lcov-report/api/routes/index.js.html +36 -30
  56. package/coverage/lcov-report/api/routes/integration.js.html +8 -8
  57. package/coverage/lcov-report/api/routes/layout.js.html +8 -8
  58. package/coverage/lcov-report/api/routes/metadata.js.html +194 -0
  59. package/coverage/lcov-report/api/routes/permission.js.html +12 -12
  60. package/coverage/lcov-report/api/routes/query.js.html +13 -13
  61. package/coverage/lcov-report/api/routes/role.js.html +12 -12
  62. package/coverage/lcov-report/api/routes/routing.js.html +8 -8
  63. package/coverage/lcov-report/api/routes/row.js.html +10 -10
  64. package/coverage/lcov-report/api/routes/screen.js.html +11 -11
  65. package/coverage/lcov-report/api/routes/script.js.html +1 -1
  66. package/coverage/lcov-report/api/routes/static.js.html +13 -13
  67. package/coverage/lcov-report/api/routes/table.js.html +12 -12
  68. package/coverage/lcov-report/api/routes/templates.js.html +8 -8
  69. package/coverage/lcov-report/api/routes/user.js.html +9 -9
  70. package/coverage/lcov-report/api/routes/view.js.html +11 -11
  71. package/coverage/lcov-report/api/routes/webhook.js.html +11 -11
  72. package/coverage/lcov-report/automations/actions.js.html +38 -107
  73. package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
  74. package/coverage/lcov-report/automations/bullboard.js.html +46 -16
  75. package/coverage/lcov-report/automations/index.html +67 -67
  76. package/coverage/lcov-report/automations/index.js.html +26 -128
  77. package/coverage/lcov-report/automations/steps/bash.js.html +33 -12
  78. package/coverage/lcov-report/automations/steps/createRow.js.html +8 -8
  79. package/coverage/lcov-report/automations/steps/delay.js.html +45 -6
  80. package/coverage/lcov-report/automations/steps/deleteRow.js.html +8 -8
  81. package/coverage/lcov-report/automations/steps/discord.js.html +329 -0
  82. package/coverage/lcov-report/automations/steps/executeQuery.js.html +19 -31
  83. package/coverage/lcov-report/automations/steps/executeScript.js.html +18 -30
  84. package/coverage/lcov-report/automations/steps/filter.js.html +22 -19
  85. package/coverage/lcov-report/automations/steps/index.html +125 -65
  86. package/coverage/lcov-report/automations/steps/integromat.js.html +341 -0
  87. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +26 -32
  88. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +9 -9
  89. package/coverage/lcov-report/automations/steps/serverLog.js.html +20 -8
  90. package/coverage/lcov-report/automations/steps/{sendgridEmail.js.html → slack.js.html} +57 -87
  91. package/coverage/lcov-report/automations/steps/updateRow.js.html +7 -7
  92. package/coverage/lcov-report/automations/steps/utils.js.html +188 -0
  93. package/coverage/lcov-report/automations/steps/zapier.js.html +332 -0
  94. package/coverage/lcov-report/automations/thread.js.html +79 -76
  95. package/coverage/lcov-report/automations/triggerInfo/app.js.html +173 -0
  96. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +173 -0
  97. package/coverage/lcov-report/automations/triggerInfo/index.html +201 -0
  98. package/coverage/lcov-report/automations/triggerInfo/index.js.html +125 -0
  99. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +176 -0
  100. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +200 -0
  101. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +200 -0
  102. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +188 -0
  103. package/coverage/lcov-report/automations/triggers.js.html +54 -819
  104. package/coverage/lcov-report/automations/utils.js.html +557 -0
  105. package/coverage/lcov-report/constants/index.html +5 -5
  106. package/coverage/lcov-report/constants/index.js.html +19 -4
  107. package/coverage/lcov-report/constants/layouts.js.html +1 -1
  108. package/coverage/lcov-report/constants/screens.js.html +2 -2
  109. package/coverage/lcov-report/db/client.js.html +1 -1
  110. package/coverage/lcov-report/db/index.html +19 -19
  111. package/coverage/lcov-report/db/index.js.html +1 -1
  112. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +73 -73
  113. package/coverage/lcov-report/db/linkedRows/index.html +17 -17
  114. package/coverage/lcov-report/db/linkedRows/index.js.html +79 -115
  115. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +31 -31
  116. package/coverage/lcov-report/db/newid.js.html +2 -2
  117. package/coverage/lcov-report/db/utils.js.html +79 -28
  118. package/coverage/lcov-report/events/AutomationEmitter.js.html +7 -7
  119. package/coverage/lcov-report/events/index.html +1 -1
  120. package/coverage/lcov-report/events/index.js.html +2 -2
  121. package/coverage/lcov-report/events/utils.js.html +1 -1
  122. package/coverage/lcov-report/index.html +115 -100
  123. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
  124. package/coverage/lcov-report/integrations/tests/index.html +1 -1
  125. package/coverage/lcov-report/{automations/logic.js.html → middleware/appInfo.js.html} +35 -38
  126. package/coverage/lcov-report/middleware/authorized.js.html +16 -16
  127. package/coverage/lcov-report/middleware/builder.js.html +15 -15
  128. package/coverage/lcov-report/middleware/currentapp.js.html +33 -33
  129. package/coverage/lcov-report/middleware/index.html +23 -8
  130. package/coverage/lcov-report/middleware/joi-validator.js.html +6 -6
  131. package/coverage/lcov-report/middleware/resourceId.js.html +28 -28
  132. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  133. package/coverage/lcov-report/middleware/usageQuota.js.html +8 -8
  134. package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
  135. package/coverage/lcov-report/utilities/budibaseDir.js.html +7 -7
  136. package/coverage/lcov-report/utilities/centralPath.js.html +4 -4
  137. package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
  138. package/coverage/lcov-report/utilities/global.js.html +21 -21
  139. package/coverage/lcov-report/utilities/index.html +18 -18
  140. package/coverage/lcov-report/utilities/index.js.html +167 -14
  141. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +12 -12
  142. package/coverage/lcov-report/utilities/queue/index.html +1 -1
  143. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  144. package/coverage/lcov-report/utilities/routing/index.js.html +6 -6
  145. package/coverage/lcov-report/utilities/rowProcessor/index.html +14 -14
  146. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +87 -51
  147. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +8 -8
  148. package/coverage/lcov-report/utilities/security.js.html +2 -2
  149. package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
  150. package/coverage/lcov-report/utilities/users.js.html +1 -1
  151. package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
  152. package/coverage/lcov.info +2641 -2357
  153. package/dist/api/controllers/automation.js +49 -127
  154. package/dist/api/controllers/deploy/index.js +17 -1
  155. package/dist/api/controllers/metadata.js +49 -0
  156. package/dist/api/controllers/query.js +0 -2
  157. package/dist/api/controllers/row/internal.js +33 -23
  158. package/dist/api/routes/automation.js +4 -5
  159. package/dist/api/routes/index.js +2 -0
  160. package/dist/api/routes/metadata.js +13 -0
  161. package/dist/api/routes/tests/utilities/TestFunctions.js +13 -0
  162. package/dist/app.js +1 -1
  163. package/dist/automations/actions.js +26 -46
  164. package/dist/automations/bullboard.js +10 -2
  165. package/dist/automations/index.js +11 -48
  166. package/dist/automations/steps/bash.js +11 -5
  167. package/dist/automations/steps/createRow.js +4 -4
  168. package/dist/automations/steps/delay.js +15 -2
  169. package/dist/automations/steps/deleteRow.js +4 -4
  170. package/dist/automations/steps/discord.js +91 -0
  171. package/dist/automations/steps/executeQuery.js +11 -14
  172. package/dist/automations/steps/executeScript.js +11 -14
  173. package/dist/automations/steps/filter.js +18 -17
  174. package/dist/automations/steps/integromat.js +94 -0
  175. package/dist/automations/steps/outgoingWebhook.js +12 -16
  176. package/dist/automations/steps/sendSmtpEmail.js +3 -3
  177. package/dist/automations/steps/serverLog.js +6 -2
  178. package/dist/automations/steps/slack.js +73 -0
  179. package/dist/automations/steps/updateRow.js +3 -3
  180. package/dist/automations/steps/utils.js +46 -0
  181. package/dist/automations/steps/zapier.js +91 -0
  182. package/dist/automations/tests/utilities/index.js +2 -12
  183. package/dist/automations/thread.js +23 -25
  184. package/dist/automations/triggerInfo/app.js +32 -0
  185. package/dist/automations/triggerInfo/cron.js +32 -0
  186. package/dist/automations/triggerInfo/index.js +15 -0
  187. package/dist/automations/triggerInfo/rowDeleted.js +33 -0
  188. package/dist/automations/triggerInfo/rowSaved.js +41 -0
  189. package/dist/automations/triggerInfo/rowUpdated.js +41 -0
  190. package/dist/automations/triggerInfo/webhook.js +37 -0
  191. package/dist/automations/triggers.js +27 -284
  192. package/dist/automations/utils.js +143 -0
  193. package/dist/constants/index.js +4 -0
  194. package/dist/db/linkedRows/index.js +14 -26
  195. package/dist/db/utils.js +14 -1
  196. package/dist/environment.js +1 -0
  197. package/dist/middleware/appInfo.js +17 -0
  198. package/dist/middleware/usageQuota.js +1 -1
  199. package/dist/package.json +4 -5
  200. package/dist/tsconfig.tsbuildinfo +1 -1
  201. package/dist/utilities/fileSystem/index.js +0 -26
  202. package/dist/utilities/index.js +54 -0
  203. package/dist/utilities/redis.js +16 -1
  204. package/dist/utilities/rowProcessor/index.js +7 -4
  205. package/package.json +5 -6
  206. package/src/api/controllers/automation.js +75 -145
  207. package/src/api/controllers/deploy/index.js +23 -1
  208. package/src/api/controllers/metadata.js +46 -0
  209. package/src/api/controllers/query.js +0 -2
  210. package/src/api/controllers/row/internal.js +34 -23
  211. package/src/api/routes/automation.js +16 -11
  212. package/src/api/routes/index.js +2 -0
  213. package/src/api/routes/metadata.js +38 -0
  214. package/src/api/routes/tests/automation.spec.js +4 -26
  215. package/src/api/routes/tests/metadata.spec.js +65 -0
  216. package/src/api/routes/tests/utilities/TestFunctions.js +14 -0
  217. package/src/app.ts +1 -1
  218. package/src/automations/actions.js +26 -49
  219. package/src/automations/bullboard.js +12 -2
  220. package/src/automations/index.js +11 -45
  221. package/src/automations/steps/bash.js +12 -5
  222. package/src/automations/steps/createRow.js +4 -4
  223. package/src/automations/steps/delay.js +15 -2
  224. package/src/automations/steps/deleteRow.js +4 -4
  225. package/src/automations/steps/discord.js +83 -0
  226. package/src/automations/steps/executeQuery.js +11 -15
  227. package/src/automations/steps/executeScript.js +11 -15
  228. package/src/automations/steps/filter.js +18 -17
  229. package/src/automations/steps/integromat.js +87 -0
  230. package/src/automations/steps/outgoingWebhook.js +12 -14
  231. package/src/automations/steps/sendSmtpEmail.js +3 -3
  232. package/src/automations/steps/serverLog.js +6 -2
  233. package/src/automations/steps/slack.js +64 -0
  234. package/src/automations/steps/updateRow.js +3 -3
  235. package/src/automations/steps/utils.js +36 -0
  236. package/src/automations/steps/zapier.js +84 -0
  237. package/src/automations/tests/automation.spec.js +3 -66
  238. package/src/automations/tests/delay.spec.js +1 -1
  239. package/src/automations/tests/filter.spec.js +13 -13
  240. package/src/automations/tests/utilities/index.js +2 -13
  241. package/src/automations/thread.js +27 -26
  242. package/src/automations/triggerInfo/app.js +31 -0
  243. package/src/automations/triggerInfo/cron.js +31 -0
  244. package/src/automations/triggerInfo/index.js +15 -0
  245. package/src/automations/triggerInfo/rowDeleted.js +32 -0
  246. package/src/automations/triggerInfo/rowSaved.js +40 -0
  247. package/src/automations/triggerInfo/rowUpdated.js +40 -0
  248. package/src/automations/triggerInfo/webhook.js +36 -0
  249. package/src/automations/triggers.js +33 -288
  250. package/src/automations/utils.js +159 -0
  251. package/src/constants/index.js +5 -0
  252. package/src/db/linkedRows/index.js +15 -27
  253. package/src/db/tests/linkTests.spec.js +0 -12
  254. package/src/db/utils.js +17 -0
  255. package/src/environment.js +1 -0
  256. package/src/middleware/appInfo.js +19 -0
  257. package/src/middleware/usageQuota.js +1 -1
  258. package/src/utilities/fileSystem/index.js +0 -30
  259. package/src/utilities/index.js +51 -0
  260. package/src/utilities/redis.js +18 -1
  261. package/src/utilities/rowProcessor/index.js +16 -4
  262. package/dist/automations/logic.js +0 -17
  263. package/dist/automations/steps/sendgridEmail.js +0 -85
  264. package/src/automations/logic.js +0 -20
  265. package/src/automations/steps/sendgridEmail.js +0 -74
  266. package/src/automations/tests/sendEmail.spec.js +0 -36
@@ -1,29 +1,30 @@
1
- const LogicConditions = {
1
+ const FilterConditions = {
2
2
  EQUAL: "EQUAL",
3
3
  NOT_EQUAL: "NOT_EQUAL",
4
4
  GREATER_THAN: "GREATER_THAN",
5
5
  LESS_THAN: "LESS_THAN",
6
6
  }
7
7
 
8
- const PrettyLogicConditions = {
9
- [LogicConditions.EQUAL]: "Equals",
10
- [LogicConditions.NOT_EQUAL]: "Not equals",
11
- [LogicConditions.GREATER_THAN]: "Greater than",
12
- [LogicConditions.LESS_THAN]: "Less than",
8
+ const PrettyFilterConditions = {
9
+ [FilterConditions.EQUAL]: "Equals",
10
+ [FilterConditions.NOT_EQUAL]: "Not equals",
11
+ [FilterConditions.GREATER_THAN]: "Greater than",
12
+ [FilterConditions.LESS_THAN]: "Less than",
13
13
  }
14
14
 
15
- module.exports.LogicConditions = LogicConditions
16
- module.exports.PrettyLogicConditions = PrettyLogicConditions
15
+ exports.FilterConditions = FilterConditions
16
+ exports.PrettyFilterConditions = PrettyFilterConditions
17
17
 
18
- module.exports.definition = {
18
+ exports.definition = {
19
19
  name: "Filter",
20
20
  tagline: "{{inputs.field}} {{inputs.condition}} {{inputs.value}}",
21
21
  icon: "ri-git-branch-line",
22
22
  description: "Filter any automations which do not meet certain conditions",
23
23
  type: "LOGIC",
24
+ internal: true,
24
25
  stepId: "FILTER",
25
26
  inputs: {
26
- condition: LogicConditions.EQUALS,
27
+ condition: FilterConditions.EQUALS,
27
28
  },
28
29
  schema: {
29
30
  inputs: {
@@ -35,8 +36,8 @@ module.exports.definition = {
35
36
  condition: {
36
37
  type: "string",
37
38
  title: "Condition",
38
- enum: Object.values(LogicConditions),
39
- pretty: Object.values(PrettyLogicConditions),
39
+ enum: Object.values(FilterConditions),
40
+ pretty: Object.values(PrettyFilterConditions),
40
41
  },
41
42
  value: {
42
43
  type: "string",
@@ -57,7 +58,7 @@ module.exports.definition = {
57
58
  },
58
59
  }
59
60
 
60
- module.exports.run = async function filter({ inputs }) {
61
+ exports.run = async function filter({ inputs }) {
61
62
  let { field, condition, value } = inputs
62
63
  // coerce types so that we can use them
63
64
  if (!isNaN(value) && !isNaN(field)) {
@@ -70,16 +71,16 @@ module.exports.run = async function filter({ inputs }) {
70
71
  let success = false
71
72
  if (typeof field !== "object" && typeof value !== "object") {
72
73
  switch (condition) {
73
- case LogicConditions.EQUAL:
74
+ case FilterConditions.EQUAL:
74
75
  success = field === value
75
76
  break
76
- case LogicConditions.NOT_EQUAL:
77
+ case FilterConditions.NOT_EQUAL:
77
78
  success = field !== value
78
79
  break
79
- case LogicConditions.GREATER_THAN:
80
+ case FilterConditions.GREATER_THAN:
80
81
  success = field > value
81
82
  break
82
- case LogicConditions.LESS_THAN:
83
+ case FilterConditions.LESS_THAN:
83
84
  success = field < value
84
85
  break
85
86
  }
@@ -0,0 +1,87 @@
1
+ const fetch = require("node-fetch")
2
+ const { getFetchResponse } = require("./utils")
3
+
4
+ exports.definition = {
5
+ name: "Integromat Integration",
6
+ tagline: "Trigger an Integromat scenario",
7
+ description:
8
+ "Performs a webhook call to Integromat and gets the response (if configured)",
9
+ icon: "ri-shut-down-line",
10
+ stepId: "integromat",
11
+ type: "ACTION",
12
+ internal: false,
13
+ inputs: {},
14
+ schema: {
15
+ inputs: {
16
+ properties: {
17
+ url: {
18
+ type: "string",
19
+ title: "Webhook URL",
20
+ },
21
+ value1: {
22
+ type: "string",
23
+ title: "Input Value 1",
24
+ },
25
+ value2: {
26
+ type: "string",
27
+ title: "Input Value 2",
28
+ },
29
+ value3: {
30
+ type: "string",
31
+ title: "Input Value 3",
32
+ },
33
+ value4: {
34
+ type: "string",
35
+ title: "Input Value 4",
36
+ },
37
+ value5: {
38
+ type: "string",
39
+ title: "Input Value 5",
40
+ },
41
+ },
42
+ required: ["url", "value1", "value2", "value3", "value4", "value5"],
43
+ },
44
+ outputs: {
45
+ properties: {
46
+ success: {
47
+ type: "boolean",
48
+ description: "Whether call was successful",
49
+ },
50
+ httpStatus: {
51
+ type: "number",
52
+ description: "The HTTP status code returned",
53
+ },
54
+ response: {
55
+ type: "object",
56
+ description: "The webhook response - this can have properties",
57
+ },
58
+ },
59
+ required: ["success", "response"],
60
+ },
61
+ },
62
+ }
63
+
64
+ exports.run = async function ({ inputs }) {
65
+ const { url, value1, value2, value3, value4, value5 } = inputs
66
+
67
+ const response = await fetch(url, {
68
+ method: "post",
69
+ body: JSON.stringify({
70
+ value1,
71
+ value2,
72
+ value3,
73
+ value4,
74
+ value5,
75
+ }),
76
+ headers: {
77
+ "Content-Type": "application/json",
78
+ },
79
+ })
80
+
81
+ const { status, message } = await getFetchResponse(response)
82
+ return {
83
+ httpStatus: status,
84
+ success: status === 200,
85
+ response: message,
86
+ }
87
+ }
@@ -1,4 +1,5 @@
1
1
  const fetch = require("node-fetch")
2
+ const { getFetchResponse } = require("./utils")
2
3
 
3
4
  const RequestType = {
4
5
  POST: "POST",
@@ -16,12 +17,13 @@ const BODY_REQUESTS = [RequestType.POST, RequestType.PUT, RequestType.PATCH]
16
17
  * GET/DELETE requests cannot handle body elements so they will not be sent if configured.
17
18
  */
18
19
 
19
- module.exports.definition = {
20
+ exports.definition = {
20
21
  name: "Outgoing webhook",
21
22
  tagline: "Send a {{inputs.requestMethod}} request",
22
23
  icon: "ri-send-plane-line",
23
24
  description: "Send a request of specified method to a URL",
24
25
  type: "ACTION",
26
+ internal: true,
25
27
  stepId: "OUTGOING_WEBHOOK",
26
28
  inputs: {
27
29
  requestMethod: "POST",
@@ -60,6 +62,10 @@ module.exports.definition = {
60
62
  type: "object",
61
63
  description: "The response from the webhook",
62
64
  },
65
+ httpStatus: {
66
+ type: "number",
67
+ description: "The HTTP status code returned",
68
+ },
63
69
  success: {
64
70
  type: "boolean",
65
71
  description: "Whether the action was successful",
@@ -70,7 +76,7 @@ module.exports.definition = {
70
76
  },
71
77
  }
72
78
 
73
- module.exports.run = async function ({ inputs }) {
79
+ exports.run = async function ({ inputs }) {
74
80
  let { requestMethod, url, requestBody, headers } = inputs
75
81
  if (!url.startsWith("http")) {
76
82
  url = `http://${url}`
@@ -107,19 +113,11 @@ module.exports.run = async function ({ inputs }) {
107
113
  JSON.parse(request.body)
108
114
  }
109
115
  const response = await fetch(url, request)
110
- const contentType = response.headers.get("content-type")
111
- const success = response.status === 200
112
- let resp
113
- if (!success) {
114
- resp = response.statusText
115
- } else if (contentType && contentType.indexOf("application/json") !== -1) {
116
- resp = await response.json()
117
- } else {
118
- resp = await response.text()
119
- }
116
+ const { status, message } = await getFetchResponse(response)
120
117
  return {
121
- response: resp,
122
- success: success,
118
+ httpStatus: status,
119
+ response: message,
120
+ success: status === 200,
123
121
  }
124
122
  } catch (err) {
125
123
  /* istanbul ignore next */
@@ -1,11 +1,12 @@
1
1
  const { sendSmtpEmail } = require("../../utilities/workerRequests")
2
2
 
3
- module.exports.definition = {
3
+ exports.definition = {
4
4
  description: "Send an email using SMTP",
5
5
  tagline: "Send SMTP email to {{inputs.to}}",
6
6
  icon: "ri-mail-open-line",
7
7
  name: "Send Email (SMTP)",
8
8
  type: "ACTION",
9
+ internal: true,
9
10
  stepId: "SEND_EMAIL_SMTP",
10
11
  inputs: {},
11
12
  schema: {
@@ -46,7 +47,7 @@ module.exports.definition = {
46
47
  },
47
48
  }
48
49
 
49
- module.exports.run = async function ({ inputs }) {
50
+ exports.run = async function ({ inputs }) {
50
51
  let { to, from, subject, contents } = inputs
51
52
  if (!contents) {
52
53
  contents = "<h1>No content</h1>"
@@ -58,7 +59,6 @@ module.exports.run = async function ({ inputs }) {
58
59
  response,
59
60
  }
60
61
  } catch (err) {
61
- console.error(err)
62
62
  return {
63
63
  success: false,
64
64
  response: err,
@@ -4,12 +4,13 @@
4
4
  * GET/DELETE requests cannot handle body elements so they will not be sent if configured.
5
5
  */
6
6
 
7
- module.exports.definition = {
7
+ exports.definition = {
8
8
  name: "Backend log",
9
9
  tagline: "Console log a value in the backend",
10
10
  icon: "ri-server-line",
11
11
  description: "Logs the given text to the server (using console.log)",
12
12
  type: "ACTION",
13
+ internal: true,
13
14
  stepId: "SERVER_LOG",
14
15
  inputs: {
15
16
  text: "",
@@ -36,6 +37,9 @@ module.exports.definition = {
36
37
  },
37
38
  }
38
39
 
39
- module.exports.run = async function ({ inputs, appId }) {
40
+ exports.run = async function ({ inputs, appId }) {
40
41
  console.log(`App ${appId} - ${inputs.text}`)
42
+ return {
43
+ success: true,
44
+ }
41
45
  }
@@ -0,0 +1,64 @@
1
+ const fetch = require("node-fetch")
2
+ const { getFetchResponse } = require("./utils")
3
+
4
+ exports.definition = {
5
+ name: "Slack Message",
6
+ tagline: "Send a message to Slack",
7
+ description: "Send a message to Slack",
8
+ icon: "ri-slack-line",
9
+ stepId: "slack",
10
+ type: "ACTION",
11
+ internal: false,
12
+ inputs: {},
13
+ schema: {
14
+ inputs: {
15
+ properties: {
16
+ url: {
17
+ type: "string",
18
+ title: "Incoming Webhook URL",
19
+ },
20
+ text: {
21
+ type: "string",
22
+ title: "Message",
23
+ },
24
+ },
25
+ required: ["url", "text"],
26
+ },
27
+ outputs: {
28
+ properties: {
29
+ httpStatus: {
30
+ type: "number",
31
+ description: "The HTTP status code of the request",
32
+ },
33
+ success: {
34
+ type: "boolean",
35
+ description: "Whether the message sent successfully",
36
+ },
37
+ response: {
38
+ type: "string",
39
+ description: "The response from the Slack Webhook",
40
+ },
41
+ },
42
+ },
43
+ },
44
+ }
45
+
46
+ exports.run = async function ({ inputs }) {
47
+ let { url, text } = inputs
48
+ const response = await fetch(url, {
49
+ method: "post",
50
+ body: JSON.stringify({
51
+ text,
52
+ }),
53
+ headers: {
54
+ "Content-Type": "application/json",
55
+ },
56
+ })
57
+
58
+ const { status, message } = await getFetchResponse(response)
59
+ return {
60
+ httpStatus: status,
61
+ response: message,
62
+ success: status === 200,
63
+ }
64
+ }
@@ -1,12 +1,13 @@
1
1
  const rowController = require("../../api/controllers/row")
2
2
  const automationUtils = require("../automationUtils")
3
3
 
4
- module.exports.definition = {
4
+ exports.definition = {
5
5
  name: "Update Row",
6
6
  tagline: "Update a {{inputs.enriched.table.name}} row",
7
7
  icon: "ri-refresh-line",
8
8
  description: "Update a row in your database",
9
9
  type: "ACTION",
10
+ internal: true,
10
11
  stepId: "UPDATE_ROW",
11
12
  inputs: {},
12
13
  schema: {
@@ -53,7 +54,7 @@ module.exports.definition = {
53
54
  },
54
55
  }
55
56
 
56
- module.exports.run = async function ({ inputs, appId, emitter }) {
57
+ exports.run = async function ({ inputs, appId, emitter }) {
57
58
  if (inputs.rowId == null || inputs.row == null) {
58
59
  return {
59
60
  success: false,
@@ -100,7 +101,6 @@ module.exports.run = async function ({ inputs, appId, emitter }) {
100
101
  success: ctx.status === 200,
101
102
  }
102
103
  } catch (err) {
103
- console.error(err)
104
104
  return {
105
105
  success: false,
106
106
  response: err,
@@ -0,0 +1,36 @@
1
+ exports.getFetchResponse = async fetched => {
2
+ let status = fetched.status,
3
+ message
4
+ const contentType = fetched.headers.get("content-type")
5
+ try {
6
+ if (contentType && contentType.indexOf("application/json") !== -1) {
7
+ message = await fetched.json()
8
+ } else {
9
+ message = await fetched.text()
10
+ }
11
+ } catch (err) {
12
+ message = "Failed to retrieve response"
13
+ }
14
+ return { status, message }
15
+ }
16
+
17
+ // need to make sure all ctx structures have the
18
+ // throw added to them, so that controllers don't
19
+ // throw a ctx.throw undefined when error occurs
20
+ exports.buildCtx = (appId, emitter, { body, params } = {}) => {
21
+ const ctx = {
22
+ appId,
23
+ user: { appId },
24
+ eventEmitter: emitter,
25
+ throw: (code, error) => {
26
+ throw error
27
+ },
28
+ }
29
+ if (body) {
30
+ ctx.request = { body }
31
+ }
32
+ if (params) {
33
+ ctx.params = params
34
+ }
35
+ return ctx
36
+ }
@@ -0,0 +1,84 @@
1
+ const fetch = require("node-fetch")
2
+ const { getFetchResponse } = require("./utils")
3
+
4
+ exports.definition = {
5
+ name: "Zapier Webhook",
6
+ stepId: "zapier",
7
+ type: "ACTION",
8
+ internal: false,
9
+ description: "Trigger a Zapier Zap via webhooks",
10
+ tagline: "Trigger a Zapier Zap",
11
+ icon: "ri-flashlight-line",
12
+ schema: {
13
+ inputs: {
14
+ properties: {
15
+ url: {
16
+ type: "string",
17
+ title: "Webhook URL",
18
+ },
19
+ value1: {
20
+ type: "string",
21
+ title: "Payload Value 1",
22
+ },
23
+ value2: {
24
+ type: "string",
25
+ title: "Payload Value 2",
26
+ },
27
+ value3: {
28
+ type: "string",
29
+ title: "Payload Value 3",
30
+ },
31
+ value4: {
32
+ type: "string",
33
+ title: "Payload Value 4",
34
+ },
35
+ value5: {
36
+ type: "string",
37
+ title: "Payload Value 5",
38
+ },
39
+ },
40
+ required: ["url"],
41
+ },
42
+ outputs: {
43
+ properties: {
44
+ httpStatus: {
45
+ type: "number",
46
+ description: "The HTTP status code of the request",
47
+ },
48
+ response: {
49
+ type: "string",
50
+ description: "The response from Zapier",
51
+ },
52
+ },
53
+ },
54
+ },
55
+ }
56
+
57
+ exports.run = async function ({ inputs }) {
58
+ const { url, value1, value2, value3, value4, value5 } = inputs
59
+
60
+ // send the platform to make sure zaps always work, even
61
+ // if no values supplied
62
+ const response = await fetch(url, {
63
+ method: "post",
64
+ body: JSON.stringify({
65
+ platform: "budibase",
66
+ value1,
67
+ value2,
68
+ value3,
69
+ value4,
70
+ value5,
71
+ }),
72
+ headers: {
73
+ "Content-Type": "application/json",
74
+ },
75
+ })
76
+
77
+ const { status, message } = await getFetchResponse(response)
78
+
79
+ return {
80
+ success: status === 200,
81
+ httpStatus: status,
82
+ response: message,
83
+ }
84
+ }