@budibase/worker 2.4.42-alpha.0 → 2.4.42-alpha.1

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.4.42-alpha.0",
4
+ "version": "2.4.42-alpha.1",
5
5
  "description": "Budibase background service",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -36,10 +36,10 @@
36
36
  "author": "Budibase",
37
37
  "license": "GPL-3.0",
38
38
  "dependencies": {
39
- "@budibase/backend-core": "2.4.42-alpha.0",
40
- "@budibase/pro": "2.4.40",
41
- "@budibase/string-templates": "2.4.42-alpha.0",
42
- "@budibase/types": "2.4.42-alpha.0",
39
+ "@budibase/backend-core": "2.4.42-alpha.1",
40
+ "@budibase/pro": "2.4.42-alpha.0",
41
+ "@budibase/string-templates": "2.4.42-alpha.1",
42
+ "@budibase/types": "2.4.42-alpha.1",
43
43
  "@koa/router": "8.0.8",
44
44
  "@sentry/node": "6.17.7",
45
45
  "@techpass/passport-openidconnect": "0.3.2",
@@ -101,5 +101,5 @@
101
101
  "typescript": "4.7.3",
102
102
  "update-dotenv": "1.1.1"
103
103
  },
104
- "gitHead": "b31f1ba51b6d82958938a9acc7f8bf1ccef104ac"
104
+ "gitHead": "7991f321a1339c06893c340f960b510321bf2554"
105
105
  }
@@ -17,3 +17,7 @@ export async function destroy(ctx: UserCtx) {
17
17
  throw err
18
18
  }
19
19
  }
20
+
21
+ export async function info(ctx: UserCtx) {
22
+ ctx.body = await tenantSdk.tenantInfo(ctx.params.tenantId)
23
+ }
@@ -10,4 +10,6 @@ router.delete(
10
10
  controller.destroy
11
11
  )
12
12
 
13
+ router.get("/api/system/tenants/:tenantId/info", controller.info)
14
+
13
15
  export default router
@@ -58,4 +58,17 @@ describe("/api/global/tenants", () => {
58
58
  expect(res.body).toEqual(config.adminOnlyResponse())
59
59
  })
60
60
  })
61
+
62
+ describe("GET /api/system/tenants/:tenantId/info", () => {
63
+ it("allows retrieving information about the tenant", async () => {
64
+ const user1 = await config.createTenant()
65
+ const res = await config.api.tenants.info(user1.tenantId)
66
+ expect(res.body.exists).toEqual(true)
67
+ })
68
+
69
+ it("check a tenant that doesn't exist", async () => {
70
+ const res = await config.api.tenants.info("cannot-exist-tenantid")
71
+ expect(res.body.exists).toEqual(false)
72
+ })
73
+ })
61
74
  })
@@ -74,3 +74,10 @@ async function removeTenantUsers(tenantId: string) {
74
74
  throw err
75
75
  }
76
76
  }
77
+
78
+ export async function tenantInfo(tenantId: string) {
79
+ const globalDbName = tenancy.getGlobalDBName(tenantId)
80
+ return {
81
+ exists: await dbCore.dbExists(globalDbName),
82
+ }
83
+ }
@@ -2,8 +2,10 @@ import TestConfiguration from "../TestConfiguration"
2
2
  import { TestAPI, TestAPIOpts } from "./base"
3
3
 
4
4
  export class TenantAPI extends TestAPI {
5
+ config: TestConfiguration
5
6
  constructor(config: TestConfiguration) {
6
7
  super(config)
8
+ this.config = config
7
9
  }
8
10
 
9
11
  delete = (tenantId: string, opts?: TestAPIOpts) => {
@@ -12,4 +14,11 @@ export class TenantAPI extends TestAPI {
12
14
  .set(opts?.headers)
13
15
  .expect(opts?.status ? opts.status : 204)
14
16
  }
17
+
18
+ info = (tenantId: string) => {
19
+ return this.request
20
+ .get(`/api/system/tenants/${tenantId}/info`)
21
+ .set(this.config.defaultHeaders())
22
+ .expect(200)
23
+ }
15
24
  }