@budibase/server 2.6.26 → 2.6.28-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
@@ -121,6 +121,7 @@ var init_event = __esm({
121
121
  Event6["USER_PASSWORD_UPDATED"] = "user:password:updated";
122
122
  Event6["USER_PASSWORD_RESET_REQUESTED"] = "user:password:reset:requested";
123
123
  Event6["USER_PASSWORD_RESET"] = "user:password:reset";
124
+ Event6["USER_DATA_COLLABORATION"] = "user:data:collaboration";
124
125
  Event6["EMAIL_SMTP_CREATED"] = "email:smtp:created";
125
126
  Event6["EMAIL_SMTP_UPDATED"] = "email:smtp:updated";
126
127
  Event6["AUTH_SSO_CREATED"] = "auth:sso:created";
@@ -271,6 +272,7 @@ var init_event = __esm({
271
272
  ["user:password:force:reset" /* USER_PASSWORD_FORCE_RESET */]: void 0,
272
273
  ["user_group:onboarding_added" /* USER_GROUP_ONBOARDING */]: void 0,
273
274
  ["user:onboarding:complete" /* USER_ONBOARDING_COMPLETE */]: void 0,
275
+ ["user:data:collaboration" /* USER_DATA_COLLABORATION */]: void 0,
274
276
  // EMAIL
275
277
  ["email:smtp:created" /* EMAIL_SMTP_CREATED */]: `Email configuration created`,
276
278
  ["email:smtp:updated" /* EMAIL_SMTP_UPDATED */]: `Email configuration updated`,
@@ -9952,6 +9954,12 @@ async function passwordReset(user) {
9952
9954
  };
9953
9955
  await publishEvent("user:password:reset" /* USER_PASSWORD_RESET */, properties);
9954
9956
  }
9957
+ async function dataCollaboration(users2) {
9958
+ const properties = {
9959
+ users: users2
9960
+ };
9961
+ await publishEvent("user:data:collaboration" /* USER_DATA_COLLABORATION */, properties);
9962
+ }
9955
9963
  var user_default = {
9956
9964
  created: created11,
9957
9965
  updated: updated6,
@@ -9966,7 +9974,8 @@ var user_default = {
9966
9974
  passwordForceReset,
9967
9975
  passwordUpdated,
9968
9976
  passwordResetRequested,
9969
- passwordReset
9977
+ passwordReset,
9978
+ dataCollaboration
9970
9979
  };
9971
9980
 
9972
9981
  // ../backend-core/src/events/publishers/view.ts
@@ -11469,8 +11478,8 @@ async function preAuth(passport2, ctx, next) {
11469
11478
  callbackUrl,
11470
11479
  ssoSaveUserNoOp
11471
11480
  );
11472
- if (!ctx.query.appId || !ctx.query.datasourceId) {
11473
- ctx.throw(400, "appId and datasourceId query params not present.");
11481
+ if (!ctx.query.appId) {
11482
+ ctx.throw(400, "appId query param not present.");
11474
11483
  }
11475
11484
  return passport2.authenticate(strategy, {
11476
11485
  scope: ["profile", "email", "https://www.googleapis.com/auth/spreadsheets"],
@@ -11490,7 +11499,7 @@ async function postAuth(passport2, ctx, next) {
11490
11499
  clientSecret: config.clientSecret,
11491
11500
  callbackURL: callbackUrl
11492
11501
  },
11493
- (accessToken, refreshToken, profile, done) => {
11502
+ (accessToken, refreshToken, _profile, done) => {
11494
11503
  clearCookie(ctx, "budibase:datasourceauth" /* DatasourceAuth */);
11495
11504
  done(null, { accessToken, refreshToken });
11496
11505
  }
@@ -11498,22 +11507,14 @@ async function postAuth(passport2, ctx, next) {
11498
11507
  { successRedirect: "/", failureRedirect: "/error" },
11499
11508
  async (err, tokens) => {
11500
11509
  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 = {};
11510
+ const id = utils_exports2.newid();
11511
+ await cache_exports.store(
11512
+ `datasource:creation:${authStateCookie.appId}:google:${id}`,
11513
+ {
11514
+ tokens
11512
11515
  }
11513
- datasource2.config.auth = { type: "google", ...tokens };
11514
- await db.put(datasource2);
11515
- ctx.redirect(`${baseUrl}/datasource/${authStateCookie.datasourceId}`);
11516
- });
11516
+ );
11517
+ ctx.redirect(`${baseUrl}/new?continue_google_setup=${id}`);
11517
11518
  }
11518
11519
  )(ctx, next);
11519
11520
  }
@@ -17251,7 +17252,7 @@ var SCHEMA12 = {
17251
17252
  },
17252
17253
  datasource: {
17253
17254
  spreadsheetId: {
17254
- display: "Google Sheet URL",
17255
+ display: "Spreadsheet URL",
17255
17256
  type: "string" /* STRING */,
17256
17257
  required: true
17257
17258
  }
@@ -17321,6 +17322,7 @@ var GoogleSheetsIntegration = class {
17321
17322
  }
17322
17323
  async testConnection() {
17323
17324
  try {
17325
+ await setupCreationAuth(this.config);
17324
17326
  await this.connect();
17325
17327
  return { connected: true };
17326
17328
  } catch (e) {
@@ -17682,6 +17684,16 @@ var GoogleSheetsIntegration = class {
17682
17684
  }
17683
17685
  }
17684
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
+ }
17685
17697
  var googlesheets_default = {
17686
17698
  schema: SCHEMA12,
17687
17699
  integration: GoogleSheetsIntegration