@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.
- package/builder/assets/{index.b33e8ad5.css → index.3c336b18.css} +1 -1
- package/builder/assets/{index.7f26f181.js → index.4afe46bb.js} +374 -374
- package/builder/index.html +2 -2
- package/dist/automation.js +46 -14
- package/dist/automation.js.map +3 -3
- package/dist/index.js +71 -35
- package/dist/index.js.map +3 -3
- package/dist/query.js +46 -14
- package/dist/query.js.map +3 -3
- package/package.json +9 -9
- package/src/api/controllers/datasource.ts +28 -23
- package/src/integrations/googlesheets.ts +18 -17
- package/src/integrations/mongodb.ts +4 -2
- package/src/integrations/postgres.ts +2 -1
- package/src/sdk/app/datasources/datasources.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -20025,11 +20025,39 @@ var init_filters = __esm({
|
|
|
20025
20025
|
// ../shared-core/src/utils.ts
|
|
20026
20026
|
var utils_exports5 = {};
|
|
20027
20027
|
__export(utils_exports5, {
|
|
20028
|
+
parallelForeach: () => parallelForeach,
|
|
20028
20029
|
unreachable: () => unreachable
|
|
20029
20030
|
});
|
|
20030
20031
|
function unreachable(value, message = `No such case in exhaustive switch: ${value}`) {
|
|
20031
20032
|
throw new Error(message);
|
|
20032
20033
|
}
|
|
20034
|
+
async function parallelForeach(items, task, maxConcurrency) {
|
|
20035
|
+
const promises = [];
|
|
20036
|
+
let index2 = 0;
|
|
20037
|
+
const processItem = async (item) => {
|
|
20038
|
+
try {
|
|
20039
|
+
await task(item);
|
|
20040
|
+
} finally {
|
|
20041
|
+
processNext();
|
|
20042
|
+
}
|
|
20043
|
+
};
|
|
20044
|
+
const processNext = () => {
|
|
20045
|
+
if (index2 >= items.length) {
|
|
20046
|
+
return;
|
|
20047
|
+
}
|
|
20048
|
+
const item = items[index2];
|
|
20049
|
+
index2++;
|
|
20050
|
+
const promise = processItem(item);
|
|
20051
|
+
promises.push(promise);
|
|
20052
|
+
if (promises.length >= maxConcurrency) {
|
|
20053
|
+
Promise.race(promises).then(processNext);
|
|
20054
|
+
} else {
|
|
20055
|
+
processNext();
|
|
20056
|
+
}
|
|
20057
|
+
};
|
|
20058
|
+
processNext();
|
|
20059
|
+
await Promise.all(promises);
|
|
20060
|
+
}
|
|
20033
20061
|
var init_utils13 = __esm({
|
|
20034
20062
|
"../shared-core/src/utils.ts"() {
|
|
20035
20063
|
}
|
|
@@ -26486,7 +26514,8 @@ var init_postgres = __esm({
|
|
|
26486
26514
|
try {
|
|
26487
26515
|
await this.openConnection();
|
|
26488
26516
|
const columnsResponse = await this.client.query(this.COLUMNS_SQL);
|
|
26489
|
-
|
|
26517
|
+
const names = columnsResponse.rows.map((row2) => row2.table_name);
|
|
26518
|
+
return [...new Set(names)];
|
|
26490
26519
|
} finally {
|
|
26491
26520
|
await this.closeConnection();
|
|
26492
26521
|
}
|
|
@@ -27115,6 +27144,8 @@ var init_mongodb = __esm({
|
|
|
27115
27144
|
response2.connected = true;
|
|
27116
27145
|
} catch (e) {
|
|
27117
27146
|
response2.error = e.message;
|
|
27147
|
+
} finally {
|
|
27148
|
+
await this.client.close();
|
|
27118
27149
|
}
|
|
27119
27150
|
return response2;
|
|
27120
27151
|
}
|
|
@@ -29158,7 +29189,6 @@ var init_googlesheets = __esm({
|
|
|
29158
29189
|
}
|
|
29159
29190
|
async testConnection() {
|
|
29160
29191
|
try {
|
|
29161
|
-
await setupCreationAuth(this.config);
|
|
29162
29192
|
await this.connect();
|
|
29163
29193
|
return { connected: true };
|
|
29164
29194
|
} catch (e) {
|
|
@@ -29210,6 +29240,7 @@ var init_googlesheets = __esm({
|
|
|
29210
29240
|
async connect() {
|
|
29211
29241
|
var _a2;
|
|
29212
29242
|
try {
|
|
29243
|
+
await setupCreationAuth(this.config);
|
|
29213
29244
|
let googleConfig = await configs_exports.getGoogleDatasourceConfig();
|
|
29214
29245
|
if (!googleConfig) {
|
|
29215
29246
|
throw new HTTPError("Google config not found", 400);
|
|
@@ -29260,21 +29291,22 @@ var init_googlesheets = __esm({
|
|
|
29260
29291
|
return table2;
|
|
29261
29292
|
}
|
|
29262
29293
|
async buildSchema(datasourceId, entities) {
|
|
29263
|
-
if (!this.config.auth) {
|
|
29264
|
-
return;
|
|
29265
|
-
}
|
|
29266
29294
|
await this.connect();
|
|
29267
29295
|
const sheets = this.client.sheetsByIndex;
|
|
29268
29296
|
const tables = {};
|
|
29269
|
-
|
|
29270
|
-
|
|
29271
|
-
|
|
29272
|
-
|
|
29273
|
-
sheet.title
|
|
29274
|
-
sheet.
|
|
29275
|
-
|
|
29276
|
-
|
|
29277
|
-
|
|
29297
|
+
await utils_exports5.parallelForeach(
|
|
29298
|
+
sheets,
|
|
29299
|
+
async (sheet) => {
|
|
29300
|
+
await sheet.getRows({ limit: 0, offset: 0 });
|
|
29301
|
+
const id = buildExternalTableId(datasourceId, sheet.title);
|
|
29302
|
+
tables[sheet.title] = this.getTableSchema(
|
|
29303
|
+
sheet.title,
|
|
29304
|
+
sheet.headerValues,
|
|
29305
|
+
id
|
|
29306
|
+
);
|
|
29307
|
+
},
|
|
29308
|
+
10
|
|
29309
|
+
);
|
|
29278
29310
|
const final = finaliseExternalTables(tables, entities);
|
|
29279
29311
|
this.tables = final.tables;
|
|
29280
29312
|
this.schemaErrors = final.errors;
|
|
@@ -34686,6 +34718,19 @@ async function buildSchemaHelper(datasource2) {
|
|
|
34686
34718
|
}
|
|
34687
34719
|
return { tables: connector.tables, error: error2 };
|
|
34688
34720
|
}
|
|
34721
|
+
async function buildFilteredSchema(datasource2, filter2) {
|
|
34722
|
+
let { tables, error: error2 } = await buildSchemaHelper(datasource2);
|
|
34723
|
+
let finalTables = tables;
|
|
34724
|
+
if (filter2) {
|
|
34725
|
+
finalTables = {};
|
|
34726
|
+
for (let key in tables) {
|
|
34727
|
+
if (filter2.some((filter3) => filter3.toLowerCase() === key.toLowerCase())) {
|
|
34728
|
+
finalTables[key] = tables[key];
|
|
34729
|
+
}
|
|
34730
|
+
}
|
|
34731
|
+
}
|
|
34732
|
+
return { tables: finalTables, error: error2 };
|
|
34733
|
+
}
|
|
34689
34734
|
async function fetch22(ctx) {
|
|
34690
34735
|
const db2 = context_exports.getAppDB();
|
|
34691
34736
|
const internalTables = await db2.allDocs(
|
|
@@ -34740,37 +34785,24 @@ async function information(ctx) {
|
|
|
34740
34785
|
}
|
|
34741
34786
|
const tableNames = await connector.getTableNames();
|
|
34742
34787
|
ctx.body = {
|
|
34743
|
-
tableNames
|
|
34788
|
+
tableNames: tableNames.sort()
|
|
34744
34789
|
};
|
|
34745
34790
|
}
|
|
34746
34791
|
async function buildSchemaFromDb(ctx) {
|
|
34747
34792
|
const db2 = context_exports.getAppDB();
|
|
34748
|
-
const datasource2 = await sdk_default.datasources.get(ctx.params.datasourceId);
|
|
34749
34793
|
const tablesFilter = ctx.request.body.tablesFilter;
|
|
34750
|
-
|
|
34751
|
-
|
|
34752
|
-
|
|
34753
|
-
datasource2.entities = {};
|
|
34754
|
-
}
|
|
34755
|
-
for (let key in tables) {
|
|
34756
|
-
if (tablesFilter.some(
|
|
34757
|
-
(filter2) => filter2.toLowerCase() === key.toLowerCase()
|
|
34758
|
-
)) {
|
|
34759
|
-
datasource2.entities[key] = tables[key];
|
|
34760
|
-
}
|
|
34761
|
-
}
|
|
34762
|
-
} else {
|
|
34763
|
-
datasource2.entities = tables;
|
|
34764
|
-
}
|
|
34794
|
+
const datasource2 = await sdk_default.datasources.get(ctx.params.datasourceId);
|
|
34795
|
+
const { tables, error: error2 } = await buildFilteredSchema(datasource2, tablesFilter);
|
|
34796
|
+
datasource2.entities = tables;
|
|
34765
34797
|
setDefaultDisplayColumns(datasource2);
|
|
34766
34798
|
const dbResp = await db2.put(datasource2);
|
|
34767
34799
|
datasource2._rev = dbResp.rev;
|
|
34768
34800
|
const cleanedDatasource = await sdk_default.datasources.removeSecretSingle(datasource2);
|
|
34769
|
-
const
|
|
34801
|
+
const res = { datasource: cleanedDatasource };
|
|
34770
34802
|
if (error2) {
|
|
34771
|
-
|
|
34803
|
+
res.error = error2;
|
|
34772
34804
|
}
|
|
34773
|
-
ctx.body =
|
|
34805
|
+
ctx.body = res;
|
|
34774
34806
|
}
|
|
34775
34807
|
function setDefaultDisplayColumns(datasource2) {
|
|
34776
34808
|
for (let entity of Object.values(datasource2.entities || {})) {
|
|
@@ -34844,6 +34876,7 @@ async function save13(ctx) {
|
|
|
34844
34876
|
const db2 = context_exports.getAppDB();
|
|
34845
34877
|
const plus = ctx.request.body.datasource.plus;
|
|
34846
34878
|
const fetchSchema = ctx.request.body.fetchSchema;
|
|
34879
|
+
const tablesFilter = ctx.request.body.tablesFilter;
|
|
34847
34880
|
const datasource2 = {
|
|
34848
34881
|
_id: generateDatasourceID({ plus }),
|
|
34849
34882
|
...ctx.request.body.datasource,
|
|
@@ -34851,7 +34884,10 @@ async function save13(ctx) {
|
|
|
34851
34884
|
};
|
|
34852
34885
|
let schemaError = null;
|
|
34853
34886
|
if (fetchSchema) {
|
|
34854
|
-
const { tables, error: error2 } = await
|
|
34887
|
+
const { tables, error: error2 } = await buildFilteredSchema(
|
|
34888
|
+
datasource2,
|
|
34889
|
+
tablesFilter
|
|
34890
|
+
);
|
|
34855
34891
|
schemaError = error2;
|
|
34856
34892
|
datasource2.entities = tables;
|
|
34857
34893
|
setDefaultDisplayColumns(datasource2);
|