@rebuy/rebuy 3.28.1 → 3.29.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +7 -3
- package/dist/index.mjs +7 -3
- package/dist/server/index.cjs +347 -142
- package/dist/server/index.mjs +347 -142
- package/dist/transforms/index.cjs +222 -17
- package/dist/transforms/index.mjs +222 -17
- package/dist/transforms/offerV1/offerTemplateSeed.d.ts +8 -5
- package/dist/transforms/postPurchase/convertImageBlock.d.ts +4 -0
- package/dist/transforms/postPurchase/convertImageContentBlock.d.ts +7 -0
- package/dist/transforms/postPurchase/convertImageContentText.d.ts +5 -0
- package/dist/transforms/postPurchase/convertImageFrame.d.ts +9 -0
- package/dist/transforms/postPurchase/convertMessagePreview.d.ts +3 -3
- package/dist/transforms/postPurchase/convertProductInformation.d.ts +4 -0
- package/dist/transforms/postPurchase/imageContentSettings.d.ts +50 -0
- package/dist/transforms/postPurchase/sizeImageSource.d.ts +2 -0
- package/package.json +1 -1
package/dist/server/index.cjs
CHANGED
|
@@ -3224,9 +3224,13 @@ var buildPriceContent = () => ({
|
|
|
3224
3224
|
content: [
|
|
3225
3225
|
{
|
|
3226
3226
|
content: [
|
|
3227
|
-
/**
|
|
3227
|
+
/**
|
|
3228
|
+
* Regular text color, not legacy's `<Text appearance="accent">`: the checkout's web components
|
|
3229
|
+
* can't render app text in the accent color, and `accent`'s nearest tint shows default blue on
|
|
3230
|
+
* most stores (REB-24049).
|
|
3231
|
+
*/
|
|
3228
3232
|
{
|
|
3229
|
-
marks: [{ attrs: { color: "
|
|
3233
|
+
marks: [{ attrs: { color: "base", fontSize: "base" }, type: "textStyle" }],
|
|
3230
3234
|
text: "{{variantPrice}}",
|
|
3231
3235
|
type: "text"
|
|
3232
3236
|
},
|
|
@@ -3778,7 +3782,7 @@ var convertOfferToV2 = ({ id, name, settings }) => {
|
|
|
3778
3782
|
var parseShielded = (schema, raw, transform = (input) => input) => schema.parse(transform(convertNumericObjects(deepCamelCase(raw))));
|
|
3779
3783
|
|
|
3780
3784
|
// src/transforms/postPurchase/convertMessagePreview.ts
|
|
3781
|
-
var
|
|
3785
|
+
var import_zod36 = require("zod");
|
|
3782
3786
|
|
|
3783
3787
|
// src/transforms/postPurchase/convertCalloutBlock.ts
|
|
3784
3788
|
var import_zod31 = require("zod");
|
|
@@ -4001,6 +4005,150 @@ var convertCalloutBlock = (raw, report) => {
|
|
|
4001
4005
|
return sections.length ? [CABLayoutSection.parse({ alignment: { horizontal }, frame: "callout", sections })] : [];
|
|
4002
4006
|
};
|
|
4003
4007
|
|
|
4008
|
+
// src/transforms/postPurchase/convertImageFrame.ts
|
|
4009
|
+
var import_zod32 = require("zod");
|
|
4010
|
+
|
|
4011
|
+
// src/transforms/postPurchase/sizeImageSource.ts
|
|
4012
|
+
var sizeImageSource = (source, size) => {
|
|
4013
|
+
const extension = source.split(".").pop();
|
|
4014
|
+
for (const previous of ["small", "medium", "large", "original", "master"]) {
|
|
4015
|
+
source = source.replace(`_${previous}.${extension}`, `.${extension}`);
|
|
4016
|
+
}
|
|
4017
|
+
return source.replace(`.${extension}`, `${size === void 0 ? "" : `_${size}`}.${extension}`);
|
|
4018
|
+
};
|
|
4019
|
+
|
|
4020
|
+
// src/transforms/postPurchase/convertImageFrame.ts
|
|
4021
|
+
var Source = import_zod32.z.url().default("https://cdn.shopify.com/s/files/1/0605/0555/5177/files/placeholder.jpg?v=1657762972");
|
|
4022
|
+
var DEFAULT_IMAGE_SIZE = 20;
|
|
4023
|
+
var convertImageFrame = (raw) => {
|
|
4024
|
+
const parsed = ImageBlock.shape.settings.options[0].safeParse(raw);
|
|
4025
|
+
if (!parsed.success) return null;
|
|
4026
|
+
const settings = parsed.data;
|
|
4027
|
+
const source = sizeImageSource(Source.parse(settings.image || void 0));
|
|
4028
|
+
const withAlt = CABImageSection.safeParse({ altText: settings.alt, source });
|
|
4029
|
+
const image = withAlt.success ? withAlt.data : CABImageSection.parse({ source });
|
|
4030
|
+
const size = settings.imageSize > 0 ? settings.imageSize : DEFAULT_IMAGE_SIZE;
|
|
4031
|
+
return CABLayoutSection.parse({
|
|
4032
|
+
alignment: { horizontal: "center" },
|
|
4033
|
+
direction: "grid",
|
|
4034
|
+
grid: { columns: size <= 1 ? ["100%"] : [size] },
|
|
4035
|
+
sections: [image],
|
|
4036
|
+
width: size <= 1 ? size * 100 : 100
|
|
4037
|
+
});
|
|
4038
|
+
};
|
|
4039
|
+
|
|
4040
|
+
// src/transforms/postPurchase/convertImageBlock.ts
|
|
4041
|
+
var dropMalformedAlt = (raw) => {
|
|
4042
|
+
if (typeof raw !== "object" || raw === null) return raw;
|
|
4043
|
+
const { settings, ...rest } = raw;
|
|
4044
|
+
if (typeof settings !== "object" || settings === null || Array.isArray(settings)) return raw;
|
|
4045
|
+
const { alt, ...restSettings } = settings;
|
|
4046
|
+
if (typeof alt === "string" || alt === void 0) return raw;
|
|
4047
|
+
return { ...rest, settings: restSettings };
|
|
4048
|
+
};
|
|
4049
|
+
var convertImageBlock = (raw, report) => {
|
|
4050
|
+
const block = ImageBlock.safeParse(dropMalformedAlt(raw));
|
|
4051
|
+
const image = block.success ? convertImageFrame(block.data.settings) : null;
|
|
4052
|
+
if (!image) {
|
|
4053
|
+
report?.({ detail: "Unreadable post-purchase image", kind: "section" });
|
|
4054
|
+
return [];
|
|
4055
|
+
}
|
|
4056
|
+
return [
|
|
4057
|
+
CABLayoutSection.parse({
|
|
4058
|
+
alignment: { horizontal: "center" },
|
|
4059
|
+
frame: "offer-content",
|
|
4060
|
+
sections: [image],
|
|
4061
|
+
spacing: "none"
|
|
4062
|
+
})
|
|
4063
|
+
];
|
|
4064
|
+
};
|
|
4065
|
+
|
|
4066
|
+
// src/transforms/postPurchase/convertImageContentBlock.ts
|
|
4067
|
+
var import_zod34 = require("zod");
|
|
4068
|
+
|
|
4069
|
+
// src/transforms/postPurchase/convertImageContentText.ts
|
|
4070
|
+
var fields2 = ["superTitle", "title", "description"];
|
|
4071
|
+
var convertImageContentText = (settings, report) => {
|
|
4072
|
+
const horizontal = { center: "center", leading: "start", trailing: "end" }[settings.horizontalAlignment];
|
|
4073
|
+
const sections = fields2.flatMap((field) => {
|
|
4074
|
+
const omit = () => {
|
|
4075
|
+
report?.({ detail: `Unreadable post-purchase image-content field: ${field}`, kind: "section" });
|
|
4076
|
+
return [];
|
|
4077
|
+
};
|
|
4078
|
+
const value = ImageContentBlock.shape.settings.shape[field].safeParse(settings[field]);
|
|
4079
|
+
if (!value.success) return omit();
|
|
4080
|
+
const text2 = value.data;
|
|
4081
|
+
if (text2 === null || text2 === "") return [];
|
|
4082
|
+
const content = typeof text2 === "string" ? {
|
|
4083
|
+
content: [
|
|
4084
|
+
{
|
|
4085
|
+
attrs: { textAlign: horizontal },
|
|
4086
|
+
content: [styledTextRun(text2, field !== "description", settings[`${field}Size`])]
|
|
4087
|
+
}
|
|
4088
|
+
]
|
|
4089
|
+
} : text2;
|
|
4090
|
+
const section = CABTextSection.safeParse({ content: { en: content } });
|
|
4091
|
+
return section.success ? [section.data] : omit();
|
|
4092
|
+
});
|
|
4093
|
+
return CABLayoutSection.parse({ alignment: { horizontal }, sections });
|
|
4094
|
+
};
|
|
4095
|
+
|
|
4096
|
+
// src/transforms/postPurchase/imageContentSettings.ts
|
|
4097
|
+
var import_zod33 = require("zod");
|
|
4098
|
+
var ImageContentSettings = ImageContentBlock.shape.settings.pick({
|
|
4099
|
+
descriptionSize: true,
|
|
4100
|
+
horizontalAlignment: true,
|
|
4101
|
+
superTitleSize: true,
|
|
4102
|
+
swapContent: true,
|
|
4103
|
+
titleSize: true
|
|
4104
|
+
}).extend({
|
|
4105
|
+
alt: import_zod33.z.unknown().optional(),
|
|
4106
|
+
description: import_zod33.z.unknown().optional(),
|
|
4107
|
+
image: import_zod33.z.unknown().optional(),
|
|
4108
|
+
imagePlacement: ImageContentBlock.shape.settings.shape.imagePlacement.unwrap().nullable(),
|
|
4109
|
+
imageSize: ImageContentBlock.shape.settings.shape.imageSize.pipe(import_zod33.z.number().positive()),
|
|
4110
|
+
superTitle: import_zod33.z.unknown().optional(),
|
|
4111
|
+
title: import_zod33.z.unknown().optional()
|
|
4112
|
+
});
|
|
4113
|
+
|
|
4114
|
+
// src/transforms/postPurchase/convertImageContentBlock.ts
|
|
4115
|
+
var Shell2 = import_zod34.z.object({ settings: ImageContentSettings, type: import_zod34.z.literal("image_content") });
|
|
4116
|
+
var PROPORTIONAL_BREAK_AT = 500;
|
|
4117
|
+
var convertImageContentBlock = (raw, report) => {
|
|
4118
|
+
const shell = Shell2.safeParse(raw);
|
|
4119
|
+
if (!shell.success) {
|
|
4120
|
+
report?.({ detail: "Unreadable post-purchase image-content block", kind: "section" });
|
|
4121
|
+
return [];
|
|
4122
|
+
}
|
|
4123
|
+
const settings = shell.data.settings;
|
|
4124
|
+
const alt = typeof settings.alt === "string" ? settings.alt : void 0;
|
|
4125
|
+
if (settings.alt !== void 0 && alt === void 0) {
|
|
4126
|
+
report?.({ detail: "Unreadable post-purchase image-content alt text", kind: "section" });
|
|
4127
|
+
}
|
|
4128
|
+
const image = convertImageFrame({ alt, image: settings.image, imageSize: settings.imageSize });
|
|
4129
|
+
if (!image) report?.({ detail: "Unreadable post-purchase image-content image", kind: "section" });
|
|
4130
|
+
const text2 = convertImageContentText(settings, report);
|
|
4131
|
+
const textFrame = CABLayoutSection.parse({ direction: "grid", grid: { columns: ["100%"] }, sections: [text2] });
|
|
4132
|
+
const placement = settings.imagePlacement ?? (settings.swapContent ? "right" : "left");
|
|
4133
|
+
const imageFirst = placement === "left" || placement === "top";
|
|
4134
|
+
const sections = imageFirst ? [image, textFrame] : [textFrame, image];
|
|
4135
|
+
const ordered = sections.filter((section) => section !== null);
|
|
4136
|
+
const inner = placement === "left" || placement === "right" ? CABLayoutSection.parse({
|
|
4137
|
+
sections: ordered,
|
|
4138
|
+
spacing: "loose",
|
|
4139
|
+
wrapping: {
|
|
4140
|
+
breakAt: settings.imageSize <= 1 ? PROPORTIONAL_BREAK_AT : settings.imageSize,
|
|
4141
|
+
maxPerLine: 2
|
|
4142
|
+
}
|
|
4143
|
+
}) : CABLayoutSection.parse({
|
|
4144
|
+
direction: "grid",
|
|
4145
|
+
grid: { columns: ["100%"] },
|
|
4146
|
+
sections: [CABLayoutSection.parse({ sections: ordered })],
|
|
4147
|
+
width: 95
|
|
4148
|
+
});
|
|
4149
|
+
return [CABLayoutSection.parse({ frame: "offer-content", sections: [inner], spacing: "none" })];
|
|
4150
|
+
};
|
|
4151
|
+
|
|
4004
4152
|
// src/transforms/postPurchase/convertPayButtonBlock.ts
|
|
4005
4153
|
var convertPayButtonBlock = (raw, report) => {
|
|
4006
4154
|
const omit = () => {
|
|
@@ -4029,6 +4177,60 @@ var convertPayButtonBlock = (raw, report) => {
|
|
|
4029
4177
|
];
|
|
4030
4178
|
};
|
|
4031
4179
|
|
|
4180
|
+
// src/transforms/postPurchase/convertProductInformation.ts
|
|
4181
|
+
var convertProductInformation = (raw, report) => {
|
|
4182
|
+
const block = ProductInformationBlock.safeParse(raw);
|
|
4183
|
+
if (!block.success) {
|
|
4184
|
+
report?.({ detail: "Unreadable post-purchase product information", kind: "section" });
|
|
4185
|
+
return [];
|
|
4186
|
+
}
|
|
4187
|
+
return [
|
|
4188
|
+
CABOffersSection.parse({
|
|
4189
|
+
direction: "grid",
|
|
4190
|
+
sections: [
|
|
4191
|
+
CABLayoutSection.parse({
|
|
4192
|
+
alignment: { horizontal: "center" },
|
|
4193
|
+
sections: [
|
|
4194
|
+
CABLayoutSection.parse({
|
|
4195
|
+
alignment: { horizontal: "center" },
|
|
4196
|
+
direction: "grid",
|
|
4197
|
+
grid: { columns: [250] },
|
|
4198
|
+
sections: [
|
|
4199
|
+
CABImageSection.parse({ altText: "{{productTitle}}", source: "{{productImage}}" })
|
|
4200
|
+
],
|
|
4201
|
+
width: 90
|
|
4202
|
+
})
|
|
4203
|
+
]
|
|
4204
|
+
}),
|
|
4205
|
+
CABLayoutSection.parse({
|
|
4206
|
+
sections: [
|
|
4207
|
+
CABTextSection.parse({
|
|
4208
|
+
content: {
|
|
4209
|
+
en: {
|
|
4210
|
+
content: [
|
|
4211
|
+
{
|
|
4212
|
+
content: [
|
|
4213
|
+
{
|
|
4214
|
+
marks: [{ attrs: { fontSize: "heading" }, type: "textStyle" }],
|
|
4215
|
+
text: "{{productTitle}}"
|
|
4216
|
+
}
|
|
4217
|
+
]
|
|
4218
|
+
}
|
|
4219
|
+
]
|
|
4220
|
+
}
|
|
4221
|
+
}
|
|
4222
|
+
}),
|
|
4223
|
+
CABReviewsSection.parse({}),
|
|
4224
|
+
CABTextSection.parse({ content: { en: "{{productDescription}}" } })
|
|
4225
|
+
]
|
|
4226
|
+
})
|
|
4227
|
+
],
|
|
4228
|
+
spacing: "extraLoose",
|
|
4229
|
+
wrapping: { breakAt: 500, maxPerLine: block.data.hideProductImage ? 1 : 2 }
|
|
4230
|
+
})
|
|
4231
|
+
];
|
|
4232
|
+
};
|
|
4233
|
+
|
|
4032
4234
|
// src/transforms/postPurchase/convertSeparatorBlock.ts
|
|
4033
4235
|
var convertSeparatorBlock = (raw, report) => {
|
|
4034
4236
|
if (!SeparatorBlock.safeParse(raw).success) {
|
|
@@ -4039,29 +4241,29 @@ var convertSeparatorBlock = (raw, report) => {
|
|
|
4039
4241
|
};
|
|
4040
4242
|
|
|
4041
4243
|
// src/transforms/postPurchase/convertTextBlock.ts
|
|
4042
|
-
var
|
|
4043
|
-
var
|
|
4244
|
+
var import_zod35 = require("zod");
|
|
4245
|
+
var fields3 = ["superTitle", "title", "description"];
|
|
4044
4246
|
var styles = {
|
|
4045
4247
|
description: [{ attrs: { color: "base", fontSize: "small" }, type: "textStyle" }],
|
|
4046
4248
|
superTitle: [{ attrs: { color: "subdued", fontSize: "small" }, type: "textStyle" }],
|
|
4047
4249
|
title: [{ type: "bold" }, { attrs: { color: "base", fontSize: "large" }, type: "textStyle" }]
|
|
4048
4250
|
};
|
|
4049
4251
|
var settingsSchema = TextBlock.shape.settings;
|
|
4050
|
-
var
|
|
4252
|
+
var Shell3 = import_zod35.z.object({
|
|
4051
4253
|
settings: settingsSchema.pick({ horizontalAlignment: true }).extend({
|
|
4052
|
-
description:
|
|
4053
|
-
superTitle:
|
|
4054
|
-
title:
|
|
4254
|
+
description: import_zod35.z.unknown().optional(),
|
|
4255
|
+
superTitle: import_zod35.z.unknown().optional(),
|
|
4256
|
+
title: import_zod35.z.unknown().optional()
|
|
4055
4257
|
}),
|
|
4056
|
-
type:
|
|
4258
|
+
type: import_zod35.z.literal("text")
|
|
4057
4259
|
});
|
|
4058
4260
|
var convertTextBlock = (raw, report) => {
|
|
4059
|
-
const shell =
|
|
4261
|
+
const shell = Shell3.safeParse(raw);
|
|
4060
4262
|
if (!shell.success) {
|
|
4061
4263
|
report?.({ detail: "Unreadable post-purchase text block", kind: "section" });
|
|
4062
4264
|
return [];
|
|
4063
4265
|
}
|
|
4064
|
-
const values =
|
|
4266
|
+
const values = fields3.map((field) => ({
|
|
4065
4267
|
field,
|
|
4066
4268
|
result: settingsSchema.shape[field].safeParse(shell.data.settings[field])
|
|
4067
4269
|
}));
|
|
@@ -4125,14 +4327,17 @@ var convertTimerBlock = (raw, report) => {
|
|
|
4125
4327
|
};
|
|
4126
4328
|
|
|
4127
4329
|
// src/transforms/postPurchase/convertMessagePreview.ts
|
|
4128
|
-
var MessageWidget =
|
|
4129
|
-
blocks:
|
|
4130
|
-
type:
|
|
4330
|
+
var MessageWidget = import_zod36.z.object({
|
|
4331
|
+
blocks: import_zod36.z.array(import_zod36.z.unknown()).min(1),
|
|
4332
|
+
type: import_zod36.z.literal(WidgetType.shopify_post_purchase_extension)
|
|
4131
4333
|
});
|
|
4132
|
-
var BlockType2 =
|
|
4334
|
+
var BlockType2 = import_zod36.z.object({ type: import_zod36.z.string() });
|
|
4133
4335
|
var converters = {
|
|
4134
4336
|
callout_banner: convertCalloutBlock,
|
|
4337
|
+
image: convertImageBlock,
|
|
4338
|
+
image_content: convertImageContentBlock,
|
|
4135
4339
|
pay_button: convertPayButtonBlock,
|
|
4340
|
+
product_information: convertProductInformation,
|
|
4136
4341
|
separator: convertSeparatorBlock,
|
|
4137
4342
|
text: convertTextBlock,
|
|
4138
4343
|
timer: convertTimerBlock
|
|
@@ -4674,7 +4879,7 @@ var fetchDataSourceResults = async (input, ctx) => {
|
|
|
4674
4879
|
};
|
|
4675
4880
|
|
|
4676
4881
|
// src/server/adsEngine.ts
|
|
4677
|
-
var
|
|
4882
|
+
var import_zod37 = require("zod");
|
|
4678
4883
|
var SUPPLY_KEY = { production: "AQF5RKLR", staging: "Z56LQ7PS" };
|
|
4679
4884
|
var OFFER_LIMIT = 4;
|
|
4680
4885
|
var SUPPORTED_COUNTRIES = /* @__PURE__ */ new Set(["US", "CA"]);
|
|
@@ -4687,28 +4892,28 @@ var transactionItems = (input) => (input.transactionItems?.map(({ id, priceCents
|
|
|
4687
4892
|
title,
|
|
4688
4893
|
type
|
|
4689
4894
|
})) ?? input.cart.items.map(({ productId, quantity }) => ({ id: productId, quantity }))).slice(0, MAX_TRANSACTION_ITEMS);
|
|
4690
|
-
var AdsEngineOffer =
|
|
4895
|
+
var AdsEngineOffer = import_zod37.z.object({
|
|
4691
4896
|
/** Pill-style value prop ("Get $45 Cashback"). Carried through the parse; the card does not render it yet (REB-24429 — pill design pending). */
|
|
4692
|
-
callout:
|
|
4693
|
-
click_url:
|
|
4694
|
-
cta:
|
|
4897
|
+
callout: import_zod37.z.string().catch(""),
|
|
4898
|
+
click_url: import_zod37.z.string(),
|
|
4899
|
+
cta: import_zod37.z.string(),
|
|
4695
4900
|
/** `omitempty` on the ad server — a bid without it must not fail the parse and drop the whole batch (composeOffer falls back to 'No Thanks'). */
|
|
4696
|
-
decline_cta:
|
|
4697
|
-
decline_url:
|
|
4698
|
-
description:
|
|
4901
|
+
decline_cta: import_zod37.z.string().catch(""),
|
|
4902
|
+
decline_url: import_zod37.z.string(),
|
|
4903
|
+
description: import_zod37.z.string(),
|
|
4699
4904
|
/** Short legal disclosure (FDIC / auto-renewal / FTC-affiliation lines). Rendered subdued under the CTAs. */
|
|
4700
|
-
disclaimer:
|
|
4905
|
+
disclaimer: import_zod37.z.string().catch(""),
|
|
4701
4906
|
/** Long legal text behind the disclosure toggle in the composed card (REB-24429). */
|
|
4702
|
-
extended_disclaimer:
|
|
4703
|
-
headline:
|
|
4704
|
-
id:
|
|
4907
|
+
extended_disclaimer: import_zod37.z.string().catch(""),
|
|
4908
|
+
headline: import_zod37.z.string(),
|
|
4909
|
+
id: import_zod37.z.string(),
|
|
4705
4910
|
/** Advertiser-supplied image alt; the composed card falls back to the stripped headline when empty. */
|
|
4706
|
-
image_alt:
|
|
4707
|
-
image_url:
|
|
4708
|
-
view_url:
|
|
4911
|
+
image_alt: import_zod37.z.string().catch(""),
|
|
4912
|
+
image_url: import_zod37.z.string().optional(),
|
|
4913
|
+
view_url: import_zod37.z.string()
|
|
4709
4914
|
});
|
|
4710
|
-
var AdsEngineResponse =
|
|
4711
|
-
offers:
|
|
4915
|
+
var AdsEngineResponse = import_zod37.z.object({
|
|
4916
|
+
offers: import_zod37.z.array(import_zod37.z.unknown()).default([]).transform(
|
|
4712
4917
|
(offers) => offers.flatMap((offer) => {
|
|
4713
4918
|
const result = AdsEngineOffer.safeParse(offer);
|
|
4714
4919
|
return result.success ? [result.data] : [];
|
|
@@ -4720,8 +4925,8 @@ var AdsEngineResponse = import_zod34.z.object({
|
|
|
4720
4925
|
* offers-testing fixture on a test store forces it, REB-24467). Both optional: an older engine or a
|
|
4721
4926
|
* non-JSON body must not fail the parse and drop the offers.
|
|
4722
4927
|
*/
|
|
4723
|
-
request_id:
|
|
4724
|
-
testing:
|
|
4928
|
+
request_id: import_zod37.z.string().optional().catch(void 0),
|
|
4929
|
+
testing: import_zod37.z.boolean().optional().catch(void 0)
|
|
4725
4930
|
});
|
|
4726
4931
|
var adsHost = (host) => `offers.${host}`;
|
|
4727
4932
|
var isTestingRequest = (input, isProduction) => !isProduction || !!input.testing || input.customerEmail?.toLowerCase() === TEST_CUSTOMER_EMAIL;
|
|
@@ -5151,13 +5356,13 @@ var convertWidgetSettings = async (input, ctx) => {
|
|
|
5151
5356
|
};
|
|
5152
5357
|
|
|
5153
5358
|
// src/server/giftWidgets.ts
|
|
5154
|
-
var
|
|
5155
|
-
var SettingsNumber =
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
]).pipe(
|
|
5159
|
-
var SgwpMilestoneSchema =
|
|
5160
|
-
selectable_product_quantity: SettingsNumber.pipe(
|
|
5359
|
+
var import_zod38 = require("zod");
|
|
5360
|
+
var SettingsNumber = import_zod38.z.union([
|
|
5361
|
+
import_zod38.z.number(),
|
|
5362
|
+
import_zod38.z.string().trim().regex(/^-?\d+(\.\d+)?$/)
|
|
5363
|
+
]).pipe(import_zod38.z.coerce.number());
|
|
5364
|
+
var SgwpMilestoneSchema = import_zod38.z.object({
|
|
5365
|
+
selectable_product_quantity: SettingsNumber.pipe(import_zod38.z.number().int().nonnegative()),
|
|
5161
5366
|
unlock_price: SettingsNumber
|
|
5162
5367
|
});
|
|
5163
5368
|
var fetchGiftWidgetSettings = async (widgetId, shop, ctx) => unwrapData(await ctx.fetchUpstream("/api/v1/widgets/settings", { id: String(widgetId), shop }, { host: ctx.host }));
|
|
@@ -5168,7 +5373,7 @@ var readDataSourcePath = (settings) => {
|
|
|
5168
5373
|
var readMilestones = (settings, report) => {
|
|
5169
5374
|
const raw = settings && typeof settings === "object" ? settings.milestones : void 0;
|
|
5170
5375
|
if (raw == null) return [];
|
|
5171
|
-
const parsed =
|
|
5376
|
+
const parsed = import_zod38.z.array(SgwpMilestoneSchema).safeParse(raw);
|
|
5172
5377
|
if (parsed.success) return parsed.data;
|
|
5173
5378
|
report?.({
|
|
5174
5379
|
detail: [
|
|
@@ -5417,7 +5622,7 @@ var postAnalyticsEvents = async (input, ctx) => {
|
|
|
5417
5622
|
};
|
|
5418
5623
|
|
|
5419
5624
|
// src/server/requestSchemas.ts
|
|
5420
|
-
var
|
|
5625
|
+
var import_zod39 = require("zod");
|
|
5421
5626
|
var REQUEST_BOUNDS = {
|
|
5422
5627
|
/** Cart-level attributes per cart. */
|
|
5423
5628
|
CART_ATTRIBUTES_MAX: 100,
|
|
@@ -5448,42 +5653,42 @@ var REQUEST_BOUNDS = {
|
|
|
5448
5653
|
/** Rich ads transaction lines — the engine's ads contract. */
|
|
5449
5654
|
TRANSACTION_ITEMS_MAX: 50
|
|
5450
5655
|
};
|
|
5451
|
-
var KeyValue =
|
|
5452
|
-
key:
|
|
5453
|
-
value:
|
|
5656
|
+
var KeyValue = import_zod39.z.object({
|
|
5657
|
+
key: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_KEY_MAX),
|
|
5658
|
+
value: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_VALUE_MAX).optional()
|
|
5454
5659
|
});
|
|
5455
|
-
var CartLineInputSchema =
|
|
5456
|
-
productId:
|
|
5457
|
-
properties:
|
|
5458
|
-
quantity:
|
|
5459
|
-
subscriptionId:
|
|
5460
|
-
variantId:
|
|
5660
|
+
var CartLineInputSchema = import_zod39.z.object({
|
|
5661
|
+
productId: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
5662
|
+
properties: import_zod39.z.array(KeyValue).max(REQUEST_BOUNDS.LINE_PROPERTIES_MAX).optional(),
|
|
5663
|
+
quantity: import_zod39.z.number(),
|
|
5664
|
+
subscriptionId: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5665
|
+
variantId: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX)
|
|
5461
5666
|
});
|
|
5462
|
-
var CartInputSchema =
|
|
5463
|
-
attributes:
|
|
5667
|
+
var CartInputSchema = import_zod39.z.object({
|
|
5668
|
+
attributes: import_zod39.z.array(KeyValue).max(REQUEST_BOUNDS.CART_ATTRIBUTES_MAX).optional(),
|
|
5464
5669
|
/**
|
|
5465
5670
|
* Presentment-per-shop-currency FX rate (buyer price ÷ shop price, e.g. `1.35` for a USD shop
|
|
5466
5671
|
* selling in CAD). Money rule thresholds are authored in SHOP currency, so the engine subtotal is
|
|
5467
5672
|
* divided by this before evaluation. Omit (or send 1) when the cart is already in the shop's currency.
|
|
5468
5673
|
*/
|
|
5469
|
-
currencyRate:
|
|
5674
|
+
currencyRate: import_zod39.z.number().optional(),
|
|
5470
5675
|
/** Applied discount codes; the engine evaluates `discount_code` rules against them (sent as `[{code}]`). */
|
|
5471
|
-
discountCodes:
|
|
5676
|
+
discountCodes: import_zod39.z.array(import_zod39.z.string().max(REQUEST_BOUNDS.STRING_KEY_MAX)).max(REQUEST_BOUNDS.DISCOUNT_CODES_MAX).optional(),
|
|
5472
5677
|
/** Presentment cents of cart-level discount allocations, subtracted from `subtotal` for the engine. */
|
|
5473
|
-
discountTotal:
|
|
5474
|
-
items:
|
|
5678
|
+
discountTotal: import_zod39.z.number().optional(),
|
|
5679
|
+
items: import_zod39.z.array(CartLineInputSchema).max(REQUEST_BOUNDS.CART_ITEMS_MAX),
|
|
5475
5680
|
/** Presentment subtotal in cents. */
|
|
5476
|
-
subtotal:
|
|
5681
|
+
subtotal: import_zod39.z.number()
|
|
5477
5682
|
});
|
|
5478
|
-
var UserConfigInputSchema =
|
|
5479
|
-
var DataSourceInputSchema =
|
|
5683
|
+
var UserConfigInputSchema = import_zod39.z.object({ shop: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX) });
|
|
5684
|
+
var DataSourceInputSchema = import_zod39.z.object({
|
|
5480
5685
|
cart: CartInputSchema,
|
|
5481
5686
|
/**
|
|
5482
5687
|
* Numeric Shopify company-location id when the buyer is a B2B session (`buyerIdentity.purchasingCompany`).
|
|
5483
5688
|
* Present ⇒ the orchestrator filters results by the location's catalog via admin-api (REB-23713); the
|
|
5484
5689
|
* client's country-context market check is bypassed for B2B (it false-negatives B2B-catalog products).
|
|
5485
5690
|
*/
|
|
5486
|
-
companyLocationId:
|
|
5691
|
+
companyLocationId: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5487
5692
|
/**
|
|
5488
5693
|
* Buyer's market country (ISO 3166-1 alpha-2) — forwarded to the engine as the `country_code` PARAM
|
|
5489
5694
|
* when the shop's markets toggle is on (REB-21688; the sink was the `X-Country-Code` header under
|
|
@@ -5492,16 +5697,16 @@ var DataSourceInputSchema = import_zod36.z.object({
|
|
|
5492
5697
|
* uppercase (the wire value is forwarded verbatim as the param) so a case-sensitive engine lookup
|
|
5493
5698
|
* can't silently miss a lowercase code — `adsEngine.ts` uppercases for the same reason.
|
|
5494
5699
|
*/
|
|
5495
|
-
country:
|
|
5496
|
-
customerId:
|
|
5497
|
-
dataSourcePath:
|
|
5700
|
+
country: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).regex(/^[A-Za-z]{2}$/, "must be an ISO 3166-1 alpha-2 country code (e.g. CA)").transform((value) => value.toUpperCase()).optional(),
|
|
5701
|
+
customerId: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5702
|
+
dataSourcePath: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_KEY_MAX),
|
|
5498
5703
|
/**
|
|
5499
5704
|
* Engine `filter_inputs` override: `'no'` keeps in-cart (input) products in the results/rule
|
|
5500
5705
|
* outputs — gift validation sends it so a gift's own product can appear in its answer. Omitted = the
|
|
5501
5706
|
* engine's default filtering.
|
|
5502
5707
|
*/
|
|
5503
|
-
filterInputs:
|
|
5504
|
-
integrations:
|
|
5708
|
+
filterInputs: import_zod39.z.enum(["no", "yes"]).optional(),
|
|
5709
|
+
integrations: import_zod39.z.record(import_zod39.z.string().max(REQUEST_BOUNDS.STRING_KEY_MAX), import_zod39.z.boolean()).refine((record) => Object.keys(record).length <= REQUEST_BOUNDS.INTEGRATION_KEYS_MAX, {
|
|
5505
5710
|
message: `Too many integration keys (max ${REQUEST_BOUNDS.INTEGRATION_KEYS_MAX})`
|
|
5506
5711
|
}).optional(),
|
|
5507
5712
|
/**
|
|
@@ -5514,31 +5719,31 @@ var DataSourceInputSchema = import_zod36.z.object({
|
|
|
5514
5719
|
* request header) fails the regex. Callers should send the buyer's resolved locale (e.g. Shopify
|
|
5515
5720
|
* checkout's `localization.language.isoCode`), not the request header verbatim.
|
|
5516
5721
|
*/
|
|
5517
|
-
language:
|
|
5518
|
-
limit:
|
|
5519
|
-
productType:
|
|
5520
|
-
shop:
|
|
5521
|
-
visitorId:
|
|
5722
|
+
language: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).regex(/^[A-Za-z0-9-]+$/, "must be a single BCP-47 tag (e.g. fr-CA), not a q-value list").optional(),
|
|
5723
|
+
limit: import_zod39.z.number().max(REQUEST_BOUNDS.LIMIT_MAX),
|
|
5724
|
+
productType: import_zod39.z.enum(["both", "one-time", "subscription"]).optional(),
|
|
5725
|
+
shop: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
5726
|
+
visitorId: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
5522
5727
|
});
|
|
5523
|
-
var GiftInputSchema =
|
|
5524
|
-
cost:
|
|
5525
|
-
discounted:
|
|
5728
|
+
var GiftInputSchema = import_zod39.z.object({
|
|
5729
|
+
cost: import_zod39.z.number(),
|
|
5730
|
+
discounted: import_zod39.z.boolean(),
|
|
5526
5731
|
/**
|
|
5527
5732
|
* Which gift attribution the line carries (REB-24363). Defaults to `gwp` because a client that predates
|
|
5528
5733
|
* the field only ever sent GWP lines — without the default an older extension's request would 422.
|
|
5529
5734
|
*/
|
|
5530
|
-
kind:
|
|
5531
|
-
lineId:
|
|
5532
|
-
productId:
|
|
5735
|
+
kind: import_zod39.z.enum(GIFT_KINDS).default("gwp"),
|
|
5736
|
+
lineId: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
5737
|
+
productId: import_zod39.z.number(),
|
|
5533
5738
|
/**
|
|
5534
5739
|
* The line's unit count (REB-24363) — the selectable-GWP verdict trims surplus units against milestone
|
|
5535
5740
|
* capacity. The second deliberate default: a client predating the field sent only GWP lines, whose
|
|
5536
5741
|
* verdict is whole-line, so a missing quantity reads as one unit rather than 422ing the older request.
|
|
5537
5742
|
*/
|
|
5538
|
-
quantity:
|
|
5539
|
-
widgetId:
|
|
5743
|
+
quantity: import_zod39.z.number().int().min(1).default(1),
|
|
5744
|
+
widgetId: import_zod39.z.number()
|
|
5540
5745
|
});
|
|
5541
|
-
var GiftValidationInputSchema =
|
|
5746
|
+
var GiftValidationInputSchema = import_zod39.z.object({
|
|
5542
5747
|
cart: CartInputSchema,
|
|
5543
5748
|
/**
|
|
5544
5749
|
* Buyer's market country — threaded into the per-widget data-source evaluations, which forward it to
|
|
@@ -5547,25 +5752,25 @@ var GiftValidationInputSchema = import_zod36.z.object({
|
|
|
5547
5752
|
* turns markets off); regex-bound and uppercase-normalized for the same reasons as
|
|
5548
5753
|
* `DataSourceInputSchema`'s `country`.
|
|
5549
5754
|
*/
|
|
5550
|
-
country:
|
|
5551
|
-
customerId:
|
|
5552
|
-
gifts:
|
|
5755
|
+
country: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).regex(/^[A-Za-z]{2}$/, "must be an ISO 3166-1 alpha-2 country code (e.g. CA)").transform((value) => value.toUpperCase()).optional(),
|
|
5756
|
+
customerId: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5757
|
+
gifts: import_zod39.z.array(GiftInputSchema).max(REQUEST_BOUNDS.GIFTS_MAX),
|
|
5553
5758
|
/**
|
|
5554
5759
|
* Buyer's checkout language — threaded into the per-widget data-source evaluations, which normalize
|
|
5555
5760
|
* and forward it as the engine `locale` param under the same markets-toggle gate (REB-21688). MUST be
|
|
5556
5761
|
* a single BCP-47 tag, for the same reason as `DataSourceInputSchema`'s `language` above.
|
|
5557
5762
|
*/
|
|
5558
|
-
language:
|
|
5559
|
-
shop:
|
|
5560
|
-
visitorId:
|
|
5763
|
+
language: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).regex(/^[A-Za-z0-9-]+$/, "must be a single BCP-47 tag (e.g. fr-CA), not a q-value list").optional(),
|
|
5764
|
+
shop: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
5765
|
+
visitorId: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
5561
5766
|
});
|
|
5562
|
-
var GiftAdjustmentSchema =
|
|
5563
|
-
lineId:
|
|
5564
|
-
quantity:
|
|
5767
|
+
var GiftAdjustmentSchema = import_zod39.z.object({
|
|
5768
|
+
lineId: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
5769
|
+
quantity: import_zod39.z.number().int().nonnegative()
|
|
5565
5770
|
});
|
|
5566
|
-
var GiftValidationResponseSchema =
|
|
5567
|
-
adjust:
|
|
5568
|
-
remove:
|
|
5771
|
+
var GiftValidationResponseSchema = import_zod39.z.object({
|
|
5772
|
+
adjust: import_zod39.z.array(GiftAdjustmentSchema).max(REQUEST_BOUNDS.GIFTS_MAX).default([]),
|
|
5773
|
+
remove: import_zod39.z.array(import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX)).max(REQUEST_BOUNDS.GIFTS_MAX).refine(
|
|
5569
5774
|
(remove) => new Set(remove).size === remove.length,
|
|
5570
5775
|
"a line id may appear at most once in `remove`"
|
|
5571
5776
|
)
|
|
@@ -5576,47 +5781,47 @@ var GiftValidationResponseSchema = import_zod36.z.object({
|
|
|
5576
5781
|
({ adjust }) => new Set(adjust.map(({ lineId }) => lineId)).size === adjust.length,
|
|
5577
5782
|
"a line id may appear at most once in `adjust`"
|
|
5578
5783
|
);
|
|
5579
|
-
var MonetizeTransactionItemSchema =
|
|
5580
|
-
id:
|
|
5581
|
-
priceCents:
|
|
5582
|
-
quantity:
|
|
5583
|
-
title:
|
|
5584
|
-
type:
|
|
5784
|
+
var MonetizeTransactionItemSchema = import_zod39.z.object({
|
|
5785
|
+
id: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
5786
|
+
priceCents: import_zod39.z.number(),
|
|
5787
|
+
quantity: import_zod39.z.number(),
|
|
5788
|
+
title: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX),
|
|
5789
|
+
type: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX)
|
|
5585
5790
|
});
|
|
5586
|
-
var MonetizeInputSchema =
|
|
5791
|
+
var MonetizeInputSchema = import_zod39.z.object({
|
|
5587
5792
|
cart: CartInputSchema,
|
|
5588
5793
|
/** Client-minted render-beacon correlation id; forwarded to the ads engine as `client_request_id`. */
|
|
5589
|
-
clientRequestId:
|
|
5590
|
-
country:
|
|
5591
|
-
currency:
|
|
5794
|
+
clientRequestId: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5795
|
+
country: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5796
|
+
currency: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5592
5797
|
/** Ads-targeting identity/geo/locale fields (React parity); folded into the engine query verbatim. */
|
|
5593
|
-
customerEmail:
|
|
5594
|
-
customerFirstName:
|
|
5595
|
-
customerId:
|
|
5596
|
-
customerLastName:
|
|
5597
|
-
language:
|
|
5798
|
+
customerEmail: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX).optional(),
|
|
5799
|
+
customerFirstName: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX).optional(),
|
|
5800
|
+
customerId: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5801
|
+
customerLastName: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX).optional(),
|
|
5802
|
+
language: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5598
5803
|
/** Buyer-facing order name (e.g. `#1001`) for the server-composed "Order … Confirmed" chrome line. */
|
|
5599
|
-
orderName:
|
|
5804
|
+
orderName: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_TEXT_MAX).optional(),
|
|
5600
5805
|
/** Ads surface label, forwarded verbatim; `customer_account` is measured/floored as its own surface (the account-area order list). */
|
|
5601
|
-
placement:
|
|
5806
|
+
placement: import_zod39.z.enum(["customer_account", "order_status", "thank_you_page"]),
|
|
5602
5807
|
/** Privacy Policy footer href — the Monetize widget's `privacy_policy_url` setting (React parity). */
|
|
5603
|
-
privacyPolicyUrl:
|
|
5808
|
+
privacyPolicyUrl: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_URL_MAX).optional(),
|
|
5604
5809
|
/** 30-min rolling session id (React parity); used for the ads `session_id`, else the visitor id. */
|
|
5605
|
-
sessionId:
|
|
5606
|
-
shop:
|
|
5810
|
+
sessionId: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5811
|
+
shop: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
5607
5812
|
/** Editor/QA indicator; OR-ed into the ads-engine `testing` flag so it stays out of billing/reporting. */
|
|
5608
|
-
testing:
|
|
5609
|
-
timezone:
|
|
5813
|
+
testing: import_zod39.z.boolean().optional(),
|
|
5814
|
+
timezone: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5610
5815
|
/** Decorated (numeric) order id → the ads `transaction_id`. */
|
|
5611
|
-
transactionId:
|
|
5816
|
+
transactionId: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5612
5817
|
/** Rich per-line ads items; capped at the engine's ads contract. Preferred over `cart.items`. */
|
|
5613
|
-
transactionItems:
|
|
5818
|
+
transactionItems: import_zod39.z.array(MonetizeTransactionItemSchema).max(REQUEST_BOUNDS.TRANSACTION_ITEMS_MAX).optional(),
|
|
5614
5819
|
/** Order total in presentment cents (React prefers total over subtotal); else `cart.subtotal`. */
|
|
5615
|
-
transactionTotal:
|
|
5616
|
-
visitorId:
|
|
5617
|
-
zipCode:
|
|
5820
|
+
transactionTotal: import_zod39.z.number().optional(),
|
|
5821
|
+
visitorId: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5822
|
+
zipCode: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
5618
5823
|
});
|
|
5619
|
-
var WidgetSettingsInputSchema =
|
|
5824
|
+
var WidgetSettingsInputSchema = import_zod39.z.object({
|
|
5620
5825
|
/**
|
|
5621
5826
|
* Same domain as `CabShopConfig.cacheKey`, for the same reason: this side WINS the orchestrator's
|
|
5622
5827
|
* `input.cacheKey ?? config.shop.cacheKey` (and an explicit value skips the config read entirely), so
|
|
@@ -5624,9 +5829,9 @@ var WidgetSettingsInputSchema = import_zod36.z.object({
|
|
|
5624
5829
|
* and pin the edge copy permanently stale. `.catch(undefined)` because a bogus buster should degrade
|
|
5625
5830
|
* the read to un-busted, never 400 a widget render.
|
|
5626
5831
|
*/
|
|
5627
|
-
cacheKey:
|
|
5628
|
-
id:
|
|
5629
|
-
key:
|
|
5832
|
+
cacheKey: import_zod39.z.number().int().positive().optional().catch(void 0),
|
|
5833
|
+
id: import_zod39.z.number(),
|
|
5834
|
+
key: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5630
5835
|
/**
|
|
5631
5836
|
* Monetize context for inline hydration: when present AND the widget converts to a Monetize marker,
|
|
5632
5837
|
* the server fetches/composes the offer cards inside this same request (no second `/cab/monetize`
|
|
@@ -5635,34 +5840,34 @@ var WidgetSettingsInputSchema = import_zod36.z.object({
|
|
|
5635
5840
|
* `privacyPolicyUrl` comes from the widget settings server-side (more authoritative than a relay).
|
|
5636
5841
|
*/
|
|
5637
5842
|
monetize: MonetizeInputSchema.omit({ privacyPolicyUrl: true, shop: true }).optional(),
|
|
5638
|
-
shop:
|
|
5843
|
+
shop: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
5639
5844
|
/** Stable per-buyer id; when present, enables sticky server-side A/B variant selection. */
|
|
5640
|
-
visitorId:
|
|
5845
|
+
visitorId: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
5641
5846
|
});
|
|
5642
|
-
var AnalyticsEventInputSchema =
|
|
5643
|
-
name:
|
|
5644
|
-
properties:
|
|
5645
|
-
sentAt:
|
|
5847
|
+
var AnalyticsEventInputSchema = import_zod39.z.object({
|
|
5848
|
+
name: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_KEY_MAX),
|
|
5849
|
+
properties: import_zod39.z.record(import_zod39.z.string().max(REQUEST_BOUNDS.STRING_KEY_MAX), import_zod39.z.unknown()).optional(),
|
|
5850
|
+
sentAt: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
5646
5851
|
});
|
|
5647
|
-
var AnalyticsSegmentsInputSchema =
|
|
5648
|
-
device:
|
|
5649
|
-
source:
|
|
5650
|
-
visitor:
|
|
5852
|
+
var AnalyticsSegmentsInputSchema = import_zod39.z.object({
|
|
5853
|
+
device: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional().catch(void 0),
|
|
5854
|
+
source: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional().catch(void 0),
|
|
5855
|
+
visitor: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional().catch(void 0)
|
|
5651
5856
|
});
|
|
5652
|
-
var AnalyticsInputSchema =
|
|
5857
|
+
var AnalyticsInputSchema = import_zod39.z.object({
|
|
5653
5858
|
/** Rebuy cart token (the `r_cart_token` cart attribute), when available — primary aggregation key. */
|
|
5654
|
-
cartToken:
|
|
5859
|
+
cartToken: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5655
5860
|
/** Shopify checkout token, when available — drives cart/checkout aggregation downstream. */
|
|
5656
|
-
checkoutToken:
|
|
5657
|
-
events:
|
|
5861
|
+
checkoutToken: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional(),
|
|
5862
|
+
events: import_zod39.z.array(AnalyticsEventInputSchema).max(REQUEST_BOUNDS.EVENTS_MAX),
|
|
5658
5863
|
/**
|
|
5659
5864
|
* Request-scoped like the tokens: one visitor's segments apply to every event in the batch. The container
|
|
5660
5865
|
* degrades too (`null` is a realistic wire artifact of `attributes ? {…} : null`), so the degrade rule is
|
|
5661
5866
|
* total: nothing about `segments` can cost the envelope.
|
|
5662
5867
|
*/
|
|
5663
5868
|
segments: AnalyticsSegmentsInputSchema.optional().catch(void 0),
|
|
5664
|
-
shop:
|
|
5665
|
-
visitorId:
|
|
5869
|
+
shop: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
5870
|
+
visitorId: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX),
|
|
5666
5871
|
/** The widget id (smartBlockId) the events belong to. */
|
|
5667
|
-
widgetId:
|
|
5872
|
+
widgetId: import_zod39.z.string().max(REQUEST_BOUNDS.STRING_ID_MAX).optional()
|
|
5668
5873
|
});
|