@budibase/server 1.2.37 → 1.2.39-alpha.1

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 (286) hide show
  1. package/__mocks__/mongodb.ts +4 -0
  2. package/__mocks__/node-fetch.ts +8 -1
  3. package/builder/assets/index.a1c0a62f.js +977 -0
  4. package/builder/assets/{index.08dd0c5e.css → index.f1c7e247.css} +1 -1
  5. package/builder/index.html +2 -2
  6. package/coverage/clover.xml +385 -380
  7. package/coverage/coverage-final.json +21 -21
  8. package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
  9. package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
  10. package/coverage/lcov-report/api/controllers/automation.js.html +3 -3
  11. package/coverage/lcov-report/api/controllers/backup.js.html +3 -3
  12. package/coverage/lcov-report/api/controllers/cloud.js.html +4 -4
  13. package/coverage/lcov-report/api/controllers/component.js.html +3 -3
  14. package/coverage/lcov-report/api/controllers/datasource.js.html +3 -3
  15. package/coverage/lcov-report/api/controllers/dev.js.html +4 -4
  16. package/coverage/lcov-report/api/controllers/index.html +1 -1
  17. package/coverage/lcov-report/api/controllers/integration.js.html +3 -3
  18. package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
  19. package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
  20. package/coverage/lcov-report/api/controllers/migrations.js.html +1 -1
  21. package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
  22. package/coverage/lcov-report/api/controllers/query/index.html +1 -1
  23. package/coverage/lcov-report/api/controllers/query/validation.js.html +1 -1
  24. package/coverage/lcov-report/api/controllers/role.js.html +1 -1
  25. package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
  26. package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
  27. package/coverage/lcov-report/api/controllers/row/index.html +25 -25
  28. package/coverage/lcov-report/api/controllers/row/internal.js.html +3 -3
  29. package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +209 -191
  30. package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +1 -1
  31. package/coverage/lcov-report/api/controllers/row/utils.js.html +27 -18
  32. package/coverage/lcov-report/api/controllers/screen.js.html +1 -1
  33. package/coverage/lcov-report/api/controllers/script.js.html +1 -1
  34. package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +1 -1
  35. package/coverage/lcov-report/api/controllers/table/external.js.html +2 -2
  36. package/coverage/lcov-report/api/controllers/table/index.html +1 -1
  37. package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
  38. package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
  39. package/coverage/lcov-report/api/controllers/user.js.html +19 -19
  40. package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
  41. package/coverage/lcov-report/api/controllers/view/index.html +1 -1
  42. package/coverage/lcov-report/api/controllers/view/index.js.html +3 -3
  43. package/coverage/lcov-report/api/controllers/view/utils.js.html +5 -5
  44. package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
  45. package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
  46. package/coverage/lcov-report/api/index.html +1 -1
  47. package/coverage/lcov-report/api/index.js.html +1 -1
  48. package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
  49. package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
  50. package/coverage/lcov-report/api/routes/auth.js.html +1 -1
  51. package/coverage/lcov-report/api/routes/automation.js.html +1 -1
  52. package/coverage/lcov-report/api/routes/backup.js.html +1 -1
  53. package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
  54. package/coverage/lcov-report/api/routes/component.js.html +1 -1
  55. package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
  56. package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
  57. package/coverage/lcov-report/api/routes/dev.js.html +1 -1
  58. package/coverage/lcov-report/api/routes/index.html +1 -1
  59. package/coverage/lcov-report/api/routes/integration.js.html +1 -1
  60. package/coverage/lcov-report/api/routes/layout.js.html +1 -1
  61. package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
  62. package/coverage/lcov-report/api/routes/migrations.js.html +1 -1
  63. package/coverage/lcov-report/api/routes/permission.js.html +1 -1
  64. package/coverage/lcov-report/api/routes/query.js.html +1 -1
  65. package/coverage/lcov-report/api/routes/role.js.html +1 -1
  66. package/coverage/lcov-report/api/routes/routing.js.html +1 -1
  67. package/coverage/lcov-report/api/routes/screen.js.html +1 -1
  68. package/coverage/lcov-report/api/routes/script.js.html +1 -1
  69. package/coverage/lcov-report/api/routes/table.js.html +1 -1
  70. package/coverage/lcov-report/api/routes/templates.js.html +1 -1
  71. package/coverage/lcov-report/api/routes/user.js.html +1 -1
  72. package/coverage/lcov-report/api/routes/utils/index.html +1 -1
  73. package/coverage/lcov-report/api/routes/utils/validators.js.html +1 -1
  74. package/coverage/lcov-report/api/routes/view.js.html +1 -1
  75. package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
  76. package/coverage/lcov-report/automations/actions.js.html +1 -1
  77. package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
  78. package/coverage/lcov-report/automations/bullboard.js.html +1 -1
  79. package/coverage/lcov-report/automations/index.html +1 -1
  80. package/coverage/lcov-report/automations/index.js.html +1 -1
  81. package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
  82. package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
  83. package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
  84. package/coverage/lcov-report/automations/steps/executeQuery.js.html +1 -1
  85. package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
  86. package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
  87. package/coverage/lcov-report/automations/steps/index.html +1 -1
  88. package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
  89. package/coverage/lcov-report/automations/steps/loop.js.html +1 -1
  90. package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
  91. package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
  92. package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
  93. package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
  94. package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
  95. package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
  96. package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
  97. package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
  98. package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
  99. package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
  100. package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
  101. package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
  102. package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
  103. package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
  104. package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
  105. package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
  106. package/coverage/lcov-report/automations/triggers.js.html +1 -1
  107. package/coverage/lcov-report/constants/index.html +1 -1
  108. package/coverage/lcov-report/constants/index.js.html +30 -30
  109. package/coverage/lcov-report/constants/layouts.js.html +1 -1
  110. package/coverage/lcov-report/constants/screens.js.html +1 -1
  111. package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
  112. package/coverage/lcov-report/db/index.html +1 -1
  113. package/coverage/lcov-report/db/index.js.html +1 -1
  114. package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
  115. package/coverage/lcov-report/db/linkedRows/index.html +1 -1
  116. package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
  117. package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +3 -3
  118. package/coverage/lcov-report/db/newid.js.html +3 -3
  119. package/coverage/lcov-report/db/utils.js.html +99 -99
  120. package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
  121. package/coverage/lcov-report/events/index.html +1 -1
  122. package/coverage/lcov-report/events/index.js.html +1 -1
  123. package/coverage/lcov-report/events/utils.js.html +1 -1
  124. package/coverage/lcov-report/index.html +19 -19
  125. package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
  126. package/coverage/lcov-report/integrations/tests/index.html +1 -1
  127. package/coverage/lcov-report/middleware/appInfo.js.html +1 -1
  128. package/coverage/lcov-report/middleware/builder.js.html +3 -3
  129. package/coverage/lcov-report/middleware/currentapp.js.html +1 -1
  130. package/coverage/lcov-report/middleware/index.html +1 -1
  131. package/coverage/lcov-report/middleware/joi-validator.js.html +1 -1
  132. package/coverage/lcov-report/middleware/publicApi.js.html +1 -1
  133. package/coverage/lcov-report/middleware/resourceId.js.html +1 -1
  134. package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
  135. package/coverage/lcov-report/middleware/utils.js.html +1 -1
  136. package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
  137. package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
  138. package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
  139. package/coverage/lcov-report/utilities/global.js.html +16 -16
  140. package/coverage/lcov-report/utilities/index.html +1 -1
  141. package/coverage/lcov-report/utilities/index.js.html +23 -23
  142. package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +1 -1
  143. package/coverage/lcov-report/utilities/queue/index.html +1 -1
  144. package/coverage/lcov-report/utilities/routing/index.html +1 -1
  145. package/coverage/lcov-report/utilities/routing/index.js.html +3 -3
  146. package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
  147. package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
  148. package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
  149. package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
  150. package/coverage/lcov-report/utilities/security.js.html +9 -9
  151. package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
  152. package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
  153. package/coverage/lcov-report/utilities/usageQuota/rows.js.html +1 -1
  154. package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
  155. package/coverage/lcov-report/utilities/users.js.html +7 -7
  156. package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
  157. package/coverage/lcov.info +598 -593
  158. package/dist/api/controllers/analytics.js +1 -1
  159. package/dist/api/controllers/application.js +8 -8
  160. package/dist/api/controllers/automation.js +2 -2
  161. package/dist/api/controllers/backup.js +2 -2
  162. package/dist/api/controllers/cloud.js +3 -3
  163. package/dist/api/controllers/component.js +2 -2
  164. package/dist/api/controllers/datasource.js +2 -2
  165. package/dist/api/controllers/deploy/index.js +6 -6
  166. package/dist/api/controllers/dev.js +3 -3
  167. package/dist/api/controllers/integration.js +2 -2
  168. package/dist/api/controllers/public/utils.js +1 -1
  169. package/dist/api/controllers/row/ExternalRequest.js +3 -3
  170. package/dist/api/controllers/row/internal.js +2 -2
  171. package/dist/api/controllers/row/internalSearch.js +5 -0
  172. package/dist/api/controllers/row/utils.js +3 -1
  173. package/dist/api/controllers/static/index.js +2 -2
  174. package/dist/api/controllers/table/external.js +1 -1
  175. package/dist/api/controllers/view/index.js +2 -2
  176. package/dist/api/controllers/view/utils.js +3 -3
  177. package/dist/automations/logging/index.js +3 -0
  178. package/dist/db/linkedRows/linkUtils.js +2 -2
  179. package/dist/db/utils.js +37 -37
  180. package/dist/db/views/staticViews.js +4 -4
  181. package/dist/definitions/automations.js +6 -6
  182. package/dist/definitions/datasource.js +6 -70
  183. package/dist/integrations/airtable.js +13 -13
  184. package/dist/integrations/arangodb.js +8 -8
  185. package/dist/integrations/base/query.js +27 -0
  186. package/dist/integrations/base/sql.js +33 -32
  187. package/dist/integrations/base/sqlTable.js +4 -4
  188. package/dist/integrations/base/utils.js +13 -27
  189. package/dist/integrations/couchdb.js +8 -8
  190. package/dist/integrations/dynamodb.js +21 -21
  191. package/dist/integrations/elasticsearch.js +12 -12
  192. package/dist/integrations/firebase.js +12 -12
  193. package/dist/integrations/googlesheets.js +14 -14
  194. package/dist/integrations/index.js +34 -34
  195. package/dist/integrations/microsoftSqlServer.js +19 -16
  196. package/dist/integrations/mongodb.js +44 -17
  197. package/dist/integrations/mysql.js +15 -15
  198. package/dist/integrations/oracle.js +13 -13
  199. package/dist/integrations/postgres.js +20 -17
  200. package/dist/integrations/redis.js +10 -10
  201. package/dist/integrations/rest.js +15 -14
  202. package/dist/integrations/s3.js +2 -2
  203. package/dist/integrations/snowflake.js +5 -5
  204. package/dist/integrations/utils.js +14 -14
  205. package/dist/middleware/builder.js +2 -2
  206. package/dist/migrations/functions/appUrls.js +2 -2
  207. package/dist/migrations/functions/backfill/app/queries.js +3 -1
  208. package/dist/migrations/functions/backfill/app.js +1 -1
  209. package/dist/migrations/functions/backfill/global/users.js +1 -1
  210. package/dist/package.json +7 -7
  211. package/dist/tests/utilities/TestConfiguration.js +2 -2
  212. package/dist/threads/automation.js +2 -2
  213. package/dist/tsconfig.build.tsbuildinfo +1 -1
  214. package/dist/utilities/routing/index.js +2 -2
  215. package/dist/utilities/security.js +8 -8
  216. package/package.json +8 -8
  217. package/src/api/controllers/analytics.ts +2 -2
  218. package/src/api/controllers/application.ts +9 -9
  219. package/src/api/controllers/automation.js +2 -2
  220. package/src/api/controllers/backup.js +2 -2
  221. package/src/api/controllers/cloud.js +3 -3
  222. package/src/api/controllers/component.js +2 -2
  223. package/src/api/controllers/datasource.js +2 -2
  224. package/src/api/controllers/deploy/index.ts +7 -7
  225. package/src/api/controllers/dev.js +3 -3
  226. package/src/api/controllers/integration.js +2 -2
  227. package/src/api/controllers/public/utils.ts +2 -2
  228. package/src/api/controllers/query/import/sources/openapi2.ts +1 -1
  229. package/src/api/controllers/query/import/sources/openapi3.ts +1 -1
  230. package/src/api/controllers/row/ExternalRequest.ts +5 -7
  231. package/src/api/controllers/row/internal.js +2 -2
  232. package/src/api/controllers/row/internalSearch.js +6 -0
  233. package/src/api/controllers/row/utils.js +4 -1
  234. package/src/api/controllers/static/index.ts +2 -2
  235. package/src/api/controllers/table/external.js +1 -1
  236. package/src/api/controllers/view/index.js +2 -2
  237. package/src/api/controllers/view/utils.js +4 -4
  238. package/src/api/routes/tests/internalSearch.spec.js +157 -0
  239. package/src/automations/logging/index.ts +3 -0
  240. package/src/db/linkedRows/linkUtils.js +2 -2
  241. package/src/db/utils.js +38 -38
  242. package/src/db/views/staticViews.js +4 -9
  243. package/src/definitions/automations.ts +2 -2
  244. package/src/definitions/common.ts +14 -65
  245. package/src/definitions/datasource.ts +5 -250
  246. package/src/integrations/airtable.ts +16 -16
  247. package/src/integrations/arangodb.ts +11 -11
  248. package/src/integrations/base/query.ts +16 -0
  249. package/src/integrations/base/sql.ts +21 -20
  250. package/src/integrations/base/sqlTable.ts +1 -6
  251. package/src/integrations/base/utils.ts +9 -19
  252. package/src/integrations/couchdb.ts +11 -11
  253. package/src/integrations/dynamodb.ts +24 -24
  254. package/src/integrations/elasticsearch.ts +15 -15
  255. package/src/integrations/firebase.ts +15 -15
  256. package/src/integrations/googlesheets.ts +19 -18
  257. package/src/integrations/index.ts +34 -34
  258. package/src/integrations/microsoftSqlServer.ts +22 -20
  259. package/src/integrations/mongodb.ts +47 -20
  260. package/src/integrations/mysql.ts +20 -19
  261. package/src/integrations/oracle.ts +16 -16
  262. package/src/integrations/postgres.ts +22 -21
  263. package/src/integrations/queries/sql.ts +1 -2
  264. package/src/integrations/redis.ts +10 -14
  265. package/src/integrations/rest.ts +22 -20
  266. package/src/integrations/s3.ts +2 -3
  267. package/src/integrations/snowflake.ts +5 -5
  268. package/src/integrations/tests/mongo.spec.js +218 -0
  269. package/src/integrations/tests/sql.spec.js +8 -8
  270. package/src/integrations/utils.ts +8 -9
  271. package/src/middleware/builder.js +2 -2
  272. package/src/migrations/functions/appUrls.ts +2 -2
  273. package/src/migrations/functions/backfill/app/queries.ts +3 -2
  274. package/src/migrations/functions/backfill/app.ts +1 -1
  275. package/src/migrations/functions/backfill/global/users.ts +1 -1
  276. package/src/migrations/functions/tests/appUrls.spec.js +3 -3
  277. package/src/migrations/tests/index.spec.ts +2 -2
  278. package/src/tests/utilities/TestConfiguration.js +2 -2
  279. package/src/threads/automation.ts +3 -3
  280. package/src/utilities/routing/index.js +2 -2
  281. package/src/utilities/security.js +8 -8
  282. package/builder/assets/index.3ce7fa08.js +0 -975
  283. package/dist/integrations/base/IntegrationBase.js +0 -2
  284. package/dist/integrations/base/datasourcePlus.js +0 -2
  285. package/src/integrations/base/IntegrationBase.ts +0 -6
  286. package/src/integrations/base/datasourcePlus.ts +0 -13
