@budibase/server 2.7.7-alpha.3 → 2.7.7-alpha.4
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.b33e8ad5.css → index.3c336b18.css} +1 -1
- package/builder/assets/{index.7f26f181.js → index.4afe46bb.js} +374 -374
- package/builder/index.html +2 -2
- package/dist/automation.js +44 -14
- package/dist/automation.js.map +3 -3
- package/dist/index.js +69 -35
- package/dist/index.js.map +3 -3
- package/dist/query.js +44 -14
- package/dist/query.js.map +3 -3
- package/package.json +8 -8
- package/src/api/controllers/datasource.ts +28 -23
- package/src/integrations/googlesheets.ts +18 -17
- package/src/integrations/postgres.ts +2 -1
- package/src/sdk/app/datasources/datasources.ts +1 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/server",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "2.7.7-alpha.
|
|
4
|
+
"version": "2.7.7-alpha.4",
|
|
5
5
|
"description": "Budibase Web Server",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -46,12 +46,12 @@
|
|
|
46
46
|
"license": "GPL-3.0",
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@apidevtools/swagger-parser": "10.0.3",
|
|
49
|
-
"@budibase/backend-core": "2.7.7-alpha.
|
|
50
|
-
"@budibase/client": "2.7.7-alpha.
|
|
51
|
-
"@budibase/pro": "2.7.7-alpha.
|
|
52
|
-
"@budibase/shared-core": "2.7.7-alpha.
|
|
53
|
-
"@budibase/string-templates": "2.7.7-alpha.
|
|
54
|
-
"@budibase/types": "2.7.7-alpha.
|
|
49
|
+
"@budibase/backend-core": "2.7.7-alpha.4",
|
|
50
|
+
"@budibase/client": "2.7.7-alpha.4",
|
|
51
|
+
"@budibase/pro": "2.7.7-alpha.4",
|
|
52
|
+
"@budibase/shared-core": "2.7.7-alpha.4",
|
|
53
|
+
"@budibase/string-templates": "2.7.7-alpha.4",
|
|
54
|
+
"@budibase/types": "2.7.7-alpha.4",
|
|
55
55
|
"@bull-board/api": "3.7.0",
|
|
56
56
|
"@bull-board/koa": "3.9.4",
|
|
57
57
|
"@elastic/elasticsearch": "7.10.0",
|
|
@@ -195,5 +195,5 @@
|
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
197
|
},
|
|
198
|
-
"gitHead": "
|
|
198
|
+
"gitHead": "a8cf83aeb0c37afa6e3df230a5235c0ae18d98f6"
|
|
199
199
|
}
|
|
@@ -103,6 +103,22 @@ async function buildSchemaHelper(datasource: Datasource) {
|
|
|
103
103
|
return { tables: connector.tables, error }
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
async function buildFilteredSchema(datasource: Datasource, filter?: string[]) {
|
|
107
|
+
let { tables, error } = await buildSchemaHelper(datasource)
|
|
108
|
+
let finalTables = tables
|
|
109
|
+
if (filter) {
|
|
110
|
+
finalTables = {}
|
|
111
|
+
for (let key in tables) {
|
|
112
|
+
if (
|
|
113
|
+
filter.some((filter: any) => filter.toLowerCase() === key.toLowerCase())
|
|
114
|
+
) {
|
|
115
|
+
finalTables[key] = tables[key]
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return { tables: finalTables, error }
|
|
120
|
+
}
|
|
121
|
+
|
|
106
122
|
export async function fetch(ctx: UserCtx) {
|
|
107
123
|
// Get internal tables
|
|
108
124
|
const db = context.getAppDB()
|
|
@@ -174,43 +190,28 @@ export async function information(
|
|
|
174
190
|
}
|
|
175
191
|
const tableNames = await connector.getTableNames()
|
|
176
192
|
ctx.body = {
|
|
177
|
-
tableNames,
|
|
193
|
+
tableNames: tableNames.sort(),
|
|
178
194
|
}
|
|
179
195
|
}
|
|
180
196
|
|
|
181
197
|
export async function buildSchemaFromDb(ctx: UserCtx) {
|
|
182
198
|
const db = context.getAppDB()
|
|
183
|
-
const datasource = await sdk.datasources.get(ctx.params.datasourceId)
|
|
184
199
|
const tablesFilter = ctx.request.body.tablesFilter
|
|
200
|
+
const datasource = await sdk.datasources.get(ctx.params.datasourceId)
|
|
185
201
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
if (!datasource.entities) {
|
|
189
|
-
datasource.entities = {}
|
|
190
|
-
}
|
|
191
|
-
for (let key in tables) {
|
|
192
|
-
if (
|
|
193
|
-
tablesFilter.some(
|
|
194
|
-
(filter: any) => filter.toLowerCase() === key.toLowerCase()
|
|
195
|
-
)
|
|
196
|
-
) {
|
|
197
|
-
datasource.entities[key] = tables[key]
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
} else {
|
|
201
|
-
datasource.entities = tables
|
|
202
|
-
}
|
|
202
|
+
const { tables, error } = await buildFilteredSchema(datasource, tablesFilter)
|
|
203
|
+
datasource.entities = tables
|
|
203
204
|
|
|
204
205
|
setDefaultDisplayColumns(datasource)
|
|
205
206
|
const dbResp = await db.put(datasource)
|
|
206
207
|
datasource._rev = dbResp.rev
|
|
207
208
|
const cleanedDatasource = await sdk.datasources.removeSecretSingle(datasource)
|
|
208
209
|
|
|
209
|
-
const
|
|
210
|
+
const res: any = { datasource: cleanedDatasource }
|
|
210
211
|
if (error) {
|
|
211
|
-
|
|
212
|
+
res.error = error
|
|
212
213
|
}
|
|
213
|
-
ctx.body =
|
|
214
|
+
ctx.body = res
|
|
214
215
|
}
|
|
215
216
|
|
|
216
217
|
/**
|
|
@@ -320,6 +321,7 @@ export async function save(
|
|
|
320
321
|
const db = context.getAppDB()
|
|
321
322
|
const plus = ctx.request.body.datasource.plus
|
|
322
323
|
const fetchSchema = ctx.request.body.fetchSchema
|
|
324
|
+
const tablesFilter = ctx.request.body.tablesFilter
|
|
323
325
|
|
|
324
326
|
const datasource = {
|
|
325
327
|
_id: generateDatasourceID({ plus }),
|
|
@@ -329,7 +331,10 @@ export async function save(
|
|
|
329
331
|
|
|
330
332
|
let schemaError = null
|
|
331
333
|
if (fetchSchema) {
|
|
332
|
-
const { tables, error } = await
|
|
334
|
+
const { tables, error } = await buildFilteredSchema(
|
|
335
|
+
datasource,
|
|
336
|
+
tablesFilter
|
|
337
|
+
)
|
|
333
338
|
schemaError = error
|
|
334
339
|
datasource.entities = tables
|
|
335
340
|
setDefaultDisplayColumns(datasource)
|
|
@@ -21,7 +21,7 @@ import { buildExternalTableId, finaliseExternalTables } from "./utils"
|
|
|
21
21
|
import { GoogleSpreadsheet, GoogleSpreadsheetRow } from "google-spreadsheet"
|
|
22
22
|
import fetch from "node-fetch"
|
|
23
23
|
import { cache, configs, context, HTTPError } from "@budibase/backend-core"
|
|
24
|
-
import { dataFilters } from "@budibase/shared-core"
|
|
24
|
+
import { dataFilters, utils } from "@budibase/shared-core"
|
|
25
25
|
import { GOOGLE_SHEETS_PRIMARY_KEY } from "../constants"
|
|
26
26
|
import sdk from "../sdk"
|
|
27
27
|
|
|
@@ -150,7 +150,6 @@ class GoogleSheetsIntegration implements DatasourcePlus {
|
|
|
150
150
|
|
|
151
151
|
async testConnection(): Promise<ConnectionInfo> {
|
|
152
152
|
try {
|
|
153
|
-
await setupCreationAuth(this.config)
|
|
154
153
|
await this.connect()
|
|
155
154
|
return { connected: true }
|
|
156
155
|
} catch (e: any) {
|
|
@@ -211,6 +210,8 @@ class GoogleSheetsIntegration implements DatasourcePlus {
|
|
|
211
210
|
|
|
212
211
|
async connect() {
|
|
213
212
|
try {
|
|
213
|
+
await setupCreationAuth(this.config)
|
|
214
|
+
|
|
214
215
|
// Initialise oAuth client
|
|
215
216
|
let googleConfig = await configs.getGoogleDatasourceConfig()
|
|
216
217
|
if (!googleConfig) {
|
|
@@ -273,24 +274,24 @@ class GoogleSheetsIntegration implements DatasourcePlus {
|
|
|
273
274
|
}
|
|
274
275
|
|
|
275
276
|
async buildSchema(datasourceId: string, entities: Record<string, Table>) {
|
|
276
|
-
// not fully configured yet
|
|
277
|
-
if (!this.config.auth) {
|
|
278
|
-
return
|
|
279
|
-
}
|
|
280
277
|
await this.connect()
|
|
281
278
|
const sheets = this.client.sheetsByIndex
|
|
282
279
|
const tables: Record<string, Table> = {}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
sheet.title
|
|
290
|
-
sheet.
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
280
|
+
await utils.parallelForeach(
|
|
281
|
+
sheets,
|
|
282
|
+
async sheet => {
|
|
283
|
+
// must fetch rows to determine schema
|
|
284
|
+
await sheet.getRows({ limit: 0, offset: 0 })
|
|
285
|
+
|
|
286
|
+
const id = buildExternalTableId(datasourceId, sheet.title)
|
|
287
|
+
tables[sheet.title] = this.getTableSchema(
|
|
288
|
+
sheet.title,
|
|
289
|
+
sheet.headerValues,
|
|
290
|
+
id
|
|
291
|
+
)
|
|
292
|
+
},
|
|
293
|
+
10
|
|
294
|
+
)
|
|
294
295
|
const final = finaliseExternalTables(tables, entities)
|
|
295
296
|
this.tables = final.tables
|
|
296
297
|
this.schemaErrors = final.errors
|
|
@@ -322,7 +322,8 @@ class PostgresIntegration extends Sql implements DatasourcePlus {
|
|
|
322
322
|
await this.openConnection()
|
|
323
323
|
const columnsResponse: { rows: PostgresColumn[] } =
|
|
324
324
|
await this.client.query(this.COLUMNS_SQL)
|
|
325
|
-
|
|
325
|
+
const names = columnsResponse.rows.map(row => row.table_name)
|
|
326
|
+
return [...new Set(names)]
|
|
326
327
|
} finally {
|
|
327
328
|
await this.closeConnection()
|
|
328
329
|
}
|