@rechargeapps/storefront-client 1.21.0 → 1.22.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.
@@ -1,5 +1,28 @@
1
1
  import { config } from 'js-xdr';
2
2
 
3
+ var __accessCheck = (obj, member, msg) => {
4
+ if (!member.has(obj))
5
+ throw TypeError("Cannot " + msg);
6
+ };
7
+ var __privateGet = (obj, member, getter) => {
8
+ __accessCheck(obj, member, "read from private field");
9
+ return getter ? getter.call(obj) : member.get(obj);
10
+ };
11
+ var __privateAdd = (obj, member, value) => {
12
+ if (member.has(obj))
13
+ throw TypeError("Cannot add the same private member more than once");
14
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
15
+ };
16
+ var __privateSet = (obj, member, value, setter) => {
17
+ __accessCheck(obj, member, "write to private field");
18
+ setter ? setter.call(obj, value) : member.set(obj, value);
19
+ return value;
20
+ };
21
+ var __privateMethod = (obj, member, method) => {
22
+ __accessCheck(obj, member, "access private method");
23
+ return method;
24
+ };
25
+ var _bundleSettings, _items, _bundleData, _formatBundleSettings, formatBundleSettings_fn, _formatBundleData, formatBundleData_fn, _isValueInRange, isValueInRange_fn, _unique, unique_fn;
3
26
  function toLineItemProperty(bundle) {
4
27
  const opts = {
5
28
  variantId: xdr.Uint64.fromString(bundle.variantId.toString()),
@@ -62,6 +85,186 @@ const xdr = config(
62
85
  });
63
86
  }
64
87
  );
88
+ class BundleSelectionValidator {
89
+ constructor(selectionItems, bundleData) {
90
+ __privateAdd(this, _formatBundleSettings);
91
+ __privateAdd(this, _formatBundleData);
92
+ __privateAdd(this, _isValueInRange);
93
+ __privateAdd(this, _unique);
94
+ __privateAdd(this, _bundleSettings, void 0);
95
+ __privateAdd(this, _items, void 0);
96
+ __privateAdd(this, _bundleData, void 0);
97
+ __privateSet(this, _bundleSettings, __privateMethod(this, _formatBundleSettings, formatBundleSettings_fn).call(this, bundleData));
98
+ __privateSet(this, _bundleData, __privateMethod(this, _formatBundleData, formatBundleData_fn).call(this, bundleData));
99
+ __privateSet(this, _items, selectionItems);
100
+ }
101
+ isInitialDataValid() {
102
+ if (!__privateGet(this, _bundleData)) {
103
+ throw "Bundle data does not exist for the given product.";
104
+ }
105
+ if (!__privateGet(this, _bundleSettings)) {
106
+ throw "Bundle settings do not exist for the given product.";
107
+ }
108
+ if (!Array.isArray(__privateGet(this, _items)) || !__privateGet(this, _items).length) {
109
+ throw "No bundle selection items provided.";
110
+ }
111
+ return true;
112
+ }
113
+ isValidVariant(externalVariantId) {
114
+ if (!__privateGet(this, _bundleSettings)?.variantsSettings[externalVariantId]) {
115
+ throw `The ${externalVariantId} bundle variant is invalid.`;
116
+ }
117
+ return true;
118
+ }
119
+ isSelectionInVariantRange(externalVariantId) {
120
+ const total = __privateGet(this, _items).reduce((acc, current) => acc + current.quantity, 0);
121
+ const ranges = __privateGet(this, _bundleSettings)?.variantsSettings[externalVariantId].ranges || [];
122
+ if (!__privateMethod(this, _isValueInRange, isValueInRange_fn).call(this, ranges, total)) {
123
+ throw "The total number of products does not fall within the required variant range.";
124
+ }
125
+ return true;
126
+ }
127
+ areItemsInMaxPerItemBound() {
128
+ const maxPerItem = __privateGet(this, _bundleSettings)?.bundleSettings.maxPerItem || 0;
129
+ const invalidProducts = __privateGet(this, _items).filter(({ quantity }) => quantity > maxPerItem);
130
+ if (maxPerItem && invalidProducts.length) {
131
+ const invalidIds = __privateMethod(this, _unique, unique_fn).call(this, invalidProducts.map(({ externalProductId }) => externalProductId)).join(", ");
132
+ throw `The selected products (${invalidIds}) exceed the maximum limit of ${maxPerItem} items per product.`;
133
+ }
134
+ return true;
135
+ }
136
+ areSelectedCollectionsValid(externalVariantId) {
137
+ const variantSettings = __privateGet(this, _bundleSettings)?.variantsSettings[externalVariantId];
138
+ const invalidCollections = __privateGet(this, _items).filter(({ collectionId }) => !variantSettings?.optionSources[collectionId]);
139
+ if (invalidCollections.length) {
140
+ const invalidIds = __privateMethod(this, _unique, unique_fn).call(this, invalidCollections.map(({ collectionId }) => collectionId)).join(", ");
141
+ throw `The collections (${invalidIds}) are no longer valid for the bundle variant (${externalVariantId}).`;
142
+ }
143
+ return true;
144
+ }
145
+ areItemsQuantitiesValidForTheCollection(externalVariantId) {
146
+ const totalSelectedByCollection = __privateGet(this, _items).reduce((acc, current) => {
147
+ acc[current.collectionId] = current.quantity + (acc[current.collectionId] || 0);
148
+ return acc;
149
+ }, {});
150
+ const variantSettings = __privateGet(this, _bundleSettings)?.variantsSettings[externalVariantId];
151
+ const invalidItems = Object.values(variantSettings?.optionSources || {}).filter((collection) => {
152
+ const quantity = totalSelectedByCollection[collection.collectionId] || 0;
153
+ return !__privateMethod(this, _isValueInRange, isValueInRange_fn).call(this, [collection], quantity);
154
+ });
155
+ if (!variantSettings || invalidItems.length) {
156
+ const invalidIds = __privateMethod(this, _unique, unique_fn).call(this, invalidItems.map(({ collectionId }) => collectionId)).join(", ");
157
+ throw `The selection exceeds the limits for the collections (${invalidIds}).`;
158
+ }
159
+ return true;
160
+ }
161
+ areSelectedProductsValid(externalVariantId) {
162
+ const bundleVariantCollections = __privateGet(this, _bundleSettings)?.variantsSettings[externalVariantId]?.optionSources || {};
163
+ const variantCollections = Object.values(bundleVariantCollections).reduce(
164
+ (acc, optionSource) => {
165
+ const collection = __privateGet(this, _bundleData)?.collections[optionSource.collectionId];
166
+ if (collection) {
167
+ acc[optionSource.collectionId] = collection;
168
+ }
169
+ return acc;
170
+ },
171
+ {}
172
+ );
173
+ if (!Object.values(variantCollections).length) {
174
+ throw `No collections found for the bundle variant (${externalVariantId}).`;
175
+ }
176
+ const missingProducts = __privateGet(this, _items).filter(
177
+ ({ externalProductId, collectionId }) => !variantCollections[collectionId]?.products[externalProductId]
178
+ );
179
+ if (missingProducts.length) {
180
+ const invalidIds = __privateMethod(this, _unique, unique_fn).call(this, missingProducts.map(({ externalProductId }) => externalProductId)).join(", ");
181
+ throw `The products (${invalidIds}) are no longer valid for the bundle product.`;
182
+ }
183
+ return true;
184
+ }
185
+ isBundleSelectionValid(externalVariantId) {
186
+ this.isInitialDataValid();
187
+ this.isValidVariant(externalVariantId);
188
+ this.isSelectionInVariantRange(externalVariantId);
189
+ this.areItemsInMaxPerItemBound();
190
+ this.areSelectedCollectionsValid(externalVariantId);
191
+ this.areItemsQuantitiesValidForTheCollection(externalVariantId);
192
+ this.areSelectedProductsValid(externalVariantId);
193
+ return true;
194
+ }
195
+ }
196
+ _bundleSettings = new WeakMap();
197
+ _items = new WeakMap();
198
+ _bundleData = new WeakMap();
199
+ _formatBundleSettings = new WeakSet();
200
+ formatBundleSettings_fn = function(bundleData) {
201
+ try {
202
+ const bundleSettings = bundleData.bundle_settings;
203
+ return {
204
+ bundleSettings: {
205
+ maxPerItem: bundleSettings.max_quantity_per_variant,
206
+ isCustomizable: bundleSettings.is_customizable
207
+ },
208
+ variantsSettings: bundleSettings.variants.reduce((acc, variant) => {
209
+ if (!variant.enabled)
210
+ return acc;
211
+ let ranges = [{ min: variant.items_count, max: variant.items_count }];
212
+ if (!variant.items_count) {
213
+ ranges = variant.ranges.map(({ quantity_max, quantity_min }) => ({
214
+ min: quantity_min,
215
+ max: quantity_max
216
+ }));
217
+ }
218
+ acc[variant.external_variant_id] = {
219
+ externalVariantId: variant.external_variant_id,
220
+ optionSources: variant.option_sources.reduce((acc2, optionSource) => {
221
+ acc2[optionSource.option_source_id] = {
222
+ min: optionSource.quantity_min,
223
+ max: optionSource.quantity_max,
224
+ collectionId: optionSource.option_source_id
225
+ };
226
+ return acc2;
227
+ }, {}),
228
+ ranges
229
+ };
230
+ return acc;
231
+ }, {})
232
+ };
233
+ } catch (error) {
234
+ return null;
235
+ }
236
+ };
237
+ _formatBundleData = new WeakSet();
238
+ formatBundleData_fn = function(bundleData) {
239
+ try {
240
+ const collections = Object.values(bundleData.collections).reduce((acc, current) => {
241
+ acc[current.id] = {
242
+ ...current,
243
+ products: current.products.reduce((productAcc, product) => {
244
+ productAcc[product.id] = product;
245
+ return productAcc;
246
+ }, {})
247
+ };
248
+ return acc;
249
+ }, {});
250
+ return { ...bundleData, collections };
251
+ } catch (error) {
252
+ return null;
253
+ }
254
+ };
255
+ _isValueInRange = new WeakSet();
256
+ isValueInRange_fn = function(ranges, value) {
257
+ const matchedRanges = ranges.filter(({ min, max }) => {
258
+ const minValue = min ?? value;
259
+ const maxValue = max ?? value;
260
+ return minValue <= value && value <= maxValue;
261
+ });
262
+ return !!matchedRanges.length;
263
+ };
264
+ _unique = new WeakSet();
265
+ unique_fn = function(ids) {
266
+ return Array.from(new Set(ids));
267
+ };
65
268
 
