@budibase/server 2.6.16-alpha.5 → 2.6.17
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.
- package/builder/assets/{index.07382a47.css → index.86c992bf.css} +2 -2
- package/builder/assets/{index.b9eeb2a8.js → index.a40dcadd.js} +315 -307
- package/builder/index.html +2 -2
- package/dist/api/controllers/datasource.js +39 -70
- package/dist/api/controllers/integration.js +2 -2
- package/dist/api/routes/datasource.js +0 -1
- package/dist/automations/steps/make.js +5 -19
- package/dist/automations/steps/zapier.js +6 -19
- package/dist/automations/triggers.js +2 -1
- package/dist/automations/utils.js +22 -17
- package/dist/db/dynamoClient.js +1 -1
- package/dist/integrations/airtable.js +2 -28
- package/dist/integrations/arangodb.js +3 -19
- package/dist/integrations/couchdb.js +1 -16
- package/dist/integrations/dynamodb.js +0 -16
- package/dist/integrations/elasticsearch.js +0 -15
- package/dist/integrations/firebase.js +0 -15
- package/dist/integrations/googlesheets.js +1 -30
- package/dist/integrations/index.js +2 -5
- package/dist/integrations/microsoftSqlServer.js +0 -16
- package/dist/integrations/mongodb.js +0 -16
- package/dist/integrations/mysql.js +5 -21
- package/dist/integrations/oracle.js +0 -29
- package/dist/integrations/postgres.js +7 -26
- package/dist/integrations/redis.js +1 -20
- package/dist/integrations/s3.js +4 -23
- package/dist/integrations/snowflake.js +0 -15
- package/dist/migrations/functions/backfill/app/queries.js +2 -1
- package/dist/sdk/app/datasources/datasources.js +3 -10
- package/dist/threads/automation.js +2 -1
- package/dist/threads/index.js +2 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/jest.config.ts +3 -3
- package/nodemon.json +3 -7
- package/package.json +9 -10
- package/src/api/controllers/datasource.ts +49 -88
- package/src/api/controllers/integration.ts +3 -3
- package/src/api/routes/datasource.ts +0 -5
- package/src/automations/steps/make.ts +1 -18
- package/src/automations/steps/zapier.ts +1 -18
- package/src/automations/tests/zapier.spec.js +27 -0
- package/src/automations/triggers.ts +5 -3
- package/src/automations/utils.ts +23 -16
- package/src/db/dynamoClient.ts +1 -1
- package/src/definitions/automations.ts +1 -5
- package/src/integration-test/postgres.spec.ts +1 -0
- package/src/integrations/airtable.ts +4 -31
- package/src/integrations/arangodb.ts +2 -18
- package/src/integrations/couchdb.ts +4 -18
- package/src/integrations/dynamodb.ts +5 -34
- package/src/integrations/elasticsearch.ts +1 -16
- package/src/integrations/firebase.ts +0 -15
- package/src/integrations/googlesheets.ts +2 -31
- package/src/integrations/index.ts +7 -12
- package/src/integrations/microsoftSqlServer.ts +0 -16
- package/src/integrations/mongodb.ts +0 -16
- package/src/integrations/mysql.ts +16 -27
- package/src/integrations/oracle.ts +6 -28
- package/src/integrations/postgres.ts +3 -21
- package/src/integrations/redis.ts +3 -26
- package/src/integrations/s3.ts +3 -19
- package/src/integrations/snowflake.ts +1 -20
- package/src/migrations/functions/backfill/app/queries.ts +1 -1
- package/src/sdk/app/datasources/datasources.ts +1 -7
- package/src/threads/automation.ts +11 -6
- package/src/threads/definitions.ts +0 -2
- package/src/threads/index.ts +4 -2
- package/tsconfig.json +1 -1
- package/src/automations/tests/make.spec.ts +0 -54
- package/src/automations/tests/zapier.spec.ts +0 -56
|
@@ -3,13 +3,10 @@ import {
|
|
|
3
3
|
DatasourceFieldType,
|
|
4
4
|
QueryType,
|
|
5
5
|
IntegrationBase,
|
|
6
|
-
DatasourceFeature,
|
|
7
|
-
ConnectionInfo,
|
|
8
6
|
} from "@budibase/types"
|
|
9
7
|
|
|
10
8
|
import AWS from "aws-sdk"
|
|
11
9
|
import { AWS_REGION } from "../db/dynamoClient"
|
|
12
|
-
import { DocumentClient } from "aws-sdk/clients/dynamodb"
|
|
13
10
|
|
|
14
11
|
interface DynamoDBConfig {
|
|
15
12
|
region: string
|
|
@@ -25,7 +22,6 @@ const SCHEMA: Integration = {
|
|
|
25
22
|
"Amazon DynamoDB is a key-value and document database that delivers single-digit millisecond performance at any scale.",
|
|
26
23
|
friendlyName: "DynamoDB",
|
|
27
24
|
type: "Non-relational",
|
|
28
|
-
features: [DatasourceFeature.CONNECTION_CHECKING],
|
|
29
25
|
datasource: {
|
|
30
26
|
region: {
|
|
31
27
|
type: DatasourceFieldType.STRING,
|
|
@@ -132,7 +128,7 @@ const SCHEMA: Integration = {
|
|
|
132
128
|
|
|
133
129
|
class DynamoDBIntegration implements IntegrationBase {
|
|
134
130
|
private config: DynamoDBConfig
|
|
135
|
-
private client
|
|
131
|
+
private client: any
|
|
136
132
|
|
|
137
133
|
constructor(config: DynamoDBConfig) {
|
|
138
134
|
this.config = config
|
|
@@ -152,23 +148,7 @@ class DynamoDBIntegration implements IntegrationBase {
|
|
|
152
148
|
this.client = new AWS.DynamoDB.DocumentClient(this.config)
|
|
153
149
|
}
|
|
154
150
|
|
|
155
|
-
async
|
|
156
|
-
const response: ConnectionInfo = {
|
|
157
|
-
connected: false,
|
|
158
|
-
}
|
|
159
|
-
try {
|
|
160
|
-
const scanRes = await new AWS.DynamoDB(this.config).listTables().promise()
|
|
161
|
-
response.connected = !!scanRes.$response
|
|
162
|
-
} catch (e: any) {
|
|
163
|
-
response.error = e.message as string
|
|
164
|
-
}
|
|
165
|
-
return response
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
async create(query: {
|
|
169
|
-
table: string
|
|
170
|
-
json: Omit<DocumentClient.PutItemInput, "TableName">
|
|
171
|
-
}) {
|
|
151
|
+
async create(query: { table: string; json: object }) {
|
|
172
152
|
const params = {
|
|
173
153
|
TableName: query.table,
|
|
174
154
|
...query.json,
|
|
@@ -209,10 +189,7 @@ class DynamoDBIntegration implements IntegrationBase {
|
|
|
209
189
|
return new AWS.DynamoDB(this.config).describeTable(params).promise()
|
|
210
190
|
}
|
|
211
191
|
|
|
212
|
-
async get(query: {
|
|
213
|
-
table: string
|
|
214
|
-
json: Omit<DocumentClient.GetItemInput, "TableName">
|
|
215
|
-
}) {
|
|
192
|
+
async get(query: { table: string; json: object }) {
|
|
216
193
|
const params = {
|
|
217
194
|
TableName: query.table,
|
|
218
195
|
...query.json,
|
|
@@ -220,10 +197,7 @@ class DynamoDBIntegration implements IntegrationBase {
|
|
|
220
197
|
return this.client.get(params).promise()
|
|
221
198
|
}
|
|
222
199
|
|
|
223
|
-
async update(query: {
|
|
224
|
-
table: string
|
|
225
|
-
json: Omit<DocumentClient.UpdateItemInput, "TableName">
|
|
226
|
-
}) {
|
|
200
|
+
async update(query: { table: string; json: object }) {
|
|
227
201
|
const params = {
|
|
228
202
|
TableName: query.table,
|
|
229
203
|
...query.json,
|
|
@@ -231,10 +205,7 @@ class DynamoDBIntegration implements IntegrationBase {
|
|
|
231
205
|
return this.client.update(params).promise()
|
|
232
206
|
}
|
|
233
207
|
|
|
234
|
-
async delete(query: {
|
|
235
|
-
table: string
|
|
236
|
-
json: Omit<DocumentClient.DeleteItemInput, "TableName">
|
|
237
|
-
}) {
|
|
208
|
+
async delete(query: { table: string; json: object }) {
|
|
238
209
|
const params = {
|
|
239
210
|
TableName: query.table,
|
|
240
211
|
...query.json,
|
|
@@ -3,8 +3,6 @@ import {
|
|
|
3
3
|
DatasourceFieldType,
|
|
4
4
|
QueryType,
|
|
5
5
|
IntegrationBase,
|
|
6
|
-
DatasourceFeature,
|
|
7
|
-
ConnectionInfo,
|
|
8
6
|
} from "@budibase/types"
|
|
9
7
|
|
|
10
8
|
import { Client, ClientOptions } from "@elastic/elasticsearch"
|
|
@@ -22,7 +20,6 @@ const SCHEMA: Integration = {
|
|
|
22
20
|
"Elasticsearch is a search engine based on the Lucene library. It provides a distributed, multitenant-capable full-text search engine with an HTTP web interface and schema-free JSON documents.",
|
|
23
21
|
friendlyName: "ElasticSearch",
|
|
24
22
|
type: "Non-relational",
|
|
25
|
-
features: [DatasourceFeature.CONNECTION_CHECKING],
|
|
26
23
|
datasource: {
|
|
27
24
|
url: {
|
|
28
25
|
type: DatasourceFieldType.STRING,
|
|
@@ -98,7 +95,7 @@ const SCHEMA: Integration = {
|
|
|
98
95
|
|
|
99
96
|
class ElasticSearchIntegration implements IntegrationBase {
|
|
100
97
|
private config: ElasticsearchConfig
|
|
101
|
-
private client
|
|
98
|
+
private client: any
|
|
102
99
|
|
|
103
100
|
constructor(config: ElasticsearchConfig) {
|
|
104
101
|
this.config = config
|
|
@@ -117,18 +114,6 @@ class ElasticSearchIntegration implements IntegrationBase {
|
|
|
117
114
|
this.client = new Client(clientConfig)
|
|
118
115
|
}
|
|
119
116
|
|
|
120
|
-
async testConnection(): Promise<ConnectionInfo> {
|
|
121
|
-
try {
|
|
122
|
-
await this.client.info()
|
|
123
|
-
return { connected: true }
|
|
124
|
-
} catch (e: any) {
|
|
125
|
-
return {
|
|
126
|
-
connected: false,
|
|
127
|
-
error: e.message as string,
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
117
|
async create(query: { index: string; json: object }) {
|
|
133
118
|
const { index, json } = query
|
|
134
119
|
|
|
@@ -3,8 +3,6 @@ import {
|
|
|
3
3
|
Integration,
|
|
4
4
|
QueryType,
|
|
5
5
|
IntegrationBase,
|
|
6
|
-
DatasourceFeature,
|
|
7
|
-
ConnectionInfo,
|
|
8
6
|
} from "@budibase/types"
|
|
9
7
|
import { Firestore, WhereFilterOp } from "@google-cloud/firestore"
|
|
10
8
|
|
|
@@ -20,7 +18,6 @@ const SCHEMA: Integration = {
|
|
|
20
18
|
type: "Non-relational",
|
|
21
19
|
description:
|
|
22
20
|
"Cloud Firestore is a flexible, scalable database for mobile, web, and server development from Firebase and Google Cloud.",
|
|
23
|
-
features: [DatasourceFeature.CONNECTION_CHECKING],
|
|
24
21
|
datasource: {
|
|
25
22
|
email: {
|
|
26
23
|
type: DatasourceFieldType.STRING,
|
|
@@ -102,18 +99,6 @@ class FirebaseIntegration implements IntegrationBase {
|
|
|
102
99
|
})
|
|
103
100
|
}
|
|
104
101
|
|
|
105
|
-
async testConnection(): Promise<ConnectionInfo> {
|
|
106
|
-
try {
|
|
107
|
-
await this.client.listCollections()
|
|
108
|
-
return { connected: true }
|
|
109
|
-
} catch (e: any) {
|
|
110
|
-
return {
|
|
111
|
-
connected: false,
|
|
112
|
-
error: e.message as string,
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
102
|
async create(query: { json: object; extra: { [key: string]: string } }) {
|
|
118
103
|
try {
|
|
119
104
|
const documentReference = this.client
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
ConnectionInfo,
|
|
3
|
-
DatasourceFeature,
|
|
4
2
|
DatasourceFieldType,
|
|
5
3
|
DatasourcePlus,
|
|
6
4
|
FieldType,
|
|
@@ -17,7 +15,7 @@ import {
|
|
|
17
15
|
} from "@budibase/types"
|
|
18
16
|
import { OAuth2Client } from "google-auth-library"
|
|
19
17
|
import { buildExternalTableId, finaliseExternalTables } from "./utils"
|
|
20
|
-
import { GoogleSpreadsheet
|
|
18
|
+
import { GoogleSpreadsheet } from "google-spreadsheet"
|
|
21
19
|
import fetch from "node-fetch"
|
|
22
20
|
import { configs, HTTPError } from "@budibase/backend-core"
|
|
23
21
|
import { dataFilters } from "@budibase/shared-core"
|
|
@@ -66,7 +64,6 @@ const SCHEMA: Integration = {
|
|
|
66
64
|
"Create and collaborate on online spreadsheets in real-time and from any device. ",
|
|
67
65
|
friendlyName: "Google Sheets",
|
|
68
66
|
type: "Spreadsheet",
|
|
69
|
-
features: [DatasourceFeature.CONNECTION_CHECKING],
|
|
70
67
|
datasource: {
|
|
71
68
|
spreadsheetId: {
|
|
72
69
|
display: "Google Sheet URL",
|
|
@@ -142,19 +139,6 @@ class GoogleSheetsIntegration implements DatasourcePlus {
|
|
|
142
139
|
this.client = new GoogleSpreadsheet(spreadsheetId)
|
|
143
140
|
}
|
|
144
141
|
|
|
145
|
-
async testConnection(): Promise<ConnectionInfo> {
|
|
146
|
-
try {
|
|
147
|
-
await this.connect()
|
|
148
|
-
await this.client.loadInfo()
|
|
149
|
-
return { connected: true }
|
|
150
|
-
} catch (e: any) {
|
|
151
|
-
return {
|
|
152
|
-
connected: false,
|
|
153
|
-
error: e.message as string,
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
142
|
getBindingIdentifier() {
|
|
159
143
|
return ""
|
|
160
144
|
}
|
|
@@ -450,20 +434,7 @@ class GoogleSheetsIntegration implements DatasourcePlus {
|
|
|
450
434
|
try {
|
|
451
435
|
await this.connect()
|
|
452
436
|
const sheet = this.client.sheetsByTitle[query.sheet]
|
|
453
|
-
|
|
454
|
-
if (query.paginate) {
|
|
455
|
-
const limit = query.paginate.limit || 100
|
|
456
|
-
let page: number =
|
|
457
|
-
typeof query.paginate.page === "number"
|
|
458
|
-
? query.paginate.page
|
|
459
|
-
: parseInt(query.paginate.page || "1")
|
|
460
|
-
rows = await sheet.getRows({
|
|
461
|
-
limit,
|
|
462
|
-
offset: (page - 1) * limit,
|
|
463
|
-
})
|
|
464
|
-
} else {
|
|
465
|
-
rows = await sheet.getRows()
|
|
466
|
-
}
|
|
437
|
+
const rows = await sheet.getRows()
|
|
467
438
|
const filtered = dataFilters.runLuceneQuery(rows, query.filters)
|
|
468
439
|
const headerValues = sheet.headerValues
|
|
469
440
|
let response = []
|
|
@@ -20,7 +20,7 @@ import env from "../environment"
|
|
|
20
20
|
import { cloneDeep } from "lodash"
|
|
21
21
|
import sdk from "../sdk"
|
|
22
22
|
|
|
23
|
-
const DEFINITIONS:
|
|
23
|
+
const DEFINITIONS: { [key: string]: Integration } = {
|
|
24
24
|
[SourceName.POSTGRES]: postgres.schema,
|
|
25
25
|
[SourceName.DYNAMODB]: dynamodb.schema,
|
|
26
26
|
[SourceName.MONGODB]: mongodb.schema,
|
|
@@ -36,10 +36,9 @@ const DEFINITIONS: Record<SourceName, Integration | undefined> = {
|
|
|
36
36
|
[SourceName.GOOGLE_SHEETS]: googlesheets.schema,
|
|
37
37
|
[SourceName.REDIS]: redis.schema,
|
|
38
38
|
[SourceName.SNOWFLAKE]: snowflake.schema,
|
|
39
|
-
[SourceName.ORACLE]: undefined,
|
|
40
39
|
}
|
|
41
40
|
|
|
42
|
-
const INTEGRATIONS:
|
|
41
|
+
const INTEGRATIONS: { [key: string]: any } = {
|
|
43
42
|
[SourceName.POSTGRES]: postgres.integration,
|
|
44
43
|
[SourceName.DYNAMODB]: dynamodb.integration,
|
|
45
44
|
[SourceName.MONGODB]: mongodb.integration,
|
|
@@ -56,7 +55,6 @@ const INTEGRATIONS: Record<SourceName, any> = {
|
|
|
56
55
|
[SourceName.REDIS]: redis.integration,
|
|
57
56
|
[SourceName.FIRESTORE]: firebase.integration,
|
|
58
57
|
[SourceName.SNOWFLAKE]: snowflake.integration,
|
|
59
|
-
[SourceName.ORACLE]: undefined,
|
|
60
58
|
}
|
|
61
59
|
|
|
62
60
|
// optionally add oracle integration if the oracle binary can be installed
|
|
@@ -69,13 +67,10 @@ if (
|
|
|
69
67
|
INTEGRATIONS[SourceName.ORACLE] = oracle.integration
|
|
70
68
|
}
|
|
71
69
|
|
|
72
|
-
export async function getDefinition(
|
|
73
|
-
source: SourceName
|
|
74
|
-
): Promise<Integration | undefined> {
|
|
70
|
+
export async function getDefinition(source: SourceName): Promise<Integration> {
|
|
75
71
|
// check if its integrated, faster
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return definition
|
|
72
|
+
if (DEFINITIONS[source]) {
|
|
73
|
+
return DEFINITIONS[source]
|
|
79
74
|
}
|
|
80
75
|
const allDefinitions = await getDefinitions()
|
|
81
76
|
return allDefinitions[source]
|
|
@@ -103,7 +98,7 @@ export async function getDefinitions() {
|
|
|
103
98
|
}
|
|
104
99
|
}
|
|
105
100
|
|
|
106
|
-
export async function getIntegration(integration:
|
|
101
|
+
export async function getIntegration(integration: string) {
|
|
107
102
|
if (INTEGRATIONS[integration]) {
|
|
108
103
|
return INTEGRATIONS[integration]
|
|
109
104
|
}
|
|
@@ -112,7 +107,7 @@ export async function getIntegration(integration: SourceName) {
|
|
|
112
107
|
for (let plugin of plugins) {
|
|
113
108
|
if (plugin.name === integration) {
|
|
114
109
|
// need to use commonJS require due to its dynamic runtime nature
|
|
115
|
-
const retrieved = await getDatasourcePlugin(plugin)
|
|
110
|
+
const retrieved: any = await getDatasourcePlugin(plugin)
|
|
116
111
|
if (retrieved.integration) {
|
|
117
112
|
return retrieved.integration
|
|
118
113
|
} else {
|
|
@@ -8,8 +8,6 @@ import {
|
|
|
8
8
|
QueryType,
|
|
9
9
|
SqlQuery,
|
|
10
10
|
DatasourcePlus,
|
|
11
|
-
DatasourceFeature,
|
|
12
|
-
ConnectionInfo,
|
|
13
11
|
} from "@budibase/types"
|
|
14
12
|
import {
|
|
15
13
|
getSqlQuery,
|
|
@@ -41,7 +39,6 @@ const SCHEMA: Integration = {
|
|
|
41
39
|
"Microsoft SQL Server is a relational database management system developed by Microsoft. ",
|
|
42
40
|
friendlyName: "MS SQL Server",
|
|
43
41
|
type: "Relational",
|
|
44
|
-
features: [DatasourceFeature.CONNECTION_CHECKING],
|
|
45
42
|
datasource: {
|
|
46
43
|
user: {
|
|
47
44
|
type: DatasourceFieldType.STRING,
|
|
@@ -124,19 +121,6 @@ class SqlServerIntegration extends Sql implements DatasourcePlus {
|
|
|
124
121
|
}
|
|
125
122
|
}
|
|
126
123
|
|
|
127
|
-
async testConnection() {
|
|
128
|
-
const response: ConnectionInfo = {
|
|
129
|
-
connected: false,
|
|
130
|
-
}
|
|
131
|
-
try {
|
|
132
|
-
await this.connect()
|
|
133
|
-
response.connected = true
|
|
134
|
-
} catch (e: any) {
|
|
135
|
-
response.error = e.message as string
|
|
136
|
-
}
|
|
137
|
-
return response
|
|
138
|
-
}
|
|
139
|
-
|
|
140
124
|
getBindingIdentifier(): string {
|
|
141
125
|
return `@p${this.index++}`
|
|
142
126
|
}
|
|
@@ -3,8 +3,6 @@ import {
|
|
|
3
3
|
DatasourceFieldType,
|
|
4
4
|
QueryType,
|
|
5
5
|
IntegrationBase,
|
|
6
|
-
DatasourceFeature,
|
|
7
|
-
ConnectionInfo,
|
|
8
6
|
} from "@budibase/types"
|
|
9
7
|
import {
|
|
10
8
|
MongoClient,
|
|
@@ -40,7 +38,6 @@ const getSchema = () => {
|
|
|
40
38
|
type: "Non-relational",
|
|
41
39
|
description:
|
|
42
40
|
"MongoDB is a general purpose, document-based, distributed database built for modern application developers and for the cloud era.",
|
|
43
|
-
features: [DatasourceFeature.CONNECTION_CHECKING],
|
|
44
41
|
datasource: {
|
|
45
42
|
connectionString: {
|
|
46
43
|
type: DatasourceFieldType.STRING,
|
|
@@ -361,19 +358,6 @@ class MongoIntegration implements IntegrationBase {
|
|
|
361
358
|
this.client = new MongoClient(config.connectionString, options)
|
|
362
359
|
}
|
|
363
360
|
|
|
364
|
-
async testConnection() {
|
|
365
|
-
const response: ConnectionInfo = {
|
|
366
|
-
connected: false,
|
|
367
|
-
}
|
|
368
|
-
try {
|
|
369
|
-
await this.connect()
|
|
370
|
-
response.connected = true
|
|
371
|
-
} catch (e: any) {
|
|
372
|
-
response.error = e.message as string
|
|
373
|
-
}
|
|
374
|
-
return response
|
|
375
|
-
}
|
|
376
|
-
|
|
377
361
|
async connect() {
|
|
378
362
|
return this.client.connect()
|
|
379
363
|
}
|
|
@@ -7,8 +7,6 @@ import {
|
|
|
7
7
|
Table,
|
|
8
8
|
TableSchema,
|
|
9
9
|
DatasourcePlus,
|
|
10
|
-
DatasourceFeature,
|
|
11
|
-
ConnectionInfo,
|
|
12
10
|
} from "@budibase/types"
|
|
13
11
|
import {
|
|
14
12
|
getSqlQuery,
|
|
@@ -22,11 +20,18 @@ import { NUMBER_REGEX } from "../utilities"
|
|
|
22
20
|
import Sql from "./base/sql"
|
|
23
21
|
import { MySQLColumn } from "./base/types"
|
|
24
22
|
|
|
25
|
-
|
|
23
|
+
const mysql = require("mysql2/promise")
|
|
26
24
|
|
|
27
|
-
interface MySQLConfig
|
|
25
|
+
interface MySQLConfig {
|
|
26
|
+
host: string
|
|
27
|
+
port: number
|
|
28
|
+
user: string
|
|
29
|
+
password: string
|
|
28
30
|
database: string
|
|
31
|
+
ssl?: { [key: string]: any }
|
|
29
32
|
rejectUnauthorized: boolean
|
|
33
|
+
typeCast: Function
|
|
34
|
+
multipleStatements: boolean
|
|
30
35
|
}
|
|
31
36
|
|
|
32
37
|
const SCHEMA: Integration = {
|
|
@@ -36,7 +41,6 @@ const SCHEMA: Integration = {
|
|
|
36
41
|
type: "Relational",
|
|
37
42
|
description:
|
|
38
43
|
"MySQL Database Service is a fully managed database service to deploy cloud-native applications. ",
|
|
39
|
-
features: [DatasourceFeature.CONNECTION_CHECKING],
|
|
40
44
|
datasource: {
|
|
41
45
|
host: {
|
|
42
46
|
type: DatasourceFieldType.STRING,
|
|
@@ -88,6 +92,8 @@ const SCHEMA: Integration = {
|
|
|
88
92
|
},
|
|
89
93
|
}
|
|
90
94
|
|
|
95
|
+
const TimezoneAwareDateTypes = ["timestamp"]
|
|
96
|
+
|
|
91
97
|
function bindingTypeCoerce(bindings: any[]) {
|
|
92
98
|
for (let i = 0; i < bindings.length; i++) {
|
|
93
99
|
const binding = bindings[i]
|
|
@@ -114,7 +120,7 @@ function bindingTypeCoerce(bindings: any[]) {
|
|
|
114
120
|
|
|
115
121
|
class MySQLIntegration extends Sql implements DatasourcePlus {
|
|
116
122
|
private config: MySQLConfig
|
|
117
|
-
private client
|
|
123
|
+
private client: any
|
|
118
124
|
public tables: Record<string, Table> = {}
|
|
119
125
|
public schemaErrors: Record<string, string> = {}
|
|
120
126
|
|
|
@@ -128,8 +134,7 @@ class MySQLIntegration extends Sql implements DatasourcePlus {
|
|
|
128
134
|
if (
|
|
129
135
|
config.rejectUnauthorized != null &&
|
|
130
136
|
!config.rejectUnauthorized &&
|
|
131
|
-
config.ssl
|
|
132
|
-
typeof config.ssl !== "string"
|
|
137
|
+
config.ssl
|
|
133
138
|
) {
|
|
134
139
|
config.ssl.rejectUnauthorized = config.rejectUnauthorized
|
|
135
140
|
}
|
|
@@ -155,22 +160,6 @@ class MySQLIntegration extends Sql implements DatasourcePlus {
|
|
|
155
160
|
}
|
|
156
161
|
}
|
|
157
162
|
|
|
158
|
-
async testConnection() {
|
|
159
|
-
const response: ConnectionInfo = {
|
|
160
|
-
connected: false,
|
|
161
|
-
}
|
|
162
|
-
try {
|
|
163
|
-
const [result] = await this.internalQuery(
|
|
164
|
-
{ sql: "SELECT 1+1 AS checkRes" },
|
|
165
|
-
{ connect: true }
|
|
166
|
-
)
|
|
167
|
-
response.connected = result?.checkRes == 2
|
|
168
|
-
} catch (e: any) {
|
|
169
|
-
response.error = e.message as string
|
|
170
|
-
}
|
|
171
|
-
return response
|
|
172
|
-
}
|
|
173
|
-
|
|
174
163
|
getBindingIdentifier(): string {
|
|
175
164
|
return "?"
|
|
176
165
|
}
|
|
@@ -184,7 +173,7 @@ class MySQLIntegration extends Sql implements DatasourcePlus {
|
|
|
184
173
|
}
|
|
185
174
|
|
|
186
175
|
async disconnect() {
|
|
187
|
-
await this.client
|
|
176
|
+
await this.client.end()
|
|
188
177
|
}
|
|
189
178
|
|
|
190
179
|
async internalQuery(
|
|
@@ -203,10 +192,10 @@ class MySQLIntegration extends Sql implements DatasourcePlus {
|
|
|
203
192
|
? baseBindings
|
|
204
193
|
: bindingTypeCoerce(baseBindings)
|
|
205
194
|
// Node MySQL is callback based, so we must wrap our call in a promise
|
|
206
|
-
const response = await this.client
|
|
195
|
+
const response = await this.client.query(query.sql, bindings)
|
|
207
196
|
return response[0]
|
|
208
197
|
} finally {
|
|
209
|
-
if (opts?.connect
|
|
198
|
+
if (opts?.connect) {
|
|
210
199
|
await this.disconnect()
|
|
211
200
|
}
|
|
212
201
|
}
|
|
@@ -7,8 +7,6 @@ import {
|
|
|
7
7
|
SqlQuery,
|
|
8
8
|
Table,
|
|
9
9
|
DatasourcePlus,
|
|
10
|
-
DatasourceFeature,
|
|
11
|
-
ConnectionInfo,
|
|
12
10
|
} from "@budibase/types"
|
|
13
11
|
import {
|
|
14
12
|
buildExternalTableId,
|
|
@@ -26,7 +24,12 @@ import {
|
|
|
26
24
|
ExecuteOptions,
|
|
27
25
|
Result,
|
|
28
26
|
} from "oracledb"
|
|
29
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
OracleTable,
|
|
29
|
+
OracleColumn,
|
|
30
|
+
OracleColumnsResponse,
|
|
31
|
+
OracleConstraint,
|
|
32
|
+
} from "./base/types"
|
|
30
33
|
let oracledb: any
|
|
31
34
|
try {
|
|
32
35
|
oracledb = require("oracledb")
|
|
@@ -50,7 +53,6 @@ const SCHEMA: Integration = {
|
|
|
50
53
|
type: "Relational",
|
|
51
54
|
description:
|
|
52
55
|
"Oracle Database is an object-relational database management system developed by Oracle Corporation",
|
|
53
|
-
features: [DatasourceFeature.CONNECTION_CHECKING],
|
|
54
56
|
datasource: {
|
|
55
57
|
host: {
|
|
56
58
|
type: DatasourceFieldType.STRING,
|
|
@@ -323,30 +325,6 @@ class OracleIntegration extends Sql implements DatasourcePlus {
|
|
|
323
325
|
this.schemaErrors = final.errors
|
|
324
326
|
}
|
|
325
327
|
|
|
326
|
-
async testConnection() {
|
|
327
|
-
const response: ConnectionInfo = {
|
|
328
|
-
connected: false,
|
|
329
|
-
}
|
|
330
|
-
let connection
|
|
331
|
-
try {
|
|
332
|
-
connection = await this.getConnection()
|
|
333
|
-
response.connected = true
|
|
334
|
-
} catch (err: any) {
|
|
335
|
-
response.connected = false
|
|
336
|
-
response.error = err.message
|
|
337
|
-
} finally {
|
|
338
|
-
if (connection) {
|
|
339
|
-
try {
|
|
340
|
-
await connection.close()
|
|
341
|
-
} catch (err: any) {
|
|
342
|
-
response.connected = false
|
|
343
|
-
response.error = err.message
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
return response
|
|
348
|
-
}
|
|
349
|
-
|
|
350
328
|
private async internalQuery<T>(query: SqlQuery): Promise<Result<T>> {
|
|
351
329
|
let connection
|
|
352
330
|
try {
|
|
@@ -6,8 +6,6 @@ import {
|
|
|
6
6
|
SqlQuery,
|
|
7
7
|
Table,
|
|
8
8
|
DatasourcePlus,
|
|
9
|
-
DatasourceFeature,
|
|
10
|
-
ConnectionInfo,
|
|
11
9
|
} from "@budibase/types"
|
|
12
10
|
import {
|
|
13
11
|
getSqlQuery,
|
|
@@ -20,7 +18,7 @@ import Sql from "./base/sql"
|
|
|
20
18
|
import { PostgresColumn } from "./base/types"
|
|
21
19
|
import { escapeDangerousCharacters } from "../utilities"
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
const { Client, types } = require("pg")
|
|
24
22
|
|
|
25
23
|
// Return "date" and "timestamp" types as plain strings.
|
|
26
24
|
// This lets us reference the original stored timezone.
|
|
@@ -52,7 +50,6 @@ const SCHEMA: Integration = {
|
|
|
52
50
|
type: "Relational",
|
|
53
51
|
description:
|
|
54
52
|
"PostgreSQL, also known as Postgres, is a free and open-source relational database management system emphasizing extensibility and SQL compliance.",
|
|
55
|
-
features: [DatasourceFeature.CONNECTION_CHECKING],
|
|
56
53
|
datasource: {
|
|
57
54
|
host: {
|
|
58
55
|
type: DatasourceFieldType.STRING,
|
|
@@ -117,7 +114,7 @@ const SCHEMA: Integration = {
|
|
|
117
114
|
}
|
|
118
115
|
|
|
119
116
|
class PostgresIntegration extends Sql implements DatasourcePlus {
|
|
120
|
-
private readonly client:
|
|
117
|
+
private readonly client: any
|
|
121
118
|
private readonly config: PostgresConfig
|
|
122
119
|
private index: number = 1
|
|
123
120
|
private open: boolean
|
|
@@ -153,21 +150,6 @@ class PostgresIntegration extends Sql implements DatasourcePlus {
|
|
|
153
150
|
this.open = false
|
|
154
151
|
}
|
|
155
152
|
|
|
156
|
-
async testConnection() {
|
|
157
|
-
const response: ConnectionInfo = {
|
|
158
|
-
connected: false,
|
|
159
|
-
}
|
|
160
|
-
try {
|
|
161
|
-
await this.openConnection()
|
|
162
|
-
response.connected = true
|
|
163
|
-
} catch (e: any) {
|
|
164
|
-
response.error = e.message as string
|
|
165
|
-
} finally {
|
|
166
|
-
await this.closeConnection()
|
|
167
|
-
}
|
|
168
|
-
return response
|
|
169
|
-
}
|
|
170
|
-
|
|
171
153
|
getBindingIdentifier(): string {
|
|
172
154
|
return `$${this.index++}`
|
|
173
155
|
}
|
|
@@ -181,7 +163,7 @@ class PostgresIntegration extends Sql implements DatasourcePlus {
|
|
|
181
163
|
if (!this.config.schema) {
|
|
182
164
|
this.config.schema = "public"
|
|
183
165
|
}
|
|
184
|
-
|
|
166
|
+
this.client.query(`SET search_path TO ${this.config.schema}`)
|
|
185
167
|
this.COLUMNS_SQL = `select * from information_schema.columns where table_schema = '${this.config.schema}'`
|
|
186
168
|
this.open = true
|
|
187
169
|
}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ConnectionInfo,
|
|
3
|
-
DatasourceFeature,
|
|
4
|
-
DatasourceFieldType,
|
|
5
|
-
Integration,
|
|
6
|
-
QueryType,
|
|
7
|
-
} from "@budibase/types"
|
|
1
|
+
import { DatasourceFieldType, Integration, QueryType } from "@budibase/types"
|
|
8
2
|
import Redis from "ioredis"
|
|
9
3
|
|
|
10
4
|
interface RedisConfig {
|
|
@@ -17,11 +11,9 @@ interface RedisConfig {
|
|
|
17
11
|
|
|
18
12
|
const SCHEMA: Integration = {
|
|
19
13
|
docs: "https://redis.io/docs/",
|
|
20
|
-
description:
|
|
21
|
-
"Redis is a caching tool, providing powerful key-value store capabilities.",
|
|
14
|
+
description: "",
|
|
22
15
|
friendlyName: "Redis",
|
|
23
16
|
type: "Non-relational",
|
|
24
|
-
features: [DatasourceFeature.CONNECTION_CHECKING],
|
|
25
17
|
datasource: {
|
|
26
18
|
host: {
|
|
27
19
|
type: "string",
|
|
@@ -94,7 +86,7 @@ const SCHEMA: Integration = {
|
|
|
94
86
|
|
|
95
87
|
class RedisIntegration {
|
|
96
88
|
private readonly config: RedisConfig
|
|
97
|
-
private client
|
|
89
|
+
private client: any
|
|
98
90
|
|
|
99
91
|
constructor(config: RedisConfig) {
|
|
100
92
|
this.config = config
|
|
@@ -107,21 +99,6 @@ class RedisIntegration {
|
|
|
107
99
|
})
|
|
108
100
|
}
|
|
109
101
|
|
|
110
|
-
async testConnection() {
|
|
111
|
-
const response: ConnectionInfo = {
|
|
112
|
-
connected: false,
|
|
113
|
-
}
|
|
114
|
-
try {
|
|
115
|
-
await this.client.ping()
|
|
116
|
-
response.connected = true
|
|
117
|
-
} catch (e: any) {
|
|
118
|
-
response.error = e.message as string
|
|
119
|
-
} finally {
|
|
120
|
-
await this.disconnect()
|
|
121
|
-
}
|
|
122
|
-
return response
|
|
123
|
-
}
|
|
124
|
-
|
|
125
102
|
async disconnect() {
|
|
126
103
|
return this.client.quit()
|
|
127
104
|
}
|