@@ -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
- }
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  Integration,
3
- DatasourceFieldTypes,
4
- QueryTypes,
5
- } from "../definitions/datasource"
6
- import { IntegrationBase } from "./base/IntegrationBase"
3
+ DatasourceFieldType,
4
+ QueryType,
5
+ IntegrationBase,
6
+ } from "@budibase/types"
7
7
 
8
8
  module AirtableModule {
9
9
  const Airtable = require("airtable")
@@ -21,61 +21,61 @@ module AirtableModule {
21
21
  type: "Spreadsheet",
22
22
  datasource: {
23
23
  apiKey: {
24
- type: DatasourceFieldTypes.PASSWORD,
24
+ type: DatasourceFieldType.PASSWORD,
25
25
  default: "enter api key",
26
26
  required: true,
27
27
  },
28
28
  base: {
29
- type: DatasourceFieldTypes.STRING,
29
+ type: DatasourceFieldType.STRING,
30
30
  default: "mybase",
31
31
  required: true,
32
32
  },
33
33
  },
34
34
  query: {
35
35
  create: {
36
- type: QueryTypes.FIELDS,
36
+ type: QueryType.FIELDS,
37
37
  customisable: true,
38
38
  fields: {
39
39
  table: {
40
- type: DatasourceFieldTypes.STRING,
40
+ type: DatasourceFieldType.STRING,
41
41
  required: true,
42
42
  },
43
43
  },
44
44
  },
45
45
  read: {
46
- type: QueryTypes.FIELDS,
46
+ type: QueryType.FIELDS,
47
47
  fields: {
48
48
  table: {
49
- type: DatasourceFieldTypes.STRING,
49
+ type: DatasourceFieldType.STRING,
50
50
  required: true,
51
51
  },
52
52
  view: {
53
- type: DatasourceFieldTypes.STRING,
53
+ type: DatasourceFieldType.STRING,
54
54
  required: true,
55
55
  },
56
56
  numRecords: {
57
- type: DatasourceFieldTypes.NUMBER,
57
+ type: DatasourceFieldType.NUMBER,
58
58
  default: 10,
59
59
  },
60
60
  },
61
61
  },
62
62
  update: {
63
- type: QueryTypes.FIELDS,
63
+ type: QueryType.FIELDS,
64
64
  customisable: true,
65
65
  fields: {
66
66
  id: {
67
67
  display: "Record ID",
68
- type: DatasourceFieldTypes.STRING,
68
+ type: DatasourceFieldType.STRING,
69
69
  required: true,
70
70
  },
71
71
  table: {
72
- type: DatasourceFieldTypes.STRING,
72
+ type: DatasourceFieldType.STRING,
73
73
  required: true,
74
74
  },
75
75
  },
76
76
  },
77
77
  delete: {
78
- type: QueryTypes.JSON,
78
+ type: QueryType.JSON,
79
79
  },
80
80
  },
81
81
  }
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  Integration,
3
- DatasourceFieldTypes,
4
- QueryTypes,
5
- } from "../definitions/datasource"
6
- import { IntegrationBase } from "./base/IntegrationBase"
3
+ DatasourceFieldType,
4
+ QueryType,
5
+ IntegrationBase,
6
+ } from "@budibase/types"
7
7
 
