@bunnyapp/components 1.7.0-beta.16 → 1.7.0-beta.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js
CHANGED
|
@@ -1280,7 +1280,7 @@ const DEFAULT_CONFIG = {
|
|
|
1280
1280
|
};
|
|
1281
1281
|
|
|
1282
1282
|
// This will be replaced at build time by rollup-plugin-replace
|
|
1283
|
-
const PACKAGE_VERSION = '1.7.0-beta.
|
|
1283
|
+
const PACKAGE_VERSION = '1.7.0-beta.17';
|
|
1284
1284
|
const createRequestHeaders = (token) => {
|
|
1285
1285
|
const headers = createClientDevHeaders({ token });
|
|
1286
1286
|
// Add the components version header
|
|
@@ -24519,6 +24519,15 @@ const splitSubscriptionsByPriceList_SubscriptionFragment = t(`
|
|
|
24519
24519
|
evergreen
|
|
24520
24520
|
startDate
|
|
24521
24521
|
endDate
|
|
24522
|
+
addonSubscriptions {
|
|
24523
|
+
id
|
|
24524
|
+
priceList {
|
|
24525
|
+
id
|
|
24526
|
+
}
|
|
24527
|
+
plan {
|
|
24528
|
+
id
|
|
24529
|
+
}
|
|
24530
|
+
}
|
|
24522
24531
|
chargeReport {
|
|
24523
24532
|
kind
|
|
24524
24533
|
startDate
|
|
@@ -24617,7 +24626,7 @@ function splitSubscriptionsByPriceList(maskedSubscriptions) {
|
|
|
24617
24626
|
// DUPLICATE the entire subscription, just filter the charges
|
|
24618
24627
|
const splitSubscriptions = [];
|
|
24619
24628
|
chargesByPriceList.forEach((charges, priceListId) => {
|
|
24620
|
-
var _a, _b;
|
|
24629
|
+
var _a, _b, _c, _d, _e, _f;
|
|
24621
24630
|
// Get the first charge to extract priceList, plan, and product info
|
|
24622
24631
|
const firstCharge = charges === null || charges === void 0 ? void 0 : charges[0];
|
|
24623
24632
|
if (!firstCharge || !charges)
|
|
@@ -24653,6 +24662,22 @@ function splitSubscriptionsByPriceList(maskedSubscriptions) {
|
|
|
24653
24662
|
}
|
|
24654
24663
|
// Only the subscription with the latest charge will actually renew
|
|
24655
24664
|
const willRenew = priceListId === latestPriceListId;
|
|
24665
|
+
// Filter addon subscriptions to only include those compatible with the new plan
|
|
24666
|
+
// If the plan has changed, we need to check if the addon subscriptions are still valid
|
|
24667
|
+
const newPlan = (_a = firstCharge.priceList) === null || _a === void 0 ? void 0 : _a.plan;
|
|
24668
|
+
const addonPlanIds = (_c = (_b = newPlan === null || newPlan === void 0 ? void 0 : newPlan.addonPlans) === null || _b === void 0 ? void 0 : _b.map(plan => plan.id)) !== null && _c !== void 0 ? _c : [];
|
|
24669
|
+
// For split subscriptions that represent a future period (after plan change),
|
|
24670
|
+
// filter out addon subscriptions that are not compatible with the new plan
|
|
24671
|
+
const filteredAddonSubscriptions = (_d = subscription.addonSubscriptions) === null || _d === void 0 ? void 0 : _d.filter(addonSub => {
|
|
24672
|
+
var _a;
|
|
24673
|
+
// If the new plan has no addon plans defined, keep all addons (backward compatibility)
|
|
24674
|
+
if (!(newPlan === null || newPlan === void 0 ? void 0 : newPlan.addonPlans) || newPlan.addonPlans.length === 0) {
|
|
24675
|
+
return true;
|
|
24676
|
+
}
|
|
24677
|
+
// Check if this addon subscription's plan is in the new plan's addonPlans list
|
|
24678
|
+
const addonPlanId = (_a = addonSub.plan) === null || _a === void 0 ? void 0 : _a.id;
|
|
24679
|
+
return addonPlanId ? addonPlanIds.includes(addonPlanId) : false;
|
|
24680
|
+
});
|
|
24656
24681
|
splitSubscriptions.push({
|
|
24657
24682
|
...maskedSubscription,
|
|
24658
24683
|
// Keep the original subscription ID intact (from maskedSubscription spread)
|
|
@@ -24673,11 +24698,13 @@ function splitSubscriptionsByPriceList(maskedSubscriptions) {
|
|
|
24673
24698
|
// Filter chargeReport to only include charges for this price list
|
|
24674
24699
|
chargeReport: charges,
|
|
24675
24700
|
// Filter charges array to only include charges for this price list
|
|
24676
|
-
charges: (
|
|
24701
|
+
charges: (_f = (_e = subscription.charges) === null || _e === void 0 ? void 0 : _e.filter(charge => {
|
|
24677
24702
|
var _a;
|
|
24678
24703
|
const chargeWithPriceList = charge;
|
|
24679
24704
|
return ((_a = chargeWithPriceList.priceList) === null || _a === void 0 ? void 0 : _a.id) === priceListId;
|
|
24680
|
-
})) !== null &&
|
|
24705
|
+
})) !== null && _f !== void 0 ? _f : [],
|
|
24706
|
+
// Filter addon subscriptions to only include those compatible with the new plan
|
|
24707
|
+
addonSubscriptions: filteredAddonSubscriptions,
|
|
24681
24708
|
});
|
|
24682
24709
|
});
|
|
24683
24710
|
// Sort split subscriptions by endDate (earliest first)
|
package/dist/cjs/types/src/components/Subscriptions/subscriptionsList/subscriptionUtils.d.ts
CHANGED
|
@@ -23,6 +23,15 @@ export declare const splitSubscriptionsByPriceList_SubscriptionFragment: import(
|
|
|
23
23
|
evergreen: boolean;
|
|
24
24
|
startDate: unknown;
|
|
25
25
|
endDate: unknown;
|
|
26
|
+
addonSubscriptions: {
|
|
27
|
+
id: string;
|
|
28
|
+
priceList: {
|
|
29
|
+
id: string;
|
|
30
|
+
} | null;
|
|
31
|
+
plan: {
|
|
32
|
+
id: string;
|
|
33
|
+
} | null;
|
|
34
|
+
}[] | null;
|
|
26
35
|
chargeReport: {
|
|
27
36
|
kind: "SUBSCRIBE" | "UPDATE" | "RENEW" | "REINSTATE" | "UNSUBSCRIBE" | "ADJUSTMENT" | "COUPON" | "DISCOUNT" | "CREDIT" | "PRICE_UPDATE" | "QUANTITY_UPDATE" | "FREE_PERIOD_DISCOUNT" | "ACTIVATE" | null;
|
|
28
37
|
startDate: unknown;
|
package/dist/esm/index.js
CHANGED
|
@@ -1278,7 +1278,7 @@ const DEFAULT_CONFIG = {
|
|
|
1278
1278
|
};
|
|
1279
1279
|
|
|
1280
1280
|
// This will be replaced at build time by rollup-plugin-replace
|
|
1281
|
-
const PACKAGE_VERSION = '1.7.0-beta.
|
|
1281
|
+
const PACKAGE_VERSION = '1.7.0-beta.17';
|
|
1282
1282
|
const createRequestHeaders = (token) => {
|
|
1283
1283
|
const headers = createClientDevHeaders({ token });
|
|
1284
1284
|
// Add the components version header
|
|
@@ -24517,6 +24517,15 @@ const splitSubscriptionsByPriceList_SubscriptionFragment = t(`
|
|
|
24517
24517
|
evergreen
|
|
24518
24518
|
startDate
|
|
24519
24519
|
endDate
|
|
24520
|
+
addonSubscriptions {
|
|
24521
|
+
id
|
|
24522
|
+
priceList {
|
|
24523
|
+
id
|
|
24524
|
+
}
|
|
24525
|
+
plan {
|
|
24526
|
+
id
|
|
24527
|
+
}
|
|
24528
|
+
}
|
|
24520
24529
|
chargeReport {
|
|
24521
24530
|
kind
|
|
24522
24531
|
startDate
|
|
@@ -24615,7 +24624,7 @@ function splitSubscriptionsByPriceList(maskedSubscriptions) {
|
|
|
24615
24624
|
// DUPLICATE the entire subscription, just filter the charges
|
|
24616
24625
|
const splitSubscriptions = [];
|
|
24617
24626
|
chargesByPriceList.forEach((charges, priceListId) => {
|
|
24618
|
-
var _a, _b;
|
|
24627
|
+
var _a, _b, _c, _d, _e, _f;
|
|
24619
24628
|
// Get the first charge to extract priceList, plan, and product info
|
|
24620
24629
|
const firstCharge = charges === null || charges === void 0 ? void 0 : charges[0];
|
|
24621
24630
|
if (!firstCharge || !charges)
|
|
@@ -24651,6 +24660,22 @@ function splitSubscriptionsByPriceList(maskedSubscriptions) {
|
|
|
24651
24660
|
}
|
|
24652
24661
|
// Only the subscription with the latest charge will actually renew
|
|
24653
24662
|
const willRenew = priceListId === latestPriceListId;
|
|
24663
|
+
// Filter addon subscriptions to only include those compatible with the new plan
|
|
24664
|
+
// If the plan has changed, we need to check if the addon subscriptions are still valid
|
|
24665
|
+
const newPlan = (_a = firstCharge.priceList) === null || _a === void 0 ? void 0 : _a.plan;
|
|
24666
|
+
const addonPlanIds = (_c = (_b = newPlan === null || newPlan === void 0 ? void 0 : newPlan.addonPlans) === null || _b === void 0 ? void 0 : _b.map(plan => plan.id)) !== null && _c !== void 0 ? _c : [];
|
|
24667
|
+
// For split subscriptions that represent a future period (after plan change),
|
|
24668
|
+
// filter out addon subscriptions that are not compatible with the new plan
|
|
24669
|
+
const filteredAddonSubscriptions = (_d = subscription.addonSubscriptions) === null || _d === void 0 ? void 0 : _d.filter(addonSub => {
|
|
24670
|
+
var _a;
|
|
24671
|
+
// If the new plan has no addon plans defined, keep all addons (backward compatibility)
|
|
24672
|
+
if (!(newPlan === null || newPlan === void 0 ? void 0 : newPlan.addonPlans) || newPlan.addonPlans.length === 0) {
|
|
24673
|
+
return true;
|
|
24674
|
+
}
|
|
24675
|
+
// Check if this addon subscription's plan is in the new plan's addonPlans list
|
|
24676
|
+
const addonPlanId = (_a = addonSub.plan) === null || _a === void 0 ? void 0 : _a.id;
|
|
24677
|
+
return addonPlanId ? addonPlanIds.includes(addonPlanId) : false;
|
|
24678
|
+
});
|
|
24654
24679
|
splitSubscriptions.push({
|
|
24655
24680
|
...maskedSubscription,
|
|
24656
24681
|
// Keep the original subscription ID intact (from maskedSubscription spread)
|
|
@@ -24671,11 +24696,13 @@ function splitSubscriptionsByPriceList(maskedSubscriptions) {
|
|
|
24671
24696
|
// Filter chargeReport to only include charges for this price list
|
|
24672
24697
|
chargeReport: charges,
|
|
24673
24698
|
// Filter charges array to only include charges for this price list
|
|
24674
|
-
charges: (
|
|
24699
|
+
charges: (_f = (_e = subscription.charges) === null || _e === void 0 ? void 0 : _e.filter(charge => {
|
|
24675
24700
|
var _a;
|
|
24676
24701
|
const chargeWithPriceList = charge;
|
|
24677
24702
|
return ((_a = chargeWithPriceList.priceList) === null || _a === void 0 ? void 0 : _a.id) === priceListId;
|
|
24678
|
-
})) !== null &&
|
|
24703
|
+
})) !== null && _f !== void 0 ? _f : [],
|
|
24704
|
+
// Filter addon subscriptions to only include those compatible with the new plan
|
|
24705
|
+
addonSubscriptions: filteredAddonSubscriptions,
|
|
24679
24706
|
});
|
|
24680
24707
|
});
|
|
24681
24708
|
// Sort split subscriptions by endDate (earliest first)
|
package/dist/esm/types/src/components/Subscriptions/subscriptionsList/subscriptionUtils.d.ts
CHANGED
|
@@ -23,6 +23,15 @@ export declare const splitSubscriptionsByPriceList_SubscriptionFragment: import(
|
|
|
23
23
|
evergreen: boolean;
|
|
24
24
|
startDate: unknown;
|
|
25
25
|
endDate: unknown;
|
|
26
|
+
addonSubscriptions: {
|
|
27
|
+
id: string;
|
|
28
|
+
priceList: {
|
|
29
|
+
id: string;
|
|
30
|
+
} | null;
|
|
31
|
+
plan: {
|
|
32
|
+
id: string;
|
|
33
|
+
} | null;
|
|
34
|
+
}[] | null;
|
|
26
35
|
chargeReport: {
|
|
27
36
|
kind: "SUBSCRIBE" | "UPDATE" | "RENEW" | "REINSTATE" | "UNSUBSCRIBE" | "ADJUSTMENT" | "COUPON" | "DISCOUNT" | "CREDIT" | "PRICE_UPDATE" | "QUANTITY_UPDATE" | "FREE_PERIOD_DISCOUNT" | "ACTIVATE" | null;
|
|
28
37
|
startDate: unknown;
|
package/package.json
CHANGED