@budibase/server 2.5.9 → 2.5.10-alpha.0

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 (187) hide show
  1. package/builder/assets/index.24635afb.js +1794 -0
  2. package/builder/assets/index.4eae16b2.css +6 -0
  3. package/builder/index.html +2 -2
  4. package/dist/api/controllers/application.js +3 -4
  5. package/dist/api/controllers/automation.js +13 -7
  6. package/dist/api/controllers/datasource.js +1 -1
  7. package/dist/api/controllers/dev.js +1 -1
  8. package/dist/api/controllers/ops.js +40 -0
  9. package/dist/api/controllers/plugin/index.js +6 -37
  10. package/dist/api/controllers/query/index.js +2 -2
  11. package/dist/api/controllers/row/ExternalRequest.js +21 -14
  12. package/dist/api/controllers/table/utils.js +9 -3
  13. package/dist/api/controllers/user.js +1 -83
  14. package/dist/api/index.js +1 -2
  15. package/dist/api/routes/index.js +2 -2
  16. package/dist/api/routes/{cloud.js → ops.js} +19 -6
  17. package/dist/api/routes/user.js +0 -1
  18. package/dist/app.js +4 -13
  19. package/dist/automations/actions.js +32 -6
  20. package/dist/automations/index.js +3 -2
  21. package/dist/automations/steps/bash.js +6 -6
  22. package/dist/automations/steps/createRow.js +11 -11
  23. package/dist/automations/steps/delay.js +3 -3
  24. package/dist/automations/steps/deleteRow.js +8 -8
  25. package/dist/automations/steps/discord.js +8 -8
  26. package/dist/automations/steps/executeQuery.js +9 -9
  27. package/dist/automations/steps/executeScript.js +6 -6
  28. package/dist/automations/steps/filter.js +6 -6
  29. package/dist/automations/steps/integromat.js +10 -10
  30. package/dist/automations/steps/loop.js +9 -9
  31. package/dist/automations/steps/outgoingWebhook.js +10 -10
  32. package/dist/automations/steps/queryRows.js +14 -14
  33. package/dist/automations/steps/sendSmtpEmail.js +9 -9
  34. package/dist/automations/steps/serverLog.js +4 -4
  35. package/dist/automations/steps/slack.js +6 -6
  36. package/dist/automations/steps/updateRow.js +11 -11
  37. package/dist/automations/steps/zapier.js +9 -9
  38. package/dist/automations/triggerInfo/app.js +5 -5
  39. package/dist/automations/triggerInfo/cron.js +4 -4
  40. package/dist/automations/triggerInfo/rowDeleted.js +5 -5
  41. package/dist/automations/triggerInfo/rowSaved.js +7 -7
  42. package/dist/automations/triggerInfo/rowUpdated.js +7 -7
  43. package/dist/automations/triggerInfo/webhook.js +6 -6
  44. package/dist/db/utils.js +3 -2
  45. package/dist/environment.js +0 -1
  46. package/dist/events/docUpdates/index.js +17 -0
  47. package/dist/events/docUpdates/processors.js +18 -0
  48. package/dist/events/docUpdates/syncUsers.js +49 -0
  49. package/dist/events/index.js +3 -0
  50. package/dist/integrations/base/sqlTable.js +9 -2
  51. package/dist/integrations/index.js +3 -3
  52. package/dist/integrations/microsoftSqlServer.js +5 -2
  53. package/dist/integrations/mysql.js +5 -3
  54. package/dist/integrations/postgres.js +7 -5
  55. package/dist/integrations/redis.js +7 -0
  56. package/dist/integrations/rest.js +4 -0
  57. package/dist/migrations/functions/syncQuotas.js +2 -0
  58. package/dist/migrations/functions/usageQuotas/syncApps.js +1 -2
  59. package/dist/migrations/functions/usageQuotas/syncRows.js +1 -2
  60. package/dist/migrations/functions/usageQuotas/syncUsers.js +21 -0
  61. package/dist/sdk/app/applications/sync.js +117 -23
  62. package/dist/sdk/app/backups/exports.js +14 -38
  63. package/dist/sdk/index.js +2 -0
  64. package/dist/sdk/plugins/index.js +27 -0
  65. package/dist/sdk/plugins/plugins.js +53 -0
  66. package/dist/sdk/users/utils.js +21 -4
  67. package/dist/startup.js +31 -28
  68. package/dist/threads/automation.js +16 -5
  69. package/dist/tsconfig.build.tsbuildinfo +1 -1
  70. package/dist/utilities/fileSystem/plugin.js +33 -23
  71. package/dist/utilities/global.js +17 -12
  72. package/dist/utilities/rowProcessor/utils.js +4 -5
  73. package/dist/watch.js +2 -2
  74. package/dist/websockets/client.js +14 -0
  75. package/dist/websockets/grid.js +60 -0
  76. package/dist/websockets/index.js +17 -0
  77. package/dist/websockets/websocket.js +78 -0
  78. package/package.json +16 -16
  79. package/scripts/dev/manage.js +2 -0
  80. package/scripts/integrations/mssql/data/entrypoint.sh +1 -0
  81. package/scripts/integrations/mssql/data/setup.sql +17 -17
  82. package/scripts/integrations/mysql/init.sql +1 -1
  83. package/scripts/integrations/postgres/init.sql +1 -0
  84. package/src/api/controllers/application.ts +4 -4
  85. package/src/api/controllers/automation.ts +12 -6
  86. package/src/api/controllers/datasource.ts +15 -5
  87. package/src/api/controllers/dev.ts +2 -2
  88. package/src/api/controllers/ops.ts +32 -0
  89. package/src/api/controllers/plugin/index.ts +8 -45
  90. package/src/api/controllers/query/index.ts +2 -2
  91. package/src/api/controllers/row/ExternalRequest.ts +21 -12
  92. package/src/api/controllers/row/internal.ts +9 -10
  93. package/src/api/controllers/row/utils.ts +2 -2
  94. package/src/api/controllers/table/utils.ts +10 -3
  95. package/src/api/controllers/user.ts +10 -96
  96. package/src/api/index.ts +2 -4
  97. package/src/api/routes/index.ts +2 -2
  98. package/src/api/routes/ops.ts +30 -0
  99. package/src/api/routes/tests/automation.spec.js +7 -4
  100. package/src/api/routes/tests/user.spec.js +48 -37
  101. package/src/api/routes/user.ts +0 -5
  102. package/src/app.ts +4 -15
  103. package/src/automations/actions.ts +56 -24
  104. package/src/automations/index.ts +1 -1
  105. package/src/automations/steps/bash.ts +10 -7
  106. package/src/automations/steps/createRow.ts +15 -12
  107. package/src/automations/steps/delay.ts +6 -4
  108. package/src/automations/steps/deleteRow.ts +12 -9
  109. package/src/automations/steps/discord.ts +10 -8
  110. package/src/automations/steps/executeQuery.ts +13 -10
  111. package/src/automations/steps/executeScript.ts +10 -7
  112. package/src/automations/steps/filter.ts +8 -6
  113. package/src/automations/steps/integromat.ts +12 -10
  114. package/src/automations/steps/loop.ts +16 -10
  115. package/src/automations/steps/outgoingWebhook.ts +14 -11
  116. package/src/automations/steps/queryRows.ts +18 -15
  117. package/src/automations/steps/sendSmtpEmail.ts +11 -9
  118. package/src/automations/steps/serverLog.ts +6 -4
  119. package/src/automations/steps/slack.ts +8 -6
  120. package/src/automations/steps/updateRow.ts +15 -12
  121. package/src/automations/steps/zapier.ts +11 -9
  122. package/src/automations/tests/utilities/index.ts +2 -2
  123. package/src/automations/triggerInfo/app.ts +8 -5
  124. package/src/automations/triggerInfo/cron.ts +7 -4
  125. package/src/automations/triggerInfo/rowDeleted.ts +8 -5
  126. package/src/automations/triggerInfo/rowSaved.ts +10 -7
  127. package/src/automations/triggerInfo/rowUpdated.ts +10 -7
  128. package/src/automations/triggerInfo/webhook.ts +9 -6
  129. package/src/db/utils.ts +1 -0
  130. package/src/environment.ts +0 -1
  131. package/src/events/docUpdates/index.ts +1 -0
  132. package/src/events/docUpdates/processors.ts +14 -0
  133. package/src/events/docUpdates/syncUsers.ts +35 -0
  134. package/src/events/index.ts +1 -0
  135. package/src/integration-test/postgres.spec.ts +3 -1
  136. package/src/integrations/base/sqlTable.ts +9 -2
  137. package/src/integrations/index.ts +3 -3
  138. package/src/integrations/microsoftSqlServer.ts +5 -2
  139. package/src/integrations/mysql.ts +5 -3
  140. package/src/integrations/postgres.ts +7 -5
  141. package/src/integrations/redis.ts +8 -0
  142. package/src/integrations/rest.ts +3 -0
  143. package/src/migrations/functions/syncQuotas.ts +2 -0
  144. package/src/migrations/functions/usageQuotas/syncApps.ts +2 -3
  145. package/src/migrations/functions/usageQuotas/syncRows.ts +2 -3
  146. package/src/migrations/functions/usageQuotas/syncUsers.ts +9 -0
  147. package/src/migrations/functions/usageQuotas/tests/syncRows.spec.ts +2 -2
  148. package/src/migrations/functions/usageQuotas/tests/syncUsers.spec.ts +26 -0
  149. package/src/migrations/index.ts +1 -0
  150. package/src/sdk/app/applications/sync.ts +129 -22
  151. package/src/sdk/app/applications/tests/sync.spec.ts +137 -0
  152. package/src/sdk/app/backups/exports.ts +17 -41
  153. package/src/sdk/index.ts +2 -0
  154. package/src/sdk/plugins/index.ts +5 -0
  155. package/src/sdk/plugins/plugins.ts +41 -0
  156. package/src/sdk/users/tests/utils.spec.ts +1 -32
  157. package/src/sdk/users/utils.ts +23 -5
  158. package/src/startup.ts +36 -34
  159. package/src/tests/jestEnv.ts +0 -1
  160. package/src/tests/jestSetup.ts +0 -1
  161. package/src/tests/utilities/TestConfiguration.ts +28 -0
  162. package/src/tests/utilities/structures.ts +25 -17
  163. package/src/threads/automation.ts +18 -6
  164. package/src/utilities/fileSystem/plugin.ts +13 -4
  165. package/src/utilities/global.ts +21 -16
  166. package/src/utilities/rowProcessor/utils.ts +9 -10
  167. package/src/watch.ts +2 -2
  168. package/src/websockets/client.ts +11 -0
  169. package/src/websockets/grid.ts +55 -0
  170. package/src/websockets/index.ts +14 -0
  171. package/src/websockets/websocket.ts +83 -0
  172. package/tsconfig.build.json +3 -5
  173. package/tsconfig.json +2 -1
  174. package/builder/assets/index.0b358332.js +0 -1817
  175. package/builder/assets/index.7f9a008b.css +0 -6
  176. package/dist/api/controllers/cloud.js +0 -130
  177. package/dist/elasticApm.js +0 -14
  178. package/dist/package.json +0 -180
  179. package/dist/websocket.js +0 -22
  180. package/scripts/likeCypress.ts +0 -35
  181. package/src/api/controllers/cloud.ts +0 -119
  182. package/src/api/routes/cloud.ts +0 -18
  183. package/src/api/routes/tests/cloud.spec.ts +0 -54
  184. package/src/elasticApm.ts +0 -10
  185. package/src/migrations/functions/tests/syncQuotas.spec.js +0 -26
  186. package/src/tests/logging.ts +0 -34
  187. package/src/websocket.ts +0 -26