8
8
  module ArangoModule {
9
9
  const { Database, aql } = require("arangojs")
@@ -24,35 +24,35 @@ module ArangoModule {
24
24
  "ArangoDB is a scalable open-source multi-model database natively supporting graph, document and search. All supported data models & access patterns can be combined in queries allowing for maximal flexibility. ",
25
25
  datasource: {
26
26
  url: {
27
- type: DatasourceFieldTypes.STRING,
27
+ type: DatasourceFieldType.STRING,
28
28
  default: "http://localhost:8529",
29
29
  required: true,
30
30
  },
31
31
  username: {
32
- type: DatasourceFieldTypes.STRING,
32
+ type: DatasourceFieldType.STRING,
33
33
  default: "root",
34
34
  required: true,
35
35
  },
36
36
  password: {
37
- type: DatasourceFieldTypes.PASSWORD,
37
+ type: DatasourceFieldType.PASSWORD,
38
38
  required: true,
39
39
  },
40
40
  databaseName: {
41
- type: DatasourceFieldTypes.STRING,
41
+ type: DatasourceFieldType.STRING,
42
42
  default: "_system",
43
43
  required: true,
44
44
  },
45
45
  collection: {
46
- type: DatasourceFieldTypes.STRING,
46
+ type: DatasourceFieldType.STRING,
47
47
  required: true,
48
48
  },
49
49
  },
50
50
  query: {
51
51
  read: {
52
- type: QueryTypes.SQL,
52
+ type: QueryType.SQL,
53
53
  },
54
54
  create: {
55
- type: QueryTypes.JSON,
55
+ type: QueryType.JSON,
56
56
  },
57
57
  },
58
58
  }
@@ -0,0 +1,16 @@
1
+ import { QueryJson, Datasource } from "@budibase/types"
2
+ const { integrations } = require("../index")
3
+
4
+ export async function makeExternalQuery(
5
+ datasource: Datasource,
6
+ json: QueryJson
7
+ ) {
8
+ const Integration = integrations[datasource.source]
9
+ // query is the opinionated function
10
+ if (Integration.prototype.query) {
11
+ const integration = new Integration(datasource.config)
12
+ return integration.query(json)
13
+ } else {
14
+ throw "Datasource does not support query."
15
+ }
16
+ }
@@ -2,14 +2,15 @@ import { Knex, knex } from "knex"
2
2
  import {
3
3
  Operation,
4
4
  QueryJson,
5
- QueryOptions,
6
5
  RelationshipsJson,
7
6
  SearchFilters,
8
7
  SortDirection,
9
- } from "../../definitions/datasource"
10
- import { isIsoDateString, SqlClients } from "../utils"
8
+ } from "@budibase/types"
9
+ import { QueryOptions } from "../../definitions/datasource"
10
+ import { isIsoDateString, SqlClient } from "../utils"
11
11
  import SqlTableQueryBuilder from "./sqlTable"
