1
0
Fork 0
mirror of synced 2024-06-28 02:50:50 +12:00

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 { getTenantId } from "@budibase/backend-core/tenancy"
import { getAllApps } from "@budibase/backend-core/db" 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 () => { export const run = async () => {
// get app count // get app count

View file

@ -1,7 +1,8 @@
import { getTenantId } from "@budibase/backend-core/tenancy" import { getTenantId } from "@budibase/backend-core/tenancy"
import { getAllApps } from "@budibase/backend-core/db" import { getAllApps } from "@budibase/backend-core/db"
import { getUniqueRows } from "../../../utilities/usageQuota/rows" 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 () => { export const run = async () => {
// get all rows in all apps // get all rows in all apps

View file

@ -1,6 +1,7 @@
import TestConfig from "../../../../tests/utilities/TestConfiguration" import TestConfig from "../../../../tests/utilities/TestConfiguration"
import * as syncApps from "../syncApps" 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", () => { describe("syncApps", () => {
let config = new TestConfig(false) let config = new TestConfig(false)

View file

@ -1,6 +1,7 @@
import TestConfig from "../../../../tests/utilities/TestConfiguration" import TestConfig from "../../../../tests/utilities/TestConfiguration"
import * as syncRows from "../syncRows" 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", () => { describe("syncRows", () => {
let config = new TestConfig(false) 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 { export interface CreateAccount {
email: string email: string
@ -22,6 +22,11 @@ export const isCreatePasswordAccount = (
account: CreateAccount account: CreateAccount
): account is CreatePassswordAccount => account.authType === AuthType.PASSWORD ): account is CreatePassswordAccount => account.authType === AuthType.PASSWORD
export interface LicenseOverrides {
features?: Feature[]
quotas?: Quotas
}
export interface Account extends CreateAccount { export interface Account extends CreateAccount {
// generated // generated
accountId: string accountId: string
@ -31,9 +36,11 @@ export interface Account extends CreateAccount {
verificationSent: boolean verificationSent: boolean
// licensing // licensing
tier: string // deprecated tier: string // deprecated
planType?: PlanType
stripeCustomerId?: string stripeCustomerId?: string
licenseKey?: string licenseKey?: string
licenseKeyActivatedAt?: number licenseKeyActivatedAt?: number
licenseOverrides?: LicenseOverrides
} }
export interface PasswordAccount extends Account { export interface PasswordAccount extends Account {

View file

@ -2,3 +2,4 @@ export * from "./config"
export * from "./user" export * from "./user"
export * from "./userGroup" export * from "./userGroup"
export * from "./plugin" 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 cancelAt: number | null | undefined
currentPeriodStart: number currentPeriodStart: number
currentPeriodEnd: number currentPeriodEnd: number
status: string
pastDueAt?: number | null
downgradeAt?: number
} }
export interface Billing { export interface Billing {

View file

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

View file

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