@rebuy/rebuy 3.35.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.
Files changed (31) hide show
  1. package/dist/index.cjs +689 -571
  2. package/dist/index.mjs +689 -571
  3. package/dist/schema/index.d.ts +3 -0
  4. package/dist/schema/postPurchaseGroup.d.ts +15 -0
  5. package/dist/schema/postPurchaseProduct.d.ts +74 -24
  6. package/dist/schema/postPurchaseProductCalculation.d.ts +87 -0
  7. package/dist/schema/postPurchaseProductCollectionView.d.ts +724 -3
  8. package/dist/schema/postPurchaseProductDisplay.d.ts +41 -12
  9. package/dist/schema/postPurchaseProductView.d.ts +708 -0
  10. package/dist/schema/postPurchaseQuantity.d.ts +16 -3
  11. package/dist/schema/postPurchaseSubscriptionProduct.d.ts +74 -17
  12. package/dist/server/__fixtures__/postPurchaseGroup.d.ts +3 -0
  13. package/dist/server/index.cjs +818 -310
  14. package/dist/server/index.d.ts +13 -2
  15. package/dist/server/index.mjs +818 -310
  16. package/dist/server/postPurchaseProductDisplay.d.ts +38 -6
  17. package/dist/server/preparePostPurchaseAdmissionView.d.ts +418 -0
  18. package/dist/server/preparePostPurchaseCollectionGroup.d.ts +458 -0
  19. package/dist/server/preparePostPurchaseCollectionView.d.ts +442 -0
  20. package/dist/server/preparePostPurchaseGroupAdmissionView.d.ts +459 -0
  21. package/dist/server/preparePostPurchaseGroupDefault.d.ts +459 -0
  22. package/dist/server/preparePostPurchaseGroupView.d.ts +458 -0
  23. package/dist/server/preparePostPurchaseMemberView.d.ts +1466 -0
  24. package/dist/server/preparePostPurchaseProduct.d.ts +11 -0
  25. package/dist/server/preparePostPurchaseQuantityAdmissionView.d.ts +440 -0
  26. package/dist/server/preparePostPurchaseQuantityView.d.ts +427 -0
  27. package/dist/server/preparePostPurchaseSubscription.d.ts +37 -5
  28. package/dist/server/preparePostPurchaseView.d.ts +8 -0
  29. package/dist/server/projectPostPurchaseProduct.d.ts +37 -5
  30. package/dist/transforms/postPurchase/convertDescriptionRte.d.ts +11 -0
  31. package/package.json +1 -1