12
12
  import environment from "../../environment"
13
+ import { removeKeyNumbering } from "./utils"
13
14
 
14
15
  const envLimit = environment.SQL_MAX_ROWS
15
16
  ? parseInt(environment.SQL_MAX_ROWS)
@@ -27,14 +28,14 @@ function likeKey(client: string, key: string): string {
27
28
  }
28
29
  let start: string, end: string
29
30
  switch (client) {
30
- case SqlClients.MY_SQL:
31
+ case SqlClient.MY_SQL:
31
32
  start = end = "`"
32
33
  break
33
- case SqlClients.ORACLE:
34
- case SqlClients.POSTGRES:
34
+ case SqlClient.ORACLE:
35
+ case SqlClient.POSTGRES:
35
36
  start = end = '"'
36
37
  break
37
- case SqlClients.MS_SQL:
38
+ case SqlClient.MS_SQL:
38
39
  start = "["
39
40
  end = "]"
40
41
  break
@@ -102,7 +103,7 @@ function generateSelectStatement(
102
103
  if (
103
104
  columnName &&
104
105
  schema?.[columnName] &&
105
- knex.client.config.client === SqlClients.POSTGRES
106
+ knex.client.config.client === SqlClient.POSTGRES
106
107
  ) {
107
108
  const externalType = schema[columnName].externalType
108
109
  if (externalType?.includes("money")) {
@@ -133,12 +134,13 @@ class InternalBuilder {
133
134
  fn: (key: string, value: any) => void
134
135
  ) {
135
136
  for (let [key, value] of Object.entries(structure)) {
136
- const isRelationshipField = key.includes(".")
137
+ const updatedKey = removeKeyNumbering(key)
138
+ const isRelationshipField = updatedKey.includes(".")
137
139
  if (!opts.relationship && !isRelationshipField) {
138
- fn(`${opts.tableName}.${key}`, value)
140
+ fn(`${opts.tableName}.${updatedKey}`, value)
139
141
  }
140
142
  if (opts.relationship && isRelationshipField) {
141
- fn(key, value)
143
+ fn(updatedKey, value)
142
144
  }
143
145
  }
144
146
  }
@@ -146,7 +148,7 @@ class InternalBuilder {
146
148
  const like = (key: string, value: any) => {
147
149
  const fnc = allOr ? "orWhere" : "where"
148
150
  // postgres supports ilike, nothing else does
149
- if (this.client === SqlClients.POSTGRES) {
151
+ if (this.client === SqlClient.POSTGRES) {
150
152
  query = query[fnc](key, "ilike", `%${value}%`)
151
153
  } else {
152
154
  const rawFnc = `${fnc}Raw`
@@ -173,7 +175,7 @@ class InternalBuilder {
173
175
  iterate(filters.string, (key, value) => {
174
176
  const fnc = allOr ? "orWhere" : "where"
175
177
  // postgres supports ilike, nothing else does
176
- if (this.client === SqlClients.POSTGRES) {
178
+ if (this.client === SqlClient.POSTGRES) {
177
179
  query = query[fnc](key, "ilike", `${value}%`)
178
180
  } else {
179
181
  const rawFnc = `${fnc}Raw`
@@ -229,7 +231,7 @@ class InternalBuilder {
229
231
  if (filters.contains) {
230
232
  const fnc = allOr ? "orWhere" : "where"
231
233
  const rawFnc = `${fnc}Raw`
232
- if (this.client === SqlClients.POSTGRES) {
234
+ if (this.client === SqlClient.POSTGRES) {
233
235
  iterate(filters.contains, (key: string, value: any) => {
234
236
  const fieldNames = key.split(/\./g)
235
237
  const tableName = fieldNames[0]
@@ -242,7 +244,7 @@ class InternalBuilder {
242
244
  `"${tableName}"."${columnName}"::jsonb @> '[${value}]'`
243
245
  )
244
246
  })
245
- } else if (this.client === SqlClients.MY_SQL) {
247
+ } else if (this.client === SqlClient.MY_SQL) {
246
248
  iterate(filters.contains, (key: string, value: any) => {
247
249
  if (typeof value === "string") {
248
250
  value = `"${value}"`
@@ -265,7 +267,7 @@ class InternalBuilder {
265
267
  const direction = value === SortDirection.ASCENDING ? "asc" : "desc"
266
268
  query = query.orderBy(`${table?.name}.${key}`, direction)
267
269
  }
268
- } else if (this.client === SqlClients.MS_SQL && paginate?.limit) {
270
+ } else if (this.client === SqlClient.MS_SQL && paginate?.limit) {
269
271
  // @ts-ignore
270
272
  query = query.orderBy(`${table?.name}.${table?.primary[0]}`)
271
273
  }
@@ -414,7 +416,7 @@ class InternalBuilder {
414
416
  [tableName]: query,
415
417
  }).select(selectStatement)
416
418
  // have to add after as well (this breaks MS-SQL)
417
- if (this.client !== SqlClients.MS_SQL) {
419
+ if (this.client !== SqlClient.MS_SQL) {
418
420
  preQuery = this.addSorting(preQuery, json)
419
421
  }
420
422
  // handle joins
@@ -565,9 +567,9 @@ class SqlQueryBuilder extends SqlTableQueryBuilder {
565
567
  // same as delete, manage returning
566
568
  if (operation === Operation.CREATE || operation === Operation.UPDATE) {
567
569
  let id
568
- if (sqlClient === SqlClients.MS_SQL) {
570
+ if (sqlClient === SqlClient.MS_SQL) {
569
571
  id = results?.[0].id
570
- } else if (sqlClient === SqlClients.MY_SQL) {
572
+ } else if (sqlClient === SqlClient.MY_SQL) {
571
573
  id = results?.insertId
572
574
  }
573
575
  row = processFn(
@@ -582,4 +584,3 @@ class SqlQueryBuilder extends SqlTableQueryBuilder {
582
584
  }
583
585
 
584
586
  export default SqlQueryBuilder
585
- module.exports = SqlQueryBuilder
@@ -1,10 +1,5 @@
1
1
  import { Knex, knex } from "knex"
2
- import { Table } from "../../definitions/common"
3
- import {
4
- Operation,
5
- QueryJson,
6
- RenameColumn,
7
- } from "../../definitions/datasource"
2
+ import { Operation, QueryJson, RenameColumn, Table } from "@budibase/types"
8
3
  import { breakExternalTableId } from "../utils"
9
4
  import SchemaBuilder = Knex.SchemaBuilder
10
5
  import CreateTableBuilder = Knex.CreateTableBuilder
@@ -1,22 +1,12 @@
1
- import { QueryJson } from "../../definitions/datasource"
2
- import { Datasource } from "../../definitions/common"
1
+ const QUERY_START_REGEX = /\d[0-9]*:/g
3
2
 
4
- module DatasourceUtils {
5
- const { integrations } = require("../index")
6
-
7
- export async function makeExternalQuery(
8
- datasource: Datasource,
9
- json: QueryJson
10
- ) {
11
- const Integration = integrations[datasource.source]
12
- // query is the opinionated function
13
- if (Integration.prototype.query) {
14
- const integration = new Integration(datasource.config)
15
- return integration.query(json)
16
- } else {
17
- throw "Datasource does not support query."
18
- }
3
+ export function removeKeyNumbering(key: any): string {
4
+ if (typeof key === "string" && key.match(QUERY_START_REGEX) != null) {
5
+ const parts = key.split(":")
6
+ // remove the number
7
+ parts.shift()
8
+ return parts.join(":")
9
+ } else {
10
+ return key
19
11
  }
20
-
21
- module.exports.makeExternalQuery = makeExternalQuery
22
12
  }
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  Integration,
3
- DatasourceFieldTypes,
4
- QueryTypes,
5
- } from "../definitions/datasource"
6
- import { IntegrationBase } from "./base/IntegrationBase"
3
+ DatasourceFieldType,
4
+ QueryType,
5
+ IntegrationBase,
6
+ } from "@budibase/types"
7
7
 
8
8
  module CouchDBModule {
9
9
  const PouchDB = require("pouchdb")
@@ -21,30 +21,30 @@ module CouchDBModule {
21
21
  "Apache CouchDB is an open-source document-oriented NoSQL database, implemented in Erlang.",
22
22
  datasource: {
23
23
  url: {
24
- type: DatasourceFieldTypes.STRING,
24
+ type: DatasourceFieldType.STRING,
25
25
  required: true,
26
26
  default: "http://localhost:5984",
27
27
  },
28
28
  database: {
29
- type: DatasourceFieldTypes.STRING,
29
+ type: DatasourceFieldType.STRING,
30
30
  required: true,
31
31
  },
32
32
  },
33
33
  query: {
34
34
  create: {
35
- type: QueryTypes.JSON,
35
+ type: QueryType.JSON,
36
36
  },
37
37
  read: {
38
- type: QueryTypes.JSON,
38
+ type: QueryType.JSON,
39
39
  },
40
40
  update: {
41
- type: QueryTypes.JSON,
41
+ type: QueryType.JSON,
42
42
  },
43
43
  delete: {
44
- type: QueryTypes.FIELDS,
44
+ type: QueryType.FIELDS,
45
45
  fields: {
46
46
  id: {
47
- type: DatasourceFieldTypes.STRING,
47
+ type: DatasourceFieldType.STRING,
48
48
  required: true,
49
49
  },
50
50
  },