refactor: separate subscriptions from customer cache
- Split subscription data into separate cache keys for better performance - Updated cache utilities to handle subscriptions independently - Modified Lua scripts to manage separate subscription cache entries - Updated API models and expand logic for separated subscriptions - Fixed test utilities to match new data structure 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -62,6 +62,22 @@ export const V1_2_EntityChange = defineVersionChange({
|
||||
)
|
||||
: undefined;
|
||||
|
||||
const scheduledCusProducts: ApiCusProductV3[] | undefined =
|
||||
input.scheduled_subscriptions
|
||||
? input.scheduled_subscriptions.map((subscription: ApiSubscription) =>
|
||||
transformSubscriptionToCusProductV3({
|
||||
input: subscription,
|
||||
legacyData:
|
||||
legacyData?.cusProductLegacyData[subscription.plan_id],
|
||||
}),
|
||||
)
|
||||
: undefined;
|
||||
|
||||
const finalCusProducts = [
|
||||
...(v0CusProducts || []),
|
||||
...(scheduledCusProducts || []),
|
||||
];
|
||||
|
||||
// Step 2: Transform features V1 → V0
|
||||
let v0_features: Record<string, ApiCusFeatureV3> | undefined;
|
||||
if (input.balances) {
|
||||
@@ -83,7 +99,7 @@ export const V1_2_EntityChange = defineVersionChange({
|
||||
feature_id: input.feature_id,
|
||||
created_at: input.created_at,
|
||||
env: input.env,
|
||||
products: v0CusProducts,
|
||||
products: finalCusProducts,
|
||||
features: v0_features,
|
||||
invoices:
|
||||
input.invoices?.map((invoice: ApiInvoiceV1) =>
|
||||
|
||||
Reference in New Issue
Block a user