@rebuy/rebuy 2.1.0 → 2.2.0-rc.10

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.
Files changed (47) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +654 -1
  4. package/dist/index.js.map +4 -4
  5. package/dist/index.mjs +654 -1
  6. package/dist/index.mjs.map +4 -4
  7. package/dist/schema/button.d.ts +273 -0
  8. package/dist/schema/button.d.ts.map +1 -0
  9. package/dist/schema/common.d.ts +369 -0
  10. package/dist/schema/common.d.ts.map +1 -0
  11. package/dist/schema/constants.d.ts +165 -0
  12. package/dist/schema/constants.d.ts.map +1 -0
  13. package/dist/schema/data-source.d.ts +13 -0
  14. package/dist/schema/data-source.d.ts.map +1 -0
  15. package/dist/schema/image.d.ts +65 -0
  16. package/dist/schema/image.d.ts.map +1 -0
  17. package/dist/schema/index.d.ts +20 -0
  18. package/dist/schema/index.d.ts.map +1 -0
  19. package/dist/schema/layout.d.ts +79 -0
  20. package/dist/schema/layout.d.ts.map +1 -0
  21. package/dist/schema/offers.d.ts +67 -0
  22. package/dist/schema/offers.d.ts.map +1 -0
  23. package/dist/schema/product.d.ts +147 -0
  24. package/dist/schema/product.d.ts.map +1 -0
  25. package/dist/schema/products.d.ts +152 -0
  26. package/dist/schema/products.d.ts.map +1 -0
  27. package/dist/schema/quantity.d.ts +21 -0
  28. package/dist/schema/quantity.d.ts.map +1 -0
  29. package/dist/schema/regex.d.ts +7 -0
  30. package/dist/schema/regex.d.ts.map +1 -0
  31. package/dist/schema/reviews.d.ts +10 -0
  32. package/dist/schema/reviews.d.ts.map +1 -0
  33. package/dist/schema/root.d.ts +127 -0
  34. package/dist/schema/root.d.ts.map +1 -0
  35. package/dist/schema/shared.d.ts +78 -0
  36. package/dist/schema/shared.d.ts.map +1 -0
  37. package/dist/schema/subscription.d.ts +10 -0
  38. package/dist/schema/subscription.d.ts.map +1 -0
  39. package/dist/schema/table.d.ts +10 -0
  40. package/dist/schema/table.d.ts.map +1 -0
  41. package/dist/schema/text.d.ts +162 -0
  42. package/dist/schema/text.d.ts.map +1 -0
  43. package/dist/schema/utils.d.ts +33 -0
  44. package/dist/schema/utils.d.ts.map +1 -0
  45. package/dist/schema/variants.d.ts +17 -0
  46. package/dist/schema/variants.d.ts.map +1 -0
  47. package/package.json +7 -2
