@budibase/server 1.0.46-alpha.7 → 1.0.48

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 (251) hide show
  1. package/builder/assets/{index.dd9e386f.css → index.39e01193.css} +1 -1
  2. package/builder/assets/{index.af9e71d8.js → index.e083dcaf.js} +221 -223
  3. package/builder/assets/{vendor.3bd2f661.js → vendor.f9faf6ab.js} +12 -12
  4. package/builder/index.html +3 -3
  5. package/coverage/clover.xml +1637 -1793
  6. package/coverage/coverage-final.json +94 -98
  7. package/coverage/lcov-report/api/controllers/analytics.js.html +1 -1
  8. package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
  9. package/coverage/lcov-report/api/controllers/application.js.html +126 -210
  10. package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
  11. package/coverage/lcov-report/api/controllers/automation.js.html +21 -21
  12. package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
  13. package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
  14. package/coverage/lcov-report/api/controllers/component.js.html +4 -4
  15. package/coverage/lcov-report/api/controllers/datasource.js.html +36 -72
  16. package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
  17. package/coverage/lcov-report/{migrations/usageQuotas/syncRows.js.html → api/controllers/hosting.js.html} +44 -41
  18. package/coverage/lcov-report/api/controllers/index.html +42 -27
  19. package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
  20. package/coverage/lcov-report/api/controllers/layout.js.html +6 -6
  21. package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
  22. package/coverage/lcov-report/api/controllers/permission.js.html +15 -15
  23. package/coverage/lcov-report/api/controllers/query/index.html +1 -1
  24. package/coverage/lcov-report/api/controllers/query/index.js.html +19 -19
  25. package/coverage/lcov-report/api/controllers/query/validation.js.html +6 -6
  26. package/coverage/lcov-report/api/controllers/role.js.html +9 -9
  27. package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
  28. package/coverage/lcov-report/api/controllers/row/external.js.html +16 -16
  29. package/coverage/lcov-report/api/controllers/row/index.html +15 -15
  30. package/coverage/lcov-report/api/controllers/row/index.js.html +26 -26
  31. package/coverage/lcov-report/api/controllers/row/internal.js.html +44 -44
  32. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +8 -8
  33. package/coverage/lcov-report/api/controllers/row/utils.js.html +57 -39
  34. package/coverage/lcov-report/api/controllers/screen.js.html +7 -7
  35. package/coverage/lcov-report/api/controllers/script.js.html +4 -4
  36. package/coverage/lcov-report/api/controllers/table/external.js.html +12 -12
  37. package/coverage/lcov-report/api/controllers/table/index.html +32 -32
  38. package/coverage/lcov-report/api/controllers/table/index.js.html +39 -57
  39. package/coverage/lcov-report/api/controllers/table/internal.js.html +34 -40
  40. package/coverage/lcov-report/api/controllers/table/utils.js.html +122 -83
  41. package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
  42. package/coverage/lcov-report/api/controllers/user.js.html +20 -20
  43. package/coverage/lcov-report/api/controllers/view/exporters.js.html +4 -4
  44. package/coverage/lcov-report/api/controllers/view/index.html +1 -1
  45. package/coverage/lcov-report/api/controllers/view/index.js.html +14 -14
  46. package/coverage/lcov-report/api/controllers/view/utils.js.html +11 -11
  47. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +7 -7
  48. package/coverage/lcov-report/api/controllers/webhook.js.html +15 -15
  49. package/coverage/lcov-report/api/index.html +1 -1
  50. package/coverage/lcov-report/api/index.js.html +10 -10
  51. package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
  52. package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
  53. package/coverage/lcov-report/api/routes/application.js.html +1 -1
  54. package/coverage/lcov-report/api/routes/auth.js.html +1 -1
  55. package/coverage/lcov-report/api/routes/automation.js.html +1 -1
  56. package/coverage/lcov-report/api/routes/backup.js.html +1 -1
  57. package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
  58. package/coverage/lcov-report/api/routes/component.js.html +1 -1
  59. package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
  60. package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
  61. package/coverage/lcov-report/api/routes/dev.js.html +1 -1
  62. package/coverage/lcov-report/{migrations/usageQuotas/syncApps.js.html → api/routes/hosting.js.html} +27 -42
  63. package/coverage/lcov-report/api/routes/index.html +22 -7
  64. package/coverage/lcov-report/api/routes/index.js.html +10 -4
  65. package/coverage/lcov-report/api/routes/integration.js.html +1 -1
  66. package/coverage/lcov-report/api/routes/layout.js.html +1 -1
  67. package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
  68. package/coverage/lcov-report/api/routes/permission.js.html +1 -1
  69. package/coverage/lcov-report/api/routes/query.js.html +1 -1
  70. package/coverage/lcov-report/api/routes/role.js.html +1 -1
  71. package/coverage/lcov-report/api/routes/routing.js.html +1 -1
  72. package/coverage/lcov-report/api/routes/row.js.html +1 -1
  73. package/coverage/lcov-report/api/routes/screen.js.html +1 -1
  74. package/coverage/lcov-report/api/routes/script.js.html +1 -1
  75. package/coverage/lcov-report/api/routes/static.js.html +2 -17
  76. package/coverage/lcov-report/api/routes/table.js.html +1 -1
  77. package/coverage/lcov-report/api/routes/templates.js.html +1 -1
  78. package/coverage/lcov-report/api/routes/user.js.html +1 -1
  79. package/coverage/lcov-report/api/routes/view.js.html +1 -1
  80. package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
  81. package/coverage/lcov-report/automations/actions.js.html +24 -24
  82. package/coverage/lcov-report/automations/automationUtils.js.html +5 -5
  83. package/coverage/lcov-report/automations/bullboard.js.html +16 -16
  84. package/coverage/lcov-report/automations/index.html +1 -1
  85. package/coverage/lcov-report/automations/index.js.html +1 -1
  86. package/coverage/lcov-report/automations/steps/bash.js.html +6 -6
  87. package/coverage/lcov-report/automations/steps/createRow.js.html +19 -13
  88. package/coverage/lcov-report/automations/steps/delay.js.html +4 -4
  89. package/coverage/lcov-report/automations/steps/deleteRow.js.html +20 -11
  90. package/coverage/lcov-report/automations/steps/discord.js.html +7 -7
  91. package/coverage/lcov-report/automations/steps/executeQuery.js.html +6 -6
  92. package/coverage/lcov-report/automations/steps/executeScript.js.html +6 -6
  93. package/coverage/lcov-report/automations/steps/filter.js.html +7 -7
  94. package/coverage/lcov-report/automations/steps/index.html +13 -13
  95. package/coverage/lcov-report/automations/steps/integromat.js.html +5 -5
  96. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +8 -8
  97. package/coverage/lcov-report/automations/steps/queryRows.js.html +10 -10
  98. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +5 -5
  99. package/coverage/lcov-report/automations/steps/serverLog.js.html +3 -3
  100. package/coverage/lcov-report/automations/steps/slack.js.html +5 -5
  101. package/coverage/lcov-report/automations/steps/updateRow.js.html +6 -6
  102. package/coverage/lcov-report/automations/steps/utils.js.html +3 -3
  103. package/coverage/lcov-report/automations/steps/zapier.js.html +5 -5
  104. package/coverage/lcov-report/automations/triggerInfo/app.js.html +2 -2
  105. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +2 -2
  106. package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
  107. package/coverage/lcov-report/automations/triggerInfo/index.js.html +8 -8
  108. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +2 -2
  109. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +2 -2
  110. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +2 -2
  111. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +2 -2
  112. package/coverage/lcov-report/automations/triggers.js.html +18 -18
  113. package/coverage/lcov-report/automations/utils.js.html +32 -32
  114. package/coverage/lcov-report/constants/index.html +11 -11
  115. package/coverage/lcov-report/constants/index.js.html +37 -40
  116. package/coverage/lcov-report/constants/layouts.js.html +5 -5
  117. package/coverage/lcov-report/constants/screens.js.html +4 -4
  118. package/coverage/lcov-report/db/client.js.html +18 -18
  119. package/coverage/lcov-report/db/inMemoryView.js.html +7 -7
  120. package/coverage/lcov-report/db/index.html +15 -15
  121. package/coverage/lcov-report/db/index.js.html +3 -3
  122. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +18 -18
  123. package/coverage/lcov-report/db/linkedRows/index.html +1 -1
  124. package/coverage/lcov-report/db/linkedRows/index.js.html +31 -31
  125. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +15 -15
  126. package/coverage/lcov-report/db/newid.js.html +4 -4
  127. package/coverage/lcov-report/db/utils.js.html +85 -85
  128. package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
  129. package/coverage/lcov-report/events/index.html +1 -1
  130. package/coverage/lcov-report/events/index.js.html +5 -5
  131. package/coverage/lcov-report/events/utils.js.html +3 -3
  132. package/coverage/lcov-report/index.html +86 -116
  133. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
  134. package/coverage/lcov-report/integrations/tests/index.html +1 -1
  135. package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
  136. package/coverage/lcov-report/middleware/authorized.js.html +11 -11
  137. package/coverage/lcov-report/middleware/builder.js.html +8 -8
  138. package/coverage/lcov-report/middleware/currentapp.js.html +29 -29
  139. package/coverage/lcov-report/middleware/index.html +20 -20
  140. package/coverage/lcov-report/middleware/joi-validator.js.html +3 -3
  141. package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
  142. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  143. package/coverage/lcov-report/middleware/usageQuota.js.html +41 -275
  144. package/coverage/lcov-report/middleware/utils.js.html +2 -2
  145. package/coverage/lcov-report/threads/automation.js.html +1 -1
  146. package/coverage/lcov-report/threads/index.html +15 -15
  147. package/coverage/lcov-report/threads/index.js.html +10 -10
  148. package/coverage/lcov-report/threads/query.js.html +8 -23
  149. package/coverage/lcov-report/threads/utils.js.html +14 -14
  150. package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
  151. package/coverage/lcov-report/utilities/budibaseDir.js.html +7 -7
  152. package/coverage/lcov-report/utilities/centralPath.js.html +4 -4
  153. package/coverage/lcov-report/utilities/csvParser.js.html +6 -6
  154. package/coverage/lcov-report/utilities/global.js.html +26 -26
  155. package/coverage/lcov-report/utilities/index.html +19 -19
  156. package/coverage/lcov-report/utilities/index.js.html +25 -25
  157. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +8 -8
  158. package/coverage/lcov-report/utilities/queue/index.html +1 -1
  159. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  160. package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
  161. package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
  162. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +53 -53
  163. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +10 -10
  164. package/coverage/lcov-report/utilities/scriptRunner.js.html +5 -5
  165. package/coverage/lcov-report/utilities/security.js.html +8 -8
  166. package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
  167. package/coverage/lcov-report/utilities/users.js.html +5 -5
  168. package/coverage/lcov-report/utilities/workerRequests.js.html +108 -39
  169. package/coverage/lcov.info +2332 -2599
  170. package/dist/api/controllers/application.js +20 -49
  171. package/dist/api/controllers/datasource.js +0 -11
  172. package/dist/api/controllers/hosting.js +30 -0
  173. package/dist/api/controllers/row/ExternalRequest.js +2 -1
  174. package/dist/api/controllers/row/utils.js +8 -6
  175. package/dist/api/controllers/static/index.js +10 -59
  176. package/dist/api/controllers/table/index.js +4 -10
  177. package/dist/api/controllers/table/internal.js +0 -2
  178. package/dist/api/controllers/table/utils.js +17 -11
  179. package/dist/api/routes/hosting.js +11 -0
  180. package/dist/api/routes/index.js +2 -0
  181. package/dist/api/routes/static.js +1 -2
  182. package/dist/automations/steps/createRow.js +4 -2
  183. package/dist/automations/steps/deleteRow.js +4 -1
  184. package/dist/constants/index.js +5 -8
  185. package/dist/definitions/datasource.js +0 -1
  186. package/dist/environment.js +0 -1
  187. package/dist/integrations/base/sql.js +6 -13
  188. package/dist/integrations/index.js +0 -3
  189. package/dist/integrations/utils.js +9 -56
  190. package/dist/middleware/usageQuota.js +13 -82
  191. package/dist/package.json +5 -8
  192. package/dist/tests/utilities/TestConfiguration.js +1 -3
  193. package/dist/threads/query.js +0 -4
  194. package/dist/tsconfig.tsbuildinfo +1 -1
  195. package/dist/utilities/{usageQuota/index.js → usageQuota.js} +31 -44
  196. package/dist/utilities/workerRequests.js +20 -0
  197. package/nodemon.json +1 -1
  198. package/package.json +6 -9
  199. package/src/api/controllers/application.js +24 -52
  200. package/src/api/controllers/datasource.js +0 -12
  201. package/src/api/controllers/hosting.js +22 -0
  202. package/src/api/controllers/row/ExternalRequest.ts +1 -1
  203. package/src/api/controllers/row/utils.js +12 -6
  204. package/src/api/controllers/static/index.js +10 -63
  205. package/src/api/controllers/table/index.js +9 -15
  206. package/src/api/controllers/table/internal.js +0 -2
  207. package/src/api/controllers/table/utils.js +24 -11
  208. package/src/api/routes/hosting.js +13 -0
  209. package/src/api/routes/index.js +2 -0
  210. package/src/api/routes/static.js +0 -5
  211. package/src/api/routes/tests/application.spec.js +2 -2
  212. package/src/api/routes/tests/hosting.spec.js +36 -0
  213. package/src/automations/steps/createRow.js +4 -2
  214. package/src/automations/steps/deleteRow.js +4 -1
  215. package/src/constants/index.js +8 -9
  216. package/src/definitions/datasource.ts +0 -3
  217. package/src/environment.js +0 -1
  218. package/src/integrations/base/sql.ts +7 -14
  219. package/src/integrations/index.ts +0 -3
  220. package/src/integrations/tests/sql.spec.js +0 -16
  221. package/src/integrations/utils.ts +11 -70
  222. package/src/middleware/tests/usageQuota.spec.js +24 -18
  223. package/src/middleware/usageQuota.js +15 -93
  224. package/src/tests/utilities/TestConfiguration.js +1 -3
  225. package/src/threads/query.js +0 -5
  226. package/src/utilities/usageQuota.js +73 -0
  227. package/src/utilities/workerRequests.js +23 -0
  228. package/coverage/lcov-report/migrations/usageQuotas/index.html +0 -141
  229. package/coverage/lcov-report/migrations/usageQuotas/index.js.html +0 -152
  230. package/coverage/lcov-report/utilities/usageQuota/index.html +0 -141
  231. package/coverage/lcov-report/utilities/usageQuota/index.js.html +0 -356
  232. package/coverage/lcov-report/utilities/usageQuota/rows.js.html +0 -302
  233. package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +0 -134
  234. package/dist/integrations/googlesheets.js +0 -340
  235. package/dist/migrations/usageQuotas/index.js +0 -24
  236. package/dist/migrations/usageQuotas/syncApps.js +0 -26
  237. package/dist/migrations/usageQuotas/syncRows.js +0 -29
  238. package/dist/utilities/usageQuota/rows.js +0 -77
  239. package/dist/utilities/usageQuota/usageQuoteReset.js +0 -16
  240. package/src/api/routes/tests/static.spec.js +0 -98
  241. package/src/integrations/googlesheets.ts +0 -353
  242. package/src/migrations/tests/usageQuotas/index.spec.js +0 -27
  243. package/src/migrations/tests/usageQuotas/syncApps.spec.js +0 -37
  244. package/src/migrations/tests/usageQuotas/syncRows.spec.js +0 -43
  245. package/src/migrations/usageQuotas/index.js +0 -24
  246. package/src/migrations/usageQuotas/syncApps.js +0 -18
  247. package/src/migrations/usageQuotas/syncRows.js +0 -21
  248. package/src/utilities/tests/usageQuota/usageQuota.spec.js +0 -72
  249. package/src/utilities/usageQuota/index.js +0 -92
  250. package/src/utilities/usageQuota/rows.js +0 -74
  251. package/src/utilities/usageQuota/usageQuoteReset.js +0 -18
