Files
cfw-autumn/server/tests/utils/testAttachUtils/getAttachPreviewTotal.ts
2025-10-04 14:07:18 +01:00

31 lines
708 B
TypeScript

import { type FeatureOptions, LegacyVersion } from "@autumn/shared";
import { AutumnInt } from "@/external/autumn/autumnCli.js";
import { getAttachTotal } from "./testAttachUtils.js";
export const getAttachPreviewTotal = async ({
customerId,
productId,
entityId,
options,
}: {
customerId: string;
productId: string;
entityId: string;
options?: FeatureOptions[];
}) => {
const autumn = new AutumnInt({ version: LegacyVersion.v1_2 });
const preview = await autumn.attachPreview({
customer_id: customerId,
product_id: productId,
entity_id: entityId,
});
const optionsCopy = structuredClone(options);
const total = getAttachTotal({
preview,
options: optionsCopy,
});
return total;
};