@rebuy/rebuy 3.40.0 → 3.42.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.
@@ -55,6 +55,7 @@ export * from './postPurchaseSubscription';
55
55
  export * from './postPurchaseSubscriptionDisplay';
56
56
  export { PreparedPostPurchaseSubscription } from './postPurchaseSubscriptionProduct';
57
57
  export * from './postPurchaseTransition';
58
+ export * from './postPurchaseUpgrade';
58
59
  export * from './postPurchaseVariantCatalog';
59
60
  export * from './postPurchaseVariantDefault';
60
61
  export * from './postPurchaseVariantDefaultContext';
@@ -1,4 +1,12 @@
1
1
  import { z } from 'zod';
2
+ /**
3
+ * Absent means `purchase`, so every pre-upgrade wire is unchanged. `upgrade` adds the selected subscription and
4
+ * refunds the buyer's original one-time line of the same variant; the server binds that line, never the client.
5
+ */
6
+ export declare const PurchaseAdmissionModeSchema: z.ZodEnum<{
7
+ purchase: "purchase";
8
+ upgrade: "upgrade";
9
+ }>;
2
10
  export declare const PurchaseExpectedSchema: z.ZodObject<{
3
11
  buyerConsentToSubscriptions: z.ZodOptional<z.ZodBoolean>;
4
12
  changeset: z.ZodObject<{
@@ -52,6 +60,10 @@ export declare const PurchaseExpectedSchema: z.ZodObject<{
52
60
  productId: z.ZodNumber;
53
61
  productIndex: z.ZodNumber;
54
62
  }, z.core.$strict>>;
63
+ mode: z.ZodOptional<z.ZodEnum<{
64
+ purchase: "purchase";
65
+ upgrade: "upgrade";
66
+ }>>;
55
67
  progressRevision: z.ZodOptional<z.ZodNumber>;
56
68
  selection: z.ZodObject<{
57
69
  productId: z.ZodNumber;
@@ -116,6 +128,10 @@ export declare const PurchaseRequestSchema: z.ZodObject<{
116
128
  productId: z.ZodNumber;
117
129
  productIndex: z.ZodNumber;
118
130
  }, z.core.$strict>>;
131
+ mode: z.ZodOptional<z.ZodEnum<{
132
+ purchase: "purchase";
133
+ upgrade: "upgrade";
134
+ }>>;
119
135
  progressRevision: z.ZodOptional<z.ZodNumber>;
120
136
  selection: z.ZodObject<{
121
137
  productId: z.ZodNumber;
@@ -129,7 +145,15 @@ export declare const PurchaseRequestSchema: z.ZodObject<{
129
145
  export declare const PurchaseReceiptSchema: z.ZodObject<{
130
146
  admittedAt: z.ZodNumber;
131
147
  changesetToken: z.ZodString;
148
+ mode: z.ZodOptional<z.ZodEnum<{
149
+ purchase: "purchase";
150
+ upgrade: "upgrade";
151
+ }>>;
132
152
  operationId: z.ZodUUID;
153
+ originalLine: z.ZodOptional<z.ZodObject<{
154
+ quantity: z.ZodNumber;
155
+ variantId: z.ZodNumber;
156
+ }, z.core.$strict>>;
133
157
  requiresSubscriptionConsent: z.ZodBoolean;
134
158
  selection: z.ZodObject<{
135
159
  productId: z.ZodNumber;
@@ -142,7 +166,15 @@ export declare const PurchaseResponseSchema: z.ZodObject<{
142
166
  data: z.ZodObject<{
143
167
  admittedAt: z.ZodNumber;
144
168
  changesetToken: z.ZodString;
169
+ mode: z.ZodOptional<z.ZodEnum<{
170
+ purchase: "purchase";
171
+ upgrade: "upgrade";
172
+ }>>;
145
173
  operationId: z.ZodUUID;
174
+ originalLine: z.ZodOptional<z.ZodObject<{
175
+ quantity: z.ZodNumber;
176
+ variantId: z.ZodNumber;
177
+ }, z.core.$strict>>;
146
178
  requiresSubscriptionConsent: z.ZodBoolean;
147
179
  selection: z.ZodObject<{
148
180
  productId: z.ZodNumber;
@@ -156,3 +188,4 @@ export declare const PurchaseResponseSchema: z.ZodObject<{
156
188
  export type PurchaseReceipt = z.infer<typeof PurchaseReceiptSchema>;
157
189
  export type PurchaseExpected = z.infer<typeof PurchaseExpectedSchema>;
158
190
  export type PurchaseRequest = z.infer<typeof PurchaseRequestSchema>;
191
+ export type PurchaseAdmissionMode = z.infer<typeof PurchaseAdmissionModeSchema>;
@@ -125,6 +125,53 @@ export declare const AcceptedFollowupsResponseSchema: z.ZodObject<{
125
125
  recordedAt: z.ZodNumber;
126
126
  operationId: z.ZodUUID;
127
127
  }, z.core.$strict>;
128
+ upgrade: z.ZodOptional<z.ZodObject<{
129
+ compensation: z.ZodNullable<z.ZodUnion<readonly [z.ZodObject<{
130
+ attemptedAt: z.ZodNumber;
131
+ status: z.ZodLiteral<"attempted">;
132
+ }, z.core.$strict>, z.ZodObject<{
133
+ attemptedAt: z.ZodNumber;
134
+ finishedAt: z.ZodNumber;
135
+ status: z.ZodEnum<{
136
+ unknown: "unknown";
137
+ failed: "failed";
138
+ removed: "removed";
139
+ }>;
140
+ }, z.core.$strict>]>>;
141
+ operationId: z.ZodUUID;
142
+ refund: z.ZodNullable<z.ZodUnion<readonly [z.ZodObject<{
143
+ attemptedAt: z.ZodNumber;
144
+ status: z.ZodLiteral<"attempted">;
145
+ }, z.core.$strict>, z.ZodObject<{
146
+ attemptedAt: z.ZodNumber;
147
+ finishedAt: z.ZodNumber;
148
+ refundId: z.ZodString;
149
+ status: z.ZodLiteral<"refunded">;
150
+ }, z.core.$strict>, z.ZodObject<{
151
+ attemptedAt: z.ZodNumber;
152
+ finishedAt: z.ZodNumber;
153
+ status: z.ZodEnum<{
154
+ unknown: "unknown";
155
+ failed: "failed";
156
+ }>;
157
+ }, z.core.$strict>]>>;
158
+ review: z.ZodNullable<z.ZodObject<{
159
+ markedAt: z.ZodNumber;
160
+ marker: z.ZodUnion<readonly [z.ZodEnum<{
161
+ unknown: "unknown";
162
+ acknowledged: "acknowledged";
163
+ rejected: "rejected";
164
+ }>, z.ZodEnum<{
165
+ attempted: "attempted";
166
+ unavailable: "unavailable";
167
+ }>]>;
168
+ reason: z.ZodEnum<{
169
+ "refund-unknown": "refund-unknown";
170
+ "compensation-failed": "compensation-failed";
171
+ "compensation-unknown": "compensation-unknown";
172
+ }>;
173
+ }, z.core.$strict>>;
174
+ }, z.core.$strict>>;
128
175
  }, z.core.$strip>;
129
176
  successful: z.ZodLiteral<true>;
130
177
  }, z.core.$strip>;
@@ -5,6 +5,44 @@ export declare const PostPurchaseProductCollectionView: z.ZodObject<{
5
5
  productId: z.ZodNumber;
6
6
  productIndex: z.ZodNumber;
7
7
  view: z.ZodUnion<readonly [z.ZodObject<{
8
+ changeset: z.ZodOptional<z.ZodObject<{
9
+ changes: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
10
+ discount: z.ZodOptional<z.ZodObject<{
11
+ title: z.ZodString;
12
+ value: z.ZodNumber;
13
+ valueType: z.ZodEnum<{
14
+ fixed_amount: "fixed_amount";
15
+ percentage: "percentage";
16
+ }>;
17
+ }, z.core.$strip>>;
18
+ quantity: z.ZodNumber;
19
+ type: z.ZodLiteral<"add_variant">;
20
+ variantId: z.ZodNumber;
21
+ }, z.core.$strip>, z.ZodObject<{
22
+ price: z.ZodNumber;
23
+ title: z.ZodString;
24
+ type: z.ZodLiteral<"add_shipping_line">;
25
+ }, z.core.$strip>, z.ZodObject<{
26
+ initialShippingPrice: z.ZodNumber;
27
+ recurringShippingPrice: z.ZodNumber;
28
+ shippingOption: z.ZodObject<{
29
+ presentmentTitle: z.ZodString;
30
+ title: z.ZodString;
31
+ }, z.core.$strip>;
32
+ discount: z.ZodOptional<z.ZodObject<{
33
+ title: z.ZodString;
34
+ value: z.ZodNumber;
35
+ valueType: z.ZodEnum<{
36
+ fixed_amount: "fixed_amount";
37
+ percentage: "percentage";
38
+ }>;
39
+ }, z.core.$strip>>;
40
+ quantity: z.ZodNumber;
41
+ sellingPlanId: z.ZodNumber;
42
+ type: z.ZodLiteral<"add_subscription">;
43
+ variantId: z.ZodNumber;
44
+ }, z.core.$strip>]>>;
45
+ }, z.core.$strip>>;
8
46
  groupCatalog: z.ZodOptional<z.ZodObject<{
9
47
  memberProductId: z.ZodNumber;
10
48
  options: z.ZodArray<z.ZodObject<{
@@ -2,8 +2,48 @@ import { z } from 'zod';
2
2
  /**
3
3
  * A prepared view shows exactly one description: plain `description`, or — when the merchant's rich
4
4
  * description wins the precedence — `description: null` with the standard-shape `descriptionDocument`.
5
+ * Only a prepared view may carry `changeset`: the unsigned changeset the server derived from this very
6
+ * preparation (the one admission later rebuilds and signs), ready for Shopify's `calculateChangeset`.
5
7
  */
6
8
  export declare const PostPurchaseProductView: z.ZodUnion<readonly [z.ZodObject<{
9
+ changeset: z.ZodOptional<z.ZodObject<{
10
+ changes: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
11
+ discount: z.ZodOptional<z.ZodObject<{
12
+ title: z.ZodString;
13
+ value: z.ZodNumber;
14
+ valueType: z.ZodEnum<{
15
+ fixed_amount: "fixed_amount";
16
+ percentage: "percentage";
17
+ }>;
18
+ }, z.core.$strip>>;
19
+ quantity: z.ZodNumber;
20
+ type: z.ZodLiteral<"add_variant">;
21
+ variantId: z.ZodNumber;
22
+ }, z.core.$strip>, z.ZodObject<{
23
+ price: z.ZodNumber;
24
+ title: z.ZodString;
25
+ type: z.ZodLiteral<"add_shipping_line">;
26
+ }, z.core.$strip>, z.ZodObject<{
27
+ initialShippingPrice: z.ZodNumber;
28
+ recurringShippingPrice: z.ZodNumber;
29
+ shippingOption: z.ZodObject<{
30
+ presentmentTitle: z.ZodString;
31
+ title: z.ZodString;
32
+ }, z.core.$strip>;
33
+ discount: z.ZodOptional<z.ZodObject<{
34
+ title: z.ZodString;
35
+ value: z.ZodNumber;
36
+ valueType: z.ZodEnum<{
37
+ fixed_amount: "fixed_amount";
38
+ percentage: "percentage";
39
+ }>;
40
+ }, z.core.$strip>>;
41
+ quantity: z.ZodNumber;
42
+ sellingPlanId: z.ZodNumber;
43
+ type: z.ZodLiteral<"add_subscription">;
44
+ variantId: z.ZodNumber;
45
+ }, z.core.$strip>]>>;
46
+ }, z.core.$strip>>;
7
47
  groupCatalog: z.ZodOptional<z.ZodObject<{
8
48
  memberProductId: z.ZodNumber;
9
49
  options: z.ZodArray<z.ZodObject<{
@@ -39,6 +39,53 @@ export declare const PurchaseRecoveryResponseSchema: z.ZodObject<{
39
39
  recordedAt: z.ZodNumber;
40
40
  }, z.core.$strict>>;
41
41
  operationId: z.ZodUUID;
42
+ upgrade: z.ZodOptional<z.ZodObject<{
43
+ compensation: z.ZodNullable<z.ZodUnion<readonly [z.ZodObject<{
44
+ attemptedAt: z.ZodNumber;
45
+ status: z.ZodLiteral<"attempted">;
46
+ }, z.core.$strict>, z.ZodObject<{
47
+ attemptedAt: z.ZodNumber;
48
+ finishedAt: z.ZodNumber;
49
+ status: z.ZodEnum<{
50
+ unknown: "unknown";
51
+ failed: "failed";
52
+ removed: "removed";
53
+ }>;
54
+ }, z.core.$strict>]>>;
55
+ operationId: z.ZodUUID;
56
+ refund: z.ZodNullable<z.ZodUnion<readonly [z.ZodObject<{
57
+ attemptedAt: z.ZodNumber;
58
+ status: z.ZodLiteral<"attempted">;
59
+ }, z.core.$strict>, z.ZodObject<{
60
+ attemptedAt: z.ZodNumber;
61
+ finishedAt: z.ZodNumber;
62
+ refundId: z.ZodString;
63
+ status: z.ZodLiteral<"refunded">;
64
+ }, z.core.$strict>, z.ZodObject<{
65
+ attemptedAt: z.ZodNumber;
66
+ finishedAt: z.ZodNumber;
67
+ status: z.ZodEnum<{
68
+ unknown: "unknown";
69
+ failed: "failed";
70
+ }>;
71
+ }, z.core.$strict>]>>;
72
+ review: z.ZodNullable<z.ZodObject<{
73
+ markedAt: z.ZodNumber;
74
+ marker: z.ZodUnion<readonly [z.ZodEnum<{
75
+ unknown: "unknown";
76
+ acknowledged: "acknowledged";
77
+ rejected: "rejected";
78
+ }>, z.ZodEnum<{
79
+ attempted: "attempted";
80
+ unavailable: "unavailable";
81
+ }>]>;
82
+ reason: z.ZodEnum<{
83
+ "refund-unknown": "refund-unknown";
84
+ "compensation-failed": "compensation-failed";
85
+ "compensation-unknown": "compensation-unknown";
86
+ }>;
87
+ }, z.core.$strict>>;
88
+ }, z.core.$strict>>;
42
89
  }, z.core.$strict>>;
43
90
  progress: z.ZodOptional<z.ZodNullable<z.ZodObject<{
44
91
  closedAt: z.ZodNullable<z.ZodNumber>;
@@ -0,0 +1,117 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * apiv2 `refund-product` for the upgrade's original one-time line. `failed` is a known refusal (nothing was
4
+ * refunded); `unknown` is a lost or ambiguous answer, which is never retried and never compensated blindly.
5
+ */
6
+ export declare const UpgradeRefundProgressSchema: z.ZodUnion<readonly [z.ZodObject<{
7
+ attemptedAt: z.ZodNumber;
8
+ status: z.ZodLiteral<"attempted">;
9
+ }, z.core.$strict>, z.ZodObject<{
10
+ attemptedAt: z.ZodNumber;
11
+ finishedAt: z.ZodNumber;
12
+ refundId: z.ZodString;
13
+ status: z.ZodLiteral<"refunded">;
14
+ }, z.core.$strict>, z.ZodObject<{
15
+ attemptedAt: z.ZodNumber;
16
+ finishedAt: z.ZodNumber;
17
+ status: z.ZodEnum<{
18
+ unknown: "unknown";
19
+ failed: "failed";
20
+ }>;
21
+ }, z.core.$strict>]>;
22
+ /** apiv2 `remove-subscription-product`: the rollback that runs only after a known refund failure. */
23
+ export declare const UpgradeCompensationProgressSchema: z.ZodUnion<readonly [z.ZodObject<{
24
+ attemptedAt: z.ZodNumber;
25
+ status: z.ZodLiteral<"attempted">;
26
+ }, z.core.$strict>, z.ZodObject<{
27
+ attemptedAt: z.ZodNumber;
28
+ finishedAt: z.ZodNumber;
29
+ status: z.ZodEnum<{
30
+ unknown: "unknown";
31
+ failed: "failed";
32
+ removed: "removed";
33
+ }>;
34
+ }, z.core.$strict>]>;
35
+ /**
36
+ * Why the upgrade is left for a person; `marker` is the `subscription_rollback_failed` metafield write. A
37
+ * `marker` of `unavailable` means the marker could not be written, NOT that no review is needed: the review
38
+ * stands whatever the marker status.
39
+ */
40
+ export declare const UpgradeReviewReasonSchema: z.ZodEnum<{
41
+ "refund-unknown": "refund-unknown";
42
+ "compensation-failed": "compensation-failed";
43
+ "compensation-unknown": "compensation-unknown";
44
+ }>;
45
+ export declare const UpgradeReviewProgressSchema: z.ZodObject<{
46
+ markedAt: z.ZodNumber;
47
+ marker: z.ZodUnion<readonly [z.ZodEnum<{
48
+ unknown: "unknown";
49
+ acknowledged: "acknowledged";
50
+ rejected: "rejected";
51
+ }>, z.ZodEnum<{
52
+ attempted: "attempted";
53
+ unavailable: "unavailable";
54
+ }>]>;
55
+ reason: z.ZodEnum<{
56
+ "refund-unknown": "refund-unknown";
57
+ "compensation-failed": "compensation-failed";
58
+ "compensation-unknown": "compensation-unknown";
59
+ }>;
60
+ }, z.core.$strict>;
61
+ /**
62
+ * The refund-compensation saga of one admitted upgrade, `null` steps not yet started. Compensation follows a
63
+ * known refund failure only, and a review is recorded exactly when the outcome is unresolved (an unknown
64
+ * refund, or a failed or unknown rollback), so a compensated or unresolved upgrade never reads as upgraded.
65
+ */
66
+ export declare const UpgradeProgressSchema: z.ZodObject<{
67
+ compensation: z.ZodNullable<z.ZodUnion<readonly [z.ZodObject<{
68
+ attemptedAt: z.ZodNumber;
69
+ status: z.ZodLiteral<"attempted">;
70
+ }, z.core.$strict>, z.ZodObject<{
71
+ attemptedAt: z.ZodNumber;
72
+ finishedAt: z.ZodNumber;
73
+ status: z.ZodEnum<{
74
+ unknown: "unknown";
75
+ failed: "failed";
76
+ removed: "removed";
77
+ }>;
78
+ }, z.core.$strict>]>>;
79
+ operationId: z.ZodUUID;
80
+ refund: z.ZodNullable<z.ZodUnion<readonly [z.ZodObject<{
81
+ attemptedAt: z.ZodNumber;
82
+ status: z.ZodLiteral<"attempted">;
83
+ }, z.core.$strict>, z.ZodObject<{
84
+ attemptedAt: z.ZodNumber;
85
+ finishedAt: z.ZodNumber;
86
+ refundId: z.ZodString;
87
+ status: z.ZodLiteral<"refunded">;
88
+ }, z.core.$strict>, z.ZodObject<{
89
+ attemptedAt: z.ZodNumber;
90
+ finishedAt: z.ZodNumber;
91
+ status: z.ZodEnum<{
92
+ unknown: "unknown";
93
+ failed: "failed";
94
+ }>;
95
+ }, z.core.$strict>]>>;
96
+ review: z.ZodNullable<z.ZodObject<{
97
+ markedAt: z.ZodNumber;
98
+ marker: z.ZodUnion<readonly [z.ZodEnum<{
99
+ unknown: "unknown";
100
+ acknowledged: "acknowledged";
101
+ rejected: "rejected";
102
+ }>, z.ZodEnum<{
103
+ attempted: "attempted";
104
+ unavailable: "unavailable";
105
+ }>]>;
106
+ reason: z.ZodEnum<{
107
+ "refund-unknown": "refund-unknown";
108
+ "compensation-failed": "compensation-failed";
109
+ "compensation-unknown": "compensation-unknown";
110
+ }>;
111
+ }, z.core.$strict>>;
112
+ }, z.core.$strict>;
113
+ export type UpgradeCompensationProgress = z.infer<typeof UpgradeCompensationProgressSchema>;
114
+ export type UpgradeProgress = z.infer<typeof UpgradeProgressSchema>;
115
+ export type UpgradeRefundProgress = z.infer<typeof UpgradeRefundProgressSchema>;
116
+ export type UpgradeReviewProgress = z.infer<typeof UpgradeReviewProgressSchema>;
117
+ export type UpgradeReviewReason = z.infer<typeof UpgradeReviewReasonSchema>;