@@ -10,7 +10,6 @@ const airtable = require("./airtable");
10
10
  const mysql = require("./mysql");
11
11
  const arangodb = require("./arangodb");
12
12
  const rest = require("./rest");
13
- const googlesheets = require("./googlesheets");
14
13
  const { SourceNames } = require("../definitions/datasource");
15
14
  const DEFINITIONS = {
16
15
  [SourceNames.POSTGRES]: postgres.schema,
@@ -24,7 +23,6 @@ const DEFINITIONS = {
24
23
  [SourceNames.MYSQL]: mysql.schema,
25
24
  [SourceNames.ARANGODB]: arangodb.schema,
26
25
  [SourceNames.REST]: rest.schema,
27
- [SourceNames.GOOGLE_SHEETS]: googlesheets.schema,
28
26
  };
29
27
  const INTEGRATIONS = {
30
28
  [SourceNames.POSTGRES]: postgres.integration,
@@ -38,7 +36,6 @@ const INTEGRATIONS = {
38
36
  [SourceNames.MYSQL]: mysql.integration,
39
37
  [SourceNames.ARANGODB]: arangodb.integration,
40
38
  [SourceNames.REST]: rest.integration,
41
- [SourceNames.GOOGLE_SHEETS]: googlesheets.integration,
42
39
  };
43
40
  // optionally add oracle integration if the oracle binary can be installed
44
41
  if (!(process.arch === "arm64" && process.platform === "darwin")) {
@@ -125,12 +125,7 @@ function isSQL(datasource) {
125
125
  if (!datasource || !datasource.source) {
126
126
  return false;
127
127
  }
128
- const SQL = [
129
- datasource_1.SourceNames.POSTGRES,
130
- datasource_1.SourceNames.SQL_SERVER,
131
- datasource_1.SourceNames.MYSQL,
132
- datasource_1.SourceNames.ORACLE,
133
- ];
128
+ const SQL = [datasource_1.SourceNames.POSTGRES, datasource_1.SourceNames.SQL_SERVER, datasource_1.SourceNames.MYSQL];
134
129
  return SQL.indexOf(datasource.source) !== -1;
135
130
  }
136
131
  exports.isSQL = isSQL;
@@ -142,43 +137,8 @@ function isIsoDateString(str) {
142
137
  return d.toISOString() === str;
143
138
  }
144
139
  exports.isIsoDateString = isIsoDateString;
145
- /**
146
- * This function will determine whether a column is a relationship and whether it
147
- * is currently valid. The reason for the validity check is that tables can be deleted
148
- * outside of Budibase control and if this is the case it will break Budibase relationships.
149
- * The tableIds is a list passed down from the main finalise tables function, which is
150
- * based on the tables that have just been fetched. This will only really be used on subsequent
151
- * fetches to the first one - if the user is periodically refreshing Budibase knowledge of tables.
152
- * @param column The column to check, to see if it is a valid relationship.
153
- * @param tableIds The IDs of the tables which currently exist.
154
- */
155
- function shouldCopyRelationship(column, tableIds) {
156
- return (column.type === constants_1.FieldTypes.LINK &&
157
- column.tableId &&
158
- tableIds.includes(column.tableId));
159
- }
160
- /**
161
- * Similar function to the shouldCopyRelationship function, but instead this looks for options and boolean
162
- * types. It is possible to switch a string -> options and a number -> boolean (and vice versus) need to make
163
- * sure that these get copied over when tables are fetched. Also checks whether they are still valid, if a
164
- * column has changed type in the external database then copying it over may not be possible.
165
- * @param column The column to check for options or boolean type.
166
- * @param fetchedColumn The fetched column to check for the type in the external database.
167
- */
168
- function shouldCopySpecialColumn(column, fetchedColumn) {
169
- return (column.type === constants_1.FieldTypes.OPTIONS ||
170
- ((!fetchedColumn || fetchedColumn.type === constants_1.FieldTypes.NUMBER) &&
171
- column.type === constants_1.FieldTypes.BOOLEAN));
172
- }
173
- /**
174
- * Looks for columns which need to be copied over into the new table definitions, like relationships
175
- * and options types.
176
- * @param tableName The name of the table which is being checked.
177
- * @param table The specific table which is being checked.
178
- * @param entities All the tables that existed before - the old table definitions.
179
- * @param tableIds The IDs of the tables which exist now, to check if anything has been removed.
180
- */
181
- function copyExistingPropsOver(tableName, table, entities, tableIds) {
140
+ // add the existing relationships from the entities if they exist, to prevent them from being overridden
141
+ function copyExistingPropsOver(tableName, table, entities) {
182
142
  if (entities && entities[tableName]) {
183
143
  if (entities[tableName].primaryDisplay) {
184
144
  table.primaryDisplay = entities[tableName].primaryDisplay;
@@ -188,28 +148,21 @@ function copyExistingPropsOver(tableName, table, entities, tableIds) {
188
148
  if (!existingTableSchema.hasOwnProperty(key)) {
189
149
  continue;
190
150
  }
191
- const column = existingTableSchema[key];
192
- if (shouldCopyRelationship(column, tableIds) ||
193
- shouldCopySpecialColumn(column, table.schema[key])) {
151
+ if (existingTableSchema[key].type === constants_1.FieldTypes.LINK ||
152
+ existingTableSchema[key].type === constants_1.FieldTypes.OPTIONS ||
153
+ existingTableSchema[key].type === constants_1.FieldTypes.ARRAY ||
154
+ ((!table.schema[key] || table.schema[key].type === constants_1.FieldTypes.NUMBER) &&
155
+ existingTableSchema[key].type === constants_1.FieldTypes.BOOLEAN)) {
194
156
  table.schema[key] = existingTableSchema[key];
195
157
  }
196
158
  }
197
159
  }
198
160
  return table;
199
161
  }
200
- /**
201
- * Look through the final table definitions to see if anything needs to be
202
- * copied over from the old and if any errors have occurred mark them so
203
- * that the user can be made aware.
204
- * @param tables The list of tables that have been retrieved from the external database.
205
- * @param entities The old list of tables, if there was any to look for definitions in.
206
- */
207
162
  function finaliseExternalTables(tables, entities) {
208
163
  const invalidColumns = Object.values(constants_1.InvalidColumns);
209
164
  let finalTables = {};
210
165
  const errors = {};
211
- // @ts-ignore
212
- const tableIds = Object.values(tables).map(table => table._id);
213
166
  for (let [name, table] of Object.entries(tables)) {
214
167
  const schemaFields = Object.keys(table.schema);
215
168
  // make sure every table has a key
@@ -222,7 +175,7 @@ function finaliseExternalTables(tables, entities) {
222
175
  continue;
223
176
  }
224
177
  // make sure all previous props have been added back
225
- finalTables[name] = copyExistingPropsOver(name, table, entities, tableIds);
178
+ finalTables[name] = copyExistingPropsOver(name, table, entities);
226
179
  }
227
180
  // sort the tables by name
228
181
  finalTables = Object.entries(finalTables)
@@ -10,9 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  const CouchDB = require("../db");
12
12
  const usageQuota = require("../utilities/usageQuota");
13
- const { getUniqueRows } = require("../utilities/usageQuota/rows");
13
+ const env = require("../environment");
14
+ const { getTenantId } = require("@budibase/backend-core/tenancy");
14
15
  const { isExternalTable, isRowId: isExternalRowId, } = require("../integrations/utils");
15
- const migration = require("../migrations/usageQuotas");
16
+ // tenants without limits
17
+ const EXCLUDED_TENANTS = ["bb", "default", "bbtest", "bbstaging"];
16
18
  // currently only counting new writes and deletes
17
19
  const METHOD_MAP = {
18
20
  POST: 1,
@@ -20,13 +22,13 @@ const METHOD_MAP = {
20
22
  };
21
23
  const DOMAIN_MAP = {
22
24
  rows: usageQuota.Properties.ROW,
23
- // upload: usageQuota.Properties.UPLOAD, // doesn't work yet
24
- // views: usageQuota.Properties.VIEW, // doesn't work yet
25
- // users: usageQuota.Properties.USER, // doesn't work yet
25
+ upload: usageQuota.Properties.UPLOAD,
26
+ views: usageQuota.Properties.VIEW,
27
+ users: usageQuota.Properties.USER,
26
28
  applications: usageQuota.Properties.APPS,
27
29
  // this will not be updated by endpoint calls
28
30
  // instead it will be updated by triggerInfo
29
- // automationRuns: usageQuota.Properties.AUTOMATION, // doesn't work yet
31
+ automationRuns: usageQuota.Properties.AUTOMATION,
30
32
  };
31
33
  function getProperty(url) {
32
34
  for (let domain of Object.keys(DOMAIN_MAP)) {
@@ -36,7 +38,9 @@ function getProperty(url) {
36
38
  }
37
39
  }
38
40
  module.exports = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
39
- if (!usageQuota.useQuotas()) {
41
+ const tenantId = getTenantId();
42
+ // if in development or a self hosted cloud usage quotas should not be executed
43
+ if (env.isDev() || env.SELF_HOSTED || EXCLUDED_TENANTS.includes(tenantId)) {
40
44
  return next();
41
45
  }
42
46
  let usage = METHOD_MAP[ctx.req.method];
@@ -74,83 +78,10 @@ module.exports = (ctx, next) => __awaiter(void 0, void 0, void 0, function* () {
74
78
  usage = files.map(file => file.size).reduce((total, size) => total + size);
75
79
  }
76
80
  try {
77
- yield migration.run();
78
- yield performRequest(ctx, next, property, usage);
81
+ yield usageQuota.update(property, usage);
82
+ return next();
79
83
  }
80
84
  catch (err) {
81
85
  ctx.throw(400, err);
82
86
  }
83
87
  });
84
- const performRequest = (ctx, next, property, usage) => __awaiter(void 0, void 0, void 0, function* () {
85
- const usageContext = {
86
- skipNext: false,
87
- skipUsage: false,
88
- [usageQuota.Properties.APPS]: {},
89
- };
90
- if (usage === -1) {
91
- if (PRE_DELETE[property]) {
92
- yield PRE_DELETE[property](ctx, usageContext);
93
- }
94
- }
95
- else {
96
- if (PRE_CREATE[property]) {
97
- yield PRE_CREATE[property](ctx, usageContext);
98
- }
99
- }
100
- // run the request
101
- if (!usageContext.skipNext) {
102
- yield usageQuota.update(property, usage, { dryRun: true });
103
- yield next();
104
- }
105
- if (usage === -1) {
106
- if (POST_DELETE[property]) {
107
- yield POST_DELETE[property](ctx, usageContext);
108
- }
109
- }
110
- else {
111
- if (POST_CREATE[property]) {
112
- yield POST_CREATE[property](ctx, usageContext);
113
- }
114
- }
115
- // update the usage
116
- if (!usageContext.skipUsage) {
117
- yield usageQuota.update(property, usage);
118
- }
119
- });
120
- const appPreDelete = (ctx, usageContext) => __awaiter(void 0, void 0, void 0, function* () {
121
- if (ctx.query.unpublish) {
122
- // don't run usage decrement for unpublish
123
- usageContext.skipUsage = true;
124
- return;
125
- }
126
- // store the row count to delete
127
- const rows = yield getUniqueRows([ctx.appId]);
128
- if (rows.length) {
129
- usageContext[usageQuota.Properties.APPS] = { rowCount: rows.length };
130
- }
131
- });
132
- const appPostDelete = (ctx, usageContext) => __awaiter(void 0, void 0, void 0, function* () {
133
- // delete the app rows from usage
134
- const rowCount = usageContext[usageQuota.Properties.APPS].rowCount;
135
- if (rowCount) {
136
- yield usageQuota.update(usageQuota.Properties.ROW, -rowCount);
137
- }
138
- });
139
- const appPostCreate = (ctx) => __awaiter(void 0, void 0, void 0, function* () {
140
- // app import & template creation
141
- if (ctx.request.body.useTemplate === "true") {
142
- const rows = yield getUniqueRows([ctx.response.body.appId]);
143
- const rowCount = rows ? rows.length : 0;
144
- yield usageQuota.update(usageQuota.Properties.ROW, rowCount);
145
- }
146
- });
147
- const PRE_DELETE = {
148
- [usageQuota.Properties.APPS]: appPreDelete,
149
- };
150
- const POST_DELETE = {
151
- [usageQuota.Properties.APPS]: appPostDelete,
152
- };
153
- const PRE_CREATE = {};
154
- const POST_CREATE = {
155
- [usageQuota.Properties.APPS]: appPostCreate,
156
- };
package/dist/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/server",
3
3
  "email": "hi@budibase.com",
4
- "version": "1.0.46-alpha.6",
4
+ "version": "1.0.47",
5
5
  "description": "Budibase Web Server",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -70,9 +70,9 @@
70
70
  "license": "GPL-3.0",
71
71
  "dependencies": {
72
72
  "@apidevtools/swagger-parser": "^10.0.3",
73
- "@budibase/backend-core": "^1.0.46-alpha.6",
74
- "@budibase/client": "^1.0.46-alpha.6",
75
- "@budibase/string-templates": "^1.0.46-alpha.6",
73
+ "@budibase/backend-core": "^1.0.47",
74
+ "@budibase/client": "^1.0.47",
75
+ "@budibase/string-templates": "^1.0.47",
76
76
  "@bull-board/api": "^3.7.0",
77
77
  "@bull-board/koa": "^3.7.0",
78
78
  "@elastic/elasticsearch": "7.10.0",
@@ -92,8 +92,6 @@
92
92
  "fix-path": "3.0.0",
93
93
  "form-data": "^4.0.0",
94
94
  "fs-extra": "8.1.0",
95
- "google-auth-library": "^7.11.0",
96
- "google-spreadsheet": "^3.2.0",
97
95
  "jimp": "0.16.1",
98
96
  "joi": "17.2.1",
99
97
  "js-yaml": "^4.1.0",
@@ -112,7 +110,7 @@
112
110
  "mongodb": "3.6.3",
113
111
  "mssql": "6.2.3",
114
112
  "mysql2": "^2.3.1",
115
- "node-fetch": "2.6.7",
113
+ "node-fetch": "2.6.0",
116
114
  "open": "^8.4.0",
117
115
  "pg": "8.5.1",
118
116
  "pino-pretty": "4.0.0",
@@ -141,7 +139,6 @@
141
139
  "@jest/test-sequencer": "^24.8.0",
142
140
  "@types/apidoc": "^0.50.0",
143
141
  "@types/bull": "^3.15.1",
144
- "@types/google-spreadsheet": "^3.1.5",
145
142
  "@types/jest": "^26.0.23",
146
143
  "@types/koa": "^2.13.3",
147
144
  "@types/koa-router": "^7.4.2",
@@ -21,7 +21,6 @@ const { getGlobalDB } = require("@budibase/backend-core/tenancy");
21
21
  const { createASession } = require("@budibase/backend-core/sessions");
22
22
  const { user: userCache } = require("@budibase/backend-core/cache");
23
23
  const CouchDB = require("../../db");
24
- const newid = require("../../db/newid");
25
24
  core.init(CouchDB);
26
25
  const GLOBAL_USER_ID = "us_uuid1";
27
26
  const EMAIL = "babs@babs.com";
@@ -84,8 +83,7 @@ class TestConfiguration {
84
83
  return Object.assign({ _rev: resp._rev }, user);
85
84
  });
86
85
  }
87
- // use a new id as the name to avoid name collisions
88
- init(appName = newid()) {
86
+ init(appName = "test_application") {
89
87
  return __awaiter(this, void 0, void 0, function* () {
90
88
  yield this.globalUser();
91
89
  return this.createApp(appName);
@@ -75,10 +75,6 @@ class QueryRunner {
75
75
  yield threadUtils.invalidateDynamicVariables(this.cachedVariables);
76
76
  return this.execute();
77
77
  }
78
- // check for undefined response
79
- if (!rows) {
80
- rows = [];
81
- }
82
78
  // needs to an array for next step
83
79
  if (!Array.isArray(rows)) {
84
80
  rows = [rows];