66
- export { toLineItemProperty };
269
+ export { BundleSelectionValidator, toLineItemProperty };
67
270
  //# sourceMappingURL=bundle.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"bundle.js","sources":["../../../src/utils/bundle.ts"],"sourcesContent":["import { config } from 'js-xdr';\n\nexport function toLineItemProperty(bundle: { variantId: string; version: number; items: any[] }) {\n const opts = {\n variantId: xdr.Uint64.fromString(bundle.variantId.toString()),\n version: bundle.version || Math.floor(Date.now() / 1000),\n items: bundle.items.map(item => {\n return new xdr.BundleItem({\n collectionId: xdr.Uint64.fromString(item.collectionId.toString()),\n productId: xdr.Uint64.fromString(item.productId.toString()),\n variantId: xdr.Uint64.fromString(item.variantId.toString()),\n sku: item.sku || '',\n quantity: item.quantity,\n ext: new xdr.BundleItemExt(0),\n });\n }),\n ext: new xdr.BundleExt(0),\n };\n\n const xdrBundle = new xdr.Bundle(opts);\n return xdr.BundleEnvelope.envelopeTypeBundle(xdrBundle).toXDR('base64');\n}\n\nconst xdr = config(\n (xdr: {\n enum: (arg0: string, arg1: { envelopeTypeBundle: number }) => void;\n typedef: (arg0: string, arg1: any) => void;\n uint: () => any;\n uhyper: () => any;\n union: (\n arg0: string,\n arg1: {\n switchOn: any;\n switchName: string;\n switches: any[][] | string[][];\n // eslint-disable-next-line @typescript-eslint/ban-types\n arms: {} | {} | { v1: any };\n }\n ) => void;\n int: () => any;\n void: () => any;\n struct: (arg0: string, arg1: any[][]) => void;\n lookup: (arg0: string) => any;\n string: () => any;\n varArray: (arg0: any, arg1: number) => any;\n }) => {\n xdr.enum('EnvelopeType', {\n envelopeTypeBundle: 0,\n });\n xdr.typedef('Uint32', xdr.uint());\n xdr.typedef('Uint64', xdr.uhyper());\n xdr.union('BundleItemExt', {\n switchOn: xdr.int(),\n switchName: 'v',\n switches: [[0, xdr.void()]],\n arms: {},\n });\n xdr.struct('BundleItem', [\n ['collectionId', xdr.lookup('Uint64')],\n ['productId', xdr.lookup('Uint64')],\n ['variantId', xdr.lookup('Uint64')],\n ['sku', xdr.string()],\n ['quantity', xdr.lookup('Uint32')],\n ['ext', xdr.lookup('BundleItemExt')],\n ]);\n xdr.union('BundleExt', {\n switchOn: xdr.int(),\n switchName: 'v',\n switches: [[0, xdr.void()]],\n arms: {},\n });\n xdr.struct('Bundle', [\n ['variantId', xdr.lookup('Uint64')],\n ['items', xdr.varArray(xdr.lookup('BundleItem'), 500)],\n ['version', xdr.lookup('Uint32')],\n ['ext', xdr.lookup('BundleExt')],\n ]);\n xdr.union('BundleEnvelope', {\n switchOn: xdr.lookup('EnvelopeType'),\n switchName: 'type',\n switches: [['envelopeTypeBundle', 'v1']],\n arms: {\n v1: xdr.lookup('Bundle'),\n },\n });\n }\n);\n"],"names":["xdr"],"mappings":";;AAEO,SAAS,mBAAmB,MAA8D,EAAA;AAC/F,EAAA,MAAM,IAAO,GAAA;AAAA,IACX,WAAW,GAAI,CAAA,MAAA,CAAO,WAAW,MAAO,CAAA,SAAA,CAAU,UAAU,CAAA;AAAA,IAC5D,OAAA,EAAS,OAAO,OAAW,IAAA,IAAA,CAAK,MAAM,IAAK,CAAA,GAAA,KAAQ,GAAI,CAAA;AAAA,IACvD,KAAO,EAAA,MAAA,CAAO,KAAM,CAAA,GAAA,CAAI,CAAQ,IAAA,KAAA;AAC9B,MAAO,OAAA,IAAI,IAAI,UAAW,CAAA;AAAA,QACxB,cAAc,GAAI,CAAA,MAAA,CAAO,WAAW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AAO,cAAc,CAAA;AAAA,MACnC,UAAY,EAAA,MAAA;AAAA,MACZ,QAAU,EAAA,CAAC,CAAC,oBAAA,EAAsB,IAAI,CAAC,CAAA;AAAA,MACvC,IAAM,EAAA;AAAA,QACJ,EAAA,EAAIA,IAAI,CAAA,MAAA,CAAO,QAAQ,CAAA;AAAA,OACzB;AAAA,KACD,CAAA,CAAA;AAAA,GACH;AACF,CAAA;;;;"}