package/dist/index.mjs CHANGED
@@ -732,37 +732,690 @@ 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/v4";
739
+
740
+ // src/schema/common.ts
741
+ import { z } from "zod/v4";
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/v4";
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/v4";
887
+
888
+ // src/schema/data-source.ts
889
+ import { v7 as uuidv7 } from "uuid";
890
+ import { z as z3 } from "zod/v4";
891
+
892
+ // src/schema/constants.ts
893
+ import { uniqBy } from "lodash-es";
894
+ import { z as z2 } from "zod/v4";
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.object({
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/v4";
983
+ var CABLayoutSection = z4.object({
984
+ alignment: z4.object({
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: z4.lazy(() => 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/v4";
1004
+
1005
+ // src/schema/products.ts
1006
+ import { v7 as uuidv75 } from "uuid";
1007
+ import { z as z7 } from "zod/v4";
1008
+
1009
+ // src/schema/product.ts
1010
+ import { v7 as uuidv74 } from "uuid";
1011
+ import { z as z6 } from "zod/v4";
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/v4";
1017
+
1018
+ // src/schema/utils.ts
1019
+ import { get as get2, 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
+ var isButtonType = (section) => get2(section, "sectionType") === SectionType.button;
1033
+ var isDataSourceType = (section) => get2(section, "sectionType") === SectionType.dataSource;
1034
+ var isImageType = (section) => get2(section, "sectionType") === SectionType.image;
1035
+ var isLayoutType = (section) => get2(section, "sectionType") === SectionType.layout;
1036
+ var isOffersType = (section) => get2(section, "sectionType") === SectionType.offers;
1037
+ var isProductType = (section) => get2(section, "sectionType") === SectionType.product;
1038
+ var isProductsType = (section) => get2(section, "sectionType") === SectionType.products;
1039
+ var isQuantityType = (section) => get2(section, "sectionType") === SectionType.quantity;
1040
+ var isReviewsType = (section) => get2(section, "sectionType") === SectionType.reviews;
1041
+ var isSubscriptionType = (section) => get2(section, "sectionType") === SectionType.subscription;
1042
+ var isTableType = (section) => get2(section, "sectionType") === SectionType.table;
1043
+ var isTextType = (section) => get2(section, "sectionType") === SectionType.text;
1044
+ var isVariantsType = (section) => get2(section, "sectionType") === SectionType.variants;
1045
+
1046
+ // src/schema/text.ts
1047
+ var enumOrOmit = (...vals) => z5.string().transform((val) => vals.includes(val) ? val : void 0).optional();
1048
+ var TiptapText = z5.object({
1049
+ marks: z5.array(
1050
+ z5.discriminatedUnion("type", [
1051
+ z5.object({ type: z5.literal("bold") }),
1052
+ z5.object({ type: z5.literal("italic") }),
1053
+ z5.object({
1054
+ attrs: z5.object({
1055
+ class: z5.string().nullable(),
1056
+ href: z5.union([z5.url(), z5.string().regex(DYNAMIC_TOKEN_REGEX)]),
1057
+ rel: z5.string().default("noopener noreferrer nofollow"),
1058
+ target: z5.string().default("_blank")
1059
+ }),
1060
+ type: z5.literal("link")
1061
+ }),
1062
+ z5.object({ type: z5.literal("strike") }),
1063
+ z5.object({
1064
+ attrs: z5.object({
1065
+ color: enumOrOmit(...textColorNames).default(TextColorName.base),
1066
+ fontSize: enumOrOmit(...textSizeNames).default(TextSizeName.base)
1067
+ }),
1068
+ type: z5.literal("textStyle")
1069
+ })
1070
+ ])
1071
+ ).optional(),
1072
+ text: z5.string().default(""),
1073
+ type: z5.literal("text").default("text")
1074
+ });
1075
+ var TiptapParagraph = z5.object({
1076
+ attrs: z5.object({
1077
+ textAlign: enumOrOmit(...textAlignments)
1078
+ }).default({ textAlign: TextAlignment.start }),
1079
+ content: z5.array(TiptapText).default([]),
1080
+ type: z5.literal("paragraph").default("paragraph")
1081
+ });
1082
+ var TiptapDocument = z5.object({
1083
+ attrs: z5.object({
1084
+ blockSpacing: enumOrOmit(...spacings)
1085
+ }).default({ blockSpacing: Spacing.base }),
1086
+ content: z5.array(TiptapParagraph).default([TiptapParagraph.parse({})]),
1087
+ type: z5.literal("doc").default("doc")
1088
+ });
1089
+ var CABTextSection = z5.object({
1090
+ buttonField: z5.enum(buttonFields).optional(),
1091
+ content: z5.record(z5.string(), z5.union([z5.string(), TiptapDocument]).refine(checkForHTML, NO_HTML).optional()).default({ en: TiptapDocument.parse({}) }).optional(),
1092
+ name: z5.string().optional(),
1093
+ sectionId: z5.uuidv7().default(() => uuidv73()),
1094
+ sectionType: z5.literal(SectionType.text).default(SectionType.text)
1095
+ }).superRefine(({ buttonField: buttonField2, content }, ctx) => {
1096
+ if (buttonField2 === ButtonField.destinationUrl && content) {
1097
+ forEach(content, (value, lang) => {
1098
+ if (value && isString2(value)) {
1099
+ if (DYNAMIC_TOKEN_REGEX.test(value)) return;
1100
+ try {
1101
+ new URL(value);
1102
+ } catch {
1103
+ ctx.addIssue({
1104
+ code: "custom",
1105
+ message: "Invalid URL",
1106
+ path: ["content", lang]
1107
+ });
1108
+ }
1109
+ }
1110
+ });
1111
+ }
1112
+ });
1113
+
1114
+ // src/schema/product.ts
1115
+ var CABProductSection = z6.object({
1116
+ name: z6.string().optional(),
1117
+ options: z6.array(
1118
+ z6.object({
1119
+ /** `name` represents `Color`, `Size`, etc. */
1120
+ name: z6.string(),
1121
+ optionId: z6.number(),
1122
+ selector: z6.enum(variantSelectors).default(VariantSelector.menu),
1123
+ values: z6.array(
1124
+ z6.object({
1125
+ color: z6.string().optional(),
1126
+ image: z6.lazy(() => CABImageSection).optional(),
1127
+ /** `name` represents `Red`, `Blue`, etc. */
1128
+ name: z6.string(),
1129
+ text: z6.lazy(() => CABTextSection).optional()
1130
+ })
1131
+ )
1132
+ })
1133
+ ).default(() => []),
1134
+ productId: z6.number().nullable().default(null),
1135
+ sectionId: z6.uuidv7().default(() => uuidv74()),
1136
+ sectionType: z6.literal(SectionType.product).default(SectionType.product)
1137
+ });
1138
+
1139
+ // src/schema/products.ts
1140
+ var CABProductsSection = z7.object({
1141
+ name: z7.string().optional(),
1142
+ sectionId: z7.uuidv7().default(() => uuidv75()),
1143
+ sections: z7.array(z7.lazy(() => CABProductSection)).default(() => []),
1144
+ sectionType: z7.literal(SectionType.products).default(SectionType.products)
1145
+ });
1146
+
1147
+ // src/schema/offers.ts
1148
+ var CABOffersSection = CABLayoutSection.omit({ sections: true, sectionType: true }).extend(
1149
+ z8.object({
1150
+ sections: z8.array(z8.lazy(() => CABSection)).default(() => [CABDataSourceSection.parse({}), CABProductsSection.parse({})]),
1151
+ sectionType: z8.literal(SectionType.offers).default(SectionType.offers)
1152
+ }).shape
1153
+ );
1154
+
1155
+ // src/schema/quantity.ts
1156
+ import { v7 as uuidv76 } from "uuid";
1157
+ import { z as z9 } from "zod/v4";
1158
+ var CABQuantitySection = z9.object({
1159
+ errorMessages: z9.record(
1160
+ z9.string(),
1161
+ z9.object({
1162
+ max: z9.string().optional(),
1163
+ min: z9.string().optional(),
1164
+ neg: z9.string().optional()
1165
+ })
1166
+ ).default({
1167
+ en: {
1168
+ max: "Maximum quantity allowed is {{max}}",
1169
+ min: "Minimum quantity required is {{min}}",
1170
+ neg: "Quantity cannot be negative"
1171
+ }
1172
+ }),
1173
+ inputType: z9.enum(quantityInputs).default(QuantityInput.select),
1174
+ max: z9.number().min(1).max(100).default(10),
1175
+ min: z9.number().min(1).default(1),
1176
+ name: z9.string().optional(),
1177
+ sectionId: z9.uuidv7().default(() => uuidv76()),
1178
+ sectionType: z9.literal(SectionType.quantity).default(SectionType.quantity)
1179
+ });
1180
+
1181
+ // src/schema/reviews.ts
1182
+ import { v7 as uuidv77 } from "uuid";
1183
+ import { z as z10 } from "zod/v4";
1184
+ var CABReviewsSection = z10.object({
1185
+ name: z10.string().optional(),
1186
+ sectionId: z10.uuidv7().default(() => uuidv77()),
1187
+ sectionType: z10.literal(SectionType.reviews).default(SectionType.reviews)
1188
+ });
1189
+
1190
+ // src/schema/subscription.ts
1191
+ import { v7 as uuidv78 } from "uuid";
1192
+ import { z as z11 } from "zod/v4";
1193
+ var CABSubscriptionSection = z11.object({
1194
+ name: z11.string().optional(),
1195
+ sectionId: z11.uuidv7().default(() => uuidv78()),
1196
+ sectionType: z11.literal(SectionType.subscription).default(SectionType.subscription)
1197
+ });
1198
+
1199
+ // src/schema/table.ts
1200
+ import { v7 as uuidv79 } from "uuid";
1201
+ import { z as z12 } from "zod/v4";
1202
+ var CABTableSection = z12.object({
1203
+ name: z12.string().optional(),
1204
+ sectionId: z12.uuidv7().default(() => uuidv79()),
1205
+ sectionType: z12.literal(SectionType.table).default(SectionType.table)
1206
+ });
1207
+
1208
+ // src/schema/variants.ts
1209
+ import { slice } from "lodash-es";
1210
+ import { v7 as uuidv710 } from "uuid";
1211
+ import { z as z13 } from "zod/v4";
1212
+ var CABVariantsSection = z13.object({
1213
+ name: z13.string().optional(),
1214
+ sectionId: z13.uuidv7().default(() => uuidv710()),
1215
+ sectionType: z13.literal(SectionType.variants).default(SectionType.variants),
1216
+ selector: z13.enum(slice(variantSelectors, 0, 3)).default(VariantSelector.menu)
1217
+ });
1218
+
1219
+ // src/schema/shared.ts
1220
+ var CABBorder = z14.object({
1221
+ radius: z14.enum(borderRadii).default(BorderRadius.base),
1222
+ style: z14.enum(borderStyles).default(BorderStyle.none),
1223
+ width: z14.enum(borderWidths).default(BorderWidth.base)
1224
+ }).default({
1225
+ radius: BorderRadius.base,
1226
+ style: BorderStyle.none,
1227
+ width: BorderWidth.base
1228
+ });
1229
+ var CABSection = z14.lazy(
1230
+ () => z14.discriminatedUnion("sectionType", [
1231
+ CABButtonSection,
1232
+ CABDataSourceSection,
1233
+ CABImageSection,
1234
+ CABLayoutSection,
1235
+ CABOffersSection,
1236
+ CABProductSection,
1237
+ CABProductsSection,
1238
+ CABQuantitySection,
1239
+ CABReviewsSection,
1240
+ CABSubscriptionSection,
1241
+ CABTableSection,
1242
+ CABTextSection,
1243
+ CABVariantsSection
1244
+ ])
1245
+ );
1246
+
1247
+ // src/schema/image.ts
1248
+ var CABImageSection = z15.object({
1249
+ altText: z15.string().refine(checkForHTML, NO_HTML).default(""),
1250
+ aspectRatio: z15.literal(1).nullable().default(null),
1251
+ border: z15.lazy(() => CABBorder),
1252
+ buttonField: z15.enum(buttonFields).optional(),
1253
+ category: z15.enum(["gallery", "icons", "payment-methods", "secure-checkout"]).nullable().default(null),
1254
+ name: z15.string().optional(),
1255
+ naturalHeight: z15.number().default(0),
1256
+ naturalWidth: z15.number().default(0),
1257
+ objectFit: z15.enum(objectFits).default(ObjectFit.cover),
1258
+ sectionId: z15.uuidv7().default(() => uuidv711()),
1259
+ sectionType: z15.literal(SectionType.image).default(SectionType.image),
1260
+ source: z15.union([z15.url(), z15.literal(""), z15.string().regex(DYNAMIC_TOKEN_REGEX)]).default(""),
1261
+ width: z15.number().default(100)
1262
+ });
1263
+
1264
+ // src/schema/button.ts
1265
+ var CABButtonContent = z16.lazy(() => z16.discriminatedUnion("sectionType", [CABImageSection, CABTextSection]));
1266
+ var CABButtonSection = z16.object({
1267
+ action: z16.union([z16.literal(""), z16.enum(buttonActions)]).default(""),
1268
+ buttonStyle: z16.enum(buttonStyles).default(ButtonStyle.primary),
1269
+ custom: z16.object({
1270
+ color: z16.string().regex(HEX_COLOR_REGEX).default("#005bd3"),
1271
+ height: z16.number().default(52),
1272
+ width: z16.number().default(300)
1273
+ }).default({
1274
+ color: "#005bd3",
1275
+ height: 52,
1276
+ width: 300
1277
+ }),
1278
+ name: z16.string().optional(),
1279
+ sectionId: z16.uuidv7().default(() => uuidv712()),
1280
+ sections: z16.array(CABButtonContent).default(() => []),
1281
+ sectionType: z16.literal(SectionType.button).default(SectionType.button)
1282
+ });
1283
+
1284
+ // src/schema/root.ts
1285
+ import { z as z17 } from "zod/v4";
1286
+ var TargetArea = z17.object({
1287
+ fill: z17.boolean().optional(),
1288
+ flip: z17.enum(["both", "horizontal", "vertical"]).optional(),
1289
+ icon: z17.string(),
1290
+ label: z17.string(),
1291
+ width: z17.string()
1292
+ }).default(targetAreas[EditorMode.checkoutExtension][1]);
1293
+ var CABRootSection = CABLayoutSection.extend(
1294
+ z17.object({
1295
+ editorMode: z17.enum(editorModes).default(EditorMode.checkoutExtension),
1296
+ previewMode: z17.boolean().default(false),
1297
+ storeId: z17.number().nullable().default(null),
1298
+ targetArea: TargetArea.nullable(),
1299
+ type: z17.enum(widgetTypes).default(WidgetType.ui_extension_content_block),
1300
+ version: z17.literal(2).default(2),
1301
+ widgetId: z17.number().nullable().default(null)
1302
+ }).shape
1303
+ );
735
1304
  export {
736
1305
  Api,
1306
+ BorderRadius,
1307
+ BorderStyle,
1308
+ BorderWidth,
1309
+ ButtonAction,
1310
+ ButtonField,
1311
+ ButtonStyle,
1312
+ CABBorder,
1313
+ CABButtonContent,
1314
+ CABButtonSection,
1315
+ CABDataSourceSection,
1316
+ CABImageSection,
1317
+ CABLayoutSection,
1318
+ CABOffersSection,
1319
+ CABProductSection,
1320
+ CABProductsSection,
1321
+ CABQuantitySection,
1322
+ CABReviewsSection,
1323
+ CABRootSection,
1324
+ CABSection,
1325
+ CABSubscriptionSection,
1326
+ CABTableSection,
1327
+ CABTextSection,
1328
+ CABVariantsSection,
1329
+ COMBINED_ENDPOINTS,
1330
+ DEFAULT_ENDPOINTS,
1331
+ DYNAMIC_TOKEN_REGEX,
1332
+ Direction,
1333
+ EditorMode,
737
1334
  Geolocation,
1335
+ HEX_COLOR_REGEX,
1336
+ HTML_TAGS_REGEX,
1337
+ HorizontalAlignment,
738
1338
  Identity,
1339
+ LanguageKey,
1340
+ NO_HTML,
1341
+ ObjectFit,
1342
+ QuantityInput,
739
1343
  RebuyClient,
1344
+ STATIC_ENDPOINTS,
1345
+ SectionType,
740
1346
  Session,
1347
+ Spacing,
1348
+ TextAlignment,
1349
+ TextColorName,
1350
+ TextSizeName,
1351
+ TiptapDocument,
1352
+ TiptapParagraph,
1353
+ TiptapText,
1354
+ VariantSelector,
1355
+ VerticalAlignment,
1356
+ WidgetType,
741
1357
  amountToCents,
1358
+ borderRadii,
1359
+ borderStyles,
1360
+ borderWidths,
1361
+ buttonActions,
1362
+ buttonFields,
1363
+ buttonStyles,
1364
+ checkForHTML,
742
1365
  convertProductToStorefrontFormat,
743
1366
  convertToNodes,
744
1367
  convertVariantToStorefrontFormat,
745
1368
  dataToString,
746
1369
  destroy,
1370
+ directions,
1371
+ editorModes,
747
1372
  enabled,
748
1373
  find,
749
1374
  firstAvailableVariant,
750
1375
  get,
751
1376
  getAll,
752
1377
  getIdFromGraphUrl,
1378
+ hasHTMLInDoc,
1379
+ horizontalAlignments,
753
1380
  isBase64Encoded,
1381
+ isButtonType,
1382
+ isDataSourceType,
1383
+ isHTML,
1384
+ isImageType,
1385
+ isLayoutType,
1386
+ isOffersType,
1387
+ isProductType,
1388
+ isProductsType,
1389
+ isQuantityType,
1390
+ isReviewsType,
1391
+ isSubscriptionType,
1392
+ isTableType,
1393
+ isTextType,
1394
+ isVariantsType,
1395
+ languageKeys,
1396
+ objectFits,
754
1397
  productImageObject,
1398
+ quantityInputs,
755
1399
  queryStringToObject,
1400
+ sectionTypes,
756
1401
  selectedVariantOptions,
757
1402
  serialize,
758
1403
  sessionId,
759
1404
  set,
1405
+ spacings,
760
1406
  stringToData,
761
1407
  stripHtml,
1408
+ targetAreas,
1409
+ textAlignments,
1410
+ textColorNames,
1411
+ textSizeNames,
762
1412
  utmObjectFromString,
763
1413
  uuid,
764
1414
  variantAvailable,
765
1415
  variantMinMaxPriceObject,
766
- variantPriceObject
1416
+ variantPriceObject,
1417
+ variantSelectors,
1418
+ verticalAlignments,
1419
+ widgetTypes
767
1420
  };
768
1421
  //# sourceMappingURL=index.mjs.map