@budibase/server 2.7.4 → 2.7.5-alpha.0
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.50108b3a.js → index.933787a7.js} +354 -354
- package/builder/assets/{index.a86e2071.css → index.b33e8ad5.css} +1 -1
- package/builder/index.html +2 -2
- package/dist/automation.js +44 -34
- package/dist/automation.js.map +3 -3
- package/dist/index.js +49 -34
- package/dist/index.js.map +3 -3
- package/dist/query.js +22 -19
- package/dist/query.js.map +3 -3
- package/package.json +8 -8
- package/src/api/controllers/datasource.ts +13 -1
- package/src/api/controllers/table/external.ts +1 -0
- package/src/integrations/googlesheets.ts +18 -2
package/dist/index.js
CHANGED
|
@@ -5397,11 +5397,11 @@ function makeCacheItem(doc, lastWrite = null) {
|
|
|
5397
5397
|
return { doc, lastWrite: lastWrite || Date.now() };
|
|
5398
5398
|
}
|
|
5399
5399
|
async function put(db2, doc, writeRateMs = DEFAULT_WRITE_RATE_MS) {
|
|
5400
|
-
const
|
|
5400
|
+
const cache3 = await getCache();
|
|
5401
5401
|
const key = doc._id;
|
|
5402
5402
|
let cacheItem;
|
|
5403
5403
|
if (key) {
|
|
5404
|
-
cacheItem = await
|
|
5404
|
+
cacheItem = await cache3.get(makeCacheKey(db2, key));
|
|
5405
5405
|
}
|
|
5406
5406
|
const updateDb = !cacheItem || cacheItem.lastWrite < Date.now() - writeRateMs;
|
|
5407
5407
|
let output = doc;
|
|
@@ -5439,30 +5439,30 @@ async function put(db2, doc, writeRateMs = DEFAULT_WRITE_RATE_MS) {
|
|
|
5439
5439
|
}
|
|
5440
5440
|
cacheItem = makeCacheItem(output, updateDb ? null : cacheItem == null ? void 0 : cacheItem.lastWrite);
|
|
5441
5441
|
if (output._id) {
|
|
5442
|
-
await
|
|
5442
|
+
await cache3.store(makeCacheKey(db2, output._id), cacheItem);
|
|
5443
5443
|
}
|
|
5444
5444
|
return { ok: true, id: output._id, rev: output._rev };
|
|
5445
5445
|
}
|
|
5446
5446
|
async function get2(db2, id) {
|
|
5447
|
-
const
|
|
5447
|
+
const cache3 = await getCache();
|
|
5448
5448
|
const cacheKey = makeCacheKey(db2, id);
|
|
5449
|
-
let cacheItem = await
|
|
5449
|
+
let cacheItem = await cache3.get(cacheKey);
|
|
5450
5450
|
if (!cacheItem) {
|
|
5451
5451
|
const doc = await db2.get(id);
|
|
5452
5452
|
cacheItem = makeCacheItem(doc);
|
|
5453
|
-
await
|
|
5453
|
+
await cache3.store(cacheKey, cacheItem);
|
|
5454
5454
|
}
|
|
5455
5455
|
return cacheItem.doc;
|
|
5456
5456
|
}
|
|
5457
5457
|
async function remove(db2, docOrId, rev) {
|
|
5458
|
-
const
|
|
5458
|
+
const cache3 = await getCache();
|
|
5459
5459
|
if (!docOrId) {
|
|
5460
5460
|
throw new Error("No ID/Rev provided.");
|
|
5461
5461
|
}
|
|
5462
5462
|
const id = typeof docOrId === "string" ? docOrId : docOrId._id;
|
|
5463
5463
|
rev = typeof docOrId === "string" ? rev : docOrId._rev;
|
|
5464
5464
|
try {
|
|
5465
|
-
await
|
|
5465
|
+
await cache3.delete(makeCacheKey(db2, id));
|
|
5466
5466
|
} finally {
|
|
5467
5467
|
await db2.remove(id, rev);
|
|
5468
5468
|
}
|
|
@@ -10060,8 +10060,8 @@ async function preAuth(passport2, ctx, next) {
|
|
|
10060
10060
|
callbackUrl,
|
|
10061
10061
|
ssoSaveUserNoOp
|
|
10062
10062
|
);
|
|
10063
|
-
if (!ctx.query.appId
|
|
10064
|
-
ctx.throw(400, "appId
|
|
10063
|
+
if (!ctx.query.appId) {
|
|
10064
|
+
ctx.throw(400, "appId query param not present.");
|
|
10065
10065
|
}
|
|
10066
10066
|
return passport2.authenticate(strategy, {
|
|
10067
10067
|
scope: ["profile", "email", "https://www.googleapis.com/auth/spreadsheets"],
|
|
@@ -10081,7 +10081,7 @@ async function postAuth(passport2, ctx, next) {
|
|
|
10081
10081
|
clientSecret: config.clientSecret,
|
|
10082
10082
|
callbackURL: callbackUrl
|
|
10083
10083
|
},
|
|
10084
|
-
(accessToken, refreshToken,
|
|
10084
|
+
(accessToken, refreshToken, _profile, done) => {
|
|
10085
10085
|
clearCookie(ctx, "budibase:datasourceauth" /* DatasourceAuth */);
|
|
10086
10086
|
done(null, { accessToken, refreshToken });
|
|
10087
10087
|
}
|
|
@@ -10089,22 +10089,14 @@ async function postAuth(passport2, ctx, next) {
|
|
|
10089
10089
|
{ successRedirect: "/", failureRedirect: "/error" },
|
|
10090
10090
|
async (err, tokens) => {
|
|
10091
10091
|
const baseUrl = `/builder/app/${authStateCookie.appId}/data`;
|
|
10092
|
-
|
|
10093
|
-
|
|
10094
|
-
|
|
10095
|
-
|
|
10096
|
-
|
|
10097
|
-
if (err2.status === 404) {
|
|
10098
|
-
ctx.redirect(baseUrl);
|
|
10099
|
-
}
|
|
10100
|
-
}
|
|
10101
|
-
if (!datasource2.config) {
|
|
10102
|
-
datasource2.config = {};
|
|
10092
|
+
const id = utils_exports2.newid();
|
|
10093
|
+
await cache_exports.store(
|
|
10094
|
+
`datasource:creation:${authStateCookie.appId}:google:${id}`,
|
|
10095
|
+
{
|
|
10096
|
+
tokens
|
|
10103
10097
|
}
|
|
10104
|
-
|
|
10105
|
-
|
|
10106
|
-
ctx.redirect(`${baseUrl}/datasource/${authStateCookie.datasourceId}`);
|
|
10107
|
-
});
|
|
10098
|
+
);
|
|
10099
|
+
ctx.redirect(`${baseUrl}/new?continue_google_setup=${id}`);
|
|
10108
10100
|
}
|
|
10109
10101
|
)(ctx, next);
|
|
10110
10102
|
}
|
|
@@ -10114,9 +10106,9 @@ var init_google2 = __esm({
|
|
|
10114
10106
|
init_google();
|
|
10115
10107
|
init_constants2();
|
|
10116
10108
|
init_utils5();
|
|
10117
|
-
init_db5();
|
|
10118
10109
|
init_configs3();
|
|
10119
10110
|
init_sso2();
|
|
10111
|
+
init_src2();
|
|
10120
10112
|
GoogleStrategy2 = require("passport-google-oauth").OAuth2Strategy;
|
|
10121
10113
|
}
|
|
10122
10114
|
});
|
|
@@ -24847,22 +24839,22 @@ function threadSetup() {
|
|
|
24847
24839
|
init10();
|
|
24848
24840
|
}
|
|
24849
24841
|
async function checkCacheForDynamicVariable(queryId, variable) {
|
|
24850
|
-
const
|
|
24851
|
-
return
|
|
24842
|
+
const cache3 = await getClient3();
|
|
24843
|
+
return cache3.get(makeVariableKey(queryId, variable));
|
|
24852
24844
|
}
|
|
24853
24845
|
async function invalidateDynamicVariables(cachedVars) {
|
|
24854
|
-
const
|
|
24846
|
+
const cache3 = await getClient3();
|
|
24855
24847
|
let promises = [];
|
|
24856
24848
|
for (let variable of cachedVars) {
|
|
24857
24849
|
promises.push(
|
|
24858
|
-
|
|
24850
|
+
cache3.delete(makeVariableKey(variable.queryId, variable.name))
|
|
24859
24851
|
);
|
|
24860
24852
|
}
|
|
24861
24853
|
await Promise.all(promises);
|
|
24862
24854
|
}
|
|
24863
24855
|
async function storeDynamicVariable(queryId, variable, value) {
|
|
24864
|
-
const
|
|
24865
|
-
await
|
|
24856
|
+
const cache3 = await getClient3();
|
|
24857
|
+
await cache3.store(
|
|
24866
24858
|
makeVariableKey(queryId, variable),
|
|
24867
24859
|
value,
|
|
24868
24860
|
VARIABLE_TTL_SECONDS
|
|
@@ -29038,6 +29030,16 @@ var init_rest = __esm({
|
|
|
29038
29030
|
});
|
|
29039
29031
|
|
|
29040
29032
|
// src/integrations/googlesheets.ts
|
|
29033
|
+
async function setupCreationAuth(datasouce) {
|
|
29034
|
+
if (datasouce.continueSetupId) {
|
|
29035
|
+
const appId = context_exports.getAppId();
|
|
29036
|
+
const tokens = await cache_exports.get(
|
|
29037
|
+
`datasource:creation:${appId}:google:${datasouce.continueSetupId}`
|
|
29038
|
+
);
|
|
29039
|
+
datasouce.auth = tokens.tokens;
|
|
29040
|
+
delete datasouce.continueSetupId;
|
|
29041
|
+
}
|
|
29042
|
+
}
|
|
29041
29043
|
var import_google_auth_library, import_google_spreadsheet, import_node_fetch10, ALLOWED_TYPES, SCHEMA12, GoogleSheetsIntegration, googlesheets_default;
|
|
29042
29044
|
var init_googlesheets = __esm({
|
|
29043
29045
|
"src/integrations/googlesheets.ts"() {
|
|
@@ -29075,7 +29077,7 @@ var init_googlesheets = __esm({
|
|
|
29075
29077
|
},
|
|
29076
29078
|
datasource: {
|
|
29077
29079
|
spreadsheetId: {
|
|
29078
|
-
display: "
|
|
29080
|
+
display: "Spreadsheet URL",
|
|
29079
29081
|
type: "string" /* STRING */,
|
|
29080
29082
|
required: true
|
|
29081
29083
|
}
|
|
@@ -29145,6 +29147,7 @@ var init_googlesheets = __esm({
|
|
|
29145
29147
|
}
|
|
29146
29148
|
async testConnection() {
|
|
29147
29149
|
try {
|
|
29150
|
+
await setupCreationAuth(this.config);
|
|
29148
29151
|
await this.connect();
|
|
29149
29152
|
return { connected: true };
|
|
29150
29153
|
} catch (e) {
|
|
@@ -34793,6 +34796,9 @@ async function save13(ctx) {
|
|
|
34793
34796
|
datasource2.entities = tables;
|
|
34794
34797
|
setDefaultDisplayColumns(datasource2);
|
|
34795
34798
|
}
|
|
34799
|
+
if (preSaveAction[datasource2.source]) {
|
|
34800
|
+
await preSaveAction[datasource2.source](datasource2);
|
|
34801
|
+
}
|
|
34796
34802
|
const dbResp = await db2.put(datasource2);
|
|
34797
34803
|
await events_exports.datasource.created(datasource2);
|
|
34798
34804
|
datasource2._rev = dbResp.rev;
|
|
@@ -34871,6 +34877,7 @@ async function query(ctx) {
|
|
|
34871
34877
|
ctx.throw(400, err);
|
|
34872
34878
|
}
|
|
34873
34879
|
}
|
|
34880
|
+
var preSaveAction;
|
|
34874
34881
|
var init_datasource5 = __esm({
|
|
34875
34882
|
"src/api/controllers/datasource.ts"() {
|
|
34876
34883
|
init_utils9();
|
|
@@ -34880,8 +34887,15 @@ var init_datasource5 = __esm({
|
|
|
34880
34887
|
init_utils24();
|
|
34881
34888
|
init_utils18();
|
|
34882
34889
|
init_src2();
|
|
34890
|
+
init_src();
|
|
34883
34891
|
init_sdk3();
|
|
34884
34892
|
init_websockets();
|
|
34893
|
+
init_googlesheets();
|
|
34894
|
+
preSaveAction = {
|
|
34895
|
+
["GOOGLE_SHEETS" /* GOOGLE_SHEETS */]: async (datasource2) => {
|
|
34896
|
+
await setupCreationAuth(datasource2.config);
|
|
34897
|
+
}
|
|
34898
|
+
};
|
|
34885
34899
|
}
|
|
34886
34900
|
});
|
|
34887
34901
|
|
|
@@ -36754,6 +36768,7 @@ async function save15(ctx) {
|
|
|
36754
36768
|
let tableToSave = {
|
|
36755
36769
|
type: "table",
|
|
36756
36770
|
_id: buildExternalTableId(datasourceId, inputs.name),
|
|
36771
|
+
sourceId: datasourceId,
|
|
36757
36772
|
...inputs
|
|
36758
36773
|
};
|
|
36759
36774
|
let oldTable;
|