@budibase/server 2.7.0 → 2.7.1-alpha.1

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.4ca5529d.js"></script>
12
- <link rel="stylesheet" href="/builder/assets/index.a86e2071.css">
11
+ <script type="module" crossorigin src="/builder/assets/index.933787a7.js"></script>
12
+ <link rel="stylesheet" href="/builder/assets/index.b33e8ad5.css">
13
13
  </head>
14
14
 
15
15
  <body id="app">
@@ -5357,11 +5357,11 @@ function makeCacheItem(doc, lastWrite = null) {
5357
5357
  return { doc, lastWrite: lastWrite || Date.now() };
5358
5358
  }
5359
5359
  async function put(db2, doc, writeRateMs = DEFAULT_WRITE_RATE_MS) {
5360
- const cache2 = await getCache();
5360
+ const cache3 = await getCache();
5361
5361
  const key = doc._id;
5362
5362
  let cacheItem;
5363
5363
  if (key) {
5364
- cacheItem = await cache2.get(makeCacheKey(db2, key));
5364
+ cacheItem = await cache3.get(makeCacheKey(db2, key));
5365
5365
  }
5366
5366
  const updateDb = !cacheItem || cacheItem.lastWrite < Date.now() - writeRateMs;
5367
5367
  let output = doc;
@@ -5399,30 +5399,30 @@ async function put(db2, doc, writeRateMs = DEFAULT_WRITE_RATE_MS) {
5399
5399
  }
5400
5400
  cacheItem = makeCacheItem(output, updateDb ? null : cacheItem == null ? void 0 : cacheItem.lastWrite);
5401
5401
  if (output._id) {
5402
- await cache2.store(makeCacheKey(db2, output._id), cacheItem);
5402
+ await cache3.store(makeCacheKey(db2, output._id), cacheItem);
5403
5403
  }
5404
5404
  return { ok: true, id: output._id, rev: output._rev };
5405
5405
  }
5406
5406
  async function get2(db2, id) {
5407
- const cache2 = await getCache();
5407
+ const cache3 = await getCache();
5408
5408
  const cacheKey = makeCacheKey(db2, id);
5409
- let cacheItem = await cache2.get(cacheKey);
5409
+ let cacheItem = await cache3.get(cacheKey);
5410
5410
  if (!cacheItem) {
5411
5411
  const doc = await db2.get(id);
5412
5412
  cacheItem = makeCacheItem(doc);
5413
- await cache2.store(cacheKey, cacheItem);
5413
+ await cache3.store(cacheKey, cacheItem);
5414
5414
  }
5415
5415
  return cacheItem.doc;
5416
5416
  }
5417
5417
  async function remove(db2, docOrId, rev) {
5418
- const cache2 = await getCache();
5418
+ const cache3 = await getCache();
5419
5419
  if (!docOrId) {
5420
5420
  throw new Error("No ID/Rev provided.");
5421
5421
  }
5422
5422
  const id = typeof docOrId === "string" ? docOrId : docOrId._id;
5423
5423
  rev = typeof docOrId === "string" ? rev : docOrId._rev;
5424
5424
  try {
5425
- await cache2.delete(makeCacheKey(db2, id));
5425
+ await cache3.delete(makeCacheKey(db2, id));
5426
5426
  } finally {
5427
5427
  await db2.remove(id, rev);
5428
5428
  }
@@ -9781,8 +9781,8 @@ async function preAuth(passport2, ctx, next) {
9781
9781
  callbackUrl,
9782
9782
  ssoSaveUserNoOp
9783
9783
  );
9784
- if (!ctx.query.appId || !ctx.query.datasourceId) {
9785
- ctx.throw(400, "appId and datasourceId query params not present.");
9784
+ if (!ctx.query.appId) {
9785
+ ctx.throw(400, "appId query param not present.");
9786
9786
  }
9787
9787
  return passport2.authenticate(strategy, {
9788
9788
  scope: ["profile", "email", "https://www.googleapis.com/auth/spreadsheets"],
@@ -9802,7 +9802,7 @@ async function postAuth(passport2, ctx, next) {
9802
9802
  clientSecret: config.clientSecret,
9803
9803
  callbackURL: callbackUrl
9804
9804
  },
9805
- (accessToken, refreshToken, profile, done) => {
9805
+ (accessToken, refreshToken, _profile, done) => {
9806
9806
  clearCookie(ctx, "budibase:datasourceauth" /* DatasourceAuth */);
9807
9807
  done(null, { accessToken, refreshToken });
9808
9808
  }
@@ -9810,22 +9810,14 @@ async function postAuth(passport2, ctx, next) {
9810
9810
  { successRedirect: "/", failureRedirect: "/error" },
9811
9811
  async (err, tokens) => {
9812
9812
  const baseUrl = `/builder/app/${authStateCookie.appId}/data`;
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
- }
9821
- }
9822
- if (!datasource2.config) {
9823
- datasource2.config = {};
9813
+ const id = utils_exports2.newid();
9814
+ await cache_exports.store(
9815
+ `datasource:creation:${authStateCookie.appId}:google:${id}`,
9816
+ {
9817
+ tokens
9824
9818
  }
9825
- datasource2.config.auth = { type: "google", ...tokens };
9826
- await db2.put(datasource2);
9827
- ctx.redirect(`${baseUrl}/datasource/${authStateCookie.datasourceId}`);
9828
- });
9819
+ );
9820
+ ctx.redirect(`${baseUrl}/new?continue_google_setup=${id}`);
9829
9821
  }
9830
9822
  )(ctx, next);
9831
9823
  }
@@ -9835,9 +9827,9 @@ var init_google2 = __esm({
9835
9827
  init_google();
9836
9828
  init_constants2();
9837
9829
  init_utils5();
9838
- init_db5();
9839
9830
  init_configs3();
9840
9831
  init_sso2();
9832
+ init_src2();
9841
9833
  GoogleStrategy2 = require("passport-google-oauth").OAuth2Strategy;
9842
9834
  }
9843
9835
  });
