@rebuy/rebuy 2.2.0-rc.1 → 2.2.0-rc.2
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.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +628 -1
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +628 -1
- package/dist/index.mjs.map +4 -4
- package/dist/schema/index.d.ts +19 -19
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +652 -0
- package/dist/schema/index.js.map +7 -0
- package/package.json +3 -2
package/dist/index.mjs
CHANGED
|
@@ -732,37 +732,664 @@ var RebuyClient = class {
|
|
|
732
732
|
return null;
|
|
733
733
|
}
|
|
734
734
|
};
|
|
735
|
+
|
|
736
|
+
// src/schema/button.ts
|
|
737
|
+
import { v7 as uuidv712 } from "uuid";
|
|
738
|
+
import { z as z16 } from "zod";
|
|
739
|
+
|
|
740
|
+
// src/schema/common.ts
|
|
741
|
+
import { z } from "zod";
|
|
742
|
+
var borderRadii = ["none", "small", "base", "large", "fullyRounded"];
|
|
743
|
+
var borderRadius = z.enum(borderRadii);
|
|
744
|
+
var BorderRadius = borderRadius.enum;
|
|
745
|
+
var borderStyles = ["none", "base", "dotted", "dashed"];
|
|
746
|
+
var borderStyle = z.enum(borderStyles);
|
|
747
|
+
var BorderStyle = borderStyle.enum;
|
|
748
|
+
var borderWidths = ["base", "medium", "thick"];
|
|
749
|
+
var borderWidth = z.enum(borderWidths);
|
|
750
|
+
var BorderWidth = borderWidth.enum;
|
|
751
|
+
var buttonActions = [
|
|
752
|
+
"addToOrder",
|
|
753
|
+
"declineAllOffers",
|
|
754
|
+
"declineOffer",
|
|
755
|
+
"goToRebuyApp",
|
|
756
|
+
"goToRebuyVault",
|
|
757
|
+
"goToURL",
|
|
758
|
+
"removeFromCart",
|
|
759
|
+
"showVariants",
|
|
760
|
+
"switchToSubscription"
|
|
761
|
+
];
|
|
762
|
+
var buttonAction = z.enum(buttonActions);
|
|
763
|
+
var ButtonAction = buttonAction.enum;
|
|
764
|
+
var buttonFields = [
|
|
765
|
+
"addedToCart",
|
|
766
|
+
"addingToCart",
|
|
767
|
+
"addToCart",
|
|
768
|
+
"buttonLabel",
|
|
769
|
+
"declineAllOffers",
|
|
770
|
+
"declineOffer",
|
|
771
|
+
"destinationUrl",
|
|
772
|
+
"payNow",
|
|
773
|
+
"removeFromCart",
|
|
774
|
+
"showVariant",
|
|
775
|
+
"showVariants",
|
|
776
|
+
"soldOut",
|
|
777
|
+
"switchToOneTimeAction",
|
|
778
|
+
"switchToOneTimePurchase",
|
|
779
|
+
"switchToSubscriptionAction",
|
|
780
|
+
"switchToSubscriptionNoDiscount",
|
|
781
|
+
"switchToSubscriptionWithDiscount"
|
|
782
|
+
];
|
|
783
|
+
var buttonField = z.enum(buttonFields);
|
|
784
|
+
var ButtonField = buttonField.enum;
|
|
785
|
+
var buttonStyles = ["primary", "secondary", "plain", "custom"];
|
|
786
|
+
var buttonStyle = z.enum(buttonStyles);
|
|
787
|
+
var ButtonStyle = buttonStyle.enum;
|
|
788
|
+
var directions = ["columns", "rows"];
|
|
789
|
+
var direction = z.enum(directions);
|
|
790
|
+
var Direction = direction.enum;
|
|
791
|
+
var editorModes = [
|
|
792
|
+
"checkoutExtension",
|
|
793
|
+
"postPurchaseOffer",
|
|
794
|
+
"thankYouPage",
|
|
795
|
+
"orderStatusPage",
|
|
796
|
+
"ordersIndexPage",
|
|
797
|
+
"customerProfilePage"
|
|
798
|
+
];
|
|
799
|
+
var editorMode = z.enum(editorModes);
|
|
800
|
+
var EditorMode = editorMode.enum;
|
|
801
|
+
var horizontalAlignments = ["start", "center", "end"];
|
|
802
|
+
var horizontalAlignment = z.enum(horizontalAlignments);
|
|
803
|
+
var HorizontalAlignment = horizontalAlignment.enum;
|
|
804
|
+
var languageKeys = [
|
|
805
|
+
"ar",
|
|
806
|
+
"cs",
|
|
807
|
+
"da",
|
|
808
|
+
"de",
|
|
809
|
+
"en",
|
|
810
|
+
"es",
|
|
811
|
+
"fi",
|
|
812
|
+
"fr",
|
|
813
|
+
"ga",
|
|
814
|
+
"he",
|
|
815
|
+
"hi",
|
|
816
|
+
"id",
|
|
817
|
+
"it",
|
|
818
|
+
"ja",
|
|
819
|
+
"ko",
|
|
820
|
+
"nl",
|
|
821
|
+
"no",
|
|
822
|
+
"pl",
|
|
823
|
+
"pt",
|
|
824
|
+
"ru",
|
|
825
|
+
"sv",
|
|
826
|
+
"th",
|
|
827
|
+
"tr",
|
|
828
|
+
"uk",
|
|
829
|
+
"vi",
|
|
830
|
+
"zh"
|
|
831
|
+
];
|
|
832
|
+
var languageKey = z.enum(languageKeys);
|
|
833
|
+
var LanguageKey = languageKey.enum;
|
|
834
|
+
var objectFits = ["cover", "contain"];
|
|
835
|
+
var objectFit = z.enum(objectFits);
|
|
836
|
+
var ObjectFit = objectFit.enum;
|
|
837
|
+
var quantityInputs = ["select", "number"];
|
|
838
|
+
var quantityInput = z.enum(quantityInputs);
|
|
839
|
+
var QuantityInput = quantityInput.enum;
|
|
840
|
+
var sectionTypes = [
|
|
841
|
+
"button",
|
|
842
|
+
"dataSource",
|
|
843
|
+
"image",
|
|
844
|
+
"layout",
|
|
845
|
+
"offers",
|
|
846
|
+
"product",
|
|
847
|
+
"products",
|
|
848
|
+
"quantity",
|
|
849
|
+
"reviews",
|
|
850
|
+
"subscription",
|
|
851
|
+
"table",
|
|
852
|
+
"text",
|
|
853
|
+
"variants"
|
|
854
|
+
];
|
|
855
|
+
var sectionType = z.enum(sectionTypes);
|
|
856
|
+
var SectionType = sectionType.enum;
|
|
857
|
+
var spacings = ["none", "extraTight", "tight", "base", "loose", "extraLoose"];
|
|
858
|
+
var spacing = z.enum(spacings);
|
|
859
|
+
var Spacing = spacing.enum;
|
|
860
|
+
var textAlignments = ["start", "center", "end"];
|
|
861
|
+
var textAlignment = z.enum(textAlignments);
|
|
862
|
+
var TextAlignment = textAlignment.enum;
|
|
863
|
+
var textColorNames = ["base", "subdued", "accent", "decorative", "success", "warning", "critical"];
|
|
864
|
+
var textColorName = z.enum(textColorNames);
|
|
865
|
+
var TextColorName = textColorName.enum;
|
|
866
|
+
var textSizeNames = ["extraSmall", "small", "base", "medium", "large", "extraLarge"];
|
|
867
|
+
var textSizeName = z.enum(textSizeNames);
|
|
868
|
+
var TextSizeName = textSizeName.enum;
|
|
869
|
+
var variantSelectors = ["menu", "button", "radio", "color", "image"];
|
|
870
|
+
var variantSelector = z.enum(variantSelectors);
|
|
871
|
+
var VariantSelector = variantSelector.enum;
|
|
872
|
+
var verticalAlignments = ["top", "middle", "bottom"];
|
|
873
|
+
var verticalAlignment = z.enum(verticalAlignments);
|
|
874
|
+
var VerticalAlignment = verticalAlignment.enum;
|
|
875
|
+
|
|
876
|
+
// src/schema/image.ts
|
|
877
|
+
import { v7 as uuidv711 } from "uuid";
|
|
878
|
+
import { z as z15 } from "zod";
|
|
879
|
+
|
|
880
|
+
// src/schema/regex.ts
|
|
881
|
+
var DYNAMIC_TOKEN_REGEX = /^\{\{\s*[A-Za-z]+\s*\}\}$/;
|
|
882
|
+
var HEX_COLOR_REGEX = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
|
|
883
|
+
var HTML_TAGS_REGEX = /<[^>]*>/gi;
|
|
884
|
+
|
|
885
|
+
// src/schema/shared.ts
|
|
886
|
+
import { z as z14 } from "zod";
|
|
887
|
+
|
|
888
|
+
// src/schema/data-source.ts
|
|
889
|
+
import { v7 as uuidv7 } from "uuid";
|
|
890
|
+
import { z as z3 } from "zod";
|
|
891
|
+
|
|
892
|
+
// src/schema/constants.ts
|
|
893
|
+
import { uniqBy } from "lodash-es";
|
|
894
|
+
import { z as z2 } from "zod";
|
|
895
|
+
var DEFAULT_ENDPOINTS = [
|
|
896
|
+
{ label: "Recommended (AI)", value: "/products/recommended" },
|
|
897
|
+
{ label: "Top Sellers", value: "/products/top_sellers" },
|
|
898
|
+
{ label: "Buy It Again", value: "/products/purchased" },
|
|
899
|
+
{ label: "Recently Viewed", value: "/products/viewed" },
|
|
900
|
+
{ label: "Products Search", value: "/products/search" },
|
|
901
|
+
{ label: "Collection Products", value: "/products/collections" },
|
|
902
|
+
{ label: "Similar Products (AI)", value: "/products/similar_products" }
|
|
903
|
+
];
|
|
904
|
+
var STATIC_ENDPOINTS = [
|
|
905
|
+
{ label: "Recommended (AI)", value: "/products/recommended" },
|
|
906
|
+
{ label: "Top Sellers", value: "/products/top_sellers" },
|
|
907
|
+
{ label: "Trending Products", value: "/products/trending_products" },
|
|
908
|
+
{ label: "Buy It Again", value: "/products/purchased" },
|
|
909
|
+
{ label: "Collection Products", value: "/products/collections" },
|
|
910
|
+
{ label: "Recently Viewed", value: "/products/viewed" },
|
|
911
|
+
{ label: "Static Products", value: "/products/static" },
|
|
912
|
+
{ label: "Products Search", value: "/products/search" },
|
|
913
|
+
{ label: "Similar Products (AI)", value: "/products/similar_products" }
|
|
914
|
+
];
|
|
915
|
+
var COMBINED_ENDPOINTS = uniqBy([...DEFAULT_ENDPOINTS, ...STATIC_ENDPOINTS], "value");
|
|
916
|
+
var targetAreas = {
|
|
917
|
+
[EditorMode.checkoutExtension]: [
|
|
918
|
+
{ icon: "splitscreen_top", label: "Header Area", width: "984px" },
|
|
919
|
+
{ icon: "splitscreen_left", label: "Main Column", width: "503px" },
|
|
920
|
+
{ icon: "splitscreen_right", label: "Summary Column", width: "404px" }
|
|
921
|
+
],
|
|
922
|
+
[EditorMode.postPurchaseOffer]: null,
|
|
923
|
+
[EditorMode.thankYouPage]: [
|
|
924
|
+
{ icon: "splitscreen_top", label: "Header Area", width: "984px" },
|
|
925
|
+
{ icon: "splitscreen_left", label: "Main Column", width: "503px" },
|
|
926
|
+
{ icon: "splitscreen_right", label: "Summary Column", width: "404px" }
|
|
927
|
+
],
|
|
928
|
+
[EditorMode.orderStatusPage]: [
|
|
929
|
+
// { fill: true, flip: 'vertical', icon: 'bottom_navigation', label: 'Announcement Bar' },
|
|
930
|
+
{ icon: "splitscreen_top", label: "Header Area", width: "1124px" },
|
|
931
|
+
{ fill: true, icon: "view_column_2", label: "Main Area", width: "646px" },
|
|
932
|
+
{ icon: "splitscreen_bottom", label: "Footer Area", width: "1124px" }
|
|
933
|
+
],
|
|
934
|
+
[EditorMode.ordersIndexPage]: [
|
|
935
|
+
// { fill: true, flip: 'vertical', icon: 'bottom_navigation', label: 'Announcement Bar' },
|
|
936
|
+
{ icon: "splitscreen_top", label: "Main Area", width: "1124px" }
|
|
937
|
+
],
|
|
938
|
+
[EditorMode.customerProfilePage]: [
|
|
939
|
+
// { fill: true, flip: 'vertical', icon: 'bottom_navigation', label: 'Announcement Bar' },
|
|
940
|
+
{ icon: "splitscreen_top", label: "Main Area", width: "1124px" }
|
|
941
|
+
]
|
|
942
|
+
};
|
|
943
|
+
var widgetTypes = [
|
|
944
|
+
"bundle_builder",
|
|
945
|
+
"cart",
|
|
946
|
+
"cart_subscription",
|
|
947
|
+
"dynamic_bundle",
|
|
948
|
+
"gift_with_purchase",
|
|
949
|
+
"pre_purchase",
|
|
950
|
+
"product",
|
|
951
|
+
"product_addon",
|
|
952
|
+
"product_upsell",
|
|
953
|
+
"recharge_checkout",
|
|
954
|
+
"recharge_customer_portal",
|
|
955
|
+
"recharge_post_purchase",
|
|
956
|
+
"shopify_checkout",
|
|
957
|
+
"shopify_checkout_extension",
|
|
958
|
+
"shopify_post_purchase",
|
|
959
|
+
"shopify_post_purchase_extension",
|
|
960
|
+
"switch_to_subscription",
|
|
961
|
+
"ui_extension_ad",
|
|
962
|
+
"ui_extension_button",
|
|
963
|
+
"ui_extension_content_block",
|
|
964
|
+
"ui_extension_line_item_editor",
|
|
965
|
+
"ui_extension_progress_bar"
|
|
966
|
+
];
|
|
967
|
+
var widgetType = z2.enum(widgetTypes);
|
|
968
|
+
var WidgetType = widgetType.enum;
|
|
969
|
+
|
|
970
|
+
// src/schema/data-source.ts
|
|
971
|
+
var CABDataSourceSection = z3.strictObject({
|
|
972
|
+
dataSourceId: z3.number().nullable().default(null),
|
|
973
|
+
dataSourcePath: z3.string().default(DEFAULT_ENDPOINTS[0].value),
|
|
974
|
+
limit: z3.number().default(1),
|
|
975
|
+
name: z3.string().default(DEFAULT_ENDPOINTS[0].label),
|
|
976
|
+
sectionId: z3.uuidv7().default(() => uuidv7()),
|
|
977
|
+
sectionType: z3.literal(SectionType.dataSource).default(SectionType.dataSource)
|
|
978
|
+
});
|
|
979
|
+
|
|
980
|
+
// src/schema/layout.ts
|
|
981
|
+
import { v7 as uuidv72 } from "uuid";
|
|
982
|
+
import { z as z4 } from "zod";
|
|
983
|
+
var CABLayoutSection = z4.strictObject({
|
|
984
|
+
alignment: z4.strictObject({
|
|
985
|
+
horizontal: z4.enum(horizontalAlignments).default(HorizontalAlignment.start),
|
|
986
|
+
vertical: z4.enum(verticalAlignments).default(VerticalAlignment.top)
|
|
987
|
+
}).default({
|
|
988
|
+
horizontal: HorizontalAlignment.start,
|
|
989
|
+
vertical: VerticalAlignment.top
|
|
990
|
+
}),
|
|
991
|
+
border: CABBorder,
|
|
992
|
+
direction: z4.enum(directions).default(Direction.rows),
|
|
993
|
+
name: z4.string().optional(),
|
|
994
|
+
padding: z4.enum(spacings).default(Spacing.none),
|
|
995
|
+
sectionId: z4.uuidv7().default(() => uuidv72()),
|
|
996
|
+
sections: z4.array(z4.lazy(() => CABSection)).default(() => []),
|
|
997
|
+
sectionType: z4.literal(SectionType.layout).default(SectionType.layout),
|
|
998
|
+
spacing: z4.enum(spacings).default(Spacing.base),
|
|
999
|
+
width: z4.number().default(100)
|
|
1000
|
+
});
|
|
1001
|
+
|
|
1002
|
+
// src/schema/offers.ts
|
|
1003
|
+
import { z as z8 } from "zod";
|
|
1004
|
+
|
|
1005
|
+
// src/schema/products.ts
|
|
1006
|
+
import { v7 as uuidv75 } from "uuid";
|
|
1007
|
+
import { z as z7 } from "zod";
|
|
1008
|
+
|
|
1009
|
+
// src/schema/product.ts
|
|
1010
|
+
import { v7 as uuidv74 } from "uuid";
|
|
1011
|
+
import { z as z6 } from "zod";
|
|
1012
|
+
|
|
1013
|
+
// src/schema/text.ts
|
|
1014
|
+
import { forEach, isString as isString2 } from "lodash-es";
|
|
1015
|
+
import { v7 as uuidv73 } from "uuid";
|
|
1016
|
+
import { z as z5 } from "zod";
|
|
1017
|
+
|
|
1018
|
+
// src/schema/utils.ts
|
|
1019
|
+
import { isPlainObject, isString } from "lodash-es";
|
|
1020
|
+
var isHTML = (html = "") => {
|
|
1021
|
+
if (typeof window !== "undefined") {
|
|
1022
|
+
const parser = new DOMParser();
|
|
1023
|
+
const doc = parser.parseFromString(html, "text/html");
|
|
1024
|
+
const hasHTML = (nodeList) => Array.from(nodeList).some((node) => node.nodeType === 1);
|
|
1025
|
+
return hasHTML(doc.body.childNodes) || hasHTML(doc.head.childNodes);
|
|
1026
|
+
}
|
|
1027
|
+
return HTML_TAGS_REGEX.test(html);
|
|
1028
|
+
};
|
|
1029
|
+
var hasHTMLInDoc = (doc) => doc.content.some(({ content = [] }) => content.some(({ text }) => isHTML(text)));
|
|
1030
|
+
var checkForHTML = (input) => !(isString(input) && isHTML(input) || isPlainObject(input) && hasHTMLInDoc(input));
|
|
1031
|
+
var NO_HTML = { message: "HTML is not supported" };
|
|
1032
|
+
|
|
1033
|
+
// src/schema/text.ts
|
|
1034
|
+
var enumOrOmit = (...vals) => z5.string().transform((val) => vals.includes(val) ? val : void 0).optional();
|
|
1035
|
+
var TiptapText = z5.strictObject({
|
|
1036
|
+
marks: z5.array(
|
|
1037
|
+
z5.discriminatedUnion("type", [
|
|
1038
|
+
z5.strictObject({ type: z5.literal("bold") }),
|
|
1039
|
+
z5.strictObject({ type: z5.literal("italic") }),
|
|
1040
|
+
z5.strictObject({
|
|
1041
|
+
attrs: z5.strictObject({
|
|
1042
|
+
class: z5.string().nullable(),
|
|
1043
|
+
href: z5.union([z5.url(), z5.string().regex(DYNAMIC_TOKEN_REGEX)]),
|
|
1044
|
+
rel: z5.string().default("noopener noreferrer nofollow"),
|
|
1045
|
+
target: z5.string().default("_blank")
|
|
1046
|
+
}),
|
|
1047
|
+
type: z5.literal("link")
|
|
1048
|
+
}),
|
|
1049
|
+
z5.strictObject({ type: z5.literal("strike") }),
|
|
1050
|
+
z5.strictObject({
|
|
1051
|
+
attrs: z5.strictObject({
|
|
1052
|
+
color: enumOrOmit(...textColorNames).default(TextColorName.base),
|
|
1053
|
+
fontSize: enumOrOmit(...textSizeNames).default(TextSizeName.base)
|
|
1054
|
+
}),
|
|
1055
|
+
type: z5.literal("textStyle")
|
|
1056
|
+
})
|
|
1057
|
+
])
|
|
1058
|
+
).optional(),
|
|
1059
|
+
text: z5.string().default(""),
|
|
1060
|
+
type: z5.literal("text").default("text")
|
|
1061
|
+
});
|
|
1062
|
+
var TiptapParagraph = z5.strictObject({
|
|
1063
|
+
attrs: z5.strictObject({
|
|
1064
|
+
textAlign: enumOrOmit(...textAlignments)
|
|
1065
|
+
}).default({ textAlign: TextAlignment.start }),
|
|
1066
|
+
content: z5.array(TiptapText).default([]),
|
|
1067
|
+
type: z5.literal("paragraph").default("paragraph")
|
|
1068
|
+
});
|
|
1069
|
+
var TiptapDocument = z5.strictObject({
|
|
1070
|
+
attrs: z5.strictObject({
|
|
1071
|
+
blockSpacing: enumOrOmit(...spacings)
|
|
1072
|
+
}).default({ blockSpacing: Spacing.base }),
|
|
1073
|
+
content: z5.array(TiptapParagraph).default([TiptapParagraph.parse({})]),
|
|
1074
|
+
type: z5.literal("doc").default("doc")
|
|
1075
|
+
});
|
|
1076
|
+
var CABTextSection = z5.strictObject({
|
|
1077
|
+
buttonField: z5.enum(buttonFields).optional(),
|
|
1078
|
+
content: z5.record(z5.string(), z5.union([z5.string(), TiptapDocument]).refine(checkForHTML, NO_HTML).optional()).default({ en: TiptapDocument.parse({}) }).optional(),
|
|
1079
|
+
name: z5.string().optional(),
|
|
1080
|
+
sectionId: z5.uuidv7().default(() => uuidv73()),
|
|
1081
|
+
sectionType: z5.literal(SectionType.text).default(SectionType.text)
|
|
1082
|
+
}).superRefine(({ buttonField: buttonField2, content }, ctx) => {
|
|
1083
|
+
if (buttonField2 === ButtonField.destinationUrl && content) {
|
|
1084
|
+
forEach(content, (value, lang) => {
|
|
1085
|
+
if (value && isString2(value)) {
|
|
1086
|
+
if (DYNAMIC_TOKEN_REGEX.test(value)) return;
|
|
1087
|
+
try {
|
|
1088
|
+
new URL(value);
|
|
1089
|
+
} catch {
|
|
1090
|
+
ctx.addIssue({
|
|
1091
|
+
code: "custom",
|
|
1092
|
+
message: "Invalid URL",
|
|
1093
|
+
path: ["content", lang]
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
});
|
|
1098
|
+
}
|
|
1099
|
+
});
|
|
1100
|
+
|
|
1101
|
+
// src/schema/product.ts
|
|
1102
|
+
var CABProductSection = z6.strictObject({
|
|
1103
|
+
name: z6.string().optional(),
|
|
1104
|
+
options: z6.array(
|
|
1105
|
+
z6.strictObject({
|
|
1106
|
+
/** `name` represents `Color`, `Size`, etc. */
|
|
1107
|
+
name: z6.string(),
|
|
1108
|
+
optionId: z6.number(),
|
|
1109
|
+
selector: z6.enum(variantSelectors).default(VariantSelector.menu),
|
|
1110
|
+
values: z6.array(
|
|
1111
|
+
z6.strictObject({
|
|
1112
|
+
color: z6.string().optional(),
|
|
1113
|
+
image: CABImageSection.optional(),
|
|
1114
|
+
/** `name` represents `Red`, `Blue`, etc. */
|
|
1115
|
+
name: z6.string(),
|
|
1116
|
+
text: CABTextSection.optional()
|
|
1117
|
+
})
|
|
1118
|
+
)
|
|
1119
|
+
})
|
|
1120
|
+
).default(() => []),
|
|
1121
|
+
productId: z6.number().nullable().default(null),
|
|
1122
|
+
sectionId: z6.uuidv7().default(() => uuidv74()),
|
|
1123
|
+
sectionType: z6.literal(SectionType.product).default(SectionType.product)
|
|
1124
|
+
});
|
|
1125
|
+
|
|
1126
|
+
// src/schema/products.ts
|
|
1127
|
+
var CABProductsSection = z7.strictObject({
|
|
1128
|
+
name: z7.string().optional(),
|
|
1129
|
+
sectionId: z7.uuidv7().default(() => uuidv75()),
|
|
1130
|
+
sections: z7.array(CABProductSection).default(() => []),
|
|
1131
|
+
sectionType: z7.literal(SectionType.products).default(SectionType.products)
|
|
1132
|
+
});
|
|
1133
|
+
|
|
1134
|
+
// src/schema/offers.ts
|
|
1135
|
+
var CABOffersSection = CABLayoutSection.omit({ sections: true, sectionType: true }).extend(
|
|
1136
|
+
z8.strictObject({
|
|
1137
|
+
sections: z8.array(z8.lazy(() => CABSection)).default(() => [CABDataSourceSection.parse({}), CABProductsSection.parse({})]),
|
|
1138
|
+
sectionType: z8.literal(SectionType.offers).default(SectionType.offers)
|
|
1139
|
+
}).shape
|
|
1140
|
+
);
|
|
1141
|
+
|
|
1142
|
+
// src/schema/quantity.ts
|
|
1143
|
+
import { v7 as uuidv76 } from "uuid";
|
|
1144
|
+
import { z as z9 } from "zod";
|
|
1145
|
+
var CABQuantitySection = z9.strictObject({
|
|
1146
|
+
errorMessages: z9.record(
|
|
1147
|
+
z9.string(),
|
|
1148
|
+
z9.strictObject({
|
|
1149
|
+
max: z9.string().optional(),
|
|
1150
|
+
min: z9.string().optional(),
|
|
1151
|
+
neg: z9.string().optional()
|
|
1152
|
+
})
|
|
1153
|
+
).default({
|
|
1154
|
+
en: {
|
|
1155
|
+
max: "Maximum quantity allowed is {{max}}",
|
|
1156
|
+
min: "Minimum quantity required is {{min}}",
|
|
1157
|
+
neg: "Quantity cannot be negative"
|
|
1158
|
+
}
|
|
1159
|
+
}),
|
|
1160
|
+
inputType: z9.enum(quantityInputs).default(QuantityInput.select),
|
|
1161
|
+
max: z9.number().min(1).max(100).default(10),
|
|
1162
|
+
min: z9.number().min(1).default(1),
|
|
1163
|
+
name: z9.string().optional(),
|
|
1164
|
+
sectionId: z9.uuidv7().default(() => uuidv76()),
|
|
1165
|
+
sectionType: z9.literal(SectionType.quantity).default(SectionType.quantity)
|
|
1166
|
+
});
|
|
1167
|
+
|
|
1168
|
+
// src/schema/reviews.ts
|
|
1169
|
+
import { v7 as uuidv77 } from "uuid";
|
|
1170
|
+
import { z as z10 } from "zod";
|
|
1171
|
+
var CABReviewsSection = z10.strictObject({
|
|
1172
|
+
name: z10.string().optional(),
|
|
1173
|
+
sectionId: z10.uuidv7().default(() => uuidv77()),
|
|
1174
|
+
sectionType: z10.literal(SectionType.reviews).default(SectionType.reviews)
|
|
1175
|
+
});
|
|
1176
|
+
|
|
1177
|
+
// src/schema/subscription.ts
|
|
1178
|
+
import { v7 as uuidv78 } from "uuid";
|
|
1179
|
+
import { z as z11 } from "zod";
|
|
1180
|
+
var CABSubscriptionSection = z11.strictObject({
|
|
1181
|
+
name: z11.string().optional(),
|
|
1182
|
+
sectionId: z11.uuidv7().default(() => uuidv78()),
|
|
1183
|
+
sectionType: z11.literal(SectionType.subscription).default(SectionType.subscription)
|
|
1184
|
+
});
|
|
1185
|
+
|
|
1186
|
+
// src/schema/table.ts
|
|
1187
|
+
import { v7 as uuidv79 } from "uuid";
|
|
1188
|
+
import { z as z12 } from "zod";
|
|
1189
|
+
var CABTableSection = z12.strictObject({
|
|
1190
|
+
name: z12.string().optional(),
|
|
1191
|
+
sectionId: z12.uuidv7().default(() => uuidv79()),
|
|
1192
|
+
sectionType: z12.literal(SectionType.table).default(SectionType.table)
|
|
1193
|
+
});
|
|
1194
|
+
|
|
1195
|
+
// src/schema/variants.ts
|
|
1196
|
+
import { slice } from "lodash-es";
|
|
1197
|
+
import { v7 as uuidv710 } from "uuid";
|
|
1198
|
+
import { z as z13 } from "zod";
|
|
1199
|
+
var CABVariantsSection = z13.strictObject({
|
|
1200
|
+
name: z13.string().optional(),
|
|
1201
|
+
sectionId: z13.uuidv7().default(() => uuidv710()),
|
|
1202
|
+
sectionType: z13.literal(SectionType.variants).default(SectionType.variants),
|
|
1203
|
+
selector: z13.enum(slice(variantSelectors, 0, 3)).default(VariantSelector.menu)
|
|
1204
|
+
});
|
|
1205
|
+
|
|
1206
|
+
// src/schema/shared.ts
|
|
1207
|
+
var CABBorder = z14.strictObject({
|
|
1208
|
+
radius: z14.enum(borderRadii).default(BorderRadius.base),
|
|
1209
|
+
style: z14.enum(borderStyles).default(BorderStyle.none),
|
|
1210
|
+
width: z14.enum(borderWidths).default(BorderWidth.base)
|
|
1211
|
+
}).default({
|
|
1212
|
+
radius: BorderRadius.base,
|
|
1213
|
+
style: BorderStyle.none,
|
|
1214
|
+
width: BorderWidth.base
|
|
1215
|
+
});
|
|
1216
|
+
var CABSection = z14.lazy(
|
|
1217
|
+
() => z14.discriminatedUnion("sectionType", [
|
|
1218
|
+
CABButtonSection,
|
|
1219
|
+
CABDataSourceSection,
|
|
1220
|
+
CABImageSection,
|
|
1221
|
+
CABLayoutSection,
|
|
1222
|
+
CABOffersSection,
|
|
1223
|
+
CABProductSection,
|
|
1224
|
+
CABProductsSection,
|
|
1225
|
+
CABQuantitySection,
|
|
1226
|
+
CABReviewsSection,
|
|
1227
|
+
CABSubscriptionSection,
|
|
1228
|
+
CABTableSection,
|
|
1229
|
+
CABTextSection,
|
|
1230
|
+
CABVariantsSection
|
|
1231
|
+
])
|
|
1232
|
+
);
|
|
1233
|
+
|
|
1234
|
+
// src/schema/image.ts
|
|
1235
|
+
var CABImageSection = z15.strictObject({
|
|
1236
|
+
altText: z15.string().refine(checkForHTML, NO_HTML).default(""),
|
|
1237
|
+
aspectRatio: z15.literal(1).nullable().default(null),
|
|
1238
|
+
border: CABBorder,
|
|
1239
|
+
buttonField: z15.enum(buttonFields).optional(),
|
|
1240
|
+
category: z15.enum(["gallery", "icons", "payment-methods", "secure-checkout"]).nullable().default(null),
|
|
1241
|
+
name: z15.string().optional(),
|
|
1242
|
+
naturalHeight: z15.number().default(0),
|
|
1243
|
+
naturalWidth: z15.number().default(0),
|
|
1244
|
+
objectFit: z15.enum(objectFits).default(ObjectFit.cover),
|
|
1245
|
+
sectionId: z15.uuidv7().default(() => uuidv711()),
|
|
1246
|
+
sectionType: z15.literal(SectionType.image).default(SectionType.image),
|
|
1247
|
+
source: z15.union([z15.url(), z15.literal(""), z15.string().regex(DYNAMIC_TOKEN_REGEX)]).default(""),
|
|
1248
|
+
width: z15.number().default(100)
|
|
1249
|
+
});
|
|
1250
|
+
|
|
1251
|
+
// src/schema/button.ts
|
|
1252
|
+
var CABButtonContent = z16.discriminatedUnion("sectionType", [CABImageSection, CABTextSection]);
|
|
1253
|
+
var CABButtonSection = z16.strictObject({
|
|
1254
|
+
action: z16.union([z16.literal(""), z16.enum(buttonActions)]).default(""),
|
|
1255
|
+
buttonStyle: z16.enum(buttonStyles).default(ButtonStyle.primary),
|
|
1256
|
+
custom: z16.strictObject({
|
|
1257
|
+
color: z16.string().regex(HEX_COLOR_REGEX).default("#005bd3"),
|
|
1258
|
+
height: z16.number().default(52),
|
|
1259
|
+
width: z16.number().default(300)
|
|
1260
|
+
}).default({
|
|
1261
|
+
color: "#005bd3",
|
|
1262
|
+
height: 52,
|
|
1263
|
+
width: 300
|
|
1264
|
+
}),
|
|
1265
|
+
name: z16.string().optional(),
|
|
1266
|
+
sectionId: z16.uuidv7().default(() => uuidv712()),
|
|
1267
|
+
sections: z16.array(CABButtonContent).default(() => []),
|
|
1268
|
+
sectionType: z16.literal(SectionType.button).default(SectionType.button)
|
|
1269
|
+
});
|
|
1270
|
+
|
|
1271
|
+
// src/schema/root.ts
|
|
1272
|
+
import { z as z17 } from "zod";
|
|
1273
|
+
var TargetArea = z17.strictObject({
|
|
1274
|
+
fill: z17.boolean().optional(),
|
|
1275
|
+
flip: z17.enum(["both", "horizontal", "vertical"]).optional(),
|
|
1276
|
+
icon: z17.string(),
|
|
1277
|
+
label: z17.string(),
|
|
1278
|
+
width: z17.string()
|
|
1279
|
+
}).default(targetAreas[EditorMode.checkoutExtension][1]);
|
|
1280
|
+
var CABRootSection = CABLayoutSection.extend(
|
|
1281
|
+
z17.strictObject({
|
|
1282
|
+
editorMode: z17.enum(editorModes).default(EditorMode.checkoutExtension),
|
|
1283
|
+
previewMode: z17.boolean().default(false),
|
|
1284
|
+
storeId: z17.number().nullable().default(null),
|
|
1285
|
+
targetArea: TargetArea.nullable(),
|
|
1286
|
+
type: z17.enum(widgetTypes).default(WidgetType.ui_extension_content_block),
|
|
1287
|
+
version: z17.literal(2).default(2),
|
|
1288
|
+
widgetId: z17.number().nullable().default(null)
|
|
1289
|
+
}).shape
|
|
1290
|
+
);
|
|
735
1291
|
export {
|
|
736
1292
|
Api,
|
|
1293
|
+
BorderRadius,
|
|
1294
|
+
BorderStyle,
|
|
1295
|
+
BorderWidth,
|
|
1296
|
+
ButtonAction,
|
|
1297
|
+
ButtonField,
|
|
1298
|
+
ButtonStyle,
|
|
1299
|
+
CABBorder,
|
|
1300
|
+
CABButtonContent,
|
|
1301
|
+
CABButtonSection,
|
|
1302
|
+
CABDataSourceSection,
|
|
1303
|
+
CABImageSection,
|
|
1304
|
+
CABLayoutSection,
|
|
1305
|
+
CABOffersSection,
|
|
1306
|
+
CABProductSection,
|
|
1307
|
+
CABProductsSection,
|
|
1308
|
+
CABQuantitySection,
|
|
1309
|
+
CABReviewsSection,
|
|
1310
|
+
CABRootSection,
|
|
1311
|
+
CABSection,
|
|
1312
|
+
CABSubscriptionSection,
|
|
1313
|
+
CABTableSection,
|
|
1314
|
+
CABTextSection,
|
|
1315
|
+
CABVariantsSection,
|
|
1316
|
+
COMBINED_ENDPOINTS,
|
|
1317
|
+
DEFAULT_ENDPOINTS,
|
|
1318
|
+
DYNAMIC_TOKEN_REGEX,
|
|
1319
|
+
Direction,
|
|
1320
|
+
EditorMode,
|
|
737
1321
|
Geolocation,
|
|
1322
|
+
HEX_COLOR_REGEX,
|
|
1323
|
+
HTML_TAGS_REGEX,
|
|
1324
|
+
HorizontalAlignment,
|
|
738
1325
|
Identity,
|
|
1326
|
+
LanguageKey,
|
|
1327
|
+
NO_HTML,
|
|
1328
|
+
ObjectFit,
|
|
1329
|
+
QuantityInput,
|
|
739
1330
|
RebuyClient,
|
|
1331
|
+
STATIC_ENDPOINTS,
|
|
1332
|
+
SectionType,
|
|
740
1333
|
Session,
|
|
1334
|
+
Spacing,
|
|
1335
|
+
TextAlignment,
|
|
1336
|
+
TextColorName,
|
|
1337
|
+
TextSizeName,
|
|
1338
|
+
TiptapDocument,
|
|
1339
|
+
TiptapParagraph,
|
|
1340
|
+
TiptapText,
|
|
1341
|
+
VariantSelector,
|
|
1342
|
+
VerticalAlignment,
|
|
1343
|
+
WidgetType,
|
|
741
1344
|
amountToCents,
|
|
1345
|
+
borderRadii,
|
|
1346
|
+
borderStyles,
|
|
1347
|
+
borderWidths,
|
|
1348
|
+
buttonActions,
|
|
1349
|
+
buttonFields,
|
|
1350
|
+
buttonStyles,
|
|
1351
|
+
checkForHTML,
|
|
742
1352
|
convertProductToStorefrontFormat,
|
|
743
1353
|
convertToNodes,
|
|
744
1354
|
convertVariantToStorefrontFormat,
|
|
745
1355
|
dataToString,
|
|
746
1356
|
destroy,
|
|
1357
|
+
directions,
|
|
1358
|
+
editorModes,
|
|
747
1359
|
enabled,
|
|
748
1360
|
find,
|
|
749
1361
|
firstAvailableVariant,
|
|
750
1362
|
get,
|
|
751
1363
|
getAll,
|
|
752
1364
|
getIdFromGraphUrl,
|
|
1365
|
+
hasHTMLInDoc,
|
|
1366
|
+
horizontalAlignments,
|
|
753
1367
|
isBase64Encoded,
|
|
1368
|
+
isHTML,
|
|
1369
|
+
languageKeys,
|
|
1370
|
+
objectFits,
|
|
754
1371
|
productImageObject,
|
|
1372
|
+
quantityInputs,
|
|
755
1373
|
queryStringToObject,
|
|
1374
|
+
sectionTypes,
|
|
756
1375
|
selectedVariantOptions,
|
|
757
1376
|
serialize,
|
|
758
1377
|
sessionId,
|
|
759
1378
|
set,
|
|
1379
|
+
spacings,
|
|
760
1380
|
stringToData,
|
|
761
1381
|
stripHtml,
|
|
1382
|
+
targetAreas,
|
|
1383
|
+
textAlignments,
|
|
1384
|
+
textColorNames,
|
|
1385
|
+
textSizeNames,
|
|
762
1386
|
utmObjectFromString,
|
|
763
1387
|
uuid,
|
|
764
1388
|
variantAvailable,
|
|
765
1389
|
variantMinMaxPriceObject,
|
|
766
|
-
variantPriceObject
|
|
1390
|
+
variantPriceObject,
|
|
1391
|
+
variantSelectors,
|
|
1392
|
+
verticalAlignments,
|
|
1393
|
+
widgetTypes
|
|
767
1394
|
};
|
|
768
1395
|
//# sourceMappingURL=index.mjs.map
|