-
Notifications
You must be signed in to change notification settings - Fork 259
Expand file tree
/
Copy pathentitlements.ts
More file actions
36 lines (31 loc) · 1003 Bytes
/
entitlements.ts
File metadata and controls
36 lines (31 loc) · 1003 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import {
Entitlement,
Plan,
getPlan as _getPlan,
getSeats as _getSeats,
hasEntitlement as _hasEntitlement,
getEntitlements as _getEntitlements,
} from "@sourcebot/shared";
import { prisma } from "./prisma.js";
import { SINGLE_TENANT_ORG_ID } from "./constants.js";
const getLicense = async () => {
return prisma.license.findUnique({
where: { orgId: SINGLE_TENANT_ORG_ID },
});
}
export const getPlan = async (): Promise<Plan> => {
const license = await getLicense();
return _getPlan(license);
}
export const getSeats = async (): Promise<number> => {
const license = await getLicense();
return _getSeats(license);
}
export const hasEntitlement = async (entitlement: Entitlement): Promise<boolean> => {
const license = await getLicense();
return _hasEntitlement(entitlement, license);
}
export const getEntitlements = async (): Promise<Entitlement[]> => {
const license = await getLicense();
return _getEntitlements(license);
}