@rebuy/rebuy 3.24.0 → 3.25.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/index.cjs +7 -0
- package/dist/index.mjs +7 -0
- package/dist/schema/checkout-and-beyond/index.cjs +7 -0
- package/dist/schema/checkout-and-beyond/index.mjs +7 -0
- package/dist/schema/widget-data.cjs +6 -0
- package/dist/schema/widget-data.mjs +6 -0
- package/dist/schema/widgets/checkout-and-beyond/monetize.d.ts +15 -0
- package/dist/server/adsEngine.d.ts +10 -1
- package/dist/server/index.cjs +30 -13
- package/dist/server/index.mjs +30 -13
- package/dist/server/monetizeOffers.d.ts +3 -1
- package/dist/server/requestSchemas.d.ts +1 -1
- package/dist/transforms/index.cjs +6 -0
- package/dist/transforms/index.mjs +6 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -48,6 +48,7 @@ __export(src_exports, {
|
|
|
48
48
|
CABImageSectionFields: () => CABImageSectionFields,
|
|
49
49
|
CABIntegrations: () => CABIntegrations,
|
|
50
50
|
CABLayoutSection: () => CABLayoutSection,
|
|
51
|
+
CABMonetizeAds: () => CABMonetizeAds,
|
|
51
52
|
CABMonetizeSection: () => CABMonetizeSection,
|
|
52
53
|
CABNumberVariable: () => CABNumberVariable,
|
|
53
54
|
CABOffersSection: () => CABOffersSection,
|
|
@@ -2621,8 +2622,14 @@ var CABDiscountSection = import_zod22.z.object({
|
|
|
2621
2622
|
// src/schema/widgets/checkout-and-beyond/monetize.ts
|
|
2622
2623
|
var import_uuid9 = require("uuid");
|
|
2623
2624
|
var import_zod23 = require("zod");
|
|
2625
|
+
var CABMonetizeAds = import_zod23.z.object({
|
|
2626
|
+
requestId: import_zod23.z.string().optional(),
|
|
2627
|
+
/** Defaulted here, never in the beacon: absence of information is `ads` itself being absent. */
|
|
2628
|
+
testing: import_zod23.z.boolean().default(false)
|
|
2629
|
+
});
|
|
2624
2630
|
var CABMonetizeSection = import_zod23.z.object({
|
|
2625
2631
|
...CABVariableFields,
|
|
2632
|
+
ads: CABMonetizeAds.optional(),
|
|
2626
2633
|
name: import_zod23.z.string().optional(),
|
|
2627
2634
|
/**
|
|
2628
2635
|
* Server-hydrated offer cards (inline hydration): when `/cab/sections` was asked with a `monetize`
|
package/dist/index.mjs
CHANGED
|
@@ -2326,8 +2326,14 @@ var CABDiscountSection = z22.object({
|
|
|
2326
2326
|
// src/schema/widgets/checkout-and-beyond/monetize.ts
|
|
2327
2327
|
import { v7 as uuidv78 } from "uuid";
|
|
2328
2328
|
import { z as z23 } from "zod";
|
|
2329
|
+
var CABMonetizeAds = z23.object({
|
|
2330
|
+
requestId: z23.string().optional(),
|
|
2331
|
+
/** Defaulted here, never in the beacon: absence of information is `ads` itself being absent. */
|
|
2332
|
+
testing: z23.boolean().default(false)
|
|
2333
|
+
});
|
|
2329
2334
|
var CABMonetizeSection = z23.object({
|
|
2330
2335
|
...CABVariableFields,
|
|
2336
|
+
ads: CABMonetizeAds.optional(),
|
|
2331
2337
|
name: z23.string().optional(),
|
|
2332
2338
|
/**
|
|
2333
2339
|
* Server-hydrated offer cards (inline hydration): when `/cab/sections` was asked with a `monetize`
|
|
@@ -4874,6 +4880,7 @@ export {
|
|
|
4874
4880
|
CABImageSectionFields,
|
|
4875
4881
|
CABIntegrations,
|
|
4876
4882
|
CABLayoutSection,
|
|
4883
|
+
CABMonetizeAds,
|
|
4877
4884
|
CABMonetizeSection,
|
|
4878
4885
|
CABNumberVariable,
|
|
4879
4886
|
CABOffersSection,
|
|
@@ -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,
|
|
@@ -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`
|
|
@@ -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;
|
|
@@ -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
|
-
/**
|
|
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
|
};
|
package/dist/server/index.cjs
CHANGED
|
@@ -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
|
-
|
|
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)}`,
|
package/dist/server/index.mjs
CHANGED
|
@@ -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
|
-
|
|
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`
|
|
@@ -904,8 +904,14 @@ var CABDiscountSection = z13.object({
|
|
|
904
904
|
// src/schema/widgets/checkout-and-beyond/monetize.ts
|
|
905
905
|
import { v7 as uuidv78 } from "uuid";
|
|
906
906
|
import { z as z14 } from "zod";
|
|
907
|
+
var CABMonetizeAds = z14.object({
|
|
908
|
+
requestId: z14.string().optional(),
|
|
909
|
+
/** Defaulted here, never in the beacon: absence of information is `ads` itself being absent. */
|
|
910
|
+
testing: z14.boolean().default(false)
|
|
911
|
+
});
|
|
907
912
|
var CABMonetizeSection = z14.object({
|
|
908
913
|
...CABVariableFields,
|
|
914
|
+
ads: CABMonetizeAds.optional(),
|
|
909
915
|
name: z14.string().optional(),
|
|
910
916
|
/**
|
|
911
917
|
* Server-hydrated offer cards (inline hydration): when `/cab/sections` was asked with a `monetize`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebuy/rebuy",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.25.0",
|
|
4
4
|
"description": "Shared zod schemas, legacy-to-CAB widget transforms, and server orchestrators for Rebuy's Shopify consumers (rebuy-api, admin-nextjs, rebuy-shopify-extensions)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Rebuy, Inc.",
|