@@ -23811,6 +23803,16 @@ var init_rest = __esm({
23811
23803
  });
23812
23804
 
23813
23805
  // src/integrations/googlesheets.ts
23806
+ async function setupCreationAuth(datasouce) {
23807
+ if (datasouce.continueSetupId) {
23808
+ const appId = context_exports.getAppId();
23809
+ const tokens = await cache_exports.get(
23810
+ `datasource:creation:${appId}:google:${datasouce.continueSetupId}`
23811
+ );
23812
+ datasouce.auth = tokens.tokens;
23813
+ delete datasouce.continueSetupId;
23814
+ }
23815
+ }
23814
23816
  var import_google_auth_library, import_google_spreadsheet, import_node_fetch9, ALLOWED_TYPES, SCHEMA12, GoogleSheetsIntegration, googlesheets_default;
23815
23817
  var init_googlesheets = __esm({
23816
23818
  "src/integrations/googlesheets.ts"() {
@@ -23848,7 +23850,7 @@ var init_googlesheets = __esm({
23848
23850
  },
23849
23851
  datasource: {
23850
23852
  spreadsheetId: {
23851
- display: "Google Sheet URL",
23853
+ display: "Spreadsheet URL",
23852
23854
  type: "string" /* STRING */,
23853
23855
  required: true
23854
23856
  }
@@ -23918,6 +23920,7 @@ var init_googlesheets = __esm({
23918
23920
  }
23919
23921
  async testConnection() {
23920
23922
  try {
23923
+ await setupCreationAuth(this.config);
23921
23924
  await this.connect();
23922
23925
  return { connected: true };
23923
23926
  } catch (e) {
@@ -26889,22 +26892,22 @@ function threadSetup() {
26889
26892
  init8();
26890
26893
  }
26891
26894
  async function checkCacheForDynamicVariable(queryId, variable) {
26892
- const cache2 = await getClient2();
26893
- return cache2.get(makeVariableKey(queryId, variable));
26895
+ const cache3 = await getClient2();
26896
+ return cache3.get(makeVariableKey(queryId, variable));
26894
26897
  }
26895
26898
  async function invalidateDynamicVariables(cachedVars) {
26896
- const cache2 = await getClient2();
26899
+ const cache3 = await getClient2();
26897
26900
  let promises = [];
26898
26901
  for (let variable of cachedVars) {
26899
26902
  promises.push(
26900
- cache2.delete(makeVariableKey(variable.queryId, variable.name))
26903
+ cache3.delete(makeVariableKey(variable.queryId, variable.name))
26901
26904
  );
26902
26905
  }
26903
26906
  await Promise.all(promises);
26904
26907
  }
26905
26908
  async function storeDynamicVariable(queryId, variable, value) {
26906
- const cache2 = await getClient2();
26907
- await cache2.store(
26909
+ const cache3 = await getClient2();
26910
+ await cache3.store(
26908
26911
  makeVariableKey(queryId, variable),
26909
26912
  value,
26910
26913
  VARIABLE_TTL_SECONDS
@@ -30682,8 +30685,15 @@ init_constants6();
30682
30685
  init_integrations2();
30683
30686
  init_utils20();
30684
30687
  init_src2();
30688
+ init_src();
30685
30689
  init_sdk3();
30686
30690
  init_websockets();
30691
+ init_googlesheets();
30692
+ var preSaveAction = {
30693
+ ["GOOGLE_SHEETS" /* GOOGLE_SHEETS */]: async (datasource2) => {
30694
+ await setupCreationAuth(datasource2.config);
30695
+ }
30696
+ };
30687
30697
 
30688
30698
  // src/api/controllers/query/validation.ts
30689
30699
  init_src2();