@rebuy/rebuy 3.32.0 → 3.34.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.
Files changed (52) hide show
  1. package/README.md +1 -1
  2. package/dist/cab/index.cjs +12 -1
  3. package/dist/cab/index.d.ts +1 -0
  4. package/dist/cab/index.mjs +12 -1
  5. package/dist/cab/utf8ByteLength.d.ts +6 -0
  6. package/dist/index.cjs +1138 -923
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.mjs +1138 -923
  9. package/dist/pricing/postPurchaseSubscriptionDisplay.d.ts +5 -0
  10. package/dist/schema/index.d.ts +8 -0
  11. package/dist/schema/postPurchaseChoice.d.ts +25 -0
  12. package/dist/schema/postPurchaseDiscount.d.ts +22 -0
  13. package/dist/schema/postPurchasePlanAdjustment.d.ts +11 -0
  14. package/dist/schema/postPurchasePlanCatalog.d.ts +42 -0
  15. package/dist/schema/postPurchaseProduct.d.ts +260 -0
  16. package/dist/schema/postPurchaseProductSettings.d.ts +1 -1
  17. package/dist/schema/postPurchaseProductSource.d.ts +2 -2
  18. package/dist/schema/postPurchaseSubscription.d.ts +21 -0
  19. package/dist/schema/postPurchaseSubscriptionDisplay.d.ts +10 -0
  20. package/dist/schema/postPurchaseSubscriptionProduct.d.ts +224 -0
  21. package/dist/schema/postPurchaseSubscriptionSettings.d.ts +22 -0
  22. package/dist/schema/widgets/checkout-and-beyond/banner.d.ts +1 -1
  23. package/dist/schema/widgets/checkout-and-beyond/carousel.d.ts +1 -1
  24. package/dist/schema/widgets/checkout-and-beyond/cartLine.d.ts +1 -1
  25. package/dist/schema/widgets/checkout-and-beyond/common.d.ts +1 -1
  26. package/dist/schema/widgets/checkout-and-beyond/dataSource.d.ts +2 -2
  27. package/dist/schema/widgets/checkout-and-beyond/discount.d.ts +1 -1
  28. package/dist/schema/widgets/checkout-and-beyond/icons.d.ts +1 -1
  29. package/dist/schema/widgets/checkout-and-beyond/image.d.ts +2 -2
  30. package/dist/schema/widgets/checkout-and-beyond/offers.d.ts +1 -1
  31. package/dist/schema/widgets/checkout-and-beyond/progressBar.d.ts +1 -1
  32. package/dist/schema/widgets/post-purchase-offer/postPurchaseOffer.d.ts +2 -2
  33. package/dist/schema/widgets/post-purchase-offer/postPurchaseSettings.d.ts +2 -2
  34. package/dist/schema/widgets/post-purchase-offer/postPurchaseWidget.d.ts +2 -2
  35. package/dist/server/__fixtures__/postPurchaseLegacyPlans.d.ts +35 -0
  36. package/dist/server/__fixtures__/postPurchaseSubscription.d.ts +75 -0
  37. package/dist/server/index.cjs +802 -118
  38. package/dist/server/index.d.ts +3 -1
  39. package/dist/server/index.mjs +802 -118
  40. package/dist/server/normalizePostPurchaseCollection.d.ts +16 -16
  41. package/dist/server/normalizePostPurchaseProduct.d.ts +9 -9
  42. package/dist/server/postPurchaseLegacyPlans.d.ts +3 -0
  43. package/dist/server/postPurchaseModernPlans.d.ts +7 -0
  44. package/dist/server/postPurchasePlanAdjustment.d.ts +3 -0
  45. package/dist/server/postPurchasePlanCatalog.d.ts +5 -0
  46. package/dist/server/postPurchaseSubscriptionEligibility.d.ts +5 -0
  47. package/dist/server/prepareNormalizedSubscription.d.ts +11 -0
  48. package/dist/server/preparePostPurchaseSubscription.d.ts +102 -0
  49. package/dist/server/projectPostPurchaseProduct.d.ts +7 -7
  50. package/dist/server/requestSchemas.d.ts +1 -1
  51. package/dist/server/selectPostPurchaseChoice.d.ts +43 -0
  52. package/package.json +1 -1
