@budibase/server 2.6.24-alpha.2 → 2.6.27

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) {
11473
- ctx.throw(400, "appId query param not present.");
11481
+ if (!ctx.query.appId || !ctx.query.datasourceId) {
11482
+ ctx.throw(400, "appId and datasourceId query params 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,14 +11507,22 @@ 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
- const id = utils_exports2.newid();
11502
- await cache_exports.store(
11503
- `datasource:creation:${authStateCookie.appId}:google:${id}`,
11504
- {
11505
- tokens
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
+ }
11506
11518
  }
11507
- );
11508
- ctx.redirect(`${baseUrl}/new?continue_google_setup=${id}`);
11519
+ if (!datasource2.config) {
11520
+ datasource2.config = {};
11521
+ }
11522
+ datasource2.config.auth = { type: "google", ...tokens };
11523
+ await db.put(datasource2);
11524
+ ctx.redirect(`${baseUrl}/datasource/${authStateCookie.datasourceId}`);
11525
+ });
11509
11526
  }
11510
11527
  )(ctx, next);
11511
11528
  }
@@ -17243,7 +17260,7 @@ var SCHEMA12 = {
17243
17260
  },
17244
17261
  datasource: {
17245
17262
  spreadsheetId: {
17246
- display: "Spreadsheet URL",
17263
+ display: "Google Sheet URL",
17247
17264
  type: "string" /* STRING */,
17248
17265
  required: true
17249
17266
  }
@@ -17313,7 +17330,6 @@ var GoogleSheetsIntegration = class {
17313
17330
  }
17314
17331
  async testConnection() {
17315
17332
  try {
17316
- await setupCreationAuth(this.config);
17317
17333
  await this.connect();
17318
17334
  return { connected: true };
17319
17335
  } catch (e) {
@@ -17675,16 +17691,6 @@ var GoogleSheetsIntegration = class {
17675
17691
  }
17676
17692
  }
17677
17693
  };
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
- }
17688
17694
  var googlesheets_default = {
17689
17695
  schema: SCHEMA12,
17690
17696
  integration: GoogleSheetsIntegration