@budibase/server 2.7.3 → 2.7.5-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/dist/query.js CHANGED
@@ -11478,8 +11478,8 @@ async function preAuth(passport2, ctx, next) {
11478
11478
  callbackUrl,
11479
11479
  ssoSaveUserNoOp
11480
11480
  );
11481
- if (!ctx.query.appId || !ctx.query.datasourceId) {
11482
- ctx.throw(400, "appId and datasourceId query params not present.");
11481
+ if (!ctx.query.appId) {
11482
+ ctx.throw(400, "appId query param not present.");
11483
11483
  }
11484
11484
  return passport2.authenticate(strategy, {
11485
11485
  scope: ["profile", "email", "https://www.googleapis.com/auth/spreadsheets"],
@@ -11499,7 +11499,7 @@ async function postAuth(passport2, ctx, next) {
11499
11499
  clientSecret: config.clientSecret,
11500
11500
  callbackURL: callbackUrl
11501
11501
  },
11502
- (accessToken, refreshToken, profile, done) => {
11502
+ (accessToken, refreshToken, _profile, done) => {
11503
11503
  clearCookie(ctx, "budibase:datasourceauth" /* DatasourceAuth */);
11504
11504
  done(null, { accessToken, refreshToken });
11505
11505
  }
@@ -11507,22 +11507,14 @@ async function postAuth(passport2, ctx, next) {
11507
11507
  { successRedirect: "/", failureRedirect: "/error" },
11508
11508
  async (err, tokens) => {
11509
11509
  const baseUrl = `/builder/app/${authStateCookie.appId}/data`;
11510
- await doWithDB(authStateCookie.appId, async (db) => {
11511
- let datasource2;
11512
- try {
11513
- datasource2 = await db.get(authStateCookie.datasourceId);
11514
- } catch (err2) {
11515
- if (err2.status === 404) {
11516
- ctx.redirect(baseUrl);
11517
- }
11518
- }
11519
- if (!datasource2.config) {
11520
- datasource2.config = {};
11510
+ const id = utils_exports2.newid();
11511
+ await cache_exports.store(
11512
+ `datasource:creation:${authStateCookie.appId}:google:${id}`,
11513
+ {
11514
+ tokens
11521
11515
  }
11522
- datasource2.config.auth = { type: "google", ...tokens };
11523
- await db.put(datasource2);
11524
- ctx.redirect(`${baseUrl}/datasource/${authStateCookie.datasourceId}`);
11525
- });
11516
+ );
11517
+ ctx.redirect(`${baseUrl}/new?continue_google_setup=${id}`);
11526
11518
  }
11527
11519
  )(ctx, next);
11528
11520
  }
@@ -17260,7 +17252,7 @@ var SCHEMA12 = {
17260
17252
  },
17261
17253
  datasource: {
17262
17254
  spreadsheetId: {
17263
- display: "Google Sheet URL",
17255
+ display: "Spreadsheet URL",
17264
17256
  type: "string" /* STRING */,
17265
17257
  required: true
17266
17258
  }
@@ -17330,6 +17322,7 @@ var GoogleSheetsIntegration = class {
17330
17322
  }
17331
17323
  async testConnection() {
17332
17324
  try {
17325
+ await setupCreationAuth(this.config);
17333
17326
  await this.connect();
17334
17327
  return { connected: true };
17335
17328
  } catch (e) {
@@ -17691,6 +17684,16 @@ var GoogleSheetsIntegration = class {
17691
17684
  }
17692
17685
  }
17693
17686
  };
17687
+ async function setupCreationAuth(datasouce) {
17688
+ if (datasouce.continueSetupId) {
17689
+ const appId = context_exports.getAppId();
17690
+ const tokens = await cache_exports.get(
17691
+ `datasource:creation:${appId}:google:${datasouce.continueSetupId}`
17692
+ );
17693
+ datasouce.auth = tokens.tokens;
17694
+ delete datasouce.continueSetupId;
17695
+ }
17696
+ }
17694
17697
  var googlesheets_default = {
17695
17698
  schema: SCHEMA12,
17696
17699
  integration: GoogleSheetsIntegration