@budibase/worker 2.32.6 → 2.32.8

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": "2.32.6",
4
+ "version": "2.32.8",
5
5
  "description": "Budibase background service",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -37,10 +37,10 @@
37
37
  "author": "Budibase",
38
38
  "license": "GPL-3.0",
39
39
  "dependencies": {
40
- "@budibase/backend-core": "2.32.6",
41
- "@budibase/pro": "2.32.6",
42
- "@budibase/string-templates": "2.32.6",
43
- "@budibase/types": "2.32.6",
40
+ "@budibase/backend-core": "2.32.8",
41
+ "@budibase/pro": "2.32.8",
42
+ "@budibase/string-templates": "2.32.8",
43
+ "@budibase/types": "2.32.8",
44
44
  "@koa/router": "8.0.8",
45
45
  "@techpass/passport-openidconnect": "0.3.3",
46
46
  "@types/global-agent": "2.1.1",
@@ -107,5 +107,5 @@
107
107
  }
108
108
  }
109
109
  },
110
- "gitHead": "02ab7c5642e95ab86547524c9e4084a1499fbd5f"
110
+ "gitHead": "2fb4f8e8807ae0d134a6aa1037f303f2f8de5493"
111
111
  }
@@ -253,6 +253,7 @@ export async function save(ctx: UserCtx<Config>) {
253
253
  if (existingConfig) {
254
254
  await verifyAIConfig(config, existingConfig)
255
255
  }
256
+ await pro.quotas.updateCustomAIConfigCount(Object.keys(config).length)
256
257
  break
257
258
  }
258
259
  } catch (err: any) {
@@ -334,32 +335,6 @@ function enrichOIDCLogos(oidcLogos: OIDCLogosConfig) {
334
335
  )
335
336
  }
336
337
 
337
- async function enrichAIConfig(aiConfig: AIConfig) {
338
- // Strip out the API Keys from the response so they don't show in the UI
339
- for (const key in aiConfig.config) {
340
- if (aiConfig.config[key].apiKey) {
341
- aiConfig.config[key].apiKey = PASSWORD_REPLACEMENT
342
- }
343
- }
344
-
345
- // Return the Budibase AI data source as part of the response if licensing allows
346
- const budibaseAIEnabled = await pro.features.isBudibaseAIEnabled()
347
- const defaultConfigExists = Object.keys(aiConfig.config).some(
348
- key => aiConfig.config[key].isDefault
349
- )
350
- if (budibaseAIEnabled) {
351
- aiConfig.config["budibase_ai"] = {
352
- provider: "OpenAI",
353
- active: true,
354
- isDefault: !defaultConfigExists,
355
- defaultModel: env.BUDIBASE_AI_DEFAULT_MODEL || "",
356
- name: "Budibase AI",
357
- }
358
- }
359
-
360
- return aiConfig
361
- }
362
-
363
338
  export async function find(ctx: UserCtx) {
364
339
  try {
365
340
  // Find the config with the most granular scope based on context
@@ -372,7 +347,13 @@ export async function find(ctx: UserCtx) {
372
347
  }
373
348
 
374
349
  if (type === ConfigType.AI) {
375
- await enrichAIConfig(scopedConfig)
350
+ await pro.sdk.ai.enrichAIConfig(scopedConfig)
351
+ // Strip out the API Keys from the response so they don't show in the UI
352
+ for (const key in scopedConfig.config) {
353
+ if (scopedConfig.config[key].apiKey) {
354
+ scopedConfig.config[key].apiKey = PASSWORD_REPLACEMENT
355
+ }
356
+ }
376
357
  }
377
358
  ctx.body = scopedConfig
378
359
  } else {
@@ -1,4 +1,3 @@
1
- import * as pro from "@budibase/pro"
2
1
  import { verifyAIConfig } from "../configs"
3
2
  import { TestConfiguration, structures } from "../../../../tests"
4
3
  import { AIInnerConfig } from "@budibase/types"
@@ -35,55 +34,6 @@ describe("Global configs controller", () => {
35
34
  })
36
35
  })
37
36
 
38
- it("Should return the default BB AI config when the feature is turned on", async () => {
39
- jest
40
- .spyOn(pro.features, "isBudibaseAIEnabled")
41
- .mockImplementation(() => Promise.resolve(true))
42
- const data = structures.configs.ai()
43
- await config.api.configs.saveConfig(data)
44
- const response = await config.api.configs.getAIConfig()
45
-
46
- expect(response.body.config).toEqual({
47
- budibase_ai: {
48
- provider: "OpenAI",
49
- active: true,
50
- isDefault: true,
51
- name: "Budibase AI",
52
- defaultModel: "",
53
- },
54
- ai: {
55
- active: true,
56
- apiKey: "--secret-value--",
57
- baseUrl: "https://api.example.com",
58
- defaultModel: "gpt4",
59
- isDefault: false,
60
- name: "Test",
61
- provider: "OpenAI",
62
- },
63
- })
64
- })
65
-
66
- it("Should not not return the default Budibase AI config when on self host", async () => {
67
- jest
68
- .spyOn(pro.features, "isBudibaseAIEnabled")
69
- .mockImplementation(() => Promise.resolve(false))
70
- const data = structures.configs.ai()
71
- await config.api.configs.saveConfig(data)
72
- const response = await config.api.configs.getAIConfig()
73
-
74
- expect(response.body.config).toEqual({
75
- ai: {
76
- active: true,
77
- apiKey: "--secret-value--",
78
- baseUrl: "https://api.example.com",
79
- defaultModel: "gpt4",
80
- isDefault: false,
81
- name: "Test",
82
- provider: "OpenAI",
83
- },
84
- })
85
- })
86
-
87
37
  it("Should not update existing secrets when updating an existing AI Config", async () => {
88
38
  const data = structures.configs.ai()
89
39
  await config.api.configs.saveConfig(data)