@rechargeapps/storefront-client 1.3.3 → 1.4.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/bundle.js +13 -0
- package/dist/cjs/api/bundle.js.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/api/bundle.js +13 -1
- package/dist/esm/api/bundle.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/index.d.ts +235 -86
- package/dist/umd/recharge-client.min.js +3 -3
- package/package.json +1 -1
package/dist/cjs/api/bundle.js
CHANGED
|
@@ -186,6 +186,18 @@ function deleteBundleSelection(session, id) {
|
|
|
186
186
|
session
|
|
187
187
|
);
|
|
188
188
|
}
|
|
189
|
+
async function updateBundle(session, purchase_item_id, updateRequest) {
|
|
190
|
+
const { subscription } = await request.rechargeApiRequest(
|
|
191
|
+
"put",
|
|
192
|
+
"/bundles",
|
|
193
|
+
{
|
|
194
|
+
id: purchase_item_id,
|
|
195
|
+
data: updateRequest
|
|
196
|
+
},
|
|
197
|
+
session
|
|
198
|
+
);
|
|
199
|
+
return subscription;
|
|
200
|
+
}
|
|
189
201
|
|
|
190
202
|
exports.createBundleSelection = createBundleSelection;
|
|
191
203
|
exports.deleteBundleSelection = deleteBundleSelection;
|
|
@@ -193,6 +205,7 @@ exports.getBundleId = getBundleId;
|
|
|
193
205
|
exports.getBundleSelection = getBundleSelection;
|
|
194
206
|
exports.getDynamicBundleItems = getDynamicBundleItems;
|
|
195
207
|
exports.listBundleSelections = listBundleSelections;
|
|
208
|
+
exports.updateBundle = updateBundle;
|
|
196
209
|
exports.updateBundleSelection = updateBundleSelection;
|
|
197
210
|
exports.validateBundle = validateBundle;
|
|
198
211
|
exports.validateDynamicBundle = validateDynamicBundle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.js","sources":["../../../src/api/bundle.ts"],"sourcesContent":["import { nanoid } from 'nanoid';\nimport {\n BundleAppProxy,\n DynamicBundleItemAppProxy,\n BundleSelection,\n BundleSelectionListParams,\n BundleSelectionsResponse,\n CreateBundleSelectionRequest,\n Session,\n UpdateBundleSelectionRequest,\n} from '../types';\nimport { rechargeApiRequest, shopifyAppProxyRequest } from '../utils/request';\nimport { getOptions } from '../utils/options';\nimport { getCDNBundleSettings } from './cdn';\nimport { toLineItemProperty } from '../utils/bundle';\n\nconst STORE_FRONT_MANAGER_URL = '/bundling-storefront-manager';\n\nfunction getTimestampSecondsFromClient(): number {\n /**\n * Get the current unix epoch in seconds from the client-side.\n */\n return Math.ceil(Date.now() / 1000);\n}\n\nasync function getTimestampSecondsFromServer(): Promise<number> {\n /**\n * Get the unix epoch from the server instead of using it directly from the\n * client. This must reduce even more the number of invalid Bundles.\n */\n try {\n const { timestamp } = await shopifyAppProxyRequest<{ timestamp: number }>('get', `${STORE_FRONT_MANAGER_URL}/t`, {\n headers: { 'X-Recharge-App': 'storefront-client' },\n });\n return timestamp;\n } catch (ex) {\n console.error(`Fetch failed: ${ex}. Using client-side date.`);\n return getTimestampSecondsFromClient();\n }\n}\n\nexport async function getBundleId(bundle: BundleAppProxy): Promise<string> {\n const opts = getOptions();\n const isValid = await validateBundle(bundle);\n if (isValid !== true) {\n throw new Error(isValid);\n }\n const timestampSeconds = await getTimestampSecondsFromServer();\n const bundleData = toLineItemProperty({\n variantId: bundle.externalVariantId,\n version: timestampSeconds,\n items: bundle.selections.map(item => {\n return {\n collectionId: item.collectionId,\n productId: item.externalProductId,\n variantId: item.externalVariantId,\n quantity: item.quantity,\n sku: '',\n };\n }),\n });\n\n try {\n const payload = await shopifyAppProxyRequest<{ id: string; code: number; message: string }>(\n 'post',\n `${STORE_FRONT_MANAGER_URL}/api/v1/bundles`,\n {\n data: {\n bundle: bundleData,\n },\n headers: {\n Origin: `https://${opts.storeIdentifier}`,\n },\n }\n );\n\n if (!payload.id || payload.code !== 200) {\n throw new Error(`1: failed generating rb_id: ${JSON.stringify(payload)}`);\n }\n\n return payload.id;\n } catch (e) {\n // Handle NetworkError exceptions\n throw new Error(`2: failed generating rb_id ${e}`);\n }\n}\n\nexport function getDynamicBundleItems(bundle: BundleAppProxy, shopifyProductHandle: string) {\n const isValid = validateDynamicBundle(bundle);\n if (isValid !== true) {\n throw new Error(`Dynamic Bundle is invalid. ${isValid}`);\n }\n // generate unique id for dynamic bundle\n const bundleId = `${nanoid(9)}:${bundle.externalProductId}`;\n return bundle.selections.map(item => {\n const itemData: DynamicBundleItemAppProxy = {\n id: item.externalVariantId,\n quantity: item.quantity,\n properties: {\n _rc_bundle: bundleId,\n _rc_bundle_variant: bundle.externalVariantId,\n _rc_bundle_parent: shopifyProductHandle,\n _rc_bundle_collection_id: item.collectionId,\n },\n };\n\n if (item.sellingPlan) {\n // this is used by SCI stores\n itemData.selling_plan = item.sellingPlan;\n } else if (item.shippingIntervalFrequency) {\n // this is used by RCS stores\n itemData.properties.shipping_interval_frequency = item.shippingIntervalFrequency;\n itemData.properties.shipping_interval_unit_type = item.shippingIntervalUnitType;\n itemData.id = `${item.discountedVariantId}`;\n }\n\n return itemData;\n });\n}\n\nexport async function validateBundle(bundle: BundleAppProxy): Promise<true | string> {\n try {\n // once we implement this function, we can make it raise an exception\n // we could also have a local store relative to this function so we don't have to pass bundleProduct\n if (!bundle) {\n return 'Bundle is not defined';\n }\n const bundleSettings = await getCDNBundleSettings(bundle.externalProductId);\n if (!bundleSettings) {\n return 'Bundle settings do not exist for the given product';\n }\n return true;\n } catch (e) {\n return `Error fetching bundle settings: ${e}`;\n }\n}\n\nconst intervalUnitGroups = {\n day: ['day', 'days', 'Days'],\n days: ['day', 'days', 'Days'],\n Days: ['day', 'days', 'Days'],\n week: ['week', 'weeks', 'Weeks'],\n weeks: ['week', 'weeks', 'Weeks'],\n Weeks: ['week', 'weeks', 'Weeks'],\n month: ['month', 'months', 'Months'],\n months: ['month', 'months', 'Months'],\n Months: ['month', 'months', 'Months'],\n};\n\n/**\n * Validates a dynamic bundle\n *\n * @param bundle Dynamic Bundle being validated\n * @returns true or error message\n */\nexport function validateDynamicBundle(bundle: BundleAppProxy): true | string {\n if (!bundle) {\n return 'No bundle defined.';\n }\n if (bundle.selections.length === 0) {\n return 'No selections defined.';\n }\n // validation for RCS onetimes\n const { shippingIntervalFrequency, shippingIntervalUnitType } =\n bundle.selections.find(selection => selection.shippingIntervalFrequency || selection.shippingIntervalUnitType) ||\n {};\n if (shippingIntervalFrequency || shippingIntervalUnitType) {\n // if we have shipping intervals then we should have both defined\n if (!shippingIntervalFrequency || !shippingIntervalUnitType) {\n return 'Shipping intervals do not match on selections.';\n } else {\n // if we have shipping intervals then any that are defined should match\n const shippingIntervalUnitGroup = intervalUnitGroups[shippingIntervalUnitType];\n for (let x = 0; x < bundle.selections.length; x++) {\n const { shippingIntervalFrequency: frequency, shippingIntervalUnitType: unitType } = bundle.selections[x];\n if (\n (frequency && frequency !== shippingIntervalFrequency) ||\n (unitType && !shippingIntervalUnitGroup.includes(unitType))\n ) {\n return 'Shipping intervals do not match on selections.';\n }\n }\n }\n }\n return true;\n}\n\nexport async function getBundleSelection(session: Session, id: string | number): Promise<BundleSelection> {\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'get',\n `/bundle_selections`,\n {\n id,\n },\n session\n );\n return bundle_selection;\n}\n\nexport function listBundleSelections(\n session: Session,\n query?: BundleSelectionListParams\n): Promise<BundleSelectionsResponse> {\n return rechargeApiRequest<BundleSelectionsResponse>('get', `/bundle_selections`, { query }, session);\n}\n\nexport async function createBundleSelection(\n session: Session,\n createRequest: CreateBundleSelectionRequest\n): Promise<BundleSelection> {\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'post',\n `/bundle_selections`,\n {\n data: createRequest,\n },\n session\n );\n return bundle_selection;\n}\n\nexport async function updateBundleSelection(\n session: Session,\n id: string | number,\n updateRequest: UpdateBundleSelectionRequest\n): Promise<BundleSelection> {\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'put',\n `/bundle_selections`,\n {\n id,\n data: updateRequest,\n },\n session\n );\n return bundle_selection;\n}\n\nexport function deleteBundleSelection(session: Session, id: string | number): Promise<void> {\n return rechargeApiRequest<void>(\n 'delete',\n `/bundle_selections`,\n {\n id,\n },\n session\n );\n}\n"],"names":["shopifyAppProxyRequest","bundle","getOptions","toLineItemProperty","nanoid","getCDNBundleSettings","rechargeApiRequest"],"mappings":";;;;;;;;;;AAKA,MAAM,uBAAuB,GAAG,8BAA8B,CAAC;AAC/D,SAAS,6BAA6B,GAAG;AACzC,EAAE,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC;AACrC,CAAC;AACD,eAAe,6BAA6B,GAAG;AAC/C,EAAE,IAAI;AACN,IAAI,MAAM,EAAE,SAAS,EAAE,GAAG,MAAMA,8BAAsB,CAAC,KAAK,EAAE,CAAC,EAAE,uBAAuB,CAAC,EAAE,CAAC,EAAE;AAC9F,MAAM,OAAO,EAAE,EAAE,gBAAgB,EAAE,mBAAmB,EAAE;AACxD,KAAK,CAAC,CAAC;AACP,IAAI,OAAO,SAAS,CAAC;AACrB,GAAG,CAAC,OAAO,EAAE,EAAE;AACf,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,cAAc,EAAE,EAAE,CAAC,yBAAyB,CAAC,CAAC,CAAC;AAClE,IAAI,OAAO,6BAA6B,EAAE,CAAC;AAC3C,GAAG;AACH,CAAC;AACM,eAAe,WAAW,CAACC,QAAM,EAAE;AAC1C,EAAE,MAAM,IAAI,GAAGC,kBAAU,EAAE,CAAC;AAC5B,EAAE,MAAM,OAAO,GAAG,MAAM,cAAc,CAACD,QAAM,CAAC,CAAC;AAC/C,EAAE,IAAI,OAAO,KAAK,IAAI,EAAE;AACxB,IAAI,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;AAC7B,GAAG;AACH,EAAE,MAAM,gBAAgB,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J,MAAM,EAAE;AACR,KAAK;AACL,IAAI,OAAO;AACX,GAAG,CAAC;AACJ,EAAE,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AACM,SAAS,oBAAoB,CAAC,OAAO,EAAE,KAAK,EAAE;AACrD,EAAE,OAAOA,0BAAkB,CAAC,KAAK,EAAE,CAAC,kBAAkB,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,CAAC,CAAC;AAC7E,CAAC;AACM,eAAe,qBAAqB,CAAC,OAAO,EAAE,aAAa,EAAE;AACpE,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAMA,0BAAkB;AACvD,IAAI,MAAM;AACV,IAAI,CAAC,kBAAkB,CAAC;AACxB,IAAI;AACJ,MAAM,IAAI,EAAE,aAAa;AACzB,KAAK;AACL,IAAI,OAAO;AACX,GAAG,CAAC;AACJ,EAAE,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AACM,eAAe,qBAAqB,CAAC,OAAO,EAAE,EAAE,EAAE,aAAa,EAAE;AACxE,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAMA,0BAAkB;AACvD,IAAI,KAAK;AACT,IAAI,CAAC,kBAAkB,CAAC;AACxB,IAAI;AACJ,MAAM,EAAE;AACR,MAAM,IAAI,EAAE,aAAa;AACzB,KAAK;AACL,IAAI,OAAO;AACX,GAAG,CAAC;AACJ,EAAE,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AACM,SAAS,qBAAqB,CAAC,OAAO,EAAE,EAAE,EAAE;AACnD,EAAE,OAAOA,0BAAkB;AAC3B,IAAI,QAAQ;AACZ,IAAI,CAAC,kBAAkB,CAAC;AACxB,IAAI;AACJ,MAAM,EAAE;AACR,KAAK;AACL,IAAI,OAAO;AACX,GAAG,CAAC;AACJ;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"bundle.js","sources":["../../../src/api/bundle.ts"],"sourcesContent":["import { nanoid } from 'nanoid';\nimport {\n BundleAppProxy,\n DynamicBundleItemAppProxy,\n BundleSelection,\n BundleSelectionListParams,\n BundleSelectionsResponse,\n CreateBundleSelectionRequest,\n Session,\n UpdateBundleSelectionRequest,\n UpdateBundlePurchaseItem,\n BundlePurchaseItem,\n} from '../types';\nimport { rechargeApiRequest, shopifyAppProxyRequest } from '../utils/request';\nimport { getOptions } from '../utils/options';\nimport { getCDNBundleSettings } from './cdn';\nimport { toLineItemProperty } from '../utils/bundle';\n\nconst STORE_FRONT_MANAGER_URL = '/bundling-storefront-manager';\n\nfunction getTimestampSecondsFromClient(): number {\n /**\n * Get the current unix epoch in seconds from the client-side.\n */\n return Math.ceil(Date.now() / 1000);\n}\n\nasync function getTimestampSecondsFromServer(): Promise<number> {\n /**\n * Get the unix epoch from the server instead of using it directly from the\n * client. This must reduce even more the number of invalid Bundles.\n */\n try {\n const { timestamp } = await shopifyAppProxyRequest<{ timestamp: number }>('get', `${STORE_FRONT_MANAGER_URL}/t`, {\n headers: { 'X-Recharge-App': 'storefront-client' },\n });\n return timestamp;\n } catch (ex) {\n console.error(`Fetch failed: ${ex}. Using client-side date.`);\n return getTimestampSecondsFromClient();\n }\n}\n\nexport async function getBundleId(bundle: BundleAppProxy): Promise<string> {\n const opts = getOptions();\n const isValid = await validateBundle(bundle);\n if (isValid !== true) {\n throw new Error(isValid);\n }\n const timestampSeconds = await getTimestampSecondsFromServer();\n const bundleData = toLineItemProperty({\n variantId: bundle.externalVariantId,\n version: timestampSeconds,\n items: bundle.selections.map(item => {\n return {\n collectionId: item.collectionId,\n productId: item.externalProductId,\n variantId: item.externalVariantId,\n quantity: item.quantity,\n sku: '',\n };\n }),\n });\n\n try {\n const payload = await shopifyAppProxyRequest<{ id: string; code: number; message: string }>(\n 'post',\n `${STORE_FRONT_MANAGER_URL}/api/v1/bundles`,\n {\n data: {\n bundle: bundleData,\n },\n headers: {\n Origin: `https://${opts.storeIdentifier}`,\n },\n }\n );\n\n if (!payload.id || payload.code !== 200) {\n throw new Error(`1: failed generating rb_id: ${JSON.stringify(payload)}`);\n }\n\n return payload.id;\n } catch (e) {\n // Handle NetworkError exceptions\n throw new Error(`2: failed generating rb_id ${e}`);\n }\n}\n\nexport function getDynamicBundleItems(bundle: BundleAppProxy, shopifyProductHandle: string) {\n const isValid = validateDynamicBundle(bundle);\n if (isValid !== true) {\n throw new Error(`Dynamic Bundle is invalid. ${isValid}`);\n }\n // generate unique id for dynamic bundle\n const bundleId = `${nanoid(9)}:${bundle.externalProductId}`;\n return bundle.selections.map(item => {\n const itemData: DynamicBundleItemAppProxy = {\n id: item.externalVariantId,\n quantity: item.quantity,\n properties: {\n _rc_bundle: bundleId,\n _rc_bundle_variant: bundle.externalVariantId,\n _rc_bundle_parent: shopifyProductHandle,\n _rc_bundle_collection_id: item.collectionId,\n },\n };\n\n if (item.sellingPlan) {\n // this is used by SCI stores\n itemData.selling_plan = item.sellingPlan;\n } else if (item.shippingIntervalFrequency) {\n // this is used by RCS stores\n itemData.properties.shipping_interval_frequency = item.shippingIntervalFrequency;\n itemData.properties.shipping_interval_unit_type = item.shippingIntervalUnitType;\n itemData.id = `${item.discountedVariantId}`;\n }\n\n return itemData;\n });\n}\n\nexport async function validateBundle(bundle: BundleAppProxy): Promise<true | string> {\n try {\n // once we implement this function, we can make it raise an exception\n // we could also have a local store relative to this function so we don't have to pass bundleProduct\n if (!bundle) {\n return 'Bundle is not defined';\n }\n const bundleSettings = await getCDNBundleSettings(bundle.externalProductId);\n if (!bundleSettings) {\n return 'Bundle settings do not exist for the given product';\n }\n return true;\n } catch (e) {\n return `Error fetching bundle settings: ${e}`;\n }\n}\n\nconst intervalUnitGroups = {\n day: ['day', 'days', 'Days'],\n days: ['day', 'days', 'Days'],\n Days: ['day', 'days', 'Days'],\n week: ['week', 'weeks', 'Weeks'],\n weeks: ['week', 'weeks', 'Weeks'],\n Weeks: ['week', 'weeks', 'Weeks'],\n month: ['month', 'months', 'Months'],\n months: ['month', 'months', 'Months'],\n Months: ['month', 'months', 'Months'],\n};\n\n/**\n * Validates a dynamic bundle\n *\n * @param bundle Dynamic Bundle being validated\n * @returns true or error message\n */\nexport function validateDynamicBundle(bundle: BundleAppProxy): true | string {\n if (!bundle) {\n return 'No bundle defined.';\n }\n if (bundle.selections.length === 0) {\n return 'No selections defined.';\n }\n // validation for RCS onetimes\n const { shippingIntervalFrequency, shippingIntervalUnitType } =\n bundle.selections.find(selection => selection.shippingIntervalFrequency || selection.shippingIntervalUnitType) ||\n {};\n if (shippingIntervalFrequency || shippingIntervalUnitType) {\n // if we have shipping intervals then we should have both defined\n if (!shippingIntervalFrequency || !shippingIntervalUnitType) {\n return 'Shipping intervals do not match on selections.';\n } else {\n // if we have shipping intervals then any that are defined should match\n const shippingIntervalUnitGroup = intervalUnitGroups[shippingIntervalUnitType];\n for (let x = 0; x < bundle.selections.length; x++) {\n const { shippingIntervalFrequency: frequency, shippingIntervalUnitType: unitType } = bundle.selections[x];\n if (\n (frequency && frequency !== shippingIntervalFrequency) ||\n (unitType && !shippingIntervalUnitGroup.includes(unitType))\n ) {\n return 'Shipping intervals do not match on selections.';\n }\n }\n }\n }\n return true;\n}\n\nexport async function getBundleSelection(session: Session, id: string | number): Promise<BundleSelection> {\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'get',\n `/bundle_selections`,\n {\n id,\n },\n session\n );\n return bundle_selection;\n}\n\nexport function listBundleSelections(\n session: Session,\n query?: BundleSelectionListParams\n): Promise<BundleSelectionsResponse> {\n return rechargeApiRequest<BundleSelectionsResponse>('get', `/bundle_selections`, { query }, session);\n}\n\nexport async function createBundleSelection(\n session: Session,\n createRequest: CreateBundleSelectionRequest\n): Promise<BundleSelection> {\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'post',\n `/bundle_selections`,\n {\n data: createRequest,\n },\n session\n );\n return bundle_selection;\n}\n\nexport async function updateBundleSelection(\n session: Session,\n id: string | number,\n updateRequest: UpdateBundleSelectionRequest\n): Promise<BundleSelection> {\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'put',\n `/bundle_selections`,\n {\n id,\n data: updateRequest,\n },\n session\n );\n return bundle_selection;\n}\n\nexport function deleteBundleSelection(session: Session, id: string | number): Promise<void> {\n return rechargeApiRequest<void>(\n 'delete',\n `/bundle_selections`,\n {\n id,\n },\n session\n );\n}\n\nexport async function updateBundle(\n session: Session,\n purchase_item_id: string | number,\n updateRequest: UpdateBundlePurchaseItem\n): Promise<BundlePurchaseItem> {\n const { subscription } = await rechargeApiRequest<{ subscription: BundlePurchaseItem }>(\n 'put',\n '/bundles',\n {\n id: purchase_item_id,\n data: updateRequest,\n },\n session\n );\n\n return subscription;\n}\n"],"names":["shopifyAppProxyRequest","bundle","getOptions","toLineItemProperty","nanoid","getCDNBundleSettings","rechargeApiRequest"],"mappings":";;;;;;;;;;AAKA,MAAM,uBAAuB,GAAG,8BAA8B,CAAC;AAC/D,SAAS,6BAA6B,GAAG;AACzC,EAAE,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC;AACrC,CAAC;AACD,eAAe,6BAA6B,GAAG;AAC/C,EAAE,IAAI;AACN,IAAI,MAAM,EAAE,SAAS,EAAE,GAAG,MAAMA,8BAAsB,CAAC,KAAK,EAAE,CAAC,EAAE,uBAAuB,CAAC,EAAE,CAAC,EAAE;AAC9F,MAAM,OAAO,EAAE,EAAE,gBAAgB,EAAE,mBAAmB,EAAE;AACxD,KAAK,CAAC,CAAC;AACP,IAAI,OAAO,SAAS,CAAC;AACrB,GAAG,CAAC,OAAO,EAAE,EAAE;AACf,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,cAAc,EAAE,EAAE,CAAC,yBAAyB,CAAC,CAAC,CAAC;AAClE,IAAI,OAAO,6BAA6B,EAAE,CAAC;AAC3C,GAAG;AACH,CAAC;AACM,eAAe,WAAW,CAACC,QAAM,EAAE;AAC1C,EAAE,MAAM,IAAI,GAAGC,kB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kBAAkB,CAAC;AACxB,IAAI;AACJ,MAAM,EAAE;AACR,KAAK;AACL,IAAI,OAAO;AACX,GAAG,CAAC;AACJ,CAAC;AACM,eAAe,YAAY,CAAC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE;AAC7E,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,MAAMA,0BAAkB;AACnD,IAAI,KAAK;AACT,IAAI,UAAU;AACd,IAAI;AACJ,MAAM,EAAE,EAAE,gBAAgB;AAC1B,MAAM,IAAI,EAAE,aAAa;AACzB,KAAK;AACL,IAAI,OAAO;AACX,GAAG,CAAC;AACJ,EAAE,OAAO,YAAY,CAAC;AACtB;;;;;;;;;;;;;"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -57,6 +57,7 @@ exports.getBundleId = bundle.getBundleId;
|
|
|
57
57
|
exports.getBundleSelection = bundle.getBundleSelection;
|
|
58
58
|
exports.getDynamicBundleItems = bundle.getDynamicBundleItems;
|
|
59
59
|
exports.listBundleSelections = bundle.listBundleSelections;
|
|
60
|
+
exports.updateBundle = bundle.updateBundle;
|
|
60
61
|
exports.updateBundleSelection = bundle.updateBundleSelection;
|
|
61
62
|
exports.validateBundle = bundle.validateBundle;
|
|
62
63
|
exports.validateDynamicBundle = bundle.validateDynamicBundle;
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/esm/api/bundle.js
CHANGED
|
@@ -182,6 +182,18 @@ function deleteBundleSelection(session, id) {
|
|
|
182
182
|
session
|
|
183
183
|
);
|
|
184
184
|
}
|
|
185
|
+
async function updateBundle(session, purchase_item_id, updateRequest) {
|
|
186
|
+
const { subscription } = await rechargeApiRequest(
|
|
187
|
+
"put",
|
|
188
|
+
"/bundles",
|
|
189
|
+
{
|
|
190
|
+
id: purchase_item_id,
|
|
191
|
+
data: updateRequest
|
|
192
|
+
},
|
|
193
|
+
session
|
|
194
|
+
);
|
|
195
|
+
return subscription;
|
|
196
|
+
}
|
|
185
197
|
|
|
186
|
-
export { createBundleSelection, deleteBundleSelection, getBundleId, getBundleSelection, getDynamicBundleItems, listBundleSelections, updateBundleSelection, validateBundle, validateDynamicBundle };
|
|
198
|
+
export { createBundleSelection, deleteBundleSelection, getBundleId, getBundleSelection, getDynamicBundleItems, listBundleSelections, updateBundle, updateBundleSelection, validateBundle, validateDynamicBundle };
|
|
187
199
|
//# sourceMappingURL=bundle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle.js","sources":["../../../src/api/bundle.ts"],"sourcesContent":["import { nanoid } from 'nanoid';\nimport {\n BundleAppProxy,\n DynamicBundleItemAppProxy,\n BundleSelection,\n BundleSelectionListParams,\n BundleSelectionsResponse,\n CreateBundleSelectionRequest,\n Session,\n UpdateBundleSelectionRequest,\n} from '../types';\nimport { rechargeApiRequest, shopifyAppProxyRequest } from '../utils/request';\nimport { getOptions } from '../utils/options';\nimport { getCDNBundleSettings } from './cdn';\nimport { toLineItemProperty } from '../utils/bundle';\n\nconst STORE_FRONT_MANAGER_URL = '/bundling-storefront-manager';\n\nfunction getTimestampSecondsFromClient(): number {\n /**\n * Get the current unix epoch in seconds from the client-side.\n */\n return Math.ceil(Date.now() / 1000);\n}\n\nasync function getTimestampSecondsFromServer(): Promise<number> {\n /**\n * Get the unix epoch from the server instead of using it directly from the\n * client. This must reduce even more the number of invalid Bundles.\n */\n try {\n const { timestamp } = await shopifyAppProxyRequest<{ timestamp: number }>('get', `${STORE_FRONT_MANAGER_URL}/t`, {\n headers: { 'X-Recharge-App': 'storefront-client' },\n });\n return timestamp;\n } catch (ex) {\n console.error(`Fetch failed: ${ex}. Using client-side date.`);\n return getTimestampSecondsFromClient();\n }\n}\n\nexport async function getBundleId(bundle: BundleAppProxy): Promise<string> {\n const opts = getOptions();\n const isValid = await validateBundle(bundle);\n if (isValid !== true) {\n throw new Error(isValid);\n }\n const timestampSeconds = await getTimestampSecondsFromServer();\n const bundleData = toLineItemProperty({\n variantId: bundle.externalVariantId,\n version: timestampSeconds,\n items: bundle.selections.map(item => {\n return {\n collectionId: item.collectionId,\n productId: item.externalProductId,\n variantId: item.externalVariantId,\n quantity: item.quantity,\n sku: '',\n };\n }),\n });\n\n try {\n const payload = await shopifyAppProxyRequest<{ id: string; code: number; message: string }>(\n 'post',\n `${STORE_FRONT_MANAGER_URL}/api/v1/bundles`,\n {\n data: {\n bundle: bundleData,\n },\n headers: {\n Origin: `https://${opts.storeIdentifier}`,\n },\n }\n );\n\n if (!payload.id || payload.code !== 200) {\n throw new Error(`1: failed generating rb_id: ${JSON.stringify(payload)}`);\n }\n\n return payload.id;\n } catch (e) {\n // Handle NetworkError exceptions\n throw new Error(`2: failed generating rb_id ${e}`);\n }\n}\n\nexport function getDynamicBundleItems(bundle: BundleAppProxy, shopifyProductHandle: string) {\n const isValid = validateDynamicBundle(bundle);\n if (isValid !== true) {\n throw new Error(`Dynamic Bundle is invalid. ${isValid}`);\n }\n // generate unique id for dynamic bundle\n const bundleId = `${nanoid(9)}:${bundle.externalProductId}`;\n return bundle.selections.map(item => {\n const itemData: DynamicBundleItemAppProxy = {\n id: item.externalVariantId,\n quantity: item.quantity,\n properties: {\n _rc_bundle: bundleId,\n _rc_bundle_variant: bundle.externalVariantId,\n _rc_bundle_parent: shopifyProductHandle,\n _rc_bundle_collection_id: item.collectionId,\n },\n };\n\n if (item.sellingPlan) {\n // this is used by SCI stores\n itemData.selling_plan = item.sellingPlan;\n } else if (item.shippingIntervalFrequency) {\n // this is used by RCS stores\n itemData.properties.shipping_interval_frequency = item.shippingIntervalFrequency;\n itemData.properties.shipping_interval_unit_type = item.shippingIntervalUnitType;\n itemData.id = `${item.discountedVariantId}`;\n }\n\n return itemData;\n });\n}\n\nexport async function validateBundle(bundle: BundleAppProxy): Promise<true | string> {\n try {\n // once we implement this function, we can make it raise an exception\n // we could also have a local store relative to this function so we don't have to pass bundleProduct\n if (!bundle) {\n return 'Bundle is not defined';\n }\n const bundleSettings = await getCDNBundleSettings(bundle.externalProductId);\n if (!bundleSettings) {\n return 'Bundle settings do not exist for the given product';\n }\n return true;\n } catch (e) {\n return `Error fetching bundle settings: ${e}`;\n }\n}\n\nconst intervalUnitGroups = {\n day: ['day', 'days', 'Days'],\n days: ['day', 'days', 'Days'],\n Days: ['day', 'days', 'Days'],\n week: ['week', 'weeks', 'Weeks'],\n weeks: ['week', 'weeks', 'Weeks'],\n Weeks: ['week', 'weeks', 'Weeks'],\n month: ['month', 'months', 'Months'],\n months: ['month', 'months', 'Months'],\n Months: ['month', 'months', 'Months'],\n};\n\n/**\n * Validates a dynamic bundle\n *\n * @param bundle Dynamic Bundle being validated\n * @returns true or error message\n */\nexport function validateDynamicBundle(bundle: BundleAppProxy): true | string {\n if (!bundle) {\n return 'No bundle defined.';\n }\n if (bundle.selections.length === 0) {\n return 'No selections defined.';\n }\n // validation for RCS onetimes\n const { shippingIntervalFrequency, shippingIntervalUnitType } =\n bundle.selections.find(selection => selection.shippingIntervalFrequency || selection.shippingIntervalUnitType) ||\n {};\n if (shippingIntervalFrequency || shippingIntervalUnitType) {\n // if we have shipping intervals then we should have both defined\n if (!shippingIntervalFrequency || !shippingIntervalUnitType) {\n return 'Shipping intervals do not match on selections.';\n } else {\n // if we have shipping intervals then any that are defined should match\n const shippingIntervalUnitGroup = intervalUnitGroups[shippingIntervalUnitType];\n for (let x = 0; x < bundle.selections.length; x++) {\n const { shippingIntervalFrequency: frequency, shippingIntervalUnitType: unitType } = bundle.selections[x];\n if (\n (frequency && frequency !== shippingIntervalFrequency) ||\n (unitType && !shippingIntervalUnitGroup.includes(unitType))\n ) {\n return 'Shipping intervals do not match on selections.';\n }\n }\n }\n }\n return true;\n}\n\nexport async function getBundleSelection(session: Session, id: string | number): Promise<BundleSelection> {\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'get',\n `/bundle_selections`,\n {\n id,\n },\n session\n );\n return bundle_selection;\n}\n\nexport function listBundleSelections(\n session: Session,\n query?: BundleSelectionListParams\n): Promise<BundleSelectionsResponse> {\n return rechargeApiRequest<BundleSelectionsResponse>('get', `/bundle_selections`, { query }, session);\n}\n\nexport async function createBundleSelection(\n session: Session,\n createRequest: CreateBundleSelectionRequest\n): Promise<BundleSelection> {\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'post',\n `/bundle_selections`,\n {\n data: createRequest,\n },\n session\n );\n return bundle_selection;\n}\n\nexport async function updateBundleSelection(\n session: Session,\n id: string | number,\n updateRequest: UpdateBundleSelectionRequest\n): Promise<BundleSelection> {\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'put',\n `/bundle_selections`,\n {\n id,\n data: updateRequest,\n },\n session\n );\n return bundle_selection;\n}\n\nexport function deleteBundleSelection(session: Session, id: string | number): Promise<void> {\n return rechargeApiRequest<void>(\n 'delete',\n `/bundle_selections`,\n {\n id,\n },\n session\n );\n}\n"],"names":[],"mappings":";;;;;;AAKA,MAAM,uBAAuB,GAAG,8BAA8B,CAAC;AAC/D,SAAS,6BAA6B,GAAG;AACzC,EAAE,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC;AACrC,CAAC;AACD,eAAe,6BAA6B,GAAG;AAC/C,EAAE,IAAI;AACN,IAAI,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,sBAAsB,CAAC,KAAK,EAAE,CAAC,EAAE,uBAAuB,CAAC,EAAE,CAAC,EAAE;AAC9F,MAAM,OAAO,EAAE,EAAE,gBAAgB,EAAE,mBAAmB,EAAE;AACxD,KAA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I,CAAC,kBAAkB,CAAC;AACxB,IAAI;AACJ,MAAM,EAAE;AACR,MAAM,IAAI,EAAE,aAAa;AACzB,KAAK;AACL,IAAI,OAAO;AACX,GAAG,CAAC;AACJ,EAAE,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AACM,SAAS,qBAAqB,CAAC,OAAO,EAAE,EAAE,EAAE;AACnD,EAAE,OAAO,kBAAkB;AAC3B,IAAI,QAAQ;AACZ,IAAI,CAAC,kBAAkB,CAAC;AACxB,IAAI;AACJ,MAAM,EAAE;AACR,KAAK;AACL,IAAI,OAAO;AACX,GAAG,CAAC;AACJ;;;;"}
|
|
1
|
+
{"version":3,"file":"bundle.js","sources":["../../../src/api/bundle.ts"],"sourcesContent":["import { nanoid } from 'nanoid';\nimport {\n BundleAppProxy,\n DynamicBundleItemAppProxy,\n BundleSelection,\n BundleSelectionListParams,\n BundleSelectionsResponse,\n CreateBundleSelectionRequest,\n Session,\n UpdateBundleSelectionRequest,\n UpdateBundlePurchaseItem,\n BundlePurchaseItem,\n} from '../types';\nimport { rechargeApiRequest, shopifyAppProxyRequest } from '../utils/request';\nimport { getOptions } from '../utils/options';\nimport { getCDNBundleSettings } from './cdn';\nimport { toLineItemProperty } from '../utils/bundle';\n\nconst STORE_FRONT_MANAGER_URL = '/bundling-storefront-manager';\n\nfunction getTimestampSecondsFromClient(): number {\n /**\n * Get the current unix epoch in seconds from the client-side.\n */\n return Math.ceil(Date.now() / 1000);\n}\n\nasync function getTimestampSecondsFromServer(): Promise<number> {\n /**\n * Get the unix epoch from the server instead of using it directly from the\n * client. This must reduce even more the number of invalid Bundles.\n */\n try {\n const { timestamp } = await shopifyAppProxyRequest<{ timestamp: number }>('get', `${STORE_FRONT_MANAGER_URL}/t`, {\n headers: { 'X-Recharge-App': 'storefront-client' },\n });\n return timestamp;\n } catch (ex) {\n console.error(`Fetch failed: ${ex}. Using client-side date.`);\n return getTimestampSecondsFromClient();\n }\n}\n\nexport async function getBundleId(bundle: BundleAppProxy): Promise<string> {\n const opts = getOptions();\n const isValid = await validateBundle(bundle);\n if (isValid !== true) {\n throw new Error(isValid);\n }\n const timestampSeconds = await getTimestampSecondsFromServer();\n const bundleData = toLineItemProperty({\n variantId: bundle.externalVariantId,\n version: timestampSeconds,\n items: bundle.selections.map(item => {\n return {\n collectionId: item.collectionId,\n productId: item.externalProductId,\n variantId: item.externalVariantId,\n quantity: item.quantity,\n sku: '',\n };\n }),\n });\n\n try {\n const payload = await shopifyAppProxyRequest<{ id: string; code: number; message: string }>(\n 'post',\n `${STORE_FRONT_MANAGER_URL}/api/v1/bundles`,\n {\n data: {\n bundle: bundleData,\n },\n headers: {\n Origin: `https://${opts.storeIdentifier}`,\n },\n }\n );\n\n if (!payload.id || payload.code !== 200) {\n throw new Error(`1: failed generating rb_id: ${JSON.stringify(payload)}`);\n }\n\n return payload.id;\n } catch (e) {\n // Handle NetworkError exceptions\n throw new Error(`2: failed generating rb_id ${e}`);\n }\n}\n\nexport function getDynamicBundleItems(bundle: BundleAppProxy, shopifyProductHandle: string) {\n const isValid = validateDynamicBundle(bundle);\n if (isValid !== true) {\n throw new Error(`Dynamic Bundle is invalid. ${isValid}`);\n }\n // generate unique id for dynamic bundle\n const bundleId = `${nanoid(9)}:${bundle.externalProductId}`;\n return bundle.selections.map(item => {\n const itemData: DynamicBundleItemAppProxy = {\n id: item.externalVariantId,\n quantity: item.quantity,\n properties: {\n _rc_bundle: bundleId,\n _rc_bundle_variant: bundle.externalVariantId,\n _rc_bundle_parent: shopifyProductHandle,\n _rc_bundle_collection_id: item.collectionId,\n },\n };\n\n if (item.sellingPlan) {\n // this is used by SCI stores\n itemData.selling_plan = item.sellingPlan;\n } else if (item.shippingIntervalFrequency) {\n // this is used by RCS stores\n itemData.properties.shipping_interval_frequency = item.shippingIntervalFrequency;\n itemData.properties.shipping_interval_unit_type = item.shippingIntervalUnitType;\n itemData.id = `${item.discountedVariantId}`;\n }\n\n return itemData;\n });\n}\n\nexport async function validateBundle(bundle: BundleAppProxy): Promise<true | string> {\n try {\n // once we implement this function, we can make it raise an exception\n // we could also have a local store relative to this function so we don't have to pass bundleProduct\n if (!bundle) {\n return 'Bundle is not defined';\n }\n const bundleSettings = await getCDNBundleSettings(bundle.externalProductId);\n if (!bundleSettings) {\n return 'Bundle settings do not exist for the given product';\n }\n return true;\n } catch (e) {\n return `Error fetching bundle settings: ${e}`;\n }\n}\n\nconst intervalUnitGroups = {\n day: ['day', 'days', 'Days'],\n days: ['day', 'days', 'Days'],\n Days: ['day', 'days', 'Days'],\n week: ['week', 'weeks', 'Weeks'],\n weeks: ['week', 'weeks', 'Weeks'],\n Weeks: ['week', 'weeks', 'Weeks'],\n month: ['month', 'months', 'Months'],\n months: ['month', 'months', 'Months'],\n Months: ['month', 'months', 'Months'],\n};\n\n/**\n * Validates a dynamic bundle\n *\n * @param bundle Dynamic Bundle being validated\n * @returns true or error message\n */\nexport function validateDynamicBundle(bundle: BundleAppProxy): true | string {\n if (!bundle) {\n return 'No bundle defined.';\n }\n if (bundle.selections.length === 0) {\n return 'No selections defined.';\n }\n // validation for RCS onetimes\n const { shippingIntervalFrequency, shippingIntervalUnitType } =\n bundle.selections.find(selection => selection.shippingIntervalFrequency || selection.shippingIntervalUnitType) ||\n {};\n if (shippingIntervalFrequency || shippingIntervalUnitType) {\n // if we have shipping intervals then we should have both defined\n if (!shippingIntervalFrequency || !shippingIntervalUnitType) {\n return 'Shipping intervals do not match on selections.';\n } else {\n // if we have shipping intervals then any that are defined should match\n const shippingIntervalUnitGroup = intervalUnitGroups[shippingIntervalUnitType];\n for (let x = 0; x < bundle.selections.length; x++) {\n const { shippingIntervalFrequency: frequency, shippingIntervalUnitType: unitType } = bundle.selections[x];\n if (\n (frequency && frequency !== shippingIntervalFrequency) ||\n (unitType && !shippingIntervalUnitGroup.includes(unitType))\n ) {\n return 'Shipping intervals do not match on selections.';\n }\n }\n }\n }\n return true;\n}\n\nexport async function getBundleSelection(session: Session, id: string | number): Promise<BundleSelection> {\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'get',\n `/bundle_selections`,\n {\n id,\n },\n session\n );\n return bundle_selection;\n}\n\nexport function listBundleSelections(\n session: Session,\n query?: BundleSelectionListParams\n): Promise<BundleSelectionsResponse> {\n return rechargeApiRequest<BundleSelectionsResponse>('get', `/bundle_selections`, { query }, session);\n}\n\nexport async function createBundleSelection(\n session: Session,\n createRequest: CreateBundleSelectionRequest\n): Promise<BundleSelection> {\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'post',\n `/bundle_selections`,\n {\n data: createRequest,\n },\n session\n );\n return bundle_selection;\n}\n\nexport async function updateBundleSelection(\n session: Session,\n id: string | number,\n updateRequest: UpdateBundleSelectionRequest\n): Promise<BundleSelection> {\n const { bundle_selection } = await rechargeApiRequest<{ bundle_selection: BundleSelection }>(\n 'put',\n `/bundle_selections`,\n {\n id,\n data: updateRequest,\n },\n session\n );\n return bundle_selection;\n}\n\nexport function deleteBundleSelection(session: Session, id: string | number): Promise<void> {\n return rechargeApiRequest<void>(\n 'delete',\n `/bundle_selections`,\n {\n id,\n },\n session\n );\n}\n\nexport async function updateBundle(\n session: Session,\n purchase_item_id: string | number,\n updateRequest: UpdateBundlePurchaseItem\n): Promise<BundlePurchaseItem> {\n const { subscription } = await rechargeApiRequest<{ subscription: BundlePurchaseItem }>(\n 'put',\n '/bundles',\n {\n id: purchase_item_id,\n data: updateRequest,\n },\n session\n );\n\n return subscription;\n}\n"],"names":[],"mappings":";;;;;;AAKA,MAAM,uBAAuB,GAAG,8BAA8B,CAAC;AAC/D,SAAS,6BAA6B,GAAG;AACzC,EAAE,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC,CAAC;AACrC,CAAC;AACD,eAAe,6BAA6B,GAAG;AAC/C,EAAE,IAAI;AACN,IAAI,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,sBAAsB,CAAC,KAAK,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AAO,EAAE,EAAE,EAAE,aAAa,EAAE;AACxE,EAAE,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,kBAAkB;AACvD,IAAI,KAAK;AACT,IAAI,CAAC,kBAAkB,CAAC;AACxB,IAAI;AACJ,MAAM,EAAE;AACR,MAAM,IAAI,EAAE,aAAa;AACzB,KAAK;AACL,IAAI,OAAO;AACX,GAAG,CAAC;AACJ,EAAE,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AACM,SAAS,qBAAqB,CAAC,OAAO,EAAE,EAAE,EAAE;AACnD,EAAE,OAAO,kBAAkB;AAC3B,IAAI,QAAQ;AACZ,IAAI,CAAC,kBAAkB,CAAC;AACxB,IAAI;AACJ,MAAM,EAAE;AACR,KAAK;AACL,IAAI,OAAO;AACX,GAAG,CAAC;AACJ,CAAC;AACM,eAAe,YAAY,CAAC,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE;AAC7E,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,kBAAkB;AACnD,IAAI,KAAK;AACT,IAAI,UAAU;AACd,IAAI;AACJ,MAAM,EAAE,EAAE,gBAAgB;AAC1B,MAAM,IAAI,EAAE,aAAa;AACzB,KAAK;AACL,IAAI,OAAO;AACX,GAAG,CAAC;AACJ,EAAE,OAAO,YAAY,CAAC;AACtB;;;;"}
|
package/dist/esm/index.js
CHANGED
|
@@ -2,7 +2,7 @@ export { applyDiscountToAddress, createAddress, deleteAddress, getAddress, listA
|
|
|
2
2
|
export { loginCustomerPortal, loginShopifyApi, loginShopifyAppProxy, sendPasswordlessCode, sendPasswordlessCodeAppProxy, validatePasswordlessCode, validatePasswordlessCodeAppProxy } from './api/auth.js';
|
|
3
3
|
export { applyDiscountToCharge, getCharge, listCharges, processCharge, removeDiscountsFromCharge, skipCharge, unskipCharge } from './api/charge.js';
|
|
4
4
|
export { getCDNBundleSettings, getCDNProduct, getCDNProductAndSettings, getCDNProducts, getCDNProductsAndSettings, getCDNStoreSettings, getCDNWidgetSettings, resetCDNCache } from './api/cdn.js';
|
|
5
|
-
export { createBundleSelection, deleteBundleSelection, getBundleId, getBundleSelection, getDynamicBundleItems, listBundleSelections, updateBundleSelection, validateBundle, validateDynamicBundle } from './api/bundle.js';
|
|
5
|
+
export { createBundleSelection, deleteBundleSelection, getBundleId, getBundleSelection, getDynamicBundleItems, listBundleSelections, updateBundle, updateBundleSelection, validateBundle, validateDynamicBundle } from './api/bundle.js';
|
|
6
6
|
export { activateMembership, cancelMembership, changeMembership, getMembership, listMemberships } from './api/membership.js';
|
|
7
7
|
export { getMembershipProgram, listMembershipPrograms } from './api/membershipProgram.js';
|
|
8
8
|
export { createMetafield, deleteMetafield, updateMetafield } from './api/metafield.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -244,6 +244,236 @@ interface PaymentMethodListParams extends ListParams<PaymentMethodSortBy> {
|
|
|
244
244
|
include?: PaymentMethodIncludes[];
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
+
interface BundleSelectionAppProxy {
|
|
248
|
+
collectionId: string;
|
|
249
|
+
externalProductId: string;
|
|
250
|
+
externalVariantId: string;
|
|
251
|
+
quantity: number;
|
|
252
|
+
sellingPlan?: number;
|
|
253
|
+
shippingIntervalFrequency?: number;
|
|
254
|
+
shippingIntervalUnitType?: IntervalUnit;
|
|
255
|
+
discountedVariantId?: number;
|
|
256
|
+
}
|
|
257
|
+
interface BundleAppProxy {
|
|
258
|
+
externalVariantId: string;
|
|
259
|
+
externalProductId: string;
|
|
260
|
+
selections: BundleSelectionAppProxy[];
|
|
261
|
+
}
|
|
262
|
+
interface DynamicBundlePropertiesAppProxy {
|
|
263
|
+
_rc_bundle: string;
|
|
264
|
+
_rc_bundle_variant: string;
|
|
265
|
+
_rc_bundle_parent: string;
|
|
266
|
+
_rc_bundle_collection_id: string;
|
|
267
|
+
shipping_interval_frequency?: number;
|
|
268
|
+
shipping_interval_unit_type?: IntervalUnit;
|
|
269
|
+
}
|
|
270
|
+
interface DynamicBundleItemAppProxy {
|
|
271
|
+
id: string;
|
|
272
|
+
properties: DynamicBundlePropertiesAppProxy;
|
|
273
|
+
quantity: number;
|
|
274
|
+
selling_plan?: number;
|
|
275
|
+
}
|
|
276
|
+
interface BundleSelectionItem {
|
|
277
|
+
/** The unique numeric identifier for the item selection. */
|
|
278
|
+
id: number;
|
|
279
|
+
/** The collection id as it appears in the external e-commerce platform. */
|
|
280
|
+
collection_id: string;
|
|
281
|
+
/** The identifier of the external e-commerce platform. */
|
|
282
|
+
collection_source: 'shopify';
|
|
283
|
+
/** The date and time when this item was selected. */
|
|
284
|
+
created_at: IsoDateString;
|
|
285
|
+
/** 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. */
|
|
286
|
+
external_product_id: string;
|
|
287
|
+
/** 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. */
|
|
288
|
+
external_variant_id: string;
|
|
289
|
+
/** The quantity of this product. */
|
|
290
|
+
quantity: number;
|
|
291
|
+
/** The date and time at which the item selection was most recently updated. */
|
|
292
|
+
updated_at: IsoDateString;
|
|
293
|
+
}
|
|
294
|
+
interface BundleSelection {
|
|
295
|
+
/** The unique numeric identifier for the BundleSelection. */
|
|
296
|
+
id: number;
|
|
297
|
+
/** The ID of the BundleVariant associated with the BundleSelection. */
|
|
298
|
+
bundle_variant_id: number;
|
|
299
|
+
/** The ID of the PurchaseItem associated with the BundleSelection. */
|
|
300
|
+
purchase_item_id: number;
|
|
301
|
+
/** The date and time when the contents were selected. */
|
|
302
|
+
created_at: IsoDateString;
|
|
303
|
+
/** 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. */
|
|
304
|
+
external_product_id: string;
|
|
305
|
+
/** 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. */
|
|
306
|
+
external_variant_id: string;
|
|
307
|
+
items: BundleSelectionItem[];
|
|
308
|
+
/** The date and time at which the BundleSelection was most recently updated. */
|
|
309
|
+
updated_at: IsoDateString;
|
|
310
|
+
}
|
|
311
|
+
type BundleSelectionItemRequiredCreateProps = 'collection_id' | 'collection_source' | 'external_product_id' | 'external_variant_id' | 'quantity';
|
|
312
|
+
interface CreateBundleSelectionRequest {
|
|
313
|
+
purchase_item_id: number;
|
|
314
|
+
items: Pick<BundleSelectionItem, BundleSelectionItemRequiredCreateProps>[];
|
|
315
|
+
}
|
|
316
|
+
interface UpdateBundleSelectionRequest extends CreateBundleSelectionRequest {
|
|
317
|
+
}
|
|
318
|
+
interface BundleSelectionsResponse {
|
|
319
|
+
next_cursor: null | string;
|
|
320
|
+
previous_cursor: null | string;
|
|
321
|
+
bundle_selections: BundleSelection[];
|
|
322
|
+
}
|
|
323
|
+
type BundleSelectionsSortBy = 'id-asc' | 'id-desc' | 'updated_at-asc' | 'updated_at-desc';
|
|
324
|
+
interface BundleSelectionListParams extends ListParams<BundleSelectionsSortBy> {
|
|
325
|
+
/** Filter BundleSelections by Subscription or Onetime ID. */
|
|
326
|
+
purchase_item_ids?: (string | number)[];
|
|
327
|
+
/** Filter BundleSelections by BundleVariants. */
|
|
328
|
+
bundle_variant_ids?: (string | number)[];
|
|
329
|
+
}
|
|
330
|
+
interface UpdateBundlePurchaseItem extends UpdateSubscriptionRequest {
|
|
331
|
+
external_product_id: {
|
|
332
|
+
ecommerce: string;
|
|
333
|
+
};
|
|
334
|
+
external_variant_id: {
|
|
335
|
+
ecommerce: string;
|
|
336
|
+
};
|
|
337
|
+
items: Pick<BundleSelectionItem, BundleSelectionItemRequiredCreateProps>[];
|
|
338
|
+
}
|
|
339
|
+
interface BundlePurchaseItem extends Subscription {
|
|
340
|
+
items: BundleSelectionItem[];
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
interface AddonSettings {
|
|
344
|
+
collectionId: string;
|
|
345
|
+
collectionHandle: string;
|
|
346
|
+
enabled: boolean;
|
|
347
|
+
}
|
|
348
|
+
interface AddToCartCallbackSettings {
|
|
349
|
+
type: 'none' | 'callback' | 'redirect';
|
|
350
|
+
value: string;
|
|
351
|
+
}
|
|
352
|
+
interface CrossSellsSettings {
|
|
353
|
+
collectionId: string;
|
|
354
|
+
collectionHandle: string;
|
|
355
|
+
enabled: boolean;
|
|
356
|
+
}
|
|
357
|
+
interface StepSettingsCommon {
|
|
358
|
+
description?: string;
|
|
359
|
+
disable?: boolean;
|
|
360
|
+
index: string;
|
|
361
|
+
name: string;
|
|
362
|
+
title: string;
|
|
363
|
+
}
|
|
364
|
+
type VariantSelector = {
|
|
365
|
+
optionsMeta: {
|
|
366
|
+
[key: string]: {
|
|
367
|
+
defaultImage: string;
|
|
368
|
+
content: string;
|
|
369
|
+
};
|
|
370
|
+
};
|
|
371
|
+
};
|
|
372
|
+
declare enum StepSettingsTypes {
|
|
373
|
+
VARIANT_SELECTOR = "variantSelector",
|
|
374
|
+
ALL_COLLECTIONS = "all-collections",
|
|
375
|
+
ADDONS = "addons",
|
|
376
|
+
SUMMARY = "summary",
|
|
377
|
+
CROSS_SELLS = "cross-sells"
|
|
378
|
+
}
|
|
379
|
+
type BundlePriceRule = 'fixed' | 'dynamic';
|
|
380
|
+
type VariantSelectorStepSetting = StepSettingsCommon & {
|
|
381
|
+
data?: VariantSelector;
|
|
382
|
+
type: StepSettingsTypes.VARIANT_SELECTOR;
|
|
383
|
+
};
|
|
384
|
+
type StepSettings = StepSettingsCommon & {
|
|
385
|
+
data?: Record<string, unknown>;
|
|
386
|
+
type: Exclude<StepSettingsTypes, StepSettingsTypes.VARIANT_SELECTOR>;
|
|
387
|
+
};
|
|
388
|
+
interface MultiStepSettings {
|
|
389
|
+
optionImages: string;
|
|
390
|
+
steps: [VariantSelectorStepSetting, ...StepSettings[]];
|
|
391
|
+
}
|
|
392
|
+
type BundleTemplateType = 'multi-step' | 'one-page' | 'custom' | 'none';
|
|
393
|
+
interface OnePageSettings {
|
|
394
|
+
frequencySelector: 'toggle' | 'dropdown';
|
|
395
|
+
}
|
|
396
|
+
interface BundleTemplateSettings {
|
|
397
|
+
multiStep?: MultiStepSettings;
|
|
398
|
+
onePage: OnePageSettings;
|
|
399
|
+
}
|
|
400
|
+
type WidgetVisibility = {
|
|
401
|
+
signup: boolean;
|
|
402
|
+
portal: boolean;
|
|
403
|
+
};
|
|
404
|
+
interface BundleProductLayoutSettings {
|
|
405
|
+
addons: AddonSettings;
|
|
406
|
+
addToCartCallback: AddToCartCallbackSettings;
|
|
407
|
+
collapsibleSections: boolean;
|
|
408
|
+
crossSells: CrossSellsSettings;
|
|
409
|
+
defaultFrequency: string;
|
|
410
|
+
defaultVariantId: string;
|
|
411
|
+
description: string;
|
|
412
|
+
filters: string[];
|
|
413
|
+
learnMoreModal: boolean;
|
|
414
|
+
published: boolean;
|
|
415
|
+
showStickyStatusBar: boolean;
|
|
416
|
+
showVariants: boolean;
|
|
417
|
+
template: BundleTemplateType;
|
|
418
|
+
templateSettings: BundleTemplateSettings;
|
|
419
|
+
title: string;
|
|
420
|
+
visibility: WidgetVisibility;
|
|
421
|
+
}
|
|
422
|
+
interface BundleVariantOptionSource {
|
|
423
|
+
id: number;
|
|
424
|
+
option_source_id: string;
|
|
425
|
+
position: number;
|
|
426
|
+
quantity_max: number | null;
|
|
427
|
+
quantity_min: number | null;
|
|
428
|
+
source_platform: 'shopify';
|
|
429
|
+
updated_at: IsoDateString;
|
|
430
|
+
created_at: IsoDateString;
|
|
431
|
+
}
|
|
432
|
+
interface BundleVariantSelectionDefault {
|
|
433
|
+
id: number;
|
|
434
|
+
quantity: number;
|
|
435
|
+
external_variant_id: string;
|
|
436
|
+
}
|
|
437
|
+
interface BundleVariantRange {
|
|
438
|
+
id: number;
|
|
439
|
+
quantity_max: number | null;
|
|
440
|
+
quantity_min: number;
|
|
441
|
+
updated_at: IsoDateString;
|
|
442
|
+
created_at: IsoDateString;
|
|
443
|
+
}
|
|
444
|
+
interface BundleVariant {
|
|
445
|
+
enabled: boolean;
|
|
446
|
+
external_variant_id: string;
|
|
447
|
+
id: number;
|
|
448
|
+
items_count: number;
|
|
449
|
+
option_sources: BundleVariantOptionSource[];
|
|
450
|
+
position: number;
|
|
451
|
+
selection_defaults: BundleVariantSelectionDefault[];
|
|
452
|
+
title: string;
|
|
453
|
+
ranges: BundleVariantRange[];
|
|
454
|
+
updated_at: IsoDateString;
|
|
455
|
+
created_at: IsoDateString;
|
|
456
|
+
}
|
|
457
|
+
interface BundleProduct {
|
|
458
|
+
custom_prices: boolean;
|
|
459
|
+
customization_window_disabled_message: string | null;
|
|
460
|
+
customization_window: number | null;
|
|
461
|
+
default_bundle_variant_id: number;
|
|
462
|
+
description: string | null;
|
|
463
|
+
external_product_id: string;
|
|
464
|
+
id: number;
|
|
465
|
+
is_customizable: boolean;
|
|
466
|
+
layout_settings_version: '2021-11';
|
|
467
|
+
max_quantity_per_variant: number | null;
|
|
468
|
+
reset_box_contents: boolean;
|
|
469
|
+
title: string;
|
|
470
|
+
updated_at: IsoDateString;
|
|
471
|
+
created_at: IsoDateString;
|
|
472
|
+
layout_settings: BundleProductLayoutSettings;
|
|
473
|
+
variants: BundleVariant[];
|
|
474
|
+
price_rule: BundlePriceRule | null;
|
|
475
|
+
}
|
|
476
|
+
|
|
247
477
|
type SubscriptionStatus = 'active' | 'cancelled' | 'expired';
|
|
248
478
|
interface Subscription {
|
|
249
479
|
/** Unique numeric identifier for the subscription. */
|
|
@@ -331,6 +561,8 @@ interface Subscription {
|
|
|
331
561
|
address?: Address;
|
|
332
562
|
customer?: Customer;
|
|
333
563
|
metafields?: Metafield[];
|
|
564
|
+
bundle_selections?: BundleSelection | null;
|
|
565
|
+
bundle_product?: BundleProduct | null;
|
|
334
566
|
};
|
|
335
567
|
}
|
|
336
568
|
interface SubscriptionsResponse {
|
|
@@ -338,7 +570,7 @@ interface SubscriptionsResponse {
|
|
|
338
570
|
previous_cursor: null | string;
|
|
339
571
|
subscriptions: Subscription[];
|
|
340
572
|
}
|
|
341
|
-
type SubscriptionIncludes = 'address' | 'customer' | 'metafields';
|
|
573
|
+
type SubscriptionIncludes = 'address' | 'customer' | 'metafields' | 'bundle_product' | 'bundle_selections';
|
|
342
574
|
interface GetSubscriptionOptions {
|
|
343
575
|
include?: SubscriptionIncludes[];
|
|
344
576
|
}
|
|
@@ -1072,90 +1304,6 @@ interface RequestOptions extends GetRequestOptions, CRUDRequestOptions {
|
|
|
1072
1304
|
headers?: RequestHeaders;
|
|
1073
1305
|
}
|
|
1074
1306
|
|
|
1075
|
-
interface BundleSelectionAppProxy {
|
|
1076
|
-
collectionId: string;
|
|
1077
|
-
externalProductId: string;
|
|
1078
|
-
externalVariantId: string;
|
|
1079
|
-
quantity: number;
|
|
1080
|
-
sellingPlan?: number;
|
|
1081
|
-
shippingIntervalFrequency?: number;
|
|
1082
|
-
shippingIntervalUnitType?: IntervalUnit;
|
|
1083
|
-
discountedVariantId?: number;
|
|
1084
|
-
}
|
|
1085
|
-
interface BundleAppProxy {
|
|
1086
|
-
externalVariantId: string;
|
|
1087
|
-
externalProductId: string;
|
|
1088
|
-
selections: BundleSelectionAppProxy[];
|
|
1089
|
-
}
|
|
1090
|
-
interface DynamicBundlePropertiesAppProxy {
|
|
1091
|
-
_rc_bundle: string;
|
|
1092
|
-
_rc_bundle_variant: string;
|
|
1093
|
-
_rc_bundle_parent: string;
|
|
1094
|
-
_rc_bundle_collection_id: string;
|
|
1095
|
-
shipping_interval_frequency?: number;
|
|
1096
|
-
shipping_interval_unit_type?: IntervalUnit;
|
|
1097
|
-
}
|
|
1098
|
-
interface DynamicBundleItemAppProxy {
|
|
1099
|
-
id: string;
|
|
1100
|
-
properties: DynamicBundlePropertiesAppProxy;
|
|
1101
|
-
quantity: number;
|
|
1102
|
-
selling_plan?: number;
|
|
1103
|
-
}
|
|
1104
|
-
interface BundleSelectionItem {
|
|
1105
|
-
/** The unique numeric identifier for the item selection. */
|
|
1106
|
-
id: number;
|
|
1107
|
-
/** The collection id as it appears in the external e-commerce platform. */
|
|
1108
|
-
collection_id: string;
|
|
1109
|
-
/** The identifier of the external e-commerce platform. */
|
|
1110
|
-
collection_source: 'shopify';
|
|
1111
|
-
/** The date and time when this item was selected. */
|
|
1112
|
-
created_at: IsoDateString;
|
|
1113
|
-
/** 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. */
|
|
1114
|
-
external_product_id: string;
|
|
1115
|
-
/** 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. */
|
|
1116
|
-
external_variant_id: string;
|
|
1117
|
-
/** The quantity of this product. */
|
|
1118
|
-
quantity: number;
|
|
1119
|
-
/** The date and time at which the item selection was most recently updated. */
|
|
1120
|
-
updated_at: IsoDateString;
|
|
1121
|
-
}
|
|
1122
|
-
interface BundleSelection {
|
|
1123
|
-
/** The unique numeric identifier for the BundleSelection. */
|
|
1124
|
-
id: number;
|
|
1125
|
-
/** The ID of the BundleVariant associated with the BundleSelection. */
|
|
1126
|
-
bundle_variant_id: number;
|
|
1127
|
-
/** The ID of the PurchaseItem associated with the BundleSelection. */
|
|
1128
|
-
purchase_item_id: number;
|
|
1129
|
-
/** The date and time when the contents were selected. */
|
|
1130
|
-
created_at: IsoDateString;
|
|
1131
|
-
/** 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. */
|
|
1132
|
-
external_product_id: string;
|
|
1133
|
-
/** 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. */
|
|
1134
|
-
external_variant_id: string;
|
|
1135
|
-
items: BundleSelectionItem[];
|
|
1136
|
-
/** The date and time at which the BundleSelection was most recently updated. */
|
|
1137
|
-
updated_at: IsoDateString;
|
|
1138
|
-
}
|
|
1139
|
-
type BundleSelectionItemRequiredCreateProps = 'collection_id' | 'collection_source' | 'external_product_id' | 'external_variant_id' | 'quantity';
|
|
1140
|
-
interface CreateBundleSelectionRequest {
|
|
1141
|
-
purchase_item_id: number;
|
|
1142
|
-
items: Pick<BundleSelectionItem, BundleSelectionItemRequiredCreateProps>[];
|
|
1143
|
-
}
|
|
1144
|
-
interface UpdateBundleSelectionRequest extends CreateBundleSelectionRequest {
|
|
1145
|
-
}
|
|
1146
|
-
interface BundleSelectionsResponse {
|
|
1147
|
-
next_cursor: null | string;
|
|
1148
|
-
previous_cursor: null | string;
|
|
1149
|
-
bundle_selections: BundleSelection[];
|
|
1150
|
-
}
|
|
1151
|
-
type BundleSelectionsSortBy = 'id-asc' | 'id-desc' | 'updated_at-asc' | 'updated_at-desc';
|
|
1152
|
-
interface BundleSelectionListParams extends ListParams<BundleSelectionsSortBy> {
|
|
1153
|
-
/** Filter BundleSelections by Subscription or Onetime ID. */
|
|
1154
|
-
purchase_item_ids?: (string | number)[];
|
|
1155
|
-
/** Filter BundleSelections by BundleVariants. */
|
|
1156
|
-
bundle_variant_ids?: (string | number)[];
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
1307
|
type FirstOption = 'onetime' | 'autodeliver';
|
|
1160
1308
|
type PriceAdjustmentsType = 'percentage';
|
|
1161
1309
|
type StorefrontPurchaseOption = 'subscription_and_onetime' | 'subscription_only' | 'onetime_only' | 'inactive';
|
|
@@ -1892,6 +2040,7 @@ declare function listBundleSelections(session: Session, query?: BundleSelectionL
|
|
|
1892
2040
|
declare function createBundleSelection(session: Session, createRequest: CreateBundleSelectionRequest): Promise<BundleSelection>;
|
|
1893
2041
|
declare function updateBundleSelection(session: Session, id: string | number, updateRequest: UpdateBundleSelectionRequest): Promise<BundleSelection>;
|
|
1894
2042
|
declare function deleteBundleSelection(session: Session, id: string | number): Promise<void>;
|
|
2043
|
+
declare function updateBundle(session: Session, purchase_item_id: string | number, updateRequest: UpdateBundlePurchaseItem): Promise<BundlePurchaseItem>;
|
|
1895
2044
|
|
|
1896
2045
|
/** @internal Retrieves membership information for passed in id */
|
|
1897
2046
|
declare function getMembership(session: Session, id: string | number): Promise<Membership>;
|
|
@@ -1995,4 +2144,4 @@ declare const api: {
|
|
|
1995
2144
|
};
|
|
1996
2145
|
declare function initRecharge(opt?: InitOptions): void;
|
|
1997
2146
|
|
|
1998
|
-
export { ActivateMembershipRequest, Address, AddressIncludes, AddressListParams, AddressListResponse, AddressResponse, AddressSortBy, AnalyticsData, AssociatedAddress, BasicSubscriptionParams, BooleanLike, BooleanNumbers, BooleanString, BooleanStringNumbers, BundleAppProxy, BundleSelection, BundleSelectionAppProxy, BundleSelectionItem, BundleSelectionItemRequiredCreateProps, BundleSelectionListParams, BundleSelectionsResponse, BundleSelectionsSortBy, BundleTranslations, CDNBaseWidgetSettings, CDNBundleLayoutSettings, CDNBundleSettings, CDNBundleStep, CDNBundleStepOption, CDNBundleVariant, CDNBundleVariantOptionSource, CDNBundleVariantSelectionDefault, CDNPrices, CDNProduct, CDNProductAndSettings, CDNProductKeyObject, CDNProductOption, CDNProductOptionValue, CDNProductRaw, CDNProductResource, CDNProductsAndSettings, CDNProductsAndSettingsResource, CDNSellingPlan, CDNSellingPlanAllocations, CDNSellingPlanGroup, CDNStoreSettings, CDNSubscriptionOption, CDNVariant, CDNVariantOptionValue, CDNWidgetSettings, CDNWidgetSettingsRaw, CDNWidgetSettingsResource, CRUDRequestOptions, CancelMembershipRequest, CancelSubscriptionRequest, ChangeMembershipRequest, ChannelSettings, Charge, ChargeIncludes, ChargeListParams, ChargeListResponse, ChargeResponse, ChargeSortBy, ChargeStatus, ColorString, CreateAddressRequest, CreateBundleSelectionRequest, CreateMetafieldRequest, CreateOnetimeRequest, CreateSubscriptionRequest, Customer, CustomerDeliveryScheduleParams, CustomerDeliveryScheduleResponse, CustomerIncludes, CustomerPortalAccessResponse, Delivery, DeliveryLineItem, DeliveryOrder, DeliveryPaymentMethod, Discount, DynamicBundleItemAppProxy, DynamicBundlePropertiesAppProxy, ExternalAttributeSchema, ExternalId, ExternalTransactionId, FirstOption, GetAddressOptions, GetChargeOptions, GetCustomerOptions, GetMembershipProgramOptions, GetPaymentMethodOptions, GetRequestOptions, GetSubscriptionOptions, HTMLString, InitOptions, IntervalUnit, 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, Onetime, OnetimeListParams, OnetimeOptionalCreateProps, OnetimeRequiredCreateProps, OnetimesResponse, OnetimesSortBy, Order, OrderIncludes, OrderListParams, OrderSortBy, OrderStatus, OrderType, OrdersResponse, PasswordlessCodeResponse, PasswordlessOptions, PasswordlessValidateResponse, PaymentDetails, PaymentMethod, PaymentMethodIncludes, PaymentMethodListParams, PaymentMethodSortBy, PaymentMethodStatus, PaymentMethodsResponse, PaymentType, Plan, PlanListParams, PlanSortBy, PlanType, PlansResponse, PriceAdjustmentsType, ProcessorName, ProductImage, Property, Request, RequestHeaders, RequestOptions, Session, ShippingLine, SkipFutureChargeAddressRequest, SkipFutureChargeAddressResponse, StorefrontEnvironment, StorefrontOptions, StorefrontPurchaseOption, SubType, Subscription, SubscriptionIncludes, SubscriptionListParams, SubscriptionOptionalCreateProps, SubscriptionPreferences, SubscriptionRequiredCreateProps, SubscriptionSortBy, SubscriptionStatus, Subscription_2021_01, SubscriptionsResponse, TaxLine, Translations, UpdateAddressRequest, UpdateBundleSelectionRequest, UpdateCustomerRequest, UpdateMetafieldRequest, UpdateOnetimeRequest, UpdatePaymentMethodRequest, UpdateSubscriptionParams, UpdateSubscriptionRequest, UpdateSubscriptionsParams, UpdateSubscriptionsRequest, WidgetIconColor, WidgetTemplateType, activateMembership, activateSubscription, api, applyDiscountToAddress, applyDiscountToCharge, cancelMembership, cancelSubscription, changeMembership, createAddress, createBundleSelection, createMetafield, createOnetime, createSubscription, createSubscriptions, deleteAddress, deleteBundleSelection, deleteMetafield, deleteOnetime, getAddress, getBundleId, getBundleSelection, getCDNBundleSettings, getCDNProduct, getCDNProductAndSettings, getCDNProducts, getCDNProductsAndSettings, getCDNStoreSettings, getCDNWidgetSettings, getCharge, getCustomer, getCustomerPortalAccess, getDeliverySchedule, getDynamicBundleItems, getMembership, getMembershipProgram, getOnetime, getOrder, getPaymentMethod, getPlan, getSubscription, initRecharge, intervalUnit, listAddresses, listBundleSelections, listCharges, listMembershipPrograms, listMemberships, listOnetimes, listOrders, listPaymentMethods, listPlans, listSubscriptions, loginCustomerPortal, loginShopifyApi, loginShopifyAppProxy, membershipIncludes, mergeAddresses, processCharge, removeDiscountsFromAddress, removeDiscountsFromCharge, resetCDNCache, sendPasswordlessCode, sendPasswordlessCodeAppProxy, skipCharge, skipFutureCharge, skipSubscriptionCharge, unskipCharge, updateAddress, updateBundleSelection, updateCustomer, updateMetafield, updateOnetime, updatePaymentMethod, updateSubscription, updateSubscriptionAddress, updateSubscriptionChargeDate, updateSubscriptions, validateBundle, validateDynamicBundle, validatePasswordlessCode, validatePasswordlessCodeAppProxy };
|
|
2147
|
+
export { ActivateMembershipRequest, Address, AddressIncludes, AddressListParams, AddressListResponse, AddressResponse, AddressSortBy, AnalyticsData, AssociatedAddress, BasicSubscriptionParams, BooleanLike, BooleanNumbers, BooleanString, BooleanStringNumbers, BundleAppProxy, BundlePurchaseItem, BundleSelection, BundleSelectionAppProxy, BundleSelectionItem, BundleSelectionItemRequiredCreateProps, BundleSelectionListParams, BundleSelectionsResponse, BundleSelectionsSortBy, BundleTranslations, CDNBaseWidgetSettings, CDNBundleLayoutSettings, CDNBundleSettings, CDNBundleStep, CDNBundleStepOption, CDNBundleVariant, CDNBundleVariantOptionSource, CDNBundleVariantSelectionDefault, CDNPrices, CDNProduct, CDNProductAndSettings, CDNProductKeyObject, CDNProductOption, CDNProductOptionValue, CDNProductRaw, CDNProductResource, CDNProductsAndSettings, CDNProductsAndSettingsResource, CDNSellingPlan, CDNSellingPlanAllocations, CDNSellingPlanGroup, CDNStoreSettings, CDNSubscriptionOption, CDNVariant, CDNVariantOptionValue, CDNWidgetSettings, CDNWidgetSettingsRaw, CDNWidgetSettingsResource, CRUDRequestOptions, CancelMembershipRequest, CancelSubscriptionRequest, ChangeMembershipRequest, ChannelSettings, Charge, ChargeIncludes, ChargeListParams, ChargeListResponse, ChargeResponse, ChargeSortBy, ChargeStatus, ColorString, CreateAddressRequest, CreateBundleSelectionRequest, CreateMetafieldRequest, CreateOnetimeRequest, CreateSubscriptionRequest, Customer, CustomerDeliveryScheduleParams, CustomerDeliveryScheduleResponse, CustomerIncludes, CustomerPortalAccessResponse, Delivery, DeliveryLineItem, DeliveryOrder, DeliveryPaymentMethod, Discount, DynamicBundleItemAppProxy, DynamicBundlePropertiesAppProxy, ExternalAttributeSchema, ExternalId, ExternalTransactionId, FirstOption, GetAddressOptions, GetChargeOptions, GetCustomerOptions, GetMembershipProgramOptions, GetPaymentMethodOptions, GetRequestOptions, GetSubscriptionOptions, HTMLString, InitOptions, IntervalUnit, 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, Onetime, OnetimeListParams, OnetimeOptionalCreateProps, OnetimeRequiredCreateProps, OnetimesResponse, OnetimesSortBy, Order, OrderIncludes, OrderListParams, OrderSortBy, OrderStatus, OrderType, OrdersResponse, PasswordlessCodeResponse, PasswordlessOptions, PasswordlessValidateResponse, PaymentDetails, PaymentMethod, PaymentMethodIncludes, PaymentMethodListParams, PaymentMethodSortBy, PaymentMethodStatus, PaymentMethodsResponse, PaymentType, Plan, PlanListParams, PlanSortBy, PlanType, PlansResponse, PriceAdjustmentsType, ProcessorName, ProductImage, Property, Request, RequestHeaders, RequestOptions, Session, ShippingLine, SkipFutureChargeAddressRequest, SkipFutureChargeAddressResponse, StorefrontEnvironment, StorefrontOptions, StorefrontPurchaseOption, SubType, Subscription, SubscriptionIncludes, SubscriptionListParams, SubscriptionOptionalCreateProps, SubscriptionPreferences, SubscriptionRequiredCreateProps, SubscriptionSortBy, SubscriptionStatus, Subscription_2021_01, SubscriptionsResponse, TaxLine, Translations, UpdateAddressRequest, UpdateBundlePurchaseItem, UpdateBundleSelectionRequest, UpdateCustomerRequest, UpdateMetafieldRequest, UpdateOnetimeRequest, UpdatePaymentMethodRequest, UpdateSubscriptionParams, UpdateSubscriptionRequest, UpdateSubscriptionsParams, UpdateSubscriptionsRequest, WidgetIconColor, WidgetTemplateType, activateMembership, activateSubscription, api, applyDiscountToAddress, applyDiscountToCharge, cancelMembership, cancelSubscription, changeMembership, createAddress, createBundleSelection, createMetafield, createOnetime, createSubscription, createSubscriptions, deleteAddress, deleteBundleSelection, deleteMetafield, deleteOnetime, getAddress, getBundleId, getBundleSelection, getCDNBundleSettings, getCDNProduct, getCDNProductAndSettings, getCDNProducts, getCDNProductsAndSettings, getCDNStoreSettings, getCDNWidgetSettings, getCharge, getCustomer, getCustomerPortalAccess, getDeliverySchedule, getDynamicBundleItems, getMembership, getMembershipProgram, getOnetime, getOrder, getPaymentMethod, getPlan, getSubscription, initRecharge, intervalUnit, listAddresses, listBundleSelections, listCharges, listMembershipPrograms, listMemberships, listOnetimes, listOrders, listPaymentMethods, listPlans, listSubscriptions, loginCustomerPortal, loginShopifyApi, loginShopifyAppProxy, membershipIncludes, mergeAddresses, processCharge, removeDiscountsFromAddress, removeDiscountsFromCharge, resetCDNCache, sendPasswordlessCode, sendPasswordlessCodeAppProxy, skipCharge, skipFutureCharge, skipSubscriptionCharge, unskipCharge, updateAddress, updateBundle, updateBundleSelection, updateCustomer, updateMetafield, updateOnetime, updatePaymentMethod, updateSubscription, updateSubscriptionAddress, updateSubscriptionChargeDate, updateSubscriptions, validateBundle, validateDynamicBundle, validatePasswordlessCode, validatePasswordlessCodeAppProxy };
|