@budibase/server 0.9.138 → 0.9.140-alpha.2

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 (296) hide show
  1. package/builder/assets/discord.c14881e9.svg +10 -0
  2. package/builder/assets/{index.b18ab99b.js → index.1d1fa051.js} +35 -35
  3. package/builder/assets/{index.121692c9.css → index.79907e5c.css} +5 -5
  4. package/builder/assets/integromat.42212f11.png +0 -0
  5. package/builder/assets/slack.1e1f7cfb.svg +33 -0
  6. package/builder/assets/{vendor.7177f366.js → vendor.d39b3c1e.js} +2 -2
  7. package/builder/assets/zapier.3fbd8f5c.png +0 -0
  8. package/builder/index.html +3 -3
  9. package/coverage/clover.xml +2138 -2091
  10. package/coverage/coverage-final.json +120 -106
  11. package/coverage/lcov-report/api/controllers/analytics.js.html +3 -3
  12. package/coverage/lcov-report/api/controllers/apikeys.js.html +6 -6
  13. package/coverage/lcov-report/api/controllers/application.js.html +84 -84
  14. package/coverage/lcov-report/api/controllers/auth.js.html +6 -6
  15. package/coverage/lcov-report/api/controllers/automation.js.html +182 -356
  16. package/coverage/lcov-report/api/controllers/backup.js.html +3 -3
  17. package/coverage/lcov-report/api/controllers/component.js.html +5 -5
  18. package/coverage/lcov-report/api/controllers/datasource.js.html +12 -12
  19. package/coverage/lcov-report/api/controllers/dev.js.html +15 -15
  20. package/coverage/lcov-report/api/controllers/hosting.js.html +8 -8
  21. package/coverage/lcov-report/api/controllers/index.html +47 -32
  22. package/coverage/lcov-report/api/controllers/integration.js.html +4 -4
  23. package/coverage/lcov-report/api/controllers/layout.js.html +6 -6
  24. package/coverage/lcov-report/api/controllers/metadata.js.html +218 -0
  25. package/coverage/lcov-report/api/controllers/permission.js.html +14 -14
  26. package/coverage/lcov-report/api/controllers/query.js.html +17 -23
  27. package/coverage/lcov-report/api/controllers/role.js.html +9 -9
  28. package/coverage/lcov-report/api/controllers/routing.js.html +9 -9
  29. package/coverage/lcov-report/api/controllers/row/external.js.html +15 -15
  30. package/coverage/lcov-report/api/controllers/row/index.html +29 -44
  31. package/coverage/lcov-report/api/controllers/row/index.js.html +48 -45
  32. package/coverage/lcov-report/api/controllers/row/internal.js.html +159 -126
  33. package/coverage/lcov-report/api/controllers/row/utils.js.html +17 -17
  34. package/coverage/lcov-report/api/controllers/screen.js.html +7 -7
  35. package/coverage/lcov-report/api/controllers/script.js.html +5 -5
  36. package/coverage/lcov-report/api/controllers/table/index.html +1 -1
  37. package/coverage/lcov-report/api/controllers/table/index.js.html +40 -40
  38. package/coverage/lcov-report/api/controllers/table/utils.js.html +48 -48
  39. package/coverage/lcov-report/api/controllers/templates.js.html +5 -5
  40. package/coverage/lcov-report/api/controllers/user.js.html +14 -11
  41. package/coverage/lcov-report/api/controllers/view/exporters.js.html +3 -3
  42. package/coverage/lcov-report/api/controllers/view/index.html +1 -1
  43. package/coverage/lcov-report/api/controllers/view/index.js.html +9 -9
  44. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +6 -6
  45. package/coverage/lcov-report/api/controllers/webhook.js.html +14 -14
  46. package/coverage/lcov-report/api/index.html +1 -1
  47. package/coverage/lcov-report/api/index.js.html +23 -23
  48. package/coverage/lcov-report/api/routes/analytics.js.html +6 -6
  49. package/coverage/lcov-report/api/routes/apikeys.js.html +8 -8
  50. package/coverage/lcov-report/api/routes/application.js.html +8 -8
  51. package/coverage/lcov-report/api/routes/auth.js.html +6 -6
  52. package/coverage/lcov-report/api/routes/automation.js.html +41 -26
  53. package/coverage/lcov-report/api/routes/backup.js.html +8 -8
  54. package/coverage/lcov-report/api/routes/component.js.html +8 -8
  55. package/coverage/lcov-report/api/routes/datasource.js.html +13 -13
  56. package/coverage/lcov-report/api/routes/deploy.js.html +8 -8
  57. package/coverage/lcov-report/api/routes/dev.js.html +11 -11
  58. package/coverage/lcov-report/api/routes/hosting.js.html +8 -8
  59. package/coverage/lcov-report/api/routes/index.html +24 -9
  60. package/coverage/lcov-report/api/routes/index.js.html +36 -30
  61. package/coverage/lcov-report/api/routes/integration.js.html +8 -8
  62. package/coverage/lcov-report/api/routes/layout.js.html +8 -8
  63. package/coverage/lcov-report/api/routes/metadata.js.html +194 -0
  64. package/coverage/lcov-report/api/routes/permission.js.html +12 -12
  65. package/coverage/lcov-report/api/routes/query.js.html +13 -13
  66. package/coverage/lcov-report/api/routes/role.js.html +12 -12
  67. package/coverage/lcov-report/api/routes/routing.js.html +8 -8
  68. package/coverage/lcov-report/api/routes/row.js.html +10 -10
  69. package/coverage/lcov-report/api/routes/screen.js.html +11 -11
  70. package/coverage/lcov-report/api/routes/script.js.html +1 -1
  71. package/coverage/lcov-report/api/routes/static.js.html +13 -16
  72. package/coverage/lcov-report/api/routes/table.js.html +12 -12
  73. package/coverage/lcov-report/api/routes/templates.js.html +8 -8
  74. package/coverage/lcov-report/api/routes/user.js.html +9 -9
  75. package/coverage/lcov-report/api/routes/view.js.html +11 -11
  76. package/coverage/lcov-report/api/routes/webhook.js.html +11 -11
  77. package/coverage/lcov-report/automations/actions.js.html +57 -117
  78. package/coverage/lcov-report/automations/automationUtils.js.html +7 -7
  79. package/coverage/lcov-report/automations/bullboard.js.html +49 -16
  80. package/coverage/lcov-report/automations/index.html +67 -67
  81. package/coverage/lcov-report/automations/index.js.html +26 -128
  82. package/coverage/lcov-report/automations/steps/bash.js.html +37 -16
  83. package/coverage/lcov-report/automations/steps/createRow.js.html +15 -15
  84. package/coverage/lcov-report/automations/steps/delay.js.html +48 -9
  85. package/coverage/lcov-report/automations/steps/deleteRow.js.html +14 -14
  86. package/coverage/lcov-report/automations/steps/discord.js.html +329 -0
  87. package/coverage/lcov-report/automations/steps/executeQuery.js.html +22 -34
  88. package/coverage/lcov-report/automations/steps/executeScript.js.html +21 -33
  89. package/coverage/lcov-report/automations/steps/filter.js.html +28 -25
  90. package/coverage/lcov-report/automations/steps/index.html +140 -65
  91. package/coverage/lcov-report/automations/steps/integromat.js.html +341 -0
  92. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +44 -38
  93. package/coverage/lcov-report/automations/steps/queryRows.js.html +437 -0
  94. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +13 -13
  95. package/coverage/lcov-report/automations/steps/serverLog.js.html +23 -11
  96. package/coverage/lcov-report/automations/steps/{sendgridEmail.js.html → slack.js.html} +58 -88
  97. package/coverage/lcov-report/automations/steps/updateRow.js.html +12 -12
  98. package/coverage/lcov-report/automations/steps/utils.js.html +188 -0
  99. package/coverage/lcov-report/automations/steps/zapier.js.html +332 -0
  100. package/coverage/lcov-report/automations/thread.js.html +79 -76
  101. package/coverage/lcov-report/automations/triggerInfo/app.js.html +173 -0
  102. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +173 -0
  103. package/coverage/lcov-report/automations/triggerInfo/index.html +201 -0
  104. package/coverage/lcov-report/automations/triggerInfo/index.js.html +125 -0
  105. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +176 -0
  106. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +200 -0
  107. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +200 -0
  108. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +188 -0
  109. package/coverage/lcov-report/automations/triggers.js.html +67 -838
  110. package/coverage/lcov-report/automations/utils.js.html +557 -0
  111. package/coverage/lcov-report/constants/index.html +5 -5
  112. package/coverage/lcov-report/constants/index.js.html +32 -17
  113. package/coverage/lcov-report/constants/layouts.js.html +5 -5
  114. package/coverage/lcov-report/constants/screens.js.html +4 -4
  115. package/coverage/lcov-report/db/client.js.html +18 -18
  116. package/coverage/lcov-report/db/index.html +19 -19
  117. package/coverage/lcov-report/db/index.js.html +3 -3
  118. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +79 -79
  119. package/coverage/lcov-report/db/linkedRows/index.html +18 -18
  120. package/coverage/lcov-report/db/linkedRows/index.js.html +107 -149
  121. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +43 -43
  122. package/coverage/lcov-report/db/newid.js.html +4 -4
  123. package/coverage/lcov-report/db/utils.js.html +127 -76
  124. package/coverage/lcov-report/events/AutomationEmitter.js.html +7 -7
  125. package/coverage/lcov-report/events/index.html +1 -1
  126. package/coverage/lcov-report/events/index.js.html +6 -6
  127. package/coverage/lcov-report/events/utils.js.html +3 -3
  128. package/coverage/lcov-report/index.html +116 -101
  129. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
  130. package/coverage/lcov-report/integrations/tests/index.html +1 -1
  131. package/coverage/lcov-report/{automations/logic.js.html → middleware/appInfo.js.html} +35 -38
  132. package/coverage/lcov-report/middleware/authorized.js.html +16 -16
  133. package/coverage/lcov-report/middleware/builder.js.html +15 -15
  134. package/coverage/lcov-report/middleware/currentapp.js.html +33 -33
  135. package/coverage/lcov-report/middleware/index.html +23 -8
  136. package/coverage/lcov-report/middleware/joi-validator.js.html +6 -6
  137. package/coverage/lcov-report/middleware/resourceId.js.html +28 -28
  138. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  139. package/coverage/lcov-report/middleware/usageQuota.js.html +8 -8
  140. package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
  141. package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
  142. package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
  143. package/coverage/lcov-report/utilities/csvParser.js.html +6 -6
  144. package/coverage/lcov-report/utilities/global.js.html +33 -33
  145. package/coverage/lcov-report/utilities/index.html +28 -28
  146. package/coverage/lcov-report/utilities/index.js.html +178 -25
  147. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +18 -18
  148. package/coverage/lcov-report/utilities/queue/index.html +1 -1
  149. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  150. package/coverage/lcov-report/utilities/routing/index.js.html +6 -6
  151. package/coverage/lcov-report/utilities/rowProcessor/index.html +14 -14
  152. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +87 -51
  153. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +10 -10
  154. package/coverage/lcov-report/utilities/security.js.html +9 -9
  155. package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
  156. package/coverage/lcov-report/utilities/users.js.html +5 -5
  157. package/coverage/lcov-report/utilities/workerRequests.js.html +52 -52
  158. package/coverage/lcov.info +3255 -3218
  159. package/dist/api/controllers/automation.js +60 -127
  160. package/dist/api/controllers/deploy/index.js +17 -1
  161. package/dist/api/controllers/metadata.js +49 -0
  162. package/dist/api/controllers/query.js +0 -2
  163. package/dist/api/controllers/row/ExternalRequest.js +1 -1
  164. package/dist/api/controllers/row/index.js +1 -0
  165. package/dist/api/controllers/row/internal.js +33 -23
  166. package/dist/api/controllers/static/index.js +1 -28
  167. package/dist/api/controllers/static/templates/BudibaseApp.svelte +4 -1
  168. package/dist/api/controllers/user.js +1 -1
  169. package/dist/api/routes/automation.js +4 -5
  170. package/dist/api/routes/index.js +2 -0
  171. package/dist/api/routes/metadata.js +13 -0
  172. package/dist/api/routes/static.js +0 -1
  173. package/dist/api/routes/tests/utilities/TestFunctions.js +13 -0
  174. package/dist/app.js +1 -1
  175. package/dist/automations/actions.js +29 -46
  176. package/dist/automations/bullboard.js +11 -2
  177. package/dist/automations/index.js +11 -48
  178. package/dist/automations/steps/bash.js +12 -6
  179. package/dist/automations/steps/createRow.js +5 -5
  180. package/dist/automations/steps/delay.js +16 -3
  181. package/dist/automations/steps/deleteRow.js +5 -5
  182. package/dist/automations/steps/discord.js +91 -0
  183. package/dist/automations/steps/executeQuery.js +12 -15
  184. package/dist/automations/steps/executeScript.js +12 -15
  185. package/dist/automations/steps/filter.js +19 -18
  186. package/dist/automations/steps/integromat.js +94 -0
  187. package/dist/automations/steps/outgoingWebhook.js +19 -20
  188. package/dist/automations/steps/queryRows.js +129 -0
  189. package/dist/automations/steps/sendSmtpEmail.js +4 -4
  190. package/dist/automations/steps/serverLog.js +7 -3
  191. package/dist/automations/steps/slack.js +73 -0
  192. package/dist/automations/steps/updateRow.js +4 -4
  193. package/dist/automations/steps/utils.js +46 -0
  194. package/dist/automations/steps/zapier.js +91 -0
  195. package/dist/automations/tests/utilities/index.js +2 -12
  196. package/dist/automations/thread.js +23 -25
  197. package/dist/automations/triggerInfo/app.js +32 -0
  198. package/dist/automations/triggerInfo/cron.js +32 -0
  199. package/dist/automations/triggerInfo/index.js +15 -0
  200. package/dist/automations/triggerInfo/rowDeleted.js +33 -0
  201. package/dist/automations/triggerInfo/rowSaved.js +41 -0
  202. package/dist/automations/triggerInfo/rowUpdated.js +41 -0
  203. package/dist/automations/triggerInfo/webhook.js +37 -0
  204. package/dist/automations/triggers.js +27 -285
  205. package/dist/automations/utils.js +143 -0
  206. package/dist/constants/index.js +4 -0
  207. package/dist/db/linkedRows/index.js +20 -34
  208. package/dist/db/utils.js +14 -1
  209. package/dist/environment.js +2 -1
  210. package/dist/integrations/mysql.js +14 -2
  211. package/dist/middleware/appInfo.js +17 -0
  212. package/dist/middleware/usageQuota.js +1 -1
  213. package/dist/package.json +12 -11
  214. package/dist/tsconfig.tsbuildinfo +1 -1
  215. package/dist/utilities/appDirectoryTemplate/package.json +1 -1
  216. package/dist/utilities/fileSystem/clientLibrary.js +2 -2
  217. package/dist/utilities/fileSystem/index.js +2 -27
  218. package/dist/utilities/index.js +54 -0
  219. package/dist/utilities/redis.js +16 -1
  220. package/dist/utilities/rowProcessor/index.js +7 -4
  221. package/package.json +13 -12
  222. package/scripts/jestSetup.js +1 -0
  223. package/scripts/selfhost.js +8 -0
  224. package/src/api/controllers/automation.js +87 -145
  225. package/src/api/controllers/deploy/index.js +23 -1
  226. package/src/api/controllers/metadata.js +46 -0
  227. package/src/api/controllers/query.js +0 -2
  228. package/src/api/controllers/row/ExternalRequest.ts +1 -1
  229. package/src/api/controllers/row/index.js +1 -0
  230. package/src/api/controllers/row/internal.js +34 -23
  231. package/src/api/controllers/static/index.js +1 -39
  232. package/src/api/controllers/static/templates/BudibaseApp.svelte +4 -1
  233. package/src/api/controllers/user.js +1 -0
  234. package/src/api/routes/automation.js +16 -11
  235. package/src/api/routes/index.js +2 -0
  236. package/src/api/routes/metadata.js +38 -0
  237. package/src/api/routes/static.js +0 -1
  238. package/src/api/routes/tests/automation.spec.js +4 -26
  239. package/src/api/routes/tests/metadata.spec.js +65 -0
  240. package/src/api/routes/tests/utilities/TestFunctions.js +14 -0
  241. package/src/app.ts +1 -1
  242. package/src/automations/actions.js +29 -49
  243. package/src/automations/bullboard.js +13 -2
  244. package/src/automations/index.js +11 -45
  245. package/src/automations/steps/bash.js +13 -6
  246. package/src/automations/steps/createRow.js +5 -5
  247. package/src/automations/steps/delay.js +16 -3
  248. package/src/automations/steps/deleteRow.js +5 -5
  249. package/src/automations/steps/discord.js +83 -0
  250. package/src/automations/steps/executeQuery.js +12 -16
  251. package/src/automations/steps/executeScript.js +12 -16
  252. package/src/automations/steps/filter.js +19 -18
  253. package/src/automations/steps/integromat.js +87 -0
  254. package/src/automations/steps/outgoingWebhook.js +20 -18
  255. package/src/automations/steps/queryRows.js +119 -0
  256. package/src/automations/steps/sendSmtpEmail.js +4 -4
  257. package/src/automations/steps/serverLog.js +7 -3
  258. package/src/automations/steps/slack.js +64 -0
  259. package/src/automations/steps/updateRow.js +4 -4
  260. package/src/automations/steps/utils.js +36 -0
  261. package/src/automations/steps/zapier.js +84 -0
  262. package/src/automations/tests/automation.spec.js +4 -67
  263. package/src/automations/tests/delay.spec.js +2 -2
  264. package/src/automations/tests/filter.spec.js +14 -14
  265. package/src/automations/tests/queryRows.spec.js +51 -0
  266. package/src/automations/tests/utilities/index.js +2 -13
  267. package/src/automations/thread.js +27 -26
  268. package/src/automations/triggerInfo/app.js +31 -0
  269. package/src/automations/triggerInfo/cron.js +31 -0
  270. package/src/automations/triggerInfo/index.js +15 -0
  271. package/src/automations/triggerInfo/rowDeleted.js +32 -0
  272. package/src/automations/triggerInfo/rowSaved.js +40 -0
  273. package/src/automations/triggerInfo/rowUpdated.js +40 -0
  274. package/src/automations/triggerInfo/webhook.js +36 -0
  275. package/src/automations/triggers.js +33 -290
  276. package/src/automations/utils.js +159 -0
  277. package/src/constants/index.js +5 -0
  278. package/src/db/linkedRows/index.js +21 -35
  279. package/src/db/tests/linkTests.spec.js +0 -12
  280. package/src/db/utils.js +17 -0
  281. package/src/environment.js +2 -1
  282. package/src/integrations/mysql.ts +15 -2
  283. package/src/middleware/appInfo.js +19 -0
  284. package/src/middleware/usageQuota.js +1 -1
  285. package/src/utilities/appDirectoryTemplate/package.json +1 -1
  286. package/src/utilities/fileSystem/clientLibrary.js +2 -2
  287. package/src/utilities/fileSystem/index.js +2 -36
  288. package/src/utilities/index.js +51 -0
  289. package/src/utilities/redis.js +18 -1
  290. package/src/utilities/rowProcessor/index.js +16 -4
  291. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +0 -1244
  292. package/dist/automations/logic.js +0 -17
  293. package/dist/automations/steps/sendgridEmail.js +0 -85
  294. package/src/automations/logic.js +0 -20
  295. package/src/automations/steps/sendgridEmail.js +0 -74
  296. package/src/automations/tests/sendEmail.spec.js +0 -36
