fix: imports

This commit is contained in:
John Yeo
2026-02-18 18:46:19 +00:00
parent 740181dd89
commit 1aecdaced2
281 changed files with 1884 additions and 2447 deletions

View File

@@ -0,0 +1,41 @@
type ApiCustomerFeatureInput = {
id: string;
name?: string;
type?: string;
credit_schema?: Array<{
metered_feature_id: string;
credit_cost: number;
}>;
creditSchema?: Array<{
meteredFeatureId: string;
creditCost: number;
}>;
};
type ApiCustomerBalanceInput = {
feature?: ApiCustomerFeatureInput;
};
export type ApiCustomerWithBalancesInput = {
balances: Record<string, ApiCustomerBalanceInput>;
};
export const apiCustomerToFeatures = ({
apiCustomer,
}: {
apiCustomer: ApiCustomerWithBalancesInput;
}) => {
const balances = Object.values(apiCustomer.balances);
if (balances.length === 0) return [];
const firstBalance = balances[0];
if (!firstBalance.feature) {
throw new Error(
"[customerToFeatures] please expand `balances.feature` to get features for the customer",
);
}
return Object.values(apiCustomer.balances).map((balance) => {
return balance.feature;
}) as ApiCustomerFeatureInput[]; // safe to cast because we checked for feature in the first balance
};