@budibase/server 2.7.0 → 2.7.1-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.
- package/builder/assets/{index.4ca5529d.js → index.933787a7.js} +326 -326
- package/builder/assets/{index.a86e2071.css → index.b33e8ad5.css} +1 -1
- package/builder/index.html +2 -2
- package/dist/automation.js +45 -34
- package/dist/automation.js.map +3 -3
- package/dist/index.js +49 -34
- package/dist/index.js.map +3 -3
- package/dist/query.js +22 -19
- package/dist/query.js.map +3 -3
- package/package.json +8 -8
- package/src/api/controllers/datasource.ts +13 -1
- package/src/integrations/googlesheets.ts +18 -2
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.0",
|
|
4
|
+
"version": "2.7.1-alpha.0",
|
|
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.0",
|
|
50
|
-
"@budibase/client": "2.7.0",
|
|
51
|
-
"@budibase/pro": "2.7.0",
|
|
52
|
-
"@budibase/shared-core": "2.7.0",
|
|
53
|
-
"@budibase/string-templates": "2.7.0",
|
|
54
|
-
"@budibase/types": "2.7.0",
|
|
49
|
+
"@budibase/backend-core": "2.7.1-alpha.0",
|
|
50
|
+
"@budibase/client": "2.7.1-alpha.0",
|
|
51
|
+
"@budibase/pro": "2.7.1-alpha.0",
|
|
52
|
+
"@budibase/shared-core": "2.7.1-alpha.0",
|
|
53
|
+
"@budibase/string-templates": "2.7.1-alpha.0",
|
|
54
|
+
"@budibase/types": "2.7.1-alpha.0",
|
|
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": "a99cd6d05e279eee8ac149d01194344197d2ead5"
|
|
199
199
|
}
|
|
@@ -11,7 +11,7 @@ import { BuildSchemaErrors, InvalidColumns } from "../../constants"
|
|
|
11
11
|
import { getIntegration } from "../../integrations"
|
|
12
12
|
import { getDatasourceAndQuery } from "./row/utils"
|
|
13
13
|
import { invalidateDynamicVariables } from "../../threads/utils"
|
|
14
|
-
import { db as dbCore, context, events } from "@budibase/backend-core"
|
|
14
|
+
import { db as dbCore, context, events, cache } from "@budibase/backend-core"
|
|
15
15
|
import {
|
|
16
16
|
UserCtx,
|
|
17
17
|
Datasource,
|
|
@@ -25,9 +25,11 @@ import {
|
|
|
25
25
|
FetchDatasourceInfoResponse,
|
|
26
26
|
IntegrationBase,
|
|
27
27
|
DatasourcePlus,
|
|
28
|
+
SourceName,
|
|
28
29
|
} from "@budibase/types"
|
|
29
30
|
import sdk from "../../sdk"
|
|
30
31
|
import { builderSocket } from "../../websockets"
|
|
32
|
+
import { setupCreationAuth as googleSetupCreationAuth } from "src/integrations/googlesheets"
|
|
31
33
|
|
|
32
34
|
function getErrorTables(errors: any, errorType: string) {
|
|
33
35
|
return Object.entries(errors)
|
|
@@ -306,6 +308,12 @@ export async function update(ctx: UserCtx<any, UpdateDatasourceResponse>) {
|
|
|
306
308
|
builderSocket?.emitDatasourceUpdate(ctx, datasource)
|
|
307
309
|
}
|
|
308
310
|
|
|
311
|
+
const preSaveAction: Partial<Record<SourceName, any>> = {
|
|
312
|
+
[SourceName.GOOGLE_SHEETS]: async (datasource: Datasource) => {
|
|
313
|
+
await googleSetupCreationAuth(datasource.config as any)
|
|
314
|
+
},
|
|
315
|
+
}
|
|
316
|
+
|
|
309
317
|
export async function save(
|
|
310
318
|
ctx: UserCtx<CreateDatasourceRequest, CreateDatasourceResponse>
|
|
311
319
|
) {
|
|
@@ -327,6 +335,10 @@ export async function save(
|
|
|
327
335
|
setDefaultDisplayColumns(datasource)
|
|
328
336
|
}
|
|
329
337
|
|
|
338
|
+
if (preSaveAction[datasource.source]) {
|
|
339
|
+
await preSaveAction[datasource.source](datasource)
|
|
340
|
+
}
|
|
341
|
+
|
|
330
342
|
const dbResp = await db.put(datasource)
|
|
331
343
|
await events.datasource.created(datasource)
|
|
332
344
|
datasource._rev = dbResp.rev
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ConnectionInfo,
|
|
3
|
+
Datasource,
|
|
3
4
|
DatasourceFeature,
|
|
4
5
|
DatasourceFieldType,
|
|
5
6
|
DatasourcePlus,
|
|
@@ -19,13 +20,15 @@ import { OAuth2Client } from "google-auth-library"
|
|
|
19
20
|
import { buildExternalTableId, finaliseExternalTables } from "./utils"
|
|
20
21
|
import { GoogleSpreadsheet, GoogleSpreadsheetRow } from "google-spreadsheet"
|
|
21
22
|
import fetch from "node-fetch"
|
|
22
|
-
import { configs, HTTPError } from "@budibase/backend-core"
|
|
23
|
+
import { cache, configs, context, HTTPError } from "@budibase/backend-core"
|
|
23
24
|
import { dataFilters } from "@budibase/shared-core"
|
|
24
25
|
import { GOOGLE_SHEETS_PRIMARY_KEY } from "../constants"
|
|
26
|
+
import sdk from "../sdk"
|
|
25
27
|
|
|
26
28
|
interface GoogleSheetsConfig {
|
|
27
29
|
spreadsheetId: string
|
|
28
30
|
auth: OAuthClientConfig
|
|
31
|
+
continueSetupId?: string
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
interface OAuthClientConfig {
|
|
@@ -72,7 +75,7 @@ const SCHEMA: Integration = {
|
|
|
72
75
|
},
|
|
73
76
|
datasource: {
|
|
74
77
|
spreadsheetId: {
|
|
75
|
-
display: "
|
|
78
|
+
display: "Spreadsheet URL",
|
|
76
79
|
type: DatasourceFieldType.STRING,
|
|
77
80
|
required: true,
|
|
78
81
|
},
|
|
@@ -147,6 +150,7 @@ class GoogleSheetsIntegration implements DatasourcePlus {
|
|
|
147
150
|
|
|
148
151
|
async testConnection(): Promise<ConnectionInfo> {
|
|
149
152
|
try {
|
|
153
|
+
await setupCreationAuth(this.config)
|
|
150
154
|
await this.connect()
|
|
151
155
|
return { connected: true }
|
|
152
156
|
} catch (e: any) {
|
|
@@ -566,6 +570,18 @@ class GoogleSheetsIntegration implements DatasourcePlus {
|
|
|
566
570
|
}
|
|
567
571
|
}
|
|
568
572
|
|
|
573
|
+
export async function setupCreationAuth(datasouce: GoogleSheetsConfig) {
|
|
574
|
+
if (datasouce.continueSetupId) {
|
|
575
|
+
const appId = context.getAppId()
|
|
576
|
+
const tokens = await cache.get(
|
|
577
|
+
`datasource:creation:${appId}:google:${datasouce.continueSetupId}`
|
|
578
|
+
)
|
|
579
|
+
|
|
580
|
+
datasouce.auth = tokens.tokens
|
|
581
|
+
delete datasouce.continueSetupId
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
|
|
569
585
|
export default {
|
|
570
586
|
schema: SCHEMA,
|
|
571
587
|
integration: GoogleSheetsIntegration,
|