@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.cjs
CHANGED
|
@@ -6473,7 +6473,7 @@ var prepareNormalizedProduct = (normalized, report, quantity2, allowCollection =
|
|
|
6473
6473
|
var preparePostPurchaseProduct = (settings, response, report) => prepareNormalizedProduct(normalizePostPurchaseProduct(settings, response), report);
|
|
6474
6474
|
|
|
6475
6475
|
// src/schema/postPurchaseProductView.ts
|
|
6476
|
-
var
|
|
6476
|
+
var import_zod68 = require("zod");
|
|
6477
6477
|
|
|
6478
6478
|
// src/schema/postPurchaseChoice.ts
|
|
6479
6479
|
var import_zod64 = require("zod");
|
|
@@ -6534,14 +6534,79 @@ var PostPurchaseGroupSelection = import_zod66.z.object({
|
|
|
6534
6534
|
productId
|
|
6535
6535
|
});
|
|
6536
6536
|
|
|
6537
|
+
// src/schema/postPurchaseProductCalculation.ts
|
|
6538
|
+
var import_zod67 = require("zod");
|
|
6539
|
+
var MoneyBag = import_zod67.z.object({
|
|
6540
|
+
presentmentMoney: import_zod67.z.object({
|
|
6541
|
+
amount: PostPurchaseAmount,
|
|
6542
|
+
currencyCode: import_zod67.z.string().regex(/^[A-Z]{3}$/)
|
|
6543
|
+
})
|
|
6544
|
+
});
|
|
6545
|
+
var PostPurchaseProductCalculation = import_zod67.z.object({
|
|
6546
|
+
calculatedPurchase: import_zod67.z.object({
|
|
6547
|
+
addedShippingLines: import_zod67.z.array(import_zod67.z.object({ priceSet: MoneyBag })),
|
|
6548
|
+
addedTaxLines: import_zod67.z.array(import_zod67.z.object({ priceSet: MoneyBag })),
|
|
6549
|
+
totalOutstandingSet: MoneyBag,
|
|
6550
|
+
updatedLineItems: import_zod67.z.array(
|
|
6551
|
+
import_zod67.z.object({
|
|
6552
|
+
priceSet: import_zod67.z.unknown().optional(),
|
|
6553
|
+
productId: import_zod67.z.number().int().positive(),
|
|
6554
|
+
sellingPlanId: import_zod67.z.unknown().optional(),
|
|
6555
|
+
variantId: import_zod67.z.number().int().positive()
|
|
6556
|
+
})
|
|
6557
|
+
)
|
|
6558
|
+
}),
|
|
6559
|
+
errors: import_zod67.z.array(import_zod67.z.unknown()).length(0),
|
|
6560
|
+
status: import_zod67.z.literal("processed")
|
|
6561
|
+
});
|
|
6562
|
+
var Minor = import_zod67.z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
6563
|
+
var PostPurchaseProductCosts = import_zod67.z.object({
|
|
6564
|
+
currencyCode: MoneyBag.shape.presentmentMoney.shape.currencyCode,
|
|
6565
|
+
recurringDisplay: import_zod67.z.object({ shippingMinor: Minor, subtotalMinor: Minor, totalMinor: Minor }).optional(),
|
|
6566
|
+
shippingMinor: Minor,
|
|
6567
|
+
subtotalMinor: Minor,
|
|
6568
|
+
taxesMinor: Minor,
|
|
6569
|
+
totalMinor: Minor
|
|
6570
|
+
});
|
|
6571
|
+
var ChangesetDiscount = import_zod67.z.object({
|
|
6572
|
+
title: import_zod67.z.string(),
|
|
6573
|
+
value: import_zod67.z.number().nonnegative(),
|
|
6574
|
+
valueType: import_zod67.z.enum(["percentage", "fixed_amount"])
|
|
6575
|
+
}).optional();
|
|
6576
|
+
var PostPurchaseProductChangeset = import_zod67.z.object({
|
|
6577
|
+
changes: import_zod67.z.array(
|
|
6578
|
+
import_zod67.z.union([
|
|
6579
|
+
import_zod67.z.object({
|
|
6580
|
+
discount: ChangesetDiscount,
|
|
6581
|
+
quantity: import_zod67.z.number().int().positive(),
|
|
6582
|
+
type: import_zod67.z.literal("add_variant"),
|
|
6583
|
+
variantId: import_zod67.z.number().int().positive()
|
|
6584
|
+
}),
|
|
6585
|
+
import_zod67.z.object({ price: import_zod67.z.number().nonnegative(), title: import_zod67.z.string(), type: import_zod67.z.literal("add_shipping_line") }),
|
|
6586
|
+
PostPurchaseSubscriptionTerms.pick({
|
|
6587
|
+
initialShippingPrice: true,
|
|
6588
|
+
recurringShippingPrice: true,
|
|
6589
|
+
shippingOption: true
|
|
6590
|
+
}).extend({
|
|
6591
|
+
discount: ChangesetDiscount,
|
|
6592
|
+
quantity: import_zod67.z.number().int().positive(),
|
|
6593
|
+
sellingPlanId: import_zod67.z.number().int().positive(),
|
|
6594
|
+
type: import_zod67.z.literal("add_subscription"),
|
|
6595
|
+
variantId: import_zod67.z.number().int().positive()
|
|
6596
|
+
})
|
|
6597
|
+
])
|
|
6598
|
+
)
|
|
6599
|
+
});
|
|
6600
|
+
|
|
6537
6601
|
// src/schema/postPurchaseProductView.ts
|
|
6538
|
-
var PostPurchaseProductView =
|
|
6539
|
-
|
|
6602
|
+
var PostPurchaseProductView = import_zod68.z.union([
|
|
6603
|
+
import_zod68.z.object({
|
|
6604
|
+
changeset: PostPurchaseProductChangeset.optional(),
|
|
6540
6605
|
groupCatalog: PostPurchaseGroupCatalog.optional(),
|
|
6541
6606
|
initialVariant: PostPurchaseVariantSelector.optional(),
|
|
6542
6607
|
planCatalog: PostPurchasePlanCatalog.nullable().optional(),
|
|
6543
6608
|
preparation: PreparedPostPurchaseProduct.extend({
|
|
6544
|
-
display: PreparedPostPurchaseProduct.shape.display.extend({ description:
|
|
6609
|
+
display: PreparedPostPurchaseProduct.shape.display.extend({ description: import_zod68.z.string().nullable() }).refine(
|
|
6545
6610
|
({ description, descriptionDocument }) => description === null === (descriptionDocument !== void 0),
|
|
6546
6611
|
"Exactly one of the plain and rich descriptions is shown"
|
|
6547
6612
|
)
|
|
@@ -6550,24 +6615,24 @@ var PostPurchaseProductView = import_zod67.z.union([
|
|
|
6550
6615
|
sections: CABRootSection,
|
|
6551
6616
|
variantCatalog: PostPurchaseVariantCatalog.optional()
|
|
6552
6617
|
}),
|
|
6553
|
-
|
|
6618
|
+
import_zod68.z.object({
|
|
6554
6619
|
groupCatalog: PostPurchaseGroupCatalog.optional(),
|
|
6555
6620
|
initialVariant: PostPurchaseVariantSelector.optional(),
|
|
6556
6621
|
planCatalog: PostPurchasePlanCatalog.nullable().optional(),
|
|
6557
6622
|
preparation: PostPurchasePreparation.options[1],
|
|
6558
6623
|
purchaseOptions: PostPurchaseOptions.optional(),
|
|
6559
|
-
sections:
|
|
6624
|
+
sections: import_zod68.z.null(),
|
|
6560
6625
|
variantCatalog: PostPurchaseVariantCatalog.optional()
|
|
6561
6626
|
})
|
|
6562
6627
|
]);
|
|
6563
6628
|
|
|
6564
6629
|
// src/server/postPurchaseOfferCopy.ts
|
|
6565
|
-
var
|
|
6566
|
-
var Copy =
|
|
6630
|
+
var import_zod69 = require("zod");
|
|
6631
|
+
var Copy = import_zod69.z.object({
|
|
6567
6632
|
superTitle: CalloutBannerBlock.shape.settings.shape.superTitle.unwrap().optional().catch(void 0),
|
|
6568
6633
|
title: CalloutBannerBlock.shape.settings.shape.title.unwrap().optional().catch(void 0)
|
|
6569
6634
|
});
|
|
6570
|
-
var Callout =
|
|
6635
|
+
var Callout = import_zod69.z.object({ settings: import_zod69.z.record(import_zod69.z.string(), import_zod69.z.unknown()), type: import_zod69.z.literal("callout_banner") });
|
|
6571
6636
|
var postPurchaseOfferCopy = (blocks, metadata) => {
|
|
6572
6637
|
const copy = Copy.safeParse(metadata.widget.language);
|
|
6573
6638
|
if (!blocks || !copy.success) return blocks;
|
|
@@ -6681,98 +6746,36 @@ var import_zod73 = require("zod");
|
|
|
6681
6746
|
var import_zod72 = require("zod");
|
|
6682
6747
|
|
|
6683
6748
|
// src/schema/postPurchaseIdentity.ts
|
|
6684
|
-
var
|
|
6749
|
+
var import_zod70 = require("zod");
|
|
6685
6750
|
var POST_PURCHASE_ID_MAX = 128;
|
|
6686
|
-
var PostPurchaseTimestampSchema =
|
|
6687
|
-
var PostPurchaseOrderIdSchema =
|
|
6688
|
-
var ShopifyDomainSchema =
|
|
6689
|
-
var DecideRequestSchema =
|
|
6690
|
-
checkoutToken:
|
|
6751
|
+
var PostPurchaseTimestampSchema = import_zod70.z.number().int().nonnegative();
|
|
6752
|
+
var PostPurchaseOrderIdSchema = import_zod70.z.string().regex(/^gid:\/\/shopify\/Order\/[1-9]\d*$/);
|
|
6753
|
+
var ShopifyDomainSchema = import_zod70.z.string().max(POST_PURCHASE_ID_MAX).regex(/^[a-z0-9]([a-z0-9-]*[a-z0-9])?\.myshopify\.com$/);
|
|
6754
|
+
var DecideRequestSchema = import_zod70.z.object({
|
|
6755
|
+
checkoutToken: import_zod70.z.string().min(1).max(POST_PURCHASE_ID_MAX),
|
|
6691
6756
|
shop: ShopifyDomainSchema
|
|
6692
6757
|
});
|
|
6693
|
-
var PostPurchaseAppIdSchema =
|
|
6694
|
-
var DecisionEntrySchema =
|
|
6695
|
-
blockId:
|
|
6696
|
-
blockIndex:
|
|
6697
|
-
blockParentIndex:
|
|
6698
|
-
flowId:
|
|
6699
|
-
sectionId:
|
|
6700
|
-
widgetId:
|
|
6701
|
-
widgetTraffic:
|
|
6758
|
+
var PostPurchaseAppIdSchema = import_zod70.z.string().min(1).max(POST_PURCHASE_ID_MAX);
|
|
6759
|
+
var DecisionEntrySchema = import_zod70.z.object({
|
|
6760
|
+
blockId: import_zod70.z.number().int().positive(),
|
|
6761
|
+
blockIndex: import_zod70.z.string(),
|
|
6762
|
+
blockParentIndex: import_zod70.z.string(),
|
|
6763
|
+
flowId: import_zod70.z.number().int().positive(),
|
|
6764
|
+
sectionId: import_zod70.z.number().int().positive(),
|
|
6765
|
+
widgetId: import_zod70.z.number().int().positive(),
|
|
6766
|
+
widgetTraffic: import_zod70.z.number().min(0).max(100)
|
|
6702
6767
|
});
|
|
6703
6768
|
|
|
6704
6769
|
// src/schema/postPurchaseMemberIdentity.ts
|
|
6705
|
-
var import_zod70 = require("zod");
|
|
6706
|
-
var PostPurchaseMemberIdentity = import_zod70.z.object({
|
|
6707
|
-
productId: import_zod70.z.number().int().positive(),
|
|
6708
|
-
productIndex: import_zod70.z.number().int().nonnegative()
|
|
6709
|
-
}).strict();
|
|
6710
|
-
|
|
6711
|
-
// src/schema/postPurchaseProductCalculation.ts
|
|
6712
6770
|
var import_zod71 = require("zod");
|
|
6713
|
-
var
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
})
|
|
6718
|
-
});
|
|
6719
|
-
var PostPurchaseProductCalculation = import_zod71.z.object({
|
|
6720
|
-
calculatedPurchase: import_zod71.z.object({
|
|
6721
|
-
addedShippingLines: import_zod71.z.array(import_zod71.z.object({ priceSet: MoneyBag })),
|
|
6722
|
-
addedTaxLines: import_zod71.z.array(import_zod71.z.object({ priceSet: MoneyBag })),
|
|
6723
|
-
totalOutstandingSet: MoneyBag,
|
|
6724
|
-
updatedLineItems: import_zod71.z.array(
|
|
6725
|
-
import_zod71.z.object({
|
|
6726
|
-
priceSet: import_zod71.z.unknown().optional(),
|
|
6727
|
-
productId: import_zod71.z.number().int().positive(),
|
|
6728
|
-
sellingPlanId: import_zod71.z.unknown().optional(),
|
|
6729
|
-
variantId: import_zod71.z.number().int().positive()
|
|
6730
|
-
})
|
|
6731
|
-
)
|
|
6732
|
-
}),
|
|
6733
|
-
errors: import_zod71.z.array(import_zod71.z.unknown()).length(0),
|
|
6734
|
-
status: import_zod71.z.literal("processed")
|
|
6735
|
-
});
|
|
6736
|
-
var Minor = import_zod71.z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
6737
|
-
var PostPurchaseProductCosts = import_zod71.z.object({
|
|
6738
|
-
currencyCode: MoneyBag.shape.presentmentMoney.shape.currencyCode,
|
|
6739
|
-
recurringDisplay: import_zod71.z.object({ shippingMinor: Minor, subtotalMinor: Minor, totalMinor: Minor }).optional(),
|
|
6740
|
-
shippingMinor: Minor,
|
|
6741
|
-
subtotalMinor: Minor,
|
|
6742
|
-
taxesMinor: Minor,
|
|
6743
|
-
totalMinor: Minor
|
|
6744
|
-
});
|
|
6745
|
-
var ChangesetDiscount = import_zod71.z.object({
|
|
6746
|
-
title: import_zod71.z.string(),
|
|
6747
|
-
value: import_zod71.z.number().nonnegative(),
|
|
6748
|
-
valueType: import_zod71.z.enum(["percentage", "fixed_amount"])
|
|
6749
|
-
}).optional();
|
|
6750
|
-
var PostPurchaseProductChangeset = import_zod71.z.object({
|
|
6751
|
-
changes: import_zod71.z.array(
|
|
6752
|
-
import_zod71.z.union([
|
|
6753
|
-
import_zod71.z.object({
|
|
6754
|
-
discount: ChangesetDiscount,
|
|
6755
|
-
quantity: import_zod71.z.number().int().positive(),
|
|
6756
|
-
type: import_zod71.z.literal("add_variant"),
|
|
6757
|
-
variantId: import_zod71.z.number().int().positive()
|
|
6758
|
-
}),
|
|
6759
|
-
import_zod71.z.object({ price: import_zod71.z.number().nonnegative(), title: import_zod71.z.string(), type: import_zod71.z.literal("add_shipping_line") }),
|
|
6760
|
-
PostPurchaseSubscriptionTerms.pick({
|
|
6761
|
-
initialShippingPrice: true,
|
|
6762
|
-
recurringShippingPrice: true,
|
|
6763
|
-
shippingOption: true
|
|
6764
|
-
}).extend({
|
|
6765
|
-
discount: ChangesetDiscount,
|
|
6766
|
-
quantity: import_zod71.z.number().int().positive(),
|
|
6767
|
-
sellingPlanId: import_zod71.z.number().int().positive(),
|
|
6768
|
-
type: import_zod71.z.literal("add_subscription"),
|
|
6769
|
-
variantId: import_zod71.z.number().int().positive()
|
|
6770
|
-
})
|
|
6771
|
-
])
|
|
6772
|
-
)
|
|
6773
|
-
});
|
|
6771
|
+
var PostPurchaseMemberIdentity = import_zod71.z.object({
|
|
6772
|
+
productId: import_zod71.z.number().int().positive(),
|
|
6773
|
+
productIndex: import_zod71.z.number().int().nonnegative()
|
|
6774
|
+
}).strict();
|
|
6774
6775
|
|
|
6775
6776
|
// src/schema/postPurchaseAdmission.ts
|
|
6777
|
+
var PurchaseAdmissionModeSchema = import_zod72.z.enum(["purchase", "upgrade"]);
|
|
6778
|
+
var selection = PreparedPostPurchaseProduct.shape.selection;
|
|
6776
6779
|
var PurchaseExpectedSchema = import_zod72.z.object({
|
|
6777
6780
|
buyerConsentToSubscriptions: import_zod72.z.boolean().optional(),
|
|
6778
6781
|
changeset: PostPurchaseProductChangeset.extend({
|
|
@@ -6780,16 +6783,20 @@ var PurchaseExpectedSchema = import_zod72.z.object({
|
|
|
6780
6783
|
}),
|
|
6781
6784
|
entry: DecisionEntrySchema,
|
|
6782
6785
|
member: PostPurchaseMemberIdentity.optional(),
|
|
6786
|
+
mode: PurchaseAdmissionModeSchema.optional(),
|
|
6783
6787
|
progressRevision: import_zod72.z.number().int().nonnegative().optional(),
|
|
6784
|
-
selection
|
|
6788
|
+
selection
|
|
6785
6789
|
}).refine(
|
|
6786
6790
|
({ member, progressRevision }) => !member || progressRevision !== void 0,
|
|
6787
6791
|
"Captured member requires progress"
|
|
6788
|
-
).refine(
|
|
6792
|
+
).refine(
|
|
6793
|
+
({ mode, selection: { sellingPlanId } }) => mode !== "upgrade" || sellingPlanId !== void 0,
|
|
6794
|
+
"An upgrade selects a subscription"
|
|
6795
|
+
).refine(({ buyerConsentToSubscriptions: consent, changeset, selection: selection4 }) => {
|
|
6789
6796
|
const [change, shipping] = changeset.changes;
|
|
6790
|
-
if (
|
|
6791
|
-
return consent !== true && change?.type === "add_variant" && change.variantId ===
|
|
6792
|
-
return consent === true && changeset.changes.length === 1 && change.type === "add_subscription" && change.sellingPlanId ===
|
|
6797
|
+
if (selection4.sellingPlanId === void 0)
|
|
6798
|
+
return consent !== true && change?.type === "add_variant" && change.variantId === selection4.variantId && change.quantity === selection4.quantity && (shipping === void 0 || shipping.type === "add_shipping_line");
|
|
6799
|
+
return consent === true && changeset.changes.length === 1 && change.type === "add_subscription" && change.sellingPlanId === selection4.sellingPlanId && change.variantId === selection4.variantId && change.quantity === selection4.quantity;
|
|
6793
6800
|
}, "Selection, change and buyer consent must agree");
|
|
6794
6801
|
var PurchaseRequestSchema = DecideRequestSchema.extend({
|
|
6795
6802
|
expected: PurchaseExpectedSchema,
|
|
@@ -6798,12 +6805,18 @@ var PurchaseRequestSchema = DecideRequestSchema.extend({
|
|
|
6798
6805
|
var PurchaseReceiptSchema = import_zod72.z.object({
|
|
6799
6806
|
admittedAt: PostPurchaseTimestampSchema,
|
|
6800
6807
|
changesetToken: import_zod72.z.string().min(1),
|
|
6808
|
+
mode: PurchaseAdmissionModeSchema.optional(),
|
|
6801
6809
|
operationId: import_zod72.z.uuid(),
|
|
6810
|
+
/** The server-bound one-time line an upgrade refunds; its quantity is the order's, not the selection's. */
|
|
6811
|
+
originalLine: import_zod72.z.strictObject({ quantity: selection.shape.quantity, variantId: selection.shape.variantId }).optional(),
|
|
6802
6812
|
requiresSubscriptionConsent: import_zod72.z.boolean(),
|
|
6803
|
-
selection
|
|
6813
|
+
selection
|
|
6804
6814
|
}).refine(
|
|
6805
|
-
({ requiresSubscriptionConsent, selection:
|
|
6815
|
+
({ requiresSubscriptionConsent, selection: selection4 }) => requiresSubscriptionConsent === (selection4.sellingPlanId !== void 0),
|
|
6806
6816
|
"Receipt consent must match its selected plan"
|
|
6817
|
+
).refine(
|
|
6818
|
+
({ mode, originalLine, selection: { sellingPlanId, variantId } }) => mode === "upgrade" ? sellingPlanId !== void 0 && originalLine?.variantId === variantId : originalLine === void 0,
|
|
6819
|
+
"An upgrade Receipt binds the original line of its subscribed variant, and only an upgrade does"
|
|
6807
6820
|
);
|
|
6808
6821
|
var PurchaseResponseSchema = import_zod72.z.object({ data: PurchaseReceiptSchema, successful: import_zod72.z.literal(true) });
|
|
6809
6822
|
|
|
@@ -6945,7 +6958,7 @@ var readPostPurchaseQuantity = ({
|
|
|
6945
6958
|
data,
|
|
6946
6959
|
effective,
|
|
6947
6960
|
original
|
|
6948
|
-
},
|
|
6961
|
+
}, selection4) => {
|
|
6949
6962
|
const positive = PreparedPostPurchaseProduct.shape.selection.shape.quantity;
|
|
6950
6963
|
for (const config of [original, effective]) {
|
|
6951
6964
|
if (!config.quantityInputs.enabled) continue;
|
|
@@ -6958,7 +6971,7 @@ var readPostPurchaseQuantity = ({
|
|
|
6958
6971
|
const policy = PostPurchaseQuantityPolicy.parse(
|
|
6959
6972
|
effective.quantityInputs.enabled ? { ...effective.quantityInputs, initialQuantity } : { enabled: false, initialQuantity, maxValue: initialQuantity, minValue: initialQuantity }
|
|
6960
6973
|
);
|
|
6961
|
-
const requested = "quantity" in
|
|
6974
|
+
const requested = "quantity" in selection4 ? selection4.quantity : selection4.expectedQuantity === initialQuantity ? void 0 : selection4.expectedQuantity;
|
|
6962
6975
|
const quantity2 = positive.parse(requested ?? initialQuantity);
|
|
6963
6976
|
if (requested !== void 0 && (policy.enabled ? quantity2 < policy.minValue || quantity2 > policy.maxValue : quantity2 !== initialQuantity))
|
|
6964
6977
|
throw new PostPurchaseQuantityUnavailable("Requested quantity is unavailable");
|
|
@@ -7102,12 +7115,12 @@ var preparePostPurchaseMemberAdmissionView = (widgetId, settings, response, requ
|
|
|
7102
7115
|
|
|
7103
7116
|
// src/server/preparePostPurchaseQuantityView.ts
|
|
7104
7117
|
var preparePostPurchaseQuantityView = (widgetId, settings, response, requested, report, excludedProductIds, defaults) => {
|
|
7105
|
-
const { quantity: quantity2, ...
|
|
7118
|
+
const { quantity: quantity2, ...selection4 } = PostPurchaseQuantityChoice.parse(requested);
|
|
7106
7119
|
const prepared = prepareMember(
|
|
7107
7120
|
widgetId,
|
|
7108
7121
|
settings,
|
|
7109
7122
|
response,
|
|
7110
|
-
|
|
7123
|
+
selection4,
|
|
7111
7124
|
report,
|
|
7112
7125
|
excludedProductIds,
|
|
7113
7126
|
{ quantity: quantity2 },
|
|
@@ -7117,9 +7130,9 @@ var preparePostPurchaseQuantityView = (widgetId, settings, response, requested,
|
|
|
7117
7130
|
};
|
|
7118
7131
|
|
|
7119
7132
|
// src/server/preparePostPurchaseQuantityAdmissionView.ts
|
|
7120
|
-
var
|
|
7133
|
+
var selection2 = PostPurchaseQuantityChoice.required({ quantity: true });
|
|
7121
7134
|
var preparePostPurchaseQuantityAdmissionView = (widgetId, settings, response, expected, report, excludedProductIds, defaults) => {
|
|
7122
|
-
const { quantity: expectedQuantity, ...requested } =
|
|
7135
|
+
const { quantity: expectedQuantity, ...requested } = selection2.parse(expected);
|
|
7123
7136
|
const prepared = prepareMember(
|
|
7124
7137
|
widgetId,
|
|
7125
7138
|
settings,
|
|
@@ -7172,12 +7185,12 @@ var readPostPurchaseGroup = (product, settings, excludedProductIds) => {
|
|
|
7172
7185
|
|
|
7173
7186
|
// src/server/readPostPurchaseGroupSelection.ts
|
|
7174
7187
|
var readPostPurchaseGroupSelection = (settings, response, requested, excludedProductIds) => {
|
|
7175
|
-
const
|
|
7188
|
+
const selection4 = PostPurchaseGroupSelection.parse(requested);
|
|
7176
7189
|
const { members, normalized } = normalizePostPurchaseCollection(settings, response);
|
|
7177
|
-
const member = members.find(({ product }) => product.id ===
|
|
7190
|
+
const member = members.find(({ product }) => product.id === selection4.memberProductId);
|
|
7178
7191
|
if (!member || !member.product.productGroupVariants.length) return null;
|
|
7179
7192
|
const group = readPostPurchaseGroup(member.product, normalized.effective, excludedProductIds);
|
|
7180
|
-
const entry = group.entries.find(({ product }) => product.id ===
|
|
7193
|
+
const entry = group.entries.find(({ product }) => product.id === selection4.productId);
|
|
7181
7194
|
if (!entry) return null;
|
|
7182
7195
|
return {
|
|
7183
7196
|
groupCatalog: group.catalog,
|
|
@@ -7191,16 +7204,16 @@ var readPostPurchaseGroupSelection = (settings, response, requested, excludedPro
|
|
|
7191
7204
|
|
|
7192
7205
|
// src/server/preparePostPurchaseGroupView.ts
|
|
7193
7206
|
var preparePostPurchaseGroupView = (widgetId, settings, response, requested, report, excludedProductIds) => {
|
|
7194
|
-
const { memberProductId, ...
|
|
7207
|
+
const { memberProductId, ...selection4 } = PostPurchaseGroupChoice.parse(requested);
|
|
7195
7208
|
const group = readPostPurchaseGroupSelection(settings, response, requested, excludedProductIds);
|
|
7196
7209
|
if (!group) return null;
|
|
7197
|
-
const variantId =
|
|
7210
|
+
const variantId = selection4.variantId ?? group.variantCatalog.variants.find(({ available }) => available)?.id;
|
|
7198
7211
|
if (variantId === void 0) return null;
|
|
7199
7212
|
const prepared = preparePostPurchaseQuantityView(
|
|
7200
7213
|
widgetId,
|
|
7201
7214
|
settings,
|
|
7202
7215
|
group.response,
|
|
7203
|
-
{ ...
|
|
7216
|
+
{ ...selection4, variantId },
|
|
7204
7217
|
report
|
|
7205
7218
|
);
|
|
7206
7219
|
return prepared && {
|
|
@@ -7214,16 +7227,16 @@ var preparePostPurchaseGroupView = (widgetId, settings, response, requested, rep
|
|
|
7214
7227
|
|
|
7215
7228
|
// src/server/preparePostPurchaseGroupAdmissionView.ts
|
|
7216
7229
|
var preparePostPurchaseGroupAdmissionView = (widgetId, settings, response, requested, report, excludedProductIds) => {
|
|
7217
|
-
const { memberProductId, ...
|
|
7230
|
+
const { memberProductId, ...selection4 } = PostPurchaseGroupChoice.required({ quantity: true }).parse(requested);
|
|
7218
7231
|
const group = readPostPurchaseGroupSelection(settings, response, requested, excludedProductIds);
|
|
7219
7232
|
if (!group) return null;
|
|
7220
|
-
const variantId =
|
|
7233
|
+
const variantId = selection4.variantId ?? group.variantCatalog.variants.find(({ available }) => available)?.id;
|
|
7221
7234
|
if (variantId === void 0) return null;
|
|
7222
7235
|
const prepared = preparePostPurchaseQuantityAdmissionView(
|
|
7223
7236
|
widgetId,
|
|
7224
7237
|
settings,
|
|
7225
7238
|
group.response,
|
|
7226
|
-
{ ...
|
|
7239
|
+
{ ...selection4, variantId },
|
|
7227
7240
|
report
|
|
7228
7241
|
);
|
|
7229
7242
|
return prepared && {
|
|
@@ -7342,16 +7355,16 @@ var preparePostPurchaseCollectionView = (widgetId, settings, response, report, r
|
|
|
7342
7355
|
|
|
7343
7356
|
// src/schema/postPurchaseOfferEligibility.ts
|
|
7344
7357
|
var import_zod81 = require("zod");
|
|
7345
|
-
var
|
|
7358
|
+
var selection3 = PreparedPostPurchaseProduct.shape.selection;
|
|
7346
7359
|
var PostPurchaseOfferSkipReason = import_zod81.z.enum(["empty", "no-eligible-subscription"]);
|
|
7347
7360
|
var PostPurchaseOfferEligibilityContext = import_zod81.z.object({
|
|
7348
7361
|
excludedProductIds: PostPurchaseExcludedProductIds,
|
|
7349
|
-
originalLineItems: import_zod81.z.array(
|
|
7362
|
+
originalLineItems: import_zod81.z.array(selection3.pick({ productId: true, sellingPlanId: true, variantId: true }))
|
|
7350
7363
|
});
|
|
7351
7364
|
var PostPurchaseOfferEligibility = import_zod81.z.discriminatedUnion("status", [
|
|
7352
7365
|
import_zod81.z.object({
|
|
7353
7366
|
members: import_zod81.z.array(
|
|
7354
|
-
import_zod81.z.object({ productId:
|
|
7367
|
+
import_zod81.z.object({ productId: selection3.shape.productId, productIndex: import_zod81.z.number().int().nonnegative() })
|
|
7355
7368
|
),
|
|
7356
7369
|
status: import_zod81.z.literal("retain")
|
|
7357
7370
|
}),
|
|
@@ -7461,12 +7474,12 @@ var Selection = import_zod83.z.object({
|
|
|
7461
7474
|
variant: OfferDeclineRequestSchema.shape.variant.unwrap()
|
|
7462
7475
|
});
|
|
7463
7476
|
var preparePostPurchaseDeclineDisplay = (settings, response, requested) => {
|
|
7464
|
-
const
|
|
7477
|
+
const selection4 = Selection.parse(requested);
|
|
7465
7478
|
const { members, normalized } = normalizePostPurchaseCollection(settings, response);
|
|
7466
|
-
const found = members.find(({ product }) => product.id ===
|
|
7479
|
+
const found = members.find(({ product }) => product.id === selection4.productId);
|
|
7467
7480
|
if (!found) return null;
|
|
7468
7481
|
const catalog = projectPostPurchaseVariantCatalog(found.product, normalized.effective);
|
|
7469
|
-
const variant2 = catalog.variants.find(({ id }) => id ===
|
|
7482
|
+
const variant2 = catalog.variants.find(({ id }) => id === selection4.variant.variantId);
|
|
7470
7483
|
return variant2 ? { productTitle: found.product.title, variantId: variant2.id, variantTitle: variant2.title } : null;
|
|
7471
7484
|
};
|
|
7472
7485
|
|