@rebuy/rebuy 3.56.0 → 3.56.1
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/server/index.cjs +5 -4
- package/dist/server/index.mjs +5 -4
- package/dist/server/normalizePostPurchaseCollection.d.ts +1 -0
- package/dist/server/normalizePostPurchaseProduct.d.ts +7 -3
- package/dist/server/postPurchasePlanCatalog.d.ts +2 -1
- package/dist/server/preparePostPurchaseMemberView.d.ts +2 -0
- package/dist/server/preparePostPurchaseStsMember.d.ts +1 -0
- package/package.json +1 -1
package/dist/server/index.cjs
CHANGED
|
@@ -6213,14 +6213,14 @@ var normalizePostPurchaseSource = (settings, response, report) => {
|
|
|
6213
6213
|
}
|
|
6214
6214
|
const effective = PostPurchaseProductSettings.parse((0, import_compat7.merge)({}, original, overrides));
|
|
6215
6215
|
const data = products.map(({ product }) => product);
|
|
6216
|
-
|
|
6216
|
+
const emptiedByDrop = !data.length && dropped.length > 0;
|
|
6217
|
+
return { dropped, normalized: { data, effective, emptiedByDrop, metadata, original }, products };
|
|
6217
6218
|
};
|
|
6218
6219
|
var underPostPurchaseCap = (entries, cap) => entries.filter(({ productIndex }) => productIndex < cap);
|
|
6219
6220
|
var normalizePostPurchaseProduct = (settings, response, report) => {
|
|
6220
6221
|
const { normalized, products } = normalizePostPurchaseSource(settings, response, report);
|
|
6221
|
-
const
|
|
6222
|
-
|
|
6223
|
-
return readable ? normalized : { ...normalized, data: [] };
|
|
6222
|
+
const capped = normalized.effective.productLimit === 1 && products.length > 0 && !underPostPurchaseCap(products, 1).length;
|
|
6223
|
+
return capped ? { ...normalized, data: [], emptiedByDrop: true } : normalized;
|
|
6224
6224
|
};
|
|
6225
6225
|
|
|
6226
6226
|
// src/pricing/amountToCents.ts
|
|
@@ -6376,6 +6376,7 @@ var readPostPurchaseModernPlans = (raw, allocations) => {
|
|
|
6376
6376
|
var projectPostPurchasePlanCatalog = (normalized, report) => {
|
|
6377
6377
|
const { data } = normalized;
|
|
6378
6378
|
if (data.length === 1 && data[0].variants.length > 1) return null;
|
|
6379
|
+
if (normalized.emptiedByDrop && !data.length) return null;
|
|
6379
6380
|
try {
|
|
6380
6381
|
if (data.length !== 1 || data[0].variants.length !== 1) throw new Error("Ambiguous product");
|
|
6381
6382
|
const product = data[0];
|
package/dist/server/index.mjs
CHANGED
|
@@ -6140,14 +6140,14 @@ var normalizePostPurchaseSource = (settings, response, report) => {
|
|
|
6140
6140
|
}
|
|
6141
6141
|
const effective = PostPurchaseProductSettings.parse(merge({}, original, overrides));
|
|
6142
6142
|
const data = products.map(({ product }) => product);
|
|
6143
|
-
|
|
6143
|
+
const emptiedByDrop = !data.length && dropped.length > 0;
|
|
6144
|
+
return { dropped, normalized: { data, effective, emptiedByDrop, metadata, original }, products };
|
|
6144
6145
|
};
|
|
6145
6146
|
var underPostPurchaseCap = (entries, cap) => entries.filter(({ productIndex }) => productIndex < cap);
|
|
6146
6147
|
var normalizePostPurchaseProduct = (settings, response, report) => {
|
|
6147
6148
|
const { normalized, products } = normalizePostPurchaseSource(settings, response, report);
|
|
6148
|
-
const
|
|
6149
|
-
|
|
6150
|
-
return readable ? normalized : { ...normalized, data: [] };
|
|
6149
|
+
const capped = normalized.effective.productLimit === 1 && products.length > 0 && !underPostPurchaseCap(products, 1).length;
|
|
6150
|
+
return capped ? { ...normalized, data: [], emptiedByDrop: true } : normalized;
|
|
6151
6151
|
};
|
|
6152
6152
|
|
|
6153
6153
|
// src/pricing/amountToCents.ts
|
|
@@ -6303,6 +6303,7 @@ var readPostPurchaseModernPlans = (raw, allocations) => {
|
|
|
6303
6303
|
var projectPostPurchasePlanCatalog = (normalized, report) => {
|
|
6304
6304
|
const { data } = normalized;
|
|
6305
6305
|
if (data.length === 1 && data[0].variants.length > 1) return null;
|
|
6306
|
+
if (normalized.emptiedByDrop && !data.length) return null;
|
|
6306
6307
|
try {
|
|
6307
6308
|
if (data.length !== 1 || data[0].variants.length !== 1) throw new Error("Ambiguous product");
|
|
6308
6309
|
const product = data[0];
|
|
@@ -175,6 +175,7 @@ export declare const normalizePostPurchaseCollection: (settings: unknown, respon
|
|
|
175
175
|
subscriptionIsDefault?: boolean | undefined;
|
|
176
176
|
blocks?: unknown[] | undefined;
|
|
177
177
|
};
|
|
178
|
+
emptiedByDrop: boolean;
|
|
178
179
|
metadata: {
|
|
179
180
|
widget: Record<string, unknown>;
|
|
180
181
|
};
|
|
@@ -3,7 +3,8 @@ import type { Reporter } from '../server/shared';
|
|
|
3
3
|
/**
|
|
4
4
|
* The normalized read plus each surviving product's raw `productIndex`, which a collection publishes as member
|
|
5
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.
|
|
6
|
+
* `dropped` is each rejected product's raw `productIndex` and zod issues. `emptiedByDrop` marks a `data` left
|
|
7
|
+
* empty only because its products were dropped (and so already reported), not because the source had none.
|
|
7
8
|
*/
|
|
8
9
|
export declare const normalizePostPurchaseSource: (settings: unknown, response: unknown, report?: Reporter) => {
|
|
9
10
|
dropped: {
|
|
@@ -130,6 +131,7 @@ export declare const normalizePostPurchaseSource: (settings: unknown, response:
|
|
|
130
131
|
subscriptionIsDefault?: boolean | undefined;
|
|
131
132
|
blocks?: unknown[] | undefined;
|
|
132
133
|
};
|
|
134
|
+
emptiedByDrop: boolean;
|
|
133
135
|
metadata: {
|
|
134
136
|
widget: Record<string, unknown>;
|
|
135
137
|
};
|
|
@@ -270,8 +272,9 @@ export declare const underPostPurchaseCap: <T extends {
|
|
|
270
272
|
* is empty (as the collection keeps no member), so `[bad, good]` with a limit of 1 prepares nothing. Otherwise
|
|
271
273
|
* `data` keeps every survivor, so a source with more than one readable product still reads as ambiguous rather
|
|
272
274
|
* than having products discarded. Each dropped product, past the cap or not, was already reported as drift.
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
+
* Only a limit of exactly 1 caps: any other limit (0, negative, fractional, or above 1) is a configuration
|
|
276
|
+
* the standalone path refuses anyway, so `data` stays whole and eligibility rejects it with the configuration
|
|
277
|
+
* reason instead of the catalog reporting drift for a readable product.
|
|
275
278
|
*/
|
|
276
279
|
export declare const normalizePostPurchaseProduct: (settings: unknown, response: unknown, report?: Reporter) => {
|
|
277
280
|
data: {
|
|
@@ -393,6 +396,7 @@ export declare const normalizePostPurchaseProduct: (settings: unknown, response:
|
|
|
393
396
|
subscriptionIsDefault?: boolean | undefined;
|
|
394
397
|
blocks?: unknown[] | undefined;
|
|
395
398
|
};
|
|
399
|
+
emptiedByDrop: boolean;
|
|
396
400
|
metadata: {
|
|
397
401
|
widget: Record<string, unknown>;
|
|
398
402
|
};
|
|
@@ -8,6 +8,7 @@ import type { Reporter } from '../server/shared';
|
|
|
8
8
|
* A catalog binds to exactly one variant, so callers that need plans narrow the product to the chosen variant first.
|
|
9
9
|
* A single product with several variants is a normal unnarrowed shape: it answers null without a drift report. Only
|
|
10
10
|
* genuinely malformed merchandise (no products, several products, no variants, a foreign variant) or unreadable plan
|
|
11
|
-
* data reports `Unreadable post-purchase plan catalog`.
|
|
11
|
+
* data reports `Unreadable post-purchase plan catalog`. No products because every one under the cap was dropped is
|
|
12
|
+
* not a second fault: each drop was already reported, so it answers null without another report.
|
|
12
13
|
*/
|
|
13
14
|
export declare const projectPostPurchasePlanCatalog: (normalized: ReturnType<typeof normalizePostPurchaseProduct>, report?: Reporter) => PostPurchasePlanCatalog | null;
|
|
@@ -730,6 +730,7 @@ export declare const prepareMember: (widgetId: number, settings: unknown, respon
|
|
|
730
730
|
subscriptionIsDefault?: boolean | undefined;
|
|
731
731
|
blocks?: unknown[] | undefined;
|
|
732
732
|
};
|
|
733
|
+
emptiedByDrop: boolean;
|
|
733
734
|
metadata: {
|
|
734
735
|
widget: Record<string, unknown>;
|
|
735
736
|
};
|
|
@@ -1546,6 +1547,7 @@ export declare const prepareMember: (widgetId: number, settings: unknown, respon
|
|
|
1546
1547
|
subscriptionIsDefault?: boolean | undefined;
|
|
1547
1548
|
blocks?: unknown[] | undefined;
|
|
1548
1549
|
};
|
|
1550
|
+
emptiedByDrop: boolean;
|
|
1549
1551
|
metadata: {
|
|
1550
1552
|
widget: Record<string, unknown>;
|
|
1551
1553
|
};
|
|
@@ -735,6 +735,7 @@ export declare const preparePostPurchaseStsMember: (widgetId: number, settings:
|
|
|
735
735
|
subscriptionIsDefault?: boolean | undefined;
|
|
736
736
|
blocks?: unknown[] | undefined;
|
|
737
737
|
};
|
|
738
|
+
emptiedByDrop: boolean;
|
|
738
739
|
metadata: {
|
|
739
740
|
widget: Record<string, unknown>;
|
|
740
741
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rebuy/rebuy",
|
|
3
|
-
"version": "3.56.
|
|
3
|
+
"version": "3.56.1",
|
|
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.",
|