@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.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -21,36 +21,107 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
Api: () => Api,
|
|
24
|
+
BorderRadius: () => BorderRadius,
|
|
25
|
+
BorderStyle: () => BorderStyle,
|
|
26
|
+
BorderWidth: () => BorderWidth,
|
|
27
|
+
ButtonAction: () => ButtonAction,
|
|
28
|
+
ButtonField: () => ButtonField,
|
|
29
|
+
ButtonStyle: () => ButtonStyle,
|
|
30
|
+
CABBorder: () => CABBorder,
|
|
31
|
+
CABButtonContent: () => CABButtonContent,
|
|
32
|
+
CABButtonSection: () => CABButtonSection,
|
|
33
|
+
CABDataSourceSection: () => CABDataSourceSection,
|
|
34
|
+
CABImageSection: () => CABImageSection,
|
|
35
|
+
CABLayoutSection: () => CABLayoutSection,
|
|
36
|
+
CABOffersSection: () => CABOffersSection,
|
|
37
|
+
CABProductSection: () => CABProductSection,
|
|
38
|
+
CABProductsSection: () => CABProductsSection,
|
|
39
|
+
CABQuantitySection: () => CABQuantitySection,
|
|
40
|
+
CABReviewsSection: () => CABReviewsSection,
|
|
41
|
+
CABRootSection: () => CABRootSection,
|
|
42
|
+
CABSection: () => CABSection,
|
|
43
|
+
CABSubscriptionSection: () => CABSubscriptionSection,
|
|
44
|
+
CABTableSection: () => CABTableSection,
|
|
45
|
+
CABTextSection: () => CABTextSection,
|
|
46
|
+
CABVariantsSection: () => CABVariantsSection,
|
|
47
|
+
COMBINED_ENDPOINTS: () => COMBINED_ENDPOINTS,
|
|
48
|
+
DEFAULT_ENDPOINTS: () => DEFAULT_ENDPOINTS,
|
|
49
|
+
DYNAMIC_TOKEN_REGEX: () => DYNAMIC_TOKEN_REGEX,
|
|
50
|
+
Direction: () => Direction,
|
|
51
|
+
EditorMode: () => EditorMode,
|
|
24
52
|
Geolocation: () => Geolocation,
|
|
53
|
+
HEX_COLOR_REGEX: () => HEX_COLOR_REGEX,
|
|
54
|
+
HTML_TAGS_REGEX: () => HTML_TAGS_REGEX,
|
|
55
|
+
HorizontalAlignment: () => HorizontalAlignment,
|
|
25
56
|
Identity: () => Identity,
|
|
57
|
+
LanguageKey: () => LanguageKey,
|
|
58
|
+
NO_HTML: () => NO_HTML,
|
|
59
|
+
ObjectFit: () => ObjectFit,
|
|
60
|
+
QuantityInput: () => QuantityInput,
|
|
26
61
|
RebuyClient: () => RebuyClient,
|
|
62
|
+
STATIC_ENDPOINTS: () => STATIC_ENDPOINTS,
|
|
63
|
+
SectionType: () => SectionType,
|
|
27
64
|
Session: () => Session,
|
|
65
|
+
Spacing: () => Spacing,
|
|
66
|
+
TextAlignment: () => TextAlignment,
|
|
67
|
+
TextColorName: () => TextColorName,
|
|
68
|
+
TextSizeName: () => TextSizeName,
|
|
69
|
+
TiptapDocument: () => TiptapDocument,
|
|
70
|
+
TiptapParagraph: () => TiptapParagraph,
|
|
71
|
+
TiptapText: () => TiptapText,
|
|
72
|
+
VariantSelector: () => VariantSelector,
|
|
73
|
+
VerticalAlignment: () => VerticalAlignment,
|
|
74
|
+
WidgetType: () => WidgetType,
|
|
28
75
|
amountToCents: () => amountToCents,
|
|
76
|
+
borderRadii: () => borderRadii,
|
|
77
|
+
borderStyles: () => borderStyles,
|
|
78
|
+
borderWidths: () => borderWidths,
|
|
79
|
+
buttonActions: () => buttonActions,
|
|
80
|
+
buttonFields: () => buttonFields,
|
|
81
|
+
buttonStyles: () => buttonStyles,
|
|
82
|
+
checkForHTML: () => checkForHTML,
|
|
29
83
|
convertProductToStorefrontFormat: () => convertProductToStorefrontFormat,
|
|
30
84
|
convertToNodes: () => convertToNodes,
|
|
31
85
|
convertVariantToStorefrontFormat: () => convertVariantToStorefrontFormat,
|
|
32
86
|
dataToString: () => dataToString,
|
|
33
87
|
destroy: () => destroy,
|
|
88
|
+
directions: () => directions,
|
|
89
|
+
editorModes: () => editorModes,
|
|
34
90
|
enabled: () => enabled,
|
|
35
91
|
find: () => find,
|
|
36
92
|
firstAvailableVariant: () => firstAvailableVariant,
|
|
37
93
|
get: () => get,
|
|
38
94
|
getAll: () => getAll,
|
|
39
95
|
getIdFromGraphUrl: () => getIdFromGraphUrl,
|
|
96
|
+
hasHTMLInDoc: () => hasHTMLInDoc,
|
|
97
|
+
horizontalAlignments: () => horizontalAlignments,
|
|
40
98
|
isBase64Encoded: () => isBase64Encoded,
|
|
99
|
+
isHTML: () => isHTML,
|
|
100
|
+
languageKeys: () => languageKeys,
|
|
101
|
+
objectFits: () => objectFits,
|
|
41
102
|
productImageObject: () => productImageObject,
|
|
103
|
+
quantityInputs: () => quantityInputs,
|
|
42
104
|
queryStringToObject: () => queryStringToObject,
|
|
105
|
+
sectionTypes: () => sectionTypes,
|
|
43
106
|
selectedVariantOptions: () => selectedVariantOptions,
|
|
44
107
|
serialize: () => serialize,
|
|
45
108
|
sessionId: () => sessionId,
|
|
46
109
|
set: () => set,
|
|
110
|
+
spacings: () => spacings,
|
|
47
111
|
stringToData: () => stringToData,
|
|
48
112
|
stripHtml: () => stripHtml,
|
|
113
|
+
targetAreas: () => targetAreas,
|
|
114
|
+
textAlignments: () => textAlignments,
|
|
115
|
+
textColorNames: () => textColorNames,
|
|
116
|
+
textSizeNames: () => textSizeNames,
|
|
49
117
|
utmObjectFromString: () => utmObjectFromString,
|
|
50
118
|
uuid: () => uuid,
|
|
51
119
|
variantAvailable: () => variantAvailable,
|
|
52
120
|
variantMinMaxPriceObject: () => variantMinMaxPriceObject,
|
|
53
|
-
variantPriceObject: () => variantPriceObject
|
|
121
|
+
variantPriceObject: () => variantPriceObject,
|
|
122
|
+
variantSelectors: () => variantSelectors,
|
|
123
|
+
verticalAlignments: () => verticalAlignments,
|
|
124
|
+
widgetTypes: () => widgetTypes
|
|
54
125
|
});
|
|
55
126
|
module.exports = __toCommonJS(index_exports);
|
|
56
127
|
|
|
@@ -788,4 +859,560 @@ var RebuyClient = class {
|
|
|
788
859
|
return null;
|
|
789
860
|
}
|
|
790
861
|
};
|
|
862
|
+
|
|
863
|
+
// src/schema/button.ts
|
|
864
|
+
var import_uuid12 = require("uuid");
|
|
865
|
+
var import_zod16 = require("zod");
|
|
866
|
+
|
|
867
|
+
// src/schema/common.ts
|
|
868
|
+
var import_zod = require("zod");
|
|
869
|
+
var borderRadii = ["none", "small", "base", "large", "fullyRounded"];
|
|
870
|
+
var borderRadius = import_zod.z.enum(borderRadii);
|
|
871
|
+
var BorderRadius = borderRadius.enum;
|
|
872
|
+
var borderStyles = ["none", "base", "dotted", "dashed"];
|
|
873
|
+
var borderStyle = import_zod.z.enum(borderStyles);
|
|
874
|
+
var BorderStyle = borderStyle.enum;
|
|
875
|
+
var borderWidths = ["base", "medium", "thick"];
|
|
876
|
+
var borderWidth = import_zod.z.enum(borderWidths);
|
|
877
|
+
var BorderWidth = borderWidth.enum;
|
|
878
|
+
var buttonActions = [
|
|
879
|
+
"addToOrder",
|
|
880
|
+
"declineAllOffers",
|
|
881
|
+
"declineOffer",
|
|
882
|
+
"goToRebuyApp",
|
|
883
|
+
"goToRebuyVault",
|
|
884
|
+
"goToURL",
|
|
885
|
+
"removeFromCart",
|
|
886
|
+
"showVariants",
|
|
887
|
+
"switchToSubscription"
|
|
888
|
+
];
|
|
889
|
+
var buttonAction = import_zod.z.enum(buttonActions);
|
|
890
|
+
var ButtonAction = buttonAction.enum;
|
|
891
|
+
var buttonFields = [
|
|
892
|
+
"addedToCart",
|
|
893
|
+
"addingToCart",
|
|
894
|
+
"addToCart",
|
|
895
|
+
"buttonLabel",
|
|
896
|
+
"declineAllOffers",
|
|
897
|
+
"declineOffer",
|
|
898
|
+
"destinationUrl",
|
|
899
|
+
"payNow",
|
|
900
|
+
"removeFromCart",
|
|
901
|
+
"showVariant",
|
|
902
|
+
"showVariants",
|
|
903
|
+
"soldOut",
|
|
904
|
+
"switchToOneTimeAction",
|
|
905
|
+
"switchToOneTimePurchase",
|
|
906
|
+
"switchToSubscriptionAction",
|
|
907
|
+
"switchToSubscriptionNoDiscount",
|
|
908
|
+
"switchToSubscriptionWithDiscount"
|
|
909
|
+
];
|
|
910
|
+
var buttonField = import_zod.z.enum(buttonFields);
|
|
911
|
+
var ButtonField = buttonField.enum;
|
|
912
|
+
var buttonStyles = ["primary", "secondary", "plain", "custom"];
|
|
913
|
+
var buttonStyle = import_zod.z.enum(buttonStyles);
|
|
914
|
+
var ButtonStyle = buttonStyle.enum;
|
|
915
|
+
var directions = ["columns", "rows"];
|
|
916
|
+
var direction = import_zod.z.enum(directions);
|
|
917
|
+
var Direction = direction.enum;
|
|
918
|
+
var editorModes = [
|
|
919
|
+
"checkoutExtension",
|
|
920
|
+
"postPurchaseOffer",
|
|
921
|
+
"thankYouPage",
|
|
922
|
+
"orderStatusPage",
|
|
923
|
+
"ordersIndexPage",
|
|
924
|
+
"customerProfilePage"
|
|
925
|
+
];
|
|
926
|
+
var editorMode = import_zod.z.enum(editorModes);
|
|
927
|
+
var EditorMode = editorMode.enum;
|
|
928
|
+
var horizontalAlignments = ["start", "center", "end"];
|
|
929
|
+
var horizontalAlignment = import_zod.z.enum(horizontalAlignments);
|
|
930
|
+
var HorizontalAlignment = horizontalAlignment.enum;
|
|
931
|
+
var languageKeys = [
|
|
932
|
+
"ar",
|
|
933
|
+
"cs",
|
|
934
|
+
"da",
|
|
935
|
+
"de",
|
|
936
|
+
"en",
|
|
937
|
+
"es",
|
|
938
|
+
"fi",
|
|
939
|
+
"fr",
|
|
940
|
+
"ga",
|
|
941
|
+
"he",
|
|
942
|
+
"hi",
|
|
943
|
+
"id",
|
|
944
|
+
"it",
|
|
945
|
+
"ja",
|
|
946
|
+
"ko",
|
|
947
|
+
"nl",
|
|
948
|
+
"no",
|
|
949
|
+
"pl",
|
|
950
|
+
"pt",
|
|
951
|
+
"ru",
|
|
952
|
+
"sv",
|
|
953
|
+
"th",
|
|
954
|
+
"tr",
|
|
955
|
+
"uk",
|
|
956
|
+
"vi",
|
|
957
|
+
"zh"
|
|
958
|
+
];
|
|
959
|
+
var languageKey = import_zod.z.enum(languageKeys);
|
|
960
|
+
var LanguageKey = languageKey.enum;
|
|
961
|
+
var objectFits = ["cover", "contain"];
|
|
962
|
+
var objectFit = import_zod.z.enum(objectFits);
|
|
963
|
+
var ObjectFit = objectFit.enum;
|
|
964
|
+
var quantityInputs = ["select", "number"];
|
|
965
|
+
var quantityInput = import_zod.z.enum(quantityInputs);
|
|
966
|
+
var QuantityInput = quantityInput.enum;
|
|
967
|
+
var sectionTypes = [
|
|
968
|
+
"button",
|
|
969
|
+
"dataSource",
|
|
970
|
+
"image",
|
|
971
|
+
"layout",
|
|
972
|
+
"offers",
|
|
973
|
+
"product",
|
|
974
|
+
"products",
|
|
975
|
+
"quantity",
|
|
976
|
+
"reviews",
|
|
977
|
+
"subscription",
|
|
978
|
+
"table",
|
|
979
|
+
"text",
|
|
980
|
+
"variants"
|
|
981
|
+
];
|
|
982
|
+
var sectionType = import_zod.z.enum(sectionTypes);
|
|
983
|
+
var SectionType = sectionType.enum;
|
|
984
|
+
var spacings = ["none", "extraTight", "tight", "base", "loose", "extraLoose"];
|
|
985
|
+
var spacing = import_zod.z.enum(spacings);
|
|
986
|
+
var Spacing = spacing.enum;
|
|
987
|
+
var textAlignments = ["start", "center", "end"];
|
|
988
|
+
var textAlignment = import_zod.z.enum(textAlignments);
|
|
989
|
+
var TextAlignment = textAlignment.enum;
|
|
990
|
+
var textColorNames = ["base", "subdued", "accent", "decorative", "success", "warning", "critical"];
|
|
991
|
+
var textColorName = import_zod.z.enum(textColorNames);
|
|
992
|
+
var TextColorName = textColorName.enum;
|
|
993
|
+
var textSizeNames = ["extraSmall", "small", "base", "medium", "large", "extraLarge"];
|
|
994
|
+
var textSizeName = import_zod.z.enum(textSizeNames);
|
|
995
|
+
var TextSizeName = textSizeName.enum;
|
|
996
|
+
var variantSelectors = ["menu", "button", "radio", "color", "image"];
|
|
997
|
+
var variantSelector = import_zod.z.enum(variantSelectors);
|
|
998
|
+
var VariantSelector = variantSelector.enum;
|
|
999
|
+
var verticalAlignments = ["top", "middle", "bottom"];
|
|
1000
|
+
var verticalAlignment = import_zod.z.enum(verticalAlignments);
|
|
1001
|
+
var VerticalAlignment = verticalAlignment.enum;
|
|
1002
|
+
|
|
1003
|
+
// src/schema/image.ts
|
|
1004
|
+
var import_uuid11 = require("uuid");
|
|
1005
|
+
var import_zod15 = require("zod");
|
|
1006
|
+
|
|
1007
|
+
// src/schema/regex.ts
|
|
1008
|
+
var DYNAMIC_TOKEN_REGEX = /^\{\{\s*[A-Za-z]+\s*\}\}$/;
|
|
1009
|
+
var HEX_COLOR_REGEX = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
|
|
1010
|
+
var HTML_TAGS_REGEX = /<[^>]*>/gi;
|
|
1011
|
+
|
|
1012
|
+
// src/schema/shared.ts
|
|
1013
|
+
var import_zod14 = require("zod");
|
|
1014
|
+
|
|
1015
|
+
// src/schema/data-source.ts
|
|
1016
|
+
var import_uuid = require("uuid");
|
|
1017
|
+
var import_zod3 = require("zod");
|
|
1018
|
+
|
|
1019
|
+
// src/schema/constants.ts
|
|
1020
|
+
var import_lodash_es = require("lodash-es");
|
|
1021
|
+
var import_zod2 = require("zod");
|
|
1022
|
+
var DEFAULT_ENDPOINTS = [
|
|
1023
|
+
{ label: "Recommended (AI)", value: "/products/recommended" },
|
|
1024
|
+
{ label: "Top Sellers", value: "/products/top_sellers" },
|
|
1025
|
+
{ label: "Buy It Again", value: "/products/purchased" },
|
|
1026
|
+
{ label: "Recently Viewed", value: "/products/viewed" },
|
|
1027
|
+
{ label: "Products Search", value: "/products/search" },
|
|
1028
|
+
{ label: "Collection Products", value: "/products/collections" },
|
|
1029
|
+
{ label: "Similar Products (AI)", value: "/products/similar_products" }
|
|
1030
|
+
];
|
|
1031
|
+
var STATIC_ENDPOINTS = [
|
|
1032
|
+
{ label: "Recommended (AI)", value: "/products/recommended" },
|
|
1033
|
+
{ label: "Top Sellers", value: "/products/top_sellers" },
|
|
1034
|
+
{ label: "Trending Products", value: "/products/trending_products" },
|
|
1035
|
+
{ label: "Buy It Again", value: "/products/purchased" },
|
|
1036
|
+
{ label: "Collection Products", value: "/products/collections" },
|
|
1037
|
+
{ label: "Recently Viewed", value: "/products/viewed" },
|
|
1038
|
+
{ label: "Static Products", value: "/products/static" },
|
|
1039
|
+
{ label: "Products Search", value: "/products/search" },
|
|
1040
|
+
{ label: "Similar Products (AI)", value: "/products/similar_products" }
|
|
1041
|
+
];
|
|
1042
|
+
var COMBINED_ENDPOINTS = (0, import_lodash_es.uniqBy)([...DEFAULT_ENDPOINTS, ...STATIC_ENDPOINTS], "value");
|
|
1043
|
+
var targetAreas = {
|
|
1044
|
+
[EditorMode.checkoutExtension]: [
|
|
1045
|
+
{ icon: "splitscreen_top", label: "Header Area", width: "984px" },
|
|
1046
|
+
{ icon: "splitscreen_left", label: "Main Column", width: "503px" },
|
|
1047
|
+
{ icon: "splitscreen_right", label: "Summary Column", width: "404px" }
|
|
1048
|
+
],
|
|
1049
|
+
[EditorMode.postPurchaseOffer]: null,
|
|
1050
|
+
[EditorMode.thankYouPage]: [
|
|
1051
|
+
{ icon: "splitscreen_top", label: "Header Area", width: "984px" },
|
|
1052
|
+
{ icon: "splitscreen_left", label: "Main Column", width: "503px" },
|
|
1053
|
+
{ icon: "splitscreen_right", label: "Summary Column", width: "404px" }
|
|
1054
|
+
],
|
|
1055
|
+
[EditorMode.orderStatusPage]: [
|
|
1056
|
+
// { fill: true, flip: 'vertical', icon: 'bottom_navigation', label: 'Announcement Bar' },
|
|
1057
|
+
{ icon: "splitscreen_top", label: "Header Area", width: "1124px" },
|
|
1058
|
+
{ fill: true, icon: "view_column_2", label: "Main Area", width: "646px" },
|
|
1059
|
+
{ icon: "splitscreen_bottom", label: "Footer Area", width: "1124px" }
|
|
1060
|
+
],
|
|
1061
|
+
[EditorMode.ordersIndexPage]: [
|
|
1062
|
+
// { fill: true, flip: 'vertical', icon: 'bottom_navigation', label: 'Announcement Bar' },
|
|
1063
|
+
{ icon: "splitscreen_top", label: "Main Area", width: "1124px" }
|
|
1064
|
+
],
|
|
1065
|
+
[EditorMode.customerProfilePage]: [
|
|
1066
|
+
// { fill: true, flip: 'vertical', icon: 'bottom_navigation', label: 'Announcement Bar' },
|
|
1067
|
+
{ icon: "splitscreen_top", label: "Main Area", width: "1124px" }
|
|
1068
|
+
]
|
|
1069
|
+
};
|
|
1070
|
+
var widgetTypes = [
|
|
1071
|
+
"bundle_builder",
|
|
1072
|
+
"cart",
|
|
1073
|
+
"cart_subscription",
|
|
1074
|
+
"dynamic_bundle",
|
|
1075
|
+
"gift_with_purchase",
|
|
1076
|
+
"pre_purchase",
|
|
1077
|
+
"product",
|
|
1078
|
+
"product_addon",
|
|
1079
|
+
"product_upsell",
|
|
1080
|
+
"recharge_checkout",
|
|
1081
|
+
"recharge_customer_portal",
|
|
1082
|
+
"recharge_post_purchase",
|
|
1083
|
+
"shopify_checkout",
|
|
1084
|
+
"shopify_checkout_extension",
|
|
1085
|
+
"shopify_post_purchase",
|
|
1086
|
+
"shopify_post_purchase_extension",
|
|
1087
|
+
"switch_to_subscription",
|
|
1088
|
+
"ui_extension_ad",
|
|
1089
|
+
"ui_extension_button",
|
|
1090
|
+
"ui_extension_content_block",
|
|
1091
|
+
"ui_extension_line_item_editor",
|
|
1092
|
+
"ui_extension_progress_bar"
|
|
1093
|
+
];
|
|
1094
|
+
var widgetType = import_zod2.z.enum(widgetTypes);
|
|
1095
|
+
var WidgetType = widgetType.enum;
|
|
1096
|
+
|
|
1097
|
+
// src/schema/data-source.ts
|
|
1098
|
+
var CABDataSourceSection = import_zod3.z.strictObject({
|
|
1099
|
+
dataSourceId: import_zod3.z.number().nullable().default(null),
|
|
1100
|
+
dataSourcePath: import_zod3.z.string().default(DEFAULT_ENDPOINTS[0].value),
|
|
1101
|
+
limit: import_zod3.z.number().default(1),
|
|
1102
|
+
name: import_zod3.z.string().default(DEFAULT_ENDPOINTS[0].label),
|
|
1103
|
+
sectionId: import_zod3.z.uuidv7().default(() => (0, import_uuid.v7)()),
|
|
1104
|
+
sectionType: import_zod3.z.literal(SectionType.dataSource).default(SectionType.dataSource)
|
|
1105
|
+
});
|
|
1106
|
+
|
|
1107
|
+
// src/schema/layout.ts
|
|
1108
|
+
var import_uuid2 = require("uuid");
|
|
1109
|
+
var import_zod4 = require("zod");
|
|
1110
|
+
var CABLayoutSection = import_zod4.z.strictObject({
|
|
1111
|
+
alignment: import_zod4.z.strictObject({
|
|
1112
|
+
horizontal: import_zod4.z.enum(horizontalAlignments).default(HorizontalAlignment.start),
|
|
1113
|
+
vertical: import_zod4.z.enum(verticalAlignments).default(VerticalAlignment.top)
|
|
1114
|
+
}).default({
|
|
1115
|
+
horizontal: HorizontalAlignment.start,
|
|
1116
|
+
vertical: VerticalAlignment.top
|
|
1117
|
+
}),
|
|
1118
|
+
border: CABBorder,
|
|
1119
|
+
direction: import_zod4.z.enum(directions).default(Direction.rows),
|
|
1120
|
+
name: import_zod4.z.string().optional(),
|
|
1121
|
+
padding: import_zod4.z.enum(spacings).default(Spacing.none),
|
|
1122
|
+
sectionId: import_zod4.z.uuidv7().default(() => (0, import_uuid2.v7)()),
|
|
1123
|
+
sections: import_zod4.z.array(import_zod4.z.lazy(() => CABSection)).default(() => []),
|
|
1124
|
+
sectionType: import_zod4.z.literal(SectionType.layout).default(SectionType.layout),
|
|
1125
|
+
spacing: import_zod4.z.enum(spacings).default(Spacing.base),
|
|
1126
|
+
width: import_zod4.z.number().default(100)
|
|
1127
|
+
});
|
|
1128
|
+
|
|
1129
|
+
// src/schema/offers.ts
|
|
1130
|
+
var import_zod8 = require("zod");
|
|
1131
|
+
|
|
1132
|
+
// src/schema/products.ts
|
|
1133
|
+
var import_uuid5 = require("uuid");
|
|
1134
|
+
var import_zod7 = require("zod");
|
|
1135
|
+
|
|
1136
|
+
// src/schema/product.ts
|
|
1137
|
+
var import_uuid4 = require("uuid");
|
|
1138
|
+
var import_zod6 = require("zod");
|
|
1139
|
+
|
|
1140
|
+
// src/schema/text.ts
|
|
1141
|
+
var import_lodash_es3 = require("lodash-es");
|
|
1142
|
+
var import_uuid3 = require("uuid");
|
|
1143
|
+
var import_zod5 = require("zod");
|
|
1144
|
+
|
|
1145
|
+
// src/schema/utils.ts
|
|
1146
|
+
var import_lodash_es2 = require("lodash-es");
|
|
1147
|
+
var isHTML = (html = "") => {
|
|
1148
|
+
if (typeof window !== "undefined") {
|
|
1149
|
+
const parser = new DOMParser();
|
|
1150
|
+
const doc = parser.parseFromString(html, "text/html");
|
|
1151
|
+
const hasHTML = (nodeList) => Array.from(nodeList).some((node) => node.nodeType === 1);
|
|
1152
|
+
return hasHTML(doc.body.childNodes) || hasHTML(doc.head.childNodes);
|
|
1153
|
+
}
|
|
1154
|
+
return HTML_TAGS_REGEX.test(html);
|
|
1155
|
+
};
|
|
1156
|
+
var hasHTMLInDoc = (doc) => doc.content.some(({ content = [] }) => content.some(({ text }) => isHTML(text)));
|
|
1157
|
+
var checkForHTML = (input) => !((0, import_lodash_es2.isString)(input) && isHTML(input) || (0, import_lodash_es2.isPlainObject)(input) && hasHTMLInDoc(input));
|
|
1158
|
+
var NO_HTML = { message: "HTML is not supported" };
|
|
1159
|
+
|
|
1160
|
+
// src/schema/text.ts
|
|
1161
|
+
var enumOrOmit = (...vals) => import_zod5.z.string().transform((val) => vals.includes(val) ? val : void 0).optional();
|
|
1162
|
+
var TiptapText = import_zod5.z.strictObject({
|
|
1163
|
+
marks: import_zod5.z.array(
|
|
1164
|
+
import_zod5.z.discriminatedUnion("type", [
|
|
1165
|
+
import_zod5.z.strictObject({ type: import_zod5.z.literal("bold") }),
|
|
1166
|
+
import_zod5.z.strictObject({ type: import_zod5.z.literal("italic") }),
|
|
1167
|
+
import_zod5.z.strictObject({
|
|
1168
|
+
attrs: import_zod5.z.strictObject({
|
|
1169
|
+
class: import_zod5.z.string().nullable(),
|
|
1170
|
+
href: import_zod5.z.union([import_zod5.z.url(), import_zod5.z.string().regex(DYNAMIC_TOKEN_REGEX)]),
|
|
1171
|
+
rel: import_zod5.z.string().default("noopener noreferrer nofollow"),
|
|
1172
|
+
target: import_zod5.z.string().default("_blank")
|
|
1173
|
+
}),
|
|
1174
|
+
type: import_zod5.z.literal("link")
|
|
1175
|
+
}),
|
|
1176
|
+
import_zod5.z.strictObject({ type: import_zod5.z.literal("strike") }),
|
|
1177
|
+
import_zod5.z.strictObject({
|
|
1178
|
+
attrs: import_zod5.z.strictObject({
|
|
1179
|
+
color: enumOrOmit(...textColorNames).default(TextColorName.base),
|
|
1180
|
+
fontSize: enumOrOmit(...textSizeNames).default(TextSizeName.base)
|
|
1181
|
+
}),
|
|
1182
|
+
type: import_zod5.z.literal("textStyle")
|
|
1183
|
+
})
|
|
1184
|
+
])
|
|
1185
|
+
).optional(),
|
|
1186
|
+
text: import_zod5.z.string().default(""),
|
|
1187
|
+
type: import_zod5.z.literal("text").default("text")
|
|
1188
|
+
});
|
|
1189
|
+
var TiptapParagraph = import_zod5.z.strictObject({
|
|
1190
|
+
attrs: import_zod5.z.strictObject({
|
|
1191
|
+
textAlign: enumOrOmit(...textAlignments)
|
|
1192
|
+
}).default({ textAlign: TextAlignment.start }),
|
|
1193
|
+
content: import_zod5.z.array(TiptapText).default([]),
|
|
1194
|
+
type: import_zod5.z.literal("paragraph").default("paragraph")
|
|
1195
|
+
});
|
|
1196
|
+
var TiptapDocument = import_zod5.z.strictObject({
|
|
1197
|
+
attrs: import_zod5.z.strictObject({
|
|
1198
|
+
blockSpacing: enumOrOmit(...spacings)
|
|
1199
|
+
}).default({ blockSpacing: Spacing.base }),
|
|
1200
|
+
content: import_zod5.z.array(TiptapParagraph).default([TiptapParagraph.parse({})]),
|
|
1201
|
+
type: import_zod5.z.literal("doc").default("doc")
|
|
1202
|
+
});
|
|
1203
|
+
var CABTextSection = import_zod5.z.strictObject({
|
|
1204
|
+
buttonField: import_zod5.z.enum(buttonFields).optional(),
|
|
1205
|
+
content: import_zod5.z.record(import_zod5.z.string(), import_zod5.z.union([import_zod5.z.string(), TiptapDocument]).refine(checkForHTML, NO_HTML).optional()).default({ en: TiptapDocument.parse({}) }).optional(),
|
|
1206
|
+
name: import_zod5.z.string().optional(),
|
|
1207
|
+
sectionId: import_zod5.z.uuidv7().default(() => (0, import_uuid3.v7)()),
|
|
1208
|
+
sectionType: import_zod5.z.literal(SectionType.text).default(SectionType.text)
|
|
1209
|
+
}).superRefine(({ buttonField: buttonField2, content }, ctx) => {
|
|
1210
|
+
if (buttonField2 === ButtonField.destinationUrl && content) {
|
|
1211
|
+
(0, import_lodash_es3.forEach)(content, (value, lang) => {
|
|
1212
|
+
if (value && (0, import_lodash_es3.isString)(value)) {
|
|
1213
|
+
if (DYNAMIC_TOKEN_REGEX.test(value)) return;
|
|
1214
|
+
try {
|
|
1215
|
+
new URL(value);
|
|
1216
|
+
} catch {
|
|
1217
|
+
ctx.addIssue({
|
|
1218
|
+
code: "custom",
|
|
1219
|
+
message: "Invalid URL",
|
|
1220
|
+
path: ["content", lang]
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
});
|
|
1225
|
+
}
|
|
1226
|
+
});
|
|
1227
|
+
|
|
1228
|
+
// src/schema/product.ts
|
|
1229
|
+
var CABProductSection = import_zod6.z.strictObject({
|
|
1230
|
+
name: import_zod6.z.string().optional(),
|
|
1231
|
+
options: import_zod6.z.array(
|
|
1232
|
+
import_zod6.z.strictObject({
|
|
1233
|
+
/** `name` represents `Color`, `Size`, etc. */
|
|
1234
|
+
name: import_zod6.z.string(),
|
|
1235
|
+
optionId: import_zod6.z.number(),
|
|
1236
|
+
selector: import_zod6.z.enum(variantSelectors).default(VariantSelector.menu),
|
|
1237
|
+
values: import_zod6.z.array(
|
|
1238
|
+
import_zod6.z.strictObject({
|
|
1239
|
+
color: import_zod6.z.string().optional(),
|
|
1240
|
+
image: CABImageSection.optional(),
|
|
1241
|
+
/** `name` represents `Red`, `Blue`, etc. */
|
|
1242
|
+
name: import_zod6.z.string(),
|
|
1243
|
+
text: CABTextSection.optional()
|
|
1244
|
+
})
|
|
1245
|
+
)
|
|
1246
|
+
})
|
|
1247
|
+
).default(() => []),
|
|
1248
|
+
productId: import_zod6.z.number().nullable().default(null),
|
|
1249
|
+
sectionId: import_zod6.z.uuidv7().default(() => (0, import_uuid4.v7)()),
|
|
1250
|
+
sectionType: import_zod6.z.literal(SectionType.product).default(SectionType.product)
|
|
1251
|
+
});
|
|
1252
|
+
|
|
1253
|
+
// src/schema/products.ts
|
|
1254
|
+
var CABProductsSection = import_zod7.z.strictObject({
|
|
1255
|
+
name: import_zod7.z.string().optional(),
|
|
1256
|
+
sectionId: import_zod7.z.uuidv7().default(() => (0, import_uuid5.v7)()),
|
|
1257
|
+
sections: import_zod7.z.array(CABProductSection).default(() => []),
|
|
1258
|
+
sectionType: import_zod7.z.literal(SectionType.products).default(SectionType.products)
|
|
1259
|
+
});
|
|
1260
|
+
|
|
1261
|
+
// src/schema/offers.ts
|
|
1262
|
+
var CABOffersSection = CABLayoutSection.omit({ sections: true, sectionType: true }).extend(
|
|
1263
|
+
import_zod8.z.strictObject({
|
|
1264
|
+
sections: import_zod8.z.array(import_zod8.z.lazy(() => CABSection)).default(() => [CABDataSourceSection.parse({}), CABProductsSection.parse({})]),
|
|
1265
|
+
sectionType: import_zod8.z.literal(SectionType.offers).default(SectionType.offers)
|
|
1266
|
+
}).shape
|
|
1267
|
+
);
|
|
1268
|
+
|
|
1269
|
+
// src/schema/quantity.ts
|
|
1270
|
+
var import_uuid6 = require("uuid");
|
|
1271
|
+
var import_zod9 = require("zod");
|
|
1272
|
+
var CABQuantitySection = import_zod9.z.strictObject({
|
|
1273
|
+
errorMessages: import_zod9.z.record(
|
|
1274
|
+
import_zod9.z.string(),
|
|
1275
|
+
import_zod9.z.strictObject({
|
|
1276
|
+
max: import_zod9.z.string().optional(),
|
|
1277
|
+
min: import_zod9.z.string().optional(),
|
|
1278
|
+
neg: import_zod9.z.string().optional()
|
|
1279
|
+
})
|
|
1280
|
+
).default({
|
|
1281
|
+
en: {
|
|
1282
|
+
max: "Maximum quantity allowed is {{max}}",
|
|
1283
|
+
min: "Minimum quantity required is {{min}}",
|
|
1284
|
+
neg: "Quantity cannot be negative"
|
|
1285
|
+
}
|
|
1286
|
+
}),
|
|
1287
|
+
inputType: import_zod9.z.enum(quantityInputs).default(QuantityInput.select),
|
|
1288
|
+
max: import_zod9.z.number().min(1).max(100).default(10),
|
|
1289
|
+
min: import_zod9.z.number().min(1).default(1),
|
|
1290
|
+
name: import_zod9.z.string().optional(),
|
|
1291
|
+
sectionId: import_zod9.z.uuidv7().default(() => (0, import_uuid6.v7)()),
|
|
1292
|
+
sectionType: import_zod9.z.literal(SectionType.quantity).default(SectionType.quantity)
|
|
1293
|
+
});
|
|
1294
|
+
|
|
1295
|
+
// src/schema/reviews.ts
|
|
1296
|
+
var import_uuid7 = require("uuid");
|
|
1297
|
+
var import_zod10 = require("zod");
|
|
1298
|
+
var CABReviewsSection = import_zod10.z.strictObject({
|
|
1299
|
+
name: import_zod10.z.string().optional(),
|
|
1300
|
+
sectionId: import_zod10.z.uuidv7().default(() => (0, import_uuid7.v7)()),
|
|
1301
|
+
sectionType: import_zod10.z.literal(SectionType.reviews).default(SectionType.reviews)
|
|
1302
|
+
});
|
|
1303
|
+
|
|
1304
|
+
// src/schema/subscription.ts
|
|
1305
|
+
var import_uuid8 = require("uuid");
|
|
1306
|
+
var import_zod11 = require("zod");
|
|
1307
|
+
var CABSubscriptionSection = import_zod11.z.strictObject({
|
|
1308
|
+
name: import_zod11.z.string().optional(),
|
|
1309
|
+
sectionId: import_zod11.z.uuidv7().default(() => (0, import_uuid8.v7)()),
|
|
1310
|
+
sectionType: import_zod11.z.literal(SectionType.subscription).default(SectionType.subscription)
|
|
1311
|
+
});
|
|
1312
|
+
|
|
1313
|
+
// src/schema/table.ts
|
|
1314
|
+
var import_uuid9 = require("uuid");
|
|
1315
|
+
var import_zod12 = require("zod");
|
|
1316
|
+
var CABTableSection = import_zod12.z.strictObject({
|
|
1317
|
+
name: import_zod12.z.string().optional(),
|
|
1318
|
+
sectionId: import_zod12.z.uuidv7().default(() => (0, import_uuid9.v7)()),
|
|
1319
|
+
sectionType: import_zod12.z.literal(SectionType.table).default(SectionType.table)
|
|
1320
|
+
});
|
|
1321
|
+
|
|
1322
|
+
// src/schema/variants.ts
|
|
1323
|
+
var import_lodash_es4 = require("lodash-es");
|
|
1324
|
+
var import_uuid10 = require("uuid");
|
|
1325
|
+
var import_zod13 = require("zod");
|
|
1326
|
+
var CABVariantsSection = import_zod13.z.strictObject({
|
|
1327
|
+
name: import_zod13.z.string().optional(),
|
|
1328
|
+
sectionId: import_zod13.z.uuidv7().default(() => (0, import_uuid10.v7)()),
|
|
1329
|
+
sectionType: import_zod13.z.literal(SectionType.variants).default(SectionType.variants),
|
|
1330
|
+
selector: import_zod13.z.enum((0, import_lodash_es4.slice)(variantSelectors, 0, 3)).default(VariantSelector.menu)
|
|
1331
|
+
});
|
|
1332
|
+
|
|
1333
|
+
// src/schema/shared.ts
|
|
1334
|
+
var CABBorder = import_zod14.z.strictObject({
|
|
1335
|
+
radius: import_zod14.z.enum(borderRadii).default(BorderRadius.base),
|
|
1336
|
+
style: import_zod14.z.enum(borderStyles).default(BorderStyle.none),
|
|
1337
|
+
width: import_zod14.z.enum(borderWidths).default(BorderWidth.base)
|
|
1338
|
+
}).default({
|
|
1339
|
+
radius: BorderRadius.base,
|
|
1340
|
+
style: BorderStyle.none,
|
|
1341
|
+
width: BorderWidth.base
|
|
1342
|
+
});
|
|
1343
|
+
var CABSection = import_zod14.z.lazy(
|
|
1344
|
+
() => import_zod14.z.discriminatedUnion("sectionType", [
|
|
1345
|
+
CABButtonSection,
|
|
1346
|
+
CABDataSourceSection,
|
|
1347
|
+
CABImageSection,
|
|
1348
|
+
CABLayoutSection,
|
|
1349
|
+
CABOffersSection,
|
|
1350
|
+
CABProductSection,
|
|
1351
|
+
CABProductsSection,
|
|
1352
|
+
CABQuantitySection,
|
|
1353
|
+
CABReviewsSection,
|
|
1354
|
+
CABSubscriptionSection,
|
|
1355
|
+
CABTableSection,
|
|
1356
|
+
CABTextSection,
|
|
1357
|
+
CABVariantsSection
|
|
1358
|
+
])
|
|
1359
|
+
);
|
|
1360
|
+
|
|
1361
|
+
// src/schema/image.ts
|
|
1362
|
+
var CABImageSection = import_zod15.z.strictObject({
|
|
1363
|
+
altText: import_zod15.z.string().refine(checkForHTML, NO_HTML).default(""),
|
|
1364
|
+
aspectRatio: import_zod15.z.literal(1).nullable().default(null),
|
|
1365
|
+
border: CABBorder,
|
|
1366
|
+
buttonField: import_zod15.z.enum(buttonFields).optional(),
|
|
1367
|
+
category: import_zod15.z.enum(["gallery", "icons", "payment-methods", "secure-checkout"]).nullable().default(null),
|
|
1368
|
+
name: import_zod15.z.string().optional(),
|
|
1369
|
+
naturalHeight: import_zod15.z.number().default(0),
|
|
1370
|
+
naturalWidth: import_zod15.z.number().default(0),
|
|
1371
|
+
objectFit: import_zod15.z.enum(objectFits).default(ObjectFit.cover),
|
|
1372
|
+
sectionId: import_zod15.z.uuidv7().default(() => (0, import_uuid11.v7)()),
|
|
1373
|
+
sectionType: import_zod15.z.literal(SectionType.image).default(SectionType.image),
|
|
1374
|
+
source: import_zod15.z.union([import_zod15.z.url(), import_zod15.z.literal(""), import_zod15.z.string().regex(DYNAMIC_TOKEN_REGEX)]).default(""),
|
|
1375
|
+
width: import_zod15.z.number().default(100)
|
|
1376
|
+
});
|
|
1377
|
+
|
|
1378
|
+
// src/schema/button.ts
|
|
1379
|
+
var CABButtonContent = import_zod16.z.discriminatedUnion("sectionType", [CABImageSection, CABTextSection]);
|
|
1380
|
+
var CABButtonSection = import_zod16.z.strictObject({
|
|
1381
|
+
action: import_zod16.z.union([import_zod16.z.literal(""), import_zod16.z.enum(buttonActions)]).default(""),
|
|
1382
|
+
buttonStyle: import_zod16.z.enum(buttonStyles).default(ButtonStyle.primary),
|
|
1383
|
+
custom: import_zod16.z.strictObject({
|
|
1384
|
+
color: import_zod16.z.string().regex(HEX_COLOR_REGEX).default("#005bd3"),
|
|
1385
|
+
height: import_zod16.z.number().default(52),
|
|
1386
|
+
width: import_zod16.z.number().default(300)
|
|
1387
|
+
}).default({
|
|
1388
|
+
color: "#005bd3",
|
|
1389
|
+
height: 52,
|
|
1390
|
+
width: 300
|
|
1391
|
+
}),
|
|
1392
|
+
name: import_zod16.z.string().optional(),
|
|
1393
|
+
sectionId: import_zod16.z.uuidv7().default(() => (0, import_uuid12.v7)()),
|
|
1394
|
+
sections: import_zod16.z.array(CABButtonContent).default(() => []),
|
|
1395
|
+
sectionType: import_zod16.z.literal(SectionType.button).default(SectionType.button)
|
|
1396
|
+
});
|
|
1397
|
+
|
|
1398
|
+
// src/schema/root.ts
|
|
1399
|
+
var import_zod17 = require("zod");
|
|
1400
|
+
var TargetArea = import_zod17.z.strictObject({
|
|
1401
|
+
fill: import_zod17.z.boolean().optional(),
|
|
1402
|
+
flip: import_zod17.z.enum(["both", "horizontal", "vertical"]).optional(),
|
|
1403
|
+
icon: import_zod17.z.string(),
|
|
1404
|
+
label: import_zod17.z.string(),
|
|
1405
|
+
width: import_zod17.z.string()
|
|
1406
|
+
}).default(targetAreas[EditorMode.checkoutExtension][1]);
|
|
1407
|
+
var CABRootSection = CABLayoutSection.extend(
|
|
1408
|
+
import_zod17.z.strictObject({
|
|
1409
|
+
editorMode: import_zod17.z.enum(editorModes).default(EditorMode.checkoutExtension),
|
|
1410
|
+
previewMode: import_zod17.z.boolean().default(false),
|
|
1411
|
+
storeId: import_zod17.z.number().nullable().default(null),
|
|
1412
|
+
targetArea: TargetArea.nullable(),
|
|
1413
|
+
type: import_zod17.z.enum(widgetTypes).default(WidgetType.ui_extension_content_block),
|
|
1414
|
+
version: import_zod17.z.literal(2).default(2),
|
|
1415
|
+
widgetId: import_zod17.z.number().nullable().default(null)
|
|
1416
|
+
}).shape
|
|
1417
|
+
);
|
|
791
1418
|
//# sourceMappingURL=index.js.map
|