offline license structure

This commit is contained in:
Rory Powell 2023-07-13 21:53:05 +01:00
parent 7c4fe15781
commit 052a74f1d7
1 changed files with 25 additions and 8 deletions

View File

@ -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 {
}
}
export const license = (
opts: {
interface GenerateLicenseOpts {
quotas?: Quotas
plan?: PurchasedPlan
planType?: PlanType
features?: Feature[]
billing?: Billing
} = {}
}
export const license = (
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()
}
}
}