1
0
Fork 0
mirror of synced 2024-07-04 22:11:23 +12:00

offline license structure

This commit is contained in:
Rory Powell 2023-07-13 21:53:05 +01:00
parent 7c4fe15781
commit 052a74f1d7

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 {
}
}
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()
}
}
}