1
+ {"version":3,"file":"bundle.js","sources":["../../../src/utils/bundle.ts"],"sourcesContent":["import { config } from 'js-xdr';\nimport { BundleData as StorefrontBundleData, CDNBundleSettings } from '../types';\n\nexport function toLineItemProperty(bundle: { variantId: string; version: number; items: any[] }) {\n const opts = {\n variantId: xdr.Uint64.fromString(bundle.variantId.toString()),\n version: bundle.version || Math.floor(Date.now() / 1000),\n items: bundle.items.map(item => {\n return new xdr.BundleItem({\n collectionId: xdr.Uint64.fromString(item.collectionId.toString()),\n productId: xdr.Uint64.fromString(item.productId.toString()),\n variantId: xdr.Uint64.fromString(item.variantId.toString()),\n sku: item.sku || '',\n quantity: item.quantity,\n ext: new xdr.BundleItemExt(0),\n });\n }),\n ext: new xdr.BundleExt(0),\n };\n\n const xdrBundle = new xdr.Bundle(opts);\n return xdr.BundleEnvelope.envelopeTypeBundle(xdrBundle).toXDR('base64');\n}\n\nconst xdr = config(\n (xdr: {\n enum: (arg0: string, arg1: { envelopeTypeBundle: number }) => void;\n typedef: (arg0: string, arg1: any) => void;\n uint: () => any;\n uhyper: () => any;\n union: (\n arg0: string,\n arg1: {\n switchOn: any;\n switchName: string;\n switches: any[][] | string[][];\n // eslint-disable-next-line @typescript-eslint/ban-types\n arms: {} | {} | { v1: any };\n }\n ) => void;\n int: () => any;\n void: () => any;\n struct: (arg0: string, arg1: any[][]) => void;\n lookup: (arg0: string) => any;\n string: () => any;\n varArray: (arg0: any, arg1: number) => any;\n }) => {\n xdr.enum('EnvelopeType', {\n envelopeTypeBundle: 0,\n });\n xdr.typedef('Uint32', xdr.uint());\n xdr.typedef('Uint64', xdr.uhyper());\n xdr.union('BundleItemExt', {\n switchOn: xdr.int(),\n switchName: 'v',\n switches: [[0, xdr.void()]],\n arms: {},\n });\n xdr.struct('BundleItem', [\n ['collectionId', xdr.lookup('Uint64')],\n ['productId', xdr.lookup('Uint64')],\n ['variantId', xdr.lookup('Uint64')],\n ['sku', xdr.string()],\n ['quantity', xdr.lookup('Uint32')],\n ['ext', xdr.lookup('BundleItemExt')],\n ]);\n xdr.union('BundleExt', {\n switchOn: xdr.int(),\n switchName: 'v',\n switches: [[0, xdr.void()]],\n arms: {},\n });\n xdr.struct('Bundle', [\n ['variantId', xdr.lookup('Uint64')],\n ['items', xdr.varArray(xdr.lookup('BundleItem'), 500)],\n ['version', xdr.lookup('Uint32')],\n ['ext', xdr.lookup('BundleExt')],\n ]);\n xdr.union('BundleEnvelope', {\n switchOn: xdr.lookup('EnvelopeType'),\n switchName: 'type',\n switches: [['envelopeTypeBundle', 'v1']],\n arms: {\n v1: xdr.lookup('Bundle'),\n },\n });\n }\n);\n\nexport interface BundleSelectionItems {\n collectionId: string;\n externalProductId: string;\n externalVariantId: string;\n quantity: number;\n}\n\ninterface VariantSettings {\n externalVariantId: string;\n optionSources: Record<string, { collectionId: string; min: number | null; max: number | null }>;\n ranges: { min: number; max: number | null }[];\n}\n\ninterface BundleSettings {\n bundleSettings: { maxPerItem: number | null; isCustomizable: boolean };\n variantsSettings: Record<string, VariantSettings>;\n}\n\ntype BundleDataCollection = StorefrontBundleData['collections'][string];\n\ninterface BundleData extends Omit<StorefrontBundleData, 'collections'> {\n collections: Record<\n string,\n Omit<BundleDataCollection, 'products'> & {\n products: Record<string, BundleDataCollection['products'][number]>;\n }\n >;\n}\n\nexport class BundleSelectionValidator {\n #bundleSettings: BundleSettings | null;\n #items: BundleSelectionItems[];\n #bundleData: BundleData | null;\n\n constructor(selectionItems: BundleSelectionItems[], bundleData: StorefrontBundleData) {\n this.#bundleSettings = this.#formatBundleSettings(bundleData);\n this.#bundleData = this.#formatBundleData(bundleData);\n this.#items = selectionItems;\n }\n\n #formatBundleSettings(bundleData: StorefrontBundleData) {\n try {\n const bundleSettings = bundleData.bundle_settings;\n return {\n bundleSettings: {\n maxPerItem: bundleSettings.max_quantity_per_variant,\n isCustomizable: bundleSettings.is_customizable,\n },\n variantsSettings: bundleSettings.variants.reduce<BundleSettings['variantsSettings']>((acc, variant) => {\n if (!variant.enabled) return acc;\n\n let ranges: VariantSettings['ranges'] = [{ min: variant.items_count, max: variant.items_count }];\n if (!variant.items_count) {\n ranges = variant.ranges.map(({ quantity_max, quantity_min }) => ({\n min: quantity_min,\n max: quantity_max,\n }));\n }\n\n acc[variant.external_variant_id] = {\n externalVariantId: variant.external_variant_id,\n optionSources: variant.option_sources.reduce<VariantSettings['optionSources']>((acc, optionSource) => {\n acc[optionSource.option_source_id] = {\n min: optionSource.quantity_min,\n max: optionSource.quantity_max,\n collectionId: optionSource.option_source_id,\n };\n return acc;\n }, {}),\n ranges,\n };\n return acc;\n }, {}),\n };\n } catch (error) {\n return null;\n }\n }\n\n #formatBundleData(bundleData: StorefrontBundleData) {\n try {\n const collections = Object.values(bundleData.collections).reduce<BundleData['collections']>((acc, current) => {\n acc[current.id] = {\n ...current,\n products: current.products.reduce<BundleData['collections'][string]['products']>((productAcc, product) => {\n productAcc[product.id] = product;\n return productAcc;\n }, {}),\n };\n\n return acc;\n }, {});\n\n return { ...bundleData, collections };\n } catch (error) {\n return null;\n }\n }\n\n #isValueInRange(ranges: { min: number | null; max: number | null }[], value: number) {\n const matchedRanges = ranges.filter(({ min, max }) => {\n const minValue = min ?? value;\n const maxValue = max ?? value;\n\n return minValue <= value && value <= maxValue;\n });\n\n return !!matchedRanges.length;\n }\n\n #unique(ids: string[]) {\n return Array.from(new Set(ids));\n }\n\n isInitialDataValid() {\n if (!this.#bundleData) {\n throw 'Bundle data does not exist for the given product.';\n }\n\n if (!this.#bundleSettings) {\n throw 'Bundle settings do not exist for the given product.';\n }\n\n if (!Array.isArray(this.#items) || !this.#items.length) {\n throw 'No bundle selection items provided.';\n }\n\n return true;\n }\n\n isValidVariant(externalVariantId: string) {\n if (!this.#bundleSettings?.variantsSettings[externalVariantId]) {\n throw `The ${externalVariantId} bundle variant is invalid.`;\n }\n\n return true;\n }\n\n isSelectionInVariantRange(externalVariantId: string) {\n const total = this.#items.reduce((acc, current) => acc + current.quantity, 0);\n const ranges = this.#bundleSettings?.variantsSettings[externalVariantId].ranges || [];\n\n if (!this.#isValueInRange(ranges, total)) {\n throw 'The total number of products does not fall within the required variant range.';\n }\n\n return true;\n }\n\n areItemsInMaxPerItemBound() {\n const maxPerItem = this.#bundleSettings?.bundleSettings.maxPerItem || 0;\n const invalidProducts = this.#items.filter(({ quantity }) => quantity > maxPerItem);\n\n if (maxPerItem && invalidProducts.length) {\n const invalidIds = this.#unique(invalidProducts.map(({ externalProductId }) => externalProductId)).join(', ');\n throw `The selected products (${invalidIds}) exceed the maximum limit of ${maxPerItem} items per product.`;\n }\n\n return true;\n }\n\n areSelectedCollectionsValid(externalVariantId: string) {\n const variantSettings = this.#bundleSettings?.variantsSettings[externalVariantId];\n const invalidCollections = this.#items.filter(({ collectionId }) => !variantSettings?.optionSources[collectionId]);\n if (invalidCollections.length) {\n const invalidIds = this.#unique(invalidCollections.map(({ collectionId }) => collectionId)).join(', ');\n throw `The collections (${invalidIds}) are no longer valid for the bundle variant (${externalVariantId}).`;\n }\n\n return true;\n }\n\n areItemsQuantitiesValidForTheCollection(externalVariantId: string) {\n const totalSelectedByCollection = this.#items.reduce<Record<string, number>>((acc, current) => {\n acc[current.collectionId] = current.quantity + (acc[current.collectionId] || 0);\n return acc;\n }, {});\n\n const variantSettings = this.#bundleSettings?.variantsSettings[externalVariantId];\n const invalidItems = Object.values(variantSettings?.optionSources || {}).filter(collection => {\n const quantity = totalSelectedByCollection[collection.collectionId] || 0;\n return !this.#isValueInRange([collection], quantity);\n });\n\n if (!variantSettings || invalidItems.length) {\n const invalidIds = this.#unique(invalidItems.map(({ collectionId }) => collectionId)).join(', ');\n throw `The selection exceeds the limits for the collections (${invalidIds}).`;\n }\n\n return true;\n }\n\n areSelectedProductsValid(externalVariantId: string) {\n const bundleVariantCollections = this.#bundleSettings?.variantsSettings[externalVariantId]?.optionSources || {};\n const variantCollections = Object.values(bundleVariantCollections).reduce<BundleData['collections']>(\n (acc, optionSource) => {\n const collection = this.#bundleData?.collections[optionSource.collectionId];\n if (collection) {\n acc[optionSource.collectionId] = collection;\n }\n return acc;\n },\n {}\n );\n\n if (!Object.values(variantCollections).length) {\n throw `No collections found for the bundle variant (${externalVariantId}).`;\n }\n\n const missingProducts = this.#items.filter(\n ({ externalProductId, collectionId }) => !variantCollections[collectionId]?.products[externalProductId]\n );\n\n if (missingProducts.length) {\n const invalidIds = this.#unique(missingProducts.map(({ externalProductId }) => externalProductId)).join(', ');\n throw `The products (${invalidIds}) are no longer valid for the bundle product.`;\n }\n\n return true;\n }\n\n isBundleSelectionValid(externalVariantId: string) {\n this.isInitialDataValid();\n this.isValidVariant(externalVariantId);\n this.isSelectionInVariantRange(externalVariantId);\n this.areItemsInMaxPerItemBound();\n this.areSelectedCollectionsValid(externalVariantId);\n this.areItemsQuantitiesValidForTheCollection(externalVariantId);\n this.areSelectedProductsValid(externalVariantId);\n\n return true;\n }\n}\n"],"names":["xdr","acc"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA,eAAA,EAAA,MAAA,EAAA,WAAA,EAAA,qBAAA,EAAA,uBAAA,EAAA,iBAAA,EAAA,mBAAA,EAAA,eAAA,EAAA,iBAAA,EAAA,OAAA,EAAA,SAAA,CAAA;AAGO,SAAS,mBAAmB,MAA8D,EAAA;AAC/F,EAAA,MAAM,IAAO,GAAA;AAAA,IACX,WAAW,GAAI,CAAA,MAAA,CAAO,WAAW,MAAO,CAAA,SAAA,CAAU,UAAU,CAAA;AAAA,IAC5D,OAAA,EAAS,OAAO,OAAW,IAAA,IAAA,CAAK,MAAM,IAAK,C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, data, headers } = {}
33
33
  "X-Recharge-Sdk-Fn": session.internalFnCall,
34
34
  ...appName ? { "X-Recharge-Sdk-App-Name": appName } : {},
35
35
  ...appVersion ? { "X-Recharge-Sdk-App-Version": appVersion } : {},
36
- "X-Recharge-Sdk-Version": "1.21.0",
36
+ "X-Recharge-Sdk-Version": "1.22.1",
37
37
  "X-Request-Id": session.internalRequestId,
38
38
  ...headers ? headers : {}
39
39
  };
