@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.
@@ -8,8 +8,8 @@
8
8
  <link rel="preconnect" href="https://fonts.gstatic.com" />
9
9
  <link href="https://fonts.googleapis.com/css2?family=Source+Sans+Pro:wght@400;600;700&display=swap"
10
10
  rel="stylesheet" />
11
- <script type="module" crossorigin src="/builder/assets/index.edf18bd3.js"></script>
12
- <link rel="stylesheet" href="/builder/assets/index.b33e8ad5.css">
11
+ <script type="module" crossorigin src="/builder/assets/index.4ca5529d.js"></script>
12
+ <link rel="stylesheet" href="/builder/assets/index.a86e2071.css">
13
13
  </head>
14
14
 
15
15
  <body id="app">
@@ -229,6 +229,7 @@ var init_event = __esm({
229
229
  Event6["USER_PASSWORD_UPDATED"] = "user:password:updated";
230
230
  Event6["USER_PASSWORD_RESET_REQUESTED"] = "user:password:reset:requested";
231
231
  Event6["USER_PASSWORD_RESET"] = "user:password:reset";
232
+ Event6["USER_DATA_COLLABORATION"] = "user:data:collaboration";
232
233
  Event6["EMAIL_SMTP_CREATED"] = "email:smtp:created";
233
234
  Event6["EMAIL_SMTP_UPDATED"] = "email:smtp:updated";
234
235
  Event6["AUTH_SSO_CREATED"] = "auth:sso:created";
@@ -379,6 +380,7 @@ var init_event = __esm({
379
380
  ["user:password:force:reset" /* USER_PASSWORD_FORCE_RESET */]: void 0,
380
381
  ["user_group:onboarding_added" /* USER_GROUP_ONBOARDING */]: void 0,
381
382
  ["user:onboarding:complete" /* USER_ONBOARDING_COMPLETE */]: void 0,
383
+ ["user:data:collaboration" /* USER_DATA_COLLABORATION */]: void 0,
382
384
  // EMAIL
383
385
  ["email:smtp:created" /* EMAIL_SMTP_CREATED */]: `Email configuration created`,
384
386
  ["email:smtp:updated" /* EMAIL_SMTP_UPDATED */]: `Email configuration updated`,
@@ -5355,11 +5357,11 @@ function makeCacheItem(doc, lastWrite = null) {
5355
5357
  return { doc, lastWrite: lastWrite || Date.now() };
5356
5358
  }
5357
5359
  async function put(db2, doc, writeRateMs = DEFAULT_WRITE_RATE_MS) {
5358
- const cache3 = await getCache();
5360
+ const cache2 = await getCache();
5359
5361
  const key = doc._id;
5360
5362
  let cacheItem;
5361
5363
  if (key) {
5362
- cacheItem = await cache3.get(makeCacheKey(db2, key));
5364
+ cacheItem = await cache2.get(makeCacheKey(db2, key));
5363
5365
  }
5364
5366
  const updateDb = !cacheItem || cacheItem.lastWrite < Date.now() - writeRateMs;
5365
5367
  let output = doc;
@@ -5397,30 +5399,30 @@ async function put(db2, doc, writeRateMs = DEFAULT_WRITE_RATE_MS) {
5397
5399
  }
5398
5400
  cacheItem = makeCacheItem(output, updateDb ? null : cacheItem == null ? void 0 : cacheItem.lastWrite);
5399
5401
  if (output._id) {
5400
- await cache3.store(makeCacheKey(db2, output._id), cacheItem);
5402
+ await cache2.store(makeCacheKey(db2, output._id), cacheItem);
5401
5403
  }
5402
5404
  return { ok: true, id: output._id, rev: output._rev };
5403
5405
  }
5404
5406
  async function get2(db2, id) {
5405
- const cache3 = await getCache();
5407
+ const cache2 = await getCache();
5406
5408
  const cacheKey = makeCacheKey(db2, id);
5407
- let cacheItem = await cache3.get(cacheKey);
5409
+ let cacheItem = await cache2.get(cacheKey);
5408
5410
  if (!cacheItem) {
5409
5411
  const doc = await db2.get(id);
5410
5412
  cacheItem = makeCacheItem(doc);
5411
- await cache3.store(cacheKey, cacheItem);
5413
+ await cache2.store(cacheKey, cacheItem);
5412
5414
  }
5413
5415
  return cacheItem.doc;
5414
5416
  }
5415
5417
  async function remove(db2, docOrId, rev) {
5416
- const cache3 = await getCache();
5418
+ const cache2 = await getCache();
5417
5419
  if (!docOrId) {
5418
5420
  throw new Error("No ID/Rev provided.");
5419
5421
  }
5420
5422
  const id = typeof docOrId === "string" ? docOrId : docOrId._id;
5421
5423
  rev = typeof docOrId === "string" ? rev : docOrId._rev;
5422
5424
  try {
5423
- await cache3.delete(makeCacheKey(db2, id));
5425
+ await cache2.delete(makeCacheKey(db2, id));
5424
5426
  } finally {
5425
5427
  await db2.remove(id, rev);
5426
5428
  }
@@ -8099,6 +8101,12 @@ async function passwordReset(user) {
8099
8101
  };
8100
8102
  await publishEvent("user:password:reset" /* USER_PASSWORD_RESET */, properties);
8101
8103
  }
8104
+ async function dataCollaboration(users2) {
8105
+ const properties = {
8106
+ users: users2
8107
+ };
8108
+ await publishEvent("user:data:collaboration" /* USER_DATA_COLLABORATION */, properties);
8109
+ }
8102
8110
  var user_default;
8103
8111
  var init_user9 = __esm({
8104
8112
  "../backend-core/src/events/publishers/user.ts"() {
@@ -8119,7 +8127,8 @@ var init_user9 = __esm({
8119
8127
  passwordForceReset,
8120
8128
  passwordUpdated,
8121
8129
  passwordResetRequested,
8122
- passwordReset
8130
+ passwordReset,
8131
+ dataCollaboration
8123
8132
  };
8124
8133
  }
8125
8134
  });
@@ -9772,8 +9781,8 @@ async function preAuth(passport2, ctx, next) {
9772
9781
  callbackUrl,
9773
9782
  ssoSaveUserNoOp
9774
9783
  );
9775
- if (!ctx.query.appId) {
9776
- ctx.throw(400, "appId query param not present.");
9784
+ if (!ctx.query.appId || !ctx.query.datasourceId) {
9785
+ ctx.throw(400, "appId and datasourceId query params not present.");
9777
9786
  }
9778
9787
  return passport2.authenticate(strategy, {
9779
9788
  scope: ["profile", "email", "https://www.googleapis.com/auth/spreadsheets"],
@@ -9793,7 +9802,7 @@ async function postAuth(passport2, ctx, next) {
9793
9802
  clientSecret: config.clientSecret,
9794
9803
  callbackURL: callbackUrl
9795
9804
  },
9796
- (accessToken, refreshToken, _profile, done) => {
9805
+ (accessToken, refreshToken, profile, done) => {
9797
9806
  clearCookie(ctx, "budibase:datasourceauth" /* DatasourceAuth */);
9798
9807
  done(null, { accessToken, refreshToken });
9799
9808
  }
@@ -9801,14 +9810,22 @@ async function postAuth(passport2, ctx, next) {
9801
9810
  { successRedirect: "/", failureRedirect: "/error" },
9802
9811
  async (err, tokens) => {
9803
9812
  const baseUrl = `/builder/app/${authStateCookie.appId}/data`;
9804
- const id = utils_exports2.newid();
9805
- await cache_exports.store(
9806
- `datasource:creation:${authStateCookie.appId}:google:${id}`,
9807
- {
9808
- tokens
9813
+ await doWithDB(authStateCookie.appId, async (db2) => {
9814
+ let datasource2;
9815
+ try {
9816
+ datasource2 = await db2.get(authStateCookie.datasourceId);
9817
+ } catch (err2) {
9818
+ if (err2.status === 404) {
9819
+ ctx.redirect(baseUrl);
9820
+ }
9809
9821
  }
9810
- );
9811
- ctx.redirect(`${baseUrl}/new?continue_google_setup=${id}`);
9822
+ if (!datasource2.config) {
9823
+ datasource2.config = {};
9824
+ }
9825
+ datasource2.config.auth = { type: "google", ...tokens };
9826
+ await db2.put(datasource2);
9827
+ ctx.redirect(`${baseUrl}/datasource/${authStateCookie.datasourceId}`);
9828
+ });
9812
9829
  }
9813
9830
  )(ctx, next);
9814
9831
  }
@@ -9818,9 +9835,9 @@ var init_google2 = __esm({
9818
9835
  init_google();
9819
9836
  init_constants2();
9820
9837
  init_utils5();
9838
+ init_db5();
9821
9839
  init_configs3();
9822
9840
  init_sso2();
9823
- init_src2();
9824
9841
  GoogleStrategy2 = require("passport-google-oauth").OAuth2Strategy;
9825
9842
  }
9826
9843
  });
@@ -23794,20 +23811,9 @@ var init_rest = __esm({
23794
23811
  });
23795
23812
 
23796
23813
  // src/integrations/googlesheets.ts
23797
- async function setupCreationAuth(datasouce) {
23798
- if (datasouce.continueSetupId) {
23799
- const appId = context_exports.getAppId();
23800
- const tokens = await cache_exports.get(
23801
- `datasource:creation:${appId}:google:${datasouce.continueSetupId}`
23802
- );
23803
- datasouce.auth = tokens.tokens;
23804
- delete datasouce.continueSetupId;
23805
- }
23806
- }
23807
23814
  var import_google_auth_library, import_google_spreadsheet, import_node_fetch9, ALLOWED_TYPES, SCHEMA12, GoogleSheetsIntegration, googlesheets_default;
23808
23815
  var init_googlesheets = __esm({
23809
23816
  "src/integrations/googlesheets.ts"() {
23810
- "use strict";
23811
23817
  init_src();
23812
23818
  import_google_auth_library = require("google-auth-library");
23813
23819
  init_utils14();
@@ -23842,7 +23848,7 @@ var init_googlesheets = __esm({
23842
23848
  },
23843
23849
  datasource: {
23844
23850
  spreadsheetId: {
23845
- display: "Spreadsheet URL",
23851
+ display: "Google Sheet URL",
23846
23852
  type: "string" /* STRING */,
23847
23853
  required: true
23848
23854
  }
@@ -23912,7 +23918,6 @@ var init_googlesheets = __esm({
23912
23918
  }
23913
23919
  async testConnection() {
23914
23920
  try {
23915
- await setupCreationAuth(this.config);
23916
23921
  await this.connect();
23917
23922
  return { connected: true };
23918
23923
  } catch (e) {
@@ -26884,22 +26889,22 @@ function threadSetup() {
26884
26889
  init8();
26885
26890
  }
26886
26891
  async function checkCacheForDynamicVariable(queryId, variable) {
26887
- const cache3 = await getClient2();
26888
- return cache3.get(makeVariableKey(queryId, variable));
26892
+ const cache2 = await getClient2();
26893
+ return cache2.get(makeVariableKey(queryId, variable));
26889
26894
  }
26890
26895
  async function invalidateDynamicVariables(cachedVars) {
26891
- const cache3 = await getClient2();
26896
+ const cache2 = await getClient2();
26892
26897
  let promises = [];
26893
26898
  for (let variable of cachedVars) {
26894
26899
  promises.push(
26895
- cache3.delete(makeVariableKey(variable.queryId, variable.name))
26900
+ cache2.delete(makeVariableKey(variable.queryId, variable.name))
26896
26901
  );
26897
26902
  }
26898
26903
  await Promise.all(promises);
26899
26904
  }
26900
26905
  async function storeDynamicVariable(queryId, variable, value) {
26901
- const cache3 = await getClient2();
26902
- await cache3.store(
26906
+ const cache2 = await getClient2();
26907
+ await cache2.store(
26903
26908
  makeVariableKey(queryId, variable),
26904
26909
  value,
26905
26910
  VARIABLE_TTL_SECONDS
@@ -30677,15 +30682,8 @@ init_constants6();
30677
30682
  init_integrations2();
30678
30683
  init_utils20();
30679
30684
  init_src2();
30680
- init_src();
30681
30685
  init_sdk3();
30682
30686
  init_websockets();
30683
- init_googlesheets();
30684
- var preSaveAction = {
30685
- ["GOOGLE_SHEETS" /* GOOGLE_SHEETS */]: async (datasource2) => {
30686
- await setupCreationAuth(datasource2.config);
30687
- }
30688
- };
30689
30687
 
30690
30688
  // src/api/controllers/query/validation.ts
30691
30689
  init_src2();