@rechargeapps/storefront-client 2.0.0 → 2.2.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.
- package/dist/cjs/api/auth.js +1 -1
- package/dist/cjs/api/bundleData.js +1 -1
- package/dist/cjs/api/subscription.js +15 -0
- package/dist/cjs/api/subscription.js.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/bundle.js +57 -59
- package/dist/cjs/utils/bundle.js.map +1 -1
- package/dist/cjs/utils/request.js +1 -1
- package/dist/esm/api/auth.js +1 -1
- package/dist/esm/api/bundleData.js +1 -1
- package/dist/esm/api/subscription.js +15 -1
- package/dist/esm/api/subscription.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/utils/bundle.js +57 -59
- package/dist/esm/utils/bundle.js.map +1 -1
- package/dist/esm/utils/request.js +1 -1
- package/dist/index.d.ts +84 -1
- package/dist/umd/recharge-client.min.js +2 -11
- package/package.json +4 -4
package/dist/esm/utils/bundle.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { enumType, union, int32, unionCase, voidType, struct, uint64, string, UNBOUNDED_MAX_LENGTH, uint32, array, field } from '@stellar/js-xdr';
|
|
2
2
|
|
|
3
3
|
var __accessCheck = (obj, member, msg) => {
|
|
4
4
|
if (!member.has(obj))
|
|
@@ -23,68 +23,66 @@ var __privateMethod = (obj, member, method) => {
|
|
|
23
23
|
return method;
|
|
24
24
|
};
|
|
25
25
|
var _bundleSettings, _items, _bundleData, _formatBundleSettings, formatBundleSettings_fn, _formatBundleData, formatBundleData_fn, _isValueInRange, isValueInRange_fn, _unique, unique_fn, _hasOwn, hasOwn_fn;
|
|
26
|
+
const textEncoder = new TextEncoder();
|
|
27
|
+
const emptyExt = { v: 0 };
|
|
28
|
+
function toBase64(bytes) {
|
|
29
|
+
let binary = "";
|
|
30
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
31
|
+
binary += String.fromCharCode(bytes[i]);
|
|
32
|
+
}
|
|
33
|
+
return btoa(binary);
|
|
34
|
+
}
|
|
35
|
+
const EnvelopeType = enumType("EnvelopeType", {
|
|
36
|
+
envelopeTypeBundle: 0
|
|
37
|
+
});
|
|
38
|
+
const BundleItemExt = union("BundleItemExt", {
|
|
39
|
+
switchOn: int32(),
|
|
40
|
+
switchKey: "v",
|
|
41
|
+
cases: [unionCase("v0", 0, voidType())]
|
|
42
|
+
});
|
|
43
|
+
const BundleItem = struct("BundleItem", {
|
|
44
|
+
collectionId: uint64(),
|
|
45
|
+
productId: uint64(),
|
|
46
|
+
variantId: uint64(),
|
|
47
|
+
sku: string(UNBOUNDED_MAX_LENGTH),
|
|
48
|
+
quantity: uint32(),
|
|
49
|
+
ext: BundleItemExt
|
|
50
|
+
});
|
|
51
|
+
const BundleExt = union("BundleExt", {
|
|
52
|
+
switchOn: int32(),
|
|
53
|
+
switchKey: "v",
|
|
54
|
+
cases: [unionCase("v0", 0, voidType())]
|
|
55
|
+
});
|
|
56
|
+
const Bundle = struct("Bundle", {
|
|
57
|
+
variantId: uint64(),
|
|
58
|
+
items: array(BundleItem, 500),
|
|
59
|
+
version: uint32(),
|
|
60
|
+
ext: BundleExt
|
|
61
|
+
});
|
|
62
|
+
const BundleEnvelope = union("BundleEnvelope", {
|
|
63
|
+
switchOn: EnvelopeType,
|
|
64
|
+
switchKey: "type",
|
|
65
|
+
cases: [unionCase("envelopeTypeBundle", EnvelopeType.envelopeTypeBundle, field("v1", Bundle))]
|
|
66
|
+
});
|
|
26
67
|
function toLineItemProperty(bundle) {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
collectionId:
|
|
33
|
-
productId:
|
|
34
|
-
variantId:
|
|
35
|
-
sku: item.sku || "",
|
|
68
|
+
const value = {
|
|
69
|
+
type: EnvelopeType.envelopeTypeBundle,
|
|
70
|
+
v1: {
|
|
71
|
+
variantId: BigInt(bundle.variantId.toString()),
|
|
72
|
+
items: bundle.items.map((item) => ({
|
|
73
|
+
collectionId: BigInt(item.collectionId.toString()),
|
|
74
|
+
productId: BigInt(item.productId.toString()),
|
|
75
|
+
variantId: BigInt(item.variantId.toString()),
|
|
76
|
+
sku: textEncoder.encode(item.sku || ""),
|
|
36
77
|
quantity: item.quantity,
|
|
37
|
-
ext:
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
|
|
78
|
+
ext: emptyExt
|
|
79
|
+
})),
|
|
80
|
+
version: bundle.version || Math.floor(Date.now() / 1e3),
|
|
81
|
+
ext: emptyExt
|
|
82
|
+
}
|
|
41
83
|
};
|
|
42
|
-
|
|
43
|
-
return xdr.BundleEnvelope.envelopeTypeBundle(xdrBundle).toXDR("base64");
|
|
84
|
+
return toBase64(BundleEnvelope.encode(value));
|
|
44
85
|
}
|
|
45
|
-
const xdr = config(
|
|
46
|
-
(xdr2) => {
|
|
47
|
-
xdr2.enum("EnvelopeType", {
|
|
48
|
-
envelopeTypeBundle: 0
|
|
49
|
-
});
|
|
50
|
-
xdr2.typedef("Uint32", xdr2.uint());
|
|
51
|
-
xdr2.typedef("Uint64", xdr2.uhyper());
|
|
52
|
-
xdr2.union("BundleItemExt", {
|
|
53
|
-
switchOn: xdr2.int(),
|
|
54
|
-
switchName: "v",
|
|
55
|
-
switches: [[0, xdr2.void()]],
|
|
56
|
-
arms: {}
|
|
57
|
-
});
|
|
58
|
-
xdr2.struct("BundleItem", [
|
|
59
|
-
["collectionId", xdr2.lookup("Uint64")],
|
|
60
|
-
["productId", xdr2.lookup("Uint64")],
|
|
61
|
-
["variantId", xdr2.lookup("Uint64")],
|
|
62
|
-
["sku", xdr2.string()],
|
|
63
|
-
["quantity", xdr2.lookup("Uint32")],
|
|
64
|
-
["ext", xdr2.lookup("BundleItemExt")]
|
|
65
|
-
]);
|
|
66
|
-
xdr2.union("BundleExt", {
|
|
67
|
-
switchOn: xdr2.int(),
|
|
68
|
-
switchName: "v",
|
|
69
|
-
switches: [[0, xdr2.void()]],
|
|
70
|
-
arms: {}
|
|
71
|
-
});
|
|
72
|
-
xdr2.struct("Bundle", [
|
|
73
|
-
["variantId", xdr2.lookup("Uint64")],
|
|
74
|
-
["items", xdr2.varArray(xdr2.lookup("BundleItem"), 500)],
|
|
75
|
-
["version", xdr2.lookup("Uint32")],
|
|
76
|
-
["ext", xdr2.lookup("BundleExt")]
|
|
77
|
-
]);
|
|
78
|
-
xdr2.union("BundleEnvelope", {
|
|
79
|
-
switchOn: xdr2.lookup("EnvelopeType"),
|
|
80
|
-
switchName: "type",
|
|
81
|
-
switches: [["envelopeTypeBundle", "v1"]],
|
|
82
|
-
arms: {
|
|
83
|
-
v1: xdr2.lookup("Bundle")
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
);
|
|
88
86
|
class BundleSelectionValidator {
|
|
89
87
|
constructor(selectionItems, bundleData) {
|
|
90
88
|
__privateAdd(this, _formatBundleSettings);
|
|
@@ -1 +1 @@
|
|
|
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 // null-proto seeds so external variant/option-source ids become real own keys, not prototype pollution\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 }, Object.create(null)),\n ranges,\n };\n return acc;\n }, Object.create(null)),\n };\n } catch (error) {\n return null;\n }\n }\n\n #formatBundleData(bundleData: StorefrontBundleData) {\n try {\n // null-proto seeds so external collection/product ids become real own keys, not prototype pollution\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 }, Object.create(null)),\n };\n\n return acc;\n }, Object.create(null));\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 // Own-property membership check. Guards against inherited keys (e.g. `__proto__`,\n // `constructor`, `toString`) resolving to truthy values on plain-object maps.\n #hasOwn(target: object, key: string) {\n return Object.prototype.hasOwnProperty.call(target, key);\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 optionSources = variantSettings?.optionSources;\n const invalidCollections = this.#items.filter(\n ({ collectionId }) => !optionSources || !this.#hasOwn(optionSources, collectionId)\n );\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 // null-proto seed so a `__proto__` collectionId becomes a real own key, not prototype pollution\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 }, Object.create(null));\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 // null-proto seed so a `__proto__` collectionId becomes a real own key, not prototype pollution\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 Object.create(null)\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(({ externalProductId, collectionId }) => {\n if (!this.#hasOwn(variantCollections, collectionId)) {\n return true;\n }\n return !this.#hasOwn(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,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,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,IAAK,CAAA,YAAA,CAAa,UAAU,CAAA;AAAA,QAChE,WAAW,GAAI,CAAA,MAAA,CAAO,WAAW,IAAK,CAAA,SAAA,CAAU,UAAU,CAAA;AAAA,QAC1D,WAAW,GAAI,CAAA,MAAA,CAAO,WAAW,IAAK,CAAA,SAAA,C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zB,CAAA,CAAA;AAEA,OAAA,GAAA,IAAA,OAAA,EAAA,CAAA;AAAA,SAAA,GAAO,SAAC,GAAe,EAAA;AACrB,EAAA,OAAO,KAAM,CAAA,IAAA,CAAK,IAAI,GAAA,CAAI,GAAG,CAAC,CAAA,CAAA;AAChC,CAAA,CAAA;AAIA,OAAA,GAAA,IAAA,OAAA,EAAA,CAAA;AAAA,SAAO,GAAA,SAAC,QAAgB,GAAa,EAAA;AACnC,EAAA,OAAO,MAAO,CAAA,SAAA,CAAU,cAAe,CAAA,IAAA,CAAK,QAAQ,GAAG,CAAA,CAAA;AACzD,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"bundle.js","sources":["../../../src/utils/bundle.ts"],"sourcesContent":["import {\n array,\n enumType,\n field,\n int32,\n string as xdrString,\n struct,\n uint32,\n uint64,\n union,\n unionCase,\n voidType,\n UNBOUNDED_MAX_LENGTH,\n} from '@stellar/js-xdr';\nimport { BundleData as StorefrontBundleData, CDNBundleSettings } from '../types';\n\nconst textEncoder = new TextEncoder();\n\nconst emptyExt = { v: 0 } as const;\n\nfunction toBase64(bytes: Uint8Array) {\n let binary = '';\n for (let i = 0; i < bytes.length; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n return btoa(binary);\n}\n\nconst EnvelopeType = enumType('EnvelopeType', {\n envelopeTypeBundle: 0,\n});\n\nconst BundleItemExt = union('BundleItemExt', {\n switchOn: int32(),\n switchKey: 'v',\n cases: [unionCase('v0', 0, voidType())],\n});\n\nconst BundleItem = struct('BundleItem', {\n collectionId: uint64(),\n productId: uint64(),\n variantId: uint64(),\n sku: xdrString(UNBOUNDED_MAX_LENGTH),\n quantity: uint32(),\n ext: BundleItemExt,\n});\n\nconst BundleExt = union('BundleExt', {\n switchOn: int32(),\n switchKey: 'v',\n cases: [unionCase('v0', 0, voidType())],\n});\n\nconst Bundle = struct('Bundle', {\n variantId: uint64(),\n items: array(BundleItem, 500),\n version: uint32(),\n ext: BundleExt,\n});\n\nconst BundleEnvelope = union('BundleEnvelope', {\n switchOn: EnvelopeType,\n switchKey: 'type',\n cases: [unionCase('envelopeTypeBundle', EnvelopeType.envelopeTypeBundle, field('v1', Bundle))],\n});\n\nexport function toLineItemProperty(bundle: { variantId: string; version: number; items: any[] }) {\n const value = {\n type: EnvelopeType.envelopeTypeBundle,\n v1: {\n variantId: BigInt(bundle.variantId.toString()),\n items: bundle.items.map(item => ({\n collectionId: BigInt(item.collectionId.toString()),\n productId: BigInt(item.productId.toString()),\n variantId: BigInt(item.variantId.toString()),\n sku: textEncoder.encode(item.sku || ''),\n quantity: item.quantity as number,\n ext: emptyExt,\n })),\n version: bundle.version || Math.floor(Date.now() / 1000),\n ext: emptyExt,\n },\n };\n\n return toBase64(BundleEnvelope.encode(value));\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 // null-proto seeds so external variant/option-source ids become real own keys, not prototype pollution\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 }, Object.create(null)),\n ranges,\n };\n return acc;\n }, Object.create(null)),\n };\n } catch (error) {\n return null;\n }\n }\n\n #formatBundleData(bundleData: StorefrontBundleData) {\n try {\n // null-proto seeds so external collection/product ids become real own keys, not prototype pollution\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 }, Object.create(null)),\n };\n\n return acc;\n }, Object.create(null));\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 // Own-property membership check. Guards against inherited keys (e.g. `__proto__`,\n // `constructor`, `toString`) resolving to truthy values on plain-object maps.\n #hasOwn(target: object, key: string) {\n return Object.prototype.hasOwnProperty.call(target, key);\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 optionSources = variantSettings?.optionSources;\n const invalidCollections = this.#items.filter(\n ({ collectionId }) => !optionSources || !this.#hasOwn(optionSources, collectionId)\n );\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 // null-proto seed so a `__proto__` collectionId becomes a real own key, not prototype pollution\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 }, Object.create(null));\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 // null-proto seed so a `__proto__` collectionId becomes a real own key, not prototype pollution\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 Object.create(null)\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(({ externalProductId, collectionId }) => {\n if (!this.#hasOwn(variantCollections, collectionId)) {\n return true;\n }\n return !this.#hasOwn(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":["xdrString","acc"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA,eAAA,EAAA,MAAA,EAAA,WAAA,EAAA,qBAAA,EAAA,uBAAA,EAAA,iBAAA,EAAA,mBAAA,EAAA,eAAA,EAAA,iB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,IAAA,QAAA,CAAA;AAAA,GACtC,CAAA,CAAA;AAED,EAAO,OAAA,CAAC,CAAC,aAAc,CAAA,MAAA,CAAA;AACzB,CAAA,CAAA;AAEA,OAAA,GAAA,IAAA,OAAA,EAAA,CAAA;AAAA,SAAA,GAAO,SAAC,GAAe,EAAA;AACrB,EAAA,OAAO,KAAM,CAAA,IAAA,CAAK,IAAI,GAAA,CAAI,GAAG,CAAC,CAAA,CAAA;AAChC,CAAA,CAAA;AAIA,OAAA,GAAA,IAAA,OAAA,EAAA,CAAA;AAAA,SAAO,GAAA,SAAC,QAAgB,GAAa,EAAA;AACnC,EAAA,OAAO,MAAO,CAAA,SAAA,CAAU,cAAe,CAAA,IAAA,CAAK,QAAQ,GAAG,CAAA,CAAA;AACzD,CAAA;;;;"}
|
|
@@ -44,7 +44,7 @@ async function rechargeApiRequest(method, url, { id, query, data, headers } = {}
|
|
|
44
44
|
"X-Recharge-Sdk-Fn": session.internalFnCall,
|
|
45
45
|
...appName ? { "X-Recharge-Sdk-App-Name": appName } : {},
|
|
46
46
|
...appVersion ? { "X-Recharge-Sdk-App-Version": appVersion } : {},
|
|
47
|
-
"X-Recharge-Sdk-Version": "2.
|
|
47
|
+
"X-Recharge-Sdk-Version": "2.2.0",
|
|
48
48
|
"X-Request-Id": session.internalRequestId,
|
|
49
49
|
...session.tmp_fn_identifier ? { "X-Recharge-Sdk-Fn-Identifier": session.tmp_fn_identifier } : {},
|
|
50
50
|
...headers ? headers : {}
|
package/dist/index.d.ts
CHANGED
|
@@ -1725,6 +1725,75 @@ interface Subscription_2021_01 {
|
|
|
1725
1725
|
}
|
|
1726
1726
|
/** @internal */
|
|
1727
1727
|
type SubscriptionListAddonsParams = Pick<SubscriptionListParams, 'include' | 'limit' | 'cursor'>;
|
|
1728
|
+
/**
|
|
1729
|
+
* @internal
|
|
1730
|
+
* A proposed change to price against an existing subscription.
|
|
1731
|
+
*
|
|
1732
|
+
* Both fields are optional and an omitted field means "keep the subscription's current value".
|
|
1733
|
+
* Quantity and frequency are deliberately not accepted -- they cannot move a dynamically priced
|
|
1734
|
+
* subscription between tiers, and accepting them would make this a general-purpose update preview.
|
|
1735
|
+
*/
|
|
1736
|
+
interface SubscriptionPricingPreviewRequest {
|
|
1737
|
+
/** The variant the customer would swap to. */
|
|
1738
|
+
external_variant_id?: ExternalId;
|
|
1739
|
+
/** The plan the customer would swap to. */
|
|
1740
|
+
plan_id?: Plan['id'] | null;
|
|
1741
|
+
}
|
|
1742
|
+
/**
|
|
1743
|
+
* @internal
|
|
1744
|
+
* What would cause a dynamic pricing progression to reset if the proposed change were committed.
|
|
1745
|
+
*/
|
|
1746
|
+
type PricingProgressionResetTrigger = 'variant_swap' | 'plan_swap';
|
|
1747
|
+
/**
|
|
1748
|
+
* @internal
|
|
1749
|
+
* The dynamic pricing plan's shape, plus where the subscription sits in its pricing progression.
|
|
1750
|
+
*/
|
|
1751
|
+
interface DynamicPricingPreviewDetails {
|
|
1752
|
+
/** True when the plan resolved for the preview is dynamically priced. */
|
|
1753
|
+
is_dynamic_priced_plan: boolean;
|
|
1754
|
+
/** Discount applied to the orders before the recurring discount takes over. A rate for `percentage`, an amount for `fixed_amount`. */
|
|
1755
|
+
initial_discount_amount: string | null;
|
|
1756
|
+
initial_discount_type: DiscountType | null;
|
|
1757
|
+
/** Discount applied to every order once the initial discount is exhausted. */
|
|
1758
|
+
recurring_discount_amount: string | null;
|
|
1759
|
+
recurring_discount_type: DiscountType | null;
|
|
1760
|
+
/** The billing cycle after which the recurring discount takes over from the initial discount. */
|
|
1761
|
+
recurring_discount_after_cycle: number | null;
|
|
1762
|
+
/** How many orders the customer would receive at the initial discount. */
|
|
1763
|
+
orders_at_initial_discount: number | null;
|
|
1764
|
+
/** How many recurring orders the customer has already completed. */
|
|
1765
|
+
completed_recurring_orders: number | null;
|
|
1766
|
+
/** True when the recurring discount is the tier currently applying. */
|
|
1767
|
+
recurring_discount_active: boolean;
|
|
1768
|
+
/** True when committing the proposed change would reset the customer's pricing progression. */
|
|
1769
|
+
progression_will_reset: boolean;
|
|
1770
|
+
/** Why the progression would reset. Null when `progression_will_reset` is false. */
|
|
1771
|
+
reset_trigger: PricingProgressionResetTrigger | null;
|
|
1772
|
+
}
|
|
1773
|
+
/**
|
|
1774
|
+
* @internal
|
|
1775
|
+
* The result of pricing a proposed subscription change without persisting it. Prices are strings
|
|
1776
|
+
* quantized to 2 decimal places and are already in the subscription's presentment currency.
|
|
1777
|
+
*/
|
|
1778
|
+
interface SubscriptionPricingPreview {
|
|
1779
|
+
subscription_id: number;
|
|
1780
|
+
/** The store's currency. */
|
|
1781
|
+
currency: string | null;
|
|
1782
|
+
/** The currency the customer is billed in. */
|
|
1783
|
+
presentment_currency: string | null;
|
|
1784
|
+
/** The per-unit price the subscription bills at today. */
|
|
1785
|
+
current_unit_price: string | null;
|
|
1786
|
+
/** The per-unit price it would bill at after the proposed change. */
|
|
1787
|
+
proposed_unit_price: string | null;
|
|
1788
|
+
/** The undiscounted per-unit price the discount was applied to. */
|
|
1789
|
+
base_unit_price: string | null;
|
|
1790
|
+
/** The discount tier that actually applied -- a rate or a fixed amount per `applied_discount_type`. */
|
|
1791
|
+
applied_discount_amount: string | null;
|
|
1792
|
+
applied_discount_type: DiscountType | null;
|
|
1793
|
+
dynamic_pricing_details: DynamicPricingPreviewDetails | null;
|
|
1794
|
+
/** Field-to-message map from the pricing chain. Keys vary by failure. */
|
|
1795
|
+
errors: Record<string, string> | null;
|
|
1796
|
+
}
|
|
1728
1797
|
|
|
1729
1798
|
type CustomerNotification = 'SHOPIFY_UPDATE_PAYMENT_INFO' | 'SHOPIFY_MIGRATE_PAYMENT_INFO';
|
|
1730
1799
|
type CustomerNotificationType = 'email' | 'sms';
|
|
@@ -4275,6 +4344,19 @@ declare function cancelSubscription(session: Session, id: string | number, cance
|
|
|
4275
4344
|
*/
|
|
4276
4345
|
declare function activateSubscription(session: Session, id: string | number, query?: BasicSubscriptionParams): Promise<Subscription>;
|
|
4277
4346
|
declare function skipSubscriptionCharge(session: Session, id: number | string, date: IsoDateString): Promise<Charge>;
|
|
4347
|
+
/**
|
|
4348
|
+
* @internal
|
|
4349
|
+
* Price a proposed variant and/or plan swap for a subscription without persisting it.
|
|
4350
|
+
*
|
|
4351
|
+
* Runs the same pricing chain the update would run, so the returned `proposed_unit_price` is what
|
|
4352
|
+
* the customer would actually be charged -- including dynamic pricing tier resolution and any
|
|
4353
|
+
* pricing progression reset the swap would cause. Omitted request fields keep the subscription's
|
|
4354
|
+
* current value; quantity and frequency are not accepted because they cannot move the per-unit price
|
|
4355
|
+
* between dynamic pricing tiers.
|
|
4356
|
+
*
|
|
4357
|
+
* Pricing failures are reported in the returned `errors` map rather than thrown.
|
|
4358
|
+
*/
|
|
4359
|
+
declare function getSubscriptionPricingPreview(session: Session, id: string | number, previewRequest?: SubscriptionPricingPreviewRequest): Promise<SubscriptionPricingPreview>;
|
|
4278
4360
|
/**
|
|
4279
4361
|
* Gift a subscription to another person. This creates onetime products for the recipient and skips that subscription for the customer.
|
|
4280
4362
|
* When the gifted onetime ships the recipient receives and email notification.
|
|
@@ -4317,4 +4399,5 @@ declare const api: {
|
|
|
4317
4399
|
};
|
|
4318
4400
|
declare function initRecharge(opt?: InitOptions): void;
|
|
4319
4401
|
|
|
4320
|
-
export { type ActivateMembershipRequest, type AddToCartCallbackSettings, type Addon, type AddonProduct, type AddonSettings, type AddonType, type AddonsSection, type Address, type AddressIncludes, type AddressListParams, type AddressListResponse, type AddressResponse, type AddressSortBy, type AnalyticsData, type Announcement, type ApplyCreditOptions, type AssociatedAddress, type BaseCardDetails, type BaseProduct, type BaseProductVariant, type BaseVariant, type BasicSubscriptionParams, type BooleanLike, type BooleanNumbers, type BooleanString, type BooleanStringNumbers, type BulkSubscriptionParams, type BundleAppProxy, type BundleData, type BundleDataBaseProduct, type BundleDataCollection, type BundleDataSellingPlan, type BundleDataSellingPlanGroup, type BundleDataVariant, type BundleFilterGroup, type BundlePriceRule, type BundleProduct, type BundleProductGlobalStyles, type BundleProductLayoutSettings, type BundlePurchaseItem, type BundlePurchaseItemParams, type BundleSelection, type BundleSelectionAppProxy, type BundleSelectionItem, type BundleSelectionItemRequiredCreateProps, type BundleSelectionListParams, type BundleSelectionsResponse, type BundleSelectionsSortBy, type BundleSettings, 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 CardDetailsFirstNameLastName, type CardDetailsFullName, type ChangeMembershipRequest, type ChannelSettings, type Charge, type ChargeIncludes, type ChargeListParams, type ChargeListResponse, type ChargeResponse, type ChargeSortBy, type ChargeStatus, type Collection, type CollectionBinding, 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 CreateSubscriptionsRequest, type CreditAccount, type CreditAccountIncludes, type CreditAccountListParams, type CreditAccountType, type CreditAccountsResponse, type CreditAccountsSortBy, type CreditSummaryIncludes, type CrossSellsSection, type CrossSellsSettings, type CurrencyPriceSet, type Customer, type CustomerCreditSummary, type CustomerDeliveryScheduleParams, type CustomerDeliveryScheduleResponse, type CustomerIncludeGiftPurchase, type CustomerIncludes, type CustomerNotification, type CustomerNotificationOptions, type CustomerNotificationTemplate, type CustomerNotificationType, type CustomerPortalAccessOptions, type CustomerPortalAccessResponse, type CustomerPortalSettings, type CustomerSurveyOfferParams, type CustomerSurveyOfferResponse, type CustomerSurveyOffersResponse, type CustomerSurveyReason, type CustomerSurveyReasonsResponse, type DefaultProduct, type DefaultSelection, type DefaultVariant, type DelayOption, type DeleteSubscriptionsParams, type DeleteSubscriptionsRequest, type Delivery, type DeliveryLineItem, type DeliveryOrder, type DeliveryPaymentMethod, type Discount, type DiscountApplicationMethod, type DiscountType, type DynamicBundleItemAppProxy, type DynamicBundlePropertiesAppProxy, type EligibleChargeType, type EligibleLineItemType, type ExternalAttributeSchema, type ExternalId, type ExternalProductStatus, type ExternalTransactionId, type FilterInputType, type FilterMatchMode, type FilterSource, 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 Incentives, type InitOptions, type InternalSession, type IntervalUnit, type InventoryPolicy, 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 OfferAttributes, type OnePageSettings, type Onetime, type OnetimeIncludes, type OnetimeListParams, type OnetimeOptionalCreateProps, type OnetimeRequiredCreateProps, type OnetimeSubscription, type OnetimesResponse, type OnetimesSortBy, type OnlineStoreOptions, type Options, type Order, type OrderIncludes, type OrderListParams, type OrderSortBy, type OrderStatus, type OrderType, type OrdersResponse, type PasswordlessCodeResponse, type PasswordlessOptions, type PasswordlessValidateResponse, type PaymentDetails, type PaymentErrorCallback, type PaymentFieldEventCallback, type PaymentFormConfig, type PaymentFormController, type PaymentFormEventHandlers, type PaymentMethod, type PaymentMethodFormOptions, type PaymentMethodIncludes, type PaymentMethodListParams, type PaymentMethodOptionalCreateProps, type PaymentMethodRequiredCreateProps, type PaymentMethodSortBy, type PaymentMethodStatus, type PaymentMethodTokenCallback, type PaymentMethodsResponse, type PaymentType, type Plan, type PlanListParams, type PlanSortBy, type PlanType, type PlansResponse, type PriceRange, type PriceRule, type PriceSet, type ProcessorName, type Product, 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 PublicBundleData, type PublishStatus, type PunchCardProgress, type PunchCardProgressData, type QuantityRange, type RecurringSubscription, type ReferralInfo, type ReferralUrl, type Request, type RequestHeaders, type RequestOptions, type SellingPlan, type SellingPlanAllocation, type SellingPlanGroup, type Session, type ShippingCountriesOptions, type ShippingCountriesResponse, type ShippingCountry, type ShippingLine, type ShippingProvince, type ShopifyStorefrontOptions, type ShopifyUpdatePaymentInfoOptions, type SkipChargeParams, type SkipFutureChargeAddressRequest, type SkipFutureChargeAddressResponse, type SortBy, type SortField, type SortKeys, type StepSettings, type StepSettingsCommon, type StepSettingsTypes, type StoreSettings, type StorefrontEnvironment, type StorefrontOptions, type StorefrontPurchaseOption, type SubType, type Subscription, type SubscriptionBase, type SubscriptionCancelled, type SubscriptionIncludes, type SubscriptionListAddonsParams, type SubscriptionListParams, type SubscriptionOption, type SubscriptionOptionalCreateProps, type SubscriptionPreferences, type SubscriptionRequiredCreateProps, type SubscriptionSortBy, type SubscriptionStatus, type Subscription_2021_01, type SubscriptionsResponse, type TaxLine, type Tier, type TieredDiscount, type TieredDiscountOffer, type TieredDiscountOfferLineItem, type TieredDiscountOfferTarget, type TieredDiscountOfferTier, type TieredDiscountOffersRequest, type TieredDiscountOffersResponse, type TieredDiscountStatus, type TieredDiscountsParams, type TieredDiscountsResponse, type Translations, type UpdateAddressParams, type UpdateAddressRequest, type UpdateBundlePurchaseItem, type UpdateBundleSelectionRequest, type UpdateCustomerRequest, type UpdateMetafieldRequest, type UpdateOnetimeRequest, type UpdatePaymentMethodRequest, type UpdateSubscriptionChargeDateParams, type UpdateSubscriptionParams, type UpdateSubscriptionRequest, type UpdateSubscriptionsParams, type UpdateSubscriptionsRequest, type Variant, type VariantSelector, type VariantSelectorStepSetting, type WidgetIconColor, type WidgetTemplateType, type WidgetVisibility, activateMembership, activateSubscription, api, applyDiscountToAddress, applyDiscountToCharge, cancelMembership, cancelSubscription, changeMembership, claimOfferCustomerSurvey, createAddress, createBundleSelection, createMetafield, createOnetime, createPaymentMethod, createSubscription, createSubscriptions, delayOrder, deleteAddress, deleteBundleSelection, deleteMetafield, deleteOnetime, deleteSubscriptions, getActiveChurnLandingPageURL, getAddress, getBundleId, getBundleSelection, getBundleSelectionId, getCDNBundleSettings, getCDNProduct, getCDNProductAndSettings, getCDNProducts, getCDNProductsAndSettings, getCDNStoreSettings, getCDNWidgetSettings, getCharge, getCollection, getCreditSummary, getCustomer, getCustomerPortalAccess, getCustomerSurveyOffers, getCustomerSurveyReasons, getDeliverySchedule, getDynamicBundleItems, getFailedPaymentMethodRecoveryLandingPageURL, getGiftPurchase, getGiftRedemptionLandingPageURL, getMembership, getMembershipProgram, getOnetime, getOrder, getPaymentMethod, getPlan, getShippingCountries, getStoreSettings, getSubscription, getTieredDiscount, getTieredDiscountOffers, initFrictionlessPaymentV1, initRecharge, type intervalUnit, listAddresses, listBundleSelections, listCharges, listCollectionProducts, listCollections, listCreditAccounts, listGiftPurchases, listMembershipPrograms, listMemberships, listOnetimes, listOrders, listPaymentMethods, listPlans, listSubscriptionAddons, listSubscriptions, listTieredDiscounts, loadBundleData, loginCustomerPortal, loginShopifyApi, loginShopifyAppProxy, loginWithShopifyCustomerAccount, loginWithShopifyStorefront, type membershipIncludes, mergeAddresses, processCharge, productSearch, removeDiscountsFromAddress, removeDiscountsFromCharge, rescheduleCharge, 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 };
|
|
4402
|
+
export { activateMembership, activateSubscription, api, applyDiscountToAddress, applyDiscountToCharge, cancelMembership, cancelSubscription, changeMembership, claimOfferCustomerSurvey, createAddress, createBundleSelection, createMetafield, createOnetime, createPaymentMethod, createSubscription, createSubscriptions, delayOrder, deleteAddress, deleteBundleSelection, deleteMetafield, deleteOnetime, deleteSubscriptions, getActiveChurnLandingPageURL, getAddress, getBundleId, getBundleSelection, getBundleSelectionId, getCDNBundleSettings, getCDNProduct, getCDNProductAndSettings, getCDNProducts, getCDNProductsAndSettings, getCDNStoreSettings, getCDNWidgetSettings, getCharge, getCollection, getCreditSummary, getCustomer, getCustomerPortalAccess, getCustomerSurveyOffers, getCustomerSurveyReasons, getDeliverySchedule, getDynamicBundleItems, getFailedPaymentMethodRecoveryLandingPageURL, getGiftPurchase, getGiftRedemptionLandingPageURL, getMembership, getMembershipProgram, getOnetime, getOrder, getPaymentMethod, getPlan, getShippingCountries, getStoreSettings, getSubscription, getSubscriptionPricingPreview, getTieredDiscount, getTieredDiscountOffers, initFrictionlessPaymentV1, initRecharge, listAddresses, listBundleSelections, listCharges, listCollectionProducts, listCollections, listCreditAccounts, listGiftPurchases, listMembershipPrograms, listMemberships, listOnetimes, listOrders, listPaymentMethods, listPlans, listSubscriptionAddons, listSubscriptions, listTieredDiscounts, loadBundleData, loginCustomerPortal, loginShopifyApi, loginShopifyAppProxy, loginWithShopifyCustomerAccount, loginWithShopifyStorefront, mergeAddresses, processCharge, productSearch, removeDiscountsFromAddress, removeDiscountsFromCharge, rescheduleCharge, 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 };
|
|
4403
|
+
export type { ActivateMembershipRequest, AddToCartCallbackSettings, Addon, AddonProduct, AddonSettings, AddonType, AddonsSection, Address, AddressIncludes, AddressListParams, AddressListResponse, AddressResponse, AddressSortBy, AnalyticsData, Announcement, ApplyCreditOptions, AssociatedAddress, BaseCardDetails, BaseProduct, BaseProductVariant, BaseVariant, BasicSubscriptionParams, BooleanLike, BooleanNumbers, BooleanString, BooleanStringNumbers, BulkSubscriptionParams, BundleAppProxy, BundleData, BundleDataBaseProduct, BundleDataCollection, BundleDataSellingPlan, BundleDataSellingPlanGroup, BundleDataVariant, BundleFilterGroup, BundlePriceRule, BundleProduct, BundleProductGlobalStyles, BundleProductLayoutSettings, BundlePurchaseItem, BundlePurchaseItemParams, BundleSelection, BundleSelectionAppProxy, BundleSelectionItem, BundleSelectionItemRequiredCreateProps, BundleSelectionListParams, BundleSelectionsResponse, BundleSelectionsSortBy, BundleSettings, BundleTemplateSettings, BundleTemplateType, BundleTranslations, BundleVariant, BundleVariantOptionSource, BundleVariantRange, BundleVariantSelectionDefault, CDNBaseWidgetSettings, CDNBundleSettings, CDNBundleVariant, CDNBundleVariantOptionSource, CDNPlan, CDNProduct, CDNProductAndSettings, CDNProductKeyObject, CDNProductQuery_2020_12, CDNProductQuery_2022_06, CDNProductRaw, CDNProductResource, CDNProductResponseType, CDNProductType, CDNProductVariant_2022_06, CDNProduct_2022_06, CDNProductsAndSettings, CDNProductsAndSettingsResource, CDNStoreSettings, CDNSubscriptionOption, CDNVariant, CDNVersion, CDNWidgetSettings, CDNWidgetSettingsRaw, CDNWidgetSettingsResource, CRUDRequestOptions, CancelMembershipRequest, CancelSubscriptionRequest, CardDetailsFirstNameLastName, CardDetailsFullName, ChangeMembershipRequest, ChannelSettings, Charge, ChargeIncludes, ChargeListParams, ChargeListResponse, ChargeResponse, ChargeSortBy, ChargeStatus, Collection, CollectionBinding, CollectionListParams, CollectionTypes, CollectionsResponse, CollectionsSortBy, ColorString, CreateAddressRequest, CreateBundleSelectionRequest, CreateMetafieldRequest, CreateOnetimeRequest, CreatePaymentMethodRequest, CreateRecipientAddress, CreateSubscriptionRequest, CreateSubscriptionsParams, CreateSubscriptionsRequest, CreditAccount, CreditAccountIncludes, CreditAccountListParams, CreditAccountType, CreditAccountsResponse, CreditAccountsSortBy, CreditSummaryIncludes, CrossSellsSection, CrossSellsSettings, CurrencyPriceSet, Customer, CustomerCreditSummary, CustomerDeliveryScheduleParams, CustomerDeliveryScheduleResponse, CustomerIncludeGiftPurchase, CustomerIncludes, CustomerNotification, CustomerNotificationOptions, CustomerNotificationTemplate, CustomerNotificationType, CustomerPortalAccessOptions, CustomerPortalAccessResponse, CustomerPortalSettings, CustomerSurveyOfferParams, CustomerSurveyOfferResponse, CustomerSurveyOffersResponse, CustomerSurveyReason, CustomerSurveyReasonsResponse, DefaultProduct, DefaultSelection, DefaultVariant, DelayOption, DeleteSubscriptionsParams, DeleteSubscriptionsRequest, Delivery, DeliveryLineItem, DeliveryOrder, DeliveryPaymentMethod, Discount, DiscountApplicationMethod, DiscountType, DynamicBundleItemAppProxy, DynamicBundlePropertiesAppProxy, DynamicPricingPreviewDetails, EligibleChargeType, EligibleLineItemType, ExternalAttributeSchema, ExternalId, ExternalProductStatus, ExternalTransactionId, FilterInputType, FilterMatchMode, FilterSource, FirstOption, GetAddressOptions, GetChargeOptions, GetCreditSummaryOptions, GetCustomerOptions, GetMembershipProgramOptions, GetPaymentMethodOptions, GetRequestOptions, GetSubscriptionOptions, GiftPurchase, GiftPurchasesParams, GiftPurchasesResponse, HTMLString, Incentives, InitOptions, InternalSession, IntervalUnit, InventoryPolicy, IsoDateString, LineItem, ListParams, LoginResponse, Membership, MembershipBenefit, MembershipIncludes, MembershipListParams, MembershipListResponse, MembershipProgram, MembershipProgramIncludes, MembershipProgramListParams, MembershipProgramListResponse, MembershipProgramResponse, MembershipProgramSortBy, MembershipProgramStatus, MembershipResponse, MembershipStatus, MembershipsSortBy, MergeAddressesRequest, Metafield, MetafieldOptionalCreateProps, MetafieldOwnerResource, MetafieldRequiredCreateProps, Method, Modifier, MultiStepSettings, OfferAttributes, OnePageSettings, Onetime, OnetimeIncludes, OnetimeListParams, OnetimeOptionalCreateProps, OnetimeRequiredCreateProps, OnetimeSubscription, OnetimesResponse, OnetimesSortBy, OnlineStoreOptions, Options, Order, OrderIncludes, OrderListParams, OrderSortBy, OrderStatus, OrderType, OrdersResponse, PasswordlessCodeResponse, PasswordlessOptions, PasswordlessValidateResponse, PaymentDetails, PaymentErrorCallback, PaymentFieldEventCallback, PaymentFormConfig, PaymentFormController, PaymentFormEventHandlers, PaymentMethod, PaymentMethodFormOptions, PaymentMethodIncludes, PaymentMethodListParams, PaymentMethodOptionalCreateProps, PaymentMethodRequiredCreateProps, PaymentMethodSortBy, PaymentMethodStatus, PaymentMethodTokenCallback, PaymentMethodsResponse, PaymentType, Plan, PlanListParams, PlanSortBy, PlanType, PlansResponse, PriceRange, PriceRule, PriceSet, PricingProgressionResetTrigger, ProcessorName, Product, ProductImage, ProductInclude, ProductListResponse, ProductOption, ProductSearchParams_2020_12, ProductSearchParams_2022_06, ProductSearchResponse_2020_12, ProductSearchResponse_2022_06, ProductSearchType, ProductSource, ProductValueOption, ProductVariant_2020_12, ProductVariant_2022_06, Product_2020_12, Product_2022_06, Property, PublicBundleData, PublishStatus, PunchCardProgress, PunchCardProgressData, QuantityRange, RecurringSubscription, ReferralInfo, ReferralUrl, Request, RequestHeaders, RequestOptions, SellingPlan, SellingPlanAllocation, SellingPlanGroup, Session, ShippingCountriesOptions, ShippingCountriesResponse, ShippingCountry, ShippingLine, ShippingProvince, ShopifyStorefrontOptions, ShopifyUpdatePaymentInfoOptions, SkipChargeParams, SkipFutureChargeAddressRequest, SkipFutureChargeAddressResponse, SortBy, SortField, SortKeys, StepSettings, StepSettingsCommon, StepSettingsTypes, StoreSettings, StorefrontEnvironment, StorefrontOptions, StorefrontPurchaseOption, SubType, Subscription, SubscriptionBase, SubscriptionCancelled, SubscriptionIncludes, SubscriptionListAddonsParams, SubscriptionListParams, SubscriptionOption, SubscriptionOptionalCreateProps, SubscriptionPreferences, SubscriptionPricingPreview, SubscriptionPricingPreviewRequest, SubscriptionRequiredCreateProps, SubscriptionSortBy, SubscriptionStatus, Subscription_2021_01, SubscriptionsResponse, TaxLine, Tier, TieredDiscount, TieredDiscountOffer, TieredDiscountOfferLineItem, TieredDiscountOfferTarget, TieredDiscountOfferTier, TieredDiscountOffersRequest, TieredDiscountOffersResponse, TieredDiscountStatus, TieredDiscountsParams, TieredDiscountsResponse, Translations, UpdateAddressParams, UpdateAddressRequest, UpdateBundlePurchaseItem, UpdateBundleSelectionRequest, UpdateCustomerRequest, UpdateMetafieldRequest, UpdateOnetimeRequest, UpdatePaymentMethodRequest, UpdateSubscriptionChargeDateParams, UpdateSubscriptionParams, UpdateSubscriptionRequest, UpdateSubscriptionsParams, UpdateSubscriptionsRequest, Variant, VariantSelector, VariantSelectorStepSetting, WidgetIconColor, WidgetTemplateType, WidgetVisibility, intervalUnit, membershipIncludes };
|