@@ -0,0 +1,427 @@
1
+ import type { PostPurchaseExcludedProductIds } from '../schema/postPurchaseProductCollectionView';
2
+ import { PostPurchaseQuantityChoice } from '../schema/postPurchaseQuantity';
3
+ import type { PostPurchaseVariantDefaultContext } from '../schema/postPurchaseVariantDefaultContext';
4
+ import type { Reporter } from '../server/shared';
5
+ /** Explicit pure capability; existing consumer preparation keeps its fixed-quantity guards. */
6
+ export declare const preparePostPurchaseQuantityView: (widgetId: number, settings: unknown, response: unknown, requested: PostPurchaseQuantityChoice, report?: Reporter, excludedProductIds?: PostPurchaseExcludedProductIds, defaults?: PostPurchaseVariantDefaultContext) => {
7
+ quantityPolicy: {
8
+ enabled: boolean;
9
+ initialQuantity: number;
10
+ maxValue: number;
11
+ minValue: number;
12
+ };
13
+ productId: number;
14
+ productIndex: number;
15
+ view: {
16
+ preparation: {
17
+ labels: {
18
+ declineAll: string;
19
+ free: string;
20
+ payNow: string;
21
+ quantity: string;
22
+ recurringShipping: string;
23
+ recurringSubtotal: string;
24
+ save: string;
25
+ shipping: string;
26
+ subtotal: string;
27
+ taxes: string;
28
+ total: string;
29
+ };
30
+ product: {
31
+ title: string;
32
+ id: number;
33
+ variant: {
34
+ title: string;
35
+ compareAtPrice: string | null;
36
+ id: number;
37
+ price: string;
38
+ };
39
+ image?: {
40
+ src: string;
41
+ } | null | undefined;
42
+ description?: string | null | undefined;
43
+ };
44
+ selection: {
45
+ productId: number;
46
+ quantity: number;
47
+ variantId: number;
48
+ sellingPlanId?: number | undefined;
49
+ };
50
+ status: "prepared";
51
+ terms: {
52
+ discount: {
53
+ amount: number;
54
+ title: string;
55
+ type: "none" | "fixed_amount" | "percentage";
56
+ };
57
+ shipping: {
58
+ amount: number;
59
+ title: string;
60
+ type: "fixed_amount" | "free";
61
+ };
62
+ subscription?: {
63
+ initialShippingPrice: number;
64
+ intervalLabel: string;
65
+ name: string;
66
+ recurringShippingPrice: number;
67
+ shippingOption: {
68
+ presentmentTitle: string;
69
+ title: string;
70
+ };
71
+ adjustment?: {
72
+ amount: number;
73
+ type: "price" | "fixed_amount" | "percentage";
74
+ } | undefined;
75
+ } | undefined;
76
+ };
77
+ display: {
78
+ discountedFrom: "price" | "compare_at_price";
79
+ language: {
80
+ description: string;
81
+ descriptionEnabled: boolean;
82
+ };
83
+ primaryImage: {
84
+ description: string;
85
+ source: string;
86
+ };
87
+ productOptions: {
88
+ showShipping: boolean;
89
+ showSubtotal: boolean;
90
+ showTaxes: boolean;
91
+ showTotal: boolean;
92
+ showVariantSelectors: boolean;
93
+ showDeclineAll?: "none" | "both" | "above" | "below" | undefined;
94
+ };
95
+ responseDescription: string;
96
+ shouldShowSavingText: boolean;
97
+ description: string | null;
98
+ descriptionDocument?: {
99
+ attrs: {
100
+ blockSpacing?: "none" | "base" | "extraTight" | "tight" | "loose" | "extraLoose" | undefined;
101
+ };
102
+ content: never[] | {
103
+ attrs: {
104
+ textAlign?: "start" | "center" | "end" | undefined;
105
+ };
106
+ content: never[] | {
107
+ text: string;
108
+ type: "text";
109
+ marks?: never[] | ({
110
+ type: "bold";
111
+ } | {
112
+ type: "italic";
113
+ } | {
114
+ attrs: {
115
+ class: string | null;
116
+ href: string;
117
+ rel: string;
118
+ target: string;
119
+ };
120
+ type: "link";
121
+ } | {
122
+ type: "strike";
123
+ } | {
124
+ attrs: {
125
+ color: "success" | "warning" | "critical" | "base" | "decorative" | "subdued" | "accent";
126
+ fontSize: "small" | "base" | "large" | "medium" | "extraSmall" | "extraLarge" | "heading";
127
+ };
128
+ type: "textStyle";
129
+ })[] | undefined;
130
+ }[];
131
+ type: "paragraph";
132
+ }[];
133
+ type: "doc";
134
+ } | undefined;
135
+ gallery?: {
136
+ images: {
137
+ description: string;
138
+ id: number;
139
+ source: string;
140
+ thumbnail: string;
141
+ }[];
142
+ selectedImageId?: number | undefined;
143
+ } | undefined;
144
+ };
145
+ };
146
+ sections: {
147
+ alignment: {
148
+ horizontal: "start" | "center" | "end";
149
+ vertical: "top" | "middle" | "bottom";
150
+ };
151
+ border: {
152
+ radius: "small" | "none" | "base" | "large" | "fullyRounded";
153
+ style: "none" | "base" | "dotted" | "dashed";
154
+ width: "base" | "medium" | "thick";
155
+ };
156
+ direction: "columns" | "rows" | "grid";
157
+ padding: "none" | "base" | "extraTight" | "tight" | "loose" | "extraLoose";
158
+ sectionId: string;
159
+ sections: never[] | import("..").CABSection[];
160
+ sectionType: "layout";
161
+ spacing: "none" | "base" | "extraTight" | "tight" | "loose" | "extraLoose";
162
+ width: number;
163
+ editorMode: "checkoutExtension" | "postPurchaseOffer" | "thankYouPage" | "orderStatusPage" | "ordersIndexPage" | "customerProfilePage";
164
+ previewMode: boolean;
165
+ storeId: number | null;
166
+ targetArea: {
167
+ icon: string;
168
+ label: string;
169
+ width: string;
170
+ fill?: boolean | undefined;
171
+ flip?: "vertical" | "horizontal" | "both" | undefined;
172
+ } | null;
173
+ tracking: {
174
+ enableAttribution: boolean;
175
+ enableSource: boolean;
176
+ enableWidget: boolean;
177
+ };
178
+ type: "product" | "bundle_builder" | "cart" | "cart_subscription" | "dynamic_bundle" | "gift_with_purchase" | "placeholder" | "pre_purchase" | "product_addon" | "product_upsell" | "recharge_checkout" | "recharge_customer_portal" | "recharge_post_purchase" | "shopify_checkout" | "shopify_checkout_extension" | "shopify_post_purchase" | "shopify_post_purchase_extension" | "switch_to_subscription" | "ui_extension_ad" | "ui_extension_button" | "ui_extension_content_block" | "ui_extension_line_item_editor" | "ui_extension_progress_bar";
179
+ uiLabels: {
180
+ currentPage: Record<string, string>;
181
+ guest: Record<string, string>;
182
+ loadingOptions: Record<string, string>;
183
+ nextPage: Record<string, string>;
184
+ offerCarousel: Record<string, string>;
185
+ offerDialog: Record<string, string>;
186
+ page: Record<string, string>;
187
+ previousPage: Record<string, string>;
188
+ selected: Record<string, string>;
189
+ subscriptionOptions: Record<string, string>;
190
+ updating: Record<string, string>;
191
+ };
192
+ version: 2;
193
+ widgetId: number | null;
194
+ buttonField?: "declineAllOffers" | "declineOffer" | "removeFromOrder" | "undoAddToOrder" | "activePage" | "addedToCart" | "addingToCart" | "addToCart" | "buttonLabel" | "destinationUrl" | "inactivePage" | "overlayContent" | "payNow" | "progressReached" | "progressRemaining" | "redirectToCheckout" | "showVariant" | "showVariants" | "soldOut" | "subscriptionOption" | "switchToOneTimePurchase" | "switchToSubscriptionNoDiscount" | "switchToSubscriptionWithDiscount" | undefined;
195
+ frame?: "callout" | "offer-content" | undefined;
196
+ grid?: {
197
+ columns: (string | number)[];
198
+ rows: (string | number)[];
199
+ } | undefined;
200
+ name?: string | undefined;
201
+ viewUrl?: string | undefined;
202
+ wrapping?: {
203
+ breakAt: number;
204
+ maxPerLine: number;
205
+ } | undefined;
206
+ mutators?: {
207
+ effect: "set_false" | "set_true" | "toggle";
208
+ variable: string;
209
+ when: {
210
+ operator: "is_empty" | "is_not_empty";
211
+ type: "content";
212
+ } | {
213
+ operator: "equals" | "greater_than" | "less_than";
214
+ type: "result_count";
215
+ value: number;
216
+ } | {
217
+ operator: "contains" | "does_not_contain";
218
+ type: "result_tag";
219
+ value: string;
220
+ } | {
221
+ event: "item_added" | "quantity_changed" | "variant_selected";
222
+ type: "event";
223
+ };
224
+ }[] | undefined;
225
+ variables?: ({
226
+ defaultValue: string;
227
+ name: string;
228
+ type: "text";
229
+ seed?: undefined;
230
+ } | {
231
+ defaultValue: number;
232
+ name: string;
233
+ type: "number";
234
+ seed?: undefined;
235
+ } | {
236
+ defaultValue: boolean;
237
+ name: string;
238
+ type: "boolean";
239
+ seed?: {
240
+ dataSourceId: number | null;
241
+ ruleset: {
242
+ exitIfMatched: boolean;
243
+ logic: {
244
+ rules: {
245
+ operator: "equals" | "greater_than" | "less_than" | "contains" | "does_not_contain" | "after" | "anything" | "before" | "contains_any" | "does_not_contain_any" | "does_not_equal";
246
+ products: never[] | unknown[];
247
+ type: "product" | "date" | "cart" | "cart_count" | "cart_item_count" | "cart_line_count" | "cart_subtotal" | "collection" | "customer" | "customer_order_count" | "customer_tag" | "customer_total_spent" | "product_tag" | "product_title" | "product_type" | "product_vendor";
248
+ value: string;
249
+ }[];
250
+ }[];
251
+ output: {
252
+ key: string;
253
+ type: "data_json";
254
+ value: string;
255
+ }[];
256
+ }[];
257
+ } | undefined;
258
+ })[] | undefined;
259
+ visibility?: {
260
+ variable: string;
261
+ visibleWhen: boolean;
262
+ } | undefined;
263
+ experiment?: {
264
+ elementId: number;
265
+ experimentId: number;
266
+ experimentType: string;
267
+ selectedId: number;
268
+ } | undefined;
269
+ };
270
+ groupCatalog?: {
271
+ memberProductId: number;
272
+ options: {
273
+ productId: number;
274
+ title: string;
275
+ variantCatalog: {
276
+ displayMode: "single" | "separate";
277
+ options: {
278
+ name: string;
279
+ values: string[];
280
+ id: number;
281
+ position: number;
282
+ }[];
283
+ productId: number;
284
+ showSelectors: boolean;
285
+ variants: {
286
+ available: boolean;
287
+ id: number;
288
+ title: string;
289
+ option1?: string | undefined;
290
+ option2?: string | null | undefined;
291
+ option3?: string | null | undefined;
292
+ imageId?: number | null | undefined;
293
+ }[];
294
+ };
295
+ }[];
296
+ } | undefined;
297
+ initialVariant?: {
298
+ variantId: number;
299
+ } | undefined;
300
+ planCatalog?: {
301
+ plans: {
302
+ id: number;
303
+ intervalLabel: string;
304
+ name: string;
305
+ adjustment?: {
306
+ amount: number;
307
+ type: "price" | "fixed_amount" | "percentage";
308
+ } | undefined;
309
+ intervalFrequency?: string | undefined;
310
+ }[];
311
+ productId: number;
312
+ requiresSellingPlan: boolean;
313
+ variantId: number;
314
+ } | null | undefined;
315
+ purchaseOptions?: {
316
+ defaultChoice: {
317
+ mode: "one-time";
318
+ } | {
319
+ mode: "subscription";
320
+ sellingPlanId: number;
321
+ };
322
+ modes: ("one-time" | "subscription")[];
323
+ selector: "radio" | "dropdown";
324
+ } | undefined;
325
+ variantCatalog?: {
326
+ displayMode: "single" | "separate";
327
+ options: {
328
+ name: string;
329
+ values: string[];
330
+ id: number;
331
+ position: number;
332
+ }[];
333
+ productId: number;
334
+ showSelectors: boolean;
335
+ variants: {
336
+ available: boolean;
337
+ id: number;
338
+ title: string;
339
+ option1?: string | undefined;
340
+ option2?: string | null | undefined;
341
+ option3?: string | null | undefined;
342
+ imageId?: number | null | undefined;
343
+ }[];
344
+ } | undefined;
345
+ } | {
346
+ preparation: {
347
+ reason: string;
348
+ status: "unsupported";
349
+ };
350
+ sections: null;
351
+ groupCatalog?: {
352
+ memberProductId: number;
353
+ options: {
354
+ productId: number;
355
+ title: string;
356
+ variantCatalog: {
357
+ displayMode: "single" | "separate";
358
+ options: {
359
+ name: string;
360
+ values: string[];
361
+ id: number;
362
+ position: number;
363
+ }[];
364
+ productId: number;
365
+ showSelectors: boolean;
366
+ variants: {
367
+ available: boolean;
368
+ id: number;
369
+ title: string;
370
+ option1?: string | undefined;
371
+ option2?: string | null | undefined;
372
+ option3?: string | null | undefined;
373
+ imageId?: number | null | undefined;
374
+ }[];
375
+ };
376
+ }[];
377
+ } | undefined;
378
+ initialVariant?: {
379
+ variantId: number;
380
+ } | undefined;
381
+ planCatalog?: {
382
+ plans: {
383
+ id: number;
384
+ intervalLabel: string;
385
+ name: string;
386
+ adjustment?: {
387
+ amount: number;
388
+ type: "price" | "fixed_amount" | "percentage";
389
+ } | undefined;
390
+ intervalFrequency?: string | undefined;
391
+ }[];
392
+ productId: number;
393
+ requiresSellingPlan: boolean;
394
+ variantId: number;
395
+ } | null | undefined;
396
+ purchaseOptions?: {
397
+ defaultChoice: {
398
+ mode: "one-time";
399
+ } | {
400
+ mode: "subscription";
401
+ sellingPlanId: number;
402
+ };
403
+ modes: ("one-time" | "subscription")[];
404
+ selector: "radio" | "dropdown";
405
+ } | undefined;
406
+ variantCatalog?: {
407
+ displayMode: "single" | "separate";
408
+ options: {
409
+ name: string;
410
+ values: string[];
411
+ id: number;
412
+ position: number;
413
+ }[];
414
+ productId: number;
415
+ showSelectors: boolean;
416
+ variants: {
417
+ available: boolean;
418
+ id: number;
419
+ title: string;
420
+ option1?: string | undefined;
421
+ option2?: string | null | undefined;
422
+ option3?: string | null | undefined;
423
+ imageId?: number | null | undefined;
424
+ }[];
425
+ } | undefined;
426
+ };
427
+ } | null;
@@ -6,11 +6,6 @@ export declare const preparePostPurchaseSubscription: (settings: unknown, respon
6
6
  language: {
7
7
  description: string;
8
8
  descriptionEnabled: boolean;
9
- descriptionRte?: {
10
- content: unknown[];
11
- type: string;
12
- } | undefined;
13
- descriptionSpacing?: "default" | "none" | "tight" | "loose" | "xtight" | "xloose" | undefined;
14
9
  };
15
10
  primaryImage: {
16
11
  description: string;
@@ -26,6 +21,43 @@ export declare const preparePostPurchaseSubscription: (settings: unknown, respon
26
21
  };
27
22
  responseDescription: string;
28
23
  shouldShowSavingText: boolean;
24
+ descriptionDocument?: {
25
+ attrs: {
26
+ blockSpacing?: "none" | "base" | "extraTight" | "tight" | "loose" | "extraLoose" | undefined;
27
+ };
28
+ content: never[] | {
29
+ attrs: {
30
+ textAlign?: "start" | "center" | "end" | undefined;
31
+ };
32
+ content: never[] | {
33
+ text: string;
34
+ type: "text";
35
+ marks?: never[] | ({
36
+ type: "bold";
37
+ } | {
38
+ type: "italic";
39
+ } | {
40
+ attrs: {
41
+ class: string | null;
42
+ href: string;
43
+ rel: string;
44
+ target: string;
45
+ };
46
+ type: "link";
47
+ } | {
48
+ type: "strike";
49
+ } | {
50
+ attrs: {
51
+ color: "success" | "warning" | "critical" | "base" | "decorative" | "subdued" | "accent";
52
+ fontSize: "small" | "base" | "large" | "medium" | "extraSmall" | "extraLarge" | "heading";
53
+ };
54
+ type: "textStyle";
55
+ })[] | undefined;
56
+ }[];
57
+ type: "paragraph";
58
+ }[];
59
+ type: "doc";
60
+ } | undefined;
29
61
  gallery?: {
30
62
  images: {
31
63
  description: string;
@@ -0,0 +1,8 @@
1
+ import type { PostPurchaseChoice } from '../schema/postPurchaseChoice';
2
+ import { PostPurchaseProductView } from '../schema/postPurchaseProductView';
3
+ import { normalizePostPurchaseProduct } from '../server/normalizePostPurchaseProduct';
4
+ import type { PostPurchaseQuantity } from '../server/readPostPurchaseQuantity';
5
+ import type { Reporter } from '../server/shared';
6
+ /** Convert from the same effective settings snapshot; no product values enter the section tree. */
7
+ export declare const prepareNormalizedPostPurchaseView: (widgetId: number, normalized: ReturnType<typeof normalizePostPurchaseProduct>, report?: Reporter, choice?: PostPurchaseChoice, quantity?: PostPurchaseQuantity, allowCollection?: boolean) => PostPurchaseProductView;
8
+ export declare const preparePostPurchaseView: (widgetId: number, settings: unknown, response: unknown, report?: Reporter, choice?: PostPurchaseChoice) => PostPurchaseProductView;
@@ -11,11 +11,6 @@ export declare const projectPostPurchaseProduct: ({ data, effective, metadata, o
11
11
  language: {
12
12
  description: string;
13
13
  descriptionEnabled: boolean;
14
- descriptionRte?: {
15
- content: unknown[];
16
- type: string;
17
- } | undefined;
18
- descriptionSpacing?: "default" | "none" | "tight" | "loose" | "xtight" | "xloose" | undefined;
19
14
  };
20
15
  primaryImage: {
21
16
  description: string;
@@ -31,6 +26,43 @@ export declare const projectPostPurchaseProduct: ({ data, effective, metadata, o
31
26
  };
32
27
  responseDescription: string;
33
28
  shouldShowSavingText: boolean;
29
+ descriptionDocument?: {
30
+ attrs: {
31
+ blockSpacing?: "none" | "base" | "extraTight" | "tight" | "loose" | "extraLoose" | undefined;
32
+ };
33
+ content: never[] | {
34
+ attrs: {
35
+ textAlign?: "start" | "center" | "end" | undefined;
36
+ };
37
+ content: never[] | {
38
+ text: string;
39
+ type: "text";
40
+ marks?: never[] | ({
41
+ type: "bold";
42
+ } | {
43
+ type: "italic";
44
+ } | {
45
+ attrs: {
46
+ class: string | null;
47
+ href: string;
48
+ rel: string;
49
+ target: string;
50
+ };
51
+ type: "link";
52
+ } | {
53
+ type: "strike";
54
+ } | {
55
+ attrs: {
56
+ color: "success" | "warning" | "critical" | "base" | "decorative" | "subdued" | "accent";
57
+ fontSize: "small" | "base" | "large" | "medium" | "extraSmall" | "extraLarge" | "heading";
58
+ };
59
+ type: "textStyle";
60
+ })[] | undefined;
61
+ }[];
62
+ type: "paragraph";
63
+ }[];
64
+ type: "doc";
65
+ } | undefined;
34
66
  gallery?: {
35
67
  images: {
36
68
  description: string;
@@ -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.35.0",
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.",