@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.js +59 -33
- package/dist/index.js.map +2 -2
- package/dist/index.mjs +60 -34
- package/dist/index.mjs.map +3 -3
- package/dist/schema/button.d.ts +34 -32
- package/dist/schema/button.d.ts.map +1 -1
- package/dist/schema/data-source.d.ts +3 -1
- package/dist/schema/data-source.d.ts.map +1 -1
- package/dist/schema/image.d.ts +4 -2
- package/dist/schema/image.d.ts.map +1 -1
- package/dist/schema/layout.d.ts +5 -4
- package/dist/schema/layout.d.ts.map +1 -1
- package/dist/schema/offers.d.ts +17 -16
- package/dist/schema/offers.d.ts.map +1 -1
- package/dist/schema/product.d.ts +20 -20
- package/dist/schema/product.d.ts.map +1 -1
- package/dist/schema/products.d.ts +21 -19
- package/dist/schema/products.d.ts.map +1 -1
- package/dist/schema/quantity.d.ts +4 -2
- package/dist/schema/quantity.d.ts.map +1 -1
- package/dist/schema/reviews.d.ts +3 -1
- package/dist/schema/reviews.d.ts.map +1 -1
- package/dist/schema/root.d.ts +4 -4
- package/dist/schema/root.d.ts.map +1 -1
- package/dist/schema/shared.d.ts +41 -1
- package/dist/schema/shared.d.ts.map +1 -1
- package/dist/schema/subscription.d.ts +3 -1
- package/dist/schema/subscription.d.ts.map +1 -1
- package/dist/schema/table.d.ts +3 -1
- package/dist/schema/table.d.ts.map +1 -1
- package/dist/schema/text.d.ts +45 -43
- package/dist/schema/text.d.ts.map +1 -1
- package/dist/schema/utils.d.ts +26 -1
- package/dist/schema/utils.d.ts.map +1 -1
- package/dist/schema/variants.d.ts +3 -1
- package/dist/schema/variants.d.ts.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -96,7 +96,20 @@ __export(index_exports, {
|
|
|
96
96
|
hasHTMLInDoc: () => hasHTMLInDoc,
|
|
97
97
|
horizontalAlignments: () => horizontalAlignments,
|
|
98
98
|
isBase64Encoded: () => isBase64Encoded,
|
|
99
|
+
isButtonType: () => isButtonType,
|
|
100
|
+
isDataSourceType: () => isDataSourceType,
|
|
99
101
|
isHTML: () => isHTML,
|
|
102
|
+
isImageType: () => isImageType,
|
|
103
|
+
isLayoutType: () => isLayoutType,
|
|
104
|
+
isOffersType: () => isOffersType,
|
|
105
|
+
isProductType: () => isProductType,
|
|
106
|
+
isProductsType: () => isProductsType,
|
|
107
|
+
isQuantityType: () => isQuantityType,
|
|
108
|
+
isReviewsType: () => isReviewsType,
|
|
109
|
+
isSubscriptionType: () => isSubscriptionType,
|
|
110
|
+
isTableType: () => isTableType,
|
|
111
|
+
isTextType: () => isTextType,
|
|
112
|
+
isVariantsType: () => isVariantsType,
|
|
100
113
|
languageKeys: () => languageKeys,
|
|
101
114
|
objectFits: () => objectFits,
|
|
102
115
|
productImageObject: () => productImageObject,
|
|
@@ -1095,7 +1108,7 @@ var widgetType = import_v42.z.enum(widgetTypes);
|
|
|
1095
1108
|
var WidgetType = widgetType.enum;
|
|
1096
1109
|
|
|
1097
1110
|
// src/schema/data-source.ts
|
|
1098
|
-
var CABDataSourceSection = import_v43.z.
|
|
1111
|
+
var CABDataSourceSection = import_v43.z.object({
|
|
1099
1112
|
dataSourceId: import_v43.z.number().nullable().default(null),
|
|
1100
1113
|
dataSourcePath: import_v43.z.string().default(DEFAULT_ENDPOINTS[0].value),
|
|
1101
1114
|
limit: import_v43.z.number().default(1),
|
|
@@ -1107,8 +1120,8 @@ var CABDataSourceSection = import_v43.z.strictObject({
|
|
|
1107
1120
|
// src/schema/layout.ts
|
|
1108
1121
|
var import_uuid2 = require("uuid");
|
|
1109
1122
|
var import_v44 = require("zod/v4");
|
|
1110
|
-
var CABLayoutSection = import_v44.z.
|
|
1111
|
-
alignment: import_v44.z.
|
|
1123
|
+
var CABLayoutSection = import_v44.z.object({
|
|
1124
|
+
alignment: import_v44.z.object({
|
|
1112
1125
|
horizontal: import_v44.z.enum(horizontalAlignments).default(HorizontalAlignment.start),
|
|
1113
1126
|
vertical: import_v44.z.enum(verticalAlignments).default(VerticalAlignment.top)
|
|
1114
1127
|
}).default({
|
|
@@ -1156,16 +1169,29 @@ var isHTML = (html = "") => {
|
|
|
1156
1169
|
var hasHTMLInDoc = (doc) => doc.content.some(({ content = [] }) => content.some(({ text }) => isHTML(text)));
|
|
1157
1170
|
var checkForHTML = (input) => !((0, import_lodash_es2.isString)(input) && isHTML(input) || (0, import_lodash_es2.isPlainObject)(input) && hasHTMLInDoc(input));
|
|
1158
1171
|
var NO_HTML = { message: "HTML is not supported" };
|
|
1172
|
+
var isButtonType = (section) => (0, import_lodash_es2.get)(section, "sectionType") === SectionType.button;
|
|
1173
|
+
var isDataSourceType = (section) => (0, import_lodash_es2.get)(section, "sectionType") === SectionType.dataSource;
|
|
1174
|
+
var isImageType = (section) => (0, import_lodash_es2.get)(section, "sectionType") === SectionType.image;
|
|
1175
|
+
var isLayoutType = (section) => (0, import_lodash_es2.get)(section, "sectionType") === SectionType.layout;
|
|
1176
|
+
var isOffersType = (section) => (0, import_lodash_es2.get)(section, "sectionType") === SectionType.offers;
|
|
1177
|
+
var isProductType = (section) => (0, import_lodash_es2.get)(section, "sectionType") === SectionType.product;
|
|
1178
|
+
var isProductsType = (section) => (0, import_lodash_es2.get)(section, "sectionType") === SectionType.products;
|
|
1179
|
+
var isQuantityType = (section) => (0, import_lodash_es2.get)(section, "sectionType") === SectionType.quantity;
|
|
1180
|
+
var isReviewsType = (section) => (0, import_lodash_es2.get)(section, "sectionType") === SectionType.reviews;
|
|
1181
|
+
var isSubscriptionType = (section) => (0, import_lodash_es2.get)(section, "sectionType") === SectionType.subscription;
|
|
1182
|
+
var isTableType = (section) => (0, import_lodash_es2.get)(section, "sectionType") === SectionType.table;
|
|
1183
|
+
var isTextType = (section) => (0, import_lodash_es2.get)(section, "sectionType") === SectionType.text;
|
|
1184
|
+
var isVariantsType = (section) => (0, import_lodash_es2.get)(section, "sectionType") === SectionType.variants;
|
|
1159
1185
|
|
|
1160
1186
|
// src/schema/text.ts
|
|
1161
1187
|
var enumOrOmit = (...vals) => import_v45.z.string().transform((val) => vals.includes(val) ? val : void 0).optional();
|
|
1162
|
-
var TiptapText = import_v45.z.
|
|
1188
|
+
var TiptapText = import_v45.z.object({
|
|
1163
1189
|
marks: import_v45.z.array(
|
|
1164
1190
|
import_v45.z.discriminatedUnion("type", [
|
|
1165
|
-
import_v45.z.
|
|
1166
|
-
import_v45.z.
|
|
1167
|
-
import_v45.z.
|
|
1168
|
-
attrs: import_v45.z.
|
|
1191
|
+
import_v45.z.object({ type: import_v45.z.literal("bold") }),
|
|
1192
|
+
import_v45.z.object({ type: import_v45.z.literal("italic") }),
|
|
1193
|
+
import_v45.z.object({
|
|
1194
|
+
attrs: import_v45.z.object({
|
|
1169
1195
|
class: import_v45.z.string().nullable(),
|
|
1170
1196
|
href: import_v45.z.union([import_v45.z.url(), import_v45.z.string().regex(DYNAMIC_TOKEN_REGEX)]),
|
|
1171
1197
|
rel: import_v45.z.string().default("noopener noreferrer nofollow"),
|
|
@@ -1173,9 +1199,9 @@ var TiptapText = import_v45.z.strictObject({
|
|
|
1173
1199
|
}),
|
|
1174
1200
|
type: import_v45.z.literal("link")
|
|
1175
1201
|
}),
|
|
1176
|
-
import_v45.z.
|
|
1177
|
-
import_v45.z.
|
|
1178
|
-
attrs: import_v45.z.
|
|
1202
|
+
import_v45.z.object({ type: import_v45.z.literal("strike") }),
|
|
1203
|
+
import_v45.z.object({
|
|
1204
|
+
attrs: import_v45.z.object({
|
|
1179
1205
|
color: enumOrOmit(...textColorNames).default(TextColorName.base),
|
|
1180
1206
|
fontSize: enumOrOmit(...textSizeNames).default(TextSizeName.base)
|
|
1181
1207
|
}),
|
|
@@ -1186,21 +1212,21 @@ var TiptapText = import_v45.z.strictObject({
|
|
|
1186
1212
|
text: import_v45.z.string().default(""),
|
|
1187
1213
|
type: import_v45.z.literal("text").default("text")
|
|
1188
1214
|
});
|
|
1189
|
-
var TiptapParagraph = import_v45.z.
|
|
1190
|
-
attrs: import_v45.z.
|
|
1215
|
+
var TiptapParagraph = import_v45.z.object({
|
|
1216
|
+
attrs: import_v45.z.object({
|
|
1191
1217
|
textAlign: enumOrOmit(...textAlignments)
|
|
1192
1218
|
}).default({ textAlign: TextAlignment.start }),
|
|
1193
1219
|
content: import_v45.z.array(TiptapText).default([]),
|
|
1194
1220
|
type: import_v45.z.literal("paragraph").default("paragraph")
|
|
1195
1221
|
});
|
|
1196
|
-
var TiptapDocument = import_v45.z.
|
|
1197
|
-
attrs: import_v45.z.
|
|
1222
|
+
var TiptapDocument = import_v45.z.object({
|
|
1223
|
+
attrs: import_v45.z.object({
|
|
1198
1224
|
blockSpacing: enumOrOmit(...spacings)
|
|
1199
1225
|
}).default({ blockSpacing: Spacing.base }),
|
|
1200
1226
|
content: import_v45.z.array(TiptapParagraph).default([TiptapParagraph.parse({})]),
|
|
1201
1227
|
type: import_v45.z.literal("doc").default("doc")
|
|
1202
1228
|
});
|
|
1203
|
-
var CABTextSection = import_v45.z.
|
|
1229
|
+
var CABTextSection = import_v45.z.object({
|
|
1204
1230
|
buttonField: import_v45.z.enum(buttonFields).optional(),
|
|
1205
1231
|
content: import_v45.z.record(import_v45.z.string(), import_v45.z.union([import_v45.z.string(), TiptapDocument]).refine(checkForHTML, NO_HTML).optional()).default({ en: TiptapDocument.parse({}) }).optional(),
|
|
1206
1232
|
name: import_v45.z.string().optional(),
|
|
@@ -1226,16 +1252,16 @@ var CABTextSection = import_v45.z.strictObject({
|
|
|
1226
1252
|
});
|
|
1227
1253
|
|
|
1228
1254
|
// src/schema/product.ts
|
|
1229
|
-
var CABProductSection = import_v46.z.
|
|
1255
|
+
var CABProductSection = import_v46.z.object({
|
|
1230
1256
|
name: import_v46.z.string().optional(),
|
|
1231
1257
|
options: import_v46.z.array(
|
|
1232
|
-
import_v46.z.
|
|
1258
|
+
import_v46.z.object({
|
|
1233
1259
|
/** `name` represents `Color`, `Size`, etc. */
|
|
1234
1260
|
name: import_v46.z.string(),
|
|
1235
1261
|
optionId: import_v46.z.number(),
|
|
1236
1262
|
selector: import_v46.z.enum(variantSelectors).default(VariantSelector.menu),
|
|
1237
1263
|
values: import_v46.z.array(
|
|
1238
|
-
import_v46.z.
|
|
1264
|
+
import_v46.z.object({
|
|
1239
1265
|
color: import_v46.z.string().optional(),
|
|
1240
1266
|
image: CABImageSection.optional(),
|
|
1241
1267
|
/** `name` represents `Red`, `Blue`, etc. */
|
|
@@ -1251,7 +1277,7 @@ var CABProductSection = import_v46.z.strictObject({
|
|
|
1251
1277
|
});
|
|
1252
1278
|
|
|
1253
1279
|
// src/schema/products.ts
|
|
1254
|
-
var CABProductsSection = import_v47.z.
|
|
1280
|
+
var CABProductsSection = import_v47.z.object({
|
|
1255
1281
|
name: import_v47.z.string().optional(),
|
|
1256
1282
|
sectionId: import_v47.z.uuidv7().default(() => (0, import_uuid5.v7)()),
|
|
1257
1283
|
sections: import_v47.z.array(CABProductSection).default(() => []),
|
|
@@ -1260,7 +1286,7 @@ var CABProductsSection = import_v47.z.strictObject({
|
|
|
1260
1286
|
|
|
1261
1287
|
// src/schema/offers.ts
|
|
1262
1288
|
var CABOffersSection = CABLayoutSection.omit({ sections: true, sectionType: true }).extend(
|
|
1263
|
-
import_v48.z.
|
|
1289
|
+
import_v48.z.object({
|
|
1264
1290
|
sections: import_v48.z.array(import_v48.z.lazy(() => CABSection)).default(() => [CABDataSourceSection.parse({}), CABProductsSection.parse({})]),
|
|
1265
1291
|
sectionType: import_v48.z.literal(SectionType.offers).default(SectionType.offers)
|
|
1266
1292
|
}).shape
|
|
@@ -1269,10 +1295,10 @@ var CABOffersSection = CABLayoutSection.omit({ sections: true, sectionType: true
|
|
|
1269
1295
|
// src/schema/quantity.ts
|
|
1270
1296
|
var import_uuid6 = require("uuid");
|
|
1271
1297
|
var import_v49 = require("zod/v4");
|
|
1272
|
-
var CABQuantitySection = import_v49.z.
|
|
1298
|
+
var CABQuantitySection = import_v49.z.object({
|
|
1273
1299
|
errorMessages: import_v49.z.record(
|
|
1274
1300
|
import_v49.z.string(),
|
|
1275
|
-
import_v49.z.
|
|
1301
|
+
import_v49.z.object({
|
|
1276
1302
|
max: import_v49.z.string().optional(),
|
|
1277
1303
|
min: import_v49.z.string().optional(),
|
|
1278
1304
|
neg: import_v49.z.string().optional()
|
|
@@ -1295,7 +1321,7 @@ var CABQuantitySection = import_v49.z.strictObject({
|
|
|
1295
1321
|
// src/schema/reviews.ts
|
|
1296
1322
|
var import_uuid7 = require("uuid");
|
|
1297
1323
|
var import_v410 = require("zod/v4");
|
|
1298
|
-
var CABReviewsSection = import_v410.z.
|
|
1324
|
+
var CABReviewsSection = import_v410.z.object({
|
|
1299
1325
|
name: import_v410.z.string().optional(),
|
|
1300
1326
|
sectionId: import_v410.z.uuidv7().default(() => (0, import_uuid7.v7)()),
|
|
1301
1327
|
sectionType: import_v410.z.literal(SectionType.reviews).default(SectionType.reviews)
|
|
@@ -1304,7 +1330,7 @@ var CABReviewsSection = import_v410.z.strictObject({
|
|
|
1304
1330
|
// src/schema/subscription.ts
|
|
1305
1331
|
var import_uuid8 = require("uuid");
|
|
1306
1332
|
var import_v411 = require("zod/v4");
|
|
1307
|
-
var CABSubscriptionSection = import_v411.z.
|
|
1333
|
+
var CABSubscriptionSection = import_v411.z.object({
|
|
1308
1334
|
name: import_v411.z.string().optional(),
|
|
1309
1335
|
sectionId: import_v411.z.uuidv7().default(() => (0, import_uuid8.v7)()),
|
|
1310
1336
|
sectionType: import_v411.z.literal(SectionType.subscription).default(SectionType.subscription)
|
|
@@ -1313,7 +1339,7 @@ var CABSubscriptionSection = import_v411.z.strictObject({
|
|
|
1313
1339
|
// src/schema/table.ts
|
|
1314
1340
|
var import_uuid9 = require("uuid");
|
|
1315
1341
|
var import_v412 = require("zod/v4");
|
|
1316
|
-
var CABTableSection = import_v412.z.
|
|
1342
|
+
var CABTableSection = import_v412.z.object({
|
|
1317
1343
|
name: import_v412.z.string().optional(),
|
|
1318
1344
|
sectionId: import_v412.z.uuidv7().default(() => (0, import_uuid9.v7)()),
|
|
1319
1345
|
sectionType: import_v412.z.literal(SectionType.table).default(SectionType.table)
|
|
@@ -1323,7 +1349,7 @@ var CABTableSection = import_v412.z.strictObject({
|
|
|
1323
1349
|
var import_lodash_es4 = require("lodash-es");
|
|
1324
1350
|
var import_uuid10 = require("uuid");
|
|
1325
1351
|
var import_v413 = require("zod/v4");
|
|
1326
|
-
var CABVariantsSection = import_v413.z.
|
|
1352
|
+
var CABVariantsSection = import_v413.z.object({
|
|
1327
1353
|
name: import_v413.z.string().optional(),
|
|
1328
1354
|
sectionId: import_v413.z.uuidv7().default(() => (0, import_uuid10.v7)()),
|
|
1329
1355
|
sectionType: import_v413.z.literal(SectionType.variants).default(SectionType.variants),
|
|
@@ -1331,7 +1357,7 @@ var CABVariantsSection = import_v413.z.strictObject({
|
|
|
1331
1357
|
});
|
|
1332
1358
|
|
|
1333
1359
|
// src/schema/shared.ts
|
|
1334
|
-
var CABBorder = import_v414.z.
|
|
1360
|
+
var CABBorder = import_v414.z.object({
|
|
1335
1361
|
radius: import_v414.z.enum(borderRadii).default(BorderRadius.base),
|
|
1336
1362
|
style: import_v414.z.enum(borderStyles).default(BorderStyle.none),
|
|
1337
1363
|
width: import_v414.z.enum(borderWidths).default(BorderWidth.base)
|
|
@@ -1359,7 +1385,7 @@ var CABSection = import_v414.z.lazy(
|
|
|
1359
1385
|
);
|
|
1360
1386
|
|
|
1361
1387
|
// src/schema/image.ts
|
|
1362
|
-
var CABImageSection = import_v415.z.
|
|
1388
|
+
var CABImageSection = import_v415.z.object({
|
|
1363
1389
|
altText: import_v415.z.string().refine(checkForHTML, NO_HTML).default(""),
|
|
1364
1390
|
aspectRatio: import_v415.z.literal(1).nullable().default(null),
|
|
1365
1391
|
border: CABBorder,
|
|
@@ -1377,10 +1403,10 @@ var CABImageSection = import_v415.z.strictObject({
|
|
|
1377
1403
|
|
|
1378
1404
|
// src/schema/button.ts
|
|
1379
1405
|
var CABButtonContent = import_v416.z.discriminatedUnion("sectionType", [CABImageSection, CABTextSection]);
|
|
1380
|
-
var CABButtonSection = import_v416.z.
|
|
1406
|
+
var CABButtonSection = import_v416.z.object({
|
|
1381
1407
|
action: import_v416.z.union([import_v416.z.literal(""), import_v416.z.enum(buttonActions)]).default(""),
|
|
1382
1408
|
buttonStyle: import_v416.z.enum(buttonStyles).default(ButtonStyle.primary),
|
|
1383
|
-
custom: import_v416.z.
|
|
1409
|
+
custom: import_v416.z.object({
|
|
1384
1410
|
color: import_v416.z.string().regex(HEX_COLOR_REGEX).default("#005bd3"),
|
|
1385
1411
|
height: import_v416.z.number().default(52),
|
|
1386
1412
|
width: import_v416.z.number().default(300)
|
|
@@ -1397,7 +1423,7 @@ var CABButtonSection = import_v416.z.strictObject({
|
|
|
1397
1423
|
|
|
1398
1424
|
// src/schema/root.ts
|
|
1399
1425
|
var import_v417 = require("zod/v4");
|
|
1400
|
-
var TargetArea = import_v417.z.
|
|
1426
|
+
var TargetArea = import_v417.z.object({
|
|
1401
1427
|
fill: import_v417.z.boolean().optional(),
|
|
1402
1428
|
flip: import_v417.z.enum(["both", "horizontal", "vertical"]).optional(),
|
|
1403
1429
|
icon: import_v417.z.string(),
|
|
@@ -1405,7 +1431,7 @@ var TargetArea = import_v417.z.strictObject({
|
|
|
1405
1431
|
width: import_v417.z.string()
|
|
1406
1432
|
}).default(targetAreas[EditorMode.checkoutExtension][1]);
|
|
1407
1433
|
var CABRootSection = CABLayoutSection.extend(
|
|
1408
|
-
import_v417.z.
|
|
1434
|
+
import_v417.z.object({
|
|
1409
1435
|
editorMode: import_v417.z.enum(editorModes).default(EditorMode.checkoutExtension),
|
|
1410
1436
|
previewMode: import_v417.z.boolean().default(false),
|
|
1411
1437
|
storeId: import_v417.z.number().nullable().default(null),
|