diff --git a/packages/backend-core/tests/core/utilities/structures/accounts.ts b/packages/backend-core/tests/core/utilities/structures/accounts.ts index 42e9d4b63a..8476399aa3 100644 --- a/packages/backend-core/tests/core/utilities/structures/accounts.ts +++ b/packages/backend-core/tests/core/utilities/structures/accounts.ts @@ -29,7 +29,7 @@ export const account = (partial: Partial = {}): Account => { size: "10+", profession: "Software Engineer", quotaUsage: quotas.usage(), - ...partial + ...partial, } } diff --git a/packages/backend-core/tests/core/utilities/structures/documents/index.ts b/packages/backend-core/tests/core/utilities/structures/documents/index.ts index 1c82c5b7d4..c3bfba3597 100644 --- a/packages/backend-core/tests/core/utilities/structures/documents/index.ts +++ b/packages/backend-core/tests/core/utilities/structures/documents/index.ts @@ -1 +1 @@ -export * from "./platform" \ No newline at end of file +export * from "./platform" diff --git a/packages/backend-core/tests/core/utilities/structures/documents/platform/index.ts b/packages/backend-core/tests/core/utilities/structures/documents/platform/index.ts index 46b85f0435..98a6314999 100644 --- a/packages/backend-core/tests/core/utilities/structures/documents/platform/index.ts +++ b/packages/backend-core/tests/core/utilities/structures/documents/platform/index.ts @@ -1 +1 @@ -export * as installation from "./installation" \ No newline at end of file +export * as installation from "./installation" diff --git a/packages/backend-core/tests/core/utilities/structures/documents/platform/installation.ts b/packages/backend-core/tests/core/utilities/structures/documents/platform/installation.ts index 30d58fd349..25c5e50e00 100644 --- a/packages/backend-core/tests/core/utilities/structures/documents/platform/installation.ts +++ b/packages/backend-core/tests/core/utilities/structures/documents/platform/installation.ts @@ -7,6 +7,6 @@ export function install(): Installation { _id: "install", _rev: db.rev(), installId: generator.guid(), - version: generator.string() + version: generator.string(), } -} \ No newline at end of file +} diff --git a/packages/backend-core/tests/core/utilities/structures/licenses.ts b/packages/backend-core/tests/core/utilities/structures/licenses.ts index fae0c7d807..5cce84edfd 100644 --- a/packages/backend-core/tests/core/utilities/structures/licenses.ts +++ b/packages/backend-core/tests/core/utilities/structures/licenses.ts @@ -138,9 +138,7 @@ interface GenerateLicenseOpts { billing?: Billing } -export const license = ( - opts: GenerateLicenseOpts = {} -): License => { +export const license = (opts: GenerateLicenseOpts = {}): License => { return { features: opts.features || [], quotas: opts.quotas || quotas(), @@ -149,23 +147,21 @@ export const license = ( } } -export function offlineLicense ( - opts: GenerateLicenseOpts = {} -): OfflineLicense { +export function offlineLicense(opts: GenerateLicenseOpts = {}): OfflineLicense { const base = license(opts) return { ...base, expireAt: new Date().toISOString(), - identifier: offlineIdentifier() + identifier: offlineIdentifier(), } } export function offlineIdentifier( installId: string = generator.guid(), - tenantId: string = generator.guid(), + tenantId: string = generator.guid() ): OfflineIdentifier { return { installId, - tenantId + tenantId, } -} \ No newline at end of file +} diff --git a/packages/builder/src/pages/builder/portal/account/upgrade.svelte b/packages/builder/src/pages/builder/portal/account/upgrade.svelte index 8e2fd5c641..8f76286c8e 100644 --- a/packages/builder/src/pages/builder/portal/account/upgrade.svelte +++ b/packages/builder/src/pages/builder/portal/account/upgrade.svelte @@ -11,7 +11,7 @@ ButtonGroup, notifications, CopyInput, - File + File, } from "@budibase/bbui" import { auth, admin } from "stores/portal" import { redirect } from "@roxi/routify" @@ -35,9 +35,7 @@ let offlineLicenseIdentifier = "" let offlineLicense = undefined - const offlineLicenseExtensions = [ - ".txt", - ] + const offlineLicenseExtensions = [".txt"] // Make sure page can't be visited directly in cloud $: { @@ -97,7 +95,7 @@ const license = await API.getOfflineLicense() if (license) { offlineLicense = { - name: "license" + name: "license", } } else { offlineLicense = undefined @@ -147,7 +145,7 @@ // prevent file preview jitter by assigning constant // as soon as possible offlineLicense = { - name: "license" + name: "license", } const reader = new FileReader() reader.readAsText(event.detail) @@ -202,7 +200,9 @@ {#if $admin.offlineMode} Installation identifier - Share this with support@budibase.com to obtain your offline license + Share this with support@budibase.com to obtain your offline license
@@ -263,8 +263,12 @@ You are currently on the {license.plan.type} plan
- If you purchase or update your plan on the account - portal, click the refresh button to sync those changes + If you purchase or update your plan on the account + portal, click the refresh button to sync those changes
{processStringSync("Updated {{ duration time 'millisecond' }} ago", { diff --git a/packages/builder/src/stores/portal/admin.js b/packages/builder/src/stores/portal/admin.js index 19abcfd841..2106acac27 100644 --- a/packages/builder/src/stores/portal/admin.js +++ b/packages/builder/src/stores/portal/admin.js @@ -17,7 +17,7 @@ export const DEFAULT_CONFIG = { adminUser: { checked: false }, sso: { checked: false }, }, - offlineMode: false + offlineMode: false, } export function createAdminStore() { diff --git a/packages/frontend-core/src/api/licensing.js b/packages/frontend-core/src/api/licensing.js index 9fe98d5e74..987fc34cf5 100644 --- a/packages/frontend-core/src/api/licensing.js +++ b/packages/frontend-core/src/api/licensing.js @@ -1,5 +1,4 @@ export const buildLicensingEndpoints = API => ({ - // LICENSE KEY activateLicenseKey: async data => { @@ -31,7 +30,7 @@ export const buildLicensingEndpoints = API => ({ return API.post({ url: "/api/global/license/offline", body: { - offlineLicenseToken + offlineLicenseToken, }, }) }, diff --git a/packages/pro b/packages/pro index 544c7e067d..b5124e76b9 160000 --- a/packages/pro +++ b/packages/pro @@ -1 +1 @@ -Subproject commit 544c7e067de69832469cde673e59501480d6d98a +Subproject commit b5124e76b9fa8020641e8d019ac1713c6245d6e6 diff --git a/packages/types/src/api/account/license.ts b/packages/types/src/api/account/license.ts index e23f6cab97..edb1267ecf 100644 --- a/packages/types/src/api/account/license.ts +++ b/packages/types/src/api/account/license.ts @@ -36,4 +36,4 @@ export interface CreateOfflineLicenseRequest { export interface GetOfflineLicenseResponse { offlineLicenseToken: string license: OfflineLicense -} \ No newline at end of file +} diff --git a/packages/types/src/api/web/global/license.ts b/packages/types/src/api/web/global/license.ts index 900a0db96d..21d8876412 100644 --- a/packages/types/src/api/web/global/license.ts +++ b/packages/types/src/api/web/global/license.ts @@ -5,7 +5,7 @@ export interface ActivateLicenseKeyRequest { } export interface GetLicenseKeyResponse { - licenseKey: string, + licenseKey: string } // OFFLINE LICENSE diff --git a/packages/types/src/sdk/licensing/license.ts b/packages/types/src/sdk/licensing/license.ts index e8ad98fe7a..105c3680a3 100644 --- a/packages/types/src/sdk/licensing/license.ts +++ b/packages/types/src/sdk/licensing/license.ts @@ -2,7 +2,7 @@ import { PurchasedPlan, Quotas, Feature, Billing } from "." import { ISO8601 } from "../../shared" export interface OfflineIdentifier { - installId: string, + installId: string tenantId: string } diff --git a/packages/types/src/shared/typeUtils.ts b/packages/types/src/shared/typeUtils.ts index 143865c60b..fbe215fdb9 100644 --- a/packages/types/src/shared/typeUtils.ts +++ b/packages/types/src/shared/typeUtils.ts @@ -2,4 +2,4 @@ export type DeepPartial = { [P in keyof T]?: T[P] extends object ? DeepPartial : T[P] } -export type ISO8601 = string \ No newline at end of file +export type ISO8601 = string diff --git a/packages/worker/__mocks__/@budibase/pro.ts b/packages/worker/__mocks__/@budibase/pro.ts index bd6250fede..f1e79bd7c7 100644 --- a/packages/worker/__mocks__/@budibase/pro.ts +++ b/packages/worker/__mocks__/@budibase/pro.ts @@ -11,16 +11,16 @@ const pro = { activateOfflineLicense: jest.fn(), getOfflineLicenseToken: jest.fn(), deleteOfflineLicenseToken: jest.fn(), - getIdentifierBase64: jest.fn() + getIdentifierBase64: jest.fn(), }, cache: { ...actual.licensing.cache, refresh: jest.fn(), - } + }, }, quotas: { ...actual.quotas, - getQuotaUsage: jest.fn() + getQuotaUsage: jest.fn(), }, } diff --git a/packages/worker/src/api/controllers/global/license.ts b/packages/worker/src/api/controllers/global/license.ts index fa95eeee0d..111cb5cea3 100644 --- a/packages/worker/src/api/controllers/global/license.ts +++ b/packages/worker/src/api/controllers/global/license.ts @@ -10,7 +10,9 @@ import { // LICENSE KEY -export async function activateLicenseKey(ctx: UserCtx) { +export async function activateLicenseKey( + ctx: UserCtx +) { const { licenseKey } = ctx.request.body await licensing.keys.activateLicenseKey(licenseKey) ctx.status = 200 @@ -33,13 +35,17 @@ export async function deleteLicenseKey(ctx: UserCtx) { // OFFLINE LICENSE -export async function activateOfflineLicenseToken(ctx: UserCtx) { +export async function activateOfflineLicenseToken( + ctx: UserCtx +) { const { offlineLicenseToken } = ctx.request.body await licensing.offline.activateOfflineLicenseToken(offlineLicenseToken) ctx.status = 200 } -export async function getOfflineLicenseToken(ctx: UserCtx) { +export async function getOfflineLicenseToken( + ctx: UserCtx +) { const offlineLicenseToken = await licensing.offline.getOfflineLicenseToken() if (offlineLicenseToken) { ctx.body = { offlineLicenseToken: "*" } @@ -54,7 +60,9 @@ export async function deleteOfflineLicenseToken(ctx: UserCtx) { ctx.status = 204 } -export async function getOfflineLicenseIdentifier(ctx: UserCtx) { +export async function getOfflineLicenseIdentifier( + ctx: UserCtx +) { const identifierBase64 = await licensing.offline.getIdentifierBase64() ctx.body = { identifierBase64 } ctx.status = 200 diff --git a/packages/worker/src/api/routes/global/license.ts b/packages/worker/src/api/routes/global/license.ts index 199dbb3846..b0e474e4d5 100644 --- a/packages/worker/src/api/routes/global/license.ts +++ b/packages/worker/src/api/routes/global/license.ts @@ -3,13 +3,17 @@ import * as controller from "../../controllers/global/license" import { middleware } from "@budibase/backend-core" import Joi from "joi" -const activateLicenseKeyValidator = middleware.joiValidator.body(Joi.object({ +const activateLicenseKeyValidator = middleware.joiValidator.body( + Joi.object({ licenseKey: Joi.string().required(), - }).required()) + }).required() +) -const activateOfflineLicenseValidator = middleware.joiValidator.body(Joi.object({ +const activateOfflineLicenseValidator = middleware.joiValidator.body( + Joi.object({ offlineLicenseToken: Joi.string().required(), -}).required()) + }).required() +) const router: Router = new Router() @@ -17,13 +21,24 @@ router .post("/api/global/license/refresh", controller.refresh) .get("/api/global/license/usage", controller.getQuotaUsage) // LICENSE KEY - .post("/api/global/license/key", activateLicenseKeyValidator, controller.activateLicenseKey) + .post( + "/api/global/license/key", + activateLicenseKeyValidator, + controller.activateLicenseKey + ) .get("/api/global/license/key", controller.getLicenseKey) .delete("/api/global/license/key", controller.deleteLicenseKey) // OFFLINE LICENSE - .post("/api/global/license/offline", activateOfflineLicenseValidator, controller.activateOfflineLicenseToken) + .post( + "/api/global/license/offline", + activateOfflineLicenseValidator, + controller.activateOfflineLicenseToken + ) .get("/api/global/license/offline", controller.getOfflineLicenseToken) .delete("/api/global/license/offline", controller.deleteOfflineLicenseToken) - .get("/api/global/license/offline/identifier", controller.getOfflineLicenseIdentifier) + .get( + "/api/global/license/offline/identifier", + controller.getOfflineLicenseIdentifier + ) export default router diff --git a/packages/worker/src/api/routes/global/tests/license.spec.ts b/packages/worker/src/api/routes/global/tests/license.spec.ts index 512d6c9c52..26e3b3dfb5 100644 --- a/packages/worker/src/api/routes/global/tests/license.spec.ts +++ b/packages/worker/src/api/routes/global/tests/license.spec.ts @@ -37,7 +37,9 @@ describe("/api/global/license", () => { describe("POST /api/global/license/key", () => { it("returns 200", async () => { - const res = await config.api.license.activateLicenseKey({ licenseKey: "licenseKey" }) + const res = await config.api.license.activateLicenseKey({ + licenseKey: "licenseKey", + }) expect(res.status).toBe(200) expect(licensing.keys.activateLicenseKey).toBeCalledWith("licenseKey") }) @@ -53,7 +55,7 @@ describe("/api/global/license", () => { const res = await config.api.license.getLicenseKey() expect(res.status).toBe(200) expect(res.body).toEqual({ - licenseKey: "*" + licenseKey: "*", }) }) }) @@ -68,8 +70,12 @@ describe("/api/global/license", () => { describe("POST /api/global/license/offline", () => { it("activates offline license", async () => { - const res = await config.api.license.activateOfflineLicense({ offlineLicenseToken: "offlineLicenseToken"}) - expect(licensing.offline.activateOfflineLicense).toBeCalledWith("offlineLicenseToken") + const res = await config.api.license.activateOfflineLicense({ + offlineLicenseToken: "offlineLicenseToken", + }) + expect(licensing.offline.activateOfflineLicenseToken).toBeCalledWith( + "offlineLicenseToken" + ) expect(res.status).toBe(200) }) }) @@ -80,11 +86,13 @@ describe("/api/global/license", () => { expect(res.status).toBe(404) }) it("returns 200 + offline license token", async () => { - licensing.offline.getOfflineLicenseToken.mockResolvedValue("offlineLicenseToken") + licensing.offline.getOfflineLicenseToken.mockResolvedValue( + "offlineLicenseToken" + ) const res = await config.api.license.getOfflineLicense() expect(res.status).toBe(200) expect(res.body).toEqual({ - offlineLicenseToken: "*" + offlineLicenseToken: "*", }) }) }) @@ -103,7 +111,7 @@ describe("/api/global/license", () => { const res = await config.api.license.getOfflineLicenseIdentifier() expect(res.status).toBe(200) expect(res.body).toEqual({ - identifierBase64: "base64" + identifierBase64: "base64", }) }) }) diff --git a/packages/worker/src/tests/api/license.ts b/packages/worker/src/tests/api/license.ts index 76d3e88df7..a6645226af 100644 --- a/packages/worker/src/tests/api/license.ts +++ b/packages/worker/src/tests/api/license.ts @@ -1,6 +1,9 @@ import TestConfiguration from "../TestConfiguration" import { TestAPI } from "./base" -import { ActivateLicenseKeyRequest, ActivateOfflineLicenseRequest } from "@budibase/types" +import { + ActivateLicenseKeyRequest, + ActivateOfflineLicenseTokenRequest, +} from "@budibase/types" export class LicenseAPI extends TestAPI { constructor(config: TestConfiguration) { @@ -35,7 +38,7 @@ export class LicenseAPI extends TestAPI { .delete("/api/global/license/key") .set(this.config.defaultHeaders()) } - activateOfflineLicense = async (body: ActivateOfflineLicenseRequest) => { + activateOfflineLicense = async (body: ActivateOfflineLicenseTokenRequest) => { return this.request .post("/api/global/license/offline") .send(body)