@budibase/worker 2.1.22-alpha.6 → 2.1.22-alpha.7
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/coverage/clover.xml +326 -305
- package/coverage/coverage-final.json +13 -13
- package/coverage/lcov-report/index.html +34 -34
- package/coverage/lcov-report/src/api/controllers/global/auth.ts.html +50 -38
- package/coverage/lcov-report/src/api/controllers/global/configs.js.html +18 -18
- package/coverage/lcov-report/src/api/controllers/global/email.js.html +1 -1
- package/coverage/lcov-report/src/api/controllers/global/index.html +10 -10
- package/coverage/lcov-report/src/api/controllers/global/license.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/global/roles.js.html +1 -1
- package/coverage/lcov-report/src/api/controllers/global/self.ts.html +3 -3
- package/coverage/lcov-report/src/api/controllers/global/templates.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/global/users.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/global/workspaces.js.html +1 -1
- package/coverage/lcov-report/src/api/controllers/system/accounts.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/system/environment.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/system/index.html +1 -1
- package/coverage/lcov-report/src/api/controllers/system/migrations.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/system/restore.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/system/status.ts.html +1 -1
- package/coverage/lcov-report/src/api/controllers/system/tenants.ts.html +1 -1
- package/coverage/lcov-report/src/api/index.html +1 -1
- package/coverage/lcov-report/src/api/index.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/global/auth.js.html +1 -1
- package/coverage/lcov-report/src/api/routes/global/configs.js.html +10 -10
- package/coverage/lcov-report/src/api/routes/global/email.js.html +1 -1
- package/coverage/lcov-report/src/api/routes/global/index.html +1 -1
- package/coverage/lcov-report/src/api/routes/global/license.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/global/roles.js.html +1 -1
- package/coverage/lcov-report/src/api/routes/global/self.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/global/templates.ts.html +3 -3
- package/coverage/lcov-report/src/api/routes/global/users.js.html +1 -1
- package/coverage/lcov-report/src/api/routes/global/workspaces.js.html +1 -1
- package/coverage/lcov-report/src/api/routes/index.html +1 -1
- package/coverage/lcov-report/src/api/routes/index.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/system/accounts.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/system/environment.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/system/index.html +1 -1
- package/coverage/lcov-report/src/api/routes/system/migrations.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/system/restore.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/system/status.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/system/tenants.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/validation/index.html +1 -1
- package/coverage/lcov-report/src/api/routes/validation/index.ts.html +1 -1
- package/coverage/lcov-report/src/api/routes/validation/users.ts.html +1 -1
- package/coverage/lcov-report/src/constants/index.html +10 -10
- package/coverage/lcov-report/src/constants/{index.js.html → index.ts.html} +92 -113
- package/coverage/lcov-report/src/constants/templates/index.html +1 -1
- package/coverage/lcov-report/src/constants/templates/index.js.html +3 -3
- package/coverage/lcov-report/src/db/index.html +1 -1
- package/coverage/lcov-report/src/db/index.ts.html +1 -1
- package/coverage/lcov-report/src/environment.ts.html +1 -1
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/index.ts.html +1 -1
- package/coverage/lcov-report/src/middleware/cloudRestricted.js.html +3 -3
- package/coverage/lcov-report/src/middleware/index.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/globalInfoSyncUsers.ts.html +1 -1
- package/coverage/lcov-report/src/migrations/functions/index.html +1 -1
- package/coverage/lcov-report/src/migrations/index.html +1 -1
- package/coverage/lcov-report/src/migrations/index.ts.html +1 -1
- package/coverage/lcov-report/src/sdk/accounts/accounts.ts.html +1 -1
- package/coverage/lcov-report/src/sdk/accounts/index.html +1 -1
- package/coverage/lcov-report/src/sdk/accounts/index.ts.html +1 -1
- package/coverage/lcov-report/src/sdk/index.html +1 -1
- package/coverage/lcov-report/src/sdk/index.ts.html +1 -1
- package/coverage/lcov-report/src/sdk/users/events.ts.html +1 -1
- package/coverage/lcov-report/src/sdk/users/index.html +1 -1
- package/coverage/lcov-report/src/sdk/users/index.ts.html +1 -1
- package/coverage/lcov-report/src/sdk/users/users.ts.html +1 -1
- package/coverage/lcov-report/src/tests/TestConfiguration.ts.html +31 -22
- package/coverage/lcov-report/src/tests/api/accounts.ts.html +1 -1
- package/coverage/lcov-report/src/tests/api/auth.ts.html +1 -1
- package/coverage/lcov-report/src/tests/api/base.ts.html +1 -1
- package/coverage/lcov-report/src/tests/api/configs.ts.html +1 -1
- package/coverage/lcov-report/src/tests/api/email.ts.html +1 -1
- package/coverage/lcov-report/src/tests/api/environment.ts.html +1 -1
- package/coverage/lcov-report/src/tests/api/index.html +1 -1
- package/coverage/lcov-report/src/tests/api/index.ts.html +1 -1
- package/coverage/lcov-report/src/tests/api/migrations.ts.html +1 -1
- package/coverage/lcov-report/src/tests/api/restore.ts.html +1 -1
- package/coverage/lcov-report/src/tests/api/self.ts.html +1 -1
- package/coverage/lcov-report/src/tests/api/status.ts.html +1 -1
- package/coverage/lcov-report/src/tests/api/tenants.ts.html +1 -1
- package/coverage/lcov-report/src/tests/api/users.ts.html +1 -1
- package/coverage/lcov-report/src/tests/controllers.js.html +1 -1
- package/coverage/lcov-report/src/tests/index.html +15 -15
- package/coverage/lcov-report/src/tests/index.ts.html +1 -1
- package/coverage/lcov-report/src/tests/mocks/email.js.html +1 -1
- package/coverage/lcov-report/src/tests/mocks/index.html +1 -1
- package/coverage/lcov-report/src/tests/mocks/index.ts.html +1 -1
- package/coverage/lcov-report/src/tests/structures/configs.js.html +7 -7
- package/coverage/lcov-report/src/tests/structures/groups.ts.html +1 -1
- package/coverage/lcov-report/src/tests/structures/index.html +1 -1
- package/coverage/lcov-report/src/tests/structures/index.ts.html +1 -1
- package/coverage/lcov-report/src/tests/structures/users.ts.html +1 -1
- package/coverage/lcov-report/src/utilities/appService.js.html +4 -4
- package/coverage/lcov-report/src/utilities/{email.js.html → email.ts.html} +160 -61
- package/coverage/lcov-report/src/utilities/fileSystem.js.html +1 -1
- package/coverage/lcov-report/src/utilities/index.html +23 -23
- package/coverage/lcov-report/src/utilities/index.js.html +1 -1
- package/coverage/lcov-report/src/utilities/{redis.js.html → redis.ts.html} +53 -38
- package/coverage/lcov-report/src/utilities/{templates.js.html → templates.ts.html} +38 -38
- package/coverage/lcov-report/src/utilities/users.js.html +1 -1
- package/coverage/lcov.info +593 -529
- package/jest.config.ts +1 -0
- package/package.json +6 -6
- package/src/api/controllers/global/auth.ts +34 -30
- package/src/api/controllers/global/configs.js +17 -17
- package/src/api/controllers/global/self.ts +2 -2
- package/src/api/routes/global/configs.js +9 -9
- package/src/api/routes/global/templates.ts +2 -2
- package/src/api/routes/global/tests/configs.spec.ts +29 -29
- package/src/constants/{index.js → index.ts} +57 -64
- package/src/constants/templates/index.js +2 -2
- package/src/middleware/cloudRestricted.js +2 -2
- package/src/middleware/tests/tenancy.spec.ts +7 -7
- package/src/tests/TestConfiguration.ts +15 -12
- package/src/tests/structures/configs.js +6 -6
- package/src/utilities/appService.js +3 -3
- package/src/utilities/{email.js → email.ts} +78 -45
- package/src/utilities/{redis.js → redis.ts} +29 -24
- package/src/utilities/templates.ts +49 -0
- package/tsconfig.build.json +3 -3
- package/src/utilities/templates.js +0 -49
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<html lang="en">
|
|
4
4
|
|
|
5
5
|
<head>
|
|
6
|
-
<title>Code coverage report for src/utilities/redis.
|
|
6
|
+
<title>Code coverage report for src/utilities/redis.ts</title>
|
|
7
7
|
<meta charset="utf-8" />
|
|
8
8
|
<link rel="stylesheet" href="../../prettify.css" />
|
|
9
9
|
<link rel="stylesheet" href="../../base.css" />
|
|
@@ -19,20 +19,20 @@
|
|
|
19
19
|
<body>
|
|
20
20
|
<div class='wrapper'>
|
|
21
21
|
<div class='pad1'>
|
|
22
|
-
<h1><a href="../../index.html">All files</a> / <a href="index.html">src/utilities</a> redis.
|
|
22
|
+
<h1><a href="../../index.html">All files</a> / <a href="index.html">src/utilities</a> redis.ts</h1>
|
|
23
23
|
<div class='clearfix'>
|
|
24
24
|
|
|
25
25
|
<div class='fl pad1y space-right2'>
|
|
26
|
-
<span class="strong">80.
|
|
26
|
+
<span class="strong">80.48% </span>
|
|
27
27
|
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>
|
|
28
|
+
<span class='fraction'>33/41</span>
|
|
29
29
|
</div>
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">
|
|
33
|
+
<span class="strong">63.63% </span>
|
|
34
34
|
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>
|
|
35
|
+
<span class='fraction'>7/11</span>
|
|
36
36
|
</div>
|
|
37
37
|
|
|
38
38
|
|
|
@@ -44,9 +44,9 @@
|
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
<div class='fl pad1y space-right2'>
|
|
47
|
-
<span class="strong">
|
|
47
|
+
<span class="strong">84.61% </span>
|
|
48
48
|
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>
|
|
49
|
+
<span class='fraction'>33/39</span>
|
|
50
50
|
</div>
|
|
51
51
|
|
|
52
52
|
|
|
@@ -171,8 +171,12 @@
|
|
|
171
171
|
<a name='L106'></a><a href='#L106'>106</a>
|
|
172
172
|
<a name='L107'></a><a href='#L107'>107</a>
|
|
173
173
|
<a name='L108'></a><a href='#L108'>108</a>
|
|
174
|
-
<a name='L109'></a><a href='#L109'>109</a
|
|
175
|
-
<
|
|
174
|
+
<a name='L109'></a><a href='#L109'>109</a>
|
|
175
|
+
<a name='L110'></a><a href='#L110'>110</a>
|
|
176
|
+
<a name='L111'></a><a href='#L111'>111</a>
|
|
177
|
+
<a name='L112'></a><a href='#L112'>112</a>
|
|
178
|
+
<a name='L113'></a><a href='#L113'>113</a>
|
|
179
|
+
<a name='L114'></a><a href='#L114'>114</a></td><td class="line-coverage quiet"><span class="cline-any cline-yes">17x</span>
|
|
176
180
|
<span class="cline-any cline-neutral"> </span>
|
|
177
181
|
<span class="cline-any cline-neutral"> </span>
|
|
178
182
|
<span class="cline-any cline-yes">7x</span>
|
|
@@ -249,6 +253,9 @@
|
|
|
249
253
|
<span class="cline-any cline-neutral"> </span>
|
|
250
254
|
<span class="cline-any cline-neutral"> </span>
|
|
251
255
|
<span class="cline-any cline-yes">17x</span>
|
|
256
|
+
<span class="cline-any cline-neutral"> </span>
|
|
257
|
+
<span class="cline-any cline-neutral"> </span>
|
|
258
|
+
<span class="cline-any cline-neutral"> </span>
|
|
252
259
|
<span class="cline-any cline-yes">1x</span>
|
|
253
260
|
<span class="cline-any cline-yes">1x</span>
|
|
254
261
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -273,59 +280,61 @@
|
|
|
273
280
|
<span class="cline-any cline-neutral"> </span>
|
|
274
281
|
<span class="cline-any cline-neutral"> </span>
|
|
275
282
|
<span class="cline-any cline-yes">17x</span>
|
|
283
|
+
<span class="cline-any cline-neutral"> </span>
|
|
284
|
+
<span class="cline-any cline-neutral"> </span>
|
|
285
|
+
<span class="cline-any cline-neutral"> </span>
|
|
276
286
|
<span class="cline-any cline-yes">1x</span>
|
|
277
287
|
<span class="cline-any cline-yes">1x</span>
|
|
278
288
|
<span class="cline-any cline-neutral"> </span>
|
|
279
289
|
<span class="cline-any cline-no"> </span>
|
|
280
290
|
<span class="cline-any cline-neutral"> </span>
|
|
281
291
|
<span class="cline-any cline-neutral"> </span>
|
|
282
|
-
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">
|
|
283
|
-
const { newid } = require("@budibase/backend-core/utils")
|
|
292
|
+
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">import { redis, utils } from "@budibase/backend-core"
|
|
284
293
|
|
|
285
|
-
function getExpirySecondsForDB(db) {
|
|
294
|
+
function getExpirySecondsForDB(db: string) {
|
|
286
295
|
switch (db) {
|
|
287
|
-
case utils.Databases.PW_RESETS:
|
|
296
|
+
case redis.utils.Databases.PW_RESETS:
|
|
288
297
|
// a hour
|
|
289
298
|
return 3600
|
|
290
|
-
case utils.Databases.INVITATIONS:
|
|
299
|
+
case redis.utils.Databases.INVITATIONS:
|
|
291
300
|
// a day
|
|
292
301
|
return 86400
|
|
293
302
|
}
|
|
294
303
|
}
|
|
295
304
|
|
|
296
|
-
let pwResetClient, invitationClient
|
|
305
|
+
let pwResetClient: any, invitationClient: any
|
|
297
306
|
|
|
298
|
-
function getClient(db) {
|
|
307
|
+
function getClient(db: string) {
|
|
299
308
|
switch (db) {
|
|
300
|
-
case utils.Databases.PW_RESETS:
|
|
309
|
+
case redis.utils.Databases.PW_RESETS:
|
|
301
310
|
return pwResetClient
|
|
302
|
-
case utils.Databases.INVITATIONS:
|
|
311
|
+
case redis.utils.Databases.INVITATIONS:
|
|
303
312
|
return invitationClient
|
|
304
313
|
}
|
|
305
314
|
}
|
|
306
315
|
|
|
307
|
-
async function writeACode(db, value) {
|
|
316
|
+
async function writeACode(db: string, value: any) {
|
|
308
317
|
const client = await getClient(db)
|
|
309
|
-
const code = newid()
|
|
318
|
+
const code = utils.newid()
|
|
310
319
|
await client.store(code, value, getExpirySecondsForDB(db))
|
|
311
320
|
return code
|
|
312
321
|
}
|
|
313
322
|
|
|
314
|
-
async function getACode(db, code, deleteCode = <span class="branch-0 cbranch-no" title="branch not covered" >true)</span> {
|
|
323
|
+
async function getACode(db: string, code: string, deleteCode = <span class="branch-0 cbranch-no" title="branch not covered" >true)</span> {
|
|
315
324
|
const client = await getClient(db)
|
|
316
325
|
const value = await client.get(code)
|
|
317
326
|
<span class="missing-if-branch" title="if path not taken" >I</span>if (!value) {
|
|
318
327
|
<span class="cstat-no" title="statement not covered" > throw "Invalid code."</span>
|
|
319
328
|
}
|
|
320
|
-
|
|
329
|
+
if (deleteCode) {
|
|
321
330
|
await client.delete(code)
|
|
322
331
|
}
|
|
323
332
|
return value
|
|
324
333
|
}
|
|
325
334
|
|
|
326
|
-
|
|
327
|
-
pwResetClient = new Client(utils.Databases.PW_RESETS)
|
|
328
|
-
invitationClient = new Client(utils.Databases.INVITATIONS)
|
|
335
|
+
export async function init() {
|
|
336
|
+
pwResetClient = new redis.Client(redis.utils.Databases.PW_RESETS)
|
|
337
|
+
invitationClient = new redis.Client(redis.utils.Databases.INVITATIONS)
|
|
329
338
|
await pwResetClient.init()
|
|
330
339
|
await invitationClient.init()
|
|
331
340
|
}
|
|
@@ -333,9 +342,9 @@ exports.init = async () => {
|
|
|
333
342
|
/**
|
|
334
343
|
* make sure redis connection is closed.
|
|
335
344
|
*/
|
|
336
|
-
|
|
337
|
-
<span class="cstat-no" title="statement not covered" > if (pwResetClient) <span class="cstat-no" title="statement not covered" >await pwResetClient.finish()</span></span>
|
|
338
|
-
<span class="cstat-no" title="statement not covered" > if (invitationClient) <span class="cstat-no" title="statement not covered" >await invitationClient.finish()</span></span>
|
|
345
|
+
export async function <span class="fstat-no" title="function not covered" >shutdown(</span>) {
|
|
346
|
+
<span class="cstat-no" title="statement not covered" > <span class="missing-if-branch" title="if path not taken" >I</span>if (pwResetClient) <span class="cstat-no" title="statement not covered" >await pwResetClient.finish()</span></span>
|
|
347
|
+
<span class="cstat-no" title="statement not covered" > <span class="missing-if-branch" title="if path not taken" >I</span>if (invitationClient) <span class="cstat-no" title="statement not covered" >await invitationClient.finish()</span></span>
|
|
339
348
|
<span class="cstat-no" title="statement not covered" > console.log("Redis shutdown")</span>
|
|
340
349
|
}
|
|
341
350
|
|
|
@@ -346,8 +355,8 @@ exports.shutdown = <span class="fstat-no" title="function not covered" >as</span
|
|
|
346
355
|
* @param {object} info Info about the user/the reset process.
|
|
347
356
|
* @return {Promise<string>} returns the code that was stored to redis.
|
|
348
357
|
*/
|
|
349
|
-
|
|
350
|
-
return writeACode(utils.Databases.PW_RESETS, { userId, info })
|
|
358
|
+
export async function getResetPasswordCode(userId: string, info: any) {
|
|
359
|
+
return writeACode(redis.utils.Databases.PW_RESETS, { userId, info })
|
|
351
360
|
}
|
|
352
361
|
|
|
353
362
|
/**
|
|
@@ -356,9 +365,12 @@ exports.getResetPasswordCode = async (userId, info) => {
|
|
|
356
365
|
* @param {boolean} deleteCode If the code is used/finished with this will delete it - defaults to true.
|
|
357
366
|
* @return {Promise<string>} returns the user ID if it is found
|
|
358
367
|
*/
|
|
359
|
-
|
|
368
|
+
export async function checkResetPasswordCode(
|
|
369
|
+
resetCode: string,
|
|
370
|
+
deleteCode = true
|
|
371
|
+
) {
|
|
360
372
|
try {
|
|
361
|
-
return getACode(utils.Databases.PW_RESETS, resetCode, deleteCode)
|
|
373
|
+
return getACode(redis.utils.Databases.PW_RESETS, resetCode, deleteCode)
|
|
362
374
|
} catch (err) {
|
|
363
375
|
<span class="cstat-no" title="statement not covered" > throw "Provided information is not valid, cannot reset password - please try again."</span>
|
|
364
376
|
}
|
|
@@ -370,8 +382,8 @@ exports.checkResetPasswordCode = async (resetCode, deleteCode = true) => {
|
|
|
370
382
|
* @param {object|null} info Information to be carried along with the invitation.
|
|
371
383
|
* @return {Promise<string>} returns the code that was stored to redis.
|
|
372
384
|
*/
|
|
373
|
-
|
|
374
|
-
return writeACode(utils.Databases.INVITATIONS, { email, info })
|
|
385
|
+
export async function getInviteCode(email: string, info: any) {
|
|
386
|
+
return writeACode(redis.utils.Databases.INVITATIONS, { email, info })
|
|
375
387
|
}
|
|
376
388
|
|
|
377
389
|
/**
|
|
@@ -380,9 +392,12 @@ exports.getInviteCode = async (email, info) => {
|
|
|
380
392
|
* @param {boolean} deleteCode whether or not the code should be deleted after retrieval - defaults to true.
|
|
381
393
|
* @return {Promise<object>} If the code is valid then an email address will be returned.
|
|
382
394
|
*/
|
|
383
|
-
|
|
395
|
+
export async function checkInviteCode(
|
|
396
|
+
inviteCode: string,
|
|
397
|
+
deleteCode: boolean = true
|
|
398
|
+
) {
|
|
384
399
|
try {
|
|
385
|
-
return getACode(utils.Databases.INVITATIONS, inviteCode, deleteCode)
|
|
400
|
+
return getACode(redis.utils.Databases.INVITATIONS, inviteCode, deleteCode)
|
|
386
401
|
} catch (err) {
|
|
387
402
|
<span class="cstat-no" title="statement not covered" > throw "Invitation is not valid or has expired, please request a new one."</span>
|
|
388
403
|
}
|
|
@@ -394,7 +409,7 @@ exports.checkInviteCode = async (inviteCode, deleteCode = true) => {
|
|
|
394
409
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
395
410
|
Code coverage generated by
|
|
396
411
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
397
|
-
at
|
|
412
|
+
at Thu Nov 17 2022 16:59:05 GMT+0000 (Coordinated Universal Time)
|
|
398
413
|
</div>
|
|
399
414
|
<script src="../../prettify.js"></script>
|
|
400
415
|
<script>
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<html lang="en">
|
|
4
4
|
|
|
5
5
|
<head>
|
|
6
|
-
<title>Code coverage report for src/utilities/templates.
|
|
6
|
+
<title>Code coverage report for src/utilities/templates.ts</title>
|
|
7
7
|
<meta charset="utf-8" />
|
|
8
8
|
<link rel="stylesheet" href="../../prettify.css" />
|
|
9
9
|
<link rel="stylesheet" href="../../base.css" />
|
|
@@ -19,20 +19,20 @@
|
|
|
19
19
|
<body>
|
|
20
20
|
<div class='wrapper'>
|
|
21
21
|
<div class='pad1'>
|
|
22
|
-
<h1><a href="../../index.html">All files</a> / <a href="index.html">src/utilities</a> templates.
|
|
22
|
+
<h1><a href="../../index.html">All files</a> / <a href="index.html">src/utilities</a> templates.ts</h1>
|
|
23
23
|
<div class='clearfix'>
|
|
24
24
|
|
|
25
25
|
<div class='fl pad1y space-right2'>
|
|
26
26
|
<span class="strong">100% </span>
|
|
27
27
|
<span class="quiet">Statements</span>
|
|
28
|
-
<span class='fraction'>
|
|
28
|
+
<span class='fraction'>17/17</span>
|
|
29
29
|
</div>
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
<div class='fl pad1y space-right2'>
|
|
33
|
-
<span class="strong">
|
|
33
|
+
<span class="strong">70% </span>
|
|
34
34
|
<span class="quiet">Branches</span>
|
|
35
|
-
<span class='fraction'>7/
|
|
35
|
+
<span class='fraction'>7/10</span>
|
|
36
36
|
</div>
|
|
37
37
|
|
|
38
38
|
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
<div class='fl pad1y space-right2'>
|
|
47
47
|
<span class="strong">100% </span>
|
|
48
48
|
<span class="quiet">Lines</span>
|
|
49
|
-
<span class='fraction'>
|
|
49
|
+
<span class='fraction'>17/17</span>
|
|
50
50
|
</div>
|
|
51
51
|
|
|
52
52
|
|
|
@@ -113,6 +113,7 @@
|
|
|
113
113
|
<a name='L48'></a><a href='#L48'>48</a>
|
|
114
114
|
<a name='L49'></a><a href='#L49'>49</a>
|
|
115
115
|
<a name='L50'></a><a href='#L50'>50</a></td><td class="line-coverage quiet"><span class="cline-any cline-yes">17x</span>
|
|
116
|
+
<span class="cline-any cline-yes">17x</span>
|
|
116
117
|
<span class="cline-any cline-neutral"> </span>
|
|
117
118
|
<span class="cline-any cline-neutral"> </span>
|
|
118
119
|
<span class="cline-any cline-neutral"> </span>
|
|
@@ -121,14 +122,13 @@
|
|
|
121
122
|
<span class="cline-any cline-yes">17x</span>
|
|
122
123
|
<span class="cline-any cline-yes">17x</span>
|
|
123
124
|
<span class="cline-any cline-neutral"> </span>
|
|
125
|
+
<span class="cline-any cline-yes">17x</span>
|
|
124
126
|
<span class="cline-any cline-neutral"> </span>
|
|
125
127
|
<span class="cline-any cline-neutral"> </span>
|
|
126
|
-
<span class="cline-any cline-yes">17x</span>
|
|
127
|
-
<span class="cline-any cline-yes">17x</span>
|
|
128
128
|
<span class="cline-any cline-neutral"> </span>
|
|
129
|
-
<span class="cline-any cline-yes">17x</span>
|
|
130
129
|
<span class="cline-any cline-yes">7x</span>
|
|
131
130
|
<span class="cline-any cline-neutral"> </span>
|
|
131
|
+
<span class="cline-any cline-neutral"> </span>
|
|
132
132
|
<span class="cline-any cline-yes">7x</span>
|
|
133
133
|
<span class="cline-any cline-yes">7x</span>
|
|
134
134
|
<span class="cline-any cline-yes">7x</span>
|
|
@@ -161,50 +161,50 @@
|
|
|
161
161
|
<span class="cline-any cline-neutral"> </span>
|
|
162
162
|
<span class="cline-any cline-yes">7x</span>
|
|
163
163
|
<span class="cline-any cline-neutral"> </span>
|
|
164
|
-
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
164
|
+
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">import { db as dbCore, tenancy } from "@budibase/backend-core"
|
|
165
|
+
import {
|
|
166
|
+
Config,
|
|
167
|
+
InternalTemplateBinding,
|
|
168
168
|
LOGO_URL,
|
|
169
169
|
EmailTemplatePurpose,
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
const {
|
|
173
|
-
getGlobalDB,
|
|
174
|
-
addTenantToUrl,
|
|
175
|
-
} = require("@budibase/backend-core/tenancy")
|
|
170
|
+
} from "../constants"
|
|
171
|
+
import { checkSlashesInUrl } from "./index"
|
|
176
172
|
const BASE_COMPANY = "Budibase"
|
|
177
173
|
|
|
178
|
-
|
|
179
|
-
|
|
174
|
+
export async function getSettingsTemplateContext(
|
|
175
|
+
purpose: EmailTemplatePurpose,
|
|
176
|
+
code?: string
|
|
177
|
+
) {
|
|
178
|
+
const db = tenancy.getGlobalDB()
|
|
180
179
|
// TODO: use more granular settings in the future if required
|
|
181
|
-
let settings =
|
|
180
|
+
let settings =
|
|
181
|
+
(await dbCore.getScopedConfig(db, { type: Config.SETTINGS })) || <span class="branch-1 cbranch-no" title="branch not covered" >{}</span>
|
|
182
182
|
const URL = settings.platformUrl
|
|
183
|
-
const context = {
|
|
184
|
-
[
|
|
183
|
+
const context: any = {
|
|
184
|
+
[InternalTemplateBinding.LOGO_URL]:
|
|
185
185
|
checkSlashesInUrl(`${URL}/${settings.logoUrl}`) || <span class="branch-1 cbranch-no" title="branch not covered" >LOGO_URL,</span>
|
|
186
|
-
[
|
|
187
|
-
[
|
|
188
|
-
[
|
|
186
|
+
[InternalTemplateBinding.PLATFORM_URL]: URL,
|
|
187
|
+
[InternalTemplateBinding.COMPANY]: settings.company || <span class="branch-1 cbranch-no" title="branch not covered" >BASE_COMPANY,</span>
|
|
188
|
+
[InternalTemplateBinding.DOCS_URL]:
|
|
189
189
|
settings.docsUrl || "https://docs.budibase.com/",
|
|
190
|
-
[
|
|
191
|
-
addTenantToUrl(`${URL}/login`)
|
|
190
|
+
[InternalTemplateBinding.LOGIN_URL]: checkSlashesInUrl(
|
|
191
|
+
tenancy.addTenantToUrl(`${URL}/login`)
|
|
192
192
|
),
|
|
193
|
-
[
|
|
194
|
-
[
|
|
193
|
+
[InternalTemplateBinding.CURRENT_DATE]: new Date().toISOString(),
|
|
194
|
+
[InternalTemplateBinding.CURRENT_YEAR]: new Date().getFullYear(),
|
|
195
195
|
}
|
|
196
196
|
// attach purpose specific context
|
|
197
197
|
switch (purpose) {
|
|
198
198
|
case EmailTemplatePurpose.PASSWORD_RECOVERY:
|
|
199
|
-
context[
|
|
200
|
-
context[
|
|
201
|
-
addTenantToUrl(`${URL}/builder/auth/reset?code=${code}`)
|
|
199
|
+
context[InternalTemplateBinding.RESET_CODE] = code
|
|
200
|
+
context[InternalTemplateBinding.RESET_URL] = checkSlashesInUrl(
|
|
201
|
+
tenancy.addTenantToUrl(`${URL}/builder/auth/reset?code=${code}`)
|
|
202
202
|
)
|
|
203
203
|
break
|
|
204
204
|
case EmailTemplatePurpose.INVITATION:
|
|
205
|
-
context[
|
|
206
|
-
context[
|
|
207
|
-
addTenantToUrl(`${URL}/builder/invite?code=${code}`)
|
|
205
|
+
context[InternalTemplateBinding.INVITE_CODE] = code
|
|
206
|
+
context[InternalTemplateBinding.INVITE_URL] = checkSlashesInUrl(
|
|
207
|
+
tenancy.addTenantToUrl(`${URL}/builder/invite?code=${code}`)
|
|
208
208
|
)
|
|
209
209
|
break
|
|
210
210
|
}
|
|
@@ -217,7 +217,7 @@ exports.getSettingsTemplateContext = async (purpose, code = <span class="branch-
|
|
|
217
217
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
218
218
|
Code coverage generated by
|
|
219
219
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
220
|
-
at
|
|
220
|
+
at Thu Nov 17 2022 16:59:05 GMT+0000 (Coordinated Universal Time)
|
|
221
221
|
</div>
|
|
222
222
|
<script src="../../prettify.js"></script>
|
|
223
223
|
<script>
|
|
@@ -121,7 +121,7 @@ exports.checkAnyUserExists = async () => {
|
|
|
121
121
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
122
122
|
Code coverage generated by
|
|
123
123
|
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
|
|
124
|
-
at
|
|
124
|
+
at Thu Nov 17 2022 16:59:05 GMT+0000 (Coordinated Universal Time)
|
|
125
125
|
</div>
|
|
126
126
|
<script src="../../prettify.js"></script>
|
|
127
127
|
<script>
|