package/dist/index.d.ts CHANGED
@@ -337,110 +337,6 @@ interface PaymentMethodListParams extends ListParams<PaymentMethodSortBy> {
337
337
  include?: PaymentMethodIncludes[];
338
338
  }
339
339
 
340
- interface BundleSelectionAppProxy {
341
- collectionId: string;
342
- externalProductId: string;
343
- externalVariantId: string;
344
- quantity: number;
345
- sellingPlan?: number;
346
- shippingIntervalFrequency?: number;
347
- shippingIntervalUnitType?: IntervalUnit;
348
- discountedVariantId?: number;
349
- }
350
- interface BundleAppProxy {
351
- externalVariantId: string;
352
- externalProductId: string;
353
- selections: BundleSelectionAppProxy[];
354
- }
355
- interface DynamicBundlePropertiesAppProxy {
356
- _rc_bundle: string;
357
- _rc_bundle_variant: string;
358
- _rc_bundle_parent: string;
359
- _rc_bundle_collection_id: string;
360
- shipping_interval_frequency?: number;
361
- shipping_interval_unit_type?: IntervalUnit;
362
- }
363
- interface DynamicBundleItemAppProxy {
364
- id: string;
365
- properties: DynamicBundlePropertiesAppProxy;
366
- quantity: number;
367
- selling_plan?: number;
368
- }
369
- interface BundleSelectionItem {
370
- /** The unique numeric identifier for the item selection. */
371
- id: number;
372
- /** The collection id as it appears in the external e-commerce platform. */
373
- collection_id: string;
374
- /** The identifier of the external e-commerce platform. */
375
- collection_source: 'shopify';
376
- /** The date and time when this item was selected. */
377
- created_at: IsoDateString;
378
- /** The product id as it appears in the external e-commerce platform. This is the item which is going to be extracted when the Bundle is processed. */
379
- external_product_id: string;
380
- /** The variant id as it appears in the external e-commerce platform. This is the item which is going to be extracted when the Bundle is processed. */
381
- external_variant_id: string;
382
- /** The quantity of this product. */
383
- quantity: number;
384
- /** The price of this product. */
385
- price: string;
386
- /** The date and time at which the item selection was most recently updated. */
387
- updated_at: IsoDateString;
388
- }
389
- interface BundleSelection {
390
- /** The unique numeric identifier for the BundleSelection. */
391
- id: number;
392
- /** The ID of the BundleVariant associated with the BundleSelection. */
393
- bundle_variant_id: number;
394
- /** The ID of the PurchaseItem associated with the BundleSelection. */
395
- purchase_item_id: number;
396
- /** The date and time when the contents were selected. */
397
- created_at: IsoDateString;
398
- /** The product id as it appears in the external e-commerce platform. The external_product_id of the Product record in Recharge, linking the BundleSelection to a Product associated with a Bundle. */
399
- external_product_id: string;
400
- /** The variant id as it appears in the external e-commerce platform. The external_variant_id of the Product record in Recharge, linking the BundleSelection to a Product associated with a Bundle. */
401
- external_variant_id: string;
402
- is_fallback: boolean;
403
- items: BundleSelectionItem[];
404
- /** The date and time at which the BundleSelection was most recently updated. */
405
- updated_at: IsoDateString;
406
- }
407
- type BundleSelectionItemRequiredCreateProps = 'collection_id' | 'collection_source' | 'external_product_id' | 'external_variant_id' | 'quantity';
408
- interface CreateBundleSelectionRequest {
409
- purchase_item_id: number;
410
- plan_id?: number;
411
- items: Pick<BundleSelectionItem, BundleSelectionItemRequiredCreateProps>[];
412
- }
413
- interface UpdateBundleSelectionRequest extends CreateBundleSelectionRequest {
414
- }
415
- interface BundleSelectionsResponse {
416
- next_cursor: null | string;
417
- previous_cursor: null | string;
418
- bundle_selections: BundleSelection[];
419
- }
420
- type BundleSelectionsSortBy = 'id-asc' | 'id-desc' | 'updated_at-asc' | 'updated_at-desc';
421
- interface BundleSelectionListParams extends ListParams<BundleSelectionsSortBy> {
422
- /** Filter BundleSelections by Subscription or Onetime ID. */
423
- purchase_item_ids?: (string | number)[];
424
- /** Filter BundleSelections by BundleVariants. */
425
- bundle_variant_ids?: (string | number)[];
426
- }
427
- interface UpdateBundlePurchaseItem extends UpdateSubscriptionRequest {
428
- external_product_id: {
429
- ecommerce: string;
430
- };
431
- external_variant_id: {
432
- ecommerce: string;
433
- };
434
- plan_id?: number;
435
- items: Pick<BundleSelectionItem, BundleSelectionItemRequiredCreateProps>[];
436
- }
437
- interface BundlePurchaseItem extends Subscription {
438
- items: BundleSelectionItem[];
439
- }
440
- interface BundlePurchaseItemParams {
441
- commit?: boolean;
442
- }
443
-
444
340
  interface AddonSettings {
445
341
  collectionHandle: string;
446
342
  collectionId: string;
@@ -569,6 +465,138 @@ interface BundleProduct {
569
465
  variants: BundleVariant[];
570
466
  }
571
467
 
468
+ interface BundleSelectionAppProxy {
469
+ collectionId: string;
470
+ externalProductId: string;
471
+ externalVariantId: string;
472
+ quantity: number;
473
+ sellingPlan?: number;
474
+ shippingIntervalFrequency?: number;
475
+ shippingIntervalUnitType?: IntervalUnit;
476
+ discountedVariantId?: number;
477
+ }
478
+ interface BundleAppProxy {
479
+ externalVariantId: string;
480
+ externalProductId: string;
481
+ selections: BundleSelectionAppProxy[];
482
+ }
483
+ interface DynamicBundlePropertiesAppProxy {
484
+ _rc_bundle: string;
485
+ _rc_bundle_variant: string;
486
+ _rc_bundle_parent: string;
487
+ _rc_bundle_collection_id: string;
488
+ shipping_interval_frequency?: number;
489
+ shipping_interval_unit_type?: IntervalUnit;
490
+ }
491
+ interface DynamicBundleItemAppProxy {
492
+ id: string;
493
+ properties: DynamicBundlePropertiesAppProxy;
494
+ quantity: number;
495
+ selling_plan?: number;
496
+ }
497
+ interface BundleSelectionItem {
498
+ /** The unique numeric identifier for the item selection. */
499
+ id: number;
500
+ /** The collection id as it appears in the external e-commerce platform. */
501
+ collection_id: string;
502
+ /** The identifier of the external e-commerce platform. */
503
+ collection_source: 'shopify';
504
+ /** The date and time when this item was selected. */
505
+ created_at: IsoDateString;
506
+ /** The product id as it appears in the external e-commerce platform. This is the item which is going to be extracted when the Bundle is processed. */
507
+ external_product_id: string;
508
+ /** The variant id as it appears in the external e-commerce platform. This is the item which is going to be extracted when the Bundle is processed. */
509
+ external_variant_id: string;
510
+ /** The quantity of this product. */
511
+ quantity: number;
512
+ /** The price of this product. */
513
+ price: string;
514
+ /** The date and time at which the item selection was most recently updated. */
515
+ updated_at: IsoDateString;
516
+ }
517
+ interface BundleSelection {
518
+ /** The unique numeric identifier for the BundleSelection. */
519
+ id: number;
520
+ /** The ID of the BundleVariant associated with the BundleSelection. */
521
+ bundle_variant_id: number;
522
+ /** The ID of the PurchaseItem associated with the BundleSelection. */
523
+ purchase_item_id: number;
524
+ /** The date and time when the contents were selected. */
525
+ created_at: IsoDateString;
526
+ /** The product id as it appears in the external e-commerce platform. The external_product_id of the Product record in Recharge, linking the BundleSelection to a Product associated with a Bundle. */
527
+ external_product_id: string;
528
+ /** The variant id as it appears in the external e-commerce platform. The external_variant_id of the Product record in Recharge, linking the BundleSelection to a Product associated with a Bundle. */
529
+ external_variant_id: string;
530
+ is_fallback: boolean;
531
+ items: BundleSelectionItem[];
532
+ /** The date and time at which the BundleSelection was most recently updated. */
533
+ updated_at: IsoDateString;
534
+ }
535
+ type BundleSelectionItemRequiredCreateProps = 'collection_id' | 'collection_source' | 'external_product_id' | 'external_variant_id' | 'quantity';
536
+ interface CreateBundleSelectionRequest {
537
+ purchase_item_id: number;
538
+ plan_id?: number;
539
+ items: Pick<BundleSelectionItem, BundleSelectionItemRequiredCreateProps>[];
540
+ }
541
+ interface UpdateBundleSelectionRequest extends CreateBundleSelectionRequest {
542
+ }
543
+ interface BundleSelectionsResponse {
544
+ next_cursor: null | string;
545
+ previous_cursor: null | string;
546
+ bundle_selections: BundleSelection[];
547
+ }
548
+ type BundleSelectionsSortBy = 'id-asc' | 'id-desc' | 'updated_at-asc' | 'updated_at-desc';
549
+ interface BundleSelectionListParams extends ListParams<BundleSelectionsSortBy> {
550
+ /** Filter BundleSelections by Subscription or Onetime ID. */
551
+ purchase_item_ids?: (string | number)[];
552
+ /** Filter BundleSelections by BundleVariants. */
553
+ bundle_variant_ids?: (string | number)[];
554
+ }
555
+ interface UpdateBundlePurchaseItem extends UpdateSubscriptionRequest {
556
+ external_product_id: {
557
+ ecommerce: string;
558
+ };
559
+ external_variant_id: {
560
+ ecommerce: string;
561
+ };
562
+ plan_id?: number;
563
+ items: Pick<BundleSelectionItem, BundleSelectionItemRequiredCreateProps>[];
564
+ }
565
+ interface BundlePurchaseItem extends Subscription {
566
+ items: BundleSelectionItem[];
567
+ }
568
+ interface BundlePurchaseItemParams {
569
+ commit?: boolean;
570
+ }
571
+ interface BundleDataCollectionProductVariant {
572
+ available: boolean;
573
+ id: number;
574
+ title: string;
575
+ handle: string;
576
+ }
577
+ interface BundleDataCollectionProduct {
578
+ id: number;
579
+ handle: string;
580
+ available: boolean;
581
+ title: string;
582
+ variants: BundleDataCollectionProductVariant[];
583
+ }
584
+ interface BundleDataCollection {
585
+ id: number;
586
+ handle: string;
587
+ title: string;
588
+ products: BundleDataCollectionProduct[];
589
+ }
590
+ interface BundleData {
591
+ id: number;
592
+ handle: string;
593
+ title: string;
594
+ collections: Record<string, BundleDataCollection>;
595
+ bundle_settings: Pick<BundleProduct, 'max_quantity_per_variant' | 'is_customizable'> & {
596
+ variants: Pick<BundleProduct['variants'][number], 'option_sources' | 'ranges' | 'enabled' | 'items_count' | 'external_variant_id'>[];
597
+ };
598
+ }
599
+
572
600
  type SubscriptionStatus = 'active' | 'cancelled' | 'expired';
573
601
  interface Subscription {
574
602
  /** Unique numeric identifier for the subscription. */
@@ -2554,6 +2582,10 @@ declare function loginCustomerPortal(): Promise<Session>;
2554
2582
  declare function getBundleId(bundle: BundleAppProxy): Promise<string>;
2555
2583
  declare function getDynamicBundleItems(bundle: BundleAppProxy, shopifyProductHandle: string): DynamicBundleItemAppProxy[];
2556
2584
  declare function validateBundle(bundle: BundleAppProxy): Promise<true | string>;
2585
+ declare function validateBundleSelection(bundle: BundleAppProxy): Promise<{
2586
+ valid: boolean;
2587
+ error?: string;
2588
+ }>;
2557
2589
  /**
2558
2590
  * Validates a dynamic bundle
2559
2591
  *
@@ -2741,4 +2773,4 @@ declare const api: {
2741
2773
  };
2742
2774
  declare function initRecharge(opt?: InitOptions): void;
2743
2775
 
2744
- export { type ActivateMembershipRequest, type AddToCartCallbackSettings, type AddonSettings, type Address, type AddressIncludes, type AddressListParams, type AddressListResponse, type AddressResponse, type AddressSortBy, type AnalyticsData, type ApplyCreditOptions, type AssociatedAddress, type BasicSubscriptionParams, type BooleanLike, type BooleanNumbers, type BooleanString, type BooleanStringNumbers, type BundleAppProxy, type BundlePriceRule, type BundleProduct, type BundleProductLayoutSettings, type BundlePurchaseItem, type BundlePurchaseItemParams, type BundleSelection, type BundleSelectionAppProxy, type BundleSelectionItem, type BundleSelectionItemRequiredCreateProps, type BundleSelectionListParams, type BundleSelectionsResponse, type BundleSelectionsSortBy, type BundleTemplateSettings, type BundleTemplateType, type BundleTranslations, type BundleVariant, type BundleVariantOptionSource, type BundleVariantRange, type BundleVariantSelectionDefault, type CDNBaseWidgetSettings, type CDNBundleSettings, type CDNBundleVariant, type CDNBundleVariantOptionSource, type CDNPlan, type CDNProduct, type CDNProductAndSettings, type CDNProductKeyObject, type CDNProductQuery_2020_12, type CDNProductQuery_2022_06, type CDNProductRaw, type CDNProductResource, type CDNProductResponseType, type CDNProductType, type CDNProductVariant_2022_06, type CDNProduct_2022_06, type CDNProductsAndSettings, type CDNProductsAndSettingsResource, type CDNStoreSettings, type CDNSubscriptionOption, type CDNVariant, type CDNVersion, type CDNWidgetSettings, type CDNWidgetSettingsRaw, type CDNWidgetSettingsResource, type CRUDRequestOptions, type CancelMembershipRequest, type CancelSubscriptionRequest, type ChangeMembershipRequest, type ChannelSettings, type Charge, type ChargeIncludes, type ChargeListParams, type ChargeListResponse, type ChargeResponse, type ChargeSortBy, type ChargeStatus, type Collection, type CollectionListParams, type CollectionTypes, type CollectionsResponse, type CollectionsSortBy, type ColorString, type CreateAddressRequest, type CreateBundleSelectionRequest, type CreateMetafieldRequest, type CreateOnetimeRequest, type CreatePaymentMethodRequest, type CreateRecipientAddress, type CreateSubscriptionRequest, type CreateSubscriptionsParams, type CreditAccount, type CreditAccountIncludes, type CreditAccountListParams, type CreditAccountType, type CreditAccountsResponse, type CreditAccountsSortBy, type CreditSummaryIncludes, type CrossSellsSettings, type Customer, type CustomerCreditSummary, type CustomerDeliveryScheduleParams, type CustomerDeliveryScheduleResponse, type CustomerIncludes, type CustomerNotification, type CustomerNotificationOptions, type CustomerNotificationTemplate, type CustomerNotificationType, type CustomerPortalAccessOptions, type CustomerPortalAccessResponse, type Delivery, type DeliveryLineItem, type DeliveryOrder, type DeliveryPaymentMethod, type Discount, type DiscountType, type DynamicBundleItemAppProxy, type DynamicBundlePropertiesAppProxy, type ExternalAttributeSchema, type ExternalId, type ExternalTransactionId, type FirstOption, type GetAddressOptions, type GetChargeOptions, type GetCreditSummaryOptions, type GetCustomerOptions, type GetMembershipProgramOptions, type GetPaymentMethodOptions, type GetRequestOptions, type GetSubscriptionOptions, type GiftPurchase, type GiftPurchasesParams, type GiftPurchasesResponse, type HTMLString, type InitOptions, type InternalSession, type IntervalUnit, type IsoDateString, type LineItem, type ListParams, type LoginResponse, type Membership, type MembershipBenefit, type MembershipIncludes, type MembershipListParams, type MembershipListResponse, type MembershipProgram, type MembershipProgramIncludes, type MembershipProgramListParams, type MembershipProgramListResponse, type MembershipProgramResponse, type MembershipProgramSortBy, type MembershipProgramStatus, type MembershipResponse, type MembershipStatus, type MembershipsSortBy, type MergeAddressesRequest, type Metafield, type MetafieldOptionalCreateProps, type MetafieldOwnerResource, type MetafieldRequiredCreateProps, type Method, type Modifier, type MultiStepSettings, type OnePageSettings, type Onetime, type OnetimeListParams, type OnetimeOptionalCreateProps, type OnetimeRequiredCreateProps, type OnetimesResponse, type OnetimesSortBy, type Order, type OrderIncludes, type OrderListParams, type OrderSortBy, type OrderStatus, type OrderType, type OrdersResponse, type PasswordlessCodeResponse, type PasswordlessOptions, type PasswordlessValidateResponse, type PaymentDetails, type PaymentMethod, type PaymentMethodIncludes, type PaymentMethodListParams, type PaymentMethodOptionalCreateProps, type PaymentMethodRequiredCreateProps, type PaymentMethodSortBy, type PaymentMethodStatus, type PaymentMethodsResponse, type PaymentType, type Plan, type PlanListParams, type PlanSortBy, type PlanType, type PlansResponse, type ProcessorName, type ProductImage, type ProductInclude, type ProductListResponse, type ProductOption, type ProductSearchParams_2020_12, type ProductSearchParams_2022_06, type ProductSearchResponse_2020_12, type ProductSearchResponse_2022_06, type ProductSearchType, type ProductSource, type ProductValueOption, type ProductVariant_2020_12, type ProductVariant_2022_06, type Product_2020_12, type Product_2022_06, type Property, type PublishStatus, type Request, type RequestHeaders, type RequestOptions, type SellingPlan, type SellingPlanGroup, type Session, type ShippingCountriesOptions, type ShippingCountriesResponse, type ShippingCountry, type ShippingLine, type ShippingProvince, type ShopifyUpdatePaymentInfoOptions, type SkipChargeParams, type SkipFutureChargeAddressRequest, type SkipFutureChargeAddressResponse, type SortBy, type SortField, type SortKeys, type StepSettings, type StepSettingsCommon, type StepSettingsTypes, type StorefrontEnvironment, type StorefrontOptions, type StorefrontPurchaseOption, type SubType, type Subscription, type SubscriptionIncludes, type SubscriptionListParams, type SubscriptionOption, type SubscriptionOptionalCreateProps, type SubscriptionPreferences, type SubscriptionRequiredCreateProps, type SubscriptionSortBy, type SubscriptionStatus, type Subscription_2021_01, type SubscriptionsResponse, type TaxLine, type Translations, type UpdateAddressRequest, type UpdateBundlePurchaseItem, type UpdateBundleSelectionRequest, type UpdateCustomerRequest, type UpdateMetafieldRequest, type UpdateOnetimeRequest, type UpdatePaymentMethodRequest, type UpdateSubscriptionParams, type UpdateSubscriptionRequest, type UpdateSubscriptionsParams, type UpdateSubscriptionsRequest, type VariantSelector, type VariantSelectorStepSetting, type WidgetIconColor, type WidgetTemplateType, type WidgetVisibility, activateMembership, activateSubscription, api, applyDiscountToAddress, applyDiscountToCharge, cancelMembership, cancelSubscription, changeMembership, createAddress, createBundleSelection, createMetafield, createOnetime, createPaymentMethod, createSubscription, createSubscriptions, deleteAddress, deleteBundleSelection, deleteMetafield, deleteOnetime, getActiveChurnLandingPageURL, getAddress, getBundleId, getBundleSelection, getCDNBundleSettings, getCDNProduct, getCDNProductAndSettings, getCDNProducts, getCDNProductsAndSettings, getCDNStoreSettings, getCDNWidgetSettings, getCharge, getCollection, getCreditSummary, getCustomer, getCustomerPortalAccess, getDeliverySchedule, getDynamicBundleItems, getGiftPurchase, getGiftRedemptionLandingPageURL, getMembership, getMembershipProgram, getOnetime, getOrder, getPaymentMethod, getPlan, getShippingCountries, getSubscription, initRecharge, type intervalUnit, listAddresses, listBundleSelections, listCharges, listCollectionProducts, listCollections, listCreditAccounts, listGiftPurchases, listMembershipPrograms, listMemberships, listOnetimes, listOrders, listPaymentMethods, listPlans, listSubscriptions, loginCustomerPortal, loginShopifyApi, loginShopifyAppProxy, loginWithShopifyCustomerAccount, loginWithShopifyStorefront, type membershipIncludes, mergeAddresses, processCharge, productSearch, removeDiscountsFromAddress, removeDiscountsFromCharge, resetCDNCache, sendCustomerNotification, sendPasswordlessCode, sendPasswordlessCodeAppProxy, setApplyCreditsToNextCharge, skipCharge, skipFutureCharge, skipGiftSubscriptionCharge, skipSubscriptionCharge, unskipCharge, updateAddress, updateBundle, updateBundleSelection, updateCustomer, updateMetafield, updateOnetime, updatePaymentMethod, updateSubscription, updateSubscriptionAddress, updateSubscriptionChargeDate, updateSubscriptions, validateBundle, validateDynamicBundle, validatePasswordlessCode, validatePasswordlessCodeAppProxy };
2776
+ export { type ActivateMembershipRequest, type AddToCartCallbackSettings, type AddonSettings, type Address, type AddressIncludes, type AddressListParams, type AddressListResponse, type AddressResponse, type AddressSortBy, type AnalyticsData, type ApplyCreditOptions, type AssociatedAddress, type BasicSubscriptionParams, type BooleanLike, type BooleanNumbers, type BooleanString, type BooleanStringNumbers, type BundleAppProxy, type BundleData, type BundlePriceRule, type BundleProduct, type BundleProductLayoutSettings, type BundlePurchaseItem, type BundlePurchaseItemParams, type BundleSelection, type BundleSelectionAppProxy, type BundleSelectionItem, type BundleSelectionItemRequiredCreateProps, type BundleSelectionListParams, type BundleSelectionsResponse, type BundleSelectionsSortBy, type BundleTemplateSettings, type BundleTemplateType, type BundleTranslations, type BundleVariant, type BundleVariantOptionSource, type BundleVariantRange, type BundleVariantSelectionDefault, type CDNBaseWidgetSettings, type CDNBundleSettings, type CDNBundleVariant, type CDNBundleVariantOptionSource, type CDNPlan, type CDNProduct, type CDNProductAndSettings, type CDNProductKeyObject, type CDNProductQuery_2020_12, type CDNProductQuery_2022_06, type CDNProductRaw, type CDNProductResource, type CDNProductResponseType, type CDNProductType, type CDNProductVariant_2022_06, type CDNProduct_2022_06, type CDNProductsAndSettings, type CDNProductsAndSettingsResource, type CDNStoreSettings, type CDNSubscriptionOption, type CDNVariant, type CDNVersion, type CDNWidgetSettings, type CDNWidgetSettingsRaw, type CDNWidgetSettingsResource, type CRUDRequestOptions, type CancelMembershipRequest, type CancelSubscriptionRequest, type ChangeMembershipRequest, type ChannelSettings, type Charge, type ChargeIncludes, type ChargeListParams, type ChargeListResponse, type ChargeResponse, type ChargeSortBy, type ChargeStatus, type Collection, type CollectionListParams, type CollectionTypes, type CollectionsResponse, type CollectionsSortBy, type ColorString, type CreateAddressRequest, type CreateBundleSelectionRequest, type CreateMetafieldRequest, type CreateOnetimeRequest, type CreatePaymentMethodRequest, type CreateRecipientAddress, type CreateSubscriptionRequest, type CreateSubscriptionsParams, type CreditAccount, type CreditAccountIncludes, type CreditAccountListParams, type CreditAccountType, type CreditAccountsResponse, type CreditAccountsSortBy, type CreditSummaryIncludes, type CrossSellsSettings, type Customer, type CustomerCreditSummary, type CustomerDeliveryScheduleParams, type CustomerDeliveryScheduleResponse, type CustomerIncludes, type CustomerNotification, type CustomerNotificationOptions, type CustomerNotificationTemplate, type CustomerNotificationType, type CustomerPortalAccessOptions, type CustomerPortalAccessResponse, type Delivery, type DeliveryLineItem, type DeliveryOrder, type DeliveryPaymentMethod, type Discount, type DiscountType, type DynamicBundleItemAppProxy, type DynamicBundlePropertiesAppProxy, type ExternalAttributeSchema, type ExternalId, type ExternalTransactionId, type FirstOption, type GetAddressOptions, type GetChargeOptions, type GetCreditSummaryOptions, type GetCustomerOptions, type GetMembershipProgramOptions, type GetPaymentMethodOptions, type GetRequestOptions, type GetSubscriptionOptions, type GiftPurchase, type GiftPurchasesParams, type GiftPurchasesResponse, type HTMLString, type InitOptions, type InternalSession, type IntervalUnit, type IsoDateString, type LineItem, type ListParams, type LoginResponse, type Membership, type MembershipBenefit, type MembershipIncludes, type MembershipListParams, type MembershipListResponse, type MembershipProgram, type MembershipProgramIncludes, type MembershipProgramListParams, type MembershipProgramListResponse, type MembershipProgramResponse, type MembershipProgramSortBy, type MembershipProgramStatus, type MembershipResponse, type MembershipStatus, type MembershipsSortBy, type MergeAddressesRequest, type Metafield, type MetafieldOptionalCreateProps, type MetafieldOwnerResource, type MetafieldRequiredCreateProps, type Method, type Modifier, type MultiStepSettings, type OnePageSettings, type Onetime, type OnetimeListParams, type OnetimeOptionalCreateProps, type OnetimeRequiredCreateProps, type OnetimesResponse, type OnetimesSortBy, type Order, type OrderIncludes, type OrderListParams, type OrderSortBy, type OrderStatus, type OrderType, type OrdersResponse, type PasswordlessCodeResponse, type PasswordlessOptions, type PasswordlessValidateResponse, type PaymentDetails, type PaymentMethod, type PaymentMethodIncludes, type PaymentMethodListParams, type PaymentMethodOptionalCreateProps, type PaymentMethodRequiredCreateProps, type PaymentMethodSortBy, type PaymentMethodStatus, type PaymentMethodsResponse, type PaymentType, type Plan, type PlanListParams, type PlanSortBy, type PlanType, type PlansResponse, type ProcessorName, type ProductImage, type ProductInclude, type ProductListResponse, type ProductOption, type ProductSearchParams_2020_12, type ProductSearchParams_2022_06, type ProductSearchResponse_2020_12, type ProductSearchResponse_2022_06, type ProductSearchType, type ProductSource, type ProductValueOption, type ProductVariant_2020_12, type ProductVariant_2022_06, type Product_2020_12, type Product_2022_06, type Property, type PublishStatus, type Request, type RequestHeaders, type RequestOptions, type SellingPlan, type SellingPlanGroup, type Session, type ShippingCountriesOptions, type ShippingCountriesResponse, type ShippingCountry, type ShippingLine, type ShippingProvince, type ShopifyUpdatePaymentInfoOptions, type SkipChargeParams, type SkipFutureChargeAddressRequest, type SkipFutureChargeAddressResponse, type SortBy, type SortField, type SortKeys, type StepSettings, type StepSettingsCommon, type StepSettingsTypes, type StorefrontEnvironment, type StorefrontOptions, type StorefrontPurchaseOption, type SubType, type Subscription, type SubscriptionIncludes, type SubscriptionListParams, type SubscriptionOption, type SubscriptionOptionalCreateProps, type SubscriptionPreferences, type SubscriptionRequiredCreateProps, type SubscriptionSortBy, type SubscriptionStatus, type Subscription_2021_01, type SubscriptionsResponse, type TaxLine, type Translations, type UpdateAddressRequest, type UpdateBundlePurchaseItem, type UpdateBundleSelectionRequest, type UpdateCustomerRequest, type UpdateMetafieldRequest, type UpdateOnetimeRequest, type UpdatePaymentMethodRequest, type UpdateSubscriptionParams, type UpdateSubscriptionRequest, type UpdateSubscriptionsParams, type UpdateSubscriptionsRequest, type VariantSelector, type VariantSelectorStepSetting, type WidgetIconColor, type WidgetTemplateType, type WidgetVisibility, activateMembership, activateSubscription, api, applyDiscountToAddress, applyDiscountToCharge, cancelMembership, cancelSubscription, changeMembership, createAddress, createBundleSelection, createMetafield, createOnetime, createPaymentMethod, createSubscription, createSubscriptions, deleteAddress, deleteBundleSelection, deleteMetafield, deleteOnetime, getActiveChurnLandingPageURL, getAddress, getBundleId, getBundleSelection, getCDNBundleSettings, getCDNProduct, getCDNProductAndSettings, getCDNProducts, getCDNProductsAndSettings, getCDNStoreSettings, getCDNWidgetSettings, getCharge, getCollection, getCreditSummary, getCustomer, getCustomerPortalAccess, getDeliverySchedule, getDynamicBundleItems, getGiftPurchase, getGiftRedemptionLandingPageURL, getMembership, getMembershipProgram, getOnetime, getOrder, getPaymentMethod, getPlan, getShippingCountries, getSubscription, initRecharge, type intervalUnit, listAddresses, listBundleSelections, listCharges, listCollectionProducts, listCollections, listCreditAccounts, listGiftPurchases, listMembershipPrograms, listMemberships, listOnetimes, listOrders, listPaymentMethods, listPlans, listSubscriptions, loginCustomerPortal, loginShopifyApi, loginShopifyAppProxy, loginWithShopifyCustomerAccount, loginWithShopifyStorefront, type membershipIncludes, mergeAddresses, processCharge, productSearch, removeDiscountsFromAddress, removeDiscountsFromCharge, resetCDNCache, sendCustomerNotification, sendPasswordlessCode, sendPasswordlessCodeAppProxy, setApplyCreditsToNextCharge, skipCharge, skipFutureCharge, skipGiftSubscriptionCharge, skipSubscriptionCharge, unskipCharge, updateAddress, updateBundle, updateBundleSelection, updateCustomer, updateMetafield, updateOnetime, updatePaymentMethod, updateSubscription, updateSubscriptionAddress, updateSubscriptionChargeDate, updateSubscriptions, validateBundle, validateBundleSelection, validateDynamicBundle, validatePasswordlessCode, validatePasswordlessCodeAppProxy };