@rebuy/rebuy 3.32.0 → 3.34.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/README.md +1 -1
- package/dist/cab/index.cjs +12 -1
- package/dist/cab/index.d.ts +1 -0
- package/dist/cab/index.mjs +12 -1
- package/dist/cab/utf8ByteLength.d.ts +6 -0
- package/dist/index.cjs +1138 -923
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +1138 -923
- package/dist/pricing/postPurchaseSubscriptionDisplay.d.ts +5 -0
- package/dist/schema/index.d.ts +8 -0
- package/dist/schema/postPurchaseChoice.d.ts +25 -0
- package/dist/schema/postPurchaseDiscount.d.ts +22 -0
- package/dist/schema/postPurchasePlanAdjustment.d.ts +11 -0
- package/dist/schema/postPurchasePlanCatalog.d.ts +42 -0
- package/dist/schema/postPurchaseProduct.d.ts +260 -0
- package/dist/schema/postPurchaseProductSettings.d.ts +1 -1
- package/dist/schema/postPurchaseProductSource.d.ts +2 -2
- package/dist/schema/postPurchaseSubscription.d.ts +21 -0
- package/dist/schema/postPurchaseSubscriptionDisplay.d.ts +10 -0
- package/dist/schema/postPurchaseSubscriptionProduct.d.ts +224 -0
- package/dist/schema/postPurchaseSubscriptionSettings.d.ts +22 -0
- package/dist/schema/widgets/checkout-and-beyond/banner.d.ts +1 -1
- package/dist/schema/widgets/checkout-and-beyond/carousel.d.ts +1 -1
- package/dist/schema/widgets/checkout-and-beyond/cartLine.d.ts +1 -1
- package/dist/schema/widgets/checkout-and-beyond/common.d.ts +1 -1
- package/dist/schema/widgets/checkout-and-beyond/dataSource.d.ts +2 -2
- package/dist/schema/widgets/checkout-and-beyond/discount.d.ts +1 -1
- package/dist/schema/widgets/checkout-and-beyond/icons.d.ts +1 -1
- package/dist/schema/widgets/checkout-and-beyond/image.d.ts +2 -2
- package/dist/schema/widgets/checkout-and-beyond/offers.d.ts +1 -1
- package/dist/schema/widgets/checkout-and-beyond/progressBar.d.ts +1 -1
- package/dist/schema/widgets/post-purchase-offer/postPurchaseOffer.d.ts +2 -2
- package/dist/schema/widgets/post-purchase-offer/postPurchaseSettings.d.ts +2 -2
- package/dist/schema/widgets/post-purchase-offer/postPurchaseWidget.d.ts +2 -2
- package/dist/server/__fixtures__/postPurchaseLegacyPlans.d.ts +35 -0
- package/dist/server/__fixtures__/postPurchaseSubscription.d.ts +75 -0
- package/dist/server/index.cjs +802 -118
- package/dist/server/index.d.ts +3 -1
- package/dist/server/index.mjs +802 -118
- package/dist/server/normalizePostPurchaseCollection.d.ts +16 -16
- package/dist/server/normalizePostPurchaseProduct.d.ts +9 -9
- package/dist/server/postPurchaseLegacyPlans.d.ts +3 -0
- package/dist/server/postPurchaseModernPlans.d.ts +7 -0
- package/dist/server/postPurchasePlanAdjustment.d.ts +3 -0
- package/dist/server/postPurchasePlanCatalog.d.ts +5 -0
- package/dist/server/postPurchaseSubscriptionEligibility.d.ts +5 -0
- package/dist/server/prepareNormalizedSubscription.d.ts +11 -0
- package/dist/server/preparePostPurchaseSubscription.d.ts +102 -0
- package/dist/server/projectPostPurchaseProduct.d.ts +7 -7
- package/dist/server/requestSchemas.d.ts +1 -1
- package/dist/server/selectPostPurchaseChoice.d.ts +43 -0
- package/package.json +1 -1
package/dist/server/index.cjs
CHANGED
|
@@ -44,6 +44,7 @@ __export(server_exports, {
|
|
|
44
44
|
fetchMonetizeOffers: () => fetchMonetizeOffers,
|
|
45
45
|
fetchUserConfig: () => fetchUserConfig,
|
|
46
46
|
postAnalyticsEvents: () => postAnalyticsEvents,
|
|
47
|
+
preparePostPurchaseSubscription: () => preparePostPurchaseSubscription,
|
|
47
48
|
translateAnalyticsEvent: () => translateAnalyticsEvent,
|
|
48
49
|
validateGifts: () => validateGifts
|
|
49
50
|
});
|
|
@@ -2264,10 +2265,10 @@ var HEADER_PARAGRAPH_STYLES = {
|
|
|
2264
2265
|
superTitle: { color: "base", fontSize: "extraLarge", marks: [{ type: "bold" }] },
|
|
2265
2266
|
title: { color: "base", fontSize: "medium", marks: [{ type: "bold" }] }
|
|
2266
2267
|
};
|
|
2267
|
-
var convertContentBlockTextToV2 = (
|
|
2268
|
-
const description =
|
|
2269
|
-
const superTitle =
|
|
2270
|
-
const title =
|
|
2268
|
+
var convertContentBlockTextToV2 = (language2, text2 = literalText, textAlign = "center") => {
|
|
2269
|
+
const description = language2?.description;
|
|
2270
|
+
const superTitle = language2?.superTitle;
|
|
2271
|
+
const title = language2?.title;
|
|
2271
2272
|
return TiptapDocument.parse({
|
|
2272
2273
|
attrs: { blockSpacing: "tight" },
|
|
2273
2274
|
content: [
|
|
@@ -2379,7 +2380,7 @@ var LOCATION_TO_EDITOR_MODE = {
|
|
|
2379
2380
|
};
|
|
2380
2381
|
|
|
2381
2382
|
// src/transforms/contentBlockV1/convertContentBlockToV2.ts
|
|
2382
|
-
var hasText = (
|
|
2383
|
+
var hasText = (language2) => !!language2 && !!(language2.description || language2.superTitle || language2.title);
|
|
2383
2384
|
var convertContentBlockToV2 = ({ id, settings }) => {
|
|
2384
2385
|
const imageBlocks = settings.imageBlocks ?? [];
|
|
2385
2386
|
return CABRootSection.parse({
|
|
@@ -3422,7 +3423,7 @@ var buildQuantity = (settings) => {
|
|
|
3422
3423
|
};
|
|
3423
3424
|
var buildSubscriptionButton = (settings) => {
|
|
3424
3425
|
if (settings.productType !== "both" && settings.productType !== "subscription") return [];
|
|
3425
|
-
const
|
|
3426
|
+
const language2 = settings.language;
|
|
3426
3427
|
const slot = (buttonField, override) => ({
|
|
3427
3428
|
buttonField,
|
|
3428
3429
|
content: localizedContent(SWITCH_LABELS[buttonField], override, SWITCH_LABEL_TOKENS2),
|
|
@@ -3436,9 +3437,9 @@ var buildSubscriptionButton = (settings) => {
|
|
|
3436
3437
|
...settings.productType === "subscription" && { disableDowngrade: true },
|
|
3437
3438
|
sections: [
|
|
3438
3439
|
slot("subscriptionOption", void 0),
|
|
3439
|
-
slot("switchToOneTimePurchase",
|
|
3440
|
-
slot("switchToSubscriptionNoDiscount",
|
|
3441
|
-
slot("switchToSubscriptionWithDiscount",
|
|
3440
|
+
slot("switchToOneTimePurchase", language2?.cartSwitchToOnetime),
|
|
3441
|
+
slot("switchToSubscriptionNoDiscount", language2?.upgradeToSubscription),
|
|
3442
|
+
slot("switchToSubscriptionWithDiscount", language2?.upgradeToSubscription)
|
|
3442
3443
|
],
|
|
3443
3444
|
sectionType: "button"
|
|
3444
3445
|
}
|
|
@@ -3494,10 +3495,10 @@ var buildOfferCard = (settings, horizontal) => {
|
|
|
3494
3495
|
const reviews = buildReviews(settings);
|
|
3495
3496
|
const variants = buildVariants(settings);
|
|
3496
3497
|
const quantity = buildQuantity(settings);
|
|
3497
|
-
const
|
|
3498
|
+
const subscription2 = buildSubscriptionButton(settings);
|
|
3498
3499
|
const reveal = buildRevealButton(settings);
|
|
3499
3500
|
const addButton = buildAddButton(settings);
|
|
3500
|
-
const controls = [...description, ...quantity, ...variants, ...
|
|
3501
|
+
const controls = [...description, ...quantity, ...variants, ...subscription2];
|
|
3501
3502
|
const info = detailBlock([title, ...variantTitle, ...reviews, price], horizontal, variantTitle.length > 0);
|
|
3502
3503
|
const card = (sections) => [
|
|
3503
3504
|
{
|
|
@@ -3551,9 +3552,9 @@ var buildCarouselNav = () => ({
|
|
|
3551
3552
|
sectionType: "layout"
|
|
3552
3553
|
});
|
|
3553
3554
|
var HEADER_FIELDS = ["superTitle", "title", "description"];
|
|
3554
|
-
var sanitizedHeader = (
|
|
3555
|
+
var sanitizedHeader = (language2) => Object.fromEntries(
|
|
3555
3556
|
HEADER_FIELDS.flatMap((field) => {
|
|
3556
|
-
const value =
|
|
3557
|
+
const value = language2?.[field];
|
|
3557
3558
|
const sanitized = value ? stripContentBlockHtml(normalizeTokens(value)) : "";
|
|
3558
3559
|
return sanitized ? [[field, sanitized]] : [];
|
|
3559
3560
|
})
|
|
@@ -3650,7 +3651,7 @@ var coerceIntegrations = (integrations) => Object.fromEntries(
|
|
|
3650
3651
|
return [key, value];
|
|
3651
3652
|
})
|
|
3652
3653
|
);
|
|
3653
|
-
var buildBanner = (
|
|
3654
|
+
var buildBanner = (language2) => language2?.successBannerEnabled ? [
|
|
3654
3655
|
{
|
|
3655
3656
|
/**
|
|
3656
3657
|
* The banner-level tag is the extraction/routing key on BOTH renderers (React CAB's
|
|
@@ -3663,7 +3664,7 @@ var buildBanner = (language) => language?.successBannerEnabled ? [
|
|
|
3663
3664
|
dismissible: true,
|
|
3664
3665
|
sections: [
|
|
3665
3666
|
{
|
|
3666
|
-
content: bannerMessageContent(
|
|
3667
|
+
content: bannerMessageContent(language2.successBannerMessageRte),
|
|
3667
3668
|
sectionType: "text"
|
|
3668
3669
|
},
|
|
3669
3670
|
{
|
|
@@ -4497,8 +4498,8 @@ var tierLabel = (tier) => {
|
|
|
4497
4498
|
};
|
|
4498
4499
|
var discountOf = (tier) => {
|
|
4499
4500
|
if (tier.type !== "discount") return void 0;
|
|
4500
|
-
const
|
|
4501
|
-
return tier.discountType === "fixedAmount" ? { amount: Math.round(
|
|
4501
|
+
const amount2 = tier.discountAmountFromTotal ?? 0;
|
|
4502
|
+
return tier.discountType === "fixedAmount" ? { amount: Math.round(amount2 * 100), type: "fixedAmount" } : { amount: amount2, type: "percentage" };
|
|
4502
4503
|
};
|
|
4503
4504
|
var iconSizeOf = (tier) => {
|
|
4504
4505
|
const px = Math.round(Number.parseFloat(String(tier.productTierElementSize ?? "")));
|
|
@@ -5502,6 +5503,689 @@ var validateGifts = async (input, ctx) => {
|
|
|
5502
5503
|
return { adjust: [...targets].map(([lineId, quantity]) => ({ lineId, quantity })), remove: [...removed] };
|
|
5503
5504
|
};
|
|
5504
5505
|
|
|
5506
|
+
// src/server/normalizePostPurchaseProduct.ts
|
|
5507
|
+
var import_compat6 = require("es-toolkit/compat");
|
|
5508
|
+
var import_zod43 = require("zod");
|
|
5509
|
+
|
|
5510
|
+
// src/schema/postPurchaseProductSettings.ts
|
|
5511
|
+
var import_zod42 = require("zod");
|
|
5512
|
+
|
|
5513
|
+
// src/schema/postPurchaseProductSource.ts
|
|
5514
|
+
var import_zod39 = require("zod");
|
|
5515
|
+
var PostPurchaseAmount = import_zod39.z.string().regex(/^\d+(?:\.\d+)?$/).refine((value) => Number.isFinite(Number(value)));
|
|
5516
|
+
var PostPurchaseProductId = import_zod39.z.number().int().positive();
|
|
5517
|
+
var PostPurchaseVariantId = import_zod39.z.number().int().positive();
|
|
5518
|
+
var ProductBase = OfferProduct.pick({ description: true, id: true, image: true, title: true }).extend({
|
|
5519
|
+
description: OfferProduct.shape.description.nullable(),
|
|
5520
|
+
id: PostPurchaseProductId
|
|
5521
|
+
});
|
|
5522
|
+
var SourceVariant = OfferProduct.shape.variants.element.pick({ id: true, title: true }).extend({
|
|
5523
|
+
compareAtPrice: PostPurchaseAmount.nullable(),
|
|
5524
|
+
id: PostPurchaseVariantId,
|
|
5525
|
+
imageId: import_zod39.z.number().int().nonnegative().nullish(),
|
|
5526
|
+
inventoryManagement: import_zod39.z.string().nullable(),
|
|
5527
|
+
inventoryPolicy: import_zod39.z.string(),
|
|
5528
|
+
inventoryQuantity: import_zod39.z.number(),
|
|
5529
|
+
option1: import_zod39.z.unknown().optional(),
|
|
5530
|
+
option2: import_zod39.z.unknown().optional(),
|
|
5531
|
+
option3: import_zod39.z.unknown().optional(),
|
|
5532
|
+
price: PostPurchaseAmount,
|
|
5533
|
+
productId: PostPurchaseProductId,
|
|
5534
|
+
sellingPlanAllocations: import_zod39.z.unknown().optional()
|
|
5535
|
+
});
|
|
5536
|
+
var Product2 = ProductBase.extend({
|
|
5537
|
+
images: import_zod39.z.array(
|
|
5538
|
+
import_zod39.z.object({ alt: import_zod39.z.string().optional().catch(void 0), id: import_zod39.z.number().int().positive(), src: import_zod39.z.string() })
|
|
5539
|
+
).nullish(),
|
|
5540
|
+
metadata: import_zod39.z.object({
|
|
5541
|
+
productQuantity: import_zod39.z.union([
|
|
5542
|
+
import_zod39.z.number().int().positive(),
|
|
5543
|
+
import_zod39.z.string().regex(/^[1-9]\d*$/).transform(Number)
|
|
5544
|
+
]).optional()
|
|
5545
|
+
}).optional(),
|
|
5546
|
+
metafields: import_zod39.z.unknown().optional(),
|
|
5547
|
+
options: import_zod39.z.unknown().optional(),
|
|
5548
|
+
productGroupVariants: import_zod39.z.array(import_zod39.z.unknown()).default([]),
|
|
5549
|
+
selectedVariant: import_zod39.z.unknown().optional(),
|
|
5550
|
+
sellingPlanGroups: import_zod39.z.array(
|
|
5551
|
+
OfferProduct.shape.sellingPlanGroups.unwrap().element.extend({
|
|
5552
|
+
discountAmount: import_zod39.z.unknown().optional(),
|
|
5553
|
+
discountType: import_zod39.z.unknown().optional(),
|
|
5554
|
+
id: import_zod39.z.unknown().optional(),
|
|
5555
|
+
requiresSellingPlan: import_zod39.z.boolean().default(false),
|
|
5556
|
+
sellingPlans: import_zod39.z.unknown().optional()
|
|
5557
|
+
})
|
|
5558
|
+
).default([]),
|
|
5559
|
+
variants: import_zod39.z.array(SourceVariant)
|
|
5560
|
+
});
|
|
5561
|
+
var PostPurchaseProductSource = import_zod39.z.object({
|
|
5562
|
+
data: import_zod39.z.array(Product2),
|
|
5563
|
+
metadata: import_zod39.z.object({ widget: import_zod39.z.record(import_zod39.z.string(), import_zod39.z.unknown()).default({}) }).default({ widget: {} })
|
|
5564
|
+
});
|
|
5565
|
+
|
|
5566
|
+
// src/schema/widgets/post-purchase-offer/postPurchaseSettings.ts
|
|
5567
|
+
var import_zod41 = require("zod");
|
|
5568
|
+
|
|
5569
|
+
// src/schema/widgets/post-purchase-offer/common.ts
|
|
5570
|
+
var import_compat5 = require("es-toolkit/compat");
|
|
5571
|
+
var import_zod40 = require("zod");
|
|
5572
|
+
var strictNumber = import_zod40.z.union([
|
|
5573
|
+
import_zod40.z.number(),
|
|
5574
|
+
import_zod40.z.string().transform((value) => (0, import_compat5.toNumber)((0, import_compat5.replace)((0, import_compat5.toString)(value), /[^0-9.]/g, "")) || 0),
|
|
5575
|
+
import_zod40.z.unknown().transform(() => 0)
|
|
5576
|
+
]);
|
|
5577
|
+
|
|
5578
|
+
// src/schema/widgets/post-purchase-offer/postPurchaseSettings.ts
|
|
5579
|
+
var PostPurchaseSettings = import_zod41.z.object({
|
|
5580
|
+
advance: import_zod41.z.object({ removePartialOrder: import_zod41.z.boolean().default(true) }).optional().default(() => ({ removePartialOrder: true })),
|
|
5581
|
+
blocks: import_zod41.z.union([import_zod41.z.array(PostPurchaseBlock), import_zod41.z.unknown().transform(() => [])]).default(() => [
|
|
5582
|
+
PostPurchaseBlock.parse({ settings: {}, styles: {}, type: BlockType.timer }),
|
|
5583
|
+
PostPurchaseBlock.parse({ settings: {}, styles: {}, type: BlockType.callout_banner }),
|
|
5584
|
+
PostPurchaseBlock.parse({ type: BlockType.product_information })
|
|
5585
|
+
]),
|
|
5586
|
+
columnLayout: import_zod41.z.boolean().optional(),
|
|
5587
|
+
discount: import_zod41.z.object({
|
|
5588
|
+
amount: strictNumber.default(30),
|
|
5589
|
+
shouldShowSavingText: import_zod41.z.boolean().optional().default(true),
|
|
5590
|
+
type: import_zod41.z.enum(["none", "fixed_amount", "percentage"]).default("none")
|
|
5591
|
+
}),
|
|
5592
|
+
discountedFrom: import_zod41.z.enum(["price", "compare_at_price"]).optional().default("price"),
|
|
5593
|
+
endpoint: import_zod41.z.string().optional(),
|
|
5594
|
+
integrations: import_zod41.z.object({
|
|
5595
|
+
judgeme: import_zod41.z.boolean().default(false),
|
|
5596
|
+
junip: import_zod41.z.boolean().optional().default(false),
|
|
5597
|
+
klaviyo: import_zod41.z.boolean().default(false),
|
|
5598
|
+
loox: import_zod41.z.boolean().default(false),
|
|
5599
|
+
okendo: import_zod41.z.boolean().default(false),
|
|
5600
|
+
opinew: import_zod41.z.boolean().optional().default(false),
|
|
5601
|
+
reviewsio: import_zod41.z.boolean().optional().default(false),
|
|
5602
|
+
stamped: import_zod41.z.boolean().default(false),
|
|
5603
|
+
yotpo: import_zod41.z.boolean().default(false)
|
|
5604
|
+
}),
|
|
5605
|
+
key: import_zod41.z.string().optional(),
|
|
5606
|
+
language: import_zod41.z.object({
|
|
5607
|
+
description: import_zod41.z.union([import_zod41.z.string(), import_zod41.z.unknown().transform(() => "")]).default(""),
|
|
5608
|
+
descriptionEnabled: import_zod41.z.boolean().optional().default(false),
|
|
5609
|
+
descriptionRte: import_zod41.z.object({
|
|
5610
|
+
content: import_zod41.z.array(import_zod41.z.unknown()),
|
|
5611
|
+
type: import_zod41.z.string()
|
|
5612
|
+
}).optional(),
|
|
5613
|
+
descriptionSpacing: import_zod41.z.enum(["none", "xtight", "tight", "default", "loose", "xloose"]).optional(),
|
|
5614
|
+
displayCtaPrice: import_zod41.z.boolean().default(true),
|
|
5615
|
+
global: import_zod41.z.object({
|
|
5616
|
+
declineAll: import_zod41.z.string().optional().default("Decline All"),
|
|
5617
|
+
declineThisOffer: import_zod41.z.string().default("Decline this offer"),
|
|
5618
|
+
free: import_zod41.z.string().optional().default("Free"),
|
|
5619
|
+
notAvailable: import_zod41.z.string().optional().default("Not available"),
|
|
5620
|
+
payNow: import_zod41.z.string().default("Pay Now"),
|
|
5621
|
+
payNowUpgradeToSubscription: import_zod41.z.string().optional().default("Upgrade to Subscription"),
|
|
5622
|
+
quantity: import_zod41.z.string().default("Quantity"),
|
|
5623
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
5624
|
+
recurringShipping: import_zod41.z.string().optional().default("Recurring shipping"),
|
|
5625
|
+
recurringSubtotal: import_zod41.z.string().default("Recurring subtotal"),
|
|
5626
|
+
reviewsPlural: import_zod41.z.string().optional().default("Reviews"),
|
|
5627
|
+
reviewsSingular: import_zod41.z.string().optional().default("Review"),
|
|
5628
|
+
save: import_zod41.z.union([import_zod41.z.string(), import_zod41.z.unknown().transform(() => "Save")]).optional().default("Save"),
|
|
5629
|
+
shipping: import_zod41.z.string().default("Shipping"),
|
|
5630
|
+
subscriptionOption: import_zod41.z.string().optional().default("Subscribe and Save"),
|
|
5631
|
+
subtotal: import_zod41.z.string().default("Subtotal"),
|
|
5632
|
+
taxes: import_zod41.z.string().default("Taxes"),
|
|
5633
|
+
total: import_zod41.z.string().default("Total")
|
|
5634
|
+
}).optional().default(() => ({
|
|
5635
|
+
declineAll: "Decline All",
|
|
5636
|
+
declineThisOffer: "Decline this offer",
|
|
5637
|
+
free: "Free",
|
|
5638
|
+
notAvailable: "Not available",
|
|
5639
|
+
payNow: "Pay Now",
|
|
5640
|
+
payNowUpgradeToSubscription: "Upgrade to Subscription",
|
|
5641
|
+
quantity: "Quantity",
|
|
5642
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
5643
|
+
recurringShipping: "Recurring shipping",
|
|
5644
|
+
recurringSubtotal: "Recurring subtotal",
|
|
5645
|
+
reviewsPlural: "Reviews",
|
|
5646
|
+
reviewsSingular: "Review",
|
|
5647
|
+
save: "Save",
|
|
5648
|
+
shipping: "Shipping",
|
|
5649
|
+
subscriptionOption: "Subscribe and Save",
|
|
5650
|
+
subtotal: "Subtotal",
|
|
5651
|
+
taxes: "Taxes",
|
|
5652
|
+
total: "Total"
|
|
5653
|
+
})),
|
|
5654
|
+
globalTranslation: import_zod41.z.string().optional().default("english")
|
|
5655
|
+
}),
|
|
5656
|
+
metafields: import_zod41.z.boolean().default(false),
|
|
5657
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
5658
|
+
offer: import_zod41.z.object({
|
|
5659
|
+
count: import_zod41.z.number().default(1)
|
|
5660
|
+
}),
|
|
5661
|
+
offersLayout: import_zod41.z.object({
|
|
5662
|
+
itemsPerPage: import_zod41.z.number().optional(),
|
|
5663
|
+
type: import_zod41.z.enum(["list", "grid", "carousel"]).default("list")
|
|
5664
|
+
}).optional().default({
|
|
5665
|
+
type: "list"
|
|
5666
|
+
}),
|
|
5667
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
5668
|
+
previewMode: import_zod41.z.boolean().default(false),
|
|
5669
|
+
productLimit: import_zod41.z.number().optional().default(1),
|
|
5670
|
+
productOptions: import_zod41.z.object({
|
|
5671
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
5672
|
+
hideOutOfStockVariants: import_zod41.z.boolean().optional().default(false),
|
|
5673
|
+
matchVariant: import_zod41.z.boolean().optional().default(true),
|
|
5674
|
+
showDeclineAll: import_zod41.z.enum(["above", "below", "both", "none"]).optional(),
|
|
5675
|
+
showShipping: import_zod41.z.boolean().optional().default(true),
|
|
5676
|
+
showSubtotal: import_zod41.z.boolean().optional().default(true),
|
|
5677
|
+
showTaxes: import_zod41.z.boolean().optional().default(true),
|
|
5678
|
+
showTotal: import_zod41.z.boolean().optional().default(true),
|
|
5679
|
+
showVariantSelectors: import_zod41.z.boolean().optional().default(true),
|
|
5680
|
+
variantSelectorDisplayMode: import_zod41.z.enum(["separate", "single"]).optional().default("separate")
|
|
5681
|
+
}),
|
|
5682
|
+
productType: import_zod41.z.union([import_zod41.z.enum(["one-time", "subscription", "both"]), import_zod41.z.literal("").transform(() => "one-time")]).default("one-time"),
|
|
5683
|
+
productTypeSelector: import_zod41.z.enum(["dropdown", "radio"]).optional().default("radio"),
|
|
5684
|
+
quantityInputs: import_zod41.z.object({
|
|
5685
|
+
defaultQuantity: import_zod41.z.union([import_zod41.z.number(), import_zod41.z.null().transform(() => 1)]).default(1),
|
|
5686
|
+
enabled: import_zod41.z.boolean().default(true),
|
|
5687
|
+
maxValue: import_zod41.z.union([import_zod41.z.number(), import_zod41.z.null().transform(() => 15)]).default(15),
|
|
5688
|
+
minValue: import_zod41.z.union([import_zod41.z.number().min(0), import_zod41.z.unknown().transform(() => 0)]).default(1)
|
|
5689
|
+
}),
|
|
5690
|
+
shipping: import_zod41.z.object({
|
|
5691
|
+
amount: strictNumber.default(10),
|
|
5692
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
5693
|
+
enabled: import_zod41.z.boolean().default(true),
|
|
5694
|
+
title: import_zod41.z.string().optional().default("Shipping Fees"),
|
|
5695
|
+
type: import_zod41.z.enum(["free", "fixed_amount"]).default("free")
|
|
5696
|
+
}),
|
|
5697
|
+
styles: import_zod41.z.object({
|
|
5698
|
+
starColor: import_zod41.z.string().optional().default("#fadb14"),
|
|
5699
|
+
starSize: import_zod41.z.union([import_zod41.z.enum(["small", "medium", "large"]), import_zod41.z.unknown().transform(() => "large")]).optional().default("large"),
|
|
5700
|
+
starStrokeColor: import_zod41.z.string().optional().default("#fadb14"),
|
|
5701
|
+
strokeWidth: import_zod41.z.string().optional().default("1")
|
|
5702
|
+
}).optional(),
|
|
5703
|
+
subImages: import_zod41.z.number().nullish().default(8),
|
|
5704
|
+
subscription: import_zod41.z.object({
|
|
5705
|
+
discount: import_zod41.z.object({
|
|
5706
|
+
amount: strictNumber.default(30),
|
|
5707
|
+
shouldShowSavingText: import_zod41.z.boolean().optional().default(true),
|
|
5708
|
+
type: import_zod41.z.enum(["none", "fixed_amount", "percentage"]).default("none")
|
|
5709
|
+
}),
|
|
5710
|
+
shipping: import_zod41.z.object({
|
|
5711
|
+
amount: strictNumber.default(1),
|
|
5712
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
5713
|
+
enabled: import_zod41.z.boolean().default(true),
|
|
5714
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
5715
|
+
recurringAmount: strictNumber.default(2),
|
|
5716
|
+
shippingTitle: import_zod41.z.string().default("Shipping Fees"),
|
|
5717
|
+
type: import_zod41.z.enum(["free", "fixed_amount"]).default("free")
|
|
5718
|
+
})
|
|
5719
|
+
}).optional().default({
|
|
5720
|
+
discount: {
|
|
5721
|
+
amount: 30,
|
|
5722
|
+
shouldShowSavingText: true,
|
|
5723
|
+
type: "none"
|
|
5724
|
+
},
|
|
5725
|
+
shipping: {
|
|
5726
|
+
amount: 1,
|
|
5727
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
5728
|
+
enabled: true,
|
|
5729
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
5730
|
+
recurringAmount: 2,
|
|
5731
|
+
shippingTitle: "Shipping Fees",
|
|
5732
|
+
type: "free"
|
|
5733
|
+
}
|
|
5734
|
+
}),
|
|
5735
|
+
subscriptionIsDefault: import_zod41.z.boolean().optional(),
|
|
5736
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
5737
|
+
template: import_zod41.z.string().optional().default(""),
|
|
5738
|
+
type: import_zod41.z.literal("shopify_post_purchase_extension").default("shopify_post_purchase_extension"),
|
|
5739
|
+
upgradeToSubscription: import_zod41.z.object({
|
|
5740
|
+
acceptButtonText: import_zod41.z.string().optional().default("Upgrade"),
|
|
5741
|
+
allow: import_zod41.z.boolean().optional().default(false),
|
|
5742
|
+
emailRefundNotice: import_zod41.z.boolean().optional().default(false),
|
|
5743
|
+
errorBannerText: import_zod41.z.string().optional().default("This subscription cannot be added - limit one per order")
|
|
5744
|
+
}).optional().default(() => ({
|
|
5745
|
+
acceptButtonText: "Upgrade",
|
|
5746
|
+
allow: false,
|
|
5747
|
+
emailRefundNotice: false,
|
|
5748
|
+
errorBannerText: "This subscription cannot be added - limit one per order"
|
|
5749
|
+
}))
|
|
5750
|
+
});
|
|
5751
|
+
|
|
5752
|
+
// src/schema/postPurchaseProductSettings.ts
|
|
5753
|
+
var amount = import_zod42.z.union([import_zod42.z.number().nonnegative(), PostPurchaseAmount.transform(Number)]);
|
|
5754
|
+
var PostPurchaseProductSettings = PostPurchaseSettings.pick({
|
|
5755
|
+
discountedFrom: true,
|
|
5756
|
+
language: true,
|
|
5757
|
+
productLimit: true,
|
|
5758
|
+
productOptions: true,
|
|
5759
|
+
productType: true,
|
|
5760
|
+
productTypeSelector: true,
|
|
5761
|
+
quantityInputs: true,
|
|
5762
|
+
subscriptionIsDefault: true,
|
|
5763
|
+
upgradeToSubscription: true
|
|
5764
|
+
}).extend({
|
|
5765
|
+
advance: import_zod42.z.unknown().default({}),
|
|
5766
|
+
blocks: import_zod42.z.array(import_zod42.z.unknown()).optional(),
|
|
5767
|
+
discount: PostPurchaseSettings.shape.discount.extend({ amount: amount.default(30) }),
|
|
5768
|
+
integrations: import_zod42.z.unknown().default({}),
|
|
5769
|
+
shipping: PostPurchaseSettings.shape.shipping.extend({ amount: amount.default(10) }),
|
|
5770
|
+
styles: import_zod42.z.unknown().default({}),
|
|
5771
|
+
subImages: PostPurchaseSettings.shape.subImages.catch(null),
|
|
5772
|
+
subscription: import_zod42.z.unknown().default(PostPurchaseSettings.shape.subscription.parse(void 0))
|
|
5773
|
+
});
|
|
5774
|
+
|
|
5775
|
+
// src/server/normalizePostPurchaseProduct.ts
|
|
5776
|
+
var normalizePostPurchaseProduct = (settings, response) => {
|
|
5777
|
+
const original = PostPurchaseProductSettings.parse(deepCamelCase(settings));
|
|
5778
|
+
const { data, metadata } = PostPurchaseProductSource.parse(deepCamelCase(response));
|
|
5779
|
+
const overrides = Object.fromEntries(Object.entries(metadata.widget).filter(([key]) => key in original));
|
|
5780
|
+
const discount = import_zod43.z.object({ type: import_zod43.z.string() }).safeParse(overrides.discount);
|
|
5781
|
+
if (discount.success && discount.data.type === "fixed") {
|
|
5782
|
+
overrides.discount = { ...import_zod43.z.record(import_zod43.z.string(), import_zod43.z.unknown()).parse(overrides.discount), type: "fixed_amount" };
|
|
5783
|
+
}
|
|
5784
|
+
const effective = PostPurchaseProductSettings.parse((0, import_compat6.merge)({}, original, overrides));
|
|
5785
|
+
return { data, effective, metadata, original };
|
|
5786
|
+
};
|
|
5787
|
+
|
|
5788
|
+
// src/schema/postPurchasePlanCatalog.ts
|
|
5789
|
+
var import_zod46 = require("zod");
|
|
5790
|
+
|
|
5791
|
+
// src/schema/postPurchasePlanAdjustment.ts
|
|
5792
|
+
var import_zod45 = require("zod");
|
|
5793
|
+
|
|
5794
|
+
// src/schema/postPurchaseDiscount.ts
|
|
5795
|
+
var import_zod44 = require("zod");
|
|
5796
|
+
var Discount = import_zod44.z.object({
|
|
5797
|
+
amount: import_zod44.z.number().nonnegative(),
|
|
5798
|
+
title: import_zod44.z.string(),
|
|
5799
|
+
type: import_zod44.z.enum(["none", "fixed_amount", "percentage"])
|
|
5800
|
+
});
|
|
5801
|
+
var validPostPurchaseDiscount = (discount) => discount.type !== "percentage" || discount.amount <= 100;
|
|
5802
|
+
var PostPurchaseDiscount = Discount.refine(validPostPurchaseDiscount);
|
|
5803
|
+
|
|
5804
|
+
// src/schema/postPurchasePlanAdjustment.ts
|
|
5805
|
+
var PostPurchasePlanAdjustment = import_zod45.z.object({
|
|
5806
|
+
amount: PostPurchaseDiscount.shape.amount,
|
|
5807
|
+
type: import_zod45.z.enum(["percentage", "fixed_amount", "price"])
|
|
5808
|
+
}).refine(({ amount: amount2, type }) => type === "price" || validPostPurchaseDiscount({ amount: amount2, type }));
|
|
5809
|
+
|
|
5810
|
+
// src/schema/postPurchasePlanCatalog.ts
|
|
5811
|
+
var PostPurchasePlanOption = import_zod46.z.object({
|
|
5812
|
+
adjustment: PostPurchasePlanAdjustment.optional(),
|
|
5813
|
+
id: import_zod46.z.number().int().positive(),
|
|
5814
|
+
intervalFrequency: import_zod46.z.string().regex(/^[1-9]\d*$/).optional(),
|
|
5815
|
+
intervalLabel: import_zod46.z.string().min(1),
|
|
5816
|
+
name: import_zod46.z.string().min(1)
|
|
5817
|
+
});
|
|
5818
|
+
var PostPurchasePlanCatalog = import_zod46.z.object({
|
|
5819
|
+
plans: import_zod46.z.array(PostPurchasePlanOption),
|
|
5820
|
+
productId: import_zod46.z.number().int().positive(),
|
|
5821
|
+
requiresSellingPlan: import_zod46.z.boolean(),
|
|
5822
|
+
variantId: import_zod46.z.number().int().positive()
|
|
5823
|
+
});
|
|
5824
|
+
|
|
5825
|
+
// src/server/postPurchaseLegacyPlans.ts
|
|
5826
|
+
var import_zod48 = require("zod");
|
|
5827
|
+
|
|
5828
|
+
// src/server/postPurchasePlanAdjustment.ts
|
|
5829
|
+
var import_zod47 = require("zod");
|
|
5830
|
+
var SourceAdjustment = import_zod47.z.object({
|
|
5831
|
+
amount: PostPurchaseProductSettings.shape.discount.shape.amount.unwrap(),
|
|
5832
|
+
type: import_zod47.z.enum(["percentage", "fixed_amount", "amount", "price", "none", "fixed"])
|
|
5833
|
+
});
|
|
5834
|
+
var readPostPurchasePlanAdjustment = (raw) => {
|
|
5835
|
+
const source = SourceAdjustment.parse(raw);
|
|
5836
|
+
if (source.type === "none" || source.type === "fixed") {
|
|
5837
|
+
if (source.amount !== 0) throw new Error("Unsupported plan adjustment");
|
|
5838
|
+
return void 0;
|
|
5839
|
+
}
|
|
5840
|
+
const adjustment = PostPurchasePlanAdjustment.parse({
|
|
5841
|
+
amount: source.amount,
|
|
5842
|
+
type: source.type === "amount" ? "fixed_amount" : source.type
|
|
5843
|
+
});
|
|
5844
|
+
return adjustment.amount === 0 && adjustment.type !== "price" ? void 0 : adjustment;
|
|
5845
|
+
};
|
|
5846
|
+
|
|
5847
|
+
// src/server/postPurchaseLegacyPlans.ts
|
|
5848
|
+
var Plan = PostPurchasePlanOption.pick({ id: true, name: true }).extend({
|
|
5849
|
+
orderIntervalFrequency: PostPurchasePlanOption.shape.intervalFrequency.unwrap(),
|
|
5850
|
+
orderIntervalUnitType: PostPurchasePlanOption.shape.intervalLabel,
|
|
5851
|
+
shopifyVariantId: import_zod48.z.string().regex(/^[1-9]\d*$/).nullish()
|
|
5852
|
+
});
|
|
5853
|
+
var Group = import_zod48.z.object({
|
|
5854
|
+
discountAmount: import_zod48.z.unknown(),
|
|
5855
|
+
discountType: import_zod48.z.unknown(),
|
|
5856
|
+
id: import_zod48.z.number().int().positive(),
|
|
5857
|
+
sellingPlans: import_zod48.z.array(import_zod48.z.object({ shopifyVariantId: Plan.shape.shopifyVariantId }).passthrough())
|
|
5858
|
+
});
|
|
5859
|
+
var readPostPurchaseLegacyPlans = (raw, variantId) => {
|
|
5860
|
+
const group = Group.pick({ id: true, sellingPlans: true }).parse(raw);
|
|
5861
|
+
const rows = group.sellingPlans.filter((row) => row.shopifyVariantId === String(variantId));
|
|
5862
|
+
if (!rows.length) return [];
|
|
5863
|
+
const terms = Group.parse(raw);
|
|
5864
|
+
const adjustment = readPostPurchasePlanAdjustment({ amount: terms.discountAmount, type: terms.discountType });
|
|
5865
|
+
return rows.map((row) => {
|
|
5866
|
+
const plan = Plan.parse(row);
|
|
5867
|
+
return {
|
|
5868
|
+
...adjustment ? { adjustment } : {},
|
|
5869
|
+
id: plan.id,
|
|
5870
|
+
intervalFrequency: plan.orderIntervalFrequency,
|
|
5871
|
+
intervalLabel: plan.orderIntervalUnitType,
|
|
5872
|
+
name: plan.name
|
|
5873
|
+
};
|
|
5874
|
+
});
|
|
5875
|
+
};
|
|
5876
|
+
|
|
5877
|
+
// src/server/postPurchaseModernPlans.ts
|
|
5878
|
+
var import_zod49 = require("zod");
|
|
5879
|
+
var Groups = import_zod49.z.array(
|
|
5880
|
+
import_zod49.z.object({
|
|
5881
|
+
id: import_zod49.z.string().min(1),
|
|
5882
|
+
sellingPlans: import_zod49.z.unknown()
|
|
5883
|
+
})
|
|
5884
|
+
);
|
|
5885
|
+
var Allocations = import_zod49.z.array(import_zod49.z.object({ sellingPlanGroupId: import_zod49.z.string().min(1) })).default([]);
|
|
5886
|
+
var Plans = import_zod49.z.array(
|
|
5887
|
+
PostPurchasePlanOption.pick({ id: true, name: true }).extend({
|
|
5888
|
+
options: import_zod49.z.array(import_zod49.z.object({ value: import_zod49.z.string().min(1) })).min(1),
|
|
5889
|
+
priceAdjustments: import_zod49.z.array(import_zod49.z.unknown())
|
|
5890
|
+
})
|
|
5891
|
+
);
|
|
5892
|
+
var FirstAdjustment = import_zod49.z.object({
|
|
5893
|
+
value: PostPurchaseProductSettings.shape.discount.shape.amount.unwrap(),
|
|
5894
|
+
valueType: PostPurchasePlanAdjustment.shape.type
|
|
5895
|
+
});
|
|
5896
|
+
var readPostPurchaseModernPlans = (raw, allocations) => {
|
|
5897
|
+
const groups = Groups.parse(raw);
|
|
5898
|
+
const memberships = Allocations.parse(allocations);
|
|
5899
|
+
return groups.filter((group) => memberships.some((entry) => entry.sellingPlanGroupId === group.id)).flatMap(
|
|
5900
|
+
(group) => Plans.parse(group.sellingPlans).map((plan) => {
|
|
5901
|
+
const first = plan.priceAdjustments.length ? FirstAdjustment.parse(plan.priceAdjustments[0]) : void 0;
|
|
5902
|
+
const adjustment = first && readPostPurchasePlanAdjustment({ amount: first.value, type: first.valueType });
|
|
5903
|
+
return {
|
|
5904
|
+
...adjustment ? { adjustment } : {},
|
|
5905
|
+
id: plan.id,
|
|
5906
|
+
intervalLabel: plan.options[0].value,
|
|
5907
|
+
name: plan.name
|
|
5908
|
+
};
|
|
5909
|
+
})
|
|
5910
|
+
);
|
|
5911
|
+
};
|
|
5912
|
+
|
|
5913
|
+
// src/server/postPurchasePlanCatalog.ts
|
|
5914
|
+
var projectPostPurchasePlanCatalog = (normalized, report) => {
|
|
5915
|
+
try {
|
|
5916
|
+
const { data } = normalized;
|
|
5917
|
+
if (data.length !== 1 || data[0].variants.length !== 1) throw new Error("Ambiguous product");
|
|
5918
|
+
const product = data[0];
|
|
5919
|
+
const variant = product.variants[0];
|
|
5920
|
+
if (variant.productId !== product.id) throw new Error("Foreign variant");
|
|
5921
|
+
const groups = product.sellingPlanGroups;
|
|
5922
|
+
const required = groups.map((group) => group.requiresSellingPlan);
|
|
5923
|
+
if (required.some((flag) => flag !== required[0])) throw new Error("Conflicting requirement");
|
|
5924
|
+
const plans = typeof groups[0]?.id === "number" ? readPostPurchaseLegacyPlans(groups[0], variant.id) : readPostPurchaseModernPlans(groups, variant.sellingPlanAllocations);
|
|
5925
|
+
const unique = /* @__PURE__ */ new Map();
|
|
5926
|
+
for (const plan of plans) {
|
|
5927
|
+
const previous = unique.get(plan.id);
|
|
5928
|
+
if (previous && JSON.stringify(previous) !== JSON.stringify(plan)) throw new Error("Conflicting plan");
|
|
5929
|
+
unique.set(plan.id, plan);
|
|
5930
|
+
}
|
|
5931
|
+
return PostPurchasePlanCatalog.parse({
|
|
5932
|
+
plans: [...unique.values()],
|
|
5933
|
+
productId: product.id,
|
|
5934
|
+
requiresSellingPlan: required[0] ?? false,
|
|
5935
|
+
variantId: variant.id
|
|
5936
|
+
});
|
|
5937
|
+
} catch {
|
|
5938
|
+
report?.({ detail: "Unreadable post-purchase plan catalog", kind: "product" });
|
|
5939
|
+
return null;
|
|
5940
|
+
}
|
|
5941
|
+
};
|
|
5942
|
+
|
|
5943
|
+
// src/schema/postPurchaseSubscriptionProduct.ts
|
|
5944
|
+
var import_zod54 = require("zod");
|
|
5945
|
+
|
|
5946
|
+
// src/schema/postPurchaseProduct.ts
|
|
5947
|
+
var import_zod53 = require("zod");
|
|
5948
|
+
|
|
5949
|
+
// src/schema/postPurchaseProductDisplay.ts
|
|
5950
|
+
var import_zod51 = require("zod");
|
|
5951
|
+
|
|
5952
|
+
// src/schema/postPurchaseProductGallery.ts
|
|
5953
|
+
var import_zod50 = require("zod");
|
|
5954
|
+
var PostPurchaseProductGallery = import_zod50.z.object({
|
|
5955
|
+
images: import_zod50.z.array(
|
|
5956
|
+
import_zod50.z.object({
|
|
5957
|
+
description: import_zod50.z.string(),
|
|
5958
|
+
id: import_zod50.z.number().int().positive(),
|
|
5959
|
+
source: import_zod50.z.string(),
|
|
5960
|
+
thumbnail: import_zod50.z.string()
|
|
5961
|
+
})
|
|
5962
|
+
),
|
|
5963
|
+
selectedImageId: import_zod50.z.number().int().positive().optional()
|
|
5964
|
+
});
|
|
5965
|
+
|
|
5966
|
+
// src/schema/postPurchaseProductDisplay.ts
|
|
5967
|
+
var language = PostPurchaseSettings.shape.language;
|
|
5968
|
+
var PostPurchasePrimaryImageSource = import_zod51.z.string().default(
|
|
5969
|
+
"https://cdn.shopify.com/shopifycloud/shopify/assets/no-image-2048-5e88c1b20e087fb7bbe9a3771824e743c244f437e4f8ba93bbf7b11b53f7824c.gif"
|
|
5970
|
+
);
|
|
5971
|
+
var PostPurchaseProductDisplay = import_zod51.z.object({
|
|
5972
|
+
discountedFrom: PostPurchaseSettings.shape.discountedFrom,
|
|
5973
|
+
gallery: PostPurchaseProductGallery.optional(),
|
|
5974
|
+
language: language.pick({
|
|
5975
|
+
description: true,
|
|
5976
|
+
descriptionEnabled: true,
|
|
5977
|
+
descriptionRte: true,
|
|
5978
|
+
descriptionSpacing: true
|
|
5979
|
+
}),
|
|
5980
|
+
primaryImage: import_zod51.z.object({ description: import_zod51.z.string(), source: import_zod51.z.string() }),
|
|
5981
|
+
productOptions: PostPurchaseSettings.shape.productOptions.pick({
|
|
5982
|
+
showDeclineAll: true,
|
|
5983
|
+
showShipping: true,
|
|
5984
|
+
showSubtotal: true,
|
|
5985
|
+
showTaxes: true,
|
|
5986
|
+
showTotal: true,
|
|
5987
|
+
showVariantSelectors: true
|
|
5988
|
+
}),
|
|
5989
|
+
responseDescription: language.shape.description,
|
|
5990
|
+
shouldShowSavingText: PostPurchaseSettings.shape.discount.shape.shouldShowSavingText
|
|
5991
|
+
});
|
|
5992
|
+
|
|
5993
|
+
// src/schema/postPurchaseSubscription.ts
|
|
5994
|
+
var import_zod52 = require("zod");
|
|
5995
|
+
var PostPurchaseSubscriptionTerms = import_zod52.z.object({
|
|
5996
|
+
adjustment: PostPurchasePlanAdjustment.optional(),
|
|
5997
|
+
initialShippingPrice: import_zod52.z.number().nonnegative(),
|
|
5998
|
+
intervalLabel: import_zod52.z.string().min(1),
|
|
5999
|
+
name: import_zod52.z.string().min(1),
|
|
6000
|
+
recurringShippingPrice: import_zod52.z.number().nonnegative(),
|
|
6001
|
+
shippingOption: import_zod52.z.object({ presentmentTitle: import_zod52.z.string(), title: import_zod52.z.string() })
|
|
6002
|
+
});
|
|
6003
|
+
|
|
6004
|
+
// src/schema/postPurchaseProduct.ts
|
|
6005
|
+
var global = PostPurchaseSettings.shape.language.shape.global.unwrap().unwrap().shape;
|
|
6006
|
+
var PostPurchaseVariant = OfferProduct.shape.variants.element.pick({ id: true, title: true }).extend({
|
|
6007
|
+
compareAtPrice: PostPurchaseAmount.nullable(),
|
|
6008
|
+
id: PostPurchaseVariantId,
|
|
6009
|
+
price: PostPurchaseAmount
|
|
6010
|
+
});
|
|
6011
|
+
var PreparedPostPurchaseProduct = import_zod53.z.object({
|
|
6012
|
+
display: PostPurchaseProductDisplay,
|
|
6013
|
+
labels: import_zod53.z.object({
|
|
6014
|
+
declineAll: global.declineAll,
|
|
6015
|
+
free: import_zod53.z.string(),
|
|
6016
|
+
payNow: import_zod53.z.string(),
|
|
6017
|
+
quantity: import_zod53.z.string(),
|
|
6018
|
+
recurringShipping: global.recurringShipping,
|
|
6019
|
+
recurringSubtotal: global.recurringSubtotal,
|
|
6020
|
+
save: import_zod53.z.string(),
|
|
6021
|
+
shipping: import_zod53.z.string(),
|
|
6022
|
+
subtotal: import_zod53.z.string(),
|
|
6023
|
+
taxes: import_zod53.z.string(),
|
|
6024
|
+
total: import_zod53.z.string()
|
|
6025
|
+
}),
|
|
6026
|
+
product: OfferProduct.pick({ description: true, id: true, image: true, title: true }).extend({
|
|
6027
|
+
description: OfferProduct.shape.description.nullable(),
|
|
6028
|
+
id: PostPurchaseProductId,
|
|
6029
|
+
variant: PostPurchaseVariant
|
|
6030
|
+
}),
|
|
6031
|
+
selection: import_zod53.z.object({
|
|
6032
|
+
productId: PostPurchaseProductId,
|
|
6033
|
+
quantity: import_zod53.z.number().int().positive(),
|
|
6034
|
+
sellingPlanId: import_zod53.z.number().int().positive().optional(),
|
|
6035
|
+
variantId: PostPurchaseVariantId
|
|
6036
|
+
}),
|
|
6037
|
+
status: import_zod53.z.literal("prepared"),
|
|
6038
|
+
terms: import_zod53.z.object({
|
|
6039
|
+
discount: PostPurchaseDiscount,
|
|
6040
|
+
shipping: import_zod53.z.object({
|
|
6041
|
+
amount: import_zod53.z.number().nonnegative(),
|
|
6042
|
+
title: import_zod53.z.string(),
|
|
6043
|
+
type: import_zod53.z.enum(["free", "fixed_amount"])
|
|
6044
|
+
}),
|
|
6045
|
+
subscription: PostPurchaseSubscriptionTerms.optional()
|
|
6046
|
+
})
|
|
6047
|
+
});
|
|
6048
|
+
var PostPurchasePreparation = import_zod53.z.discriminatedUnion("status", [
|
|
6049
|
+
PreparedPostPurchaseProduct,
|
|
6050
|
+
import_zod53.z.object({ reason: import_zod53.z.string(), status: import_zod53.z.literal("unsupported") })
|
|
6051
|
+
]);
|
|
6052
|
+
|
|
6053
|
+
// src/schema/postPurchaseSubscriptionProduct.ts
|
|
6054
|
+
var PreparedPostPurchaseSubscription = PreparedPostPurchaseProduct.extend({
|
|
6055
|
+
selection: PreparedPostPurchaseProduct.shape.selection.extend({ sellingPlanId: import_zod54.z.number().int().positive() }),
|
|
6056
|
+
terms: PreparedPostPurchaseProduct.shape.terms.extend({
|
|
6057
|
+
subscription: PostPurchaseSubscriptionTerms
|
|
6058
|
+
}).refine(
|
|
6059
|
+
({ discount, shipping, subscription: subscription2 }) => (discount.type !== "none" || discount.amount === 0) && shipping.amount === subscription2.initialShippingPrice && shipping.amount === subscription2.recurringShippingPrice && (shipping.type !== "free" || shipping.amount === 0)
|
|
6060
|
+
)
|
|
6061
|
+
});
|
|
6062
|
+
|
|
6063
|
+
// src/schema/postPurchaseSubscriptionSettings.ts
|
|
6064
|
+
var subscription = PostPurchaseSettings.shape.subscription.unwrap().unwrap();
|
|
6065
|
+
var PostPurchaseSubscriptionSettings = subscription.extend({
|
|
6066
|
+
discount: subscription.shape.discount.extend({
|
|
6067
|
+
amount: PostPurchaseProductSettings.shape.discount.shape.amount.unwrap().default(subscription.shape.discount.shape.amount.parse(void 0))
|
|
6068
|
+
}).refine(validPostPurchaseDiscount),
|
|
6069
|
+
shipping: subscription.shape.shipping.extend({
|
|
6070
|
+
amount: PostPurchaseProductSettings.shape.shipping.shape.amount.unwrap().default(subscription.shape.shipping.shape.amount.parse(void 0))
|
|
6071
|
+
})
|
|
6072
|
+
});
|
|
6073
|
+
|
|
6074
|
+
// src/server/postPurchaseVariantAvailable.ts
|
|
6075
|
+
var postPurchaseVariantAvailable = (variant) => !(variant.inventoryManagement && variant.inventoryPolicy === "deny" && variant.inventoryQuantity <= 0);
|
|
6076
|
+
|
|
6077
|
+
// src/server/postPurchaseSubscriptionEligibility.ts
|
|
6078
|
+
var subscriptionUnavailable = (normalized, plan, allowCollection, quantity) => {
|
|
6079
|
+
const { data, effective, original } = normalized;
|
|
6080
|
+
const unavailable = "An eligible subscription plan with supported shipping and discount is required";
|
|
6081
|
+
if (data.length !== 1 || data[0].variants.length !== 1) return unavailable;
|
|
6082
|
+
if (effective.productType === "one-time" || [original, effective].some(
|
|
6083
|
+
(config) => !allowCollection && config.productLimit !== 1 || config.upgradeToSubscription.allow || !quantity && config.quantityInputs.enabled && (config.quantityInputs.minValue !== config.quantityInputs.maxValue || config.quantityInputs.defaultQuantity !== config.quantityInputs.minValue)
|
|
6084
|
+
))
|
|
6085
|
+
return unavailable;
|
|
6086
|
+
const product = data[0];
|
|
6087
|
+
const variant = product.variants[0];
|
|
6088
|
+
if (product.productGroupVariants.length || !postPurchaseVariantAvailable(variant) || variant.productId !== product.id)
|
|
6089
|
+
return unavailable;
|
|
6090
|
+
const terms = [original, effective].map(
|
|
6091
|
+
(config) => PostPurchaseSubscriptionSettings.safeParse(config.subscription)
|
|
6092
|
+
);
|
|
6093
|
+
if (!plan || terms.some((term) => !term.success)) return unavailable;
|
|
6094
|
+
};
|
|
6095
|
+
|
|
6096
|
+
// src/server/postPurchaseProductDisplay.ts
|
|
6097
|
+
var import_zod55 = require("zod");
|
|
6098
|
+
|
|
6099
|
+
// src/server/postPurchasePrimaryImage.ts
|
|
6100
|
+
var postPurchasePrimaryImage = (product) => {
|
|
6101
|
+
const variantImageId = product.variants[0].imageId;
|
|
6102
|
+
const selectedImage = variantImageId ? product.images?.find((image) => image.id === variantImageId) : void 0;
|
|
6103
|
+
const source = PostPurchasePrimaryImageSource.parse((selectedImage ?? product.image)?.src || void 0);
|
|
6104
|
+
return { description: product.title, source: sizeImageSource(source, "800x800") };
|
|
6105
|
+
};
|
|
6106
|
+
|
|
6107
|
+
// src/server/postPurchaseProductGallery.ts
|
|
6108
|
+
var postPurchaseProductGallery = (product, limit) => ({
|
|
6109
|
+
images: (product.images ?? []).slice(0, limit ?? 0).map((image) => ({
|
|
6110
|
+
description: image.alt ?? product.title,
|
|
6111
|
+
id: image.id,
|
|
6112
|
+
source: sizeImageSource(image.src, "800x800"),
|
|
6113
|
+
thumbnail: sizeImageSource(image.src, "200x200")
|
|
6114
|
+
})),
|
|
6115
|
+
selectedImageId: product.images?.find((image) => image.id === product.variants[0].imageId)?.id
|
|
6116
|
+
});
|
|
6117
|
+
|
|
6118
|
+
// src/server/postPurchaseProductDisplay.ts
|
|
6119
|
+
var ResponseLanguage = import_zod55.z.object({ description: PostPurchaseProductDisplay.shape.responseDescription }).default({ description: "" });
|
|
6120
|
+
var projectPostPurchaseProductDisplay = (effective, metadata, product) => PostPurchaseProductDisplay.parse({
|
|
6121
|
+
discountedFrom: effective.discountedFrom,
|
|
6122
|
+
gallery: postPurchaseProductGallery(product, effective.subImages),
|
|
6123
|
+
language: effective.language,
|
|
6124
|
+
primaryImage: postPurchasePrimaryImage(product),
|
|
6125
|
+
productOptions: effective.productOptions,
|
|
6126
|
+
responseDescription: ResponseLanguage.parse(metadata.widget.language).description,
|
|
6127
|
+
shouldShowSavingText: effective.discount.shouldShowSavingText
|
|
6128
|
+
});
|
|
6129
|
+
|
|
6130
|
+
// src/server/projectPostPurchaseProduct.ts
|
|
6131
|
+
var projectPostPurchaseProduct = ({ data, effective, metadata, original }, selectedQuantity) => {
|
|
6132
|
+
const product = data[0];
|
|
6133
|
+
const variant = product.variants[0];
|
|
6134
|
+
return {
|
|
6135
|
+
display: projectPostPurchaseProductDisplay(effective, metadata, product),
|
|
6136
|
+
labels: effective.language.global,
|
|
6137
|
+
product: { ...product, variant },
|
|
6138
|
+
selection: {
|
|
6139
|
+
productId: product.id,
|
|
6140
|
+
quantity: selectedQuantity?.quantity ?? product.metadata?.productQuantity ?? (original.quantityInputs.enabled ? original.quantityInputs.defaultQuantity : 1),
|
|
6141
|
+
variantId: variant.id
|
|
6142
|
+
}
|
|
6143
|
+
};
|
|
6144
|
+
};
|
|
6145
|
+
|
|
6146
|
+
// src/server/prepareNormalizedSubscription.ts
|
|
6147
|
+
var prepareNormalizedSubscription = (normalized, report, plan, quantity, allowCollection = false) => {
|
|
6148
|
+
if (!plan) return { reason: "Subscription plan is unavailable", status: "unsupported" };
|
|
6149
|
+
const reason = subscriptionUnavailable(normalized, plan, allowCollection, quantity);
|
|
6150
|
+
if (reason) return { reason, status: "unsupported" };
|
|
6151
|
+
const { effective } = normalized;
|
|
6152
|
+
const projected = projectPostPurchaseProduct(normalized, quantity);
|
|
6153
|
+
const { discount, shipping } = PostPurchaseSubscriptionSettings.parse(effective.subscription);
|
|
6154
|
+
const shippingPrice = shipping.type === "free" ? 0 : shipping.amount;
|
|
6155
|
+
return PreparedPostPurchaseSubscription.parse({
|
|
6156
|
+
...projected,
|
|
6157
|
+
display: { ...projected.display, shouldShowSavingText: discount.shouldShowSavingText },
|
|
6158
|
+
selection: { ...projected.selection, sellingPlanId: plan.id },
|
|
6159
|
+
status: "prepared",
|
|
6160
|
+
terms: {
|
|
6161
|
+
discount: {
|
|
6162
|
+
amount: discount.type === "none" ? 0 : discount.amount,
|
|
6163
|
+
title: effective.language.global.save,
|
|
6164
|
+
type: discount.type
|
|
6165
|
+
},
|
|
6166
|
+
shipping: { amount: shippingPrice, title: "Subscription shipping line", type: shipping.type },
|
|
6167
|
+
subscription: {
|
|
6168
|
+
...plan.adjustment ? { adjustment: plan.adjustment } : {},
|
|
6169
|
+
initialShippingPrice: shippingPrice,
|
|
6170
|
+
intervalLabel: plan.intervalLabel,
|
|
6171
|
+
name: plan.name,
|
|
6172
|
+
recurringShippingPrice: shippingPrice,
|
|
6173
|
+
shippingOption: { presentmentTitle: "Subscription shipping line", title: "Subscription shipping line" }
|
|
6174
|
+
}
|
|
6175
|
+
}
|
|
6176
|
+
});
|
|
6177
|
+
};
|
|
6178
|
+
|
|
6179
|
+
// src/server/preparePostPurchaseSubscription.ts
|
|
6180
|
+
var preparePostPurchaseSubscription = (settings, response, report) => {
|
|
6181
|
+
const normalized = normalizePostPurchaseProduct(settings, response);
|
|
6182
|
+
return prepareNormalizedSubscription(
|
|
6183
|
+
normalized,
|
|
6184
|
+
report,
|
|
6185
|
+
projectPostPurchasePlanCatalog(normalized, report)?.plans[0]
|
|
6186
|
+
);
|
|
6187
|
+
};
|
|
6188
|
+
|
|
5505
6189
|
// src/server/analytics.ts
|
|
5506
6190
|
var import_es_toolkit7 = require("es-toolkit");
|
|
5507
6191
|
|
|
@@ -5638,7 +6322,7 @@ var postAnalyticsEvents = async (input, ctx) => {
|
|
|
5638
6322
|
};
|
|
5639
6323
|
|
|
5640
6324
|
// src/server/requestSchemas.ts
|
|
5641
|
-
var
|
|
6325
|
+
var import_zod56 = require("zod");
|
|
5642
6326
|
var REQUEST_BOUNDS = {
|
|
5643
6327
|
/** Cart-level attributes per cart. */
|
|
5644
6328
|
CART_ATTRIBUTES_MAX: 100,
|
|
@@ -5669,42 +6353,42 @@ var REQUEST_BOUNDS = {
|
|
|
5669
6353
|
/** Rich ads transaction lines — the engine's ads contract. */
|
|
5670
6354
|
TRANSACTION_ITEMS_MAX: 50
|
|
5671
6355
|
};
|
|
5672
|
-
var KeyValue =
|
|
5673
|
-
key:
|
|
5674
|
-
value:
|
|
6356
|
+
var KeyValue = import_zod56.z.object({
|
|
6357
|
+
key: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_KEY_MAX),
|
|
6358
|
+
value: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_VALUE_MAX).optional()
|
|
5675
6359
|
});
|
|
5676
|
-
var CartLineInputSchema =
|
|
5677
|
-
productId:
|
|
5678
|
-
properties:
|
|
5679
|
-
quantity:
|
|
5680
|
-
subscriptionId:
|
|
5681
|
-
variantId:
|
|
6360
|
+
var CartLineInputSchema = import_zod56.z.object({
|
|
6361
|
+
productId: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
6362
|
+
properties: import_zod56.z.array(KeyValue).max(REQUEST_BOUNDS.LINE_PROPERTIES_MAX).optional(),
|
|
6363
|
+
quantity: import_zod56.z.number(),
|
|
6364
|
+
subscriptionId: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
6365
|
+
variantId: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX)
|
|
5682
6366
|
});
|
|
5683
|
-
var CartInputSchema =
|
|
5684
|
-
attributes:
|
|
6367
|
+
var CartInputSchema = import_zod56.z.object({
|
|
6368
|
+
attributes: import_zod56.z.array(KeyValue).max(REQUEST_BOUNDS.CART_ATTRIBUTES_MAX).optional(),
|
|
5685
6369
|
/**
|
|
5686
6370
|
* Presentment-per-shop-currency FX rate (buyer price ÷ shop price, e.g. `1.35` for a USD shop
|
|
5687
6371
|
* selling in CAD). Money rule thresholds are authored in SHOP currency, so the engine subtotal is
|
|
5688
6372
|
* divided by this before evaluation. Omit (or send 1) when the cart is already in the shop's currency.
|
|
5689
6373
|
*/
|
|
5690
|
-
currencyRate:
|
|
6374
|
+
currencyRate: import_zod56.z.number().optional(),
|
|
5691
6375
|
/** Applied discount codes; the engine evaluates `discount_code` rules against them (sent as `[{code}]`). */
|
|
5692
|
-
discountCodes:
|
|
6376
|
+
discountCodes: import_zod56.z.array(import_zod56.z.string().max(REQUEST_BOUNDS.STRING_KEY_MAX)).max(REQUEST_BOUNDS.DISCOUNT_CODES_MAX).optional(),
|
|
5693
6377
|
/** Presentment cents of cart-level discount allocations, subtracted from `subtotal` for the engine. */
|
|
5694
|
-
discountTotal:
|
|
5695
|
-
items:
|
|
6378
|
+
discountTotal: import_zod56.z.number().optional(),
|
|
6379
|
+
items: import_zod56.z.array(CartLineInputSchema).max(REQUEST_BOUNDS.CART_ITEMS_MAX),
|
|
5696
6380
|
/** Presentment subtotal in cents. */
|
|
5697
|
-
subtotal:
|
|
6381
|
+
subtotal: import_zod56.z.number()
|
|
5698
6382
|
});
|
|
5699
|
-
var UserConfigInputSchema =
|
|
5700
|
-
var DataSourceInputSchema =
|
|
6383
|
+
var UserConfigInputSchema = import_zod56.z.object({ shop: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX) });
|
|
6384
|
+
var DataSourceInputSchema = import_zod56.z.object({
|
|
5701
6385
|
cart: CartInputSchema,
|
|
5702
6386
|
/**
|
|
5703
6387
|
* Numeric Shopify company-location id when the buyer is a B2B session (`buyerIdentity.purchasingCompany`).
|
|
5704
6388
|
* Present ⇒ the orchestrator filters results by the location's catalog via admin-api (REB-23713); the
|
|
5705
6389
|
* client's country-context market check is bypassed for B2B (it false-negatives B2B-catalog products).
|
|
5706
6390
|
*/
|
|
5707
|
-
companyLocationId:
|
|
6391
|
+
companyLocationId: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5708
6392
|
/**
|
|
5709
6393
|
* Buyer's market country (ISO 3166-1 alpha-2) — forwarded to the engine as the `country_code` PARAM
|
|
5710
6394
|
* when the shop's markets toggle is on (REB-21688; the sink was the `X-Country-Code` header under
|
|
@@ -5713,16 +6397,16 @@ var DataSourceInputSchema = import_zod39.z.object({
|
|
|
5713
6397
|
* uppercase (the wire value is forwarded verbatim as the param) so a case-sensitive engine lookup
|
|
5714
6398
|
* can't silently miss a lowercase code — `adsEngine.ts` uppercases for the same reason.
|
|
5715
6399
|
*/
|
|
5716
|
-
country:
|
|
5717
|
-
customerId:
|
|
5718
|
-
dataSourcePath:
|
|
6400
|
+
country: import_zod56.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(),
|
|
6401
|
+
customerId: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
6402
|
+
dataSourcePath: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_KEY_MAX),
|
|
5719
6403
|
/**
|
|
5720
6404
|
* Engine `filter_inputs` override: `'no'` keeps in-cart (input) products in the results/rule
|
|
5721
6405
|
* outputs — gift validation sends it so a gift's own product can appear in its answer. Omitted = the
|
|
5722
6406
|
* engine's default filtering.
|
|
5723
6407
|
*/
|
|
5724
|
-
filterInputs:
|
|
5725
|
-
integrations:
|
|
6408
|
+
filterInputs: import_zod56.z.enum(["no", "yes"]).optional(),
|
|
6409
|
+
integrations: import_zod56.z.record(import_zod56.z.string().max(REQUEST_BOUNDS.STRING_KEY_MAX), import_zod56.z.boolean()).refine((record) => Object.keys(record).length <= REQUEST_BOUNDS.INTEGRATION_KEYS_MAX, {
|
|
5726
6410
|
message: `Too many integration keys (max ${REQUEST_BOUNDS.INTEGRATION_KEYS_MAX})`
|
|
5727
6411
|
}).optional(),
|
|
5728
6412
|
/**
|
|
@@ -5735,31 +6419,31 @@ var DataSourceInputSchema = import_zod39.z.object({
|
|
|
5735
6419
|
* request header) fails the regex. Callers should send the buyer's resolved locale (e.g. Shopify
|
|
5736
6420
|
* checkout's `localization.language.isoCode`), not the request header verbatim.
|
|
5737
6421
|
*/
|
|
5738
|
-
language:
|
|
5739
|
-
limit:
|
|
5740
|
-
productType:
|
|
5741
|
-
shop:
|
|
5742
|
-
visitorId:
|
|
5743
|
-
});
|
|
5744
|
-
var GiftInputSchema =
|
|
5745
|
-
cost:
|
|
5746
|
-
discounted:
|
|
6422
|
+
language: import_zod56.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(),
|
|
6423
|
+
limit: import_zod56.z.number().max(REQUEST_BOUNDS.LIMIT_MAX),
|
|
6424
|
+
productType: import_zod56.z.enum(["both", "one-time", "subscription"]).optional(),
|
|
6425
|
+
shop: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
6426
|
+
visitorId: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
6427
|
+
});
|
|
6428
|
+
var GiftInputSchema = import_zod56.z.object({
|
|
6429
|
+
cost: import_zod56.z.number(),
|
|
6430
|
+
discounted: import_zod56.z.boolean(),
|
|
5747
6431
|
/**
|
|
5748
6432
|
* Which gift attribution the line carries (REB-24363). Defaults to `gwp` because a client that predates
|
|
5749
6433
|
* the field only ever sent GWP lines — without the default an older extension's request would 422.
|
|
5750
6434
|
*/
|
|
5751
|
-
kind:
|
|
5752
|
-
lineId:
|
|
5753
|
-
productId:
|
|
6435
|
+
kind: import_zod56.z.enum(GIFT_KINDS).default("gwp"),
|
|
6436
|
+
lineId: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
6437
|
+
productId: import_zod56.z.number(),
|
|
5754
6438
|
/**
|
|
5755
6439
|
* The line's unit count (REB-24363) — the selectable-GWP verdict trims surplus units against milestone
|
|
5756
6440
|
* capacity. The second deliberate default: a client predating the field sent only GWP lines, whose
|
|
5757
6441
|
* verdict is whole-line, so a missing quantity reads as one unit rather than 422ing the older request.
|
|
5758
6442
|
*/
|
|
5759
|
-
quantity:
|
|
5760
|
-
widgetId:
|
|
6443
|
+
quantity: import_zod56.z.number().int().min(1).default(1),
|
|
6444
|
+
widgetId: import_zod56.z.number()
|
|
5761
6445
|
});
|
|
5762
|
-
var GiftValidationInputSchema =
|
|
6446
|
+
var GiftValidationInputSchema = import_zod56.z.object({
|
|
5763
6447
|
cart: CartInputSchema,
|
|
5764
6448
|
/**
|
|
5765
6449
|
* Buyer's market country — threaded into the per-widget data-source evaluations, which forward it to
|
|
@@ -5768,25 +6452,25 @@ var GiftValidationInputSchema = import_zod39.z.object({
|
|
|
5768
6452
|
* turns markets off); regex-bound and uppercase-normalized for the same reasons as
|
|
5769
6453
|
* `DataSourceInputSchema`'s `country`.
|
|
5770
6454
|
*/
|
|
5771
|
-
country:
|
|
5772
|
-
customerId:
|
|
5773
|
-
gifts:
|
|
6455
|
+
country: import_zod56.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(),
|
|
6456
|
+
customerId: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
6457
|
+
gifts: import_zod56.z.array(GiftInputSchema).max(REQUEST_BOUNDS.GIFTS_MAX),
|
|
5774
6458
|
/**
|
|
5775
6459
|
* Buyer's checkout language — threaded into the per-widget data-source evaluations, which normalize
|
|
5776
6460
|
* and forward it as the engine `locale` param under the same markets-toggle gate (REB-21688). MUST be
|
|
5777
6461
|
* a single BCP-47 tag, for the same reason as `DataSourceInputSchema`'s `language` above.
|
|
5778
6462
|
*/
|
|
5779
|
-
language:
|
|
5780
|
-
shop:
|
|
5781
|
-
visitorId:
|
|
6463
|
+
language: import_zod56.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(),
|
|
6464
|
+
shop: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
6465
|
+
visitorId: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
5782
6466
|
});
|
|
5783
|
-
var GiftAdjustmentSchema =
|
|
5784
|
-
lineId:
|
|
5785
|
-
quantity:
|
|
6467
|
+
var GiftAdjustmentSchema = import_zod56.z.object({
|
|
6468
|
+
lineId: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
6469
|
+
quantity: import_zod56.z.number().int().nonnegative()
|
|
5786
6470
|
});
|
|
5787
|
-
var GiftValidationResponseSchema =
|
|
5788
|
-
adjust:
|
|
5789
|
-
remove:
|
|
6471
|
+
var GiftValidationResponseSchema = import_zod56.z.object({
|
|
6472
|
+
adjust: import_zod56.z.array(GiftAdjustmentSchema).max(REQUEST_BOUNDS.GIFTS_MAX).default([]),
|
|
6473
|
+
remove: import_zod56.z.array(import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX)).max(REQUEST_BOUNDS.GIFTS_MAX).refine(
|
|
5790
6474
|
(remove) => new Set(remove).size === remove.length,
|
|
5791
6475
|
"a line id may appear at most once in `remove`"
|
|
5792
6476
|
)
|
|
@@ -5797,47 +6481,47 @@ var GiftValidationResponseSchema = import_zod39.z.object({
|
|
|
5797
6481
|
({ adjust }) => new Set(adjust.map(({ lineId }) => lineId)).size === adjust.length,
|
|
5798
6482
|
"a line id may appear at most once in `adjust`"
|
|
5799
6483
|
);
|
|
5800
|
-
var MonetizeTransactionItemSchema =
|
|
5801
|
-
id:
|
|
5802
|
-
priceCents:
|
|
5803
|
-
quantity:
|
|
5804
|
-
title:
|
|
5805
|
-
type:
|
|
5806
|
-
});
|
|
5807
|
-
var MonetizeInputSchema =
|
|
6484
|
+
var MonetizeTransactionItemSchema = import_zod56.z.object({
|
|
6485
|
+
id: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
6486
|
+
priceCents: import_zod56.z.number(),
|
|
6487
|
+
quantity: import_zod56.z.number(),
|
|
6488
|
+
title: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX),
|
|
6489
|
+
type: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX)
|
|
6490
|
+
});
|
|
6491
|
+
var MonetizeInputSchema = import_zod56.z.object({
|
|
5808
6492
|
cart: CartInputSchema,
|
|
5809
6493
|
/** Client-minted render-beacon correlation id; forwarded to the ads engine as `client_request_id`. */
|
|
5810
|
-
clientRequestId:
|
|
5811
|
-
country:
|
|
5812
|
-
currency:
|
|
6494
|
+
clientRequestId: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
6495
|
+
country: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
6496
|
+
currency: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5813
6497
|
/** Ads-targeting identity/geo/locale fields (React parity); folded into the engine query verbatim. */
|
|
5814
|
-
customerEmail:
|
|
5815
|
-
customerFirstName:
|
|
5816
|
-
customerId:
|
|
5817
|
-
customerLastName:
|
|
5818
|
-
language:
|
|
6498
|
+
customerEmail: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX).optional(),
|
|
6499
|
+
customerFirstName: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX).optional(),
|
|
6500
|
+
customerId: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
6501
|
+
customerLastName: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX).optional(),
|
|
6502
|
+
language: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5819
6503
|
/** Buyer-facing order name (e.g. `#1001`) for the server-composed "Order … Confirmed" chrome line. */
|
|
5820
|
-
orderName:
|
|
6504
|
+
orderName: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX).optional(),
|
|
5821
6505
|
/** Ads surface label, forwarded verbatim; `customer_account` is measured/floored as its own surface (the account-area order list). */
|
|
5822
|
-
placement:
|
|
6506
|
+
placement: import_zod56.z.enum(["customer_account", "order_status", "thank_you_page"]),
|
|
5823
6507
|
/** Privacy Policy footer href — the Monetize widget's `privacy_policy_url` setting (React parity). */
|
|
5824
|
-
privacyPolicyUrl:
|
|
6508
|
+
privacyPolicyUrl: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_URL_MAX).optional(),
|
|
5825
6509
|
/** 30-min rolling session id (React parity); used for the ads `session_id`, else the visitor id. */
|
|
5826
|
-
sessionId:
|
|
5827
|
-
shop:
|
|
6510
|
+
sessionId: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
6511
|
+
shop: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
5828
6512
|
/** Editor/QA indicator; OR-ed into the ads-engine `testing` flag so it stays out of billing/reporting. */
|
|
5829
|
-
testing:
|
|
5830
|
-
timezone:
|
|
6513
|
+
testing: import_zod56.z.boolean().optional(),
|
|
6514
|
+
timezone: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5831
6515
|
/** Decorated (numeric) order id → the ads `transaction_id`. */
|
|
5832
|
-
transactionId:
|
|
6516
|
+
transactionId: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5833
6517
|
/** Rich per-line ads items; capped at the engine's ads contract. Preferred over `cart.items`. */
|
|
5834
|
-
transactionItems:
|
|
6518
|
+
transactionItems: import_zod56.z.array(MonetizeTransactionItemSchema).max(REQUEST_BOUNDS.TRANSACTION_ITEMS_MAX).optional(),
|
|
5835
6519
|
/** Order total in presentment cents (React prefers total over subtotal); else `cart.subtotal`. */
|
|
5836
|
-
transactionTotal:
|
|
5837
|
-
visitorId:
|
|
5838
|
-
zipCode:
|
|
6520
|
+
transactionTotal: import_zod56.z.number().optional(),
|
|
6521
|
+
visitorId: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
6522
|
+
zipCode: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
5839
6523
|
});
|
|
5840
|
-
var WidgetSettingsInputSchema =
|
|
6524
|
+
var WidgetSettingsInputSchema = import_zod56.z.object({
|
|
5841
6525
|
/**
|
|
5842
6526
|
* Same domain as `CabShopConfig.cacheKey`, for the same reason: this side WINS the orchestrator's
|
|
5843
6527
|
* `input.cacheKey ?? config.shop.cacheKey` (and an explicit value skips the config read entirely), so
|
|
@@ -5845,9 +6529,9 @@ var WidgetSettingsInputSchema = import_zod39.z.object({
|
|
|
5845
6529
|
* and pin the edge copy permanently stale. `.catch(undefined)` because a bogus buster should degrade
|
|
5846
6530
|
* the read to un-busted, never 400 a widget render.
|
|
5847
6531
|
*/
|
|
5848
|
-
cacheKey:
|
|
5849
|
-
id:
|
|
5850
|
-
key:
|
|
6532
|
+
cacheKey: import_zod56.z.number().int().positive().optional().catch(void 0),
|
|
6533
|
+
id: import_zod56.z.number(),
|
|
6534
|
+
key: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5851
6535
|
/**
|
|
5852
6536
|
* Monetize context for inline hydration: when present AND the widget converts to a Monetize marker,
|
|
5853
6537
|
* the server fetches/composes the offer cards inside this same request (no second `/cab/monetize`
|
|
@@ -5856,34 +6540,34 @@ var WidgetSettingsInputSchema = import_zod39.z.object({
|
|
|
5856
6540
|
* `privacyPolicyUrl` comes from the widget settings server-side (more authoritative than a relay).
|
|
5857
6541
|
*/
|
|
5858
6542
|
monetize: MonetizeInputSchema.omit({ privacyPolicyUrl: true, shop: true }).optional(),
|
|
5859
|
-
shop:
|
|
6543
|
+
shop: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
5860
6544
|
/** Stable per-buyer id; when present, enables sticky server-side A/B variant selection. */
|
|
5861
|
-
visitorId:
|
|
6545
|
+
visitorId: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
5862
6546
|
});
|
|
5863
|
-
var AnalyticsEventInputSchema =
|
|
5864
|
-
name:
|
|
5865
|
-
properties:
|
|
5866
|
-
sentAt:
|
|
6547
|
+
var AnalyticsEventInputSchema = import_zod56.z.object({
|
|
6548
|
+
name: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_KEY_MAX),
|
|
6549
|
+
properties: import_zod56.z.record(import_zod56.z.string().max(REQUEST_BOUNDS.STRING_KEY_MAX), import_zod56.z.unknown()).optional(),
|
|
6550
|
+
sentAt: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
5867
6551
|
});
|
|
5868
|
-
var AnalyticsSegmentsInputSchema =
|
|
5869
|
-
device:
|
|
5870
|
-
source:
|
|
5871
|
-
visitor:
|
|
6552
|
+
var AnalyticsSegmentsInputSchema = import_zod56.z.object({
|
|
6553
|
+
device: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional().catch(void 0),
|
|
6554
|
+
source: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional().catch(void 0),
|
|
6555
|
+
visitor: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional().catch(void 0)
|
|
5872
6556
|
});
|
|
5873
|
-
var AnalyticsInputSchema =
|
|
6557
|
+
var AnalyticsInputSchema = import_zod56.z.object({
|
|
5874
6558
|
/** Rebuy cart token (the `r_cart_token` cart attribute), when available — primary aggregation key. */
|
|
5875
|
-
cartToken:
|
|
6559
|
+
cartToken: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5876
6560
|
/** Shopify checkout token, when available — drives cart/checkout aggregation downstream. */
|
|
5877
|
-
checkoutToken:
|
|
5878
|
-
events:
|
|
6561
|
+
checkoutToken: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
6562
|
+
events: import_zod56.z.array(AnalyticsEventInputSchema).max(REQUEST_BOUNDS.EVENTS_MAX),
|
|
5879
6563
|
/**
|
|
5880
6564
|
* Request-scoped like the tokens: one visitor's segments apply to every event in the batch. The container
|
|
5881
6565
|
* degrades too (`null` is a realistic wire artifact of `attributes ? {…} : null`), so the degrade rule is
|
|
5882
6566
|
* total: nothing about `segments` can cost the envelope.
|
|
5883
6567
|
*/
|
|
5884
6568
|
segments: AnalyticsSegmentsInputSchema.optional().catch(void 0),
|
|
5885
|
-
shop:
|
|
5886
|
-
visitorId:
|
|
6569
|
+
shop: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
6570
|
+
visitorId: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
5887
6571
|
/** The widget id (smartBlockId) the events belong to. */
|
|
5888
|
-
widgetId:
|
|
6572
|
+
widgetId: import_zod56.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
5889
6573
|
});
|