@rebuy/rebuy 3.7.0 → 3.9.0-rc.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 +23 -1
- package/dist/index.mjs +23 -1
- package/dist/schema/checkout-and-beyond/index.cjs +7 -1
- package/dist/schema/checkout-and-beyond/index.mjs +7 -1
- package/dist/schema/widget-data.cjs +7 -1
- package/dist/schema/widget-data.mjs +7 -1
- package/dist/schema/widgets/checkout-and-beyond/monetize.d.ts +13 -2
- package/dist/server/index.cjs +252 -187
- package/dist/server/index.mjs +252 -187
- package/dist/server/requestSchemas.d.ts +59 -8
- package/dist/transforms/index.cjs +23 -1
- package/dist/transforms/index.mjs +23 -1
- package/dist/transforms/monetizeV1/convertMonetizeToV2.d.ts +3 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2519,7 +2519,13 @@ var import_zod23 = require("zod");
|
|
|
2519
2519
|
var CABMonetizeSection = import_zod23.z.object({
|
|
2520
2520
|
...CABVariableFields,
|
|
2521
2521
|
name: import_zod23.z.string().optional(),
|
|
2522
|
-
/**
|
|
2522
|
+
/**
|
|
2523
|
+
* Server-hydrated offer cards (inline hydration): when `/cab/sections` was asked with a `monetize`
|
|
2524
|
+
* context block, the composed cards ride the marker itself — `[]` means "hydrated, no fill" (render
|
|
2525
|
+
* nothing, skip the fetch); ABSENT means "not hydrated" (the client fetches via `/cab/monetize`).
|
|
2526
|
+
*/
|
|
2527
|
+
offers: import_zod23.z.array(import_zod23.z.lazy(() => CABSection)).optional(),
|
|
2528
|
+
/** Privacy Policy footer href (the widget's `privacy_policy_url` setting); read server-side for hydration, relayed by the client only on the legacy `/cab/monetize` fallback. */
|
|
2523
2529
|
privacyPolicyUrl: import_zod23.z.string().optional(),
|
|
2524
2530
|
sectionId: import_zod23.z.uuid().default(() => (0, import_uuid9.v7)()),
|
|
2525
2531
|
sectionType: import_zod23.z.literal(SectionType.monetize).default(SectionType.monetize),
|
|
@@ -4662,6 +4668,19 @@ var buildCarouselNav = () => ({
|
|
|
4662
4668
|
sectionType: "layout"
|
|
4663
4669
|
});
|
|
4664
4670
|
var hasHeaderText = (language) => !!(language?.title || language?.superTitle || language?.description);
|
|
4671
|
+
var HAS_PRODUCTS = "hasProducts";
|
|
4672
|
+
var hasProductsMutators = () => [
|
|
4673
|
+
{
|
|
4674
|
+
effect: "set_false",
|
|
4675
|
+
variable: HAS_PRODUCTS,
|
|
4676
|
+
when: { operator: "equals", type: "result_count", value: 0 }
|
|
4677
|
+
},
|
|
4678
|
+
{
|
|
4679
|
+
effect: "set_true",
|
|
4680
|
+
variable: HAS_PRODUCTS,
|
|
4681
|
+
when: { operator: "greater_than", type: "result_count", value: 0 }
|
|
4682
|
+
}
|
|
4683
|
+
];
|
|
4665
4684
|
var DISCOUNTED_FROM = {
|
|
4666
4685
|
compare_at_price: "compare_at_price",
|
|
4667
4686
|
original_price: "price",
|
|
@@ -4776,6 +4795,7 @@ var convertOfferToV2 = ({ id, name, settings }) => {
|
|
|
4776
4795
|
*/
|
|
4777
4796
|
alignment: horizontalCard ? { horizontal: "start", vertical: "middle" } : { horizontal: "center", vertical: "top" },
|
|
4778
4797
|
border: gridChrome ? { ...containerBorder, style: "none" } : containerBorder,
|
|
4798
|
+
mutators: hasProductsMutators(),
|
|
4779
4799
|
padding: gridChrome ? "none" : paddingFor(containerBorder.style),
|
|
4780
4800
|
sections: [
|
|
4781
4801
|
...buildOfferCard(settings, horizontalCard),
|
|
@@ -4813,7 +4833,9 @@ var convertOfferToV2 = ({ id, name, settings }) => {
|
|
|
4813
4833
|
// CABTracking's schema fallbacks fill missing or null fields and the missing object; malformed values throw.
|
|
4814
4834
|
tracking: settings.tracking,
|
|
4815
4835
|
type: SHOPIFY_CHECKOUT_EXTENSION,
|
|
4836
|
+
variables: [{ defaultValue: false, name: HAS_PRODUCTS }],
|
|
4816
4837
|
version: 2,
|
|
4838
|
+
visibility: { variable: HAS_PRODUCTS, visibleWhen: true },
|
|
4817
4839
|
widgetId: id
|
|
4818
4840
|
});
|
|
4819
4841
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -2238,7 +2238,13 @@ import { z as z23 } from "zod";
|
|
|
2238
2238
|
var CABMonetizeSection = z23.object({
|
|
2239
2239
|
...CABVariableFields,
|
|
2240
2240
|
name: z23.string().optional(),
|
|
2241
|
-
/**
|
|
2241
|
+
/**
|
|
2242
|
+
* Server-hydrated offer cards (inline hydration): when `/cab/sections` was asked with a `monetize`
|
|
2243
|
+
* context block, the composed cards ride the marker itself — `[]` means "hydrated, no fill" (render
|
|
2244
|
+
* nothing, skip the fetch); ABSENT means "not hydrated" (the client fetches via `/cab/monetize`).
|
|
2245
|
+
*/
|
|
2246
|
+
offers: z23.array(z23.lazy(() => CABSection)).optional(),
|
|
2247
|
+
/** Privacy Policy footer href (the widget's `privacy_policy_url` setting); read server-side for hydration, relayed by the client only on the legacy `/cab/monetize` fallback. */
|
|
2242
2248
|
privacyPolicyUrl: z23.string().optional(),
|
|
2243
2249
|
sectionId: z23.uuid().default(() => uuidv78()),
|
|
2244
2250
|
sectionType: z23.literal(SectionType.monetize).default(SectionType.monetize),
|
|
@@ -4381,6 +4387,19 @@ var buildCarouselNav = () => ({
|
|
|
4381
4387
|
sectionType: "layout"
|
|
4382
4388
|
});
|
|
4383
4389
|
var hasHeaderText = (language) => !!(language?.title || language?.superTitle || language?.description);
|
|
4390
|
+
var HAS_PRODUCTS = "hasProducts";
|
|
4391
|
+
var hasProductsMutators = () => [
|
|
4392
|
+
{
|
|
4393
|
+
effect: "set_false",
|
|
4394
|
+
variable: HAS_PRODUCTS,
|
|
4395
|
+
when: { operator: "equals", type: "result_count", value: 0 }
|
|
4396
|
+
},
|
|
4397
|
+
{
|
|
4398
|
+
effect: "set_true",
|
|
4399
|
+
variable: HAS_PRODUCTS,
|
|
4400
|
+
when: { operator: "greater_than", type: "result_count", value: 0 }
|
|
4401
|
+
}
|
|
4402
|
+
];
|
|
4384
4403
|
var DISCOUNTED_FROM = {
|
|
4385
4404
|
compare_at_price: "compare_at_price",
|
|
4386
4405
|
original_price: "price",
|
|
@@ -4495,6 +4514,7 @@ var convertOfferToV2 = ({ id, name, settings }) => {
|
|
|
4495
4514
|
*/
|
|
4496
4515
|
alignment: horizontalCard ? { horizontal: "start", vertical: "middle" } : { horizontal: "center", vertical: "top" },
|
|
4497
4516
|
border: gridChrome ? { ...containerBorder, style: "none" } : containerBorder,
|
|
4517
|
+
mutators: hasProductsMutators(),
|
|
4498
4518
|
padding: gridChrome ? "none" : paddingFor(containerBorder.style),
|
|
4499
4519
|
sections: [
|
|
4500
4520
|
...buildOfferCard(settings, horizontalCard),
|
|
@@ -4532,7 +4552,9 @@ var convertOfferToV2 = ({ id, name, settings }) => {
|
|
|
4532
4552
|
// CABTracking's schema fallbacks fill missing or null fields and the missing object; malformed values throw.
|
|
4533
4553
|
tracking: settings.tracking,
|
|
4534
4554
|
type: SHOPIFY_CHECKOUT_EXTENSION,
|
|
4555
|
+
variables: [{ defaultValue: false, name: HAS_PRODUCTS }],
|
|
4535
4556
|
version: 2,
|
|
4557
|
+
visibility: { variable: HAS_PRODUCTS, visibleWhen: true },
|
|
4536
4558
|
widgetId: id
|
|
4537
4559
|
});
|
|
4538
4560
|
};
|
|
@@ -1088,7 +1088,13 @@ var import_zod13 = require("zod");
|
|
|
1088
1088
|
var CABMonetizeSection = import_zod13.z.object({
|
|
1089
1089
|
...CABVariableFields,
|
|
1090
1090
|
name: import_zod13.z.string().optional(),
|
|
1091
|
-
/**
|
|
1091
|
+
/**
|
|
1092
|
+
* Server-hydrated offer cards (inline hydration): when `/cab/sections` was asked with a `monetize`
|
|
1093
|
+
* context block, the composed cards ride the marker itself — `[]` means "hydrated, no fill" (render
|
|
1094
|
+
* nothing, skip the fetch); ABSENT means "not hydrated" (the client fetches via `/cab/monetize`).
|
|
1095
|
+
*/
|
|
1096
|
+
offers: import_zod13.z.array(import_zod13.z.lazy(() => CABSection)).optional(),
|
|
1097
|
+
/** Privacy Policy footer href (the widget's `privacy_policy_url` setting); read server-side for hydration, relayed by the client only on the legacy `/cab/monetize` fallback. */
|
|
1092
1098
|
privacyPolicyUrl: import_zod13.z.string().optional(),
|
|
1093
1099
|
sectionId: import_zod13.z.uuid().default(() => (0, import_uuid8.v7)()),
|
|
1094
1100
|
sectionType: import_zod13.z.literal(SectionType.monetize).default(SectionType.monetize),
|
|
@@ -896,7 +896,13 @@ import { z as z13 } from "zod";
|
|
|
896
896
|
var CABMonetizeSection = z13.object({
|
|
897
897
|
...CABVariableFields,
|
|
898
898
|
name: z13.string().optional(),
|
|
899
|
-
/**
|
|
899
|
+
/**
|
|
900
|
+
* Server-hydrated offer cards (inline hydration): when `/cab/sections` was asked with a `monetize`
|
|
901
|
+
* context block, the composed cards ride the marker itself — `[]` means "hydrated, no fill" (render
|
|
902
|
+
* nothing, skip the fetch); ABSENT means "not hydrated" (the client fetches via `/cab/monetize`).
|
|
903
|
+
*/
|
|
904
|
+
offers: z13.array(z13.lazy(() => CABSection)).optional(),
|
|
905
|
+
/** Privacy Policy footer href (the widget's `privacy_policy_url` setting); read server-side for hydration, relayed by the client only on the legacy `/cab/monetize` fallback. */
|
|
900
906
|
privacyPolicyUrl: z13.string().optional(),
|
|
901
907
|
sectionId: z13.uuid().default(() => uuidv78()),
|
|
902
908
|
sectionType: z13.literal(SectionType.monetize).default(SectionType.monetize),
|
|
@@ -934,7 +934,13 @@ var import_zod16 = require("zod");
|
|
|
934
934
|
var CABMonetizeSection = import_zod16.z.object({
|
|
935
935
|
...CABVariableFields,
|
|
936
936
|
name: import_zod16.z.string().optional(),
|
|
937
|
-
/**
|
|
937
|
+
/**
|
|
938
|
+
* Server-hydrated offer cards (inline hydration): when `/cab/sections` was asked with a `monetize`
|
|
939
|
+
* context block, the composed cards ride the marker itself — `[]` means "hydrated, no fill" (render
|
|
940
|
+
* nothing, skip the fetch); ABSENT means "not hydrated" (the client fetches via `/cab/monetize`).
|
|
941
|
+
*/
|
|
942
|
+
offers: import_zod16.z.array(import_zod16.z.lazy(() => CABSection)).optional(),
|
|
943
|
+
/** Privacy Policy footer href (the widget's `privacy_policy_url` setting); read server-side for hydration, relayed by the client only on the legacy `/cab/monetize` fallback. */
|
|
938
944
|
privacyPolicyUrl: import_zod16.z.string().optional(),
|
|
939
945
|
sectionId: import_zod16.z.uuid().default(() => (0, import_uuid8.v7)()),
|
|
940
946
|
sectionType: import_zod16.z.literal(SectionType.monetize).default(SectionType.monetize),
|
|
@@ -909,7 +909,13 @@ import { z as z16 } from "zod";
|
|
|
909
909
|
var CABMonetizeSection = z16.object({
|
|
910
910
|
...CABVariableFields,
|
|
911
911
|
name: z16.string().optional(),
|
|
912
|
-
/**
|
|
912
|
+
/**
|
|
913
|
+
* Server-hydrated offer cards (inline hydration): when `/cab/sections` was asked with a `monetize`
|
|
914
|
+
* context block, the composed cards ride the marker itself — `[]` means "hydrated, no fill" (render
|
|
915
|
+
* nothing, skip the fetch); ABSENT means "not hydrated" (the client fetches via `/cab/monetize`).
|
|
916
|
+
*/
|
|
917
|
+
offers: z16.array(z16.lazy(() => CABSection)).optional(),
|
|
918
|
+
/** Privacy Policy footer href (the widget's `privacy_policy_url` setting); read server-side for hydration, relayed by the client only on the legacy `/cab/monetize` fallback. */
|
|
913
919
|
privacyPolicyUrl: z16.string().optional(),
|
|
914
920
|
sectionId: z16.uuid().default(() => uuidv78()),
|
|
915
921
|
sectionType: z16.literal(SectionType.monetize).default(SectionType.monetize),
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { type SectionDetails } from './shared';
|
|
2
|
+
import { CABSection, type SectionDetails } from './shared';
|
|
3
|
+
import { CABVariableFields } from './variables';
|
|
3
4
|
export declare const CABMonetizeSection: z.ZodObject<{
|
|
4
5
|
name: z.ZodOptional<z.ZodString>;
|
|
6
|
+
offers: z.ZodOptional<z.ZodArray<z.ZodLazy<z.ZodType<CABSection, unknown, z.core.$ZodTypeInternals<CABSection, unknown>>>>>;
|
|
5
7
|
privacyPolicyUrl: z.ZodOptional<z.ZodString>;
|
|
6
8
|
sectionId: z.ZodDefault<z.ZodUUID>;
|
|
7
9
|
sectionType: z.ZodDefault<z.ZodLiteral<"monetize">>;
|
|
@@ -154,5 +156,14 @@ export declare const CABMonetizeSection: z.ZodObject<{
|
|
|
154
156
|
visibleWhen: z.ZodDefault<z.ZodBoolean>;
|
|
155
157
|
}, z.core.$strip>>;
|
|
156
158
|
}, z.core.$strip>;
|
|
157
|
-
|
|
159
|
+
/** Twin of the schema above — `offers` makes this a recursive node (see recursiveTwins.test.ts). */
|
|
160
|
+
export type CABMonetizeSection = CABVariableFields & {
|
|
161
|
+
name?: string;
|
|
162
|
+
offers?: CABSection[];
|
|
163
|
+
privacyPolicyUrl?: string;
|
|
164
|
+
sectionId: string;
|
|
165
|
+
sectionType: 'monetize';
|
|
166
|
+
subVertical?: string;
|
|
167
|
+
vertical?: string;
|
|
168
|
+
};
|
|
158
169
|
export type CABMonetizeSectionProps = CABMonetizeSection & SectionDetails;
|