@rebuy/rebuy 3.66.0 → 3.67.0
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/index.cjs +812 -784
- package/dist/index.mjs +812 -784
- package/dist/schema/cabShopConfig.d.ts +5 -5
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/postPurchaseDecisionTrace.d.ts +90 -0
- package/dist/schema/postPurchaseShadow.d.ts +33 -7
- package/dist/schema/smartCart.d.ts +18 -18
- package/dist/schema/userConfig.d.ts +5 -5
- package/dist/server/index.cjs +34 -12
- package/dist/server/index.mjs +34 -12
- package/dist/transforms/index.cjs +23 -9
- package/dist/transforms/index.mjs +23 -9
- package/dist/transforms/smartCart/convertSmartCartProgressBarToV2.d.ts +3 -1
- package/package.json +7 -1
|
@@ -4866,7 +4866,14 @@ var MAX_ICON_SIZE_PX = 64;
|
|
|
4866
4866
|
var IN_SCOPE_TIER_TYPES = new Set(progressTierTypes);
|
|
4867
4867
|
var inScope = (tier) => IN_SCOPE_TIER_TYPES.has(tier.type ?? "");
|
|
4868
4868
|
var thresholdOf = (tier) => tier.unlockConditionType === "item_quantity" ? Math.ceil(Number(tier.minimum)) : Math.round(Number(tier.minimum) * 100);
|
|
4869
|
-
var tierThresholds = (tier) =>
|
|
4869
|
+
var tierThresholds = (tier, shopCurrency) => {
|
|
4870
|
+
const shopCode = shopCurrency?.toLowerCase();
|
|
4871
|
+
return Object.fromEntries(
|
|
4872
|
+
Object.entries(presentmentThresholds(tier.presentmentCurrencies)).filter(
|
|
4873
|
+
([code, cents]) => cents > 0 && code !== shopCode
|
|
4874
|
+
)
|
|
4875
|
+
);
|
|
4876
|
+
};
|
|
4870
4877
|
var tierLabel = (tier) => {
|
|
4871
4878
|
const type = tier.type;
|
|
4872
4879
|
if ((tier.customTierLabel || type === "decorative") && tier.customTierLabelText) return tier.customTierLabelText;
|
|
@@ -4920,7 +4927,7 @@ var exclusionsOf = (tier) => {
|
|
|
4920
4927
|
});
|
|
4921
4928
|
return rules.length > 0 ? rules : void 0;
|
|
4922
4929
|
};
|
|
4923
|
-
var toTierMeta = (tier) => {
|
|
4930
|
+
var toTierMeta = (tier, shopCurrency) => {
|
|
4924
4931
|
const discount = discountOf(tier);
|
|
4925
4932
|
const exclusions = exclusionsOf(tier);
|
|
4926
4933
|
const gift = giftOf(tier);
|
|
@@ -4941,16 +4948,16 @@ var toTierMeta = (tier) => {
|
|
|
4941
4948
|
/** Carry the image-swap flag only on gift tiers that set it — the client shows the gift's product image in the step slot instead of the bag icon. */
|
|
4942
4949
|
...gift && tier.productTierImage && { productTierImage: true },
|
|
4943
4950
|
threshold: thresholdOf(tier),
|
|
4944
|
-
thresholds:
|
|
4951
|
+
thresholds: isItemCount ? {} : tierThresholds(tier, shopCurrency),
|
|
4945
4952
|
...tier.id && { tierId: tier.id },
|
|
4946
4953
|
tierType: type,
|
|
4947
4954
|
...isItemCount && { unit: "item" }
|
|
4948
4955
|
};
|
|
4949
4956
|
};
|
|
4950
|
-
var renderableTiers = (bar) => (bar.tiers ?? []).filter(
|
|
4957
|
+
var renderableTiers = (bar, shopCurrency) => (bar.tiers ?? []).filter(
|
|
4951
4958
|
(tier) => (
|
|
4952
4959
|
/** onsite `isTierDataValid`: a non-numeric (null/absent) minimum is dropped — else `thresholdOf` reads it as 0, an always-reached tier that auto-adds its gift to every cart. A literal 0 is finite and kept. Divergence: onsite's strict `typeof === 'number'` also drops a string `'50'`; here `minimum` was already `z.coerce`d (`'50' → 50`), so `Number.isFinite` keeps it — see smartCart.ts. */
|
|
4953
|
-
inScope(tier) && Number.isFinite(tier.minimum) && CABProgressTier.safeParse(toTierMeta(tier)).success
|
|
4960
|
+
inScope(tier) && Number.isFinite(tier.minimum) && CABProgressTier.safeParse(toTierMeta(tier, shopCurrency)).success
|
|
4954
4961
|
)
|
|
4955
4962
|
);
|
|
4956
4963
|
var PRODUCT_TOKENS = ["productTitle", "remainingAmount"];
|
|
@@ -5005,7 +5012,7 @@ var toTierFeedback = (tier) => {
|
|
|
5005
5012
|
});
|
|
5006
5013
|
return sections;
|
|
5007
5014
|
};
|
|
5008
|
-
var toProgressBarSection = (bar, tiers, countryCodes, excludeCountryCodes, progressColor) => ({
|
|
5015
|
+
var toProgressBarSection = (bar, tiers, countryCodes, excludeCountryCodes, progressColor, shopCurrency) => ({
|
|
5009
5016
|
/**
|
|
5010
5017
|
* React's `SmartCartProgressBarContent` centers the bar/message stack (`inlineAlignment="center"`); the
|
|
5011
5018
|
* section inherits `layout`'s `alignment.horizontal: 'start'`, so an emitted-bare bar would left-align.
|
|
@@ -5061,7 +5068,7 @@ var toProgressBarSection = (bar, tiers, countryCodes, excludeCountryCodes, progr
|
|
|
5061
5068
|
sectionType: "progressBar",
|
|
5062
5069
|
/** React's bar/message stack uses `spacing="tight"` (→ `small-100`); `layout` defaults `spacing` to `base`, a wider gap. Emit `tight` for parity (mirrors the v1 shipping converter). */
|
|
5063
5070
|
spacing: "tight",
|
|
5064
|
-
tiers: tiers.map(toTierMeta)
|
|
5071
|
+
tiers: tiers.map((tier) => toTierMeta(tier, shopCurrency))
|
|
5065
5072
|
});
|
|
5066
5073
|
var barCountries = (bar) => [
|
|
5067
5074
|
...new Set((bar.countryCodes ?? []).map((code) => code.trim().toUpperCase()).filter(Boolean))
|
|
@@ -5087,9 +5094,16 @@ var dedupeBars = (entries) => {
|
|
|
5087
5094
|
return rendered;
|
|
5088
5095
|
};
|
|
5089
5096
|
var convertSmartCartProgressBarToV2 = (input) => {
|
|
5090
|
-
const entries = input.bars.map((bar) => ({ bar, tiers: renderableTiers(bar) }));
|
|
5097
|
+
const entries = input.bars.map((bar) => ({ bar, tiers: renderableTiers(bar, input.shopCurrency) }));
|
|
5091
5098
|
const sections = dedupeBars(entries).map(
|
|
5092
|
-
({ countryCodes, entry, excludeCountryCodes }) => toProgressBarSection(
|
|
5099
|
+
({ countryCodes, entry, excludeCountryCodes }) => toProgressBarSection(
|
|
5100
|
+
entry.bar,
|
|
5101
|
+
entry.tiers,
|
|
5102
|
+
countryCodes,
|
|
5103
|
+
excludeCountryCodes,
|
|
5104
|
+
input.progressColor,
|
|
5105
|
+
input.shopCurrency
|
|
5106
|
+
)
|
|
5093
5107
|
);
|
|
5094
5108
|
return CABRootSection.parse(
|
|
5095
5109
|
normalizeTextContent({
|
|
@@ -4805,7 +4805,14 @@ var MAX_ICON_SIZE_PX = 64;
|
|
|
4805
4805
|
var IN_SCOPE_TIER_TYPES = new Set(progressTierTypes);
|
|
4806
4806
|
var inScope = (tier) => IN_SCOPE_TIER_TYPES.has(tier.type ?? "");
|
|
4807
4807
|
var thresholdOf = (tier) => tier.unlockConditionType === "item_quantity" ? Math.ceil(Number(tier.minimum)) : Math.round(Number(tier.minimum) * 100);
|
|
4808
|
-
var tierThresholds = (tier) =>
|
|
4808
|
+
var tierThresholds = (tier, shopCurrency) => {
|
|
4809
|
+
const shopCode = shopCurrency?.toLowerCase();
|
|
4810
|
+
return Object.fromEntries(
|
|
4811
|
+
Object.entries(presentmentThresholds(tier.presentmentCurrencies)).filter(
|
|
4812
|
+
([code, cents]) => cents > 0 && code !== shopCode
|
|
4813
|
+
)
|
|
4814
|
+
);
|
|
4815
|
+
};
|
|
4809
4816
|
var tierLabel = (tier) => {
|
|
4810
4817
|
const type = tier.type;
|
|
4811
4818
|
if ((tier.customTierLabel || type === "decorative") && tier.customTierLabelText) return tier.customTierLabelText;
|
|
@@ -4859,7 +4866,7 @@ var exclusionsOf = (tier) => {
|
|
|
4859
4866
|
});
|
|
4860
4867
|
return rules.length > 0 ? rules : void 0;
|
|
4861
4868
|
};
|
|
4862
|
-
var toTierMeta = (tier) => {
|
|
4869
|
+
var toTierMeta = (tier, shopCurrency) => {
|
|
4863
4870
|
const discount = discountOf(tier);
|
|
4864
4871
|
const exclusions = exclusionsOf(tier);
|
|
4865
4872
|
const gift = giftOf(tier);
|
|
@@ -4880,16 +4887,16 @@ var toTierMeta = (tier) => {
|
|
|
4880
4887
|
/** Carry the image-swap flag only on gift tiers that set it — the client shows the gift's product image in the step slot instead of the bag icon. */
|
|
4881
4888
|
...gift && tier.productTierImage && { productTierImage: true },
|
|
4882
4889
|
threshold: thresholdOf(tier),
|
|
4883
|
-
thresholds:
|
|
4890
|
+
thresholds: isItemCount ? {} : tierThresholds(tier, shopCurrency),
|
|
4884
4891
|
...tier.id && { tierId: tier.id },
|
|
4885
4892
|
tierType: type,
|
|
4886
4893
|
...isItemCount && { unit: "item" }
|
|
4887
4894
|
};
|
|
4888
4895
|
};
|
|
4889
|
-
var renderableTiers = (bar) => (bar.tiers ?? []).filter(
|
|
4896
|
+
var renderableTiers = (bar, shopCurrency) => (bar.tiers ?? []).filter(
|
|
4890
4897
|
(tier) => (
|
|
4891
4898
|
/** onsite `isTierDataValid`: a non-numeric (null/absent) minimum is dropped — else `thresholdOf` reads it as 0, an always-reached tier that auto-adds its gift to every cart. A literal 0 is finite and kept. Divergence: onsite's strict `typeof === 'number'` also drops a string `'50'`; here `minimum` was already `z.coerce`d (`'50' → 50`), so `Number.isFinite` keeps it — see smartCart.ts. */
|
|
4892
|
-
inScope(tier) && Number.isFinite(tier.minimum) && CABProgressTier.safeParse(toTierMeta(tier)).success
|
|
4899
|
+
inScope(tier) && Number.isFinite(tier.minimum) && CABProgressTier.safeParse(toTierMeta(tier, shopCurrency)).success
|
|
4893
4900
|
)
|
|
4894
4901
|
);
|
|
4895
4902
|
var PRODUCT_TOKENS = ["productTitle", "remainingAmount"];
|
|
@@ -4944,7 +4951,7 @@ var toTierFeedback = (tier) => {
|
|
|
4944
4951
|
});
|
|
4945
4952
|
return sections;
|
|
4946
4953
|
};
|
|
4947
|
-
var toProgressBarSection = (bar, tiers, countryCodes, excludeCountryCodes, progressColor) => ({
|
|
4954
|
+
var toProgressBarSection = (bar, tiers, countryCodes, excludeCountryCodes, progressColor, shopCurrency) => ({
|
|
4948
4955
|
/**
|
|
4949
4956
|
* React's `SmartCartProgressBarContent` centers the bar/message stack (`inlineAlignment="center"`); the
|
|
4950
4957
|
* section inherits `layout`'s `alignment.horizontal: 'start'`, so an emitted-bare bar would left-align.
|
|
@@ -5000,7 +5007,7 @@ var toProgressBarSection = (bar, tiers, countryCodes, excludeCountryCodes, progr
|
|
|
5000
5007
|
sectionType: "progressBar",
|
|
5001
5008
|
/** React's bar/message stack uses `spacing="tight"` (→ `small-100`); `layout` defaults `spacing` to `base`, a wider gap. Emit `tight` for parity (mirrors the v1 shipping converter). */
|
|
5002
5009
|
spacing: "tight",
|
|
5003
|
-
tiers: tiers.map(toTierMeta)
|
|
5010
|
+
tiers: tiers.map((tier) => toTierMeta(tier, shopCurrency))
|
|
5004
5011
|
});
|
|
5005
5012
|
var barCountries = (bar) => [
|
|
5006
5013
|
...new Set((bar.countryCodes ?? []).map((code) => code.trim().toUpperCase()).filter(Boolean))
|
|
@@ -5026,9 +5033,16 @@ var dedupeBars = (entries) => {
|
|
|
5026
5033
|
return rendered;
|
|
5027
5034
|
};
|
|
5028
5035
|
var convertSmartCartProgressBarToV2 = (input) => {
|
|
5029
|
-
const entries = input.bars.map((bar) => ({ bar, tiers: renderableTiers(bar) }));
|
|
5036
|
+
const entries = input.bars.map((bar) => ({ bar, tiers: renderableTiers(bar, input.shopCurrency) }));
|
|
5030
5037
|
const sections = dedupeBars(entries).map(
|
|
5031
|
-
({ countryCodes, entry, excludeCountryCodes }) => toProgressBarSection(
|
|
5038
|
+
({ countryCodes, entry, excludeCountryCodes }) => toProgressBarSection(
|
|
5039
|
+
entry.bar,
|
|
5040
|
+
entry.tiers,
|
|
5041
|
+
countryCodes,
|
|
5042
|
+
excludeCountryCodes,
|
|
5043
|
+
input.progressColor,
|
|
5044
|
+
input.shopCurrency
|
|
5045
|
+
)
|
|
5032
5046
|
);
|
|
5033
5047
|
return CABRootSection.parse(
|
|
5034
5048
|
normalizeTextContent({
|
|
@@ -6,7 +6,7 @@ import { type V1ProgressBarSettings } from '../../transforms/progressBarV1/types
|
|
|
6
6
|
* `progressBar` container per configured bar (tiers come from the shop's smart-cart config — see
|
|
7
7
|
* `extractSmartCartBars`). Each container holds its tier display (composable `columns → rows → text/image`)
|
|
8
8
|
* + copy as children, with milestones on `tiers` (server-precomputed per tier: cents — base +
|
|
9
|
-
* per-presentment-currency
|
|
9
|
+
* per-presentment-currency on every money tier — or a raw item count for `item_quantity` tiers) so the
|
|
10
10
|
* client only compares each tier against its own unit's progress, mirroring the shipping bar. DISPLAY
|
|
11
11
|
* ONLY — gift add/remove is a later stage. Tiers whose meta fails the strict schema are dropped (never
|
|
12
12
|
* thrown); a bar left with no renderable tier renders nothing — but a geo bar still shadows its countries
|
|
@@ -18,4 +18,6 @@ export declare const convertSmartCartProgressBarToV2: (input: {
|
|
|
18
18
|
/** The shop theme's `buttonBackground` (bar fill), resolved by the caller; schema-defaulted when absent. */
|
|
19
19
|
progressColor?: string;
|
|
20
20
|
settings: V1ProgressBarSettings;
|
|
21
|
+
/** The shop's base-currency ISO code (`CabShopConfig.currency`): its per-currency entry is never a threshold. */
|
|
22
|
+
shopCurrency?: string;
|
|
21
23
|
}) => CABRootSection;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebuy/rebuy",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.67.0",
|
|
4
4
|
"description": "Shared zod schemas, legacy-to-CAB widget transforms, and server orchestrators for Rebuy's Shopify consumers (rebuy-api, admin-nextjs, rebuy-shopify-extensions)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Rebuy, Inc.",
|
|
@@ -217,5 +217,11 @@
|
|
|
217
217
|
},
|
|
218
218
|
"publishConfig": {
|
|
219
219
|
"access": "public"
|
|
220
|
+
},
|
|
221
|
+
"overrides": {
|
|
222
|
+
"external-editor": {
|
|
223
|
+
"tmp": "^0.2.6"
|
|
224
|
+
},
|
|
225
|
+
"brace-expansion@^1": "^1.1.21"
|
|
220
226
|
}
|
|
221
227
|
}
|