@rebuy/rebuy 3.40.0 → 3.42.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 +9 -0
- package/dist/cab/index.d.ts +1 -0
- package/dist/cab/index.mjs +9 -0
- package/dist/cab/resolveVariables.d.ts +9 -0
- package/dist/index.cjs +698 -632
- package/dist/index.mjs +698 -632
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/postPurchaseAdmission.d.ts +33 -0
- package/dist/schema/postPurchaseFollowups.d.ts +47 -0
- package/dist/schema/postPurchaseProductCollectionView.d.ts +38 -0
- package/dist/schema/postPurchaseProductView.d.ts +40 -0
- package/dist/schema/postPurchaseRecovery.d.ts +47 -0
- package/dist/schema/postPurchaseUpgrade.d.ts +117 -0
- package/dist/server/index.cjs +133 -120
- package/dist/server/index.mjs +133 -120
- package/dist/server/preparePostPurchaseAdmissionView.d.ts +32 -0
- package/dist/server/preparePostPurchaseCollectionGroup.d.ts +32 -0
- package/dist/server/preparePostPurchaseCollectionView.d.ts +32 -0
- package/dist/server/preparePostPurchaseGroupAdmissionView.d.ts +32 -0
- package/dist/server/preparePostPurchaseGroupDefault.d.ts +32 -0
- package/dist/server/preparePostPurchaseGroupView.d.ts +32 -0
- package/dist/server/preparePostPurchaseMemberView.d.ts +96 -0
- package/dist/server/preparePostPurchaseQuantityAdmissionView.d.ts +32 -0
- package/dist/server/preparePostPurchaseQuantityView.d.ts +32 -0
- package/package.json +1 -1
package/dist/server/index.mjs
CHANGED
|
@@ -6402,7 +6402,7 @@ var prepareNormalizedProduct = (normalized, report, quantity2, allowCollection =
|
|
|
6402
6402
|
var preparePostPurchaseProduct = (settings, response, report) => prepareNormalizedProduct(normalizePostPurchaseProduct(settings, response), report);
|
|
6403
6403
|
|
|
6404
6404
|
// src/schema/postPurchaseProductView.ts
|
|
6405
|
-
import { z as
|
|
6405
|
+
import { z as z68 } from "zod";
|
|
6406
6406
|
|
|
6407
6407
|
// src/schema/postPurchaseChoice.ts
|
|
6408
6408
|
import { z as z64 } from "zod";
|
|
@@ -6463,14 +6463,79 @@ var PostPurchaseGroupSelection = z66.object({
|
|
|
6463
6463
|
productId
|
|
6464
6464
|
});
|
|
6465
6465
|
|
|
6466
|
+
// src/schema/postPurchaseProductCalculation.ts
|
|
6467
|
+
import { z as z67 } from "zod";
|
|
6468
|
+
var MoneyBag = z67.object({
|
|
6469
|
+
presentmentMoney: z67.object({
|
|
6470
|
+
amount: PostPurchaseAmount,
|
|
6471
|
+
currencyCode: z67.string().regex(/^[A-Z]{3}$/)
|
|
6472
|
+
})
|
|
6473
|
+
});
|
|
6474
|
+
var PostPurchaseProductCalculation = z67.object({
|
|
6475
|
+
calculatedPurchase: z67.object({
|
|
6476
|
+
addedShippingLines: z67.array(z67.object({ priceSet: MoneyBag })),
|
|
6477
|
+
addedTaxLines: z67.array(z67.object({ priceSet: MoneyBag })),
|
|
6478
|
+
totalOutstandingSet: MoneyBag,
|
|
6479
|
+
updatedLineItems: z67.array(
|
|
6480
|
+
z67.object({
|
|
6481
|
+
priceSet: z67.unknown().optional(),
|
|
6482
|
+
productId: z67.number().int().positive(),
|
|
6483
|
+
sellingPlanId: z67.unknown().optional(),
|
|
6484
|
+
variantId: z67.number().int().positive()
|
|
6485
|
+
})
|
|
6486
|
+
)
|
|
6487
|
+
}),
|
|
6488
|
+
errors: z67.array(z67.unknown()).length(0),
|
|
6489
|
+
status: z67.literal("processed")
|
|
6490
|
+
});
|
|
6491
|
+
var Minor = z67.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
6492
|
+
var PostPurchaseProductCosts = z67.object({
|
|
6493
|
+
currencyCode: MoneyBag.shape.presentmentMoney.shape.currencyCode,
|
|
6494
|
+
recurringDisplay: z67.object({ shippingMinor: Minor, subtotalMinor: Minor, totalMinor: Minor }).optional(),
|
|
6495
|
+
shippingMinor: Minor,
|
|
6496
|
+
subtotalMinor: Minor,
|
|
6497
|
+
taxesMinor: Minor,
|
|
6498
|
+
totalMinor: Minor
|
|
6499
|
+
});
|
|
6500
|
+
var ChangesetDiscount = z67.object({
|
|
6501
|
+
title: z67.string(),
|
|
6502
|
+
value: z67.number().nonnegative(),
|
|
6503
|
+
valueType: z67.enum(["percentage", "fixed_amount"])
|
|
6504
|
+
}).optional();
|
|
6505
|
+
var PostPurchaseProductChangeset = z67.object({
|
|
6506
|
+
changes: z67.array(
|
|
6507
|
+
z67.union([
|
|
6508
|
+
z67.object({
|
|
6509
|
+
discount: ChangesetDiscount,
|
|
6510
|
+
quantity: z67.number().int().positive(),
|
|
6511
|
+
type: z67.literal("add_variant"),
|
|
6512
|
+
variantId: z67.number().int().positive()
|
|
6513
|
+
}),
|
|
6514
|
+
z67.object({ price: z67.number().nonnegative(), title: z67.string(), type: z67.literal("add_shipping_line") }),
|
|
6515
|
+
PostPurchaseSubscriptionTerms.pick({
|
|
6516
|
+
initialShippingPrice: true,
|
|
6517
|
+
recurringShippingPrice: true,
|
|
6518
|
+
shippingOption: true
|
|
6519
|
+
}).extend({
|
|
6520
|
+
discount: ChangesetDiscount,
|
|
6521
|
+
quantity: z67.number().int().positive(),
|
|
6522
|
+
sellingPlanId: z67.number().int().positive(),
|
|
6523
|
+
type: z67.literal("add_subscription"),
|
|
6524
|
+
variantId: z67.number().int().positive()
|
|
6525
|
+
})
|
|
6526
|
+
])
|
|
6527
|
+
)
|
|
6528
|
+
});
|
|
6529
|
+
|
|
6466
6530
|
// src/schema/postPurchaseProductView.ts
|
|
6467
|
-
var PostPurchaseProductView =
|
|
6468
|
-
|
|
6531
|
+
var PostPurchaseProductView = z68.union([
|
|
6532
|
+
z68.object({
|
|
6533
|
+
changeset: PostPurchaseProductChangeset.optional(),
|
|
6469
6534
|
groupCatalog: PostPurchaseGroupCatalog.optional(),
|
|
6470
6535
|
initialVariant: PostPurchaseVariantSelector.optional(),
|
|
6471
6536
|
planCatalog: PostPurchasePlanCatalog.nullable().optional(),
|
|
6472
6537
|
preparation: PreparedPostPurchaseProduct.extend({
|
|
6473
|
-
display: PreparedPostPurchaseProduct.shape.display.extend({ description:
|
|
6538
|
+
display: PreparedPostPurchaseProduct.shape.display.extend({ description: z68.string().nullable() }).refine(
|
|
6474
6539
|
({ description, descriptionDocument }) => description === null === (descriptionDocument !== void 0),
|
|
6475
6540
|
"Exactly one of the plain and rich descriptions is shown"
|
|
6476
6541
|
)
|
|
@@ -6479,24 +6544,24 @@ var PostPurchaseProductView = z67.union([
|
|
|
6479
6544
|
sections: CABRootSection,
|
|
6480
6545
|
variantCatalog: PostPurchaseVariantCatalog.optional()
|
|
6481
6546
|
}),
|
|
6482
|
-
|
|
6547
|
+
z68.object({
|
|
6483
6548
|
groupCatalog: PostPurchaseGroupCatalog.optional(),
|
|
6484
6549
|
initialVariant: PostPurchaseVariantSelector.optional(),
|
|
6485
6550
|
planCatalog: PostPurchasePlanCatalog.nullable().optional(),
|
|
6486
6551
|
preparation: PostPurchasePreparation.options[1],
|
|
6487
6552
|
purchaseOptions: PostPurchaseOptions.optional(),
|
|
6488
|
-
sections:
|
|
6553
|
+
sections: z68.null(),
|
|
6489
6554
|
variantCatalog: PostPurchaseVariantCatalog.optional()
|
|
6490
6555
|
})
|
|
6491
6556
|
]);
|
|
6492
6557
|
|
|
6493
6558
|
// src/server/postPurchaseOfferCopy.ts
|
|
6494
|
-
import { z as
|
|
6495
|
-
var Copy =
|
|
6559
|
+
import { z as z69 } from "zod";
|
|
6560
|
+
var Copy = z69.object({
|
|
6496
6561
|
superTitle: CalloutBannerBlock.shape.settings.shape.superTitle.unwrap().optional().catch(void 0),
|
|
6497
6562
|
title: CalloutBannerBlock.shape.settings.shape.title.unwrap().optional().catch(void 0)
|
|
6498
6563
|
});
|
|
6499
|
-
var Callout =
|
|
6564
|
+
var Callout = z69.object({ settings: z69.record(z69.string(), z69.unknown()), type: z69.literal("callout_banner") });
|
|
6500
6565
|
var postPurchaseOfferCopy = (blocks, metadata) => {
|
|
6501
6566
|
const copy = Copy.safeParse(metadata.widget.language);
|
|
6502
6567
|
if (!blocks || !copy.success) return blocks;
|
|
@@ -6610,98 +6675,36 @@ import { z as z73 } from "zod";
|
|
|
6610
6675
|
import { z as z72 } from "zod";
|
|
6611
6676
|
|
|
6612
6677
|
// src/schema/postPurchaseIdentity.ts
|
|
6613
|
-
import { z as
|
|
6678
|
+
import { z as z70 } from "zod";
|
|
6614
6679
|
var POST_PURCHASE_ID_MAX = 128;
|
|
6615
|
-
var PostPurchaseTimestampSchema =
|
|
6616
|
-
var PostPurchaseOrderIdSchema =
|
|
6617
|
-
var ShopifyDomainSchema =
|
|
6618
|
-
var DecideRequestSchema =
|
|
6619
|
-
checkoutToken:
|
|
6680
|
+
var PostPurchaseTimestampSchema = z70.number().int().nonnegative();
|
|
6681
|
+
var PostPurchaseOrderIdSchema = z70.string().regex(/^gid:\/\/shopify\/Order\/[1-9]\d*$/);
|
|
6682
|
+
var ShopifyDomainSchema = z70.string().max(POST_PURCHASE_ID_MAX).regex(/^[a-z0-9]([a-z0-9-]*[a-z0-9])?\.myshopify\.com$/);
|
|
6683
|
+
var DecideRequestSchema = z70.object({
|
|
6684
|
+
checkoutToken: z70.string().min(1).max(POST_PURCHASE_ID_MAX),
|
|
6620
6685
|
shop: ShopifyDomainSchema
|
|
6621
6686
|
});
|
|
6622
|
-
var PostPurchaseAppIdSchema =
|
|
6623
|
-
var DecisionEntrySchema =
|
|
6624
|
-
blockId:
|
|
6625
|
-
blockIndex:
|
|
6626
|
-
blockParentIndex:
|
|
6627
|
-
flowId:
|
|
6628
|
-
sectionId:
|
|
6629
|
-
widgetId:
|
|
6630
|
-
widgetTraffic:
|
|
6687
|
+
var PostPurchaseAppIdSchema = z70.string().min(1).max(POST_PURCHASE_ID_MAX);
|
|
6688
|
+
var DecisionEntrySchema = z70.object({
|
|
6689
|
+
blockId: z70.number().int().positive(),
|
|
6690
|
+
blockIndex: z70.string(),
|
|
6691
|
+
blockParentIndex: z70.string(),
|
|
6692
|
+
flowId: z70.number().int().positive(),
|
|
6693
|
+
sectionId: z70.number().int().positive(),
|
|
6694
|
+
widgetId: z70.number().int().positive(),
|
|
6695
|
+
widgetTraffic: z70.number().min(0).max(100)
|
|
6631
6696
|
});
|
|
6632
6697
|
|
|
6633
6698
|
// src/schema/postPurchaseMemberIdentity.ts
|
|
6634
|
-
import { z as z70 } from "zod";
|
|
6635
|
-
var PostPurchaseMemberIdentity = z70.object({
|
|
6636
|
-
productId: z70.number().int().positive(),
|
|
6637
|
-
productIndex: z70.number().int().nonnegative()
|
|
6638
|
-
}).strict();
|
|
6639
|
-
|
|
6640
|
-
// src/schema/postPurchaseProductCalculation.ts
|
|
6641
6699
|
import { z as z71 } from "zod";
|
|
6642
|
-
var
|
|
6643
|
-
|
|
6644
|
-
|
|
6645
|
-
|
|
6646
|
-
})
|
|
6647
|
-
});
|
|
6648
|
-
var PostPurchaseProductCalculation = z71.object({
|
|
6649
|
-
calculatedPurchase: z71.object({
|
|
6650
|
-
addedShippingLines: z71.array(z71.object({ priceSet: MoneyBag })),
|
|
6651
|
-
addedTaxLines: z71.array(z71.object({ priceSet: MoneyBag })),
|
|
6652
|
-
totalOutstandingSet: MoneyBag,
|
|
6653
|
-
updatedLineItems: z71.array(
|
|
6654
|
-
z71.object({
|
|
6655
|
-
priceSet: z71.unknown().optional(),
|
|
6656
|
-
productId: z71.number().int().positive(),
|
|
6657
|
-
sellingPlanId: z71.unknown().optional(),
|
|
6658
|
-
variantId: z71.number().int().positive()
|
|
6659
|
-
})
|
|
6660
|
-
)
|
|
6661
|
-
}),
|
|
6662
|
-
errors: z71.array(z71.unknown()).length(0),
|
|
6663
|
-
status: z71.literal("processed")
|
|
6664
|
-
});
|
|
6665
|
-
var Minor = z71.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
6666
|
-
var PostPurchaseProductCosts = z71.object({
|
|
6667
|
-
currencyCode: MoneyBag.shape.presentmentMoney.shape.currencyCode,
|
|
6668
|
-
recurringDisplay: z71.object({ shippingMinor: Minor, subtotalMinor: Minor, totalMinor: Minor }).optional(),
|
|
6669
|
-
shippingMinor: Minor,
|
|
6670
|
-
subtotalMinor: Minor,
|
|
6671
|
-
taxesMinor: Minor,
|
|
6672
|
-
totalMinor: Minor
|
|
6673
|
-
});
|
|
6674
|
-
var ChangesetDiscount = z71.object({
|
|
6675
|
-
title: z71.string(),
|
|
6676
|
-
value: z71.number().nonnegative(),
|
|
6677
|
-
valueType: z71.enum(["percentage", "fixed_amount"])
|
|
6678
|
-
}).optional();
|
|
6679
|
-
var PostPurchaseProductChangeset = z71.object({
|
|
6680
|
-
changes: z71.array(
|
|
6681
|
-
z71.union([
|
|
6682
|
-
z71.object({
|
|
6683
|
-
discount: ChangesetDiscount,
|
|
6684
|
-
quantity: z71.number().int().positive(),
|
|
6685
|
-
type: z71.literal("add_variant"),
|
|
6686
|
-
variantId: z71.number().int().positive()
|
|
6687
|
-
}),
|
|
6688
|
-
z71.object({ price: z71.number().nonnegative(), title: z71.string(), type: z71.literal("add_shipping_line") }),
|
|
6689
|
-
PostPurchaseSubscriptionTerms.pick({
|
|
6690
|
-
initialShippingPrice: true,
|
|
6691
|
-
recurringShippingPrice: true,
|
|
6692
|
-
shippingOption: true
|
|
6693
|
-
}).extend({
|
|
6694
|
-
discount: ChangesetDiscount,
|
|
6695
|
-
quantity: z71.number().int().positive(),
|
|
6696
|
-
sellingPlanId: z71.number().int().positive(),
|
|
6697
|
-
type: z71.literal("add_subscription"),
|
|
6698
|
-
variantId: z71.number().int().positive()
|
|
6699
|
-
})
|
|
6700
|
-
])
|
|
6701
|
-
)
|
|
6702
|
-
});
|
|
6700
|
+
var PostPurchaseMemberIdentity = z71.object({
|
|
6701
|
+
productId: z71.number().int().positive(),
|
|
6702
|
+
productIndex: z71.number().int().nonnegative()
|
|
6703
|
+
}).strict();
|
|
6703
6704
|
|
|
6704
6705
|
// src/schema/postPurchaseAdmission.ts
|
|
6706
|
+
var PurchaseAdmissionModeSchema = z72.enum(["purchase", "upgrade"]);
|
|
6707
|
+
var selection = PreparedPostPurchaseProduct.shape.selection;
|
|
6705
6708
|
var PurchaseExpectedSchema = z72.object({
|
|
6706
6709
|
buyerConsentToSubscriptions: z72.boolean().optional(),
|
|
6707
6710
|
changeset: PostPurchaseProductChangeset.extend({
|
|
@@ -6709,16 +6712,20 @@ var PurchaseExpectedSchema = z72.object({
|
|
|
6709
6712
|
}),
|
|
6710
6713
|
entry: DecisionEntrySchema,
|
|
6711
6714
|
member: PostPurchaseMemberIdentity.optional(),
|
|
6715
|
+
mode: PurchaseAdmissionModeSchema.optional(),
|
|
6712
6716
|
progressRevision: z72.number().int().nonnegative().optional(),
|
|
6713
|
-
selection
|
|
6717
|
+
selection
|
|
6714
6718
|
}).refine(
|
|
6715
6719
|
({ member, progressRevision }) => !member || progressRevision !== void 0,
|
|
6716
6720
|
"Captured member requires progress"
|
|
6717
|
-
).refine(
|
|
6721
|
+
).refine(
|
|
6722
|
+
({ mode, selection: { sellingPlanId } }) => mode !== "upgrade" || sellingPlanId !== void 0,
|
|
6723
|
+
"An upgrade selects a subscription"
|
|
6724
|
+
).refine(({ buyerConsentToSubscriptions: consent, changeset, selection: selection4 }) => {
|
|
6718
6725
|
const [change, shipping] = changeset.changes;
|
|
6719
|
-
if (
|
|
6720
|
-
return consent !== true && change?.type === "add_variant" && change.variantId ===
|
|
6721
|
-
return consent === true && changeset.changes.length === 1 && change.type === "add_subscription" && change.sellingPlanId ===
|
|
6726
|
+
if (selection4.sellingPlanId === void 0)
|
|
6727
|
+
return consent !== true && change?.type === "add_variant" && change.variantId === selection4.variantId && change.quantity === selection4.quantity && (shipping === void 0 || shipping.type === "add_shipping_line");
|
|
6728
|
+
return consent === true && changeset.changes.length === 1 && change.type === "add_subscription" && change.sellingPlanId === selection4.sellingPlanId && change.variantId === selection4.variantId && change.quantity === selection4.quantity;
|
|
6722
6729
|
}, "Selection, change and buyer consent must agree");
|
|
6723
6730
|
var PurchaseRequestSchema = DecideRequestSchema.extend({
|
|
6724
6731
|
expected: PurchaseExpectedSchema,
|
|
@@ -6727,12 +6734,18 @@ var PurchaseRequestSchema = DecideRequestSchema.extend({
|
|
|
6727
6734
|
var PurchaseReceiptSchema = z72.object({
|
|
6728
6735
|
admittedAt: PostPurchaseTimestampSchema,
|
|
6729
6736
|
changesetToken: z72.string().min(1),
|
|
6737
|
+
mode: PurchaseAdmissionModeSchema.optional(),
|
|
6730
6738
|
operationId: z72.uuid(),
|
|
6739
|
+
/** The server-bound one-time line an upgrade refunds; its quantity is the order's, not the selection's. */
|
|
6740
|
+
originalLine: z72.strictObject({ quantity: selection.shape.quantity, variantId: selection.shape.variantId }).optional(),
|
|
6731
6741
|
requiresSubscriptionConsent: z72.boolean(),
|
|
6732
|
-
selection
|
|
6742
|
+
selection
|
|
6733
6743
|
}).refine(
|
|
6734
|
-
({ requiresSubscriptionConsent, selection:
|
|
6744
|
+
({ requiresSubscriptionConsent, selection: selection4 }) => requiresSubscriptionConsent === (selection4.sellingPlanId !== void 0),
|
|
6735
6745
|
"Receipt consent must match its selected plan"
|
|
6746
|
+
).refine(
|
|
6747
|
+
({ mode, originalLine, selection: { sellingPlanId, variantId } }) => mode === "upgrade" ? sellingPlanId !== void 0 && originalLine?.variantId === variantId : originalLine === void 0,
|
|
6748
|
+
"An upgrade Receipt binds the original line of its subscribed variant, and only an upgrade does"
|
|
6736
6749
|
);
|
|
6737
6750
|
var PurchaseResponseSchema = z72.object({ data: PurchaseReceiptSchema, successful: z72.literal(true) });
|
|
6738
6751
|
|
|
@@ -6874,7 +6887,7 @@ var readPostPurchaseQuantity = ({
|
|
|
6874
6887
|
data,
|
|
6875
6888
|
effective,
|
|
6876
6889
|
original
|
|
6877
|
-
},
|
|
6890
|
+
}, selection4) => {
|
|
6878
6891
|
const positive = PreparedPostPurchaseProduct.shape.selection.shape.quantity;
|
|
6879
6892
|
for (const config of [original, effective]) {
|
|
6880
6893
|
if (!config.quantityInputs.enabled) continue;
|
|
@@ -6887,7 +6900,7 @@ var readPostPurchaseQuantity = ({
|
|
|
6887
6900
|
const policy = PostPurchaseQuantityPolicy.parse(
|
|
6888
6901
|
effective.quantityInputs.enabled ? { ...effective.quantityInputs, initialQuantity } : { enabled: false, initialQuantity, maxValue: initialQuantity, minValue: initialQuantity }
|
|
6889
6902
|
);
|
|
6890
|
-
const requested = "quantity" in
|
|
6903
|
+
const requested = "quantity" in selection4 ? selection4.quantity : selection4.expectedQuantity === initialQuantity ? void 0 : selection4.expectedQuantity;
|
|
6891
6904
|
const quantity2 = positive.parse(requested ?? initialQuantity);
|
|
6892
6905
|
if (requested !== void 0 && (policy.enabled ? quantity2 < policy.minValue || quantity2 > policy.maxValue : quantity2 !== initialQuantity))
|
|
6893
6906
|
throw new PostPurchaseQuantityUnavailable("Requested quantity is unavailable");
|
|
@@ -7031,12 +7044,12 @@ var preparePostPurchaseMemberAdmissionView = (widgetId, settings, response, requ
|
|
|
7031
7044
|
|
|
7032
7045
|
// src/server/preparePostPurchaseQuantityView.ts
|
|
7033
7046
|
var preparePostPurchaseQuantityView = (widgetId, settings, response, requested, report, excludedProductIds, defaults) => {
|
|
7034
|
-
const { quantity: quantity2, ...
|
|
7047
|
+
const { quantity: quantity2, ...selection4 } = PostPurchaseQuantityChoice.parse(requested);
|
|
7035
7048
|
const prepared = prepareMember(
|
|
7036
7049
|
widgetId,
|
|
7037
7050
|
settings,
|
|
7038
7051
|
response,
|
|
7039
|
-
|
|
7052
|
+
selection4,
|
|
7040
7053
|
report,
|
|
7041
7054
|
excludedProductIds,
|
|
7042
7055
|
{ quantity: quantity2 },
|
|
@@ -7046,9 +7059,9 @@ var preparePostPurchaseQuantityView = (widgetId, settings, response, requested,
|
|
|
7046
7059
|
};
|
|
7047
7060
|
|
|
7048
7061
|
// src/server/preparePostPurchaseQuantityAdmissionView.ts
|
|
7049
|
-
var
|
|
7062
|
+
var selection2 = PostPurchaseQuantityChoice.required({ quantity: true });
|
|
7050
7063
|
var preparePostPurchaseQuantityAdmissionView = (widgetId, settings, response, expected, report, excludedProductIds, defaults) => {
|
|
7051
|
-
const { quantity: expectedQuantity, ...requested } =
|
|
7064
|
+
const { quantity: expectedQuantity, ...requested } = selection2.parse(expected);
|
|
7052
7065
|
const prepared = prepareMember(
|
|
7053
7066
|
widgetId,
|
|
7054
7067
|
settings,
|
|
@@ -7101,12 +7114,12 @@ var readPostPurchaseGroup = (product, settings, excludedProductIds) => {
|
|
|
7101
7114
|
|
|
7102
7115
|
// src/server/readPostPurchaseGroupSelection.ts
|
|
7103
7116
|
var readPostPurchaseGroupSelection = (settings, response, requested, excludedProductIds) => {
|
|
7104
|
-
const
|
|
7117
|
+
const selection4 = PostPurchaseGroupSelection.parse(requested);
|
|
7105
7118
|
const { members, normalized } = normalizePostPurchaseCollection(settings, response);
|
|
7106
|
-
const member = members.find(({ product }) => product.id ===
|
|
7119
|
+
const member = members.find(({ product }) => product.id === selection4.memberProductId);
|
|
7107
7120
|
if (!member || !member.product.productGroupVariants.length) return null;
|
|
7108
7121
|
const group = readPostPurchaseGroup(member.product, normalized.effective, excludedProductIds);
|
|
7109
|
-
const entry = group.entries.find(({ product }) => product.id ===
|
|
7122
|
+
const entry = group.entries.find(({ product }) => product.id === selection4.productId);
|
|
7110
7123
|
if (!entry) return null;
|
|
7111
7124
|
return {
|
|
7112
7125
|
groupCatalog: group.catalog,
|
|
@@ -7120,16 +7133,16 @@ var readPostPurchaseGroupSelection = (settings, response, requested, excludedPro
|
|
|
7120
7133
|
|
|
7121
7134
|
// src/server/preparePostPurchaseGroupView.ts
|
|
7122
7135
|
var preparePostPurchaseGroupView = (widgetId, settings, response, requested, report, excludedProductIds) => {
|
|
7123
|
-
const { memberProductId, ...
|
|
7136
|
+
const { memberProductId, ...selection4 } = PostPurchaseGroupChoice.parse(requested);
|
|
7124
7137
|
const group = readPostPurchaseGroupSelection(settings, response, requested, excludedProductIds);
|
|
7125
7138
|
if (!group) return null;
|
|
7126
|
-
const variantId =
|
|
7139
|
+
const variantId = selection4.variantId ?? group.variantCatalog.variants.find(({ available }) => available)?.id;
|
|
7127
7140
|
if (variantId === void 0) return null;
|
|
7128
7141
|
const prepared = preparePostPurchaseQuantityView(
|
|
7129
7142
|
widgetId,
|
|
7130
7143
|
settings,
|
|
7131
7144
|
group.response,
|
|
7132
|
-
{ ...
|
|
7145
|
+
{ ...selection4, variantId },
|
|
7133
7146
|
report
|
|
7134
7147
|
);
|
|
7135
7148
|
return prepared && {
|
|
@@ -7143,16 +7156,16 @@ var preparePostPurchaseGroupView = (widgetId, settings, response, requested, rep
|
|
|
7143
7156
|
|
|
7144
7157
|
// src/server/preparePostPurchaseGroupAdmissionView.ts
|
|
7145
7158
|
var preparePostPurchaseGroupAdmissionView = (widgetId, settings, response, requested, report, excludedProductIds) => {
|
|
7146
|
-
const { memberProductId, ...
|
|
7159
|
+
const { memberProductId, ...selection4 } = PostPurchaseGroupChoice.required({ quantity: true }).parse(requested);
|
|
7147
7160
|
const group = readPostPurchaseGroupSelection(settings, response, requested, excludedProductIds);
|
|
7148
7161
|
if (!group) return null;
|
|
7149
|
-
const variantId =
|
|
7162
|
+
const variantId = selection4.variantId ?? group.variantCatalog.variants.find(({ available }) => available)?.id;
|
|
7150
7163
|
if (variantId === void 0) return null;
|
|
7151
7164
|
const prepared = preparePostPurchaseQuantityAdmissionView(
|
|
7152
7165
|
widgetId,
|
|
7153
7166
|
settings,
|
|
7154
7167
|
group.response,
|
|
7155
|
-
{ ...
|
|
7168
|
+
{ ...selection4, variantId },
|
|
7156
7169
|
report
|
|
7157
7170
|
);
|
|
7158
7171
|
return prepared && {
|
|
@@ -7271,16 +7284,16 @@ var preparePostPurchaseCollectionView = (widgetId, settings, response, report, r
|
|
|
7271
7284
|
|
|
7272
7285
|
// src/schema/postPurchaseOfferEligibility.ts
|
|
7273
7286
|
import { z as z81 } from "zod";
|
|
7274
|
-
var
|
|
7287
|
+
var selection3 = PreparedPostPurchaseProduct.shape.selection;
|
|
7275
7288
|
var PostPurchaseOfferSkipReason = z81.enum(["empty", "no-eligible-subscription"]);
|
|
7276
7289
|
var PostPurchaseOfferEligibilityContext = z81.object({
|
|
7277
7290
|
excludedProductIds: PostPurchaseExcludedProductIds,
|
|
7278
|
-
originalLineItems: z81.array(
|
|
7291
|
+
originalLineItems: z81.array(selection3.pick({ productId: true, sellingPlanId: true, variantId: true }))
|
|
7279
7292
|
});
|
|
7280
7293
|
var PostPurchaseOfferEligibility = z81.discriminatedUnion("status", [
|
|
7281
7294
|
z81.object({
|
|
7282
7295
|
members: z81.array(
|
|
7283
|
-
z81.object({ productId:
|
|
7296
|
+
z81.object({ productId: selection3.shape.productId, productIndex: z81.number().int().nonnegative() })
|
|
7284
7297
|
),
|
|
7285
7298
|
status: z81.literal("retain")
|
|
7286
7299
|
}),
|
|
@@ -7390,12 +7403,12 @@ var Selection = z83.object({
|
|
|
7390
7403
|
variant: OfferDeclineRequestSchema.shape.variant.unwrap()
|
|
7391
7404
|
});
|
|
7392
7405
|
var preparePostPurchaseDeclineDisplay = (settings, response, requested) => {
|
|
7393
|
-
const
|
|
7406
|
+
const selection4 = Selection.parse(requested);
|
|
7394
7407
|
const { members, normalized } = normalizePostPurchaseCollection(settings, response);
|
|
7395
|
-
const found = members.find(({ product }) => product.id ===
|
|
7408
|
+
const found = members.find(({ product }) => product.id === selection4.productId);
|
|
7396
7409
|
if (!found) return null;
|
|
7397
7410
|
const catalog = projectPostPurchaseVariantCatalog(found.product, normalized.effective);
|
|
7398
|
-
const variant2 = catalog.variants.find(({ id }) => id ===
|
|
7411
|
+
const variant2 = catalog.variants.find(({ id }) => id === selection4.variant.variantId);
|
|
7399
7412
|
return variant2 ? { productTitle: found.product.title, variantId: variant2.id, variantTitle: variant2.title } : null;
|
|
7400
7413
|
};
|
|
7401
7414
|
|
|
@@ -268,6 +268,38 @@ export declare const preparePostPurchaseAdmissionView: (widgetId: number, settin
|
|
|
268
268
|
selectedId: number;
|
|
269
269
|
} | undefined;
|
|
270
270
|
};
|
|
271
|
+
changeset?: {
|
|
272
|
+
changes: ({
|
|
273
|
+
quantity: number;
|
|
274
|
+
type: "add_variant";
|
|
275
|
+
variantId: number;
|
|
276
|
+
discount?: {
|
|
277
|
+
title: string;
|
|
278
|
+
value: number;
|
|
279
|
+
valueType: "fixed_amount" | "percentage";
|
|
280
|
+
} | undefined;
|
|
281
|
+
} | {
|
|
282
|
+
price: number;
|
|
283
|
+
title: string;
|
|
284
|
+
type: "add_shipping_line";
|
|
285
|
+
} | {
|
|
286
|
+
initialShippingPrice: number;
|
|
287
|
+
recurringShippingPrice: number;
|
|
288
|
+
shippingOption: {
|
|
289
|
+
presentmentTitle: string;
|
|
290
|
+
title: string;
|
|
291
|
+
};
|
|
292
|
+
quantity: number;
|
|
293
|
+
sellingPlanId: number;
|
|
294
|
+
type: "add_subscription";
|
|
295
|
+
variantId: number;
|
|
296
|
+
discount?: {
|
|
297
|
+
title: string;
|
|
298
|
+
value: number;
|
|
299
|
+
valueType: "fixed_amount" | "percentage";
|
|
300
|
+
} | undefined;
|
|
301
|
+
})[];
|
|
302
|
+
} | undefined;
|
|
271
303
|
groupCatalog?: {
|
|
272
304
|
memberProductId: number;
|
|
273
305
|
options: {
|
|
@@ -305,6 +305,38 @@ export declare const preparePostPurchaseCollectionGroup: (widgetId: number, sett
|
|
|
305
305
|
selectedId: number;
|
|
306
306
|
} | undefined;
|
|
307
307
|
};
|
|
308
|
+
changeset?: {
|
|
309
|
+
changes: ({
|
|
310
|
+
quantity: number;
|
|
311
|
+
type: "add_variant";
|
|
312
|
+
variantId: number;
|
|
313
|
+
discount?: {
|
|
314
|
+
title: string;
|
|
315
|
+
value: number;
|
|
316
|
+
valueType: "fixed_amount" | "percentage";
|
|
317
|
+
} | undefined;
|
|
318
|
+
} | {
|
|
319
|
+
price: number;
|
|
320
|
+
title: string;
|
|
321
|
+
type: "add_shipping_line";
|
|
322
|
+
} | {
|
|
323
|
+
initialShippingPrice: number;
|
|
324
|
+
recurringShippingPrice: number;
|
|
325
|
+
shippingOption: {
|
|
326
|
+
presentmentTitle: string;
|
|
327
|
+
title: string;
|
|
328
|
+
};
|
|
329
|
+
quantity: number;
|
|
330
|
+
sellingPlanId: number;
|
|
331
|
+
type: "add_subscription";
|
|
332
|
+
variantId: number;
|
|
333
|
+
discount?: {
|
|
334
|
+
title: string;
|
|
335
|
+
value: number;
|
|
336
|
+
valueType: "fixed_amount" | "percentage";
|
|
337
|
+
} | undefined;
|
|
338
|
+
})[];
|
|
339
|
+
} | undefined;
|
|
308
340
|
planCatalog?: {
|
|
309
341
|
plans: {
|
|
310
342
|
id: number;
|
|
@@ -290,6 +290,38 @@ export declare const preparePostPurchaseCollectionView: (widgetId: number, setti
|
|
|
290
290
|
selectedId: number;
|
|
291
291
|
} | undefined;
|
|
292
292
|
};
|
|
293
|
+
changeset?: {
|
|
294
|
+
changes: ({
|
|
295
|
+
quantity: number;
|
|
296
|
+
type: "add_variant";
|
|
297
|
+
variantId: number;
|
|
298
|
+
discount?: {
|
|
299
|
+
title: string;
|
|
300
|
+
value: number;
|
|
301
|
+
valueType: "fixed_amount" | "percentage";
|
|
302
|
+
} | undefined;
|
|
303
|
+
} | {
|
|
304
|
+
price: number;
|
|
305
|
+
title: string;
|
|
306
|
+
type: "add_shipping_line";
|
|
307
|
+
} | {
|
|
308
|
+
initialShippingPrice: number;
|
|
309
|
+
recurringShippingPrice: number;
|
|
310
|
+
shippingOption: {
|
|
311
|
+
presentmentTitle: string;
|
|
312
|
+
title: string;
|
|
313
|
+
};
|
|
314
|
+
quantity: number;
|
|
315
|
+
sellingPlanId: number;
|
|
316
|
+
type: "add_subscription";
|
|
317
|
+
variantId: number;
|
|
318
|
+
discount?: {
|
|
319
|
+
title: string;
|
|
320
|
+
value: number;
|
|
321
|
+
valueType: "fixed_amount" | "percentage";
|
|
322
|
+
} | undefined;
|
|
323
|
+
})[];
|
|
324
|
+
} | undefined;
|
|
293
325
|
groupCatalog?: {
|
|
294
326
|
memberProductId: number;
|
|
295
327
|
options: {
|
|
@@ -309,6 +309,38 @@ export declare const preparePostPurchaseGroupAdmissionView: (widgetId: number, s
|
|
|
309
309
|
selectedId: number;
|
|
310
310
|
} | undefined;
|
|
311
311
|
};
|
|
312
|
+
changeset?: {
|
|
313
|
+
changes: ({
|
|
314
|
+
quantity: number;
|
|
315
|
+
type: "add_variant";
|
|
316
|
+
variantId: number;
|
|
317
|
+
discount?: {
|
|
318
|
+
title: string;
|
|
319
|
+
value: number;
|
|
320
|
+
valueType: "fixed_amount" | "percentage";
|
|
321
|
+
} | undefined;
|
|
322
|
+
} | {
|
|
323
|
+
price: number;
|
|
324
|
+
title: string;
|
|
325
|
+
type: "add_shipping_line";
|
|
326
|
+
} | {
|
|
327
|
+
initialShippingPrice: number;
|
|
328
|
+
recurringShippingPrice: number;
|
|
329
|
+
shippingOption: {
|
|
330
|
+
presentmentTitle: string;
|
|
331
|
+
title: string;
|
|
332
|
+
};
|
|
333
|
+
quantity: number;
|
|
334
|
+
sellingPlanId: number;
|
|
335
|
+
type: "add_subscription";
|
|
336
|
+
variantId: number;
|
|
337
|
+
discount?: {
|
|
338
|
+
title: string;
|
|
339
|
+
value: number;
|
|
340
|
+
valueType: "fixed_amount" | "percentage";
|
|
341
|
+
} | undefined;
|
|
342
|
+
})[];
|
|
343
|
+
} | undefined;
|
|
312
344
|
groupCatalog?: {
|
|
313
345
|
memberProductId: number;
|
|
314
346
|
options: {
|
|
@@ -272,6 +272,38 @@ export declare const preparePostPurchaseGroupDefault: (widgetId: number, setting
|
|
|
272
272
|
selectedId: number;
|
|
273
273
|
} | undefined;
|
|
274
274
|
};
|
|
275
|
+
changeset?: {
|
|
276
|
+
changes: ({
|
|
277
|
+
quantity: number;
|
|
278
|
+
type: "add_variant";
|
|
279
|
+
variantId: number;
|
|
280
|
+
discount?: {
|
|
281
|
+
title: string;
|
|
282
|
+
value: number;
|
|
283
|
+
valueType: "fixed_amount" | "percentage";
|
|
284
|
+
} | undefined;
|
|
285
|
+
} | {
|
|
286
|
+
price: number;
|
|
287
|
+
title: string;
|
|
288
|
+
type: "add_shipping_line";
|
|
289
|
+
} | {
|
|
290
|
+
initialShippingPrice: number;
|
|
291
|
+
recurringShippingPrice: number;
|
|
292
|
+
shippingOption: {
|
|
293
|
+
presentmentTitle: string;
|
|
294
|
+
title: string;
|
|
295
|
+
};
|
|
296
|
+
quantity: number;
|
|
297
|
+
sellingPlanId: number;
|
|
298
|
+
type: "add_subscription";
|
|
299
|
+
variantId: number;
|
|
300
|
+
discount?: {
|
|
301
|
+
title: string;
|
|
302
|
+
value: number;
|
|
303
|
+
valueType: "fixed_amount" | "percentage";
|
|
304
|
+
} | undefined;
|
|
305
|
+
})[];
|
|
306
|
+
} | undefined;
|
|
275
307
|
groupCatalog?: {
|
|
276
308
|
memberProductId: number;
|
|
277
309
|
options: {
|
|
@@ -308,6 +308,38 @@ export declare const preparePostPurchaseGroupView: (widgetId: number, settings:
|
|
|
308
308
|
selectedId: number;
|
|
309
309
|
} | undefined;
|
|
310
310
|
};
|
|
311
|
+
changeset?: {
|
|
312
|
+
changes: ({
|
|
313
|
+
quantity: number;
|
|
314
|
+
type: "add_variant";
|
|
315
|
+
variantId: number;
|
|
316
|
+
discount?: {
|
|
317
|
+
title: string;
|
|
318
|
+
value: number;
|
|
319
|
+
valueType: "fixed_amount" | "percentage";
|
|
320
|
+
} | undefined;
|
|
321
|
+
} | {
|
|
322
|
+
price: number;
|
|
323
|
+
title: string;
|
|
324
|
+
type: "add_shipping_line";
|
|
325
|
+
} | {
|
|
326
|
+
initialShippingPrice: number;
|
|
327
|
+
recurringShippingPrice: number;
|
|
328
|
+
shippingOption: {
|
|
329
|
+
presentmentTitle: string;
|
|
330
|
+
title: string;
|
|
331
|
+
};
|
|
332
|
+
quantity: number;
|
|
333
|
+
sellingPlanId: number;
|
|
334
|
+
type: "add_subscription";
|
|
335
|
+
variantId: number;
|
|
336
|
+
discount?: {
|
|
337
|
+
title: string;
|
|
338
|
+
value: number;
|
|
339
|
+
valueType: "fixed_amount" | "percentage";
|
|
340
|
+
} | undefined;
|
|
341
|
+
})[];
|
|
342
|
+
} | undefined;
|
|
311
343
|
groupCatalog?: {
|
|
312
344
|
memberProductId: number;
|
|
313
345
|
options: {
|