@budibase/worker 3.4.5 → 3.4.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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/worker",
|
|
3
3
|
"email": "hi@budibase.com",
|
|
4
|
-
"version": "3.4.
|
|
4
|
+
"version": "3.4.7",
|
|
5
5
|
"description": "Budibase background service",
|
|
6
6
|
"main": "src/index.ts",
|
|
7
7
|
"repository": {
|
|
@@ -114,5 +114,5 @@
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
},
|
|
117
|
-
"gitHead": "
|
|
117
|
+
"gitHead": "8b7e234e9da5237a393084a101bb7e6fcdbd97ce"
|
|
118
118
|
}
|
|
@@ -322,27 +322,27 @@ export async function save(
|
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
324
|
|
|
325
|
-
function enrichOIDCLogos(oidcLogos: OIDCLogosConfig) {
|
|
325
|
+
async function enrichOIDCLogos(oidcLogos: OIDCLogosConfig) {
|
|
326
326
|
if (!oidcLogos) {
|
|
327
327
|
return
|
|
328
328
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
|
|
329
|
+
const newConfig: Record<string, string> = {}
|
|
330
|
+
const keys = Object.keys(oidcLogos.config || {})
|
|
331
|
+
|
|
332
|
+
for (const key of keys) {
|
|
333
|
+
if (!key.endsWith("Etag")) {
|
|
334
|
+
const etag = oidcLogos.config[`${key}Etag`]
|
|
335
|
+
const objectStoreUrl = await objectStore.getGlobalFileUrl(
|
|
336
|
+
oidcLogos.type,
|
|
337
|
+
key,
|
|
338
|
+
etag
|
|
339
|
+
)
|
|
340
|
+
newConfig[key] = objectStoreUrl
|
|
341
|
+
} else {
|
|
342
|
+
newConfig[key] = oidcLogos.config[key]
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
oidcLogos.config = newConfig
|
|
346
346
|
}
|
|
347
347
|
|
|
348
348
|
export async function find(ctx: UserCtx<void, FindConfigResponse>) {
|
|
@@ -370,7 +370,7 @@ export async function find(ctx: UserCtx<void, FindConfigResponse>) {
|
|
|
370
370
|
|
|
371
371
|
async function handleConfigType(type: ConfigType, config: Config) {
|
|
372
372
|
if (type === ConfigType.OIDC_LOGOS) {
|
|
373
|
-
enrichOIDCLogos(config)
|
|
373
|
+
await enrichOIDCLogos(config)
|
|
374
374
|
} else if (type === ConfigType.AI) {
|
|
375
375
|
await handleAIConfig(config)
|
|
376
376
|
}
|
|
@@ -396,7 +396,7 @@ export async function publicOidc(ctx: Ctx<void, GetPublicOIDCConfigResponse>) {
|
|
|
396
396
|
const oidcCustomLogos = await configs.getOIDCLogosDoc()
|
|
397
397
|
|
|
398
398
|
if (oidcCustomLogos) {
|
|
399
|
-
enrichOIDCLogos(oidcCustomLogos)
|
|
399
|
+
await enrichOIDCLogos(oidcCustomLogos)
|
|
400
400
|
}
|
|
401
401
|
|
|
402
402
|
if (!oidcConfig) {
|
|
@@ -427,7 +427,7 @@ export async function publicSettings(
|
|
|
427
427
|
|
|
428
428
|
// enrich the logo url - empty url means deleted
|
|
429
429
|
if (config.logoUrl && config.logoUrl !== "") {
|
|
430
|
-
config.logoUrl = objectStore.getGlobalFileUrl(
|
|
430
|
+
config.logoUrl = await objectStore.getGlobalFileUrl(
|
|
431
431
|
"settings",
|
|
432
432
|
"logoUrl",
|
|
433
433
|
config.logoUrlEtag
|
|
@@ -437,7 +437,7 @@ export async function publicSettings(
|
|
|
437
437
|
// enrich the favicon url - empty url means deleted
|
|
438
438
|
const faviconUrl =
|
|
439
439
|
branding.faviconUrl && branding.faviconUrl !== ""
|
|
440
|
-
? objectStore.getGlobalFileUrl(
|
|
440
|
+
? await objectStore.getGlobalFileUrl(
|
|
441
441
|
"settings",
|
|
442
442
|
"faviconUrl",
|
|
443
443
|
branding.faviconUrlEtag
|
|
@@ -522,7 +522,7 @@ export async function upload(ctx: UserCtx<void, UploadConfigFileResponse>) {
|
|
|
522
522
|
|
|
523
523
|
ctx.body = {
|
|
524
524
|
message: "File has been uploaded and url stored to config.",
|
|
525
|
-
url: objectStore.getGlobalFileUrl(type, name, etag),
|
|
525
|
+
url: await objectStore.getGlobalFileUrl(type, name, etag),
|
|
526
526
|
}
|
|
527
527
|
}
|
|
528
528
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TestConfiguration } from "../../../../tests"
|
|
2
|
+
import { withEnv } from "../../../../environment"
|
|
2
3
|
|
|
3
4
|
jest.unmock("node-fetch")
|
|
4
5
|
|
|
@@ -32,7 +33,7 @@ describe("/api/system/environment", () => {
|
|
|
32
33
|
})
|
|
33
34
|
|
|
34
35
|
it("returns the expected environment for self hosters", async () => {
|
|
35
|
-
await
|
|
36
|
+
await withEnv({ SELF_HOSTED: true }, async () => {
|
|
36
37
|
const env = await config.api.environment.getEnvironment()
|
|
37
38
|
expect(env.body).toEqual({
|
|
38
39
|
cloud: false,
|
package/src/environment.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { env as coreEnv } from "@budibase/backend-core"
|
|
2
2
|
import { ServiceType } from "@budibase/types"
|
|
3
3
|
import { join } from "path"
|
|
4
|
+
import cloneDeep from "lodash/cloneDeep"
|
|
4
5
|
|
|
5
6
|
coreEnv._set("SERVICE_TYPE", ServiceType.WORKER)
|
|
6
7
|
|
|
@@ -92,6 +93,32 @@ if (!environment.APPS_URL) {
|
|
|
92
93
|
: "http://app-service:4002"
|
|
93
94
|
}
|
|
94
95
|
|
|
96
|
+
export function setEnv(newEnvVars: Partial<typeof environment>): () => void {
|
|
97
|
+
const oldEnv = cloneDeep(environment)
|
|
98
|
+
|
|
99
|
+
let key: keyof typeof newEnvVars
|
|
100
|
+
for (key in newEnvVars) {
|
|
101
|
+
environment._set(key, newEnvVars[key])
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return () => {
|
|
105
|
+
for (const [key, value] of Object.entries(oldEnv)) {
|
|
106
|
+
environment._set(key, value)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function withEnv<T>(envVars: Partial<typeof environment>, f: () => T) {
|
|
112
|
+
const cleanup = setEnv(envVars)
|
|
113
|
+
const result = f()
|
|
114
|
+
if (result instanceof Promise) {
|
|
115
|
+
return result.finally(cleanup)
|
|
116
|
+
} else {
|
|
117
|
+
cleanup()
|
|
118
|
+
return result
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
95
122
|
// clean up any environment variable edge cases
|
|
96
123
|
for (let [key, value] of Object.entries(environment)) {
|
|
97
124
|
// handle the edge case of "0" to disable an environment variable
|
|
@@ -35,7 +35,6 @@ import {
|
|
|
35
35
|
} from "@budibase/types"
|
|
36
36
|
import API from "./api"
|
|
37
37
|
import jwt, { Secret } from "jsonwebtoken"
|
|
38
|
-
import cloneDeep from "lodash/fp/cloneDeep"
|
|
39
38
|
|
|
40
39
|
class TestConfiguration {
|
|
41
40
|
server: any
|
|
@@ -247,34 +246,6 @@ class TestConfiguration {
|
|
|
247
246
|
return { message: "Admin user only endpoint.", status: 403 }
|
|
248
247
|
}
|
|
249
248
|
|
|
250
|
-
async withEnv(newEnvVars: Partial<typeof env>, f: () => Promise<void>) {
|
|
251
|
-
let cleanup = this.setEnv(newEnvVars)
|
|
252
|
-
try {
|
|
253
|
-
await f()
|
|
254
|
-
} finally {
|
|
255
|
-
cleanup()
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/*
|
|
260
|
-
* Sets the environment variables to the given values and returns a function
|
|
261
|
-
* that can be called to reset the environment variables to their original values.
|
|
262
|
-
*/
|
|
263
|
-
setEnv(newEnvVars: Partial<typeof env>): () => void {
|
|
264
|
-
const oldEnv = cloneDeep(env)
|
|
265
|
-
|
|
266
|
-
let key: keyof typeof newEnvVars
|
|
267
|
-
for (key in newEnvVars) {
|
|
268
|
-
env._set(key, newEnvVars[key])
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
return () => {
|
|
272
|
-
for (const [key, value] of Object.entries(oldEnv)) {
|
|
273
|
-
env._set(key, value)
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
249
|
// USERS
|
|
279
250
|
|
|
280
251
|
async createDefaultUser() {
|