@@ -62,7 +62,7 @@ exports.definition = {
62
62
  icon: "Search",
63
63
  name: "Query rows",
64
64
  tagline: "Query rows from {{inputs.enriched.table.name}} table",
65
- type: "ACTION",
65
+ type: types_1.AutomationStepType.ACTION,
66
66
  stepId: types_1.AutomationActionStepId.QUERY_ROWS,
67
67
  internal: true,
68
68
  inputs: {},
@@ -70,35 +70,35 @@ exports.definition = {
70
70
  inputs: {
71
71
  properties: {
72
72
  tableId: {
73
- type: "string",
74
- customType: "table",
73
+ type: types_1.AutomationIOType.STRING,
74
+ customType: types_1.AutomationCustomIOType.TABLE,
75
75
  title: "Table",
76
76
  },
77
77
  filters: {
78
- type: "object",
79
- customType: "filters",
78
+ type: types_1.AutomationIOType.OBJECT,
79
+ customType: types_1.AutomationCustomIOType.FILTERS,
80
80
  title: "Filtering",
81
81
  },
82
82
  sortColumn: {
83
- type: "string",
83
+ type: types_1.AutomationIOType.STRING,
84
84
  title: "Sort Column",
85
- customType: "column",
85
+ customType: types_1.AutomationCustomIOType.COLUMN,
86
86
  },
87
87
  sortOrder: {
88
- type: "string",
88
+ type: types_1.AutomationIOType.STRING,
89
89
  title: "Sort Order",
90
90
  enum: Object.values(SortOrder),
91
91
  pretty: Object.values(SortOrderPretty),
92
92
  },
93
93
  limit: {
94
- type: "number",
94
+ type: types_1.AutomationIOType.NUMBER,
95
95
  title: "Limit",
96
- customType: "queryLimit",
96
+ customType: types_1.AutomationCustomIOType.QUERY_LIMIT,
97
97
  },
98
98
  onEmptyFilter: {
99
99
  pretty: Object.values(EmptyFilterOptionPretty),
100
100
  enum: Object.values(EmptyFilterOption),
101
- type: "string",
101
+ type: types_1.AutomationIOType.STRING,
102
102
  title: "When Filter Empty",
103
103
  },
104
104
  },
@@ -107,12 +107,12 @@ exports.definition = {
107
107
  outputs: {
108
108
  properties: {
109
109
  rows: {
110
- type: "array",
111
- customType: "rows",
110
+ type: types_1.AutomationIOType.ARRAY,
111
+ customType: types_1.AutomationCustomIOType.ROWS,
112
112
  description: "The rows that were found",
113
113
  },
114
114
  success: {
115
- type: "boolean",
115
+ type: types_1.AutomationIOType.BOOLEAN,
116
116
  description: "Whether the query was successful",
117
117
  },
118
118
  },
@@ -41,7 +41,7 @@ exports.definition = {
41
41
  tagline: "Send SMTP email to {{inputs.to}}",
42
42
  icon: "Email",
43
43
  name: "Send Email (SMTP)",
44
- type: "ACTION",
44
+ type: types_1.AutomationStepType.ACTION,
45
45
  internal: true,
46
46
  stepId: types_1.AutomationActionStepId.SEND_EMAIL_SMTP,
47
47
  inputs: {},
@@ -49,27 +49,27 @@ exports.definition = {
49
49
  inputs: {
50
50
  properties: {
51
51
  to: {
52
- type: "string",
52
+ type: types_1.AutomationIOType.STRING,
53
53
  title: "Send To",
54
54
  },
55
55
  from: {
56
- type: "string",
56
+ type: types_1.AutomationIOType.STRING,
57
57
  title: "Send From",
58
58
  },
59
59
  cc: {
60
- type: "string",
60
+ type: types_1.AutomationIOType.STRING,
61
61
  title: "CC",
62
62
  },
63
63
  bcc: {
64
- type: "string",
64
+ type: types_1.AutomationIOType.STRING,
65
65
  title: "BCC",
66
66
  },
67
67
  subject: {
68
- type: "string",
68
+ type: types_1.AutomationIOType.STRING,
69
69
  title: "Email Subject",
70
70
  },
71
71
  contents: {
72
- type: "string",
72
+ type: types_1.AutomationIOType.STRING,
73
73
  title: "HTML Contents",
74
74
  },
75
75
  },
@@ -78,11 +78,11 @@ exports.definition = {
78
78
  outputs: {
79
79
  properties: {
80
80
  success: {
81
- type: "boolean",
81
+ type: types_1.AutomationIOType.BOOLEAN,
82
82
  description: "Whether the email was sent",
83
83
  },
84
84
  response: {
85
- type: "object",
85
+ type: types_1.AutomationIOType.OBJECT,
86
86
  description: "A response from the email client, this may be an error",
87
87
  },
88
88
  },
@@ -21,7 +21,7 @@ exports.definition = {
21
21
  tagline: "Console log a value in the backend",
22
22
  icon: "Monitoring",
23
23
  description: "Logs the given text to the server (using console.log)",
24
- type: "ACTION",
24
+ type: types_1.AutomationStepType.ACTION,
25
25
  internal: true,
26
26
  stepId: types_1.AutomationActionStepId.SERVER_LOG,
27
27
  inputs: {
@@ -31,7 +31,7 @@ exports.definition = {
31
31
  inputs: {
32
32
  properties: {
33
33
  text: {
34
- type: "string",
34
+ type: types_1.AutomationIOType.STRING,
35
35
  title: "Log",
36
36
  },
37
37
  },
@@ -40,11 +40,11 @@ exports.definition = {
40
40
  outputs: {
41
41
  properties: {
42
42
  success: {
43
- type: "boolean",
43
+ type: types_1.AutomationIOType.BOOLEAN,
44
44
  description: "Whether the action was successful",
45
45
  },
46
46
  message: {
47
- type: "string",
47
+ type: types_1.AutomationIOType.STRING,
48
48
  description: "What was output",
49
49
  },
50
50
  },
@@ -22,18 +22,18 @@ exports.definition = {
22
22
  description: "Send a message to Slack",
23
23
  icon: "ri-slack-line",
24
24
  stepId: types_1.AutomationActionStepId.slack,
25
- type: "ACTION",
25
+ type: types_1.AutomationStepType.ACTION,
26
26
  internal: false,
27
27
  inputs: {},
28
28
  schema: {
29
29
  inputs: {
30
30
  properties: {
31
31
  url: {
32
- type: "string",
32
+ type: types_1.AutomationIOType.STRING,
33
33
  title: "Incoming Webhook URL",
34
34
  },
35
35
  text: {
36
- type: "string",
36
+ type: types_1.AutomationIOType.STRING,
37
37
  title: "Message",
38
38
  },
39
39
  },
@@ -42,15 +42,15 @@ exports.definition = {
42
42
  outputs: {
43
43
  properties: {
44
44
  httpStatus: {
45
- type: "number",
45
+ type: types_1.AutomationIOType.NUMBER,
46
46
  description: "The HTTP status code of the request",
47
47
  },
48
48
  success: {
49
- type: "boolean",
49
+ type: types_1.AutomationIOType.BOOLEAN,
50
50
  description: "Whether the message sent successfully",
51
51
  },
52
52
  response: {
53
- type: "string",
53
+ type: types_1.AutomationIOType.STRING,
54
54
  description: "The response from the Slack Webhook",
55
55
  },
56
56
  },
@@ -42,7 +42,7 @@ exports.definition = {
42
42
  tagline: "Update a {{inputs.enriched.table.name}} row",
43
43
  icon: "Refresh",
44
44
  description: "Update a row in your database",
45
- type: "ACTION",
45
+ type: types_1.AutomationStepType.ACTION,
46
46
  internal: true,
47
47
  stepId: types_1.AutomationActionStepId.UPDATE_ROW,
48
48
  inputs: {},
@@ -50,16 +50,16 @@ exports.definition = {
50
50
  inputs: {
51
51
  properties: {
52
52
  meta: {
53
- type: "object",
53
+ type: types_1.AutomationIOType.OBJECT,
54
54
  title: "Field settings",
55
55
  },
56
56
  row: {
57
- type: "object",
58
- customType: "row",
57
+ type: types_1.AutomationIOType.OBJECT,
58
+ customType: types_1.AutomationCustomIOType.ROW,
59
59
  title: "Table",
60
60
  },
61
61
  rowId: {
62
- type: "string",
62
+ type: types_1.AutomationIOType.STRING,
63
63
  title: "Row ID",
64
64
  },
65
65
  },
@@ -68,24 +68,24 @@ exports.definition = {
68
68
  outputs: {
69
69
  properties: {
70
70
  row: {
71
- type: "object",
72
- customType: "row",
71
+ type: types_1.AutomationIOType.OBJECT,
72
+ customType: types_1.AutomationCustomIOType.ROW,
73
73
  description: "The updated row",
74
74
  },
75
75
  response: {
76
- type: "object",
76
+ type: types_1.AutomationIOType.OBJECT,
77
77
  description: "The response from the table",
78
78
  },
79
79
  success: {
80
- type: "boolean",
80
+ type: types_1.AutomationIOType.BOOLEAN,
81
81
  description: "Whether the action was successful",
82
82
  },
83
83
  id: {
84
- type: "string",
84
+ type: types_1.AutomationIOType.STRING,
85
85
  description: "The identifier of the updated row",
86
86
  },
87
87
  revision: {
88
- type: "string",
88
+ type: types_1.AutomationIOType.STRING,
89
89
  description: "The revision of the updated row",
90
90
  },
91
91
  },
@@ -19,7 +19,7 @@ const types_1 = require("@budibase/types");
19
19
  exports.definition = {
20
20
  name: "Zapier Webhook",
21
21
  stepId: types_1.AutomationActionStepId.zapier,
22
- type: "ACTION",
22
+ type: types_1.AutomationStepType.ACTION,
23
23
  internal: false,
24
24
  description: "Trigger a Zapier Zap via webhooks",
25
25
  tagline: "Trigger a Zapier Zap",
@@ -29,27 +29,27 @@ exports.definition = {
29
29
  inputs: {
30
30
  properties: {
31
31
  url: {
32
- type: "string",
32
+ type: types_1.AutomationIOType.STRING,
33
33
  title: "Webhook URL",
34
34
  },
35
35
  value1: {
36
- type: "string",
36
+ type: types_1.AutomationIOType.STRING,
37
37
  title: "Payload Value 1",
38
38
  },
39
39
  value2: {
40
- type: "string",
40
+ type: types_1.AutomationIOType.STRING,
41
41
  title: "Payload Value 2",
42
42
  },
43
43
  value3: {
44
- type: "string",
44
+ type: types_1.AutomationIOType.STRING,
45
45
  title: "Payload Value 3",
46
46
  },
47
47
  value4: {
48
- type: "string",
48
+ type: types_1.AutomationIOType.STRING,
49
49
  title: "Payload Value 4",
50
50
  },
51
51
  value5: {
52
- type: "string",
52
+ type: types_1.AutomationIOType.STRING,
53
53
  title: "Payload Value 5",
54
54
  },
55
55
  },
@@ -58,11 +58,11 @@ exports.definition = {
58
58
  outputs: {
59
59
  properties: {
60
60
  httpStatus: {
61
- type: "number",
61
+ type: types_1.AutomationIOType.NUMBER,
62
62
  description: "The HTTP status code of the request",
63
63
  },
64
64
  response: {
65
- type: "string",
65
+ type: types_1.AutomationIOType.STRING,
66
66
  description: "The response from Zapier",
67
67
  },
68
68
  },
@@ -14,8 +14,8 @@ exports.definition = {
14
14
  inputs: {
15
15
  properties: {
16
16
  fields: {
17
- type: "object",
18
- customType: "triggerSchema",
17
+ type: types_1.AutomationIOType.OBJECT,
18
+ customType: types_1.AutomationCustomIOType.TRIGGER_SCHEMA,
19
19
  title: "Fields",
20
20
  },
21
21
  },
@@ -24,13 +24,13 @@ exports.definition = {
24
24
  outputs: {
25
25
  properties: {
26
26
  fields: {
27
- type: "object",
27
+ type: types_1.AutomationIOType.OBJECT,
28
28
  description: "Fields submitted from the app frontend",
29
- customType: "triggerSchema",
29
+ customType: types_1.AutomationCustomIOType.TRIGGER_SCHEMA,
30
30
  },
31
31
  },
32
32
  required: ["fields"],
33
33
  },
34
34
  },
35
- type: "TRIGGER",
35
+ type: types_1.AutomationStepType.TRIGGER,
36
36
  };
@@ -14,8 +14,8 @@ exports.definition = {
14
14
  inputs: {
15
15
  properties: {
16
16
  cron: {
17
- type: "string",
18
- customType: "cron",
17
+ type: types_1.AutomationIOType.STRING,
18
+ customType: types_1.AutomationCustomIOType.CRON,
19
19
  title: "Expression",
20
20
  },
21
21
  },
@@ -24,12 +24,12 @@ exports.definition = {
24
24
  outputs: {
25
25
  properties: {
26
26
  timestamp: {
27
- type: "number",
27
+ type: types_1.AutomationIOType.NUMBER,
28
28
  description: "Timestamp the cron was executed",
29
29
  },
30
30
  },
31
31
  required: ["timestamp"],
32
32
  },
33
33
  },
34
- type: "TRIGGER",
34
+ type: types_1.AutomationStepType.TRIGGER,
35
35
  };
@@ -14,8 +14,8 @@ exports.definition = {
14
14
  inputs: {
15
15
  properties: {
16
16
  tableId: {
17
- type: "string",
18
- customType: "table",
17
+ type: types_1.AutomationIOType.STRING,
18
+ customType: types_1.AutomationCustomIOType.TABLE,
19
19
  title: "Table",
20
20
  },
21
21
  },
@@ -24,13 +24,13 @@ exports.definition = {
24
24
  outputs: {
25
25
  properties: {
26
26
  row: {
27
- type: "object",
28
- customType: "row",
27
+ type: types_1.AutomationIOType.OBJECT,
28
+ customType: types_1.AutomationCustomIOType.ROW,
29
29
  description: "The row that was deleted",
30
30
  },
31
31
  },
32
32
  required: ["row"],
33
33
  },
34
34
  },
35
- type: "TRIGGER",
35
+ type: types_1.AutomationStepType.TRIGGER,
36
36
  };
@@ -14,8 +14,8 @@ exports.definition = {
14
14
  inputs: {
15
15
  properties: {
16
16
  tableId: {
17
- type: "string",
18
- customType: "table",
17
+ type: types_1.AutomationIOType.STRING,
18
+ customType: types_1.AutomationCustomIOType.TABLE,
19
19
  title: "Table",
20
20
  },
21
21
  },
@@ -24,21 +24,21 @@ exports.definition = {
24
24
  outputs: {
25
25
  properties: {
26
26
  row: {
27
- type: "object",
28
- customType: "row",
27
+ type: types_1.AutomationIOType.OBJECT,
28
+ customType: types_1.AutomationCustomIOType.ROW,
29
29
  description: "The new row that was created",
30
30
  },
31
31
  id: {
32
- type: "string",
32
+ type: types_1.AutomationIOType.STRING,
33
33
  description: "Row ID - can be used for updating",
34
34
  },
35
35
  revision: {
36
- type: "string",
36
+ type: types_1.AutomationIOType.STRING,
37
37
  description: "Revision of row",
38
38
  },
39
39
  },
40
40
  required: ["row", "id"],
41
41
  },
42
42
  },
43
- type: "TRIGGER",
43
+ type: types_1.AutomationStepType.TRIGGER,
44
44
  };
@@ -14,8 +14,8 @@ exports.definition = {
14
14
  inputs: {
15
15
  properties: {
16
16
  tableId: {
17
- type: "string",
18
- customType: "table",
17
+ type: types_1.AutomationIOType.STRING,
18
+ customType: types_1.AutomationCustomIOType.TABLE,
19
19
  title: "Table",
20
20
  },
21
21
  },
@@ -24,21 +24,21 @@ exports.definition = {
24
24
  outputs: {
25
25
  properties: {
26
26
  row: {
27
- type: "object",
28
- customType: "row",
27
+ type: types_1.AutomationIOType.OBJECT,
28
+ customType: types_1.AutomationCustomIOType.ROW,
29
29
  description: "The row that was updated",
30
30
  },
31
31
  id: {
32
- type: "string",
32
+ type: types_1.AutomationIOType.STRING,
33
33
  description: "Row ID - can be used for updating",
34
34
  },
35
35
  revision: {
36
- type: "string",
36
+ type: types_1.AutomationIOType.STRING,
37
37
  description: "Revision of row",
38
38
  },
39
39
  },
40
40
  required: ["row", "id"],
41
41
  },
42
42
  },
43
- type: "TRIGGER",
43
+ type: types_1.AutomationStepType.TRIGGER,
44
44
  };
@@ -14,13 +14,13 @@ exports.definition = {
14
14
  inputs: {
15
15
  properties: {
16
16
  schemaUrl: {
17
- type: "string",
18
- customType: "webhookUrl",
17
+ type: types_1.AutomationIOType.STRING,
18
+ customType: types_1.AutomationCustomIOType.WEBHOOK_URL,
19
19
  title: "Schema URL",
20
20
  },
21
21
  triggerUrl: {
22
- type: "string",
23
- customType: "webhookUrl",
22
+ type: types_1.AutomationIOType.STRING,
23
+ customType: types_1.AutomationCustomIOType.WEBHOOK_URL,
24
24
  title: "Trigger URL",
25
25
  },
26
26
  },
@@ -29,12 +29,12 @@ exports.definition = {
29
29
  outputs: {
30
30
  properties: {
31
31
  body: {
32
- type: "object",
32
+ type: types_1.AutomationIOType.OBJECT,
33
33
  description: "Body of the request which hit the webhook",
34
34
  },
35
35
  },
36
36
  required: ["body"],
37
37
  },
38
38
  },
39
- type: "TRIGGER",
39
+ type: types_1.AutomationStepType.TRIGGER,
40
40
  };
package/dist/db/utils.js CHANGED
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getMemoryViewParams = exports.generateMemoryViewID = exports.getMetadataParams = exports.generateMetadataID = exports.generateUserFlagID = exports.getQueryParams = exports.getAutomationMetadataParams = exports.generateAutomationMetadataID = exports.generateQueryID = exports.getDatasourceParams = exports.generateDatasourceID = exports.getWebhookParams = exports.generateWebhookID = exports.getScreenParams = exports.generateScreenID = exports.getLayoutParams = exports.generateLayoutID = exports.getLinkParams = exports.generateLinkID = exports.generateAutomationID = exports.getAutomationParams = exports.getTableIDFromRowID = exports.generateTableID = exports.getTableParams = exports.getGlobalIDFromUserMetadataID = exports.generateUserMetadataID = exports.getUserMetadataParams = exports.generateRowID = exports.getRowParams = exports.getDocParams = exports.getQueryIndex = exports.getRoleParams = exports.generateRoleID = exports.generateDevAppID = exports.generateAppID = exports.UNICODE_MAX = exports.InternalTables = exports.ViewName = exports.TABLE_ROW_PREFIX = exports.LINK_USER_METADATA_PREFIX = exports.USER_METDATA_PREFIX = exports.isProdAppID = exports.isDevAppID = exports.APP_DEV_PREFIX = exports.APP_PREFIX = exports.DocumentType = exports.StaticDatabases = exports.SEPARATOR = exports.BudibaseInternalDB = exports.AppStatus = void 0;
7
- exports.getMultiIDParams = exports.generatePluginID = void 0;
6
+ exports.generateMemoryViewID = exports.getMetadataParams = exports.generateMetadataID = exports.generateUserFlagID = exports.getQueryParams = exports.getAutomationMetadataParams = exports.generateAutomationMetadataID = exports.generateQueryID = exports.getDatasourceParams = exports.generateDatasourceID = exports.getWebhookParams = exports.generateWebhookID = exports.getScreenParams = exports.generateScreenID = exports.getLayoutParams = exports.generateLayoutID = exports.getLinkParams = exports.generateLinkID = exports.generateAutomationID = exports.getAutomationParams = exports.getTableIDFromRowID = exports.generateTableID = exports.getTableParams = exports.getGlobalIDFromUserMetadataID = exports.generateUserMetadataID = exports.getUserMetadataParams = exports.generateRowID = exports.getRowParams = exports.getDocParams = exports.getQueryIndex = exports.getRoleParams = exports.generateRoleID = exports.generateDevAppID = exports.generateAppID = exports.UNICODE_MAX = exports.InternalTables = exports.ViewName = exports.AUTOMATION_LOG_PREFIX = exports.TABLE_ROW_PREFIX = exports.LINK_USER_METADATA_PREFIX = exports.USER_METDATA_PREFIX = exports.isProdAppID = exports.isDevAppID = exports.APP_DEV_PREFIX = exports.APP_PREFIX = exports.DocumentType = exports.StaticDatabases = exports.SEPARATOR = exports.BudibaseInternalDB = exports.AppStatus = void 0;
7
+ exports.getMultiIDParams = exports.generatePluginID = exports.getMemoryViewParams = void 0;
8
8
  const newid_1 = __importDefault(require("./newid"));
9
9
  const backend_core_1 = require("@budibase/backend-core");
10
10
  exports.AppStatus = {
@@ -29,6 +29,7 @@ exports.isProdAppID = backend_core_1.db.isProdAppID;
29
29
  exports.USER_METDATA_PREFIX = `${exports.DocumentType.ROW}${exports.SEPARATOR}${backend_core_1.db.InternalTable.USER_METADATA}${exports.SEPARATOR}`;
30
30
  exports.LINK_USER_METADATA_PREFIX = `${exports.DocumentType.LINK}${exports.SEPARATOR}${backend_core_1.db.InternalTable.USER_METADATA}${exports.SEPARATOR}`;
31
31
  exports.TABLE_ROW_PREFIX = `${exports.DocumentType.ROW}${exports.SEPARATOR}${exports.DocumentType.TABLE}`;
32
+ exports.AUTOMATION_LOG_PREFIX = `${exports.DocumentType.AUTOMATION_LOG}${exports.SEPARATOR}`;
32
33
  exports.ViewName = backend_core_1.db.ViewName;
33
34
  exports.InternalTables = backend_core_1.db.InternalTable;
34
35
  exports.UNICODE_MAX = backend_core_1.db.UNICODE_MAX;
@@ -54,7 +54,6 @@ const environment = {
54
54
  // minor
55
55
  SALT_ROUNDS: process.env.SALT_ROUNDS,
56
56
  LOGGER: process.env.LOGGER,
57
- LOG_LEVEL: process.env.LOG_LEVEL,
58
57
  ACCOUNT_PORTAL_URL: process.env.ACCOUNT_PORTAL_URL,
59
58
  AUTOMATION_MAX_ITERATIONS: parseIntSafe(process.env.AUTOMATION_MAX_ITERATIONS) || 200,
60
59
  SENDGRID_API_KEY: process.env.SENDGRID_API_KEY,
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./processors"), exports);
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.init = void 0;
7
+ const syncUsers_1 = __importDefault(require("./syncUsers"));
8
+ const backend_core_1 = require("@budibase/backend-core");
9
+ let started = false;
10
+ function init(updateCb) {
11
+ if (started) {
12
+ return;
13
+ }
14
+ const processors = [(0, syncUsers_1.default)(updateCb)];
15
+ backend_core_1.docUpdates.init(processors);
16
+ started = true;
17
+ }
18
+ exports.init = init;
@@ -0,0 +1,49 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const backend_core_1 = require("@budibase/backend-core");
13
+ const pro_1 = require("@budibase/pro");
14
+ const types_1 = require("@budibase/types");
15
+ const sync_1 = require("../../sdk/app/applications/sync");
16
+ function process(updateCb) {
17
+ const processor = (update) => __awaiter(this, void 0, void 0, function* () {
18
+ var _a;
19
+ try {
20
+ const docId = update.id;
21
+ const isGroup = docId.startsWith(backend_core_1.constants.DocumentType.GROUP);
22
+ let userIds;
23
+ if (isGroup) {
24
+ const group = yield pro_1.sdk.groups.get(docId);
25
+ userIds = ((_a = group.users) === null || _a === void 0 ? void 0 : _a.map(user => user._id)) || [];
26
+ }
27
+ else {
28
+ userIds = [docId];
29
+ }
30
+ if (userIds.length > 0) {
31
+ yield (0, sync_1.syncUsersToAllApps)(userIds);
32
+ }
33
+ if (updateCb) {
34
+ updateCb(docId);
35
+ }
36
+ }
37
+ catch (err) {
38
+ // if something not found - no changes to perform
39
+ if ((err === null || err === void 0 ? void 0 : err.status) === 404) {
40
+ return;
41
+ }
42
+ else {
43
+ backend_core_1.logging.logAlert("Failed to perform user/group app sync", err);
44
+ }
45
+ }
46
+ });
47
+ return { events: types_1.UserGroupSyncEvents, processor };
48
+ }
49
+ exports.default = process;
@@ -3,6 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.init = void 0;
6
7
  const BudibaseEmitter_1 = __importDefault(require("./BudibaseEmitter"));
7
8
  const emitter = new BudibaseEmitter_1.default();
9
+ var docUpdates_1 = require("./docUpdates");
10
+ Object.defineProperty(exports, "init", { enumerable: true, get: function () { return docUpdates_1.init; } });
8
11
  exports.default = emitter;