@kachingappz/bundles-js 1.1.3 → 1.1.4
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/bundles-js.iife.js +13 -10
- package/dist/index.d.ts +57 -9
- package/dist/index.js +86 -79
- package/dist/kaching-bundle-component/index.d.ts +57 -9
- package/dist/kaching-bundle-component/index.js +106 -99
- package/dist/react/index.cjs +13 -10
- package/dist/react/index.d.ts +57 -9
- package/dist/react/index.js +82 -75
- package/package.json +2 -2
package/dist/react/index.d.ts
CHANGED
|
@@ -66,6 +66,7 @@ declare interface BaseDealBar {
|
|
|
66
66
|
freeGiftsSummary?: FreeGiftsSummary | null;
|
|
67
67
|
multipleGiftsSelectors?: MultipleGiftsSelector[];
|
|
68
68
|
upsells: Upsell[];
|
|
69
|
+
sectionsOrder?: DealBarSection[];
|
|
69
70
|
productPersonalisation: ProductPersonalisation | null;
|
|
70
71
|
highlights?: Highlights | null;
|
|
71
72
|
sellingPlanEnabled?: boolean;
|
|
@@ -98,7 +99,7 @@ declare type BrandColorKey = (typeof BRAND_COLOR_KEYS)[number];
|
|
|
98
99
|
|
|
99
100
|
declare type BrandColors = Record<BrandColorKey, string>;
|
|
100
101
|
|
|
101
|
-
declare interface BundleDealBar extends BaseDealBar, ShowAsSoldOutFeature
|
|
102
|
+
declare interface BundleDealBar extends BaseDealBar, ShowAsSoldOutFeature {
|
|
102
103
|
dealBarType: DealBarType.Bundle;
|
|
103
104
|
layout?: "horizontal" | "vertical";
|
|
104
105
|
quantitySelector: boolean;
|
|
@@ -119,7 +120,7 @@ declare interface BundleProduct {
|
|
|
119
120
|
hidePrice?: boolean;
|
|
120
121
|
}
|
|
121
122
|
|
|
122
|
-
declare interface BxgyDealBar extends BaseDealBar, ShowAsSoldOutFeature
|
|
123
|
+
declare interface BxgyDealBar extends BaseDealBar, ShowAsSoldOutFeature {
|
|
123
124
|
dealBarType: DealBarType.Bxgy;
|
|
124
125
|
buyQuantity: number;
|
|
125
126
|
buyDiscountType?: DiscountType;
|
|
@@ -260,6 +261,8 @@ declare type DealBarProgressiveGiftStyle = {
|
|
|
260
261
|
lockedMediaImageGID: string | null;
|
|
261
262
|
};
|
|
262
263
|
|
|
264
|
+
declare type DealBarSection = (typeof DEFAULT_DEAL_BAR_SECTIONS_ORDER)[number];
|
|
265
|
+
|
|
263
266
|
declare enum DealBarType {
|
|
264
267
|
QuantityBreak = "quantity-break",
|
|
265
268
|
Bxgy = "bxgy",
|
|
@@ -297,6 +300,7 @@ declare type DealBlock = {
|
|
|
297
300
|
startTimestamp: number;
|
|
298
301
|
endTimestamp: number | null;
|
|
299
302
|
differentVariantsEnabled: boolean;
|
|
303
|
+
requireVariantSelectionEnabled?: boolean;
|
|
300
304
|
hideVariantPicker: boolean;
|
|
301
305
|
disableVariantOptionSync?: boolean;
|
|
302
306
|
hideUnavailableOptions?: boolean;
|
|
@@ -404,6 +408,8 @@ declare type DealBlock = {
|
|
|
404
408
|
lowStockAlert: LowStockAlert | null;
|
|
405
409
|
};
|
|
406
410
|
|
|
411
|
+
declare const DEFAULT_DEAL_BAR_SECTIONS_ORDER: readonly ["upsells", "freeGifts", "multipleGiftsSelectors"];
|
|
412
|
+
|
|
407
413
|
declare type DefaultSortOption = "relevance" | "newest-first" | "price-low-to-high" | "price-high-to-low";
|
|
408
414
|
|
|
409
415
|
declare type DiscountType = "default" | "percentage" | "amount" | "specific";
|
|
@@ -433,6 +439,7 @@ declare type FreeGift = {
|
|
|
433
439
|
text: string;
|
|
434
440
|
imageSize: number;
|
|
435
441
|
quantity: number;
|
|
442
|
+
matchQuantityWithDealBar?: boolean;
|
|
436
443
|
showPrice: boolean;
|
|
437
444
|
includeInCompareAt?: boolean;
|
|
438
445
|
applyOnlyForSubscriptions: boolean;
|
|
@@ -466,6 +473,7 @@ declare interface GlobalConfig {
|
|
|
466
473
|
ignoreUnitPrice: boolean;
|
|
467
474
|
requireCustomerLogin: boolean;
|
|
468
475
|
abTestsRunning: boolean;
|
|
476
|
+
cartKachingSessionId?: string | null;
|
|
469
477
|
webPixel: boolean;
|
|
470
478
|
b2bCustomer: boolean;
|
|
471
479
|
isLoggedIn: boolean;
|
|
@@ -581,6 +589,47 @@ declare interface GlobalConfig {
|
|
|
581
589
|
"system.deal_page_rating_count_other"?: string;
|
|
582
590
|
"system.deal_page_rating_count_few"?: string;
|
|
583
591
|
"system.deal_page_rating_count_many"?: string;
|
|
592
|
+
"system.deal_page_gift_badge_shipping"?: string;
|
|
593
|
+
"system.deal_page_gift_badge_one"?: string;
|
|
594
|
+
"system.deal_page_gift_badge_other"?: string;
|
|
595
|
+
"system.deal_page_gift_badge_few"?: string;
|
|
596
|
+
"system.deal_page_gift_badge_many"?: string;
|
|
597
|
+
"system.deal_page_gifts_title"?: string;
|
|
598
|
+
"system.deal_page_your_gifts_title"?: string;
|
|
599
|
+
"system.deal_page_free_shipping"?: string;
|
|
600
|
+
"system.deal_page_gift_unlocks_at_one"?: string;
|
|
601
|
+
"system.deal_page_gift_unlocks_at_other"?: string;
|
|
602
|
+
"system.deal_page_gift_unlocks_at_few"?: string;
|
|
603
|
+
"system.deal_page_gift_unlocks_at_many"?: string;
|
|
604
|
+
"system.deal_page_choose_option"?: string;
|
|
605
|
+
"system.deal_page_change"?: string;
|
|
606
|
+
"system.deal_page_choose_gift_option"?: string;
|
|
607
|
+
"system.deal_page_your_gifts_row_one"?: string;
|
|
608
|
+
"system.deal_page_your_gifts_row_other"?: string;
|
|
609
|
+
"system.deal_page_your_gifts_row_few"?: string;
|
|
610
|
+
"system.deal_page_your_gifts_row_many"?: string;
|
|
611
|
+
"system.deal_page_free"?: string;
|
|
612
|
+
"system.deal_page_gift_count_one"?: string;
|
|
613
|
+
"system.deal_page_gift_count_other"?: string;
|
|
614
|
+
"system.deal_page_gift_count_few"?: string;
|
|
615
|
+
"system.deal_page_gift_count_many"?: string;
|
|
616
|
+
"system.deal_page_percentage_gifts_unlocked"?: string;
|
|
617
|
+
"system.deal_page_box_of_gifts"?: string;
|
|
618
|
+
"system.deal_page_gifts_unlocked"?: string;
|
|
619
|
+
"system.deal_page_gift_phrase_shipping"?: string;
|
|
620
|
+
"system.deal_page_gift_phrase_one"?: string;
|
|
621
|
+
"system.deal_page_gift_phrase_other"?: string;
|
|
622
|
+
"system.deal_page_gift_phrase_few"?: string;
|
|
623
|
+
"system.deal_page_gift_phrase_many"?: string;
|
|
624
|
+
"system.deal_page_nudge_start_offer_one"?: string;
|
|
625
|
+
"system.deal_page_nudge_start_offer_other"?: string;
|
|
626
|
+
"system.deal_page_nudge_start_offer_few"?: string;
|
|
627
|
+
"system.deal_page_nudge_start_offer_many"?: string;
|
|
628
|
+
"system.deal_page_nudge_more_offer_one"?: string;
|
|
629
|
+
"system.deal_page_nudge_more_offer_other"?: string;
|
|
630
|
+
"system.deal_page_nudge_more_offer_few"?: string;
|
|
631
|
+
"system.deal_page_nudge_more_offer_many"?: string;
|
|
632
|
+
"system.deal_page_offer_with_gifts"?: string;
|
|
584
633
|
"system.deal_page_promotion_percentage"?: string;
|
|
585
634
|
};
|
|
586
635
|
customSelectors: {
|
|
@@ -597,7 +646,7 @@ declare interface GlobalConfig {
|
|
|
597
646
|
cart_interceptor_dedupe_disabled?: boolean;
|
|
598
647
|
debug_cart_add?: boolean;
|
|
599
648
|
disable_nested_cart_lines?: boolean;
|
|
600
|
-
|
|
649
|
+
early_xhr_wrapper?: boolean;
|
|
601
650
|
hide_missing_variants?: boolean;
|
|
602
651
|
initialize_with_form_variant?: boolean;
|
|
603
652
|
intercept_cart_request?: boolean;
|
|
@@ -722,7 +771,7 @@ declare interface MixAndMatchChooseProductModal {
|
|
|
722
771
|
buttonText: string;
|
|
723
772
|
}
|
|
724
773
|
|
|
725
|
-
declare interface MixAndMatchDealBar extends BaseDealBar, ShowAsSoldOutFeature
|
|
774
|
+
declare interface MixAndMatchDealBar extends BaseDealBar, ShowAsSoldOutFeature {
|
|
726
775
|
dealBarType: DealBarType.MixAndMatch;
|
|
727
776
|
discountType: DiscountType;
|
|
728
777
|
discountValue: string | number;
|
|
@@ -789,6 +838,7 @@ declare interface Product {
|
|
|
789
838
|
text4: string | null;
|
|
790
839
|
};
|
|
791
840
|
rating?: ProductRating | null;
|
|
841
|
+
subtitle?: string | null;
|
|
792
842
|
}
|
|
793
843
|
|
|
794
844
|
declare interface ProductOption {
|
|
@@ -834,6 +884,8 @@ declare type ProgressiveGift = {
|
|
|
834
884
|
mediaImageGID: string | null;
|
|
835
885
|
unlockAtBar: number;
|
|
836
886
|
unlockAtBarOnly?: boolean;
|
|
887
|
+
unlockAtScope?: "and-higher" | "only" | "custom";
|
|
888
|
+
unlockDealBarIds?: string[];
|
|
837
889
|
label: string;
|
|
838
890
|
labelCrossedOut: string;
|
|
839
891
|
title: string;
|
|
@@ -885,7 +937,7 @@ declare type ProgressiveGiftsStyle = {
|
|
|
885
937
|
lockedMediaImageGID: string | null;
|
|
886
938
|
};
|
|
887
939
|
|
|
888
|
-
declare interface QuantityBreakDealBar extends BaseDealBar, ShowAsSoldOutFeature
|
|
940
|
+
declare interface QuantityBreakDealBar extends BaseDealBar, ShowAsSoldOutFeature {
|
|
889
941
|
dealBarType?: DealBarType.QuantityBreak;
|
|
890
942
|
quantity: number | string;
|
|
891
943
|
discountType: DiscountType;
|
|
@@ -904,10 +956,6 @@ declare type RequireItemSelectionAlert = {
|
|
|
904
956
|
backgroundColor: Color;
|
|
905
957
|
};
|
|
906
958
|
|
|
907
|
-
declare interface RequireVariantSelectionFeature {
|
|
908
|
-
requireVariantSelectionEnabled?: boolean;
|
|
909
|
-
}
|
|
910
|
-
|
|
911
959
|
declare type SavingsSummary = {
|
|
912
960
|
title: string;
|
|
913
961
|
backgroundColor: Color;
|
package/dist/react/index.js
CHANGED
|
@@ -33,7 +33,23 @@ var a = (e, { language: t, country: n }) => {
|
|
|
33
33
|
i = t.metaobjects.pageInfo.endCursor;
|
|
34
34
|
}
|
|
35
35
|
return r;
|
|
36
|
-
}
|
|
36
|
+
};
|
|
37
|
+
[
|
|
38
|
+
"primaryBackground",
|
|
39
|
+
"secondaryBackground",
|
|
40
|
+
"primaryText",
|
|
41
|
+
"secondaryText",
|
|
42
|
+
"border",
|
|
43
|
+
"overlay",
|
|
44
|
+
"primaryAccent",
|
|
45
|
+
"primaryAccentText",
|
|
46
|
+
"badgeBackground",
|
|
47
|
+
"badgeText",
|
|
48
|
+
"error"
|
|
49
|
+
].map((e) => `brand_${e}`);
|
|
50
|
+
var g = /* @__PURE__ */ function(e) {
|
|
51
|
+
return e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e;
|
|
52
|
+
}({}), _ = async (e, { country: t, language: n, blockVisibility: r, excludedProductGIDs: i, selectedProductGIDs: a, selectedCollectionGIDs: o, limit: s = 1e3 }) => {
|
|
37
53
|
switch (r) {
|
|
38
54
|
case "selected-products": return a.slice(0, s);
|
|
39
55
|
case "all-products":
|
|
@@ -91,16 +107,16 @@ var a = (e, { language: t, country: n }) => {
|
|
|
91
107
|
return Array.from(new Set(i)).slice(0, s);
|
|
92
108
|
}
|
|
93
109
|
}
|
|
94
|
-
},
|
|
110
|
+
}, v = "\n id\n availableForSale\n price {\n amount\n }\n compareAtPrice {\n amount\n }\n selectedOptions {\n name\n value\n }\n image {\n id\n url(transform: $variantImageTransform)\n }\n unitPriceMeasurement {\n quantityUnit\n quantityValue\n referenceUnit\n referenceValue\n }\n requiresComponents\n sellingPlanAllocations(first: 100) @include(if: $includeSellingPlans) {\n nodes {\n sellingPlan {\n id\n }\n priceAdjustments {\n price {\n amount\n }\n compareAtPrice {\n amount\n }\n perDeliveryPrice {\n amount\n }\n }\n }\n }\n quantityAvailable @include(if: $includeAvailableQuantity)\n", y = async (e, { country: t, language: n, productIds: r, includeSellingPlans: i = !0, includeAvailableQuantity: a = !0, includeProductRating: o = !1, includeProductSubtitle: s = !1, productSubtitleMetafield: c = "descriptors.subtitle", useExternalMetafieldNamespace: l = !1, batchSize: u = 250, onBatchError: d, variantImageTransform: p = {
|
|
95
111
|
maxWidth: 200,
|
|
96
112
|
maxHeight: 200
|
|
97
113
|
} }) => {
|
|
98
114
|
if (!r.length) return [];
|
|
99
|
-
let
|
|
115
|
+
let m = r.map((e) => typeof e == "string" && e.startsWith("gid://") ? e : `gid://shopify/Product/${e}`), h = f({
|
|
100
116
|
country: t,
|
|
101
117
|
language: n
|
|
102
|
-
}),
|
|
103
|
-
query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $includeProductRating: Boolean!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${
|
|
118
|
+
}), g = `
|
|
119
|
+
query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $includeProductRating: Boolean!, $includeProductSubtitle: Boolean!, $subtitleNamespace: String!, $subtitleKey: String!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${h} {
|
|
104
120
|
shop {
|
|
105
121
|
currencyRateConstant: metafield(namespace: $metafieldNamespace, key: "currency_rate_constant") {
|
|
106
122
|
value
|
|
@@ -134,7 +150,7 @@ var a = (e, { language: t, country: n }) => {
|
|
|
134
150
|
}
|
|
135
151
|
variants(first: 250) {
|
|
136
152
|
nodes {
|
|
137
|
-
${
|
|
153
|
+
${v}
|
|
138
154
|
}
|
|
139
155
|
}
|
|
140
156
|
collections(first: 50) {
|
|
@@ -160,6 +176,9 @@ var a = (e, { language: t, country: n }) => {
|
|
|
160
176
|
reviewsRatingCount: metafield(namespace: "reviews", key: "rating_count") @include(if: $includeProductRating) {
|
|
161
177
|
value
|
|
162
178
|
}
|
|
179
|
+
subtitle: metafield(namespace: $subtitleNamespace, key: $subtitleKey) @include(if: $includeProductSubtitle) {
|
|
180
|
+
value
|
|
181
|
+
}
|
|
163
182
|
requiresSellingPlan
|
|
164
183
|
sellingPlanGroups(first: 100) @include(if: $includeSellingPlans) {
|
|
165
184
|
nodes {
|
|
@@ -192,40 +211,43 @@ var a = (e, { language: t, country: n }) => {
|
|
|
192
211
|
}
|
|
193
212
|
}
|
|
194
213
|
}
|
|
195
|
-
`,
|
|
196
|
-
for (let e = 0; e <
|
|
197
|
-
let
|
|
198
|
-
let n = await e.query(
|
|
214
|
+
`, _ = l ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", y = c.indexOf("."), S = c.slice(0, y), C = c.slice(y + 1), w = [], T = Math.min(u, 250);
|
|
215
|
+
for (let e = 0; e < m.length; e += T) w.push(m.slice(e, e + T));
|
|
216
|
+
let E = 1, D = async (t) => {
|
|
217
|
+
let n = await e.query(g, { variables: {
|
|
199
218
|
productGIDs: t,
|
|
200
219
|
includeSellingPlans: i,
|
|
201
220
|
includeAvailableQuantity: a,
|
|
202
221
|
includeProductRating: o,
|
|
203
|
-
|
|
204
|
-
|
|
222
|
+
includeProductSubtitle: s,
|
|
223
|
+
subtitleNamespace: S,
|
|
224
|
+
subtitleKey: C,
|
|
225
|
+
metafieldNamespace: _,
|
|
226
|
+
variantImageTransform: p
|
|
205
227
|
} });
|
|
206
|
-
return n.shop.currencyRateConstant && (
|
|
207
|
-
},
|
|
208
|
-
if (
|
|
209
|
-
let e = await Promise.allSettled(
|
|
210
|
-
for (let t of e) t.status === "rejected" &&
|
|
211
|
-
|
|
212
|
-
} else
|
|
213
|
-
let
|
|
214
|
-
if (
|
|
215
|
-
let t = await Promise.allSettled(
|
|
228
|
+
return n.shop.currencyRateConstant && (E = JSON.parse(n.shop.currencyRateConstant.value).amount / 1e6), n;
|
|
229
|
+
}, O;
|
|
230
|
+
if (d) {
|
|
231
|
+
let e = await Promise.allSettled(w.map(D));
|
|
232
|
+
for (let t of e) t.status === "rejected" && d(t.reason instanceof Error ? t.reason : Error(String(t.reason)));
|
|
233
|
+
O = e.filter((e) => e.status === "fulfilled").flatMap((e) => e.value.nodes);
|
|
234
|
+
} else O = (await Promise.all(w.map(D))).flatMap((e) => e.nodes);
|
|
235
|
+
let k = O.filter((e) => e != null);
|
|
236
|
+
if (d) {
|
|
237
|
+
let t = await Promise.allSettled(k.map(async (t) => x(await b(e, t, {
|
|
216
238
|
includeSellingPlans: i,
|
|
217
239
|
includeAvailableQuantity: a,
|
|
218
|
-
variantImageTransform:
|
|
219
|
-
},
|
|
220
|
-
for (let e of t) e.status === "fulfilled" ? n.push(e.value) :
|
|
240
|
+
variantImageTransform: p
|
|
241
|
+
}, h), e.shopifyDomain, E))), n = [];
|
|
242
|
+
for (let e of t) e.status === "fulfilled" ? n.push(e.value) : d(e.reason instanceof Error ? e.reason : Error(String(e.reason)));
|
|
221
243
|
return n;
|
|
222
244
|
}
|
|
223
|
-
return (await Promise.all(
|
|
245
|
+
return (await Promise.all(k.map((t) => b(e, t, {
|
|
224
246
|
includeSellingPlans: i,
|
|
225
247
|
includeAvailableQuantity: a,
|
|
226
|
-
variantImageTransform:
|
|
227
|
-
},
|
|
228
|
-
},
|
|
248
|
+
variantImageTransform: p
|
|
249
|
+
}, h)))).map((t) => x(t, e.shopifyDomain, E));
|
|
250
|
+
}, b = async (e, t, n, r = "") => {
|
|
229
251
|
if (t.variants.nodes.length < 250) return t;
|
|
230
252
|
let i = /* @__PURE__ */ new Set(), a = [], o = [], s = async (s) => {
|
|
231
253
|
let c = !0, l = null;
|
|
@@ -235,7 +257,7 @@ var a = (e, { language: t, country: n }) => {
|
|
|
235
257
|
product(id: $productGID) {
|
|
236
258
|
variants(first: 250, after: $cursor, reverse: $reverse) {
|
|
237
259
|
nodes {
|
|
238
|
-
${
|
|
260
|
+
${v}
|
|
239
261
|
}
|
|
240
262
|
pageInfo {
|
|
241
263
|
endCursor
|
|
@@ -261,7 +283,7 @@ var a = (e, { language: t, country: n }) => {
|
|
|
261
283
|
}
|
|
262
284
|
};
|
|
263
285
|
return await Promise.all([s(!1), s(!0)]), t.variants.nodes = [...a, ...o.reverse()], t;
|
|
264
|
-
},
|
|
286
|
+
}, x = (e, t, n) => {
|
|
265
287
|
let r = e.variants.nodes.map(({ unitPriceMeasurement: e, ...t }) => ({
|
|
266
288
|
id: Number(t.id.split("/").pop()),
|
|
267
289
|
availableForSale: t.availableForSale,
|
|
@@ -299,7 +321,7 @@ var a = (e, { language: t, country: n }) => {
|
|
|
299
321
|
defaultName: e.name,
|
|
300
322
|
name: e.name,
|
|
301
323
|
position: t + 1,
|
|
302
|
-
optionValues:
|
|
324
|
+
optionValues: w(n, t, r)
|
|
303
325
|
};
|
|
304
326
|
}), a = (e) => {
|
|
305
327
|
let t = e.priceAdjustments[0];
|
|
@@ -346,26 +368,27 @@ var a = (e, { language: t, country: n }) => {
|
|
|
346
368
|
text3: e.metafield3?.value || null,
|
|
347
369
|
text4: e.metafield4?.value || null
|
|
348
370
|
},
|
|
349
|
-
rating:
|
|
371
|
+
rating: S(e.reviewsRating, e.reviewsRatingCount),
|
|
372
|
+
subtitle: e.subtitle?.value || null
|
|
350
373
|
};
|
|
351
|
-
},
|
|
374
|
+
}, S = (e, t) => {
|
|
352
375
|
if (!e) return null;
|
|
353
|
-
let n =
|
|
376
|
+
let n = C(e.value);
|
|
354
377
|
if (n === null) return null;
|
|
355
378
|
let r = Number(t?.value);
|
|
356
379
|
return {
|
|
357
380
|
value: n,
|
|
358
381
|
count: Number.isInteger(r) && r > 0 ? r : null
|
|
359
382
|
};
|
|
360
|
-
},
|
|
383
|
+
}, C = (e) => {
|
|
361
384
|
try {
|
|
362
385
|
let { value: t, scale_max: n } = JSON.parse(e), r = Number(t) / Number(n) * 5;
|
|
363
386
|
return Number.isFinite(r) && r > 0 ? Math.min(5, r) : null;
|
|
364
387
|
} catch {
|
|
365
388
|
return null;
|
|
366
389
|
}
|
|
367
|
-
},
|
|
368
|
-
let i = r ? `${
|
|
390
|
+
}, w = (e, t, n) => e.filter((e) => n.filter((n) => n.options[t] === e.name).length > 0), T = "app--2935586817", E = async (e, { language: t, country: n, useExternalMetafieldNamespace: r }) => {
|
|
391
|
+
let i = r ? `${T}--kaching_bundles` : "$app:kaching_bundles", o = r ? T : "$app", s = f({ country: n }), { localization: { country: { currency: { isoCode: c } } }, shop: { moneyFormat: l, paymentSettings: { currencyCode: u }, currencyRateConstant: d, primaryDomain: p, settingsMetafield: m } } = await e.query(`
|
|
369
392
|
query config($metafieldNamespace: String!, $settingsNamespace: String!) ${s} {
|
|
370
393
|
localization {
|
|
371
394
|
country {
|
|
@@ -396,7 +419,7 @@ var a = (e, { language: t, country: n }) => {
|
|
|
396
419
|
} }), h = c === u ? l : a(c, {
|
|
397
420
|
language: t,
|
|
398
421
|
country: n
|
|
399
|
-
}), g = d ?
|
|
422
|
+
}), g = d ? D(d.value) : 1, _ = m ? JSON.parse(m.value) : null, v = _?.feature_flags ?? {}, y = _?.custom_selectors ?? {};
|
|
400
423
|
return {
|
|
401
424
|
shopifyDomain: p.host,
|
|
402
425
|
moneyFormat: h,
|
|
@@ -457,7 +480,7 @@ var a = (e, { language: t, country: n }) => {
|
|
|
457
480
|
featureFlags: v,
|
|
458
481
|
brandColors: _?.brand_colors ?? null
|
|
459
482
|
};
|
|
460
|
-
},
|
|
483
|
+
}, D = (e) => JSON.parse(e).amount / 1e6, O = async (e, t, n = 200) => {
|
|
461
484
|
let r = [...new Set(t.filter(Boolean).filter((e) => !e.startsWith("placeholder")))];
|
|
462
485
|
if (r.length === 0) return [];
|
|
463
486
|
let i = [];
|
|
@@ -469,48 +492,32 @@ var a = (e, { language: t, country: n }) => {
|
|
|
469
492
|
gid: e.id,
|
|
470
493
|
url: e.image.url
|
|
471
494
|
}] : []);
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
"secondaryText",
|
|
478
|
-
"border",
|
|
479
|
-
"overlay",
|
|
480
|
-
"primaryAccent",
|
|
481
|
-
"primaryAccentText",
|
|
482
|
-
"badgeBackground",
|
|
483
|
-
"badgeText",
|
|
484
|
-
"error"
|
|
485
|
-
].map((e) => `brand_${e}`);
|
|
486
|
-
var E = /* @__PURE__ */ function(e) {
|
|
487
|
-
return e.QuantityBreak = "quantity-break", e.Bxgy = "bxgy", e.Bundle = "bundle", e.MixAndMatch = "mix-and-match", e.Sku = "sku", e;
|
|
488
|
-
}({}), ne = (e) => [
|
|
495
|
+
}, k = (e) => [
|
|
496
|
+
...A(e),
|
|
497
|
+
...ee(e),
|
|
498
|
+
...te(e),
|
|
499
|
+
...ne(e),
|
|
489
500
|
...re(e),
|
|
490
501
|
...ie(e),
|
|
491
502
|
...ae(e),
|
|
492
503
|
...oe(e),
|
|
493
504
|
...se(e),
|
|
494
505
|
...ce(e),
|
|
495
|
-
...D(e),
|
|
496
|
-
...O(e),
|
|
497
|
-
...k(e),
|
|
498
|
-
...A(e),
|
|
499
506
|
...j(e),
|
|
500
507
|
...M(e),
|
|
501
508
|
...N(e)
|
|
502
|
-
].filter((e) => e != null && !e.includes("placeholder")),
|
|
509
|
+
].filter((e) => e != null && !e.includes("placeholder")), A = (e) => e.dealBars.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), ee = (e) => e.dealBars.flatMap((e) => e.dealBarType === g.Bundle ? e.bundleProducts.map((e) => e.mediaImageGID) : []).filter((e) => e != null), te = (e) => e.dealBars.map(({ freeGifts: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), ne = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => (e || []).map((e) => e.mediaImageGID)).filter((e) => e != null), re = (e) => e.dealBars.map(({ upsells: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), ie = (e) => e.swatchOptions ? e.swatchOptions.reduce((e, t) => {
|
|
503
510
|
let n = t.images.map((e) => e.mediaImageGID).filter((e) => e != null);
|
|
504
511
|
return [...e, ...n];
|
|
505
|
-
}, []) : [],
|
|
512
|
+
}, []) : [], ae = (e) => {
|
|
506
513
|
if (!e.collectionBreaksEnabled || !e.collectionBreaks) return [];
|
|
507
514
|
let t = e.collectionBreaks.mediaImageGID;
|
|
508
515
|
return t ? [t] : [];
|
|
509
|
-
},
|
|
516
|
+
}, oe = (e) => e.progressiveGifts ? [
|
|
510
517
|
...e.progressiveGifts.gifts?.map((e) => e.mediaImageGID) || [],
|
|
511
518
|
e.progressiveGifts.style?.lockedMediaImageGID,
|
|
512
519
|
e.progressiveGifts.dealBarStyle?.lockedMediaImageGID
|
|
513
|
-
].filter((e) => e != null) : [],
|
|
520
|
+
].filter((e) => e != null) : [], se = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), ce = (e) => e.dealBars.map((e) => e.productPersonalisation?.mediaImageGID).filter((e) => e != null), j = (e) => {
|
|
514
521
|
let t = e.dealBars.map((e) => e.highlights?.customIconGID).filter((e) => e != null), n = e.subscriptions?.highlights?.customIconGID;
|
|
515
522
|
return n ? [...t, n] : t;
|
|
516
523
|
}, M = (e) => (e.badges || []).flatMap((e) => e.badgeType === "custom" && e.imageGID ? [e.imageGID] : []), N = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], P = (e) => {
|
|
@@ -525,7 +532,7 @@ var E = /* @__PURE__ */ function(e) {
|
|
|
525
532
|
...H(e)
|
|
526
533
|
];
|
|
527
534
|
return Array.from(new Set(t.filter((e) => e != null)));
|
|
528
|
-
}, F = (e) => e.dealBars.flatMap(({ freeGifts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), I = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => e ? e.flatMap((e) => e.products ? e.products.map((e) => e.id) : []) : []).filter((e) => e != null), L = (e) => e.progressiveGiftsEnabled && e.progressiveGifts?.gifts.map((e) => e.productGID).filter((e) => e != null) || [], R = (e) => e.dealBars.flatMap(({ upsells: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), z = (e) => e.dealBars.filter((e) => e.dealBarType ===
|
|
535
|
+
}, F = (e) => e.dealBars.flatMap(({ freeGifts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), I = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => e ? e.flatMap((e) => e.products ? e.products.map((e) => e.id) : []) : []).filter((e) => e != null), L = (e) => e.progressiveGiftsEnabled && e.progressiveGifts?.gifts.map((e) => e.productGID).filter((e) => e != null) || [], R = (e) => e.dealBars.flatMap(({ upsells: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), z = (e) => e.dealBars.filter((e) => e.dealBarType === g.Bundle).flatMap(({ bundleProducts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null).filter((e) => e !== "default"), B = (e) => e.dealBars.filter((e) => e.dealBarType === g.MixAndMatch).flatMap(({ bundleProducts: e }) => e ? e.flatMap((e) => [e.productGID, ...e.selectedProducts?.map((e) => e.id) ?? []]) : []).filter((e) => e != null).filter((e) => e !== "default"), V = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((e) => e.productGID).filter((e) => e != null), H = (e) => e.dealBars.filter((e) => e.dealBarType === g.Sku).flatMap(({ productGID: e }) => e ? [e] : []), U = class extends Error {
|
|
529
536
|
constructor({ status: e, operationName: t, graphqlErrors: n }) {
|
|
530
537
|
let r = n.length ? `: ${n.join("; ")}` : "";
|
|
531
538
|
super(`Storefront API ${t ?? "query"} failed (HTTP ${e})${r}`), this.name = "StorefrontApiError", this.status = e, this.operationName = t, this.graphqlErrors = n;
|
|
@@ -581,14 +588,14 @@ var E = /* @__PURE__ */ function(e) {
|
|
|
581
588
|
let i = t.collectionBreaks;
|
|
582
589
|
if (!t.collectionBreaksEnabled || !i) return;
|
|
583
590
|
let a;
|
|
584
|
-
a = i.visibility === "deal-products" ? await
|
|
591
|
+
a = i.visibility === "deal-products" ? await _(e, {
|
|
585
592
|
country: n,
|
|
586
593
|
language: r,
|
|
587
594
|
blockVisibility: t.blockVisibility,
|
|
588
595
|
excludedProductGIDs: (t.excludedProductIds || []).map((e) => `gid://shopify/Product/${e}`),
|
|
589
596
|
selectedProductGIDs: (t.selectedProductIds || []).map((e) => `gid://shopify/Product/${e}`),
|
|
590
597
|
selectedCollectionGIDs: (t.selectedCollectionIds || []).map((e) => `gid://shopify/Collection/${e}`)
|
|
591
|
-
}) : await
|
|
598
|
+
}) : await _(e, {
|
|
592
599
|
country: n,
|
|
593
600
|
language: r,
|
|
594
601
|
blockVisibility: i.visibility,
|
|
@@ -596,7 +603,7 @@ var E = /* @__PURE__ */ function(e) {
|
|
|
596
603
|
selectedProductGIDs: (i.selectedProducts || []).map(({ id: e }) => e),
|
|
597
604
|
selectedCollectionGIDs: (i.selectedCollections || []).map(({ id: e }) => e)
|
|
598
605
|
});
|
|
599
|
-
let o = await
|
|
606
|
+
let o = await y(e, {
|
|
600
607
|
country: n,
|
|
601
608
|
language: r,
|
|
602
609
|
productIds: a.map((e) => Number(e.split("/").pop())),
|
|
@@ -651,13 +658,13 @@ var E = /* @__PURE__ */ function(e) {
|
|
|
651
658
|
try {
|
|
652
659
|
let a = [Number(t.split("/").pop())], o = new he(e);
|
|
653
660
|
r ||= o.i18n?.country, i ||= o.i18n?.language;
|
|
654
|
-
let s = await
|
|
661
|
+
let s = await E(o, {
|
|
655
662
|
language: i,
|
|
656
663
|
country: r,
|
|
657
664
|
useExternalMetafieldNamespace: !0
|
|
658
665
|
});
|
|
659
666
|
o.shopifyDomain = s.shopifyDomain;
|
|
660
|
-
let c = s.storefrontAccessToken ? new G(s.shopifyDomain, s.storefrontAccessToken) : o, [l, u] = await Promise.all([
|
|
667
|
+
let c = s.storefrontAccessToken ? new G(s.shopifyDomain, s.storefrontAccessToken) : o, [l, u] = await Promise.all([y(c, {
|
|
661
668
|
country: r,
|
|
662
669
|
language: i,
|
|
663
670
|
productIds: a,
|
|
@@ -669,14 +676,14 @@ var E = /* @__PURE__ */ function(e) {
|
|
|
669
676
|
if (!d) return null;
|
|
670
677
|
let f = le(u, d), m;
|
|
671
678
|
if (n ? (m = f.find((e) => e.id === n || e.nanoId === n), m ||= f[0]) : m = f[0], !m) return null;
|
|
672
|
-
let h =
|
|
673
|
-
|
|
679
|
+
let h = k(m), g = P(m), [_, v, b, x] = await Promise.all([
|
|
680
|
+
y(c, {
|
|
674
681
|
country: r,
|
|
675
682
|
language: i,
|
|
676
683
|
productIds: g,
|
|
677
684
|
useExternalMetafieldNamespace: !0
|
|
678
685
|
}),
|
|
679
|
-
|
|
686
|
+
O(c, h, 300),
|
|
680
687
|
ue(c, m, {
|
|
681
688
|
country: r,
|
|
682
689
|
language: i
|
|
@@ -691,7 +698,7 @@ var E = /* @__PURE__ */ function(e) {
|
|
|
691
698
|
dealBlock: m,
|
|
692
699
|
config: s,
|
|
693
700
|
otherProducts: _,
|
|
694
|
-
mediaImages:
|
|
701
|
+
mediaImages: v,
|
|
695
702
|
collectionBreaksProducts: b ?? [],
|
|
696
703
|
translations: x
|
|
697
704
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kachingappz/bundles-js",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/kachingappz/bundles.git",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
],
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@kachingappz/bundles-storefront-api": "^0.1.0",
|
|
54
|
-
"@kachingappz/bundles-types": "^0.
|
|
54
|
+
"@kachingappz/bundles-types": "^0.4.3",
|
|
55
55
|
"@kachingappz/kaching-bundles-block": "^1.0.0",
|
|
56
56
|
"@microsoft/api-extractor": "^7.57.7",
|
|
57
57
|
"@testing-library/react": "^16.3.3",
|