From 052a74f1d75fa0293df3a96cd818426fda1fbdf4 Mon Sep 17 00:00:00 2001 From: Rory Powell Date: Thu, 13 Jul 2023 21:53:05 +0100 Subject: [PATCH] offline license structure --- .../core/utilities/structures/licenses.ts | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/packages/backend-core/tests/core/utilities/structures/licenses.ts b/packages/backend-core/tests/core/utilities/structures/licenses.ts index 22e73f2871..35c9156ec6 100644 --- a/packages/backend-core/tests/core/utilities/structures/licenses.ts +++ b/packages/backend-core/tests/core/utilities/structures/licenses.ts @@ -2,7 +2,7 @@ import { Billing, Customer, Feature, - License, + License, OfflineLicense, PlanModel, PlanType, PriceDuration, @@ -11,6 +11,7 @@ import { Quotas, Subscription, } from "@budibase/types" +import { generator } from "./generator" export function price(): PurchasedPrice { return { @@ -127,14 +128,16 @@ export function subscription(): Subscription { } } +interface GenerateLicenseOpts { + quotas?: Quotas + plan?: PurchasedPlan + planType?: PlanType + features?: Feature[] + billing?: Billing +} + export const license = ( - opts: { - quotas?: Quotas - plan?: PurchasedPlan - planType?: PlanType - features?: Feature[] - billing?: Billing - } = {} + opts: GenerateLicenseOpts = {} ): License => { return { features: opts.features || [], @@ -143,3 +146,17 @@ export const license = ( billing: opts.billing || billing(), } } + +export function offlineLicense ( + opts: GenerateLicenseOpts = {} +): OfflineLicense { + const base = license(opts) + return { + ...base, + expireAt: new Date().toISOString(), + identifier: { + installId: generator.guid(), + tenantId: generator.guid() + } + } +} \ No newline at end of file