@@ -8,29 +8,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- const LogicConditions = {
11
+ const FilterConditions = {
12
12
  EQUAL: "EQUAL",
13
13
  NOT_EQUAL: "NOT_EQUAL",
14
14
  GREATER_THAN: "GREATER_THAN",
15
15
  LESS_THAN: "LESS_THAN",
16
16
  };
17
- const PrettyLogicConditions = {
18
- [LogicConditions.EQUAL]: "Equals",
19
- [LogicConditions.NOT_EQUAL]: "Not equals",
20
- [LogicConditions.GREATER_THAN]: "Greater than",
21
- [LogicConditions.LESS_THAN]: "Less than",
17
+ const PrettyFilterConditions = {
18
+ [FilterConditions.EQUAL]: "Equals",
19
+ [FilterConditions.NOT_EQUAL]: "Not equals",
20
+ [FilterConditions.GREATER_THAN]: "Greater than",
21
+ [FilterConditions.LESS_THAN]: "Less than",
22
22
  };
23
- module.exports.LogicConditions = LogicConditions;
24
- module.exports.PrettyLogicConditions = PrettyLogicConditions;
25
- module.exports.definition = {
23
+ exports.FilterConditions = FilterConditions;
24
+ exports.PrettyFilterConditions = PrettyFilterConditions;
25
+ exports.definition = {
26
26
  name: "Filter",
27
27
  tagline: "{{inputs.field}} {{inputs.condition}} {{inputs.value}}",
28
- icon: "ri-git-branch-line",
28
+ icon: "Branch2",
29
29
  description: "Filter any automations which do not meet certain conditions",
30
30
  type: "LOGIC",
31
+ internal: true,
31
32
  stepId: "FILTER",
32
33
  inputs: {
33
- condition: LogicConditions.EQUALS,
34
+ condition: FilterConditions.EQUALS,
34
35
  },
35
36
  schema: {
36
37
  inputs: {
@@ -42,8 +43,8 @@ module.exports.definition = {
42
43
  condition: {
43
44
  type: "string",
44
45
  title: "Condition",
45
- enum: Object.values(LogicConditions),
46
- pretty: Object.values(PrettyLogicConditions),
46
+ enum: Object.values(FilterConditions),
47
+ pretty: Object.values(PrettyFilterConditions),
47
48
  },
48
49
  value: {
49
50
  type: "string",
@@ -63,7 +64,7 @@ module.exports.definition = {
63
64
  },
64
65
  },
65
66
  };
66
- module.exports.run = function filter({ inputs }) {
67
+ exports.run = function filter({ inputs }) {
67
68
  return __awaiter(this, void 0, void 0, function* () {
68
69
  let { field, condition, value } = inputs;
69
70
  // coerce types so that we can use them
@@ -78,16 +79,16 @@ module.exports.run = function filter({ inputs }) {
78
79
  let success = false;
79
80
  if (typeof field !== "object" && typeof value !== "object") {
80
81
  switch (condition) {
81
- case LogicConditions.EQUAL:
82
+ case FilterConditions.EQUAL:
82
83
  success = field === value;
83
84
  break;
84
- case LogicConditions.NOT_EQUAL:
85
+ case FilterConditions.NOT_EQUAL:
85
86
  success = field !== value;
86
87
  break;
87
- case LogicConditions.GREATER_THAN:
88
+ case FilterConditions.GREATER_THAN:
88
89
  success = field > value;
89
90
  break;
90
- case LogicConditions.LESS_THAN:
91
+ case FilterConditions.LESS_THAN:
91
92
  success = field < value;
92
93
  break;
93
94
  }
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ const fetch = require("node-fetch");
12
+ const { getFetchResponse } = require("./utils");
13
+ exports.definition = {
14
+ name: "Integromat Integration",
15
+ tagline: "Trigger an Integromat scenario",
16
+ description: "Performs a webhook call to Integromat and gets the response (if configured)",
17
+ icon: "ri-shut-down-line",
18
+ stepId: "integromat",
19
+ type: "ACTION",
20
+ internal: false,
21
+ inputs: {},
22
+ schema: {
23
+ inputs: {
24
+ properties: {
25
+ url: {
26
+ type: "string",
27
+ title: "Webhook URL",
28
+ },
29
+ value1: {
30
+ type: "string",
31
+ title: "Input Value 1",
32
+ },
33
+ value2: {
34
+ type: "string",
35
+ title: "Input Value 2",
36
+ },
37
+ value3: {
38
+ type: "string",
39
+ title: "Input Value 3",
40
+ },
41
+ value4: {
42
+ type: "string",
43
+ title: "Input Value 4",
44
+ },
45
+ value5: {
46
+ type: "string",
47
+ title: "Input Value 5",
48
+ },
49
+ },
50
+ required: ["url", "value1", "value2", "value3", "value4", "value5"],
51
+ },
52
+ outputs: {
53
+ properties: {
54
+ success: {
55
+ type: "boolean",
56
+ description: "Whether call was successful",
57
+ },
58
+ httpStatus: {
59
+ type: "number",
60
+ description: "The HTTP status code returned",
61
+ },
62
+ response: {
63
+ type: "object",
64
+ description: "The webhook response - this can have properties",
65
+ },
66
+ },
67
+ required: ["success", "response"],
68
+ },
69
+ },
70
+ };
71
+ exports.run = function ({ inputs }) {
72
+ return __awaiter(this, void 0, void 0, function* () {
73
+ const { url, value1, value2, value3, value4, value5 } = inputs;
74
+ const response = yield fetch(url, {
75
+ method: "post",
76
+ body: JSON.stringify({
77
+ value1,
78
+ value2,
79
+ value3,
80
+ value4,
81
+ value5,
82
+ }),
83
+ headers: {
84
+ "Content-Type": "application/json",
85
+ },
86
+ });
87
+ const { status, message } = yield getFetchResponse(response);
88
+ return {
89
+ httpStatus: status,
90
+ success: status === 200,
91
+ response: message,
92
+ };
93
+ });
94
+ };
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  const fetch = require("node-fetch");
12
+ const { getFetchResponse } = require("./utils");
12
13
  const RequestType = {
13
14
  POST: "POST",
14
15
  GET: "GET",
@@ -22,12 +23,13 @@ const BODY_REQUESTS = [RequestType.POST, RequestType.PUT, RequestType.PATCH];
22
23
  * is complex and maybe better to be opinionated here.
23
24
  * GET/DELETE requests cannot handle body elements so they will not be sent if configured.
24
25
  */
25
- module.exports.definition = {
26
+ exports.definition = {
26
27
  name: "Outgoing webhook",
27
28
  tagline: "Send a {{inputs.requestMethod}} request",
28
- icon: "ri-send-plane-line",
29
+ icon: "Send",
29
30
  description: "Send a request of specified method to a URL",
30
31
  type: "ACTION",
32
+ internal: true,
31
33
  stepId: "OUTGOING_WEBHOOK",
32
34
  inputs: {
33
35
  requestMethod: "POST",
@@ -66,6 +68,10 @@ module.exports.definition = {
66
68
  type: "object",
67
69
  description: "The response from the webhook",
68
70
  },
71
+ httpStatus: {
72
+ type: "number",
73
+ description: "The HTTP status code returned",
74
+ },
69
75
  success: {
70
76
  type: "boolean",
71
77
  description: "Whether the action was successful",
@@ -75,7 +81,7 @@ module.exports.definition = {
75
81
  },
76
82
  },
77
83
  };
78
- module.exports.run = function ({ inputs }) {
84
+ exports.run = function ({ inputs }) {
79
85
  return __awaiter(this, void 0, void 0, function* () {
80
86
  let { requestMethod, url, requestBody, headers } = inputs;
81
87
  if (!url.startsWith("http")) {
@@ -94,13 +100,16 @@ module.exports.run = function ({ inputs }) {
94
100
  request.headers = {
95
101
  "Content-Type": "application/json",
96
102
  };
97
- if (headers && headers.length !== 0) {
103
+ if (headers) {
98
104
  try {
99
- const customHeaders = JSON.parse(headers);
105
+ const customHeaders = typeof headers === "string" ? JSON.parse(headers) : headers;
100
106
  request.headers = Object.assign(Object.assign({}, request.headers), customHeaders);
101
107
  }
102
108
  catch (err) {
103
- console.error(err);
109
+ return {
110
+ success: false,
111
+ response: "Unable to process headers, must be a JSON object.",
112
+ };
104
113
  }
105
114
  }
106
115
  }
@@ -110,21 +119,11 @@ module.exports.run = function ({ inputs }) {
110
119
  JSON.parse(request.body);
111
120
  }
112
121
  const response = yield fetch(url, request);
113
- const contentType = response.headers.get("content-type");
114
- const success = response.status === 200;
115
- let resp;
116
- if (!success) {
117
- resp = response.statusText;
118
- }
119
- else if (contentType && contentType.indexOf("application/json") !== -1) {
120
- resp = yield response.json();
121
- }
122
- else {
123
- resp = yield response.text();
124
- }
122
+ const { status, message } = yield getFetchResponse(response);
125
123
  return {
126
- response: resp,
127
- success: success,
124
+ httpStatus: status,
125
+ response: message,
126
+ success: status === 200,
128
127
  };
129
128
  }
130
129
  catch (err) {
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ const rowController = require("../../api/controllers/row");
12
+ const tableController = require("../../api/controllers/table");
13
+ const { FieldTypes } = require("../../constants");
14
+ const SortOrders = {
15
+ ASCENDING: "ascending",
16
+ DESCENDING: "descending",
17
+ };
18
+ const SortOrdersPretty = {
19
+ [SortOrders.ASCENDING]: "Ascending",
20
+ [SortOrders.DESCENDING]: "Descending",
21
+ };
22
+ exports.definition = {
23
+ description: "Query rows from the database",
24
+ icon: "Search",
25
+ name: "Query rows",
26
+ tagline: "Query rows from {{inputs.enriched.table.name}} table",
27
+ type: "ACTION",
28
+ stepId: "QUERY_ROWS",
29
+ internal: true,
30
+ inputs: {},
31
+ schema: {
32
+ inputs: {
33
+ properties: {
34
+ tableId: {
35
+ type: "string",
36
+ customType: "table",
37
+ title: "Table",
38
+ },
39
+ filters: {
40
+ type: "object",
41
+ customType: "filters",
42
+ title: "Filtering",
43
+ },
44
+ sortColumn: {
45
+ type: "string",
46
+ title: "Sort Column",
47
+ customType: "column",
48
+ },
49
+ sortOrder: {
50
+ type: "string",
51
+ title: "Sort Order",
52
+ enum: Object.values(SortOrders),
53
+ pretty: Object.values(SortOrdersPretty),
54
+ },
55
+ limit: {
56
+ type: "number",
57
+ title: "Limit",
58
+ },
59
+ },
60
+ required: ["tableId"],
61
+ },
62
+ outputs: {
63
+ properties: {
64
+ rows: {
65
+ type: "array",
66
+ customType: "rows",
67
+ description: "The rows that were found",
68
+ },
69
+ success: {
70
+ type: "boolean",
71
+ description: "Whether the deletion was successful",
72
+ },
73
+ },
74
+ required: ["rows", "success"],
75
+ },
76
+ },
77
+ };
78
+ function getTable(appId, tableId) {
79
+ return __awaiter(this, void 0, void 0, function* () {
80
+ const ctx = {
81
+ params: {
82
+ id: tableId,
83
+ },
84
+ appId,
85
+ };
86
+ yield tableController.find(ctx);
87
+ return ctx.body;
88
+ });
89
+ }
90
+ exports.run = function ({ inputs, appId }) {
91
+ return __awaiter(this, void 0, void 0, function* () {
92
+ const { tableId, filters, sortColumn, sortOrder, limit } = inputs;
93
+ const table = yield getTable(appId, tableId);
94
+ let sortType = FieldTypes.STRING;
95
+ if (table && table.schema && sortColumn) {
96
+ const fieldType = table.schema[sortColumn].type;
97
+ sortType =
98
+ fieldType === FieldTypes.NUMBER ? FieldTypes.NUMBER : FieldTypes.STRING;
99
+ }
100
+ const ctx = {
101
+ params: {
102
+ tableId,
103
+ },
104
+ request: {
105
+ body: {
106
+ sortOrder,
107
+ sortType,
108
+ sort: sortColumn,
109
+ query: filters || {},
110
+ limit,
111
+ },
112
+ },
113
+ appId,
114
+ };
115
+ try {
116
+ yield rowController.search(ctx);
117
+ return {
118
+ rows: ctx.body ? ctx.body.rows : [],
119
+ success: ctx.status === 200,
120
+ };
121
+ }
122
+ catch (err) {
123
+ return {
124
+ success: false,
125
+ response: err,
126
+ };
127
+ }
128
+ });
129
+ };
@@ -9,12 +9,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  const { sendSmtpEmail } = require("../../utilities/workerRequests");
12
- module.exports.definition = {
12
+ exports.definition = {
13
13
  description: "Send an email using SMTP",
14
14
  tagline: "Send SMTP email to {{inputs.to}}",
15
- icon: "ri-mail-open-line",
15
+ icon: "Email",
16
16
  name: "Send Email (SMTP)",
17
17
  type: "ACTION",
18
+ internal: true,
18
19
  stepId: "SEND_EMAIL_SMTP",
19
20
  inputs: {},
20
21
  schema: {
@@ -54,7 +55,7 @@ module.exports.definition = {
54
55
  },
55
56
  },
56
57
  };
57
- module.exports.run = function ({ inputs }) {
58
+ exports.run = function ({ inputs }) {
58
59
  return __awaiter(this, void 0, void 0, function* () {
59
60
  let { to, from, subject, contents } = inputs;
60
61
  if (!contents) {
@@ -68,7 +69,6 @@ module.exports.run = function ({ inputs }) {
68
69
  };
69
70
  }
70
71
  catch (err) {
71
- console.error(err);
72
72
  return {
73
73
  success: false,
74
74
  response: err,
@@ -13,12 +13,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
13
13
  step((generator = generator.apply(thisArg, _arguments || [])).next());
14
14
  });
15
15
  };
16
- module.exports.definition = {
16
+ exports.definition = {
17
17
  name: "Backend log",
18
18
  tagline: "Console log a value in the backend",
19
- icon: "ri-server-line",
19
+ icon: "Monitoring",
20
20
  description: "Logs the given text to the server (using console.log)",
21
21
  type: "ACTION",
22
+ internal: true,
22
23
  stepId: "SERVER_LOG",
23
24
  inputs: {
24
25
  text: "",
@@ -44,8 +45,11 @@ module.exports.definition = {
44
45
  },
45
46
  },
46
47
  };
47
- module.exports.run = function ({ inputs, appId }) {
48
+ exports.run = function ({ inputs, appId }) {
48
49
  return __awaiter(this, void 0, void 0, function* () {
49
50
  console.log(`App ${appId} - ${inputs.text}`);
51
+ return {
52
+ success: true,
53
+ };
50
54
  });
51
55
  };
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ const fetch = require("node-fetch");
12
+ const { getFetchResponse } = require("./utils");
13
+ exports.definition = {
14
+ name: "Slack Message",
15
+ tagline: "Send a message to Slack",
16
+ description: "Send a message to Slack",
17
+ icon: "ri-slack-line",
18
+ stepId: "slack",
19
+ type: "ACTION",
20
+ internal: false,
21
+ inputs: {},
22
+ schema: {
23
+ inputs: {
24
+ properties: {
25
+ url: {
26
+ type: "string",
27
+ title: "Incoming Webhook URL",
28
+ },
29
+ text: {
30
+ type: "string",
31
+ title: "Message",
32
+ },
33
+ },
34
+ required: ["url", "text"],
35
+ },
36
+ outputs: {
37
+ properties: {
38
+ httpStatus: {
39
+ type: "number",
40
+ description: "The HTTP status code of the request",
41
+ },
42
+ success: {
43
+ type: "boolean",
44
+ description: "Whether the message sent successfully",
45
+ },
46
+ response: {
47
+ type: "string",
48
+ description: "The response from the Slack Webhook",
49
+ },
50
+ },
51
+ },
52
+ },
53
+ };
54
+ exports.run = function ({ inputs }) {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ let { url, text } = inputs;
57
+ const response = yield fetch(url, {
58
+ method: "post",
59
+ body: JSON.stringify({
60
+ text,
61
+ }),
62
+ headers: {
63
+ "Content-Type": "application/json",
64
+ },
65
+ });
66
+ const { status, message } = yield getFetchResponse(response);
67
+ return {
68
+ httpStatus: status,
69
+ response: message,
70
+ success: status === 200,
71
+ };
72
+ });
73
+ };
@@ -10,12 +10,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  const rowController = require("../../api/controllers/row");
12
12
  const automationUtils = require("../automationUtils");
13
- module.exports.definition = {
13
+ exports.definition = {
14
14
  name: "Update Row",
15
15
  tagline: "Update a {{inputs.enriched.table.name}} row",
16
- icon: "ri-refresh-line",
16
+ icon: "Refresh",
17
17
  description: "Update a row in your database",
18
18
  type: "ACTION",
19
+ internal: true,
19
20
  stepId: "UPDATE_ROW",
20
21
  inputs: {},
21
22
  schema: {
@@ -61,7 +62,7 @@ module.exports.definition = {
61
62
  },
62
63
  },
63
64
  };
64
- module.exports.run = function ({ inputs, appId, emitter }) {
65
+ exports.run = function ({ inputs, appId, emitter }) {
65
66
  return __awaiter(this, void 0, void 0, function* () {
66
67
  if (inputs.rowId == null || inputs.row == null) {
67
68
  return {
@@ -100,7 +101,6 @@ module.exports.run = function ({ inputs, appId, emitter }) {
100
101
  };
101
102
  }
102
103
  catch (err) {
103
- console.error(err);
104
104
  return {
105
105
  success: false,
106
106
  response: err,
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ exports.getFetchResponse = (fetched) => __awaiter(void 0, void 0, void 0, function* () {
12
+ let status = fetched.status, message;
13
+ const contentType = fetched.headers.get("content-type");
14
+ try {
15
+ if (contentType && contentType.indexOf("application/json") !== -1) {
16
+ message = yield fetched.json();
17
+ }
18
+ else {
19
+ message = yield fetched.text();
20
+ }
21
+ }
22
+ catch (err) {
23
+ message = "Failed to retrieve response";
24
+ }
25
+ return { status, message };
26
+ });
27
+ // need to make sure all ctx structures have the
28
+ // throw added to them, so that controllers don't
29
+ // throw a ctx.throw undefined when error occurs
30
+ exports.buildCtx = (appId, emitter, { body, params } = {}) => {
31
+ const ctx = {
32
+ appId,
33
+ user: { appId },
34
+ eventEmitter: emitter,
35
+ throw: (code, error) => {
36
+ throw error;
37
+ },
38
+ };
39
+ if (body) {
40
+ ctx.request = { body };
41
+ }
42
+ if (params) {
43
+ ctx.params = params;
44
+ }
45
+ return ctx;
46
+ };