@rebuy/rebuy 3.60.5 → 3.62.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.cjs +37 -6
- package/dist/index.mjs +37 -6
- package/dist/schema/cabShopConfig.d.ts +9 -5
- package/dist/schema/checkout-and-beyond/index.cjs +11 -1
- package/dist/schema/checkout-and-beyond/index.mjs +11 -1
- package/dist/schema/smartCart.d.ts +104 -6
- package/dist/schema/user-config.cjs +24 -4
- package/dist/schema/user-config.mjs +24 -4
- package/dist/schema/userConfig.d.ts +6 -3
- package/dist/schema/widget-data.cjs +11 -1
- package/dist/schema/widget-data.mjs +11 -1
- package/dist/schema/widgets/checkout-and-beyond/common.d.ts +1 -1
- package/dist/schema/widgets/checkout-and-beyond/progressBar.d.ts +18 -8
- package/dist/server/index.cjs +80 -39
- package/dist/server/index.mjs +80 -39
- package/dist/server/postPurchaseProductEligibility.d.ts +2 -1
- package/dist/server/postPurchaseSubscriptionEligibility.d.ts +2 -1
- package/dist/server/postPurchaseUnavailableChoice.d.ts +43 -10
- package/dist/server/prepareNormalizedSubscription.d.ts +2 -2
- package/dist/server/preparePostPurchaseCollectionGroup.d.ts +141 -0
- package/dist/server/preparePostPurchaseProduct.d.ts +2 -1
- package/dist/server/preparePostPurchaseView.d.ts +1 -1
- package/dist/server/selectPostPurchaseChoice.d.ts +8 -2
- package/dist/server/shared.d.ts +6 -6
- package/dist/transforms/index.cjs +21 -3
- package/dist/transforms/index.mjs +21 -3
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PostPurchasePlanOption } from '../schema/postPurchasePlanCatalog';
|
|
2
|
-
import { type PostPurchasePreparation } from '../schema/postPurchaseProduct';
|
|
3
2
|
import type { normalizePostPurchaseProduct } from '../server/normalizePostPurchaseProduct';
|
|
3
|
+
import { type LeveledPostPurchasePreparation } from '../server/postPurchaseUnavailableChoice';
|
|
4
4
|
import type { PostPurchaseQuantity } from '../server/readPostPurchaseQuantity';
|
|
5
5
|
import type { Reporter } from '../server/shared';
|
|
6
6
|
/**
|
|
@@ -8,4 +8,4 @@ import type { Reporter } from '../server/shared';
|
|
|
8
8
|
* unreadable-review drift. A switch to subscription (STS) charges no initial shipping, only the recurring
|
|
9
9
|
* shipping (legacy `useSubscriptionPurchaseOptions`, L112/L122).
|
|
10
10
|
*/
|
|
11
|
-
export declare const prepareNormalizedSubscription: (normalized: ReturnType<typeof normalizePostPurchaseProduct>, report: Reporter | undefined, plan: PostPurchasePlanOption | undefined, quantity?: PostPurchaseQuantity, allowCollection?: boolean) =>
|
|
11
|
+
export declare const prepareNormalizedSubscription: (normalized: ReturnType<typeof normalizePostPurchaseProduct>, report: Reporter | undefined, plan: PostPurchasePlanOption | undefined, quantity?: PostPurchaseQuantity, allowCollection?: boolean) => LeveledPostPurchasePreparation;
|
|
@@ -647,6 +647,147 @@ export declare const preparePostPurchaseCollectionGroup: (widgetId: number, sett
|
|
|
647
647
|
notAvailable: string;
|
|
648
648
|
};
|
|
649
649
|
preparation: {
|
|
650
|
+
display: {
|
|
651
|
+
discountedFrom: "price" | "compare_at_price";
|
|
652
|
+
language: {
|
|
653
|
+
description: string;
|
|
654
|
+
descriptionEnabled: boolean;
|
|
655
|
+
};
|
|
656
|
+
primaryImage: {
|
|
657
|
+
description: string;
|
|
658
|
+
source: string;
|
|
659
|
+
};
|
|
660
|
+
productOptions: {
|
|
661
|
+
showShipping: boolean;
|
|
662
|
+
showSubtotal: boolean;
|
|
663
|
+
showTaxes: boolean;
|
|
664
|
+
showTotal: boolean;
|
|
665
|
+
showVariantSelectors: boolean;
|
|
666
|
+
showDeclineAll?: "none" | "both" | "above" | "below" | undefined;
|
|
667
|
+
};
|
|
668
|
+
responseDescription: string;
|
|
669
|
+
reviews: {
|
|
670
|
+
color: string;
|
|
671
|
+
rating: number;
|
|
672
|
+
reviewCount: number;
|
|
673
|
+
reviewsPlural: string;
|
|
674
|
+
reviewsSingular: string;
|
|
675
|
+
size: "small" | "large" | "medium";
|
|
676
|
+
strokeColor: string;
|
|
677
|
+
strokeWidth: number;
|
|
678
|
+
} | null;
|
|
679
|
+
shouldShowSavingText: boolean;
|
|
680
|
+
descriptionDocument?: {
|
|
681
|
+
attrs: {
|
|
682
|
+
blockSpacing?: "none" | "base" | "extraTight" | "tight" | "loose" | "extraLoose" | undefined;
|
|
683
|
+
};
|
|
684
|
+
content: never[] | {
|
|
685
|
+
attrs: {
|
|
686
|
+
textAlign?: "start" | "center" | "end" | undefined;
|
|
687
|
+
};
|
|
688
|
+
content: never[] | {
|
|
689
|
+
text: string;
|
|
690
|
+
type: "text";
|
|
691
|
+
marks?: never[] | ({
|
|
692
|
+
type: "bold";
|
|
693
|
+
} | {
|
|
694
|
+
type: "italic";
|
|
695
|
+
} | {
|
|
696
|
+
attrs: {
|
|
697
|
+
class: string | null;
|
|
698
|
+
href: string;
|
|
699
|
+
rel: string;
|
|
700
|
+
target: string;
|
|
701
|
+
};
|
|
702
|
+
type: "link";
|
|
703
|
+
} | {
|
|
704
|
+
type: "strike";
|
|
705
|
+
} | {
|
|
706
|
+
attrs: {
|
|
707
|
+
color: "success" | "warning" | "critical" | "base" | "decorative" | "subdued" | "accent";
|
|
708
|
+
fontSize: "small" | "base" | "large" | "medium" | "extraSmall" | "extraLarge" | "heading";
|
|
709
|
+
};
|
|
710
|
+
type: "textStyle";
|
|
711
|
+
})[] | undefined;
|
|
712
|
+
}[];
|
|
713
|
+
type: "paragraph";
|
|
714
|
+
}[];
|
|
715
|
+
type: "doc";
|
|
716
|
+
} | undefined;
|
|
717
|
+
gallery?: {
|
|
718
|
+
images: {
|
|
719
|
+
description: string;
|
|
720
|
+
id: number;
|
|
721
|
+
source: string;
|
|
722
|
+
thumbnail: string;
|
|
723
|
+
}[];
|
|
724
|
+
hasMultiple?: boolean | undefined;
|
|
725
|
+
selectedImageId?: number | undefined;
|
|
726
|
+
} | undefined;
|
|
727
|
+
};
|
|
728
|
+
labels: {
|
|
729
|
+
declineAll: string;
|
|
730
|
+
free: string;
|
|
731
|
+
notAvailable: string;
|
|
732
|
+
payNow: string;
|
|
733
|
+
quantity: string;
|
|
734
|
+
recurringShipping: string;
|
|
735
|
+
recurringSubtotal: string;
|
|
736
|
+
save: string;
|
|
737
|
+
shipping: string;
|
|
738
|
+
subtotal: string;
|
|
739
|
+
taxes: string;
|
|
740
|
+
total: string;
|
|
741
|
+
};
|
|
742
|
+
product: {
|
|
743
|
+
title: string;
|
|
744
|
+
id: number;
|
|
745
|
+
variant: {
|
|
746
|
+
title: string;
|
|
747
|
+
compareAtPrice: string | null;
|
|
748
|
+
id: number;
|
|
749
|
+
price: string;
|
|
750
|
+
};
|
|
751
|
+
image?: {
|
|
752
|
+
src: string;
|
|
753
|
+
} | null | undefined;
|
|
754
|
+
description?: string | null | undefined;
|
|
755
|
+
};
|
|
756
|
+
selection: {
|
|
757
|
+
productId: number;
|
|
758
|
+
quantity: number;
|
|
759
|
+
variantId: number;
|
|
760
|
+
sellingPlanId?: number | undefined;
|
|
761
|
+
};
|
|
762
|
+
status: "prepared";
|
|
763
|
+
terms: {
|
|
764
|
+
discount: {
|
|
765
|
+
amount: number;
|
|
766
|
+
title: string;
|
|
767
|
+
type: "none" | "fixed_amount" | "percentage";
|
|
768
|
+
};
|
|
769
|
+
shipping: {
|
|
770
|
+
amount: number;
|
|
771
|
+
title: string;
|
|
772
|
+
type: "fixed_amount" | "free";
|
|
773
|
+
};
|
|
774
|
+
subscription?: {
|
|
775
|
+
initialShippingPrice: number;
|
|
776
|
+
intervalLabel: string;
|
|
777
|
+
name: string;
|
|
778
|
+
recurringShippingPrice: number;
|
|
779
|
+
shippingOption: {
|
|
780
|
+
presentmentTitle: string;
|
|
781
|
+
title: string;
|
|
782
|
+
};
|
|
783
|
+
adjustment?: {
|
|
784
|
+
amount: number;
|
|
785
|
+
type: "price" | "fixed_amount" | "percentage";
|
|
786
|
+
} | undefined;
|
|
787
|
+
sts?: true | undefined;
|
|
788
|
+
} | undefined;
|
|
789
|
+
};
|
|
790
|
+
} | {
|
|
650
791
|
reason: string;
|
|
651
792
|
status: "unsupported";
|
|
652
793
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { type PostPurchasePreparation } from '../schema/postPurchaseProduct';
|
|
2
2
|
import { normalizePostPurchaseProduct } from '../server/normalizePostPurchaseProduct';
|
|
3
|
+
import { type LeveledPostPurchasePreparation } from '../server/postPurchaseUnavailableChoice';
|
|
3
4
|
import type { PostPurchaseQuantity } from '../server/readPostPurchaseQuantity';
|
|
4
5
|
import type { Reporter } from '../server/shared';
|
|
5
6
|
/** The one-time sibling of `prepareNormalizedSubscription`; `report` receives unreadable-review drift. */
|
|
6
|
-
export declare const prepareNormalizedProduct: (normalized: ReturnType<typeof normalizePostPurchaseProduct>, report?: Reporter, quantity?: PostPurchaseQuantity, allowCollection?: boolean) =>
|
|
7
|
+
export declare const prepareNormalizedProduct: (normalized: ReturnType<typeof normalizePostPurchaseProduct>, report?: Reporter, quantity?: PostPurchaseQuantity, allowCollection?: boolean) => LeveledPostPurchasePreparation;
|
|
7
8
|
/** Pure preparation only: the authenticated caller owns selected-entry binding and session expiry. */
|
|
8
9
|
export declare const preparePostPurchaseProduct: (settings: unknown, response: unknown, report?: Reporter) => PostPurchasePreparation;
|
|
@@ -5,7 +5,7 @@ import type { PostPurchaseQuantity } from '../server/readPostPurchaseQuantity';
|
|
|
5
5
|
import type { Reporter } from '../server/shared';
|
|
6
6
|
/**
|
|
7
7
|
* Convert from the same effective settings snapshot; no product values enter the section tree. A choice-level
|
|
8
|
-
* unavailable product keeps its tree (`
|
|
8
|
+
* unavailable product keeps its tree (its `level` is `choice`); a configuration-level one answers `sections: null`.
|
|
9
9
|
*/
|
|
10
10
|
export declare const prepareNormalizedPostPurchaseView: (widgetId: number, normalized: ReturnType<typeof normalizePostPurchaseProduct>, report?: Reporter, choice?: PostPurchaseChoice, quantity?: PostPurchaseQuantity, allowCollection?: boolean) => PostPurchaseProductView;
|
|
11
11
|
export declare const preparePostPurchaseView: (widgetId: number, settings: unknown, response: unknown, report?: Reporter, choice?: PostPurchaseChoice) => PostPurchaseProductView;
|
|
@@ -10,7 +10,10 @@ export declare const selectPostPurchaseChoice: (normalized: ReturnType<typeof no
|
|
|
10
10
|
choice: undefined;
|
|
11
11
|
options: undefined;
|
|
12
12
|
plan: undefined;
|
|
13
|
-
|
|
13
|
+
unavailable: Readonly<{
|
|
14
|
+
level: "choice" | "configuration";
|
|
15
|
+
reason: string;
|
|
16
|
+
}>;
|
|
14
17
|
} | {
|
|
15
18
|
choice: {
|
|
16
19
|
mode: "one-time";
|
|
@@ -39,5 +42,8 @@ export declare const selectPostPurchaseChoice: (normalized: ReturnType<typeof no
|
|
|
39
42
|
discountPercentage?: number | undefined;
|
|
40
43
|
intervalFrequency?: string | undefined;
|
|
41
44
|
} | undefined;
|
|
42
|
-
|
|
45
|
+
unavailable: Readonly<{
|
|
46
|
+
level: "choice" | "configuration";
|
|
47
|
+
reason: string;
|
|
48
|
+
}> | undefined;
|
|
43
49
|
};
|
package/dist/server/shared.d.ts
CHANGED
|
@@ -11,12 +11,12 @@ export declare const REBUY_ENGINE_HOST = "rebuyengine.com";
|
|
|
11
11
|
* {@link UpstreamError} on a non-2xx response so orchestrators can interpret the status.
|
|
12
12
|
*
|
|
13
13
|
* Defaults to GET with `params`/`search` as the query string. `headers` apply regardless of method —
|
|
14
|
-
* implementations must not gate them behind a `method === 'POST'` branch.
|
|
15
|
-
*
|
|
16
|
-
* REB-
|
|
17
|
-
*
|
|
18
|
-
* future GET caller's headers can't silently drop.
|
|
19
|
-
* write-style calls like analytics ingest.
|
|
14
|
+
* implementations must not gate them behind a `method === 'POST'` branch. Both current library callers
|
|
15
|
+
* sending `headers` are POSTs: the analytics ingest and B2B availability, which forwards the buyer's session
|
|
16
|
+
* token as `Authorization` (REB-21688 moved market context off the REB-21102 headers onto engine params,
|
|
17
|
+
* retiring the GET+headers case and the test that witnessed it). So a POST-gated implementation would pass
|
|
18
|
+
* every test in this repo today; the invariant stands so a future GET caller's headers can't silently drop.
|
|
19
|
+
* Pass `method: 'POST'` with `body` (JSON body) for write-style calls like analytics ingest.
|
|
20
20
|
*/
|
|
21
21
|
export type UpstreamFetch = (path: string, params: Record<string, string>, options?: {
|
|
22
22
|
body?: unknown;
|
|
@@ -1146,7 +1146,17 @@ var GIFT_LABELS = {
|
|
|
1146
1146
|
// src/schema/widgets/checkout-and-beyond/progressBar.ts
|
|
1147
1147
|
var CABProgressTierExclusion = import_zod16.z.object({
|
|
1148
1148
|
collectionIds: import_zod16.z.array(import_zod16.z.number().int().positive()).default(() => []),
|
|
1149
|
-
|
|
1149
|
+
/**
|
|
1150
|
+
* `products` rules: each excluded product with ITS OWN variants, mirroring the bar-level
|
|
1151
|
+
* excluded products. An empty `variantIds` means "the whole product", which is how the admin
|
|
1152
|
+
* picker stores a whole-product selection, and a populated one means those variants.
|
|
1153
|
+
*/
|
|
1154
|
+
products: import_zod16.z.array(
|
|
1155
|
+
import_zod16.z.object({
|
|
1156
|
+
productId: import_zod16.z.number().int().positive(),
|
|
1157
|
+
variantIds: import_zod16.z.array(import_zod16.z.number().int().positive()).default(() => [])
|
|
1158
|
+
})
|
|
1159
|
+
).default(() => []),
|
|
1150
1160
|
tags: import_zod16.z.array(import_zod16.z.string().min(1)).default(() => []),
|
|
1151
1161
|
type: import_zod16.z.enum(progressTierExclusionTypes)
|
|
1152
1162
|
});
|
|
@@ -4875,13 +4885,21 @@ var giftOf = (tier) => {
|
|
|
4875
4885
|
variantIds: positiveIds(product.variantIds)
|
|
4876
4886
|
};
|
|
4877
4887
|
};
|
|
4878
|
-
var RULE_LIST = { collections: "collectionIds", products: "
|
|
4888
|
+
var RULE_LIST = { collections: "collectionIds", products: "products", tags: "tags" };
|
|
4889
|
+
var exclusionProducts = (rule) => (rule.products ?? []).flatMap((entry) => {
|
|
4890
|
+
const productId = entry.productId;
|
|
4891
|
+
if (!Number.isInteger(productId) || !productId || productId <= 0) return [];
|
|
4892
|
+
const requested = entry.variantIds ?? [];
|
|
4893
|
+
const variantIds = positiveIds(requested);
|
|
4894
|
+
if (requested.length > 0 && variantIds.length === 0) return [];
|
|
4895
|
+
return [{ productId, variantIds }];
|
|
4896
|
+
});
|
|
4879
4897
|
var exclusionsOf = (tier) => {
|
|
4880
4898
|
if (!tier.exclusionsEnabled) return void 0;
|
|
4881
4899
|
const rules = (tier.exclusions ?? []).flatMap((rule) => {
|
|
4882
4900
|
const parsed = CABProgressTierExclusion.safeParse({
|
|
4883
4901
|
...rule.type === "collections" && { collectionIds: positiveIds(rule.collectionIds) },
|
|
4884
|
-
...rule.type === "products" && {
|
|
4902
|
+
...rule.type === "products" && { products: exclusionProducts(rule) },
|
|
4885
4903
|
...rule.type === "tags" && { tags: (rule.tags ?? []).map((tag) => tag.trim()).filter(Boolean) },
|
|
4886
4904
|
type: rule.type
|
|
4887
4905
|
});
|
|
@@ -1085,7 +1085,17 @@ var GIFT_LABELS = {
|
|
|
1085
1085
|
// src/schema/widgets/checkout-and-beyond/progressBar.ts
|
|
1086
1086
|
var CABProgressTierExclusion = z16.object({
|
|
1087
1087
|
collectionIds: z16.array(z16.number().int().positive()).default(() => []),
|
|
1088
|
-
|
|
1088
|
+
/**
|
|
1089
|
+
* `products` rules: each excluded product with ITS OWN variants, mirroring the bar-level
|
|
1090
|
+
* excluded products. An empty `variantIds` means "the whole product", which is how the admin
|
|
1091
|
+
* picker stores a whole-product selection, and a populated one means those variants.
|
|
1092
|
+
*/
|
|
1093
|
+
products: z16.array(
|
|
1094
|
+
z16.object({
|
|
1095
|
+
productId: z16.number().int().positive(),
|
|
1096
|
+
variantIds: z16.array(z16.number().int().positive()).default(() => [])
|
|
1097
|
+
})
|
|
1098
|
+
).default(() => []),
|
|
1089
1099
|
tags: z16.array(z16.string().min(1)).default(() => []),
|
|
1090
1100
|
type: z16.enum(progressTierExclusionTypes)
|
|
1091
1101
|
});
|
|
@@ -4814,13 +4824,21 @@ var giftOf = (tier) => {
|
|
|
4814
4824
|
variantIds: positiveIds(product.variantIds)
|
|
4815
4825
|
};
|
|
4816
4826
|
};
|
|
4817
|
-
var RULE_LIST = { collections: "collectionIds", products: "
|
|
4827
|
+
var RULE_LIST = { collections: "collectionIds", products: "products", tags: "tags" };
|
|
4828
|
+
var exclusionProducts = (rule) => (rule.products ?? []).flatMap((entry) => {
|
|
4829
|
+
const productId = entry.productId;
|
|
4830
|
+
if (!Number.isInteger(productId) || !productId || productId <= 0) return [];
|
|
4831
|
+
const requested = entry.variantIds ?? [];
|
|
4832
|
+
const variantIds = positiveIds(requested);
|
|
4833
|
+
if (requested.length > 0 && variantIds.length === 0) return [];
|
|
4834
|
+
return [{ productId, variantIds }];
|
|
4835
|
+
});
|
|
4818
4836
|
var exclusionsOf = (tier) => {
|
|
4819
4837
|
if (!tier.exclusionsEnabled) return void 0;
|
|
4820
4838
|
const rules = (tier.exclusions ?? []).flatMap((rule) => {
|
|
4821
4839
|
const parsed = CABProgressTierExclusion.safeParse({
|
|
4822
4840
|
...rule.type === "collections" && { collectionIds: positiveIds(rule.collectionIds) },
|
|
4823
|
-
...rule.type === "products" && {
|
|
4841
|
+
...rule.type === "products" && { products: exclusionProducts(rule) },
|
|
4824
4842
|
...rule.type === "tags" && { tags: (rule.tags ?? []).map((tag) => tag.trim()).filter(Boolean) },
|
|
4825
4843
|
type: rule.type
|
|
4826
4844
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebuy/rebuy",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.62.0",
|
|
4
4
|
"description": "Shared zod schemas, legacy-to-CAB widget transforms, and server orchestrators for Rebuy's Shopify consumers (rebuy-api, admin-nextjs, rebuy-shopify-extensions)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Rebuy, Inc.",
|
|
@@ -136,7 +136,7 @@
|
|
|
136
136
|
"build:watch": "npm run clean && npm run build:types && node esbuild.config.mjs --watch",
|
|
137
137
|
"check:dist": "node scripts/verify-dist.mjs",
|
|
138
138
|
"check:node": "node scripts/assert-node-supported.mjs",
|
|
139
|
-
"check-types": "tsc --noEmit",
|
|
139
|
+
"check-types": "tsc --noEmit && tsc -p tsconfig.renderer.json",
|
|
140
140
|
"clean": "rm -rf dist",
|
|
141
141
|
"deploy": "npm run build && npx semantic-release --debug --no-ci",
|
|
142
142
|
"deploy:dryrun": "npm run deploy -- --dry-run",
|