@@ -6,6 +6,13 @@ export declare const normalizePostPurchaseCollection: (settings: unknown, respon
6
6
  title: string;
7
7
  id: number;
8
8
  productGroupVariants: unknown[];
9
+ sellingPlanGroups: {
10
+ requiresSellingPlan: boolean;
11
+ discountAmount?: unknown;
12
+ discountType?: unknown;
13
+ id?: unknown;
14
+ sellingPlans?: unknown;
15
+ }[];
9
16
  variants: {
10
17
  title: string;
11
18
  compareAtPrice: string | null;
@@ -36,13 +43,6 @@ export declare const normalizePostPurchaseCollection: (settings: unknown, respon
36
43
  metafields?: unknown;
37
44
  options?: unknown;
38
45
  selectedVariant?: unknown;
39
- sellingPlanGroups?: {
40
- requiresSellingPlan?: boolean | undefined;
41
- discountAmount?: unknown;
42
- discountType?: unknown;
43
- id?: unknown;
44
- sellingPlans?: unknown;
45
- }[] | undefined;
46
46
  };
47
47
  productIndex: number;
48
48
  }[];
@@ -51,6 +51,13 @@ export declare const normalizePostPurchaseCollection: (settings: unknown, respon
51
51
  title: string;
52
52
  id: number;
53
53
  productGroupVariants: unknown[];
54
+ sellingPlanGroups: {
55
+ requiresSellingPlan: boolean;
56
+ discountAmount?: unknown;
57
+ discountType?: unknown;
58
+ id?: unknown;
59
+ sellingPlans?: unknown;
60
+ }[];
54
61
  variants: {
55
62
  title: string;
56
63
  compareAtPrice: string | null;
@@ -81,13 +88,6 @@ export declare const normalizePostPurchaseCollection: (settings: unknown, respon
81
88
  metafields?: unknown;
82
89
  options?: unknown;
83
90
  selectedVariant?: unknown;
84
- sellingPlanGroups?: {
85
- requiresSellingPlan?: boolean | undefined;
86
- discountAmount?: unknown;
87
- discountType?: unknown;
88
- id?: unknown;
89
- sellingPlans?: unknown;
90
- }[] | undefined;
91
91
  }[];
92
92
  effective: {
93
93
  language: {
@@ -150,7 +150,7 @@ export declare const normalizePostPurchaseCollection: (settings: unknown, respon
150
150
  advance: unknown;
151
151
  discount: {
152
152
  shouldShowSavingText: boolean;
153
- type: "none" | "percentage" | "fixed_amount";
153
+ type: "none" | "fixed_amount" | "percentage";
154
154
  amount: number;
155
155
  };
156
156
  integrations: unknown;
@@ -230,7 +230,7 @@ export declare const normalizePostPurchaseCollection: (settings: unknown, respon
230
230
  advance: unknown;
231
231
  discount: {
232
232
  shouldShowSavingText: boolean;
233
- type: "none" | "percentage" | "fixed_amount";
233
+ type: "none" | "fixed_amount" | "percentage";
234
234
  amount: number;
235
235
  };
236
236
  integrations: unknown;
@@ -4,6 +4,13 @@ export declare const normalizePostPurchaseProduct: (settings: unknown, response:
4
4
  title: string;
5
5
  id: number;
6
6
  productGroupVariants: unknown[];
7
+ sellingPlanGroups: {
8
+ requiresSellingPlan: boolean;
9
+ discountAmount?: unknown;
10
+ discountType?: unknown;
11
+ id?: unknown;
12
+ sellingPlans?: unknown;
13
+ }[];
7
14
  variants: {
8
15
  title: string;
9
16
  compareAtPrice: string | null;
@@ -34,13 +41,6 @@ export declare const normalizePostPurchaseProduct: (settings: unknown, response:
34
41
  metafields?: unknown;
35
42
  options?: unknown;
36
43
  selectedVariant?: unknown;
37
- sellingPlanGroups?: {
38
- requiresSellingPlan?: boolean | undefined;
39
- discountAmount?: unknown;
40
- discountType?: unknown;
41
- id?: unknown;
42
- sellingPlans?: unknown;
43
- }[] | undefined;
44
44
  }[];
45
45
  effective: {
46
46
  language: {
@@ -103,7 +103,7 @@ export declare const normalizePostPurchaseProduct: (settings: unknown, response:
103
103
  advance: unknown;
104
104
  discount: {
105
105
  shouldShowSavingText: boolean;
106
- type: "none" | "percentage" | "fixed_amount";
106
+ type: "none" | "fixed_amount" | "percentage";
107
107
  amount: number;
108
108
  };
109
109
  integrations: unknown;
@@ -183,7 +183,7 @@ export declare const normalizePostPurchaseProduct: (settings: unknown, response:
183
183
  advance: unknown;
184
184
  discount: {
185
185
  shouldShowSavingText: boolean;
186
- type: "none" | "percentage" | "fixed_amount";
186
+ type: "none" | "fixed_amount" | "percentage";
187
187
  amount: number;
188
188
  };
189
189
  integrations: unknown;
@@ -0,0 +1,3 @@
1
+ import { PostPurchasePlanOption } from '../schema/postPurchasePlanCatalog';
2
+ /** Core emits a row per plan/variant join. A missing LEFT JOIN grants no variant membership. */
3
+ export declare const readPostPurchaseLegacyPlans: (raw: unknown, variantId: number) => PostPurchasePlanOption[];
@@ -0,0 +1,7 @@
1
+ import { PostPurchasePlanOption } from '../schema/postPurchasePlanCatalog';
2
+ /**
3
+ * Match allocation groups in product order, then preserve each matching group's plan order. Membership is
4
+ * group-level by design (frozen-branch parity): Shopify allocates every plan of a group to a member variant, and
5
+ * an allocation's `selling_plan_id` is neither required nor consulted, so a group-only allocation still admits it.
6
+ */
7
+ export declare const readPostPurchaseModernPlans: (raw: unknown, allocations: unknown) => PostPurchasePlanOption[];
@@ -0,0 +1,3 @@
1
+ import { PostPurchasePlanAdjustment } from '../schema/postPurchasePlanAdjustment';
2
+ /** Legacy amount is a reduction; no inspected producer defines a nonzero fixed plan alias. */
3
+ export declare const readPostPurchasePlanAdjustment: (raw: unknown) => PostPurchasePlanAdjustment | undefined;
@@ -0,0 +1,5 @@
1
+ import { PostPurchasePlanCatalog } from '../schema/postPurchasePlanCatalog';
2
+ import type { normalizePostPurchaseProduct } from '../server/normalizePostPurchaseProduct';
3
+ import type { Reporter } from '../server/shared';
4
+ /** Optional inspection data survives unsupported preparation without changing its purchase authority. */
5
+ export declare const projectPostPurchasePlanCatalog: (normalized: ReturnType<typeof normalizePostPurchaseProduct>, report?: Reporter) => PostPurchasePlanCatalog | null;
@@ -0,0 +1,5 @@
1
+ import type { PostPurchasePlanOption } from '../schema/postPurchasePlanCatalog';
2
+ import type { normalizePostPurchaseProduct } from '../server/normalizePostPurchaseProduct';
3
+ export declare const subscriptionUnavailable: (normalized: ReturnType<typeof normalizePostPurchaseProduct>, plan: PostPurchasePlanOption | undefined, allowCollection: boolean, quantity?: {
4
+ quantity: number;
5
+ }) => "An eligible subscription plan with supported shipping and discount is required" | undefined;
@@ -0,0 +1,11 @@
1
+ import type { PostPurchasePlanOption } from '../schema/postPurchasePlanCatalog';
2
+ import { type PostPurchasePreparation } from '../schema/postPurchaseProduct';
3
+ import type { normalizePostPurchaseProduct } from '../server/normalizePostPurchaseProduct';
4
+ import type { Reporter } from '../server/shared';
5
+ /**
6
+ * Preparation for one allocated plan with validated configured shipping and discount. `report` is kept in the
7
+ * frozen position for Slice 26, whose review projection is the only consumer inside `projectPostPurchaseProduct`.
8
+ */
9
+ export declare const prepareNormalizedSubscription: (normalized: ReturnType<typeof normalizePostPurchaseProduct>, report: Reporter | undefined, plan: PostPurchasePlanOption | undefined, quantity?: {
10
+ quantity: number;
11
+ }, allowCollection?: boolean) => PostPurchasePreparation;
@@ -0,0 +1,102 @@
1
+ import type { Reporter } from '../server/shared';
2
+ /** Standalone subscription preparation uses the same normalized dispatcher input. */
3
+ export declare const preparePostPurchaseSubscription: (settings: unknown, response: unknown, report?: Reporter) => {
4
+ display: {
5
+ discountedFrom: "price" | "compare_at_price";
6
+ language: {
7
+ description: string;
8
+ descriptionEnabled: boolean;
9
+ descriptionRte?: {
10
+ content: unknown[];
11
+ type: string;
12
+ } | undefined;
13
+ descriptionSpacing?: "default" | "none" | "tight" | "loose" | "xtight" | "xloose" | undefined;
14
+ };
15
+ primaryImage: {
16
+ description: string;
17
+ source: string;
18
+ };
19
+ productOptions: {
20
+ showShipping: boolean;
21
+ showSubtotal: boolean;
22
+ showTaxes: boolean;
23
+ showTotal: boolean;
24
+ showVariantSelectors: boolean;
25
+ showDeclineAll?: "none" | "both" | "above" | "below" | undefined;
26
+ };
27
+ responseDescription: string;
28
+ shouldShowSavingText: boolean;
29
+ gallery?: {
30
+ images: {
31
+ description: string;
32
+ id: number;
33
+ source: string;
34
+ thumbnail: string;
35
+ }[];
36
+ selectedImageId?: number | undefined;
37
+ } | undefined;
38
+ };
39
+ labels: {
40
+ declineAll: string;
41
+ free: string;
42
+ payNow: string;
43
+ quantity: string;
44
+ recurringShipping: string;
45
+ recurringSubtotal: string;
46
+ save: string;
47
+ shipping: string;
48
+ subtotal: string;
49
+ taxes: string;
50
+ total: string;
51
+ };
52
+ product: {
53
+ title: string;
54
+ id: number;
55
+ variant: {
56
+ title: string;
57
+ compareAtPrice: string | null;
58
+ id: number;
59
+ price: string;
60
+ };
61
+ image?: {
62
+ src: string;
63
+ } | null | undefined;
64
+ description?: string | null | undefined;
65
+ };
66
+ selection: {
67
+ productId: number;
68
+ quantity: number;
69
+ variantId: number;
70
+ sellingPlanId?: number | undefined;
71
+ };
72
+ status: "prepared";
73
+ terms: {
74
+ discount: {
75
+ amount: number;
76
+ title: string;
77
+ type: "none" | "fixed_amount" | "percentage";
78
+ };
79
+ shipping: {
80
+ amount: number;
81
+ title: string;
82
+ type: "fixed_amount" | "free";
83
+ };
84
+ subscription?: {
85
+ initialShippingPrice: number;
86
+ intervalLabel: string;
87
+ name: string;
88
+ recurringShippingPrice: number;
89
+ shippingOption: {
90
+ presentmentTitle: string;
91
+ title: string;
92
+ };
93
+ adjustment?: {
94
+ amount: number;
95
+ type: "price" | "fixed_amount" | "percentage";
96
+ } | undefined;
97
+ } | undefined;
98
+ };
99
+ } | {
100
+ reason: string;
101
+ status: "unsupported";
102
+ };
@@ -81,6 +81,13 @@ export declare const projectPostPurchaseProduct: ({ data, effective, metadata, o
81
81
  title: string;
82
82
  id: number;
83
83
  productGroupVariants: unknown[];
84
+ sellingPlanGroups: {
85
+ requiresSellingPlan: boolean;
86
+ discountAmount?: unknown;
87
+ discountType?: unknown;
88
+ id?: unknown;
89
+ sellingPlans?: unknown;
90
+ }[];
84
91
  variants: {
85
92
  title: string;
86
93
  compareAtPrice: string | null;
@@ -111,13 +118,6 @@ export declare const projectPostPurchaseProduct: ({ data, effective, metadata, o
111
118
  metafields?: unknown;
112
119
  options?: unknown;
113
120
  selectedVariant?: unknown;
114
- sellingPlanGroups?: {
115
- requiresSellingPlan?: boolean | undefined;
116
- discountAmount?: unknown;
117
- discountType?: unknown;
118
- id?: unknown;
119
- sellingPlans?: unknown;
120
- }[] | undefined;
121
121
  };
122
122
  selection: {
123
123
  productId: number;
@@ -270,7 +270,6 @@ export declare const WidgetSettingsInputSchema: z.ZodObject<{
270
270
  monetize: z.ZodOptional<z.ZodObject<{
271
271
  language: z.ZodOptional<z.ZodString>;
272
272
  currency: z.ZodOptional<z.ZodString>;
273
- sessionId: z.ZodOptional<z.ZodString>;
274
273
  cart: z.ZodObject<{
275
274
  attributes: z.ZodOptional<z.ZodArray<z.ZodObject<{
276
275
  key: z.ZodString;
@@ -292,6 +291,7 @@ export declare const WidgetSettingsInputSchema: z.ZodObject<{
292
291
  subtotal: z.ZodNumber;
293
292
  }, z.core.$strip>;
294
293
  testing: z.ZodOptional<z.ZodBoolean>;
294
+ sessionId: z.ZodOptional<z.ZodString>;
295
295
  country: z.ZodOptional<z.ZodString>;
296
296
  customerId: z.ZodOptional<z.ZodString>;
297
297
  visitorId: z.ZodOptional<z.ZodString>;
@@ -0,0 +1,43 @@
1
+ import { type PostPurchaseChoice } from '../schema/postPurchaseChoice';
2
+ import type { PostPurchasePlanCatalog } from '../schema/postPurchasePlanCatalog';
3
+ import type { normalizePostPurchaseProduct } from '../server/normalizePostPurchaseProduct';
4
+ /**
5
+ * Catalog inspection is not authority; the chosen mode still passes its complete preparation guards. A catalog
6
+ * projected for another product or variant is treated as absent, so a stale catalog never lends its plans.
7
+ */
8
+ export declare const selectPostPurchaseChoice: (normalized: ReturnType<typeof normalizePostPurchaseProduct>, projected: PostPurchasePlanCatalog | null, requested: PostPurchaseChoice | undefined, allowCollection: boolean, quantity?: {
9
+ quantity: number;
10
+ }) => {
11
+ choice: undefined;
12
+ options: undefined;
13
+ plan: undefined;
14
+ reason: string;
15
+ } | {
16
+ choice: {
17
+ mode: "one-time";
18
+ } | {
19
+ mode: "subscription";
20
+ sellingPlanId: number;
21
+ } | undefined;
22
+ options: {
23
+ defaultChoice: {
24
+ mode: "one-time";
25
+ } | {
26
+ mode: "subscription";
27
+ sellingPlanId: number;
28
+ };
29
+ modes: ("one-time" | "subscription")[];
30
+ selector: "radio" | "dropdown";
31
+ };
32
+ plan: {
33
+ id: number;
34
+ intervalLabel: string;
35
+ name: string;
36
+ adjustment?: {
37
+ amount: number;
38
+ type: "price" | "fixed_amount" | "percentage";
39
+ } | undefined;
40
+ intervalFrequency?: string | undefined;
41
+ } | undefined;
42
+ reason: string | undefined;
43
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rebuy/rebuy",
3
- "version": "3.32.0",
3
+ "version": "3.34.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.",