@budibase/server 2.6.24-alpha.2 → 2.6.26

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.9bd22774.js"></script>
12
+ <link rel="stylesheet" href="/builder/assets/index.a86e2071.css">
13
13
  </head>
14
14
 
15
15
  <body id="app">
@@ -5355,11 +5355,11 @@ function makeCacheItem(doc, lastWrite = null) {
5355
5355
  return { doc, lastWrite: lastWrite || Date.now() };
5356
5356
  }
5357
5357
  async function put(db2, doc, writeRateMs = DEFAULT_WRITE_RATE_MS) {
5358
- const cache3 = await getCache();
5358
+ const cache2 = await getCache();
5359
5359
  const key = doc._id;
5360
5360
  let cacheItem;
5361
5361
  if (key) {
5362
- cacheItem = await cache3.get(makeCacheKey(db2, key));
5362
+ cacheItem = await cache2.get(makeCacheKey(db2, key));
5363
5363
  }
5364
5364
  const updateDb = !cacheItem || cacheItem.lastWrite < Date.now() - writeRateMs;
5365
5365
  let output = doc;
@@ -5397,30 +5397,30 @@ async function put(db2, doc, writeRateMs = DEFAULT_WRITE_RATE_MS) {
5397
5397
  }
5398
5398
  cacheItem = makeCacheItem(output, updateDb ? null : cacheItem == null ? void 0 : cacheItem.lastWrite);
5399
5399
  if (output._id) {
5400
- await cache3.store(makeCacheKey(db2, output._id), cacheItem);
5400
+ await cache2.store(makeCacheKey(db2, output._id), cacheItem);
5401
5401
  }
5402
5402
  return { ok: true, id: output._id, rev: output._rev };
5403
5403
  }
5404
5404
  async function get2(db2, id) {
5405
- const cache3 = await getCache();
5405
+ const cache2 = await getCache();
5406
5406
  const cacheKey = makeCacheKey(db2, id);
5407
- let cacheItem = await cache3.get(cacheKey);
5407
+ let cacheItem = await cache2.get(cacheKey);
5408
5408
  if (!cacheItem) {
5409
5409
  const doc = await db2.get(id);
5410
5410
  cacheItem = makeCacheItem(doc);
5411
- await cache3.store(cacheKey, cacheItem);
5411
+ await cache2.store(cacheKey, cacheItem);
5412
5412
  }
5413
5413
  return cacheItem.doc;
5414
5414
  }
