feat: new subject cache

This commit is contained in:
John Yeo
2026-04-13 10:24:58 +01:00
parent 9489cf90e9
commit c8e154fe53
108 changed files with 8684 additions and 1983 deletions

View File

@@ -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),
);
};

View File

@@ -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),
);
};