feat: new subject cache
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import type { FullCusEntWithFullCusProduct } from "../../../models/cusProductModels/cusEntModels/cusEntWithProduct.js";
|
||||
import { AllowanceType } from "../../../models/productModels/entModels/entModels.js";
|
||||
|
||||
export const cusEntsHaveUnlimited = ({
|
||||
cusEnts,
|
||||
internalFeatureId,
|
||||
}: {
|
||||
cusEnts: FullCusEntWithFullCusProduct[];
|
||||
internalFeatureId: string;
|
||||
}) => {
|
||||
return cusEnts.some(
|
||||
(customerEntitlement) =>
|
||||
customerEntitlement.internal_feature_id === internalFeatureId &&
|
||||
(customerEntitlement.entitlement.allowance_type ===
|
||||
AllowanceType.Unlimited ||
|
||||
customerEntitlement.unlimited),
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
import type { FullCusEntWithFullCusProduct } from "../../../models/cusProductModels/cusEntModels/cusEntWithProduct.js";
|
||||
import { nullish } from "../../utils.js";
|
||||
|
||||
export const cusEntsHaveUsageAllowed = ({
|
||||
cusEnts,
|
||||
internalFeatureId,
|
||||
includeUsageLimit = true,
|
||||
}: {
|
||||
cusEnts: FullCusEntWithFullCusProduct[];
|
||||
internalFeatureId: string;
|
||||
includeUsageLimit?: boolean;
|
||||
}) => {
|
||||
return cusEnts.some(
|
||||
(customerEntitlement) =>
|
||||
customerEntitlement.internal_feature_id === internalFeatureId &&
|
||||
customerEntitlement.usage_allowed &&
|
||||
(includeUsageLimit
|
||||
? nullish(customerEntitlement.entitlement.usage_limit)
|
||||
: true),
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user