@mintlify/common 1.0.729 → 1.0.731
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/entitlements/index.d.ts +9 -0
- package/dist/entitlements/index.js +22 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/isOrgLessThanTwoWeeksOld.d.ts +7 -0
- package/dist/isOrgLessThanTwoWeeksOld.js +11 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { OrgType, StaticPropsOrgType } from '@mintlify/models';
|
|
2
|
+
import { DeploymentEntitlement, DeploymentEntitlements } from '@mintlify/validation';
|
|
3
|
+
export declare const TRIAL_ENTITLEMENTS: DeploymentEntitlement[];
|
|
4
|
+
export declare function checkAccess({ entitlements, org, entitlementToCheck, allowTrialAccess, }: {
|
|
5
|
+
entitlements: DeploymentEntitlements | undefined;
|
|
6
|
+
org?: OrgType | StaticPropsOrgType;
|
|
7
|
+
entitlementToCheck: DeploymentEntitlement;
|
|
8
|
+
allowTrialAccess?: boolean;
|
|
9
|
+
}): boolean;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { isOrgLessThanTwoWeeksOld } from '../isOrgLessThanTwoWeeksOld.js';
|
|
2
|
+
export const TRIAL_ENTITLEMENTS = [
|
|
3
|
+
'AI_CHAT',
|
|
4
|
+
'ANALYTICS',
|
|
5
|
+
'CUSTOM_SUBPATH',
|
|
6
|
+
'UNLIMITED_EDITORS',
|
|
7
|
+
'PREVIEW_DEPLOYMENTS',
|
|
8
|
+
'SOURCE_CHECK_LINK_ROT',
|
|
9
|
+
'SOURCE_CHECK_VALE_SPELLCHECK',
|
|
10
|
+
'MCP_ENDPOINTS',
|
|
11
|
+
];
|
|
12
|
+
export function checkAccess({ entitlements, org, entitlementToCheck, allowTrialAccess = false, }) {
|
|
13
|
+
var _a;
|
|
14
|
+
const enabledByEntitlement = ((_a = entitlements === null || entitlements === void 0 ? void 0 : entitlements[entitlementToCheck]) === null || _a === void 0 ? void 0 : _a.status) === 'ENABLED';
|
|
15
|
+
if (enabledByEntitlement) {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
if (allowTrialAccess && !!org && TRIAL_ENTITLEMENTS.includes(entitlementToCheck)) {
|
|
19
|
+
return isOrgLessThanTwoWeeksOld(org.createdAt);
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { OrgType } from '@mintlify/models';
|
|
2
|
+
export declare const SECOND_IN_MILLISECONDS = 1000;
|
|
3
|
+
export declare const MINUTE_IN_MILLISECONDS: number;
|
|
4
|
+
export declare const HOUR_IN_MILLISECONDS: number;
|
|
5
|
+
export declare const DAY_IN_MILLISECONDS: number;
|
|
6
|
+
export declare const TWO_WEEKS_IN_MILLISECONDS: number;
|
|
7
|
+
export declare function isOrgLessThanTwoWeeksOld(createdAt: OrgType['createdAt'] | undefined): boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const SECOND_IN_MILLISECONDS = 1000;
|
|
2
|
+
export const MINUTE_IN_MILLISECONDS = SECOND_IN_MILLISECONDS * 60;
|
|
3
|
+
export const HOUR_IN_MILLISECONDS = MINUTE_IN_MILLISECONDS * 60;
|
|
4
|
+
export const DAY_IN_MILLISECONDS = HOUR_IN_MILLISECONDS * 24;
|
|
5
|
+
export const TWO_WEEKS_IN_MILLISECONDS = DAY_IN_MILLISECONDS * 14;
|
|
6
|
+
export function isOrgLessThanTwoWeeksOld(createdAt) {
|
|
7
|
+
if (!createdAt) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
return Date.now() - new Date(createdAt).getTime() < TWO_WEEKS_IN_MILLISECONDS;
|
|
11
|
+
}
|