@budibase/server 1.2.35 → 1.2.38

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 (268) hide show
  1. package/builder/assets/{index.05962580.js → index.47bfb9a6.js} +48 -48
  2. package/builder/index.html +1 -1
  3. package/coverage/clover.xml +2 -2
  4. package/coverage/coverage-final.json +13 -13
  5. package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
  6. package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
  7. package/coverage/lcov-report/api/controllers/automation.js.html +3 -3
  8. package/coverage/lcov-report/api/controllers/backup.js.html +3 -3
  9. package/coverage/lcov-report/api/controllers/cloud.js.html +4 -4
  10. package/coverage/lcov-report/api/controllers/component.js.html +3 -3
  11. package/coverage/lcov-report/api/controllers/datasource.js.html +3 -3
  12. package/coverage/lcov-report/api/controllers/dev.js.html +4 -4
  13. package/coverage/lcov-report/api/controllers/index.html +1 -1
  14. package/coverage/lcov-report/api/controllers/integration.js.html +3 -3
  15. package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
  16. package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
  17. package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
  18. package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
  19. package/coverage/lcov-report/api/controllers/query/index.html +1 -1
  20. package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
  21. package/coverage/lcov-report/api/controllers/role.js.html +1 -1
  22. package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
  23. package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
  24. package/coverage/lcov-report/api/controllers/row/index.html +1 -1
  25. package/coverage/lcov-report/api/controllers/row/internal.js.html +3 -3
  26. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
  27. package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
  28. package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
  29. package/coverage/lcov-report/api/controllers/screen.js.html +1 -1
  30. package/coverage/lcov-report/api/controllers/script.js.html +1 -1
  31. package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +1 -1
  32. package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
  33. package/coverage/lcov-report/api/controllers/table/index.html +1 -1
  34. package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
  35. package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
  36. package/coverage/lcov-report/api/controllers/user.js.html +1 -1
  37. package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
  38. package/coverage/lcov-report/api/controllers/view/index.html +1 -1
  39. package/coverage/lcov-report/api/controllers/view/index.js.html +3 -3
  40. package/coverage/lcov-report/api/controllers/view/utils.js.html +5 -5
  41. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
  42. package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
  43. package/coverage/lcov-report/api/index.html +1 -1
  44. package/coverage/lcov-report/api/index.js.html +1 -1
  45. package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
  46. package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
  47. package/coverage/lcov-report/api/routes/auth.js.html +1 -1
  48. package/coverage/lcov-report/api/routes/automation.js.html +1 -1
  49. package/coverage/lcov-report/api/routes/backup.js.html +1 -1
  50. package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
  51. package/coverage/lcov-report/api/routes/component.js.html +1 -1
  52. package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
  53. package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
  54. package/coverage/lcov-report/api/routes/dev.js.html +1 -1
  55. package/coverage/lcov-report/api/routes/index.html +1 -1
  56. package/coverage/lcov-report/api/routes/integration.js.html +1 -1
  57. package/coverage/lcov-report/api/routes/layout.js.html +1 -1
  58. package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
  59. package/coverage/lcov-report/api/routes/migrations.js.html +1 -1
  60. package/coverage/lcov-report/api/routes/permission.js.html +1 -1
  61. package/coverage/lcov-report/api/routes/query.js.html +1 -1
  62. package/coverage/lcov-report/api/routes/role.js.html +1 -1
  63. package/coverage/lcov-report/api/routes/routing.js.html +1 -1
  64. package/coverage/lcov-report/api/routes/screen.js.html +1 -1
  65. package/coverage/lcov-report/api/routes/script.js.html +1 -1
  66. package/coverage/lcov-report/api/routes/table.js.html +1 -1
  67. package/coverage/lcov-report/api/routes/templates.js.html +1 -1
  68. package/coverage/lcov-report/api/routes/user.js.html +1 -1
  69. package/coverage/lcov-report/api/routes/utils/index.html +1 -1
  70. package/coverage/lcov-report/api/routes/utils/validators.js.html +1 -1
  71. package/coverage/lcov-report/api/routes/view.js.html +1 -1
  72. package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
  73. package/coverage/lcov-report/automations/actions.js.html +1 -1
  74. package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
  75. package/coverage/lcov-report/automations/bullboard.js.html +1 -1
  76. package/coverage/lcov-report/automations/index.html +1 -1
  77. package/coverage/lcov-report/automations/index.js.html +1 -1
  78. package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
  79. package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
  80. package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
  81. package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
  82. package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
  83. package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
  84. package/coverage/lcov-report/automations/steps/index.html +1 -1
  85. package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
  86. package/coverage/lcov-report/automations/steps/loop.js.html +1 -1
  87. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
  88. package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
  89. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
  90. package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
  91. package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
  92. package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
  93. package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
  94. package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
  95. package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
  96. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
  97. package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
  98. package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
  99. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
  100. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
  101. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
  102. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
  103. package/coverage/lcov-report/automations/triggers.js.html +1 -1
  104. package/coverage/lcov-report/constants/index.html +1 -1
  105. package/coverage/lcov-report/constants/index.js.html +1 -1
  106. package/coverage/lcov-report/constants/layouts.js.html +1 -1
  107. package/coverage/lcov-report/constants/screens.js.html +1 -1
  108. package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
  109. package/coverage/lcov-report/db/index.html +1 -1
  110. package/coverage/lcov-report/db/index.js.html +1 -1
  111. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
  112. package/coverage/lcov-report/db/linkedRows/index.html +1 -1
  113. package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
  114. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +3 -3
  115. package/coverage/lcov-report/db/newid.js.html +1 -1
  116. package/coverage/lcov-report/db/utils.js.html +39 -39
  117. package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
  118. package/coverage/lcov-report/events/index.html +1 -1
  119. package/coverage/lcov-report/events/index.js.html +1 -1
  120. package/coverage/lcov-report/events/utils.js.html +1 -1
  121. package/coverage/lcov-report/index.html +1 -1
  122. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
  123. package/coverage/lcov-report/integrations/tests/index.html +1 -1
  124. package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
  125. package/coverage/lcov-report/middleware/builder.js.html +3 -3
  126. package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
  127. package/coverage/lcov-report/middleware/index.html +1 -1
  128. package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
  129. package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
  130. package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
  131. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  132. package/coverage/lcov-report/middleware/utils.js.html +1 -1
  133. package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
  134. package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
  135. package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
  136. package/coverage/lcov-report/utilities/global.js.html +1 -1
  137. package/coverage/lcov-report/utilities/index.html +1 -1
  138. package/coverage/lcov-report/utilities/index.js.html +1 -1
  139. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +1 -1
  140. package/coverage/lcov-report/utilities/queue/index.html +1 -1
  141. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  142. package/coverage/lcov-report/utilities/routing/index.js.html +3 -3
  143. package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
  144. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
  145. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
  146. package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
  147. package/coverage/lcov-report/utilities/security.js.html +9 -9
  148. package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
  149. package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
  150. package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
  151. package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
  152. package/coverage/lcov-report/utilities/users.js.html +1 -1
  153. package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
  154. package/dist/api/controllers/analytics.js +1 -1
  155. package/dist/api/controllers/application.js +8 -8
  156. package/dist/api/controllers/automation.js +2 -2
  157. package/dist/api/controllers/backup.js +2 -2
  158. package/dist/api/controllers/cloud.js +3 -3
  159. package/dist/api/controllers/component.js +2 -2
  160. package/dist/api/controllers/datasource.js +2 -2
  161. package/dist/api/controllers/deploy/index.js +6 -6
  162. package/dist/api/controllers/dev.js +3 -3
  163. package/dist/api/controllers/integration.js +2 -2
  164. package/dist/api/controllers/public/utils.js +1 -1
  165. package/dist/api/controllers/row/ExternalRequest.js +3 -3
  166. package/dist/api/controllers/row/internal.js +2 -2
  167. package/dist/api/controllers/static/index.js +2 -2
  168. package/dist/api/controllers/view/index.js +2 -2
  169. package/dist/api/controllers/view/utils.js +3 -3
  170. package/dist/db/linkedRows/linkUtils.js +2 -2
  171. package/dist/db/utils.js +37 -37
  172. package/dist/db/views/staticViews.js +4 -4
  173. package/dist/definitions/automations.js +6 -6
  174. package/dist/definitions/datasource.js +6 -70
  175. package/dist/integrations/airtable.js +13 -13
  176. package/dist/integrations/arangodb.js +8 -8
  177. package/dist/integrations/base/sql.js +28 -28
  178. package/dist/integrations/base/sqlTable.js +4 -4
  179. package/dist/integrations/couchdb.js +8 -8
  180. package/dist/integrations/dynamodb.js +21 -21
  181. package/dist/integrations/elasticsearch.js +12 -12
  182. package/dist/integrations/firebase.js +12 -12
  183. package/dist/integrations/googlesheets.js +14 -14
  184. package/dist/integrations/index.js +34 -34
  185. package/dist/integrations/microsoftSqlServer.js +14 -14
  186. package/dist/integrations/mongodb.js +9 -9
  187. package/dist/integrations/mysql.js +13 -13
  188. package/dist/integrations/oracle.js +13 -13
  189. package/dist/integrations/postgres.js +15 -15
  190. package/dist/integrations/redis.js +10 -10
  191. package/dist/integrations/rest.js +15 -14
  192. package/dist/integrations/s3.js +2 -2
  193. package/dist/integrations/snowflake.js +5 -5
  194. package/dist/integrations/utils.js +14 -14
  195. package/dist/middleware/builder.js +2 -2
  196. package/dist/migrations/functions/appUrls.js +2 -2
  197. package/dist/migrations/functions/backfill/app/queries.js +3 -1
  198. package/dist/migrations/functions/backfill/app.js +1 -1
  199. package/dist/migrations/functions/backfill/global/users.js +1 -1
  200. package/dist/package.json +6 -6
  201. package/dist/tests/utilities/TestConfiguration.js +2 -2
  202. package/dist/threads/automation.js +2 -2
  203. package/dist/tsconfig.build.tsbuildinfo +1 -1
  204. package/dist/utilities/routing/index.js +2 -2
  205. package/dist/utilities/security.js +8 -8
  206. package/package.json +7 -7
  207. package/src/api/controllers/analytics.ts +2 -2
  208. package/src/api/controllers/application.ts +9 -9
  209. package/src/api/controllers/automation.js +2 -2
  210. package/src/api/controllers/backup.js +2 -2
  211. package/src/api/controllers/cloud.js +3 -3
  212. package/src/api/controllers/component.js +2 -2
  213. package/src/api/controllers/datasource.js +2 -2
  214. package/src/api/controllers/deploy/index.ts +7 -7
  215. package/src/api/controllers/dev.js +3 -3
  216. package/src/api/controllers/integration.js +2 -2
  217. package/src/api/controllers/public/utils.ts +2 -2
  218. package/src/api/controllers/query/import/sources/openapi2.ts +1 -1
  219. package/src/api/controllers/query/import/sources/openapi3.ts +1 -1
  220. package/src/api/controllers/row/ExternalRequest.ts +5 -7
  221. package/src/api/controllers/row/internal.js +2 -2
  222. package/src/api/controllers/static/index.ts +2 -2
  223. package/src/api/controllers/view/index.js +2 -2
  224. package/src/api/controllers/view/utils.js +4 -4
  225. package/src/db/linkedRows/linkUtils.js +2 -2
  226. package/src/db/utils.js +38 -38
  227. package/src/db/views/staticViews.js +4 -9
  228. package/src/definitions/automations.ts +2 -2
  229. package/src/definitions/common.ts +14 -65
  230. package/src/definitions/datasource.ts +5 -250
  231. package/src/integrations/airtable.ts +16 -16
  232. package/src/integrations/arangodb.ts +11 -11
  233. package/src/integrations/base/sql.ts +16 -16
  234. package/src/integrations/base/sqlTable.ts +1 -6
  235. package/src/integrations/base/utils.ts +1 -2
  236. package/src/integrations/couchdb.ts +11 -11
  237. package/src/integrations/dynamodb.ts +24 -24
  238. package/src/integrations/elasticsearch.ts +15 -15
  239. package/src/integrations/firebase.ts +15 -15
  240. package/src/integrations/googlesheets.ts +19 -18
  241. package/src/integrations/index.ts +34 -34
  242. package/src/integrations/microsoftSqlServer.ts +19 -18
  243. package/src/integrations/mongodb.ts +12 -12
  244. package/src/integrations/mysql.ts +19 -18
  245. package/src/integrations/oracle.ts +16 -16
  246. package/src/integrations/postgres.ts +20 -20
  247. package/src/integrations/queries/sql.ts +1 -2
  248. package/src/integrations/redis.ts +10 -14
  249. package/src/integrations/rest.ts +22 -20
  250. package/src/integrations/s3.ts +2 -3
  251. package/src/integrations/snowflake.ts +5 -5
  252. package/src/integrations/tests/sql.spec.js +7 -7
  253. package/src/integrations/utils.ts +8 -9
  254. package/src/middleware/builder.js +2 -2
  255. package/src/migrations/functions/appUrls.ts +2 -2
  256. package/src/migrations/functions/backfill/app/queries.ts +3 -2
  257. package/src/migrations/functions/backfill/app.ts +1 -1
  258. package/src/migrations/functions/backfill/global/users.ts +1 -1
  259. package/src/migrations/functions/tests/appUrls.spec.js +3 -3
  260. package/src/migrations/tests/index.spec.ts +2 -2
  261. package/src/tests/utilities/TestConfiguration.js +2 -2
  262. package/src/threads/automation.ts +3 -3
  263. package/src/utilities/routing/index.js +2 -2
  264. package/src/utilities/security.js +8 -8
  265. package/dist/integrations/base/IntegrationBase.js +0 -2
  266. package/dist/integrations/base/datasourcePlus.js +0 -2
  267. package/src/integrations/base/IntegrationBase.ts +0 -6
  268. package/src/integrations/base/datasourcePlus.ts +0 -13
