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