addressed code review changes, fix check
This commit is contained in:
@@ -91,7 +91,8 @@ export const handleCheck = createRoute({
|
||||
targetVersion: ctx.apiVersion,
|
||||
resource: AffectedResource.Check,
|
||||
legacyData: {
|
||||
noCusEnts: checkData.apiBalance === undefined,
|
||||
noCusEnts:
|
||||
checkData.apiBalance === undefined && checkData.apiFlag === undefined,
|
||||
featureToUse: checkData.featureToUse,
|
||||
},
|
||||
ctx,
|
||||
|
||||
@@ -4,7 +4,6 @@ import {
|
||||
CheckResponseV3Schema,
|
||||
ErrCode,
|
||||
FeatureType,
|
||||
type FullCustomer,
|
||||
featureUtils,
|
||||
InsufficientBalanceError,
|
||||
InternalError,
|
||||
@@ -52,6 +51,14 @@ export const runCheckWithTrack = async ({
|
||||
});
|
||||
}
|
||||
|
||||
if (checkData.originalFeature.type === FeatureType.Boolean) {
|
||||
throw new RecaseError({
|
||||
message: "Not allowed to pass in send_event: true for a boolean feature",
|
||||
code: ErrCode.InvalidRequest,
|
||||
statusCode: 400,
|
||||
});
|
||||
}
|
||||
|
||||
const featureDeductions = getTrackFeatureDeductions({
|
||||
ctx,
|
||||
featureId: body.feature_id,
|
||||
@@ -71,7 +78,6 @@ export const runCheckWithTrack = async ({
|
||||
};
|
||||
|
||||
let allowed = true;
|
||||
let fullCustomer: FullCustomer | undefined;
|
||||
|
||||
try {
|
||||
// Use V2_1 to get ApiBalanceV1 format internally
|
||||
@@ -135,7 +141,7 @@ export const runCheckWithTrack = async ({
|
||||
entity_id: checkData.entityId,
|
||||
required_balance: requiredBalance,
|
||||
balance: checkData.apiBalance ?? null,
|
||||
// lock_id: body.lock?.lock_id,
|
||||
flag: checkData.apiFlag ?? null,
|
||||
});
|
||||
|
||||
return checkResponse;
|
||||
|
||||
@@ -12,6 +12,7 @@ export const GetEntityQuerySchema = z.object({
|
||||
CustomerExpand.SubscriptionsPlan,
|
||||
CustomerExpand.PurchasesPlan,
|
||||
CustomerExpand.BalancesFeature,
|
||||
CustomerExpand.FlagsFeature,
|
||||
]),
|
||||
).default([]),
|
||||
skip_cache: z.boolean().optional(),
|
||||
|
||||
@@ -6,10 +6,7 @@ import {
|
||||
import type { z } from "zod/v4";
|
||||
import type { SharedContext } from "../../../types/sharedContext";
|
||||
import { CustomerExpand } from "../../customers/components/customerExpand/customerExpand";
|
||||
import {
|
||||
type GetEntityQuery,
|
||||
GetEntityQuerySchema,
|
||||
} from "../entityOpModels";
|
||||
import { type GetEntityQuery, GetEntityQuerySchema } from "../entityOpModels";
|
||||
|
||||
/**
|
||||
* V1_2_EntityQueryChange: Transforms entity query TO latest format
|
||||
@@ -60,6 +57,7 @@ export const V1_2_EntityQueryChange = defineVersionChange({
|
||||
...existingExpand,
|
||||
CustomerExpand.SubscriptionsPlan,
|
||||
CustomerExpand.BalancesFeature,
|
||||
CustomerExpand.FlagsFeature,
|
||||
CustomerExpand.PurchasesPlan,
|
||||
] as GetEntityQuery["expand"];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user