@budibase/server 2.6.24-alpha.0 → 2.6.24-alpha.2

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
@@ -11469,8 +11469,8 @@ async function preAuth(passport2, ctx, next) {
11469
11469
  callbackUrl,
11470
11470
  ssoSaveUserNoOp
11471
11471
  );
11472
- if (!ctx.query.appId || !ctx.query.datasourceId) {
11473
- ctx.throw(400, "appId and datasourceId query params not present.");
11472
+ if (!ctx.query.appId) {
11473
+ ctx.throw(400, "appId query param not present.");
11474
11474
  }
11475
11475
  return passport2.authenticate(strategy, {
11476
11476
  scope: ["profile", "email", "https://www.googleapis.com/auth/spreadsheets"],
@@ -11490,7 +11490,7 @@ async function postAuth(passport2, ctx, next) {
11490
11490
  clientSecret: config.clientSecret,
11491
11491
  callbackURL: callbackUrl
11492
11492
  },
11493
- (accessToken, refreshToken, profile, done) => {
11493
+ (accessToken, refreshToken, _profile, done) => {
11494
11494
  clearCookie(ctx, "budibase:datasourceauth" /* DatasourceAuth */);
11495
11495
  done(null, { accessToken, refreshToken });
11496
11496
  }
@@ -11498,22 +11498,14 @@ async function postAuth(passport2, ctx, next) {
11498
11498
  { successRedirect: "/", failureRedirect: "/error" },
11499
11499
  async (err, tokens) => {
11500
11500
  const baseUrl = `/builder/app/${authStateCookie.appId}/data`;
11501
- await doWithDB(authStateCookie.appId, async (db) => {
11502
- let datasource2;
11503
- try {
11504
- datasource2 = await db.get(authStateCookie.datasourceId);
11505
- } catch (err2) {
11506
- if (err2.status === 404) {
11507
- ctx.redirect(baseUrl);
11508
- }
11509
- }
11510
- if (!datasource2.config) {
11511
- datasource2.config = {};
11501
+ const id = utils_exports2.newid();
11502
+ await cache_exports.store(
11503
+ `datasource:creation:${authStateCookie.appId}:google:${id}`,
11504
+ {
11505
+ tokens
11512
11506
  }
11513
- datasource2.config.auth = { type: "google", ...tokens };
11514
- await db.put(datasource2);
11515
- ctx.redirect(`${baseUrl}/datasource/${authStateCookie.datasourceId}`);
11516
- });
11507
+ );
11508
+ ctx.redirect(`${baseUrl}/new?continue_google_setup=${id}`);
11517
11509
  }
11518
11510
  )(ctx, next);
11519
11511
  }
@@ -17251,7 +17243,7 @@ var SCHEMA12 = {
17251
17243
  },
17252
17244
  datasource: {
17253
17245
  spreadsheetId: {
17254
- display: "Google Sheet URL",
17246
+ display: "Spreadsheet URL",
17255
17247
  type: "string" /* STRING */,
17256
17248
  required: true
17257
17249
  }
@@ -17321,6 +17313,7 @@ var GoogleSheetsIntegration = class {
17321
17313
  }
17322
17314
  async testConnection() {
17323
17315
  try {
17316
+ await setupCreationAuth(this.config);
17324
17317
  await this.connect();
17325
17318
  return { connected: true };
17326
17319
  } catch (e) {
@@ -17682,6 +17675,16 @@ var GoogleSheetsIntegration = class {
17682
17675
  }
17683
17676
  }
17684
17677
  };
17678
+ async function setupCreationAuth(datasouce) {
17679
+ if (datasouce.continueSetupId) {
17680
+ const appId = context_exports.getAppId();
17681
+ const tokens = await cache_exports.get(
17682
+ `datasource:creation:${appId}:google:${datasouce.continueSetupId}`
17683
+ );
17684
+ datasouce.auth = tokens.tokens;
17685
+ delete datasouce.continueSetupId;
17686
+ }
17687
+ }
17685
17688
  var googlesheets_default = {
17686
17689
  schema: SCHEMA12,
17687
17690
  integration: GoogleSheetsIntegration