1
0
Fork 0
mirror of synced 2024-06-28 02:50:50 +12:00
budibase/packages/types/src/documents/account/account.ts

96 lines
2.1 KiB
TypeScript
Raw Normal View History

2022-10-07 04:03:47 +13:00
import {
Feature,
Hosting,
MonthlyQuotaName,
PlanType,
Quotas,
StaticQuotaName,
} from "../../sdk"
import { MonthlyUsage, QuotaUsage, StaticUsage } from "../global"
2022-05-05 19:32:14 +12:00
2022-05-24 09:14:44 +12:00
export interface CreateAccount {
email: string
tenantId: string
2022-05-05 19:32:14 +12:00
hosting: Hosting
2022-05-24 09:14:44 +12:00
authType: AuthType
// optional fields - for sso based sign ups
registrationStep?: string
// profile
tenantName?: string
name?: string
size?: string
profession?: string
}
export interface CreatePassswordAccount extends CreateAccount {
password: string
}
export const isCreatePasswordAccount = (
account: CreateAccount
): account is CreatePassswordAccount => account.authType === AuthType.PASSWORD
export interface LicenseOverrides {
features?: Feature[]
quotas?: Quotas
}
2022-05-24 09:14:44 +12:00
export interface Account extends CreateAccount {
// generated
accountId: string
createdAt: number
// registration
verified: boolean
2022-05-24 09:14:44 +12:00
verificationSent: boolean
// licensing
tier: string // deprecated
planType?: PlanType
2022-09-22 02:45:29 +12:00
planTier?: number
2022-05-24 09:14:44 +12:00
stripeCustomerId?: string
licenseKey?: string
licenseKeyActivatedAt?: number
licenseOverrides?: LicenseOverrides
2022-10-08 01:57:10 +13:00
quotaUsage?: QuotaUsage
2022-05-24 09:14:44 +12:00
}
export interface PasswordAccount extends Account {
password: string
}
export const isPasswordAccount = (
account: Account
): account is PasswordAccount =>
account.authType === AuthType.PASSWORD && account.hosting === Hosting.SELF
export interface CloudAccount extends Account {
password?: string
budibaseUserId: string
}
export const isCloudAccount = (account: Account): account is CloudAccount =>
account.hosting === Hosting.CLOUD
export const isSelfHostAccount = (account: Account) =>
account.hosting === Hosting.SELF
export const isSSOAccount = (account: Account): account is SSOAccount =>
account.authType === AuthType.SSO
export interface SSOAccount extends Account {
pictureUrl?: string
provider?: string
providerType?: string
oauth2?: OAuthTokens
thirdPartyProfile: any // TODO: define what the google profile looks like
}
export enum AuthType {
SSO = "sso",
PASSWORD = "password",
}
export interface OAuthTokens {
accessToken: string
refreshToken: string
2022-05-05 19:32:14 +12:00
}