@rebuy/rebuy 3.6.0 → 3.8.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 +30 -2
- package/dist/index.mjs +30 -2
- package/dist/schema/checkout-and-beyond/index.cjs +7 -1
- package/dist/schema/checkout-and-beyond/index.mjs +7 -1
- package/dist/schema/metadata.d.ts +3 -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 +259 -188
- package/dist/server/index.mjs +259 -188
- package/dist/server/requestSchemas.d.ts +59 -8
- package/dist/transforms/index.cjs +7 -1
- package/dist/transforms/index.mjs +7 -1
- package/dist/transforms/monetizeV1/convertMonetizeToV2.d.ts +3 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1409,7 +1409,29 @@ var Metadata = import_zod4.z.object({
|
|
|
1409
1409
|
unmatchedRules: import_zod4.z.array(MatchedRule).optional(),
|
|
1410
1410
|
widget: import_zod4.z.object({
|
|
1411
1411
|
discount: import_zod4.z.object({ amount: import_zod4.z.string(), type: import_zod4.z.string() }).optional(),
|
|
1412
|
-
|
|
1412
|
+
/**
|
|
1413
|
+
* Data-source-authored text content, dual-purpose in the CAB renderer (rebuy-shopify-extensions'
|
|
1414
|
+
* `checkout-and-beyond`): every key becomes a `{{token}}` for the interpolation pass
|
|
1415
|
+
* (`extractDataVariables`), e.g. `{ superTitle: 'Limited drop' }` resolves `{{superTitle}}`
|
|
1416
|
+
* anywhere in the widget's copy, and the legacy add-to-order state keys (`extractLabelOverrides`)
|
|
1417
|
+
* plus `variantOption`/`variantOptions` (`extractVariantLabels`) additionally keep their
|
|
1418
|
+
* whole-label override behavior. The serve path passes metadata through verbatim
|
|
1419
|
+
* (`fetchDataSourceResults` only camelCases keys, which lands snake_case names in the canonical
|
|
1420
|
+
* token grammar); this schema is the contract of record. Parsing mirrors the renderer's
|
|
1421
|
+
* fail-safe: an entry whose value is not a string or finite number — a data-source author's
|
|
1422
|
+
* `null`, boolean, object, or a computed `NaN`/`Infinity` — is dropped at parse time rather
|
|
1423
|
+
* than failing the whole `Metadata` block or rendering `[object Object]` (or a literal `NaN`)
|
|
1424
|
+
* into buyer copy. Booleans stay excluded on purpose (unlike
|
|
1425
|
+
* `Output.value` above, this is buyer-facing copy); an empty string is kept — it deliberately
|
|
1426
|
+
* blanks a token.
|
|
1427
|
+
*/
|
|
1428
|
+
language: import_zod4.z.record(import_zod4.z.string(), import_zod4.z.unknown()).transform(
|
|
1429
|
+
(raw) => Object.fromEntries(
|
|
1430
|
+
Object.entries(raw).filter(
|
|
1431
|
+
(entry) => typeof entry[1] === "string" || Number.isFinite(entry[1])
|
|
1432
|
+
)
|
|
1433
|
+
)
|
|
1434
|
+
).optional()
|
|
1413
1435
|
}).optional()
|
|
1414
1436
|
});
|
|
1415
1437
|
|
|
@@ -2497,7 +2519,13 @@ var import_zod23 = require("zod");
|
|
|
2497
2519
|
var CABMonetizeSection = import_zod23.z.object({
|
|
2498
2520
|
...CABVariableFields,
|
|
2499
2521
|
name: import_zod23.z.string().optional(),
|
|
2500
|
-
/**
|
|
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. */
|
|
2501
2529
|
privacyPolicyUrl: import_zod23.z.string().optional(),
|
|
2502
2530
|
sectionId: import_zod23.z.uuid().default(() => (0, import_uuid9.v7)()),
|
|
2503
2531
|
sectionType: import_zod23.z.literal(SectionType.monetize).default(SectionType.monetize),
|
package/dist/index.mjs
CHANGED
|
@@ -1128,7 +1128,29 @@ var Metadata = z4.object({
|
|
|
1128
1128
|
unmatchedRules: z4.array(MatchedRule).optional(),
|
|
1129
1129
|
widget: z4.object({
|
|
1130
1130
|
discount: z4.object({ amount: z4.string(), type: z4.string() }).optional(),
|
|
1131
|
-
|
|
1131
|
+
/**
|
|
1132
|
+
* Data-source-authored text content, dual-purpose in the CAB renderer (rebuy-shopify-extensions'
|
|
1133
|
+
* `checkout-and-beyond`): every key becomes a `{{token}}` for the interpolation pass
|
|
1134
|
+
* (`extractDataVariables`), e.g. `{ superTitle: 'Limited drop' }` resolves `{{superTitle}}`
|
|
1135
|
+
* anywhere in the widget's copy, and the legacy add-to-order state keys (`extractLabelOverrides`)
|
|
1136
|
+
* plus `variantOption`/`variantOptions` (`extractVariantLabels`) additionally keep their
|
|
1137
|
+
* whole-label override behavior. The serve path passes metadata through verbatim
|
|
1138
|
+
* (`fetchDataSourceResults` only camelCases keys, which lands snake_case names in the canonical
|
|
1139
|
+
* token grammar); this schema is the contract of record. Parsing mirrors the renderer's
|
|
1140
|
+
* fail-safe: an entry whose value is not a string or finite number — a data-source author's
|
|
1141
|
+
* `null`, boolean, object, or a computed `NaN`/`Infinity` — is dropped at parse time rather
|
|
1142
|
+
* than failing the whole `Metadata` block or rendering `[object Object]` (or a literal `NaN`)
|
|
1143
|
+
* into buyer copy. Booleans stay excluded on purpose (unlike
|
|
1144
|
+
* `Output.value` above, this is buyer-facing copy); an empty string is kept — it deliberately
|
|
1145
|
+
* blanks a token.
|
|
1146
|
+
*/
|
|
1147
|
+
language: z4.record(z4.string(), z4.unknown()).transform(
|
|
1148
|
+
(raw) => Object.fromEntries(
|
|
1149
|
+
Object.entries(raw).filter(
|
|
1150
|
+
(entry) => typeof entry[1] === "string" || Number.isFinite(entry[1])
|
|
1151
|
+
)
|
|
1152
|
+
)
|
|
1153
|
+
).optional()
|
|
1132
1154
|
}).optional()
|
|
1133
1155
|
});
|
|
1134
1156
|
|
|
@@ -2216,7 +2238,13 @@ import { z as z23 } from "zod";
|
|
|
2216
2238
|
var CABMonetizeSection = z23.object({
|
|
2217
2239
|
...CABVariableFields,
|
|
2218
2240
|
name: z23.string().optional(),
|
|
2219
|
-
/**
|
|
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. */
|
|
2220
2248
|
privacyPolicyUrl: z23.string().optional(),
|
|
2221
2249
|
sectionId: z23.uuid().default(() => uuidv78()),
|
|
2222
2250
|
sectionType: z23.literal(SectionType.monetize).default(SectionType.monetize),
|
|
@@ -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),
|
|
@@ -665,7 +665,9 @@ export declare const Metadata: z.ZodObject<{
|
|
|
665
665
|
amount: z.ZodString;
|
|
666
666
|
type: z.ZodString;
|
|
667
667
|
}, z.core.$strip>>;
|
|
668
|
-
language: z.ZodOptional<z.ZodRecord<z.ZodString, z.
|
|
668
|
+
language: z.ZodOptional<z.ZodPipe<z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodTransform<{
|
|
669
|
+
[k: string]: string | number;
|
|
670
|
+
}, Record<string, unknown>>>>;
|
|
669
671
|
}, z.core.$strip>>;
|
|
670
672
|
}, z.core.$strip>;
|
|
671
673
|
export type Metadata = z.infer<typeof Metadata>;
|
|
@@ -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;
|