@rebuy/rebuy 3.34.0 → 3.36.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 +1003 -801
- package/dist/index.mjs +1005 -803
- package/dist/schema/index.d.ts +8 -0
- package/dist/schema/postPurchaseGroup.d.ts +15 -0
- package/dist/schema/postPurchaseGroupCatalog.d.ts +56 -0
- package/dist/schema/postPurchaseOfferEligibility.d.ts +32 -0
- package/dist/schema/postPurchaseOfferPresentation.d.ts +386 -0
- package/dist/schema/postPurchaseProduct.d.ts +74 -24
- package/dist/schema/postPurchaseProductCalculation.d.ts +87 -0
- package/dist/schema/postPurchaseProductCollectionView.d.ts +724 -3
- package/dist/schema/postPurchaseProductDisplay.d.ts +41 -12
- package/dist/schema/postPurchaseProductSource.d.ts +10 -5
- package/dist/schema/postPurchaseProductView.d.ts +708 -0
- package/dist/schema/postPurchaseQuantity.d.ts +26 -0
- package/dist/schema/postPurchaseSubscriptionProduct.d.ts +74 -17
- package/dist/schema/postPurchaseVariantDefault.d.ts +17 -0
- package/dist/schema/postPurchaseVariantDefaultContext.d.ts +10 -0
- package/dist/server/__fixtures__/postPurchaseGroup.d.ts +78 -0
- package/dist/server/classifyPostPurchaseOffer.d.ts +3 -0
- package/dist/server/createPostPurchaseOrderAttributes.d.ts +9 -0
- package/dist/server/index.cjs +1131 -210
- package/dist/server/index.d.ts +20 -2
- package/dist/server/index.mjs +1131 -210
- package/dist/server/postPurchaseMemberEligibility.d.ts +7 -0
- package/dist/server/postPurchaseOfferCopy.d.ts +3 -0
- package/dist/server/postPurchaseProductDisplay.d.ts +38 -6
- package/dist/server/postPurchaseProductEligibility.d.ts +3 -7
- package/dist/server/postPurchaseSubscriptionEligibility.d.ts +2 -3
- package/dist/server/prepareNormalizedSubscription.d.ts +2 -3
- package/dist/server/preparePostPurchaseAdmissionView.d.ts +418 -0
- package/dist/server/preparePostPurchaseCollectionGroup.d.ts +458 -0
- package/dist/server/preparePostPurchaseCollectionView.d.ts +442 -0
- package/dist/server/preparePostPurchaseGroupAdmissionView.d.ts +459 -0
- package/dist/server/preparePostPurchaseGroupDeclineDisplay.d.ts +12 -0
- package/dist/server/preparePostPurchaseGroupDefault.d.ts +459 -0
- package/dist/server/preparePostPurchaseGroupView.d.ts +458 -0
- package/dist/server/preparePostPurchaseMemberView.d.ts +1466 -0
- package/dist/server/preparePostPurchaseOfferPresentation.d.ts +137 -0
- package/dist/server/preparePostPurchaseProduct.d.ts +11 -0
- package/dist/server/preparePostPurchaseQuantityAdmissionView.d.ts +440 -0
- package/dist/server/preparePostPurchaseQuantityView.d.ts +427 -0
- package/dist/server/preparePostPurchaseSubscription.d.ts +37 -5
- package/dist/server/preparePostPurchaseView.d.ts +8 -0
- package/dist/server/projectPostPurchaseProduct.d.ts +42 -12
- package/dist/server/readPostPurchaseGroup.d.ts +101 -0
- package/dist/server/readPostPurchaseGroupSelection.d.ts +110 -0
- package/dist/server/readPostPurchaseQuantity.d.ts +27 -0
- package/dist/server/resolvePostPurchaseMemberDefault.d.ts +8 -0
- package/dist/server/selectPostPurchaseChoice.d.ts +2 -3
- package/dist/transforms/postPurchase/convertDescriptionRte.d.ts +11 -0
- package/package.json +1 -1
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { PostPurchaseGroupSelection } from '../schema/postPurchaseGroupCatalog';
|
|
2
|
+
import type { PostPurchaseExcludedProductIds } from '../schema/postPurchaseProductCollectionView';
|
|
3
|
+
/** Validated association and representative facts only; this reader grants no financial permission. */
|
|
4
|
+
export declare const readPostPurchaseGroupSelection: (settings: unknown, response: unknown, requested: PostPurchaseGroupSelection, excludedProductIds?: PostPurchaseExcludedProductIds) => {
|
|
5
|
+
groupCatalog: {
|
|
6
|
+
memberProductId: number;
|
|
7
|
+
options: {
|
|
8
|
+
productId: number;
|
|
9
|
+
title: string;
|
|
10
|
+
variantCatalog: {
|
|
11
|
+
displayMode: "single" | "separate";
|
|
12
|
+
options: {
|
|
13
|
+
name: string;
|
|
14
|
+
values: string[];
|
|
15
|
+
id: number;
|
|
16
|
+
position: number;
|
|
17
|
+
}[];
|
|
18
|
+
productId: number;
|
|
19
|
+
showSelectors: boolean;
|
|
20
|
+
variants: {
|
|
21
|
+
available: boolean;
|
|
22
|
+
id: number;
|
|
23
|
+
title: string;
|
|
24
|
+
option1?: string | undefined;
|
|
25
|
+
option2?: string | null | undefined;
|
|
26
|
+
option3?: string | null | undefined;
|
|
27
|
+
imageId?: number | null | undefined;
|
|
28
|
+
}[];
|
|
29
|
+
};
|
|
30
|
+
}[];
|
|
31
|
+
};
|
|
32
|
+
memberProductId: number;
|
|
33
|
+
productIndex: number;
|
|
34
|
+
reportingProduct: {
|
|
35
|
+
id: number;
|
|
36
|
+
title: string;
|
|
37
|
+
};
|
|
38
|
+
response: {
|
|
39
|
+
data: {
|
|
40
|
+
images: {
|
|
41
|
+
id: number;
|
|
42
|
+
src: string;
|
|
43
|
+
alt?: string | undefined;
|
|
44
|
+
}[] | null | undefined;
|
|
45
|
+
productGroupVariants: never[];
|
|
46
|
+
variants: {
|
|
47
|
+
title: string;
|
|
48
|
+
compareAtPrice: string | null;
|
|
49
|
+
id: number;
|
|
50
|
+
inventoryManagement: string | null;
|
|
51
|
+
inventoryPolicy: string;
|
|
52
|
+
inventoryQuantity: number;
|
|
53
|
+
price: string;
|
|
54
|
+
productId: number;
|
|
55
|
+
imageId?: number | null | undefined;
|
|
56
|
+
option1?: unknown;
|
|
57
|
+
option2?: unknown;
|
|
58
|
+
option3?: unknown;
|
|
59
|
+
sellingPlanAllocations?: unknown;
|
|
60
|
+
}[];
|
|
61
|
+
id: number;
|
|
62
|
+
title: string;
|
|
63
|
+
description: string | null;
|
|
64
|
+
image: {
|
|
65
|
+
src: string;
|
|
66
|
+
} | null;
|
|
67
|
+
options: {
|
|
68
|
+
name: string;
|
|
69
|
+
values: string[];
|
|
70
|
+
id: number;
|
|
71
|
+
position: number;
|
|
72
|
+
}[];
|
|
73
|
+
sellingPlanGroups: {
|
|
74
|
+
requiresSellingPlan: boolean;
|
|
75
|
+
discountAmount?: unknown;
|
|
76
|
+
discountType?: unknown;
|
|
77
|
+
id?: unknown;
|
|
78
|
+
sellingPlans?: unknown;
|
|
79
|
+
}[];
|
|
80
|
+
metadata?: {
|
|
81
|
+
productQuantity?: number | undefined;
|
|
82
|
+
} | undefined;
|
|
83
|
+
metafields?: unknown;
|
|
84
|
+
selectedVariant?: unknown;
|
|
85
|
+
}[];
|
|
86
|
+
metadata: {
|
|
87
|
+
widget: Record<string, unknown>;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
variantCatalog: {
|
|
91
|
+
displayMode: "single" | "separate";
|
|
92
|
+
options: {
|
|
93
|
+
name: string;
|
|
94
|
+
values: string[];
|
|
95
|
+
id: number;
|
|
96
|
+
position: number;
|
|
97
|
+
}[];
|
|
98
|
+
productId: number;
|
|
99
|
+
showSelectors: boolean;
|
|
100
|
+
variants: {
|
|
101
|
+
available: boolean;
|
|
102
|
+
id: number;
|
|
103
|
+
title: string;
|
|
104
|
+
option1?: string | undefined;
|
|
105
|
+
option2?: string | null | undefined;
|
|
106
|
+
option3?: string | null | undefined;
|
|
107
|
+
imageId?: number | null | undefined;
|
|
108
|
+
}[];
|
|
109
|
+
};
|
|
110
|
+
} | null;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { normalizePostPurchaseProduct } from '../server/normalizePostPurchaseProduct';
|
|
2
|
+
/** The configured policy is valid, but this selection cannot be prepared. */
|
|
3
|
+
export declare class PostPurchaseQuantityUnavailable extends Error {
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* The initial quantity is the first product's metadata override, else the original picker default (1 when the
|
|
7
|
+
* picker is off; empty data has no override), and is never clamped; an explicit buyer choice must satisfy
|
|
8
|
+
* today's effective bounds. The metadata override is flagged new behaviour (decision 15, L82): legacy's schema
|
|
9
|
+
* stripped it. An admission's
|
|
10
|
+
* `expectedQuantity` equal to the initial quantity is identity, not a new choice. A disabled picker's
|
|
11
|
+
* configured default and bounds are ignored, as legacy ignored them: its policy is fixed at the initial
|
|
12
|
+
* quantity, so leftover junk such as a `null` minimum cannot refuse the Offer.
|
|
13
|
+
*/
|
|
14
|
+
export declare const readPostPurchaseQuantity: ({ data, effective, original, }: Pick<ReturnType<typeof normalizePostPurchaseProduct>, "data" | "effective" | "original">, selection: {
|
|
15
|
+
quantity: number | undefined;
|
|
16
|
+
} | {
|
|
17
|
+
expectedQuantity: number;
|
|
18
|
+
}) => {
|
|
19
|
+
policy: {
|
|
20
|
+
enabled: boolean;
|
|
21
|
+
initialQuantity: number;
|
|
22
|
+
maxValue: number;
|
|
23
|
+
minValue: number;
|
|
24
|
+
};
|
|
25
|
+
quantity: number;
|
|
26
|
+
};
|
|
27
|
+
export type PostPurchaseQuantity = ReturnType<typeof readPostPurchaseQuantity>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PostPurchaseVariantDefaultContext } from '../schema/postPurchaseVariantDefaultContext';
|
|
2
|
+
import type { normalizePostPurchaseProduct } from '../server/normalizePostPurchaseProduct';
|
|
3
|
+
/**
|
|
4
|
+
* Matching alone consumes original attributes; recommendation and explicit preselection need no enrichment. Absent
|
|
5
|
+
* enrichment (rebuy-api's line-item read is optional) skips matching and keeps the unmatched default; present but
|
|
6
|
+
* malformed enrichment still throws.
|
|
7
|
+
*/
|
|
8
|
+
export declare const resolvePostPurchaseMemberDefault: (product: ReturnType<typeof normalizePostPurchaseProduct>["data"][number], original: ReturnType<typeof normalizePostPurchaseProduct>["original"], context: PostPurchaseVariantDefaultContext) => number;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { type PostPurchaseChoice } from '../schema/postPurchaseChoice';
|
|
2
2
|
import type { PostPurchasePlanCatalog } from '../schema/postPurchasePlanCatalog';
|
|
3
3
|
import type { normalizePostPurchaseProduct } from '../server/normalizePostPurchaseProduct';
|
|
4
|
+
import type { PostPurchaseQuantity } from '../server/readPostPurchaseQuantity';
|
|
4
5
|
/**
|
|
5
6
|
* Catalog inspection is not authority; the chosen mode still passes its complete preparation guards. A catalog
|
|
6
7
|
* projected for another product or variant is treated as absent, so a stale catalog never lends its plans.
|
|
7
8
|
*/
|
|
8
|
-
export declare const selectPostPurchaseChoice: (normalized: ReturnType<typeof normalizePostPurchaseProduct>, projected: PostPurchasePlanCatalog | null, requested: PostPurchaseChoice | undefined, allowCollection: boolean, quantity?: {
|
|
9
|
-
quantity: number;
|
|
10
|
-
}) => {
|
|
9
|
+
export declare const selectPostPurchaseChoice: (normalized: ReturnType<typeof normalizePostPurchaseProduct>, projected: PostPurchasePlanCatalog | null, requested: PostPurchaseChoice | undefined, allowCollection: boolean, quantity?: PostPurchaseQuantity) => {
|
|
11
10
|
choice: undefined;
|
|
12
11
|
options: undefined;
|
|
13
12
|
plan: undefined;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TiptapDocument } from '../../schema/widgets/checkout-and-beyond/text';
|
|
2
|
+
import { type PostPurchaseSettings } from '../../schema/widgets/post-purchase-offer/postPurchaseSettings';
|
|
3
|
+
type Language = PostPurchaseSettings['language'];
|
|
4
|
+
/**
|
|
5
|
+
* Converts the post-purchase editor's custom `descriptionRte` (the first Tiptap attempt: `ShopifyTextBlock`
|
|
6
|
+
* nodes and one `ShopifyTextInline` mark) into the standard CAB `TiptapDocument`, so renderers draw one shape.
|
|
7
|
+
* The legacy renderer drew only `ShopifyTextBlock`/`text`, so any other node is dropped; an empty block stays
|
|
8
|
+
* an empty paragraph (legacy drew it as a blank line); a missing spacing is legacy's `none`.
|
|
9
|
+
*/
|
|
10
|
+
export declare const convertDescriptionRte: (rte: NonNullable<Language["descriptionRte"]>, spacing: Language["descriptionSpacing"]) => TiptapDocument;
|
|
11
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebuy/rebuy",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.36.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.",
|