@funnelsgrove/runtime 0.7.1 → 0.7.2
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.
|
@@ -40,26 +40,33 @@ const getLegacyProviderMapping = (plan, mode) => {
|
|
|
40
40
|
const buildPlanModeConfig = (item, mode, legacyPlan = null) => {
|
|
41
41
|
var _a, _b;
|
|
42
42
|
const metadata = isRecord(item.metadata) ? item.metadata : {};
|
|
43
|
+
const directMappings = isRecord(item.providerMappingsByMode)
|
|
44
|
+
? item.providerMappingsByMode
|
|
45
|
+
: {};
|
|
43
46
|
const metadataMappings = isRecord(metadata.providerMappingsByMode)
|
|
44
47
|
? metadata.providerMappingsByMode
|
|
45
48
|
: {};
|
|
46
|
-
const
|
|
49
|
+
const modeMapping = isRecord(directMappings[mode])
|
|
50
|
+
? directMappings[mode]
|
|
51
|
+
: isRecord(metadataMappings[mode])
|
|
52
|
+
? metadataMappings[mode]
|
|
53
|
+
: {};
|
|
47
54
|
const legacyMapping = getLegacyProviderMapping(legacyPlan, mode);
|
|
48
55
|
const prefix = mode === 'test' ? 'test' : 'live';
|
|
49
56
|
const providerPlanId = (pickString(item, `${prefix}ProviderPlanId`, `${prefix}_provider_plan_id`)
|
|
50
|
-
|| pickString(
|
|
57
|
+
|| pickString(modeMapping, 'providerPlanId')
|
|
51
58
|
|| (legacyMapping ? pickString(legacyMapping, 'providerPlanId', 'provider_plan_id') : null));
|
|
52
59
|
if (!providerPlanId) {
|
|
53
60
|
return null;
|
|
54
61
|
}
|
|
55
|
-
const amountMinor = (_a = pickNumber(
|
|
56
|
-
const interval = pickString(
|
|
62
|
+
const amountMinor = (_a = pickNumber(modeMapping, 'amountCents')) !== null && _a !== void 0 ? _a : (legacyMapping ? pickNumber(legacyMapping, 'amountMinor', 'amount_minor') : null);
|
|
63
|
+
const interval = pickString(modeMapping, 'billingInterval')
|
|
57
64
|
|| (legacyMapping ? pickString(legacyMapping, 'interval') : null);
|
|
58
|
-
const intervalCount = (_b = pickNumber(
|
|
59
|
-
const currency = pickString(
|
|
65
|
+
const intervalCount = (_b = pickNumber(modeMapping, 'billingIntervalCount')) !== null && _b !== void 0 ? _b : (legacyMapping ? pickNumber(legacyMapping, 'intervalCount', 'interval_count') : null);
|
|
66
|
+
const currency = pickString(modeMapping, 'currency')
|
|
60
67
|
|| (legacyMapping ? pickString(legacyMapping, 'currency') : null);
|
|
61
68
|
const amountMajor = amountMinor === null ? null : amountMinor / 100;
|
|
62
|
-
const priceLabel = pickString(
|
|
69
|
+
const priceLabel = pickString(modeMapping, 'priceLabel') || (amountMajor === null
|
|
63
70
|
? null
|
|
64
71
|
: new Intl.NumberFormat('en-US', {
|
|
65
72
|
style: 'currency',
|
|
@@ -67,12 +74,12 @@ const buildPlanModeConfig = (item, mode, legacyPlan = null) => {
|
|
|
67
74
|
minimumFractionDigits: 2,
|
|
68
75
|
maximumFractionDigits: 2,
|
|
69
76
|
}).format(amountMajor) + (interval ? `/${interval}` : ''));
|
|
70
|
-
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ providerPlanId }, (priceLabel ? { priceLabel } : {})), (pickString(
|
|
71
|
-
? { perDayAmount: pickString(
|
|
72
|
-
: {})), (pickString(
|
|
73
|
-
? { perDayLabel: pickString(
|
|
74
|
-
: {})), (amountMinor === null ? {} : { amountCents: amountMinor })), (pickString(
|
|
75
|
-
? { checkoutSummaryLabel: pickString(
|
|
77
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ providerPlanId }, (priceLabel ? { priceLabel } : {})), (pickString(modeMapping, 'perDayAmount')
|
|
78
|
+
? { perDayAmount: pickString(modeMapping, 'perDayAmount') }
|
|
79
|
+
: {})), (pickString(modeMapping, 'perDayLabel')
|
|
80
|
+
? { perDayLabel: pickString(modeMapping, 'perDayLabel') }
|
|
81
|
+
: {})), (amountMinor === null ? {} : { amountCents: amountMinor })), (pickString(modeMapping, 'checkoutSummaryLabel')
|
|
82
|
+
? { checkoutSummaryLabel: pickString(modeMapping, 'checkoutSummaryLabel') }
|
|
76
83
|
: amountMajor === null
|
|
77
84
|
? {}
|
|
78
85
|
: { checkoutSummaryLabel: `${new Intl.NumberFormat('en-US', {
|