@rebuy/rebuy 3.41.0 → 3.43.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 +971 -787
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +971 -787
- package/dist/pricing/index.cjs +58 -1
- package/dist/pricing/index.d.ts +2 -0
- package/dist/pricing/index.mjs +58 -1
- package/dist/pricing/postPurchaseDisplayFacts.d.ts +36 -0
- package/dist/pricing/postPurchaseDisplayPrice.d.ts +8 -0
- package/dist/pricing/postPurchaseReduction.d.ts +17 -0
- package/dist/schema/checkout-and-beyond/constants.cjs +4 -0
- package/dist/schema/checkout-and-beyond/constants.mjs +4 -0
- package/dist/schema/checkout-and-beyond/index.cjs +388 -374
- package/dist/schema/checkout-and-beyond/index.mjs +388 -374
- package/dist/schema/index.d.ts +2 -0
- package/dist/schema/postPurchaseAdmission.d.ts +33 -0
- package/dist/schema/postPurchaseDisplayPrice.d.ts +31 -0
- package/dist/schema/postPurchaseFollowups.d.ts +47 -0
- package/dist/schema/postPurchaseHealth.d.ts +5 -0
- package/dist/schema/postPurchasePlanCatalog.d.ts +2 -0
- package/dist/schema/postPurchaseProduct.d.ts +2 -0
- package/dist/schema/postPurchaseProductCollectionView.d.ts +62 -0
- package/dist/schema/postPurchaseProductView.d.ts +65 -0
- package/dist/schema/postPurchaseRecovery.d.ts +47 -0
- package/dist/schema/postPurchaseSubscriptionProduct.d.ts +2 -0
- package/dist/schema/postPurchaseUpgrade.d.ts +117 -0
- package/dist/schema/widget-data.cjs +452 -441
- package/dist/schema/widget-data.mjs +452 -441
- package/dist/schema/widgets/checkout-and-beyond/common.d.ts +14 -0
- package/dist/schema/widgets/checkout-and-beyond/image.d.ts +8 -0
- package/dist/schema/widgets/checkout-and-beyond/imageThumbnails.d.ts +13 -0
- package/dist/schema/widgets/checkout-and-beyond/index.d.ts +1 -0
- package/dist/schema/widgets/checkout-and-beyond/variants.d.ts +1 -0
- package/dist/server/index.cjs +1721 -1419
- package/dist/server/index.mjs +1707 -1405
- package/dist/server/postPurchasePlanCatalog.d.ts +4 -1
- package/dist/server/preparePostPurchaseAdmissionView.d.ts +53 -0
- package/dist/server/preparePostPurchaseCollectionGroup.d.ts +57 -0
- package/dist/server/preparePostPurchaseCollectionView.d.ts +53 -0
- package/dist/server/preparePostPurchaseGroupAdmissionView.d.ts +53 -0
- package/dist/server/preparePostPurchaseGroupDefault.d.ts +53 -0
- package/dist/server/preparePostPurchaseGroupView.d.ts +53 -0
- package/dist/server/preparePostPurchaseMemberView.d.ts +159 -0
- package/dist/server/preparePostPurchaseQuantityAdmissionView.d.ts +53 -0
- package/dist/server/preparePostPurchaseQuantityView.d.ts +53 -0
- package/dist/server/preparePostPurchaseSubscription.d.ts +1 -0
- package/dist/server/selectPostPurchaseChoice.d.ts +1 -0
- package/dist/transforms/index.cjs +980 -581
- package/dist/transforms/index.mjs +980 -581
- package/dist/transforms/postPurchase/convertProductInformation.d.ts +6 -2
- package/dist/transforms/postPurchase/productCardControls.d.ts +7 -0
- package/dist/transforms/postPurchase/productCardCosts.d.ts +3 -0
- package/dist/transforms/postPurchase/productCardPricing.d.ts +3 -0
- package/dist/transforms/postPurchase/productCardRows.d.ts +63 -0
- package/dist/transforms/postPurchase/productCardSettings.d.ts +103 -0
- package/dist/transforms/postPurchase/types.d.ts +2 -2
- package/dist/transforms/productCard/earnedText.d.ts +25 -0
- package/dist/transforms/productCard/priceText.d.ts +2 -0
- package/dist/transforms/productCard/quantitySection.d.ts +28 -0
- package/dist/transforms/productCard/subscriptionToggle.d.ts +18 -0
- package/package.json +1 -1
package/dist/server/index.cjs
CHANGED
|
@@ -70,7 +70,7 @@ __export(server_exports, {
|
|
|
70
70
|
module.exports = __toCommonJS(server_exports);
|
|
71
71
|
|
|
72
72
|
// src/server/dataSourceResults.ts
|
|
73
|
-
var
|
|
73
|
+
var import_es_toolkit7 = require("es-toolkit");
|
|
74
74
|
|
|
75
75
|
// src/gwp/getValidGwpProductIds.ts
|
|
76
76
|
var getValidGwpProductIds = (matchedRules = []) => new Set(
|
|
@@ -695,7 +695,7 @@ var CabUserConfig = import_zod6.z.object({
|
|
|
695
695
|
|
|
696
696
|
// src/schema/widgets/checkout-and-beyond/image.ts
|
|
697
697
|
var import_uuid13 = require("uuid");
|
|
698
|
-
var
|
|
698
|
+
var import_zod28 = require("zod");
|
|
699
699
|
|
|
700
700
|
// src/schema/widgets/checkout-and-beyond/common.ts
|
|
701
701
|
var freezeEnum = (values2) => Object.freeze(Object.fromEntries(values2.map((v) => [v, v])));
|
|
@@ -865,6 +865,8 @@ var variableTypes = ["boolean", "number", "text"];
|
|
|
865
865
|
var VariableType = freezeEnum(variableTypes);
|
|
866
866
|
var variantModes = ["multiple", "single"];
|
|
867
867
|
var VariantMode = freezeEnum(variantModes);
|
|
868
|
+
var variantsModes = [...variantModes, "productGroup"];
|
|
869
|
+
var VariantsMode = freezeEnum(variantsModes);
|
|
868
870
|
var variantSelectors = ["menu", "radio", "button"];
|
|
869
871
|
var VariantSelector = freezeEnum(variantSelectors);
|
|
870
872
|
var verticalAlignments = ["top", "middle", "bottom"];
|
|
@@ -981,6 +983,13 @@ var IconSize = freezeEnum(iconSizes);
|
|
|
981
983
|
var iconTones = ["auto", "critical", "custom", "info", "neutral", "success", "warning"];
|
|
982
984
|
var IconTone = freezeEnum(iconTones);
|
|
983
985
|
|
|
986
|
+
// src/schema/widgets/checkout-and-beyond/imageThumbnails.ts
|
|
987
|
+
var import_zod7 = require("zod");
|
|
988
|
+
var CABImageThumbnails = import_zod7.z.object({
|
|
989
|
+
limit: import_zod7.z.number().int().min(1).default(8),
|
|
990
|
+
perLine: import_zod7.z.number().int().min(1).max(8).default(4)
|
|
991
|
+
});
|
|
992
|
+
|
|
984
993
|
// src/schema/widgets/checkout-and-beyond/regex.ts
|
|
985
994
|
var DYNAMIC_TOKEN_REGEX = /^\{\{\s*[A-Za-z]+\s*\}\}$/;
|
|
986
995
|
var HEX_COLOR_REGEX = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
|
|
@@ -988,20 +997,20 @@ var ROOT_RELATIVE_PATH_REGEX = /^\/(?!\/)/;
|
|
|
988
997
|
var HTML_TAGS_REGEX = /<\/?[a-zA-Z][^>]*>/g;
|
|
989
998
|
|
|
990
999
|
// src/schema/widgets/checkout-and-beyond/shared.ts
|
|
991
|
-
var
|
|
1000
|
+
var import_zod27 = require("zod");
|
|
992
1001
|
|
|
993
1002
|
// src/schema/widgets/checkout-and-beyond/banner.ts
|
|
994
|
-
var
|
|
1003
|
+
var import_zod11 = require("zod");
|
|
995
1004
|
|
|
996
1005
|
// src/schema/widgets/checkout-and-beyond/layout.ts
|
|
997
1006
|
var import_uuid = require("uuid");
|
|
998
|
-
var
|
|
1007
|
+
var import_zod10 = require("zod");
|
|
999
1008
|
|
|
1000
1009
|
// src/schema/widgets/checkout-and-beyond/variables.ts
|
|
1001
|
-
var
|
|
1010
|
+
var import_zod9 = require("zod");
|
|
1002
1011
|
|
|
1003
1012
|
// src/schema/widgets/checkout-and-beyond/rule.ts
|
|
1004
|
-
var
|
|
1013
|
+
var import_zod8 = require("zod");
|
|
1005
1014
|
var ruleTypes = [
|
|
1006
1015
|
"cart",
|
|
1007
1016
|
"cart_count",
|
|
@@ -1020,7 +1029,7 @@ var ruleTypes = [
|
|
|
1020
1029
|
"product_type",
|
|
1021
1030
|
"product_vendor"
|
|
1022
1031
|
];
|
|
1023
|
-
var ruleType =
|
|
1032
|
+
var ruleType = import_zod8.z.enum(ruleTypes);
|
|
1024
1033
|
var RuleType = ruleType.enum;
|
|
1025
1034
|
var ruleOperators = [
|
|
1026
1035
|
"after",
|
|
@@ -1035,148 +1044,148 @@ var ruleOperators = [
|
|
|
1035
1044
|
"greater_than",
|
|
1036
1045
|
"less_than"
|
|
1037
1046
|
];
|
|
1038
|
-
var ruleOperator =
|
|
1047
|
+
var ruleOperator = import_zod8.z.enum(ruleOperators);
|
|
1039
1048
|
var RuleOperator = ruleOperator.enum;
|
|
1040
|
-
var RuleCondition =
|
|
1041
|
-
operator:
|
|
1042
|
-
products:
|
|
1043
|
-
type:
|
|
1044
|
-
value:
|
|
1045
|
-
});
|
|
1046
|
-
var RuleLogicBlock =
|
|
1047
|
-
rules:
|
|
1048
|
-
});
|
|
1049
|
-
var CABRulesetEntry =
|
|
1050
|
-
exitIfMatched:
|
|
1051
|
-
logic:
|
|
1052
|
-
output:
|
|
1053
|
-
|
|
1054
|
-
key:
|
|
1055
|
-
type:
|
|
1056
|
-
value:
|
|
1049
|
+
var RuleCondition = import_zod8.z.object({
|
|
1050
|
+
operator: import_zod8.z.enum(ruleOperators).default(RuleOperator.anything),
|
|
1051
|
+
products: import_zod8.z.union([import_zod8.z.array(import_zod8.z.unknown()), import_zod8.z.strictObject({}).transform(() => [])]).default(() => []),
|
|
1052
|
+
type: import_zod8.z.enum(ruleTypes).default(RuleType.cart_subtotal),
|
|
1053
|
+
value: import_zod8.z.coerce.string().default("")
|
|
1054
|
+
});
|
|
1055
|
+
var RuleLogicBlock = import_zod8.z.object({
|
|
1056
|
+
rules: import_zod8.z.array(RuleCondition).default(() => [])
|
|
1057
|
+
});
|
|
1058
|
+
var CABRulesetEntry = import_zod8.z.object({
|
|
1059
|
+
exitIfMatched: import_zod8.z.boolean().default(true),
|
|
1060
|
+
logic: import_zod8.z.array(RuleLogicBlock).default(() => []),
|
|
1061
|
+
output: import_zod8.z.array(
|
|
1062
|
+
import_zod8.z.object({
|
|
1063
|
+
key: import_zod8.z.string().default("should_show"),
|
|
1064
|
+
type: import_zod8.z.literal("data_json").default("data_json"),
|
|
1065
|
+
value: import_zod8.z.string().default("true")
|
|
1057
1066
|
})
|
|
1058
1067
|
).default(() => [{ key: "should_show", type: "data_json", value: "true" }])
|
|
1059
1068
|
});
|
|
1060
|
-
var CABRuleset =
|
|
1069
|
+
var CABRuleset = import_zod8.z.union([import_zod8.z.array(CABRulesetEntry), import_zod8.z.strictObject({}).transform(() => [])]).default(() => []);
|
|
1061
1070
|
|
|
1062
1071
|
// src/schema/widgets/checkout-and-beyond/variables.ts
|
|
1063
|
-
var variableEffect =
|
|
1064
|
-
var CABVariableSeed =
|
|
1065
|
-
dataSourceId:
|
|
1072
|
+
var variableEffect = import_zod9.z.enum(variableEffects);
|
|
1073
|
+
var CABVariableSeed = import_zod9.z.object({
|
|
1074
|
+
dataSourceId: import_zod9.z.number().nullable().default(null),
|
|
1066
1075
|
ruleset: CABRuleset
|
|
1067
1076
|
});
|
|
1068
|
-
var CABBooleanVariable =
|
|
1077
|
+
var CABBooleanVariable = import_zod9.z.object({
|
|
1069
1078
|
/**
|
|
1070
1079
|
* Holds until the first seed verdict lands (and forever, for unseeded variables). Omitted, it derives
|
|
1071
1080
|
* from seededness — `false` with a `seed` (visibility is EARNED), `true` without — via the transform
|
|
1072
1081
|
* below; a cross-field default has no `.default()` spelling. An explicit value always wins.
|
|
1073
1082
|
*/
|
|
1074
|
-
defaultValue:
|
|
1075
|
-
name:
|
|
1083
|
+
defaultValue: import_zod9.z.boolean().optional(),
|
|
1084
|
+
name: import_zod9.z.string().min(1),
|
|
1076
1085
|
seed: CABVariableSeed.optional(),
|
|
1077
1086
|
/** Defaulted so every stored declaration (all boolean before `text` existed) parses unchanged. */
|
|
1078
|
-
type:
|
|
1087
|
+
type: import_zod9.z.literal(VariableType.boolean).default(VariableType.boolean)
|
|
1079
1088
|
});
|
|
1080
|
-
var CABTextVariable =
|
|
1081
|
-
defaultValue:
|
|
1082
|
-
name:
|
|
1083
|
-
seed:
|
|
1084
|
-
type:
|
|
1089
|
+
var CABTextVariable = import_zod9.z.object({
|
|
1090
|
+
defaultValue: import_zod9.z.string(),
|
|
1091
|
+
name: import_zod9.z.string().min(1),
|
|
1092
|
+
seed: import_zod9.z.never().optional(),
|
|
1093
|
+
type: import_zod9.z.literal(VariableType.text)
|
|
1085
1094
|
});
|
|
1086
|
-
var CABNumberVariable =
|
|
1087
|
-
defaultValue:
|
|
1088
|
-
name:
|
|
1089
|
-
seed:
|
|
1090
|
-
type:
|
|
1095
|
+
var CABNumberVariable = import_zod9.z.object({
|
|
1096
|
+
defaultValue: import_zod9.z.number(),
|
|
1097
|
+
name: import_zod9.z.string().min(1),
|
|
1098
|
+
seed: import_zod9.z.never().optional(),
|
|
1099
|
+
type: import_zod9.z.literal(VariableType.number)
|
|
1091
1100
|
});
|
|
1092
|
-
var CABVariable =
|
|
1101
|
+
var CABVariable = import_zod9.z.union([CABTextVariable, CABNumberVariable, CABBooleanVariable]).transform(
|
|
1093
1102
|
(variable) => variable.type === VariableType.boolean ? { ...variable, defaultValue: variable.defaultValue ?? variable.seed === void 0 } : variable
|
|
1094
1103
|
);
|
|
1095
|
-
var CABVariableEffect =
|
|
1104
|
+
var CABVariableEffect = import_zod9.z.object({
|
|
1096
1105
|
effect: variableEffect.default(VariableEffect.toggle),
|
|
1097
|
-
variable:
|
|
1106
|
+
variable: import_zod9.z.string().min(1)
|
|
1098
1107
|
});
|
|
1099
|
-
var CABVisibility =
|
|
1100
|
-
variable:
|
|
1101
|
-
visibleWhen:
|
|
1108
|
+
var CABVisibility = import_zod9.z.object({
|
|
1109
|
+
variable: import_zod9.z.string().min(1),
|
|
1110
|
+
visibleWhen: import_zod9.z.boolean().default(true)
|
|
1102
1111
|
});
|
|
1103
|
-
var contentOperator =
|
|
1104
|
-
var resultCountOperator =
|
|
1105
|
-
var resultTagOperator =
|
|
1106
|
-
var mutatorEvent =
|
|
1107
|
-
var CABContentTrigger =
|
|
1112
|
+
var contentOperator = import_zod9.z.enum(contentOperators);
|
|
1113
|
+
var resultCountOperator = import_zod9.z.enum(resultCountOperators);
|
|
1114
|
+
var resultTagOperator = import_zod9.z.enum(resultTagOperators);
|
|
1115
|
+
var mutatorEvent = import_zod9.z.enum(mutatorEvents);
|
|
1116
|
+
var CABContentTrigger = import_zod9.z.object({
|
|
1108
1117
|
operator: contentOperator.default(ContentOperator.is_empty),
|
|
1109
|
-
type:
|
|
1118
|
+
type: import_zod9.z.literal("content")
|
|
1110
1119
|
});
|
|
1111
|
-
var CABResultCountTrigger =
|
|
1120
|
+
var CABResultCountTrigger = import_zod9.z.object({
|
|
1112
1121
|
operator: resultCountOperator.default(ResultCountOperator.equals),
|
|
1113
|
-
type:
|
|
1114
|
-
value:
|
|
1122
|
+
type: import_zod9.z.literal("result_count"),
|
|
1123
|
+
value: import_zod9.z.number().default(0)
|
|
1115
1124
|
});
|
|
1116
|
-
var CABResultTagTrigger =
|
|
1125
|
+
var CABResultTagTrigger = import_zod9.z.object({
|
|
1117
1126
|
operator: resultTagOperator.default(ResultTagOperator.contains),
|
|
1118
|
-
type:
|
|
1119
|
-
value:
|
|
1127
|
+
type: import_zod9.z.literal("result_tag"),
|
|
1128
|
+
value: import_zod9.z.string().min(1)
|
|
1120
1129
|
});
|
|
1121
|
-
var CABEventTrigger =
|
|
1130
|
+
var CABEventTrigger = import_zod9.z.object({
|
|
1122
1131
|
event: mutatorEvent,
|
|
1123
|
-
type:
|
|
1132
|
+
type: import_zod9.z.literal("event")
|
|
1124
1133
|
});
|
|
1125
|
-
var CABVariableTrigger =
|
|
1134
|
+
var CABVariableTrigger = import_zod9.z.discriminatedUnion("type", [
|
|
1126
1135
|
CABContentTrigger,
|
|
1127
1136
|
CABEventTrigger,
|
|
1128
1137
|
CABResultCountTrigger,
|
|
1129
1138
|
CABResultTagTrigger
|
|
1130
1139
|
]);
|
|
1131
|
-
var CABVariableMutator =
|
|
1140
|
+
var CABVariableMutator = import_zod9.z.object({
|
|
1132
1141
|
effect: variableEffect.default(VariableEffect.set_false),
|
|
1133
|
-
variable:
|
|
1142
|
+
variable: import_zod9.z.string().min(1),
|
|
1134
1143
|
when: CABVariableTrigger
|
|
1135
1144
|
});
|
|
1136
1145
|
var CABVariableFields = {
|
|
1137
|
-
mutators:
|
|
1138
|
-
variables:
|
|
1146
|
+
mutators: import_zod9.z.array(CABVariableMutator).optional(),
|
|
1147
|
+
variables: import_zod9.z.array(CABVariable).refine((variables) => new Set(variables.map(({ name }) => name)).size === variables.length, {
|
|
1139
1148
|
message: "variable names must be unique within a section"
|
|
1140
1149
|
}).optional(),
|
|
1141
1150
|
visibility: CABVisibility.optional()
|
|
1142
1151
|
};
|
|
1143
1152
|
|
|
1144
1153
|
// src/schema/widgets/checkout-and-beyond/layout.ts
|
|
1145
|
-
var GridItem =
|
|
1146
|
-
var CABLayoutWrapping =
|
|
1147
|
-
breakAt:
|
|
1148
|
-
maxPerLine:
|
|
1154
|
+
var GridItem = import_zod10.z.union([import_zod10.z.literal("auto"), import_zod10.z.literal("fill"), import_zod10.z.string().regex(/^\d+%$/), import_zod10.z.number()]);
|
|
1155
|
+
var CABLayoutWrapping = import_zod10.z.object({
|
|
1156
|
+
breakAt: import_zod10.z.number().positive(),
|
|
1157
|
+
maxPerLine: import_zod10.z.number().int().positive()
|
|
1149
1158
|
});
|
|
1150
|
-
var CABLayoutSection =
|
|
1159
|
+
var CABLayoutSection = import_zod10.z.object({
|
|
1151
1160
|
...CABVariableFields,
|
|
1152
|
-
alignment:
|
|
1153
|
-
horizontal:
|
|
1154
|
-
vertical:
|
|
1161
|
+
alignment: import_zod10.z.object({
|
|
1162
|
+
horizontal: import_zod10.z.enum(horizontalAlignments).default(HorizontalAlignment.start),
|
|
1163
|
+
vertical: import_zod10.z.enum(verticalAlignments).default(VerticalAlignment.top)
|
|
1155
1164
|
}).default({
|
|
1156
1165
|
horizontal: HorizontalAlignment.start,
|
|
1157
1166
|
vertical: VerticalAlignment.top
|
|
1158
1167
|
}),
|
|
1159
|
-
border:
|
|
1160
|
-
buttonField:
|
|
1161
|
-
direction:
|
|
1168
|
+
border: import_zod10.z.lazy(() => CABBorder),
|
|
1169
|
+
buttonField: import_zod10.z.enum(buttonFields).optional(),
|
|
1170
|
+
direction: import_zod10.z.enum(directions).default(Direction.rows),
|
|
1162
1171
|
/**
|
|
1163
1172
|
* Platform chrome around the section, not a layout behavior: `callout` is a subdued box with block borders
|
|
1164
1173
|
* (the legacy post-purchase callout banner), `offer-content` the post-purchase offer's own content card.
|
|
1165
1174
|
*/
|
|
1166
|
-
frame:
|
|
1167
|
-
grid:
|
|
1168
|
-
columns:
|
|
1169
|
-
rows:
|
|
1175
|
+
frame: import_zod10.z.enum(layoutFrames).optional(),
|
|
1176
|
+
grid: import_zod10.z.object({
|
|
1177
|
+
columns: import_zod10.z.union([import_zod10.z.array(GridItem), import_zod10.z.undefined()]).default(() => ["auto"]),
|
|
1178
|
+
rows: import_zod10.z.union([import_zod10.z.array(GridItem), import_zod10.z.undefined()]).default(() => ["auto"])
|
|
1170
1179
|
}).default({ columns: ["auto"], rows: ["auto"] }).optional(),
|
|
1171
|
-
name:
|
|
1172
|
-
padding:
|
|
1173
|
-
sectionId:
|
|
1174
|
-
sections:
|
|
1175
|
-
sectionType:
|
|
1176
|
-
spacing:
|
|
1180
|
+
name: import_zod10.z.string().optional(),
|
|
1181
|
+
padding: import_zod10.z.enum(spacings).default(Spacing.none),
|
|
1182
|
+
sectionId: import_zod10.z.uuid().default(() => (0, import_uuid.v7)()),
|
|
1183
|
+
sections: import_zod10.z.union([import_zod10.z.array(import_zod10.z.lazy(() => CABSection)), import_zod10.z.strictObject({}).transform(() => [])]).default(() => []),
|
|
1184
|
+
sectionType: import_zod10.z.literal(SectionType.layout).default(SectionType.layout),
|
|
1185
|
+
spacing: import_zod10.z.enum(spacings).default(Spacing.base),
|
|
1177
1186
|
/** Fire-and-forget impression pixel POSTed once when the section is shown (e.g. a Monetize offer view). */
|
|
1178
|
-
viewUrl:
|
|
1179
|
-
width:
|
|
1187
|
+
viewUrl: import_zod10.z.string().optional(),
|
|
1188
|
+
width: import_zod10.z.number().default(100),
|
|
1180
1189
|
wrapping: CABLayoutWrapping.optional()
|
|
1181
1190
|
});
|
|
1182
1191
|
|
|
@@ -1247,11 +1256,11 @@ var isTextType = isSectionType(SectionType.text);
|
|
|
1247
1256
|
var isVariantsType = isSectionType(SectionType.variants);
|
|
1248
1257
|
|
|
1249
1258
|
// src/schema/widgets/checkout-and-beyond/banner.ts
|
|
1250
|
-
var CABBannerSection =
|
|
1259
|
+
var CABBannerSection = import_zod11.z.lazy(
|
|
1251
1260
|
() => CABLayoutSection.omit({ sectionType: true }).extend({
|
|
1252
|
-
buttonField:
|
|
1253
|
-
color:
|
|
1254
|
-
dismissible:
|
|
1261
|
+
buttonField: import_zod11.z.enum(buttonFields).optional(),
|
|
1262
|
+
color: import_zod11.z.enum(bannerColors).default("info"),
|
|
1263
|
+
dismissible: import_zod11.z.boolean().default(true),
|
|
1255
1264
|
/**
|
|
1256
1265
|
* The `s-banner` heading — localized content (a buyer can see a merchant-composed banner). Absent OR
|
|
1257
1266
|
* blank ⇒ no heading; the renderer emits no heading slot for `''` rather than an empty one.
|
|
@@ -1267,83 +1276,83 @@ var CABBannerSection = import_zod10.z.lazy(
|
|
|
1267
1276
|
* not a 500. Nothing emits `heading` yet; the first converter that maps merchant banner copy into it
|
|
1268
1277
|
* either strips first or teaches `normalizeTextContent` to strip this field.
|
|
1269
1278
|
*/
|
|
1270
|
-
heading:
|
|
1271
|
-
sectionType:
|
|
1279
|
+
heading: import_zod11.z.record(import_zod11.z.string(), import_zod11.z.string().refine(checkForHTML, NO_HTML)).optional(),
|
|
1280
|
+
sectionType: import_zod11.z.literal(SectionType.banner).default(SectionType.banner)
|
|
1272
1281
|
})
|
|
1273
1282
|
);
|
|
1274
1283
|
|
|
1275
1284
|
// src/schema/widgets/checkout-and-beyond/button.ts
|
|
1276
1285
|
var import_uuid3 = require("uuid");
|
|
1277
|
-
var
|
|
1286
|
+
var import_zod13 = require("zod");
|
|
1278
1287
|
|
|
1279
1288
|
// src/schema/widgets/checkout-and-beyond/text.ts
|
|
1280
1289
|
var import_compat2 = require("es-toolkit/compat");
|
|
1281
1290
|
var import_uuid2 = require("uuid");
|
|
1282
|
-
var
|
|
1283
|
-
var enumOrOmit = (...vals) =>
|
|
1284
|
-
var TiptapText =
|
|
1285
|
-
marks:
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
attrs:
|
|
1292
|
-
class:
|
|
1293
|
-
href:
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1291
|
+
var import_zod12 = require("zod");
|
|
1292
|
+
var enumOrOmit = (...vals) => import_zod12.z.string().transform((val) => vals.includes(val) ? val : void 0).optional();
|
|
1293
|
+
var TiptapText = import_zod12.z.object({
|
|
1294
|
+
marks: import_zod12.z.union([
|
|
1295
|
+
import_zod12.z.array(
|
|
1296
|
+
import_zod12.z.discriminatedUnion("type", [
|
|
1297
|
+
import_zod12.z.object({ type: import_zod12.z.literal("bold") }),
|
|
1298
|
+
import_zod12.z.object({ type: import_zod12.z.literal("italic") }),
|
|
1299
|
+
import_zod12.z.object({
|
|
1300
|
+
attrs: import_zod12.z.object({
|
|
1301
|
+
class: import_zod12.z.string().nullable(),
|
|
1302
|
+
href: import_zod12.z.union([
|
|
1303
|
+
import_zod12.z.url(),
|
|
1304
|
+
import_zod12.z.literal("#"),
|
|
1305
|
+
import_zod12.z.string().regex(DYNAMIC_TOKEN_REGEX),
|
|
1306
|
+
import_zod12.z.string().regex(ROOT_RELATIVE_PATH_REGEX)
|
|
1298
1307
|
]),
|
|
1299
|
-
rel:
|
|
1300
|
-
target:
|
|
1308
|
+
rel: import_zod12.z.string().default("noopener noreferrer nofollow"),
|
|
1309
|
+
target: import_zod12.z.string().default("_blank")
|
|
1301
1310
|
}),
|
|
1302
|
-
type:
|
|
1311
|
+
type: import_zod12.z.literal("link")
|
|
1303
1312
|
}),
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
attrs:
|
|
1313
|
+
import_zod12.z.object({ type: import_zod12.z.literal("strike") }),
|
|
1314
|
+
import_zod12.z.object({
|
|
1315
|
+
attrs: import_zod12.z.object({
|
|
1307
1316
|
color: enumOrOmit(...textColorNames).default(TextColorName.base),
|
|
1308
1317
|
fontSize: enumOrOmit(...textSizeNames).default(TextSizeName.base)
|
|
1309
1318
|
}),
|
|
1310
|
-
type:
|
|
1319
|
+
type: import_zod12.z.literal("textStyle")
|
|
1311
1320
|
})
|
|
1312
1321
|
])
|
|
1313
1322
|
),
|
|
1314
|
-
|
|
1323
|
+
import_zod12.z.strictObject({}).transform(() => [])
|
|
1315
1324
|
]).optional(),
|
|
1316
|
-
text:
|
|
1317
|
-
type:
|
|
1325
|
+
text: import_zod12.z.string().default(""),
|
|
1326
|
+
type: import_zod12.z.literal("text").default("text")
|
|
1318
1327
|
});
|
|
1319
|
-
var TiptapParagraph =
|
|
1320
|
-
attrs:
|
|
1328
|
+
var TiptapParagraph = import_zod12.z.object({
|
|
1329
|
+
attrs: import_zod12.z.object({
|
|
1321
1330
|
textAlign: enumOrOmit(...textAlignments)
|
|
1322
1331
|
}).default({ textAlign: TextAlignment.start }),
|
|
1323
|
-
content:
|
|
1324
|
-
type:
|
|
1332
|
+
content: import_zod12.z.union([import_zod12.z.array(TiptapText), import_zod12.z.strictObject({}).transform(() => [])]).default(() => []),
|
|
1333
|
+
type: import_zod12.z.literal("paragraph").default("paragraph")
|
|
1325
1334
|
});
|
|
1326
|
-
var TiptapDocument =
|
|
1327
|
-
attrs:
|
|
1335
|
+
var TiptapDocument = import_zod12.z.object({
|
|
1336
|
+
attrs: import_zod12.z.object({
|
|
1328
1337
|
blockSpacing: enumOrOmit(...spacings)
|
|
1329
1338
|
}).default({ blockSpacing: Spacing.base }),
|
|
1330
|
-
content:
|
|
1331
|
-
type:
|
|
1339
|
+
content: import_zod12.z.union([import_zod12.z.array(TiptapParagraph), import_zod12.z.strictObject({}).transform(() => [])]).default(() => [TiptapParagraph.parse({})]),
|
|
1340
|
+
type: import_zod12.z.literal("doc").default("doc")
|
|
1332
1341
|
});
|
|
1333
|
-
var CABTextTier =
|
|
1334
|
-
threshold:
|
|
1335
|
-
thresholds:
|
|
1336
|
-
tierId:
|
|
1337
|
-
tierType:
|
|
1342
|
+
var CABTextTier = import_zod12.z.object({
|
|
1343
|
+
threshold: import_zod12.z.number().int().nonnegative(),
|
|
1344
|
+
thresholds: import_zod12.z.record(import_zod12.z.string(), import_zod12.z.number().int().nonnegative()).default(() => ({})),
|
|
1345
|
+
tierId: import_zod12.z.string().optional(),
|
|
1346
|
+
tierType: import_zod12.z.enum(progressTierTypes).default(ProgressTierType.shipping)
|
|
1338
1347
|
});
|
|
1339
|
-
var CABTextSection =
|
|
1348
|
+
var CABTextSection = import_zod12.z.object({
|
|
1340
1349
|
...CABVariableFields,
|
|
1341
|
-
buttonField:
|
|
1342
|
-
content:
|
|
1343
|
-
name:
|
|
1344
|
-
optionId:
|
|
1345
|
-
sectionId:
|
|
1346
|
-
sectionType:
|
|
1350
|
+
buttonField: import_zod12.z.enum(buttonFields).optional(),
|
|
1351
|
+
content: import_zod12.z.record(import_zod12.z.string(), import_zod12.z.union([import_zod12.z.string(), TiptapDocument]).refine(checkForHTML, NO_HTML).optional()).default({ en: TiptapDocument.parse({}) }).optional(),
|
|
1352
|
+
name: import_zod12.z.string().optional(),
|
|
1353
|
+
optionId: import_zod12.z.number().optional(),
|
|
1354
|
+
sectionId: import_zod12.z.uuid().default(() => (0, import_uuid2.v7)()),
|
|
1355
|
+
sectionType: import_zod12.z.literal(SectionType.text).default(SectionType.text),
|
|
1347
1356
|
tier: CABTextTier.optional()
|
|
1348
1357
|
}).superRefine(({ buttonField, content }, ctx) => {
|
|
1349
1358
|
if (buttonField === ButtonField.destinationUrl && content) {
|
|
@@ -1365,35 +1374,35 @@ var CABTextSection = import_zod11.z.object({
|
|
|
1365
1374
|
});
|
|
1366
1375
|
|
|
1367
1376
|
// src/schema/widgets/checkout-and-beyond/button.ts
|
|
1368
|
-
var CABButtonContent =
|
|
1369
|
-
() =>
|
|
1377
|
+
var CABButtonContent = import_zod13.z.lazy(
|
|
1378
|
+
() => import_zod13.z.discriminatedUnion("sectionType", [CABImageSection, CABLayoutSection, CABTextSection])
|
|
1370
1379
|
);
|
|
1371
|
-
var CABButtonSection =
|
|
1380
|
+
var CABButtonSection = import_zod13.z.object({
|
|
1372
1381
|
...CABVariableFields,
|
|
1373
|
-
action:
|
|
1374
|
-
buttonStyle:
|
|
1375
|
-
custom:
|
|
1376
|
-
color:
|
|
1377
|
-
height:
|
|
1378
|
-
width:
|
|
1382
|
+
action: import_zod13.z.union([import_zod13.z.literal(""), import_zod13.z.enum(buttonActions)]).default(""),
|
|
1383
|
+
buttonStyle: import_zod13.z.enum(buttonStyles).default(ButtonStyle.primary),
|
|
1384
|
+
custom: import_zod13.z.object({
|
|
1385
|
+
color: import_zod13.z.string().regex(HEX_COLOR_REGEX).default("#005bd3"),
|
|
1386
|
+
height: import_zod13.z.number().default(52),
|
|
1387
|
+
width: import_zod13.z.number().default(300)
|
|
1379
1388
|
}).default({
|
|
1380
1389
|
color: "#005bd3",
|
|
1381
1390
|
height: 52,
|
|
1382
1391
|
width: 300
|
|
1383
1392
|
}),
|
|
1384
|
-
disableDowngrade:
|
|
1385
|
-
name:
|
|
1386
|
-
optionId:
|
|
1387
|
-
popover:
|
|
1388
|
-
alignment:
|
|
1389
|
-
position:
|
|
1393
|
+
disableDowngrade: import_zod13.z.boolean().default(false),
|
|
1394
|
+
name: import_zod13.z.string().optional(),
|
|
1395
|
+
optionId: import_zod13.z.number().optional(),
|
|
1396
|
+
popover: import_zod13.z.object({
|
|
1397
|
+
alignment: import_zod13.z.enum(textAlignments).default(TextAlignment.center),
|
|
1398
|
+
position: import_zod13.z.enum(popoverPositions).default(PopoverPosition.blockStart)
|
|
1390
1399
|
}).optional().default(() => ({
|
|
1391
1400
|
alignment: TextAlignment.center,
|
|
1392
1401
|
position: PopoverPosition.blockStart
|
|
1393
1402
|
})),
|
|
1394
|
-
sectionId:
|
|
1395
|
-
sections:
|
|
1396
|
-
sectionType:
|
|
1403
|
+
sectionId: import_zod13.z.uuid().default(() => (0, import_uuid3.v7)()),
|
|
1404
|
+
sections: import_zod13.z.union([import_zod13.z.array(CABButtonContent), import_zod13.z.strictObject({}).transform(() => [])]).default(() => []),
|
|
1405
|
+
sectionType: import_zod13.z.literal(SectionType.button).default(SectionType.button),
|
|
1397
1406
|
/**
|
|
1398
1407
|
* The smart-cart tier this button acts on (`addGift`/`removeGift`): scopes the click to one tier's gift. The
|
|
1399
1408
|
* client resolves the tier's gift (productId) from the progress-bar context by this `tierId` — the button node
|
|
@@ -1408,25 +1417,25 @@ var CABButtonSection = import_zod12.z.object({
|
|
|
1408
1417
|
* lookup finds no tier and the click resolves to nothing. Safe to bound — the field is new, so there are no
|
|
1409
1418
|
* stored payloads to grandfather, and the producer is client code, not a merchant form.
|
|
1410
1419
|
*/
|
|
1411
|
-
tier:
|
|
1420
|
+
tier: import_zod13.z.object({ tierId: import_zod13.z.string().min(1) }).optional(),
|
|
1412
1421
|
/** Fire-and-forget pixel POSTed when the button is clicked (e.g. a Monetize decline). */
|
|
1413
|
-
trackingUrl:
|
|
1422
|
+
trackingUrl: import_zod13.z.string().optional(),
|
|
1414
1423
|
/**
|
|
1415
1424
|
* Secondary effects applied to in-scope variables on click, alongside (never instead of) the primary
|
|
1416
1425
|
* `action` — an `addToOrder` button can also flip a variable. Applied in array order.
|
|
1417
1426
|
*/
|
|
1418
|
-
variableEffects:
|
|
1427
|
+
variableEffects: import_zod13.z.array(CABVariableEffect).optional()
|
|
1419
1428
|
});
|
|
1420
1429
|
|
|
1421
1430
|
// src/schema/widgets/checkout-and-beyond/carousel.ts
|
|
1422
|
-
var
|
|
1431
|
+
var import_zod18 = require("zod");
|
|
1423
1432
|
|
|
1424
1433
|
// src/schema/widgets/checkout-and-beyond/offers.ts
|
|
1425
|
-
var
|
|
1434
|
+
var import_zod17 = require("zod");
|
|
1426
1435
|
|
|
1427
1436
|
// src/schema/widgets/checkout-and-beyond/dataSource.ts
|
|
1428
1437
|
var import_uuid4 = require("uuid");
|
|
1429
|
-
var
|
|
1438
|
+
var import_zod14 = require("zod");
|
|
1430
1439
|
|
|
1431
1440
|
// src/schema/widgets/checkout-and-beyond/constants.ts
|
|
1432
1441
|
var import_es_toolkit3 = require("es-toolkit");
|
|
@@ -1480,77 +1489,77 @@ var targetAreas = {
|
|
|
1480
1489
|
};
|
|
1481
1490
|
|
|
1482
1491
|
// src/schema/widgets/checkout-and-beyond/dataSource.ts
|
|
1483
|
-
var CABDiscount =
|
|
1484
|
-
amount:
|
|
1485
|
-
discountedBy:
|
|
1486
|
-
discountedFrom:
|
|
1487
|
-
type:
|
|
1488
|
-
});
|
|
1489
|
-
var CABIntegrations =
|
|
1490
|
-
judgeme:
|
|
1491
|
-
junip:
|
|
1492
|
-
klaviyo:
|
|
1493
|
-
loox:
|
|
1494
|
-
okendo:
|
|
1495
|
-
opinew:
|
|
1496
|
-
reviewsio:
|
|
1497
|
-
stamped:
|
|
1498
|
-
yotpo:
|
|
1499
|
-
});
|
|
1500
|
-
var CABVariantLabels =
|
|
1501
|
-
variantOption:
|
|
1502
|
-
variantOptions:
|
|
1503
|
-
});
|
|
1504
|
-
var CABDataSourceSection =
|
|
1505
|
-
dataSourceId:
|
|
1506
|
-
dataSourcePath:
|
|
1492
|
+
var CABDiscount = import_zod14.z.object({
|
|
1493
|
+
amount: import_zod14.z.union([import_zod14.z.number(), import_zod14.z.string()]).catch(0),
|
|
1494
|
+
discountedBy: import_zod14.z.string().optional(),
|
|
1495
|
+
discountedFrom: import_zod14.z.enum(discountSources).optional().catch(void 0),
|
|
1496
|
+
type: import_zod14.z.enum(discountTypes).catch("none")
|
|
1497
|
+
});
|
|
1498
|
+
var CABIntegrations = import_zod14.z.object({
|
|
1499
|
+
judgeme: import_zod14.z.boolean().default(false),
|
|
1500
|
+
junip: import_zod14.z.boolean().default(false),
|
|
1501
|
+
klaviyo: import_zod14.z.boolean().default(false),
|
|
1502
|
+
loox: import_zod14.z.boolean().default(false),
|
|
1503
|
+
okendo: import_zod14.z.boolean().default(false),
|
|
1504
|
+
opinew: import_zod14.z.boolean().default(false),
|
|
1505
|
+
reviewsio: import_zod14.z.boolean().default(false),
|
|
1506
|
+
stamped: import_zod14.z.boolean().default(false),
|
|
1507
|
+
yotpo: import_zod14.z.boolean().default(false)
|
|
1508
|
+
});
|
|
1509
|
+
var CABVariantLabels = import_zod14.z.object({
|
|
1510
|
+
variantOption: import_zod14.z.string().optional().catch(void 0),
|
|
1511
|
+
variantOptions: import_zod14.z.string().optional().catch(void 0)
|
|
1512
|
+
});
|
|
1513
|
+
var CABDataSourceSection = import_zod14.z.object({
|
|
1514
|
+
dataSourceId: import_zod14.z.number().nullable().default(null),
|
|
1515
|
+
dataSourcePath: import_zod14.z.string().default(DEFAULT_ENDPOINTS[0].value),
|
|
1507
1516
|
discount: CABDiscount.optional(),
|
|
1508
1517
|
integrations: CABIntegrations.optional(),
|
|
1509
|
-
limit:
|
|
1510
|
-
matchVariant:
|
|
1511
|
-
matchVariantOutOfStock:
|
|
1512
|
-
name:
|
|
1513
|
-
productType:
|
|
1514
|
-
sectionId:
|
|
1515
|
-
sectionType:
|
|
1518
|
+
limit: import_zod14.z.number().default(1),
|
|
1519
|
+
matchVariant: import_zod14.z.boolean().default(false),
|
|
1520
|
+
matchVariantOutOfStock: import_zod14.z.boolean().default(false),
|
|
1521
|
+
name: import_zod14.z.string().default(DEFAULT_ENDPOINTS[0].label),
|
|
1522
|
+
productType: import_zod14.z.enum(productTypes).optional(),
|
|
1523
|
+
sectionId: import_zod14.z.uuid().default(() => (0, import_uuid4.v7)()),
|
|
1524
|
+
sectionType: import_zod14.z.literal(SectionType.dataSource).default(SectionType.dataSource),
|
|
1516
1525
|
/** Default subscribe-vs-one-time for `productType: both` (legacy `subscription_is_default`). */
|
|
1517
|
-
subscriptionIsDefault:
|
|
1518
|
-
treatAsGwp:
|
|
1526
|
+
subscriptionIsDefault: import_zod14.z.boolean().default(false),
|
|
1527
|
+
treatAsGwp: import_zod14.z.boolean().default(false),
|
|
1519
1528
|
variantLabels: CABVariantLabels.optional().catch(void 0)
|
|
1520
1529
|
});
|
|
1521
1530
|
|
|
1522
1531
|
// src/schema/widgets/checkout-and-beyond/products.ts
|
|
1523
1532
|
var import_uuid6 = require("uuid");
|
|
1524
|
-
var
|
|
1533
|
+
var import_zod16 = require("zod");
|
|
1525
1534
|
|
|
1526
1535
|
// src/schema/widgets/checkout-and-beyond/product.ts
|
|
1527
1536
|
var import_uuid5 = require("uuid");
|
|
1528
|
-
var
|
|
1529
|
-
var CABVariantContent =
|
|
1530
|
-
() =>
|
|
1537
|
+
var import_zod15 = require("zod");
|
|
1538
|
+
var CABVariantContent = import_zod15.z.lazy(
|
|
1539
|
+
() => import_zod15.z.discriminatedUnion("sectionType", [CABButtonSection, CABTextSection])
|
|
1531
1540
|
);
|
|
1532
|
-
var CABProductSection =
|
|
1541
|
+
var CABProductSection = import_zod15.z.object({
|
|
1533
1542
|
...CABVariableFields,
|
|
1534
|
-
name:
|
|
1535
|
-
productId:
|
|
1536
|
-
sectionId:
|
|
1537
|
-
sections:
|
|
1538
|
-
sectionType:
|
|
1539
|
-
selectors:
|
|
1540
|
-
variantMode:
|
|
1543
|
+
name: import_zod15.z.string().optional(),
|
|
1544
|
+
productId: import_zod15.z.number().nullable().default(null),
|
|
1545
|
+
sectionId: import_zod15.z.uuid().default(() => (0, import_uuid5.v7)()),
|
|
1546
|
+
sections: import_zod15.z.union([import_zod15.z.array(CABVariantContent), import_zod15.z.strictObject({}).transform(() => [])]).default(() => []),
|
|
1547
|
+
sectionType: import_zod15.z.literal(SectionType.product).default(SectionType.product),
|
|
1548
|
+
selectors: import_zod15.z.record(import_zod15.z.string(), import_zod15.z.enum(variantSelectors).default(VariantSelector.menu)).default(() => ({})),
|
|
1549
|
+
variantMode: import_zod15.z.enum(variantModes).default(VariantMode.multiple)
|
|
1541
1550
|
});
|
|
1542
1551
|
|
|
1543
1552
|
// src/schema/widgets/checkout-and-beyond/products.ts
|
|
1544
|
-
var CABProductsSection =
|
|
1553
|
+
var CABProductsSection = import_zod16.z.object({
|
|
1545
1554
|
...CABVariableFields,
|
|
1546
|
-
name:
|
|
1547
|
-
sectionId:
|
|
1548
|
-
sections:
|
|
1549
|
-
sectionType:
|
|
1555
|
+
name: import_zod16.z.string().optional(),
|
|
1556
|
+
sectionId: import_zod16.z.uuid().default(() => (0, import_uuid6.v7)()),
|
|
1557
|
+
sections: import_zod16.z.union([import_zod16.z.array(import_zod16.z.lazy(() => CABProductSection)), import_zod16.z.strictObject({}).transform(() => [])]).default(() => []),
|
|
1558
|
+
sectionType: import_zod16.z.literal(SectionType.products).default(SectionType.products)
|
|
1550
1559
|
});
|
|
1551
1560
|
|
|
1552
1561
|
// src/schema/widgets/checkout-and-beyond/offers.ts
|
|
1553
|
-
var CABOffersSection =
|
|
1562
|
+
var CABOffersSection = import_zod17.z.lazy(
|
|
1554
1563
|
() => CABLayoutSection.omit({ sections: true, sectionType: true }).extend({
|
|
1555
1564
|
/**
|
|
1556
1565
|
* A rule between consecutive cards in the vertical list — legacy checkout-offers' `<Divider />`,
|
|
@@ -1558,8 +1567,8 @@ var CABOffersSection = import_zod16.z.lazy(
|
|
|
1558
1567
|
* run of products). Optional, not defaulted: only the v1 converter sets it (REB-24265); a
|
|
1559
1568
|
* hand-built tree keeps React CAB's dividerless rendering.
|
|
1560
1569
|
*/
|
|
1561
|
-
divider:
|
|
1562
|
-
sections:
|
|
1570
|
+
divider: import_zod17.z.boolean().optional(),
|
|
1571
|
+
sections: import_zod17.z.union([import_zod17.z.array(import_zod17.z.lazy(() => CABSection)), import_zod17.z.strictObject({}).transform(() => [])]).default(() => [
|
|
1563
1572
|
CABBannerSection.parse({
|
|
1564
1573
|
buttonField: "undoAddToOrder",
|
|
1565
1574
|
color: "success",
|
|
@@ -1573,77 +1582,77 @@ var CABOffersSection = import_zod16.z.lazy(
|
|
|
1573
1582
|
CABDataSourceSection.parse({}),
|
|
1574
1583
|
CABProductsSection.parse({})
|
|
1575
1584
|
]),
|
|
1576
|
-
sectionType:
|
|
1585
|
+
sectionType: import_zod17.z.literal(SectionType.offers).default(SectionType.offers)
|
|
1577
1586
|
})
|
|
1578
1587
|
);
|
|
1579
1588
|
|
|
1580
1589
|
// src/schema/widgets/checkout-and-beyond/carousel.ts
|
|
1581
|
-
var CABCarouselSection =
|
|
1590
|
+
var CABCarouselSection = import_zod18.z.lazy(
|
|
1582
1591
|
() => CABLayoutSection.omit({ sections: true, sectionType: true }).extend({
|
|
1583
|
-
autoAdvanceInterval:
|
|
1584
|
-
itemsAtOnce:
|
|
1592
|
+
autoAdvanceInterval: import_zod18.z.number().default(0),
|
|
1593
|
+
itemsAtOnce: import_zod18.z.number().min(1).default(1),
|
|
1585
1594
|
/** Card arrangement for the offers child (`horizontal` = side-by-side) — NOT the carousel's own `direction`. */
|
|
1586
|
-
offersDirection:
|
|
1587
|
-
sections:
|
|
1588
|
-
sectionType:
|
|
1595
|
+
offersDirection: import_zod18.z.enum(offersDirections).default("vertical"),
|
|
1596
|
+
sections: import_zod18.z.union([import_zod18.z.array(import_zod18.z.lazy(() => CABSection)), import_zod18.z.strictObject({}).transform(() => [])]).default(() => [CABOffersSection.parse({})]),
|
|
1597
|
+
sectionType: import_zod18.z.literal(SectionType.carousel).default(SectionType.carousel)
|
|
1589
1598
|
})
|
|
1590
1599
|
);
|
|
1591
1600
|
|
|
1592
1601
|
// src/schema/widgets/checkout-and-beyond/cartLine.ts
|
|
1593
|
-
var
|
|
1594
|
-
var CABCartLineSection =
|
|
1602
|
+
var import_zod19 = require("zod");
|
|
1603
|
+
var CABCartLineSection = import_zod19.z.lazy(
|
|
1595
1604
|
() => CABLayoutSection.omit({ sections: true, sectionType: true }).extend({
|
|
1596
|
-
sections:
|
|
1597
|
-
sectionType:
|
|
1605
|
+
sections: import_zod19.z.union([import_zod19.z.array(import_zod19.z.lazy(() => CABSection)), import_zod19.z.strictObject({}).transform(() => [])]).default(() => [CABButtonSection.parse({ action: ButtonAction.switchToSubscription })]),
|
|
1606
|
+
sectionType: import_zod19.z.literal(SectionType.cartLine).default(SectionType.cartLine)
|
|
1598
1607
|
})
|
|
1599
1608
|
);
|
|
1600
1609
|
|
|
1601
1610
|
// src/schema/widgets/checkout-and-beyond/discount.ts
|
|
1602
1611
|
var import_uuid7 = require("uuid");
|
|
1603
|
-
var
|
|
1604
|
-
var CABDiscountSection =
|
|
1612
|
+
var import_zod20 = require("zod");
|
|
1613
|
+
var CABDiscountSection = import_zod20.z.object({
|
|
1605
1614
|
...CABVariableFields,
|
|
1606
|
-
amount:
|
|
1607
|
-
discountedBy:
|
|
1608
|
-
discountedFrom:
|
|
1609
|
-
message:
|
|
1610
|
-
name:
|
|
1611
|
-
quantity:
|
|
1612
|
-
sectionId:
|
|
1613
|
-
sectionType:
|
|
1614
|
-
type:
|
|
1615
|
+
amount: import_zod20.z.union([import_zod20.z.number(), import_zod20.z.string()]).catch(0),
|
|
1616
|
+
discountedBy: import_zod20.z.string().optional(),
|
|
1617
|
+
discountedFrom: import_zod20.z.enum(discountSources).optional().catch(void 0),
|
|
1618
|
+
message: import_zod20.z.string().optional(),
|
|
1619
|
+
name: import_zod20.z.string().optional(),
|
|
1620
|
+
quantity: import_zod20.z.number().default(1),
|
|
1621
|
+
sectionId: import_zod20.z.uuid().default(() => (0, import_uuid7.v7)()),
|
|
1622
|
+
sectionType: import_zod20.z.literal(SectionType.discount).default(SectionType.discount),
|
|
1623
|
+
type: import_zod20.z.enum(discountTypes).catch("none")
|
|
1615
1624
|
});
|
|
1616
1625
|
|
|
1617
1626
|
// src/schema/widgets/checkout-and-beyond/monetize.ts
|
|
1618
1627
|
var import_uuid8 = require("uuid");
|
|
1619
|
-
var
|
|
1620
|
-
var CABMonetizeAds =
|
|
1621
|
-
requestId:
|
|
1628
|
+
var import_zod21 = require("zod");
|
|
1629
|
+
var CABMonetizeAds = import_zod21.z.object({
|
|
1630
|
+
requestId: import_zod21.z.string().optional(),
|
|
1622
1631
|
/** Defaulted here, never in the beacon: absence of information is `ads` itself being absent. */
|
|
1623
|
-
testing:
|
|
1632
|
+
testing: import_zod21.z.boolean().default(false)
|
|
1624
1633
|
});
|
|
1625
|
-
var CABMonetizeSection =
|
|
1634
|
+
var CABMonetizeSection = import_zod21.z.object({
|
|
1626
1635
|
...CABVariableFields,
|
|
1627
1636
|
ads: CABMonetizeAds.optional(),
|
|
1628
|
-
name:
|
|
1637
|
+
name: import_zod21.z.string().optional(),
|
|
1629
1638
|
/**
|
|
1630
1639
|
* Server-hydrated offer cards (inline hydration): when `/cab/sections` was asked with a `monetize`
|
|
1631
1640
|
* context block, the composed cards ride the marker itself — `[]` means "hydrated, no fill" (render
|
|
1632
1641
|
* nothing, skip the fetch); ABSENT means "not hydrated" (the client fetches via `/cab/monetize`).
|
|
1633
1642
|
*/
|
|
1634
|
-
offers:
|
|
1643
|
+
offers: import_zod21.z.array(import_zod21.z.lazy(() => CABSection)).optional(),
|
|
1635
1644
|
/** Privacy Policy footer href (the widget's `privacy_policy_url` setting); read server-side for hydration, relayed by the client only on the legacy `/cab/monetize` fallback. */
|
|
1636
|
-
privacyPolicyUrl:
|
|
1637
|
-
sectionId:
|
|
1638
|
-
sectionType:
|
|
1645
|
+
privacyPolicyUrl: import_zod21.z.string().optional(),
|
|
1646
|
+
sectionId: import_zod21.z.uuid().default(() => (0, import_uuid8.v7)()),
|
|
1647
|
+
sectionType: import_zod21.z.literal(SectionType.monetize).default(SectionType.monetize),
|
|
1639
1648
|
/** Ads-taxonomy sub-vertical id (the widget's `sub_vertical` setting); paired with `vertical`. */
|
|
1640
|
-
subVertical:
|
|
1649
|
+
subVertical: import_zod21.z.string().optional(),
|
|
1641
1650
|
/** Ads-taxonomy vertical id (the widget's `vertical` setting) — with `subVertical`, the admin Monetize editor's two configurables. */
|
|
1642
|
-
vertical:
|
|
1651
|
+
vertical: import_zod21.z.string().optional()
|
|
1643
1652
|
});
|
|
1644
1653
|
|
|
1645
1654
|
// src/schema/widgets/checkout-and-beyond/progressBar.ts
|
|
1646
|
-
var
|
|
1655
|
+
var import_zod22 = require("zod");
|
|
1647
1656
|
|
|
1648
1657
|
// src/schema/widgets/checkout-and-beyond/giftLabels.ts
|
|
1649
1658
|
var GIFT_LABELS = {
|
|
@@ -1762,34 +1771,34 @@ var GIFT_LABELS = {
|
|
|
1762
1771
|
};
|
|
1763
1772
|
|
|
1764
1773
|
// src/schema/widgets/checkout-and-beyond/progressBar.ts
|
|
1765
|
-
var CABProgressTierExclusion =
|
|
1766
|
-
collectionIds:
|
|
1767
|
-
productIds:
|
|
1768
|
-
tags:
|
|
1769
|
-
type:
|
|
1774
|
+
var CABProgressTierExclusion = import_zod22.z.object({
|
|
1775
|
+
collectionIds: import_zod22.z.array(import_zod22.z.number().int().positive()).default(() => []),
|
|
1776
|
+
productIds: import_zod22.z.array(import_zod22.z.number().int().positive()).default(() => []),
|
|
1777
|
+
tags: import_zod22.z.array(import_zod22.z.string().min(1)).default(() => []),
|
|
1778
|
+
type: import_zod22.z.enum(progressTierExclusionTypes)
|
|
1770
1779
|
});
|
|
1771
|
-
var CABProgressTier =
|
|
1780
|
+
var CABProgressTier = import_zod22.z.object({
|
|
1772
1781
|
/**
|
|
1773
1782
|
* Order-discount tiers only (onsite `discount`): the reward the order-discount Function applies at
|
|
1774
1783
|
* cart time, carried so the client can resolve the `{{discountAmount}}` token in this tier's copy.
|
|
1775
1784
|
* `fixedAmount`: shop-currency CENTS (FX-scaled by the client, like {@link CABProgressTier.threshold});
|
|
1776
1785
|
* `percentage`: the whole-percent number rendered raw (`{n}%`). Absent on non-discount tiers.
|
|
1777
1786
|
*/
|
|
1778
|
-
discount:
|
|
1787
|
+
discount: import_zod22.z.object({ amount: import_zod22.z.number().nonnegative(), type: import_zod22.z.enum(["fixedAmount", "percentage"]) }).optional(),
|
|
1779
1788
|
/**
|
|
1780
1789
|
* Per-tier exclusion rules (onsite `exclusions` when `exclusions_enabled`): lines they match don't count
|
|
1781
1790
|
* toward this tier. Empty (the default, and the converter's output for a disabled or ruleless tier) means
|
|
1782
1791
|
* the tier measures the plain bar-level adjusted progress. Consumers read ONLY the list named by the rule's
|
|
1783
1792
|
* `type` — the converter leaves the other two at `[]`, so a populated off-type list never reaches the tree.
|
|
1784
1793
|
*/
|
|
1785
|
-
exclusions:
|
|
1794
|
+
exclusions: import_zod22.z.array(CABProgressTierExclusion).default(() => []),
|
|
1786
1795
|
/**
|
|
1787
1796
|
* Smart-cart product (gift) tiers only (onsite `filter_oos_variants`): when set, the client drops this
|
|
1788
1797
|
* tier entirely once its gift has NO in-stock eligible variant — the milestone, fill slot and gift
|
|
1789
1798
|
* controls all disappear, mirroring onsite removing the tier from `bar.tiers` before it renders. Absent
|
|
1790
1799
|
* on shipping/discount/decorative tiers and left off by default (the tier renders regardless of stock).
|
|
1791
1800
|
*/
|
|
1792
|
-
filterOosVariants:
|
|
1801
|
+
filterOosVariants: import_zod22.z.boolean().default(false),
|
|
1793
1802
|
/**
|
|
1794
1803
|
* Smart-cart product (gift) tiers only: the reward unlocked at this tier. The client enriches
|
|
1795
1804
|
* `productId`/`variantIds` to live variants (availability, price) and adds the chosen one to the cart
|
|
@@ -1797,10 +1806,10 @@ var CABProgressTier = import_zod21.z.object({
|
|
|
1797
1806
|
* tiers and on tiers with no configured product. Cart add/remove is a later stage; carried here so the
|
|
1798
1807
|
* tree is complete.
|
|
1799
1808
|
*/
|
|
1800
|
-
gift:
|
|
1801
|
-
productId:
|
|
1802
|
-
title:
|
|
1803
|
-
variantIds:
|
|
1809
|
+
gift: import_zod22.z.object({
|
|
1810
|
+
productId: import_zod22.z.number().int().positive(),
|
|
1811
|
+
title: import_zod22.z.string().optional(),
|
|
1812
|
+
variantIds: import_zod22.z.array(import_zod22.z.number().int().positive()).default(() => [])
|
|
1804
1813
|
}).optional(),
|
|
1805
1814
|
/**
|
|
1806
1815
|
* The step-row icon's square size in PIXELS (onsite `product_tier_element_size`, an admin px string the
|
|
@@ -1820,7 +1829,7 @@ var CABProgressTier = import_zod21.z.object({
|
|
|
1820
1829
|
* renderer never spells a fallback), which also makes a tree authored before this field render at
|
|
1821
1830
|
* React's size rather than the old hardcoded 20.
|
|
1822
1831
|
*/
|
|
1823
|
-
iconSizePx:
|
|
1832
|
+
iconSizePx: import_zod22.z.number().int().min(1).max(64).default(18),
|
|
1824
1833
|
/**
|
|
1825
1834
|
* The step-row label at this tier's slot (onsite `getTierLabel`): the merchant custom label, else the
|
|
1826
1835
|
* type default — 'Free Shipping' or '{n}% Discount'. A PRODUCT tier gets NO converter label: its name is
|
|
@@ -1830,35 +1839,35 @@ var CABProgressTier = import_zod21.z.object({
|
|
|
1830
1839
|
* turns a blank label into an absent key, and a client-authored blank means the same thing — the renderer
|
|
1831
1840
|
* emits no caption slot rather than an empty one). Plain text — a compact icon+label.
|
|
1832
1841
|
*/
|
|
1833
|
-
label:
|
|
1842
|
+
label: import_zod22.z.record(import_zod22.z.string(), import_zod22.z.string()).optional(),
|
|
1834
1843
|
/**
|
|
1835
1844
|
* Smart-cart product (gift) tiers only (onsite `product_tier_image`): show the gift's product image in
|
|
1836
1845
|
* the step-row slot instead of the generic bag icon. The converter can't supply the image URL (config
|
|
1837
1846
|
* carries only product IDs), so the client resolves it (authoritative Shopify featured image, React
|
|
1838
1847
|
* parity) and falls back to the bag icon when the flag is off or no image resolves. Default false.
|
|
1839
1848
|
*/
|
|
1840
|
-
productTierImage:
|
|
1849
|
+
productTierImage: import_zod22.z.boolean().default(false),
|
|
1841
1850
|
/**
|
|
1842
1851
|
* The tier's goal, measured per `unit`. `currency` (default): SHOP-currency cents — the canonical
|
|
1843
1852
|
* fallback: when the buyer's presentment currency has no entry in `thresholds`, the client
|
|
1844
1853
|
* multiplies this by the live FX rate (converter maps the v1 `unlock_price`, e.g. `75` → `7500`).
|
|
1845
1854
|
* `item`: a raw item count — no cents, no FX, no `thresholds` overrides.
|
|
1846
1855
|
*/
|
|
1847
|
-
threshold:
|
|
1856
|
+
threshold: import_zod22.z.number().int().nonnegative(),
|
|
1848
1857
|
/**
|
|
1849
1858
|
* Per-presentment-currency goal overrides — lowercased ISO currency code → cents (e.g. `{ cad: 9900 }`).
|
|
1850
1859
|
* When the buyer's currency has an entry, the client uses it verbatim INSTEAD of FX-converting
|
|
1851
1860
|
* `threshold`, so merchants show intentional, clean per-market amounts (Shopify Markets) rather than a
|
|
1852
1861
|
* converted base. Defaults to `{}` — no overrides means always fall back to `threshold`.
|
|
1853
1862
|
*/
|
|
1854
|
-
thresholds:
|
|
1863
|
+
thresholds: import_zod22.z.record(import_zod22.z.string(), import_zod22.z.number().int().nonnegative()).default(() => ({})),
|
|
1855
1864
|
/**
|
|
1856
1865
|
* Smart-cart tier identifier, mirrored onto the gift cart line's `_tier` attribute so the client can
|
|
1857
1866
|
* match an in-cart gift back to its tier (add on reach, remove on downgrade/decline). Absent on the
|
|
1858
1867
|
* shipping bar (single unlabeled tier, no gift).
|
|
1859
1868
|
*/
|
|
1860
|
-
tierId:
|
|
1861
|
-
tierType:
|
|
1869
|
+
tierId: import_zod22.z.string().optional(),
|
|
1870
|
+
tierType: import_zod22.z.enum(progressTierTypes).default(ProgressTierType.shipping),
|
|
1862
1871
|
/**
|
|
1863
1872
|
* What this tier's progress is measured in — PER TIER (onsite's `unlock_condition_type` model, NOT
|
|
1864
1873
|
* the React port's bar-level `tiers[0]` shortcut). `currency` compares money cents against the
|
|
@@ -1869,9 +1878,9 @@ var CABProgressTier = import_zod21.z.object({
|
|
|
1869
1878
|
* count carries no injected noun (no English `item`/`items` inflection on localized copy); merchant
|
|
1870
1879
|
* template text supplies grammatically-neutral wording around the token.
|
|
1871
1880
|
*/
|
|
1872
|
-
unit:
|
|
1881
|
+
unit: import_zod22.z.enum(progressTierUnits).default(ProgressTierUnit.currency)
|
|
1873
1882
|
});
|
|
1874
|
-
var CABProgressBarSection =
|
|
1883
|
+
var CABProgressBarSection = import_zod22.z.lazy(
|
|
1875
1884
|
() => CABLayoutSection.omit({ sectionType: true }).extend({
|
|
1876
1885
|
/**
|
|
1877
1886
|
* The onsite bar id (smart-cart TPB bars only). The client mirrors it to the cart's `_barId` attribute
|
|
@@ -1880,35 +1889,35 @@ var CABProgressBarSection = import_zod21.z.lazy(
|
|
|
1880
1889
|
* checkout reaches the extension without it, so the client writes it or the tier gift's 100% discount
|
|
1881
1890
|
* (and any tier order discount) never applies. Absent on the v1 shipping bar (no gift tiers, no id).
|
|
1882
1891
|
*/
|
|
1883
|
-
barId:
|
|
1892
|
+
barId: import_zod22.z.string().optional(),
|
|
1884
1893
|
/** Empty = shown everywhere; otherwise uppercase ISO country codes. */
|
|
1885
|
-
countryCodes:
|
|
1894
|
+
countryCodes: import_zod22.z.array(import_zod22.z.string().transform((code) => code.trim().toUpperCase())).default(() => []),
|
|
1886
1895
|
/**
|
|
1887
1896
|
* Uppercase ISO codes where a higher-precedence geo bar applies, so this (default, non-geo) bar is
|
|
1888
1897
|
* hidden there — replicates React `getbar`'s geo-match-over-default precedence. Empty = never excluded.
|
|
1889
1898
|
*/
|
|
1890
|
-
excludeCountryCodes:
|
|
1899
|
+
excludeCountryCodes: import_zod22.z.array(import_zod22.z.string().transform((code) => code.trim().toUpperCase())).default(() => []),
|
|
1891
1900
|
/**
|
|
1892
1901
|
* Measure progress against the PRE-discount subtotal (onsite `exclude_discount_in_subtotal`, and
|
|
1893
1902
|
* forced on for bars with a discount tier so its own reward can't un-reach the tier). The client
|
|
1894
1903
|
* adds the cart's discount allocations back to the live subtotal.
|
|
1895
1904
|
*/
|
|
1896
|
-
excludeDiscountInSubtotal:
|
|
1905
|
+
excludeDiscountInSubtotal: import_zod22.z.boolean().default(false),
|
|
1897
1906
|
/** Variant ids the client subtracts from the adjusted subtotal (React `bar.excluded_products`). */
|
|
1898
|
-
excludedVariantIds:
|
|
1907
|
+
excludedVariantIds: import_zod22.z.array(import_zod22.z.number().int().positive()).default(() => []),
|
|
1899
1908
|
/**
|
|
1900
1909
|
* When the cart holds a subscription item, treat the bar as reached regardless of subtotal (React
|
|
1901
1910
|
* `free_shipping_on_subscription(s)`). `freeShippingOnAll` is already a zero-threshold tier instead.
|
|
1902
1911
|
*/
|
|
1903
|
-
freeShippingOnSubscription:
|
|
1912
|
+
freeShippingOnSubscription: import_zod22.z.boolean().default(false),
|
|
1904
1913
|
/** Localized heading over the gift controls (onsite `gift_area_title`, default 'FREE GIFTS'). */
|
|
1905
|
-
giftAreaTitle:
|
|
1914
|
+
giftAreaTitle: import_zod22.z.record(import_zod22.z.string(), import_zod22.z.string()).default(() => ({ en: "FREE GIFTS" })),
|
|
1906
1915
|
/** Localized gift-control labels (add/remove/heading); a tier's gift `title` beats `yourGift`. */
|
|
1907
|
-
giftLabels:
|
|
1908
|
-
addGift:
|
|
1909
|
-
remove:
|
|
1910
|
-
selectOptions:
|
|
1911
|
-
yourGift:
|
|
1916
|
+
giftLabels: import_zod22.z.object({
|
|
1917
|
+
addGift: import_zod22.z.record(import_zod22.z.string(), import_zod22.z.string()).default(() => ({ ...GIFT_LABELS.addGift })),
|
|
1918
|
+
remove: import_zod22.z.record(import_zod22.z.string(), import_zod22.z.string()).default(() => ({ ...GIFT_LABELS.remove })),
|
|
1919
|
+
selectOptions: import_zod22.z.record(import_zod22.z.string(), import_zod22.z.string()).default(() => ({ ...GIFT_LABELS.selectOptions })),
|
|
1920
|
+
yourGift: import_zod22.z.record(import_zod22.z.string(), import_zod22.z.string()).default(() => ({ ...GIFT_LABELS.yourGift }))
|
|
1912
1921
|
}).default(() => ({
|
|
1913
1922
|
addGift: { ...GIFT_LABELS.addGift },
|
|
1914
1923
|
remove: { ...GIFT_LABELS.remove },
|
|
@@ -1916,38 +1925,38 @@ var CABProgressBarSection = import_zod21.z.lazy(
|
|
|
1916
1925
|
yourGift: { ...GIFT_LABELS.yourGift }
|
|
1917
1926
|
})),
|
|
1918
1927
|
/** The bar's a11y label; the merchant names it in the editor, else this default (React parity). */
|
|
1919
|
-
name:
|
|
1928
|
+
name: import_zod22.z.string().default("Order progress"),
|
|
1920
1929
|
/**
|
|
1921
1930
|
* Bar fill color. An explicit (widget-authored) value is used verbatim; when absent the server
|
|
1922
1931
|
* fills it with the live shop theme's `buttonBackground` (React `useRebuyTheme` parity). Still
|
|
1923
1932
|
* absent after that ⇒ the theme fetch failed and the client renders its platform-default bar —
|
|
1924
1933
|
* optional, not defaulted, so "merchant chose no color" stays distinguishable from any real value.
|
|
1925
1934
|
*/
|
|
1926
|
-
progressColor:
|
|
1927
|
-
sectionType:
|
|
1935
|
+
progressColor: import_zod22.z.string().optional(),
|
|
1936
|
+
sectionType: import_zod22.z.literal(SectionType.progressBar).default(SectionType.progressBar),
|
|
1928
1937
|
/**
|
|
1929
1938
|
* The bar's milestones in the merchant's CONFIGURED order — the renderer does NOT sort them (022
|
|
1930
1939
|
* O-B2: sorting by resolved threshold reversed configured milestones on out-of-order or mixed-unit
|
|
1931
1940
|
* count-vs-cents bars). Drives the fill (even slot per tier) and, for smart-cart product tiers, the
|
|
1932
1941
|
* gift add/remove. The visual tier display lives in `sections` (composable), NOT here.
|
|
1933
1942
|
*/
|
|
1934
|
-
tiers:
|
|
1943
|
+
tiers: import_zod22.z.union([import_zod22.z.array(CABProgressTier), import_zod22.z.strictObject({}).transform(() => [])]).default(() => [])
|
|
1935
1944
|
})
|
|
1936
1945
|
);
|
|
1937
1946
|
|
|
1938
1947
|
// src/schema/widgets/checkout-and-beyond/quantity.ts
|
|
1939
1948
|
var import_uuid9 = require("uuid");
|
|
1940
|
-
var
|
|
1941
|
-
var CABQuantitySection =
|
|
1949
|
+
var import_zod23 = require("zod");
|
|
1950
|
+
var CABQuantitySection = import_zod23.z.object({
|
|
1942
1951
|
...CABVariableFields,
|
|
1943
|
-
errorMessages:
|
|
1944
|
-
|
|
1945
|
-
|
|
1952
|
+
errorMessages: import_zod23.z.record(
|
|
1953
|
+
import_zod23.z.string(),
|
|
1954
|
+
import_zod23.z.object({
|
|
1946
1955
|
/** `{{step}}` is interpolated at render — the off-increment message React never gave a merchant key. */
|
|
1947
|
-
increment:
|
|
1948
|
-
max:
|
|
1949
|
-
min:
|
|
1950
|
-
neg:
|
|
1956
|
+
increment: import_zod23.z.string().optional(),
|
|
1957
|
+
max: import_zod23.z.string().optional(),
|
|
1958
|
+
min: import_zod23.z.string().optional(),
|
|
1959
|
+
neg: import_zod23.z.string().optional()
|
|
1951
1960
|
})
|
|
1952
1961
|
).default({
|
|
1953
1962
|
en: {
|
|
@@ -1957,18 +1966,18 @@ var CABQuantitySection = import_zod22.z.object({
|
|
|
1957
1966
|
neg: "Quantity cannot be negative"
|
|
1958
1967
|
}
|
|
1959
1968
|
}),
|
|
1960
|
-
inputType:
|
|
1961
|
-
max:
|
|
1962
|
-
min:
|
|
1969
|
+
inputType: import_zod23.z.enum(quantityInputs).default(QuantityInput.select),
|
|
1970
|
+
max: import_zod23.z.number().min(1).max(100).default(10),
|
|
1971
|
+
min: import_zod23.z.number().min(1).default(1),
|
|
1963
1972
|
/** The a11y label for the quantity control; the merchant names it in the editor, else this default. */
|
|
1964
|
-
name:
|
|
1965
|
-
sectionId:
|
|
1966
|
-
sectionType:
|
|
1973
|
+
name: import_zod23.z.string().default("Quantity"),
|
|
1974
|
+
sectionId: import_zod23.z.uuid().default(() => (0, import_uuid9.v7)()),
|
|
1975
|
+
sectionType: import_zod23.z.literal(SectionType.quantity).default(SectionType.quantity)
|
|
1967
1976
|
});
|
|
1968
1977
|
|
|
1969
1978
|
// src/schema/widgets/checkout-and-beyond/reviews.ts
|
|
1970
1979
|
var import_uuid10 = require("uuid");
|
|
1971
|
-
var
|
|
1980
|
+
var import_zod24 = require("zod");
|
|
1972
1981
|
|
|
1973
1982
|
// src/schema/widgets/checkout-and-beyond/reviewLabels.ts
|
|
1974
1983
|
var REVIEW_LABELS = {
|
|
@@ -2031,68 +2040,69 @@ var REVIEW_LABELS = {
|
|
|
2031
2040
|
};
|
|
2032
2041
|
|
|
2033
2042
|
// src/schema/widgets/checkout-and-beyond/reviews.ts
|
|
2034
|
-
var CABReviewsSection =
|
|
2043
|
+
var CABReviewsSection = import_zod24.z.object({
|
|
2035
2044
|
...CABVariableFields,
|
|
2036
|
-
color:
|
|
2045
|
+
color: import_zod24.z.string().default("#fadb14"),
|
|
2037
2046
|
/**
|
|
2038
2047
|
* Localized review-count templates (`{{reviewCount}}`), one/other plural forms; the client picks the
|
|
2039
2048
|
* form via `Intl.PluralRules`. Defaults here (schema-first) so every tree localizes without converter
|
|
2040
2049
|
* or merchant work.
|
|
2041
2050
|
*/
|
|
2042
|
-
countLabels:
|
|
2043
|
-
one:
|
|
2044
|
-
other:
|
|
2051
|
+
countLabels: import_zod24.z.object({
|
|
2052
|
+
one: import_zod24.z.record(import_zod24.z.string(), import_zod24.z.string()).default(() => ({ ...REVIEW_LABELS.one })),
|
|
2053
|
+
other: import_zod24.z.record(import_zod24.z.string(), import_zod24.z.string()).default(() => ({ ...REVIEW_LABELS.other }))
|
|
2045
2054
|
}).default(() => ({ one: { ...REVIEW_LABELS.one }, other: { ...REVIEW_LABELS.other } })),
|
|
2046
|
-
name:
|
|
2047
|
-
sectionId:
|
|
2048
|
-
sectionType:
|
|
2049
|
-
size:
|
|
2055
|
+
name: import_zod24.z.string().optional(),
|
|
2056
|
+
sectionId: import_zod24.z.uuid().default(() => (0, import_uuid10.v7)()),
|
|
2057
|
+
sectionType: import_zod24.z.literal(SectionType.reviews).default(SectionType.reviews),
|
|
2058
|
+
size: import_zod24.z.enum(reviewsSizes).default(ReviewsSize.default),
|
|
2050
2059
|
/**
|
|
2051
2060
|
* Star outline color, interpolated into a style by the renderer, so it is hex-constrained like
|
|
2052
2061
|
* `CABButtonSection.color`. The legacy source (`PostPurchaseSettings.styles.starStrokeColor`) is a free
|
|
2053
2062
|
* string: its converter must validate and fall back to this default rather than let one odd value drop
|
|
2054
2063
|
* the whole reviews section.
|
|
2055
2064
|
*/
|
|
2056
|
-
strokeColor:
|
|
2065
|
+
strokeColor: import_zod24.z.string().regex(HEX_COLOR_REGEX).default("#fadb14"),
|
|
2057
2066
|
/** Star outline width in px; `0` draws no outline. The legacy `styles.strokeWidth` is a STRING ('1') — its converter coerces. */
|
|
2058
|
-
strokeWidth:
|
|
2067
|
+
strokeWidth: import_zod24.z.number().nonnegative().default(0)
|
|
2059
2068
|
});
|
|
2060
2069
|
|
|
2061
2070
|
// src/schema/widgets/checkout-and-beyond/separator.ts
|
|
2062
2071
|
var import_uuid11 = require("uuid");
|
|
2063
|
-
var
|
|
2064
|
-
var CABSeparatorSection =
|
|
2072
|
+
var import_zod25 = require("zod");
|
|
2073
|
+
var CABSeparatorSection = import_zod25.z.object({
|
|
2065
2074
|
...CABVariableFields,
|
|
2066
|
-
sectionId:
|
|
2067
|
-
sectionType:
|
|
2075
|
+
sectionId: import_zod25.z.uuid().default(() => (0, import_uuid11.v7)()),
|
|
2076
|
+
sectionType: import_zod25.z.literal(SectionType.separator).default(SectionType.separator)
|
|
2068
2077
|
});
|
|
2069
2078
|
|
|
2070
2079
|
// src/schema/widgets/checkout-and-beyond/variants.ts
|
|
2071
2080
|
var import_compat3 = require("es-toolkit/compat");
|
|
2072
2081
|
var import_uuid12 = require("uuid");
|
|
2073
|
-
var
|
|
2074
|
-
var CABVariantsSection =
|
|
2082
|
+
var import_zod26 = require("zod");
|
|
2083
|
+
var CABVariantsSection = import_zod26.z.object({
|
|
2075
2084
|
...CABVariableFields,
|
|
2076
|
-
hideOutOfStockVariants:
|
|
2077
|
-
name:
|
|
2078
|
-
sectionId:
|
|
2079
|
-
sectionType:
|
|
2080
|
-
selector:
|
|
2081
|
-
|
|
2085
|
+
hideOutOfStockVariants: import_zod26.z.boolean().default(false),
|
|
2086
|
+
name: import_zod26.z.string().optional(),
|
|
2087
|
+
sectionId: import_zod26.z.uuid().default(() => (0, import_uuid12.v7)()),
|
|
2088
|
+
sectionType: import_zod26.z.literal(SectionType.variants).default(SectionType.variants),
|
|
2089
|
+
selector: import_zod26.z.enum((0, import_compat3.slice)(variantSelectors, 0, 3)).default(VariantSelector.menu),
|
|
2090
|
+
/** `productGroup` is additive (REB-24817): a renderer without group support must render nothing for it. */
|
|
2091
|
+
variantMode: import_zod26.z.enum(variantsModes).default(VariantsMode.multiple)
|
|
2082
2092
|
});
|
|
2083
2093
|
|
|
2084
2094
|
// src/schema/widgets/checkout-and-beyond/shared.ts
|
|
2085
|
-
var CABBorder =
|
|
2086
|
-
radius:
|
|
2087
|
-
style:
|
|
2088
|
-
width:
|
|
2095
|
+
var CABBorder = import_zod27.z.object({
|
|
2096
|
+
radius: import_zod27.z.enum(borderRadii).default(BorderRadius.base),
|
|
2097
|
+
style: import_zod27.z.enum(borderStyles).default(BorderStyle.none),
|
|
2098
|
+
width: import_zod27.z.enum(borderWidths).default(BorderWidth.base)
|
|
2089
2099
|
}).default({
|
|
2090
2100
|
radius: BorderRadius.base,
|
|
2091
2101
|
style: BorderStyle.none,
|
|
2092
2102
|
width: BorderWidth.base
|
|
2093
2103
|
});
|
|
2094
|
-
var CABSection =
|
|
2095
|
-
() =>
|
|
2104
|
+
var CABSection = import_zod27.z.lazy(
|
|
2105
|
+
() => import_zod27.z.discriminatedUnion("sectionType", [
|
|
2096
2106
|
CABBannerSection,
|
|
2097
2107
|
CABButtonSection,
|
|
2098
2108
|
CABCarouselSection,
|
|
@@ -2115,17 +2125,17 @@ var CABSection = import_zod26.z.lazy(
|
|
|
2115
2125
|
);
|
|
2116
2126
|
|
|
2117
2127
|
// src/schema/widgets/checkout-and-beyond/image.ts
|
|
2118
|
-
var CABImageSectionFields =
|
|
2128
|
+
var CABImageSectionFields = import_zod28.z.object({
|
|
2119
2129
|
...CABVariableFields,
|
|
2120
|
-
altText:
|
|
2130
|
+
altText: import_zod28.z.string().refine(checkForHTML, NO_HTML).default(""),
|
|
2121
2131
|
/**
|
|
2122
2132
|
* Image width÷height (e.g. `46` for the progress-bar fill); `null` renders at natural size. Any POSITIVE
|
|
2123
2133
|
* ratio — never limited to 1, but never `0`/negative either: a renderer dividing by it would get `Infinity`,
|
|
2124
2134
|
* and CSS `aspect-ratio` drops a negative value and silently reverts to natural size.
|
|
2125
2135
|
*/
|
|
2126
|
-
aspectRatio:
|
|
2127
|
-
border:
|
|
2128
|
-
buttonField:
|
|
2136
|
+
aspectRatio: import_zod28.z.number().positive().nullable().default(null),
|
|
2137
|
+
border: import_zod28.z.lazy(() => CABBorder),
|
|
2138
|
+
buttonField: import_zod28.z.enum(buttonFields).optional(),
|
|
2129
2139
|
/**
|
|
2130
2140
|
* `icon` renders `source` as a single `s-icon` by name (the uber-image path covers icons too), reading
|
|
2131
2141
|
* `iconSize`/`iconTone`. The other values are a harmless informational holdover from the previous
|
|
@@ -2144,29 +2154,30 @@ var CABImageSectionFields = import_zod27.z.object({
|
|
|
2144
2154
|
* behavior degraded gracefully and told us about it. The client-assembled half of the invariant was never
|
|
2145
2155
|
* the risky half.
|
|
2146
2156
|
*/
|
|
2147
|
-
category:
|
|
2157
|
+
category: import_zod28.z.enum(["gallery", "icon", "icons", "payment-methods", "secure-checkout"]).nullable().default(null),
|
|
2148
2158
|
/** `icon`-mode only: the `s-icon` `size`; `null` ⇒ the component default (`base`). Ignored by image treatments. */
|
|
2149
|
-
iconSize:
|
|
2159
|
+
iconSize: import_zod28.z.enum(iconSizes).nullable().default(null),
|
|
2150
2160
|
/** `icon`-mode only: the `s-icon` `tone`; `null` ⇒ the component default (`auto`). Ignored by image treatments. */
|
|
2151
|
-
iconTone:
|
|
2152
|
-
name:
|
|
2153
|
-
naturalHeight:
|
|
2154
|
-
naturalWidth:
|
|
2161
|
+
iconTone: import_zod28.z.enum(iconTones).nullable().default(null),
|
|
2162
|
+
name: import_zod28.z.string().optional(),
|
|
2163
|
+
naturalHeight: import_zod28.z.number().default(0),
|
|
2164
|
+
naturalWidth: import_zod28.z.number().default(0),
|
|
2155
2165
|
/**
|
|
2156
2166
|
* `contain` (the component default): dimensionless images render in s-image's 1/1 default frame, and
|
|
2157
2167
|
* `cover` would crop non-square art (payment badges lost their edges — 15993); `contain` letterboxes.
|
|
2158
2168
|
*/
|
|
2159
|
-
objectFit:
|
|
2160
|
-
sectionId:
|
|
2161
|
-
sectionType:
|
|
2169
|
+
objectFit: import_zod28.z.enum(objectFits).default(ObjectFit.contain),
|
|
2170
|
+
sectionId: import_zod28.z.uuid().default(() => (0, import_uuid13.v7)()),
|
|
2171
|
+
sectionType: import_zod28.z.literal(SectionType.image).default(SectionType.image),
|
|
2162
2172
|
/**
|
|
2163
2173
|
* An image URL or dynamic token, an empty default, or — when `category: 'icon'` — an icon NAME. Icon mode
|
|
2164
2174
|
* takes a name or `''` only, NOT a token: no renderer resolves a token to an icon today, so accepting one
|
|
2165
2175
|
* would promise a capability that doesn't exist. Widen the refine's carve-out to `DYNAMIC_TOKEN_REGEX` when a
|
|
2166
2176
|
* server-chosen tier icon actually needs it.
|
|
2167
2177
|
*/
|
|
2168
|
-
source:
|
|
2169
|
-
|
|
2178
|
+
source: import_zod28.z.union([import_zod28.z.url(), import_zod28.z.literal(""), import_zod28.z.string().regex(DYNAMIC_TOKEN_REGEX), import_zod28.z.enum(iconNames)]).default(""),
|
|
2179
|
+
thumbnails: CABImageThumbnails.optional(),
|
|
2180
|
+
width: import_zod28.z.number().default(100)
|
|
2170
2181
|
});
|
|
2171
2182
|
var iconNameSet = new Set(iconNames);
|
|
2172
2183
|
var isIconName = (source2) => iconNameSet.has(source2);
|
|
@@ -2317,7 +2328,7 @@ var convertContentBlockTextToV2 = (language3, text2 = literalText, textAlign = "
|
|
|
2317
2328
|
};
|
|
2318
2329
|
|
|
2319
2330
|
// src/schema/widgets/checkout-and-beyond/root.ts
|
|
2320
|
-
var
|
|
2331
|
+
var import_zod29 = require("zod");
|
|
2321
2332
|
|
|
2322
2333
|
// src/schema/widgets/checkout-and-beyond/uiLabels.ts
|
|
2323
2334
|
var UI_LABELS = {
|
|
@@ -2337,8 +2348,8 @@ var UI_LABELS = {
|
|
|
2337
2348
|
};
|
|
2338
2349
|
|
|
2339
2350
|
// src/schema/widgets/checkout-and-beyond/root.ts
|
|
2340
|
-
var localized = (fallback) =>
|
|
2341
|
-
var CABUILabels =
|
|
2351
|
+
var localized = (fallback) => import_zod29.z.record(import_zod29.z.string(), import_zod29.z.string()).default(() => ({ ...fallback })).transform((labels) => Object.keys(labels).length > 0 ? labels : { ...fallback });
|
|
2352
|
+
var CABUILabels = import_zod29.z.object({
|
|
2342
2353
|
currentPage: localized(UI_LABELS.currentPage),
|
|
2343
2354
|
guest: localized(UI_LABELS.guest),
|
|
2344
2355
|
loadingOptions: localized(UI_LABELS.loadingOptions),
|
|
@@ -2363,37 +2374,37 @@ var CABUILabels = import_zod28.z.object({
|
|
|
2363
2374
|
subscriptionOptions: { ...UI_LABELS.subscriptionOptions },
|
|
2364
2375
|
updating: { ...UI_LABELS.updating }
|
|
2365
2376
|
}));
|
|
2366
|
-
var TargetArea =
|
|
2367
|
-
fill:
|
|
2368
|
-
flip:
|
|
2369
|
-
icon:
|
|
2370
|
-
label:
|
|
2371
|
-
width:
|
|
2377
|
+
var TargetArea = import_zod29.z.object({
|
|
2378
|
+
fill: import_zod29.z.boolean().optional(),
|
|
2379
|
+
flip: import_zod29.z.enum(["both", "horizontal", "vertical"]).optional(),
|
|
2380
|
+
icon: import_zod29.z.string(),
|
|
2381
|
+
label: import_zod29.z.string(),
|
|
2382
|
+
width: import_zod29.z.string()
|
|
2372
2383
|
}).default(targetAreas[EditorMode.checkoutExtension][1]);
|
|
2373
|
-
var CABTracking =
|
|
2374
|
-
enableAttribution:
|
|
2375
|
-
enableSource:
|
|
2376
|
-
enableWidget:
|
|
2384
|
+
var CABTracking = import_zod29.z.object({
|
|
2385
|
+
enableAttribution: import_zod29.z.boolean().nullish().transform((value) => value ?? true),
|
|
2386
|
+
enableSource: import_zod29.z.boolean().nullish().transform((value) => value ?? true),
|
|
2387
|
+
enableWidget: import_zod29.z.boolean().nullish().transform((value) => value ?? true)
|
|
2377
2388
|
}).nullish().transform((value) => value ?? { enableAttribution: true, enableSource: true, enableWidget: true });
|
|
2378
|
-
var CABExperiment =
|
|
2379
|
-
elementId:
|
|
2380
|
-
experimentId:
|
|
2381
|
-
experimentType:
|
|
2382
|
-
selectedId:
|
|
2389
|
+
var CABExperiment = import_zod29.z.object({
|
|
2390
|
+
elementId: import_zod29.z.number(),
|
|
2391
|
+
experimentId: import_zod29.z.number(),
|
|
2392
|
+
experimentType: import_zod29.z.string(),
|
|
2393
|
+
selectedId: import_zod29.z.number()
|
|
2383
2394
|
});
|
|
2384
2395
|
var CABRootSection = CABLayoutSection.extend({
|
|
2385
|
-
editorMode:
|
|
2396
|
+
editorMode: import_zod29.z.enum(editorModes).default(EditorMode.checkoutExtension),
|
|
2386
2397
|
experiment: CABExperiment.optional(),
|
|
2387
2398
|
// Same rule as CABTracking above: the v1 converters pass raw legacy `previewMode` through, so a
|
|
2388
2399
|
// `null` must fall back rather than throw the widget; malformed values still throw.
|
|
2389
|
-
previewMode:
|
|
2390
|
-
storeId:
|
|
2400
|
+
previewMode: import_zod29.z.boolean().nullish().transform((value) => value ?? false),
|
|
2401
|
+
storeId: import_zod29.z.number().nullable().default(null),
|
|
2391
2402
|
targetArea: TargetArea.nullable(),
|
|
2392
2403
|
tracking: CABTracking,
|
|
2393
|
-
type:
|
|
2404
|
+
type: import_zod29.z.enum(widgetTypes).default(WidgetType.ui_extension_content_block),
|
|
2394
2405
|
uiLabels: CABUILabels,
|
|
2395
|
-
version:
|
|
2396
|
-
widgetId:
|
|
2406
|
+
version: import_zod29.z.literal(2).default(2),
|
|
2407
|
+
widgetId: import_zod29.z.number().nullable().default(null)
|
|
2397
2408
|
});
|
|
2398
2409
|
|
|
2399
2410
|
// src/transforms/v1Location.ts
|
|
@@ -3231,21 +3242,26 @@ var convertPlaceholderToV2 = ({ id, settings }) => CABRootSection.parse({
|
|
|
3231
3242
|
// src/transforms/placeholderV1/types.ts
|
|
3232
3243
|
var isPlaceholderV1 = (data) => !!data && typeof data === "object" && data.type === WidgetType.placeholder;
|
|
3233
3244
|
|
|
3234
|
-
// src/transforms/
|
|
3235
|
-
var
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
var
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3245
|
+
// src/transforms/productCard/earnedText.ts
|
|
3246
|
+
var contentMutator = (effect, variable, operator) => ({
|
|
3247
|
+
effect,
|
|
3248
|
+
variable,
|
|
3249
|
+
when: { operator, type: "content" }
|
|
3250
|
+
});
|
|
3251
|
+
var earnedFrom = (variable) => [
|
|
3252
|
+
contentMutator("set_false", variable, "is_empty"),
|
|
3253
|
+
contentMutator("set_true", variable, "is_not_empty")
|
|
3254
|
+
];
|
|
3255
|
+
var shownWhile = (variable) => ({ variable, visibleWhen: true });
|
|
3256
|
+
var earnedText = (variable, content) => ({
|
|
3257
|
+
content: { en: content },
|
|
3258
|
+
mutators: earnedFrom(variable),
|
|
3259
|
+
sectionType: "text",
|
|
3260
|
+
visibility: shownWhile(variable)
|
|
3261
|
+
});
|
|
3262
|
+
|
|
3263
|
+
// src/transforms/productCard/priceText.ts
|
|
3264
|
+
var priceContent = () => ({
|
|
3249
3265
|
content: [
|
|
3250
3266
|
{
|
|
3251
3267
|
content: [
|
|
@@ -3271,6 +3287,64 @@ var buildPriceContent = () => ({
|
|
|
3271
3287
|
],
|
|
3272
3288
|
type: "doc"
|
|
3273
3289
|
});
|
|
3290
|
+
var priceText = () => ({
|
|
3291
|
+
content: { en: priceContent() },
|
|
3292
|
+
sectionType: "text"
|
|
3293
|
+
});
|
|
3294
|
+
|
|
3295
|
+
// src/transforms/productCard/quantitySection.ts
|
|
3296
|
+
var quantitySection = ({ errorMessages, inputType, maxValue, minValue, name }) => {
|
|
3297
|
+
const max = Math.min(Math.max(maxValue ?? 10, 1), 100);
|
|
3298
|
+
const min = Math.min(Math.max(minValue ?? 1, 1), max);
|
|
3299
|
+
return {
|
|
3300
|
+
...errorMessages && { errorMessages },
|
|
3301
|
+
...inputType && { inputType },
|
|
3302
|
+
max,
|
|
3303
|
+
min,
|
|
3304
|
+
...name && { name },
|
|
3305
|
+
sectionType: "quantity"
|
|
3306
|
+
};
|
|
3307
|
+
};
|
|
3308
|
+
|
|
3309
|
+
// src/transforms/productCard/subscriptionToggle.ts
|
|
3310
|
+
var SWITCH_LABEL_TOKENS2 = ["subscriptionDiscount", "frequency", "interval"];
|
|
3311
|
+
var subscriptionToggle = (productType, labels = {}) => {
|
|
3312
|
+
if (productType !== "both" && productType !== "subscription") return [];
|
|
3313
|
+
const slot = (buttonField, override) => ({
|
|
3314
|
+
buttonField,
|
|
3315
|
+
content: localizedContent(SWITCH_LABELS[buttonField], override, SWITCH_LABEL_TOKENS2),
|
|
3316
|
+
sectionType: "text"
|
|
3317
|
+
});
|
|
3318
|
+
return [
|
|
3319
|
+
{
|
|
3320
|
+
action: "switchToSubscription",
|
|
3321
|
+
buttonStyle: "plain",
|
|
3322
|
+
/** A `subscription` widget offers no one-time purchase; suppress the downgrade so the buyer can't switch to one-time. */
|
|
3323
|
+
...productType === "subscription" && { disableDowngrade: true },
|
|
3324
|
+
sections: [
|
|
3325
|
+
slot("subscriptionOption", void 0),
|
|
3326
|
+
slot("switchToOneTimePurchase", labels.oneTime),
|
|
3327
|
+
slot("switchToSubscriptionNoDiscount", labels.upgrade),
|
|
3328
|
+
slot("switchToSubscriptionWithDiscount", labels.upgrade)
|
|
3329
|
+
],
|
|
3330
|
+
sectionType: "button"
|
|
3331
|
+
}
|
|
3332
|
+
];
|
|
3333
|
+
};
|
|
3334
|
+
|
|
3335
|
+
// src/transforms/offerV1/offerCard.ts
|
|
3336
|
+
var borderToken = (tokens, value) => value !== void 0 && tokens.includes(value) ? value : "base";
|
|
3337
|
+
var GRID_CARD_IMAGE_PX = 120;
|
|
3338
|
+
var COMPACT_CARD_IMAGE_PX = 64;
|
|
3339
|
+
var ADD_LABEL_TOKENS = ["quantity", "price", "total"];
|
|
3340
|
+
var QUANTITY_ERROR_TOKENS = ["max", "min", "step"];
|
|
3341
|
+
var VARIANT_SELECTOR = { button: "button", radio: "radio", select: "menu" };
|
|
3342
|
+
var buildStyledText = (token, style, fontSize = style?.textSize ?? "base") => {
|
|
3343
|
+
const marks2 = [{ attrs: { color: "base", fontSize }, type: "textStyle" }];
|
|
3344
|
+
if (style?.textEmphasis === "bold") marks2.push({ type: "bold" });
|
|
3345
|
+
if (style?.textEmphasis === "italic") marks2.push({ type: "italic" });
|
|
3346
|
+
return { content: [{ content: [{ marks: marks2, text: token, type: "text" }], type: "paragraph" }], type: "doc" };
|
|
3347
|
+
};
|
|
3274
3348
|
var buildReviews = (settings) => {
|
|
3275
3349
|
if (!settings.integrations || !Object.values(settings.integrations).some(Boolean)) return [];
|
|
3276
3350
|
const reviews = settings.displaySettings?.reviews;
|
|
@@ -3312,29 +3386,11 @@ var buildTitle = (settings) => ({
|
|
|
3312
3386
|
},
|
|
3313
3387
|
sectionType: "text"
|
|
3314
3388
|
});
|
|
3315
|
-
var buildPrice = () => ({
|
|
3316
|
-
content: { en: buildPriceContent() },
|
|
3317
|
-
sectionType: "text"
|
|
3318
|
-
});
|
|
3319
3389
|
var HAS_VARIANT_TITLE = "hasVariantTitle";
|
|
3320
3390
|
var buildVariantTitle = (settings) => {
|
|
3321
3391
|
const show = settings.productOptions?.showVariantTitle;
|
|
3322
3392
|
if (!show || show === "hide") return [];
|
|
3323
|
-
return [
|
|
3324
|
-
{
|
|
3325
|
-
content: { en: buildStyledText("{{variantTitle}}", settings.displaySettings?.variant) },
|
|
3326
|
-
mutators: [
|
|
3327
|
-
{ effect: "set_false", variable: HAS_VARIANT_TITLE, when: { operator: "is_empty", type: "content" } },
|
|
3328
|
-
{
|
|
3329
|
-
effect: "set_true",
|
|
3330
|
-
variable: HAS_VARIANT_TITLE,
|
|
3331
|
-
when: { operator: "is_not_empty", type: "content" }
|
|
3332
|
-
}
|
|
3333
|
-
],
|
|
3334
|
-
sectionType: "text",
|
|
3335
|
-
visibility: { variable: HAS_VARIANT_TITLE, visibleWhen: true }
|
|
3336
|
-
}
|
|
3337
|
-
];
|
|
3393
|
+
return [earnedText(HAS_VARIANT_TITLE, buildStyledText("{{variantTitle}}", settings.displaySettings?.variant))];
|
|
3338
3394
|
};
|
|
3339
3395
|
var detailBlock = (sections, horizontal, hasVariantTitleLine) => ({
|
|
3340
3396
|
alignment: { horizontal: horizontal ? "start" : "center", vertical: "top" },
|
|
@@ -3363,18 +3419,7 @@ var buildDescription = (settings) => {
|
|
|
3363
3419
|
},
|
|
3364
3420
|
{
|
|
3365
3421
|
content: { en: buildStyledText("{{productDescription}}", void 0) },
|
|
3366
|
-
mutators:
|
|
3367
|
-
{
|
|
3368
|
-
effect: "set_false",
|
|
3369
|
-
variable: HAS_DESCRIPTION,
|
|
3370
|
-
when: { operator: "is_empty", type: "content" }
|
|
3371
|
-
},
|
|
3372
|
-
{
|
|
3373
|
-
effect: "set_true",
|
|
3374
|
-
variable: HAS_DESCRIPTION,
|
|
3375
|
-
when: { operator: "is_not_empty", type: "content" }
|
|
3376
|
-
}
|
|
3377
|
-
],
|
|
3422
|
+
mutators: earnedFrom(HAS_DESCRIPTION),
|
|
3378
3423
|
sectionType: "text",
|
|
3379
3424
|
visibility: { variable: SHOW_DESCRIPTION, visibleWhen: true }
|
|
3380
3425
|
}
|
|
@@ -3390,7 +3435,7 @@ var buildDescription = (settings) => {
|
|
|
3390
3435
|
var SHOW_VARIANTS = "showVariants";
|
|
3391
3436
|
var REVEAL_PENDING = "revealPending";
|
|
3392
3437
|
var revealsVariants = (settings) => settings.viewOptions?.displayActions !== false && settings.productOptions?.showVariantOptions === "default";
|
|
3393
|
-
var
|
|
3438
|
+
var contentMutator2 = (effect, variable, operator) => ({
|
|
3394
3439
|
effect,
|
|
3395
3440
|
variable,
|
|
3396
3441
|
when: { operator, type: "content" }
|
|
@@ -3404,10 +3449,10 @@ var buildVariants = (settings) => {
|
|
|
3404
3449
|
hideOutOfStockVariants: !!settings.productOptions?.hideOutOfStockVariants,
|
|
3405
3450
|
...revealsVariants(settings) && {
|
|
3406
3451
|
mutators: [
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3452
|
+
contentMutator2("set_true", SHOW_VARIANTS, "is_empty"),
|
|
3453
|
+
contentMutator2("set_false", REVEAL_PENDING, "is_empty"),
|
|
3454
|
+
contentMutator2("set_true", REVEAL_PENDING, "is_not_empty"),
|
|
3455
|
+
contentMutator2("set_false", SHOW_VARIANTS, "is_not_empty")
|
|
3411
3456
|
]
|
|
3412
3457
|
},
|
|
3413
3458
|
...selector && { selector: VARIANT_SELECTOR[selector] },
|
|
@@ -3421,54 +3466,31 @@ var QUANTITY_INPUT_TYPE = {
|
|
|
3421
3466
|
"buttons-manual-input": "number",
|
|
3422
3467
|
"dropdown-select": "select"
|
|
3423
3468
|
};
|
|
3424
|
-
var buildQuantityErrors = (
|
|
3469
|
+
var buildQuantityErrors = (quantity3) => {
|
|
3425
3470
|
const en = {
|
|
3426
|
-
...
|
|
3427
|
-
...
|
|
3428
|
-
...
|
|
3471
|
+
...quantity3.maxError && { max: normalizeTokens(quantity3.maxError, QUANTITY_ERROR_TOKENS) },
|
|
3472
|
+
...quantity3.minError && { min: normalizeTokens(quantity3.minError, QUANTITY_ERROR_TOKENS) },
|
|
3473
|
+
...quantity3.negativeError && { neg: normalizeTokens(quantity3.negativeError, QUANTITY_ERROR_TOKENS) }
|
|
3429
3474
|
};
|
|
3430
3475
|
return Object.keys(en).length ? { errorMessages: { en } } : {};
|
|
3431
3476
|
};
|
|
3432
3477
|
var buildQuantity = (settings) => {
|
|
3433
|
-
const
|
|
3434
|
-
if (!
|
|
3435
|
-
const
|
|
3436
|
-
const max = Math.min(Math.max(quantity2.maxValue ?? 10, 1), 100);
|
|
3437
|
-
const min = Math.min(Math.max(quantity2.minValue ?? 1, 1), max);
|
|
3438
|
-
return [
|
|
3439
|
-
{
|
|
3440
|
-
...buildQuantityErrors(quantity2),
|
|
3441
|
-
...inputType && { inputType },
|
|
3442
|
-
max,
|
|
3443
|
-
min,
|
|
3444
|
-
sectionType: "quantity"
|
|
3445
|
-
}
|
|
3446
|
-
];
|
|
3447
|
-
};
|
|
3448
|
-
var buildSubscriptionButton = (settings) => {
|
|
3449
|
-
if (settings.productType !== "both" && settings.productType !== "subscription") return [];
|
|
3450
|
-
const language3 = settings.language;
|
|
3451
|
-
const slot = (buttonField, override) => ({
|
|
3452
|
-
buttonField,
|
|
3453
|
-
content: localizedContent(SWITCH_LABELS[buttonField], override, SWITCH_LABEL_TOKENS2),
|
|
3454
|
-
sectionType: "text"
|
|
3455
|
-
});
|
|
3478
|
+
const quantity3 = settings.quantityInputs;
|
|
3479
|
+
if (!quantity3?.enabled) return [];
|
|
3480
|
+
const errors = buildQuantityErrors(quantity3);
|
|
3456
3481
|
return [
|
|
3457
|
-
{
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
slot("subscriptionOption", void 0),
|
|
3464
|
-
slot("switchToOneTimePurchase", language3?.cartSwitchToOnetime),
|
|
3465
|
-
slot("switchToSubscriptionNoDiscount", language3?.upgradeToSubscription),
|
|
3466
|
-
slot("switchToSubscriptionWithDiscount", language3?.upgradeToSubscription)
|
|
3467
|
-
],
|
|
3468
|
-
sectionType: "button"
|
|
3469
|
-
}
|
|
3482
|
+
quantitySection({
|
|
3483
|
+
...errors,
|
|
3484
|
+
inputType: quantity3.type ? QUANTITY_INPUT_TYPE[quantity3.type] : void 0,
|
|
3485
|
+
maxValue: quantity3.maxValue,
|
|
3486
|
+
minValue: quantity3.minValue
|
|
3487
|
+
})
|
|
3470
3488
|
];
|
|
3471
3489
|
};
|
|
3490
|
+
var buildSubscriptionButton = (settings) => subscriptionToggle(settings.productType, {
|
|
3491
|
+
oneTime: settings.language?.cartSwitchToOnetime,
|
|
3492
|
+
upgrade: settings.language?.upgradeToSubscription
|
|
3493
|
+
});
|
|
3472
3494
|
var BUTTON_KINDS2 = ["plain", "primary", "secondary"];
|
|
3473
3495
|
var buttonKind = (settings) => {
|
|
3474
3496
|
const kind = settings.button?.kind;
|
|
@@ -3514,15 +3536,15 @@ var buildOfferCard = (settings, horizontal) => {
|
|
|
3514
3536
|
const image = buildImage(settings);
|
|
3515
3537
|
const title = buildTitle(settings);
|
|
3516
3538
|
const variantTitle = buildVariantTitle(settings);
|
|
3517
|
-
const price =
|
|
3539
|
+
const price = priceText();
|
|
3518
3540
|
const description = buildDescription(settings);
|
|
3519
3541
|
const reviews = buildReviews(settings);
|
|
3520
3542
|
const variants = buildVariants(settings);
|
|
3521
|
-
const
|
|
3543
|
+
const quantity3 = buildQuantity(settings);
|
|
3522
3544
|
const subscription2 = buildSubscriptionButton(settings);
|
|
3523
3545
|
const reveal = buildRevealButton(settings);
|
|
3524
3546
|
const addButton = buildAddButton(settings);
|
|
3525
|
-
const controls = [...description, ...
|
|
3547
|
+
const controls = [...description, ...quantity3, ...variants, ...subscription2];
|
|
3526
3548
|
const info = detailBlock([title, ...variantTitle, ...reviews, price], horizontal, variantTitle.length > 0);
|
|
3527
3549
|
const card = (sections) => [
|
|
3528
3550
|
{
|
|
@@ -3818,18 +3840,18 @@ var convertOfferToV2 = ({ id, name, settings }) => {
|
|
|
3818
3840
|
var parseShielded = (schema, raw, transform = (input) => input) => schema.parse(transform(convertNumericObjects(deepCamelCase(raw))));
|
|
3819
3841
|
|
|
3820
3842
|
// src/transforms/postPurchase/convertMessagePreview.ts
|
|
3821
|
-
var
|
|
3843
|
+
var import_zod40 = require("zod");
|
|
3822
3844
|
|
|
3823
3845
|
// src/transforms/postPurchase/convertCalloutBlock.ts
|
|
3824
|
-
var
|
|
3846
|
+
var import_zod32 = require("zod");
|
|
3825
3847
|
|
|
3826
3848
|
// src/schema/widgets/post-purchase-offer/postPurchaseBlocks.ts
|
|
3827
3849
|
var import_compat4 = require("es-toolkit/compat");
|
|
3828
3850
|
var import_uuid14 = require("uuid");
|
|
3829
|
-
var
|
|
3851
|
+
var import_zod31 = require("zod");
|
|
3830
3852
|
|
|
3831
3853
|
// src/schema/widgets/post-purchase-offer/constants.ts
|
|
3832
|
-
var
|
|
3854
|
+
var import_zod30 = require("zod");
|
|
3833
3855
|
var blockTypes = [
|
|
3834
3856
|
"callout_banner",
|
|
3835
3857
|
"image",
|
|
@@ -3840,141 +3862,141 @@ var blockTypes = [
|
|
|
3840
3862
|
"text",
|
|
3841
3863
|
"timer"
|
|
3842
3864
|
];
|
|
3843
|
-
var blockType =
|
|
3865
|
+
var blockType = import_zod30.z.enum(blockTypes);
|
|
3844
3866
|
var BlockType = blockType.enum;
|
|
3845
3867
|
|
|
3846
3868
|
// src/schema/widgets/post-purchase-offer/postPurchaseBlocks.ts
|
|
3847
|
-
var TextAlignment2 =
|
|
3848
|
-
var TextSize =
|
|
3849
|
-
|
|
3850
|
-
|
|
3869
|
+
var TextAlignment2 = import_zod31.z.union([import_zod31.z.enum(["leading", "center", "trailing"]), import_zod31.z.unknown().transform(() => "leading")]);
|
|
3870
|
+
var TextSize = import_zod31.z.union([
|
|
3871
|
+
import_zod31.z.enum(["xsmall", "small", "base", "default", "medium", "large", "xlarge"]),
|
|
3872
|
+
import_zod31.z.unknown().transform(() => "medium")
|
|
3851
3873
|
]);
|
|
3852
|
-
var CalloutBannerBlock =
|
|
3853
|
-
id:
|
|
3854
|
-
name:
|
|
3855
|
-
settings:
|
|
3856
|
-
superTitle:
|
|
3857
|
-
title:
|
|
3874
|
+
var CalloutBannerBlock = import_zod31.z.object({
|
|
3875
|
+
id: import_zod31.z.string().optional().default(() => (0, import_uuid14.v4)()),
|
|
3876
|
+
name: import_zod31.z.string().optional(),
|
|
3877
|
+
settings: import_zod31.z.object({
|
|
3878
|
+
superTitle: import_zod31.z.union([import_zod31.z.string(), TiptapDocument]).default(() => "Limited-time Offer"),
|
|
3879
|
+
title: import_zod31.z.union([import_zod31.z.string(), TiptapDocument]).default(() => "Add this customer favorite to your order")
|
|
3858
3880
|
}),
|
|
3859
|
-
styles:
|
|
3860
|
-
superTitleEmphasized:
|
|
3881
|
+
styles: import_zod31.z.object({
|
|
3882
|
+
superTitleEmphasized: import_zod31.z.boolean().default(false),
|
|
3861
3883
|
superTitleSize: TextSize.default("large"),
|
|
3862
3884
|
textAlignment: TextAlignment2.default("center"),
|
|
3863
|
-
titleEmphasized:
|
|
3885
|
+
titleEmphasized: import_zod31.z.boolean().default(true),
|
|
3864
3886
|
titleSize: TextSize.default("large")
|
|
3865
3887
|
}),
|
|
3866
|
-
type:
|
|
3888
|
+
type: import_zod31.z.literal(BlockType.callout_banner).default(BlockType.callout_banner)
|
|
3867
3889
|
});
|
|
3868
|
-
var ImageBlock =
|
|
3869
|
-
id:
|
|
3870
|
-
name:
|
|
3871
|
-
settings:
|
|
3872
|
-
|
|
3890
|
+
var ImageBlock = import_zod31.z.object({
|
|
3891
|
+
id: import_zod31.z.string().optional().default(() => (0, import_uuid14.v4)()),
|
|
3892
|
+
name: import_zod31.z.string().optional(),
|
|
3893
|
+
settings: import_zod31.z.union([
|
|
3894
|
+
import_zod31.z.object({
|
|
3873
3895
|
/** This isn't used in the post-purchase offer widget */
|
|
3874
|
-
alt:
|
|
3875
|
-
image:
|
|
3876
|
-
imageSize:
|
|
3877
|
-
imageType:
|
|
3896
|
+
alt: import_zod31.z.string().optional().default(""),
|
|
3897
|
+
image: import_zod31.z.union([import_zod31.z.literal(""), import_zod31.z.url()]).default(""),
|
|
3898
|
+
imageSize: import_zod31.z.number().default(20),
|
|
3899
|
+
imageType: import_zod31.z.enum(["URL", "UPLOAD"]).default("URL")
|
|
3878
3900
|
}),
|
|
3879
|
-
|
|
3901
|
+
import_zod31.z.array(import_zod31.z.never()).transform(() => ({}))
|
|
3880
3902
|
]),
|
|
3881
|
-
type:
|
|
3882
|
-
});
|
|
3883
|
-
var ImageContentBlock =
|
|
3884
|
-
id:
|
|
3885
|
-
name:
|
|
3886
|
-
settings:
|
|
3887
|
-
alt:
|
|
3888
|
-
description:
|
|
3903
|
+
type: import_zod31.z.literal(BlockType.image).default(BlockType.image)
|
|
3904
|
+
});
|
|
3905
|
+
var ImageContentBlock = import_zod31.z.object({
|
|
3906
|
+
id: import_zod31.z.string().optional().default(() => (0, import_uuid14.v4)()),
|
|
3907
|
+
name: import_zod31.z.string().optional(),
|
|
3908
|
+
settings: import_zod31.z.object({
|
|
3909
|
+
alt: import_zod31.z.string().optional().default(""),
|
|
3910
|
+
description: import_zod31.z.union([import_zod31.z.string(), TiptapDocument, import_zod31.z.null()]).default(
|
|
3889
3911
|
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
|
|
3890
3912
|
),
|
|
3891
3913
|
descriptionSize: TextSize.default("medium"),
|
|
3892
3914
|
horizontalAlignment: TextAlignment2.default("leading"),
|
|
3893
|
-
image:
|
|
3894
|
-
imagePlacement:
|
|
3895
|
-
imageSize:
|
|
3896
|
-
superTitle:
|
|
3915
|
+
image: import_zod31.z.union([import_zod31.z.literal(""), import_zod31.z.url()]).default(""),
|
|
3916
|
+
imagePlacement: import_zod31.z.enum(["bottom", "left", "right", "top"]).optional().default("left"),
|
|
3917
|
+
imageSize: import_zod31.z.number().default(20),
|
|
3918
|
+
superTitle: import_zod31.z.union([import_zod31.z.string(), TiptapDocument]).default("Lorem Ipsum!"),
|
|
3897
3919
|
superTitleSize: TextSize.default("medium"),
|
|
3898
3920
|
/** This isn't configurable in the admin-nextjs editor */
|
|
3899
|
-
swapContent:
|
|
3900
|
-
title:
|
|
3921
|
+
swapContent: import_zod31.z.boolean().optional().default(false),
|
|
3922
|
+
title: import_zod31.z.union([import_zod31.z.string(), TiptapDocument]).nullable().default("Lorem ipsum dolor sit amet"),
|
|
3901
3923
|
titleSize: TextSize.default("medium")
|
|
3902
3924
|
}),
|
|
3903
|
-
type:
|
|
3904
|
-
});
|
|
3905
|
-
var PayButtonBlock =
|
|
3906
|
-
id:
|
|
3907
|
-
name:
|
|
3908
|
-
settings:
|
|
3909
|
-
|
|
3910
|
-
label:
|
|
3925
|
+
type: import_zod31.z.literal(BlockType.image_content).default(BlockType.image_content)
|
|
3926
|
+
});
|
|
3927
|
+
var PayButtonBlock = import_zod31.z.object({
|
|
3928
|
+
id: import_zod31.z.string().optional().default(() => (0, import_uuid14.v4)()),
|
|
3929
|
+
name: import_zod31.z.string().optional(),
|
|
3930
|
+
settings: import_zod31.z.union([
|
|
3931
|
+
import_zod31.z.object({
|
|
3932
|
+
label: import_zod31.z.string().default("Pay Now")
|
|
3911
3933
|
}),
|
|
3912
|
-
|
|
3934
|
+
import_zod31.z.array(import_zod31.z.never()).transform(() => ({
|
|
3913
3935
|
label: "Pay Now"
|
|
3914
3936
|
}))
|
|
3915
3937
|
]),
|
|
3916
|
-
styles:
|
|
3917
|
-
|
|
3918
|
-
buttonWidth:
|
|
3938
|
+
styles: import_zod31.z.union([
|
|
3939
|
+
import_zod31.z.object({
|
|
3940
|
+
buttonWidth: import_zod31.z.number().min(10).max(100).default(50)
|
|
3919
3941
|
}),
|
|
3920
|
-
|
|
3942
|
+
import_zod31.z.array(import_zod31.z.never()).transform(() => ({
|
|
3921
3943
|
buttonWidth: 50
|
|
3922
3944
|
}))
|
|
3923
3945
|
]),
|
|
3924
|
-
type:
|
|
3946
|
+
type: import_zod31.z.literal(BlockType.pay_button).default(BlockType.pay_button)
|
|
3925
3947
|
});
|
|
3926
|
-
var ProductInformationBlock =
|
|
3948
|
+
var ProductInformationBlock = import_zod31.z.object({
|
|
3927
3949
|
/** This isn't configurable in the admin-nextjs editor */
|
|
3928
|
-
hideProductImage:
|
|
3929
|
-
id:
|
|
3930
|
-
name:
|
|
3931
|
-
type:
|
|
3932
|
-
});
|
|
3933
|
-
var SeparatorBlock =
|
|
3934
|
-
id:
|
|
3935
|
-
name:
|
|
3936
|
-
type:
|
|
3937
|
-
});
|
|
3938
|
-
var TextBlock =
|
|
3939
|
-
id:
|
|
3940
|
-
name:
|
|
3941
|
-
settings:
|
|
3942
|
-
description:
|
|
3950
|
+
hideProductImage: import_zod31.z.boolean().optional().default(false),
|
|
3951
|
+
id: import_zod31.z.string().optional().default(() => (0, import_uuid14.v4)()),
|
|
3952
|
+
name: import_zod31.z.string().optional(),
|
|
3953
|
+
type: import_zod31.z.literal(BlockType.product_information).default(BlockType.product_information)
|
|
3954
|
+
});
|
|
3955
|
+
var SeparatorBlock = import_zod31.z.object({
|
|
3956
|
+
id: import_zod31.z.string().optional().default(() => (0, import_uuid14.v4)()),
|
|
3957
|
+
name: import_zod31.z.string().optional(),
|
|
3958
|
+
type: import_zod31.z.literal(BlockType.separator).default(BlockType.separator)
|
|
3959
|
+
});
|
|
3960
|
+
var TextBlock = import_zod31.z.object({
|
|
3961
|
+
id: import_zod31.z.string().optional().default(() => (0, import_uuid14.v4)()),
|
|
3962
|
+
name: import_zod31.z.string().optional(),
|
|
3963
|
+
settings: import_zod31.z.object({
|
|
3964
|
+
description: import_zod31.z.union([import_zod31.z.string(), TiptapDocument]).optional().default(
|
|
3943
3965
|
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
|
|
3944
3966
|
),
|
|
3945
3967
|
/** This isn't used in the post-purchase offer widget */
|
|
3946
3968
|
descriptionSize: TextSize.default("medium"),
|
|
3947
3969
|
horizontalAlignment: TextAlignment2.default("leading"),
|
|
3948
|
-
superTitle:
|
|
3970
|
+
superTitle: import_zod31.z.union([import_zod31.z.string(), TiptapDocument]).default("Super Title"),
|
|
3949
3971
|
/** This isn't used in the post-purchase offer widget */
|
|
3950
3972
|
superTitleSize: TextSize.default("medium"),
|
|
3951
|
-
title:
|
|
3973
|
+
title: import_zod31.z.union([import_zod31.z.string(), TiptapDocument]).nullable().default("Lorem ipsum dolor sit amet."),
|
|
3952
3974
|
/** This isn't used in the post-purchase offer widget */
|
|
3953
3975
|
titleSize: TextSize.default("medium")
|
|
3954
3976
|
}),
|
|
3955
|
-
type:
|
|
3956
|
-
});
|
|
3957
|
-
var TimerBlock =
|
|
3958
|
-
id:
|
|
3959
|
-
name:
|
|
3960
|
-
settings:
|
|
3961
|
-
durationMinutes:
|
|
3962
|
-
durationSeconds:
|
|
3963
|
-
endOffer:
|
|
3964
|
-
title:
|
|
3977
|
+
type: import_zod31.z.literal(BlockType.text).default(BlockType.text)
|
|
3978
|
+
});
|
|
3979
|
+
var TimerBlock = import_zod31.z.object({
|
|
3980
|
+
id: import_zod31.z.string().optional().default(() => (0, import_uuid14.v4)()),
|
|
3981
|
+
name: import_zod31.z.string().optional(),
|
|
3982
|
+
settings: import_zod31.z.object({
|
|
3983
|
+
durationMinutes: import_zod31.z.number().min(0).default(10),
|
|
3984
|
+
durationSeconds: import_zod31.z.union([import_zod31.z.number().min(0), import_zod31.z.unknown().transform(() => 0)]).default(0),
|
|
3985
|
+
endOffer: import_zod31.z.boolean().default(true),
|
|
3986
|
+
title: import_zod31.z.union([import_zod31.z.string(), TiptapDocument]).default("Hurry \u2014 your special offer ends in:")
|
|
3965
3987
|
}),
|
|
3966
|
-
styles:
|
|
3988
|
+
styles: import_zod31.z.object({
|
|
3967
3989
|
textAlignment: TextAlignment2.default("center"),
|
|
3968
|
-
timerBackgroundColor:
|
|
3969
|
-
timerEmphasized:
|
|
3990
|
+
timerBackgroundColor: import_zod31.z.enum(["info", "warning", "success", "critical"]).default("warning"),
|
|
3991
|
+
timerEmphasized: import_zod31.z.union([import_zod31.z.boolean(), import_zod31.z.unknown().transform(() => true)]).default(true),
|
|
3970
3992
|
timerSize: TextSize.default("medium"),
|
|
3971
|
-
timerWidth:
|
|
3972
|
-
titleEmphasized:
|
|
3993
|
+
timerWidth: import_zod31.z.number().min(10).max(100).optional().default(100),
|
|
3994
|
+
titleEmphasized: import_zod31.z.union([import_zod31.z.boolean(), import_zod31.z.unknown().transform(() => true)]).default(false),
|
|
3973
3995
|
titleSize: TextSize.default("medium")
|
|
3974
3996
|
}),
|
|
3975
|
-
type:
|
|
3997
|
+
type: import_zod31.z.literal(BlockType.timer).default(BlockType.timer)
|
|
3976
3998
|
});
|
|
3977
|
-
var PostPurchaseBlock =
|
|
3999
|
+
var PostPurchaseBlock = import_zod31.z.discriminatedUnion("type", [
|
|
3978
4000
|
CalloutBannerBlock,
|
|
3979
4001
|
ImageBlock,
|
|
3980
4002
|
ImageContentBlock,
|
|
@@ -4007,7 +4029,7 @@ var styledTextRun = (text2, emphasized, size) => ({
|
|
|
4007
4029
|
// src/transforms/postPurchase/convertCalloutBlock.ts
|
|
4008
4030
|
var fields = ["superTitle", "title"];
|
|
4009
4031
|
var Shell = CalloutBannerBlock.pick({ styles: true }).extend({
|
|
4010
|
-
settings:
|
|
4032
|
+
settings: import_zod32.z.object({ superTitle: import_zod32.z.unknown().optional(), title: import_zod32.z.unknown().optional() })
|
|
4011
4033
|
});
|
|
4012
4034
|
var convertCalloutBlock = (raw, report) => {
|
|
4013
4035
|
const omit = (detail) => {
|
|
@@ -4042,7 +4064,7 @@ var convertCalloutBlock = (raw, report) => {
|
|
|
4042
4064
|
};
|
|
4043
4065
|
|
|
4044
4066
|
// src/transforms/postPurchase/convertImageFrame.ts
|
|
4045
|
-
var
|
|
4067
|
+
var import_zod33 = require("zod");
|
|
4046
4068
|
|
|
4047
4069
|
// src/transforms/postPurchase/sizeImageSource.ts
|
|
4048
4070
|
var sizeImageSource = (source2, size) => {
|
|
@@ -4054,7 +4076,7 @@ var sizeImageSource = (source2, size) => {
|
|
|
4054
4076
|
};
|
|
4055
4077
|
|
|
4056
4078
|
// src/transforms/postPurchase/convertImageFrame.ts
|
|
4057
|
-
var Source =
|
|
4079
|
+
var Source = import_zod33.z.url().default("https://cdn.shopify.com/s/files/1/0605/0555/5177/files/placeholder.jpg?v=1657762972");
|
|
4058
4080
|
var DEFAULT_IMAGE_SIZE = 20;
|
|
4059
4081
|
var convertImageFrame = (raw) => {
|
|
4060
4082
|
const parsed = ImageBlock.shape.settings.options[0].safeParse(raw);
|
|
@@ -4100,7 +4122,7 @@ var convertImageBlock = (raw, report) => {
|
|
|
4100
4122
|
};
|
|
4101
4123
|
|
|
4102
4124
|
// src/transforms/postPurchase/convertImageContentBlock.ts
|
|
4103
|
-
var
|
|
4125
|
+
var import_zod35 = require("zod");
|
|
4104
4126
|
|
|
4105
4127
|
// src/transforms/postPurchase/convertImageContentText.ts
|
|
4106
4128
|
var fields2 = ["superTitle", "title", "description"];
|
|
@@ -4130,7 +4152,7 @@ var convertImageContentText = (settings, report) => {
|
|
|
4130
4152
|
};
|
|
4131
4153
|
|
|
4132
4154
|
// src/transforms/postPurchase/imageContentSettings.ts
|
|
4133
|
-
var
|
|
4155
|
+
var import_zod34 = require("zod");
|
|
4134
4156
|
var ImageContentSettings = ImageContentBlock.shape.settings.pick({
|
|
4135
4157
|
descriptionSize: true,
|
|
4136
4158
|
horizontalAlignment: true,
|
|
@@ -4138,17 +4160,17 @@ var ImageContentSettings = ImageContentBlock.shape.settings.pick({
|
|
|
4138
4160
|
swapContent: true,
|
|
4139
4161
|
titleSize: true
|
|
4140
4162
|
}).extend({
|
|
4141
|
-
alt:
|
|
4142
|
-
description:
|
|
4143
|
-
image:
|
|
4163
|
+
alt: import_zod34.z.unknown().optional(),
|
|
4164
|
+
description: import_zod34.z.unknown().optional(),
|
|
4165
|
+
image: import_zod34.z.unknown().optional(),
|
|
4144
4166
|
imagePlacement: ImageContentBlock.shape.settings.shape.imagePlacement.unwrap().nullable(),
|
|
4145
|
-
imageSize: ImageContentBlock.shape.settings.shape.imageSize.pipe(
|
|
4146
|
-
superTitle:
|
|
4147
|
-
title:
|
|
4167
|
+
imageSize: ImageContentBlock.shape.settings.shape.imageSize.pipe(import_zod34.z.number().positive()),
|
|
4168
|
+
superTitle: import_zod34.z.unknown().optional(),
|
|
4169
|
+
title: import_zod34.z.unknown().optional()
|
|
4148
4170
|
});
|
|
4149
4171
|
|
|
4150
4172
|
// src/transforms/postPurchase/convertImageContentBlock.ts
|
|
4151
|
-
var Shell2 =
|
|
4173
|
+
var Shell2 = import_zod35.z.object({ settings: ImageContentSettings, type: import_zod35.z.literal("image_content") });
|
|
4152
4174
|
var PROPORTIONAL_BREAK_AT = 500;
|
|
4153
4175
|
var convertImageContentBlock = (raw, report) => {
|
|
4154
4176
|
const shell = Shell2.safeParse(raw);
|
|
@@ -4213,91 +4235,468 @@ var convertPayButtonBlock = (raw, report) => {
|
|
|
4213
4235
|
];
|
|
4214
4236
|
};
|
|
4215
4237
|
|
|
4216
|
-
// src/transforms/postPurchase/
|
|
4217
|
-
var
|
|
4218
|
-
|
|
4219
|
-
if (!
|
|
4220
|
-
|
|
4221
|
-
return [];
|
|
4222
|
-
}
|
|
4238
|
+
// src/transforms/postPurchase/productCardControls.ts
|
|
4239
|
+
var groupSelector = { sectionType: "variants", selector: "menu", variantMode: "productGroup" };
|
|
4240
|
+
var variantSelector = ({ productOptions }) => {
|
|
4241
|
+
if (!productOptions.showVariantSelectors) return [];
|
|
4242
|
+
const single = productOptions.variantSelectorDisplayMode === "single";
|
|
4223
4243
|
return [
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
|
|
4230
|
-
CABLayoutSection.parse({
|
|
4231
|
-
alignment: { horizontal: "center" },
|
|
4232
|
-
direction: "grid",
|
|
4233
|
-
grid: { columns: [250] },
|
|
4234
|
-
sections: [
|
|
4235
|
-
CABImageSection.parse({ altText: "{{productTitle}}", source: "{{productImage}}" })
|
|
4236
|
-
],
|
|
4237
|
-
width: 90
|
|
4238
|
-
})
|
|
4239
|
-
]
|
|
4240
|
-
}),
|
|
4241
|
-
CABLayoutSection.parse({
|
|
4242
|
-
sections: [
|
|
4243
|
-
CABTextSection.parse({
|
|
4244
|
-
content: {
|
|
4245
|
-
en: {
|
|
4246
|
-
content: [
|
|
4247
|
-
{
|
|
4248
|
-
content: [
|
|
4249
|
-
{
|
|
4250
|
-
marks: [{ attrs: { fontSize: "heading" }, type: "textStyle" }],
|
|
4251
|
-
text: "{{productTitle}}"
|
|
4252
|
-
}
|
|
4253
|
-
]
|
|
4254
|
-
}
|
|
4255
|
-
]
|
|
4256
|
-
}
|
|
4257
|
-
}
|
|
4258
|
-
}),
|
|
4259
|
-
CABReviewsSection.parse({}),
|
|
4260
|
-
CABTextSection.parse({ content: { en: "{{productDescription}}" } })
|
|
4261
|
-
]
|
|
4262
|
-
})
|
|
4263
|
-
],
|
|
4264
|
-
spacing: "extraLoose",
|
|
4265
|
-
wrapping: { breakAt: 500, maxPerLine: block.data.hideProductImage ? 1 : 2 }
|
|
4266
|
-
})
|
|
4244
|
+
{
|
|
4245
|
+
hideOutOfStockVariants: single || productOptions.hideOutOfStockVariants,
|
|
4246
|
+
sectionType: "variants",
|
|
4247
|
+
selector: "menu",
|
|
4248
|
+
variantMode: single ? "single" : "multiple"
|
|
4249
|
+
}
|
|
4267
4250
|
];
|
|
4268
4251
|
};
|
|
4252
|
+
var quantity = ({ language: language3, quantityInputs: quantityInputs2 }) => quantityInputs2.enabled ? [
|
|
4253
|
+
quantitySection({
|
|
4254
|
+
maxValue: quantityInputs2.maxValue,
|
|
4255
|
+
minValue: quantityInputs2.minValue,
|
|
4256
|
+
name: language3.global.quantity.trim()
|
|
4257
|
+
})
|
|
4258
|
+
] : [];
|
|
4259
|
+
var productCardControls = (settings) => [
|
|
4260
|
+
...subscriptionToggle(settings.productType),
|
|
4261
|
+
groupSelector,
|
|
4262
|
+
...variantSelector(settings),
|
|
4263
|
+
...quantity(settings)
|
|
4264
|
+
];
|
|
4269
4265
|
|
|
4270
|
-
// src/transforms/postPurchase/
|
|
4271
|
-
var
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4266
|
+
// src/transforms/postPurchase/productCardRows.ts
|
|
4267
|
+
var styledCopy = (text2, look) => ({
|
|
4268
|
+
content: [{ content: [{ marks: [{ attrs: look, type: "textStyle" }], text: text2, type: "text" }], type: "paragraph" }],
|
|
4269
|
+
type: "doc"
|
|
4270
|
+
});
|
|
4271
|
+
var merchantLabel = (value, fallback) => localizedContent({ en: fallback }, value);
|
|
4272
|
+
var boundText = (variable, content) => ({
|
|
4273
|
+
content,
|
|
4274
|
+
sectionType: "text",
|
|
4275
|
+
visibility: shownWhile(variable)
|
|
4276
|
+
});
|
|
4277
|
+
var earnedRow = ({ after, columns, label: label2, look, spacing, token, variable }) => {
|
|
4278
|
+
const styled2 = (text2) => look ? styledCopy(text2, look) : text2;
|
|
4279
|
+
const value = earnedText(variable, styled2(token));
|
|
4280
|
+
return {
|
|
4281
|
+
direction: "grid",
|
|
4282
|
+
grid: { columns, rows: ["auto"] },
|
|
4283
|
+
sections: [
|
|
4284
|
+
boundText(variable, look ? { en: styled2(String(label2.en)) } : label2),
|
|
4285
|
+
value,
|
|
4286
|
+
...after === void 0 ? [] : [boundText(variable, { en: styled2(String(after)) })]
|
|
4287
|
+
],
|
|
4288
|
+
sectionType: "layout",
|
|
4289
|
+
...spacing && { spacing }
|
|
4290
|
+
};
|
|
4277
4291
|
};
|
|
4292
|
+
var earnedVariables = (names) => names.map((name) => ({ defaultValue: false, name }));
|
|
4278
4293
|
|
|
4279
|
-
// src/transforms/postPurchase/
|
|
4280
|
-
var
|
|
4281
|
-
var
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
var
|
|
4288
|
-
var
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
var
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4294
|
+
// src/transforms/postPurchase/productCardSettings.ts
|
|
4295
|
+
var import_es_toolkit6 = require("es-toolkit");
|
|
4296
|
+
var import_zod38 = require("zod");
|
|
4297
|
+
|
|
4298
|
+
// src/schema/widgets/post-purchase-offer/postPurchaseSettings.ts
|
|
4299
|
+
var import_zod37 = require("zod");
|
|
4300
|
+
|
|
4301
|
+
// src/schema/widgets/post-purchase-offer/common.ts
|
|
4302
|
+
var import_compat5 = require("es-toolkit/compat");
|
|
4303
|
+
var import_zod36 = require("zod");
|
|
4304
|
+
var strictNumber = import_zod36.z.union([
|
|
4305
|
+
import_zod36.z.number(),
|
|
4306
|
+
import_zod36.z.string().transform((value) => (0, import_compat5.toNumber)((0, import_compat5.replace)((0, import_compat5.toString)(value), /[^0-9.]/g, "")) || 0),
|
|
4307
|
+
import_zod36.z.unknown().transform(() => 0)
|
|
4308
|
+
]);
|
|
4309
|
+
|
|
4310
|
+
// src/schema/widgets/post-purchase-offer/postPurchaseSettings.ts
|
|
4311
|
+
var PostPurchaseSettings = import_zod37.z.object({
|
|
4312
|
+
advance: import_zod37.z.object({ removePartialOrder: import_zod37.z.boolean().default(true) }).optional().default(() => ({ removePartialOrder: true })),
|
|
4313
|
+
blocks: import_zod37.z.union([import_zod37.z.array(PostPurchaseBlock), import_zod37.z.unknown().transform(() => [])]).default(() => [
|
|
4314
|
+
PostPurchaseBlock.parse({ settings: {}, styles: {}, type: BlockType.timer }),
|
|
4315
|
+
PostPurchaseBlock.parse({ settings: {}, styles: {}, type: BlockType.callout_banner }),
|
|
4316
|
+
PostPurchaseBlock.parse({ type: BlockType.product_information })
|
|
4317
|
+
]),
|
|
4318
|
+
columnLayout: import_zod37.z.boolean().optional(),
|
|
4319
|
+
discount: import_zod37.z.object({
|
|
4320
|
+
amount: strictNumber.default(30),
|
|
4321
|
+
shouldShowSavingText: import_zod37.z.boolean().optional().default(true),
|
|
4322
|
+
type: import_zod37.z.enum(["none", "fixed_amount", "percentage"]).default("none")
|
|
4323
|
+
}),
|
|
4324
|
+
discountedFrom: import_zod37.z.enum(["price", "compare_at_price"]).optional().default("price"),
|
|
4325
|
+
endpoint: import_zod37.z.string().optional(),
|
|
4326
|
+
integrations: import_zod37.z.object({
|
|
4327
|
+
judgeme: import_zod37.z.boolean().default(false),
|
|
4328
|
+
junip: import_zod37.z.boolean().optional().default(false),
|
|
4329
|
+
klaviyo: import_zod37.z.boolean().default(false),
|
|
4330
|
+
loox: import_zod37.z.boolean().default(false),
|
|
4331
|
+
okendo: import_zod37.z.boolean().default(false),
|
|
4332
|
+
opinew: import_zod37.z.boolean().optional().default(false),
|
|
4333
|
+
reviewsio: import_zod37.z.boolean().optional().default(false),
|
|
4334
|
+
stamped: import_zod37.z.boolean().default(false),
|
|
4335
|
+
yotpo: import_zod37.z.boolean().default(false)
|
|
4336
|
+
}),
|
|
4337
|
+
key: import_zod37.z.string().optional(),
|
|
4338
|
+
language: import_zod37.z.object({
|
|
4339
|
+
description: import_zod37.z.union([import_zod37.z.string(), import_zod37.z.unknown().transform(() => "")]).default(""),
|
|
4340
|
+
descriptionEnabled: import_zod37.z.boolean().optional().default(false),
|
|
4341
|
+
descriptionRte: import_zod37.z.object({
|
|
4342
|
+
content: import_zod37.z.array(import_zod37.z.unknown()),
|
|
4343
|
+
type: import_zod37.z.string()
|
|
4344
|
+
}).optional(),
|
|
4345
|
+
descriptionSpacing: import_zod37.z.enum(["none", "xtight", "tight", "default", "loose", "xloose"]).optional(),
|
|
4346
|
+
displayCtaPrice: import_zod37.z.boolean().default(true),
|
|
4347
|
+
global: import_zod37.z.object({
|
|
4348
|
+
declineAll: import_zod37.z.string().optional().default("Decline All"),
|
|
4349
|
+
declineThisOffer: import_zod37.z.string().default("Decline this offer"),
|
|
4350
|
+
free: import_zod37.z.string().optional().default("Free"),
|
|
4351
|
+
notAvailable: import_zod37.z.string().optional().default("Not available"),
|
|
4352
|
+
payNow: import_zod37.z.string().default("Pay Now"),
|
|
4353
|
+
payNowUpgradeToSubscription: import_zod37.z.string().optional().default("Upgrade to Subscription"),
|
|
4354
|
+
quantity: import_zod37.z.string().default("Quantity"),
|
|
4355
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
4356
|
+
recurringShipping: import_zod37.z.string().optional().default("Recurring shipping"),
|
|
4357
|
+
recurringSubtotal: import_zod37.z.string().default("Recurring subtotal"),
|
|
4358
|
+
reviewsPlural: import_zod37.z.string().optional().default("Reviews"),
|
|
4359
|
+
reviewsSingular: import_zod37.z.string().optional().default("Review"),
|
|
4360
|
+
save: import_zod37.z.union([import_zod37.z.string(), import_zod37.z.unknown().transform(() => "Save")]).optional().default("Save"),
|
|
4361
|
+
shipping: import_zod37.z.string().default("Shipping"),
|
|
4362
|
+
subscriptionOption: import_zod37.z.string().optional().default("Subscribe and Save"),
|
|
4363
|
+
subtotal: import_zod37.z.string().default("Subtotal"),
|
|
4364
|
+
taxes: import_zod37.z.string().default("Taxes"),
|
|
4365
|
+
total: import_zod37.z.string().default("Total")
|
|
4366
|
+
}).optional().default(() => ({
|
|
4367
|
+
declineAll: "Decline All",
|
|
4368
|
+
declineThisOffer: "Decline this offer",
|
|
4369
|
+
free: "Free",
|
|
4370
|
+
notAvailable: "Not available",
|
|
4371
|
+
payNow: "Pay Now",
|
|
4372
|
+
payNowUpgradeToSubscription: "Upgrade to Subscription",
|
|
4373
|
+
quantity: "Quantity",
|
|
4374
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
4375
|
+
recurringShipping: "Recurring shipping",
|
|
4376
|
+
recurringSubtotal: "Recurring subtotal",
|
|
4377
|
+
reviewsPlural: "Reviews",
|
|
4378
|
+
reviewsSingular: "Review",
|
|
4379
|
+
save: "Save",
|
|
4380
|
+
shipping: "Shipping",
|
|
4381
|
+
subscriptionOption: "Subscribe and Save",
|
|
4382
|
+
subtotal: "Subtotal",
|
|
4383
|
+
taxes: "Taxes",
|
|
4384
|
+
total: "Total"
|
|
4385
|
+
})),
|
|
4386
|
+
globalTranslation: import_zod37.z.string().optional().default("english")
|
|
4387
|
+
}),
|
|
4388
|
+
metafields: import_zod37.z.boolean().default(false),
|
|
4389
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
4390
|
+
offer: import_zod37.z.object({
|
|
4391
|
+
count: import_zod37.z.number().default(1)
|
|
4392
|
+
}),
|
|
4393
|
+
offersLayout: import_zod37.z.object({
|
|
4394
|
+
itemsPerPage: import_zod37.z.number().optional(),
|
|
4395
|
+
type: import_zod37.z.enum(["list", "grid", "carousel"]).default("list")
|
|
4396
|
+
}).optional().default({
|
|
4397
|
+
type: "list"
|
|
4398
|
+
}),
|
|
4399
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
4400
|
+
previewMode: import_zod37.z.boolean().default(false),
|
|
4401
|
+
productLimit: import_zod37.z.number().optional().default(1),
|
|
4402
|
+
productOptions: import_zod37.z.object({
|
|
4403
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
4404
|
+
hideOutOfStockVariants: import_zod37.z.boolean().optional().default(false),
|
|
4405
|
+
matchVariant: import_zod37.z.boolean().optional().default(true),
|
|
4406
|
+
showDeclineAll: import_zod37.z.enum(["above", "below", "both", "none"]).optional(),
|
|
4407
|
+
showShipping: import_zod37.z.boolean().optional().default(true),
|
|
4408
|
+
showSubtotal: import_zod37.z.boolean().optional().default(true),
|
|
4409
|
+
showTaxes: import_zod37.z.boolean().optional().default(true),
|
|
4410
|
+
showTotal: import_zod37.z.boolean().optional().default(true),
|
|
4411
|
+
showVariantSelectors: import_zod37.z.boolean().optional().default(true),
|
|
4412
|
+
variantSelectorDisplayMode: import_zod37.z.enum(["separate", "single"]).optional().default("separate")
|
|
4413
|
+
}),
|
|
4414
|
+
productType: import_zod37.z.union([import_zod37.z.enum(["one-time", "subscription", "both"]), import_zod37.z.literal("").transform(() => "one-time")]).default("one-time"),
|
|
4415
|
+
productTypeSelector: import_zod37.z.enum(["dropdown", "radio"]).optional().default("radio"),
|
|
4416
|
+
quantityInputs: import_zod37.z.object({
|
|
4417
|
+
defaultQuantity: import_zod37.z.union([import_zod37.z.number(), import_zod37.z.null().transform(() => 1)]).default(1),
|
|
4418
|
+
enabled: import_zod37.z.boolean().default(true),
|
|
4419
|
+
maxValue: import_zod37.z.union([import_zod37.z.number(), import_zod37.z.null().transform(() => 15)]).default(15),
|
|
4420
|
+
minValue: import_zod37.z.union([import_zod37.z.number().min(0), import_zod37.z.unknown().transform(() => 0)]).default(1)
|
|
4421
|
+
}),
|
|
4422
|
+
shipping: import_zod37.z.object({
|
|
4423
|
+
amount: strictNumber.default(10),
|
|
4424
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
4425
|
+
enabled: import_zod37.z.boolean().default(true),
|
|
4426
|
+
title: import_zod37.z.string().optional().default("Shipping Fees"),
|
|
4427
|
+
type: import_zod37.z.enum(["free", "fixed_amount"]).default("free")
|
|
4428
|
+
}),
|
|
4429
|
+
styles: import_zod37.z.object({
|
|
4430
|
+
starColor: import_zod37.z.string().optional().default("#fadb14"),
|
|
4431
|
+
starSize: import_zod37.z.union([import_zod37.z.enum(["small", "medium", "large"]), import_zod37.z.unknown().transform(() => "large")]).optional().default("large"),
|
|
4432
|
+
starStrokeColor: import_zod37.z.string().optional().default("#fadb14"),
|
|
4433
|
+
strokeWidth: import_zod37.z.string().optional().default("1")
|
|
4434
|
+
}).optional(),
|
|
4435
|
+
subImages: import_zod37.z.number().nullish().default(8),
|
|
4436
|
+
subscription: import_zod37.z.object({
|
|
4437
|
+
discount: import_zod37.z.object({
|
|
4438
|
+
amount: strictNumber.default(30),
|
|
4439
|
+
shouldShowSavingText: import_zod37.z.boolean().optional().default(true),
|
|
4440
|
+
type: import_zod37.z.enum(["none", "fixed_amount", "percentage"]).default("none")
|
|
4441
|
+
}),
|
|
4442
|
+
shipping: import_zod37.z.object({
|
|
4443
|
+
amount: strictNumber.default(1),
|
|
4444
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
4445
|
+
enabled: import_zod37.z.boolean().default(true),
|
|
4446
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
4447
|
+
recurringAmount: strictNumber.default(2),
|
|
4448
|
+
shippingTitle: import_zod37.z.string().default("Shipping Fees"),
|
|
4449
|
+
type: import_zod37.z.enum(["free", "fixed_amount"]).default("free")
|
|
4450
|
+
})
|
|
4451
|
+
}).optional().default({
|
|
4452
|
+
discount: {
|
|
4453
|
+
amount: 30,
|
|
4454
|
+
shouldShowSavingText: true,
|
|
4455
|
+
type: "none"
|
|
4456
|
+
},
|
|
4457
|
+
shipping: {
|
|
4458
|
+
amount: 1,
|
|
4459
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
4460
|
+
enabled: true,
|
|
4461
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
4462
|
+
recurringAmount: 2,
|
|
4463
|
+
shippingTitle: "Shipping Fees",
|
|
4464
|
+
type: "free"
|
|
4465
|
+
}
|
|
4466
|
+
}),
|
|
4467
|
+
subscriptionIsDefault: import_zod37.z.boolean().optional(),
|
|
4468
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
4469
|
+
template: import_zod37.z.string().optional().default(""),
|
|
4470
|
+
type: import_zod37.z.literal("shopify_post_purchase_extension").default("shopify_post_purchase_extension"),
|
|
4471
|
+
upgradeToSubscription: import_zod37.z.object({
|
|
4472
|
+
acceptButtonText: import_zod37.z.string().optional().default("Upgrade"),
|
|
4473
|
+
allow: import_zod37.z.boolean().optional().default(false),
|
|
4474
|
+
emailRefundNotice: import_zod37.z.boolean().optional().default(false),
|
|
4475
|
+
errorBannerText: import_zod37.z.string().optional().default("This subscription cannot be added - limit one per order")
|
|
4476
|
+
}).optional().default(() => ({
|
|
4477
|
+
acceptButtonText: "Upgrade",
|
|
4478
|
+
allow: false,
|
|
4479
|
+
emailRefundNotice: false,
|
|
4480
|
+
errorBannerText: "This subscription cannot be added - limit one per order"
|
|
4481
|
+
}))
|
|
4482
|
+
});
|
|
4483
|
+
|
|
4484
|
+
// src/transforms/postPurchase/productCardSettings.ts
|
|
4485
|
+
var { shape } = PostPurchaseSettings;
|
|
4486
|
+
var Labels = import_zod38.z.object(
|
|
4487
|
+
(0, import_es_toolkit6.mapValues)(shape.language.shape.global.unwrap().unwrap().shape, (label2) => label2.catch(() => label2.parse(void 0)))
|
|
4488
|
+
);
|
|
4489
|
+
var Language = import_zod38.z.object({ global: Labels.catch(() => Labels.parse({})) });
|
|
4490
|
+
var Fields = import_zod38.z.object({
|
|
4491
|
+
discount: shape.discount.catch(() => shape.discount.parse({})),
|
|
4492
|
+
language: Language.catch(() => Language.parse({})),
|
|
4493
|
+
productOptions: shape.productOptions.catch(() => shape.productOptions.parse({})),
|
|
4494
|
+
productType: shape.productType.catch("one-time"),
|
|
4495
|
+
quantityInputs: shape.quantityInputs.catch(() => shape.quantityInputs.parse({})),
|
|
4496
|
+
subImages: shape.subImages.catch(null),
|
|
4497
|
+
subscription: shape.subscription.catch(() => shape.subscription.parse(void 0)),
|
|
4498
|
+
upgradeToSubscription: shape.upgradeToSubscription.catch(() => shape.upgradeToSubscription.parse(void 0))
|
|
4499
|
+
});
|
|
4500
|
+
var ProductCardSettings = Fields.catch(() => Fields.parse({}));
|
|
4501
|
+
var sellsSubscription = ({ productType, upgradeToSubscription }) => productType !== "one-time" || upgradeToSubscription.allow;
|
|
4502
|
+
|
|
4503
|
+
// src/transforms/postPurchase/productCardCosts.ts
|
|
4504
|
+
var COST_ROWS = [
|
|
4505
|
+
["showSubtotal", "subtotal", "Subtotal", "hasSubtotal"],
|
|
4506
|
+
["showShipping", "shipping", "Shipping", "hasShipping"],
|
|
4507
|
+
["showTaxes", "taxes", "Taxes", "hasTaxes"],
|
|
4508
|
+
["showTotal", "total", "Total", "hasTotal"]
|
|
4509
|
+
];
|
|
4510
|
+
var costRows = ({ language: language3, productOptions }) => {
|
|
4511
|
+
const rows = COST_ROWS.filter(([show]) => productOptions[show]);
|
|
4512
|
+
if (!rows.length) return [];
|
|
4513
|
+
return [
|
|
4514
|
+
{
|
|
4515
|
+
direction: "rows",
|
|
4516
|
+
name: "costs",
|
|
4517
|
+
sections: rows.map(
|
|
4518
|
+
([, key, fallback, variable]) => earnedRow({
|
|
4519
|
+
columns: ["fill", "auto"],
|
|
4520
|
+
label: merchantLabel(language3.global[key], fallback),
|
|
4521
|
+
token: `{{${key}}}`,
|
|
4522
|
+
variable
|
|
4523
|
+
})
|
|
4524
|
+
),
|
|
4525
|
+
sectionType: "layout",
|
|
4526
|
+
spacing: "tight",
|
|
4527
|
+
variables: earnedVariables(rows.map(([, , , variable]) => variable))
|
|
4528
|
+
}
|
|
4529
|
+
];
|
|
4530
|
+
};
|
|
4531
|
+
var HAS_RECURRING_TOTAL = "hasRecurringTotal";
|
|
4532
|
+
var HAS_RECURRING_SHIPPING = "hasRecurringShipping";
|
|
4533
|
+
var small = { color: "subdued", fontSize: "small" };
|
|
4534
|
+
var FOOTNOTES = ["Doesn't include tax, duties, or any applicable discounts.", "Auto-renews, skip or cancel anytime"];
|
|
4535
|
+
var recurringSummary = (settings) => {
|
|
4536
|
+
if (!sellsSubscription(settings)) return [];
|
|
4537
|
+
const { global: global2 } = settings.language;
|
|
4538
|
+
return [
|
|
4539
|
+
{
|
|
4540
|
+
direction: "rows",
|
|
4541
|
+
name: "recurring",
|
|
4542
|
+
sections: [
|
|
4543
|
+
earnedRow({
|
|
4544
|
+
after: "on every Delivery",
|
|
4545
|
+
columns: ["fill", "auto", "auto"],
|
|
4546
|
+
label: merchantLabel(global2.recurringSubtotal, "Recurring subtotal"),
|
|
4547
|
+
spacing: "extraTight",
|
|
4548
|
+
token: "{{recurringTotal}}",
|
|
4549
|
+
variable: HAS_RECURRING_TOTAL
|
|
4550
|
+
}),
|
|
4551
|
+
earnedRow({
|
|
4552
|
+
after: "(included)",
|
|
4553
|
+
columns: ["auto", "auto", "auto"],
|
|
4554
|
+
label: { en: `${merchantLabel(global2.recurringShipping, "Recurring shipping").en}:` },
|
|
4555
|
+
look: small,
|
|
4556
|
+
spacing: "extraTight",
|
|
4557
|
+
token: "{{recurringShipping}}",
|
|
4558
|
+
variable: HAS_RECURRING_SHIPPING
|
|
4559
|
+
}),
|
|
4560
|
+
...FOOTNOTES.map((text2) => ({
|
|
4561
|
+
content: { en: styledCopy(text2, small) },
|
|
4562
|
+
sectionType: "text",
|
|
4563
|
+
visibility: shownWhile(HAS_RECURRING_TOTAL)
|
|
4564
|
+
}))
|
|
4565
|
+
],
|
|
4566
|
+
sectionType: "layout",
|
|
4567
|
+
spacing: "tight",
|
|
4568
|
+
variables: earnedVariables([HAS_RECURRING_TOTAL, HAS_RECURRING_SHIPPING])
|
|
4569
|
+
}
|
|
4570
|
+
];
|
|
4571
|
+
};
|
|
4572
|
+
var productCardCosts = (settings) => [
|
|
4573
|
+
...costRows(settings),
|
|
4574
|
+
...recurringSummary(settings)
|
|
4575
|
+
];
|
|
4576
|
+
|
|
4577
|
+
// src/transforms/postPurchase/productCardPricing.ts
|
|
4578
|
+
var import_compat6 = require("es-toolkit/compat");
|
|
4579
|
+
var HAS_SAVING = "hasSaving";
|
|
4580
|
+
var savingLine = (settings) => {
|
|
4581
|
+
const subscriptionSaving = sellsSubscription(settings) && settings.subscription.discount.shouldShowSavingText;
|
|
4582
|
+
if (!settings.discount.shouldShowSavingText && !subscriptionSaving) return [];
|
|
4583
|
+
return [
|
|
4584
|
+
{
|
|
4585
|
+
...earnedRow({
|
|
4586
|
+
columns: ["auto", "auto"],
|
|
4587
|
+
label: merchantLabel((0, import_compat6.capitalize)(settings.language.global.save), "Save"),
|
|
4588
|
+
look: { color: "success" },
|
|
4589
|
+
spacing: "extraTight",
|
|
4590
|
+
token: "{{variantSaving}}",
|
|
4591
|
+
variable: HAS_SAVING
|
|
4592
|
+
}),
|
|
4593
|
+
name: "saving",
|
|
4594
|
+
variables: earnedVariables([HAS_SAVING])
|
|
4595
|
+
}
|
|
4596
|
+
];
|
|
4597
|
+
};
|
|
4598
|
+
var productCardPricing = (settings) => [
|
|
4599
|
+
priceText(),
|
|
4600
|
+
...savingLine(settings)
|
|
4601
|
+
];
|
|
4602
|
+
|
|
4603
|
+
// src/transforms/postPurchase/convertProductInformation.ts
|
|
4604
|
+
var thumbnails = ({ subImages }) => {
|
|
4605
|
+
const limit = Math.floor(subImages ?? 0);
|
|
4606
|
+
return limit >= 1 ? { thumbnails: { limit } } : {};
|
|
4607
|
+
};
|
|
4608
|
+
var convertProductInformation = (raw, report, widgetSettings) => {
|
|
4609
|
+
const block = ProductInformationBlock.safeParse(raw);
|
|
4610
|
+
if (!block.success) {
|
|
4611
|
+
report?.({ detail: "Unreadable post-purchase product information", kind: "section" });
|
|
4612
|
+
return [];
|
|
4613
|
+
}
|
|
4614
|
+
const settings = ProductCardSettings.parse(widgetSettings ?? {});
|
|
4615
|
+
return [
|
|
4616
|
+
CABOffersSection.parse({
|
|
4617
|
+
direction: "grid",
|
|
4618
|
+
sections: [
|
|
4619
|
+
CABLayoutSection.parse({
|
|
4620
|
+
alignment: { horizontal: "center" },
|
|
4621
|
+
sections: [
|
|
4622
|
+
CABLayoutSection.parse({
|
|
4623
|
+
alignment: { horizontal: "center" },
|
|
4624
|
+
direction: "grid",
|
|
4625
|
+
grid: { columns: [250] },
|
|
4626
|
+
sections: [
|
|
4627
|
+
CABImageSection.parse({
|
|
4628
|
+
altText: "{{productTitle}}",
|
|
4629
|
+
source: "{{productImage}}",
|
|
4630
|
+
...thumbnails(settings)
|
|
4631
|
+
})
|
|
4632
|
+
],
|
|
4633
|
+
width: 90
|
|
4634
|
+
})
|
|
4635
|
+
]
|
|
4636
|
+
}),
|
|
4637
|
+
CABLayoutSection.parse({
|
|
4638
|
+
sections: [
|
|
4639
|
+
CABTextSection.parse({
|
|
4640
|
+
content: {
|
|
4641
|
+
en: {
|
|
4642
|
+
content: [
|
|
4643
|
+
{
|
|
4644
|
+
content: [
|
|
4645
|
+
{
|
|
4646
|
+
marks: [{ attrs: { fontSize: "heading" }, type: "textStyle" }],
|
|
4647
|
+
text: "{{productTitle}}"
|
|
4648
|
+
}
|
|
4649
|
+
]
|
|
4650
|
+
}
|
|
4651
|
+
]
|
|
4652
|
+
}
|
|
4653
|
+
}
|
|
4654
|
+
}),
|
|
4655
|
+
...productCardPricing(settings),
|
|
4656
|
+
CABReviewsSection.parse({}),
|
|
4657
|
+
CABTextSection.parse({ content: { en: "{{productDescription}}" } }),
|
|
4658
|
+
...productCardControls(settings),
|
|
4659
|
+
...productCardCosts(settings)
|
|
4660
|
+
]
|
|
4661
|
+
})
|
|
4662
|
+
],
|
|
4663
|
+
spacing: "extraLoose",
|
|
4664
|
+
wrapping: { breakAt: 500, maxPerLine: block.data.hideProductImage ? 1 : 2 }
|
|
4665
|
+
})
|
|
4666
|
+
];
|
|
4667
|
+
};
|
|
4668
|
+
|
|
4669
|
+
// src/transforms/postPurchase/convertSeparatorBlock.ts
|
|
4670
|
+
var convertSeparatorBlock = (raw, report) => {
|
|
4671
|
+
if (!SeparatorBlock.safeParse(raw).success) {
|
|
4672
|
+
report?.({ detail: "Unreadable post-purchase separator", kind: "section" });
|
|
4673
|
+
return [];
|
|
4674
|
+
}
|
|
4675
|
+
return [CABSeparatorSection.parse({})];
|
|
4676
|
+
};
|
|
4677
|
+
|
|
4678
|
+
// src/transforms/postPurchase/convertTextBlock.ts
|
|
4679
|
+
var import_zod39 = require("zod");
|
|
4680
|
+
var fields3 = ["superTitle", "title", "description"];
|
|
4681
|
+
var styles = {
|
|
4682
|
+
description: [{ attrs: { color: "base", fontSize: "small" }, type: "textStyle" }],
|
|
4683
|
+
superTitle: [{ attrs: { color: "subdued", fontSize: "small" }, type: "textStyle" }],
|
|
4684
|
+
title: [{ type: "bold" }, { attrs: { color: "base", fontSize: "large" }, type: "textStyle" }]
|
|
4685
|
+
};
|
|
4686
|
+
var settingsSchema = TextBlock.shape.settings;
|
|
4687
|
+
var Shell3 = import_zod39.z.object({
|
|
4688
|
+
settings: settingsSchema.pick({ horizontalAlignment: true }).extend({
|
|
4689
|
+
description: import_zod39.z.unknown().optional(),
|
|
4690
|
+
superTitle: import_zod39.z.unknown().optional(),
|
|
4691
|
+
title: import_zod39.z.unknown().optional()
|
|
4692
|
+
}),
|
|
4693
|
+
type: import_zod39.z.literal("text")
|
|
4694
|
+
});
|
|
4695
|
+
var convertTextBlock = (raw, report) => {
|
|
4696
|
+
const shell = Shell3.safeParse(raw);
|
|
4697
|
+
if (!shell.success) {
|
|
4698
|
+
report?.({ detail: "Unreadable post-purchase text block", kind: "section" });
|
|
4699
|
+
return [];
|
|
4301
4700
|
}
|
|
4302
4701
|
const values2 = fields3.map((field) => ({
|
|
4303
4702
|
field,
|
|
@@ -4363,11 +4762,11 @@ var convertTimerBlock = (raw, report) => {
|
|
|
4363
4762
|
};
|
|
4364
4763
|
|
|
4365
4764
|
// src/transforms/postPurchase/convertMessagePreview.ts
|
|
4366
|
-
var MessageWidget =
|
|
4367
|
-
blocks:
|
|
4368
|
-
type:
|
|
4765
|
+
var MessageWidget = import_zod40.z.object({
|
|
4766
|
+
blocks: import_zod40.z.array(import_zod40.z.unknown()).min(1),
|
|
4767
|
+
type: import_zod40.z.literal(WidgetType.shopify_post_purchase_extension)
|
|
4369
4768
|
});
|
|
4370
|
-
var BlockType2 =
|
|
4769
|
+
var BlockType2 = import_zod40.z.object({ type: import_zod40.z.string() });
|
|
4371
4770
|
var converters = {
|
|
4372
4771
|
callout_banner: convertCalloutBlock,
|
|
4373
4772
|
image: convertImageBlock,
|
|
@@ -4388,7 +4787,7 @@ var convertMessagePreview = (id, settings, report) => {
|
|
|
4388
4787
|
const type = BlockType2.safeParse(block);
|
|
4389
4788
|
const kind = type.success ? type.data.type : void 0;
|
|
4390
4789
|
const convert2 = kind && Object.hasOwn(converters, kind) ? converters[kind] : void 0;
|
|
4391
|
-
if (convert2) return convert2(block, report);
|
|
4790
|
+
if (convert2) return convert2(block, report, settings);
|
|
4392
4791
|
report?.({
|
|
4393
4792
|
detail: kind ? `Unsupported post-purchase block type: ${kind}` : "Unreadable post-purchase block: missing type",
|
|
4394
4793
|
kind: "section"
|
|
@@ -4827,14 +5226,14 @@ function serialize(obj) {
|
|
|
4827
5226
|
var encodeAttributes = (pairs = []) => JSON.stringify(Object.fromEntries(pairs.map(({ key, value }) => [key, value ?? ""])));
|
|
4828
5227
|
var buildEngineParams = (input, key) => {
|
|
4829
5228
|
const { cart, customerId, filterInputs, integrations, limit, productType, shop, visitorId } = input;
|
|
4830
|
-
const items = cart.items.map(({ productId: productId2, properties, quantity:
|
|
5229
|
+
const items = cart.items.map(({ productId: productId2, properties, quantity: quantity3, subscriptionId, variantId }) => ({
|
|
4831
5230
|
product_id: productId2,
|
|
4832
5231
|
properties: encodeAttributes(properties),
|
|
4833
|
-
quantity:
|
|
5232
|
+
quantity: quantity3,
|
|
4834
5233
|
...subscriptionId && { subscription_id: subscriptionId },
|
|
4835
5234
|
variant_id: variantId
|
|
4836
5235
|
}));
|
|
4837
|
-
const itemCount = cart.items.reduce((total, { quantity:
|
|
5236
|
+
const itemCount = cart.items.reduce((total, { quantity: quantity3 }) => total + quantity3, 0);
|
|
4838
5237
|
const subtotal = shopSubtotalCents(cart);
|
|
4839
5238
|
return {
|
|
4840
5239
|
cart: {
|
|
@@ -4879,7 +5278,7 @@ var reportUnreadableVerdict = (metadata, report) => {
|
|
|
4879
5278
|
if (RuleVerdict.safeParse(metadata).success || isDefinitiveRuleAnswer(metadata)) return;
|
|
4880
5279
|
report?.({ detail: "rule verdict lacks readable custom.shouldShow", kind: "ruleVerdict" });
|
|
4881
5280
|
};
|
|
4882
|
-
var dedupeById = (products) => (0,
|
|
5281
|
+
var dedupeById = (products) => (0, import_es_toolkit7.uniqBy)(products, (product) => product.id);
|
|
4883
5282
|
var MAX_REQUEST_LINE_BYTES = 32e3;
|
|
4884
5283
|
var requestLineBytes = (path, search) => new TextEncoder().encode(`GET ${path}?${search} HTTP/1.1`).length;
|
|
4885
5284
|
var fetchDataSourceResults = async (input, ctx) => {
|
|
@@ -4915,43 +5314,43 @@ var fetchDataSourceResults = async (input, ctx) => {
|
|
|
4915
5314
|
};
|
|
4916
5315
|
|
|
4917
5316
|
// src/server/adsEngine.ts
|
|
4918
|
-
var
|
|
5317
|
+
var import_zod41 = require("zod");
|
|
4919
5318
|
var SUPPLY_KEY = { production: "AQF5RKLR", staging: "Z56LQ7PS" };
|
|
4920
5319
|
var OFFER_LIMIT = 4;
|
|
4921
5320
|
var SUPPORTED_COUNTRIES = /* @__PURE__ */ new Set(["US", "CA", "GB"]);
|
|
4922
5321
|
var MAX_TRANSACTION_ITEMS = 50;
|
|
4923
5322
|
var TEST_CUSTOMER_EMAIL = "test@rebuyengine.com";
|
|
4924
|
-
var transactionItems = (input) => (input.transactionItems?.map(({ id, priceCents, quantity:
|
|
5323
|
+
var transactionItems = (input) => (input.transactionItems?.map(({ id, priceCents, quantity: quantity3, title, type }) => ({
|
|
4925
5324
|
id,
|
|
4926
5325
|
price_cents: priceCents,
|
|
4927
|
-
quantity:
|
|
5326
|
+
quantity: quantity3,
|
|
4928
5327
|
title,
|
|
4929
5328
|
type
|
|
4930
|
-
})) ?? input.cart.items.map(({ productId: productId2, quantity:
|
|
4931
|
-
var AdsEngineOffer =
|
|
5329
|
+
})) ?? input.cart.items.map(({ productId: productId2, quantity: quantity3 }) => ({ id: productId2, quantity: quantity3 }))).slice(0, MAX_TRANSACTION_ITEMS);
|
|
5330
|
+
var AdsEngineOffer = import_zod41.z.object({
|
|
4932
5331
|
/** Pill-style value prop ("Get $45 Cashback"). Carried through the parse; the card does not render it yet (REB-24429 — pill design pending). */
|
|
4933
|
-
callout:
|
|
4934
|
-
click_url:
|
|
4935
|
-
cta:
|
|
5332
|
+
callout: import_zod41.z.string().catch(""),
|
|
5333
|
+
click_url: import_zod41.z.string(),
|
|
5334
|
+
cta: import_zod41.z.string(),
|
|
4936
5335
|
/** `omitempty` on the ad server — a bid without it must not fail the parse and drop the whole batch (composeOffer falls back to 'No Thanks'). */
|
|
4937
|
-
decline_cta:
|
|
4938
|
-
decline_url:
|
|
4939
|
-
description:
|
|
5336
|
+
decline_cta: import_zod41.z.string().catch(""),
|
|
5337
|
+
decline_url: import_zod41.z.string(),
|
|
5338
|
+
description: import_zod41.z.string(),
|
|
4940
5339
|
/** Short legal disclosure (FDIC / auto-renewal / FTC-affiliation lines). Rendered subdued under the CTAs. */
|
|
4941
|
-
disclaimer:
|
|
5340
|
+
disclaimer: import_zod41.z.string().catch(""),
|
|
4942
5341
|
/** Long legal text behind the disclosure toggle in the composed card (REB-24429). */
|
|
4943
|
-
extended_disclaimer:
|
|
4944
|
-
headline:
|
|
4945
|
-
id:
|
|
5342
|
+
extended_disclaimer: import_zod41.z.string().catch(""),
|
|
5343
|
+
headline: import_zod41.z.string(),
|
|
5344
|
+
id: import_zod41.z.string(),
|
|
4946
5345
|
/** Advertiser-supplied image alt; the composed card falls back to the stripped headline when empty. */
|
|
4947
|
-
image_alt:
|
|
4948
|
-
image_url:
|
|
5346
|
+
image_alt: import_zod41.z.string().catch(""),
|
|
5347
|
+
image_url: import_zod41.z.string().optional(),
|
|
4949
5348
|
/** The serving network's own privacy page (Falcon, REB-24744); the card prefers it over the widget setting. A bad value drops only this field, never the offer. */
|
|
4950
|
-
privacy_url:
|
|
4951
|
-
view_url:
|
|
5349
|
+
privacy_url: import_zod41.z.string().optional().catch(void 0),
|
|
5350
|
+
view_url: import_zod41.z.string()
|
|
4952
5351
|
});
|
|
4953
|
-
var AdsEngineResponse =
|
|
4954
|
-
offers:
|
|
5352
|
+
var AdsEngineResponse = import_zod41.z.object({
|
|
5353
|
+
offers: import_zod41.z.array(import_zod41.z.unknown()).default([]).transform(
|
|
4955
5354
|
(offers) => offers.flatMap((offer) => {
|
|
4956
5355
|
const result = AdsEngineOffer.safeParse(offer);
|
|
4957
5356
|
return result.success ? [result.data] : [];
|
|
@@ -4963,8 +5362,8 @@ var AdsEngineResponse = import_zod37.z.object({
|
|
|
4963
5362
|
* offers-testing fixture on a test store forces it, REB-24467). Both optional: an older engine or a
|
|
4964
5363
|
* non-JSON body must not fail the parse and drop the offers.
|
|
4965
5364
|
*/
|
|
4966
|
-
request_id:
|
|
4967
|
-
testing:
|
|
5365
|
+
request_id: import_zod41.z.string().optional().catch(void 0),
|
|
5366
|
+
testing: import_zod41.z.boolean().optional().catch(void 0)
|
|
4968
5367
|
});
|
|
4969
5368
|
var adsHost = (host) => `offers.${host}`;
|
|
4970
5369
|
var isTestingRequest = (input, isProduction) => !isProduction || !!input.testing || input.customerEmail?.toLowerCase() === TEST_CUSTOMER_EMAIL;
|
|
@@ -5416,13 +5815,13 @@ var convertWidgetSettings = async (input, ctx) => {
|
|
|
5416
5815
|
};
|
|
5417
5816
|
|
|
5418
5817
|
// src/server/giftWidgets.ts
|
|
5419
|
-
var
|
|
5420
|
-
var SettingsNumber =
|
|
5421
|
-
|
|
5422
|
-
|
|
5423
|
-
]).pipe(
|
|
5424
|
-
var SgwpMilestoneSchema =
|
|
5425
|
-
selectable_product_quantity: SettingsNumber.pipe(
|
|
5818
|
+
var import_zod42 = require("zod");
|
|
5819
|
+
var SettingsNumber = import_zod42.z.union([
|
|
5820
|
+
import_zod42.z.number(),
|
|
5821
|
+
import_zod42.z.string().trim().regex(/^-?\d+(\.\d+)?$/)
|
|
5822
|
+
]).pipe(import_zod42.z.coerce.number());
|
|
5823
|
+
var SgwpMilestoneSchema = import_zod42.z.object({
|
|
5824
|
+
selectable_product_quantity: SettingsNumber.pipe(import_zod42.z.number().int().nonnegative()),
|
|
5426
5825
|
unlock_price: SettingsNumber
|
|
5427
5826
|
});
|
|
5428
5827
|
var fetchGiftWidgetSettings = async (widgetId, shop, ctx) => unwrapData(await ctx.fetchUpstream("/api/v1/widgets/settings", { id: String(widgetId), shop }, { host: ctx.host }));
|
|
@@ -5433,7 +5832,7 @@ var readDataSourcePath = (settings) => {
|
|
|
5433
5832
|
var readMilestones = (settings, report) => {
|
|
5434
5833
|
const raw = settings && typeof settings === "object" ? settings.milestones : void 0;
|
|
5435
5834
|
if (raw == null) return [];
|
|
5436
|
-
const parsed =
|
|
5835
|
+
const parsed = import_zod42.z.array(SgwpMilestoneSchema).safeParse(raw);
|
|
5437
5836
|
if (parsed.success) return parsed.data;
|
|
5438
5837
|
report?.({
|
|
5439
5838
|
detail: [
|
|
@@ -5539,25 +5938,25 @@ var validateGifts = async (input, ctx) => {
|
|
|
5539
5938
|
const [remove, adjust] = await Promise.all([validateGwpGifts(input, ctx), validateSelectableGifts(input, ctx)]);
|
|
5540
5939
|
const removed = new Set(remove);
|
|
5541
5940
|
const targets = /* @__PURE__ */ new Map();
|
|
5542
|
-
for (const { lineId, quantity:
|
|
5941
|
+
for (const { lineId, quantity: quantity3 } of adjust) {
|
|
5543
5942
|
if (removed.has(lineId)) continue;
|
|
5544
|
-
targets.set(lineId, Math.min(
|
|
5943
|
+
targets.set(lineId, Math.min(quantity3, targets.get(lineId) ?? quantity3));
|
|
5545
5944
|
}
|
|
5546
|
-
return { adjust: [...targets].map(([lineId,
|
|
5945
|
+
return { adjust: [...targets].map(([lineId, quantity3]) => ({ lineId, quantity: quantity3 })), remove: [...removed] };
|
|
5547
5946
|
};
|
|
5548
5947
|
|
|
5549
5948
|
// src/server/normalizePostPurchaseProduct.ts
|
|
5550
|
-
var
|
|
5551
|
-
var
|
|
5949
|
+
var import_compat7 = require("es-toolkit/compat");
|
|
5950
|
+
var import_zod45 = require("zod");
|
|
5552
5951
|
|
|
5553
5952
|
// src/schema/postPurchaseProductSettings.ts
|
|
5554
|
-
var
|
|
5953
|
+
var import_zod44 = require("zod");
|
|
5555
5954
|
|
|
5556
5955
|
// src/schema/postPurchaseProductSource.ts
|
|
5557
|
-
var
|
|
5558
|
-
var PostPurchaseAmount =
|
|
5559
|
-
var PostPurchaseProductId =
|
|
5560
|
-
var PostPurchaseVariantId =
|
|
5956
|
+
var import_zod43 = require("zod");
|
|
5957
|
+
var PostPurchaseAmount = import_zod43.z.string().regex(/^\d+(?:\.\d+)?$/).refine((value) => Number.isFinite(Number(value)));
|
|
5958
|
+
var PostPurchaseProductId = import_zod43.z.number().int().positive();
|
|
5959
|
+
var PostPurchaseVariantId = import_zod43.z.number().int().positive();
|
|
5561
5960
|
var ProductBase = OfferProduct.pick({ description: true, id: true, image: true, title: true }).extend({
|
|
5562
5961
|
description: OfferProduct.shape.description.nullable(),
|
|
5563
5962
|
id: PostPurchaseProductId
|
|
@@ -5565,235 +5964,49 @@ var ProductBase = OfferProduct.pick({ description: true, id: true, image: true,
|
|
|
5565
5964
|
var SourceVariant = OfferProduct.shape.variants.element.pick({ id: true, title: true }).extend({
|
|
5566
5965
|
compareAtPrice: PostPurchaseAmount.nullable(),
|
|
5567
5966
|
id: PostPurchaseVariantId,
|
|
5568
|
-
imageId:
|
|
5569
|
-
inventoryManagement:
|
|
5570
|
-
inventoryPolicy:
|
|
5571
|
-
inventoryQuantity:
|
|
5572
|
-
option1:
|
|
5573
|
-
option2:
|
|
5574
|
-
option3:
|
|
5967
|
+
imageId: import_zod43.z.number().int().nonnegative().nullish(),
|
|
5968
|
+
inventoryManagement: import_zod43.z.string().nullable(),
|
|
5969
|
+
inventoryPolicy: import_zod43.z.string(),
|
|
5970
|
+
inventoryQuantity: import_zod43.z.number(),
|
|
5971
|
+
option1: import_zod43.z.unknown().optional(),
|
|
5972
|
+
option2: import_zod43.z.unknown().optional(),
|
|
5973
|
+
option3: import_zod43.z.unknown().optional(),
|
|
5575
5974
|
price: PostPurchaseAmount,
|
|
5576
|
-
productId: PostPurchaseProductId,
|
|
5577
|
-
sellingPlanAllocations:
|
|
5578
|
-
});
|
|
5579
|
-
var Product2 = ProductBase.extend({
|
|
5580
|
-
images:
|
|
5581
|
-
|
|
5582
|
-
).nullish(),
|
|
5583
|
-
metadata:
|
|
5584
|
-
productQuantity:
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
]).optional()
|
|
5588
|
-
}).optional(),
|
|
5589
|
-
metafields: import_zod39.z.unknown().optional(),
|
|
5590
|
-
options: import_zod39.z.unknown().optional(),
|
|
5591
|
-
productGroupVariants: import_zod39.z.array(import_zod39.z.unknown()).default([]),
|
|
5592
|
-
selectedVariant: import_zod39.z.unknown().optional(),
|
|
5593
|
-
sellingPlanGroups: import_zod39.z.array(
|
|
5594
|
-
OfferProduct.shape.sellingPlanGroups.unwrap().element.extend({
|
|
5595
|
-
discountAmount: import_zod39.z.unknown().optional(),
|
|
5596
|
-
discountType: import_zod39.z.unknown().optional(),
|
|
5597
|
-
id: import_zod39.z.unknown().optional(),
|
|
5598
|
-
requiresSellingPlan: import_zod39.z.boolean().default(false),
|
|
5599
|
-
sellingPlans: import_zod39.z.unknown().optional()
|
|
5600
|
-
})
|
|
5601
|
-
).default([]),
|
|
5602
|
-
variants: import_zod39.z.array(SourceVariant)
|
|
5603
|
-
});
|
|
5604
|
-
var PostPurchaseProductSource = import_zod39.z.object({
|
|
5605
|
-
data: import_zod39.z.array(Product2),
|
|
5606
|
-
metadata: import_zod39.z.object({ widget: import_zod39.z.record(import_zod39.z.string(), import_zod39.z.unknown()).default({}) }).default({ widget: {} })
|
|
5607
|
-
});
|
|
5608
|
-
|
|
5609
|
-
// src/schema/widgets/post-purchase-offer/postPurchaseSettings.ts
|
|
5610
|
-
var import_zod41 = require("zod");
|
|
5611
|
-
|
|
5612
|
-
// src/schema/widgets/post-purchase-offer/common.ts
|
|
5613
|
-
var import_compat5 = require("es-toolkit/compat");
|
|
5614
|
-
var import_zod40 = require("zod");
|
|
5615
|
-
var strictNumber = import_zod40.z.union([
|
|
5616
|
-
import_zod40.z.number(),
|
|
5617
|
-
import_zod40.z.string().transform((value) => (0, import_compat5.toNumber)((0, import_compat5.replace)((0, import_compat5.toString)(value), /[^0-9.]/g, "")) || 0),
|
|
5618
|
-
import_zod40.z.unknown().transform(() => 0)
|
|
5619
|
-
]);
|
|
5620
|
-
|
|
5621
|
-
// src/schema/widgets/post-purchase-offer/postPurchaseSettings.ts
|
|
5622
|
-
var PostPurchaseSettings = import_zod41.z.object({
|
|
5623
|
-
advance: import_zod41.z.object({ removePartialOrder: import_zod41.z.boolean().default(true) }).optional().default(() => ({ removePartialOrder: true })),
|
|
5624
|
-
blocks: import_zod41.z.union([import_zod41.z.array(PostPurchaseBlock), import_zod41.z.unknown().transform(() => [])]).default(() => [
|
|
5625
|
-
PostPurchaseBlock.parse({ settings: {}, styles: {}, type: BlockType.timer }),
|
|
5626
|
-
PostPurchaseBlock.parse({ settings: {}, styles: {}, type: BlockType.callout_banner }),
|
|
5627
|
-
PostPurchaseBlock.parse({ type: BlockType.product_information })
|
|
5628
|
-
]),
|
|
5629
|
-
columnLayout: import_zod41.z.boolean().optional(),
|
|
5630
|
-
discount: import_zod41.z.object({
|
|
5631
|
-
amount: strictNumber.default(30),
|
|
5632
|
-
shouldShowSavingText: import_zod41.z.boolean().optional().default(true),
|
|
5633
|
-
type: import_zod41.z.enum(["none", "fixed_amount", "percentage"]).default("none")
|
|
5634
|
-
}),
|
|
5635
|
-
discountedFrom: import_zod41.z.enum(["price", "compare_at_price"]).optional().default("price"),
|
|
5636
|
-
endpoint: import_zod41.z.string().optional(),
|
|
5637
|
-
integrations: import_zod41.z.object({
|
|
5638
|
-
judgeme: import_zod41.z.boolean().default(false),
|
|
5639
|
-
junip: import_zod41.z.boolean().optional().default(false),
|
|
5640
|
-
klaviyo: import_zod41.z.boolean().default(false),
|
|
5641
|
-
loox: import_zod41.z.boolean().default(false),
|
|
5642
|
-
okendo: import_zod41.z.boolean().default(false),
|
|
5643
|
-
opinew: import_zod41.z.boolean().optional().default(false),
|
|
5644
|
-
reviewsio: import_zod41.z.boolean().optional().default(false),
|
|
5645
|
-
stamped: import_zod41.z.boolean().default(false),
|
|
5646
|
-
yotpo: import_zod41.z.boolean().default(false)
|
|
5647
|
-
}),
|
|
5648
|
-
key: import_zod41.z.string().optional(),
|
|
5649
|
-
language: import_zod41.z.object({
|
|
5650
|
-
description: import_zod41.z.union([import_zod41.z.string(), import_zod41.z.unknown().transform(() => "")]).default(""),
|
|
5651
|
-
descriptionEnabled: import_zod41.z.boolean().optional().default(false),
|
|
5652
|
-
descriptionRte: import_zod41.z.object({
|
|
5653
|
-
content: import_zod41.z.array(import_zod41.z.unknown()),
|
|
5654
|
-
type: import_zod41.z.string()
|
|
5655
|
-
}).optional(),
|
|
5656
|
-
descriptionSpacing: import_zod41.z.enum(["none", "xtight", "tight", "default", "loose", "xloose"]).optional(),
|
|
5657
|
-
displayCtaPrice: import_zod41.z.boolean().default(true),
|
|
5658
|
-
global: import_zod41.z.object({
|
|
5659
|
-
declineAll: import_zod41.z.string().optional().default("Decline All"),
|
|
5660
|
-
declineThisOffer: import_zod41.z.string().default("Decline this offer"),
|
|
5661
|
-
free: import_zod41.z.string().optional().default("Free"),
|
|
5662
|
-
notAvailable: import_zod41.z.string().optional().default("Not available"),
|
|
5663
|
-
payNow: import_zod41.z.string().default("Pay Now"),
|
|
5664
|
-
payNowUpgradeToSubscription: import_zod41.z.string().optional().default("Upgrade to Subscription"),
|
|
5665
|
-
quantity: import_zod41.z.string().default("Quantity"),
|
|
5666
|
-
/** This isn't configurable in the admin-nextjs editor */
|
|
5667
|
-
recurringShipping: import_zod41.z.string().optional().default("Recurring shipping"),
|
|
5668
|
-
recurringSubtotal: import_zod41.z.string().default("Recurring subtotal"),
|
|
5669
|
-
reviewsPlural: import_zod41.z.string().optional().default("Reviews"),
|
|
5670
|
-
reviewsSingular: import_zod41.z.string().optional().default("Review"),
|
|
5671
|
-
save: import_zod41.z.union([import_zod41.z.string(), import_zod41.z.unknown().transform(() => "Save")]).optional().default("Save"),
|
|
5672
|
-
shipping: import_zod41.z.string().default("Shipping"),
|
|
5673
|
-
subscriptionOption: import_zod41.z.string().optional().default("Subscribe and Save"),
|
|
5674
|
-
subtotal: import_zod41.z.string().default("Subtotal"),
|
|
5675
|
-
taxes: import_zod41.z.string().default("Taxes"),
|
|
5676
|
-
total: import_zod41.z.string().default("Total")
|
|
5677
|
-
}).optional().default(() => ({
|
|
5678
|
-
declineAll: "Decline All",
|
|
5679
|
-
declineThisOffer: "Decline this offer",
|
|
5680
|
-
free: "Free",
|
|
5681
|
-
notAvailable: "Not available",
|
|
5682
|
-
payNow: "Pay Now",
|
|
5683
|
-
payNowUpgradeToSubscription: "Upgrade to Subscription",
|
|
5684
|
-
quantity: "Quantity",
|
|
5685
|
-
/** This isn't configurable in the admin-nextjs editor */
|
|
5686
|
-
recurringShipping: "Recurring shipping",
|
|
5687
|
-
recurringSubtotal: "Recurring subtotal",
|
|
5688
|
-
reviewsPlural: "Reviews",
|
|
5689
|
-
reviewsSingular: "Review",
|
|
5690
|
-
save: "Save",
|
|
5691
|
-
shipping: "Shipping",
|
|
5692
|
-
subscriptionOption: "Subscribe and Save",
|
|
5693
|
-
subtotal: "Subtotal",
|
|
5694
|
-
taxes: "Taxes",
|
|
5695
|
-
total: "Total"
|
|
5696
|
-
})),
|
|
5697
|
-
globalTranslation: import_zod41.z.string().optional().default("english")
|
|
5698
|
-
}),
|
|
5699
|
-
metafields: import_zod41.z.boolean().default(false),
|
|
5700
|
-
/** This isn't configurable in the admin-nextjs editor */
|
|
5701
|
-
offer: import_zod41.z.object({
|
|
5702
|
-
count: import_zod41.z.number().default(1)
|
|
5703
|
-
}),
|
|
5704
|
-
offersLayout: import_zod41.z.object({
|
|
5705
|
-
itemsPerPage: import_zod41.z.number().optional(),
|
|
5706
|
-
type: import_zod41.z.enum(["list", "grid", "carousel"]).default("list")
|
|
5707
|
-
}).optional().default({
|
|
5708
|
-
type: "list"
|
|
5709
|
-
}),
|
|
5710
|
-
/** This isn't configurable in the admin-nextjs editor */
|
|
5711
|
-
previewMode: import_zod41.z.boolean().default(false),
|
|
5712
|
-
productLimit: import_zod41.z.number().optional().default(1),
|
|
5713
|
-
productOptions: import_zod41.z.object({
|
|
5714
|
-
/** This isn't configurable in the admin-nextjs editor */
|
|
5715
|
-
hideOutOfStockVariants: import_zod41.z.boolean().optional().default(false),
|
|
5716
|
-
matchVariant: import_zod41.z.boolean().optional().default(true),
|
|
5717
|
-
showDeclineAll: import_zod41.z.enum(["above", "below", "both", "none"]).optional(),
|
|
5718
|
-
showShipping: import_zod41.z.boolean().optional().default(true),
|
|
5719
|
-
showSubtotal: import_zod41.z.boolean().optional().default(true),
|
|
5720
|
-
showTaxes: import_zod41.z.boolean().optional().default(true),
|
|
5721
|
-
showTotal: import_zod41.z.boolean().optional().default(true),
|
|
5722
|
-
showVariantSelectors: import_zod41.z.boolean().optional().default(true),
|
|
5723
|
-
variantSelectorDisplayMode: import_zod41.z.enum(["separate", "single"]).optional().default("separate")
|
|
5724
|
-
}),
|
|
5725
|
-
productType: import_zod41.z.union([import_zod41.z.enum(["one-time", "subscription", "both"]), import_zod41.z.literal("").transform(() => "one-time")]).default("one-time"),
|
|
5726
|
-
productTypeSelector: import_zod41.z.enum(["dropdown", "radio"]).optional().default("radio"),
|
|
5727
|
-
quantityInputs: import_zod41.z.object({
|
|
5728
|
-
defaultQuantity: import_zod41.z.union([import_zod41.z.number(), import_zod41.z.null().transform(() => 1)]).default(1),
|
|
5729
|
-
enabled: import_zod41.z.boolean().default(true),
|
|
5730
|
-
maxValue: import_zod41.z.union([import_zod41.z.number(), import_zod41.z.null().transform(() => 15)]).default(15),
|
|
5731
|
-
minValue: import_zod41.z.union([import_zod41.z.number().min(0), import_zod41.z.unknown().transform(() => 0)]).default(1)
|
|
5732
|
-
}),
|
|
5733
|
-
shipping: import_zod41.z.object({
|
|
5734
|
-
amount: strictNumber.default(10),
|
|
5735
|
-
/** This isn't configurable in the admin-nextjs editor */
|
|
5736
|
-
enabled: import_zod41.z.boolean().default(true),
|
|
5737
|
-
title: import_zod41.z.string().optional().default("Shipping Fees"),
|
|
5738
|
-
type: import_zod41.z.enum(["free", "fixed_amount"]).default("free")
|
|
5739
|
-
}),
|
|
5740
|
-
styles: import_zod41.z.object({
|
|
5741
|
-
starColor: import_zod41.z.string().optional().default("#fadb14"),
|
|
5742
|
-
starSize: import_zod41.z.union([import_zod41.z.enum(["small", "medium", "large"]), import_zod41.z.unknown().transform(() => "large")]).optional().default("large"),
|
|
5743
|
-
starStrokeColor: import_zod41.z.string().optional().default("#fadb14"),
|
|
5744
|
-
strokeWidth: import_zod41.z.string().optional().default("1")
|
|
5975
|
+
productId: PostPurchaseProductId,
|
|
5976
|
+
sellingPlanAllocations: import_zod43.z.unknown().optional()
|
|
5977
|
+
});
|
|
5978
|
+
var Product2 = ProductBase.extend({
|
|
5979
|
+
images: import_zod43.z.array(
|
|
5980
|
+
import_zod43.z.object({ alt: import_zod43.z.string().optional().catch(void 0), id: import_zod43.z.number().int().positive(), src: import_zod43.z.string() })
|
|
5981
|
+
).nullish(),
|
|
5982
|
+
metadata: import_zod43.z.object({
|
|
5983
|
+
productQuantity: import_zod43.z.union([
|
|
5984
|
+
import_zod43.z.number().int().positive(),
|
|
5985
|
+
import_zod43.z.string().regex(/^[1-9]\d*$/).transform(Number)
|
|
5986
|
+
]).optional()
|
|
5745
5987
|
}).optional(),
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
/** This isn't configurable in the admin-nextjs editor */
|
|
5758
|
-
recurringAmount: strictNumber.default(2),
|
|
5759
|
-
shippingTitle: import_zod41.z.string().default("Shipping Fees"),
|
|
5760
|
-
type: import_zod41.z.enum(["free", "fixed_amount"]).default("free")
|
|
5988
|
+
metafields: import_zod43.z.unknown().optional(),
|
|
5989
|
+
options: import_zod43.z.unknown().optional(),
|
|
5990
|
+
productGroupVariants: import_zod43.z.array(import_zod43.z.unknown()).default([]),
|
|
5991
|
+
selectedVariant: import_zod43.z.unknown().optional(),
|
|
5992
|
+
sellingPlanGroups: import_zod43.z.array(
|
|
5993
|
+
OfferProduct.shape.sellingPlanGroups.unwrap().element.extend({
|
|
5994
|
+
discountAmount: import_zod43.z.unknown().optional(),
|
|
5995
|
+
discountType: import_zod43.z.unknown().optional(),
|
|
5996
|
+
id: import_zod43.z.unknown().optional(),
|
|
5997
|
+
requiresSellingPlan: import_zod43.z.boolean().default(false),
|
|
5998
|
+
sellingPlans: import_zod43.z.unknown().optional()
|
|
5761
5999
|
})
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
shipping: {
|
|
5769
|
-
amount: 1,
|
|
5770
|
-
/** This isn't configurable in the admin-nextjs editor */
|
|
5771
|
-
enabled: true,
|
|
5772
|
-
/** This isn't configurable in the admin-nextjs editor */
|
|
5773
|
-
recurringAmount: 2,
|
|
5774
|
-
shippingTitle: "Shipping Fees",
|
|
5775
|
-
type: "free"
|
|
5776
|
-
}
|
|
5777
|
-
}),
|
|
5778
|
-
subscriptionIsDefault: import_zod41.z.boolean().optional(),
|
|
5779
|
-
/** This isn't configurable in the admin-nextjs editor */
|
|
5780
|
-
template: import_zod41.z.string().optional().default(""),
|
|
5781
|
-
type: import_zod41.z.literal("shopify_post_purchase_extension").default("shopify_post_purchase_extension"),
|
|
5782
|
-
upgradeToSubscription: import_zod41.z.object({
|
|
5783
|
-
acceptButtonText: import_zod41.z.string().optional().default("Upgrade"),
|
|
5784
|
-
allow: import_zod41.z.boolean().optional().default(false),
|
|
5785
|
-
emailRefundNotice: import_zod41.z.boolean().optional().default(false),
|
|
5786
|
-
errorBannerText: import_zod41.z.string().optional().default("This subscription cannot be added - limit one per order")
|
|
5787
|
-
}).optional().default(() => ({
|
|
5788
|
-
acceptButtonText: "Upgrade",
|
|
5789
|
-
allow: false,
|
|
5790
|
-
emailRefundNotice: false,
|
|
5791
|
-
errorBannerText: "This subscription cannot be added - limit one per order"
|
|
5792
|
-
}))
|
|
6000
|
+
).default([]),
|
|
6001
|
+
variants: import_zod43.z.array(SourceVariant)
|
|
6002
|
+
});
|
|
6003
|
+
var PostPurchaseProductSource = import_zod43.z.object({
|
|
6004
|
+
data: import_zod43.z.array(Product2),
|
|
6005
|
+
metadata: import_zod43.z.object({ widget: import_zod43.z.record(import_zod43.z.string(), import_zod43.z.unknown()).default({}) }).default({ widget: {} })
|
|
5793
6006
|
});
|
|
5794
6007
|
|
|
5795
6008
|
// src/schema/postPurchaseProductSettings.ts
|
|
5796
|
-
var amount =
|
|
6009
|
+
var amount = import_zod44.z.union([import_zod44.z.number().nonnegative(), PostPurchaseAmount.transform(Number)]);
|
|
5797
6010
|
var PostPurchaseProductSettings = PostPurchaseSettings.pick({
|
|
5798
6011
|
discountedFrom: true,
|
|
5799
6012
|
language: true,
|
|
@@ -5805,14 +6018,14 @@ var PostPurchaseProductSettings = PostPurchaseSettings.pick({
|
|
|
5805
6018
|
subscriptionIsDefault: true,
|
|
5806
6019
|
upgradeToSubscription: true
|
|
5807
6020
|
}).extend({
|
|
5808
|
-
advance:
|
|
5809
|
-
blocks:
|
|
6021
|
+
advance: import_zod44.z.unknown().default({}),
|
|
6022
|
+
blocks: import_zod44.z.array(import_zod44.z.unknown()).optional(),
|
|
5810
6023
|
discount: PostPurchaseSettings.shape.discount.extend({ amount: amount.default(30) }),
|
|
5811
|
-
integrations:
|
|
6024
|
+
integrations: import_zod44.z.unknown().default({}),
|
|
5812
6025
|
shipping: PostPurchaseSettings.shape.shipping.extend({ amount: amount.default(10) }),
|
|
5813
|
-
styles:
|
|
6026
|
+
styles: import_zod44.z.unknown().default({}),
|
|
5814
6027
|
subImages: PostPurchaseSettings.shape.subImages.catch(null),
|
|
5815
|
-
subscription:
|
|
6028
|
+
subscription: import_zod44.z.unknown().default(PostPurchaseSettings.shape.subscription.parse(void 0))
|
|
5816
6029
|
});
|
|
5817
6030
|
|
|
5818
6031
|
// src/server/normalizePostPurchaseProduct.ts
|
|
@@ -5820,59 +6033,83 @@ var normalizePostPurchaseProduct = (settings, response) => {
|
|
|
5820
6033
|
const original = PostPurchaseProductSettings.parse(deepCamelCase(settings));
|
|
5821
6034
|
const { data, metadata } = PostPurchaseProductSource.parse(deepCamelCase(response));
|
|
5822
6035
|
const overrides = Object.fromEntries(Object.entries(metadata.widget).filter(([key]) => key in original));
|
|
5823
|
-
const discount =
|
|
6036
|
+
const discount = import_zod45.z.object({ type: import_zod45.z.string() }).safeParse(overrides.discount);
|
|
5824
6037
|
if (discount.success && discount.data.type === "fixed") {
|
|
5825
|
-
overrides.discount = { ...
|
|
6038
|
+
overrides.discount = { ...import_zod45.z.record(import_zod45.z.string(), import_zod45.z.unknown()).parse(overrides.discount), type: "fixed_amount" };
|
|
5826
6039
|
}
|
|
5827
|
-
const effective = PostPurchaseProductSettings.parse((0,
|
|
6040
|
+
const effective = PostPurchaseProductSettings.parse((0, import_compat7.merge)({}, original, overrides));
|
|
5828
6041
|
return { data, effective, metadata, original };
|
|
5829
6042
|
};
|
|
5830
6043
|
|
|
6044
|
+
// src/pricing/amountToCents.ts
|
|
6045
|
+
var round = (value, precision = 0) => {
|
|
6046
|
+
const factor = 10 ** precision;
|
|
6047
|
+
return Math.round(value * factor) / factor;
|
|
6048
|
+
};
|
|
6049
|
+
var amountToCents = (amount2, decimals = 2) => {
|
|
6050
|
+
const value = Number(amount2);
|
|
6051
|
+
return Number.isFinite(value) ? round(round(value, decimals) * 10 ** decimals) : 0;
|
|
6052
|
+
};
|
|
6053
|
+
|
|
6054
|
+
// src/pricing/postPurchaseReduction.ts
|
|
6055
|
+
var reducePostPurchaseMinor = (priceMinor, { amount: amount2, type }, decimals) => {
|
|
6056
|
+
if (type === "price") return amountToCents(amount2, decimals);
|
|
6057
|
+
const reduction = type === "percentage" ? Math.round(priceMinor * (amount2 / 100)) : type === "fixed_amount" ? amountToCents(amount2, decimals) : 0;
|
|
6058
|
+
return Math.max(0, priceMinor - reduction);
|
|
6059
|
+
};
|
|
6060
|
+
var postPurchasePlanDiscountPercentage = (price, adjustment) => {
|
|
6061
|
+
const regularMinor = amountToCents(price);
|
|
6062
|
+
const planMinor = adjustment ? reducePostPurchaseMinor(regularMinor, adjustment, 2) : regularMinor;
|
|
6063
|
+
return regularMinor > 0 && planMinor < regularMinor ? Math.round((1 - planMinor / regularMinor) * 100) : 0;
|
|
6064
|
+
};
|
|
6065
|
+
|
|
5831
6066
|
// src/schema/postPurchasePlanCatalog.ts
|
|
5832
|
-
var
|
|
6067
|
+
var import_zod48 = require("zod");
|
|
5833
6068
|
|
|
5834
6069
|
// src/schema/postPurchasePlanAdjustment.ts
|
|
5835
|
-
var
|
|
6070
|
+
var import_zod47 = require("zod");
|
|
5836
6071
|
|
|
5837
6072
|
// src/schema/postPurchaseDiscount.ts
|
|
5838
|
-
var
|
|
5839
|
-
var Discount =
|
|
5840
|
-
amount:
|
|
5841
|
-
title:
|
|
5842
|
-
type:
|
|
6073
|
+
var import_zod46 = require("zod");
|
|
6074
|
+
var Discount = import_zod46.z.object({
|
|
6075
|
+
amount: import_zod46.z.number().nonnegative(),
|
|
6076
|
+
title: import_zod46.z.string(),
|
|
6077
|
+
type: import_zod46.z.enum(["none", "fixed_amount", "percentage"])
|
|
5843
6078
|
});
|
|
5844
6079
|
var validPostPurchaseDiscount = (discount) => discount.type !== "percentage" || discount.amount <= 100;
|
|
5845
6080
|
var PostPurchaseDiscount = Discount.refine(validPostPurchaseDiscount);
|
|
5846
6081
|
|
|
5847
6082
|
// src/schema/postPurchasePlanAdjustment.ts
|
|
5848
|
-
var PostPurchasePlanAdjustment =
|
|
6083
|
+
var PostPurchasePlanAdjustment = import_zod47.z.object({
|
|
5849
6084
|
amount: PostPurchaseDiscount.shape.amount,
|
|
5850
|
-
type:
|
|
6085
|
+
type: import_zod47.z.enum(["percentage", "fixed_amount", "price"])
|
|
5851
6086
|
}).refine(({ amount: amount2, type }) => type === "price" || validPostPurchaseDiscount({ amount: amount2, type }));
|
|
5852
6087
|
|
|
5853
6088
|
// src/schema/postPurchasePlanCatalog.ts
|
|
5854
|
-
var PostPurchasePlanOption =
|
|
6089
|
+
var PostPurchasePlanOption = import_zod48.z.object({
|
|
5855
6090
|
adjustment: PostPurchasePlanAdjustment.optional(),
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
6091
|
+
/** cab-checkout's `discountPercentage`: the plan's own whole-percent saving on the regular price (`{{subscriptionDiscount}}`). */
|
|
6092
|
+
discountPercentage: import_zod48.z.number().int().min(0).max(100).optional(),
|
|
6093
|
+
id: import_zod48.z.number().int().positive(),
|
|
6094
|
+
intervalFrequency: import_zod48.z.string().regex(/^[1-9]\d*$/).optional(),
|
|
6095
|
+
intervalLabel: import_zod48.z.string().min(1),
|
|
6096
|
+
name: import_zod48.z.string().min(1)
|
|
5860
6097
|
});
|
|
5861
|
-
var PostPurchasePlanCatalog =
|
|
5862
|
-
plans:
|
|
5863
|
-
productId:
|
|
5864
|
-
requiresSellingPlan:
|
|
5865
|
-
variantId:
|
|
6098
|
+
var PostPurchasePlanCatalog = import_zod48.z.object({
|
|
6099
|
+
plans: import_zod48.z.array(PostPurchasePlanOption),
|
|
6100
|
+
productId: import_zod48.z.number().int().positive(),
|
|
6101
|
+
requiresSellingPlan: import_zod48.z.boolean(),
|
|
6102
|
+
variantId: import_zod48.z.number().int().positive()
|
|
5866
6103
|
});
|
|
5867
6104
|
|
|
5868
6105
|
// src/server/postPurchaseLegacyPlans.ts
|
|
5869
|
-
var
|
|
6106
|
+
var import_zod50 = require("zod");
|
|
5870
6107
|
|
|
5871
6108
|
// src/server/postPurchasePlanAdjustment.ts
|
|
5872
|
-
var
|
|
5873
|
-
var SourceAdjustment =
|
|
6109
|
+
var import_zod49 = require("zod");
|
|
6110
|
+
var SourceAdjustment = import_zod49.z.object({
|
|
5874
6111
|
amount: PostPurchaseProductSettings.shape.discount.shape.amount.unwrap(),
|
|
5875
|
-
type:
|
|
6112
|
+
type: import_zod49.z.enum(["percentage", "fixed_amount", "amount", "price", "none", "fixed"])
|
|
5876
6113
|
});
|
|
5877
6114
|
var readPostPurchasePlanAdjustment = (raw) => {
|
|
5878
6115
|
const source2 = SourceAdjustment.parse(raw);
|
|
@@ -5891,13 +6128,13 @@ var readPostPurchasePlanAdjustment = (raw) => {
|
|
|
5891
6128
|
var Plan = PostPurchasePlanOption.pick({ id: true, name: true }).extend({
|
|
5892
6129
|
orderIntervalFrequency: PostPurchasePlanOption.shape.intervalFrequency.unwrap(),
|
|
5893
6130
|
orderIntervalUnitType: PostPurchasePlanOption.shape.intervalLabel,
|
|
5894
|
-
shopifyVariantId:
|
|
6131
|
+
shopifyVariantId: import_zod50.z.string().regex(/^[1-9]\d*$/).nullish()
|
|
5895
6132
|
});
|
|
5896
|
-
var Group =
|
|
5897
|
-
discountAmount:
|
|
5898
|
-
discountType:
|
|
5899
|
-
id:
|
|
5900
|
-
sellingPlans:
|
|
6133
|
+
var Group = import_zod50.z.object({
|
|
6134
|
+
discountAmount: import_zod50.z.unknown(),
|
|
6135
|
+
discountType: import_zod50.z.unknown(),
|
|
6136
|
+
id: import_zod50.z.number().int().positive(),
|
|
6137
|
+
sellingPlans: import_zod50.z.array(import_zod50.z.object({ shopifyVariantId: Plan.shape.shopifyVariantId }).passthrough())
|
|
5901
6138
|
});
|
|
5902
6139
|
var readPostPurchaseLegacyPlans = (raw, variantId) => {
|
|
5903
6140
|
const group = Group.pick({ id: true, sellingPlans: true }).parse(raw);
|
|
@@ -5918,21 +6155,21 @@ var readPostPurchaseLegacyPlans = (raw, variantId) => {
|
|
|
5918
6155
|
};
|
|
5919
6156
|
|
|
5920
6157
|
// src/server/postPurchaseModernPlans.ts
|
|
5921
|
-
var
|
|
5922
|
-
var Groups =
|
|
5923
|
-
|
|
5924
|
-
id:
|
|
5925
|
-
sellingPlans:
|
|
6158
|
+
var import_zod51 = require("zod");
|
|
6159
|
+
var Groups = import_zod51.z.array(
|
|
6160
|
+
import_zod51.z.object({
|
|
6161
|
+
id: import_zod51.z.string().min(1),
|
|
6162
|
+
sellingPlans: import_zod51.z.unknown()
|
|
5926
6163
|
})
|
|
5927
6164
|
);
|
|
5928
|
-
var Allocations =
|
|
5929
|
-
var Plans =
|
|
6165
|
+
var Allocations = import_zod51.z.array(import_zod51.z.object({ sellingPlanGroupId: import_zod51.z.string().min(1) })).default([]);
|
|
6166
|
+
var Plans = import_zod51.z.array(
|
|
5930
6167
|
PostPurchasePlanOption.pick({ id: true, name: true }).extend({
|
|
5931
|
-
options:
|
|
5932
|
-
priceAdjustments:
|
|
6168
|
+
options: import_zod51.z.array(import_zod51.z.object({ value: import_zod51.z.string().min(1) })).min(1),
|
|
6169
|
+
priceAdjustments: import_zod51.z.array(import_zod51.z.unknown())
|
|
5933
6170
|
})
|
|
5934
6171
|
);
|
|
5935
|
-
var FirstAdjustment =
|
|
6172
|
+
var FirstAdjustment = import_zod51.z.object({
|
|
5936
6173
|
value: PostPurchaseProductSettings.shape.discount.shape.amount.unwrap(),
|
|
5937
6174
|
valueType: PostPurchasePlanAdjustment.shape.type
|
|
5938
6175
|
});
|
|
@@ -5972,7 +6209,10 @@ var projectPostPurchasePlanCatalog = (normalized, report) => {
|
|
|
5972
6209
|
unique.set(plan.id, plan);
|
|
5973
6210
|
}
|
|
5974
6211
|
return PostPurchasePlanCatalog.parse({
|
|
5975
|
-
plans: [...unique.values()]
|
|
6212
|
+
plans: [...unique.values()].map((plan) => ({
|
|
6213
|
+
...plan,
|
|
6214
|
+
discountPercentage: postPurchasePlanDiscountPercentage(variant2.price, plan.adjustment)
|
|
6215
|
+
})),
|
|
5976
6216
|
productId: product.id,
|
|
5977
6217
|
requiresSellingPlan: required[0] ?? false,
|
|
5978
6218
|
variantId: variant2.id
|
|
@@ -5984,66 +6224,66 @@ var projectPostPurchasePlanCatalog = (normalized, report) => {
|
|
|
5984
6224
|
};
|
|
5985
6225
|
|
|
5986
6226
|
// src/schema/postPurchaseSubscriptionProduct.ts
|
|
5987
|
-
var
|
|
6227
|
+
var import_zod57 = require("zod");
|
|
5988
6228
|
|
|
5989
6229
|
// src/schema/postPurchaseProduct.ts
|
|
5990
|
-
var
|
|
6230
|
+
var import_zod56 = require("zod");
|
|
5991
6231
|
|
|
5992
6232
|
// src/schema/postPurchaseProductDisplay.ts
|
|
5993
|
-
var
|
|
6233
|
+
var import_zod54 = require("zod");
|
|
5994
6234
|
|
|
5995
6235
|
// src/schema/postPurchaseProductGallery.ts
|
|
5996
|
-
var
|
|
5997
|
-
var PostPurchaseProductGallery =
|
|
5998
|
-
images:
|
|
5999
|
-
|
|
6000
|
-
description:
|
|
6001
|
-
id:
|
|
6002
|
-
source:
|
|
6003
|
-
thumbnail:
|
|
6236
|
+
var import_zod52 = require("zod");
|
|
6237
|
+
var PostPurchaseProductGallery = import_zod52.z.object({
|
|
6238
|
+
images: import_zod52.z.array(
|
|
6239
|
+
import_zod52.z.object({
|
|
6240
|
+
description: import_zod52.z.string(),
|
|
6241
|
+
id: import_zod52.z.number().int().positive(),
|
|
6242
|
+
source: import_zod52.z.string(),
|
|
6243
|
+
thumbnail: import_zod52.z.string()
|
|
6004
6244
|
})
|
|
6005
6245
|
),
|
|
6006
|
-
selectedImageId:
|
|
6246
|
+
selectedImageId: import_zod52.z.number().int().positive().optional()
|
|
6007
6247
|
});
|
|
6008
6248
|
|
|
6009
6249
|
// src/schema/postPurchaseProductReviews.ts
|
|
6010
|
-
var
|
|
6011
|
-
var decimal =
|
|
6012
|
-
|
|
6013
|
-
|
|
6250
|
+
var import_zod53 = require("zod");
|
|
6251
|
+
var decimal = import_zod53.z.union([
|
|
6252
|
+
import_zod53.z.number(),
|
|
6253
|
+
import_zod53.z.string().regex(/^\d+(?:\.\d+)?$/).transform(Number)
|
|
6014
6254
|
]);
|
|
6015
|
-
var PostPurchaseCommonReviewRating =
|
|
6255
|
+
var PostPurchaseCommonReviewRating = import_zod53.z.object({ value: decimal.pipe(import_zod53.z.number().min(0).max(5)) });
|
|
6016
6256
|
var PostPurchaseKlaviyoReviewRating = PostPurchaseCommonReviewRating.extend({
|
|
6017
6257
|
// Legacy validates key presence, then displays the raw value on five stars without rescaling.
|
|
6018
|
-
scale_max:
|
|
6019
|
-
scale_min:
|
|
6258
|
+
scale_max: import_zod53.z.unknown().nonoptional(),
|
|
6259
|
+
scale_min: import_zod53.z.unknown().nonoptional()
|
|
6020
6260
|
});
|
|
6021
|
-
var PostPurchaseReviewCount =
|
|
6261
|
+
var PostPurchaseReviewCount = import_zod53.z.string().regex(/^\d+(?:\.\d+)?$/).transform(Number).pipe(import_zod53.z.number().int().nonnegative());
|
|
6022
6262
|
var PostPurchaseReviewStyles = PostPurchaseSettings.shape.styles.unwrap().extend({
|
|
6023
|
-
strokeWidth: decimal.pipe(
|
|
6263
|
+
strokeWidth: decimal.pipe(import_zod53.z.number().nonnegative()).default(1)
|
|
6024
6264
|
}).prefault({});
|
|
6025
|
-
var PostPurchaseProductReviews =
|
|
6026
|
-
color:
|
|
6027
|
-
rating:
|
|
6028
|
-
reviewCount:
|
|
6029
|
-
reviewsPlural:
|
|
6030
|
-
reviewsSingular:
|
|
6031
|
-
size:
|
|
6032
|
-
strokeColor:
|
|
6033
|
-
strokeWidth:
|
|
6265
|
+
var PostPurchaseProductReviews = import_zod53.z.object({
|
|
6266
|
+
color: import_zod53.z.string(),
|
|
6267
|
+
rating: import_zod53.z.number().positive().max(5),
|
|
6268
|
+
reviewCount: import_zod53.z.number().int().nonnegative(),
|
|
6269
|
+
reviewsPlural: import_zod53.z.string(),
|
|
6270
|
+
reviewsSingular: import_zod53.z.string(),
|
|
6271
|
+
size: import_zod53.z.enum(["small", "medium", "large"]),
|
|
6272
|
+
strokeColor: import_zod53.z.string(),
|
|
6273
|
+
strokeWidth: import_zod53.z.number().nonnegative()
|
|
6034
6274
|
});
|
|
6035
6275
|
|
|
6036
6276
|
// src/schema/postPurchaseProductDisplay.ts
|
|
6037
6277
|
var language = PostPurchaseSettings.shape.language;
|
|
6038
|
-
var PostPurchasePrimaryImageSource =
|
|
6278
|
+
var PostPurchasePrimaryImageSource = import_zod54.z.string().default(
|
|
6039
6279
|
"https://cdn.shopify.com/shopifycloud/shopify/assets/no-image-2048-5e88c1b20e087fb7bbe9a3771824e743c244f437e4f8ba93bbf7b11b53f7824c.gif"
|
|
6040
6280
|
);
|
|
6041
|
-
var PostPurchaseProductDisplay =
|
|
6281
|
+
var PostPurchaseProductDisplay = import_zod54.z.object({
|
|
6042
6282
|
descriptionDocument: TiptapDocument.optional(),
|
|
6043
6283
|
discountedFrom: PostPurchaseSettings.shape.discountedFrom,
|
|
6044
6284
|
gallery: PostPurchaseProductGallery.optional(),
|
|
6045
6285
|
language: language.pick({ description: true, descriptionEnabled: true }),
|
|
6046
|
-
primaryImage:
|
|
6286
|
+
primaryImage: import_zod54.z.object({ description: import_zod54.z.string(), source: import_zod54.z.string() }),
|
|
6047
6287
|
productOptions: PostPurchaseSettings.shape.productOptions.pick({
|
|
6048
6288
|
showDeclineAll: true,
|
|
6049
6289
|
showShipping: true,
|
|
@@ -6058,14 +6298,14 @@ var PostPurchaseProductDisplay = import_zod52.z.object({
|
|
|
6058
6298
|
});
|
|
6059
6299
|
|
|
6060
6300
|
// src/schema/postPurchaseSubscription.ts
|
|
6061
|
-
var
|
|
6062
|
-
var PostPurchaseSubscriptionTerms =
|
|
6301
|
+
var import_zod55 = require("zod");
|
|
6302
|
+
var PostPurchaseSubscriptionTerms = import_zod55.z.object({
|
|
6063
6303
|
adjustment: PostPurchasePlanAdjustment.optional(),
|
|
6064
|
-
initialShippingPrice:
|
|
6065
|
-
intervalLabel:
|
|
6066
|
-
name:
|
|
6067
|
-
recurringShippingPrice:
|
|
6068
|
-
shippingOption:
|
|
6304
|
+
initialShippingPrice: import_zod55.z.number().nonnegative(),
|
|
6305
|
+
intervalLabel: import_zod55.z.string().min(1),
|
|
6306
|
+
name: import_zod55.z.string().min(1),
|
|
6307
|
+
recurringShippingPrice: import_zod55.z.number().nonnegative(),
|
|
6308
|
+
shippingOption: import_zod55.z.object({ presentmentTitle: import_zod55.z.string(), title: import_zod55.z.string() })
|
|
6069
6309
|
});
|
|
6070
6310
|
|
|
6071
6311
|
// src/schema/postPurchaseProduct.ts
|
|
@@ -6075,51 +6315,52 @@ var PostPurchaseVariant = OfferProduct.shape.variants.element.pick({ id: true, t
|
|
|
6075
6315
|
id: PostPurchaseVariantId,
|
|
6076
6316
|
price: PostPurchaseAmount
|
|
6077
6317
|
});
|
|
6078
|
-
var PreparedPostPurchaseProduct =
|
|
6318
|
+
var PreparedPostPurchaseProduct = import_zod56.z.object({
|
|
6079
6319
|
display: PostPurchaseProductDisplay,
|
|
6080
|
-
labels:
|
|
6320
|
+
labels: import_zod56.z.object({
|
|
6081
6321
|
declineAll: global.declineAll,
|
|
6082
|
-
free:
|
|
6083
|
-
|
|
6084
|
-
|
|
6322
|
+
free: import_zod56.z.string(),
|
|
6323
|
+
notAvailable: global.notAvailable,
|
|
6324
|
+
payNow: import_zod56.z.string(),
|
|
6325
|
+
quantity: import_zod56.z.string(),
|
|
6085
6326
|
recurringShipping: global.recurringShipping,
|
|
6086
6327
|
recurringSubtotal: global.recurringSubtotal,
|
|
6087
|
-
save:
|
|
6088
|
-
shipping:
|
|
6089
|
-
subtotal:
|
|
6090
|
-
taxes:
|
|
6091
|
-
total:
|
|
6328
|
+
save: import_zod56.z.string(),
|
|
6329
|
+
shipping: import_zod56.z.string(),
|
|
6330
|
+
subtotal: import_zod56.z.string(),
|
|
6331
|
+
taxes: import_zod56.z.string(),
|
|
6332
|
+
total: import_zod56.z.string()
|
|
6092
6333
|
}),
|
|
6093
6334
|
product: OfferProduct.pick({ description: true, id: true, image: true, title: true }).extend({
|
|
6094
6335
|
description: OfferProduct.shape.description.nullable(),
|
|
6095
6336
|
id: PostPurchaseProductId,
|
|
6096
6337
|
variant: PostPurchaseVariant
|
|
6097
6338
|
}),
|
|
6098
|
-
selection:
|
|
6339
|
+
selection: import_zod56.z.object({
|
|
6099
6340
|
productId: PostPurchaseProductId,
|
|
6100
|
-
quantity:
|
|
6101
|
-
sellingPlanId:
|
|
6341
|
+
quantity: import_zod56.z.number().int().positive(),
|
|
6342
|
+
sellingPlanId: import_zod56.z.number().int().positive().optional(),
|
|
6102
6343
|
variantId: PostPurchaseVariantId
|
|
6103
6344
|
}),
|
|
6104
|
-
status:
|
|
6105
|
-
terms:
|
|
6345
|
+
status: import_zod56.z.literal("prepared"),
|
|
6346
|
+
terms: import_zod56.z.object({
|
|
6106
6347
|
discount: PostPurchaseDiscount,
|
|
6107
|
-
shipping:
|
|
6108
|
-
amount:
|
|
6109
|
-
title:
|
|
6110
|
-
type:
|
|
6348
|
+
shipping: import_zod56.z.object({
|
|
6349
|
+
amount: import_zod56.z.number().nonnegative(),
|
|
6350
|
+
title: import_zod56.z.string(),
|
|
6351
|
+
type: import_zod56.z.enum(["free", "fixed_amount"])
|
|
6111
6352
|
}),
|
|
6112
6353
|
subscription: PostPurchaseSubscriptionTerms.optional()
|
|
6113
6354
|
})
|
|
6114
6355
|
});
|
|
6115
|
-
var PostPurchasePreparation =
|
|
6356
|
+
var PostPurchasePreparation = import_zod56.z.discriminatedUnion("status", [
|
|
6116
6357
|
PreparedPostPurchaseProduct,
|
|
6117
|
-
|
|
6358
|
+
import_zod56.z.object({ reason: import_zod56.z.string(), status: import_zod56.z.literal("unsupported") })
|
|
6118
6359
|
]);
|
|
6119
6360
|
|
|
6120
6361
|
// src/schema/postPurchaseSubscriptionProduct.ts
|
|
6121
6362
|
var PreparedPostPurchaseSubscription = PreparedPostPurchaseProduct.extend({
|
|
6122
|
-
selection: PreparedPostPurchaseProduct.shape.selection.extend({ sellingPlanId:
|
|
6363
|
+
selection: PreparedPostPurchaseProduct.shape.selection.extend({ sellingPlanId: import_zod57.z.number().int().positive() }),
|
|
6123
6364
|
terms: PreparedPostPurchaseProduct.shape.terms.extend({
|
|
6124
6365
|
subscription: PostPurchaseSubscriptionTerms
|
|
6125
6366
|
}).refine(
|
|
@@ -6142,12 +6383,12 @@ var PostPurchaseSubscriptionSettings = subscription.extend({
|
|
|
6142
6383
|
var postPurchaseVariantAvailable = (variant2) => !(variant2.inventoryManagement && variant2.inventoryPolicy === "deny" && variant2.inventoryQuantity <= 0);
|
|
6143
6384
|
|
|
6144
6385
|
// src/server/postPurchaseSubscriptionEligibility.ts
|
|
6145
|
-
var subscriptionUnavailable = (normalized, plan, allowCollection,
|
|
6386
|
+
var subscriptionUnavailable = (normalized, plan, allowCollection, quantity3) => {
|
|
6146
6387
|
const { data, effective, original } = normalized;
|
|
6147
6388
|
const unavailable = "An eligible subscription plan with supported shipping and discount is required";
|
|
6148
6389
|
if (data.length !== 1 || data[0].variants.length !== 1) return unavailable;
|
|
6149
6390
|
if (effective.productType === "one-time" || [original, effective].some(
|
|
6150
|
-
(config) => !allowCollection && config.productLimit !== 1 || config.upgradeToSubscription.allow || !
|
|
6391
|
+
(config) => !allowCollection && config.productLimit !== 1 || config.upgradeToSubscription.allow || !quantity3 && config.quantityInputs.enabled && (config.quantityInputs.minValue !== config.quantityInputs.maxValue || config.quantityInputs.defaultQuantity !== config.quantityInputs.minValue)
|
|
6151
6392
|
))
|
|
6152
6393
|
return unavailable;
|
|
6153
6394
|
const product = data[0];
|
|
@@ -6161,7 +6402,7 @@ var subscriptionUnavailable = (normalized, plan, allowCollection, quantity2) =>
|
|
|
6161
6402
|
};
|
|
6162
6403
|
|
|
6163
6404
|
// src/server/postPurchaseProductDisplay.ts
|
|
6164
|
-
var
|
|
6405
|
+
var import_zod59 = require("zod");
|
|
6165
6406
|
|
|
6166
6407
|
// src/server/postPurchasePrimaryImage.ts
|
|
6167
6408
|
var postPurchasePrimaryImage = (product) => {
|
|
@@ -6183,7 +6424,7 @@ var postPurchaseProductGallery = (product, limit) => ({
|
|
|
6183
6424
|
});
|
|
6184
6425
|
|
|
6185
6426
|
// src/transforms/postPurchase/convertDescriptionRte.ts
|
|
6186
|
-
var
|
|
6427
|
+
var import_zod58 = require("zod");
|
|
6187
6428
|
var alignments = { center: "center", left: "start", right: "end" };
|
|
6188
6429
|
var colors = ["critical", "subdued", "success", "warning"];
|
|
6189
6430
|
var sizes2 = ["extraSmall", "small", "medium", "large", "extraLarge"];
|
|
@@ -6195,19 +6436,19 @@ var spacings2 = {
|
|
|
6195
6436
|
xloose: "extraLoose",
|
|
6196
6437
|
xtight: "extraTight"
|
|
6197
6438
|
};
|
|
6198
|
-
var Block =
|
|
6199
|
-
attrs:
|
|
6200
|
-
content:
|
|
6201
|
-
type:
|
|
6202
|
-
});
|
|
6203
|
-
var Run =
|
|
6204
|
-
var Inline =
|
|
6205
|
-
attrs:
|
|
6206
|
-
color:
|
|
6207
|
-
emphasis:
|
|
6208
|
-
size:
|
|
6439
|
+
var Block = import_zod58.z.object({
|
|
6440
|
+
attrs: import_zod58.z.object({ alignment: import_zod58.z.enum(["left", "center", "right"]).optional().catch(void 0) }).catch({}),
|
|
6441
|
+
content: import_zod58.z.array(import_zod58.z.unknown()).catch([]),
|
|
6442
|
+
type: import_zod58.z.literal("ShopifyTextBlock")
|
|
6443
|
+
});
|
|
6444
|
+
var Run = import_zod58.z.object({ marks: import_zod58.z.array(import_zod58.z.unknown()).catch([]), text: import_zod58.z.string().min(1), type: import_zod58.z.literal("text") });
|
|
6445
|
+
var Inline = import_zod58.z.object({
|
|
6446
|
+
attrs: import_zod58.z.object({
|
|
6447
|
+
color: import_zod58.z.enum(colors).optional().catch(void 0),
|
|
6448
|
+
emphasis: import_zod58.z.array(import_zod58.z.unknown()).catch([]),
|
|
6449
|
+
size: import_zod58.z.enum(sizes2).optional().catch(void 0)
|
|
6209
6450
|
}),
|
|
6210
|
-
type:
|
|
6451
|
+
type: import_zod58.z.literal("ShopifyTextInline")
|
|
6211
6452
|
});
|
|
6212
6453
|
var marks = (raw) => {
|
|
6213
6454
|
const found = raw.map((mark) => Inline.safeParse(mark)).find(({ success }) => success)?.data;
|
|
@@ -6240,7 +6481,7 @@ var convertDescriptionRte = (rte, spacing) => TiptapDocument.parse({
|
|
|
6240
6481
|
});
|
|
6241
6482
|
|
|
6242
6483
|
// src/server/postPurchaseProductDisplay.ts
|
|
6243
|
-
var ResponseLanguage =
|
|
6484
|
+
var ResponseLanguage = import_zod59.z.object({ description: PostPurchaseProductDisplay.shape.responseDescription }).default({ description: "" });
|
|
6244
6485
|
var projectPostPurchaseProductDisplay = (effective, metadata, product) => PostPurchaseProductDisplay.parse({
|
|
6245
6486
|
descriptionDocument: effective.language.descriptionRte && convertDescriptionRte(effective.language.descriptionRte, effective.language.descriptionSpacing),
|
|
6246
6487
|
discountedFrom: effective.discountedFrom,
|
|
@@ -6253,14 +6494,14 @@ var projectPostPurchaseProductDisplay = (effective, metadata, product) => PostPu
|
|
|
6253
6494
|
});
|
|
6254
6495
|
|
|
6255
6496
|
// src/server/postPurchaseReviewData.ts
|
|
6256
|
-
var
|
|
6497
|
+
var import_zod63 = require("zod");
|
|
6257
6498
|
|
|
6258
6499
|
// src/server/postPurchaseJudgeMeReviews.ts
|
|
6259
|
-
var
|
|
6500
|
+
var import_zod60 = require("zod");
|
|
6260
6501
|
var readJudgeMeReviews = (find) => {
|
|
6261
6502
|
const field = find("judgeme", "badge");
|
|
6262
6503
|
if (!field) return null;
|
|
6263
|
-
const html =
|
|
6504
|
+
const html = import_zod60.z.string().parse(field.value);
|
|
6264
6505
|
const rating = html.match(/data-average-rating=['"](\d+(?:\.\d+)?)['"]/);
|
|
6265
6506
|
const count = html.match(/data-number-of-reviews=['"](\d+)['"]/);
|
|
6266
6507
|
if (!rating || !count) throw new Error("Unreadable Judge.me attributes");
|
|
@@ -6271,26 +6512,26 @@ var readJudgeMeReviews = (find) => {
|
|
|
6271
6512
|
};
|
|
6272
6513
|
|
|
6273
6514
|
// src/server/postPurchaseOkendoReviews.ts
|
|
6274
|
-
var
|
|
6275
|
-
var Summary =
|
|
6515
|
+
var import_zod61 = require("zod");
|
|
6516
|
+
var Summary = import_zod61.z.object({
|
|
6276
6517
|
reviewAverageValue: PostPurchaseCommonReviewRating.shape.value,
|
|
6277
|
-
reviewCount:
|
|
6518
|
+
reviewCount: import_zod61.z.union([PostPurchaseProductReviews.shape.reviewCount, PostPurchaseReviewCount])
|
|
6278
6519
|
});
|
|
6279
6520
|
var readOkendoReviews = (find) => {
|
|
6280
6521
|
const field = find("okendo", "summaryData");
|
|
6281
6522
|
if (!field) return null;
|
|
6282
|
-
const summary = Summary.parse(JSON.parse(
|
|
6523
|
+
const summary = Summary.parse(JSON.parse(import_zod61.z.string().parse(field.value)));
|
|
6283
6524
|
return { rating: summary.reviewAverageValue, reviewCount: summary.reviewCount };
|
|
6284
6525
|
};
|
|
6285
6526
|
|
|
6286
6527
|
// src/server/postPurchaseScalarReviews.ts
|
|
6287
|
-
var
|
|
6528
|
+
var import_zod62 = require("zod");
|
|
6288
6529
|
var readScalarReviews = (find, namespace, ratingKey, countKey) => {
|
|
6289
6530
|
const rating = find(namespace, ratingKey);
|
|
6290
6531
|
const count = find(namespace, countKey);
|
|
6291
6532
|
if (!rating || !count) return null;
|
|
6292
6533
|
return {
|
|
6293
|
-
rating: PostPurchaseCommonReviewRating.parse({ value:
|
|
6534
|
+
rating: PostPurchaseCommonReviewRating.parse({ value: import_zod62.z.string().parse(rating.value) }).value,
|
|
6294
6535
|
reviewCount: PostPurchaseReviewCount.parse(count.value)
|
|
6295
6536
|
};
|
|
6296
6537
|
};
|
|
@@ -6309,16 +6550,16 @@ var readPostPurchaseReviewData = (provider, find) => {
|
|
|
6309
6550
|
const count = find("reviews", "rating_count");
|
|
6310
6551
|
if (!rating || !count) return null;
|
|
6311
6552
|
return {
|
|
6312
|
-
rating: PostPurchaseKlaviyoReviewRating.parse(JSON.parse(
|
|
6553
|
+
rating: PostPurchaseKlaviyoReviewRating.parse(JSON.parse(import_zod63.z.string().parse(rating.value))).value,
|
|
6313
6554
|
reviewCount: PostPurchaseReviewCount.parse(count.value)
|
|
6314
6555
|
};
|
|
6315
6556
|
};
|
|
6316
6557
|
|
|
6317
6558
|
// src/server/postPurchaseReviewFields.ts
|
|
6318
|
-
var
|
|
6319
|
-
var Field =
|
|
6559
|
+
var import_zod64 = require("zod");
|
|
6560
|
+
var Field = import_zod64.z.object({ key: import_zod64.z.string(), namespace: import_zod64.z.string(), value: import_zod64.z.unknown().optional() });
|
|
6320
6561
|
var reviewFields = (raw) => {
|
|
6321
|
-
const fields4 =
|
|
6562
|
+
const fields4 = import_zod64.z.array(import_zod64.z.unknown()).parse(raw).flatMap((field) => {
|
|
6322
6563
|
const parsed = Field.safeParse(field);
|
|
6323
6564
|
return parsed.success ? [parsed.data] : [];
|
|
6324
6565
|
});
|
|
@@ -6326,8 +6567,8 @@ var reviewFields = (raw) => {
|
|
|
6326
6567
|
};
|
|
6327
6568
|
|
|
6328
6569
|
// src/server/postPurchaseReviewProvider.ts
|
|
6329
|
-
var
|
|
6330
|
-
var IntegrationInput =
|
|
6570
|
+
var import_zod65 = require("zod");
|
|
6571
|
+
var IntegrationInput = import_zod65.z.record(import_zod65.z.string(), import_zod65.z.unknown()).prefault({});
|
|
6331
6572
|
var precedence = [
|
|
6332
6573
|
"klaviyo",
|
|
6333
6574
|
"judgeme",
|
|
@@ -6339,7 +6580,7 @@ var precedence = [
|
|
|
6339
6580
|
"stamped",
|
|
6340
6581
|
"yotpo"
|
|
6341
6582
|
];
|
|
6342
|
-
var ReviewsIoFlag =
|
|
6583
|
+
var ReviewsIoFlag = import_zod65.z.preprocess((value) => {
|
|
6343
6584
|
if (typeof value === "string") {
|
|
6344
6585
|
const flag = value.toLowerCase();
|
|
6345
6586
|
if (flag === "true" || flag === "yes") return true;
|
|
@@ -6399,12 +6640,12 @@ var projectPostPurchaseProduct = ({ data, effective, metadata, original }, repor
|
|
|
6399
6640
|
};
|
|
6400
6641
|
|
|
6401
6642
|
// src/server/prepareNormalizedSubscription.ts
|
|
6402
|
-
var prepareNormalizedSubscription = (normalized, report, plan,
|
|
6643
|
+
var prepareNormalizedSubscription = (normalized, report, plan, quantity3, allowCollection = false) => {
|
|
6403
6644
|
if (!plan) return { reason: "Subscription plan is unavailable", status: "unsupported" };
|
|
6404
|
-
const reason = subscriptionUnavailable(normalized, plan, allowCollection,
|
|
6645
|
+
const reason = subscriptionUnavailable(normalized, plan, allowCollection, quantity3);
|
|
6405
6646
|
if (reason) return { reason, status: "unsupported" };
|
|
6406
6647
|
const { effective } = normalized;
|
|
6407
|
-
const projected = projectPostPurchaseProduct(normalized, report,
|
|
6648
|
+
const projected = projectPostPurchaseProduct(normalized, report, quantity3);
|
|
6408
6649
|
const { discount, shipping } = PostPurchaseSubscriptionSettings.parse(effective.subscription);
|
|
6409
6650
|
const shippingPrice = shipping.type === "free" ? 0 : shipping.amount;
|
|
6410
6651
|
return PreparedPostPurchaseSubscription.parse({
|
|
@@ -6442,11 +6683,11 @@ var preparePostPurchaseSubscription = (settings, response, report) => {
|
|
|
6442
6683
|
};
|
|
6443
6684
|
|
|
6444
6685
|
// src/server/postPurchaseProductEligibility.ts
|
|
6445
|
-
var oneTimeUnavailable = (normalized, allowCollection,
|
|
6686
|
+
var oneTimeUnavailable = (normalized, allowCollection, quantity3) => {
|
|
6446
6687
|
const { data, effective, original } = normalized;
|
|
6447
6688
|
if (data.length !== 1 || data[0].variants.length !== 1) return "Only one fixed product and variant are supported";
|
|
6448
6689
|
if (effective.productType === "subscription" || [original, effective].some(
|
|
6449
|
-
(config) => !allowCollection && config.productLimit !== 1 || config.upgradeToSubscription.allow || !
|
|
6690
|
+
(config) => !allowCollection && config.productLimit !== 1 || config.upgradeToSubscription.allow || !quantity3 && config.quantityInputs.enabled && (config.quantityInputs.minValue !== config.quantityInputs.maxValue || config.quantityInputs.defaultQuantity !== config.quantityInputs.minValue)
|
|
6450
6691
|
))
|
|
6451
6692
|
return "Only fixed one-time configuration is supported";
|
|
6452
6693
|
const product = data[0];
|
|
@@ -6457,12 +6698,12 @@ var oneTimeUnavailable = (normalized, allowCollection, quantity2) => {
|
|
|
6457
6698
|
};
|
|
6458
6699
|
|
|
6459
6700
|
// src/server/preparePostPurchaseProduct.ts
|
|
6460
|
-
var prepareNormalizedProduct = (normalized, report,
|
|
6461
|
-
const reason = oneTimeUnavailable(normalized, allowCollection,
|
|
6701
|
+
var prepareNormalizedProduct = (normalized, report, quantity3, allowCollection = false) => {
|
|
6702
|
+
const reason = oneTimeUnavailable(normalized, allowCollection, quantity3);
|
|
6462
6703
|
if (reason) return { reason, status: "unsupported" };
|
|
6463
6704
|
const { effective } = normalized;
|
|
6464
6705
|
return PreparedPostPurchaseProduct.parse({
|
|
6465
|
-
...projectPostPurchaseProduct(normalized, report,
|
|
6706
|
+
...projectPostPurchaseProduct(normalized, report, quantity3),
|
|
6466
6707
|
status: "prepared",
|
|
6467
6708
|
terms: {
|
|
6468
6709
|
discount: { ...effective.discount, title: effective.language.global.save },
|
|
@@ -6473,45 +6714,80 @@ var prepareNormalizedProduct = (normalized, report, quantity2, allowCollection =
|
|
|
6473
6714
|
var preparePostPurchaseProduct = (settings, response, report) => prepareNormalizedProduct(normalizePostPurchaseProduct(settings, response), report);
|
|
6474
6715
|
|
|
6475
6716
|
// src/schema/postPurchaseProductView.ts
|
|
6476
|
-
var
|
|
6717
|
+
var import_zod72 = require("zod");
|
|
6477
6718
|
|
|
6478
6719
|
// src/schema/postPurchaseChoice.ts
|
|
6479
|
-
var
|
|
6480
|
-
var PostPurchaseChoice =
|
|
6481
|
-
|
|
6482
|
-
|
|
6720
|
+
var import_zod66 = require("zod");
|
|
6721
|
+
var PostPurchaseChoice = import_zod66.z.discriminatedUnion("mode", [
|
|
6722
|
+
import_zod66.z.object({ mode: import_zod66.z.literal("one-time") }).strict(),
|
|
6723
|
+
import_zod66.z.object({ mode: import_zod66.z.literal("subscription"), sellingPlanId: PostPurchasePlanOption.shape.id }).strict()
|
|
6483
6724
|
]);
|
|
6484
|
-
var PostPurchaseOptions =
|
|
6725
|
+
var PostPurchaseOptions = import_zod66.z.object({
|
|
6485
6726
|
defaultChoice: PostPurchaseChoice,
|
|
6486
|
-
modes:
|
|
6727
|
+
modes: import_zod66.z.array(import_zod66.z.enum(["one-time", "subscription"])).min(1).max(2),
|
|
6487
6728
|
selector: PostPurchaseSettings.shape.productTypeSelector
|
|
6488
6729
|
});
|
|
6489
6730
|
|
|
6731
|
+
// src/schema/postPurchaseDisplayPrice.ts
|
|
6732
|
+
var import_zod68 = require("zod");
|
|
6733
|
+
|
|
6734
|
+
// src/schema/postPurchaseSubscriptionDisplay.ts
|
|
6735
|
+
var import_zod67 = require("zod");
|
|
6736
|
+
var Minor = import_zod67.z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
6737
|
+
var PostPurchaseSubscriptionDisplay = import_zod67.z.object({
|
|
6738
|
+
comparisonMinor: Minor,
|
|
6739
|
+
currencyCode: import_zod67.z.string().regex(/^[A-Z]{3}$/),
|
|
6740
|
+
priceMinor: Minor,
|
|
6741
|
+
savingMinor: Minor,
|
|
6742
|
+
savingPercent: import_zod67.z.number().int().min(0).max(100)
|
|
6743
|
+
});
|
|
6744
|
+
|
|
6745
|
+
// src/schema/postPurchaseDisplayPrice.ts
|
|
6746
|
+
var { currencyCode: CurrencyCode, priceMinor: Minor2, savingPercent: Percent } = PostPurchaseSubscriptionDisplay.shape;
|
|
6747
|
+
var PostPurchaseDisplayPrice = import_zod68.z.object({
|
|
6748
|
+
currencyCode: CurrencyCode,
|
|
6749
|
+
savingFormat: import_zod68.z.enum(["amount", "percent"]),
|
|
6750
|
+
savingMinor: Minor2,
|
|
6751
|
+
savingPercent: Percent,
|
|
6752
|
+
subscriptionUnit: PostPurchaseSubscriptionDisplay.optional(),
|
|
6753
|
+
variantCompareAtPriceMinor: Minor2.nullable(),
|
|
6754
|
+
variantPriceMinor: Minor2
|
|
6755
|
+
}).refine(
|
|
6756
|
+
({ variantCompareAtPriceMinor: struck, variantPriceMinor: price }) => struck === null || struck > price,
|
|
6757
|
+
"A compare-at price is struck only above the price"
|
|
6758
|
+
).refine(
|
|
6759
|
+
({ savingMinor, savingPercent, variantCompareAtPriceMinor: struck, variantPriceMinor: price }) => savingMinor === (struck ?? price) - price && (savingMinor > 0 || savingPercent === 0),
|
|
6760
|
+
"The saving is the struck price minus the price"
|
|
6761
|
+
).refine(
|
|
6762
|
+
({ subscriptionUnit: unit, ...facts }) => !unit || unit.currencyCode === facts.currencyCode && unit.priceMinor === facts.variantPriceMinor && unit.savingMinor === facts.savingMinor && unit.savingPercent === facts.savingPercent && unit.savingMinor === Math.max(0, unit.comparisonMinor - unit.priceMinor),
|
|
6763
|
+
"The subscription unit estimate restates the plan facts in the same currency"
|
|
6764
|
+
);
|
|
6765
|
+
|
|
6490
6766
|
// src/schema/postPurchaseGroupCatalog.ts
|
|
6491
|
-
var
|
|
6767
|
+
var import_zod70 = require("zod");
|
|
6492
6768
|
|
|
6493
6769
|
// src/schema/postPurchaseVariantCatalog.ts
|
|
6494
|
-
var
|
|
6495
|
-
var PostPurchaseVariantSelector =
|
|
6770
|
+
var import_zod69 = require("zod");
|
|
6771
|
+
var PostPurchaseVariantSelector = import_zod69.z.object({ variantId: PostPurchaseVariantId }).strict();
|
|
6496
6772
|
var PostPurchaseVariantOption = OfferProduct.shape.options.element.extend({
|
|
6497
|
-
id:
|
|
6498
|
-
position:
|
|
6773
|
+
id: import_zod69.z.number().int().positive(),
|
|
6774
|
+
position: import_zod69.z.number().int().min(1).max(3)
|
|
6499
6775
|
});
|
|
6500
6776
|
var PostPurchaseVariantValues = OfferProduct.shape.variants.element.pick({
|
|
6501
6777
|
option1: true,
|
|
6502
6778
|
option2: true,
|
|
6503
6779
|
option3: true
|
|
6504
6780
|
});
|
|
6505
|
-
var PostPurchaseVariantCatalog =
|
|
6781
|
+
var PostPurchaseVariantCatalog = import_zod69.z.object({
|
|
6506
6782
|
displayMode: PostPurchaseSettings.shape.productOptions.shape.variantSelectorDisplayMode,
|
|
6507
|
-
options:
|
|
6783
|
+
options: import_zod69.z.array(PostPurchaseVariantOption),
|
|
6508
6784
|
productId: PostPurchaseProductId,
|
|
6509
6785
|
showSelectors: PostPurchaseSettings.shape.productOptions.shape.showVariantSelectors,
|
|
6510
|
-
variants:
|
|
6786
|
+
variants: import_zod69.z.array(
|
|
6511
6787
|
PostPurchaseVariantValues.partial().extend({
|
|
6512
|
-
available:
|
|
6788
|
+
available: import_zod69.z.boolean(),
|
|
6513
6789
|
id: PostPurchaseVariantId,
|
|
6514
|
-
imageId:
|
|
6790
|
+
imageId: import_zod69.z.number().int().nonnegative().nullish(),
|
|
6515
6791
|
title: OfferProduct.shape.variants.element.shape.title
|
|
6516
6792
|
})
|
|
6517
6793
|
)
|
|
@@ -6525,23 +6801,89 @@ var PostPurchaseGroupDescription = source.pick({ description: true, id: true, im
|
|
|
6525
6801
|
image: source.shape.image.default(null),
|
|
6526
6802
|
options: PostPurchaseVariantCatalog.shape.options.default([])
|
|
6527
6803
|
});
|
|
6528
|
-
var PostPurchaseGroupCatalog =
|
|
6804
|
+
var PostPurchaseGroupCatalog = import_zod70.z.object({
|
|
6529
6805
|
memberProductId: productId,
|
|
6530
|
-
options:
|
|
6806
|
+
options: import_zod70.z.array(import_zod70.z.object({ productId, title: import_zod70.z.string(), variantCatalog: PostPurchaseVariantCatalog }))
|
|
6531
6807
|
});
|
|
6532
|
-
var PostPurchaseGroupSelection =
|
|
6808
|
+
var PostPurchaseGroupSelection = import_zod70.z.object({
|
|
6533
6809
|
memberProductId: productId,
|
|
6534
6810
|
productId
|
|
6535
6811
|
});
|
|
6536
6812
|
|
|
6813
|
+
// src/schema/postPurchaseProductCalculation.ts
|
|
6814
|
+
var import_zod71 = require("zod");
|
|
6815
|
+
var MoneyBag = import_zod71.z.object({
|
|
6816
|
+
presentmentMoney: import_zod71.z.object({
|
|
6817
|
+
amount: PostPurchaseAmount,
|
|
6818
|
+
currencyCode: import_zod71.z.string().regex(/^[A-Z]{3}$/)
|
|
6819
|
+
})
|
|
6820
|
+
});
|
|
6821
|
+
var PostPurchaseProductCalculation = import_zod71.z.object({
|
|
6822
|
+
calculatedPurchase: import_zod71.z.object({
|
|
6823
|
+
addedShippingLines: import_zod71.z.array(import_zod71.z.object({ priceSet: MoneyBag })),
|
|
6824
|
+
addedTaxLines: import_zod71.z.array(import_zod71.z.object({ priceSet: MoneyBag })),
|
|
6825
|
+
totalOutstandingSet: MoneyBag,
|
|
6826
|
+
updatedLineItems: import_zod71.z.array(
|
|
6827
|
+
import_zod71.z.object({
|
|
6828
|
+
priceSet: import_zod71.z.unknown().optional(),
|
|
6829
|
+
productId: import_zod71.z.number().int().positive(),
|
|
6830
|
+
sellingPlanId: import_zod71.z.unknown().optional(),
|
|
6831
|
+
variantId: import_zod71.z.number().int().positive()
|
|
6832
|
+
})
|
|
6833
|
+
)
|
|
6834
|
+
}),
|
|
6835
|
+
errors: import_zod71.z.array(import_zod71.z.unknown()).length(0),
|
|
6836
|
+
status: import_zod71.z.literal("processed")
|
|
6837
|
+
});
|
|
6838
|
+
var Minor3 = import_zod71.z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
6839
|
+
var PostPurchaseProductCosts = import_zod71.z.object({
|
|
6840
|
+
currencyCode: MoneyBag.shape.presentmentMoney.shape.currencyCode,
|
|
6841
|
+
recurringDisplay: import_zod71.z.object({ shippingMinor: Minor3, subtotalMinor: Minor3, totalMinor: Minor3 }).optional(),
|
|
6842
|
+
shippingMinor: Minor3,
|
|
6843
|
+
subtotalMinor: Minor3,
|
|
6844
|
+
taxesMinor: Minor3,
|
|
6845
|
+
totalMinor: Minor3
|
|
6846
|
+
});
|
|
6847
|
+
var ChangesetDiscount = import_zod71.z.object({
|
|
6848
|
+
title: import_zod71.z.string(),
|
|
6849
|
+
value: import_zod71.z.number().nonnegative(),
|
|
6850
|
+
valueType: import_zod71.z.enum(["percentage", "fixed_amount"])
|
|
6851
|
+
}).optional();
|
|
6852
|
+
var PostPurchaseProductChangeset = import_zod71.z.object({
|
|
6853
|
+
changes: import_zod71.z.array(
|
|
6854
|
+
import_zod71.z.union([
|
|
6855
|
+
import_zod71.z.object({
|
|
6856
|
+
discount: ChangesetDiscount,
|
|
6857
|
+
quantity: import_zod71.z.number().int().positive(),
|
|
6858
|
+
type: import_zod71.z.literal("add_variant"),
|
|
6859
|
+
variantId: import_zod71.z.number().int().positive()
|
|
6860
|
+
}),
|
|
6861
|
+
import_zod71.z.object({ price: import_zod71.z.number().nonnegative(), title: import_zod71.z.string(), type: import_zod71.z.literal("add_shipping_line") }),
|
|
6862
|
+
PostPurchaseSubscriptionTerms.pick({
|
|
6863
|
+
initialShippingPrice: true,
|
|
6864
|
+
recurringShippingPrice: true,
|
|
6865
|
+
shippingOption: true
|
|
6866
|
+
}).extend({
|
|
6867
|
+
discount: ChangesetDiscount,
|
|
6868
|
+
quantity: import_zod71.z.number().int().positive(),
|
|
6869
|
+
sellingPlanId: import_zod71.z.number().int().positive(),
|
|
6870
|
+
type: import_zod71.z.literal("add_subscription"),
|
|
6871
|
+
variantId: import_zod71.z.number().int().positive()
|
|
6872
|
+
})
|
|
6873
|
+
])
|
|
6874
|
+
)
|
|
6875
|
+
});
|
|
6876
|
+
|
|
6537
6877
|
// src/schema/postPurchaseProductView.ts
|
|
6538
|
-
var PostPurchaseProductView =
|
|
6539
|
-
|
|
6878
|
+
var PostPurchaseProductView = import_zod72.z.union([
|
|
6879
|
+
import_zod72.z.object({
|
|
6880
|
+
changeset: PostPurchaseProductChangeset.optional(),
|
|
6881
|
+
displayPrice: PostPurchaseDisplayPrice.optional(),
|
|
6540
6882
|
groupCatalog: PostPurchaseGroupCatalog.optional(),
|
|
6541
6883
|
initialVariant: PostPurchaseVariantSelector.optional(),
|
|
6542
6884
|
planCatalog: PostPurchasePlanCatalog.nullable().optional(),
|
|
6543
6885
|
preparation: PreparedPostPurchaseProduct.extend({
|
|
6544
|
-
display: PreparedPostPurchaseProduct.shape.display.extend({ description:
|
|
6886
|
+
display: PreparedPostPurchaseProduct.shape.display.extend({ description: import_zod72.z.string().nullable() }).refine(
|
|
6545
6887
|
({ description, descriptionDocument }) => description === null === (descriptionDocument !== void 0),
|
|
6546
6888
|
"Exactly one of the plain and rich descriptions is shown"
|
|
6547
6889
|
)
|
|
@@ -6550,24 +6892,26 @@ var PostPurchaseProductView = import_zod67.z.union([
|
|
|
6550
6892
|
sections: CABRootSection,
|
|
6551
6893
|
variantCatalog: PostPurchaseVariantCatalog.optional()
|
|
6552
6894
|
}),
|
|
6553
|
-
|
|
6895
|
+
import_zod72.z.object({
|
|
6554
6896
|
groupCatalog: PostPurchaseGroupCatalog.optional(),
|
|
6555
6897
|
initialVariant: PostPurchaseVariantSelector.optional(),
|
|
6898
|
+
/** The localized unavailable copy, for the choices still offered beneath an unprepared product. */
|
|
6899
|
+
labels: PreparedPostPurchaseProduct.shape.labels.pick({ notAvailable: true }).optional(),
|
|
6556
6900
|
planCatalog: PostPurchasePlanCatalog.nullable().optional(),
|
|
6557
6901
|
preparation: PostPurchasePreparation.options[1],
|
|
6558
6902
|
purchaseOptions: PostPurchaseOptions.optional(),
|
|
6559
|
-
sections:
|
|
6903
|
+
sections: import_zod72.z.null(),
|
|
6560
6904
|
variantCatalog: PostPurchaseVariantCatalog.optional()
|
|
6561
6905
|
})
|
|
6562
6906
|
]);
|
|
6563
6907
|
|
|
6564
6908
|
// src/server/postPurchaseOfferCopy.ts
|
|
6565
|
-
var
|
|
6566
|
-
var Copy =
|
|
6909
|
+
var import_zod73 = require("zod");
|
|
6910
|
+
var Copy = import_zod73.z.object({
|
|
6567
6911
|
superTitle: CalloutBannerBlock.shape.settings.shape.superTitle.unwrap().optional().catch(void 0),
|
|
6568
6912
|
title: CalloutBannerBlock.shape.settings.shape.title.unwrap().optional().catch(void 0)
|
|
6569
6913
|
});
|
|
6570
|
-
var Callout =
|
|
6914
|
+
var Callout = import_zod73.z.object({ settings: import_zod73.z.record(import_zod73.z.string(), import_zod73.z.unknown()), type: import_zod73.z.literal("callout_banner") });
|
|
6571
6915
|
var postPurchaseOfferCopy = (blocks, metadata) => {
|
|
6572
6916
|
const copy = Copy.safeParse(metadata.widget.language);
|
|
6573
6917
|
if (!blocks || !copy.success) return blocks;
|
|
@@ -6588,13 +6932,13 @@ var postPurchaseOfferCopy = (blocks, metadata) => {
|
|
|
6588
6932
|
};
|
|
6589
6933
|
|
|
6590
6934
|
// src/server/selectPostPurchaseChoice.ts
|
|
6591
|
-
var selectPostPurchaseChoice = (normalized, projected, requested, allowCollection,
|
|
6935
|
+
var selectPostPurchaseChoice = (normalized, projected, requested, allowCollection, quantity3) => {
|
|
6592
6936
|
const { data, effective } = normalized;
|
|
6593
6937
|
const modes = [];
|
|
6594
6938
|
const catalog = projected && projected.productId === data[0]?.id && projected.variantId === data[0].variants[0]?.id ? projected : null;
|
|
6595
6939
|
const firstPlan = catalog?.plans[0];
|
|
6596
|
-
const oneTimeReason = oneTimeUnavailable(normalized, allowCollection,
|
|
6597
|
-
const subscriptionReason = subscriptionUnavailable(normalized, firstPlan, allowCollection,
|
|
6940
|
+
const oneTimeReason = oneTimeUnavailable(normalized, allowCollection, quantity3);
|
|
6941
|
+
const subscriptionReason = subscriptionUnavailable(normalized, firstPlan, allowCollection, quantity3);
|
|
6598
6942
|
if (!oneTimeReason) modes.push("one-time");
|
|
6599
6943
|
if (!subscriptionReason) modes.push("subscription");
|
|
6600
6944
|
if (oneTimeReason && subscriptionReason)
|
|
@@ -6622,22 +6966,26 @@ var resolveDescription = ({ descriptionDocument, ...display }, productDescriptio
|
|
|
6622
6966
|
const plain = display.language.descriptionEnabled && productDescription || display.responseDescription || (descriptionDocument ? null : display.language.description);
|
|
6623
6967
|
return plain === null ? { ...display, description: null, descriptionDocument } : { ...display, description: plain };
|
|
6624
6968
|
};
|
|
6625
|
-
var prepareNormalizedPostPurchaseView = (widgetId, normalized, report, choice,
|
|
6969
|
+
var prepareNormalizedPostPurchaseView = (widgetId, normalized, report, choice, quantity3, allowCollection = false) => {
|
|
6626
6970
|
const planCatalog = projectPostPurchasePlanCatalog(normalized, report);
|
|
6627
|
-
const selected = selectPostPurchaseChoice(normalized, planCatalog, choice, allowCollection,
|
|
6971
|
+
const selected = selectPostPurchaseChoice(normalized, planCatalog, choice, allowCollection, quantity3);
|
|
6628
6972
|
const purchaseOptions = selected.options;
|
|
6629
|
-
const
|
|
6973
|
+
const labels = { notAvailable: normalized.effective.language.global.notAvailable };
|
|
6974
|
+
const preparation = !selected.choice ? { reason: selected.reason, status: "unsupported" } : selected.choice.mode === "subscription" ? prepareNormalizedSubscription(normalized, report, selected.plan, quantity3, allowCollection) : prepareNormalizedProduct(normalized, report, quantity3, allowCollection);
|
|
6630
6975
|
const unsupported = (reason) => ({
|
|
6976
|
+
labels,
|
|
6631
6977
|
planCatalog,
|
|
6632
6978
|
preparation: { reason, status: "unsupported" },
|
|
6633
6979
|
purchaseOptions,
|
|
6634
6980
|
sections: null
|
|
6635
6981
|
});
|
|
6636
|
-
if (preparation.status === "unsupported")
|
|
6982
|
+
if (preparation.status === "unsupported")
|
|
6983
|
+
return { labels, planCatalog, preparation, purchaseOptions, sections: null };
|
|
6637
6984
|
if (!normalized.effective.blocks?.length) return unsupported("One fixed product information block is required");
|
|
6638
6985
|
const sections = convertMessagePreview(
|
|
6639
6986
|
widgetId,
|
|
6640
6987
|
{
|
|
6988
|
+
...normalized.effective,
|
|
6641
6989
|
blocks: postPurchaseOfferCopy(normalized.effective.blocks, normalized.metadata),
|
|
6642
6990
|
type: "shopify_post_purchase_extension"
|
|
6643
6991
|
},
|
|
@@ -6666,154 +7014,102 @@ var preparePostPurchaseAdmissionView = (widgetId, settings, response, report, ch
|
|
|
6666
7014
|
};
|
|
6667
7015
|
|
|
6668
7016
|
// src/schema/postPurchaseProductCollectionView.ts
|
|
6669
|
-
var
|
|
7017
|
+
var import_zod80 = require("zod");
|
|
6670
7018
|
|
|
6671
7019
|
// src/schema/postPurchaseProgress.ts
|
|
6672
|
-
var
|
|
7020
|
+
var import_zod79 = require("zod");
|
|
6673
7021
|
|
|
6674
7022
|
// src/schema/postPurchaseDeclineDelivery.ts
|
|
6675
|
-
var
|
|
7023
|
+
var import_zod78 = require("zod");
|
|
6676
7024
|
|
|
6677
7025
|
// src/schema/postPurchaseAcceptedEvent.ts
|
|
6678
|
-
var
|
|
7026
|
+
var import_zod77 = require("zod");
|
|
6679
7027
|
|
|
6680
7028
|
// src/schema/postPurchaseAdmission.ts
|
|
6681
|
-
var
|
|
7029
|
+
var import_zod76 = require("zod");
|
|
6682
7030
|
|
|
6683
7031
|
// src/schema/postPurchaseIdentity.ts
|
|
6684
|
-
var
|
|
7032
|
+
var import_zod74 = require("zod");
|
|
6685
7033
|
var POST_PURCHASE_ID_MAX = 128;
|
|
6686
|
-
var PostPurchaseTimestampSchema =
|
|
6687
|
-
var PostPurchaseOrderIdSchema =
|
|
6688
|
-
var ShopifyDomainSchema =
|
|
6689
|
-
var DecideRequestSchema =
|
|
6690
|
-
checkoutToken:
|
|
7034
|
+
var PostPurchaseTimestampSchema = import_zod74.z.number().int().nonnegative();
|
|
7035
|
+
var PostPurchaseOrderIdSchema = import_zod74.z.string().regex(/^gid:\/\/shopify\/Order\/[1-9]\d*$/);
|
|
7036
|
+
var ShopifyDomainSchema = import_zod74.z.string().max(POST_PURCHASE_ID_MAX).regex(/^[a-z0-9]([a-z0-9-]*[a-z0-9])?\.myshopify\.com$/);
|
|
7037
|
+
var DecideRequestSchema = import_zod74.z.object({
|
|
7038
|
+
checkoutToken: import_zod74.z.string().min(1).max(POST_PURCHASE_ID_MAX),
|
|
6691
7039
|
shop: ShopifyDomainSchema
|
|
6692
7040
|
});
|
|
6693
|
-
var PostPurchaseAppIdSchema =
|
|
6694
|
-
var DecisionEntrySchema =
|
|
6695
|
-
blockId:
|
|
6696
|
-
blockIndex:
|
|
6697
|
-
blockParentIndex:
|
|
6698
|
-
flowId:
|
|
6699
|
-
sectionId:
|
|
6700
|
-
widgetId:
|
|
6701
|
-
widgetTraffic:
|
|
7041
|
+
var PostPurchaseAppIdSchema = import_zod74.z.string().min(1).max(POST_PURCHASE_ID_MAX);
|
|
7042
|
+
var DecisionEntrySchema = import_zod74.z.object({
|
|
7043
|
+
blockId: import_zod74.z.number().int().positive(),
|
|
7044
|
+
blockIndex: import_zod74.z.string(),
|
|
7045
|
+
blockParentIndex: import_zod74.z.string(),
|
|
7046
|
+
flowId: import_zod74.z.number().int().positive(),
|
|
7047
|
+
sectionId: import_zod74.z.number().int().positive(),
|
|
7048
|
+
widgetId: import_zod74.z.number().int().positive(),
|
|
7049
|
+
widgetTraffic: import_zod74.z.number().min(0).max(100)
|
|
6702
7050
|
});
|
|
6703
7051
|
|
|
6704
7052
|
// src/schema/postPurchaseMemberIdentity.ts
|
|
6705
|
-
var
|
|
6706
|
-
var PostPurchaseMemberIdentity =
|
|
6707
|
-
productId:
|
|
6708
|
-
productIndex:
|
|
7053
|
+
var import_zod75 = require("zod");
|
|
7054
|
+
var PostPurchaseMemberIdentity = import_zod75.z.object({
|
|
7055
|
+
productId: import_zod75.z.number().int().positive(),
|
|
7056
|
+
productIndex: import_zod75.z.number().int().nonnegative()
|
|
6709
7057
|
}).strict();
|
|
6710
7058
|
|
|
6711
|
-
// src/schema/postPurchaseProductCalculation.ts
|
|
6712
|
-
var import_zod71 = require("zod");
|
|
6713
|
-
var MoneyBag = import_zod71.z.object({
|
|
6714
|
-
presentmentMoney: import_zod71.z.object({
|
|
6715
|
-
amount: PostPurchaseAmount,
|
|
6716
|
-
currencyCode: import_zod71.z.string().regex(/^[A-Z]{3}$/)
|
|
6717
|
-
})
|
|
6718
|
-
});
|
|
6719
|
-
var PostPurchaseProductCalculation = import_zod71.z.object({
|
|
6720
|
-
calculatedPurchase: import_zod71.z.object({
|
|
6721
|
-
addedShippingLines: import_zod71.z.array(import_zod71.z.object({ priceSet: MoneyBag })),
|
|
6722
|
-
addedTaxLines: import_zod71.z.array(import_zod71.z.object({ priceSet: MoneyBag })),
|
|
6723
|
-
totalOutstandingSet: MoneyBag,
|
|
6724
|
-
updatedLineItems: import_zod71.z.array(
|
|
6725
|
-
import_zod71.z.object({
|
|
6726
|
-
priceSet: import_zod71.z.unknown().optional(),
|
|
6727
|
-
productId: import_zod71.z.number().int().positive(),
|
|
6728
|
-
sellingPlanId: import_zod71.z.unknown().optional(),
|
|
6729
|
-
variantId: import_zod71.z.number().int().positive()
|
|
6730
|
-
})
|
|
6731
|
-
)
|
|
6732
|
-
}),
|
|
6733
|
-
errors: import_zod71.z.array(import_zod71.z.unknown()).length(0),
|
|
6734
|
-
status: import_zod71.z.literal("processed")
|
|
6735
|
-
});
|
|
6736
|
-
var Minor = import_zod71.z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
6737
|
-
var PostPurchaseProductCosts = import_zod71.z.object({
|
|
6738
|
-
currencyCode: MoneyBag.shape.presentmentMoney.shape.currencyCode,
|
|
6739
|
-
recurringDisplay: import_zod71.z.object({ shippingMinor: Minor, subtotalMinor: Minor, totalMinor: Minor }).optional(),
|
|
6740
|
-
shippingMinor: Minor,
|
|
6741
|
-
subtotalMinor: Minor,
|
|
6742
|
-
taxesMinor: Minor,
|
|
6743
|
-
totalMinor: Minor
|
|
6744
|
-
});
|
|
6745
|
-
var ChangesetDiscount = import_zod71.z.object({
|
|
6746
|
-
title: import_zod71.z.string(),
|
|
6747
|
-
value: import_zod71.z.number().nonnegative(),
|
|
6748
|
-
valueType: import_zod71.z.enum(["percentage", "fixed_amount"])
|
|
6749
|
-
}).optional();
|
|
6750
|
-
var PostPurchaseProductChangeset = import_zod71.z.object({
|
|
6751
|
-
changes: import_zod71.z.array(
|
|
6752
|
-
import_zod71.z.union([
|
|
6753
|
-
import_zod71.z.object({
|
|
6754
|
-
discount: ChangesetDiscount,
|
|
6755
|
-
quantity: import_zod71.z.number().int().positive(),
|
|
6756
|
-
type: import_zod71.z.literal("add_variant"),
|
|
6757
|
-
variantId: import_zod71.z.number().int().positive()
|
|
6758
|
-
}),
|
|
6759
|
-
import_zod71.z.object({ price: import_zod71.z.number().nonnegative(), title: import_zod71.z.string(), type: import_zod71.z.literal("add_shipping_line") }),
|
|
6760
|
-
PostPurchaseSubscriptionTerms.pick({
|
|
6761
|
-
initialShippingPrice: true,
|
|
6762
|
-
recurringShippingPrice: true,
|
|
6763
|
-
shippingOption: true
|
|
6764
|
-
}).extend({
|
|
6765
|
-
discount: ChangesetDiscount,
|
|
6766
|
-
quantity: import_zod71.z.number().int().positive(),
|
|
6767
|
-
sellingPlanId: import_zod71.z.number().int().positive(),
|
|
6768
|
-
type: import_zod71.z.literal("add_subscription"),
|
|
6769
|
-
variantId: import_zod71.z.number().int().positive()
|
|
6770
|
-
})
|
|
6771
|
-
])
|
|
6772
|
-
)
|
|
6773
|
-
});
|
|
6774
|
-
|
|
6775
7059
|
// src/schema/postPurchaseAdmission.ts
|
|
6776
|
-
var
|
|
6777
|
-
|
|
7060
|
+
var PurchaseAdmissionModeSchema = import_zod76.z.enum(["purchase", "upgrade"]);
|
|
7061
|
+
var selection = PreparedPostPurchaseProduct.shape.selection;
|
|
7062
|
+
var PurchaseExpectedSchema = import_zod76.z.object({
|
|
7063
|
+
buyerConsentToSubscriptions: import_zod76.z.boolean().optional(),
|
|
6778
7064
|
changeset: PostPurchaseProductChangeset.extend({
|
|
6779
7065
|
changes: PostPurchaseProductChangeset.shape.changes.min(1).max(2)
|
|
6780
7066
|
}),
|
|
6781
7067
|
entry: DecisionEntrySchema,
|
|
6782
7068
|
member: PostPurchaseMemberIdentity.optional(),
|
|
6783
|
-
|
|
6784
|
-
|
|
7069
|
+
mode: PurchaseAdmissionModeSchema.optional(),
|
|
7070
|
+
progressRevision: import_zod76.z.number().int().nonnegative().optional(),
|
|
7071
|
+
selection
|
|
6785
7072
|
}).refine(
|
|
6786
7073
|
({ member, progressRevision }) => !member || progressRevision !== void 0,
|
|
6787
7074
|
"Captured member requires progress"
|
|
6788
|
-
).refine(
|
|
7075
|
+
).refine(
|
|
7076
|
+
({ mode, selection: { sellingPlanId } }) => mode !== "upgrade" || sellingPlanId !== void 0,
|
|
7077
|
+
"An upgrade selects a subscription"
|
|
7078
|
+
).refine(({ buyerConsentToSubscriptions: consent, changeset, selection: selection4 }) => {
|
|
6789
7079
|
const [change, shipping] = changeset.changes;
|
|
6790
|
-
if (
|
|
6791
|
-
return consent !== true && change?.type === "add_variant" && change.variantId ===
|
|
6792
|
-
return consent === true && changeset.changes.length === 1 && change.type === "add_subscription" && change.sellingPlanId ===
|
|
7080
|
+
if (selection4.sellingPlanId === void 0)
|
|
7081
|
+
return consent !== true && change?.type === "add_variant" && change.variantId === selection4.variantId && change.quantity === selection4.quantity && (shipping === void 0 || shipping.type === "add_shipping_line");
|
|
7082
|
+
return consent === true && changeset.changes.length === 1 && change.type === "add_subscription" && change.sellingPlanId === selection4.sellingPlanId && change.variantId === selection4.variantId && change.quantity === selection4.quantity;
|
|
6793
7083
|
}, "Selection, change and buyer consent must agree");
|
|
6794
7084
|
var PurchaseRequestSchema = DecideRequestSchema.extend({
|
|
6795
7085
|
expected: PurchaseExpectedSchema,
|
|
6796
|
-
requestId:
|
|
7086
|
+
requestId: import_zod76.z.uuid()
|
|
6797
7087
|
}).strict();
|
|
6798
|
-
var PurchaseReceiptSchema =
|
|
7088
|
+
var PurchaseReceiptSchema = import_zod76.z.object({
|
|
6799
7089
|
admittedAt: PostPurchaseTimestampSchema,
|
|
6800
|
-
changesetToken:
|
|
6801
|
-
|
|
6802
|
-
|
|
6803
|
-
selection
|
|
7090
|
+
changesetToken: import_zod76.z.string().min(1),
|
|
7091
|
+
mode: PurchaseAdmissionModeSchema.optional(),
|
|
7092
|
+
operationId: import_zod76.z.uuid(),
|
|
7093
|
+
/** The server-bound one-time line an upgrade refunds; its quantity is the order's, not the selection's. */
|
|
7094
|
+
originalLine: import_zod76.z.strictObject({ quantity: selection.shape.quantity, variantId: selection.shape.variantId }).optional(),
|
|
7095
|
+
requiresSubscriptionConsent: import_zod76.z.boolean(),
|
|
7096
|
+
selection
|
|
6804
7097
|
}).refine(
|
|
6805
|
-
({ requiresSubscriptionConsent, selection:
|
|
7098
|
+
({ requiresSubscriptionConsent, selection: selection4 }) => requiresSubscriptionConsent === (selection4.sellingPlanId !== void 0),
|
|
6806
7099
|
"Receipt consent must match its selected plan"
|
|
7100
|
+
).refine(
|
|
7101
|
+
({ mode, originalLine, selection: { sellingPlanId, variantId } }) => mode === "upgrade" ? sellingPlanId !== void 0 && originalLine?.variantId === variantId : originalLine === void 0,
|
|
7102
|
+
"An upgrade Receipt binds the original line of its subscribed variant, and only an upgrade does"
|
|
6807
7103
|
);
|
|
6808
|
-
var PurchaseResponseSchema =
|
|
7104
|
+
var PurchaseResponseSchema = import_zod76.z.object({ data: PurchaseReceiptSchema, successful: import_zod76.z.literal(true) });
|
|
6809
7105
|
|
|
6810
7106
|
// src/schema/postPurchaseAcceptedEvent.ts
|
|
6811
7107
|
var EventCalculationSchema = PostPurchaseProductCosts.pick({ currencyCode: true, totalMinor: true }).strict();
|
|
6812
|
-
var AcceptedEventOutcomeSchema =
|
|
6813
|
-
var AttemptProgressSchema =
|
|
7108
|
+
var AcceptedEventOutcomeSchema = import_zod77.z.enum(["acknowledged", "rejected", "skipped", "unknown"]);
|
|
7109
|
+
var AttemptProgressSchema = import_zod77.z.strictObject({
|
|
6814
7110
|
attemptedAt: PostPurchaseTimestampSchema,
|
|
6815
7111
|
reportedCalculation: EventCalculationSchema,
|
|
6816
|
-
status:
|
|
7112
|
+
status: import_zod77.z.literal("attempted")
|
|
6817
7113
|
});
|
|
6818
7114
|
var AcceptedEventAttemptProgressSchema = AttemptProgressSchema.extend({
|
|
6819
7115
|
operationId: PurchaseReceiptSchema.shape.operationId
|
|
@@ -6826,17 +7122,17 @@ var AcceptedEventRequestSchema = DecideRequestSchema.extend({
|
|
|
6826
7122
|
operationId: PurchaseReceiptSchema.shape.operationId,
|
|
6827
7123
|
reportedCalculation: EventCalculationSchema
|
|
6828
7124
|
}).strict();
|
|
6829
|
-
var AcceptedEventResponseSchema =
|
|
6830
|
-
data:
|
|
6831
|
-
successful:
|
|
7125
|
+
var AcceptedEventResponseSchema = import_zod77.z.object({
|
|
7126
|
+
data: import_zod77.z.union([AcceptedEventAttemptProgressSchema, AcceptedEventResultProgressSchema]),
|
|
7127
|
+
successful: import_zod77.z.literal(true)
|
|
6832
7128
|
});
|
|
6833
7129
|
|
|
6834
7130
|
// src/schema/postPurchaseDeclineDelivery.ts
|
|
6835
|
-
var AttemptSchema =
|
|
7131
|
+
var AttemptSchema = import_zod78.z.strictObject({
|
|
6836
7132
|
attemptedAt: PostPurchaseTimestampSchema,
|
|
6837
|
-
status:
|
|
7133
|
+
status: import_zod78.z.enum(["attempted", "unavailable"])
|
|
6838
7134
|
});
|
|
6839
|
-
var DeclineDeliveryProgressSchema =
|
|
7135
|
+
var DeclineDeliveryProgressSchema = import_zod78.z.union([
|
|
6840
7136
|
AttemptSchema,
|
|
6841
7137
|
AttemptSchema.extend({
|
|
6842
7138
|
finishedAt: PostPurchaseTimestampSchema,
|
|
@@ -6845,36 +7141,36 @@ var DeclineDeliveryProgressSchema = import_zod74.z.union([
|
|
|
6845
7141
|
]);
|
|
6846
7142
|
|
|
6847
7143
|
// src/schema/postPurchaseProgress.ts
|
|
6848
|
-
var PostPurchaseProgressSchema =
|
|
7144
|
+
var PostPurchaseProgressSchema = import_zod79.z.object({
|
|
6849
7145
|
closedAt: PostPurchaseTimestampSchema.nullable(),
|
|
6850
7146
|
deadline: PostPurchaseTimestampSchema,
|
|
6851
7147
|
entry: DecisionEntrySchema,
|
|
6852
|
-
entryRevision:
|
|
6853
|
-
members:
|
|
7148
|
+
entryRevision: import_zod79.z.number().int().nonnegative(),
|
|
7149
|
+
members: import_zod79.z.array(
|
|
6854
7150
|
PostPurchaseMemberIdentity.extend({
|
|
6855
7151
|
declineDelivery: DeclineDeliveryProgressSchema.optional(),
|
|
6856
|
-
status:
|
|
7152
|
+
status: import_zod79.z.enum(["unhandled", "accepted", "declined"])
|
|
6857
7153
|
}).strict()
|
|
6858
7154
|
),
|
|
6859
|
-
revision:
|
|
7155
|
+
revision: import_zod79.z.number().int().nonnegative()
|
|
6860
7156
|
}).strict();
|
|
6861
7157
|
|
|
6862
7158
|
// src/schema/postPurchaseProductCollectionView.ts
|
|
6863
|
-
var PostPurchaseProductCollectionView =
|
|
6864
|
-
members:
|
|
6865
|
-
|
|
7159
|
+
var PostPurchaseProductCollectionView = import_zod80.z.object({
|
|
7160
|
+
members: import_zod80.z.array(
|
|
7161
|
+
import_zod80.z.object({
|
|
6866
7162
|
productId: PostPurchaseProductId,
|
|
6867
|
-
productIndex:
|
|
7163
|
+
productIndex: import_zod80.z.number().int().nonnegative(),
|
|
6868
7164
|
view: PostPurchaseProductView
|
|
6869
7165
|
})
|
|
6870
7166
|
)
|
|
6871
7167
|
});
|
|
6872
|
-
var PostPurchaseCollectionChoice =
|
|
7168
|
+
var PostPurchaseCollectionChoice = import_zod80.z.object({
|
|
6873
7169
|
choice: PostPurchaseChoice.optional(),
|
|
6874
7170
|
productId: PostPurchaseProductId,
|
|
6875
7171
|
variantId: PostPurchaseVariantSelector.shape.variantId.optional()
|
|
6876
7172
|
}).strict();
|
|
6877
|
-
var PostPurchaseExcludedProductIds =
|
|
7173
|
+
var PostPurchaseExcludedProductIds = import_zod80.z.array(PostPurchaseProductId).default([]);
|
|
6878
7174
|
var PostPurchaseMemberSelector = PostPurchaseProgressSchema.shape.members.element.pick({ productId: true }).extend({ progressRevision: PostPurchaseProgressSchema.shape.revision });
|
|
6879
7175
|
var PostPurchaseMemberPointer = PostPurchaseProgressSchema.shape.members.element.omit({ status: true }).extend({
|
|
6880
7176
|
entryRevision: PostPurchaseProgressSchema.shape.entryRevision,
|
|
@@ -6882,10 +7178,10 @@ var PostPurchaseMemberPointer = PostPurchaseProgressSchema.shape.members.element
|
|
|
6882
7178
|
});
|
|
6883
7179
|
|
|
6884
7180
|
// src/server/normalizePostPurchaseCollection.ts
|
|
6885
|
-
var
|
|
7181
|
+
var import_zod81 = require("zod");
|
|
6886
7182
|
var normalizePostPurchaseCollection = (settings, response, excludedProductIds) => {
|
|
6887
7183
|
const normalized = normalizePostPurchaseProduct(settings, response);
|
|
6888
|
-
const limit =
|
|
7184
|
+
const limit = import_zod81.z.number().int().positive();
|
|
6889
7185
|
limit.parse(normalized.original.productLimit);
|
|
6890
7186
|
const prefix = normalized.data.slice(0, limit.parse(normalized.effective.productLimit));
|
|
6891
7187
|
if (new Set(prefix.map(({ id }) => id)).size !== prefix.length)
|
|
@@ -6929,13 +7225,13 @@ var projectPostPurchaseVariantCatalog = (product, settings) => {
|
|
|
6929
7225
|
};
|
|
6930
7226
|
|
|
6931
7227
|
// src/schema/postPurchaseQuantity.ts
|
|
6932
|
-
var
|
|
6933
|
-
var
|
|
6934
|
-
var PostPurchaseQuantityChoice = PostPurchaseCollectionChoice.extend({ quantity:
|
|
7228
|
+
var import_zod82 = require("zod");
|
|
7229
|
+
var quantity2 = PreparedPostPurchaseProduct.shape.selection.shape.quantity;
|
|
7230
|
+
var PostPurchaseQuantityChoice = PostPurchaseCollectionChoice.extend({ quantity: quantity2.optional() });
|
|
6935
7231
|
var PostPurchaseQuantityPolicy = PostPurchaseSettings.shape.quantityInputs.omit({ defaultQuantity: true }).extend({
|
|
6936
|
-
initialQuantity:
|
|
6937
|
-
maxValue:
|
|
6938
|
-
minValue:
|
|
7232
|
+
initialQuantity: quantity2,
|
|
7233
|
+
maxValue: quantity2,
|
|
7234
|
+
minValue: import_zod82.z.literal(0).transform(() => 1).or(quantity2)
|
|
6939
7235
|
}).refine(({ maxValue, minValue }) => minValue <= maxValue, "Quantity bounds are reversed");
|
|
6940
7236
|
|
|
6941
7237
|
// src/server/readPostPurchaseQuantity.ts
|
|
@@ -6945,7 +7241,7 @@ var readPostPurchaseQuantity = ({
|
|
|
6945
7241
|
data,
|
|
6946
7242
|
effective,
|
|
6947
7243
|
original
|
|
6948
|
-
},
|
|
7244
|
+
}, selection4) => {
|
|
6949
7245
|
const positive = PreparedPostPurchaseProduct.shape.selection.shape.quantity;
|
|
6950
7246
|
for (const config of [original, effective]) {
|
|
6951
7247
|
if (!config.quantityInputs.enabled) continue;
|
|
@@ -6958,47 +7254,47 @@ var readPostPurchaseQuantity = ({
|
|
|
6958
7254
|
const policy = PostPurchaseQuantityPolicy.parse(
|
|
6959
7255
|
effective.quantityInputs.enabled ? { ...effective.quantityInputs, initialQuantity } : { enabled: false, initialQuantity, maxValue: initialQuantity, minValue: initialQuantity }
|
|
6960
7256
|
);
|
|
6961
|
-
const requested = "quantity" in
|
|
6962
|
-
const
|
|
6963
|
-
if (requested !== void 0 && (policy.enabled ?
|
|
7257
|
+
const requested = "quantity" in selection4 ? selection4.quantity : selection4.expectedQuantity === initialQuantity ? void 0 : selection4.expectedQuantity;
|
|
7258
|
+
const quantity3 = positive.parse(requested ?? initialQuantity);
|
|
7259
|
+
if (requested !== void 0 && (policy.enabled ? quantity3 < policy.minValue || quantity3 > policy.maxValue : quantity3 !== initialQuantity))
|
|
6964
7260
|
throw new PostPurchaseQuantityUnavailable("Requested quantity is unavailable");
|
|
6965
|
-
return { policy, quantity:
|
|
7261
|
+
return { policy, quantity: quantity3 };
|
|
6966
7262
|
};
|
|
6967
7263
|
|
|
6968
7264
|
// src/schema/postPurchaseVariantDefault.ts
|
|
6969
|
-
var
|
|
7265
|
+
var import_zod83 = require("zod");
|
|
6970
7266
|
var values = PostPurchaseVariantValues.partial().extend({
|
|
6971
7267
|
option1: PostPurchaseVariantValues.shape.option1.nullish()
|
|
6972
7268
|
});
|
|
6973
7269
|
var variant = values.extend({
|
|
6974
7270
|
id: PostPurchaseVariantId,
|
|
6975
|
-
inventoryManagement:
|
|
6976
|
-
inventoryPolicy:
|
|
6977
|
-
inventoryQuantity:
|
|
7271
|
+
inventoryManagement: import_zod83.z.string().nullable(),
|
|
7272
|
+
inventoryPolicy: import_zod83.z.string(),
|
|
7273
|
+
inventoryQuantity: import_zod83.z.number()
|
|
6978
7274
|
});
|
|
6979
|
-
var options =
|
|
6980
|
-
var PostPurchaseVariantDefaultProduct =
|
|
7275
|
+
var options = import_zod83.z.array(PostPurchaseVariantOption.pick({ name: true, values: true }));
|
|
7276
|
+
var PostPurchaseVariantDefaultProduct = import_zod83.z.object({
|
|
6981
7277
|
id: PostPurchaseProductId,
|
|
6982
7278
|
options,
|
|
6983
7279
|
selectedVariant: variant.optional(),
|
|
6984
|
-
variants:
|
|
7280
|
+
variants: import_zod83.z.array(variant)
|
|
6985
7281
|
});
|
|
6986
7282
|
var PostPurchaseVariantDefaultSettings = PostPurchaseSettings.shape.productOptions.pick({
|
|
6987
7283
|
hideOutOfStockVariants: true,
|
|
6988
7284
|
matchVariant: true
|
|
6989
7285
|
});
|
|
6990
|
-
var PostPurchaseOrderAttributes =
|
|
6991
|
-
var PostPurchaseOriginalVariants =
|
|
6992
|
-
|
|
7286
|
+
var PostPurchaseOrderAttributes = import_zod83.z.record(import_zod83.z.string(), import_zod83.z.array(import_zod83.z.string())).default({});
|
|
7287
|
+
var PostPurchaseOriginalVariants = import_zod83.z.array(
|
|
7288
|
+
import_zod83.z.object({ productId: PostPurchaseProductId, variantId: PostPurchaseVariantId })
|
|
6993
7289
|
);
|
|
6994
|
-
var PostPurchaseAttributeProducts =
|
|
6995
|
-
|
|
7290
|
+
var PostPurchaseAttributeProducts = import_zod83.z.array(
|
|
7291
|
+
import_zod83.z.object({ id: PostPurchaseProductId, options, variants: import_zod83.z.array(values.extend({ id: PostPurchaseVariantId })) })
|
|
6996
7292
|
);
|
|
6997
7293
|
|
|
6998
7294
|
// src/schema/postPurchaseVariantDefaultContext.ts
|
|
6999
|
-
var
|
|
7000
|
-
var PostPurchaseVariantDefaultContext =
|
|
7001
|
-
enrichedLineItems:
|
|
7295
|
+
var import_zod84 = require("zod");
|
|
7296
|
+
var PostPurchaseVariantDefaultContext = import_zod84.z.object({
|
|
7297
|
+
enrichedLineItems: import_zod84.z.unknown().optional(),
|
|
7002
7298
|
originalVariants: PostPurchaseOriginalVariants
|
|
7003
7299
|
});
|
|
7004
7300
|
|
|
@@ -7084,13 +7380,13 @@ var prepareMember = (widgetId, settings, response, requested, report, excludedPr
|
|
|
7084
7380
|
variants: found.product.variants.filter(({ id }) => id === variantId)
|
|
7085
7381
|
};
|
|
7086
7382
|
const selectedInput = { ...normalized, data: [product] };
|
|
7087
|
-
const
|
|
7088
|
-
const view = prepareNormalizedPostPurchaseView(widgetId, selectedInput, report, selected.choice,
|
|
7383
|
+
const quantity3 = requestedQuantity ? readPostPurchaseQuantity(selectedInput, requestedQuantity) : void 0;
|
|
7384
|
+
const view = prepareNormalizedPostPurchaseView(widgetId, selectedInput, report, selected.choice, quantity3, true);
|
|
7089
7385
|
if (selected.variantId !== void 0 || found.product.variants.length > 1)
|
|
7090
7386
|
view.variantCatalog = projectPostPurchaseVariantCatalog(found.product, normalized.effective);
|
|
7091
7387
|
if (defaults && selected.variantId === void 0 && variantId && view.variantCatalog?.variants.some(({ id }) => id === variantId))
|
|
7092
7388
|
view.initialVariant = { variantId };
|
|
7093
|
-
return { member: { productId: found.product.id, productIndex: found.productIndex, view }, normalized, quantity:
|
|
7389
|
+
return { member: { productId: found.product.id, productIndex: found.productIndex, view }, normalized, quantity: quantity3 };
|
|
7094
7390
|
};
|
|
7095
7391
|
var preparePostPurchaseMemberView = (widgetId, settings, response, requested, report, excludedProductIds) => prepareMember(widgetId, settings, response, requested, report, excludedProductIds)?.member ?? null;
|
|
7096
7392
|
var preparePostPurchaseMemberAdmissionView = (widgetId, settings, response, requested, report, excludedProductIds) => {
|
|
@@ -7102,24 +7398,24 @@ var preparePostPurchaseMemberAdmissionView = (widgetId, settings, response, requ
|
|
|
7102
7398
|
|
|
7103
7399
|
// src/server/preparePostPurchaseQuantityView.ts
|
|
7104
7400
|
var preparePostPurchaseQuantityView = (widgetId, settings, response, requested, report, excludedProductIds, defaults) => {
|
|
7105
|
-
const { quantity:
|
|
7401
|
+
const { quantity: quantity3, ...selection4 } = PostPurchaseQuantityChoice.parse(requested);
|
|
7106
7402
|
const prepared = prepareMember(
|
|
7107
7403
|
widgetId,
|
|
7108
7404
|
settings,
|
|
7109
7405
|
response,
|
|
7110
|
-
|
|
7406
|
+
selection4,
|
|
7111
7407
|
report,
|
|
7112
7408
|
excludedProductIds,
|
|
7113
|
-
{ quantity:
|
|
7409
|
+
{ quantity: quantity3 },
|
|
7114
7410
|
defaults
|
|
7115
7411
|
);
|
|
7116
7412
|
return prepared ? { ...prepared.member, quantityPolicy: prepared.quantity.policy } : null;
|
|
7117
7413
|
};
|
|
7118
7414
|
|
|
7119
7415
|
// src/server/preparePostPurchaseQuantityAdmissionView.ts
|
|
7120
|
-
var
|
|
7416
|
+
var selection2 = PostPurchaseQuantityChoice.required({ quantity: true });
|
|
7121
7417
|
var preparePostPurchaseQuantityAdmissionView = (widgetId, settings, response, expected, report, excludedProductIds, defaults) => {
|
|
7122
|
-
const { quantity: expectedQuantity, ...requested } =
|
|
7418
|
+
const { quantity: expectedQuantity, ...requested } = selection2.parse(expected);
|
|
7123
7419
|
const prepared = prepareMember(
|
|
7124
7420
|
widgetId,
|
|
7125
7421
|
settings,
|
|
@@ -7172,12 +7468,12 @@ var readPostPurchaseGroup = (product, settings, excludedProductIds) => {
|
|
|
7172
7468
|
|
|
7173
7469
|
// src/server/readPostPurchaseGroupSelection.ts
|
|
7174
7470
|
var readPostPurchaseGroupSelection = (settings, response, requested, excludedProductIds) => {
|
|
7175
|
-
const
|
|
7471
|
+
const selection4 = PostPurchaseGroupSelection.parse(requested);
|
|
7176
7472
|
const { members, normalized } = normalizePostPurchaseCollection(settings, response);
|
|
7177
|
-
const member = members.find(({ product }) => product.id ===
|
|
7473
|
+
const member = members.find(({ product }) => product.id === selection4.memberProductId);
|
|
7178
7474
|
if (!member || !member.product.productGroupVariants.length) return null;
|
|
7179
7475
|
const group = readPostPurchaseGroup(member.product, normalized.effective, excludedProductIds);
|
|
7180
|
-
const entry = group.entries.find(({ product }) => product.id ===
|
|
7476
|
+
const entry = group.entries.find(({ product }) => product.id === selection4.productId);
|
|
7181
7477
|
if (!entry) return null;
|
|
7182
7478
|
return {
|
|
7183
7479
|
groupCatalog: group.catalog,
|
|
@@ -7191,16 +7487,16 @@ var readPostPurchaseGroupSelection = (settings, response, requested, excludedPro
|
|
|
7191
7487
|
|
|
7192
7488
|
// src/server/preparePostPurchaseGroupView.ts
|
|
7193
7489
|
var preparePostPurchaseGroupView = (widgetId, settings, response, requested, report, excludedProductIds) => {
|
|
7194
|
-
const { memberProductId, ...
|
|
7490
|
+
const { memberProductId, ...selection4 } = PostPurchaseGroupChoice.parse(requested);
|
|
7195
7491
|
const group = readPostPurchaseGroupSelection(settings, response, requested, excludedProductIds);
|
|
7196
7492
|
if (!group) return null;
|
|
7197
|
-
const variantId =
|
|
7493
|
+
const variantId = selection4.variantId ?? group.variantCatalog.variants.find(({ available }) => available)?.id;
|
|
7198
7494
|
if (variantId === void 0) return null;
|
|
7199
7495
|
const prepared = preparePostPurchaseQuantityView(
|
|
7200
7496
|
widgetId,
|
|
7201
7497
|
settings,
|
|
7202
7498
|
group.response,
|
|
7203
|
-
{ ...
|
|
7499
|
+
{ ...selection4, variantId },
|
|
7204
7500
|
report
|
|
7205
7501
|
);
|
|
7206
7502
|
return prepared && {
|
|
@@ -7214,16 +7510,16 @@ var preparePostPurchaseGroupView = (widgetId, settings, response, requested, rep
|
|
|
7214
7510
|
|
|
7215
7511
|
// src/server/preparePostPurchaseGroupAdmissionView.ts
|
|
7216
7512
|
var preparePostPurchaseGroupAdmissionView = (widgetId, settings, response, requested, report, excludedProductIds) => {
|
|
7217
|
-
const { memberProductId, ...
|
|
7513
|
+
const { memberProductId, ...selection4 } = PostPurchaseGroupChoice.required({ quantity: true }).parse(requested);
|
|
7218
7514
|
const group = readPostPurchaseGroupSelection(settings, response, requested, excludedProductIds);
|
|
7219
7515
|
if (!group) return null;
|
|
7220
|
-
const variantId =
|
|
7516
|
+
const variantId = selection4.variantId ?? group.variantCatalog.variants.find(({ available }) => available)?.id;
|
|
7221
7517
|
if (variantId === void 0) return null;
|
|
7222
7518
|
const prepared = preparePostPurchaseQuantityAdmissionView(
|
|
7223
7519
|
widgetId,
|
|
7224
7520
|
settings,
|
|
7225
7521
|
group.response,
|
|
7226
|
-
{ ...
|
|
7522
|
+
{ ...selection4, variantId },
|
|
7227
7523
|
report
|
|
7228
7524
|
);
|
|
7229
7525
|
return prepared && {
|
|
@@ -7286,6 +7582,7 @@ var preparePostPurchaseCollectionGroup = (widgetId, settings, response, member,
|
|
|
7286
7582
|
reportingProduct: { id: member.product.id, title: member.product.title },
|
|
7287
7583
|
view: prepared ? { ...prepared.view, groupCatalog: prepared.groupCatalog } : {
|
|
7288
7584
|
groupCatalog: group.catalog,
|
|
7585
|
+
labels: { notAvailable: normalized.effective.language.global.notAvailable },
|
|
7289
7586
|
preparation: { reason: "Post-purchase group default is unavailable", status: "unsupported" },
|
|
7290
7587
|
sections: null
|
|
7291
7588
|
}
|
|
@@ -7341,22 +7638,22 @@ var preparePostPurchaseCollectionView = (widgetId, settings, response, report, r
|
|
|
7341
7638
|
};
|
|
7342
7639
|
|
|
7343
7640
|
// src/schema/postPurchaseOfferEligibility.ts
|
|
7344
|
-
var
|
|
7345
|
-
var
|
|
7346
|
-
var PostPurchaseOfferSkipReason =
|
|
7347
|
-
var PostPurchaseOfferEligibilityContext =
|
|
7641
|
+
var import_zod85 = require("zod");
|
|
7642
|
+
var selection3 = PreparedPostPurchaseProduct.shape.selection;
|
|
7643
|
+
var PostPurchaseOfferSkipReason = import_zod85.z.enum(["empty", "no-eligible-subscription"]);
|
|
7644
|
+
var PostPurchaseOfferEligibilityContext = import_zod85.z.object({
|
|
7348
7645
|
excludedProductIds: PostPurchaseExcludedProductIds,
|
|
7349
|
-
originalLineItems:
|
|
7646
|
+
originalLineItems: import_zod85.z.array(selection3.pick({ productId: true, sellingPlanId: true, variantId: true }))
|
|
7350
7647
|
});
|
|
7351
|
-
var PostPurchaseOfferEligibility =
|
|
7352
|
-
|
|
7353
|
-
members:
|
|
7354
|
-
|
|
7648
|
+
var PostPurchaseOfferEligibility = import_zod85.z.discriminatedUnion("status", [
|
|
7649
|
+
import_zod85.z.object({
|
|
7650
|
+
members: import_zod85.z.array(
|
|
7651
|
+
import_zod85.z.object({ productId: selection3.shape.productId, productIndex: import_zod85.z.number().int().nonnegative() })
|
|
7355
7652
|
),
|
|
7356
|
-
status:
|
|
7653
|
+
status: import_zod85.z.literal("retain")
|
|
7357
7654
|
}),
|
|
7358
|
-
|
|
7359
|
-
|
|
7655
|
+
import_zod85.z.object({ reason: PostPurchaseOfferSkipReason, status: import_zod85.z.literal("skip") }),
|
|
7656
|
+
import_zod85.z.object({ reason: import_zod85.z.literal("eligible-upgrade").optional(), status: import_zod85.z.literal("unavailable") })
|
|
7360
7657
|
]);
|
|
7361
7658
|
|
|
7362
7659
|
// src/server/postPurchaseMemberEligibility.ts
|
|
@@ -7435,10 +7732,10 @@ var classifyPostPurchaseOffer = (settings, response, context) => {
|
|
|
7435
7732
|
};
|
|
7436
7733
|
|
|
7437
7734
|
// src/server/preparePostPurchaseDeclineDisplay.ts
|
|
7438
|
-
var
|
|
7735
|
+
var import_zod87 = require("zod");
|
|
7439
7736
|
|
|
7440
7737
|
// src/schema/postPurchaseDecline.ts
|
|
7441
|
-
var
|
|
7738
|
+
var import_zod86 = require("zod");
|
|
7442
7739
|
var OfferDeclineRequestSchema = DecideRequestSchema.extend({
|
|
7443
7740
|
entryRevision: PostPurchaseProgressSchema.shape.entryRevision,
|
|
7444
7741
|
productId: PostPurchaseProgressSchema.shape.members.element.shape.productId,
|
|
@@ -7450,23 +7747,23 @@ var OfferDeclineRequestSchema = DecideRequestSchema.extend({
|
|
|
7450
7747
|
"Selected merchandise requires a variant"
|
|
7451
7748
|
);
|
|
7452
7749
|
var RecordedOfferDeclineSchema = PostPurchaseProgressSchema.shape.members.element.omit({ declineDelivery: true, status: true }).extend({ entry: DecisionEntrySchema.strict(), entryRevision: PostPurchaseProgressSchema.shape.entryRevision }).strict();
|
|
7453
|
-
var OfferDeclineResponseSchema =
|
|
7454
|
-
data:
|
|
7455
|
-
successful:
|
|
7750
|
+
var OfferDeclineResponseSchema = import_zod86.z.object({
|
|
7751
|
+
data: import_zod86.z.object({ decline: RecordedOfferDeclineSchema, progress: PostPurchaseProgressSchema }),
|
|
7752
|
+
successful: import_zod86.z.literal(true)
|
|
7456
7753
|
});
|
|
7457
7754
|
|
|
7458
7755
|
// src/server/preparePostPurchaseDeclineDisplay.ts
|
|
7459
|
-
var Selection =
|
|
7756
|
+
var Selection = import_zod87.z.object({
|
|
7460
7757
|
productId: OfferDeclineRequestSchema.shape.productId,
|
|
7461
7758
|
variant: OfferDeclineRequestSchema.shape.variant.unwrap()
|
|
7462
7759
|
});
|
|
7463
7760
|
var preparePostPurchaseDeclineDisplay = (settings, response, requested) => {
|
|
7464
|
-
const
|
|
7761
|
+
const selection4 = Selection.parse(requested);
|
|
7465
7762
|
const { members, normalized } = normalizePostPurchaseCollection(settings, response);
|
|
7466
|
-
const found = members.find(({ product }) => product.id ===
|
|
7763
|
+
const found = members.find(({ product }) => product.id === selection4.productId);
|
|
7467
7764
|
if (!found) return null;
|
|
7468
7765
|
const catalog = projectPostPurchaseVariantCatalog(found.product, normalized.effective);
|
|
7469
|
-
const variant2 = catalog.variants.find(({ id }) => id ===
|
|
7766
|
+
const variant2 = catalog.variants.find(({ id }) => id === selection4.variant.variantId);
|
|
7470
7767
|
return variant2 ? { productTitle: found.product.title, variantId: variant2.id, variantTitle: variant2.title } : null;
|
|
7471
7768
|
};
|
|
7472
7769
|
|
|
@@ -7485,41 +7782,46 @@ var preparePostPurchaseGroupDeclineDisplay = (settings, response, requested, exc
|
|
|
7485
7782
|
};
|
|
7486
7783
|
|
|
7487
7784
|
// src/server/preparePostPurchaseOfferPresentation.ts
|
|
7488
|
-
var
|
|
7489
|
-
var
|
|
7785
|
+
var import_compat8 = require("es-toolkit/compat");
|
|
7786
|
+
var import_zod89 = require("zod");
|
|
7490
7787
|
|
|
7491
7788
|
// src/schema/postPurchaseOfferPresentation.ts
|
|
7492
|
-
var
|
|
7789
|
+
var import_zod88 = require("zod");
|
|
7493
7790
|
var language2 = PostPurchaseSettings.shape.language.shape.global.unwrap().unwrap();
|
|
7494
|
-
var PostPurchaseOfferPresentation =
|
|
7791
|
+
var PostPurchaseOfferPresentation = import_zod88.z.strictObject({
|
|
7495
7792
|
labels: language2.pick({ declineAll: true, declineThisOffer: true }),
|
|
7496
7793
|
layout: PostPurchaseSettings.shape.offersLayout,
|
|
7497
7794
|
sections: CABRootSection.nullable(),
|
|
7498
7795
|
showDeclineAll: PostPurchaseSettings.shape.productOptions.shape.showDeclineAll
|
|
7499
7796
|
});
|
|
7500
7797
|
var OfferPresentationRequestSchema = DecideRequestSchema.strict();
|
|
7501
|
-
var OfferPresentationResponseSchema =
|
|
7502
|
-
data:
|
|
7798
|
+
var OfferPresentationResponseSchema = import_zod88.z.object({
|
|
7799
|
+
data: import_zod88.z.strictObject({
|
|
7503
7800
|
presentation: PostPurchaseOfferPresentation.nullable(),
|
|
7504
7801
|
progress: PostPurchaseProgressSchema.nullable(),
|
|
7505
7802
|
serverNow: PostPurchaseTimestampSchema
|
|
7506
7803
|
}),
|
|
7507
|
-
successful:
|
|
7804
|
+
successful: import_zod88.z.literal(true)
|
|
7508
7805
|
});
|
|
7509
7806
|
|
|
7510
7807
|
// src/server/preparePostPurchaseOfferPresentation.ts
|
|
7511
7808
|
var FrameSettings = PostPurchaseSettings.pick({ language: true, offersLayout: true, productOptions: true }).extend({
|
|
7512
|
-
blocks:
|
|
7809
|
+
blocks: import_zod89.z.array(import_zod89.z.unknown()).optional()
|
|
7513
7810
|
});
|
|
7514
7811
|
var preparePostPurchaseOfferPresentation = (widgetId, settings, response, report) => {
|
|
7515
7812
|
const { metadata } = PostPurchaseProductSource.pick({ metadata: true }).parse(deepCamelCase(response));
|
|
7516
7813
|
const original = FrameSettings.parse(deepCamelCase(settings));
|
|
7517
|
-
const
|
|
7814
|
+
const merged = (0, import_compat8.merge)({}, deepCamelCase(settings), metadata.widget);
|
|
7815
|
+
const effective = FrameSettings.parse((0, import_compat8.merge)({}, original, metadata.widget));
|
|
7518
7816
|
let sections = null;
|
|
7519
7817
|
try {
|
|
7520
7818
|
sections = convertMessagePreview(
|
|
7521
7819
|
widgetId,
|
|
7522
|
-
{
|
|
7820
|
+
{
|
|
7821
|
+
...merged,
|
|
7822
|
+
blocks: postPurchaseOfferCopy(effective.blocks, metadata),
|
|
7823
|
+
type: "shopify_post_purchase_extension"
|
|
7824
|
+
},
|
|
7523
7825
|
report
|
|
7524
7826
|
);
|
|
7525
7827
|
} catch (error) {
|
|
@@ -7534,7 +7836,7 @@ var preparePostPurchaseOfferPresentation = (widgetId, settings, response, report
|
|
|
7534
7836
|
};
|
|
7535
7837
|
|
|
7536
7838
|
// src/server/analytics.ts
|
|
7537
|
-
var
|
|
7839
|
+
var import_es_toolkit8 = require("es-toolkit");
|
|
7538
7840
|
|
|
7539
7841
|
// src/server/analyticsSegments.ts
|
|
7540
7842
|
var SEGMENT_BUCKETS = {
|
|
@@ -7653,7 +7955,7 @@ var postAnalyticsEvents = async (input, ctx) => {
|
|
|
7653
7955
|
const events = input.events.map((event) => translateAnalyticsEvent(event, input)).filter((event) => event !== null);
|
|
7654
7956
|
if (events.length === 0) return { accepted: 0 };
|
|
7655
7957
|
const { shop } = await fetchUserConfig({ shop: input.shop }, ctx);
|
|
7656
|
-
for (const batch of (0,
|
|
7958
|
+
for (const batch of (0, import_es_toolkit8.chunk)(events, MAX_ANALYTICS_EVENTS)) {
|
|
7657
7959
|
await ctx.fetchUpstream(
|
|
7658
7960
|
"/api/v2/analytics/event/bulk",
|
|
7659
7961
|
{},
|
|
@@ -7669,7 +7971,7 @@ var postAnalyticsEvents = async (input, ctx) => {
|
|
|
7669
7971
|
};
|
|
7670
7972
|
|
|
7671
7973
|
// src/server/requestSchemas.ts
|
|
7672
|
-
var
|
|
7974
|
+
var import_zod90 = require("zod");
|
|
7673
7975
|
var REQUEST_BOUNDS = {
|
|
7674
7976
|
/** Cart-level attributes per cart. */
|
|
7675
7977
|
CART_ATTRIBUTES_MAX: 100,
|
|
@@ -7700,42 +8002,42 @@ var REQUEST_BOUNDS = {
|
|
|
7700
8002
|
/** Rich ads transaction lines — the engine's ads contract. */
|
|
7701
8003
|
TRANSACTION_ITEMS_MAX: 50
|
|
7702
8004
|
};
|
|
7703
|
-
var KeyValue =
|
|
7704
|
-
key:
|
|
7705
|
-
value:
|
|
8005
|
+
var KeyValue = import_zod90.z.object({
|
|
8006
|
+
key: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_KEY_MAX),
|
|
8007
|
+
value: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_VALUE_MAX).optional()
|
|
7706
8008
|
});
|
|
7707
|
-
var CartLineInputSchema =
|
|
7708
|
-
productId:
|
|
7709
|
-
properties:
|
|
7710
|
-
quantity:
|
|
7711
|
-
subscriptionId:
|
|
7712
|
-
variantId:
|
|
8009
|
+
var CartLineInputSchema = import_zod90.z.object({
|
|
8010
|
+
productId: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
8011
|
+
properties: import_zod90.z.array(KeyValue).max(REQUEST_BOUNDS.LINE_PROPERTIES_MAX).optional(),
|
|
8012
|
+
quantity: import_zod90.z.number(),
|
|
8013
|
+
subscriptionId: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
8014
|
+
variantId: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX)
|
|
7713
8015
|
});
|
|
7714
|
-
var CartInputSchema =
|
|
7715
|
-
attributes:
|
|
8016
|
+
var CartInputSchema = import_zod90.z.object({
|
|
8017
|
+
attributes: import_zod90.z.array(KeyValue).max(REQUEST_BOUNDS.CART_ATTRIBUTES_MAX).optional(),
|
|
7716
8018
|
/**
|
|
7717
8019
|
* Presentment-per-shop-currency FX rate (buyer price ÷ shop price, e.g. `1.35` for a USD shop
|
|
7718
8020
|
* selling in CAD). Money rule thresholds are authored in SHOP currency, so the engine subtotal is
|
|
7719
8021
|
* divided by this before evaluation. Omit (or send 1) when the cart is already in the shop's currency.
|
|
7720
8022
|
*/
|
|
7721
|
-
currencyRate:
|
|
8023
|
+
currencyRate: import_zod90.z.number().optional(),
|
|
7722
8024
|
/** Applied discount codes; the engine evaluates `discount_code` rules against them (sent as `[{code}]`). */
|
|
7723
|
-
discountCodes:
|
|
8025
|
+
discountCodes: import_zod90.z.array(import_zod90.z.string().max(REQUEST_BOUNDS.STRING_KEY_MAX)).max(REQUEST_BOUNDS.DISCOUNT_CODES_MAX).optional(),
|
|
7724
8026
|
/** Presentment cents of cart-level discount allocations, subtracted from `subtotal` for the engine. */
|
|
7725
|
-
discountTotal:
|
|
7726
|
-
items:
|
|
8027
|
+
discountTotal: import_zod90.z.number().optional(),
|
|
8028
|
+
items: import_zod90.z.array(CartLineInputSchema).max(REQUEST_BOUNDS.CART_ITEMS_MAX),
|
|
7727
8029
|
/** Presentment subtotal in cents. */
|
|
7728
|
-
subtotal:
|
|
8030
|
+
subtotal: import_zod90.z.number()
|
|
7729
8031
|
});
|
|
7730
|
-
var UserConfigInputSchema =
|
|
7731
|
-
var DataSourceInputSchema =
|
|
8032
|
+
var UserConfigInputSchema = import_zod90.z.object({ shop: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX) });
|
|
8033
|
+
var DataSourceInputSchema = import_zod90.z.object({
|
|
7732
8034
|
cart: CartInputSchema,
|
|
7733
8035
|
/**
|
|
7734
8036
|
* Numeric Shopify company-location id when the buyer is a B2B session (`buyerIdentity.purchasingCompany`).
|
|
7735
8037
|
* Present ⇒ the orchestrator filters results by the location's catalog via admin-api (REB-23713); the
|
|
7736
8038
|
* client's country-context market check is bypassed for B2B (it false-negatives B2B-catalog products).
|
|
7737
8039
|
*/
|
|
7738
|
-
companyLocationId:
|
|
8040
|
+
companyLocationId: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
7739
8041
|
/**
|
|
7740
8042
|
* Buyer's market country (ISO 3166-1 alpha-2) — forwarded to the engine as the `country_code` PARAM
|
|
7741
8043
|
* when the shop's markets toggle is on (REB-21688; the sink was the `X-Country-Code` header under
|
|
@@ -7744,16 +8046,16 @@ var DataSourceInputSchema = import_zod86.z.object({
|
|
|
7744
8046
|
* uppercase (the wire value is forwarded verbatim as the param) so a case-sensitive engine lookup
|
|
7745
8047
|
* can't silently miss a lowercase code — `adsEngine.ts` uppercases for the same reason.
|
|
7746
8048
|
*/
|
|
7747
|
-
country:
|
|
7748
|
-
customerId:
|
|
7749
|
-
dataSourcePath:
|
|
8049
|
+
country: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).regex(/^[A-Za-z]{2}$/, "must be an ISO 3166-1 alpha-2 country code (e.g. CA)").transform((value) => value.toUpperCase()).optional(),
|
|
8050
|
+
customerId: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
8051
|
+
dataSourcePath: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_KEY_MAX),
|
|
7750
8052
|
/**
|
|
7751
8053
|
* Engine `filter_inputs` override: `'no'` keeps in-cart (input) products in the results/rule
|
|
7752
8054
|
* outputs — gift validation sends it so a gift's own product can appear in its answer. Omitted = the
|
|
7753
8055
|
* engine's default filtering.
|
|
7754
8056
|
*/
|
|
7755
|
-
filterInputs:
|
|
7756
|
-
integrations:
|
|
8057
|
+
filterInputs: import_zod90.z.enum(["no", "yes"]).optional(),
|
|
8058
|
+
integrations: import_zod90.z.record(import_zod90.z.string().max(REQUEST_BOUNDS.STRING_KEY_MAX), import_zod90.z.boolean()).refine((record) => Object.keys(record).length <= REQUEST_BOUNDS.INTEGRATION_KEYS_MAX, {
|
|
7757
8059
|
message: `Too many integration keys (max ${REQUEST_BOUNDS.INTEGRATION_KEYS_MAX})`
|
|
7758
8060
|
}).optional(),
|
|
7759
8061
|
/**
|
|
@@ -7766,31 +8068,31 @@ var DataSourceInputSchema = import_zod86.z.object({
|
|
|
7766
8068
|
* request header) fails the regex. Callers should send the buyer's resolved locale (e.g. Shopify
|
|
7767
8069
|
* checkout's `localization.language.isoCode`), not the request header verbatim.
|
|
7768
8070
|
*/
|
|
7769
|
-
language:
|
|
7770
|
-
limit:
|
|
7771
|
-
productType:
|
|
7772
|
-
shop:
|
|
7773
|
-
visitorId:
|
|
7774
|
-
});
|
|
7775
|
-
var GiftInputSchema =
|
|
7776
|
-
cost:
|
|
7777
|
-
discounted:
|
|
8071
|
+
language: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).regex(/^[A-Za-z0-9-]+$/, "must be a single BCP-47 tag (e.g. fr-CA), not a q-value list").optional(),
|
|
8072
|
+
limit: import_zod90.z.number().max(REQUEST_BOUNDS.LIMIT_MAX),
|
|
8073
|
+
productType: import_zod90.z.enum(["both", "one-time", "subscription"]).optional(),
|
|
8074
|
+
shop: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
8075
|
+
visitorId: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
8076
|
+
});
|
|
8077
|
+
var GiftInputSchema = import_zod90.z.object({
|
|
8078
|
+
cost: import_zod90.z.number(),
|
|
8079
|
+
discounted: import_zod90.z.boolean(),
|
|
7778
8080
|
/**
|
|
7779
8081
|
* Which gift attribution the line carries (REB-24363). Defaults to `gwp` because a client that predates
|
|
7780
8082
|
* the field only ever sent GWP lines — without the default an older extension's request would 422.
|
|
7781
8083
|
*/
|
|
7782
|
-
kind:
|
|
7783
|
-
lineId:
|
|
7784
|
-
productId:
|
|
8084
|
+
kind: import_zod90.z.enum(GIFT_KINDS).default("gwp"),
|
|
8085
|
+
lineId: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
8086
|
+
productId: import_zod90.z.number(),
|
|
7785
8087
|
/**
|
|
7786
8088
|
* The line's unit count (REB-24363) — the selectable-GWP verdict trims surplus units against milestone
|
|
7787
8089
|
* capacity. The second deliberate default: a client predating the field sent only GWP lines, whose
|
|
7788
8090
|
* verdict is whole-line, so a missing quantity reads as one unit rather than 422ing the older request.
|
|
7789
8091
|
*/
|
|
7790
|
-
quantity:
|
|
7791
|
-
widgetId:
|
|
8092
|
+
quantity: import_zod90.z.number().int().min(1).default(1),
|
|
8093
|
+
widgetId: import_zod90.z.number()
|
|
7792
8094
|
});
|
|
7793
|
-
var GiftValidationInputSchema =
|
|
8095
|
+
var GiftValidationInputSchema = import_zod90.z.object({
|
|
7794
8096
|
cart: CartInputSchema,
|
|
7795
8097
|
/**
|
|
7796
8098
|
* Buyer's market country — threaded into the per-widget data-source evaluations, which forward it to
|
|
@@ -7799,25 +8101,25 @@ var GiftValidationInputSchema = import_zod86.z.object({
|
|
|
7799
8101
|
* turns markets off); regex-bound and uppercase-normalized for the same reasons as
|
|
7800
8102
|
* `DataSourceInputSchema`'s `country`.
|
|
7801
8103
|
*/
|
|
7802
|
-
country:
|
|
7803
|
-
customerId:
|
|
7804
|
-
gifts:
|
|
8104
|
+
country: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).regex(/^[A-Za-z]{2}$/, "must be an ISO 3166-1 alpha-2 country code (e.g. CA)").transform((value) => value.toUpperCase()).optional(),
|
|
8105
|
+
customerId: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
8106
|
+
gifts: import_zod90.z.array(GiftInputSchema).max(REQUEST_BOUNDS.GIFTS_MAX),
|
|
7805
8107
|
/**
|
|
7806
8108
|
* Buyer's checkout language — threaded into the per-widget data-source evaluations, which normalize
|
|
7807
8109
|
* and forward it as the engine `locale` param under the same markets-toggle gate (REB-21688). MUST be
|
|
7808
8110
|
* a single BCP-47 tag, for the same reason as `DataSourceInputSchema`'s `language` above.
|
|
7809
8111
|
*/
|
|
7810
|
-
language:
|
|
7811
|
-
shop:
|
|
7812
|
-
visitorId:
|
|
8112
|
+
language: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).regex(/^[A-Za-z0-9-]+$/, "must be a single BCP-47 tag (e.g. fr-CA), not a q-value list").optional(),
|
|
8113
|
+
shop: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
8114
|
+
visitorId: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
7813
8115
|
});
|
|
7814
|
-
var GiftAdjustmentSchema =
|
|
7815
|
-
lineId:
|
|
7816
|
-
quantity:
|
|
8116
|
+
var GiftAdjustmentSchema = import_zod90.z.object({
|
|
8117
|
+
lineId: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
8118
|
+
quantity: import_zod90.z.number().int().nonnegative()
|
|
7817
8119
|
});
|
|
7818
|
-
var GiftValidationResponseSchema =
|
|
7819
|
-
adjust:
|
|
7820
|
-
remove:
|
|
8120
|
+
var GiftValidationResponseSchema = import_zod90.z.object({
|
|
8121
|
+
adjust: import_zod90.z.array(GiftAdjustmentSchema).max(REQUEST_BOUNDS.GIFTS_MAX).default([]),
|
|
8122
|
+
remove: import_zod90.z.array(import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX)).max(REQUEST_BOUNDS.GIFTS_MAX).refine(
|
|
7821
8123
|
(remove) => new Set(remove).size === remove.length,
|
|
7822
8124
|
"a line id may appear at most once in `remove`"
|
|
7823
8125
|
)
|
|
@@ -7828,47 +8130,47 @@ var GiftValidationResponseSchema = import_zod86.z.object({
|
|
|
7828
8130
|
({ adjust }) => new Set(adjust.map(({ lineId }) => lineId)).size === adjust.length,
|
|
7829
8131
|
"a line id may appear at most once in `adjust`"
|
|
7830
8132
|
);
|
|
7831
|
-
var MonetizeTransactionItemSchema =
|
|
7832
|
-
id:
|
|
7833
|
-
priceCents:
|
|
7834
|
-
quantity:
|
|
7835
|
-
title:
|
|
7836
|
-
type:
|
|
7837
|
-
});
|
|
7838
|
-
var MonetizeInputSchema =
|
|
8133
|
+
var MonetizeTransactionItemSchema = import_zod90.z.object({
|
|
8134
|
+
id: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
8135
|
+
priceCents: import_zod90.z.number(),
|
|
8136
|
+
quantity: import_zod90.z.number(),
|
|
8137
|
+
title: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX),
|
|
8138
|
+
type: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX)
|
|
8139
|
+
});
|
|
8140
|
+
var MonetizeInputSchema = import_zod90.z.object({
|
|
7839
8141
|
cart: CartInputSchema,
|
|
7840
8142
|
/** Client-minted render-beacon correlation id; forwarded to the ads engine as `client_request_id`. */
|
|
7841
|
-
clientRequestId:
|
|
7842
|
-
country:
|
|
7843
|
-
currency:
|
|
8143
|
+
clientRequestId: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
8144
|
+
country: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
8145
|
+
currency: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
7844
8146
|
/** Ads-targeting identity/geo/locale fields (React parity); folded into the engine query verbatim. */
|
|
7845
|
-
customerEmail:
|
|
7846
|
-
customerFirstName:
|
|
7847
|
-
customerId:
|
|
7848
|
-
customerLastName:
|
|
7849
|
-
language:
|
|
8147
|
+
customerEmail: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX).optional(),
|
|
8148
|
+
customerFirstName: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX).optional(),
|
|
8149
|
+
customerId: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
8150
|
+
customerLastName: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX).optional(),
|
|
8151
|
+
language: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
7850
8152
|
/** Buyer-facing order name (e.g. `#1001`) for the server-composed "Order … Confirmed" chrome line. */
|
|
7851
|
-
orderName:
|
|
8153
|
+
orderName: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX).optional(),
|
|
7852
8154
|
/** Ads surface label, forwarded verbatim; `customer_account` is measured/floored as its own surface (the account-area order list). */
|
|
7853
|
-
placement:
|
|
8155
|
+
placement: import_zod90.z.enum(["customer_account", "order_status", "thank_you_page"]),
|
|
7854
8156
|
/** Privacy Policy footer href — the Monetize widget's `privacy_policy_url` setting (React parity). */
|
|
7855
|
-
privacyPolicyUrl:
|
|
8157
|
+
privacyPolicyUrl: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_URL_MAX).optional(),
|
|
7856
8158
|
/** 30-min rolling session id (React parity); used for the ads `session_id`, else the visitor id. */
|
|
7857
|
-
sessionId:
|
|
7858
|
-
shop:
|
|
8159
|
+
sessionId: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
8160
|
+
shop: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
7859
8161
|
/** Editor/QA indicator; OR-ed into the ads-engine `testing` flag so it stays out of billing/reporting. */
|
|
7860
|
-
testing:
|
|
7861
|
-
timezone:
|
|
8162
|
+
testing: import_zod90.z.boolean().optional(),
|
|
8163
|
+
timezone: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
7862
8164
|
/** Decorated (numeric) order id → the ads `transaction_id`. */
|
|
7863
|
-
transactionId:
|
|
8165
|
+
transactionId: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
7864
8166
|
/** Rich per-line ads items; capped at the engine's ads contract. Preferred over `cart.items`. */
|
|
7865
|
-
transactionItems:
|
|
8167
|
+
transactionItems: import_zod90.z.array(MonetizeTransactionItemSchema).max(REQUEST_BOUNDS.TRANSACTION_ITEMS_MAX).optional(),
|
|
7866
8168
|
/** Order total in presentment cents (React prefers total over subtotal); else `cart.subtotal`. */
|
|
7867
|
-
transactionTotal:
|
|
7868
|
-
visitorId:
|
|
7869
|
-
zipCode:
|
|
8169
|
+
transactionTotal: import_zod90.z.number().optional(),
|
|
8170
|
+
visitorId: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
8171
|
+
zipCode: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
7870
8172
|
});
|
|
7871
|
-
var WidgetSettingsInputSchema =
|
|
8173
|
+
var WidgetSettingsInputSchema = import_zod90.z.object({
|
|
7872
8174
|
/**
|
|
7873
8175
|
* Same domain as `CabShopConfig.cacheKey`, for the same reason: this side WINS the orchestrator's
|
|
7874
8176
|
* `input.cacheKey ?? config.shop.cacheKey` (and an explicit value skips the config read entirely), so
|
|
@@ -7876,9 +8178,9 @@ var WidgetSettingsInputSchema = import_zod86.z.object({
|
|
|
7876
8178
|
* and pin the edge copy permanently stale. `.catch(undefined)` because a bogus buster should degrade
|
|
7877
8179
|
* the read to un-busted, never 400 a widget render.
|
|
7878
8180
|
*/
|
|
7879
|
-
cacheKey:
|
|
7880
|
-
id:
|
|
7881
|
-
key:
|
|
8181
|
+
cacheKey: import_zod90.z.number().int().positive().optional().catch(void 0),
|
|
8182
|
+
id: import_zod90.z.number(),
|
|
8183
|
+
key: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
7882
8184
|
/**
|
|
7883
8185
|
* Monetize context for inline hydration: when present AND the widget converts to a Monetize marker,
|
|
7884
8186
|
* the server fetches/composes the offer cards inside this same request (no second `/cab/monetize`
|
|
@@ -7887,34 +8189,34 @@ var WidgetSettingsInputSchema = import_zod86.z.object({
|
|
|
7887
8189
|
* `privacyPolicyUrl` comes from the widget settings server-side (more authoritative than a relay).
|
|
7888
8190
|
*/
|
|
7889
8191
|
monetize: MonetizeInputSchema.omit({ privacyPolicyUrl: true, shop: true }).optional(),
|
|
7890
|
-
shop:
|
|
8192
|
+
shop: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
7891
8193
|
/** Stable per-buyer id; when present, enables sticky server-side A/B variant selection. */
|
|
7892
|
-
visitorId:
|
|
8194
|
+
visitorId: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
7893
8195
|
});
|
|
7894
|
-
var AnalyticsEventInputSchema =
|
|
7895
|
-
name:
|
|
7896
|
-
properties:
|
|
7897
|
-
sentAt:
|
|
8196
|
+
var AnalyticsEventInputSchema = import_zod90.z.object({
|
|
8197
|
+
name: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_KEY_MAX),
|
|
8198
|
+
properties: import_zod90.z.record(import_zod90.z.string().max(REQUEST_BOUNDS.STRING_KEY_MAX), import_zod90.z.unknown()).optional(),
|
|
8199
|
+
sentAt: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
7898
8200
|
});
|
|
7899
|
-
var AnalyticsSegmentsInputSchema =
|
|
7900
|
-
device:
|
|
7901
|
-
source:
|
|
7902
|
-
visitor:
|
|
8201
|
+
var AnalyticsSegmentsInputSchema = import_zod90.z.object({
|
|
8202
|
+
device: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional().catch(void 0),
|
|
8203
|
+
source: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional().catch(void 0),
|
|
8204
|
+
visitor: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional().catch(void 0)
|
|
7903
8205
|
});
|
|
7904
|
-
var AnalyticsInputSchema =
|
|
8206
|
+
var AnalyticsInputSchema = import_zod90.z.object({
|
|
7905
8207
|
/** Rebuy cart token (the `r_cart_token` cart attribute), when available — primary aggregation key. */
|
|
7906
|
-
cartToken:
|
|
8208
|
+
cartToken: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
7907
8209
|
/** Shopify checkout token, when available — drives cart/checkout aggregation downstream. */
|
|
7908
|
-
checkoutToken:
|
|
7909
|
-
events:
|
|
8210
|
+
checkoutToken: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
8211
|
+
events: import_zod90.z.array(AnalyticsEventInputSchema).max(REQUEST_BOUNDS.EVENTS_MAX),
|
|
7910
8212
|
/**
|
|
7911
8213
|
* Request-scoped like the tokens: one visitor's segments apply to every event in the batch. The container
|
|
7912
8214
|
* degrades too (`null` is a realistic wire artifact of `attributes ? {…} : null`), so the degrade rule is
|
|
7913
8215
|
* total: nothing about `segments` can cost the envelope.
|
|
7914
8216
|
*/
|
|
7915
8217
|
segments: AnalyticsSegmentsInputSchema.optional().catch(void 0),
|
|
7916
|
-
shop:
|
|
7917
|
-
visitorId:
|
|
8218
|
+
shop: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
8219
|
+
visitorId: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
7918
8220
|
/** The widget id (smartBlockId) the events belong to. */
|
|
7919
|
-
widgetId:
|
|
8221
|
+
widgetId: import_zod90.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
7920
8222
|
});
|