@budibase/server 2.7.7-alpha.3 → 2.7.7-alpha.4
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 +44 -14
- package/dist/automation.js.map +3 -3
- package/dist/index.js +69 -35
- package/dist/index.js.map +3 -3
- package/dist/query.js +44 -14
- package/dist/query.js.map +3 -3
- package/package.json +8 -8
- package/src/api/controllers/datasource.ts +28 -23
- package/src/integrations/googlesheets.ts +18 -17
- 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
|
}
|
|
@@ -29158,7 +29187,6 @@ var init_googlesheets = __esm({
|
|
|
29158
29187
|
}
|
|
29159
29188
|
async testConnection() {
|
|
29160
29189
|
try {
|
|
29161
|
-
await setupCreationAuth(this.config);
|
|
29162
29190
|
await this.connect();
|
|
29163
29191
|
return { connected: true };
|
|
29164
29192
|
} catch (e) {
|
|
@@ -29210,6 +29238,7 @@ var init_googlesheets = __esm({
|
|
|
29210
29238
|
async connect() {
|
|
29211
29239
|
var _a2;
|
|
29212
29240
|
try {
|
|
29241
|
+
await setupCreationAuth(this.config);
|
|
29213
29242
|
let googleConfig = await configs_exports.getGoogleDatasourceConfig();
|
|
29214
29243
|
if (!googleConfig) {
|
|
29215
29244
|
throw new HTTPError("Google config not found", 400);
|
|
@@ -29260,21 +29289,22 @@ var init_googlesheets = __esm({
|
|
|
29260
29289
|
return table2;
|
|
29261
29290
|
}
|
|
29262
29291
|
async buildSchema(datasourceId, entities) {
|
|
29263
|
-
if (!this.config.auth) {
|
|
29264
|
-
return;
|
|
29265
|
-
}
|
|
29266
29292
|
await this.connect();
|
|
29267
29293
|
const sheets = this.client.sheetsByIndex;
|
|
29268
29294
|
const tables = {};
|
|
29269
|
-
|
|
29270
|
-
|
|
29271
|
-
|
|
29272
|
-
|
|
29273
|
-
sheet.title
|
|
29274
|
-
sheet.
|
|
29275
|
-
|
|
29276
|
-
|
|
29277
|
-
|
|
29295
|
+
await utils_exports5.parallelForeach(
|
|
29296
|
+
sheets,
|
|
29297
|
+
async (sheet) => {
|
|
29298
|
+
await sheet.getRows({ limit: 0, offset: 0 });
|
|
29299
|
+
const id = buildExternalTableId(datasourceId, sheet.title);
|
|
29300
|
+
tables[sheet.title] = this.getTableSchema(
|
|
29301
|
+
sheet.title,
|
|
29302
|
+
sheet.headerValues,
|
|
29303
|
+
id
|
|
29304
|
+
);
|
|
29305
|
+
},
|
|
29306
|
+
10
|
|
29307
|
+
);
|
|
29278
29308
|
const final = finaliseExternalTables(tables, entities);
|
|
29279
29309
|
this.tables = final.tables;
|
|
29280
29310
|
this.schemaErrors = final.errors;
|
|
@@ -34686,6 +34716,19 @@ async function buildSchemaHelper(datasource2) {
|
|
|
34686
34716
|
}
|
|
34687
34717
|
return { tables: connector.tables, error: error2 };
|
|
34688
34718
|
}
|
|
34719
|
+
async function buildFilteredSchema(datasource2, filter2) {
|
|
34720
|
+
let { tables, error: error2 } = await buildSchemaHelper(datasource2);
|
|
34721
|
+
let finalTables = tables;
|
|
34722
|
+
if (filter2) {
|
|
34723
|
+
finalTables = {};
|
|
34724
|
+
for (let key in tables) {
|
|
34725
|
+
if (filter2.some((filter3) => filter3.toLowerCase() === key.toLowerCase())) {
|
|
34726
|
+
finalTables[key] = tables[key];
|
|
34727
|
+
}
|
|
34728
|
+
}
|
|
34729
|
+
}
|
|
34730
|
+
return { tables: finalTables, error: error2 };
|
|
34731
|
+
}
|
|
34689
34732
|
async function fetch22(ctx) {
|
|
34690
34733
|
const db2 = context_exports.getAppDB();
|
|
34691
34734
|
const internalTables = await db2.allDocs(
|
|
@@ -34740,37 +34783,24 @@ async function information(ctx) {
|
|
|
34740
34783
|
}
|
|
34741
34784
|
const tableNames = await connector.getTableNames();
|
|
34742
34785
|
ctx.body = {
|
|
34743
|
-
tableNames
|
|
34786
|
+
tableNames: tableNames.sort()
|
|
34744
34787
|
};
|
|
34745
34788
|
}
|
|
34746
34789
|
async function buildSchemaFromDb(ctx) {
|
|
34747
34790
|
const db2 = context_exports.getAppDB();
|
|
34748
|
-
const datasource2 = await sdk_default.datasources.get(ctx.params.datasourceId);
|
|
34749
34791
|
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
|
-
}
|
|
34792
|
+
const datasource2 = await sdk_default.datasources.get(ctx.params.datasourceId);
|
|
34793
|
+
const { tables, error: error2 } = await buildFilteredSchema(datasource2, tablesFilter);
|
|
34794
|
+
datasource2.entities = tables;
|
|
34765
34795
|
setDefaultDisplayColumns(datasource2);
|
|
34766
34796
|
const dbResp = await db2.put(datasource2);
|
|
34767
34797
|
datasource2._rev = dbResp.rev;
|
|
34768
34798
|
const cleanedDatasource = await sdk_default.datasources.removeSecretSingle(datasource2);
|
|
34769
|
-
const
|
|
34799
|
+
const res = { datasource: cleanedDatasource };
|
|
34770
34800
|
if (error2) {
|
|
34771
|
-
|
|
34801
|
+
res.error = error2;
|
|
34772
34802
|
}
|
|
34773
|
-
ctx.body =
|
|
34803
|
+
ctx.body = res;
|
|
34774
34804
|
}
|
|
34775
34805
|
function setDefaultDisplayColumns(datasource2) {
|
|
34776
34806
|
for (let entity of Object.values(datasource2.entities || {})) {
|
|
@@ -34844,6 +34874,7 @@ async function save13(ctx) {
|
|
|
34844
34874
|
const db2 = context_exports.getAppDB();
|
|
34845
34875
|
const plus = ctx.request.body.datasource.plus;
|
|
34846
34876
|
const fetchSchema = ctx.request.body.fetchSchema;
|
|
34877
|
+
const tablesFilter = ctx.request.body.tablesFilter;
|
|
34847
34878
|
const datasource2 = {
|
|
34848
34879
|
_id: generateDatasourceID({ plus }),
|
|
34849
34880
|
...ctx.request.body.datasource,
|
|
@@ -34851,7 +34882,10 @@ async function save13(ctx) {
|
|
|
34851
34882
|
};
|
|
34852
34883
|
let schemaError = null;
|
|
34853
34884
|
if (fetchSchema) {
|
|
34854
|
-
const { tables, error: error2 } = await
|
|
34885
|
+
const { tables, error: error2 } = await buildFilteredSchema(
|
|
34886
|
+
datasource2,
|
|
34887
|
+
tablesFilter
|
|
34888
|
+
);
|
|
34855
34889
|
schemaError = error2;
|
|
34856
34890
|
datasource2.entities = tables;
|
|
34857
34891
|
setDefaultDisplayColumns(datasource2);
|