package/src/db/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const newid = require("./newid")
2
2
  const {
3
- DocumentTypes: CoreDocTypes,
3
+ DocumentType: CoreDocTypes,
4
4
  getRoleParams,
5
5
  generateRoleID,
6
6
  APP_DEV_PREFIX,
@@ -12,7 +12,7 @@ const {
12
12
  getDevelopmentAppID,
13
13
  generateAppID,
14
14
  getQueryIndex,
15
- ViewNames,
15
+ ViewName,
16
16
  } = require("@budibase/backend-core/db")
17
17
 
18
18
  const UNICODE_MAX = "\ufff0"
@@ -23,7 +23,7 @@ const AppStatus = {
23
23
  DEPLOYED: "published",
24
24
  }
25
25
 
26
- const DocumentTypes = {
26
+ const DocumentType = {
27
27
  ...CoreDocTypes,
28
28
  TABLE: "ta",
29
29
  ROW: "ro",
@@ -66,12 +66,12 @@ exports.APP_PREFIX = APP_PREFIX
66
66
  exports.APP_DEV_PREFIX = APP_DEV_PREFIX
67
67
  exports.isDevAppID = isDevAppID
68
68
  exports.isProdAppID = isProdAppID
69
- exports.USER_METDATA_PREFIX = `${DocumentTypes.ROW}${SEPARATOR}${InternalTables.USER_METADATA}${SEPARATOR}`
70
- exports.LINK_USER_METADATA_PREFIX = `${DocumentTypes.LINK}${SEPARATOR}${InternalTables.USER_METADATA}${SEPARATOR}`
71
- exports.TABLE_ROW_PREFIX = `${DocumentTypes.ROW}${SEPARATOR}${DocumentTypes.TABLE}`
72
- exports.ViewNames = ViewNames
69
+ exports.USER_METDATA_PREFIX = `${DocumentType.ROW}${SEPARATOR}${InternalTables.USER_METADATA}${SEPARATOR}`
70
+ exports.LINK_USER_METADATA_PREFIX = `${DocumentType.LINK}${SEPARATOR}${InternalTables.USER_METADATA}${SEPARATOR}`
71
+ exports.TABLE_ROW_PREFIX = `${DocumentType.ROW}${SEPARATOR}${DocumentType.TABLE}`
72
+ exports.ViewName = ViewName
73
73
  exports.InternalTables = InternalTables
74
- exports.DocumentTypes = DocumentTypes
74
+ exports.DocumentType = DocumentType
75
75
  exports.SEPARATOR = SEPARATOR
76
76
  exports.UNICODE_MAX = UNICODE_MAX
77
77
  exports.SearchIndexes = SearchIndexes
@@ -114,7 +114,7 @@ exports.getDocParams = getDocParams
114
114
  * Gets parameters for retrieving tables, this is a utility function for the getDocParams function.
115
115
  */
116
116
  exports.getTableParams = (tableId = null, otherProps = {}) => {
117
- return getDocParams(DocumentTypes.TABLE, tableId, otherProps)
117
+ return getDocParams(DocumentType.TABLE, tableId, otherProps)
118
118
  }
119
119
 
120
120
  /**
@@ -122,7 +122,7 @@ exports.getTableParams = (tableId = null, otherProps = {}) => {
122
122
  * @returns {string} The new table ID which the table doc can be stored under.
123
123
  */
124
124
  exports.generateTableID = () => {
125
- return `${DocumentTypes.TABLE}${SEPARATOR}${newid()}`
125
+ return `${DocumentType.TABLE}${SEPARATOR}${newid()}`
126
126
  }
127
127
 
128
128
  /**
@@ -135,12 +135,12 @@ exports.generateTableID = () => {
135
135
  */
136
136
  exports.getRowParams = (tableId = null, rowId = null, otherProps = {}) => {
137
137
  if (tableId == null) {
138
- return getDocParams(DocumentTypes.ROW, null, otherProps)
138
+ return getDocParams(DocumentType.ROW, null, otherProps)
139
139
  }
140
140
 
141
141
  const endOfKey = rowId == null ? `${tableId}${SEPARATOR}` : rowId
142
142
 
143
- return getDocParams(DocumentTypes.ROW, endOfKey, otherProps)
143
+ return getDocParams(DocumentType.ROW, endOfKey, otherProps)
144
144
  }
145
145
 
146
146
  /**
@@ -150,9 +150,9 @@ exports.getRowParams = (tableId = null, rowId = null, otherProps = {}) => {
150
150
  */
151
151
  exports.getTableIDFromRowID = rowId => {
152
152
  const components = rowId
153
- .split(DocumentTypes.TABLE + SEPARATOR)[1]
153
+ .split(DocumentType.TABLE + SEPARATOR)[1]
154
154
  .split(SEPARATOR)
155
- return `${DocumentTypes.TABLE}${SEPARATOR}${components[0]}`
155
+ return `${DocumentType.TABLE}${SEPARATOR}${components[0]}`
156
156
  }
157
157
 
158
158
  /**
@@ -163,7 +163,7 @@ exports.getTableIDFromRowID = rowId => {
163
163
  */
164
164
  exports.generateRowID = (tableId, id = null) => {
165
165
  id = id || newid()
166
- return `${DocumentTypes.ROW}${SEPARATOR}${tableId}${SEPARATOR}${id}`
166
+ return `${DocumentType.ROW}${SEPARATOR}${tableId}${SEPARATOR}${id}`
167
167
  }
168
168
 
169
169
  /**
@@ -186,7 +186,7 @@ exports.generateUserMetadataID = globalId => {
186
186
  * Breaks up the ID to get the global ID.
187
187
  */
188
188
  exports.getGlobalIDFromUserMetadataID = id => {
189
- const prefix = `${DocumentTypes.ROW}${SEPARATOR}${InternalTables.USER_METADATA}${SEPARATOR}`
189
+ const prefix = `${DocumentType.ROW}${SEPARATOR}${InternalTables.USER_METADATA}${SEPARATOR}`
190
190
  if (!id || !id.includes(prefix)) {
191
191
  return id
192
192
  }
@@ -197,7 +197,7 @@ exports.getGlobalIDFromUserMetadataID = id => {
197
197
  * Gets parameters for retrieving automations, this is a utility function for the getDocParams function.
198
198
  */
199
199
  exports.getAutomationParams = (automationId = null, otherProps = {}) => {
200
- return getDocParams(DocumentTypes.AUTOMATION, automationId, otherProps)
200
+ return getDocParams(DocumentType.AUTOMATION, automationId, otherProps)
201
201
  }
202
202
 
203
203
  /**
@@ -205,7 +205,7 @@ exports.getAutomationParams = (automationId = null, otherProps = {}) => {
205
205
  * @returns {string} The new automation ID which the automation doc can be stored under.
206
206
  */
207
207
  exports.generateAutomationID = () => {
208
- return `${DocumentTypes.AUTOMATION}${SEPARATOR}${newid()}`
208
+ return `${DocumentType.AUTOMATION}${SEPARATOR}${newid()}`
209
209
  }
210
210
 
211
211
  /**
@@ -230,14 +230,14 @@ exports.generateLinkID = (
230
230
  const tables = `${SEPARATOR}${tableId1}${SEPARATOR}${tableId2}`
231
231
  const rows = `${SEPARATOR}${rowId1}${SEPARATOR}${rowId2}`
232
232
  const fields = `${SEPARATOR}${fieldName1}${SEPARATOR}${fieldName2}`
233
- return `${DocumentTypes.LINK}${tables}${rows}${fields}`
233
+ return `${DocumentType.LINK}${tables}${rows}${fields}`
234
234
  }
235
235
 
236
236
  /**
237
237
  * Gets parameters for retrieving link docs, this is a utility function for the getDocParams function.
238
238
  */
239
239
  exports.getLinkParams = (otherProps = {}) => {
240
- return getDocParams(DocumentTypes.LINK, null, otherProps)
240
+ return getDocParams(DocumentType.LINK, null, otherProps)
241
241
  }
242
242
 
243
243
  /**
@@ -245,14 +245,14 @@ exports.getLinkParams = (otherProps = {}) => {
245
245
  * @returns {string} The new layout ID which the layout doc can be stored under.
246
246
  */
247
247
  exports.generateLayoutID = id => {
248
- return `${DocumentTypes.LAYOUT}${SEPARATOR}${id || newid()}`
248
+ return `${DocumentType.LAYOUT}${SEPARATOR}${id || newid()}`
249
249
  }
250
250
 
251
251
  /**
252
252
  * Gets parameters for retrieving layout, this is a utility function for the getDocParams function.
253
253
  */
254
254
  exports.getLayoutParams = (layoutId = null, otherProps = {}) => {
255
- return getDocParams(DocumentTypes.LAYOUT, layoutId, otherProps)
255
+ return getDocParams(DocumentType.LAYOUT, layoutId, otherProps)
256
256
  }
257
257
 
258
258
  /**
@@ -260,14 +260,14 @@ exports.getLayoutParams = (layoutId = null, otherProps = {}) => {
260
260
  * @returns {string} The new screen ID which the screen doc can be stored under.
261
261
  */
262
262
  exports.generateScreenID = () => {
263
- return `${DocumentTypes.SCREEN}${SEPARATOR}${newid()}`
263
+ return `${DocumentType.SCREEN}${SEPARATOR}${newid()}`
264
264
  }
265
265
 
266
266
  /**
267
267
  * Gets parameters for retrieving screens, this is a utility function for the getDocParams function.
268
268
  */
269
269
  exports.getScreenParams = (screenId = null, otherProps = {}) => {
270
- return getDocParams(DocumentTypes.SCREEN, screenId, otherProps)
270
+ return getDocParams(DocumentType.SCREEN, screenId, otherProps)
271
271
  }
272
272
 
273
273
  /**
@@ -275,14 +275,14 @@ exports.getScreenParams = (screenId = null, otherProps = {}) => {
275
275
  * @returns {string} The new webhook ID which the webhook doc can be stored under.
276
276
  */
277
277
  exports.generateWebhookID = () => {
278
- return `${DocumentTypes.WEBHOOK}${SEPARATOR}${newid()}`
278
+ return `${DocumentType.WEBHOOK}${SEPARATOR}${newid()}`
279
279
  }
280
280
 
281
281
  /**
282
282
  * Gets parameters for retrieving a webhook, this is a utility function for the getDocParams function.
283
283
  */
284
284
  exports.getWebhookParams = (webhookId = null, otherProps = {}) => {
285
- return getDocParams(DocumentTypes.WEBHOOK, webhookId, otherProps)
285
+ return getDocParams(DocumentType.WEBHOOK, webhookId, otherProps)
286
286
  }
287
287
 
288
288
  /**
@@ -291,7 +291,7 @@ exports.getWebhookParams = (webhookId = null, otherProps = {}) => {
291
291
  */
292
292
  exports.generateDatasourceID = ({ plus = false } = {}) => {
293
293
  return `${
294
- plus ? DocumentTypes.DATASOURCE_PLUS : DocumentTypes.DATASOURCE
294
+ plus ? DocumentType.DATASOURCE_PLUS : DocumentType.DATASOURCE
295
295
  }${SEPARATOR}${newid()}`
296
296
  }
297
297
 
@@ -299,7 +299,7 @@ exports.generateDatasourceID = ({ plus = false } = {}) => {
299
299
  * Gets parameters for retrieving a datasource, this is a utility function for the getDocParams function.
300
300
  */
301
301
  exports.getDatasourceParams = (datasourceId = null, otherProps = {}) => {
302
- return getDocParams(DocumentTypes.DATASOURCE, datasourceId, otherProps)
302
+ return getDocParams(DocumentType.DATASOURCE, datasourceId, otherProps)
303
303
  }
304
304
 
305
305
  /**
@@ -308,7 +308,7 @@ exports.getDatasourceParams = (datasourceId = null, otherProps = {}) => {
308
308
  */
309
309
  exports.generateQueryID = datasourceId => {
310
310
  return `${
311
- DocumentTypes.QUERY
311
+ DocumentType.QUERY
312
312
  }${SEPARATOR}${datasourceId}${SEPARATOR}${newid()}`
313
313
  }
314
314
 
@@ -317,14 +317,14 @@ exports.generateQueryID = datasourceId => {
317
317
  * automations etc.
318
318
  */
319
319
  exports.generateAutomationMetadataID = automationId => {
320
- return `${DocumentTypes.AUTOMATION_METADATA}${SEPARATOR}${automationId}`
320
+ return `${DocumentType.AUTOMATION_METADATA}${SEPARATOR}${automationId}`
321
321
  }
322
322
 
323
323
  /**
324
324
  * Retrieve all automation metadata in an app database.
325
325
  */
326
326
  exports.getAutomationMetadataParams = (otherProps = {}) => {
327
- return getDocParams(DocumentTypes.AUTOMATION_METADATA, null, otherProps)
327
+ return getDocParams(DocumentType.AUTOMATION_METADATA, null, otherProps)
328
328
  }
329
329
 
330
330
  /**
@@ -332,11 +332,11 @@ exports.getAutomationMetadataParams = (otherProps = {}) => {
332
332
  */
333
333
  exports.getQueryParams = (datasourceId = null, otherProps = {}) => {
334
334
  if (datasourceId == null) {
335
- return getDocParams(DocumentTypes.QUERY, null, otherProps)
335
+ return getDocParams(DocumentType.QUERY, null, otherProps)
336
336
  }
337
337
 
338
338
  return getDocParams(
339
- DocumentTypes.QUERY,
339
+ DocumentType.QUERY,
340
340
  `${datasourceId}${SEPARATOR}`,
341
341
  otherProps
342
342
  )
@@ -347,11 +347,11 @@ exports.getQueryParams = (datasourceId = null, otherProps = {}) => {
347
347
  * @returns {string} The ID of the flag document that was generated.
348
348
  */
349
349
  exports.generateUserFlagID = userId => {
350
- return `${DocumentTypes.USER_FLAG}${SEPARATOR}${userId}`
350
+ return `${DocumentType.USER_FLAG}${SEPARATOR}${userId}`
351
351
  }
352
352
 
353
353
  exports.generateMetadataID = (type, entityId) => {
354
- return `${DocumentTypes.METADATA}${SEPARATOR}${type}${SEPARATOR}${entityId}`
354
+ return `${DocumentType.METADATA}${SEPARATOR}${type}${SEPARATOR}${entityId}`
355
355
  }
356
356
 
357
357
  exports.getMetadataParams = (type, entityId = null, otherProps = {}) => {
@@ -359,15 +359,15 @@ exports.getMetadataParams = (type, entityId = null, otherProps = {}) => {
359
359
  if (entityId != null) {
360
360
  docId += entityId
361
361
  }
362
- return getDocParams(DocumentTypes.METADATA, docId, otherProps)
362
+ return getDocParams(DocumentType.METADATA, docId, otherProps)
363
363
  }
364
364
 
365
365
  exports.generateMemoryViewID = viewName => {
366
- return `${DocumentTypes.MEM_VIEW}${SEPARATOR}${viewName}`
366
+ return `${DocumentType.MEM_VIEW}${SEPARATOR}${viewName}`
367
367
  }
368
368
 
369
369
  exports.getMemoryViewParams = (otherProps = {}) => {
370
- return getDocParams(DocumentTypes.MEM_VIEW, null, otherProps)
370
+ return getDocParams(DocumentType.MEM_VIEW, null, otherProps)
371
371
  }
372
372
 
373
373
  /**
@@ -1,11 +1,6 @@
1
1
  const { getAppDB } = require("@budibase/backend-core/context")
2
- const {
3
- DocumentTypes,
4
- SEPARATOR,
5
- ViewNames,
6
- SearchIndexes,
7
- } = require("../utils")
8
- const SCREEN_PREFIX = DocumentTypes.SCREEN + SEPARATOR
2
+ const { DocumentType, SEPARATOR, ViewName, SearchIndexes } = require("../utils")
3
+ const SCREEN_PREFIX = DocumentType.SCREEN + SEPARATOR
9
4
 
10
5
  /**************************************************
11
6
  * INFORMATION *
@@ -53,7 +48,7 @@ exports.createLinkView = async () => {
53
48
  }
54
49
  designDoc.views = {
55
50
  ...designDoc.views,
56
- [ViewNames.LINK]: view,
51
+ [ViewName.LINK]: view,
57
52
  }
58
53
  await db.put(designDoc)
59
54
  }
@@ -74,7 +69,7 @@ exports.createRoutingView = async () => {
74
69
  }
75
70
  designDoc.views = {
76
71
  ...designDoc.views,
77
- [ViewNames.ROUTING]: view,
72
+ [ViewName.ROUTING]: view,
78
73
  }
79
74
  await db.put(designDoc)
80
75
  }
@@ -5,14 +5,14 @@ import {
5
5
  Document,
6
6
  } from "@budibase/types"
7
7
 
8
- export enum LoopStepTypes {
8
+ export enum LoopStepType {
9
9
  ARRAY = "Array",
10
10
  STRING = "String",
11
11
  }
12
12
 
13
13
  export interface LoopStep extends AutomationStep {
14
14
  inputs: {
15
- option: LoopStepTypes
15
+ option: LoopStepType
16
16
  [key: string]: any
17
17
  }
18
18
  }
@@ -1,70 +1,19 @@
1
- export { Query, Datasource } from "./datasource"
2
-
3
- export interface Base {
4
- _id?: string
5
- _rev?: string
6
- }
7
-
8
- export interface Application extends Base {
1
+ import { Document } from "@budibase/types"
2
+ export {
3
+ Query,
4
+ Datasource,
5
+ FieldSchema,
6
+ TableSchema,
7
+ Table,
8
+ Document,
9
+ Row,
10
+ } from "@budibase/types"
11
+
12
+ export interface Application extends Document {
13
+ _id: string
9
14
  appId?: string
10
15
  }
11
16
 
12
- export interface FieldSchema {
13
- // TODO: replace with field types enum when done
14
- type: string
15
- externalType?: string
16
- fieldName?: string
17
- name: string
18
- tableId?: string
19
- relationshipType?: string
20
- through?: string
21
- foreignKey?: string
22
- autocolumn?: boolean
23
- subtype?: string
24
- throughFrom?: string
25
- throughTo?: string
26
- formula?: string
27
- formulaType?: string
28
- main?: boolean
29
- ignoreTimezones?: boolean
30
- meta?: {
31
- toTable: string
32
- toKey: string
33
- }
34
- constraints?: {
35
- type?: string
36
- email?: boolean
37
- inclusion?: string[]
38
- length?: {
39
- minimum?: string | number
40
- maximum?: string | number
41
- }
42
- presence?: boolean
43
- }
44
- }
45
-
46
- export interface TableSchema {
47
- [key: string]: FieldSchema
48
- }
49
-
50
- export interface Table extends Base {
51
- type?: string
52
- views?: {}
53
- name: string
54
- primary?: string[]
55
- schema: TableSchema
56
- primaryDisplay?: string
57
- sourceId?: string
58
- relatedFormula?: string[]
59
- constrained?: string[]
60
- }
61
-
62
- export interface Row extends Base {
63
- type?: string
64
- tableId?: string
65
- [key: string]: any
66
- }
67
-
68
17
  interface JsonSchemaField {
69
18
  properties: {
70
19
  [key: string]: {
@@ -94,7 +43,7 @@ export interface AutomationStep {
94
43
  type: string
95
44
  }
96
45
 
97
- export interface Automation extends Base {
46
+ export interface Automation extends Document {
98
47
  name: string
99
48
  type: string
100
49
  appId?: string
@@ -1,214 +1,13 @@
1
- import { Row, Table, Base } from "./common"
2
-
3
- export enum Operation {
4
- CREATE = "CREATE",
5
- READ = "READ",
6
- UPDATE = "UPDATE",
7
- DELETE = "DELETE",
8
- BULK_CREATE = "BULK_CREATE",
9
- CREATE_TABLE = "CREATE_TABLE",
10
- UPDATE_TABLE = "UPDATE_TABLE",
11
- DELETE_TABLE = "DELETE_TABLE",
12
- }
13
-
14
- export enum SortDirection {
15
- ASCENDING = "ASCENDING",
16
- DESCENDING = "DESCENDING",
17
- }
18
-
19
- export enum QueryTypes {
20
- SQL = "sql",
21
- JSON = "json",
22
- FIELDS = "fields",
23
- }
24
-
25
- export enum DatasourceFieldTypes {
26
- STRING = "string",
27
- LONGFORM = "longForm",
28
- BOOLEAN = "boolean",
29
- NUMBER = "number",
30
- PASSWORD = "password",
31
- LIST = "list",
32
- OBJECT = "object",
33
- JSON = "json",
34
- FILE = "file",
35
- }
36
-
37
- export enum SourceNames {
38
- POSTGRES = "POSTGRES",
39
- DYNAMODB = "DYNAMODB",
40
- MONGODB = "MONGODB",
41
- ELASTICSEARCH = "ELASTICSEARCH",
42
- COUCHDB = "COUCHDB",
43
- SQL_SERVER = "SQL_SERVER",
44
- S3 = "S3",
45
- AIRTABLE = "AIRTABLE",
46
- MYSQL = "MYSQL",
47
- ARANGODB = "ARANGODB",
48
- REST = "REST",
49
- ORACLE = "ORACLE",
50
- GOOGLE_SHEETS = "GOOGLE_SHEETS",
51
- FIRESTORE = "FIRESTORE",
52
- REDIS = "REDIS",
53
- SNOWFLAKE = "SNOWFLAKE",
54
- }
55
-
56
- export enum IncludeRelationships {
57
- INCLUDE = 1,
58
- EXCLUDE = 0,
59
- }
60
-
61
- export enum FilterTypes {
62
- STRING = "string",
63
- FUZZY = "fuzzy",
64
- RANGE = "range",
65
- EQUAL = "equal",
66
- NOT_EQUAL = "notEqual",
67
- EMPTY = "empty",
68
- NOT_EMPTY = "notEmpty",
69
- ONE_OF = "oneOf",
70
- }
71
-
72
- export interface QueryDefinition {
73
- type: QueryTypes
74
- displayName?: string
75
- readable?: boolean
76
- customisable?: boolean
77
- fields?: object
78
- urlDisplay?: boolean
79
- }
80
-
81
- export interface ExtraQueryConfig {
82
- [key: string]: {
83
- displayName: string
84
- type: string
85
- required: boolean
86
- data?: object
87
- }
88
- }
89
-
90
- export interface Integration {
91
- docs: string
92
- plus?: boolean
93
- auth?: { type: string }
94
- relationships?: boolean
95
- description: string
96
- friendlyName: string
97
- type?: string
98
- datasource: {}
99
- query: {
100
- [key: string]: QueryDefinition
101
- }
102
- extra?: ExtraQueryConfig
103
- }
104
-
105
- export interface SearchFilters {
106
- allOr?: boolean
107
- string?: {
108
- [key: string]: string
109
- }
110
- fuzzy?: {
111
- [key: string]: string
112
- }
113
- range?: {
114
- [key: string]: {
115
- high: number | string
116
- low: number | string
117
- }
118
- }
119
- equal?: {
120
- [key: string]: any
121
- }
122
- notEqual?: {
123
- [key: string]: any
124
- }
125
- empty?: {
126
- [key: string]: any
127
- }
128
- notEmpty?: {
129
- [key: string]: any
130
- }
131
- oneOf?: {
132
- [key: string]: any[]
133
- }
134
- contains?: {
135
- [key: string]: any
136
- }
137
- }
138
-
139
- export interface SortJson {
140
- [key: string]: SortDirection
141
- }
142
-
143
- export interface PaginationJson {
144
- limit: number
145
- page?: string | number
146
- }
147
-
148
- export interface RenameColumn {
149
- old: string
150
- updated: string
151
- }
152
-
153
- export interface RelationshipsJson {
154
- through?: string
155
- from?: string
156
- to?: string
157
- fromPrimary?: string
158
- toPrimary?: string
159
- tableName: string
160
- column: string
161
- }
162
-
163
- export interface QueryJson {
164
- endpoint: {
165
- datasourceId: string
166
- entityId: string
167
- operation: Operation
168
- schema?: string
169
- }
170
- resource: {
171
- fields: string[]
172
- }
173
- filters?: SearchFilters
174
- sort?: SortJson
175
- paginate?: PaginationJson
176
- body?: Row | Row[]
177
- table?: Table
178
- meta?: {
179
- table?: Table
180
- tables?: Record<string, Table>
181
- renamed: RenameColumn
182
- }
183
- extra?: {
184
- idFilter?: SearchFilters
185
- }
186
- relationships?: RelationshipsJson[]
187
- }
188
-
189
- export interface SqlQuery {
190
- sql: string
191
- bindings?: string[]
192
- }
1
+ /********************************************
2
+ * This file contains structures which are *
3
+ * internal to the server and don't need to *
4
+ * be exposed for use by other services. *
5
+ ********************************************/
193
6
 
194
7
  export interface QueryOptions {
195
8
  disableReturning?: boolean
196
9
  }
197
10
 
198
- export interface Datasource extends Base {
199
- type: string
200
- name: string
201
- source: SourceNames
202
- // the config is defined by the schema
203
- config: {
204
- [key: string]: string | number | boolean
205
- }
206
- plus: boolean
207
- entities?: {
208
- [key: string]: Table
209
- }
210
- }
211
-
212
11
  export enum AuthType {
213
12
  BASIC = "basic",
214
13
  BEARER = "bearer",
@@ -230,25 +29,6 @@ export interface BearerAuthConfig {
230
29
  token: string
231
30
  }
232
31
 
233
- export interface QueryParameter {
234
- name: string
235
- default: string
236
- }
237
-
238
- export interface RestQueryFields {
239
- path: string
240
- queryString?: string
241
- headers: { [key: string]: any }
242
- disabledHeaders: { [key: string]: any }
243
- requestBody: any
244
- bodyType: string
245
- json: object
246
- method: string
247
- authConfigId: string
248
- pagination: PaginationConfig | null
249
- paginationValues: PaginationValues | null
250
- }
251
-
252
32
  export interface RestConfig {
253
33
  url: string
254
34
  defaultHeaders: {
@@ -266,28 +46,3 @@ export interface RestConfig {
266
46
  }
267
47
  ]
268
48
  }
269
-
270
- export interface PaginationConfig {
271
- type: string
272
- location: string
273
- pageParam: string
274
- sizeParam: string | null
275
- responseParam: string | null
276
- }
277
-
278
- export interface PaginationValues {
279
- page: string | number | null
280
- limit: number | null
281
- }
282
-
283
- export interface Query {
284
- _id?: string
285
- datasourceId: string
286
- name: string
287
- parameters: QueryParameter[]
288
- fields: RestQueryFields | any
289
- transformer: string | null
290
- schema: any
291
- readable: boolean
292
- queryVerb: string
293
- }