5415
5415
  async function remove(db2, docOrId, rev) {
5416
- const cache3 = await getCache();
5416
+ const cache2 = await getCache();
5417
5417
  if (!docOrId) {
5418
5418
  throw new Error("No ID/Rev provided.");
5419
5419
  }
5420
5420
  const id = typeof docOrId === "string" ? docOrId : docOrId._id;
5421
5421
  rev = typeof docOrId === "string" ? rev : docOrId._rev;
5422
5422
  try {
5423
- await cache3.delete(makeCacheKey(db2, id));
5423
+ await cache2.delete(makeCacheKey(db2, id));
5424
5424
  } finally {
5425
5425
  await db2.remove(id, rev);
5426
5426
  }
@@ -9772,8 +9772,8 @@ async function preAuth(passport2, ctx, next) {
9772
9772
  callbackUrl,
9773
9773
  ssoSaveUserNoOp
9774
9774
  );
9775
- if (!ctx.query.appId) {
9776
- ctx.throw(400, "appId query param not present.");
9775
+ if (!ctx.query.appId || !ctx.query.datasourceId) {
9776
+ ctx.throw(400, "appId and datasourceId query params not present.");
9777
9777
  }
9778
9778
  return passport2.authenticate(strategy, {
9779
9779
  scope: ["profile", "email", "https://www.googleapis.com/auth/spreadsheets"],
@@ -9793,7 +9793,7 @@ async function postAuth(passport2, ctx, next) {
9793
9793
  clientSecret: config.clientSecret,
9794
9794
  callbackURL: callbackUrl
9795
9795
  },
9796
- (accessToken, refreshToken, _profile, done) => {
9796
+ (accessToken, refreshToken, profile, done) => {
9797
9797
  clearCookie(ctx, "budibase:datasourceauth" /* DatasourceAuth */);
9798
9798
  done(null, { accessToken, refreshToken });
9799
9799
  }
@@ -9801,14 +9801,22 @@ async function postAuth(passport2, ctx, next) {
9801
9801
  { successRedirect: "/", failureRedirect: "/error" },
9802
9802
  async (err, tokens) => {
9803
9803
  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
9804
+ await doWithDB(authStateCookie.appId, async (db2) => {
9805
+ let datasource2;
9806
+ try {
9807
+ datasource2 = await db2.get(authStateCookie.datasourceId);
9808
+ } catch (err2) {
9809
+ if (err2.status === 404) {
9810
+ ctx.redirect(baseUrl);
9811
+ }
9809
9812
  }
9810
- );
9811
- ctx.redirect(`${baseUrl}/new?continue_google_setup=${id}`);
9813
+ if (!datasource2.config) {
9814
+ datasource2.config = {};
9815
+ }
9816
+ datasource2.config.auth = { type: "google", ...tokens };
9817
+ await db2.put(datasource2);
9818
+ ctx.redirect(`${baseUrl}/datasource/${authStateCookie.datasourceId}`);
9819
+ });
9812
9820
  }
9813
9821
  )(ctx, next);
9814
9822
  }
@@ -9818,9 +9826,9 @@ var init_google2 = __esm({
9818
9826
  init_google();
9819
9827
  init_constants2();
9820
9828
  init_utils5();
9829
+ init_db5();
9821
9830
  init_configs3();
9822
9831
  init_sso2();
9823
- init_src2();
9824
9832
  GoogleStrategy2 = require("passport-google-oauth").OAuth2Strategy;
9825
9833
  }
9826
9834
  });
@@ -23794,20 +23802,9 @@ var init_rest = __esm({
23794
23802
  });
23795
23803
 
23796
23804
  // 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
23805
  var import_google_auth_library, import_google_spreadsheet, import_node_fetch9, ALLOWED_TYPES, SCHEMA12, GoogleSheetsIntegration, googlesheets_default;
23808
23806
  var init_googlesheets = __esm({
23809
23807
  "src/integrations/googlesheets.ts"() {
23810
- "use strict";
23811
23808
  init_src();
23812
23809
  import_google_auth_library = require("google-auth-library");
23813
23810
  init_utils14();
@@ -23842,7 +23839,7 @@ var init_googlesheets = __esm({
23842
23839
  },
23843
23840
  datasource: {
23844
23841
  spreadsheetId: {
23845
- display: "Spreadsheet URL",
23842
+ display: "Google Sheet URL",
23846
23843
  type: "string" /* STRING */,
23847
23844
  required: true
23848
23845
  }
@@ -23912,7 +23909,6 @@ var init_googlesheets = __esm({
23912
23909
  }
23913
23910
  async testConnection() {
23914
23911
  try {
23915
- await setupCreationAuth(this.config);
23916
23912
  await this.connect();
23917
23913
  return { connected: true };
23918
23914
  } catch (e) {
@@ -26884,22 +26880,22 @@ function threadSetup() {
26884
26880
  init8();
26885
26881
  }
26886
26882
  async function checkCacheForDynamicVariable(queryId, variable) {
26887
- const cache3 = await getClient2();
26888
- return cache3.get(makeVariableKey(queryId, variable));
26883
+ const cache2 = await getClient2();
26884
+ return cache2.get(makeVariableKey(queryId, variable));
26889
26885
  }
26890
26886
  async function invalidateDynamicVariables(cachedVars) {
26891
- const cache3 = await getClient2();
26887
+ const cache2 = await getClient2();
26892
26888
  let promises = [];
26893
26889
  for (let variable of cachedVars) {
26894
26890
  promises.push(
26895
- cache3.delete(makeVariableKey(variable.queryId, variable.name))
26891
+ cache2.delete(makeVariableKey(variable.queryId, variable.name))
26896
26892
  );
26897
26893
  }
26898
26894
  await Promise.all(promises);
26899
26895
  }
26900
26896
  async function storeDynamicVariable(queryId, variable, value) {
26901
- const cache3 = await getClient2();
26902
- await cache3.store(
26897
+ const cache2 = await getClient2();
26898
+ await cache2.store(
26903
26899
  makeVariableKey(queryId, variable),
26904
26900
  value,
26905
26901
  VARIABLE_TTL_SECONDS
@@ -30677,15 +30673,8 @@ init_constants6();
30677
30673
  init_integrations2();
30678
30674
  init_utils20();
30679
30675
  init_src2();
30680
- init_src();
30681
30676
  init_sdk3();
30682
30677
  init_websockets();
30683
- init_googlesheets();
30684
- var preSaveAction = {
30685
- ["GOOGLE_SHEETS" /* GOOGLE_SHEETS */]: async (datasource2) => {
30686
- await setupCreationAuth(datasource2.config);
30687
- }
30688
- };
30689
30678
 
30690
30679
  // src/api/controllers/query/validation.ts
30691
30680
  init_src2();