Add enterprise types and change from @budibase/pro to @budibase/types for licensing types

This commit is contained in:
Rory Powell 2022-09-20 08:02:14 +01:00
parent 408fcc725b
commit f984a16942
10 changed files with 39 additions and 7 deletions

View File

@ -1,6 +1,7 @@
import { getTenantId } from "@budibase/backend-core/tenancy"
import { getAllApps } from "@budibase/backend-core/db"
import { quotas, QuotaUsageType, StaticQuotaName } from "@budibase/pro"
import { quotas } from "@budibase/pro"
import { QuotaUsageType, StaticQuotaName } from "@budibase/types"
export const run = async () => {
// get app count

View File

@ -1,7 +1,8 @@
import { getTenantId } from "@budibase/backend-core/tenancy"
import { getAllApps } from "@budibase/backend-core/db"
import { getUniqueRows } from "../../../utilities/usageQuota/rows"
import { quotas, QuotaUsageType, StaticQuotaName } from "@budibase/pro"
import { quotas } from "@budibase/pro"
import { QuotaUsageType, StaticQuotaName } from "@budibase/types"
export const run = async () => {
// get all rows in all apps

View File

@ -1,6 +1,7 @@
import TestConfig from "../../../../tests/utilities/TestConfiguration"
import * as syncApps from "../syncApps"
import { quotas, QuotaUsageType, StaticQuotaName } from "@budibase/pro"
import { quotas } from "@budibase/pro"
import { QuotaUsageType, StaticQuotaName } from "@budibase/types"
describe("syncApps", () => {
let config = new TestConfig(false)

View File

@ -1,6 +1,7 @@
import TestConfig from "../../../../tests/utilities/TestConfiguration"
import * as syncRows from "../syncRows"
import { quotas, QuotaUsageType, StaticQuotaName } from "@budibase/pro"
import { quotas } from "@budibase/pro"
import { QuotaUsageType, StaticQuotaName } from "@budibase/types"
describe("syncRows", () => {
let config = new TestConfig(false)

View File

@ -1,4 +1,4 @@
import { Hosting } from "../../sdk"
import { Feature, Hosting, PlanType, Quotas } from "../../sdk"
export interface CreateAccount {
email: string
@ -22,6 +22,11 @@ export const isCreatePasswordAccount = (
account: CreateAccount
): account is CreatePassswordAccount => account.authType === AuthType.PASSWORD
export interface LicenseOverrides {
features?: Feature[]
quotas?: Quotas
}
export interface Account extends CreateAccount {
// generated
accountId: string
@ -31,9 +36,11 @@ export interface Account extends CreateAccount {
verificationSent: boolean
// licensing
tier: string // deprecated
planType?: PlanType
stripeCustomerId?: string
licenseKey?: string
licenseKeyActivatedAt?: number
licenseOverrides?: LicenseOverrides
}
export interface PasswordAccount extends Account {

View File

@ -2,3 +2,4 @@ export * from "./config"
export * from "./user"
export * from "./userGroup"
export * from "./plugin"
export * from "./quotas"

View File

@ -0,0 +1,15 @@
import { MonthlyQuotaName, StaticQuotaName } from "../../sdk"
export interface QuotaUsage {
_id: string
_rev?: string
quotaReset: string
usageQuota: {
[key in StaticQuotaName]: number
}
monthly: {
[key: string]: {
[key in MonthlyQuotaName]: number
}
}
}

View File

@ -12,6 +12,9 @@ export interface Subscription {
cancelAt: number | null | undefined
currentPeriodStart: number
currentPeriodEnd: number
status: string
pastDueAt?: number | null
downgradeAt?: number
}
export interface Billing {

View File

@ -6,6 +6,7 @@ export interface AccountPlan {
export enum PlanType {
FREE = "free",
PRO = "pro",
TEAM = "team",
BUSINESS = "business",
ENTERPRISE = "enterprise",
}

View File

@ -13,6 +13,7 @@ export enum QuotaType {
export enum StaticQuotaName {
ROWS = "rows",
APPS = "apps",
USER_GROUPS = "userGroups",
}
export enum MonthlyQuotaName {
@ -22,7 +23,6 @@ export enum MonthlyQuotaName {
}
export enum ConstantQuotaName {
QUERY_TIMEOUT_SECONDS = "queryTimeoutSeconds",
AUTOMATION_LOG_RETENTION_DAYS = "automationLogRetentionDays",
}
@ -54,6 +54,7 @@ export const isConstantQuota = (
export type PlanQuotas = {
[PlanType.FREE]: Quotas
[PlanType.PRO]: Quotas
[PlanType.TEAM]: Quotas
[PlanType.BUSINESS]: Quotas
[PlanType.ENTERPRISE]: Quotas
}
@ -68,10 +69,10 @@ export type Quotas = {
[QuotaUsageType.STATIC]: {
[StaticQuotaName.ROWS]: Quota
[StaticQuotaName.APPS]: Quota
[StaticQuotaName.USER_GROUPS]: Quota
}
}
[QuotaType.CONSTANT]: {
[ConstantQuotaName.QUERY_TIMEOUT_SECONDS]: Quota
[ConstantQuotaName.AUTOMATION_LOG_RETENTION_DAYS]: Quota
}
}