@rebuy/rebuy 3.24.0 → 3.26.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.
@@ -45,6 +45,7 @@ __export(checkout_and_beyond_exports, {
45
45
  CABImageSectionFields: () => CABImageSectionFields,
46
46
  CABIntegrations: () => CABIntegrations,
47
47
  CABLayoutSection: () => CABLayoutSection,
48
+ CABMonetizeAds: () => CABMonetizeAds,
48
49
  CABMonetizeSection: () => CABMonetizeSection,
49
50
  CABNumberVariable: () => CABNumberVariable,
50
51
  CABOffersSection: () => CABOffersSection,
@@ -1134,8 +1135,14 @@ var CABDiscountSection = import_zod12.z.object({
1134
1135
  // src/schema/widgets/checkout-and-beyond/monetize.ts
1135
1136
  var import_uuid8 = require("uuid");
1136
1137
  var import_zod13 = require("zod");
1138
+ var CABMonetizeAds = import_zod13.z.object({
1139
+ requestId: import_zod13.z.string().optional(),
1140
+ /** Defaulted here, never in the beacon: absence of information is `ads` itself being absent. */
1141
+ testing: import_zod13.z.boolean().default(false)
1142
+ });
1137
1143
  var CABMonetizeSection = import_zod13.z.object({
1138
1144
  ...CABVariableFields,
1145
+ ads: CABMonetizeAds.optional(),
1139
1146
  name: import_zod13.z.string().optional(),
1140
1147
  /**
1141
1148
  * Server-hydrated offer cards (inline hydration): when `/cab/sections` was asked with a `monetize`
@@ -929,8 +929,14 @@ var CABDiscountSection = z12.object({
929
929
  // src/schema/widgets/checkout-and-beyond/monetize.ts
930
930
  import { v7 as uuidv78 } from "uuid";
931
931
  import { z as z13 } from "zod";
932
+ var CABMonetizeAds = z13.object({
933
+ requestId: z13.string().optional(),
934
+ /** Defaulted here, never in the beacon: absence of information is `ads` itself being absent. */
935
+ testing: z13.boolean().default(false)
936
+ });
932
937
  var CABMonetizeSection = z13.object({
933
938
  ...CABVariableFields,
939
+ ads: CABMonetizeAds.optional(),
934
940
  name: z13.string().optional(),
935
941
  /**
936
942
  * Server-hydrated offer cards (inline hydration): when `/cab/sections` was asked with a `monetize`
@@ -1909,6 +1915,7 @@ export {
1909
1915
  CABImageSectionFields,
1910
1916
  CABIntegrations,
1911
1917
  CABLayoutSection,
1918
+ CABMonetizeAds,
1912
1919
  CABMonetizeSection,
1913
1920
  CABNumberVariable,
1914
1921
  CABOffersSection,
@@ -1,6 +1,10 @@
1
1
  export * from './cabShopConfig';
2
2
  export * from './metadata';
3
3
  export * from './offerProduct';
4
+ export * from './postPurchaseEligibility';
5
+ export * from './postPurchaseIdentity';
6
+ export * from './postPurchaseShadow';
7
+ export * from './postPurchaseSkipTrace';
4
8
  export * from './product';
5
9
  export * from './shopConfig';
6
10
  export * from './smartCart';
@@ -0,0 +1,12 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Why the Decider skipped a candidate. Extracted from the frozen branch's `PostPurchaseOfferEligibility`
4
+ * union, which also modeled retained product membership (`status: 'retain' | 'unavailable'`, `members`)
5
+ * — that half is Offer/product-specific and stays out of this Slice. Only the skip-reason vocabulary a
6
+ * skip trace records travels with the Decision contract.
7
+ */
8
+ export declare const PostPurchaseSkipReason: z.ZodEnum<{
9
+ empty: "empty";
10
+ "no-eligible-subscription": "no-eligible-subscription";
11
+ }>;
12
+ export type PostPurchaseSkipReason = z.infer<typeof PostPurchaseSkipReason>;
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ export declare const PostPurchaseTimestampSchema: z.ZodNumber;
3
+ export declare const PostPurchaseOrderIdSchema: z.ZodString;
4
+ export declare const ShopifyDomainSchema: z.ZodString;
5
+ export declare const DecideRequestSchema: z.ZodObject<{
6
+ checkoutToken: z.ZodString;
7
+ shop: z.ZodString;
8
+ }, z.core.$strip>;
9
+ /** A Decision entry: which Flow and node in its tree, which Split (widgetTraffic share) and Widget won. */
10
+ export declare const DecisionEntrySchema: z.ZodObject<{
11
+ blockId: z.ZodNumber;
12
+ blockIndex: z.ZodString;
13
+ blockParentIndex: z.ZodString;
14
+ flowId: z.ZodNumber;
15
+ sectionId: z.ZodNumber;
16
+ widgetId: z.ZodNumber;
17
+ widgetTraffic: z.ZodNumber;
18
+ }, z.core.$strip>;
@@ -0,0 +1,69 @@
1
+ import { z } from 'zod';
2
+ /** Either the Decider found a Widget candidate worth rendering, or it decided to skip. */
3
+ export declare const PostPurchaseShadowSelectionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
4
+ entry: z.ZodObject<{
5
+ blockId: z.ZodNumber;
6
+ blockIndex: z.ZodString;
7
+ blockParentIndex: z.ZodString;
8
+ flowId: z.ZodNumber;
9
+ sectionId: z.ZodNumber;
10
+ widgetId: z.ZodNumber;
11
+ widgetTraffic: z.ZodNumber;
12
+ }, z.core.$strip>;
13
+ verdict: z.ZodLiteral<"render">;
14
+ }, z.core.$strip>, z.ZodObject<{
15
+ verdict: z.ZodLiteral<"skip">;
16
+ }, z.core.$strip>], "verdict">;
17
+ export type PostPurchaseShadowSelection = z.infer<typeof PostPurchaseShadowSelectionSchema>;
18
+ /**
19
+ * A shadow comparison between the legacy client-side selection and the Decider's own — wire-only. The
20
+ * sampled request/capture shape (`ShadowSampleSchema` upstream, with its Flow-listing and product data)
21
+ * is not small and stays out of this Slice.
22
+ */
23
+ export declare const PostPurchaseShadowReportSchema: z.ZodObject<{
24
+ differences: z.ZodArray<z.ZodEnum<{
25
+ verdict: "verdict";
26
+ entry: "entry";
27
+ targeting: "targeting";
28
+ "incomplete-capture": "incomplete-capture";
29
+ "unsupported-configuration": "unsupported-configuration";
30
+ }>>;
31
+ legacySelection: z.ZodDiscriminatedUnion<[z.ZodObject<{
32
+ entry: z.ZodObject<{
33
+ blockId: z.ZodNumber;
34
+ blockIndex: z.ZodString;
35
+ blockParentIndex: z.ZodString;
36
+ flowId: z.ZodNumber;
37
+ sectionId: z.ZodNumber;
38
+ widgetId: z.ZodNumber;
39
+ widgetTraffic: z.ZodNumber;
40
+ }, z.core.$strip>;
41
+ verdict: z.ZodLiteral<"render">;
42
+ }, z.core.$strip>, z.ZodObject<{
43
+ verdict: z.ZodLiteral<"skip">;
44
+ }, z.core.$strip>], "verdict">;
45
+ phase: z.ZodLiteral<"shouldRender">;
46
+ sampleId: z.ZodString;
47
+ serverSelection: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
48
+ entry: z.ZodObject<{
49
+ blockId: z.ZodNumber;
50
+ blockIndex: z.ZodString;
51
+ blockParentIndex: z.ZodString;
52
+ flowId: z.ZodNumber;
53
+ sectionId: z.ZodNumber;
54
+ widgetId: z.ZodNumber;
55
+ widgetTraffic: z.ZodNumber;
56
+ }, z.core.$strip>;
57
+ verdict: z.ZodLiteral<"render">;
58
+ }, z.core.$strip>, z.ZodObject<{
59
+ verdict: z.ZodLiteral<"skip">;
60
+ }, z.core.$strip>], "verdict">>;
61
+ status: z.ZodEnum<{
62
+ match: "match";
63
+ diverged: "diverged";
64
+ incomplete: "incomplete";
65
+ }>;
66
+ targetingFlowIds: z.ZodArray<z.ZodNumber>;
67
+ workflowPhase: z.ZodLiteral<"decide">;
68
+ }, z.core.$strip>;
69
+ export type PostPurchaseShadowReport = z.infer<typeof PostPurchaseShadowReportSchema>;
@@ -0,0 +1,19 @@
1
+ import { z } from 'zod';
2
+ export declare const POST_PURCHASE_SKIP_LIMIT = 32;
3
+ /** This request's verified reads, not a claim about the path of a competing committed winner. */
4
+ export declare const PostPurchaseSkipTrace: z.ZodArray<z.ZodObject<{
5
+ entry: z.ZodObject<{
6
+ blockId: z.ZodNumber;
7
+ blockIndex: z.ZodString;
8
+ blockParentIndex: z.ZodString;
9
+ flowId: z.ZodNumber;
10
+ sectionId: z.ZodNumber;
11
+ widgetId: z.ZodNumber;
12
+ widgetTraffic: z.ZodNumber;
13
+ }, z.core.$strip>;
14
+ reason: z.ZodEnum<{
15
+ empty: "empty";
16
+ "no-eligible-subscription": "no-eligible-subscription";
17
+ }>;
18
+ }, z.core.$strip>>;
19
+ export type PostPurchaseSkipTrace = z.infer<typeof PostPurchaseSkipTrace>;
@@ -966,8 +966,14 @@ var CABDiscountSection = import_zod15.z.object({
966
966
  // src/schema/widgets/checkout-and-beyond/monetize.ts
967
967
  var import_uuid8 = require("uuid");
968
968
  var import_zod16 = require("zod");
969
+ var CABMonetizeAds = import_zod16.z.object({
970
+ requestId: import_zod16.z.string().optional(),
971
+ /** Defaulted here, never in the beacon: absence of information is `ads` itself being absent. */
972
+ testing: import_zod16.z.boolean().default(false)
973
+ });
969
974
  var CABMonetizeSection = import_zod16.z.object({
970
975
  ...CABVariableFields,
976
+ ads: CABMonetizeAds.optional(),
971
977
  name: import_zod16.z.string().optional(),
972
978
  /**
973
979
  * Server-hydrated offer cards (inline hydration): when `/cab/sections` was asked with a `monetize`
@@ -941,8 +941,14 @@ var CABDiscountSection = z15.object({
941
941
  // src/schema/widgets/checkout-and-beyond/monetize.ts
942
942
  import { v7 as uuidv78 } from "uuid";
943
943
  import { z as z16 } from "zod";
944
+ var CABMonetizeAds = z16.object({
945
+ requestId: z16.string().optional(),
946
+ /** Defaulted here, never in the beacon: absence of information is `ads` itself being absent. */
947
+ testing: z16.boolean().default(false)
948
+ });
944
949
  var CABMonetizeSection = z16.object({
945
950
  ...CABVariableFields,
951
+ ads: CABMonetizeAds.optional(),
946
952
  name: z16.string().optional(),
947
953
  /**
948
954
  * Server-hydrated offer cards (inline hydration): when `/cab/sections` was asked with a `monetize`
@@ -5,6 +5,7 @@ import { type SectionDetails } from './shared';
5
5
  export declare const CABBannerSection: z.ZodLazy<z.ZodObject<{
6
6
  name: z.ZodOptional<z.ZodString>;
7
7
  width: z.ZodDefault<z.ZodNumber>;
8
+ sectionId: z.ZodDefault<z.ZodUUID>;
8
9
  grid: z.ZodOptional<z.ZodDefault<z.ZodObject<{
9
10
  columns: z.ZodDefault<z.ZodUnion<readonly [z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<"auto">, z.ZodLiteral<"fill">, z.ZodString, z.ZodNumber]>>, z.ZodUndefined]>>;
10
11
  rows: z.ZodDefault<z.ZodUnion<readonly [z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<"auto">, z.ZodLiteral<"fill">, z.ZodString, z.ZodNumber]>>, z.ZodUndefined]>>;
@@ -29,7 +30,6 @@ export declare const CABBannerSection: z.ZodLazy<z.ZodObject<{
29
30
  thick: "thick";
30
31
  }>>;
31
32
  }, z.core.$strip>>>;
32
- sectionId: z.ZodDefault<z.ZodUUID>;
33
33
  mutators: z.ZodOptional<z.ZodArray<z.ZodObject<{
34
34
  effect: z.ZodDefault<z.ZodEnum<{
35
35
  set_false: "set_false";
@@ -5,6 +5,7 @@ import { CABSection, type SectionDetails } from './shared';
5
5
  export declare const CABCarouselSection: z.ZodLazy<z.ZodObject<{
6
6
  name: z.ZodOptional<z.ZodString>;
7
7
  width: z.ZodDefault<z.ZodNumber>;
8
+ sectionId: z.ZodDefault<z.ZodUUID>;
8
9
  grid: z.ZodOptional<z.ZodDefault<z.ZodObject<{
9
10
  columns: z.ZodDefault<z.ZodUnion<readonly [z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<"auto">, z.ZodLiteral<"fill">, z.ZodString, z.ZodNumber]>>, z.ZodUndefined]>>;
10
11
  rows: z.ZodDefault<z.ZodUnion<readonly [z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<"auto">, z.ZodLiteral<"fill">, z.ZodString, z.ZodNumber]>>, z.ZodUndefined]>>;
@@ -54,7 +55,6 @@ export declare const CABCarouselSection: z.ZodLazy<z.ZodObject<{
54
55
  switchToSubscriptionNoDiscount: "switchToSubscriptionNoDiscount";
55
56
  switchToSubscriptionWithDiscount: "switchToSubscriptionWithDiscount";
56
57
  }>>;
57
- sectionId: z.ZodDefault<z.ZodUUID>;
58
58
  mutators: z.ZodOptional<z.ZodArray<z.ZodObject<{
59
59
  effect: z.ZodDefault<z.ZodEnum<{
60
60
  set_false: "set_false";
@@ -4,6 +4,7 @@ import { CABSection, type SectionDetails } from './shared';
4
4
  export declare const CABCartLineSection: z.ZodLazy<z.ZodObject<{
5
5
  name: z.ZodOptional<z.ZodString>;
6
6
  width: z.ZodDefault<z.ZodNumber>;
7
+ sectionId: z.ZodDefault<z.ZodUUID>;
7
8
  grid: z.ZodOptional<z.ZodDefault<z.ZodObject<{
8
9
  columns: z.ZodDefault<z.ZodUnion<readonly [z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<"auto">, z.ZodLiteral<"fill">, z.ZodString, z.ZodNumber]>>, z.ZodUndefined]>>;
9
10
  rows: z.ZodDefault<z.ZodUnion<readonly [z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<"auto">, z.ZodLiteral<"fill">, z.ZodString, z.ZodNumber]>>, z.ZodUndefined]>>;
@@ -53,7 +54,6 @@ export declare const CABCartLineSection: z.ZodLazy<z.ZodObject<{
53
54
  switchToSubscriptionNoDiscount: "switchToSubscriptionNoDiscount";
54
55
  switchToSubscriptionWithDiscount: "switchToSubscriptionWithDiscount";
55
56
  }>>;
56
- sectionId: z.ZodDefault<z.ZodUUID>;
57
57
  mutators: z.ZodOptional<z.ZodArray<z.ZodObject<{
58
58
  effect: z.ZodDefault<z.ZodEnum<{
59
59
  set_false: "set_false";
@@ -20,6 +20,7 @@ export declare const IconName: {
20
20
  readonly check: "check";
21
21
  readonly image: "image";
22
22
  readonly discount: "discount";
23
+ readonly empty: "empty";
23
24
  readonly info: "info";
24
25
  readonly grid: "grid";
25
26
  readonly menu: "menu";
@@ -55,7 +56,6 @@ export declare const IconName: {
55
56
  readonly disabled: "disabled";
56
57
  readonly edit: "edit";
57
58
  readonly email: "email";
58
- readonly empty: "empty";
59
59
  readonly external: "external";
60
60
  readonly geolocation: "geolocation";
61
61
  readonly "gift-card": "gift-card";
@@ -94,6 +94,7 @@ export declare const CABImageSectionFields: z.ZodObject<{
94
94
  check: "check";
95
95
  image: "image";
96
96
  discount: "discount";
97
+ empty: "empty";
97
98
  info: "info";
98
99
  grid: "grid";
99
100
  menu: "menu";
@@ -129,7 +130,6 @@ export declare const CABImageSectionFields: z.ZodObject<{
129
130
  disabled: "disabled";
130
131
  edit: "edit";
131
132
  email: "email";
132
- empty: "empty";
133
133
  external: "external";
134
134
  geolocation: "geolocation";
135
135
  "gift-card": "gift-card";
@@ -448,6 +448,7 @@ export declare const CABImageSection: z.ZodObject<{
448
448
  check: "check";
449
449
  image: "image";
450
450
  discount: "discount";
451
+ empty: "empty";
451
452
  info: "info";
452
453
  grid: "grid";
453
454
  menu: "menu";
@@ -483,7 +484,6 @@ export declare const CABImageSection: z.ZodObject<{
483
484
  disabled: "disabled";
484
485
  edit: "edit";
485
486
  email: "email";
486
- empty: "empty";
487
487
  external: "external";
488
488
  geolocation: "geolocation";
489
489
  "gift-card": "gift-card";
@@ -1,7 +1,21 @@
1
1
  import { z } from 'zod';
2
2
  import { CABSection, type SectionDetails } from './shared';
3
3
  import { CABVariableFields } from './variables';
4
+ /**
5
+ * The ads engine's own verdict on the hydrated request, echoed for the render beacon (REB-24362):
6
+ * `testing` is server-final (the engine can force it, e.g. an armed offers-testing fixture) and
7
+ * `requestId` is its `ad_requests` row. Present only alongside hydrated `offers`.
8
+ */
9
+ export declare const CABMonetizeAds: z.ZodObject<{
10
+ requestId: z.ZodOptional<z.ZodString>;
11
+ testing: z.ZodDefault<z.ZodBoolean>;
12
+ }, z.core.$strip>;
13
+ export type CABMonetizeAds = z.infer<typeof CABMonetizeAds>;
4
14
  export declare const CABMonetizeSection: z.ZodObject<{
15
+ ads: z.ZodOptional<z.ZodObject<{
16
+ requestId: z.ZodOptional<z.ZodString>;
17
+ testing: z.ZodDefault<z.ZodBoolean>;
18
+ }, z.core.$strip>>;
5
19
  name: z.ZodOptional<z.ZodString>;
6
20
  offers: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodType<CABSection, unknown, z.core.$ZodTypeInternals<CABSection, unknown>>>>>;
7
21
  privacyPolicyUrl: z.ZodOptional<z.ZodString>;
@@ -197,6 +211,7 @@ export declare const CABMonetizeSection: z.ZodObject<{
197
211
  }, z.core.$strip>;
198
212
  /** Twin of the schema above — `offers` makes this a recursive node (see recursiveTwins.test.ts). */
199
213
  export type CABMonetizeSection = CABVariableFields & {
214
+ ads?: CABMonetizeAds;
200
215
  name?: string;
201
216
  offers?: CABSection[];
202
217
  privacyPolicyUrl?: string;
@@ -4,6 +4,7 @@ import { CABSection, type SectionDetails } from './shared';
4
4
  export declare const CABOffersSection: z.ZodLazy<z.ZodObject<{
5
5
  name: z.ZodOptional<z.ZodString>;
6
6
  width: z.ZodDefault<z.ZodNumber>;
7
+ sectionId: z.ZodDefault<z.ZodUUID>;
7
8
  grid: z.ZodOptional<z.ZodDefault<z.ZodObject<{
8
9
  columns: z.ZodDefault<z.ZodUnion<readonly [z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<"auto">, z.ZodLiteral<"fill">, z.ZodString, z.ZodNumber]>>, z.ZodUndefined]>>;
9
10
  rows: z.ZodDefault<z.ZodUnion<readonly [z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<"auto">, z.ZodLiteral<"fill">, z.ZodString, z.ZodNumber]>>, z.ZodUndefined]>>;
@@ -53,7 +54,6 @@ export declare const CABOffersSection: z.ZodLazy<z.ZodObject<{
53
54
  switchToSubscriptionNoDiscount: "switchToSubscriptionNoDiscount";
54
55
  switchToSubscriptionWithDiscount: "switchToSubscriptionWithDiscount";
55
56
  }>>;
56
- sectionId: z.ZodDefault<z.ZodUUID>;
57
57
  mutators: z.ZodOptional<z.ZodArray<z.ZodObject<{
58
58
  effect: z.ZodDefault<z.ZodEnum<{
59
59
  set_false: "set_false";
@@ -69,6 +69,7 @@ export type CABProgressTier = z.infer<typeof CABProgressTier>;
69
69
  */
70
70
  export declare const CABProgressBarSection: z.ZodLazy<z.ZodObject<{
71
71
  width: z.ZodDefault<z.ZodNumber>;
72
+ sectionId: z.ZodDefault<z.ZodUUID>;
72
73
  grid: z.ZodOptional<z.ZodDefault<z.ZodObject<{
73
74
  columns: z.ZodDefault<z.ZodUnion<readonly [z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<"auto">, z.ZodLiteral<"fill">, z.ZodString, z.ZodNumber]>>, z.ZodUndefined]>>;
74
75
  rows: z.ZodDefault<z.ZodUnion<readonly [z.ZodArray<z.ZodUnion<readonly [z.ZodLiteral<"auto">, z.ZodLiteral<"fill">, z.ZodString, z.ZodNumber]>>, z.ZodUndefined]>>;
@@ -118,7 +119,6 @@ export declare const CABProgressBarSection: z.ZodLazy<z.ZodObject<{
118
119
  switchToSubscriptionNoDiscount: "switchToSubscriptionNoDiscount";
119
120
  switchToSubscriptionWithDiscount: "switchToSubscriptionWithDiscount";
120
121
  }>>;
121
- sectionId: z.ZodDefault<z.ZodUUID>;
122
122
  mutators: z.ZodOptional<z.ZodArray<z.ZodObject<{
123
123
  effect: z.ZodDefault<z.ZodEnum<{
124
124
  set_false: "set_false";
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { type CabUserConfig } from '../schema/cabShopConfig';
3
+ import { type CABMonetizeAds } from '../schema/widgets/checkout-and-beyond/monetize';
3
4
  import { type MonetizeInput, type ServerContext } from '../server/shared';
4
5
  /**
5
6
  * A single ads-engine offer. The `*_url` fields are tracking endpoints the engine returns fully
@@ -35,8 +36,16 @@ export declare const isTestingRequest: (input: MonetizeInput, isProduction: bool
35
36
  * (total preferred over subtotal). Empty values are omitted.
36
37
  */
37
38
  export declare const buildAdsParams: (input: MonetizeInput, publisherKey: string, supplyKey: string, testing: boolean, userAgent?: string, ipAddress?: string) => Record<string, string>;
38
- /** The engine offers plus the shop's display name (for the header copy), resolved on the same config read. */
39
+ /**
40
+ * The engine offers plus the shop's display name (for the header copy), resolved on the same config
41
+ * read, plus `ads` — what the engine decided about the request, for the render beacon to echo verbatim
42
+ * (REB-24362): `testing` is the engine's response flag OR-ed with the flag we sent (never only our own
43
+ * rule, because the engine can force it server-side) and `requestId` is its `ad_requests` row id. Present
44
+ * only once the engine was actually called (absent on every early return, where there is no request to
45
+ * describe).
46
+ */
39
47
  export type AdsEngineResult = {
48
+ ads?: CABMonetizeAds;
40
49
  offers: AdsEngineOffer[];
41
50
  storeName?: string;
42
51
  };
@@ -1579,8 +1579,14 @@ var CABDiscountSection = import_zod19.z.object({
1579
1579
  // src/schema/widgets/checkout-and-beyond/monetize.ts
1580
1580
  var import_uuid8 = require("uuid");
1581
1581
  var import_zod20 = require("zod");
1582
+ var CABMonetizeAds = import_zod20.z.object({
1583
+ requestId: import_zod20.z.string().optional(),
1584
+ /** Defaulted here, never in the beacon: absence of information is `ads` itself being absent. */
1585
+ testing: import_zod20.z.boolean().default(false)
1586
+ });
1582
1587
  var CABMonetizeSection = import_zod20.z.object({
1583
1588
  ...CABVariableFields,
1589
+ ads: CABMonetizeAds.optional(),
1584
1590
  name: import_zod20.z.string().optional(),
1585
1591
  /**
1586
1592
  * Server-hydrated offer cards (inline hydration): when `/cab/sections` was asked with a `monetize`
@@ -4290,7 +4296,15 @@ var AdsEngineResponse = import_zod28.z.object({
4290
4296
  const result = AdsEngineOffer.safeParse(offer);
4291
4297
  return result.success ? [result.data] : [];
4292
4298
  })
4293
- )
4299
+ ),
4300
+ /**
4301
+ * Server-decided facts about THIS ads request, echoed so the render beacon can copy them (REB-24362).
4302
+ * `testing` is the engine's final verdict — it can be true when the caller sent false (an armed
4303
+ * offers-testing fixture on a test store forces it, REB-24467). Both optional: an older engine or a
4304
+ * non-JSON body must not fail the parse and drop the offers.
4305
+ */
4306
+ request_id: import_zod28.z.string().optional().catch(void 0),
4307
+ testing: import_zod28.z.boolean().optional().catch(void 0)
4294
4308
  });
4295
4309
  var adsHost = (host) => `offers.${host}`;
4296
4310
  var isTestingRequest = (input, isProduction) => !isProduction || !!input.testing || input.customerEmail?.toLowerCase() === TEST_CUSTOMER_EMAIL;
@@ -4338,19 +4352,21 @@ var fetchAdsEngineOffers = async (input, ctx, prefetched) => {
4338
4352
  if (!publisherKey) return { offers: [], storeName };
4339
4353
  const isProduction = ctx.host === REBUY_ENGINE_HOST;
4340
4354
  const supplyKey = isProduction ? SUPPLY_KEY.production : SUPPLY_KEY.staging;
4355
+ const testing = isTestingRequest(input, isProduction);
4341
4356
  const upstream = await ctx.fetchUpstream(
4342
4357
  "/api/v1/offers",
4343
- buildAdsParams(
4344
- input,
4345
- publisherKey,
4346
- supplyKey,
4347
- isTestingRequest(input, isProduction),
4348
- ctx.userAgent,
4349
- ctx.ipAddress
4350
- ),
4358
+ buildAdsParams(input, publisherKey, supplyKey, testing, ctx.userAgent, ctx.ipAddress),
4351
4359
  { host: adsHost(ctx.host) }
4352
4360
  );
4353
- return { offers: AdsEngineResponse.parse(upstream).offers, storeName };
4361
+ const response = AdsEngineResponse.parse(upstream);
4362
+ return {
4363
+ ads: {
4364
+ ...response.request_id && { requestId: response.request_id },
4365
+ testing: testing || response.testing === true
4366
+ },
4367
+ offers: response.offers,
4368
+ storeName
4369
+ };
4354
4370
  };
4355
4371
 
4356
4372
  // src/transforms/htmlToPlainText.ts
@@ -4549,7 +4565,7 @@ var composeOfferCard = (offer, input, storeName) => {
4549
4565
 
4550
4566
  // src/server/monetizeOffers.ts
4551
4567
  var fetchMonetizeOffers = async (input, ctx, prefetched) => {
4552
- const { offers: engineOffers, storeName } = await fetchAdsEngineOffers(input, ctx, prefetched);
4568
+ const { ads, offers: engineOffers, storeName } = await fetchAdsEngineOffers(input, ctx, prefetched);
4553
4569
  const composed = engineOffers.map((offer) => composeOfferCard(offer, input, storeName));
4554
4570
  const offers = composed.filter((card) => card !== void 0);
4555
4571
  if (offers.length < composed.length)
@@ -4557,7 +4573,7 @@ var fetchMonetizeOffers = async (input, ctx, prefetched) => {
4557
4573
  detail: `${composed.length - offers.length} monetize offer(s) failed to compose`,
4558
4574
  kind: "monetizeOffer"
4559
4575
  });
4560
- return { offers };
4576
+ return { ...ads && { ads }, offers };
4561
4577
  };
4562
4578
 
4563
4579
  // src/server/salvageSections.ts
@@ -4651,7 +4667,7 @@ var hydrateMonetizeMarkers = async (converted, input, ctx, config) => {
4651
4667
  const first = findMonetizeMarker(converted);
4652
4668
  if (!first) return;
4653
4669
  try {
4654
- const { offers } = await fetchMonetizeOffers(
4670
+ const { ads, offers } = await fetchMonetizeOffers(
4655
4671
  {
4656
4672
  ...input.monetize,
4657
4673
  privacyPolicyUrl: first.privacyPolicyUrl,
@@ -4662,6 +4678,7 @@ var hydrateMonetizeMarkers = async (converted, input, ctx, config) => {
4662
4678
  config ?? void 0
4663
4679
  );
4664
4680
  first.offers = offers;
4681
+ if (ads) first.ads = ads;
4665
4682
  } catch (err) {
4666
4683
  ctx.reportDrift?.({
4667
4684
  detail: `inline hydration failed: ${err instanceof Error ? err.message : String(err)}`,
@@ -1528,8 +1528,14 @@ var CABDiscountSection = z19.object({
1528
1528
  // src/schema/widgets/checkout-and-beyond/monetize.ts
1529
1529
  import { v7 as uuidv78 } from "uuid";
1530
1530
  import { z as z20 } from "zod";
1531
+ var CABMonetizeAds = z20.object({
1532
+ requestId: z20.string().optional(),
1533
+ /** Defaulted here, never in the beacon: absence of information is `ads` itself being absent. */
1534
+ testing: z20.boolean().default(false)
1535
+ });
1531
1536
  var CABMonetizeSection = z20.object({
1532
1537
  ...CABVariableFields,
1538
+ ads: CABMonetizeAds.optional(),
1533
1539
  name: z20.string().optional(),
1534
1540
  /**
1535
1541
  * Server-hydrated offer cards (inline hydration): when `/cab/sections` was asked with a `monetize`
@@ -4239,7 +4245,15 @@ var AdsEngineResponse = z28.object({
4239
4245
  const result = AdsEngineOffer.safeParse(offer);
4240
4246
  return result.success ? [result.data] : [];
4241
4247
  })
4242
- )
4248
+ ),
4249
+ /**
4250
+ * Server-decided facts about THIS ads request, echoed so the render beacon can copy them (REB-24362).
4251
+ * `testing` is the engine's final verdict — it can be true when the caller sent false (an armed
4252
+ * offers-testing fixture on a test store forces it, REB-24467). Both optional: an older engine or a
4253
+ * non-JSON body must not fail the parse and drop the offers.
4254
+ */
4255
+ request_id: z28.string().optional().catch(void 0),
4256
+ testing: z28.boolean().optional().catch(void 0)
4243
4257
  });
4244
4258
  var adsHost = (host) => `offers.${host}`;
4245
4259
  var isTestingRequest = (input, isProduction) => !isProduction || !!input.testing || input.customerEmail?.toLowerCase() === TEST_CUSTOMER_EMAIL;
@@ -4287,19 +4301,21 @@ var fetchAdsEngineOffers = async (input, ctx, prefetched) => {
4287
4301
  if (!publisherKey) return { offers: [], storeName };
4288
4302
  const isProduction = ctx.host === REBUY_ENGINE_HOST;
4289
4303
  const supplyKey = isProduction ? SUPPLY_KEY.production : SUPPLY_KEY.staging;
4304
+ const testing = isTestingRequest(input, isProduction);
4290
4305
  const upstream = await ctx.fetchUpstream(
4291
4306
  "/api/v1/offers",
4292
- buildAdsParams(
4293
- input,
4294
- publisherKey,
4295
- supplyKey,
4296
- isTestingRequest(input, isProduction),
4297
- ctx.userAgent,
4298
- ctx.ipAddress
4299
- ),
4307
+ buildAdsParams(input, publisherKey, supplyKey, testing, ctx.userAgent, ctx.ipAddress),
4300
4308
  { host: adsHost(ctx.host) }
4301
4309
  );
4302
- return { offers: AdsEngineResponse.parse(upstream).offers, storeName };
4310
+ const response = AdsEngineResponse.parse(upstream);
4311
+ return {
4312
+ ads: {
4313
+ ...response.request_id && { requestId: response.request_id },
4314
+ testing: testing || response.testing === true
4315
+ },
4316
+ offers: response.offers,
4317
+ storeName
4318
+ };
4303
4319
  };
4304
4320
 
4305
4321
  // src/transforms/htmlToPlainText.ts
@@ -4498,7 +4514,7 @@ var composeOfferCard = (offer, input, storeName) => {
4498
4514
 
4499
4515
  // src/server/monetizeOffers.ts
4500
4516
  var fetchMonetizeOffers = async (input, ctx, prefetched) => {
4501
- const { offers: engineOffers, storeName } = await fetchAdsEngineOffers(input, ctx, prefetched);
4517
+ const { ads, offers: engineOffers, storeName } = await fetchAdsEngineOffers(input, ctx, prefetched);
4502
4518
  const composed = engineOffers.map((offer) => composeOfferCard(offer, input, storeName));
4503
4519
  const offers = composed.filter((card) => card !== void 0);
4504
4520
  if (offers.length < composed.length)
@@ -4506,7 +4522,7 @@ var fetchMonetizeOffers = async (input, ctx, prefetched) => {
4506
4522
  detail: `${composed.length - offers.length} monetize offer(s) failed to compose`,
4507
4523
  kind: "monetizeOffer"
4508
4524
  });
4509
- return { offers };
4525
+ return { ...ads && { ads }, offers };
4510
4526
  };
4511
4527
 
4512
4528
  // src/server/salvageSections.ts
@@ -4600,7 +4616,7 @@ var hydrateMonetizeMarkers = async (converted, input, ctx, config) => {
4600
4616
  const first = findMonetizeMarker(converted);
4601
4617
  if (!first) return;
4602
4618
  try {
4603
- const { offers } = await fetchMonetizeOffers(
4619
+ const { ads, offers } = await fetchMonetizeOffers(
4604
4620
  {
4605
4621
  ...input.monetize,
4606
4622
  privacyPolicyUrl: first.privacyPolicyUrl,
@@ -4611,6 +4627,7 @@ var hydrateMonetizeMarkers = async (converted, input, ctx, config) => {
4611
4627
  config ?? void 0
4612
4628
  );
4613
4629
  first.offers = offers;
4630
+ if (ads) first.ads = ads;
4614
4631
  } catch (err) {
4615
4632
  ctx.reportDrift?.({
4616
4633
  detail: `inline hydration failed: ${err instanceof Error ? err.message : String(err)}`,
@@ -1,7 +1,9 @@
1
1
  import { type CabUserConfig } from '../schema/cabShopConfig';
2
- import { type CABSection } from '../schema/widgets/checkout-and-beyond';
2
+ import { type CABMonetizeAds, type CABSection } from '../schema/widgets/checkout-and-beyond';
3
3
  import { type MonetizeInput, type ServerContext } from '../server/shared';
4
+ /** Cards plus the engine's own verdict on the request (`ads`), absent when the engine was never called. */
4
5
  export type MonetizeOffers = {
6
+ ads?: CABMonetizeAds;
5
7
  offers: CABSection[];
6
8
  };
7
9
  /**
@@ -290,6 +290,7 @@ export declare const WidgetSettingsInputSchema: z.ZodObject<{
290
290
  }, z.core.$strip>>;
291
291
  subtotal: z.ZodNumber;
292
292
  }, z.core.$strip>;
293
+ testing: z.ZodOptional<z.ZodBoolean>;
293
294
  country: z.ZodOptional<z.ZodString>;
294
295
  customerId: z.ZodOptional<z.ZodString>;
295
296
  visitorId: z.ZodOptional<z.ZodString>;
@@ -304,7 +305,6 @@ export declare const WidgetSettingsInputSchema: z.ZodObject<{
304
305
  thank_you_page: "thank_you_page";
305
306
  }>;
306
307
  sessionId: z.ZodOptional<z.ZodString>;
307
- testing: z.ZodOptional<z.ZodBoolean>;
308
308
  timezone: z.ZodOptional<z.ZodString>;
309
309
  transactionId: z.ZodOptional<z.ZodString>;
310
310
  transactionItems: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -963,8 +963,14 @@ var CABDiscountSection = import_zod13.z.object({
963
963
  // src/schema/widgets/checkout-and-beyond/monetize.ts
964
964
  var import_uuid8 = require("uuid");
965
965
  var import_zod14 = require("zod");
966
+ var CABMonetizeAds = import_zod14.z.object({
967
+ requestId: import_zod14.z.string().optional(),
968
+ /** Defaulted here, never in the beacon: absence of information is `ads` itself being absent. */
969
+ testing: import_zod14.z.boolean().default(false)
970
+ });
966
971
  var CABMonetizeSection = import_zod14.z.object({
967
972
  ...CABVariableFields,
973
+ ads: CABMonetizeAds.optional(),
968
974
  name: import_zod14.z.string().optional(),
969
975
  /**
970
976
  * Server-hydrated offer cards (inline hydration): when `/cab/sections` was asked with a `monetize`