@rebuy/rebuy 3.47.0 → 3.48.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/gwp/index.cjs +3 -3
- package/dist/gwp/index.mjs +3 -3
- package/dist/index.cjs +31 -25
- package/dist/index.mjs +31 -25
- package/dist/server/index.cjs +152 -121
- package/dist/server/index.mjs +148 -117
- package/dist/transforms/index.cjs +144 -113
- package/dist/transforms/index.mjs +144 -113
- package/dist/transforms/postPurchase/convertPayButtonBlock.d.ts +6 -2
- package/dist/transforms/postPurchase/convertProductInformation.d.ts +2 -1
- package/dist/transforms/postPurchase/productCardPay.d.ts +24 -0
- package/dist/transforms/postPurchase/productCardSettings.d.ts +1 -0
- package/dist/transforms/productCard/addToOrderButton.d.ts +22 -0
- package/package.json +1 -1
package/dist/gwp/index.cjs
CHANGED
|
@@ -37,9 +37,9 @@ var getValidGwpProductIds = (matchedRules = []) => new Set(
|
|
|
37
37
|
|
|
38
38
|
// src/gwp/hasUnsupportedRuleTypes.ts
|
|
39
39
|
var UNSUPPORTED_RULE_TYPES = ["url", "order_tag"];
|
|
40
|
-
var
|
|
41
|
-
|
|
42
|
-
);
|
|
40
|
+
var UNSUPPORTED_RULE_TYPE_PREFIX = "geolocation_";
|
|
41
|
+
var isUnsupportedType = (type = "") => UNSUPPORTED_RULE_TYPES.includes(type) || type.startsWith(UNSUPPORTED_RULE_TYPE_PREFIX);
|
|
42
|
+
var ruleHasUnsupportedType = (rule) => (rule.logic ?? []).some((group) => (group.rules ?? []).some((item) => isUnsupportedType(item.type)));
|
|
43
43
|
var hasUnsupportedRuleTypes = (metadata) => [...metadata?.matchedRules ?? [], ...metadata?.unmatchedRules ?? []].some(ruleHasUnsupportedType);
|
|
44
44
|
|
|
45
45
|
// src/gwp/isConfirmedRuleMiss.ts
|
package/dist/gwp/index.mjs
CHANGED
|
@@ -5,9 +5,9 @@ var getValidGwpProductIds = (matchedRules = []) => new Set(
|
|
|
5
5
|
|
|
6
6
|
// src/gwp/hasUnsupportedRuleTypes.ts
|
|
7
7
|
var UNSUPPORTED_RULE_TYPES = ["url", "order_tag"];
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
);
|
|
8
|
+
var UNSUPPORTED_RULE_TYPE_PREFIX = "geolocation_";
|
|
9
|
+
var isUnsupportedType = (type = "") => UNSUPPORTED_RULE_TYPES.includes(type) || type.startsWith(UNSUPPORTED_RULE_TYPE_PREFIX);
|
|
10
|
+
var ruleHasUnsupportedType = (rule) => (rule.logic ?? []).some((group) => (group.rules ?? []).some((item) => isUnsupportedType(item.type)));
|
|
11
11
|
var hasUnsupportedRuleTypes = (metadata) => [...metadata?.matchedRules ?? [], ...metadata?.unmatchedRules ?? []].some(ruleHasUnsupportedType);
|
|
12
12
|
|
|
13
13
|
// src/gwp/isConfirmedRuleMiss.ts
|
package/dist/index.cjs
CHANGED
|
@@ -6157,6 +6157,20 @@ var tiptapPlainText = (doc) => listOf(doc?.content).map(
|
|
|
6157
6157
|
(paragraph) => listOf(paragraph.content).map((node) => node.text ?? "").join("")
|
|
6158
6158
|
).join(" ").trim();
|
|
6159
6159
|
|
|
6160
|
+
// src/transforms/productCard/addToOrderButton.ts
|
|
6161
|
+
var labelSlot = (buttonField, defaults, override, knownTokens = [], legacyDefaults = []) => ({
|
|
6162
|
+
buttonField,
|
|
6163
|
+
content: localizedContent(defaults, override, knownTokens, legacyDefaults),
|
|
6164
|
+
sectionType: "text"
|
|
6165
|
+
});
|
|
6166
|
+
var addToOrderButton = (buttonStyle, sections, extra = {}) => ({
|
|
6167
|
+
action: "addToOrder",
|
|
6168
|
+
buttonStyle,
|
|
6169
|
+
sections,
|
|
6170
|
+
sectionType: "button",
|
|
6171
|
+
...extra
|
|
6172
|
+
});
|
|
6173
|
+
|
|
6160
6174
|
// src/transforms/productCard/earnedText.ts
|
|
6161
6175
|
var contentMutator = (effect, variable, operator) => ({
|
|
6162
6176
|
effect,
|
|
@@ -6225,16 +6239,13 @@ var quantitySection = ({ errorMessages, inputType, maxValue, minValue, name }) =
|
|
|
6225
6239
|
var SWITCH_LABEL_TOKENS = ["subscriptionDiscount", "frequency", "interval"];
|
|
6226
6240
|
var subscriptionToggle = (productType, labels = {}) => {
|
|
6227
6241
|
if (productType !== "both" && productType !== "subscription") return [];
|
|
6228
|
-
const slot = (buttonField, override) => (
|
|
6242
|
+
const slot = (buttonField, override) => labelSlot(
|
|
6229
6243
|
buttonField,
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
),
|
|
6236
|
-
sectionType: "text"
|
|
6237
|
-
});
|
|
6244
|
+
SWITCH_LABELS[buttonField],
|
|
6245
|
+
override,
|
|
6246
|
+
SWITCH_LABEL_TOKENS,
|
|
6247
|
+
LEGACY_LABEL_DEFAULTS[buttonField]
|
|
6248
|
+
);
|
|
6238
6249
|
return [
|
|
6239
6250
|
{
|
|
6240
6251
|
action: "switchToSubscription",
|
|
@@ -6433,20 +6444,16 @@ var buildRevealButton = (settings) => revealsVariants(settings) ? [
|
|
|
6433
6444
|
}
|
|
6434
6445
|
] : [];
|
|
6435
6446
|
var buildAddButton = (settings) => {
|
|
6436
|
-
const slot = (buttonField, override) => (
|
|
6447
|
+
const slot = (buttonField, override) => labelSlot(
|
|
6437
6448
|
buttonField,
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
return {
|
|
6447
|
-
action: "addToOrder",
|
|
6448
|
-
buttonStyle: buttonKind(settings),
|
|
6449
|
-
sections: [
|
|
6449
|
+
OFFER_LABELS[buttonField],
|
|
6450
|
+
override,
|
|
6451
|
+
ADD_LABEL_TOKENS,
|
|
6452
|
+
LEGACY_LABEL_DEFAULTS[buttonField]
|
|
6453
|
+
);
|
|
6454
|
+
return addToOrderButton(
|
|
6455
|
+
buttonKind(settings),
|
|
6456
|
+
[
|
|
6450
6457
|
slot("addToCart", settings.language?.addToCart),
|
|
6451
6458
|
slot("addingToCart", settings.language?.addingToCart),
|
|
6452
6459
|
slot("addedToCart", settings.language?.addedToCart),
|
|
@@ -6454,9 +6461,8 @@ var buildAddButton = (settings) => {
|
|
|
6454
6461
|
// Off-checkout Buy Now: the label the button shows once it links to the created checkout.
|
|
6455
6462
|
slot("redirectToCheckout", settings.language?.redirectToCheckout)
|
|
6456
6463
|
],
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
};
|
|
6464
|
+
revealsVariants(settings) ? { visibility: { variable: SHOW_VARIANTS, visibleWhen: true } } : {}
|
|
6465
|
+
);
|
|
6460
6466
|
};
|
|
6461
6467
|
var buildOfferCard = (settings, horizontal) => {
|
|
6462
6468
|
const image = buildImage(settings);
|
package/dist/index.mjs
CHANGED
|
@@ -5686,6 +5686,20 @@ var tiptapPlainText = (doc) => listOf(doc?.content).map(
|
|
|
5686
5686
|
(paragraph) => listOf(paragraph.content).map((node) => node.text ?? "").join("")
|
|
5687
5687
|
).join(" ").trim();
|
|
5688
5688
|
|
|
5689
|
+
// src/transforms/productCard/addToOrderButton.ts
|
|
5690
|
+
var labelSlot = (buttonField, defaults, override, knownTokens = [], legacyDefaults = []) => ({
|
|
5691
|
+
buttonField,
|
|
5692
|
+
content: localizedContent(defaults, override, knownTokens, legacyDefaults),
|
|
5693
|
+
sectionType: "text"
|
|
5694
|
+
});
|
|
5695
|
+
var addToOrderButton = (buttonStyle, sections, extra = {}) => ({
|
|
5696
|
+
action: "addToOrder",
|
|
5697
|
+
buttonStyle,
|
|
5698
|
+
sections,
|
|
5699
|
+
sectionType: "button",
|
|
5700
|
+
...extra
|
|
5701
|
+
});
|
|
5702
|
+
|
|
5689
5703
|
// src/transforms/productCard/earnedText.ts
|
|
5690
5704
|
var contentMutator = (effect, variable, operator) => ({
|
|
5691
5705
|
effect,
|
|
@@ -5754,16 +5768,13 @@ var quantitySection = ({ errorMessages, inputType, maxValue, minValue, name }) =
|
|
|
5754
5768
|
var SWITCH_LABEL_TOKENS = ["subscriptionDiscount", "frequency", "interval"];
|
|
5755
5769
|
var subscriptionToggle = (productType, labels = {}) => {
|
|
5756
5770
|
if (productType !== "both" && productType !== "subscription") return [];
|
|
5757
|
-
const slot = (buttonField, override) => (
|
|
5771
|
+
const slot = (buttonField, override) => labelSlot(
|
|
5758
5772
|
buttonField,
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
),
|
|
5765
|
-
sectionType: "text"
|
|
5766
|
-
});
|
|
5773
|
+
SWITCH_LABELS[buttonField],
|
|
5774
|
+
override,
|
|
5775
|
+
SWITCH_LABEL_TOKENS,
|
|
5776
|
+
LEGACY_LABEL_DEFAULTS[buttonField]
|
|
5777
|
+
);
|
|
5767
5778
|
return [
|
|
5768
5779
|
{
|
|
5769
5780
|
action: "switchToSubscription",
|
|
@@ -5962,20 +5973,16 @@ var buildRevealButton = (settings) => revealsVariants(settings) ? [
|
|
|
5962
5973
|
}
|
|
5963
5974
|
] : [];
|
|
5964
5975
|
var buildAddButton = (settings) => {
|
|
5965
|
-
const slot = (buttonField, override) => (
|
|
5976
|
+
const slot = (buttonField, override) => labelSlot(
|
|
5966
5977
|
buttonField,
|
|
5967
|
-
|
|
5968
|
-
|
|
5969
|
-
|
|
5970
|
-
|
|
5971
|
-
|
|
5972
|
-
|
|
5973
|
-
|
|
5974
|
-
|
|
5975
|
-
return {
|
|
5976
|
-
action: "addToOrder",
|
|
5977
|
-
buttonStyle: buttonKind(settings),
|
|
5978
|
-
sections: [
|
|
5978
|
+
OFFER_LABELS[buttonField],
|
|
5979
|
+
override,
|
|
5980
|
+
ADD_LABEL_TOKENS,
|
|
5981
|
+
LEGACY_LABEL_DEFAULTS[buttonField]
|
|
5982
|
+
);
|
|
5983
|
+
return addToOrderButton(
|
|
5984
|
+
buttonKind(settings),
|
|
5985
|
+
[
|
|
5979
5986
|
slot("addToCart", settings.language?.addToCart),
|
|
5980
5987
|
slot("addingToCart", settings.language?.addingToCart),
|
|
5981
5988
|
slot("addedToCart", settings.language?.addedToCart),
|
|
@@ -5983,9 +5990,8 @@ var buildAddButton = (settings) => {
|
|
|
5983
5990
|
// Off-checkout Buy Now: the label the button shows once it links to the created checkout.
|
|
5984
5991
|
slot("redirectToCheckout", settings.language?.redirectToCheckout)
|
|
5985
5992
|
],
|
|
5986
|
-
|
|
5987
|
-
|
|
5988
|
-
};
|
|
5993
|
+
revealsVariants(settings) ? { visibility: { variable: SHOW_VARIANTS, visibleWhen: true } } : {}
|
|
5994
|
+
);
|
|
5989
5995
|
};
|
|
5990
5996
|
var buildOfferCard = (settings, horizontal) => {
|
|
5991
5997
|
const image = buildImage(settings);
|
package/dist/server/index.cjs
CHANGED
|
@@ -71,7 +71,7 @@ __export(server_exports, {
|
|
|
71
71
|
module.exports = __toCommonJS(server_exports);
|
|
72
72
|
|
|
73
73
|
// src/server/dataSourceResults.ts
|
|
74
|
-
var
|
|
74
|
+
var import_es_toolkit8 = require("es-toolkit");
|
|
75
75
|
|
|
76
76
|
// src/gwp/getValidGwpProductIds.ts
|
|
77
77
|
var getValidGwpProductIds = (matchedRules = []) => new Set(
|
|
@@ -80,9 +80,9 @@ var getValidGwpProductIds = (matchedRules = []) => new Set(
|
|
|
80
80
|
|
|
81
81
|
// src/gwp/hasUnsupportedRuleTypes.ts
|
|
82
82
|
var UNSUPPORTED_RULE_TYPES = ["url", "order_tag"];
|
|
83
|
-
var
|
|
84
|
-
|
|
85
|
-
);
|
|
83
|
+
var UNSUPPORTED_RULE_TYPE_PREFIX = "geolocation_";
|
|
84
|
+
var isUnsupportedType = (type = "") => UNSUPPORTED_RULE_TYPES.includes(type) || type.startsWith(UNSUPPORTED_RULE_TYPE_PREFIX);
|
|
85
|
+
var ruleHasUnsupportedType = (rule) => (rule.logic ?? []).some((group) => (group.rules ?? []).some((item) => isUnsupportedType(item.type)));
|
|
86
86
|
var hasUnsupportedRuleTypes = (metadata) => [...metadata?.matchedRules ?? [], ...metadata?.unmatchedRules ?? []].some(ruleHasUnsupportedType);
|
|
87
87
|
|
|
88
88
|
// src/gwp/isConfirmedRuleMiss.ts
|
|
@@ -3300,6 +3300,20 @@ var tiptapPlainText = (doc) => listOf(doc?.content).map(
|
|
|
3300
3300
|
(paragraph) => listOf(paragraph.content).map((node) => node.text ?? "").join("")
|
|
3301
3301
|
).join(" ").trim();
|
|
3302
3302
|
|
|
3303
|
+
// src/transforms/productCard/addToOrderButton.ts
|
|
3304
|
+
var labelSlot = (buttonField, defaults, override, knownTokens = [], legacyDefaults = []) => ({
|
|
3305
|
+
buttonField,
|
|
3306
|
+
content: localizedContent(defaults, override, knownTokens, legacyDefaults),
|
|
3307
|
+
sectionType: "text"
|
|
3308
|
+
});
|
|
3309
|
+
var addToOrderButton = (buttonStyle, sections, extra = {}) => ({
|
|
3310
|
+
action: "addToOrder",
|
|
3311
|
+
buttonStyle,
|
|
3312
|
+
sections,
|
|
3313
|
+
sectionType: "button",
|
|
3314
|
+
...extra
|
|
3315
|
+
});
|
|
3316
|
+
|
|
3303
3317
|
// src/transforms/productCard/earnedText.ts
|
|
3304
3318
|
var contentMutator = (effect, variable, operator) => ({
|
|
3305
3319
|
effect,
|
|
@@ -3368,16 +3382,13 @@ var quantitySection = ({ errorMessages, inputType, maxValue, minValue, name }) =
|
|
|
3368
3382
|
var SWITCH_LABEL_TOKENS2 = ["subscriptionDiscount", "frequency", "interval"];
|
|
3369
3383
|
var subscriptionToggle = (productType, labels = {}) => {
|
|
3370
3384
|
if (productType !== "both" && productType !== "subscription") return [];
|
|
3371
|
-
const slot = (buttonField, override) => (
|
|
3385
|
+
const slot = (buttonField, override) => labelSlot(
|
|
3372
3386
|
buttonField,
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
),
|
|
3379
|
-
sectionType: "text"
|
|
3380
|
-
});
|
|
3387
|
+
SWITCH_LABELS[buttonField],
|
|
3388
|
+
override,
|
|
3389
|
+
SWITCH_LABEL_TOKENS2,
|
|
3390
|
+
LEGACY_LABEL_DEFAULTS[buttonField]
|
|
3391
|
+
);
|
|
3381
3392
|
return [
|
|
3382
3393
|
{
|
|
3383
3394
|
action: "switchToSubscription",
|
|
@@ -3576,20 +3587,16 @@ var buildRevealButton = (settings) => revealsVariants(settings) ? [
|
|
|
3576
3587
|
}
|
|
3577
3588
|
] : [];
|
|
3578
3589
|
var buildAddButton = (settings) => {
|
|
3579
|
-
const slot = (buttonField, override) => (
|
|
3590
|
+
const slot = (buttonField, override) => labelSlot(
|
|
3580
3591
|
buttonField,
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
return {
|
|
3590
|
-
action: "addToOrder",
|
|
3591
|
-
buttonStyle: buttonKind(settings),
|
|
3592
|
-
sections: [
|
|
3592
|
+
OFFER_LABELS[buttonField],
|
|
3593
|
+
override,
|
|
3594
|
+
ADD_LABEL_TOKENS,
|
|
3595
|
+
LEGACY_LABEL_DEFAULTS[buttonField]
|
|
3596
|
+
);
|
|
3597
|
+
return addToOrderButton(
|
|
3598
|
+
buttonKind(settings),
|
|
3599
|
+
[
|
|
3593
3600
|
slot("addToCart", settings.language?.addToCart),
|
|
3594
3601
|
slot("addingToCart", settings.language?.addingToCart),
|
|
3595
3602
|
slot("addedToCart", settings.language?.addedToCart),
|
|
@@ -3597,9 +3604,8 @@ var buildAddButton = (settings) => {
|
|
|
3597
3604
|
// Off-checkout Buy Now: the label the button shows once it links to the created checkout.
|
|
3598
3605
|
slot("redirectToCheckout", settings.language?.redirectToCheckout)
|
|
3599
3606
|
],
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
};
|
|
3607
|
+
revealsVariants(settings) ? { visibility: { variable: SHOW_VARIANTS, visibleWhen: true } } : {}
|
|
3608
|
+
);
|
|
3603
3609
|
};
|
|
3604
3610
|
var buildOfferCard = (settings, horizontal) => {
|
|
3605
3611
|
const image = buildImage(settings);
|
|
@@ -4280,95 +4286,28 @@ var convertImageContentBlock = (raw, report) => {
|
|
|
4280
4286
|
return [CABLayoutSection.parse({ frame: "offer-content", sections: [inner], spacing: "none" })];
|
|
4281
4287
|
};
|
|
4282
4288
|
|
|
4283
|
-
// src/transforms/postPurchase/
|
|
4284
|
-
var
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
const {
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
CABButtonSection.parse({
|
|
4302
|
-
action: "addToOrder",
|
|
4303
|
-
sections: [text2.data]
|
|
4304
|
-
})
|
|
4305
|
-
],
|
|
4306
|
-
width: styles2.buttonWidth
|
|
4307
|
-
})
|
|
4308
|
-
];
|
|
4309
|
-
};
|
|
4310
|
-
|
|
4311
|
-
// src/transforms/postPurchase/productCardControls.ts
|
|
4312
|
-
var SELECT_VARIANT = { en: "Select Variant" };
|
|
4313
|
-
var PRODUCT_GROUP = { en: "Option" };
|
|
4314
|
-
var groupSelector = { label: PRODUCT_GROUP, sectionType: "variants", selector: "menu", variantMode: "productGroup" };
|
|
4315
|
-
var variantSelector = ({ productOptions }) => {
|
|
4316
|
-
if (!productOptions.showVariantSelectors) return [];
|
|
4317
|
-
const single = productOptions.variantSelectorDisplayMode === "single";
|
|
4318
|
-
return [
|
|
4319
|
-
{
|
|
4320
|
-
hideOutOfStockVariants: single || productOptions.hideOutOfStockVariants,
|
|
4321
|
-
...single && { label: SELECT_VARIANT },
|
|
4322
|
-
sectionType: "variants",
|
|
4323
|
-
selector: "menu",
|
|
4324
|
-
variantMode: single ? "single" : "multiple"
|
|
4325
|
-
}
|
|
4326
|
-
];
|
|
4327
|
-
};
|
|
4328
|
-
var quantity = ({ language: language3, quantityInputs: quantityInputs2 }) => quantityInputs2.enabled ? [
|
|
4329
|
-
quantitySection({
|
|
4330
|
-
maxValue: quantityInputs2.maxValue,
|
|
4331
|
-
minValue: quantityInputs2.minValue,
|
|
4332
|
-
name: language3.global.quantity.trim()
|
|
4333
|
-
})
|
|
4334
|
-
] : [];
|
|
4335
|
-
var productCardControls = (settings) => [
|
|
4336
|
-
...subscriptionToggle(settings.productType, { frequencyLabel: "planName" }),
|
|
4337
|
-
groupSelector,
|
|
4338
|
-
...variantSelector(settings),
|
|
4339
|
-
...quantity(settings)
|
|
4289
|
+
// src/transforms/postPurchase/productCardPay.ts
|
|
4290
|
+
var import_es_toolkit6 = require("es-toolkit");
|
|
4291
|
+
var PAY_NOW = { en: "Pay Now" };
|
|
4292
|
+
var DECLINE_THIS_OFFER = { en: "Decline this offer" };
|
|
4293
|
+
var NOT_AVAILABLE_DEFAULTS = ["Not available"];
|
|
4294
|
+
var soldOutSlot = ({ language: language3 }) => labelSlot("soldOut", OFFER_LABELS.soldOut, language3.global.notAvailable, [], NOT_AVAILABLE_DEFAULTS);
|
|
4295
|
+
var productCardPay = (settings) => {
|
|
4296
|
+
const payNow = labelSlot("payNow", PAY_NOW, settings.language.global.payNow);
|
|
4297
|
+
const priced = settings.language.displayCtaPrice ? { ...payNow, content: (0, import_es_toolkit6.mapValues)(payNow.content, (label2) => `${label2} \xB7 {{total}}`) } : payNow;
|
|
4298
|
+
return [addToOrderButton("primary", [priced, soldOutSlot(settings)])];
|
|
4299
|
+
};
|
|
4300
|
+
var productCardDecline = ({ language: language3 }) => [
|
|
4301
|
+
{
|
|
4302
|
+
action: "declineOffer",
|
|
4303
|
+
buttonStyle: "secondary",
|
|
4304
|
+
sections: [labelSlot("declineOffer", DECLINE_THIS_OFFER, language3.global.declineThisOffer)],
|
|
4305
|
+
sectionType: "button"
|
|
4306
|
+
}
|
|
4340
4307
|
];
|
|
4341
4308
|
|
|
4342
|
-
// src/transforms/postPurchase/productCardRows.ts
|
|
4343
|
-
var styledCopy = (text2, look) => ({
|
|
4344
|
-
content: [{ content: [{ marks: [{ attrs: look, type: "textStyle" }], text: text2, type: "text" }], type: "paragraph" }],
|
|
4345
|
-
type: "doc"
|
|
4346
|
-
});
|
|
4347
|
-
var merchantLabel = (value, fallback) => localizedContent({ en: fallback }, value);
|
|
4348
|
-
var boundText = (variable, content) => ({
|
|
4349
|
-
content,
|
|
4350
|
-
sectionType: "text",
|
|
4351
|
-
visibility: shownWhile(variable)
|
|
4352
|
-
});
|
|
4353
|
-
var earnedRow = ({ after, columns, label: label2, look, spacing, token, variable }) => {
|
|
4354
|
-
const styled2 = (text2) => look ? styledCopy(text2, look) : text2;
|
|
4355
|
-
const value = earnedText(variable, styled2(token));
|
|
4356
|
-
return {
|
|
4357
|
-
direction: "grid",
|
|
4358
|
-
grid: { columns, rows: ["auto"] },
|
|
4359
|
-
sections: [
|
|
4360
|
-
boundText(variable, look ? { en: styled2(String(label2.en)) } : label2),
|
|
4361
|
-
value,
|
|
4362
|
-
...after === void 0 ? [] : [boundText(variable, { en: styled2(String(after)) })]
|
|
4363
|
-
],
|
|
4364
|
-
sectionType: "layout",
|
|
4365
|
-
...spacing && { spacing }
|
|
4366
|
-
};
|
|
4367
|
-
};
|
|
4368
|
-
var earnedVariables = (names) => names.map((name) => ({ defaultValue: false, name }));
|
|
4369
|
-
|
|
4370
4309
|
// src/transforms/postPurchase/productCardSettings.ts
|
|
4371
|
-
var
|
|
4310
|
+
var import_es_toolkit7 = require("es-toolkit");
|
|
4372
4311
|
var import_zod38 = require("zod");
|
|
4373
4312
|
|
|
4374
4313
|
// src/schema/widgets/post-purchase-offer/postPurchaseSettings.ts
|
|
@@ -4560,9 +4499,12 @@ var PostPurchaseSettings = import_zod37.z.object({
|
|
|
4560
4499
|
// src/transforms/postPurchase/productCardSettings.ts
|
|
4561
4500
|
var { shape } = PostPurchaseSettings;
|
|
4562
4501
|
var Labels = import_zod38.z.object(
|
|
4563
|
-
(0,
|
|
4502
|
+
(0, import_es_toolkit7.mapValues)(shape.language.shape.global.unwrap().unwrap().shape, (label2) => label2.catch(() => label2.parse(void 0)))
|
|
4564
4503
|
);
|
|
4565
|
-
var Language = import_zod38.z.object({
|
|
4504
|
+
var Language = import_zod38.z.object({
|
|
4505
|
+
displayCtaPrice: shape.language.shape.displayCtaPrice.catch(true),
|
|
4506
|
+
global: Labels.catch(() => Labels.parse({}))
|
|
4507
|
+
});
|
|
4566
4508
|
var Fields = import_zod38.z.object({
|
|
4567
4509
|
discount: shape.discount.catch(() => shape.discount.parse({})),
|
|
4568
4510
|
language: Language.catch(() => Language.parse({})),
|
|
@@ -4576,6 +4518,93 @@ var Fields = import_zod38.z.object({
|
|
|
4576
4518
|
var ProductCardSettings = Fields.catch(() => Fields.parse({}));
|
|
4577
4519
|
var sellsSubscription = ({ productType, upgradeToSubscription }) => productType !== "one-time" || upgradeToSubscription.allow;
|
|
4578
4520
|
|
|
4521
|
+
// src/transforms/postPurchase/convertPayButtonBlock.ts
|
|
4522
|
+
var convertPayButtonBlock = (raw, report, widgetSettings) => {
|
|
4523
|
+
const omit = () => {
|
|
4524
|
+
report?.({ detail: "Unreadable post-purchase Pay block", kind: "section" });
|
|
4525
|
+
return [];
|
|
4526
|
+
};
|
|
4527
|
+
const parsed = PayButtonBlock.safeParse(raw);
|
|
4528
|
+
if (!parsed.success) return omit();
|
|
4529
|
+
const { settings, styles: styles2 } = parsed.data;
|
|
4530
|
+
const label2 = settings.label ? `${settings.label} \xB7 {{total}}` : "{{total}}";
|
|
4531
|
+
const text2 = CABTextSection.safeParse({ content: { en: label2 } });
|
|
4532
|
+
if (!text2.success) return omit();
|
|
4533
|
+
return [
|
|
4534
|
+
CABLayoutSection.parse({
|
|
4535
|
+
alignment: { horizontal: "center" },
|
|
4536
|
+
direction: "grid",
|
|
4537
|
+
grid: { columns: ["100%"] },
|
|
4538
|
+
sections: [
|
|
4539
|
+
CABButtonSection.parse({
|
|
4540
|
+
action: "addToOrder",
|
|
4541
|
+
sections: [text2.data, soldOutSlot(ProductCardSettings.parse(widgetSettings ?? {}))]
|
|
4542
|
+
})
|
|
4543
|
+
],
|
|
4544
|
+
width: styles2.buttonWidth
|
|
4545
|
+
})
|
|
4546
|
+
];
|
|
4547
|
+
};
|
|
4548
|
+
|
|
4549
|
+
// src/transforms/postPurchase/productCardControls.ts
|
|
4550
|
+
var SELECT_VARIANT = { en: "Select Variant" };
|
|
4551
|
+
var PRODUCT_GROUP = { en: "Option" };
|
|
4552
|
+
var groupSelector = { label: PRODUCT_GROUP, sectionType: "variants", selector: "menu", variantMode: "productGroup" };
|
|
4553
|
+
var variantSelector = ({ productOptions }) => {
|
|
4554
|
+
if (!productOptions.showVariantSelectors) return [];
|
|
4555
|
+
const single = productOptions.variantSelectorDisplayMode === "single";
|
|
4556
|
+
return [
|
|
4557
|
+
{
|
|
4558
|
+
hideOutOfStockVariants: single || productOptions.hideOutOfStockVariants,
|
|
4559
|
+
...single && { label: SELECT_VARIANT },
|
|
4560
|
+
sectionType: "variants",
|
|
4561
|
+
selector: "menu",
|
|
4562
|
+
variantMode: single ? "single" : "multiple"
|
|
4563
|
+
}
|
|
4564
|
+
];
|
|
4565
|
+
};
|
|
4566
|
+
var quantity = ({ language: language3, quantityInputs: quantityInputs2 }) => quantityInputs2.enabled ? [
|
|
4567
|
+
quantitySection({
|
|
4568
|
+
maxValue: quantityInputs2.maxValue,
|
|
4569
|
+
minValue: quantityInputs2.minValue,
|
|
4570
|
+
name: language3.global.quantity.trim()
|
|
4571
|
+
})
|
|
4572
|
+
] : [];
|
|
4573
|
+
var productCardControls = (settings) => [
|
|
4574
|
+
...subscriptionToggle(settings.productType, { frequencyLabel: "planName" }),
|
|
4575
|
+
groupSelector,
|
|
4576
|
+
...variantSelector(settings),
|
|
4577
|
+
...quantity(settings)
|
|
4578
|
+
];
|
|
4579
|
+
|
|
4580
|
+
// src/transforms/postPurchase/productCardRows.ts
|
|
4581
|
+
var styledCopy = (text2, look) => ({
|
|
4582
|
+
content: [{ content: [{ marks: [{ attrs: look, type: "textStyle" }], text: text2, type: "text" }], type: "paragraph" }],
|
|
4583
|
+
type: "doc"
|
|
4584
|
+
});
|
|
4585
|
+
var merchantLabel = (value, fallback) => localizedContent({ en: fallback }, value);
|
|
4586
|
+
var boundText = (variable, content) => ({
|
|
4587
|
+
content,
|
|
4588
|
+
sectionType: "text",
|
|
4589
|
+
visibility: shownWhile(variable)
|
|
4590
|
+
});
|
|
4591
|
+
var earnedRow = ({ after, columns, label: label2, look, spacing, token, variable }) => {
|
|
4592
|
+
const styled2 = (text2) => look ? styledCopy(text2, look) : text2;
|
|
4593
|
+
const value = earnedText(variable, styled2(token));
|
|
4594
|
+
return {
|
|
4595
|
+
direction: "grid",
|
|
4596
|
+
grid: { columns, rows: ["auto"] },
|
|
4597
|
+
sections: [
|
|
4598
|
+
boundText(variable, look ? { en: styled2(String(label2.en)) } : label2),
|
|
4599
|
+
value,
|
|
4600
|
+
...after === void 0 ? [] : [boundText(variable, { en: styled2(String(after)) })]
|
|
4601
|
+
],
|
|
4602
|
+
sectionType: "layout",
|
|
4603
|
+
...spacing && { spacing }
|
|
4604
|
+
};
|
|
4605
|
+
};
|
|
4606
|
+
var earnedVariables = (names) => names.map((name) => ({ defaultValue: false, name }));
|
|
4607
|
+
|
|
4579
4608
|
// src/transforms/postPurchase/productCardCosts.ts
|
|
4580
4609
|
var COST_ROWS = [
|
|
4581
4610
|
["showSubtotal", "subtotal", "Subtotal", "hasSubtotal"],
|
|
@@ -4732,7 +4761,9 @@ var convertProductInformation = (raw, report, widgetSettings) => {
|
|
|
4732
4761
|
CABReviewsSection.parse({}),
|
|
4733
4762
|
CABTextSection.parse({ content: { en: "{{productDescription}}" } }),
|
|
4734
4763
|
...productCardControls(settings),
|
|
4735
|
-
...productCardCosts(settings)
|
|
4764
|
+
...productCardCosts(settings),
|
|
4765
|
+
...productCardPay(settings),
|
|
4766
|
+
...productCardDecline(settings)
|
|
4736
4767
|
]
|
|
4737
4768
|
})
|
|
4738
4769
|
],
|
|
@@ -5354,7 +5385,7 @@ var reportUnreadableVerdict = (metadata, report) => {
|
|
|
5354
5385
|
if (RuleVerdict.safeParse(metadata).success || isDefinitiveRuleAnswer(metadata)) return;
|
|
5355
5386
|
report?.({ detail: "rule verdict lacks readable custom.shouldShow", kind: "ruleVerdict" });
|
|
5356
5387
|
};
|
|
5357
|
-
var dedupeById = (products) => (0,
|
|
5388
|
+
var dedupeById = (products) => (0, import_es_toolkit8.uniqBy)(products, (product) => product.id);
|
|
5358
5389
|
var MAX_REQUEST_LINE_BYTES = 32e3;
|
|
5359
5390
|
var requestLineBytes = (path, search) => new TextEncoder().encode(`GET ${path}?${search} HTTP/1.1`).length;
|
|
5360
5391
|
var fetchDataSourceResults = async (input, ctx) => {
|
|
@@ -7971,7 +8002,7 @@ var preparePostPurchaseOfferPresentation = (widgetId, settings, response, report
|
|
|
7971
8002
|
};
|
|
7972
8003
|
|
|
7973
8004
|
// src/server/analytics.ts
|
|
7974
|
-
var
|
|
8005
|
+
var import_es_toolkit9 = require("es-toolkit");
|
|
7975
8006
|
|
|
7976
8007
|
// src/server/analyticsSegments.ts
|
|
7977
8008
|
var SEGMENT_BUCKETS = {
|
|
@@ -8090,7 +8121,7 @@ var postAnalyticsEvents = async (input, ctx) => {
|
|
|
8090
8121
|
const events = input.events.map((event) => translateAnalyticsEvent(event, input)).filter((event) => event !== null);
|
|
8091
8122
|
if (events.length === 0) return { accepted: 0 };
|
|
8092
8123
|
const { shop } = await fetchUserConfig({ shop: input.shop }, ctx);
|
|
8093
|
-
for (const batch of (0,
|
|
8124
|
+
for (const batch of (0, import_es_toolkit9.chunk)(events, MAX_ANALYTICS_EVENTS)) {
|
|
8094
8125
|
await ctx.fetchUpstream(
|
|
8095
8126
|
"/api/v2/analytics/event/bulk",
|
|
8096
8127
|
{},
|