Path: blob/main/components/gitpod-protocol/src/billing-mode.ts
2498 views
/**1* Copyright (c) 2022 Gitpod GmbH. All rights reserved.2* Licensed under the GNU Affero General Public License (AGPL).3* See License.AGPL.txt in the project root for license information.4*/56/**7* BillingMode is used to answer the following questions:8* - Should UI piece x be displayed for this user/team? (getBillingModeForUser/Team)9* - What model should be used to limit this workspace's capabilities (mayStartWorkspace, setTimeout, workspace class, etc...) (getBillingMode(workspaceInstance.attributionId))10* - How is a workspace session charged for? (getBillingMode(workspaceInstance.attributionId))11*/12export type BillingMode = None | UsageBased;13export namespace BillingMode {14export const NONE: None = {15mode: "none",16};1718/** Incl. upgrade and status */19export function showUsageBasedBilling(billingMode?: BillingMode): boolean {20return billingMode?.mode === "usage-based";21}2223export function canSetCostCenter(billingMode: BillingMode): boolean {24return billingMode.mode === "usage-based";25}26}2728/** Payment is disabled */29interface None {30mode: "none";31}3233/** Session is handld with new usage-based logic */34interface UsageBased {35mode: "usage-based";3637/** True if the org has a paid plan. */38paid: boolean;39}404142