@rebuy/rebuy 2.2.0-rc.5 → 2.2.0-rc.7

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.mjs CHANGED
@@ -968,7 +968,7 @@ var widgetType = z2.enum(widgetTypes);
968
968
  var WidgetType = widgetType.enum;
969
969
 
970
970
  // src/schema/data-source.ts
971
- var CABDataSourceSection = z3.strictObject({
971
+ var CABDataSourceSection = z3.object({
972
972
  dataSourceId: z3.number().nullable().default(null),
973
973
  dataSourcePath: z3.string().default(DEFAULT_ENDPOINTS[0].value),
974
974
  limit: z3.number().default(1),
@@ -980,8 +980,8 @@ var CABDataSourceSection = z3.strictObject({
980
980
  // src/schema/layout.ts
981
981
  import { v7 as uuidv72 } from "uuid";
982
982
  import { z as z4 } from "zod/v4";
983
- var CABLayoutSection = z4.strictObject({
984
- alignment: z4.strictObject({
983
+ var CABLayoutSection = z4.object({
984
+ alignment: z4.object({
985
985
  horizontal: z4.enum(horizontalAlignments).default(HorizontalAlignment.start),
986
986
  vertical: z4.enum(verticalAlignments).default(VerticalAlignment.top)
987
987
  }).default({
@@ -1016,7 +1016,7 @@ import { v7 as uuidv73 } from "uuid";
1016
1016
  import { z as z5 } from "zod/v4";
1017
1017
 
1018
1018
  // src/schema/utils.ts
1019
- import { isPlainObject, isString } from "lodash-es";
1019
+ import { get as get2, isPlainObject, isString } from "lodash-es";
1020
1020
  var isHTML = (html = "") => {
1021
1021
  if (typeof window !== "undefined") {
1022
1022
  const parser = new DOMParser();
@@ -1029,16 +1029,29 @@ var isHTML = (html = "") => {
1029
1029
  var hasHTMLInDoc = (doc) => doc.content.some(({ content = [] }) => content.some(({ text }) => isHTML(text)));
1030
1030
  var checkForHTML = (input) => !(isString(input) && isHTML(input) || isPlainObject(input) && hasHTMLInDoc(input));
1031
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;
1032
1045
 
1033
1046
  // src/schema/text.ts
1034
1047
  var enumOrOmit = (...vals) => z5.string().transform((val) => vals.includes(val) ? val : void 0).optional();
1035
- var TiptapText = z5.strictObject({
1048
+ var TiptapText = z5.object({
1036
1049
  marks: z5.array(
1037
1050
  z5.discriminatedUnion("type", [
1038
- z5.strictObject({ type: z5.literal("bold") }),
1039
- z5.strictObject({ type: z5.literal("italic") }),
1040
- z5.strictObject({
1041
- attrs: z5.strictObject({
1051
+ z5.object({ type: z5.literal("bold") }),
1052
+ z5.object({ type: z5.literal("italic") }),
1053
+ z5.object({
1054
+ attrs: z5.object({
1042
1055
  class: z5.string().nullable(),
1043
1056
  href: z5.union([z5.url(), z5.string().regex(DYNAMIC_TOKEN_REGEX)]),
1044
1057
  rel: z5.string().default("noopener noreferrer nofollow"),
@@ -1046,9 +1059,9 @@ var TiptapText = z5.strictObject({
1046
1059
  }),
1047
1060
  type: z5.literal("link")
1048
1061
  }),
1049
- z5.strictObject({ type: z5.literal("strike") }),
1050
- z5.strictObject({
1051
- attrs: z5.strictObject({
1062
+ z5.object({ type: z5.literal("strike") }),
1063
+ z5.object({
1064
+ attrs: z5.object({
1052
1065
  color: enumOrOmit(...textColorNames).default(TextColorName.base),
1053
1066
  fontSize: enumOrOmit(...textSizeNames).default(TextSizeName.base)
1054
1067
  }),
@@ -1059,21 +1072,21 @@ var TiptapText = z5.strictObject({
1059
1072
  text: z5.string().default(""),
1060
1073
  type: z5.literal("text").default("text")
1061
1074
  });
1062
- var TiptapParagraph = z5.strictObject({
1063
- attrs: z5.strictObject({
1075
+ var TiptapParagraph = z5.object({
1076
+ attrs: z5.object({
1064
1077
  textAlign: enumOrOmit(...textAlignments)
1065
1078
  }).default({ textAlign: TextAlignment.start }),
1066
1079
  content: z5.array(TiptapText).default([]),
1067
1080
  type: z5.literal("paragraph").default("paragraph")
1068
1081
  });
1069
- var TiptapDocument = z5.strictObject({
1070
- attrs: z5.strictObject({
1082
+ var TiptapDocument = z5.object({
1083
+ attrs: z5.object({
1071
1084
  blockSpacing: enumOrOmit(...spacings)
1072
1085
  }).default({ blockSpacing: Spacing.base }),
1073
1086
  content: z5.array(TiptapParagraph).default([TiptapParagraph.parse({})]),
1074
1087
  type: z5.literal("doc").default("doc")
1075
1088
  });
1076
- var CABTextSection = z5.strictObject({
1089
+ var CABTextSection = z5.object({
1077
1090
  buttonField: z5.enum(buttonFields).optional(),
1078
1091
  content: z5.record(z5.string(), z5.union([z5.string(), TiptapDocument]).refine(checkForHTML, NO_HTML).optional()).default({ en: TiptapDocument.parse({}) }).optional(),
1079
1092
  name: z5.string().optional(),
@@ -1099,16 +1112,16 @@ var CABTextSection = z5.strictObject({
1099
1112
  });
1100
1113
 
1101
1114
  // src/schema/product.ts
1102
- var CABProductSection = z6.strictObject({
1115
+ var CABProductSection = z6.object({
1103
1116
  name: z6.string().optional(),
1104
1117
  options: z6.array(
1105
- z6.strictObject({
1118
+ z6.object({
1106
1119
  /** `name` represents `Color`, `Size`, etc. */
1107
1120
  name: z6.string(),
1108
1121
  optionId: z6.number(),
1109
1122
  selector: z6.enum(variantSelectors).default(VariantSelector.menu),
1110
1123
  values: z6.array(
1111
- z6.strictObject({
1124
+ z6.object({
1112
1125
  color: z6.string().optional(),
1113
1126
  image: CABImageSection.optional(),
1114
1127
  /** `name` represents `Red`, `Blue`, etc. */
@@ -1124,7 +1137,7 @@ var CABProductSection = z6.strictObject({
1124
1137
  });
1125
1138
 
1126
1139
  // src/schema/products.ts
1127
- var CABProductsSection = z7.strictObject({
1140
+ var CABProductsSection = z7.object({
1128
1141
  name: z7.string().optional(),
1129
1142
  sectionId: z7.uuidv7().default(() => uuidv75()),
1130
1143
  sections: z7.array(CABProductSection).default(() => []),
@@ -1133,7 +1146,7 @@ var CABProductsSection = z7.strictObject({
1133
1146
 
1134
1147
  // src/schema/offers.ts
1135
1148
  var CABOffersSection = CABLayoutSection.omit({ sections: true, sectionType: true }).extend(
1136
- z8.strictObject({
1149
+ z8.object({
1137
1150
  sections: z8.array(z8.lazy(() => CABSection)).default(() => [CABDataSourceSection.parse({}), CABProductsSection.parse({})]),
1138
1151
  sectionType: z8.literal(SectionType.offers).default(SectionType.offers)
1139
1152
  }).shape
@@ -1142,10 +1155,10 @@ var CABOffersSection = CABLayoutSection.omit({ sections: true, sectionType: true
1142
1155
  // src/schema/quantity.ts
1143
1156
  import { v7 as uuidv76 } from "uuid";
1144
1157
  import { z as z9 } from "zod/v4";
1145
- var CABQuantitySection = z9.strictObject({
1158
+ var CABQuantitySection = z9.object({
1146
1159
  errorMessages: z9.record(
1147
1160
  z9.string(),
1148
- z9.strictObject({
1161
+ z9.object({
1149
1162
  max: z9.string().optional(),
1150
1163
  min: z9.string().optional(),
1151
1164
  neg: z9.string().optional()
@@ -1168,7 +1181,7 @@ var CABQuantitySection = z9.strictObject({
1168
1181
  // src/schema/reviews.ts
1169
1182
  import { v7 as uuidv77 } from "uuid";
1170
1183
  import { z as z10 } from "zod/v4";
1171
- var CABReviewsSection = z10.strictObject({
1184
+ var CABReviewsSection = z10.object({
1172
1185
  name: z10.string().optional(),
1173
1186
  sectionId: z10.uuidv7().default(() => uuidv77()),
1174
1187
  sectionType: z10.literal(SectionType.reviews).default(SectionType.reviews)
@@ -1177,7 +1190,7 @@ var CABReviewsSection = z10.strictObject({
1177
1190
  // src/schema/subscription.ts
1178
1191
  import { v7 as uuidv78 } from "uuid";
1179
1192
  import { z as z11 } from "zod/v4";
1180
- var CABSubscriptionSection = z11.strictObject({
1193
+ var CABSubscriptionSection = z11.object({
1181
1194
  name: z11.string().optional(),
1182
1195
  sectionId: z11.uuidv7().default(() => uuidv78()),
1183
1196
  sectionType: z11.literal(SectionType.subscription).default(SectionType.subscription)
@@ -1186,7 +1199,7 @@ var CABSubscriptionSection = z11.strictObject({
1186
1199
  // src/schema/table.ts
1187
1200
  import { v7 as uuidv79 } from "uuid";
1188
1201
  import { z as z12 } from "zod/v4";
1189
- var CABTableSection = z12.strictObject({
1202
+ var CABTableSection = z12.object({
1190
1203
  name: z12.string().optional(),
1191
1204
  sectionId: z12.uuidv7().default(() => uuidv79()),
1192
1205
  sectionType: z12.literal(SectionType.table).default(SectionType.table)
@@ -1196,7 +1209,7 @@ var CABTableSection = z12.strictObject({
1196
1209
  import { slice } from "lodash-es";
1197
1210
  import { v7 as uuidv710 } from "uuid";
1198
1211
  import { z as z13 } from "zod/v4";
1199
- var CABVariantsSection = z13.strictObject({
1212
+ var CABVariantsSection = z13.object({
1200
1213
  name: z13.string().optional(),
1201
1214
  sectionId: z13.uuidv7().default(() => uuidv710()),
1202
1215
  sectionType: z13.literal(SectionType.variants).default(SectionType.variants),
@@ -1204,7 +1217,7 @@ var CABVariantsSection = z13.strictObject({
1204
1217
  });
1205
1218
 
1206
1219
  // src/schema/shared.ts
1207
- var CABBorder = z14.strictObject({
1220
+ var CABBorder = z14.object({
1208
1221
  radius: z14.enum(borderRadii).default(BorderRadius.base),
1209
1222
  style: z14.enum(borderStyles).default(BorderStyle.none),
1210
1223
  width: z14.enum(borderWidths).default(BorderWidth.base)
@@ -1232,7 +1245,7 @@ var CABSection = z14.lazy(
1232
1245
  );
1233
1246
 
1234
1247
  // src/schema/image.ts
1235
- var CABImageSection = z15.strictObject({
1248
+ var CABImageSection = z15.object({
1236
1249
  altText: z15.string().refine(checkForHTML, NO_HTML).default(""),
1237
1250
  aspectRatio: z15.literal(1).nullable().default(null),
1238
1251
  border: CABBorder,
@@ -1250,10 +1263,10 @@ var CABImageSection = z15.strictObject({
1250
1263
 
1251
1264
  // src/schema/button.ts
1252
1265
  var CABButtonContent = z16.discriminatedUnion("sectionType", [CABImageSection, CABTextSection]);
1253
- var CABButtonSection = z16.strictObject({
1266
+ var CABButtonSection = z16.object({
1254
1267
  action: z16.union([z16.literal(""), z16.enum(buttonActions)]).default(""),
1255
1268
  buttonStyle: z16.enum(buttonStyles).default(ButtonStyle.primary),
1256
- custom: z16.strictObject({
1269
+ custom: z16.object({
1257
1270
  color: z16.string().regex(HEX_COLOR_REGEX).default("#005bd3"),
1258
1271
  height: z16.number().default(52),
1259
1272
  width: z16.number().default(300)
@@ -1270,7 +1283,7 @@ var CABButtonSection = z16.strictObject({
1270
1283
 
1271
1284
  // src/schema/root.ts
1272
1285
  import { z as z17 } from "zod/v4";
1273
- var TargetArea = z17.strictObject({
1286
+ var TargetArea = z17.object({
1274
1287
  fill: z17.boolean().optional(),
1275
1288
  flip: z17.enum(["both", "horizontal", "vertical"]).optional(),
1276
1289
  icon: z17.string(),
@@ -1278,7 +1291,7 @@ var TargetArea = z17.strictObject({
1278
1291
  width: z17.string()
1279
1292
  }).default(targetAreas[EditorMode.checkoutExtension][1]);
1280
1293
  var CABRootSection = CABLayoutSection.extend(
1281
- z17.strictObject({
1294
+ z17.object({
1282
1295
  editorMode: z17.enum(editorModes).default(EditorMode.checkoutExtension),
1283
1296
  previewMode: z17.boolean().default(false),
1284
1297
  storeId: z17.number().nullable().default(null),
@@ -1365,7 +1378,20 @@ export {
1365
1378
  hasHTMLInDoc,
1366
1379
  horizontalAlignments,
1367
1380
  isBase64Encoded,
1381
+ isButtonType,
1382
+ isDataSourceType,
1368
1383
  isHTML,
1384
+ isImageType,
1385
+ isLayoutType,
1386
+ isOffersType,
1387
+ isProductType,
1388
+ isProductsType,
1389
+ isQuantityType,
1390
+ isReviewsType,
1391
+ isSubscriptionType,
1392
+ isTableType,
1393
+ isTextType,
1394
+ isVariantsType,
1369
1395
  languageKeys,
1370
1396
  objectFits,
1371
1397
  productImageObject,