@budibase/server 2.7.7-alpha.3 → 2.7.7-alpha.5

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.7f26f181.js"></script>
12
- <link rel="stylesheet" href="/builder/assets/index.b33e8ad5.css">
11
+ <script type="module" crossorigin src="/builder/assets/index.4afe46bb.js"></script>
12
+ <link rel="stylesheet" href="/builder/assets/index.3c336b18.css">
13
13
  </head>
14
14
 
15
15
  <body id="app">
@@ -18882,11 +18882,39 @@ var init_filters = __esm({
18882
18882
  // ../shared-core/src/utils.ts
18883
18883
  var utils_exports5 = {};
18884
18884
  __export(utils_exports5, {
18885
+ parallelForeach: () => parallelForeach,
18885
18886
  unreachable: () => unreachable
18886
18887
  });
18887
18888
  function unreachable(value, message = `No such case in exhaustive switch: ${value}`) {
18888
18889
  throw new Error(message);
18889
18890
  }
18891
+ async function parallelForeach(items, task, maxConcurrency) {
18892
+ const promises = [];
18893
+ let index2 = 0;
18894
+ const processItem = async (item) => {
18895
+ try {
18896
+ await task(item);
18897
+ } finally {
18898
+ processNext();
18899
+ }
18900
+ };
18901
+ const processNext = () => {
18902
+ if (index2 >= items.length) {
18903
+ return;
18904
+ }
18905
+ const item = items[index2];
18906
+ index2++;
18907
+ const promise = processItem(item);
18908
+ promises.push(promise);
18909
+ if (promises.length >= maxConcurrency) {
18910
+ Promise.race(promises).then(processNext);
18911
+ } else {
18912
+ processNext();
18913
+ }
18914
+ };
18915
+ processNext();
18916
+ await Promise.all(promises);
18917
+ }
18890
18918
  var init_utils12 = __esm({
18891
18919
  "../shared-core/src/utils.ts"() {
18892
18920
  }
@@ -21249,7 +21277,8 @@ var init_postgres = __esm({
21249
21277
  try {
21250
21278
  await this.openConnection();
21251
21279
  const columnsResponse = await this.client.query(this.COLUMNS_SQL);
21252
- return columnsResponse.rows.map((row) => row.table_name);
21280
+ const names = columnsResponse.rows.map((row) => row.table_name);
21281
+ return [...new Set(names)];
21253
21282
  } finally {
21254
21283
  await this.closeConnection();
21255
21284
  }
@@ -21878,6 +21907,8 @@ var init_mongodb = __esm({
21878
21907
  response2.connected = true;
21879
21908
  } catch (e) {
21880
21909
  response2.error = e.message;
21910
+ } finally {
21911
+ await this.client.close();
21881
21912
  }
21882
21913
  return response2;
21883
21914
  }
@@ -23921,7 +23952,6 @@ var init_googlesheets = __esm({
23921
23952
  }
23922
23953
  async testConnection() {
23923
23954
  try {
23924
- await setupCreationAuth(this.config);
23925
23955
  await this.connect();
23926
23956
  return { connected: true };
23927
23957
  } catch (e) {
@@ -23973,6 +24003,7 @@ var init_googlesheets = __esm({
23973
24003
  async connect() {
23974
24004
  var _a;
23975
24005
  try {
24006
+ await setupCreationAuth(this.config);
23976
24007
  let googleConfig = await configs_exports.getGoogleDatasourceConfig();
23977
24008
  if (!googleConfig) {
23978
24009
  throw new HTTPError("Google config not found", 400);
@@ -24023,21 +24054,22 @@ var init_googlesheets = __esm({
24023
24054
  return table;
24024
24055
  }
24025
24056
  async buildSchema(datasourceId, entities) {
24026
- if (!this.config.auth) {
24027
- return;
24028
- }
24029
24057
  await this.connect();
24030
24058
  const sheets = this.client.sheetsByIndex;
24031
24059
  const tables = {};
24032
- for (let sheet of sheets) {
24033
- await sheet.getRows();
24034
- const id = buildExternalTableId(datasourceId, sheet.title);
24035
- tables[sheet.title] = this.getTableSchema(
24036
- sheet.title,
24037
- sheet.headerValues,
24038
- id
24039
- );
24040
- }
24060
+ await utils_exports5.parallelForeach(
24061
+ sheets,
24062
+ async (sheet) => {
24063
+ await sheet.getRows({ limit: 0, offset: 0 });
24064
+ const id = buildExternalTableId(datasourceId, sheet.title);
24065
+ tables[sheet.title] = this.getTableSchema(
24066
+ sheet.title,
24067
+ sheet.headerValues,
24068
+ id
24069
+ );
24070
+ },
24071
+ 10
24072
+ );
24041
24073
  const final = finaliseExternalTables(tables, entities);
24042
24074
  this.tables = final.tables;
24043
24075
  this.schemaErrors = final.errors;