@rebuy/rebuy 3.32.0 → 3.33.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 +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.mjs
CHANGED
|
@@ -2213,10 +2213,10 @@ var HEADER_PARAGRAPH_STYLES = {
|
|
|
2213
2213
|
superTitle: { color: "base", fontSize: "extraLarge", marks: [{ type: "bold" }] },
|
|
2214
2214
|
title: { color: "base", fontSize: "medium", marks: [{ type: "bold" }] }
|
|
2215
2215
|
};
|
|
2216
|
-
var convertContentBlockTextToV2 = (
|
|
2217
|
-
const description =
|
|
2218
|
-
const superTitle =
|
|
2219
|
-
const title =
|
|
2216
|
+
var convertContentBlockTextToV2 = (language2, text2 = literalText, textAlign = "center") => {
|
|
2217
|
+
const description = language2?.description;
|
|
2218
|
+
const superTitle = language2?.superTitle;
|
|
2219
|
+
const title = language2?.title;
|
|
2220
2220
|
return TiptapDocument.parse({
|
|
2221
2221
|
attrs: { blockSpacing: "tight" },
|
|
2222
2222
|
content: [
|
|
@@ -2328,7 +2328,7 @@ var LOCATION_TO_EDITOR_MODE = {
|
|
|
2328
2328
|
};
|
|
2329
2329
|
|
|
2330
2330
|
// src/transforms/contentBlockV1/convertContentBlockToV2.ts
|
|
2331
|
-
var hasText = (
|
|
2331
|
+
var hasText = (language2) => !!language2 && !!(language2.description || language2.superTitle || language2.title);
|
|
2332
2332
|
var convertContentBlockToV2 = ({ id, settings }) => {
|
|
2333
2333
|
const imageBlocks = settings.imageBlocks ?? [];
|
|
2334
2334
|
return CABRootSection.parse({
|
|
@@ -3371,7 +3371,7 @@ var buildQuantity = (settings) => {
|
|
|
3371
3371
|
};
|
|
3372
3372
|
var buildSubscriptionButton = (settings) => {
|
|
3373
3373
|
if (settings.productType !== "both" && settings.productType !== "subscription") return [];
|
|
3374
|
-
const
|
|
3374
|
+
const language2 = settings.language;
|
|
3375
3375
|
const slot = (buttonField, override) => ({
|
|
3376
3376
|
buttonField,
|
|
3377
3377
|
content: localizedContent(SWITCH_LABELS[buttonField], override, SWITCH_LABEL_TOKENS2),
|
|
@@ -3385,9 +3385,9 @@ var buildSubscriptionButton = (settings) => {
|
|
|
3385
3385
|
...settings.productType === "subscription" && { disableDowngrade: true },
|
|
3386
3386
|
sections: [
|
|
3387
3387
|
slot("subscriptionOption", void 0),
|
|
3388
|
-
slot("switchToOneTimePurchase",
|
|
3389
|
-
slot("switchToSubscriptionNoDiscount",
|
|
3390
|
-
slot("switchToSubscriptionWithDiscount",
|
|
3388
|
+
slot("switchToOneTimePurchase", language2?.cartSwitchToOnetime),
|
|
3389
|
+
slot("switchToSubscriptionNoDiscount", language2?.upgradeToSubscription),
|
|
3390
|
+
slot("switchToSubscriptionWithDiscount", language2?.upgradeToSubscription)
|
|
3391
3391
|
],
|
|
3392
3392
|
sectionType: "button"
|
|
3393
3393
|
}
|
|
@@ -3443,10 +3443,10 @@ var buildOfferCard = (settings, horizontal) => {
|
|
|
3443
3443
|
const reviews = buildReviews(settings);
|
|
3444
3444
|
const variants = buildVariants(settings);
|
|
3445
3445
|
const quantity = buildQuantity(settings);
|
|
3446
|
-
const
|
|
3446
|
+
const subscription2 = buildSubscriptionButton(settings);
|
|
3447
3447
|
const reveal = buildRevealButton(settings);
|
|
3448
3448
|
const addButton = buildAddButton(settings);
|
|
3449
|
-
const controls = [...description, ...quantity, ...variants, ...
|
|
3449
|
+
const controls = [...description, ...quantity, ...variants, ...subscription2];
|
|
3450
3450
|
const info = detailBlock([title, ...variantTitle, ...reviews, price], horizontal, variantTitle.length > 0);
|
|
3451
3451
|
const card = (sections) => [
|
|
3452
3452
|
{
|
|
@@ -3500,9 +3500,9 @@ var buildCarouselNav = () => ({
|
|
|
3500
3500
|
sectionType: "layout"
|
|
3501
3501
|
});
|
|
3502
3502
|
var HEADER_FIELDS = ["superTitle", "title", "description"];
|
|
3503
|
-
var sanitizedHeader = (
|
|
3503
|
+
var sanitizedHeader = (language2) => Object.fromEntries(
|
|
3504
3504
|
HEADER_FIELDS.flatMap((field) => {
|
|
3505
|
-
const value =
|
|
3505
|
+
const value = language2?.[field];
|
|
3506
3506
|
const sanitized = value ? stripContentBlockHtml(normalizeTokens(value)) : "";
|
|
3507
3507
|
return sanitized ? [[field, sanitized]] : [];
|
|
3508
3508
|
})
|
|
@@ -3599,7 +3599,7 @@ var coerceIntegrations = (integrations) => Object.fromEntries(
|
|
|
3599
3599
|
return [key, value];
|
|
3600
3600
|
})
|
|
3601
3601
|
);
|
|
3602
|
-
var buildBanner = (
|
|
3602
|
+
var buildBanner = (language2) => language2?.successBannerEnabled ? [
|
|
3603
3603
|
{
|
|
3604
3604
|
/**
|
|
3605
3605
|
* The banner-level tag is the extraction/routing key on BOTH renderers (React CAB's
|
|
@@ -3612,7 +3612,7 @@ var buildBanner = (language) => language?.successBannerEnabled ? [
|
|
|
3612
3612
|
dismissible: true,
|
|
3613
3613
|
sections: [
|
|
3614
3614
|
{
|
|
3615
|
-
content: bannerMessageContent(
|
|
3615
|
+
content: bannerMessageContent(language2.successBannerMessageRte),
|
|
3616
3616
|
sectionType: "text"
|
|
3617
3617
|
},
|
|
3618
3618
|
{
|
|
@@ -4446,8 +4446,8 @@ var tierLabel = (tier) => {
|
|
|
4446
4446
|
};
|
|
4447
4447
|
var discountOf = (tier) => {
|
|
4448
4448
|
if (tier.type !== "discount") return void 0;
|
|
4449
|
-
const
|
|
4450
|
-
return tier.discountType === "fixedAmount" ? { amount: Math.round(
|
|
4449
|
+
const amount2 = tier.discountAmountFromTotal ?? 0;
|
|
4450
|
+
return tier.discountType === "fixedAmount" ? { amount: Math.round(amount2 * 100), type: "fixedAmount" } : { amount: amount2, type: "percentage" };
|
|
4451
4451
|
};
|
|
4452
4452
|
var iconSizeOf = (tier) => {
|
|
4453
4453
|
const px = Math.round(Number.parseFloat(String(tier.productTierElementSize ?? "")));
|
|
@@ -5451,6 +5451,689 @@ var validateGifts = async (input, ctx) => {
|
|
|
5451
5451
|
return { adjust: [...targets].map(([lineId, quantity]) => ({ lineId, quantity })), remove: [...removed] };
|
|
5452
5452
|
};
|
|
5453
5453
|
|
|
5454
|
+
// src/server/normalizePostPurchaseProduct.ts
|
|
5455
|
+
import { merge } from "es-toolkit/compat";
|
|
5456
|
+
import { z as z43 } from "zod";
|
|
5457
|
+
|
|
5458
|
+
// src/schema/postPurchaseProductSettings.ts
|
|
5459
|
+
import { z as z42 } from "zod";
|
|
5460
|
+
|
|
5461
|
+
// src/schema/postPurchaseProductSource.ts
|
|
5462
|
+
import { z as z39 } from "zod";
|
|
5463
|
+
var PostPurchaseAmount = z39.string().regex(/^\d+(?:\.\d+)?$/).refine((value) => Number.isFinite(Number(value)));
|
|
5464
|
+
var PostPurchaseProductId = z39.number().int().positive();
|
|
5465
|
+
var PostPurchaseVariantId = z39.number().int().positive();
|
|
5466
|
+
var ProductBase = OfferProduct.pick({ description: true, id: true, image: true, title: true }).extend({
|
|
5467
|
+
description: OfferProduct.shape.description.nullable(),
|
|
5468
|
+
id: PostPurchaseProductId
|
|
5469
|
+
});
|
|
5470
|
+
var SourceVariant = OfferProduct.shape.variants.element.pick({ id: true, title: true }).extend({
|
|
5471
|
+
compareAtPrice: PostPurchaseAmount.nullable(),
|
|
5472
|
+
id: PostPurchaseVariantId,
|
|
5473
|
+
imageId: z39.number().int().nonnegative().nullish(),
|
|
5474
|
+
inventoryManagement: z39.string().nullable(),
|
|
5475
|
+
inventoryPolicy: z39.string(),
|
|
5476
|
+
inventoryQuantity: z39.number(),
|
|
5477
|
+
option1: z39.unknown().optional(),
|
|
5478
|
+
option2: z39.unknown().optional(),
|
|
5479
|
+
option3: z39.unknown().optional(),
|
|
5480
|
+
price: PostPurchaseAmount,
|
|
5481
|
+
productId: PostPurchaseProductId,
|
|
5482
|
+
sellingPlanAllocations: z39.unknown().optional()
|
|
5483
|
+
});
|
|
5484
|
+
var Product2 = ProductBase.extend({
|
|
5485
|
+
images: z39.array(
|
|
5486
|
+
z39.object({ alt: z39.string().optional().catch(void 0), id: z39.number().int().positive(), src: z39.string() })
|
|
5487
|
+
).nullish(),
|
|
5488
|
+
metadata: z39.object({
|
|
5489
|
+
productQuantity: z39.union([
|
|
5490
|
+
z39.number().int().positive(),
|
|
5491
|
+
z39.string().regex(/^[1-9]\d*$/).transform(Number)
|
|
5492
|
+
]).optional()
|
|
5493
|
+
}).optional(),
|
|
5494
|
+
metafields: z39.unknown().optional(),
|
|
5495
|
+
options: z39.unknown().optional(),
|
|
5496
|
+
productGroupVariants: z39.array(z39.unknown()).default([]),
|
|
5497
|
+
selectedVariant: z39.unknown().optional(),
|
|
5498
|
+
sellingPlanGroups: z39.array(
|
|
5499
|
+
OfferProduct.shape.sellingPlanGroups.unwrap().element.extend({
|
|
5500
|
+
discountAmount: z39.unknown().optional(),
|
|
5501
|
+
discountType: z39.unknown().optional(),
|
|
5502
|
+
id: z39.unknown().optional(),
|
|
5503
|
+
requiresSellingPlan: z39.boolean().default(false),
|
|
5504
|
+
sellingPlans: z39.unknown().optional()
|
|
5505
|
+
})
|
|
5506
|
+
).default([]),
|
|
5507
|
+
variants: z39.array(SourceVariant)
|
|
5508
|
+
});
|
|
5509
|
+
var PostPurchaseProductSource = z39.object({
|
|
5510
|
+
data: z39.array(Product2),
|
|
5511
|
+
metadata: z39.object({ widget: z39.record(z39.string(), z39.unknown()).default({}) }).default({ widget: {} })
|
|
5512
|
+
});
|
|
5513
|
+
|
|
5514
|
+
// src/schema/widgets/post-purchase-offer/postPurchaseSettings.ts
|
|
5515
|
+
import { z as z41 } from "zod";
|
|
5516
|
+
|
|
5517
|
+
// src/schema/widgets/post-purchase-offer/common.ts
|
|
5518
|
+
import { replace, toNumber, toString } from "es-toolkit/compat";
|
|
5519
|
+
import { z as z40 } from "zod";
|
|
5520
|
+
var strictNumber = z40.union([
|
|
5521
|
+
z40.number(),
|
|
5522
|
+
z40.string().transform((value) => toNumber(replace(toString(value), /[^0-9.]/g, "")) || 0),
|
|
5523
|
+
z40.unknown().transform(() => 0)
|
|
5524
|
+
]);
|
|
5525
|
+
|
|
5526
|
+
// src/schema/widgets/post-purchase-offer/postPurchaseSettings.ts
|
|
5527
|
+
var PostPurchaseSettings = z41.object({
|
|
5528
|
+
advance: z41.object({ removePartialOrder: z41.boolean().default(true) }).optional().default(() => ({ removePartialOrder: true })),
|
|
5529
|
+
blocks: z41.union([z41.array(PostPurchaseBlock), z41.unknown().transform(() => [])]).default(() => [
|
|
5530
|
+
PostPurchaseBlock.parse({ settings: {}, styles: {}, type: BlockType.timer }),
|
|
5531
|
+
PostPurchaseBlock.parse({ settings: {}, styles: {}, type: BlockType.callout_banner }),
|
|
5532
|
+
PostPurchaseBlock.parse({ type: BlockType.product_information })
|
|
5533
|
+
]),
|
|
5534
|
+
columnLayout: z41.boolean().optional(),
|
|
5535
|
+
discount: z41.object({
|
|
5536
|
+
amount: strictNumber.default(30),
|
|
5537
|
+
shouldShowSavingText: z41.boolean().optional().default(true),
|
|
5538
|
+
type: z41.enum(["none", "fixed_amount", "percentage"]).default("none")
|
|
5539
|
+
}),
|
|
5540
|
+
discountedFrom: z41.enum(["price", "compare_at_price"]).optional().default("price"),
|
|
5541
|
+
endpoint: z41.string().optional(),
|
|
5542
|
+
integrations: z41.object({
|
|
5543
|
+
judgeme: z41.boolean().default(false),
|
|
5544
|
+
junip: z41.boolean().optional().default(false),
|
|
5545
|
+
klaviyo: z41.boolean().default(false),
|
|
5546
|
+
loox: z41.boolean().default(false),
|
|
5547
|
+
okendo: z41.boolean().default(false),
|
|
5548
|
+
opinew: z41.boolean().optional().default(false),
|
|
5549
|
+
reviewsio: z41.boolean().optional().default(false),
|
|
5550
|
+
stamped: z41.boolean().default(false),
|
|
5551
|
+
yotpo: z41.boolean().default(false)
|
|
5552
|
+
}),
|
|
5553
|
+
key: z41.string().optional(),
|
|
5554
|
+
language: z41.object({
|
|
5555
|
+
description: z41.union([z41.string(), z41.unknown().transform(() => "")]).default(""),
|
|
5556
|
+
descriptionEnabled: z41.boolean().optional().default(false),
|
|
5557
|
+
descriptionRte: z41.object({
|
|
5558
|
+
content: z41.array(z41.unknown()),
|
|
5559
|
+
type: z41.string()
|
|
5560
|
+
}).optional(),
|
|
5561
|
+
descriptionSpacing: z41.enum(["none", "xtight", "tight", "default", "loose", "xloose"]).optional(),
|
|
5562
|
+
displayCtaPrice: z41.boolean().default(true),
|
|
5563
|
+
global: z41.object({
|
|
5564
|
+
declineAll: z41.string().optional().default("Decline All"),
|
|
5565
|
+
declineThisOffer: z41.string().default("Decline this offer"),
|
|
5566
|
+
free: z41.string().optional().default("Free"),
|
|
5567
|
+
notAvailable: z41.string().optional().default("Not available"),
|
|
5568
|
+
payNow: z41.string().default("Pay Now"),
|
|
5569
|
+
payNowUpgradeToSubscription: z41.string().optional().default("Upgrade to Subscription"),
|
|
5570
|
+
quantity: z41.string().default("Quantity"),
|
|
5571
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
5572
|
+
recurringShipping: z41.string().optional().default("Recurring shipping"),
|
|
5573
|
+
recurringSubtotal: z41.string().default("Recurring subtotal"),
|
|
5574
|
+
reviewsPlural: z41.string().optional().default("Reviews"),
|
|
5575
|
+
reviewsSingular: z41.string().optional().default("Review"),
|
|
5576
|
+
save: z41.union([z41.string(), z41.unknown().transform(() => "Save")]).optional().default("Save"),
|
|
5577
|
+
shipping: z41.string().default("Shipping"),
|
|
5578
|
+
subscriptionOption: z41.string().optional().default("Subscribe and Save"),
|
|
5579
|
+
subtotal: z41.string().default("Subtotal"),
|
|
5580
|
+
taxes: z41.string().default("Taxes"),
|
|
5581
|
+
total: z41.string().default("Total")
|
|
5582
|
+
}).optional().default(() => ({
|
|
5583
|
+
declineAll: "Decline All",
|
|
5584
|
+
declineThisOffer: "Decline this offer",
|
|
5585
|
+
free: "Free",
|
|
5586
|
+
notAvailable: "Not available",
|
|
5587
|
+
payNow: "Pay Now",
|
|
5588
|
+
payNowUpgradeToSubscription: "Upgrade to Subscription",
|
|
5589
|
+
quantity: "Quantity",
|
|
5590
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
5591
|
+
recurringShipping: "Recurring shipping",
|
|
5592
|
+
recurringSubtotal: "Recurring subtotal",
|
|
5593
|
+
reviewsPlural: "Reviews",
|
|
5594
|
+
reviewsSingular: "Review",
|
|
5595
|
+
save: "Save",
|
|
5596
|
+
shipping: "Shipping",
|
|
5597
|
+
subscriptionOption: "Subscribe and Save",
|
|
5598
|
+
subtotal: "Subtotal",
|
|
5599
|
+
taxes: "Taxes",
|
|
5600
|
+
total: "Total"
|
|
5601
|
+
})),
|
|
5602
|
+
globalTranslation: z41.string().optional().default("english")
|
|
5603
|
+
}),
|
|
5604
|
+
metafields: z41.boolean().default(false),
|
|
5605
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
5606
|
+
offer: z41.object({
|
|
5607
|
+
count: z41.number().default(1)
|
|
5608
|
+
}),
|
|
5609
|
+
offersLayout: z41.object({
|
|
5610
|
+
itemsPerPage: z41.number().optional(),
|
|
5611
|
+
type: z41.enum(["list", "grid", "carousel"]).default("list")
|
|
5612
|
+
}).optional().default({
|
|
5613
|
+
type: "list"
|
|
5614
|
+
}),
|
|
5615
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
5616
|
+
previewMode: z41.boolean().default(false),
|
|
5617
|
+
productLimit: z41.number().optional().default(1),
|
|
5618
|
+
productOptions: z41.object({
|
|
5619
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
5620
|
+
hideOutOfStockVariants: z41.boolean().optional().default(false),
|
|
5621
|
+
matchVariant: z41.boolean().optional().default(true),
|
|
5622
|
+
showDeclineAll: z41.enum(["above", "below", "both", "none"]).optional(),
|
|
5623
|
+
showShipping: z41.boolean().optional().default(true),
|
|
5624
|
+
showSubtotal: z41.boolean().optional().default(true),
|
|
5625
|
+
showTaxes: z41.boolean().optional().default(true),
|
|
5626
|
+
showTotal: z41.boolean().optional().default(true),
|
|
5627
|
+
showVariantSelectors: z41.boolean().optional().default(true),
|
|
5628
|
+
variantSelectorDisplayMode: z41.enum(["separate", "single"]).optional().default("separate")
|
|
5629
|
+
}),
|
|
5630
|
+
productType: z41.union([z41.enum(["one-time", "subscription", "both"]), z41.literal("").transform(() => "one-time")]).default("one-time"),
|
|
5631
|
+
productTypeSelector: z41.enum(["dropdown", "radio"]).optional().default("radio"),
|
|
5632
|
+
quantityInputs: z41.object({
|
|
5633
|
+
defaultQuantity: z41.union([z41.number(), z41.null().transform(() => 1)]).default(1),
|
|
5634
|
+
enabled: z41.boolean().default(true),
|
|
5635
|
+
maxValue: z41.union([z41.number(), z41.null().transform(() => 15)]).default(15),
|
|
5636
|
+
minValue: z41.union([z41.number().min(0), z41.unknown().transform(() => 0)]).default(1)
|
|
5637
|
+
}),
|
|
5638
|
+
shipping: z41.object({
|
|
5639
|
+
amount: strictNumber.default(10),
|
|
5640
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
5641
|
+
enabled: z41.boolean().default(true),
|
|
5642
|
+
title: z41.string().optional().default("Shipping Fees"),
|
|
5643
|
+
type: z41.enum(["free", "fixed_amount"]).default("free")
|
|
5644
|
+
}),
|
|
5645
|
+
styles: z41.object({
|
|
5646
|
+
starColor: z41.string().optional().default("#fadb14"),
|
|
5647
|
+
starSize: z41.union([z41.enum(["small", "medium", "large"]), z41.unknown().transform(() => "large")]).optional().default("large"),
|
|
5648
|
+
starStrokeColor: z41.string().optional().default("#fadb14"),
|
|
5649
|
+
strokeWidth: z41.string().optional().default("1")
|
|
5650
|
+
}).optional(),
|
|
5651
|
+
subImages: z41.number().nullish().default(8),
|
|
5652
|
+
subscription: z41.object({
|
|
5653
|
+
discount: z41.object({
|
|
5654
|
+
amount: strictNumber.default(30),
|
|
5655
|
+
shouldShowSavingText: z41.boolean().optional().default(true),
|
|
5656
|
+
type: z41.enum(["none", "fixed_amount", "percentage"]).default("none")
|
|
5657
|
+
}),
|
|
5658
|
+
shipping: z41.object({
|
|
5659
|
+
amount: strictNumber.default(1),
|
|
5660
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
5661
|
+
enabled: z41.boolean().default(true),
|
|
5662
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
5663
|
+
recurringAmount: strictNumber.default(2),
|
|
5664
|
+
shippingTitle: z41.string().default("Shipping Fees"),
|
|
5665
|
+
type: z41.enum(["free", "fixed_amount"]).default("free")
|
|
5666
|
+
})
|
|
5667
|
+
}).optional().default({
|
|
5668
|
+
discount: {
|
|
5669
|
+
amount: 30,
|
|
5670
|
+
shouldShowSavingText: true,
|
|
5671
|
+
type: "none"
|
|
5672
|
+
},
|
|
5673
|
+
shipping: {
|
|
5674
|
+
amount: 1,
|
|
5675
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
5676
|
+
enabled: true,
|
|
5677
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
5678
|
+
recurringAmount: 2,
|
|
5679
|
+
shippingTitle: "Shipping Fees",
|
|
5680
|
+
type: "free"
|
|
5681
|
+
}
|
|
5682
|
+
}),
|
|
5683
|
+
subscriptionIsDefault: z41.boolean().optional(),
|
|
5684
|
+
/** This isn't configurable in the admin-nextjs editor */
|
|
5685
|
+
template: z41.string().optional().default(""),
|
|
5686
|
+
type: z41.literal("shopify_post_purchase_extension").default("shopify_post_purchase_extension"),
|
|
5687
|
+
upgradeToSubscription: z41.object({
|
|
5688
|
+
acceptButtonText: z41.string().optional().default("Upgrade"),
|
|
5689
|
+
allow: z41.boolean().optional().default(false),
|
|
5690
|
+
emailRefundNotice: z41.boolean().optional().default(false),
|
|
5691
|
+
errorBannerText: z41.string().optional().default("This subscription cannot be added - limit one per order")
|
|
5692
|
+
}).optional().default(() => ({
|
|
5693
|
+
acceptButtonText: "Upgrade",
|
|
5694
|
+
allow: false,
|
|
5695
|
+
emailRefundNotice: false,
|
|
5696
|
+
errorBannerText: "This subscription cannot be added - limit one per order"
|
|
5697
|
+
}))
|
|
5698
|
+
});
|
|
5699
|
+
|
|
5700
|
+
// src/schema/postPurchaseProductSettings.ts
|
|
5701
|
+
var amount = z42.union([z42.number().nonnegative(), PostPurchaseAmount.transform(Number)]);
|
|
5702
|
+
var PostPurchaseProductSettings = PostPurchaseSettings.pick({
|
|
5703
|
+
discountedFrom: true,
|
|
5704
|
+
language: true,
|
|
5705
|
+
productLimit: true,
|
|
5706
|
+
productOptions: true,
|
|
5707
|
+
productType: true,
|
|
5708
|
+
productTypeSelector: true,
|
|
5709
|
+
quantityInputs: true,
|
|
5710
|
+
subscriptionIsDefault: true,
|
|
5711
|
+
upgradeToSubscription: true
|
|
5712
|
+
}).extend({
|
|
5713
|
+
advance: z42.unknown().default({}),
|
|
5714
|
+
blocks: z42.array(z42.unknown()).optional(),
|
|
5715
|
+
discount: PostPurchaseSettings.shape.discount.extend({ amount: amount.default(30) }),
|
|
5716
|
+
integrations: z42.unknown().default({}),
|
|
5717
|
+
shipping: PostPurchaseSettings.shape.shipping.extend({ amount: amount.default(10) }),
|
|
5718
|
+
styles: z42.unknown().default({}),
|
|
5719
|
+
subImages: PostPurchaseSettings.shape.subImages.catch(null),
|
|
5720
|
+
subscription: z42.unknown().default(PostPurchaseSettings.shape.subscription.parse(void 0))
|
|
5721
|
+
});
|
|
5722
|
+
|
|
5723
|
+
// src/server/normalizePostPurchaseProduct.ts
|
|
5724
|
+
var normalizePostPurchaseProduct = (settings, response) => {
|
|
5725
|
+
const original = PostPurchaseProductSettings.parse(deepCamelCase(settings));
|
|
5726
|
+
const { data, metadata } = PostPurchaseProductSource.parse(deepCamelCase(response));
|
|
5727
|
+
const overrides = Object.fromEntries(Object.entries(metadata.widget).filter(([key]) => key in original));
|
|
5728
|
+
const discount = z43.object({ type: z43.string() }).safeParse(overrides.discount);
|
|
5729
|
+
if (discount.success && discount.data.type === "fixed") {
|
|
5730
|
+
overrides.discount = { ...z43.record(z43.string(), z43.unknown()).parse(overrides.discount), type: "fixed_amount" };
|
|
5731
|
+
}
|
|
5732
|
+
const effective = PostPurchaseProductSettings.parse(merge({}, original, overrides));
|
|
5733
|
+
return { data, effective, metadata, original };
|
|
5734
|
+
};
|
|
5735
|
+
|
|
5736
|
+
// src/schema/postPurchasePlanCatalog.ts
|
|
5737
|
+
import { z as z46 } from "zod";
|
|
5738
|
+
|
|
5739
|
+
// src/schema/postPurchasePlanAdjustment.ts
|
|
5740
|
+
import { z as z45 } from "zod";
|
|
5741
|
+
|
|
5742
|
+
// src/schema/postPurchaseDiscount.ts
|
|
5743
|
+
import { z as z44 } from "zod";
|
|
5744
|
+
var Discount = z44.object({
|
|
5745
|
+
amount: z44.number().nonnegative(),
|
|
5746
|
+
title: z44.string(),
|
|
5747
|
+
type: z44.enum(["none", "fixed_amount", "percentage"])
|
|
5748
|
+
});
|
|
5749
|
+
var validPostPurchaseDiscount = (discount) => discount.type !== "percentage" || discount.amount <= 100;
|
|
5750
|
+
var PostPurchaseDiscount = Discount.refine(validPostPurchaseDiscount);
|
|
5751
|
+
|
|
5752
|
+
// src/schema/postPurchasePlanAdjustment.ts
|
|
5753
|
+
var PostPurchasePlanAdjustment = z45.object({
|
|
5754
|
+
amount: PostPurchaseDiscount.shape.amount,
|
|
5755
|
+
type: z45.enum(["percentage", "fixed_amount", "price"])
|
|
5756
|
+
}).refine(({ amount: amount2, type }) => type === "price" || validPostPurchaseDiscount({ amount: amount2, type }));
|
|
5757
|
+
|
|
5758
|
+
// src/schema/postPurchasePlanCatalog.ts
|
|
5759
|
+
var PostPurchasePlanOption = z46.object({
|
|
5760
|
+
adjustment: PostPurchasePlanAdjustment.optional(),
|
|
5761
|
+
id: z46.number().int().positive(),
|
|
5762
|
+
intervalFrequency: z46.string().regex(/^[1-9]\d*$/).optional(),
|
|
5763
|
+
intervalLabel: z46.string().min(1),
|
|
5764
|
+
name: z46.string().min(1)
|
|
5765
|
+
});
|
|
5766
|
+
var PostPurchasePlanCatalog = z46.object({
|
|
5767
|
+
plans: z46.array(PostPurchasePlanOption),
|
|
5768
|
+
productId: z46.number().int().positive(),
|
|
5769
|
+
requiresSellingPlan: z46.boolean(),
|
|
5770
|
+
variantId: z46.number().int().positive()
|
|
5771
|
+
});
|
|
5772
|
+
|
|
5773
|
+
// src/server/postPurchaseLegacyPlans.ts
|
|
5774
|
+
import { z as z48 } from "zod";
|
|
5775
|
+
|
|
5776
|
+
// src/server/postPurchasePlanAdjustment.ts
|
|
5777
|
+
import { z as z47 } from "zod";
|
|
5778
|
+
var SourceAdjustment = z47.object({
|
|
5779
|
+
amount: PostPurchaseProductSettings.shape.discount.shape.amount.unwrap(),
|
|
5780
|
+
type: z47.enum(["percentage", "fixed_amount", "amount", "price", "none", "fixed"])
|
|
5781
|
+
});
|
|
5782
|
+
var readPostPurchasePlanAdjustment = (raw) => {
|
|
5783
|
+
const source = SourceAdjustment.parse(raw);
|
|
5784
|
+
if (source.type === "none" || source.type === "fixed") {
|
|
5785
|
+
if (source.amount !== 0) throw new Error("Unsupported plan adjustment");
|
|
5786
|
+
return void 0;
|
|
5787
|
+
}
|
|
5788
|
+
const adjustment = PostPurchasePlanAdjustment.parse({
|
|
5789
|
+
amount: source.amount,
|
|
5790
|
+
type: source.type === "amount" ? "fixed_amount" : source.type
|
|
5791
|
+
});
|
|
5792
|
+
return adjustment.amount === 0 && adjustment.type !== "price" ? void 0 : adjustment;
|
|
5793
|
+
};
|
|
5794
|
+
|
|
5795
|
+
// src/server/postPurchaseLegacyPlans.ts
|
|
5796
|
+
var Plan = PostPurchasePlanOption.pick({ id: true, name: true }).extend({
|
|
5797
|
+
orderIntervalFrequency: PostPurchasePlanOption.shape.intervalFrequency.unwrap(),
|
|
5798
|
+
orderIntervalUnitType: PostPurchasePlanOption.shape.intervalLabel,
|
|
5799
|
+
shopifyVariantId: z48.string().regex(/^[1-9]\d*$/).nullish()
|
|
5800
|
+
});
|
|
5801
|
+
var Group = z48.object({
|
|
5802
|
+
discountAmount: z48.unknown(),
|
|
5803
|
+
discountType: z48.unknown(),
|
|
5804
|
+
id: z48.number().int().positive(),
|
|
5805
|
+
sellingPlans: z48.array(z48.object({ shopifyVariantId: Plan.shape.shopifyVariantId }).passthrough())
|
|
5806
|
+
});
|
|
5807
|
+
var readPostPurchaseLegacyPlans = (raw, variantId) => {
|
|
5808
|
+
const group = Group.pick({ id: true, sellingPlans: true }).parse(raw);
|
|
5809
|
+
const rows = group.sellingPlans.filter((row) => row.shopifyVariantId === String(variantId));
|
|
5810
|
+
if (!rows.length) return [];
|
|
5811
|
+
const terms = Group.parse(raw);
|
|
5812
|
+
const adjustment = readPostPurchasePlanAdjustment({ amount: terms.discountAmount, type: terms.discountType });
|
|
5813
|
+
return rows.map((row) => {
|
|
5814
|
+
const plan = Plan.parse(row);
|
|
5815
|
+
return {
|
|
5816
|
+
...adjustment ? { adjustment } : {},
|
|
5817
|
+
id: plan.id,
|
|
5818
|
+
intervalFrequency: plan.orderIntervalFrequency,
|
|
5819
|
+
intervalLabel: plan.orderIntervalUnitType,
|
|
5820
|
+
name: plan.name
|
|
5821
|
+
};
|
|
5822
|
+
});
|
|
5823
|
+
};
|
|
5824
|
+
|
|
5825
|
+
// src/server/postPurchaseModernPlans.ts
|
|
5826
|
+
import { z as z49 } from "zod";
|
|
5827
|
+
var Groups = z49.array(
|
|
5828
|
+
z49.object({
|
|
5829
|
+
id: z49.string().min(1),
|
|
5830
|
+
sellingPlans: z49.unknown()
|
|
5831
|
+
})
|
|
5832
|
+
);
|
|
5833
|
+
var Allocations = z49.array(z49.object({ sellingPlanGroupId: z49.string().min(1) })).default([]);
|
|
5834
|
+
var Plans = z49.array(
|
|
5835
|
+
PostPurchasePlanOption.pick({ id: true, name: true }).extend({
|
|
5836
|
+
options: z49.array(z49.object({ value: z49.string().min(1) })).min(1),
|
|
5837
|
+
priceAdjustments: z49.array(z49.unknown())
|
|
5838
|
+
})
|
|
5839
|
+
);
|
|
5840
|
+
var FirstAdjustment = z49.object({
|
|
5841
|
+
value: PostPurchaseProductSettings.shape.discount.shape.amount.unwrap(),
|
|
5842
|
+
valueType: PostPurchasePlanAdjustment.shape.type
|
|
5843
|
+
});
|
|
5844
|
+
var readPostPurchaseModernPlans = (raw, allocations) => {
|
|
5845
|
+
const groups = Groups.parse(raw);
|
|
5846
|
+
const memberships = Allocations.parse(allocations);
|
|
5847
|
+
return groups.filter((group) => memberships.some((entry) => entry.sellingPlanGroupId === group.id)).flatMap(
|
|
5848
|
+
(group) => Plans.parse(group.sellingPlans).map((plan) => {
|
|
5849
|
+
const first = plan.priceAdjustments.length ? FirstAdjustment.parse(plan.priceAdjustments[0]) : void 0;
|
|
5850
|
+
const adjustment = first && readPostPurchasePlanAdjustment({ amount: first.value, type: first.valueType });
|
|
5851
|
+
return {
|
|
5852
|
+
...adjustment ? { adjustment } : {},
|
|
5853
|
+
id: plan.id,
|
|
5854
|
+
intervalLabel: plan.options[0].value,
|
|
5855
|
+
name: plan.name
|
|
5856
|
+
};
|
|
5857
|
+
})
|
|
5858
|
+
);
|
|
5859
|
+
};
|
|
5860
|
+
|
|
5861
|
+
// src/server/postPurchasePlanCatalog.ts
|
|
5862
|
+
var projectPostPurchasePlanCatalog = (normalized, report) => {
|
|
5863
|
+
try {
|
|
5864
|
+
const { data } = normalized;
|
|
5865
|
+
if (data.length !== 1 || data[0].variants.length !== 1) throw new Error("Ambiguous product");
|
|
5866
|
+
const product = data[0];
|
|
5867
|
+
const variant = product.variants[0];
|
|
5868
|
+
if (variant.productId !== product.id) throw new Error("Foreign variant");
|
|
5869
|
+
const groups = product.sellingPlanGroups;
|
|
5870
|
+
const required = groups.map((group) => group.requiresSellingPlan);
|
|
5871
|
+
if (required.some((flag) => flag !== required[0])) throw new Error("Conflicting requirement");
|
|
5872
|
+
const plans = typeof groups[0]?.id === "number" ? readPostPurchaseLegacyPlans(groups[0], variant.id) : readPostPurchaseModernPlans(groups, variant.sellingPlanAllocations);
|
|
5873
|
+
const unique = /* @__PURE__ */ new Map();
|
|
5874
|
+
for (const plan of plans) {
|
|
5875
|
+
const previous = unique.get(plan.id);
|
|
5876
|
+
if (previous && JSON.stringify(previous) !== JSON.stringify(plan)) throw new Error("Conflicting plan");
|
|
5877
|
+
unique.set(plan.id, plan);
|
|
5878
|
+
}
|
|
5879
|
+
return PostPurchasePlanCatalog.parse({
|
|
5880
|
+
plans: [...unique.values()],
|
|
5881
|
+
productId: product.id,
|
|
5882
|
+
requiresSellingPlan: required[0] ?? false,
|
|
5883
|
+
variantId: variant.id
|
|
5884
|
+
});
|
|
5885
|
+
} catch {
|
|
5886
|
+
report?.({ detail: "Unreadable post-purchase plan catalog", kind: "product" });
|
|
5887
|
+
return null;
|
|
5888
|
+
}
|
|
5889
|
+
};
|
|
5890
|
+
|
|
5891
|
+
// src/schema/postPurchaseSubscriptionProduct.ts
|
|
5892
|
+
import { z as z54 } from "zod";
|
|
5893
|
+
|
|
5894
|
+
// src/schema/postPurchaseProduct.ts
|
|
5895
|
+
import { z as z53 } from "zod";
|
|
5896
|
+
|
|
5897
|
+
// src/schema/postPurchaseProductDisplay.ts
|
|
5898
|
+
import { z as z51 } from "zod";
|
|
5899
|
+
|
|
5900
|
+
// src/schema/postPurchaseProductGallery.ts
|
|
5901
|
+
import { z as z50 } from "zod";
|
|
5902
|
+
var PostPurchaseProductGallery = z50.object({
|
|
5903
|
+
images: z50.array(
|
|
5904
|
+
z50.object({
|
|
5905
|
+
description: z50.string(),
|
|
5906
|
+
id: z50.number().int().positive(),
|
|
5907
|
+
source: z50.string(),
|
|
5908
|
+
thumbnail: z50.string()
|
|
5909
|
+
})
|
|
5910
|
+
),
|
|
5911
|
+
selectedImageId: z50.number().int().positive().optional()
|
|
5912
|
+
});
|
|
5913
|
+
|
|
5914
|
+
// src/schema/postPurchaseProductDisplay.ts
|
|
5915
|
+
var language = PostPurchaseSettings.shape.language;
|
|
5916
|
+
var PostPurchasePrimaryImageSource = z51.string().default(
|
|
5917
|
+
"https://cdn.shopify.com/shopifycloud/shopify/assets/no-image-2048-5e88c1b20e087fb7bbe9a3771824e743c244f437e4f8ba93bbf7b11b53f7824c.gif"
|
|
5918
|
+
);
|
|
5919
|
+
var PostPurchaseProductDisplay = z51.object({
|
|
5920
|
+
discountedFrom: PostPurchaseSettings.shape.discountedFrom,
|
|
5921
|
+
gallery: PostPurchaseProductGallery.optional(),
|
|
5922
|
+
language: language.pick({
|
|
5923
|
+
description: true,
|
|
5924
|
+
descriptionEnabled: true,
|
|
5925
|
+
descriptionRte: true,
|
|
5926
|
+
descriptionSpacing: true
|
|
5927
|
+
}),
|
|
5928
|
+
primaryImage: z51.object({ description: z51.string(), source: z51.string() }),
|
|
5929
|
+
productOptions: PostPurchaseSettings.shape.productOptions.pick({
|
|
5930
|
+
showDeclineAll: true,
|
|
5931
|
+
showShipping: true,
|
|
5932
|
+
showSubtotal: true,
|
|
5933
|
+
showTaxes: true,
|
|
5934
|
+
showTotal: true,
|
|
5935
|
+
showVariantSelectors: true
|
|
5936
|
+
}),
|
|
5937
|
+
responseDescription: language.shape.description,
|
|
5938
|
+
shouldShowSavingText: PostPurchaseSettings.shape.discount.shape.shouldShowSavingText
|
|
5939
|
+
});
|
|
5940
|
+
|
|
5941
|
+
// src/schema/postPurchaseSubscription.ts
|
|
5942
|
+
import { z as z52 } from "zod";
|
|
5943
|
+
var PostPurchaseSubscriptionTerms = z52.object({
|
|
5944
|
+
adjustment: PostPurchasePlanAdjustment.optional(),
|
|
5945
|
+
initialShippingPrice: z52.number().nonnegative(),
|
|
5946
|
+
intervalLabel: z52.string().min(1),
|
|
5947
|
+
name: z52.string().min(1),
|
|
5948
|
+
recurringShippingPrice: z52.number().nonnegative(),
|
|
5949
|
+
shippingOption: z52.object({ presentmentTitle: z52.string(), title: z52.string() })
|
|
5950
|
+
});
|
|
5951
|
+
|
|
5952
|
+
// src/schema/postPurchaseProduct.ts
|
|
5953
|
+
var global = PostPurchaseSettings.shape.language.shape.global.unwrap().unwrap().shape;
|
|
5954
|
+
var PostPurchaseVariant = OfferProduct.shape.variants.element.pick({ id: true, title: true }).extend({
|
|
5955
|
+
compareAtPrice: PostPurchaseAmount.nullable(),
|
|
5956
|
+
id: PostPurchaseVariantId,
|
|
5957
|
+
price: PostPurchaseAmount
|
|
5958
|
+
});
|
|
5959
|
+
var PreparedPostPurchaseProduct = z53.object({
|
|
5960
|
+
display: PostPurchaseProductDisplay,
|
|
5961
|
+
labels: z53.object({
|
|
5962
|
+
declineAll: global.declineAll,
|
|
5963
|
+
free: z53.string(),
|
|
5964
|
+
payNow: z53.string(),
|
|
5965
|
+
quantity: z53.string(),
|
|
5966
|
+
recurringShipping: global.recurringShipping,
|
|
5967
|
+
recurringSubtotal: global.recurringSubtotal,
|
|
5968
|
+
save: z53.string(),
|
|
5969
|
+
shipping: z53.string(),
|
|
5970
|
+
subtotal: z53.string(),
|
|
5971
|
+
taxes: z53.string(),
|
|
5972
|
+
total: z53.string()
|
|
5973
|
+
}),
|
|
5974
|
+
product: OfferProduct.pick({ description: true, id: true, image: true, title: true }).extend({
|
|
5975
|
+
description: OfferProduct.shape.description.nullable(),
|
|
5976
|
+
id: PostPurchaseProductId,
|
|
5977
|
+
variant: PostPurchaseVariant
|
|
5978
|
+
}),
|
|
5979
|
+
selection: z53.object({
|
|
5980
|
+
productId: PostPurchaseProductId,
|
|
5981
|
+
quantity: z53.number().int().positive(),
|
|
5982
|
+
sellingPlanId: z53.number().int().positive().optional(),
|
|
5983
|
+
variantId: PostPurchaseVariantId
|
|
5984
|
+
}),
|
|
5985
|
+
status: z53.literal("prepared"),
|
|
5986
|
+
terms: z53.object({
|
|
5987
|
+
discount: PostPurchaseDiscount,
|
|
5988
|
+
shipping: z53.object({
|
|
5989
|
+
amount: z53.number().nonnegative(),
|
|
5990
|
+
title: z53.string(),
|
|
5991
|
+
type: z53.enum(["free", "fixed_amount"])
|
|
5992
|
+
}),
|
|
5993
|
+
subscription: PostPurchaseSubscriptionTerms.optional()
|
|
5994
|
+
})
|
|
5995
|
+
});
|
|
5996
|
+
var PostPurchasePreparation = z53.discriminatedUnion("status", [
|
|
5997
|
+
PreparedPostPurchaseProduct,
|
|
5998
|
+
z53.object({ reason: z53.string(), status: z53.literal("unsupported") })
|
|
5999
|
+
]);
|
|
6000
|
+
|
|
6001
|
+
// src/schema/postPurchaseSubscriptionProduct.ts
|
|
6002
|
+
var PreparedPostPurchaseSubscription = PreparedPostPurchaseProduct.extend({
|
|
6003
|
+
selection: PreparedPostPurchaseProduct.shape.selection.extend({ sellingPlanId: z54.number().int().positive() }),
|
|
6004
|
+
terms: PreparedPostPurchaseProduct.shape.terms.extend({
|
|
6005
|
+
subscription: PostPurchaseSubscriptionTerms
|
|
6006
|
+
}).refine(
|
|
6007
|
+
({ discount, shipping, subscription: subscription2 }) => (discount.type !== "none" || discount.amount === 0) && shipping.amount === subscription2.initialShippingPrice && shipping.amount === subscription2.recurringShippingPrice && (shipping.type !== "free" || shipping.amount === 0)
|
|
6008
|
+
)
|
|
6009
|
+
});
|
|
6010
|
+
|
|
6011
|
+
// src/schema/postPurchaseSubscriptionSettings.ts
|
|
6012
|
+
var subscription = PostPurchaseSettings.shape.subscription.unwrap().unwrap();
|
|
6013
|
+
var PostPurchaseSubscriptionSettings = subscription.extend({
|
|
6014
|
+
discount: subscription.shape.discount.extend({
|
|
6015
|
+
amount: PostPurchaseProductSettings.shape.discount.shape.amount.unwrap().default(subscription.shape.discount.shape.amount.parse(void 0))
|
|
6016
|
+
}).refine(validPostPurchaseDiscount),
|
|
6017
|
+
shipping: subscription.shape.shipping.extend({
|
|
6018
|
+
amount: PostPurchaseProductSettings.shape.shipping.shape.amount.unwrap().default(subscription.shape.shipping.shape.amount.parse(void 0))
|
|
6019
|
+
})
|
|
6020
|
+
});
|
|
6021
|
+
|
|
6022
|
+
// src/server/postPurchaseVariantAvailable.ts
|
|
6023
|
+
var postPurchaseVariantAvailable = (variant) => !(variant.inventoryManagement && variant.inventoryPolicy === "deny" && variant.inventoryQuantity <= 0);
|
|
6024
|
+
|
|
6025
|
+
// src/server/postPurchaseSubscriptionEligibility.ts
|
|
6026
|
+
var subscriptionUnavailable = (normalized, plan, allowCollection, quantity) => {
|
|
6027
|
+
const { data, effective, original } = normalized;
|
|
6028
|
+
const unavailable = "An eligible subscription plan with supported shipping and discount is required";
|
|
6029
|
+
if (data.length !== 1 || data[0].variants.length !== 1) return unavailable;
|
|
6030
|
+
if (effective.productType === "one-time" || [original, effective].some(
|
|
6031
|
+
(config) => !allowCollection && config.productLimit !== 1 || config.upgradeToSubscription.allow || !quantity && config.quantityInputs.enabled && (config.quantityInputs.minValue !== config.quantityInputs.maxValue || config.quantityInputs.defaultQuantity !== config.quantityInputs.minValue)
|
|
6032
|
+
))
|
|
6033
|
+
return unavailable;
|
|
6034
|
+
const product = data[0];
|
|
6035
|
+
const variant = product.variants[0];
|
|
6036
|
+
if (product.productGroupVariants.length || !postPurchaseVariantAvailable(variant) || variant.productId !== product.id)
|
|
6037
|
+
return unavailable;
|
|
6038
|
+
const terms = [original, effective].map(
|
|
6039
|
+
(config) => PostPurchaseSubscriptionSettings.safeParse(config.subscription)
|
|
6040
|
+
);
|
|
6041
|
+
if (!plan || terms.some((term) => !term.success)) return unavailable;
|
|
6042
|
+
};
|
|
6043
|
+
|
|
6044
|
+
// src/server/postPurchaseProductDisplay.ts
|
|
6045
|
+
import { z as z55 } from "zod";
|
|
6046
|
+
|
|
6047
|
+
// src/server/postPurchasePrimaryImage.ts
|
|
6048
|
+
var postPurchasePrimaryImage = (product) => {
|
|
6049
|
+
const variantImageId = product.variants[0].imageId;
|
|
6050
|
+
const selectedImage = variantImageId ? product.images?.find((image) => image.id === variantImageId) : void 0;
|
|
6051
|
+
const source = PostPurchasePrimaryImageSource.parse((selectedImage ?? product.image)?.src || void 0);
|
|
6052
|
+
return { description: product.title, source: sizeImageSource(source, "800x800") };
|
|
6053
|
+
};
|
|
6054
|
+
|
|
6055
|
+
// src/server/postPurchaseProductGallery.ts
|
|
6056
|
+
var postPurchaseProductGallery = (product, limit) => ({
|
|
6057
|
+
images: (product.images ?? []).slice(0, limit ?? 0).map((image) => ({
|
|
6058
|
+
description: image.alt ?? product.title,
|
|
6059
|
+
id: image.id,
|
|
6060
|
+
source: sizeImageSource(image.src, "800x800"),
|
|
6061
|
+
thumbnail: sizeImageSource(image.src, "200x200")
|
|
6062
|
+
})),
|
|
6063
|
+
selectedImageId: product.images?.find((image) => image.id === product.variants[0].imageId)?.id
|
|
6064
|
+
});
|
|
6065
|
+
|
|
6066
|
+
// src/server/postPurchaseProductDisplay.ts
|
|
6067
|
+
var ResponseLanguage = z55.object({ description: PostPurchaseProductDisplay.shape.responseDescription }).default({ description: "" });
|
|
6068
|
+
var projectPostPurchaseProductDisplay = (effective, metadata, product) => PostPurchaseProductDisplay.parse({
|
|
6069
|
+
discountedFrom: effective.discountedFrom,
|
|
6070
|
+
gallery: postPurchaseProductGallery(product, effective.subImages),
|
|
6071
|
+
language: effective.language,
|
|
6072
|
+
primaryImage: postPurchasePrimaryImage(product),
|
|
6073
|
+
productOptions: effective.productOptions,
|
|
6074
|
+
responseDescription: ResponseLanguage.parse(metadata.widget.language).description,
|
|
6075
|
+
shouldShowSavingText: effective.discount.shouldShowSavingText
|
|
6076
|
+
});
|
|
6077
|
+
|
|
6078
|
+
// src/server/projectPostPurchaseProduct.ts
|
|
6079
|
+
var projectPostPurchaseProduct = ({ data, effective, metadata, original }, selectedQuantity) => {
|
|
6080
|
+
const product = data[0];
|
|
6081
|
+
const variant = product.variants[0];
|
|
6082
|
+
return {
|
|
6083
|
+
display: projectPostPurchaseProductDisplay(effective, metadata, product),
|
|
6084
|
+
labels: effective.language.global,
|
|
6085
|
+
product: { ...product, variant },
|
|
6086
|
+
selection: {
|
|
6087
|
+
productId: product.id,
|
|
6088
|
+
quantity: selectedQuantity?.quantity ?? product.metadata?.productQuantity ?? (original.quantityInputs.enabled ? original.quantityInputs.defaultQuantity : 1),
|
|
6089
|
+
variantId: variant.id
|
|
6090
|
+
}
|
|
6091
|
+
};
|
|
6092
|
+
};
|
|
6093
|
+
|
|
6094
|
+
// src/server/prepareNormalizedSubscription.ts
|
|
6095
|
+
var prepareNormalizedSubscription = (normalized, report, plan, quantity, allowCollection = false) => {
|
|
6096
|
+
if (!plan) return { reason: "Subscription plan is unavailable", status: "unsupported" };
|
|
6097
|
+
const reason = subscriptionUnavailable(normalized, plan, allowCollection, quantity);
|
|
6098
|
+
if (reason) return { reason, status: "unsupported" };
|
|
6099
|
+
const { effective } = normalized;
|
|
6100
|
+
const projected = projectPostPurchaseProduct(normalized, quantity);
|
|
6101
|
+
const { discount, shipping } = PostPurchaseSubscriptionSettings.parse(effective.subscription);
|
|
6102
|
+
const shippingPrice = shipping.type === "free" ? 0 : shipping.amount;
|
|
6103
|
+
return PreparedPostPurchaseSubscription.parse({
|
|
6104
|
+
...projected,
|
|
6105
|
+
display: { ...projected.display, shouldShowSavingText: discount.shouldShowSavingText },
|
|
6106
|
+
selection: { ...projected.selection, sellingPlanId: plan.id },
|
|
6107
|
+
status: "prepared",
|
|
6108
|
+
terms: {
|
|
6109
|
+
discount: {
|
|
6110
|
+
amount: discount.type === "none" ? 0 : discount.amount,
|
|
6111
|
+
title: effective.language.global.save,
|
|
6112
|
+
type: discount.type
|
|
6113
|
+
},
|
|
6114
|
+
shipping: { amount: shippingPrice, title: "Subscription shipping line", type: shipping.type },
|
|
6115
|
+
subscription: {
|
|
6116
|
+
...plan.adjustment ? { adjustment: plan.adjustment } : {},
|
|
6117
|
+
initialShippingPrice: shippingPrice,
|
|
6118
|
+
intervalLabel: plan.intervalLabel,
|
|
6119
|
+
name: plan.name,
|
|
6120
|
+
recurringShippingPrice: shippingPrice,
|
|
6121
|
+
shippingOption: { presentmentTitle: "Subscription shipping line", title: "Subscription shipping line" }
|
|
6122
|
+
}
|
|
6123
|
+
}
|
|
6124
|
+
});
|
|
6125
|
+
};
|
|
6126
|
+
|
|
6127
|
+
// src/server/preparePostPurchaseSubscription.ts
|
|
6128
|
+
var preparePostPurchaseSubscription = (settings, response, report) => {
|
|
6129
|
+
const normalized = normalizePostPurchaseProduct(settings, response);
|
|
6130
|
+
return prepareNormalizedSubscription(
|
|
6131
|
+
normalized,
|
|
6132
|
+
report,
|
|
6133
|
+
projectPostPurchasePlanCatalog(normalized, report)?.plans[0]
|
|
6134
|
+
);
|
|
6135
|
+
};
|
|
6136
|
+
|
|
5454
6137
|
// src/server/analytics.ts
|
|
5455
6138
|
import { chunk } from "es-toolkit";
|
|
5456
6139
|
|
|
@@ -5587,7 +6270,7 @@ var postAnalyticsEvents = async (input, ctx) => {
|
|
|
5587
6270
|
};
|
|
5588
6271
|
|
|
5589
6272
|
// src/server/requestSchemas.ts
|
|
5590
|
-
import { z as
|
|
6273
|
+
import { z as z56 } from "zod";
|
|
5591
6274
|
var REQUEST_BOUNDS = {
|
|
5592
6275
|
/** Cart-level attributes per cart. */
|
|
5593
6276
|
CART_ATTRIBUTES_MAX: 100,
|
|
@@ -5618,42 +6301,42 @@ var REQUEST_BOUNDS = {
|
|
|
5618
6301
|
/** Rich ads transaction lines — the engine's ads contract. */
|
|
5619
6302
|
TRANSACTION_ITEMS_MAX: 50
|
|
5620
6303
|
};
|
|
5621
|
-
var KeyValue =
|
|
5622
|
-
key:
|
|
5623
|
-
value:
|
|
6304
|
+
var KeyValue = z56.object({
|
|
6305
|
+
key: z56.string().max(REQUEST_BOUNDS.STRING_KEY_MAX),
|
|
6306
|
+
value: z56.string().max(REQUEST_BOUNDS.STRING_VALUE_MAX).optional()
|
|
5624
6307
|
});
|
|
5625
|
-
var CartLineInputSchema =
|
|
5626
|
-
productId:
|
|
5627
|
-
properties:
|
|
5628
|
-
quantity:
|
|
5629
|
-
subscriptionId:
|
|
5630
|
-
variantId:
|
|
6308
|
+
var CartLineInputSchema = z56.object({
|
|
6309
|
+
productId: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
6310
|
+
properties: z56.array(KeyValue).max(REQUEST_BOUNDS.LINE_PROPERTIES_MAX).optional(),
|
|
6311
|
+
quantity: z56.number(),
|
|
6312
|
+
subscriptionId: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
6313
|
+
variantId: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX)
|
|
5631
6314
|
});
|
|
5632
|
-
var CartInputSchema =
|
|
5633
|
-
attributes:
|
|
6315
|
+
var CartInputSchema = z56.object({
|
|
6316
|
+
attributes: z56.array(KeyValue).max(REQUEST_BOUNDS.CART_ATTRIBUTES_MAX).optional(),
|
|
5634
6317
|
/**
|
|
5635
6318
|
* Presentment-per-shop-currency FX rate (buyer price ÷ shop price, e.g. `1.35` for a USD shop
|
|
5636
6319
|
* selling in CAD). Money rule thresholds are authored in SHOP currency, so the engine subtotal is
|
|
5637
6320
|
* divided by this before evaluation. Omit (or send 1) when the cart is already in the shop's currency.
|
|
5638
6321
|
*/
|
|
5639
|
-
currencyRate:
|
|
6322
|
+
currencyRate: z56.number().optional(),
|
|
5640
6323
|
/** Applied discount codes; the engine evaluates `discount_code` rules against them (sent as `[{code}]`). */
|
|
5641
|
-
discountCodes:
|
|
6324
|
+
discountCodes: z56.array(z56.string().max(REQUEST_BOUNDS.STRING_KEY_MAX)).max(REQUEST_BOUNDS.DISCOUNT_CODES_MAX).optional(),
|
|
5642
6325
|
/** Presentment cents of cart-level discount allocations, subtracted from `subtotal` for the engine. */
|
|
5643
|
-
discountTotal:
|
|
5644
|
-
items:
|
|
6326
|
+
discountTotal: z56.number().optional(),
|
|
6327
|
+
items: z56.array(CartLineInputSchema).max(REQUEST_BOUNDS.CART_ITEMS_MAX),
|
|
5645
6328
|
/** Presentment subtotal in cents. */
|
|
5646
|
-
subtotal:
|
|
6329
|
+
subtotal: z56.number()
|
|
5647
6330
|
});
|
|
5648
|
-
var UserConfigInputSchema =
|
|
5649
|
-
var DataSourceInputSchema =
|
|
6331
|
+
var UserConfigInputSchema = z56.object({ shop: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX) });
|
|
6332
|
+
var DataSourceInputSchema = z56.object({
|
|
5650
6333
|
cart: CartInputSchema,
|
|
5651
6334
|
/**
|
|
5652
6335
|
* Numeric Shopify company-location id when the buyer is a B2B session (`buyerIdentity.purchasingCompany`).
|
|
5653
6336
|
* Present ⇒ the orchestrator filters results by the location's catalog via admin-api (REB-23713); the
|
|
5654
6337
|
* client's country-context market check is bypassed for B2B (it false-negatives B2B-catalog products).
|
|
5655
6338
|
*/
|
|
5656
|
-
companyLocationId:
|
|
6339
|
+
companyLocationId: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5657
6340
|
/**
|
|
5658
6341
|
* Buyer's market country (ISO 3166-1 alpha-2) — forwarded to the engine as the `country_code` PARAM
|
|
5659
6342
|
* when the shop's markets toggle is on (REB-21688; the sink was the `X-Country-Code` header under
|
|
@@ -5662,16 +6345,16 @@ var DataSourceInputSchema = z39.object({
|
|
|
5662
6345
|
* uppercase (the wire value is forwarded verbatim as the param) so a case-sensitive engine lookup
|
|
5663
6346
|
* can't silently miss a lowercase code — `adsEngine.ts` uppercases for the same reason.
|
|
5664
6347
|
*/
|
|
5665
|
-
country:
|
|
5666
|
-
customerId:
|
|
5667
|
-
dataSourcePath:
|
|
6348
|
+
country: z56.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(),
|
|
6349
|
+
customerId: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
6350
|
+
dataSourcePath: z56.string().max(REQUEST_BOUNDS.STRING_KEY_MAX),
|
|
5668
6351
|
/**
|
|
5669
6352
|
* Engine `filter_inputs` override: `'no'` keeps in-cart (input) products in the results/rule
|
|
5670
6353
|
* outputs — gift validation sends it so a gift's own product can appear in its answer. Omitted = the
|
|
5671
6354
|
* engine's default filtering.
|
|
5672
6355
|
*/
|
|
5673
|
-
filterInputs:
|
|
5674
|
-
integrations:
|
|
6356
|
+
filterInputs: z56.enum(["no", "yes"]).optional(),
|
|
6357
|
+
integrations: z56.record(z56.string().max(REQUEST_BOUNDS.STRING_KEY_MAX), z56.boolean()).refine((record) => Object.keys(record).length <= REQUEST_BOUNDS.INTEGRATION_KEYS_MAX, {
|
|
5675
6358
|
message: `Too many integration keys (max ${REQUEST_BOUNDS.INTEGRATION_KEYS_MAX})`
|
|
5676
6359
|
}).optional(),
|
|
5677
6360
|
/**
|
|
@@ -5684,31 +6367,31 @@ var DataSourceInputSchema = z39.object({
|
|
|
5684
6367
|
* request header) fails the regex. Callers should send the buyer's resolved locale (e.g. Shopify
|
|
5685
6368
|
* checkout's `localization.language.isoCode`), not the request header verbatim.
|
|
5686
6369
|
*/
|
|
5687
|
-
language:
|
|
5688
|
-
limit:
|
|
5689
|
-
productType:
|
|
5690
|
-
shop:
|
|
5691
|
-
visitorId:
|
|
5692
|
-
});
|
|
5693
|
-
var GiftInputSchema =
|
|
5694
|
-
cost:
|
|
5695
|
-
discounted:
|
|
6370
|
+
language: z56.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(),
|
|
6371
|
+
limit: z56.number().max(REQUEST_BOUNDS.LIMIT_MAX),
|
|
6372
|
+
productType: z56.enum(["both", "one-time", "subscription"]).optional(),
|
|
6373
|
+
shop: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
6374
|
+
visitorId: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
6375
|
+
});
|
|
6376
|
+
var GiftInputSchema = z56.object({
|
|
6377
|
+
cost: z56.number(),
|
|
6378
|
+
discounted: z56.boolean(),
|
|
5696
6379
|
/**
|
|
5697
6380
|
* Which gift attribution the line carries (REB-24363). Defaults to `gwp` because a client that predates
|
|
5698
6381
|
* the field only ever sent GWP lines — without the default an older extension's request would 422.
|
|
5699
6382
|
*/
|
|
5700
|
-
kind:
|
|
5701
|
-
lineId:
|
|
5702
|
-
productId:
|
|
6383
|
+
kind: z56.enum(GIFT_KINDS).default("gwp"),
|
|
6384
|
+
lineId: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
6385
|
+
productId: z56.number(),
|
|
5703
6386
|
/**
|
|
5704
6387
|
* The line's unit count (REB-24363) — the selectable-GWP verdict trims surplus units against milestone
|
|
5705
6388
|
* capacity. The second deliberate default: a client predating the field sent only GWP lines, whose
|
|
5706
6389
|
* verdict is whole-line, so a missing quantity reads as one unit rather than 422ing the older request.
|
|
5707
6390
|
*/
|
|
5708
|
-
quantity:
|
|
5709
|
-
widgetId:
|
|
6391
|
+
quantity: z56.number().int().min(1).default(1),
|
|
6392
|
+
widgetId: z56.number()
|
|
5710
6393
|
});
|
|
5711
|
-
var GiftValidationInputSchema =
|
|
6394
|
+
var GiftValidationInputSchema = z56.object({
|
|
5712
6395
|
cart: CartInputSchema,
|
|
5713
6396
|
/**
|
|
5714
6397
|
* Buyer's market country — threaded into the per-widget data-source evaluations, which forward it to
|
|
@@ -5717,25 +6400,25 @@ var GiftValidationInputSchema = z39.object({
|
|
|
5717
6400
|
* turns markets off); regex-bound and uppercase-normalized for the same reasons as
|
|
5718
6401
|
* `DataSourceInputSchema`'s `country`.
|
|
5719
6402
|
*/
|
|
5720
|
-
country:
|
|
5721
|
-
customerId:
|
|
5722
|
-
gifts:
|
|
6403
|
+
country: z56.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(),
|
|
6404
|
+
customerId: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
6405
|
+
gifts: z56.array(GiftInputSchema).max(REQUEST_BOUNDS.GIFTS_MAX),
|
|
5723
6406
|
/**
|
|
5724
6407
|
* Buyer's checkout language — threaded into the per-widget data-source evaluations, which normalize
|
|
5725
6408
|
* and forward it as the engine `locale` param under the same markets-toggle gate (REB-21688). MUST be
|
|
5726
6409
|
* a single BCP-47 tag, for the same reason as `DataSourceInputSchema`'s `language` above.
|
|
5727
6410
|
*/
|
|
5728
|
-
language:
|
|
5729
|
-
shop:
|
|
5730
|
-
visitorId:
|
|
6411
|
+
language: z56.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(),
|
|
6412
|
+
shop: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
6413
|
+
visitorId: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
5731
6414
|
});
|
|
5732
|
-
var GiftAdjustmentSchema =
|
|
5733
|
-
lineId:
|
|
5734
|
-
quantity:
|
|
6415
|
+
var GiftAdjustmentSchema = z56.object({
|
|
6416
|
+
lineId: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
6417
|
+
quantity: z56.number().int().nonnegative()
|
|
5735
6418
|
});
|
|
5736
|
-
var GiftValidationResponseSchema =
|
|
5737
|
-
adjust:
|
|
5738
|
-
remove:
|
|
6419
|
+
var GiftValidationResponseSchema = z56.object({
|
|
6420
|
+
adjust: z56.array(GiftAdjustmentSchema).max(REQUEST_BOUNDS.GIFTS_MAX).default([]),
|
|
6421
|
+
remove: z56.array(z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX)).max(REQUEST_BOUNDS.GIFTS_MAX).refine(
|
|
5739
6422
|
(remove) => new Set(remove).size === remove.length,
|
|
5740
6423
|
"a line id may appear at most once in `remove`"
|
|
5741
6424
|
)
|
|
@@ -5746,47 +6429,47 @@ var GiftValidationResponseSchema = z39.object({
|
|
|
5746
6429
|
({ adjust }) => new Set(adjust.map(({ lineId }) => lineId)).size === adjust.length,
|
|
5747
6430
|
"a line id may appear at most once in `adjust`"
|
|
5748
6431
|
);
|
|
5749
|
-
var MonetizeTransactionItemSchema =
|
|
5750
|
-
id:
|
|
5751
|
-
priceCents:
|
|
5752
|
-
quantity:
|
|
5753
|
-
title:
|
|
5754
|
-
type:
|
|
5755
|
-
});
|
|
5756
|
-
var MonetizeInputSchema =
|
|
6432
|
+
var MonetizeTransactionItemSchema = z56.object({
|
|
6433
|
+
id: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
6434
|
+
priceCents: z56.number(),
|
|
6435
|
+
quantity: z56.number(),
|
|
6436
|
+
title: z56.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX),
|
|
6437
|
+
type: z56.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX)
|
|
6438
|
+
});
|
|
6439
|
+
var MonetizeInputSchema = z56.object({
|
|
5757
6440
|
cart: CartInputSchema,
|
|
5758
6441
|
/** Client-minted render-beacon correlation id; forwarded to the ads engine as `client_request_id`. */
|
|
5759
|
-
clientRequestId:
|
|
5760
|
-
country:
|
|
5761
|
-
currency:
|
|
6442
|
+
clientRequestId: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
6443
|
+
country: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
6444
|
+
currency: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5762
6445
|
/** Ads-targeting identity/geo/locale fields (React parity); folded into the engine query verbatim. */
|
|
5763
|
-
customerEmail:
|
|
5764
|
-
customerFirstName:
|
|
5765
|
-
customerId:
|
|
5766
|
-
customerLastName:
|
|
5767
|
-
language:
|
|
6446
|
+
customerEmail: z56.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX).optional(),
|
|
6447
|
+
customerFirstName: z56.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX).optional(),
|
|
6448
|
+
customerId: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
6449
|
+
customerLastName: z56.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX).optional(),
|
|
6450
|
+
language: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5768
6451
|
/** Buyer-facing order name (e.g. `#1001`) for the server-composed "Order … Confirmed" chrome line. */
|
|
5769
|
-
orderName:
|
|
6452
|
+
orderName: z56.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX).optional(),
|
|
5770
6453
|
/** Ads surface label, forwarded verbatim; `customer_account` is measured/floored as its own surface (the account-area order list). */
|
|
5771
|
-
placement:
|
|
6454
|
+
placement: z56.enum(["customer_account", "order_status", "thank_you_page"]),
|
|
5772
6455
|
/** Privacy Policy footer href — the Monetize widget's `privacy_policy_url` setting (React parity). */
|
|
5773
|
-
privacyPolicyUrl:
|
|
6456
|
+
privacyPolicyUrl: z56.string().max(REQUEST_BOUNDS.STRING_URL_MAX).optional(),
|
|
5774
6457
|
/** 30-min rolling session id (React parity); used for the ads `session_id`, else the visitor id. */
|
|
5775
|
-
sessionId:
|
|
5776
|
-
shop:
|
|
6458
|
+
sessionId: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
6459
|
+
shop: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
5777
6460
|
/** Editor/QA indicator; OR-ed into the ads-engine `testing` flag so it stays out of billing/reporting. */
|
|
5778
|
-
testing:
|
|
5779
|
-
timezone:
|
|
6461
|
+
testing: z56.boolean().optional(),
|
|
6462
|
+
timezone: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5780
6463
|
/** Decorated (numeric) order id → the ads `transaction_id`. */
|
|
5781
|
-
transactionId:
|
|
6464
|
+
transactionId: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5782
6465
|
/** Rich per-line ads items; capped at the engine's ads contract. Preferred over `cart.items`. */
|
|
5783
|
-
transactionItems:
|
|
6466
|
+
transactionItems: z56.array(MonetizeTransactionItemSchema).max(REQUEST_BOUNDS.TRANSACTION_ITEMS_MAX).optional(),
|
|
5784
6467
|
/** Order total in presentment cents (React prefers total over subtotal); else `cart.subtotal`. */
|
|
5785
|
-
transactionTotal:
|
|
5786
|
-
visitorId:
|
|
5787
|
-
zipCode:
|
|
6468
|
+
transactionTotal: z56.number().optional(),
|
|
6469
|
+
visitorId: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
6470
|
+
zipCode: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
5788
6471
|
});
|
|
5789
|
-
var WidgetSettingsInputSchema =
|
|
6472
|
+
var WidgetSettingsInputSchema = z56.object({
|
|
5790
6473
|
/**
|
|
5791
6474
|
* Same domain as `CabShopConfig.cacheKey`, for the same reason: this side WINS the orchestrator's
|
|
5792
6475
|
* `input.cacheKey ?? config.shop.cacheKey` (and an explicit value skips the config read entirely), so
|
|
@@ -5794,9 +6477,9 @@ var WidgetSettingsInputSchema = z39.object({
|
|
|
5794
6477
|
* and pin the edge copy permanently stale. `.catch(undefined)` because a bogus buster should degrade
|
|
5795
6478
|
* the read to un-busted, never 400 a widget render.
|
|
5796
6479
|
*/
|
|
5797
|
-
cacheKey:
|
|
5798
|
-
id:
|
|
5799
|
-
key:
|
|
6480
|
+
cacheKey: z56.number().int().positive().optional().catch(void 0),
|
|
6481
|
+
id: z56.number(),
|
|
6482
|
+
key: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5800
6483
|
/**
|
|
5801
6484
|
* Monetize context for inline hydration: when present AND the widget converts to a Monetize marker,
|
|
5802
6485
|
* the server fetches/composes the offer cards inside this same request (no second `/cab/monetize`
|
|
@@ -5805,36 +6488,36 @@ var WidgetSettingsInputSchema = z39.object({
|
|
|
5805
6488
|
* `privacyPolicyUrl` comes from the widget settings server-side (more authoritative than a relay).
|
|
5806
6489
|
*/
|
|
5807
6490
|
monetize: MonetizeInputSchema.omit({ privacyPolicyUrl: true, shop: true }).optional(),
|
|
5808
|
-
shop:
|
|
6491
|
+
shop: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
5809
6492
|
/** Stable per-buyer id; when present, enables sticky server-side A/B variant selection. */
|
|
5810
|
-
visitorId:
|
|
6493
|
+
visitorId: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
5811
6494
|
});
|
|
5812
|
-
var AnalyticsEventInputSchema =
|
|
5813
|
-
name:
|
|
5814
|
-
properties:
|
|
5815
|
-
sentAt:
|
|
6495
|
+
var AnalyticsEventInputSchema = z56.object({
|
|
6496
|
+
name: z56.string().max(REQUEST_BOUNDS.STRING_KEY_MAX),
|
|
6497
|
+
properties: z56.record(z56.string().max(REQUEST_BOUNDS.STRING_KEY_MAX), z56.unknown()).optional(),
|
|
6498
|
+
sentAt: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
5816
6499
|
});
|
|
5817
|
-
var AnalyticsSegmentsInputSchema =
|
|
5818
|
-
device:
|
|
5819
|
-
source:
|
|
5820
|
-
visitor:
|
|
6500
|
+
var AnalyticsSegmentsInputSchema = z56.object({
|
|
6501
|
+
device: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional().catch(void 0),
|
|
6502
|
+
source: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional().catch(void 0),
|
|
6503
|
+
visitor: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional().catch(void 0)
|
|
5821
6504
|
});
|
|
5822
|
-
var AnalyticsInputSchema =
|
|
6505
|
+
var AnalyticsInputSchema = z56.object({
|
|
5823
6506
|
/** Rebuy cart token (the `r_cart_token` cart attribute), when available — primary aggregation key. */
|
|
5824
|
-
cartToken:
|
|
6507
|
+
cartToken: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5825
6508
|
/** Shopify checkout token, when available — drives cart/checkout aggregation downstream. */
|
|
5826
|
-
checkoutToken:
|
|
5827
|
-
events:
|
|
6509
|
+
checkoutToken: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
6510
|
+
events: z56.array(AnalyticsEventInputSchema).max(REQUEST_BOUNDS.EVENTS_MAX),
|
|
5828
6511
|
/**
|
|
5829
6512
|
* Request-scoped like the tokens: one visitor's segments apply to every event in the batch. The container
|
|
5830
6513
|
* degrades too (`null` is a realistic wire artifact of `attributes ? {…} : null`), so the degrade rule is
|
|
5831
6514
|
* total: nothing about `segments` can cost the envelope.
|
|
5832
6515
|
*/
|
|
5833
6516
|
segments: AnalyticsSegmentsInputSchema.optional().catch(void 0),
|
|
5834
|
-
shop:
|
|
5835
|
-
visitorId:
|
|
6517
|
+
shop: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
6518
|
+
visitorId: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
5836
6519
|
/** The widget id (smartBlockId) the events belong to. */
|
|
5837
|
-
widgetId:
|
|
6520
|
+
widgetId: z56.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
5838
6521
|
});
|
|
5839
6522
|
export {
|
|
5840
6523
|
AnalyticsEventInputSchema,
|
|
@@ -5861,6 +6544,7 @@ export {
|
|
|
5861
6544
|
fetchMonetizeOffers,
|
|
5862
6545
|
fetchUserConfig,
|
|
5863
6546
|
postAnalyticsEvents,
|
|
6547
|
+
preparePostPurchaseSubscription,
|
|
5864
6548
|
translateAnalyticsEvent,
|
|
5865
6549
|
validateGifts
|
|
5866
6550
|
};
|