@budibase/server 2.6.18 → 2.6.19-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/builder/assets/{index.86c992bf.css → index.07382a47.css} +2 -2
  2. package/builder/assets/{index.69c5c1ea.js → index.b9eeb2a8.js} +310 -318
  3. package/builder/index.html +2 -2
  4. package/dist/api/controllers/datasource.js +70 -39
  5. package/dist/api/controllers/integration.js +2 -2
  6. package/dist/api/routes/datasource.js +1 -0
  7. package/dist/automations/steps/make.js +19 -5
  8. package/dist/automations/steps/zapier.js +19 -6
  9. package/dist/automations/utils.js +13 -7
  10. package/dist/db/dynamoClient.js +1 -1
  11. package/dist/integrations/airtable.js +28 -2
  12. package/dist/integrations/arangodb.js +19 -3
  13. package/dist/integrations/couchdb.js +16 -1
  14. package/dist/integrations/dynamodb.js +16 -0
  15. package/dist/integrations/elasticsearch.js +15 -0
  16. package/dist/integrations/firebase.js +15 -0
  17. package/dist/integrations/googlesheets.js +30 -1
  18. package/dist/integrations/index.js +5 -2
  19. package/dist/integrations/microsoftSqlServer.js +16 -0
  20. package/dist/integrations/mongodb.js +16 -0
  21. package/dist/integrations/mysql.js +21 -5
  22. package/dist/integrations/oracle.js +29 -0
  23. package/dist/integrations/postgres.js +26 -7
  24. package/dist/integrations/redis.js +20 -1
  25. package/dist/integrations/s3.js +23 -4
  26. package/dist/integrations/snowflake.js +15 -0
  27. package/dist/migrations/functions/backfill/app/queries.js +1 -2
  28. package/dist/sdk/app/datasources/datasources.js +10 -3
  29. package/dist/tsconfig.build.tsbuildinfo +1 -1
  30. package/jest.config.ts +3 -3
  31. package/nodemon.json +7 -3
  32. package/package.json +10 -9
  33. package/src/api/controllers/datasource.ts +88 -49
  34. package/src/api/controllers/integration.ts +3 -3
  35. package/src/api/routes/datasource.ts +5 -0
  36. package/src/automations/steps/make.ts +18 -1
  37. package/src/automations/steps/zapier.ts +18 -1
  38. package/src/automations/tests/make.spec.ts +54 -0
  39. package/src/automations/tests/zapier.spec.ts +56 -0
  40. package/src/automations/utils.ts +13 -7
  41. package/src/db/dynamoClient.ts +1 -1
  42. package/src/integration-test/postgres.spec.ts +0 -1
  43. package/src/integrations/airtable.ts +31 -4
  44. package/src/integrations/arangodb.ts +18 -2
  45. package/src/integrations/couchdb.ts +18 -4
  46. package/src/integrations/dynamodb.ts +34 -5
  47. package/src/integrations/elasticsearch.ts +16 -1
  48. package/src/integrations/firebase.ts +15 -0
  49. package/src/integrations/googlesheets.ts +31 -2
  50. package/src/integrations/index.ts +12 -7
  51. package/src/integrations/microsoftSqlServer.ts +16 -0
  52. package/src/integrations/mongodb.ts +16 -0
  53. package/src/integrations/mysql.ts +27 -16
  54. package/src/integrations/oracle.ts +28 -6
  55. package/src/integrations/postgres.ts +21 -3
  56. package/src/integrations/redis.ts +26 -3
  57. package/src/integrations/s3.ts +19 -3
  58. package/src/integrations/snowflake.ts +20 -1
  59. package/src/migrations/functions/backfill/app/queries.ts +1 -1
  60. package/src/sdk/app/datasources/datasources.ts +7 -1
  61. package/tsconfig.json +1 -1
  62. package/src/automations/tests/zapier.spec.js +0 -27
