@rebuy/rebuy 3.53.0 → 3.55.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/routes.cjs +1 -1
- package/dist/routes.d.ts +5 -3
- package/dist/routes.mjs +1 -1
- package/dist/schema/postPurchaseProductSource.d.ts +4 -1
- package/dist/server/index.cjs +475 -429
- package/dist/server/index.d.ts +3 -2
- package/dist/server/index.mjs +475 -429
- package/dist/server/normalizePostPurchaseCollection.d.ts +11 -2
- package/dist/server/normalizePostPurchaseProduct.d.ts +260 -1
- package/dist/server/postPurchasePlanCatalog.d.ts +5 -0
- package/dist/server/readPostPurchaseProductSource.d.ts +70 -0
- package/dist/server/shared.d.ts +2 -1
- package/package.json +1 -1
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { PostPurchaseExcludedProductIds } from '../schema/postPurchaseProductCollectionView';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import type { Reporter } from '../server/shared';
|
|
3
|
+
/**
|
|
4
|
+
* Preserve the original capped positions before applying product-wide exclusions. `productLimit` caps raw
|
|
5
|
+
* positions, and a member's `productIndex` is its raw position: a product the schema dropped leaves its slot
|
|
6
|
+
* empty rather than promoting a product past the cap or renumbering the members after it. A source that sent
|
|
7
|
+
* products under the cap but whose every one the schema dropped is unreadable data, not an empty catalog (a
|
|
8
|
+
* survivor past the cap does not count): it throws the drops' `ZodError`, paths from the source root, exactly
|
|
9
|
+
* as the whole-source schema failed it before salvage, so a consumer's validation reporting still names the
|
|
10
|
+
* field.
|
|
11
|
+
*/
|
|
12
|
+
export declare const normalizePostPurchaseCollection: (settings: unknown, response: unknown, excludedProductIds?: PostPurchaseExcludedProductIds, report?: Reporter) => {
|
|
4
13
|
members: {
|
|
5
14
|
product: {
|
|
6
15
|
title: string;
|
|
@@ -1,5 +1,264 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Reporter } from '../server/shared';
|
|
3
|
+
/**
|
|
4
|
+
* The normalized read plus each surviving product's raw `productIndex`, which a collection publishes as member
|
|
5
|
+
* identity. `data` holds only the products the shared schema accepts; `report` hears each dropped one as drift.
|
|
6
|
+
* `dropped` is each rejected product's raw `productIndex` and zod issues.
|
|
7
|
+
*/
|
|
8
|
+
export declare const normalizePostPurchaseSource: (settings: unknown, response: unknown, report?: Reporter) => {
|
|
9
|
+
dropped: {
|
|
10
|
+
issues: z.core.$ZodIssue[];
|
|
11
|
+
productIndex: number;
|
|
12
|
+
}[];
|
|
13
|
+
normalized: {
|
|
14
|
+
data: {
|
|
15
|
+
title: string;
|
|
16
|
+
id: number;
|
|
17
|
+
productGroupVariants: unknown[];
|
|
18
|
+
sellingPlanGroups: {
|
|
19
|
+
requiresSellingPlan: boolean;
|
|
20
|
+
discountAmount?: unknown;
|
|
21
|
+
discountType?: unknown;
|
|
22
|
+
id?: unknown;
|
|
23
|
+
sellingPlans?: unknown;
|
|
24
|
+
}[];
|
|
25
|
+
variants: {
|
|
26
|
+
title: string;
|
|
27
|
+
compareAtPrice: string | null;
|
|
28
|
+
id: number;
|
|
29
|
+
inventoryManagement: string | null;
|
|
30
|
+
inventoryPolicy: string;
|
|
31
|
+
inventoryQuantity: number;
|
|
32
|
+
price: string;
|
|
33
|
+
productId: number;
|
|
34
|
+
imageId?: number | null | undefined;
|
|
35
|
+
option1?: unknown;
|
|
36
|
+
option2?: unknown;
|
|
37
|
+
option3?: unknown;
|
|
38
|
+
sellingPlanAllocations?: unknown;
|
|
39
|
+
}[];
|
|
40
|
+
image?: {
|
|
41
|
+
src: string;
|
|
42
|
+
} | null | undefined;
|
|
43
|
+
description?: string | null | undefined;
|
|
44
|
+
images?: {
|
|
45
|
+
id: number;
|
|
46
|
+
src: string;
|
|
47
|
+
alt?: string | undefined;
|
|
48
|
+
}[] | null | undefined;
|
|
49
|
+
metadata?: {
|
|
50
|
+
productQuantity?: number | undefined;
|
|
51
|
+
} | undefined;
|
|
52
|
+
metafields?: unknown;
|
|
53
|
+
options?: unknown;
|
|
54
|
+
selectedVariant?: unknown;
|
|
55
|
+
}[];
|
|
56
|
+
effective: {
|
|
57
|
+
language: {
|
|
58
|
+
description: string;
|
|
59
|
+
descriptionEnabled: boolean;
|
|
60
|
+
displayCtaPrice: boolean;
|
|
61
|
+
global: {
|
|
62
|
+
declineAll: string;
|
|
63
|
+
declineThisOffer: string;
|
|
64
|
+
free: string;
|
|
65
|
+
notAvailable: string;
|
|
66
|
+
payNow: string;
|
|
67
|
+
payNowUpgradeToSubscription: string;
|
|
68
|
+
quantity: string;
|
|
69
|
+
recurringShipping: string;
|
|
70
|
+
recurringSubtotal: string;
|
|
71
|
+
reviewsPlural: string;
|
|
72
|
+
reviewsSingular: string;
|
|
73
|
+
save: string;
|
|
74
|
+
shipping: string;
|
|
75
|
+
subscriptionOption: string;
|
|
76
|
+
subtotal: string;
|
|
77
|
+
taxes: string;
|
|
78
|
+
total: string;
|
|
79
|
+
};
|
|
80
|
+
globalTranslation: string;
|
|
81
|
+
descriptionRte?: {
|
|
82
|
+
content: unknown[];
|
|
83
|
+
type: string;
|
|
84
|
+
} | undefined;
|
|
85
|
+
descriptionSpacing?: "default" | "none" | "tight" | "loose" | "xtight" | "xloose" | undefined;
|
|
86
|
+
};
|
|
87
|
+
productType: string;
|
|
88
|
+
discountedFrom: "price" | "compare_at_price";
|
|
89
|
+
productLimit: number;
|
|
90
|
+
productOptions: {
|
|
91
|
+
hideOutOfStockVariants: boolean;
|
|
92
|
+
matchVariant: boolean;
|
|
93
|
+
showShipping: boolean;
|
|
94
|
+
showSubtotal: boolean;
|
|
95
|
+
showTaxes: boolean;
|
|
96
|
+
showTotal: boolean;
|
|
97
|
+
showVariantSelectors: boolean;
|
|
98
|
+
variantSelectorDisplayMode: "single" | "separate";
|
|
99
|
+
showDeclineAll?: "none" | "both" | "above" | "below" | undefined;
|
|
100
|
+
};
|
|
101
|
+
productTypeSelector: "radio" | "dropdown";
|
|
102
|
+
quantityInputs: {
|
|
103
|
+
defaultQuantity: number;
|
|
104
|
+
enabled: boolean;
|
|
105
|
+
maxValue: number;
|
|
106
|
+
minValue: number;
|
|
107
|
+
};
|
|
108
|
+
upgradeToSubscription: {
|
|
109
|
+
acceptButtonText: string;
|
|
110
|
+
allow: boolean;
|
|
111
|
+
emailRefundNotice: boolean;
|
|
112
|
+
errorBannerText: string;
|
|
113
|
+
};
|
|
114
|
+
advance: unknown;
|
|
115
|
+
discount: {
|
|
116
|
+
shouldShowSavingText: boolean;
|
|
117
|
+
type: "none" | "fixed_amount" | "percentage";
|
|
118
|
+
amount: number;
|
|
119
|
+
};
|
|
120
|
+
integrations: unknown;
|
|
121
|
+
shipping: {
|
|
122
|
+
enabled: boolean;
|
|
123
|
+
title: string;
|
|
124
|
+
type: "fixed_amount" | "free";
|
|
125
|
+
amount: number;
|
|
126
|
+
};
|
|
127
|
+
styles: unknown;
|
|
128
|
+
subImages: number | null;
|
|
129
|
+
subscription: unknown;
|
|
130
|
+
subscriptionIsDefault?: boolean | undefined;
|
|
131
|
+
blocks?: unknown[] | undefined;
|
|
132
|
+
};
|
|
133
|
+
metadata: {
|
|
134
|
+
widget: Record<string, unknown>;
|
|
135
|
+
};
|
|
136
|
+
original: {
|
|
137
|
+
language: {
|
|
138
|
+
description: string;
|
|
139
|
+
descriptionEnabled: boolean;
|
|
140
|
+
displayCtaPrice: boolean;
|
|
141
|
+
global: {
|
|
142
|
+
declineAll: string;
|
|
143
|
+
declineThisOffer: string;
|
|
144
|
+
free: string;
|
|
145
|
+
notAvailable: string;
|
|
146
|
+
payNow: string;
|
|
147
|
+
payNowUpgradeToSubscription: string;
|
|
148
|
+
quantity: string;
|
|
149
|
+
recurringShipping: string;
|
|
150
|
+
recurringSubtotal: string;
|
|
151
|
+
reviewsPlural: string;
|
|
152
|
+
reviewsSingular: string;
|
|
153
|
+
save: string;
|
|
154
|
+
shipping: string;
|
|
155
|
+
subscriptionOption: string;
|
|
156
|
+
subtotal: string;
|
|
157
|
+
taxes: string;
|
|
158
|
+
total: string;
|
|
159
|
+
};
|
|
160
|
+
globalTranslation: string;
|
|
161
|
+
descriptionRte?: {
|
|
162
|
+
content: unknown[];
|
|
163
|
+
type: string;
|
|
164
|
+
} | undefined;
|
|
165
|
+
descriptionSpacing?: "default" | "none" | "tight" | "loose" | "xtight" | "xloose" | undefined;
|
|
166
|
+
};
|
|
167
|
+
productType: string;
|
|
168
|
+
discountedFrom: "price" | "compare_at_price";
|
|
169
|
+
productLimit: number;
|
|
170
|
+
productOptions: {
|
|
171
|
+
hideOutOfStockVariants: boolean;
|
|
172
|
+
matchVariant: boolean;
|
|
173
|
+
showShipping: boolean;
|
|
174
|
+
showSubtotal: boolean;
|
|
175
|
+
showTaxes: boolean;
|
|
176
|
+
showTotal: boolean;
|
|
177
|
+
showVariantSelectors: boolean;
|
|
178
|
+
variantSelectorDisplayMode: "single" | "separate";
|
|
179
|
+
showDeclineAll?: "none" | "both" | "above" | "below" | undefined;
|
|
180
|
+
};
|
|
181
|
+
productTypeSelector: "radio" | "dropdown";
|
|
182
|
+
quantityInputs: {
|
|
183
|
+
defaultQuantity: number;
|
|
184
|
+
enabled: boolean;
|
|
185
|
+
maxValue: number;
|
|
186
|
+
minValue: number;
|
|
187
|
+
};
|
|
188
|
+
upgradeToSubscription: {
|
|
189
|
+
acceptButtonText: string;
|
|
190
|
+
allow: boolean;
|
|
191
|
+
emailRefundNotice: boolean;
|
|
192
|
+
errorBannerText: string;
|
|
193
|
+
};
|
|
194
|
+
advance: unknown;
|
|
195
|
+
discount: {
|
|
196
|
+
shouldShowSavingText: boolean;
|
|
197
|
+
type: "none" | "fixed_amount" | "percentage";
|
|
198
|
+
amount: number;
|
|
199
|
+
};
|
|
200
|
+
integrations: unknown;
|
|
201
|
+
shipping: {
|
|
202
|
+
enabled: boolean;
|
|
203
|
+
title: string;
|
|
204
|
+
type: "fixed_amount" | "free";
|
|
205
|
+
amount: number;
|
|
206
|
+
};
|
|
207
|
+
styles: unknown;
|
|
208
|
+
subImages: number | null;
|
|
209
|
+
subscription: unknown;
|
|
210
|
+
subscriptionIsDefault?: boolean | undefined;
|
|
211
|
+
blocks?: unknown[] | undefined;
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
products: {
|
|
215
|
+
product: {
|
|
216
|
+
title: string;
|
|
217
|
+
id: number;
|
|
218
|
+
productGroupVariants: unknown[];
|
|
219
|
+
sellingPlanGroups: {
|
|
220
|
+
requiresSellingPlan: boolean;
|
|
221
|
+
discountAmount?: unknown;
|
|
222
|
+
discountType?: unknown;
|
|
223
|
+
id?: unknown;
|
|
224
|
+
sellingPlans?: unknown;
|
|
225
|
+
}[];
|
|
226
|
+
variants: {
|
|
227
|
+
title: string;
|
|
228
|
+
compareAtPrice: string | null;
|
|
229
|
+
id: number;
|
|
230
|
+
inventoryManagement: string | null;
|
|
231
|
+
inventoryPolicy: string;
|
|
232
|
+
inventoryQuantity: number;
|
|
233
|
+
price: string;
|
|
234
|
+
productId: number;
|
|
235
|
+
imageId?: number | null | undefined;
|
|
236
|
+
option1?: unknown;
|
|
237
|
+
option2?: unknown;
|
|
238
|
+
option3?: unknown;
|
|
239
|
+
sellingPlanAllocations?: unknown;
|
|
240
|
+
}[];
|
|
241
|
+
image?: {
|
|
242
|
+
src: string;
|
|
243
|
+
} | null | undefined;
|
|
244
|
+
description?: string | null | undefined;
|
|
245
|
+
images?: {
|
|
246
|
+
id: number;
|
|
247
|
+
src: string;
|
|
248
|
+
alt?: string | undefined;
|
|
249
|
+
}[] | null | undefined;
|
|
250
|
+
metadata?: {
|
|
251
|
+
productQuantity?: number | undefined;
|
|
252
|
+
} | undefined;
|
|
253
|
+
metafields?: unknown;
|
|
254
|
+
options?: unknown;
|
|
255
|
+
selectedVariant?: unknown;
|
|
256
|
+
};
|
|
257
|
+
productIndex: number;
|
|
258
|
+
}[];
|
|
259
|
+
};
|
|
1
260
|
/** Both prepared purchase terms and display structure consume this one effective configuration. */
|
|
2
|
-
export declare const normalizePostPurchaseProduct: (settings: unknown, response: unknown) => {
|
|
261
|
+
export declare const normalizePostPurchaseProduct: (settings: unknown, response: unknown, report?: Reporter) => {
|
|
3
262
|
data: {
|
|
4
263
|
title: string;
|
|
5
264
|
id: number;
|
|
@@ -4,5 +4,10 @@ import type { Reporter } from '../server/shared';
|
|
|
4
4
|
/**
|
|
5
5
|
* Optional inspection data survives unsupported preparation without changing its purchase authority. Each plan
|
|
6
6
|
* carries its own display saving on this variant's price, so the switch label needs no client maths.
|
|
7
|
+
*
|
|
8
|
+
* A catalog binds to exactly one variant, so callers that need plans narrow the product to the chosen variant first.
|
|
9
|
+
* A single product with several variants is a normal unnarrowed shape: it answers null without a drift report. Only
|
|
10
|
+
* genuinely malformed merchandise (no products, several products, no variants, a foreign variant) or unreadable plan
|
|
11
|
+
* data reports `Unreadable post-purchase plan catalog`.
|
|
7
12
|
*/
|
|
8
13
|
export declare const projectPostPurchasePlanCatalog: (normalized: ReturnType<typeof normalizePostPurchaseProduct>, report?: Reporter) => PostPurchasePlanCatalog | null;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Reporter } from '../server/shared';
|
|
3
|
+
/**
|
|
4
|
+
* Reads a data-source response one product at a time (Slice 102): a product the shared schema rejects is
|
|
5
|
+
* dropped, not the whole source, so one bad product costs one card instead of the Offer. Each drop is a
|
|
6
|
+
* `product` drift naming the product id (when readable) and the first failing dotted path from the source
|
|
7
|
+
* root, e.g. `data.0.variants.0.price`, never a value; a reporter hears a response's drops once however many
|
|
8
|
+
* projections reread it, keyed on the `response` object itself: pass the same object to every projection of
|
|
9
|
+
* one request (a re-parse or clone per projection reports the drops again). The envelope (an object, `data`
|
|
10
|
+
* an array, readable `metadata`) still throws.
|
|
11
|
+
*
|
|
12
|
+
* Every survivor keeps `productIndex`, its position in the raw `data` array: Decision, Render and Offer
|
|
13
|
+
* members identify a product by that index, so a drop never renumbers the products after it. `dropped` keeps
|
|
14
|
+
* each drop's `productIndex` and its zod issues with paths from the source root, so a caller can fail a source
|
|
15
|
+
* whose every product failed exactly as the whole-source schema did before salvage.
|
|
16
|
+
*/
|
|
17
|
+
export declare const readPostPurchaseProductSource: (response: unknown, report?: Reporter) => {
|
|
18
|
+
dropped: {
|
|
19
|
+
issues: z.core.$ZodIssue[];
|
|
20
|
+
productIndex: number;
|
|
21
|
+
}[];
|
|
22
|
+
metadata: {
|
|
23
|
+
widget: Record<string, unknown>;
|
|
24
|
+
};
|
|
25
|
+
products: {
|
|
26
|
+
product: {
|
|
27
|
+
title: string;
|
|
28
|
+
id: number;
|
|
29
|
+
productGroupVariants: unknown[];
|
|
30
|
+
sellingPlanGroups: {
|
|
31
|
+
requiresSellingPlan: boolean;
|
|
32
|
+
discountAmount?: unknown;
|
|
33
|
+
discountType?: unknown;
|
|
34
|
+
id?: unknown;
|
|
35
|
+
sellingPlans?: unknown;
|
|
36
|
+
}[];
|
|
37
|
+
variants: {
|
|
38
|
+
title: string;
|
|
39
|
+
compareAtPrice: string | null;
|
|
40
|
+
id: number;
|
|
41
|
+
inventoryManagement: string | null;
|
|
42
|
+
inventoryPolicy: string;
|
|
43
|
+
inventoryQuantity: number;
|
|
44
|
+
price: string;
|
|
45
|
+
productId: number;
|
|
46
|
+
imageId?: number | null | undefined;
|
|
47
|
+
option1?: unknown;
|
|
48
|
+
option2?: unknown;
|
|
49
|
+
option3?: unknown;
|
|
50
|
+
sellingPlanAllocations?: unknown;
|
|
51
|
+
}[];
|
|
52
|
+
image?: {
|
|
53
|
+
src: string;
|
|
54
|
+
} | null | undefined;
|
|
55
|
+
description?: string | null | undefined;
|
|
56
|
+
images?: {
|
|
57
|
+
id: number;
|
|
58
|
+
src: string;
|
|
59
|
+
alt?: string | undefined;
|
|
60
|
+
}[] | null | undefined;
|
|
61
|
+
metadata?: {
|
|
62
|
+
productQuantity?: number | undefined;
|
|
63
|
+
} | undefined;
|
|
64
|
+
metafields?: unknown;
|
|
65
|
+
options?: unknown;
|
|
66
|
+
selectedVariant?: unknown;
|
|
67
|
+
};
|
|
68
|
+
productIndex: number;
|
|
69
|
+
}[];
|
|
70
|
+
};
|
package/dist/server/shared.d.ts
CHANGED
|
@@ -27,7 +27,8 @@ export type UpstreamFetch = (path: string, params: Record<string, string>, optio
|
|
|
27
27
|
}) => Promise<unknown>;
|
|
28
28
|
/**
|
|
29
29
|
* A drift signal the orchestrators emit when a per-item payload salvage drops something: a malformed
|
|
30
|
-
* offer product
|
|
30
|
+
* offer product (or a post-purchase data-source product, `product`, named by id and dotted path), an
|
|
31
|
+
* invalid/unknown section stubbed out, an unreadable rule verdict, a shop-config
|
|
31
32
|
* entry the shared schema inerted (`shopConfig`), unreadable selectable-gift milestones
|
|
32
33
|
* (`giftMilestones` — the widget's gifts are then kept), or a post-purchase product's malformed selected review
|
|
33
34
|
* metafield (`reviews` — the reviews are then omitted; it names the product and the field, never the value). Distinct from a hard {@link UpstreamError} — the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebuy/rebuy",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.55.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.",
|