@budibase/server 2.7.7-alpha.2 → 2.7.9
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.fbee8e8b.js → index.358319af.js} +364 -364
- package/builder/assets/{index.b33e8ad5.css → index.a86e2071.css} +1 -1
- package/builder/index.html +2 -2
- package/dist/automation.js +42 -112
- package/dist/automation.js.map +3 -3
- package/dist/index.js +42 -116
- package/dist/index.js.map +3 -3
- package/dist/query.js +20 -24
- package/dist/query.js.map +3 -3
- package/package.json +8 -8
- package/src/api/controllers/datasource.ts +1 -13
- package/src/automations/steps/sendSmtpEmail.ts +4 -55
- package/src/automations/tests/sendSmtpEmail.spec.js +71 -0
- package/src/integrations/googlesheets.ts +2 -18
- package/src/sdk/app/datasources/datasources.ts +1 -1
- package/src/utilities/workerRequests.ts +9 -20
- package/src/automations/tests/sendSmtpEmail.spec.ts +0 -74
package/dist/index.js
CHANGED
|
@@ -838,7 +838,6 @@ var init_automation2 = __esm({
|
|
|
838
838
|
AutomationIOType2["NUMBER"] = "number";
|
|
839
839
|
AutomationIOType2["ARRAY"] = "array";
|
|
840
840
|
AutomationIOType2["JSON"] = "json";
|
|
841
|
-
AutomationIOType2["DATE"] = "date";
|
|
842
841
|
return AutomationIOType2;
|
|
843
842
|
})(AutomationIOType || {});
|
|
844
843
|
AutomationCustomIOType = /* @__PURE__ */ ((AutomationCustomIOType2) => {
|
|
@@ -5398,11 +5397,11 @@ function makeCacheItem(doc, lastWrite = null) {
|
|
|
5398
5397
|
return { doc, lastWrite: lastWrite || Date.now() };
|
|
5399
5398
|
}
|
|
5400
5399
|
async function put(db2, doc, writeRateMs = DEFAULT_WRITE_RATE_MS) {
|
|
5401
|
-
const
|
|
5400
|
+
const cache2 = await getCache();
|
|
5402
5401
|
const key = doc._id;
|
|
5403
5402
|
let cacheItem;
|
|
5404
5403
|
if (key) {
|
|
5405
|
-
cacheItem = await
|
|
5404
|
+
cacheItem = await cache2.get(makeCacheKey(db2, key));
|
|
5406
5405
|
}
|
|
5407
5406
|
const updateDb = !cacheItem || cacheItem.lastWrite < Date.now() - writeRateMs;
|
|
5408
5407
|
let output = doc;
|
|
@@ -5440,30 +5439,30 @@ async function put(db2, doc, writeRateMs = DEFAULT_WRITE_RATE_MS) {
|
|
|
5440
5439
|
}
|
|
5441
5440
|
cacheItem = makeCacheItem(output, updateDb ? null : cacheItem == null ? void 0 : cacheItem.lastWrite);
|
|
5442
5441
|
if (output._id) {
|
|
5443
|
-
await
|
|
5442
|
+
await cache2.store(makeCacheKey(db2, output._id), cacheItem);
|
|
5444
5443
|
}
|
|
5445
5444
|
return { ok: true, id: output._id, rev: output._rev };
|
|
5446
5445
|
}
|
|
5447
5446
|
async function get2(db2, id) {
|
|
5448
|
-
const
|
|
5447
|
+
const cache2 = await getCache();
|
|
5449
5448
|
const cacheKey = makeCacheKey(db2, id);
|
|
5450
|
-
let cacheItem = await
|
|
5449
|
+
let cacheItem = await cache2.get(cacheKey);
|
|
5451
5450
|
if (!cacheItem) {
|
|
5452
5451
|
const doc = await db2.get(id);
|
|
5453
5452
|
cacheItem = makeCacheItem(doc);
|
|
5454
|
-
await
|
|
5453
|
+
await cache2.store(cacheKey, cacheItem);
|
|
5455
5454
|
}
|
|
5456
5455
|
return cacheItem.doc;
|
|
5457
5456
|
}
|
|
5458
5457
|
async function remove(db2, docOrId, rev) {
|
|
5459
|
-
const
|
|
5458
|
+
const cache2 = await getCache();
|
|
5460
5459
|
if (!docOrId) {
|
|
5461
5460
|
throw new Error("No ID/Rev provided.");
|
|
5462
5461
|
}
|
|
5463
5462
|
const id = typeof docOrId === "string" ? docOrId : docOrId._id;
|
|
5464
5463
|
rev = typeof docOrId === "string" ? rev : docOrId._rev;
|
|
5465
5464
|
try {
|
|
5466
|
-
await
|
|
5465
|
+
await cache2.delete(makeCacheKey(db2, id));
|
|
5467
5466
|
} finally {
|
|
5468
5467
|
await db2.remove(id, rev);
|
|
5469
5468
|
}
|
|
@@ -10061,8 +10060,8 @@ async function preAuth(passport2, ctx, next) {
|
|
|
10061
10060
|
callbackUrl,
|
|
10062
10061
|
ssoSaveUserNoOp
|
|
10063
10062
|
);
|
|
10064
|
-
if (!ctx.query.appId) {
|
|
10065
|
-
ctx.throw(400, "appId query
|
|
10063
|
+
if (!ctx.query.appId || !ctx.query.datasourceId) {
|
|
10064
|
+
ctx.throw(400, "appId and datasourceId query params not present.");
|
|
10066
10065
|
}
|
|
10067
10066
|
return passport2.authenticate(strategy, {
|
|
10068
10067
|
scope: ["profile", "email", "https://www.googleapis.com/auth/spreadsheets"],
|
|
@@ -10082,7 +10081,7 @@ async function postAuth(passport2, ctx, next) {
|
|
|
10082
10081
|
clientSecret: config.clientSecret,
|
|
10083
10082
|
callbackURL: callbackUrl
|
|
10084
10083
|
},
|
|
10085
|
-
(accessToken, refreshToken,
|
|
10084
|
+
(accessToken, refreshToken, profile, done) => {
|
|
10086
10085
|
clearCookie(ctx, "budibase:datasourceauth" /* DatasourceAuth */);
|
|
10087
10086
|
done(null, { accessToken, refreshToken });
|
|
10088
10087
|
}
|
|
@@ -10090,14 +10089,22 @@ async function postAuth(passport2, ctx, next) {
|
|
|
10090
10089
|
{ successRedirect: "/", failureRedirect: "/error" },
|
|
10091
10090
|
async (err, tokens) => {
|
|
10092
10091
|
const baseUrl = `/builder/app/${authStateCookie.appId}/data`;
|
|
10093
|
-
|
|
10094
|
-
|
|
10095
|
-
|
|
10096
|
-
|
|
10097
|
-
|
|
10092
|
+
await doWithDB(authStateCookie.appId, async (db2) => {
|
|
10093
|
+
let datasource2;
|
|
10094
|
+
try {
|
|
10095
|
+
datasource2 = await db2.get(authStateCookie.datasourceId);
|
|
10096
|
+
} catch (err2) {
|
|
10097
|
+
if (err2.status === 404) {
|
|
10098
|
+
ctx.redirect(baseUrl);
|
|
10099
|
+
}
|
|
10098
10100
|
}
|
|
10099
|
-
|
|
10100
|
-
|
|
10101
|
+
if (!datasource2.config) {
|
|
10102
|
+
datasource2.config = {};
|
|
10103
|
+
}
|
|
10104
|
+
datasource2.config.auth = { type: "google", ...tokens };
|
|
10105
|
+
await db2.put(datasource2);
|
|
10106
|
+
ctx.redirect(`${baseUrl}/datasource/${authStateCookie.datasourceId}`);
|
|
10107
|
+
});
|
|
10101
10108
|
}
|
|
10102
10109
|
)(ctx, next);
|
|
10103
10110
|
}
|
|
@@ -10106,9 +10113,9 @@ var init_google2 = __esm({
|
|
|
10106
10113
|
"../backend-core/src/middleware/passport/datasource/google.ts"() {
|
|
10107
10114
|
init_google();
|
|
10108
10115
|
init_constants2();
|
|
10109
|
-
init_configs3();
|
|
10110
|
-
init_cache();
|
|
10111
10116
|
init_utils5();
|
|
10117
|
+
init_db5();
|
|
10118
|
+
init_configs3();
|
|
10112
10119
|
init_sso2();
|
|
10113
10120
|
GoogleStrategy2 = require("passport-google-oauth").OAuth2Strategy;
|
|
10114
10121
|
}
|
|
@@ -24334,16 +24341,7 @@ async function checkResponse(response2, errorMsg, { ctx } = {}) {
|
|
|
24334
24341
|
}
|
|
24335
24342
|
return response2.json();
|
|
24336
24343
|
}
|
|
24337
|
-
async function sendSmtpEmail({
|
|
24338
|
-
to,
|
|
24339
|
-
from,
|
|
24340
|
-
subject,
|
|
24341
|
-
contents,
|
|
24342
|
-
cc,
|
|
24343
|
-
bcc,
|
|
24344
|
-
automation,
|
|
24345
|
-
invite
|
|
24346
|
-
}) {
|
|
24344
|
+
async function sendSmtpEmail(to, from, subject, contents, cc, bcc, automation) {
|
|
24347
24345
|
const response2 = await (0, import_node_fetch8.default)(
|
|
24348
24346
|
checkSlashesInUrl2(environment_default2.WORKER_URL + `/api/global/email/send`),
|
|
24349
24347
|
request(void 0, {
|
|
@@ -24356,8 +24354,7 @@ async function sendSmtpEmail({
|
|
|
24356
24354
|
cc,
|
|
24357
24355
|
bcc,
|
|
24358
24356
|
purpose: "custom",
|
|
24359
|
-
automation
|
|
24360
|
-
invite
|
|
24357
|
+
automation
|
|
24361
24358
|
}
|
|
24362
24359
|
})
|
|
24363
24360
|
);
|
|
@@ -24850,22 +24847,22 @@ function threadSetup() {
|
|
|
24850
24847
|
init10();
|
|
24851
24848
|
}
|
|
24852
24849
|
async function checkCacheForDynamicVariable(queryId, variable) {
|
|
24853
|
-
const
|
|
24854
|
-
return
|
|
24850
|
+
const cache2 = await getClient3();
|
|
24851
|
+
return cache2.get(makeVariableKey(queryId, variable));
|
|
24855
24852
|
}
|
|
24856
24853
|
async function invalidateDynamicVariables(cachedVars) {
|
|
24857
|
-
const
|
|
24854
|
+
const cache2 = await getClient3();
|
|
24858
24855
|
let promises = [];
|
|
24859
24856
|
for (let variable of cachedVars) {
|
|
24860
24857
|
promises.push(
|
|
24861
|
-
|
|
24858
|
+
cache2.delete(makeVariableKey(variable.queryId, variable.name))
|
|
24862
24859
|
);
|
|
24863
24860
|
}
|
|
24864
24861
|
await Promise.all(promises);
|
|
24865
24862
|
}
|
|
24866
24863
|
async function storeDynamicVariable(queryId, variable, value) {
|
|
24867
|
-
const
|
|
24868
|
-
await
|
|
24864
|
+
const cache2 = await getClient3();
|
|
24865
|
+
await cache2.store(
|
|
24869
24866
|
makeVariableKey(queryId, variable),
|
|
24870
24867
|
value,
|
|
24871
24868
|
VARIABLE_TTL_SECONDS
|
|
@@ -29041,16 +29038,6 @@ var init_rest = __esm({
|
|
|
29041
29038
|
});
|
|
29042
29039
|
|
|
29043
29040
|
// src/integrations/googlesheets.ts
|
|
29044
|
-
async function setupCreationAuth(datasouce) {
|
|
29045
|
-
if (datasouce.continueSetupId) {
|
|
29046
|
-
const appId = context_exports.getAppId();
|
|
29047
|
-
const tokens = await cache_exports.get(
|
|
29048
|
-
`datasource:creation:${appId}:google:${datasouce.continueSetupId}`
|
|
29049
|
-
);
|
|
29050
|
-
datasouce.auth = tokens.tokens;
|
|
29051
|
-
delete datasouce.continueSetupId;
|
|
29052
|
-
}
|
|
29053
|
-
}
|
|
29054
29041
|
var import_google_auth_library, import_google_spreadsheet, import_node_fetch10, ALLOWED_TYPES, SCHEMA12, GoogleSheetsIntegration, googlesheets_default;
|
|
29055
29042
|
var init_googlesheets = __esm({
|
|
29056
29043
|
"src/integrations/googlesheets.ts"() {
|
|
@@ -29088,7 +29075,7 @@ var init_googlesheets = __esm({
|
|
|
29088
29075
|
},
|
|
29089
29076
|
datasource: {
|
|
29090
29077
|
spreadsheetId: {
|
|
29091
|
-
display: "
|
|
29078
|
+
display: "Google Sheet URL",
|
|
29092
29079
|
type: "string" /* STRING */,
|
|
29093
29080
|
required: true
|
|
29094
29081
|
}
|
|
@@ -29158,7 +29145,6 @@ var init_googlesheets = __esm({
|
|
|
29158
29145
|
}
|
|
29159
29146
|
async testConnection() {
|
|
29160
29147
|
try {
|
|
29161
|
-
await setupCreationAuth(this.config);
|
|
29162
29148
|
await this.connect();
|
|
29163
29149
|
return { connected: true };
|
|
29164
29150
|
} catch (e) {
|
|
@@ -30541,7 +30527,7 @@ function mergeConfigs(update15, old) {
|
|
|
30541
30527
|
}
|
|
30542
30528
|
if (hasAuthConfigs(update15)) {
|
|
30543
30529
|
const configs = update15.config.authConfigs;
|
|
30544
|
-
const oldConfigs = (_a2 = old.config) == null ? void 0 : _a2.authConfigs;
|
|
30530
|
+
const oldConfigs = ((_a2 = old.config) == null ? void 0 : _a2.authConfigs) || [];
|
|
30545
30531
|
for (let config of configs) {
|
|
30546
30532
|
if (config.type !== "basic" /* BASIC */) {
|
|
30547
30533
|
continue;
|
|
@@ -32066,41 +32052,21 @@ var init_automationUtils = __esm({
|
|
|
32066
32052
|
|
|
32067
32053
|
// src/automations/steps/sendSmtpEmail.ts
|
|
32068
32054
|
async function run3({ inputs }) {
|
|
32069
|
-
let {
|
|
32070
|
-
to,
|
|
32071
|
-
from,
|
|
32072
|
-
subject,
|
|
32073
|
-
contents,
|
|
32074
|
-
cc,
|
|
32075
|
-
bcc,
|
|
32076
|
-
addInvite,
|
|
32077
|
-
startTime,
|
|
32078
|
-
endTime,
|
|
32079
|
-
summary,
|
|
32080
|
-
location,
|
|
32081
|
-
url
|
|
32082
|
-
} = inputs;
|
|
32055
|
+
let { to, from, subject, contents, cc, bcc } = inputs;
|
|
32083
32056
|
if (!contents) {
|
|
32084
32057
|
contents = "<h1>No content</h1>";
|
|
32085
32058
|
}
|
|
32086
32059
|
to = to || void 0;
|
|
32087
32060
|
try {
|
|
32088
|
-
let response2 = await sendSmtpEmail(
|
|
32061
|
+
let response2 = await sendSmtpEmail(
|
|
32089
32062
|
to,
|
|
32090
32063
|
from,
|
|
32091
32064
|
subject,
|
|
32092
32065
|
contents,
|
|
32093
32066
|
cc,
|
|
32094
32067
|
bcc,
|
|
32095
|
-
|
|
32096
|
-
|
|
32097
|
-
startTime,
|
|
32098
|
-
endTime,
|
|
32099
|
-
summary,
|
|
32100
|
-
location,
|
|
32101
|
-
url
|
|
32102
|
-
} : void 0
|
|
32103
|
-
});
|
|
32068
|
+
true
|
|
32069
|
+
);
|
|
32104
32070
|
return {
|
|
32105
32071
|
success: true,
|
|
32106
32072
|
response: response2
|
|
@@ -32156,35 +32122,6 @@ var init_sendSmtpEmail = __esm({
|
|
|
32156
32122
|
contents: {
|
|
32157
32123
|
type: "string" /* STRING */,
|
|
32158
32124
|
title: "HTML Contents"
|
|
32159
|
-
},
|
|
32160
|
-
addInvite: {
|
|
32161
|
-
type: "boolean" /* BOOLEAN */,
|
|
32162
|
-
title: "Add calendar invite"
|
|
32163
|
-
},
|
|
32164
|
-
startTime: {
|
|
32165
|
-
type: "date" /* DATE */,
|
|
32166
|
-
title: "Start Time",
|
|
32167
|
-
dependsOn: "addInvite"
|
|
32168
|
-
},
|
|
32169
|
-
endTime: {
|
|
32170
|
-
type: "date" /* DATE */,
|
|
32171
|
-
title: "End Time",
|
|
32172
|
-
dependsOn: "addInvite"
|
|
32173
|
-
},
|
|
32174
|
-
summary: {
|
|
32175
|
-
type: "string" /* STRING */,
|
|
32176
|
-
title: "Meeting Summary",
|
|
32177
|
-
dependsOn: "addInvite"
|
|
32178
|
-
},
|
|
32179
|
-
location: {
|
|
32180
|
-
type: "string" /* STRING */,
|
|
32181
|
-
title: "Location",
|
|
32182
|
-
dependsOn: "addInvite"
|
|
32183
|
-
},
|
|
32184
|
-
url: {
|
|
32185
|
-
type: "string" /* STRING */,
|
|
32186
|
-
title: "URL",
|
|
32187
|
-
dependsOn: "addInvite"
|
|
32188
32125
|
}
|
|
32189
32126
|
},
|
|
32190
32127
|
required: ["to", "from", "subject", "contents"]
|
|
@@ -34856,9 +34793,6 @@ async function save13(ctx) {
|
|
|
34856
34793
|
datasource2.entities = tables;
|
|
34857
34794
|
setDefaultDisplayColumns(datasource2);
|
|
34858
34795
|
}
|
|
34859
|
-
if (preSaveAction[datasource2.source]) {
|
|
34860
|
-
await preSaveAction[datasource2.source](datasource2);
|
|
34861
|
-
}
|
|
34862
34796
|
const dbResp = await db2.put(datasource2);
|
|
34863
34797
|
await events_exports.datasource.created(datasource2);
|
|
34864
34798
|
datasource2._rev = dbResp.rev;
|
|
@@ -34937,7 +34871,6 @@ async function query(ctx) {
|
|
|
34937
34871
|
ctx.throw(400, err);
|
|
34938
34872
|
}
|
|
34939
34873
|
}
|
|
34940
|
-
var preSaveAction;
|
|
34941
34874
|
var init_datasource5 = __esm({
|
|
34942
34875
|
"src/api/controllers/datasource.ts"() {
|
|
34943
34876
|
init_utils9();
|
|
@@ -34947,15 +34880,8 @@ var init_datasource5 = __esm({
|
|
|
34947
34880
|
init_utils24();
|
|
34948
34881
|
init_utils18();
|
|
34949
34882
|
init_src2();
|
|
34950
|
-
init_src();
|
|
34951
34883
|
init_sdk3();
|
|
34952
34884
|
init_websockets();
|
|
34953
|
-
init_googlesheets();
|
|
34954
|
-
preSaveAction = {
|
|
34955
|
-
["GOOGLE_SHEETS" /* GOOGLE_SHEETS */]: async (datasource2) => {
|
|
34956
|
-
await setupCreationAuth(datasource2.config);
|
|
34957
|
-
}
|
|
34958
|
-
};
|
|
34959
34885
|
}
|
|
34960
34886
|
});
|
|
34961
34887
|
|