@@ -28,6 +28,7 @@ const getSchema = () => {
28
28
  friendlyName: "MongoDB",
29
29
  type: "Non-relational",
30
30
  description: "MongoDB is a general purpose, document-based, distributed database built for modern application developers and for the cloud era.",
31
+ features: [types_1.DatasourceFeature.CONNECTION_CHECKING],
31
32
  datasource: {
32
33
  connectionString: {
33
34
  type: types_1.DatasourceFieldType.STRING,
@@ -340,6 +341,21 @@ class MongoIntegration {
340
341
  };
341
342
  this.client = new mongodb_1.MongoClient(config.connectionString, options);
342
343
  }
344
+ testConnection() {
345
+ return __awaiter(this, void 0, void 0, function* () {
346
+ const response = {
347
+ connected: false,
348
+ };
349
+ try {
350
+ yield this.connect();
351
+ response.connected = true;
352
+ }
353
+ catch (e) {
354
+ response.error = e.message;
355
+ }
356
+ return response;
357
+ });
358
+ }
343
359
  connect() {
344
360
  return __awaiter(this, void 0, void 0, function* () {
345
361
  return this.client.connect();
@@ -17,13 +17,14 @@ const utils_1 = require("./utils");
17
17
  const dayjs_1 = __importDefault(require("dayjs"));
18
18
  const utilities_1 = require("../utilities");
19
19
  const sql_1 = __importDefault(require("./base/sql"));
20
- const mysql = require("mysql2/promise");
20
+ const promise_1 = __importDefault(require("mysql2/promise"));
21
21
  const SCHEMA = {
22
22
  docs: "https://github.com/sidorares/node-mysql2",
23
23
  plus: true,
24
24
  friendlyName: "MySQL",
25
25
  type: "Relational",
26
26
  description: "MySQL Database Service is a fully managed database service to deploy cloud-native applications. ",
27
+ features: [types_1.DatasourceFeature.CONNECTION_CHECKING],
27
28
  datasource: {
28
29
  host: {
29
30
  type: types_1.DatasourceFieldType.STRING,
@@ -74,7 +75,6 @@ const SCHEMA = {
74
75
  },
75
76
  },
76
77
  };
77
- const TimezoneAwareDateTypes = ["timestamp"];
78
78
  function bindingTypeCoerce(bindings) {
79
79
  for (let i = 0; i < bindings.length; i++) {
80
80
  const binding = bindings[i];
@@ -108,7 +108,8 @@ class MySQLIntegration extends sql_1.default {
108
108
  // make sure this defaults to true
109
109
  if (config.rejectUnauthorized != null &&
110
110
  !config.rejectUnauthorized &&
111
- config.ssl) {
111
+ config.ssl &&
112
+ typeof config.ssl !== "string") {
112
113
  config.ssl.rejectUnauthorized = config.rejectUnauthorized;
113
114
  }
114
115
  // @ts-ignore
@@ -127,6 +128,21 @@ class MySQLIntegration extends sql_1.default {
127
128
  return next();
128
129
  } });
129
130
  }
131
+ testConnection() {
132
+ return __awaiter(this, void 0, void 0, function* () {
133
+ const response = {
134
+ connected: false,
135
+ };
136
+ try {
137
+ const [result] = yield this.internalQuery({ sql: "SELECT 1+1 AS checkRes" }, { connect: true });
138
+ response.connected = (result === null || result === void 0 ? void 0 : result.checkRes) == 2;
139
+ }
140
+ catch (e) {
141
+ response.error = e.message;
142
+ }
143
+ return response;
144
+ });
145
+ }
130
146
  getBindingIdentifier() {
131
147
  return "?";
132
148
  }
@@ -135,7 +151,7 @@ class MySQLIntegration extends sql_1.default {
135
151
  }
136
152
  connect() {
137
153
  return __awaiter(this, void 0, void 0, function* () {
138
- this.client = yield mysql.createConnection(this.config);
154
+ this.client = yield promise_1.default.createConnection(this.config);
139
155
  });
140
156
  }
141
157
  disconnect() {
@@ -161,7 +177,7 @@ class MySQLIntegration extends sql_1.default {
161
177
  return response[0];
162
178
  }
163
179
  finally {
164
- if (opts === null || opts === void 0 ? void 0 : opts.connect) {
180
+ if ((opts === null || opts === void 0 ? void 0 : opts.connect) && this.client) {
165
181
  yield this.disconnect();
166
182
  }
167
183
  }
@@ -30,6 +30,7 @@ const SCHEMA = {
30
30
  friendlyName: "Oracle",
31
31
  type: "Relational",
32
32
  description: "Oracle Database is an object-relational database management system developed by Oracle Corporation",
33
+ features: [types_1.DatasourceFeature.CONNECTION_CHECKING],
33
34
  datasource: {
34
35
  host: {
35
36
  type: types_1.DatasourceFieldType.STRING,
@@ -271,6 +272,34 @@ class OracleIntegration extends sql_1.default {
271
272
  this.schemaErrors = final.errors;
272
273
  });
273
274
  }
275
+ testConnection() {
276
+ return __awaiter(this, void 0, void 0, function* () {
277
+ const response = {
278
+ connected: false,
279
+ };
280
+ let connection;
281
+ try {
282
+ connection = yield this.getConnection();
283
+ response.connected = true;
284
+ }
285
+ catch (err) {
286
+ response.connected = false;
287
+ response.error = err.message;
288
+ }
289
+ finally {
290
+ if (connection) {
291
+ try {
292
+ yield connection.close();
293
+ }
294
+ catch (err) {
295
+ response.connected = false;
296
+ response.error = err.message;
297
+ }
298
+ }
299
+ }
300
+ return response;
301
+ });
302
+ }
274
303
  internalQuery(query) {
275
304
  return __awaiter(this, void 0, void 0, function* () {
276
305
  let connection;
@@ -16,14 +16,14 @@ const types_1 = require("@budibase/types");
16
16
  const utils_1 = require("./utils");
17
17
  const sql_1 = __importDefault(require("./base/sql"));
18
18
  const utilities_1 = require("../utilities");
19
- const { Client, types } = require("pg");
19
+ const pg_1 = require("pg");
20
20
  // Return "date" and "timestamp" types as plain strings.
21
21
  // This lets us reference the original stored timezone.
22
22
  // types is undefined when running in a test env for some reason.
23
- if (types) {
24
- types.setTypeParser(1114, (val) => val); // timestamp
25
- types.setTypeParser(1082, (val) => val); // date
26
- types.setTypeParser(1184, (val) => val); // timestampz
23
+ if (pg_1.types) {
24
+ pg_1.types.setTypeParser(1114, (val) => val); // timestamp
25
+ pg_1.types.setTypeParser(1082, (val) => val); // date
26
+ pg_1.types.setTypeParser(1184, (val) => val); // timestampz
27
27
  }
28
28
  const JSON_REGEX = /'{.*}'::json/s;
29
29
  const SCHEMA = {
@@ -32,6 +32,7 @@ const SCHEMA = {
32
32
  friendlyName: "PostgreSQL",
33
33
  type: "Relational",
34
34
  description: "PostgreSQL, also known as Postgres, is a free and open-source relational database management system emphasizing extensibility and SQL compliance.",
35
+ features: [types_1.DatasourceFeature.CONNECTION_CHECKING],
35
36
  datasource: {
36
37
  host: {
37
38
  type: types_1.DatasourceFieldType.STRING,
@@ -116,9 +117,27 @@ class PostgresIntegration extends sql_1.default {
116
117
  ca: this.config.ca,
117
118
  }
118
119
  : undefined });
119
- this.client = new Client(newConfig);
120
+ this.client = new pg_1.Client(newConfig);
120
121
  this.open = false;
121
122
  }
123
+ testConnection() {
124
+ return __awaiter(this, void 0, void 0, function* () {
125
+ const response = {
126
+ connected: false,
127
+ };
128
+ try {
129
+ yield this.openConnection();
130
+ response.connected = true;
131
+ }
132
+ catch (e) {
133
+ response.error = e.message;
134
+ }
135
+ finally {
136
+ yield this.closeConnection();
137
+ }
138
+ return response;
139
+ });
140
+ }
122
141
  getBindingIdentifier() {
123
142
  return `$${this.index++}`;
124
143
  }
@@ -131,7 +150,7 @@ class PostgresIntegration extends sql_1.default {
131
150
  if (!this.config.schema) {
132
151
  this.config.schema = "public";
133
152
  }
134
- this.client.query(`SET search_path TO ${this.config.schema}`);
153
+ yield this.client.query(`SET search_path TO ${this.config.schema}`);
135
154
  this.COLUMNS_SQL = `select * from information_schema.columns where table_schema = '${this.config.schema}'`;
136
155
  this.open = true;
137
156
  });
@@ -16,9 +16,10 @@ const types_1 = require("@budibase/types");
16
16
  const ioredis_1 = __importDefault(require("ioredis"));
17
17
  const SCHEMA = {
18
18
  docs: "https://redis.io/docs/",
19
- description: "",
19
+ description: "Redis is a caching tool, providing powerful key-value store capabilities.",
20
20
  friendlyName: "Redis",
21
21
  type: "Non-relational",
22
+ features: [types_1.DatasourceFeature.CONNECTION_CHECKING],
22
23
  datasource: {
23
24
  host: {
24
25
  type: "string",
@@ -99,6 +100,24 @@ class RedisIntegration {
99
100
  db: this.config.db,
100
101
  });
101
102
  }
103
+ testConnection() {
104
+ return __awaiter(this, void 0, void 0, function* () {
105
+ const response = {
106
+ connected: false,
107
+ };
108
+ try {
109
+ yield this.client.ping();
110
+ response.connected = true;
111
+ }
112
+ catch (e) {
113
+ response.error = e.message;
114
+ }
115
+ finally {
116
+ yield this.disconnect();
117
+ }
118
+ return response;
119
+ });
120
+ }
102
121
  disconnect() {
103
122
  return __awaiter(this, void 0, void 0, function* () {
104
123
  return this.client.quit();
@@ -8,15 +8,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
11
14
  Object.defineProperty(exports, "__esModule", { value: true });
12
15
  const types_1 = require("@budibase/types");
13
- const AWS = require("aws-sdk");
14
- const csv = require("csvtojson");
16
+ const aws_sdk_1 = __importDefault(require("aws-sdk"));
17
+ const csvtojson_1 = __importDefault(require("csvtojson"));
15
18
  const SCHEMA = {
16
19
  docs: "https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html",
17
20
  description: "Amazon Simple Storage Service (Amazon S3) is an object storage service that offers industry-leading scalability, data availability, security, and performance.",
18
21
  friendlyName: "Amazon S3",
19
22
  type: "Object store",
23
+ features: [types_1.DatasourceFeature.CONNECTION_CHECKING],
20
24
  datasource: {
21
25
  region: {
22
26
  type: "string",
@@ -153,7 +157,22 @@ class S3Integration {
153
157
  else {
154
158
  delete this.config.endpoint;
155
159
  }
156
- this.client = new AWS.S3(this.config);
160
+ this.client = new aws_sdk_1.default.S3(this.config);
161
+ }
162
+ testConnection() {
163
+ return __awaiter(this, void 0, void 0, function* () {
164
+ const response = {
165
+ connected: false,
166
+ };
167
+ try {
168
+ yield this.client.listBuckets().promise();
169
+ response.connected = true;
170
+ }
171
+ catch (e) {
172
+ response.error = e.message;
173
+ }
174
+ return response;
175
+ });
157
176
  }
158
177
  create(query) {
159
178
  var _a;
@@ -202,7 +221,7 @@ class S3Integration {
202
221
  stream.on("error", (err) => {
203
222
  reject(err);
204
223
  });
205
- const response = csv()
224
+ const response = (0, csvtojson_1.default)()
206
225
  .fromStream(stream)
207
226
  .on("error", () => {
208
227
  csvError = true;
@@ -16,6 +16,7 @@ const SCHEMA = {
16
16
  description: "Snowflake is a solution for data warehousing, data lakes, data engineering, data science, data application development, and securely sharing and consuming shared data.",
17
17
  friendlyName: "Snowflake",
18
18
  type: "Relational",
19
+ features: [types_1.DatasourceFeature.CONNECTION_CHECKING],
19
20
  datasource: {
20
21
  account: {
21
22
  type: "string",
@@ -61,6 +62,20 @@ class SnowflakeIntegration {
61
62
  constructor(config) {
62
63
  this.client = new snowflake_promise_1.Snowflake(config);
63
64
  }
65
+ testConnection() {
66
+ return __awaiter(this, void 0, void 0, function* () {
67
+ try {
68
+ yield this.client.connect();
69
+ return { connected: true };
70
+ }
71
+ catch (e) {
72
+ return {
73
+ connected: false,
74
+ error: e.message,
75
+ };
76
+ }
77
+ });
78
+ }
64
79
  internalQuery(query) {
65
80
  return __awaiter(this, void 0, void 0, function* () {
66
81
  yield this.client.connect();
@@ -12,7 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.backfill = void 0;
13
13
  const backend_core_1 = require("@budibase/backend-core");
14
14
  const utils_1 = require("../../../../db/utils");
15
- const types_1 = require("@budibase/types");
16
15
  const getQueries = (appDb) => __awaiter(void 0, void 0, void 0, function* () {
17
16
  const response = yield appDb.allDocs((0, utils_1.getQueryParams)(null, {
18
17
  include_docs: true,
@@ -36,7 +35,7 @@ const backfill = (appDb, timestamp) => __awaiter(void 0, void 0, void 0, functio
36
35
  datasource = {
37
36
  type: "unknown",
38
37
  _id: query.datasourceId,
39
- source: types_1.SourceName.UNKNOWN,
38
+ source: "unknown",
40
39
  };
41
40
  }
42
41
  else {
@@ -8,6 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
11
14
  Object.defineProperty(exports, "__esModule", { value: true });
12
15
  exports.mergeConfigs = exports.removeSecretSingle = exports.removeSecrets = exports.getWithEnvVars = exports.get = exports.enrich = exports.checkDatasourceTypes = void 0;
13
16
  const backend_core_1 = require("@budibase/backend-core");
@@ -16,6 +19,7 @@ const types_1 = require("@budibase/types");
16
19
  const fp_1 = require("lodash/fp");
17
20
  const utils_1 = require("../../utils");
18
21
  const integrations_1 = require("../../../integrations");
22
+ const lodash_1 = __importDefault(require("lodash"));
19
23
  const ENV_VAR_PREFIX = "env.";
20
24
  function checkDatasourceTypes(schema, config) {
21
25
  for (let key of Object.keys(config)) {
@@ -130,7 +134,7 @@ function removeSecretSingle(datasource) {
130
134
  }
131
135
  exports.removeSecretSingle = removeSecretSingle;
132
136
  function mergeConfigs(update, old) {
133
- var _a, _b, _c, _d;
137
+ var _a, _b, _c, _d, _e;
134
138
  if (!update.config) {
135
139
  return update;
136
140
  }
@@ -149,13 +153,16 @@ function mergeConfigs(update, old) {
149
153
  }
150
154
  }
151
155
  }
156
+ if ((_c = old.config) === null || _c === void 0 ? void 0 : _c.auth) {
157
+ update.config = lodash_1.default.merge(old.config, update.config);
158
+ }
152
159
  // update back to actual passwords for everything else
153
160
  for (let [key, value] of Object.entries(update.config)) {
154
161
  if (value !== types_1.PASSWORD_REPLACEMENT) {
155
162
  continue;
156
163
  }
157
- if ((_c = old.config) === null || _c === void 0 ? void 0 : _c[key]) {
158
- update.config[key] = (_d = old.config) === null || _d === void 0 ? void 0 : _d[key];
164
+ if ((_d = old.config) === null || _d === void 0 ? void 0 : _d[key]) {
165
+ update.config[key] = (_e = old.config) === null || _e === void 0 ? void 0 : _e[key];
159
166
  }
160
167
  else {
161
168
  delete update.config[key];