@rebuy/rebuy 3.54.0 → 3.55.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/schema/postPurchaseProductSource.d.ts +4 -1
- package/dist/server/index.cjs +475 -429
- package/dist/server/index.d.ts +3 -2
- package/dist/server/index.mjs +475 -429
- package/dist/server/normalizePostPurchaseCollection.d.ts +11 -2
- package/dist/server/normalizePostPurchaseProduct.d.ts +260 -1
- package/dist/server/postPurchasePlanCatalog.d.ts +5 -0
- package/dist/server/readPostPurchaseProductSource.d.ts +70 -0
- package/dist/server/shared.d.ts +2 -1
- package/package.json +1 -1
package/dist/server/index.mjs
CHANGED
|
@@ -6008,7 +6008,7 @@ var validateGifts = async (input, ctx) => {
|
|
|
6008
6008
|
|
|
6009
6009
|
// src/server/normalizePostPurchaseProduct.ts
|
|
6010
6010
|
import { merge } from "es-toolkit/compat";
|
|
6011
|
-
import { z as
|
|
6011
|
+
import { z as z46 } from "zod";
|
|
6012
6012
|
|
|
6013
6013
|
// src/schema/postPurchaseProductSettings.ts
|
|
6014
6014
|
import { z as z44 } from "zod";
|
|
@@ -6089,18 +6089,54 @@ var PostPurchaseProductSettings = PostPurchaseSettings.pick({
|
|
|
6089
6089
|
subscription: z44.unknown().default(PostPurchaseSettings.shape.subscription.parse(void 0))
|
|
6090
6090
|
});
|
|
6091
6091
|
|
|
6092
|
+
// src/server/readPostPurchaseProductSource.ts
|
|
6093
|
+
import { z as z45 } from "zod";
|
|
6094
|
+
var Envelope = PostPurchaseProductSource.extend({ data: z45.array(z45.unknown()) });
|
|
6095
|
+
var Product3 = PostPurchaseProductSource.shape.data.element;
|
|
6096
|
+
var Identified = z45.object({ id: PostPurchaseProductId });
|
|
6097
|
+
var heard = /* @__PURE__ */ new WeakMap();
|
|
6098
|
+
var firstHearing = (response, report) => {
|
|
6099
|
+
const reporters = heard.get(response) ?? /* @__PURE__ */ new WeakSet();
|
|
6100
|
+
heard.set(response, reporters);
|
|
6101
|
+
if (reporters.has(report)) return false;
|
|
6102
|
+
reporters.add(report);
|
|
6103
|
+
return true;
|
|
6104
|
+
};
|
|
6105
|
+
var readPostPurchaseProductSource = (response, report) => {
|
|
6106
|
+
const { data, metadata } = Envelope.parse(deepCamelCase(response));
|
|
6107
|
+
const drift = [];
|
|
6108
|
+
const dropped = [];
|
|
6109
|
+
const products = data.flatMap((raw, productIndex) => {
|
|
6110
|
+
const parsed = Product3.safeParse(raw);
|
|
6111
|
+
if (parsed.success) return [{ product: parsed.data, productIndex }];
|
|
6112
|
+
const id = Identified.safeParse(raw);
|
|
6113
|
+
const issues = parsed.error.issues.map((issue) => ({ ...issue, path: ["data", productIndex, ...issue.path] }));
|
|
6114
|
+
const path = issues[0].path.join(".");
|
|
6115
|
+
dropped.push({ issues, productIndex });
|
|
6116
|
+
drift.push({
|
|
6117
|
+
detail: `Dropped post-purchase product${id.success ? ` ${id.data.id}` : ""}: ${path}`,
|
|
6118
|
+
kind: "product"
|
|
6119
|
+
});
|
|
6120
|
+
return [];
|
|
6121
|
+
});
|
|
6122
|
+
if (report && drift.length && firstHearing(response, report)) drift.forEach((event) => report(event));
|
|
6123
|
+
return { dropped, metadata, products };
|
|
6124
|
+
};
|
|
6125
|
+
|
|
6092
6126
|
// src/server/normalizePostPurchaseProduct.ts
|
|
6093
|
-
var
|
|
6127
|
+
var normalizePostPurchaseSource = (settings, response, report) => {
|
|
6094
6128
|
const original = PostPurchaseProductSettings.parse(deepCamelCase(settings));
|
|
6095
|
-
const {
|
|
6129
|
+
const { dropped, metadata, products } = readPostPurchaseProductSource(response, report);
|
|
6096
6130
|
const overrides = Object.fromEntries(Object.entries(metadata.widget).filter(([key]) => key in original));
|
|
6097
|
-
const discount =
|
|
6131
|
+
const discount = z46.object({ type: z46.string() }).safeParse(overrides.discount);
|
|
6098
6132
|
if (discount.success && discount.data.type === "fixed") {
|
|
6099
|
-
overrides.discount = { ...
|
|
6133
|
+
overrides.discount = { ...z46.record(z46.string(), z46.unknown()).parse(overrides.discount), type: "fixed_amount" };
|
|
6100
6134
|
}
|
|
6101
6135
|
const effective = PostPurchaseProductSettings.parse(merge({}, original, overrides));
|
|
6102
|
-
|
|
6136
|
+
const data = products.map(({ product }) => product);
|
|
6137
|
+
return { dropped, normalized: { data, effective, metadata, original }, products };
|
|
6103
6138
|
};
|
|
6139
|
+
var normalizePostPurchaseProduct = (settings, response, report) => normalizePostPurchaseSource(settings, response, report).normalized;
|
|
6104
6140
|
|
|
6105
6141
|
// src/pricing/amountToCents.ts
|
|
6106
6142
|
var round = (value, precision = 0) => {
|
|
@@ -6125,52 +6161,52 @@ var postPurchasePlanDiscountPercentage = (price, adjustment) => {
|
|
|
6125
6161
|
};
|
|
6126
6162
|
|
|
6127
6163
|
// src/schema/postPurchasePlanCatalog.ts
|
|
6128
|
-
import { z as
|
|
6164
|
+
import { z as z49 } from "zod";
|
|
6129
6165
|
|
|
6130
6166
|
// src/schema/postPurchasePlanAdjustment.ts
|
|
6131
|
-
import { z as
|
|
6167
|
+
import { z as z48 } from "zod";
|
|
6132
6168
|
|
|
6133
6169
|
// src/schema/postPurchaseDiscount.ts
|
|
6134
|
-
import { z as
|
|
6135
|
-
var Discount =
|
|
6136
|
-
amount:
|
|
6137
|
-
title:
|
|
6138
|
-
type:
|
|
6170
|
+
import { z as z47 } from "zod";
|
|
6171
|
+
var Discount = z47.object({
|
|
6172
|
+
amount: z47.number().nonnegative(),
|
|
6173
|
+
title: z47.string(),
|
|
6174
|
+
type: z47.enum(["none", "fixed_amount", "percentage"])
|
|
6139
6175
|
});
|
|
6140
6176
|
var validPostPurchaseDiscount = (discount) => discount.type !== "percentage" || discount.amount <= 100;
|
|
6141
6177
|
var PostPurchaseDiscount = Discount.refine(validPostPurchaseDiscount);
|
|
6142
6178
|
|
|
6143
6179
|
// src/schema/postPurchasePlanAdjustment.ts
|
|
6144
|
-
var PostPurchasePlanAdjustment =
|
|
6180
|
+
var PostPurchasePlanAdjustment = z48.object({
|
|
6145
6181
|
amount: PostPurchaseDiscount.shape.amount,
|
|
6146
|
-
type:
|
|
6182
|
+
type: z48.enum(["percentage", "fixed_amount", "price"])
|
|
6147
6183
|
}).refine(({ amount: amount2, type }) => type === "price" || validPostPurchaseDiscount({ amount: amount2, type }));
|
|
6148
6184
|
|
|
6149
6185
|
// src/schema/postPurchasePlanCatalog.ts
|
|
6150
|
-
var PostPurchasePlanOption =
|
|
6186
|
+
var PostPurchasePlanOption = z49.object({
|
|
6151
6187
|
adjustment: PostPurchasePlanAdjustment.optional(),
|
|
6152
6188
|
/** cab-checkout's `discountPercentage`: the plan's own whole-percent saving on the regular price (`{{subscriptionDiscount}}`). */
|
|
6153
|
-
discountPercentage:
|
|
6154
|
-
id:
|
|
6155
|
-
intervalFrequency:
|
|
6156
|
-
intervalLabel:
|
|
6157
|
-
name:
|
|
6189
|
+
discountPercentage: z49.number().int().min(0).max(100).optional(),
|
|
6190
|
+
id: z49.number().int().positive(),
|
|
6191
|
+
intervalFrequency: z49.string().regex(/^[1-9]\d*$/).optional(),
|
|
6192
|
+
intervalLabel: z49.string().min(1),
|
|
6193
|
+
name: z49.string().min(1)
|
|
6158
6194
|
});
|
|
6159
|
-
var PostPurchasePlanCatalog =
|
|
6160
|
-
plans:
|
|
6161
|
-
productId:
|
|
6162
|
-
requiresSellingPlan:
|
|
6163
|
-
variantId:
|
|
6195
|
+
var PostPurchasePlanCatalog = z49.object({
|
|
6196
|
+
plans: z49.array(PostPurchasePlanOption),
|
|
6197
|
+
productId: z49.number().int().positive(),
|
|
6198
|
+
requiresSellingPlan: z49.boolean(),
|
|
6199
|
+
variantId: z49.number().int().positive()
|
|
6164
6200
|
});
|
|
6165
6201
|
|
|
6166
6202
|
// src/server/postPurchaseLegacyPlans.ts
|
|
6167
|
-
import { z as
|
|
6203
|
+
import { z as z51 } from "zod";
|
|
6168
6204
|
|
|
6169
6205
|
// src/server/postPurchasePlanAdjustment.ts
|
|
6170
|
-
import { z as
|
|
6171
|
-
var SourceAdjustment =
|
|
6206
|
+
import { z as z50 } from "zod";
|
|
6207
|
+
var SourceAdjustment = z50.object({
|
|
6172
6208
|
amount: PostPurchaseProductSettings.shape.discount.shape.amount.unwrap(),
|
|
6173
|
-
type:
|
|
6209
|
+
type: z50.enum(["percentage", "fixed_amount", "amount", "price", "none", "fixed"])
|
|
6174
6210
|
});
|
|
6175
6211
|
var readPostPurchasePlanAdjustment = (raw) => {
|
|
6176
6212
|
const source2 = SourceAdjustment.parse(raw);
|
|
@@ -6189,13 +6225,13 @@ var readPostPurchasePlanAdjustment = (raw) => {
|
|
|
6189
6225
|
var Plan = PostPurchasePlanOption.pick({ id: true, name: true }).extend({
|
|
6190
6226
|
orderIntervalFrequency: PostPurchasePlanOption.shape.intervalFrequency.unwrap(),
|
|
6191
6227
|
orderIntervalUnitType: PostPurchasePlanOption.shape.intervalLabel,
|
|
6192
|
-
shopifyVariantId:
|
|
6228
|
+
shopifyVariantId: z51.string().regex(/^[1-9]\d*$/).nullish()
|
|
6193
6229
|
});
|
|
6194
|
-
var Group =
|
|
6195
|
-
discountAmount:
|
|
6196
|
-
discountType:
|
|
6197
|
-
id:
|
|
6198
|
-
sellingPlans:
|
|
6230
|
+
var Group = z51.object({
|
|
6231
|
+
discountAmount: z51.unknown(),
|
|
6232
|
+
discountType: z51.unknown(),
|
|
6233
|
+
id: z51.number().int().positive(),
|
|
6234
|
+
sellingPlans: z51.array(z51.object({ shopifyVariantId: Plan.shape.shopifyVariantId }).passthrough())
|
|
6199
6235
|
});
|
|
6200
6236
|
var readPostPurchaseLegacyPlans = (raw, variantId) => {
|
|
6201
6237
|
const group = Group.pick({ id: true, sellingPlans: true }).parse(raw);
|
|
@@ -6216,21 +6252,21 @@ var readPostPurchaseLegacyPlans = (raw, variantId) => {
|
|
|
6216
6252
|
};
|
|
6217
6253
|
|
|
6218
6254
|
// src/server/postPurchaseModernPlans.ts
|
|
6219
|
-
import { z as
|
|
6220
|
-
var Groups =
|
|
6221
|
-
|
|
6222
|
-
id:
|
|
6223
|
-
sellingPlans:
|
|
6255
|
+
import { z as z52 } from "zod";
|
|
6256
|
+
var Groups = z52.array(
|
|
6257
|
+
z52.object({
|
|
6258
|
+
id: z52.string().min(1),
|
|
6259
|
+
sellingPlans: z52.unknown()
|
|
6224
6260
|
})
|
|
6225
6261
|
);
|
|
6226
|
-
var Allocations =
|
|
6227
|
-
var Plans =
|
|
6262
|
+
var Allocations = z52.array(z52.object({ sellingPlanGroupId: z52.string().min(1) })).default([]);
|
|
6263
|
+
var Plans = z52.array(
|
|
6228
6264
|
PostPurchasePlanOption.pick({ id: true, name: true }).extend({
|
|
6229
|
-
options:
|
|
6230
|
-
priceAdjustments:
|
|
6265
|
+
options: z52.array(z52.object({ value: z52.string().min(1) })).min(1),
|
|
6266
|
+
priceAdjustments: z52.array(z52.unknown())
|
|
6231
6267
|
})
|
|
6232
6268
|
);
|
|
6233
|
-
var FirstAdjustment =
|
|
6269
|
+
var FirstAdjustment = z52.object({
|
|
6234
6270
|
value: PostPurchaseProductSettings.shape.discount.shape.amount.unwrap(),
|
|
6235
6271
|
valueType: PostPurchasePlanAdjustment.shape.type
|
|
6236
6272
|
});
|
|
@@ -6253,8 +6289,9 @@ var readPostPurchaseModernPlans = (raw, allocations) => {
|
|
|
6253
6289
|
|
|
6254
6290
|
// src/server/postPurchasePlanCatalog.ts
|
|
6255
6291
|
var projectPostPurchasePlanCatalog = (normalized, report) => {
|
|
6292
|
+
const { data } = normalized;
|
|
6293
|
+
if (data.length === 1 && data[0].variants.length > 1) return null;
|
|
6256
6294
|
try {
|
|
6257
|
-
const { data } = normalized;
|
|
6258
6295
|
if (data.length !== 1 || data[0].variants.length !== 1) throw new Error("Ambiguous product");
|
|
6259
6296
|
const product = data[0];
|
|
6260
6297
|
const variant2 = product.variants[0];
|
|
@@ -6285,72 +6322,72 @@ var projectPostPurchasePlanCatalog = (normalized, report) => {
|
|
|
6285
6322
|
};
|
|
6286
6323
|
|
|
6287
6324
|
// src/schema/postPurchaseSubscriptionProduct.ts
|
|
6288
|
-
import { z as
|
|
6325
|
+
import { z as z58 } from "zod";
|
|
6289
6326
|
|
|
6290
6327
|
// src/schema/postPurchaseProduct.ts
|
|
6291
|
-
import { z as
|
|
6328
|
+
import { z as z57 } from "zod";
|
|
6292
6329
|
|
|
6293
6330
|
// src/schema/postPurchaseProductDisplay.ts
|
|
6294
|
-
import { z as
|
|
6331
|
+
import { z as z55 } from "zod";
|
|
6295
6332
|
|
|
6296
6333
|
// src/schema/postPurchaseProductGallery.ts
|
|
6297
|
-
import { z as
|
|
6298
|
-
var PostPurchaseProductGallery =
|
|
6334
|
+
import { z as z53 } from "zod";
|
|
6335
|
+
var PostPurchaseProductGallery = z53.object({
|
|
6299
6336
|
/**
|
|
6300
6337
|
* Show the thumbnail row: the product had more than one image before `images` was capped at the
|
|
6301
6338
|
* sub-image limit, and that limit allows at least one thumbnail. It stays true when the cap leaves one
|
|
6302
6339
|
* image (legacy checks the count before slicing). Older replies omit it; fall back to `images.length > 1`.
|
|
6303
6340
|
*/
|
|
6304
|
-
hasMultiple:
|
|
6305
|
-
images:
|
|
6306
|
-
|
|
6307
|
-
description:
|
|
6308
|
-
id:
|
|
6309
|
-
source:
|
|
6310
|
-
thumbnail:
|
|
6341
|
+
hasMultiple: z53.boolean().optional(),
|
|
6342
|
+
images: z53.array(
|
|
6343
|
+
z53.object({
|
|
6344
|
+
description: z53.string(),
|
|
6345
|
+
id: z53.number().int().positive(),
|
|
6346
|
+
source: z53.string(),
|
|
6347
|
+
thumbnail: z53.string()
|
|
6311
6348
|
})
|
|
6312
6349
|
),
|
|
6313
|
-
selectedImageId:
|
|
6350
|
+
selectedImageId: z53.number().int().positive().optional()
|
|
6314
6351
|
});
|
|
6315
6352
|
|
|
6316
6353
|
// src/schema/postPurchaseProductReviews.ts
|
|
6317
|
-
import { z as
|
|
6318
|
-
var decimal =
|
|
6319
|
-
|
|
6320
|
-
|
|
6354
|
+
import { z as z54 } from "zod";
|
|
6355
|
+
var decimal = z54.union([
|
|
6356
|
+
z54.number(),
|
|
6357
|
+
z54.string().regex(/^\d+(?:\.\d+)?$/).transform(Number)
|
|
6321
6358
|
]);
|
|
6322
|
-
var PostPurchaseCommonReviewRating =
|
|
6359
|
+
var PostPurchaseCommonReviewRating = z54.object({ value: decimal.pipe(z54.number().min(0).max(5)) });
|
|
6323
6360
|
var PostPurchaseKlaviyoReviewRating = PostPurchaseCommonReviewRating.extend({
|
|
6324
6361
|
// Legacy validates key presence, then displays the raw value on five stars without rescaling.
|
|
6325
|
-
scale_max:
|
|
6326
|
-
scale_min:
|
|
6362
|
+
scale_max: z54.unknown().nonoptional(),
|
|
6363
|
+
scale_min: z54.unknown().nonoptional()
|
|
6327
6364
|
});
|
|
6328
|
-
var PostPurchaseReviewCount =
|
|
6365
|
+
var PostPurchaseReviewCount = z54.string().regex(/^\d+(?:\.\d+)?$/).transform(Number).pipe(z54.number().int().nonnegative());
|
|
6329
6366
|
var PostPurchaseReviewStyles = PostPurchaseSettings.shape.styles.unwrap().extend({
|
|
6330
|
-
strokeWidth: decimal.pipe(
|
|
6367
|
+
strokeWidth: decimal.pipe(z54.number().nonnegative()).default(1)
|
|
6331
6368
|
}).prefault({});
|
|
6332
|
-
var PostPurchaseProductReviews =
|
|
6333
|
-
color:
|
|
6334
|
-
rating:
|
|
6335
|
-
reviewCount:
|
|
6336
|
-
reviewsPlural:
|
|
6337
|
-
reviewsSingular:
|
|
6338
|
-
size:
|
|
6339
|
-
strokeColor:
|
|
6340
|
-
strokeWidth:
|
|
6369
|
+
var PostPurchaseProductReviews = z54.object({
|
|
6370
|
+
color: z54.string(),
|
|
6371
|
+
rating: z54.number().positive().max(5),
|
|
6372
|
+
reviewCount: z54.number().int().nonnegative(),
|
|
6373
|
+
reviewsPlural: z54.string(),
|
|
6374
|
+
reviewsSingular: z54.string(),
|
|
6375
|
+
size: z54.enum(["small", "medium", "large"]),
|
|
6376
|
+
strokeColor: z54.string(),
|
|
6377
|
+
strokeWidth: z54.number().nonnegative()
|
|
6341
6378
|
});
|
|
6342
6379
|
|
|
6343
6380
|
// src/schema/postPurchaseProductDisplay.ts
|
|
6344
6381
|
var language = PostPurchaseSettings.shape.language;
|
|
6345
|
-
var PostPurchasePrimaryImageSource =
|
|
6382
|
+
var PostPurchasePrimaryImageSource = z55.string().default(
|
|
6346
6383
|
"https://cdn.shopify.com/shopifycloud/shopify/assets/no-image-2048-5e88c1b20e087fb7bbe9a3771824e743c244f437e4f8ba93bbf7b11b53f7824c.gif"
|
|
6347
6384
|
);
|
|
6348
|
-
var PostPurchaseProductDisplay =
|
|
6385
|
+
var PostPurchaseProductDisplay = z55.object({
|
|
6349
6386
|
descriptionDocument: TiptapDocument.optional(),
|
|
6350
6387
|
discountedFrom: PostPurchaseSettings.shape.discountedFrom,
|
|
6351
6388
|
gallery: PostPurchaseProductGallery.optional(),
|
|
6352
6389
|
language: language.pick({ description: true, descriptionEnabled: true }),
|
|
6353
|
-
primaryImage:
|
|
6390
|
+
primaryImage: z55.object({ description: z55.string(), source: z55.string() }),
|
|
6354
6391
|
productOptions: PostPurchaseSettings.shape.productOptions.pick({
|
|
6355
6392
|
showDeclineAll: true,
|
|
6356
6393
|
showShipping: true,
|
|
@@ -6365,14 +6402,14 @@ var PostPurchaseProductDisplay = z54.object({
|
|
|
6365
6402
|
});
|
|
6366
6403
|
|
|
6367
6404
|
// src/schema/postPurchaseSubscription.ts
|
|
6368
|
-
import { z as
|
|
6369
|
-
var PostPurchaseSubscriptionTerms =
|
|
6405
|
+
import { z as z56 } from "zod";
|
|
6406
|
+
var PostPurchaseSubscriptionTerms = z56.object({
|
|
6370
6407
|
adjustment: PostPurchasePlanAdjustment.optional(),
|
|
6371
|
-
initialShippingPrice:
|
|
6372
|
-
intervalLabel:
|
|
6373
|
-
name:
|
|
6374
|
-
recurringShippingPrice:
|
|
6375
|
-
shippingOption:
|
|
6408
|
+
initialShippingPrice: z56.number().nonnegative(),
|
|
6409
|
+
intervalLabel: z56.string().min(1),
|
|
6410
|
+
name: z56.string().min(1),
|
|
6411
|
+
recurringShippingPrice: z56.number().nonnegative(),
|
|
6412
|
+
shippingOption: z56.object({ presentmentTitle: z56.string(), title: z56.string() })
|
|
6376
6413
|
});
|
|
6377
6414
|
|
|
6378
6415
|
// src/schema/postPurchaseProduct.ts
|
|
@@ -6382,52 +6419,52 @@ var PostPurchaseVariant = OfferProduct.shape.variants.element.pick({ id: true, t
|
|
|
6382
6419
|
id: PostPurchaseVariantId,
|
|
6383
6420
|
price: PostPurchaseAmount
|
|
6384
6421
|
});
|
|
6385
|
-
var PreparedPostPurchaseProduct =
|
|
6422
|
+
var PreparedPostPurchaseProduct = z57.object({
|
|
6386
6423
|
display: PostPurchaseProductDisplay,
|
|
6387
|
-
labels:
|
|
6424
|
+
labels: z57.object({
|
|
6388
6425
|
declineAll: global.declineAll,
|
|
6389
|
-
free:
|
|
6426
|
+
free: z57.string(),
|
|
6390
6427
|
notAvailable: global.notAvailable,
|
|
6391
|
-
payNow:
|
|
6392
|
-
quantity:
|
|
6428
|
+
payNow: z57.string(),
|
|
6429
|
+
quantity: z57.string(),
|
|
6393
6430
|
recurringShipping: global.recurringShipping,
|
|
6394
6431
|
recurringSubtotal: global.recurringSubtotal,
|
|
6395
|
-
save:
|
|
6396
|
-
shipping:
|
|
6397
|
-
subtotal:
|
|
6398
|
-
taxes:
|
|
6399
|
-
total:
|
|
6432
|
+
save: z57.string(),
|
|
6433
|
+
shipping: z57.string(),
|
|
6434
|
+
subtotal: z57.string(),
|
|
6435
|
+
taxes: z57.string(),
|
|
6436
|
+
total: z57.string()
|
|
6400
6437
|
}),
|
|
6401
6438
|
product: OfferProduct.pick({ description: true, id: true, image: true, title: true }).extend({
|
|
6402
6439
|
description: OfferProduct.shape.description.nullable(),
|
|
6403
6440
|
id: PostPurchaseProductId,
|
|
6404
6441
|
variant: PostPurchaseVariant
|
|
6405
6442
|
}),
|
|
6406
|
-
selection:
|
|
6443
|
+
selection: z57.object({
|
|
6407
6444
|
productId: PostPurchaseProductId,
|
|
6408
|
-
quantity:
|
|
6409
|
-
sellingPlanId:
|
|
6445
|
+
quantity: z57.number().int().positive(),
|
|
6446
|
+
sellingPlanId: z57.number().int().positive().optional(),
|
|
6410
6447
|
variantId: PostPurchaseVariantId
|
|
6411
6448
|
}),
|
|
6412
|
-
status:
|
|
6413
|
-
terms:
|
|
6449
|
+
status: z57.literal("prepared"),
|
|
6450
|
+
terms: z57.object({
|
|
6414
6451
|
discount: PostPurchaseDiscount,
|
|
6415
|
-
shipping:
|
|
6416
|
-
amount:
|
|
6417
|
-
title:
|
|
6418
|
-
type:
|
|
6452
|
+
shipping: z57.object({
|
|
6453
|
+
amount: z57.number().nonnegative(),
|
|
6454
|
+
title: z57.string(),
|
|
6455
|
+
type: z57.enum(["free", "fixed_amount"])
|
|
6419
6456
|
}),
|
|
6420
6457
|
subscription: PostPurchaseSubscriptionTerms.optional()
|
|
6421
6458
|
})
|
|
6422
6459
|
});
|
|
6423
|
-
var PostPurchasePreparation =
|
|
6460
|
+
var PostPurchasePreparation = z57.discriminatedUnion("status", [
|
|
6424
6461
|
PreparedPostPurchaseProduct,
|
|
6425
|
-
|
|
6462
|
+
z57.object({ reason: z57.string(), status: z57.literal("unsupported") })
|
|
6426
6463
|
]);
|
|
6427
6464
|
|
|
6428
6465
|
// src/schema/postPurchaseSubscriptionProduct.ts
|
|
6429
6466
|
var PreparedPostPurchaseSubscription = PreparedPostPurchaseProduct.extend({
|
|
6430
|
-
selection: PreparedPostPurchaseProduct.shape.selection.extend({ sellingPlanId:
|
|
6467
|
+
selection: PreparedPostPurchaseProduct.shape.selection.extend({ sellingPlanId: z58.number().int().positive() }),
|
|
6431
6468
|
terms: PreparedPostPurchaseProduct.shape.terms.extend({
|
|
6432
6469
|
subscription: PostPurchaseSubscriptionTerms
|
|
6433
6470
|
}).refine(
|
|
@@ -6486,7 +6523,7 @@ var subscriptionUnavailable = (normalized, plan, allowCollection, quantity3) =>
|
|
|
6486
6523
|
};
|
|
6487
6524
|
|
|
6488
6525
|
// src/server/postPurchaseProductDisplay.ts
|
|
6489
|
-
import { z as
|
|
6526
|
+
import { z as z60 } from "zod";
|
|
6490
6527
|
|
|
6491
6528
|
// src/server/postPurchasePrimaryImage.ts
|
|
6492
6529
|
var postPurchasePrimaryImage = (product) => {
|
|
@@ -6512,7 +6549,7 @@ var postPurchaseProductGallery = (product, limit) => {
|
|
|
6512
6549
|
};
|
|
6513
6550
|
|
|
6514
6551
|
// src/transforms/postPurchase/convertDescriptionRte.ts
|
|
6515
|
-
import { z as
|
|
6552
|
+
import { z as z59 } from "zod";
|
|
6516
6553
|
var alignments = { center: "center", left: "start", right: "end" };
|
|
6517
6554
|
var colors = ["critical", "subdued", "success", "warning"];
|
|
6518
6555
|
var sizes2 = ["extraSmall", "small", "medium", "large", "extraLarge"];
|
|
@@ -6524,19 +6561,19 @@ var spacings2 = {
|
|
|
6524
6561
|
xloose: "extraLoose",
|
|
6525
6562
|
xtight: "extraTight"
|
|
6526
6563
|
};
|
|
6527
|
-
var Block =
|
|
6528
|
-
attrs:
|
|
6529
|
-
content:
|
|
6530
|
-
type:
|
|
6531
|
-
});
|
|
6532
|
-
var Run =
|
|
6533
|
-
var Inline =
|
|
6534
|
-
attrs:
|
|
6535
|
-
color:
|
|
6536
|
-
emphasis:
|
|
6537
|
-
size:
|
|
6564
|
+
var Block = z59.object({
|
|
6565
|
+
attrs: z59.object({ alignment: z59.enum(["left", "center", "right"]).optional().catch(void 0) }).catch({}),
|
|
6566
|
+
content: z59.array(z59.unknown()).catch([]),
|
|
6567
|
+
type: z59.literal("ShopifyTextBlock")
|
|
6568
|
+
});
|
|
6569
|
+
var Run = z59.object({ marks: z59.array(z59.unknown()).catch([]), text: z59.string().min(1), type: z59.literal("text") });
|
|
6570
|
+
var Inline = z59.object({
|
|
6571
|
+
attrs: z59.object({
|
|
6572
|
+
color: z59.enum(colors).optional().catch(void 0),
|
|
6573
|
+
emphasis: z59.array(z59.unknown()).catch([]),
|
|
6574
|
+
size: z59.enum(sizes2).optional().catch(void 0)
|
|
6538
6575
|
}),
|
|
6539
|
-
type:
|
|
6576
|
+
type: z59.literal("ShopifyTextInline")
|
|
6540
6577
|
});
|
|
6541
6578
|
var marks = (raw) => {
|
|
6542
6579
|
const found = raw.map((mark) => Inline.safeParse(mark)).find(({ success }) => success)?.data;
|
|
@@ -6569,7 +6606,7 @@ var convertDescriptionRte = (rte, spacing) => TiptapDocument.parse({
|
|
|
6569
6606
|
});
|
|
6570
6607
|
|
|
6571
6608
|
// src/server/postPurchaseProductDisplay.ts
|
|
6572
|
-
var ResponseLanguage =
|
|
6609
|
+
var ResponseLanguage = z60.object({ description: PostPurchaseProductDisplay.shape.responseDescription }).default({ description: "" });
|
|
6573
6610
|
var projectPostPurchaseProductDisplay = (effective, metadata, product) => PostPurchaseProductDisplay.parse({
|
|
6574
6611
|
descriptionDocument: effective.language.descriptionRte && convertDescriptionRte(effective.language.descriptionRte, effective.language.descriptionSpacing),
|
|
6575
6612
|
discountedFrom: effective.discountedFrom,
|
|
@@ -6582,16 +6619,16 @@ var projectPostPurchaseProductDisplay = (effective, metadata, product) => PostPu
|
|
|
6582
6619
|
});
|
|
6583
6620
|
|
|
6584
6621
|
// src/server/postPurchaseReviewData.ts
|
|
6585
|
-
import { z as
|
|
6622
|
+
import { z as z65 } from "zod";
|
|
6586
6623
|
|
|
6587
6624
|
// src/server/postPurchaseJudgeMeReviews.ts
|
|
6588
|
-
import { z as
|
|
6625
|
+
import { z as z62 } from "zod";
|
|
6589
6626
|
|
|
6590
6627
|
// src/server/postPurchaseReviewFields.ts
|
|
6591
|
-
import { z as
|
|
6592
|
-
var Field =
|
|
6628
|
+
import { z as z61 } from "zod";
|
|
6629
|
+
var Field = z61.object({ key: z61.string(), namespace: z61.string(), value: z61.unknown().optional() });
|
|
6593
6630
|
var reviewFields = (raw) => {
|
|
6594
|
-
const fields4 =
|
|
6631
|
+
const fields4 = z61.array(z61.unknown()).parse(raw).flatMap((field) => {
|
|
6595
6632
|
const parsed = Field.safeParse(field);
|
|
6596
6633
|
return parsed.success ? [parsed.data] : [];
|
|
6597
6634
|
});
|
|
@@ -6616,7 +6653,7 @@ var readJudgeMeReviews = (find) => {
|
|
|
6616
6653
|
const field = find("judgeme", "badge");
|
|
6617
6654
|
if (!field) return null;
|
|
6618
6655
|
return readReviewField(field, (value) => {
|
|
6619
|
-
const html =
|
|
6656
|
+
const html = z62.string().parse(value);
|
|
6620
6657
|
const rating = html.match(/data-average-rating=['"](\d+(?:\.\d+)?)['"]/);
|
|
6621
6658
|
const count = html.match(/data-number-of-reviews=['"](\d+)['"]/);
|
|
6622
6659
|
if (!rating || !count) throw new Error("Unreadable Judge.me attributes");
|
|
@@ -6628,20 +6665,20 @@ var readJudgeMeReviews = (find) => {
|
|
|
6628
6665
|
};
|
|
6629
6666
|
|
|
6630
6667
|
// src/server/postPurchaseOkendoReviews.ts
|
|
6631
|
-
import { z as
|
|
6632
|
-
var Summary =
|
|
6668
|
+
import { z as z63 } from "zod";
|
|
6669
|
+
var Summary = z63.object({
|
|
6633
6670
|
reviewAverageValue: PostPurchaseCommonReviewRating.shape.value,
|
|
6634
|
-
reviewCount:
|
|
6671
|
+
reviewCount: z63.union([PostPurchaseProductReviews.shape.reviewCount, PostPurchaseReviewCount])
|
|
6635
6672
|
});
|
|
6636
6673
|
var readOkendoReviews = (find) => {
|
|
6637
6674
|
const field = find("okendo", "summaryData");
|
|
6638
6675
|
if (!field) return null;
|
|
6639
|
-
const summary = readReviewField(field, (value) => Summary.parse(JSON.parse(
|
|
6676
|
+
const summary = readReviewField(field, (value) => Summary.parse(JSON.parse(z63.string().parse(value))));
|
|
6640
6677
|
return { rating: summary.reviewAverageValue, reviewCount: summary.reviewCount };
|
|
6641
6678
|
};
|
|
6642
6679
|
|
|
6643
6680
|
// src/server/postPurchaseScalarReviews.ts
|
|
6644
|
-
import { z as
|
|
6681
|
+
import { z as z64 } from "zod";
|
|
6645
6682
|
var readScalarReviews = (find, namespace, ratingKey, countKey) => {
|
|
6646
6683
|
const rating = find(namespace, ratingKey);
|
|
6647
6684
|
const count = find(namespace, countKey);
|
|
@@ -6649,7 +6686,7 @@ var readScalarReviews = (find, namespace, ratingKey, countKey) => {
|
|
|
6649
6686
|
return {
|
|
6650
6687
|
rating: readReviewField(
|
|
6651
6688
|
rating,
|
|
6652
|
-
(value) => PostPurchaseCommonReviewRating.parse({ value:
|
|
6689
|
+
(value) => PostPurchaseCommonReviewRating.parse({ value: z64.string().parse(value) }).value
|
|
6653
6690
|
),
|
|
6654
6691
|
reviewCount: readReviewField(count, (value) => PostPurchaseReviewCount.parse(value))
|
|
6655
6692
|
};
|
|
@@ -6662,7 +6699,7 @@ var readStandardReviews = (find) => {
|
|
|
6662
6699
|
if (!rating || !count) return null;
|
|
6663
6700
|
return {
|
|
6664
6701
|
rating: readReviewField(rating, (raw) => {
|
|
6665
|
-
const value =
|
|
6702
|
+
const value = z65.string().parse(raw);
|
|
6666
6703
|
return PostPurchaseCommonReviewRating.parse(/^\d+(?:\.\d+)?$/.test(value) ? { value } : JSON.parse(value)).value;
|
|
6667
6704
|
}),
|
|
6668
6705
|
reviewCount: readReviewField(count, (value) => PostPurchaseReviewCount.parse(value))
|
|
@@ -6684,15 +6721,15 @@ var readPostPurchaseReviewData = (provider, find) => {
|
|
|
6684
6721
|
return {
|
|
6685
6722
|
rating: readReviewField(
|
|
6686
6723
|
rating,
|
|
6687
|
-
(value) => PostPurchaseKlaviyoReviewRating.parse(JSON.parse(
|
|
6724
|
+
(value) => PostPurchaseKlaviyoReviewRating.parse(JSON.parse(z65.string().parse(value))).value
|
|
6688
6725
|
),
|
|
6689
6726
|
reviewCount: readReviewField(count, (value) => PostPurchaseReviewCount.parse(value))
|
|
6690
6727
|
};
|
|
6691
6728
|
};
|
|
6692
6729
|
|
|
6693
6730
|
// src/server/postPurchaseReviewProvider.ts
|
|
6694
|
-
import { z as
|
|
6695
|
-
var IntegrationInput =
|
|
6731
|
+
import { z as z66 } from "zod";
|
|
6732
|
+
var IntegrationInput = z66.record(z66.string(), z66.unknown()).prefault({});
|
|
6696
6733
|
var precedence = [
|
|
6697
6734
|
"klaviyo",
|
|
6698
6735
|
"judgeme",
|
|
@@ -6704,7 +6741,7 @@ var precedence = [
|
|
|
6704
6741
|
"stamped",
|
|
6705
6742
|
"yotpo"
|
|
6706
6743
|
];
|
|
6707
|
-
var ReviewsIoFlag =
|
|
6744
|
+
var ReviewsIoFlag = z66.preprocess((value) => {
|
|
6708
6745
|
if (typeof value === "string") {
|
|
6709
6746
|
const flag = value.toLowerCase();
|
|
6710
6747
|
if (flag === "true" || flag === "yes") return true;
|
|
@@ -6805,7 +6842,7 @@ var prepareNormalizedSubscription = (normalized, report, plan, quantity3, allowC
|
|
|
6805
6842
|
|
|
6806
6843
|
// src/server/preparePostPurchaseSubscription.ts
|
|
6807
6844
|
var preparePostPurchaseSubscription = (settings, response, report) => {
|
|
6808
|
-
const normalized = normalizePostPurchaseProduct(settings, response);
|
|
6845
|
+
const normalized = normalizePostPurchaseProduct(settings, response, report);
|
|
6809
6846
|
return prepareNormalizedSubscription(
|
|
6810
6847
|
normalized,
|
|
6811
6848
|
report,
|
|
@@ -6843,42 +6880,42 @@ var prepareNormalizedProduct = (normalized, report, quantity3, allowCollection =
|
|
|
6843
6880
|
}
|
|
6844
6881
|
});
|
|
6845
6882
|
};
|
|
6846
|
-
var preparePostPurchaseProduct = (settings, response, report) => prepareNormalizedProduct(normalizePostPurchaseProduct(settings, response), report);
|
|
6883
|
+
var preparePostPurchaseProduct = (settings, response, report) => prepareNormalizedProduct(normalizePostPurchaseProduct(settings, response, report), report);
|
|
6847
6884
|
|
|
6848
6885
|
// src/schema/postPurchaseProductView.ts
|
|
6849
|
-
import { z as
|
|
6886
|
+
import { z as z73 } from "zod";
|
|
6850
6887
|
|
|
6851
6888
|
// src/schema/postPurchaseChoice.ts
|
|
6852
|
-
import { z as
|
|
6853
|
-
var PostPurchaseChoice =
|
|
6854
|
-
|
|
6855
|
-
|
|
6889
|
+
import { z as z67 } from "zod";
|
|
6890
|
+
var PostPurchaseChoice = z67.discriminatedUnion("mode", [
|
|
6891
|
+
z67.object({ mode: z67.literal("one-time") }).strict(),
|
|
6892
|
+
z67.object({ mode: z67.literal("subscription"), sellingPlanId: PostPurchasePlanOption.shape.id }).strict()
|
|
6856
6893
|
]);
|
|
6857
|
-
var PostPurchaseOptions =
|
|
6894
|
+
var PostPurchaseOptions = z67.object({
|
|
6858
6895
|
defaultChoice: PostPurchaseChoice,
|
|
6859
|
-
modes:
|
|
6896
|
+
modes: z67.array(z67.enum(["one-time", "subscription"])).min(1).max(2),
|
|
6860
6897
|
selector: PostPurchaseSettings.shape.productTypeSelector
|
|
6861
6898
|
});
|
|
6862
6899
|
|
|
6863
6900
|
// src/schema/postPurchaseDisplayPrice.ts
|
|
6864
|
-
import { z as
|
|
6901
|
+
import { z as z69 } from "zod";
|
|
6865
6902
|
|
|
6866
6903
|
// src/schema/postPurchaseSubscriptionDisplay.ts
|
|
6867
|
-
import { z as
|
|
6868
|
-
var Minor =
|
|
6869
|
-
var PostPurchaseSubscriptionDisplay =
|
|
6904
|
+
import { z as z68 } from "zod";
|
|
6905
|
+
var Minor = z68.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
6906
|
+
var PostPurchaseSubscriptionDisplay = z68.object({
|
|
6870
6907
|
comparisonMinor: Minor,
|
|
6871
|
-
currencyCode:
|
|
6908
|
+
currencyCode: z68.string().regex(/^[A-Z]{3}$/),
|
|
6872
6909
|
priceMinor: Minor,
|
|
6873
6910
|
savingMinor: Minor,
|
|
6874
|
-
savingPercent:
|
|
6911
|
+
savingPercent: z68.number().int().min(0).max(100)
|
|
6875
6912
|
});
|
|
6876
6913
|
|
|
6877
6914
|
// src/schema/postPurchaseDisplayPrice.ts
|
|
6878
6915
|
var { currencyCode: CurrencyCode, priceMinor: Minor2, savingPercent: Percent } = PostPurchaseSubscriptionDisplay.shape;
|
|
6879
|
-
var PostPurchaseDisplayPrice =
|
|
6916
|
+
var PostPurchaseDisplayPrice = z69.object({
|
|
6880
6917
|
currencyCode: CurrencyCode,
|
|
6881
|
-
savingFormat:
|
|
6918
|
+
savingFormat: z69.enum(["amount", "percent"]).nullable(),
|
|
6882
6919
|
savingMinor: Minor2,
|
|
6883
6920
|
savingPercent: Percent,
|
|
6884
6921
|
subscriptionUnit: PostPurchaseSubscriptionDisplay.optional(),
|
|
@@ -6896,30 +6933,30 @@ var PostPurchaseDisplayPrice = z68.object({
|
|
|
6896
6933
|
);
|
|
6897
6934
|
|
|
6898
6935
|
// src/schema/postPurchaseGroupCatalog.ts
|
|
6899
|
-
import { z as
|
|
6936
|
+
import { z as z71 } from "zod";
|
|
6900
6937
|
|
|
6901
6938
|
// src/schema/postPurchaseVariantCatalog.ts
|
|
6902
|
-
import { z as
|
|
6903
|
-
var PostPurchaseVariantSelector =
|
|
6939
|
+
import { z as z70 } from "zod";
|
|
6940
|
+
var PostPurchaseVariantSelector = z70.object({ variantId: PostPurchaseVariantId }).strict();
|
|
6904
6941
|
var PostPurchaseVariantOption = OfferProduct.shape.options.element.extend({
|
|
6905
|
-
id:
|
|
6906
|
-
position:
|
|
6942
|
+
id: z70.number().int().positive().optional(),
|
|
6943
|
+
position: z70.number().int().min(1).max(3)
|
|
6907
6944
|
});
|
|
6908
6945
|
var PostPurchaseVariantValues = OfferProduct.shape.variants.element.pick({
|
|
6909
6946
|
option1: true,
|
|
6910
6947
|
option2: true,
|
|
6911
6948
|
option3: true
|
|
6912
6949
|
});
|
|
6913
|
-
var PostPurchaseVariantCatalog =
|
|
6950
|
+
var PostPurchaseVariantCatalog = z70.object({
|
|
6914
6951
|
displayMode: PostPurchaseSettings.shape.productOptions.shape.variantSelectorDisplayMode,
|
|
6915
|
-
options:
|
|
6952
|
+
options: z70.array(PostPurchaseVariantOption),
|
|
6916
6953
|
productId: PostPurchaseProductId,
|
|
6917
6954
|
showSelectors: PostPurchaseSettings.shape.productOptions.shape.showVariantSelectors,
|
|
6918
|
-
variants:
|
|
6955
|
+
variants: z70.array(
|
|
6919
6956
|
PostPurchaseVariantValues.partial().extend({
|
|
6920
|
-
available:
|
|
6957
|
+
available: z70.boolean(),
|
|
6921
6958
|
id: PostPurchaseVariantId,
|
|
6922
|
-
imageId:
|
|
6959
|
+
imageId: z70.number().int().nonnegative().nullish(),
|
|
6923
6960
|
title: OfferProduct.shape.variants.element.shape.title
|
|
6924
6961
|
})
|
|
6925
6962
|
)
|
|
@@ -6933,89 +6970,89 @@ var PostPurchaseGroupDescription = source.pick({ description: true, id: true, im
|
|
|
6933
6970
|
image: source.shape.image.default(null),
|
|
6934
6971
|
options: PostPurchaseVariantCatalog.shape.options.default([])
|
|
6935
6972
|
});
|
|
6936
|
-
var PostPurchaseGroupCatalog =
|
|
6973
|
+
var PostPurchaseGroupCatalog = z71.object({
|
|
6937
6974
|
memberProductId: productId,
|
|
6938
|
-
options:
|
|
6975
|
+
options: z71.array(z71.object({ productId, title: z71.string(), variantCatalog: PostPurchaseVariantCatalog }))
|
|
6939
6976
|
});
|
|
6940
|
-
var PostPurchaseGroupSelection =
|
|
6977
|
+
var PostPurchaseGroupSelection = z71.object({
|
|
6941
6978
|
memberProductId: productId,
|
|
6942
6979
|
productId
|
|
6943
6980
|
});
|
|
6944
6981
|
|
|
6945
6982
|
// src/schema/postPurchaseProductCalculation.ts
|
|
6946
|
-
import { z as
|
|
6947
|
-
var MoneyBag =
|
|
6948
|
-
presentmentMoney:
|
|
6983
|
+
import { z as z72 } from "zod";
|
|
6984
|
+
var MoneyBag = z72.object({
|
|
6985
|
+
presentmentMoney: z72.object({
|
|
6949
6986
|
amount: PostPurchaseAmount,
|
|
6950
|
-
currencyCode:
|
|
6987
|
+
currencyCode: z72.string().regex(/^[A-Z]{3}$/)
|
|
6951
6988
|
})
|
|
6952
6989
|
});
|
|
6953
|
-
var PostPurchaseProductCalculation =
|
|
6954
|
-
calculatedPurchase:
|
|
6955
|
-
addedShippingLines:
|
|
6956
|
-
addedTaxLines:
|
|
6990
|
+
var PostPurchaseProductCalculation = z72.object({
|
|
6991
|
+
calculatedPurchase: z72.object({
|
|
6992
|
+
addedShippingLines: z72.array(z72.object({ priceSet: MoneyBag })),
|
|
6993
|
+
addedTaxLines: z72.array(z72.object({ priceSet: MoneyBag })),
|
|
6957
6994
|
totalOutstandingSet: MoneyBag,
|
|
6958
|
-
updatedLineItems:
|
|
6959
|
-
|
|
6960
|
-
priceSet:
|
|
6961
|
-
productId:
|
|
6962
|
-
sellingPlanId:
|
|
6963
|
-
variantId:
|
|
6995
|
+
updatedLineItems: z72.array(
|
|
6996
|
+
z72.object({
|
|
6997
|
+
priceSet: z72.unknown().optional(),
|
|
6998
|
+
productId: z72.number().int().positive(),
|
|
6999
|
+
sellingPlanId: z72.unknown().optional(),
|
|
7000
|
+
variantId: z72.number().int().positive()
|
|
6964
7001
|
})
|
|
6965
7002
|
)
|
|
6966
7003
|
}),
|
|
6967
|
-
errors:
|
|
6968
|
-
status:
|
|
7004
|
+
errors: z72.array(z72.unknown()).length(0),
|
|
7005
|
+
status: z72.literal("processed")
|
|
6969
7006
|
});
|
|
6970
|
-
var Minor3 =
|
|
6971
|
-
var PostPurchaseProductCosts =
|
|
7007
|
+
var Minor3 = z72.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
7008
|
+
var PostPurchaseProductCosts = z72.object({
|
|
6972
7009
|
currencyCode: MoneyBag.shape.presentmentMoney.shape.currencyCode,
|
|
6973
|
-
recurringDisplay:
|
|
7010
|
+
recurringDisplay: z72.object({ shippingMinor: Minor3, subtotalMinor: Minor3, totalMinor: Minor3 }).optional(),
|
|
6974
7011
|
shippingMinor: Minor3,
|
|
6975
7012
|
subtotalMinor: Minor3,
|
|
6976
7013
|
taxesMinor: Minor3,
|
|
6977
7014
|
totalMinor: Minor3
|
|
6978
7015
|
});
|
|
6979
|
-
var ChangesetDiscount =
|
|
6980
|
-
title:
|
|
6981
|
-
value:
|
|
6982
|
-
valueType:
|
|
7016
|
+
var ChangesetDiscount = z72.object({
|
|
7017
|
+
title: z72.string(),
|
|
7018
|
+
value: z72.number().nonnegative(),
|
|
7019
|
+
valueType: z72.enum(["percentage", "fixed_amount"])
|
|
6983
7020
|
}).optional();
|
|
6984
|
-
var PostPurchaseProductChangeset =
|
|
6985
|
-
changes:
|
|
6986
|
-
|
|
6987
|
-
|
|
7021
|
+
var PostPurchaseProductChangeset = z72.object({
|
|
7022
|
+
changes: z72.array(
|
|
7023
|
+
z72.union([
|
|
7024
|
+
z72.object({
|
|
6988
7025
|
discount: ChangesetDiscount,
|
|
6989
|
-
quantity:
|
|
6990
|
-
type:
|
|
6991
|
-
variantId:
|
|
7026
|
+
quantity: z72.number().int().positive(),
|
|
7027
|
+
type: z72.literal("add_variant"),
|
|
7028
|
+
variantId: z72.number().int().positive()
|
|
6992
7029
|
}),
|
|
6993
|
-
|
|
7030
|
+
z72.object({ price: z72.number().nonnegative(), title: z72.string(), type: z72.literal("add_shipping_line") }),
|
|
6994
7031
|
PostPurchaseSubscriptionTerms.pick({
|
|
6995
7032
|
initialShippingPrice: true,
|
|
6996
7033
|
recurringShippingPrice: true,
|
|
6997
7034
|
shippingOption: true
|
|
6998
7035
|
}).extend({
|
|
6999
7036
|
discount: ChangesetDiscount,
|
|
7000
|
-
quantity:
|
|
7001
|
-
sellingPlanId:
|
|
7002
|
-
type:
|
|
7003
|
-
variantId:
|
|
7037
|
+
quantity: z72.number().int().positive(),
|
|
7038
|
+
sellingPlanId: z72.number().int().positive(),
|
|
7039
|
+
type: z72.literal("add_subscription"),
|
|
7040
|
+
variantId: z72.number().int().positive()
|
|
7004
7041
|
})
|
|
7005
7042
|
])
|
|
7006
7043
|
)
|
|
7007
7044
|
});
|
|
7008
7045
|
|
|
7009
7046
|
// src/schema/postPurchaseProductView.ts
|
|
7010
|
-
var PostPurchaseProductView =
|
|
7011
|
-
|
|
7047
|
+
var PostPurchaseProductView = z73.union([
|
|
7048
|
+
z73.object({
|
|
7012
7049
|
changeset: PostPurchaseProductChangeset.optional(),
|
|
7013
7050
|
displayPrice: PostPurchaseDisplayPrice.optional(),
|
|
7014
7051
|
groupCatalog: PostPurchaseGroupCatalog.optional(),
|
|
7015
7052
|
initialVariant: PostPurchaseVariantSelector.optional(),
|
|
7016
7053
|
planCatalog: PostPurchasePlanCatalog.nullable().optional(),
|
|
7017
7054
|
preparation: PreparedPostPurchaseProduct.extend({
|
|
7018
|
-
display: PreparedPostPurchaseProduct.shape.display.extend({ description:
|
|
7055
|
+
display: PreparedPostPurchaseProduct.shape.display.extend({ description: z73.string().nullable() }).refine(
|
|
7019
7056
|
({ description, descriptionDocument }) => description === null === (descriptionDocument !== void 0),
|
|
7020
7057
|
"Exactly one of the plain and rich descriptions is shown"
|
|
7021
7058
|
)
|
|
@@ -7024,7 +7061,7 @@ var PostPurchaseProductView = z72.union([
|
|
|
7024
7061
|
sections: CABRootSection,
|
|
7025
7062
|
variantCatalog: PostPurchaseVariantCatalog.optional()
|
|
7026
7063
|
}),
|
|
7027
|
-
|
|
7064
|
+
z73.object({
|
|
7028
7065
|
groupCatalog: PostPurchaseGroupCatalog.optional(),
|
|
7029
7066
|
initialVariant: PostPurchaseVariantSelector.optional(),
|
|
7030
7067
|
/** The localized unavailable copy, for the choices still offered beneath an unprepared product. */
|
|
@@ -7039,12 +7076,12 @@ var PostPurchaseProductView = z72.union([
|
|
|
7039
7076
|
]);
|
|
7040
7077
|
|
|
7041
7078
|
// src/server/postPurchaseOfferCopy.ts
|
|
7042
|
-
import { z as
|
|
7043
|
-
var Copy =
|
|
7079
|
+
import { z as z74 } from "zod";
|
|
7080
|
+
var Copy = z74.object({
|
|
7044
7081
|
superTitle: CalloutBannerBlock.shape.settings.shape.superTitle.unwrap().optional().catch(void 0),
|
|
7045
7082
|
title: CalloutBannerBlock.shape.settings.shape.title.unwrap().optional().catch(void 0)
|
|
7046
7083
|
});
|
|
7047
|
-
var Callout =
|
|
7084
|
+
var Callout = z74.object({ settings: z74.record(z74.string(), z74.unknown()), type: z74.literal("callout_banner") });
|
|
7048
7085
|
var postPurchaseOfferCopy = (blocks, metadata) => {
|
|
7049
7086
|
const copy = Copy.safeParse(metadata.widget.language);
|
|
7050
7087
|
if (!blocks || !copy.success) return blocks;
|
|
@@ -7078,7 +7115,7 @@ var postPurchaseCardSections = (widgetId, { effective, metadata }, report) => {
|
|
|
7078
7115
|
);
|
|
7079
7116
|
return sections.sections.filter(({ sectionType }) => sectionType === "offers").length === 1 ? sections : null;
|
|
7080
7117
|
};
|
|
7081
|
-
var preparePostPurchaseCardSections = (widgetId, settings, response, report) => postPurchaseCardSections(widgetId, normalizePostPurchaseProduct(settings, response), report);
|
|
7118
|
+
var preparePostPurchaseCardSections = (widgetId, settings, response, report) => postPurchaseCardSections(widgetId, normalizePostPurchaseProduct(settings, response, report), report);
|
|
7082
7119
|
|
|
7083
7120
|
// src/server/selectPostPurchaseChoice.ts
|
|
7084
7121
|
var preferChoiceLevel = (preferred, other) => !isChoiceUnavailable(preferred) && isChoiceUnavailable(other) ? other : preferred;
|
|
@@ -7148,72 +7185,77 @@ var prepareNormalizedPostPurchaseView = (widgetId, normalized, report, choice, q
|
|
|
7148
7185
|
sections
|
|
7149
7186
|
});
|
|
7150
7187
|
};
|
|
7151
|
-
var preparePostPurchaseView = (widgetId, settings, response, report, choice) => prepareNormalizedPostPurchaseView(
|
|
7188
|
+
var preparePostPurchaseView = (widgetId, settings, response, report, choice) => prepareNormalizedPostPurchaseView(
|
|
7189
|
+
widgetId,
|
|
7190
|
+
normalizePostPurchaseProduct(settings, response, report),
|
|
7191
|
+
report,
|
|
7192
|
+
choice
|
|
7193
|
+
);
|
|
7152
7194
|
|
|
7153
7195
|
// src/server/preparePostPurchaseAdmissionView.ts
|
|
7154
7196
|
var preparePostPurchaseAdmissionView = (widgetId, settings, response, report, choice) => {
|
|
7155
|
-
const normalized = normalizePostPurchaseProduct(settings, response);
|
|
7197
|
+
const normalized = normalizePostPurchaseProduct(settings, response, report);
|
|
7156
7198
|
const view = prepareNormalizedPostPurchaseView(widgetId, normalized, report, choice);
|
|
7157
7199
|
const { removePartialOrder } = PostPurchaseSettings.shape.advance.parse(normalized.effective.advance);
|
|
7158
7200
|
return { removePartialOrder, view };
|
|
7159
7201
|
};
|
|
7160
7202
|
|
|
7161
7203
|
// src/schema/postPurchaseProductCollectionView.ts
|
|
7162
|
-
import { z as
|
|
7204
|
+
import { z as z81 } from "zod";
|
|
7163
7205
|
|
|
7164
7206
|
// src/schema/postPurchaseProgress.ts
|
|
7165
|
-
import { z as
|
|
7207
|
+
import { z as z80 } from "zod";
|
|
7166
7208
|
|
|
7167
7209
|
// src/schema/postPurchaseDeclineDelivery.ts
|
|
7168
|
-
import { z as
|
|
7210
|
+
import { z as z79 } from "zod";
|
|
7169
7211
|
|
|
7170
7212
|
// src/schema/postPurchaseAcceptedEvent.ts
|
|
7171
|
-
import { z as
|
|
7213
|
+
import { z as z78 } from "zod";
|
|
7172
7214
|
|
|
7173
7215
|
// src/schema/postPurchaseAdmission.ts
|
|
7174
|
-
import { z as
|
|
7216
|
+
import { z as z77 } from "zod";
|
|
7175
7217
|
|
|
7176
7218
|
// src/schema/postPurchaseIdentity.ts
|
|
7177
|
-
import { z as
|
|
7219
|
+
import { z as z75 } from "zod";
|
|
7178
7220
|
var POST_PURCHASE_ID_MAX = 128;
|
|
7179
|
-
var PostPurchaseTimestampSchema =
|
|
7180
|
-
var PostPurchaseOrderIdSchema =
|
|
7181
|
-
var ShopifyDomainSchema =
|
|
7182
|
-
var DecideRequestSchema =
|
|
7183
|
-
checkoutToken:
|
|
7221
|
+
var PostPurchaseTimestampSchema = z75.number().int().nonnegative();
|
|
7222
|
+
var PostPurchaseOrderIdSchema = z75.string().regex(/^gid:\/\/shopify\/Order\/[1-9]\d*$/);
|
|
7223
|
+
var ShopifyDomainSchema = z75.string().max(POST_PURCHASE_ID_MAX).regex(/^[a-z0-9]([a-z0-9-]*[a-z0-9])?\.myshopify\.com$/);
|
|
7224
|
+
var DecideRequestSchema = z75.object({
|
|
7225
|
+
checkoutToken: z75.string().min(1).max(POST_PURCHASE_ID_MAX),
|
|
7184
7226
|
shop: ShopifyDomainSchema
|
|
7185
7227
|
});
|
|
7186
|
-
var PostPurchaseAppIdSchema =
|
|
7187
|
-
var DecisionEntrySchema =
|
|
7188
|
-
blockId:
|
|
7189
|
-
blockIndex:
|
|
7190
|
-
blockParentIndex:
|
|
7191
|
-
flowId:
|
|
7192
|
-
sectionId:
|
|
7193
|
-
widgetId:
|
|
7194
|
-
widgetTraffic:
|
|
7228
|
+
var PostPurchaseAppIdSchema = z75.string().min(1).max(POST_PURCHASE_ID_MAX);
|
|
7229
|
+
var DecisionEntrySchema = z75.object({
|
|
7230
|
+
blockId: z75.number().int().positive(),
|
|
7231
|
+
blockIndex: z75.string(),
|
|
7232
|
+
blockParentIndex: z75.string(),
|
|
7233
|
+
flowId: z75.number().int().positive(),
|
|
7234
|
+
sectionId: z75.number().int().positive(),
|
|
7235
|
+
widgetId: z75.number().int().positive(),
|
|
7236
|
+
widgetTraffic: z75.number().min(0).max(100)
|
|
7195
7237
|
});
|
|
7196
7238
|
|
|
7197
7239
|
// src/schema/postPurchaseMemberIdentity.ts
|
|
7198
|
-
import { z as
|
|
7199
|
-
var PostPurchaseMemberIdentity =
|
|
7200
|
-
productId:
|
|
7201
|
-
productIndex:
|
|
7240
|
+
import { z as z76 } from "zod";
|
|
7241
|
+
var PostPurchaseMemberIdentity = z76.object({
|
|
7242
|
+
productId: z76.number().int().positive(),
|
|
7243
|
+
productIndex: z76.number().int().nonnegative()
|
|
7202
7244
|
}).strict();
|
|
7203
7245
|
|
|
7204
7246
|
// src/schema/postPurchaseAdmission.ts
|
|
7205
|
-
var PurchaseAdmissionModeSchema =
|
|
7247
|
+
var PurchaseAdmissionModeSchema = z77.enum(["purchase", "sts"]);
|
|
7206
7248
|
var selection = PreparedPostPurchaseProduct.shape.selection;
|
|
7207
7249
|
var EventCalculationSchema = PostPurchaseProductCosts.pick({ currencyCode: true, totalMinor: true }).strict();
|
|
7208
|
-
var PurchaseExpectedSchema =
|
|
7209
|
-
buyerConsentToSubscriptions:
|
|
7250
|
+
var PurchaseExpectedSchema = z77.object({
|
|
7251
|
+
buyerConsentToSubscriptions: z77.boolean().optional(),
|
|
7210
7252
|
changeset: PostPurchaseProductChangeset.extend({
|
|
7211
7253
|
changes: PostPurchaseProductChangeset.shape.changes.min(1).max(2)
|
|
7212
7254
|
}),
|
|
7213
7255
|
entry: DecisionEntrySchema,
|
|
7214
7256
|
member: PostPurchaseMemberIdentity.optional(),
|
|
7215
7257
|
mode: PurchaseAdmissionModeSchema.optional(),
|
|
7216
|
-
progressRevision:
|
|
7258
|
+
progressRevision: z77.number().int().nonnegative().optional(),
|
|
7217
7259
|
/**
|
|
7218
7260
|
* The total the buyer affirmed, stored with the admitted operation so a reloaded client can still
|
|
7219
7261
|
* send its follow-ups with it. Optional: a client from before it was added admits without one.
|
|
@@ -7234,16 +7276,16 @@ var PurchaseExpectedSchema = z76.object({
|
|
|
7234
7276
|
}, "Selection, change and buyer consent must agree");
|
|
7235
7277
|
var PurchaseRequestSchema = DecideRequestSchema.extend({
|
|
7236
7278
|
expected: PurchaseExpectedSchema,
|
|
7237
|
-
requestId:
|
|
7279
|
+
requestId: z77.uuid()
|
|
7238
7280
|
}).strict();
|
|
7239
|
-
var PurchaseReceiptSchema =
|
|
7281
|
+
var PurchaseReceiptSchema = z77.object({
|
|
7240
7282
|
admittedAt: PostPurchaseTimestampSchema,
|
|
7241
|
-
changesetToken:
|
|
7283
|
+
changesetToken: z77.string().min(1),
|
|
7242
7284
|
mode: PurchaseAdmissionModeSchema.optional(),
|
|
7243
|
-
operationId:
|
|
7285
|
+
operationId: z77.uuid(),
|
|
7244
7286
|
/** The server-bound one-time line an STS refunds; its quantity is the order's, not the selection's. */
|
|
7245
|
-
originalLine:
|
|
7246
|
-
requiresSubscriptionConsent:
|
|
7287
|
+
originalLine: z77.strictObject({ quantity: selection.shape.quantity, variantId: selection.shape.variantId }).optional(),
|
|
7288
|
+
requiresSubscriptionConsent: z77.boolean(),
|
|
7247
7289
|
selection
|
|
7248
7290
|
}).refine(
|
|
7249
7291
|
({ requiresSubscriptionConsent, selection: selection4 }) => requiresSubscriptionConsent === (selection4.sellingPlanId !== void 0),
|
|
@@ -7252,14 +7294,14 @@ var PurchaseReceiptSchema = z76.object({
|
|
|
7252
7294
|
({ mode, originalLine, selection: { sellingPlanId, variantId } }) => mode === "sts" ? sellingPlanId !== void 0 && originalLine?.variantId === variantId : originalLine === void 0,
|
|
7253
7295
|
"An STS Receipt binds the original line of its subscribed variant, and only an STS does"
|
|
7254
7296
|
);
|
|
7255
|
-
var PurchaseResponseSchema =
|
|
7297
|
+
var PurchaseResponseSchema = z77.object({ data: PurchaseReceiptSchema, successful: z77.literal(true) });
|
|
7256
7298
|
|
|
7257
7299
|
// src/schema/postPurchaseAcceptedEvent.ts
|
|
7258
|
-
var AcceptedEventOutcomeSchema =
|
|
7259
|
-
var AttemptProgressSchema =
|
|
7300
|
+
var AcceptedEventOutcomeSchema = z78.enum(["acknowledged", "rejected", "skipped", "unknown"]);
|
|
7301
|
+
var AttemptProgressSchema = z78.strictObject({
|
|
7260
7302
|
attemptedAt: PostPurchaseTimestampSchema,
|
|
7261
7303
|
reportedCalculation: EventCalculationSchema,
|
|
7262
|
-
status:
|
|
7304
|
+
status: z78.literal("attempted")
|
|
7263
7305
|
});
|
|
7264
7306
|
var AcceptedEventAttemptProgressSchema = AttemptProgressSchema.extend({
|
|
7265
7307
|
operationId: PurchaseReceiptSchema.shape.operationId
|
|
@@ -7272,17 +7314,17 @@ var AcceptedEventRequestSchema = DecideRequestSchema.extend({
|
|
|
7272
7314
|
operationId: PurchaseReceiptSchema.shape.operationId,
|
|
7273
7315
|
reportedCalculation: EventCalculationSchema
|
|
7274
7316
|
}).strict();
|
|
7275
|
-
var AcceptedEventResponseSchema =
|
|
7276
|
-
data:
|
|
7277
|
-
successful:
|
|
7317
|
+
var AcceptedEventResponseSchema = z78.object({
|
|
7318
|
+
data: z78.union([AcceptedEventAttemptProgressSchema, AcceptedEventResultProgressSchema]),
|
|
7319
|
+
successful: z78.literal(true)
|
|
7278
7320
|
});
|
|
7279
7321
|
|
|
7280
7322
|
// src/schema/postPurchaseDeclineDelivery.ts
|
|
7281
|
-
var AttemptSchema =
|
|
7323
|
+
var AttemptSchema = z79.strictObject({
|
|
7282
7324
|
attemptedAt: PostPurchaseTimestampSchema,
|
|
7283
|
-
status:
|
|
7325
|
+
status: z79.enum(["attempted", "unavailable"])
|
|
7284
7326
|
});
|
|
7285
|
-
var DeclineDeliveryProgressSchema =
|
|
7327
|
+
var DeclineDeliveryProgressSchema = z79.union([
|
|
7286
7328
|
AttemptSchema,
|
|
7287
7329
|
AttemptSchema.extend({
|
|
7288
7330
|
finishedAt: PostPurchaseTimestampSchema,
|
|
@@ -7291,36 +7333,36 @@ var DeclineDeliveryProgressSchema = z78.union([
|
|
|
7291
7333
|
]);
|
|
7292
7334
|
|
|
7293
7335
|
// src/schema/postPurchaseProgress.ts
|
|
7294
|
-
var PostPurchaseProgressSchema =
|
|
7336
|
+
var PostPurchaseProgressSchema = z80.object({
|
|
7295
7337
|
closedAt: PostPurchaseTimestampSchema.nullable(),
|
|
7296
7338
|
deadline: PostPurchaseTimestampSchema,
|
|
7297
7339
|
entry: DecisionEntrySchema,
|
|
7298
|
-
entryRevision:
|
|
7299
|
-
members:
|
|
7340
|
+
entryRevision: z80.number().int().nonnegative(),
|
|
7341
|
+
members: z80.array(
|
|
7300
7342
|
PostPurchaseMemberIdentity.extend({
|
|
7301
7343
|
declineDelivery: DeclineDeliveryProgressSchema.optional(),
|
|
7302
|
-
status:
|
|
7344
|
+
status: z80.enum(["unhandled", "accepted", "declined"])
|
|
7303
7345
|
}).strict()
|
|
7304
7346
|
),
|
|
7305
|
-
revision:
|
|
7347
|
+
revision: z80.number().int().nonnegative()
|
|
7306
7348
|
}).strict();
|
|
7307
7349
|
|
|
7308
7350
|
// src/schema/postPurchaseProductCollectionView.ts
|
|
7309
|
-
var PostPurchaseProductCollectionView =
|
|
7310
|
-
members:
|
|
7311
|
-
|
|
7351
|
+
var PostPurchaseProductCollectionView = z81.object({
|
|
7352
|
+
members: z81.array(
|
|
7353
|
+
z81.object({
|
|
7312
7354
|
productId: PostPurchaseProductId,
|
|
7313
|
-
productIndex:
|
|
7355
|
+
productIndex: z81.number().int().nonnegative(),
|
|
7314
7356
|
view: PostPurchaseProductView
|
|
7315
7357
|
})
|
|
7316
7358
|
)
|
|
7317
7359
|
});
|
|
7318
|
-
var PostPurchaseCollectionChoice =
|
|
7360
|
+
var PostPurchaseCollectionChoice = z81.object({
|
|
7319
7361
|
choice: PostPurchaseChoice.optional(),
|
|
7320
7362
|
productId: PostPurchaseProductId,
|
|
7321
7363
|
variantId: PostPurchaseVariantSelector.shape.variantId.optional()
|
|
7322
7364
|
}).strict();
|
|
7323
|
-
var PostPurchaseExcludedProductIds =
|
|
7365
|
+
var PostPurchaseExcludedProductIds = z81.array(PostPurchaseProductId).default([]);
|
|
7324
7366
|
var PostPurchaseMemberSelector = PostPurchaseProgressSchema.shape.members.element.pick({ productId: true }).extend({ progressRevision: PostPurchaseProgressSchema.shape.revision });
|
|
7325
7367
|
var PostPurchaseMemberPointer = PostPurchaseProgressSchema.shape.members.element.omit({ status: true }).extend({
|
|
7326
7368
|
entryRevision: PostPurchaseProgressSchema.shape.entryRevision,
|
|
@@ -7328,16 +7370,19 @@ var PostPurchaseMemberPointer = PostPurchaseProgressSchema.shape.members.element
|
|
|
7328
7370
|
});
|
|
7329
7371
|
|
|
7330
7372
|
// src/server/normalizePostPurchaseCollection.ts
|
|
7331
|
-
import { z as
|
|
7332
|
-
var normalizePostPurchaseCollection = (settings, response, excludedProductIds) => {
|
|
7333
|
-
const normalized =
|
|
7334
|
-
const limit =
|
|
7373
|
+
import { z as z82, ZodError } from "zod";
|
|
7374
|
+
var normalizePostPurchaseCollection = (settings, response, excludedProductIds, report) => {
|
|
7375
|
+
const { dropped, normalized, products } = normalizePostPurchaseSource(settings, response, report);
|
|
7376
|
+
const limit = z82.number().int().positive();
|
|
7335
7377
|
limit.parse(normalized.original.productLimit);
|
|
7336
|
-
const
|
|
7337
|
-
|
|
7378
|
+
const cap = limit.parse(normalized.effective.productLimit);
|
|
7379
|
+
const prefix = products.filter(({ productIndex }) => productIndex < cap);
|
|
7380
|
+
const unread = dropped.filter(({ productIndex }) => productIndex < cap);
|
|
7381
|
+
if (unread.length && !prefix.length) throw new ZodError(unread.flatMap(({ issues }) => issues));
|
|
7382
|
+
if (new Set(prefix.map(({ product }) => product.id)).size !== prefix.length)
|
|
7338
7383
|
throw new Error("Ambiguous post-purchase collection");
|
|
7339
7384
|
const excluded = new Set(PostPurchaseExcludedProductIds.parse(excludedProductIds));
|
|
7340
|
-
const members = prefix.
|
|
7385
|
+
const members = prefix.filter(({ product }) => !excluded.has(product.id));
|
|
7341
7386
|
return { members, normalized };
|
|
7342
7387
|
};
|
|
7343
7388
|
|
|
@@ -7375,40 +7420,40 @@ var projectPostPurchaseVariantCatalog = (product, settings) => {
|
|
|
7375
7420
|
};
|
|
7376
7421
|
|
|
7377
7422
|
// src/schema/postPurchaseOfferEligibility.ts
|
|
7378
|
-
import { z as
|
|
7423
|
+
import { z as z83 } from "zod";
|
|
7379
7424
|
var selection2 = PreparedPostPurchaseProduct.shape.selection;
|
|
7380
|
-
var PostPurchaseOfferSkipReason =
|
|
7381
|
-
var PostPurchaseOfferEligibilityContext =
|
|
7425
|
+
var PostPurchaseOfferSkipReason = z83.enum(["empty", "no-eligible-subscription"]);
|
|
7426
|
+
var PostPurchaseOfferEligibilityContext = z83.object({
|
|
7382
7427
|
excludedProductIds: PostPurchaseExcludedProductIds,
|
|
7383
|
-
originalLineItems:
|
|
7428
|
+
originalLineItems: z83.array(selection2.pick({ productId: true, sellingPlanId: true, variantId: true }))
|
|
7384
7429
|
});
|
|
7385
|
-
var PostPurchaseStsOptions =
|
|
7386
|
-
var PostPurchaseStsContext =
|
|
7387
|
-
originalLineItems:
|
|
7430
|
+
var PostPurchaseStsOptions = z83.object({ sts: z83.boolean().optional() }).strict();
|
|
7431
|
+
var PostPurchaseStsContext = z83.object({
|
|
7432
|
+
originalLineItems: z83.array(
|
|
7388
7433
|
selection2.pick({ productId: true, quantity: true, sellingPlanId: true, variantId: true })
|
|
7389
7434
|
)
|
|
7390
7435
|
});
|
|
7391
|
-
var PostPurchaseOfferEligibility =
|
|
7392
|
-
|
|
7393
|
-
members:
|
|
7394
|
-
|
|
7436
|
+
var PostPurchaseOfferEligibility = z83.discriminatedUnion("status", [
|
|
7437
|
+
z83.object({
|
|
7438
|
+
members: z83.array(
|
|
7439
|
+
z83.object({ productId: selection2.shape.productId, productIndex: z83.number().int().nonnegative() })
|
|
7395
7440
|
),
|
|
7396
7441
|
/** Present only with STS on: each member switches one original one-time line to subscription. */
|
|
7397
|
-
mode:
|
|
7398
|
-
status:
|
|
7442
|
+
mode: z83.literal("sts").optional(),
|
|
7443
|
+
status: z83.literal("retain")
|
|
7399
7444
|
}),
|
|
7400
|
-
|
|
7401
|
-
|
|
7445
|
+
z83.object({ reason: PostPurchaseOfferSkipReason, status: z83.literal("skip") }),
|
|
7446
|
+
z83.object({ reason: z83.literal("eligible-sts").optional(), status: z83.literal("unavailable") })
|
|
7402
7447
|
]);
|
|
7403
7448
|
|
|
7404
7449
|
// src/schema/postPurchaseQuantity.ts
|
|
7405
|
-
import { z as
|
|
7450
|
+
import { z as z84 } from "zod";
|
|
7406
7451
|
var quantity2 = PreparedPostPurchaseProduct.shape.selection.shape.quantity;
|
|
7407
7452
|
var PostPurchaseQuantityChoice = PostPurchaseCollectionChoice.extend({ quantity: quantity2.optional() });
|
|
7408
7453
|
var PostPurchaseQuantityPolicy = PostPurchaseSettings.shape.quantityInputs.omit({ defaultQuantity: true }).extend({
|
|
7409
7454
|
initialQuantity: quantity2,
|
|
7410
7455
|
maxValue: quantity2,
|
|
7411
|
-
minValue:
|
|
7456
|
+
minValue: z84.literal(0).transform(() => 1).or(quantity2)
|
|
7412
7457
|
}).refine(({ maxValue, minValue }) => minValue <= maxValue, "Quantity bounds are reversed");
|
|
7413
7458
|
|
|
7414
7459
|
// src/server/readPostPurchaseQuantity.ts
|
|
@@ -7476,7 +7521,7 @@ var prepareStsCollectionMember = (widgetId, normalized, { product, productIndex
|
|
|
7476
7521
|
|
|
7477
7522
|
// src/server/preparePostPurchaseStsMember.ts
|
|
7478
7523
|
var preparePostPurchaseStsMember = (widgetId, settings, response, selected, sts, requestedQuantity, report) => {
|
|
7479
|
-
const { members, normalized } = normalizePostPurchaseCollection(settings, response);
|
|
7524
|
+
const { members, normalized } = normalizePostPurchaseCollection(settings, response, void 0, report);
|
|
7480
7525
|
if (!stsAllowed(normalized)) return void 0;
|
|
7481
7526
|
const member = members.find(({ product }) => product.id === selected.productId);
|
|
7482
7527
|
const quantity3 = requestedQuantity && ("quantity" in requestedQuantity ? requestedQuantity.quantity : requestedQuantity.expectedQuantity);
|
|
@@ -7487,39 +7532,39 @@ var preparePostPurchaseStsMember = (widgetId, settings, response, selected, sts,
|
|
|
7487
7532
|
};
|
|
7488
7533
|
|
|
7489
7534
|
// src/schema/postPurchaseVariantDefault.ts
|
|
7490
|
-
import { z as
|
|
7535
|
+
import { z as z85 } from "zod";
|
|
7491
7536
|
var values = PostPurchaseVariantValues.partial().extend({
|
|
7492
7537
|
option1: PostPurchaseVariantValues.shape.option1.nullish()
|
|
7493
7538
|
});
|
|
7494
7539
|
var variant = values.extend({
|
|
7495
7540
|
id: PostPurchaseVariantId,
|
|
7496
|
-
inventoryManagement:
|
|
7497
|
-
inventoryPolicy:
|
|
7498
|
-
inventoryQuantity:
|
|
7541
|
+
inventoryManagement: z85.string().nullable(),
|
|
7542
|
+
inventoryPolicy: z85.string(),
|
|
7543
|
+
inventoryQuantity: z85.number()
|
|
7499
7544
|
});
|
|
7500
|
-
var options =
|
|
7501
|
-
var PostPurchaseVariantDefaultProduct =
|
|
7545
|
+
var options = z85.array(PostPurchaseVariantOption.pick({ name: true, values: true }));
|
|
7546
|
+
var PostPurchaseVariantDefaultProduct = z85.object({
|
|
7502
7547
|
id: PostPurchaseProductId,
|
|
7503
7548
|
options,
|
|
7504
7549
|
selectedVariant: variant.optional(),
|
|
7505
|
-
variants:
|
|
7550
|
+
variants: z85.array(variant)
|
|
7506
7551
|
});
|
|
7507
7552
|
var PostPurchaseVariantDefaultSettings = PostPurchaseSettings.shape.productOptions.pick({
|
|
7508
7553
|
hideOutOfStockVariants: true,
|
|
7509
7554
|
matchVariant: true
|
|
7510
7555
|
});
|
|
7511
|
-
var PostPurchaseOrderAttributes =
|
|
7512
|
-
var PostPurchaseOriginalVariants =
|
|
7513
|
-
|
|
7556
|
+
var PostPurchaseOrderAttributes = z85.record(z85.string(), z85.array(z85.string())).default({});
|
|
7557
|
+
var PostPurchaseOriginalVariants = z85.array(
|
|
7558
|
+
z85.object({ productId: PostPurchaseProductId, variantId: PostPurchaseVariantId })
|
|
7514
7559
|
);
|
|
7515
|
-
var PostPurchaseAttributeProducts =
|
|
7516
|
-
|
|
7560
|
+
var PostPurchaseAttributeProducts = z85.array(
|
|
7561
|
+
z85.object({ id: PostPurchaseProductId, options, variants: z85.array(values.extend({ id: PostPurchaseVariantId })) })
|
|
7517
7562
|
);
|
|
7518
7563
|
|
|
7519
7564
|
// src/schema/postPurchaseVariantDefaultContext.ts
|
|
7520
|
-
import { z as
|
|
7521
|
-
var PostPurchaseVariantDefaultContext =
|
|
7522
|
-
enrichedLineItems:
|
|
7565
|
+
import { z as z86 } from "zod";
|
|
7566
|
+
var PostPurchaseVariantDefaultContext = z86.object({
|
|
7567
|
+
enrichedLineItems: z86.unknown().optional(),
|
|
7523
7568
|
originalVariants: PostPurchaseOriginalVariants
|
|
7524
7569
|
});
|
|
7525
7570
|
|
|
@@ -7598,7 +7643,7 @@ var prepareMember = (widgetId, settings, response, requested, report, excludedPr
|
|
|
7598
7643
|
const selected = PostPurchaseCollectionChoice.parse(requested);
|
|
7599
7644
|
const stsResult = sts && preparePostPurchaseStsMember(widgetId, settings, response, selected, sts, requestedQuantity, report);
|
|
7600
7645
|
if (stsResult !== void 0) return stsResult;
|
|
7601
|
-
const { members, normalized } = normalizePostPurchaseCollection(settings, response, excludedProductIds);
|
|
7646
|
+
const { members, normalized } = normalizePostPurchaseCollection(settings, response, excludedProductIds, report);
|
|
7602
7647
|
const found = members.find(({ product: product2 }) => product2.id === selected.productId);
|
|
7603
7648
|
if (!found) return null;
|
|
7604
7649
|
const variantId = selected.variantId ?? (defaults && resolvePostPurchaseMemberDefault(found.product, normalized.original, defaults));
|
|
@@ -7772,7 +7817,7 @@ var preparePostPurchaseGroupAdmissionView = (widgetId, settings, response, reque
|
|
|
7772
7817
|
|
|
7773
7818
|
// src/server/preparePostPurchaseGroupDefault.ts
|
|
7774
7819
|
var preparePostPurchaseGroupDefault = (widgetId, settings, response, memberProductId, context, report, excludedProductIds) => {
|
|
7775
|
-
const { members, normalized } = normalizePostPurchaseCollection(settings, response);
|
|
7820
|
+
const { members, normalized } = normalizePostPurchaseCollection(settings, response, void 0, report);
|
|
7776
7821
|
const member = members.find(({ product }) => product.id === memberProductId);
|
|
7777
7822
|
if (!member || !member.product.productGroupVariants.length) return null;
|
|
7778
7823
|
const group = readPostPurchaseGroup(member.product, normalized.effective, excludedProductIds);
|
|
@@ -7831,7 +7876,7 @@ var preparePostPurchaseCollectionGroup = (widgetId, settings, response, member,
|
|
|
7831
7876
|
// src/server/preparePostPurchaseCollectionView.ts
|
|
7832
7877
|
var CollectionChoice = PostPurchaseCollectionChoice.omit({ variantId: true });
|
|
7833
7878
|
var preparePostPurchaseCollectionView = (widgetId, settings, response, report, requested, excludedProductIds, defaults, sts) => {
|
|
7834
|
-
const { members, normalized } = normalizePostPurchaseCollection(settings, response);
|
|
7879
|
+
const { members, normalized } = normalizePostPurchaseCollection(settings, response, void 0, report);
|
|
7835
7880
|
const excluded = PostPurchaseExcludedProductIds.parse(excludedProductIds);
|
|
7836
7881
|
const selected = CollectionChoice.optional().parse(requested);
|
|
7837
7882
|
const stsMode = sts && stsAllowed(normalized) ? sts : void 0;
|
|
@@ -7957,10 +8002,10 @@ var classifyPostPurchaseOffer = (settings, response, context, options2) => {
|
|
|
7957
8002
|
};
|
|
7958
8003
|
|
|
7959
8004
|
// src/server/preparePostPurchaseDeclineDisplay.ts
|
|
7960
|
-
import { z as
|
|
8005
|
+
import { z as z88 } from "zod";
|
|
7961
8006
|
|
|
7962
8007
|
// src/schema/postPurchaseDecline.ts
|
|
7963
|
-
import { z as
|
|
8008
|
+
import { z as z87 } from "zod";
|
|
7964
8009
|
var OfferDeclineRequestSchema = DecideRequestSchema.extend({
|
|
7965
8010
|
entryRevision: PostPurchaseProgressSchema.shape.entryRevision,
|
|
7966
8011
|
productId: PostPurchaseProgressSchema.shape.members.element.shape.productId,
|
|
@@ -7972,13 +8017,13 @@ var OfferDeclineRequestSchema = DecideRequestSchema.extend({
|
|
|
7972
8017
|
"Selected merchandise requires a variant"
|
|
7973
8018
|
);
|
|
7974
8019
|
var RecordedOfferDeclineSchema = PostPurchaseProgressSchema.shape.members.element.omit({ declineDelivery: true, status: true }).extend({ entry: DecisionEntrySchema.strict(), entryRevision: PostPurchaseProgressSchema.shape.entryRevision }).strict();
|
|
7975
|
-
var OfferDeclineResponseSchema =
|
|
7976
|
-
data:
|
|
7977
|
-
successful:
|
|
8020
|
+
var OfferDeclineResponseSchema = z87.object({
|
|
8021
|
+
data: z87.object({ decline: RecordedOfferDeclineSchema, progress: PostPurchaseProgressSchema }),
|
|
8022
|
+
successful: z87.literal(true)
|
|
7978
8023
|
});
|
|
7979
8024
|
|
|
7980
8025
|
// src/server/preparePostPurchaseDeclineDisplay.ts
|
|
7981
|
-
var Selection =
|
|
8026
|
+
var Selection = z88.object({
|
|
7982
8027
|
productId: OfferDeclineRequestSchema.shape.productId,
|
|
7983
8028
|
variant: OfferDeclineRequestSchema.shape.variant.unwrap()
|
|
7984
8029
|
});
|
|
@@ -8008,30 +8053,30 @@ var preparePostPurchaseGroupDeclineDisplay = (settings, response, requested, exc
|
|
|
8008
8053
|
|
|
8009
8054
|
// src/server/preparePostPurchaseOfferPresentation.ts
|
|
8010
8055
|
import { merge as merge2 } from "es-toolkit/compat";
|
|
8011
|
-
import { z as
|
|
8056
|
+
import { z as z90 } from "zod";
|
|
8012
8057
|
|
|
8013
8058
|
// src/schema/postPurchaseOfferPresentation.ts
|
|
8014
|
-
import { z as
|
|
8059
|
+
import { z as z89 } from "zod";
|
|
8015
8060
|
var language2 = PostPurchaseSettings.shape.language.shape.global.unwrap().unwrap();
|
|
8016
|
-
var PostPurchaseOfferPresentation =
|
|
8061
|
+
var PostPurchaseOfferPresentation = z89.strictObject({
|
|
8017
8062
|
labels: language2.pick({ declineAll: true, declineThisOffer: true }),
|
|
8018
8063
|
layout: PostPurchaseSettings.shape.offersLayout,
|
|
8019
8064
|
sections: CABRootSection.nullable(),
|
|
8020
8065
|
showDeclineAll: PostPurchaseSettings.shape.productOptions.shape.showDeclineAll
|
|
8021
8066
|
});
|
|
8022
8067
|
var OfferPresentationRequestSchema = DecideRequestSchema.strict();
|
|
8023
|
-
var OfferPresentationResponseSchema =
|
|
8024
|
-
data:
|
|
8068
|
+
var OfferPresentationResponseSchema = z89.object({
|
|
8069
|
+
data: z89.strictObject({
|
|
8025
8070
|
presentation: PostPurchaseOfferPresentation.nullable(),
|
|
8026
8071
|
progress: PostPurchaseProgressSchema.nullable(),
|
|
8027
8072
|
serverNow: PostPurchaseTimestampSchema
|
|
8028
8073
|
}),
|
|
8029
|
-
successful:
|
|
8074
|
+
successful: z89.literal(true)
|
|
8030
8075
|
});
|
|
8031
8076
|
|
|
8032
8077
|
// src/server/preparePostPurchaseOfferPresentation.ts
|
|
8033
8078
|
var FrameSettings = PostPurchaseSettings.pick({ language: true, offersLayout: true, productOptions: true }).extend({
|
|
8034
|
-
blocks:
|
|
8079
|
+
blocks: z90.array(z90.unknown()).optional()
|
|
8035
8080
|
});
|
|
8036
8081
|
var preparePostPurchaseOfferPresentation = (widgetId, settings, response, report) => {
|
|
8037
8082
|
const { metadata } = PostPurchaseProductSource.pick({ metadata: true }).parse(deepCamelCase(response));
|
|
@@ -8196,7 +8241,7 @@ var postAnalyticsEvents = async (input, ctx) => {
|
|
|
8196
8241
|
};
|
|
8197
8242
|
|
|
8198
8243
|
// src/server/requestSchemas.ts
|
|
8199
|
-
import { z as
|
|
8244
|
+
import { z as z91 } from "zod";
|
|
8200
8245
|
var REQUEST_BOUNDS = {
|
|
8201
8246
|
/** Cart-level attributes per cart. */
|
|
8202
8247
|
CART_ATTRIBUTES_MAX: 100,
|
|
@@ -8227,42 +8272,42 @@ var REQUEST_BOUNDS = {
|
|
|
8227
8272
|
/** Rich ads transaction lines — the engine's ads contract. */
|
|
8228
8273
|
TRANSACTION_ITEMS_MAX: 50
|
|
8229
8274
|
};
|
|
8230
|
-
var KeyValue =
|
|
8231
|
-
key:
|
|
8232
|
-
value:
|
|
8275
|
+
var KeyValue = z91.object({
|
|
8276
|
+
key: z91.string().max(REQUEST_BOUNDS.STRING_KEY_MAX),
|
|
8277
|
+
value: z91.string().max(REQUEST_BOUNDS.STRING_VALUE_MAX).optional()
|
|
8233
8278
|
});
|
|
8234
|
-
var CartLineInputSchema =
|
|
8235
|
-
productId:
|
|
8236
|
-
properties:
|
|
8237
|
-
quantity:
|
|
8238
|
-
subscriptionId:
|
|
8239
|
-
variantId:
|
|
8279
|
+
var CartLineInputSchema = z91.object({
|
|
8280
|
+
productId: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
8281
|
+
properties: z91.array(KeyValue).max(REQUEST_BOUNDS.LINE_PROPERTIES_MAX).optional(),
|
|
8282
|
+
quantity: z91.number(),
|
|
8283
|
+
subscriptionId: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
8284
|
+
variantId: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX)
|
|
8240
8285
|
});
|
|
8241
|
-
var CartInputSchema =
|
|
8242
|
-
attributes:
|
|
8286
|
+
var CartInputSchema = z91.object({
|
|
8287
|
+
attributes: z91.array(KeyValue).max(REQUEST_BOUNDS.CART_ATTRIBUTES_MAX).optional(),
|
|
8243
8288
|
/**
|
|
8244
8289
|
* Presentment-per-shop-currency FX rate (buyer price ÷ shop price, e.g. `1.35` for a USD shop
|
|
8245
8290
|
* selling in CAD). Money rule thresholds are authored in SHOP currency, so the engine subtotal is
|
|
8246
8291
|
* divided by this before evaluation. Omit (or send 1) when the cart is already in the shop's currency.
|
|
8247
8292
|
*/
|
|
8248
|
-
currencyRate:
|
|
8293
|
+
currencyRate: z91.number().optional(),
|
|
8249
8294
|
/** Applied discount codes; the engine evaluates `discount_code` rules against them (sent as `[{code}]`). */
|
|
8250
|
-
discountCodes:
|
|
8295
|
+
discountCodes: z91.array(z91.string().max(REQUEST_BOUNDS.STRING_KEY_MAX)).max(REQUEST_BOUNDS.DISCOUNT_CODES_MAX).optional(),
|
|
8251
8296
|
/** Presentment cents of cart-level discount allocations, subtracted from `subtotal` for the engine. */
|
|
8252
|
-
discountTotal:
|
|
8253
|
-
items:
|
|
8297
|
+
discountTotal: z91.number().optional(),
|
|
8298
|
+
items: z91.array(CartLineInputSchema).max(REQUEST_BOUNDS.CART_ITEMS_MAX),
|
|
8254
8299
|
/** Presentment subtotal in cents. */
|
|
8255
|
-
subtotal:
|
|
8300
|
+
subtotal: z91.number()
|
|
8256
8301
|
});
|
|
8257
|
-
var UserConfigInputSchema =
|
|
8258
|
-
var DataSourceInputSchema =
|
|
8302
|
+
var UserConfigInputSchema = z91.object({ shop: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX) });
|
|
8303
|
+
var DataSourceInputSchema = z91.object({
|
|
8259
8304
|
cart: CartInputSchema,
|
|
8260
8305
|
/**
|
|
8261
8306
|
* Numeric Shopify company-location id when the buyer is a B2B session (`buyerIdentity.purchasingCompany`).
|
|
8262
8307
|
* Present ⇒ the orchestrator filters results by the location's catalog via admin-api (REB-23713); the
|
|
8263
8308
|
* client's country-context market check is bypassed for B2B (it false-negatives B2B-catalog products).
|
|
8264
8309
|
*/
|
|
8265
|
-
companyLocationId:
|
|
8310
|
+
companyLocationId: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
8266
8311
|
/**
|
|
8267
8312
|
* Buyer's market country (ISO 3166-1 alpha-2) — forwarded to the engine as the `country_code` PARAM
|
|
8268
8313
|
* when the shop's markets toggle is on (REB-21688; the sink was the `X-Country-Code` header under
|
|
@@ -8271,16 +8316,16 @@ var DataSourceInputSchema = z90.object({
|
|
|
8271
8316
|
* uppercase (the wire value is forwarded verbatim as the param) so a case-sensitive engine lookup
|
|
8272
8317
|
* can't silently miss a lowercase code — `adsEngine.ts` uppercases for the same reason.
|
|
8273
8318
|
*/
|
|
8274
|
-
country:
|
|
8275
|
-
customerId:
|
|
8276
|
-
dataSourcePath:
|
|
8319
|
+
country: z91.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(),
|
|
8320
|
+
customerId: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
8321
|
+
dataSourcePath: z91.string().max(REQUEST_BOUNDS.STRING_KEY_MAX),
|
|
8277
8322
|
/**
|
|
8278
8323
|
* Engine `filter_inputs` override: `'no'` keeps in-cart (input) products in the results/rule
|
|
8279
8324
|
* outputs — gift validation sends it so a gift's own product can appear in its answer. Omitted = the
|
|
8280
8325
|
* engine's default filtering.
|
|
8281
8326
|
*/
|
|
8282
|
-
filterInputs:
|
|
8283
|
-
integrations:
|
|
8327
|
+
filterInputs: z91.enum(["no", "yes"]).optional(),
|
|
8328
|
+
integrations: z91.record(z91.string().max(REQUEST_BOUNDS.STRING_KEY_MAX), z91.boolean()).refine((record) => Object.keys(record).length <= REQUEST_BOUNDS.INTEGRATION_KEYS_MAX, {
|
|
8284
8329
|
message: `Too many integration keys (max ${REQUEST_BOUNDS.INTEGRATION_KEYS_MAX})`
|
|
8285
8330
|
}).optional(),
|
|
8286
8331
|
/**
|
|
@@ -8293,31 +8338,31 @@ var DataSourceInputSchema = z90.object({
|
|
|
8293
8338
|
* request header) fails the regex. Callers should send the buyer's resolved locale (e.g. Shopify
|
|
8294
8339
|
* checkout's `localization.language.isoCode`), not the request header verbatim.
|
|
8295
8340
|
*/
|
|
8296
|
-
language:
|
|
8297
|
-
limit:
|
|
8298
|
-
productType:
|
|
8299
|
-
shop:
|
|
8300
|
-
visitorId:
|
|
8301
|
-
});
|
|
8302
|
-
var GiftInputSchema =
|
|
8303
|
-
cost:
|
|
8304
|
-
discounted:
|
|
8341
|
+
language: z91.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(),
|
|
8342
|
+
limit: z91.number().max(REQUEST_BOUNDS.LIMIT_MAX),
|
|
8343
|
+
productType: z91.enum(["both", "one-time", "subscription"]).optional(),
|
|
8344
|
+
shop: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
8345
|
+
visitorId: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
8346
|
+
});
|
|
8347
|
+
var GiftInputSchema = z91.object({
|
|
8348
|
+
cost: z91.number(),
|
|
8349
|
+
discounted: z91.boolean(),
|
|
8305
8350
|
/**
|
|
8306
8351
|
* Which gift attribution the line carries (REB-24363). Defaults to `gwp` because a client that predates
|
|
8307
8352
|
* the field only ever sent GWP lines — without the default an older extension's request would 422.
|
|
8308
8353
|
*/
|
|
8309
|
-
kind:
|
|
8310
|
-
lineId:
|
|
8311
|
-
productId:
|
|
8354
|
+
kind: z91.enum(GIFT_KINDS).default("gwp"),
|
|
8355
|
+
lineId: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
8356
|
+
productId: z91.number(),
|
|
8312
8357
|
/**
|
|
8313
8358
|
* The line's unit count (REB-24363) — the selectable-GWP verdict trims surplus units against milestone
|
|
8314
8359
|
* capacity. The second deliberate default: a client predating the field sent only GWP lines, whose
|
|
8315
8360
|
* verdict is whole-line, so a missing quantity reads as one unit rather than 422ing the older request.
|
|
8316
8361
|
*/
|
|
8317
|
-
quantity:
|
|
8318
|
-
widgetId:
|
|
8362
|
+
quantity: z91.number().int().min(1).default(1),
|
|
8363
|
+
widgetId: z91.number()
|
|
8319
8364
|
});
|
|
8320
|
-
var GiftValidationInputSchema =
|
|
8365
|
+
var GiftValidationInputSchema = z91.object({
|
|
8321
8366
|
cart: CartInputSchema,
|
|
8322
8367
|
/**
|
|
8323
8368
|
* Buyer's market country — threaded into the per-widget data-source evaluations, which forward it to
|
|
@@ -8326,25 +8371,25 @@ var GiftValidationInputSchema = z90.object({
|
|
|
8326
8371
|
* turns markets off); regex-bound and uppercase-normalized for the same reasons as
|
|
8327
8372
|
* `DataSourceInputSchema`'s `country`.
|
|
8328
8373
|
*/
|
|
8329
|
-
country:
|
|
8330
|
-
customerId:
|
|
8331
|
-
gifts:
|
|
8374
|
+
country: z91.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(),
|
|
8375
|
+
customerId: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
8376
|
+
gifts: z91.array(GiftInputSchema).max(REQUEST_BOUNDS.GIFTS_MAX),
|
|
8332
8377
|
/**
|
|
8333
8378
|
* Buyer's checkout language — threaded into the per-widget data-source evaluations, which normalize
|
|
8334
8379
|
* and forward it as the engine `locale` param under the same markets-toggle gate (REB-21688). MUST be
|
|
8335
8380
|
* a single BCP-47 tag, for the same reason as `DataSourceInputSchema`'s `language` above.
|
|
8336
8381
|
*/
|
|
8337
|
-
language:
|
|
8338
|
-
shop:
|
|
8339
|
-
visitorId:
|
|
8382
|
+
language: z91.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(),
|
|
8383
|
+
shop: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
8384
|
+
visitorId: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
8340
8385
|
});
|
|
8341
|
-
var GiftAdjustmentSchema =
|
|
8342
|
-
lineId:
|
|
8343
|
-
quantity:
|
|
8386
|
+
var GiftAdjustmentSchema = z91.object({
|
|
8387
|
+
lineId: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
8388
|
+
quantity: z91.number().int().nonnegative()
|
|
8344
8389
|
});
|
|
8345
|
-
var GiftValidationResponseSchema =
|
|
8346
|
-
adjust:
|
|
8347
|
-
remove:
|
|
8390
|
+
var GiftValidationResponseSchema = z91.object({
|
|
8391
|
+
adjust: z91.array(GiftAdjustmentSchema).max(REQUEST_BOUNDS.GIFTS_MAX).default([]),
|
|
8392
|
+
remove: z91.array(z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX)).max(REQUEST_BOUNDS.GIFTS_MAX).refine(
|
|
8348
8393
|
(remove) => new Set(remove).size === remove.length,
|
|
8349
8394
|
"a line id may appear at most once in `remove`"
|
|
8350
8395
|
)
|
|
@@ -8355,47 +8400,47 @@ var GiftValidationResponseSchema = z90.object({
|
|
|
8355
8400
|
({ adjust }) => new Set(adjust.map(({ lineId }) => lineId)).size === adjust.length,
|
|
8356
8401
|
"a line id may appear at most once in `adjust`"
|
|
8357
8402
|
);
|
|
8358
|
-
var MonetizeTransactionItemSchema =
|
|
8359
|
-
id:
|
|
8360
|
-
priceCents:
|
|
8361
|
-
quantity:
|
|
8362
|
-
title:
|
|
8363
|
-
type:
|
|
8364
|
-
});
|
|
8365
|
-
var MonetizeInputSchema =
|
|
8403
|
+
var MonetizeTransactionItemSchema = z91.object({
|
|
8404
|
+
id: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
8405
|
+
priceCents: z91.number(),
|
|
8406
|
+
quantity: z91.number(),
|
|
8407
|
+
title: z91.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX),
|
|
8408
|
+
type: z91.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX)
|
|
8409
|
+
});
|
|
8410
|
+
var MonetizeInputSchema = z91.object({
|
|
8366
8411
|
cart: CartInputSchema,
|
|
8367
8412
|
/** Client-minted render-beacon correlation id; forwarded to the ads engine as `client_request_id`. */
|
|
8368
|
-
clientRequestId:
|
|
8369
|
-
country:
|
|
8370
|
-
currency:
|
|
8413
|
+
clientRequestId: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
8414
|
+
country: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
8415
|
+
currency: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
8371
8416
|
/** Ads-targeting identity/geo/locale fields (React parity); folded into the engine query verbatim. */
|
|
8372
|
-
customerEmail:
|
|
8373
|
-
customerFirstName:
|
|
8374
|
-
customerId:
|
|
8375
|
-
customerLastName:
|
|
8376
|
-
language:
|
|
8417
|
+
customerEmail: z91.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX).optional(),
|
|
8418
|
+
customerFirstName: z91.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX).optional(),
|
|
8419
|
+
customerId: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
8420
|
+
customerLastName: z91.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX).optional(),
|
|
8421
|
+
language: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
8377
8422
|
/** Buyer-facing order name (e.g. `#1001`) for the server-composed "Order … Confirmed" chrome line. */
|
|
8378
|
-
orderName:
|
|
8423
|
+
orderName: z91.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX).optional(),
|
|
8379
8424
|
/** Ads surface label, forwarded verbatim; `customer_account` is measured/floored as its own surface (the account-area order list). */
|
|
8380
|
-
placement:
|
|
8425
|
+
placement: z91.enum(["customer_account", "order_status", "thank_you_page"]),
|
|
8381
8426
|
/** Privacy Policy footer href — the Monetize widget's `privacy_policy_url` setting (React parity). */
|
|
8382
|
-
privacyPolicyUrl:
|
|
8427
|
+
privacyPolicyUrl: z91.string().max(REQUEST_BOUNDS.STRING_URL_MAX).optional(),
|
|
8383
8428
|
/** 30-min rolling session id (React parity); used for the ads `session_id`, else the visitor id. */
|
|
8384
|
-
sessionId:
|
|
8385
|
-
shop:
|
|
8429
|
+
sessionId: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
8430
|
+
shop: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
8386
8431
|
/** Editor/QA indicator; OR-ed into the ads-engine `testing` flag so it stays out of billing/reporting. */
|
|
8387
|
-
testing:
|
|
8388
|
-
timezone:
|
|
8432
|
+
testing: z91.boolean().optional(),
|
|
8433
|
+
timezone: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
8389
8434
|
/** Decorated (numeric) order id → the ads `transaction_id`. */
|
|
8390
|
-
transactionId:
|
|
8435
|
+
transactionId: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
8391
8436
|
/** Rich per-line ads items; capped at the engine's ads contract. Preferred over `cart.items`. */
|
|
8392
|
-
transactionItems:
|
|
8437
|
+
transactionItems: z91.array(MonetizeTransactionItemSchema).max(REQUEST_BOUNDS.TRANSACTION_ITEMS_MAX).optional(),
|
|
8393
8438
|
/** Order total in presentment cents (React prefers total over subtotal); else `cart.subtotal`. */
|
|
8394
|
-
transactionTotal:
|
|
8395
|
-
visitorId:
|
|
8396
|
-
zipCode:
|
|
8439
|
+
transactionTotal: z91.number().optional(),
|
|
8440
|
+
visitorId: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
8441
|
+
zipCode: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
8397
8442
|
});
|
|
8398
|
-
var WidgetSettingsInputSchema =
|
|
8443
|
+
var WidgetSettingsInputSchema = z91.object({
|
|
8399
8444
|
/**
|
|
8400
8445
|
* Same domain as `CabShopConfig.cacheKey`, for the same reason: this side WINS the orchestrator's
|
|
8401
8446
|
* `input.cacheKey ?? config.shop.cacheKey` (and an explicit value skips the config read entirely), so
|
|
@@ -8403,9 +8448,9 @@ var WidgetSettingsInputSchema = z90.object({
|
|
|
8403
8448
|
* and pin the edge copy permanently stale. `.catch(undefined)` because a bogus buster should degrade
|
|
8404
8449
|
* the read to un-busted, never 400 a widget render.
|
|
8405
8450
|
*/
|
|
8406
|
-
cacheKey:
|
|
8407
|
-
id:
|
|
8408
|
-
key:
|
|
8451
|
+
cacheKey: z91.number().int().positive().optional().catch(void 0),
|
|
8452
|
+
id: z91.number(),
|
|
8453
|
+
key: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
8409
8454
|
/**
|
|
8410
8455
|
* Monetize context for inline hydration: when present AND the widget converts to a Monetize marker,
|
|
8411
8456
|
* the server fetches/composes the offer cards inside this same request (no second `/cab/monetize`
|
|
@@ -8414,36 +8459,36 @@ var WidgetSettingsInputSchema = z90.object({
|
|
|
8414
8459
|
* `privacyPolicyUrl` comes from the widget settings server-side (more authoritative than a relay).
|
|
8415
8460
|
*/
|
|
8416
8461
|
monetize: MonetizeInputSchema.omit({ privacyPolicyUrl: true, shop: true }).optional(),
|
|
8417
|
-
shop:
|
|
8462
|
+
shop: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
8418
8463
|
/** Stable per-buyer id; when present, enables sticky server-side A/B variant selection. */
|
|
8419
|
-
visitorId:
|
|
8464
|
+
visitorId: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
8420
8465
|
});
|
|
8421
|
-
var AnalyticsEventInputSchema =
|
|
8422
|
-
name:
|
|
8423
|
-
properties:
|
|
8424
|
-
sentAt:
|
|
8466
|
+
var AnalyticsEventInputSchema = z91.object({
|
|
8467
|
+
name: z91.string().max(REQUEST_BOUNDS.STRING_KEY_MAX),
|
|
8468
|
+
properties: z91.record(z91.string().max(REQUEST_BOUNDS.STRING_KEY_MAX), z91.unknown()).optional(),
|
|
8469
|
+
sentAt: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
8425
8470
|
});
|
|
8426
|
-
var AnalyticsSegmentsInputSchema =
|
|
8427
|
-
device:
|
|
8428
|
-
source:
|
|
8429
|
-
visitor:
|
|
8471
|
+
var AnalyticsSegmentsInputSchema = z91.object({
|
|
8472
|
+
device: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional().catch(void 0),
|
|
8473
|
+
source: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional().catch(void 0),
|
|
8474
|
+
visitor: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional().catch(void 0)
|
|
8430
8475
|
});
|
|
8431
|
-
var AnalyticsInputSchema =
|
|
8476
|
+
var AnalyticsInputSchema = z91.object({
|
|
8432
8477
|
/** Rebuy cart token (the `r_cart_token` cart attribute), when available — primary aggregation key. */
|
|
8433
|
-
cartToken:
|
|
8478
|
+
cartToken: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
8434
8479
|
/** Shopify checkout token, when available — drives cart/checkout aggregation downstream. */
|
|
8435
|
-
checkoutToken:
|
|
8436
|
-
events:
|
|
8480
|
+
checkoutToken: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
8481
|
+
events: z91.array(AnalyticsEventInputSchema).max(REQUEST_BOUNDS.EVENTS_MAX),
|
|
8437
8482
|
/**
|
|
8438
8483
|
* Request-scoped like the tokens: one visitor's segments apply to every event in the batch. The container
|
|
8439
8484
|
* degrades too (`null` is a realistic wire artifact of `attributes ? {…} : null`), so the degrade rule is
|
|
8440
8485
|
* total: nothing about `segments` can cost the envelope.
|
|
8441
8486
|
*/
|
|
8442
8487
|
segments: AnalyticsSegmentsInputSchema.optional().catch(void 0),
|
|
8443
|
-
shop:
|
|
8444
|
-
visitorId:
|
|
8488
|
+
shop: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
8489
|
+
visitorId: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
8445
8490
|
/** The widget id (smartBlockId) the events belong to. */
|
|
8446
|
-
widgetId:
|
|
8491
|
+
widgetId: z91.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
8447
8492
|
});
|
|
8448
8493
|
export {
|
|
8449
8494
|
AnalyticsEventInputSchema,
|
|
@@ -8490,6 +8535,7 @@ export {
|
|
|
8490
8535
|
preparePostPurchaseSubscription,
|
|
8491
8536
|
preparePostPurchaseView,
|
|
8492
8537
|
readPostPurchaseGroupSelection,
|
|
8538
|
+
readPostPurchaseProductSource,
|
|
8493
8539
|
readPostPurchaseQuantity,
|
|
8494
8540
|
translateAnalyticsEvent,
|
|
8495
8541
|
validateGifts
|