Merge branch 'grow-472-remove-use-of-types-package-in-account-portal' of https://github.com/Budibase/budibase into grow-472-remove-use-of-types-package-in-account-portal

This commit is contained in:
Mel O'Hagan 2024-06-17 10:54:02 +01:00
commit 41a1dc683c
9 changed files with 31 additions and 12 deletions

View File

@ -73,9 +73,9 @@ jobs:
- name: Check types - name: Check types
run: | run: |
if ${{ env.USE_NX_AFFECTED }}; then if ${{ env.USE_NX_AFFECTED }}; then
yarn check:types --since=${{ env.NX_BASE_BRANCH }} yarn check:types --since=${{ env.NX_BASE_BRANCH }} --ignore @budibase/account-portal-server
else else
yarn check:types yarn check:types --ignore @budibase/account-portal-server
fi fi
helm-lint: helm-lint:

View File

@ -1,5 +1,5 @@
{ {
"version": "2.28.6", "version": "2.28.7",
"npmClient": "yarn", "npmClient": "yarn",
"packages": [ "packages": [
"packages/*", "packages/*",

View File

@ -40,7 +40,7 @@
"build:oss": "NODE_OPTIONS=--max-old-space-size=1500 lerna run build --stream --ignore @budibase/account-portal-server --ignore @budibase/account-portal-ui", "build:oss": "NODE_OPTIONS=--max-old-space-size=1500 lerna run build --stream --ignore @budibase/account-portal-server --ignore @budibase/account-portal-ui",
"build:account-portal": "NODE_OPTIONS=--max-old-space-size=1500 lerna run build --stream --scope @budibase/account-portal-server --scope @budibase/account-portal-ui", "build:account-portal": "NODE_OPTIONS=--max-old-space-size=1500 lerna run build --stream --scope @budibase/account-portal-server --scope @budibase/account-portal-ui",
"build:dev": "lerna run --stream prebuild && yarn nx run-many --target=build --output-style=dynamic --watch --preserveWatchOutput", "build:dev": "lerna run --stream prebuild && yarn nx run-many --target=build --output-style=dynamic --watch --preserveWatchOutput",
"check:types": "lerna run --concurrency 2 check:types", "check:types": "lerna run --concurrency 2 check:types --ignore @budibase/account-portal-server",
"build:sdk": "lerna run --stream build:sdk", "build:sdk": "lerna run --stream build:sdk",
"deps:circular": "madge packages/server/dist/index.js packages/worker/src/index.ts packages/backend-core/dist/src/index.js packages/cli/src/index.js --circular", "deps:circular": "madge packages/server/dist/index.js packages/worker/src/index.ts packages/backend-core/dist/src/index.js packages/cli/src/index.js --circular",
"release": "lerna publish from-package --yes --force-publish --no-git-tag-version --no-push --no-git-reset", "release": "lerna publish from-package --yes --force-publish --no-git-tag-version --no-push --no-git-reset",

View File

@ -9,8 +9,13 @@ export function getTenantDB(tenantId: string) {
export async function saveTenantInfo(tenantInfo: TenantInfo) { export async function saveTenantInfo(tenantInfo: TenantInfo) {
const db = getTenantDB(tenantInfo.tenantId) const db = getTenantDB(tenantInfo.tenantId)
// save the tenant info to db // save the tenant info to db
return await db.put({ return db.put({
_id: "tenant_info", _id: "tenant_info",
...tenantInfo, ...tenantInfo,
}) })
} }
export async function getTenantInfo(tenantId: string): Promise<TenantInfo> {
const db = getTenantDB(tenantId)
return db.get("tenant_info")
}

View File

@ -1,3 +1,4 @@
import { Hosting } from "../../sdk"
import { Document } from "../document" import { Document } from "../document"
export interface TenantInfo extends Document { export interface TenantInfo extends Document {
@ -10,4 +11,5 @@ export interface TenantInfo extends Document {
budibaseUserId?: string budibaseUserId?: string
} }
tenantId: string tenantId: string
hosting: Hosting
} }

View File

@ -8,3 +8,7 @@ export const save = async (ctx: Ctx<TenantInfo>) => {
_rev: response.rev, _rev: response.rev,
} }
} }
export const get = async (ctx: Ctx) => {
ctx.body = await tenancy.getTenantInfo(ctx.params.id)
}

View File

@ -129,6 +129,10 @@ const NO_TENANCY_ENDPOINTS = [
route: "/api/global/tenant", route: "/api/global/tenant",
method: "POST", method: "POST",
}, },
{
route: "/api/global/tenant/:id",
method: "GET",
},
] ]
// most public endpoints are gets, but some are posts // most public endpoints are gets, but some are posts

View File

@ -18,16 +18,19 @@ function buildTenantInfoValidation() {
familyName: OPTIONAL_STRING, familyName: OPTIONAL_STRING,
budibaseUserId: OPTIONAL_STRING, budibaseUserId: OPTIONAL_STRING,
}).required(), }).required(),
hosting: Joi.string().required(),
tenantId: Joi.string().required(), tenantId: Joi.string().required(),
}).required() }).required()
) )
} }
router.post( router
.post(
"/api/global/tenant", "/api/global/tenant",
cloudRestricted, cloudRestricted,
buildTenantInfoValidation(), buildTenantInfoValidation(),
controller.save controller.save
) )
.get("/api/global/tenant/:id", controller.get)
export default router export default router

View File

@ -1,4 +1,4 @@
import { TenantInfo } from "@budibase/types" import { Hosting, TenantInfo } from "@budibase/types"
import { TestConfiguration } from "../../../../tests" import { TestConfiguration } from "../../../../tests"
import { tenancy as _tenancy } from "@budibase/backend-core" import { tenancy as _tenancy } from "@budibase/backend-core"
@ -36,6 +36,7 @@ describe("/api/global/tenant", () => {
budibaseUserId: "USER_ID", budibaseUserId: "USER_ID",
}, },
tenantId: "tenant123", tenantId: "tenant123",
hosting: Hosting.CLOUD,
} }
const response = await config.api.tenants.saveTenantInfo(tenantInfo) const response = await config.api.tenants.saveTenantInfo(tenantInfo)