@rebuy/rebuy 2.34.0 → 2.35.0
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 +204 -23
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +204 -23
- package/dist/index.mjs.map +4 -4
- package/dist/schema/checkout-and-beyond/constants.js +2 -0
- package/dist/schema/checkout-and-beyond/constants.js.map +2 -2
- package/dist/schema/checkout-and-beyond/constants.mjs +2 -0
- package/dist/schema/checkout-and-beyond/constants.mjs.map +2 -2
- package/dist/schema/checkout-and-beyond/index.js +183 -6
- package/dist/schema/checkout-and-beyond/index.js.map +3 -3
- package/dist/schema/checkout-and-beyond/index.mjs +183 -6
- package/dist/schema/checkout-and-beyond/index.mjs.map +3 -3
- package/dist/schema/widget-data.js +197 -23
- package/dist/schema/widget-data.js.map +4 -4
- package/dist/schema/widget-data.mjs +197 -23
- package/dist/schema/widget-data.mjs.map +3 -3
- package/dist/schema/widgets/checkout-and-beyond/banner.d.ts +27 -25
- package/dist/schema/widgets/checkout-and-beyond/banner.d.ts.map +1 -1
- package/dist/schema/widgets/checkout-and-beyond/button.d.ts +5 -0
- package/dist/schema/widgets/checkout-and-beyond/button.d.ts.map +1 -1
- package/dist/schema/widgets/checkout-and-beyond/carousel.d.ts +25 -25
- package/dist/schema/widgets/checkout-and-beyond/cartLine.d.ts +25 -25
- package/dist/schema/widgets/checkout-and-beyond/common.d.ts +3 -1
- package/dist/schema/widgets/checkout-and-beyond/common.d.ts.map +1 -1
- package/dist/schema/widgets/checkout-and-beyond/icons.d.ts +124 -0
- package/dist/schema/widgets/checkout-and-beyond/icons.d.ts.map +1 -0
- package/dist/schema/widgets/checkout-and-beyond/image.d.ts +319 -2
- package/dist/schema/widgets/checkout-and-beyond/image.d.ts.map +1 -1
- package/dist/schema/widgets/checkout-and-beyond/index.d.ts +1 -0
- package/dist/schema/widgets/checkout-and-beyond/index.d.ts.map +1 -1
- package/dist/schema/widgets/checkout-and-beyond/offers.d.ts +25 -25
- package/dist/schema/widgets/checkout-and-beyond/progressBar.d.ts +25 -25
- package/dist/schema/widgets/checkout-and-beyond/progressBar.d.ts.map +1 -1
- package/dist/server/index.js +193 -25
- package/dist/server/index.js.map +4 -4
- package/dist/server/index.mjs +193 -25
- package/dist/server/index.mjs.map +4 -4
- package/dist/transforms/index.js +193 -25
- package/dist/transforms/index.js.map +3 -3
- package/dist/transforms/index.mjs +193 -25
- package/dist/transforms/index.mjs.map +3 -3
- package/dist/transforms/smartCart/convertSmartCartProgressBarToV2.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -22,6 +22,7 @@ var borderWidths = ["base", "medium", "thick"];
|
|
|
22
22
|
var BorderWidth = freezeEnum(borderWidths);
|
|
23
23
|
var buttonActions = [
|
|
24
24
|
"acceptOffer",
|
|
25
|
+
"addGift",
|
|
25
26
|
"addToOrder",
|
|
26
27
|
"declineAllOffers",
|
|
27
28
|
"declineOffer",
|
|
@@ -31,6 +32,7 @@ var buttonActions = [
|
|
|
31
32
|
"goToPrevPage",
|
|
32
33
|
"goToURL",
|
|
33
34
|
"removeFromOrder",
|
|
35
|
+
"removeGift",
|
|
34
36
|
"selectVariant",
|
|
35
37
|
"showPagination",
|
|
36
38
|
"switchToSubscription",
|
|
@@ -323,22 +325,10 @@ import { z as z20 } from "zod";
|
|
|
323
325
|
|
|
324
326
|
// src/schema/widgets/checkout-and-beyond/banner.ts
|
|
325
327
|
import { z as z4 } from "zod";
|
|
326
|
-
var CABBannerSection = z4.lazy(
|
|
327
|
-
() => CABLayoutSection.omit({ sectionType: true }).extend({
|
|
328
|
-
buttonField: z4.enum(buttonFields).optional(),
|
|
329
|
-
color: z4.enum(bannerColors).default("info"),
|
|
330
|
-
dismissible: z4.boolean().default(true),
|
|
331
|
-
sectionType: z4.literal(SectionType.banner).default(SectionType.banner)
|
|
332
|
-
})
|
|
333
|
-
);
|
|
334
328
|
|
|
335
|
-
// src/schema/widgets/checkout-and-beyond/
|
|
336
|
-
import {
|
|
337
|
-
import {
|
|
338
|
-
|
|
339
|
-
// src/schema/widgets/checkout-and-beyond/image.ts
|
|
340
|
-
import { v7 as uuidv7 } from "uuid";
|
|
341
|
-
import { z as z5 } from "zod";
|
|
329
|
+
// src/schema/widgets/checkout-and-beyond/utils.ts
|
|
330
|
+
import { isPlainObject, mapValues } from "es-toolkit";
|
|
331
|
+
import { every, get, isArray, isString, map, size, toPairs } from "es-toolkit/compat";
|
|
342
332
|
|
|
343
333
|
// src/schema/widgets/checkout-and-beyond/regex.ts
|
|
344
334
|
var DYNAMIC_TOKEN_REGEX = /^\{\{\s*[A-Za-z]+\s*\}\}$/;
|
|
@@ -347,8 +337,6 @@ var ROOT_RELATIVE_PATH_REGEX = /^\/(?!\/)/;
|
|
|
347
337
|
var HTML_TAGS_REGEX = /<\/?[a-zA-Z][^>]*>/g;
|
|
348
338
|
|
|
349
339
|
// src/schema/widgets/checkout-and-beyond/utils.ts
|
|
350
|
-
import { isPlainObject, mapValues } from "es-toolkit";
|
|
351
|
-
import { every, get, isArray, isString, map, size, toPairs } from "es-toolkit/compat";
|
|
352
340
|
var isHTML = (html = "") => {
|
|
353
341
|
if (typeof window !== "undefined") {
|
|
354
342
|
const parser = new DOMParser();
|
|
@@ -362,13 +350,158 @@ var hasHTMLInDoc = (doc) => doc.content.some(({ content = [] }) => content.some(
|
|
|
362
350
|
var checkForHTML = (input) => !(isString(input) && isHTML(input) || isPlainObject(input) && hasHTMLInDoc(input));
|
|
363
351
|
var NO_HTML = { message: "HTML is not supported" };
|
|
364
352
|
|
|
353
|
+
// src/schema/widgets/checkout-and-beyond/banner.ts
|
|
354
|
+
var CABBannerSection = z4.lazy(
|
|
355
|
+
() => CABLayoutSection.omit({ sectionType: true }).extend({
|
|
356
|
+
buttonField: z4.enum(buttonFields).optional(),
|
|
357
|
+
color: z4.enum(bannerColors).default("info"),
|
|
358
|
+
dismissible: z4.boolean().default(true),
|
|
359
|
+
/**
|
|
360
|
+
* The `s-banner` heading — localized content (a buyer can see a merchant-composed banner). Absent OR
|
|
361
|
+
* blank ⇒ no heading; the renderer emits no heading slot for `''` rather than an empty one.
|
|
362
|
+
*
|
|
363
|
+
* Merchant-composed buyer-facing plain text, so it rejects HTML at the boundary the same way
|
|
364
|
+
* `CABImageSection.altText` and `CABTextSection.content` do (the unchecked localized records elsewhere —
|
|
365
|
+
* `progressBar`'s gift labels, `reviews`' plurals — are converter/constant-sourced, not merchant input).
|
|
366
|
+
*
|
|
367
|
+
* The refinement is a last-resort ASSERTION, not the normalization boundary: `normalizeTextContent` only
|
|
368
|
+
* rewrites `sectionType: 'text'` nodes' `content`, so nothing strips markup or canonicalizes `{token}`
|
|
369
|
+
* here. A producer must strip upstream the way `composeOffer` does for `altText`. Get it wrong and
|
|
370
|
+
* `salvageSections` stubs the whole banner (children included) with a drift report — degraded, reported,
|
|
371
|
+
* not a 500. Nothing emits `heading` yet; the first converter that maps merchant banner copy into it
|
|
372
|
+
* either strips first or teaches `normalizeTextContent` to strip this field.
|
|
373
|
+
*/
|
|
374
|
+
heading: z4.record(z4.string(), z4.string().refine(checkForHTML, NO_HTML)).optional(),
|
|
375
|
+
sectionType: z4.literal(SectionType.banner).default(SectionType.banner)
|
|
376
|
+
})
|
|
377
|
+
);
|
|
378
|
+
|
|
379
|
+
// src/schema/widgets/checkout-and-beyond/button.ts
|
|
380
|
+
import { v7 as uuidv73 } from "uuid";
|
|
381
|
+
import { z as z7 } from "zod";
|
|
382
|
+
|
|
383
|
+
// src/schema/widgets/checkout-and-beyond/image.ts
|
|
384
|
+
import { v7 as uuidv7 } from "uuid";
|
|
385
|
+
import { z as z5 } from "zod";
|
|
386
|
+
|
|
387
|
+
// src/schema/widgets/checkout-and-beyond/icons.ts
|
|
388
|
+
var iconNames = [
|
|
389
|
+
"alert-circle",
|
|
390
|
+
"alert-triangle",
|
|
391
|
+
"alert-triangle-filled",
|
|
392
|
+
"arrow-down",
|
|
393
|
+
"arrow-left",
|
|
394
|
+
"arrow-right",
|
|
395
|
+
"arrow-up",
|
|
396
|
+
"arrow-up-right",
|
|
397
|
+
"bag",
|
|
398
|
+
"bullet",
|
|
399
|
+
"calendar",
|
|
400
|
+
"camera",
|
|
401
|
+
"caret-down",
|
|
402
|
+
"cart",
|
|
403
|
+
"cash-dollar",
|
|
404
|
+
"categories",
|
|
405
|
+
"check",
|
|
406
|
+
"check-circle",
|
|
407
|
+
"check-circle-filled",
|
|
408
|
+
"chevron-down",
|
|
409
|
+
"chevron-left",
|
|
410
|
+
"chevron-right",
|
|
411
|
+
"chevron-up",
|
|
412
|
+
"circle",
|
|
413
|
+
"clipboard",
|
|
414
|
+
"clock",
|
|
415
|
+
"credit-card",
|
|
416
|
+
"delete",
|
|
417
|
+
"delivered",
|
|
418
|
+
"delivery",
|
|
419
|
+
"disabled",
|
|
420
|
+
"discount",
|
|
421
|
+
"edit",
|
|
422
|
+
"email",
|
|
423
|
+
"empty",
|
|
424
|
+
"external",
|
|
425
|
+
"filter",
|
|
426
|
+
"geolocation",
|
|
427
|
+
"gift-card",
|
|
428
|
+
"globe",
|
|
429
|
+
"grid",
|
|
430
|
+
"image",
|
|
431
|
+
"info",
|
|
432
|
+
"info-filled",
|
|
433
|
+
"list-bulleted",
|
|
434
|
+
"location",
|
|
435
|
+
"lock",
|
|
436
|
+
"map",
|
|
437
|
+
"menu",
|
|
438
|
+
"menu-horizontal",
|
|
439
|
+
"menu-vertical",
|
|
440
|
+
"minus",
|
|
441
|
+
"mobile",
|
|
442
|
+
"note",
|
|
443
|
+
"order",
|
|
444
|
+
"organization",
|
|
445
|
+
"plus",
|
|
446
|
+
"profile",
|
|
447
|
+
"question-circle",
|
|
448
|
+
"question-circle-filled",
|
|
449
|
+
"reorder",
|
|
450
|
+
"reset",
|
|
451
|
+
"return",
|
|
452
|
+
"savings",
|
|
453
|
+
"search",
|
|
454
|
+
"settings",
|
|
455
|
+
"star",
|
|
456
|
+
"star-filled",
|
|
457
|
+
"star-half",
|
|
458
|
+
"store",
|
|
459
|
+
"truck",
|
|
460
|
+
"upload",
|
|
461
|
+
"x",
|
|
462
|
+
"x-circle",
|
|
463
|
+
"x-circle-filled"
|
|
464
|
+
];
|
|
465
|
+
var IconName = freezeEnum(iconNames);
|
|
466
|
+
var iconSizes = ["base", "large", "large-100", "small", "small-100", "small-200"];
|
|
467
|
+
var IconSize = freezeEnum(iconSizes);
|
|
468
|
+
var iconTones = ["auto", "critical", "custom", "info", "neutral", "success", "warning"];
|
|
469
|
+
var IconTone = freezeEnum(iconTones);
|
|
470
|
+
|
|
365
471
|
// src/schema/widgets/checkout-and-beyond/image.ts
|
|
366
|
-
var
|
|
472
|
+
var CABImageSectionFields = z5.object({
|
|
367
473
|
altText: z5.string().refine(checkForHTML, NO_HTML).default(""),
|
|
368
|
-
|
|
474
|
+
/**
|
|
475
|
+
* Image width÷height (e.g. `46` for the progress-bar fill); `null` renders at natural size. Any POSITIVE
|
|
476
|
+
* ratio — never limited to 1, but never `0`/negative either: a renderer dividing by it would get `Infinity`,
|
|
477
|
+
* and CSS `aspect-ratio` drops a negative value and silently reverts to natural size.
|
|
478
|
+
*/
|
|
479
|
+
aspectRatio: z5.number().positive().nullable().default(null),
|
|
369
480
|
border: z5.lazy(() => CABBorder),
|
|
370
481
|
buttonField: z5.enum(buttonFields).optional(),
|
|
371
|
-
|
|
482
|
+
/**
|
|
483
|
+
* `icon` renders `source` as a single `s-icon` by name (the uber-image path covers icons too), reading
|
|
484
|
+
* `iconSize`/`iconTone`. The other values are a harmless informational holdover from the previous
|
|
485
|
+
* implementation — they were never significant to rendering (`icons`, plural, is NOT deprecated, just one of
|
|
486
|
+
* those inert legacy tags); `icon` is the first value that means anything.
|
|
487
|
+
*
|
|
488
|
+
* INVARIANT, encoded by the `.superRefine` below (a refined object IS a valid `z.discriminatedUnion` member
|
|
489
|
+
* in zod 4 — see `CABTextSection`): `category: 'icon'` ⇒ `source` is an icon name or `''` (icon not yet
|
|
490
|
+
* chosen); any other category ⇒ `source` is NOT a bare icon name, so it stays a URL/token/`''`.
|
|
491
|
+
*
|
|
492
|
+
* Encoded rather than left to the renderer because `source` is ONE union with no category gate, so widening
|
|
493
|
+
* it with `iconNames` also widened what a STORED payload may contain: 14 of the names are plain English
|
|
494
|
+
* words (`image`, `x`, `search`, `note`, `order`, `globe`, …), and a legacy `source: 'image'` used to fail
|
|
495
|
+
* parse — which `salvageSections` turns into a null-rendering stub PLUS a drift report. Ungated it would
|
|
496
|
+
* instead parse and reach the renderer as `<img src="image">`: a broken image, silently, where the old
|
|
497
|
+
* behavior degraded gracefully and told us about it. The client-assembled half of the invariant was never
|
|
498
|
+
* the risky half.
|
|
499
|
+
*/
|
|
500
|
+
category: z5.enum(["gallery", "icon", "icons", "payment-methods", "secure-checkout"]).nullable().default(null),
|
|
501
|
+
/** `icon`-mode only: the `s-icon` `size`; `null` ⇒ the component default (`base`). Ignored by image treatments. */
|
|
502
|
+
iconSize: z5.enum(iconSizes).nullable().default(null),
|
|
503
|
+
/** `icon`-mode only: the `s-icon` `tone`; `null` ⇒ the component default (`auto`). Ignored by image treatments. */
|
|
504
|
+
iconTone: z5.enum(iconTones).nullable().default(null),
|
|
372
505
|
name: z5.string().optional(),
|
|
373
506
|
naturalHeight: z5.number().default(0),
|
|
374
507
|
naturalWidth: z5.number().default(0),
|
|
@@ -380,9 +513,31 @@ var CABImageSection = z5.object({
|
|
|
380
513
|
rule: CABRule.optional(),
|
|
381
514
|
sectionId: z5.uuid().default(() => uuidv7()),
|
|
382
515
|
sectionType: z5.literal(SectionType.image).default(SectionType.image),
|
|
383
|
-
|
|
516
|
+
/**
|
|
517
|
+
* An image URL or dynamic token, an empty default, or — when `category: 'icon'` — an icon NAME. Icon mode
|
|
518
|
+
* takes a name or `''` only, NOT a token: no renderer resolves a token to an icon today, so accepting one
|
|
519
|
+
* would promise a capability that doesn't exist. Widen the refine's carve-out to `DYNAMIC_TOKEN_REGEX` when a
|
|
520
|
+
* server-chosen tier icon actually needs it.
|
|
521
|
+
*/
|
|
522
|
+
source: z5.union([z5.url(), z5.literal(""), z5.string().regex(DYNAMIC_TOKEN_REGEX), z5.enum(iconNames)]).default(""),
|
|
384
523
|
width: z5.number().default(100)
|
|
385
524
|
});
|
|
525
|
+
var iconNameSet = new Set(iconNames);
|
|
526
|
+
var isIconName = (source) => iconNameSet.has(source);
|
|
527
|
+
var CABImageSection = CABImageSectionFields.superRefine(({ category, source }, ctx) => {
|
|
528
|
+
if (category === "icon" && source !== "" && !isIconName(source))
|
|
529
|
+
ctx.addIssue({
|
|
530
|
+
code: "custom",
|
|
531
|
+
message: "icon-mode source must be an icon name",
|
|
532
|
+
path: ["source"]
|
|
533
|
+
});
|
|
534
|
+
if (category !== "icon" && isIconName(source))
|
|
535
|
+
ctx.addIssue({
|
|
536
|
+
code: "custom",
|
|
537
|
+
message: "source must be a URL or dynamic token unless category is `icon`",
|
|
538
|
+
path: ["source"]
|
|
539
|
+
});
|
|
540
|
+
});
|
|
386
541
|
|
|
387
542
|
// src/schema/widgets/checkout-and-beyond/text.ts
|
|
388
543
|
import { forEach, isString as isString2 } from "es-toolkit/compat";
|
|
@@ -502,6 +657,21 @@ var CABButtonSection = z7.object({
|
|
|
502
657
|
sectionId: z7.uuid().default(() => uuidv73()),
|
|
503
658
|
sections: z7.union([z7.array(CABButtonContent), z7.strictObject({}).transform(() => [])]).default(() => []),
|
|
504
659
|
sectionType: z7.literal(SectionType.button).default(SectionType.button),
|
|
660
|
+
/**
|
|
661
|
+
* The smart-cart tier this button acts on (`addGift`/`removeGift`): scopes the click to one tier's gift. The
|
|
662
|
+
* client resolves the tier's gift (productId) from the progress-bar context by this `tierId` — the button node
|
|
663
|
+
* stays data, no bespoke per-tier wiring. Absent on non-gift buttons (offer add/remove, navigation, links).
|
|
664
|
+
*
|
|
665
|
+
* Deliberately NOT `CABTextTier` (the shape `CABTextSection.tier` uses): a gift button acts on a tier the bar
|
|
666
|
+
* already resolved, so it needs the id and nothing else. Reusing the text tier would make `threshold`
|
|
667
|
+
* required, leave `tierId` optional, and DEFAULT `tierType` to `'shipping'` — a schema-supplied wrong answer
|
|
668
|
+
* on a gift button. Unknown keys are stripped, so a client spreading a whole tier in still parses.
|
|
669
|
+
*
|
|
670
|
+
* `.min(1)` because an empty id IS the silently-id-less state this shape exists to prevent: the client's
|
|
671
|
+
* lookup finds no tier and the click resolves to nothing. Safe to bound — the field is new, so there are no
|
|
672
|
+
* stored payloads to grandfather, and the producer is client code, not a merchant form.
|
|
673
|
+
*/
|
|
674
|
+
tier: z7.object({ tierId: z7.string().min(1) }).optional(),
|
|
505
675
|
/** Fire-and-forget pixel POSTed when the button is clicked (e.g. a Monetize decline). */
|
|
506
676
|
trackingUrl: z7.string().optional()
|
|
507
677
|
});
|
|
@@ -797,8 +967,12 @@ var CABProgressTier = z16.object({
|
|
|
797
967
|
}).optional(),
|
|
798
968
|
/**
|
|
799
969
|
* The step-row label at this tier's slot (onsite `getTierLabel`): the merchant custom label, else the
|
|
800
|
-
* type default
|
|
801
|
-
*
|
|
970
|
+
* type default — 'Free Shipping' or '{n}% Discount'. A PRODUCT tier gets NO converter label: its name is
|
|
971
|
+
* the gift PRODUCT title, which the converter can't supply (config carries only product IDs), so the
|
|
972
|
+
* client resolves it (authoritative Shopify title, React parity) with its own localized generic fallback.
|
|
973
|
+
* Localized content; absent OR blank ⇒ no label under the tier's icon (the converter's `toTierMeta` already
|
|
974
|
+
* turns a blank label into an absent key, and a client-authored blank means the same thing — the renderer
|
|
975
|
+
* emits no caption slot rather than an empty one). Plain text — a compact icon+label.
|
|
802
976
|
*/
|
|
803
977
|
label: z16.record(z16.string(), z16.string()).optional(),
|
|
804
978
|
/**
|