@rebuy/rebuy 3.43.1 → 3.44.1
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 +72 -13
- package/dist/index.mjs +72 -13
- package/dist/pricing/postPurchaseDisplayPrice.d.ts +2 -0
- package/dist/schema/postPurchaseDisplayPrice.d.ts +4 -3
- package/dist/schema/postPurchaseProductCollectionView.d.ts +365 -3
- package/dist/schema/postPurchaseProductView.d.ts +367 -4
- package/dist/schema/postPurchaseTransition.d.ts +80 -3
- package/dist/server/index.cjs +119 -40
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.mjs +119 -40
- package/dist/server/postPurchaseCardSections.d.ts +12 -0
- package/dist/server/postPurchaseProductEligibility.d.ts +1 -1
- package/dist/server/postPurchaseSubscriptionEligibility.d.ts +1 -1
- package/dist/server/postPurchaseUnavailableChoice.d.ts +12 -0
- package/dist/server/preparePostPurchaseAdmissionView.d.ts +125 -2
- package/dist/server/preparePostPurchaseCollectionGroup.d.ts +130 -4
- package/dist/server/preparePostPurchaseCollectionView.d.ts +125 -2
- package/dist/server/preparePostPurchaseGroupAdmissionView.d.ts +125 -2
- package/dist/server/preparePostPurchaseGroupDefault.d.ts +125 -2
- package/dist/server/preparePostPurchaseGroupView.d.ts +125 -2
- package/dist/server/preparePostPurchaseMemberView.d.ts +375 -6
- package/dist/server/preparePostPurchaseQuantityAdmissionView.d.ts +125 -2
- package/dist/server/preparePostPurchaseQuantityView.d.ts +125 -2
- package/dist/server/preparePostPurchaseView.d.ts +4 -1
- package/dist/transforms/index.cjs +57 -7
- package/dist/transforms/index.mjs +57 -7
- package/dist/transforms/legacyLabelDefaults.d.ts +15 -0
- package/dist/transforms/localizedContent.d.ts +23 -6
- package/dist/transforms/postPurchase/productCardRows.d.ts +3 -1
- package/package.json +1 -1
|
@@ -312,7 +312,7 @@ export declare const preparePostPurchaseQuantityView: (widgetId: number, setting
|
|
|
312
312
|
} | undefined;
|
|
313
313
|
displayPrice?: {
|
|
314
314
|
currencyCode: string;
|
|
315
|
-
savingFormat: "amount" | "percent";
|
|
315
|
+
savingFormat: "amount" | "percent" | null;
|
|
316
316
|
savingMinor: number;
|
|
317
317
|
savingPercent: number;
|
|
318
318
|
variantCompareAtPriceMinor: number | null;
|
|
@@ -406,7 +406,130 @@ export declare const preparePostPurchaseQuantityView: (widgetId: number, setting
|
|
|
406
406
|
reason: string;
|
|
407
407
|
status: "unsupported";
|
|
408
408
|
};
|
|
409
|
-
sections:
|
|
409
|
+
sections: {
|
|
410
|
+
alignment: {
|
|
411
|
+
horizontal: "start" | "center" | "end";
|
|
412
|
+
vertical: "top" | "middle" | "bottom";
|
|
413
|
+
};
|
|
414
|
+
border: {
|
|
415
|
+
radius: "small" | "none" | "base" | "large" | "fullyRounded";
|
|
416
|
+
style: "none" | "base" | "dotted" | "dashed";
|
|
417
|
+
width: "base" | "medium" | "thick";
|
|
418
|
+
};
|
|
419
|
+
direction: "columns" | "rows" | "grid";
|
|
420
|
+
padding: "none" | "base" | "extraTight" | "tight" | "loose" | "extraLoose";
|
|
421
|
+
sectionId: string;
|
|
422
|
+
sections: never[] | import("..").CABSection[];
|
|
423
|
+
sectionType: "layout";
|
|
424
|
+
spacing: "none" | "base" | "extraTight" | "tight" | "loose" | "extraLoose";
|
|
425
|
+
width: number;
|
|
426
|
+
editorMode: "checkoutExtension" | "postPurchaseOffer" | "thankYouPage" | "orderStatusPage" | "ordersIndexPage" | "customerProfilePage";
|
|
427
|
+
previewMode: boolean;
|
|
428
|
+
storeId: number | null;
|
|
429
|
+
targetArea: {
|
|
430
|
+
icon: string;
|
|
431
|
+
label: string;
|
|
432
|
+
width: string;
|
|
433
|
+
fill?: boolean | undefined;
|
|
434
|
+
flip?: "vertical" | "horizontal" | "both" | undefined;
|
|
435
|
+
} | null;
|
|
436
|
+
tracking: {
|
|
437
|
+
enableAttribution: boolean;
|
|
438
|
+
enableSource: boolean;
|
|
439
|
+
enableWidget: boolean;
|
|
440
|
+
};
|
|
441
|
+
type: "product" | "bundle_builder" | "cart" | "cart_subscription" | "dynamic_bundle" | "gift_with_purchase" | "placeholder" | "pre_purchase" | "product_addon" | "product_upsell" | "recharge_checkout" | "recharge_customer_portal" | "recharge_post_purchase" | "shopify_checkout" | "shopify_checkout_extension" | "shopify_post_purchase" | "shopify_post_purchase_extension" | "switch_to_subscription" | "ui_extension_ad" | "ui_extension_button" | "ui_extension_content_block" | "ui_extension_line_item_editor" | "ui_extension_progress_bar";
|
|
442
|
+
uiLabels: {
|
|
443
|
+
currentPage: Record<string, string>;
|
|
444
|
+
guest: Record<string, string>;
|
|
445
|
+
loadingOptions: Record<string, string>;
|
|
446
|
+
nextPage: Record<string, string>;
|
|
447
|
+
offerCarousel: Record<string, string>;
|
|
448
|
+
offerDialog: Record<string, string>;
|
|
449
|
+
page: Record<string, string>;
|
|
450
|
+
previousPage: Record<string, string>;
|
|
451
|
+
selected: Record<string, string>;
|
|
452
|
+
subscriptionOptions: Record<string, string>;
|
|
453
|
+
updating: Record<string, string>;
|
|
454
|
+
};
|
|
455
|
+
version: 2;
|
|
456
|
+
widgetId: number | null;
|
|
457
|
+
buttonField?: "declineAllOffers" | "declineOffer" | "removeFromOrder" | "undoAddToOrder" | "activePage" | "addedToCart" | "addingToCart" | "addToCart" | "buttonLabel" | "destinationUrl" | "inactivePage" | "overlayContent" | "payNow" | "progressReached" | "progressRemaining" | "redirectToCheckout" | "showVariant" | "showVariants" | "soldOut" | "subscriptionOption" | "switchToOneTimePurchase" | "switchToSubscriptionNoDiscount" | "switchToSubscriptionWithDiscount" | undefined;
|
|
458
|
+
frame?: "callout" | "offer-content" | undefined;
|
|
459
|
+
grid?: {
|
|
460
|
+
columns: (string | number)[];
|
|
461
|
+
rows: (string | number)[];
|
|
462
|
+
} | undefined;
|
|
463
|
+
name?: string | undefined;
|
|
464
|
+
viewUrl?: string | undefined;
|
|
465
|
+
wrapping?: {
|
|
466
|
+
breakAt: number;
|
|
467
|
+
maxPerLine: number;
|
|
468
|
+
} | undefined;
|
|
469
|
+
mutators?: {
|
|
470
|
+
effect: "set_false" | "set_true" | "toggle";
|
|
471
|
+
variable: string;
|
|
472
|
+
when: {
|
|
473
|
+
operator: "is_empty" | "is_not_empty";
|
|
474
|
+
type: "content";
|
|
475
|
+
} | {
|
|
476
|
+
operator: "equals" | "greater_than" | "less_than";
|
|
477
|
+
type: "result_count";
|
|
478
|
+
value: number;
|
|
479
|
+
} | {
|
|
480
|
+
operator: "contains" | "does_not_contain";
|
|
481
|
+
type: "result_tag";
|
|
482
|
+
value: string;
|
|
483
|
+
} | {
|
|
484
|
+
event: "item_added" | "quantity_changed" | "variant_selected";
|
|
485
|
+
type: "event";
|
|
486
|
+
};
|
|
487
|
+
}[] | undefined;
|
|
488
|
+
variables?: ({
|
|
489
|
+
defaultValue: string;
|
|
490
|
+
name: string;
|
|
491
|
+
type: "text";
|
|
492
|
+
seed?: undefined;
|
|
493
|
+
} | {
|
|
494
|
+
defaultValue: number;
|
|
495
|
+
name: string;
|
|
496
|
+
type: "number";
|
|
497
|
+
seed?: undefined;
|
|
498
|
+
} | {
|
|
499
|
+
defaultValue: boolean;
|
|
500
|
+
name: string;
|
|
501
|
+
type: "boolean";
|
|
502
|
+
seed?: {
|
|
503
|
+
dataSourceId: number | null;
|
|
504
|
+
ruleset: {
|
|
505
|
+
exitIfMatched: boolean;
|
|
506
|
+
logic: {
|
|
507
|
+
rules: {
|
|
508
|
+
operator: "equals" | "greater_than" | "less_than" | "contains" | "does_not_contain" | "after" | "anything" | "before" | "contains_any" | "does_not_contain_any" | "does_not_equal";
|
|
509
|
+
products: never[] | unknown[];
|
|
510
|
+
type: "product" | "date" | "cart" | "cart_count" | "cart_item_count" | "cart_line_count" | "cart_subtotal" | "collection" | "customer" | "customer_order_count" | "customer_tag" | "customer_total_spent" | "product_tag" | "product_title" | "product_type" | "product_vendor";
|
|
511
|
+
value: string;
|
|
512
|
+
}[];
|
|
513
|
+
}[];
|
|
514
|
+
output: {
|
|
515
|
+
key: string;
|
|
516
|
+
type: "data_json";
|
|
517
|
+
value: string;
|
|
518
|
+
}[];
|
|
519
|
+
}[];
|
|
520
|
+
} | undefined;
|
|
521
|
+
})[] | undefined;
|
|
522
|
+
visibility?: {
|
|
523
|
+
variable: string;
|
|
524
|
+
visibleWhen: boolean;
|
|
525
|
+
} | undefined;
|
|
526
|
+
experiment?: {
|
|
527
|
+
elementId: number;
|
|
528
|
+
experimentId: number;
|
|
529
|
+
experimentType: string;
|
|
530
|
+
selectedId: number;
|
|
531
|
+
} | undefined;
|
|
532
|
+
} | null;
|
|
410
533
|
groupCatalog?: {
|
|
411
534
|
memberProductId: number;
|
|
412
535
|
options: {
|
|
@@ -3,6 +3,9 @@ import { PostPurchaseProductView } from '../schema/postPurchaseProductView';
|
|
|
3
3
|
import { normalizePostPurchaseProduct } from '../server/normalizePostPurchaseProduct';
|
|
4
4
|
import type { PostPurchaseQuantity } from '../server/readPostPurchaseQuantity';
|
|
5
5
|
import type { Reporter } from '../server/shared';
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Convert from the same effective settings snapshot; no product values enter the section tree. A choice-level
|
|
8
|
+
* unavailable product keeps its tree (`isChoiceUnavailable`); a configuration-level one answers `sections: null`.
|
|
9
|
+
*/
|
|
7
10
|
export declare const prepareNormalizedPostPurchaseView: (widgetId: number, normalized: ReturnType<typeof normalizePostPurchaseProduct>, report?: Reporter, choice?: PostPurchaseChoice, quantity?: PostPurchaseQuantity, allowCollection?: boolean) => PostPurchaseProductView;
|
|
8
11
|
export declare const preparePostPurchaseView: (widgetId: number, settings: unknown, response: unknown, report?: Reporter, choice?: PostPurchaseChoice) => PostPurchaseProductView;
|
|
@@ -2224,10 +2224,37 @@ var SWITCH_LABELS = {
|
|
|
2224
2224
|
}
|
|
2225
2225
|
};
|
|
2226
2226
|
|
|
2227
|
+
// src/transforms/legacyLabelDefaults.ts
|
|
2228
|
+
var LEGACY_LABEL_DEFAULTS = {
|
|
2229
|
+
/** The banner's RTE default, compared by its plain text. */
|
|
2230
|
+
addedToCartMessage: ["{{quantity}} {{product_title}} successfully added to cart!"],
|
|
2231
|
+
/** Offers template; the Recommended template stores the bare `Add`. */
|
|
2232
|
+
addToCart: ["Add {{quantity}} \u2022 {{total}}", "Add"],
|
|
2233
|
+
/** Line-item editor template, then the base template's `cartSwitchToOnetime` (the offer card's one-time label). */
|
|
2234
|
+
switchToOneTimePurchase: ["Downgrade to One-time", "One-time purchase"],
|
|
2235
|
+
/** Line-item editor template; the offers template's one upsell label fills both upsell slots. */
|
|
2236
|
+
switchToSubscriptionNoDiscount: [
|
|
2237
|
+
"Upgrade to Subscription",
|
|
2238
|
+
"Upgrade to Subscription and Save {{subscription_discount}}%"
|
|
2239
|
+
],
|
|
2240
|
+
/** Line-item editor template, then the offers template. */
|
|
2241
|
+
switchToSubscriptionWithDiscount: [
|
|
2242
|
+
"Upgrade to Subscription & Save {{subscription_discount}}%",
|
|
2243
|
+
"Upgrade to Subscription and Save {{subscription_discount}}%"
|
|
2244
|
+
]
|
|
2245
|
+
};
|
|
2246
|
+
|
|
2227
2247
|
// src/transforms/localizedContent.ts
|
|
2228
|
-
var
|
|
2248
|
+
var comparable = (label) => label.replace(/\s+/g, " ").trim().toLowerCase();
|
|
2249
|
+
var isDefaultLabel = (label, defaults, knownTokens = [], legacyDefaults = []) => {
|
|
2250
|
+
const candidates = [defaults.en, ...legacyDefaults];
|
|
2251
|
+
const target = comparable(normalizeTokens(label, knownTokens));
|
|
2252
|
+
return candidates.some((candidate) => comparable(normalizeTokens(candidate, knownTokens)) === target);
|
|
2253
|
+
};
|
|
2254
|
+
var localizedContent = (defaults, override, knownTokens = [], legacyDefaults = []) => {
|
|
2229
2255
|
const trimmed = normalizeTokens(stripContentBlockHtml(override ?? "").trim(), knownTokens);
|
|
2230
|
-
|
|
2256
|
+
if (!trimmed) return defaults;
|
|
2257
|
+
return isDefaultLabel(trimmed, defaults, knownTokens, legacyDefaults) ? { ...defaults, en: trimmed } : { en: trimmed };
|
|
2231
2258
|
};
|
|
2232
2259
|
|
|
2233
2260
|
// src/transforms/lineItemEditorV1/convertLineItemEditorToV2.ts
|
|
@@ -2248,7 +2275,8 @@ var convertLineItemEditorToV2 = ({ id, settings }) => {
|
|
|
2248
2275
|
content: localizedContent(
|
|
2249
2276
|
SWITCH_LABELS[buttonField],
|
|
2250
2277
|
switchToSubscription?.language?.[OVERRIDE_KEY[buttonField]],
|
|
2251
|
-
SWITCH_LABEL_TOKENS
|
|
2278
|
+
SWITCH_LABEL_TOKENS,
|
|
2279
|
+
LEGACY_LABEL_DEFAULTS[buttonField]
|
|
2252
2280
|
),
|
|
2253
2281
|
sectionType: "text"
|
|
2254
2282
|
}));
|
|
@@ -3039,6 +3067,14 @@ var convertPlaceholderToV2 = ({ id, settings }) => CABRootSection.parse({
|
|
|
3039
3067
|
// src/transforms/placeholderV1/types.ts
|
|
3040
3068
|
var isPlaceholderV1 = (data) => !!data && typeof data === "object" && data.type === WidgetType.placeholder;
|
|
3041
3069
|
|
|
3070
|
+
// src/cab/listOf.ts
|
|
3071
|
+
var listOf = (value) => Array.isArray(value) ? value.filter((item) => !!item) : [];
|
|
3072
|
+
|
|
3073
|
+
// src/cab/tiptapPlain.ts
|
|
3074
|
+
var tiptapPlainText = (doc) => listOf(doc?.content).map(
|
|
3075
|
+
(paragraph) => listOf(paragraph.content).map((node) => node.text ?? "").join("")
|
|
3076
|
+
).join(" ").trim();
|
|
3077
|
+
|
|
3042
3078
|
// src/transforms/productCard/earnedText.ts
|
|
3043
3079
|
var contentMutator = (effect, variable, operator) => ({
|
|
3044
3080
|
effect,
|
|
@@ -3109,7 +3145,12 @@ var subscriptionToggle = (productType, labels = {}) => {
|
|
|
3109
3145
|
if (productType !== "both" && productType !== "subscription") return [];
|
|
3110
3146
|
const slot = (buttonField, override) => ({
|
|
3111
3147
|
buttonField,
|
|
3112
|
-
content: localizedContent(
|
|
3148
|
+
content: localizedContent(
|
|
3149
|
+
SWITCH_LABELS[buttonField],
|
|
3150
|
+
override,
|
|
3151
|
+
SWITCH_LABEL_TOKENS2,
|
|
3152
|
+
LEGACY_LABEL_DEFAULTS[buttonField]
|
|
3153
|
+
),
|
|
3113
3154
|
sectionType: "text"
|
|
3114
3155
|
});
|
|
3115
3156
|
return [
|
|
@@ -3311,7 +3352,12 @@ var buildRevealButton = (settings) => revealsVariants(settings) ? [
|
|
|
3311
3352
|
var buildAddButton = (settings) => {
|
|
3312
3353
|
const slot = (buttonField, override) => ({
|
|
3313
3354
|
buttonField,
|
|
3314
|
-
content: localizedContent(
|
|
3355
|
+
content: localizedContent(
|
|
3356
|
+
OFFER_LABELS[buttonField],
|
|
3357
|
+
override,
|
|
3358
|
+
ADD_LABEL_TOKENS,
|
|
3359
|
+
LEGACY_LABEL_DEFAULTS[buttonField]
|
|
3360
|
+
),
|
|
3315
3361
|
sectionType: "text"
|
|
3316
3362
|
});
|
|
3317
3363
|
return {
|
|
@@ -3492,9 +3538,13 @@ var buildDiscountSection = (discount) => {
|
|
|
3492
3538
|
}
|
|
3493
3539
|
];
|
|
3494
3540
|
};
|
|
3541
|
+
var BANNER_MESSAGE_TOKENS = ["quantity", "productTitle"];
|
|
3495
3542
|
var bannerMessageContent = (message) => {
|
|
3496
|
-
const
|
|
3497
|
-
|
|
3543
|
+
const { addedToCartMessage } = OFFER_LABELS;
|
|
3544
|
+
const legacyDefaults = LEGACY_LABEL_DEFAULTS.addedToCartMessage;
|
|
3545
|
+
if (typeof message === "string" || !message)
|
|
3546
|
+
return localizedContent(addedToCartMessage, message, BANNER_MESSAGE_TOKENS, legacyDefaults);
|
|
3547
|
+
return isDefaultLabel(tiptapPlainText(message), addedToCartMessage, BANNER_MESSAGE_TOKENS, legacyDefaults) ? { ...addedToCartMessage, en: message } : { en: message };
|
|
3498
3548
|
};
|
|
3499
3549
|
var coerceIntegrations = (integrations) => Object.fromEntries(
|
|
3500
3550
|
Object.entries(integrations).map(([key, value]) => {
|
|
@@ -2163,10 +2163,37 @@ var SWITCH_LABELS = {
|
|
|
2163
2163
|
}
|
|
2164
2164
|
};
|
|
2165
2165
|
|
|
2166
|
+
// src/transforms/legacyLabelDefaults.ts
|
|
2167
|
+
var LEGACY_LABEL_DEFAULTS = {
|
|
2168
|
+
/** The banner's RTE default, compared by its plain text. */
|
|
2169
|
+
addedToCartMessage: ["{{quantity}} {{product_title}} successfully added to cart!"],
|
|
2170
|
+
/** Offers template; the Recommended template stores the bare `Add`. */
|
|
2171
|
+
addToCart: ["Add {{quantity}} \u2022 {{total}}", "Add"],
|
|
2172
|
+
/** Line-item editor template, then the base template's `cartSwitchToOnetime` (the offer card's one-time label). */
|
|
2173
|
+
switchToOneTimePurchase: ["Downgrade to One-time", "One-time purchase"],
|
|
2174
|
+
/** Line-item editor template; the offers template's one upsell label fills both upsell slots. */
|
|
2175
|
+
switchToSubscriptionNoDiscount: [
|
|
2176
|
+
"Upgrade to Subscription",
|
|
2177
|
+
"Upgrade to Subscription and Save {{subscription_discount}}%"
|
|
2178
|
+
],
|
|
2179
|
+
/** Line-item editor template, then the offers template. */
|
|
2180
|
+
switchToSubscriptionWithDiscount: [
|
|
2181
|
+
"Upgrade to Subscription & Save {{subscription_discount}}%",
|
|
2182
|
+
"Upgrade to Subscription and Save {{subscription_discount}}%"
|
|
2183
|
+
]
|
|
2184
|
+
};
|
|
2185
|
+
|
|
2166
2186
|
// src/transforms/localizedContent.ts
|
|
2167
|
-
var
|
|
2187
|
+
var comparable = (label) => label.replace(/\s+/g, " ").trim().toLowerCase();
|
|
2188
|
+
var isDefaultLabel = (label, defaults, knownTokens = [], legacyDefaults = []) => {
|
|
2189
|
+
const candidates = [defaults.en, ...legacyDefaults];
|
|
2190
|
+
const target = comparable(normalizeTokens(label, knownTokens));
|
|
2191
|
+
return candidates.some((candidate) => comparable(normalizeTokens(candidate, knownTokens)) === target);
|
|
2192
|
+
};
|
|
2193
|
+
var localizedContent = (defaults, override, knownTokens = [], legacyDefaults = []) => {
|
|
2168
2194
|
const trimmed = normalizeTokens(stripContentBlockHtml(override ?? "").trim(), knownTokens);
|
|
2169
|
-
|
|
2195
|
+
if (!trimmed) return defaults;
|
|
2196
|
+
return isDefaultLabel(trimmed, defaults, knownTokens, legacyDefaults) ? { ...defaults, en: trimmed } : { en: trimmed };
|
|
2170
2197
|
};
|
|
2171
2198
|
|
|
2172
2199
|
// src/transforms/lineItemEditorV1/convertLineItemEditorToV2.ts
|
|
@@ -2187,7 +2214,8 @@ var convertLineItemEditorToV2 = ({ id, settings }) => {
|
|
|
2187
2214
|
content: localizedContent(
|
|
2188
2215
|
SWITCH_LABELS[buttonField],
|
|
2189
2216
|
switchToSubscription?.language?.[OVERRIDE_KEY[buttonField]],
|
|
2190
|
-
SWITCH_LABEL_TOKENS
|
|
2217
|
+
SWITCH_LABEL_TOKENS,
|
|
2218
|
+
LEGACY_LABEL_DEFAULTS[buttonField]
|
|
2191
2219
|
),
|
|
2192
2220
|
sectionType: "text"
|
|
2193
2221
|
}));
|
|
@@ -2978,6 +3006,14 @@ var convertPlaceholderToV2 = ({ id, settings }) => CABRootSection.parse({
|
|
|
2978
3006
|
// src/transforms/placeholderV1/types.ts
|
|
2979
3007
|
var isPlaceholderV1 = (data) => !!data && typeof data === "object" && data.type === WidgetType.placeholder;
|
|
2980
3008
|
|
|
3009
|
+
// src/cab/listOf.ts
|
|
3010
|
+
var listOf = (value) => Array.isArray(value) ? value.filter((item) => !!item) : [];
|
|
3011
|
+
|
|
3012
|
+
// src/cab/tiptapPlain.ts
|
|
3013
|
+
var tiptapPlainText = (doc) => listOf(doc?.content).map(
|
|
3014
|
+
(paragraph) => listOf(paragraph.content).map((node) => node.text ?? "").join("")
|
|
3015
|
+
).join(" ").trim();
|
|
3016
|
+
|
|
2981
3017
|
// src/transforms/productCard/earnedText.ts
|
|
2982
3018
|
var contentMutator = (effect, variable, operator) => ({
|
|
2983
3019
|
effect,
|
|
@@ -3048,7 +3084,12 @@ var subscriptionToggle = (productType, labels = {}) => {
|
|
|
3048
3084
|
if (productType !== "both" && productType !== "subscription") return [];
|
|
3049
3085
|
const slot = (buttonField, override) => ({
|
|
3050
3086
|
buttonField,
|
|
3051
|
-
content: localizedContent(
|
|
3087
|
+
content: localizedContent(
|
|
3088
|
+
SWITCH_LABELS[buttonField],
|
|
3089
|
+
override,
|
|
3090
|
+
SWITCH_LABEL_TOKENS2,
|
|
3091
|
+
LEGACY_LABEL_DEFAULTS[buttonField]
|
|
3092
|
+
),
|
|
3052
3093
|
sectionType: "text"
|
|
3053
3094
|
});
|
|
3054
3095
|
return [
|
|
@@ -3250,7 +3291,12 @@ var buildRevealButton = (settings) => revealsVariants(settings) ? [
|
|
|
3250
3291
|
var buildAddButton = (settings) => {
|
|
3251
3292
|
const slot = (buttonField, override) => ({
|
|
3252
3293
|
buttonField,
|
|
3253
|
-
content: localizedContent(
|
|
3294
|
+
content: localizedContent(
|
|
3295
|
+
OFFER_LABELS[buttonField],
|
|
3296
|
+
override,
|
|
3297
|
+
ADD_LABEL_TOKENS,
|
|
3298
|
+
LEGACY_LABEL_DEFAULTS[buttonField]
|
|
3299
|
+
),
|
|
3254
3300
|
sectionType: "text"
|
|
3255
3301
|
});
|
|
3256
3302
|
return {
|
|
@@ -3431,9 +3477,13 @@ var buildDiscountSection = (discount) => {
|
|
|
3431
3477
|
}
|
|
3432
3478
|
];
|
|
3433
3479
|
};
|
|
3480
|
+
var BANNER_MESSAGE_TOKENS = ["quantity", "productTitle"];
|
|
3434
3481
|
var bannerMessageContent = (message) => {
|
|
3435
|
-
const
|
|
3436
|
-
|
|
3482
|
+
const { addedToCartMessage } = OFFER_LABELS;
|
|
3483
|
+
const legacyDefaults = LEGACY_LABEL_DEFAULTS.addedToCartMessage;
|
|
3484
|
+
if (typeof message === "string" || !message)
|
|
3485
|
+
return localizedContent(addedToCartMessage, message, BANNER_MESSAGE_TOKENS, legacyDefaults);
|
|
3486
|
+
return isDefaultLabel(tiptapPlainText(message), addedToCartMessage, BANNER_MESSAGE_TOKENS, legacyDefaults) ? { ...addedToCartMessage, en: message } : { en: message };
|
|
3437
3487
|
};
|
|
3438
3488
|
var coerceIntegrations = (integrations) => Object.fromEntries(
|
|
3439
3489
|
Object.entries(integrations).map(([key, value]) => {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type OFFER_LABELS } from '../schema/widgets/checkout-and-beyond/offerLabels';
|
|
2
|
+
import { type SWITCH_LABELS } from '../schema/widgets/checkout-and-beyond/switchLabels';
|
|
3
|
+
/** The CAB label slots a v1 label can override; keying by them makes a typo'd slot a type error. */
|
|
4
|
+
type LabelSlot = keyof typeof OFFER_LABELS | keyof typeof SWITCH_LABELS;
|
|
5
|
+
/**
|
|
6
|
+
* The defaults the v1 checkout admin stores into a new widget's `language`, per CAB label slot — the
|
|
7
|
+
* admin-nextjs `shopify-checkout-extension/templates/widgetSettings*.ts` values, plus the base widget
|
|
8
|
+
* template (`templates/widgets/widgetSettings.ts`) that older checkout widgets were created from. A stored v1 label equal
|
|
9
|
+
* to one of these (or to the slot's CAB `en` default) is untouched template copy, not merchant copy, so
|
|
10
|
+
* `localizedContent` keeps the localized defaults for it instead of showing it to every language
|
|
11
|
+
* (REB-24836). Most differ from the CAB `en` default in wording, so the case-insensitive `en` comparison
|
|
12
|
+
* alone would miss them. Token spelling is canonicalized before comparing, so legacy snake_case is fine.
|
|
13
|
+
*/
|
|
14
|
+
export declare const LEGACY_LABEL_DEFAULTS: Readonly<Partial<Record<LabelSlot, readonly string[]>>>;
|
|
15
|
+
export {};
|
|
@@ -1,10 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a stored v1 label is untouched default copy rather than merchant copy: it equals the slot's
|
|
3
|
+
* CAB `en` default or one of the v1 admin's template defaults (`LEGACY_LABEL_DEFAULTS`), compared
|
|
4
|
+
* case- and whitespace-insensitively after both sides' token spelling is canonicalized.
|
|
5
|
+
*/
|
|
6
|
+
export declare const isDefaultLabel: (label: string, defaults: {
|
|
7
|
+
en: string;
|
|
8
|
+
}, knownTokens?: readonly string[], legacyDefaults?: readonly string[]) => boolean;
|
|
1
9
|
/**
|
|
2
10
|
* The v1 label-override policy shared by the offer-card and line-item-editor converters: a defined v1
|
|
3
|
-
* label ALWAYS passes through verbatim
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
11
|
+
* label ALWAYS passes through verbatim — existing widget language is never rewritten (product owner,
|
|
12
|
+
* 2026-07-02); blank/whitespace falls back to the full default locale set (legacy `getLabelWithFallback`
|
|
13
|
+
* parity). HTML the merchant typed into a label is stripped first — `CABTextSection.content` rejects
|
|
14
|
+
* tag-shaped strings at parse, so a raw `<b>`-style label would otherwise 500 the whole widget.
|
|
15
|
+
*
|
|
16
|
+
* A label the merchant changed is emitted `en`-only, so `selectLanguage` shows it to EVERY buyer language
|
|
17
|
+
* — legacy rendered the merchant's label whatever the checkout language, and overlaying just `en` let the
|
|
18
|
+
* localized defaults beat it for non-English buyers (REB-24836: a Swedish "Köp" rendered as "Lägg i
|
|
19
|
+
* varukorgen"). A label that is still default copy (`isDefaultLabel`, given the slot's
|
|
20
|
+
* `LEGACY_LABEL_DEFAULTS`) keeps the localized defaults, with its own wording as `en`.
|
|
8
21
|
*
|
|
9
22
|
* `knownTokens` canonicalizes legacy token GRAMMAR in the stored label (single-brace `{price}`,
|
|
10
23
|
* case `{{Total}}`, snake `{subscription_discount}`, internal spaces → `{{camelCase}}`) so the strict
|
|
@@ -13,4 +26,8 @@
|
|
|
13
26
|
* This preserves the merchant's WORDING (only the token spelling is normalized), distinct from the
|
|
14
27
|
* verbatim-label policy above.
|
|
15
28
|
*/
|
|
16
|
-
export declare const localizedContent: (defaults: Record<string, string
|
|
29
|
+
export declare const localizedContent: (defaults: Record<string, string> & {
|
|
30
|
+
en: string;
|
|
31
|
+
}, override: string | undefined, knownTokens?: readonly string[], legacyDefaults?: readonly string[]) => Record<string, string> & {
|
|
32
|
+
en: string;
|
|
33
|
+
};
|
|
@@ -18,7 +18,9 @@ export declare const styledCopy: (text: string, look: Look) => {
|
|
|
18
18
|
type: string;
|
|
19
19
|
};
|
|
20
20
|
/** Merchant copy over its English default: blank falls back, markup is stripped (the `localizedContent` policy). */
|
|
21
|
-
export declare const merchantLabel: (value: string | undefined, fallback: string) => Record<string, string
|
|
21
|
+
export declare const merchantLabel: (value: string | undefined, fallback: string) => Record<string, string> & {
|
|
22
|
+
en: string;
|
|
23
|
+
};
|
|
22
24
|
export type EarnedRow = {
|
|
23
25
|
/** Copy after the value in its own cell (legacy "on every Delivery", "(included)"). */
|
|
24
26
|
after?: unknown;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebuy/rebuy",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.44.1",
|
|
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.",
|