@rechargeapps/storefront-client 0.0.14
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/README.md +47 -0
- package/dist/cjs/api/bundle.js +100 -0
- package/dist/cjs/api/bundle.js.map +1 -0
- package/dist/cjs/api/cdn.js +109 -0
- package/dist/cjs/api/cdn.js.map +1 -0
- package/dist/cjs/constants/api.js +8 -0
- package/dist/cjs/constants/api.js.map +1 -0
- package/dist/cjs/index.js +23 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/mappers/cdn.js +67 -0
- package/dist/cjs/mappers/cdn.js.map +1 -0
- package/dist/cjs/mappers/utils.js +38 -0
- package/dist/cjs/mappers/utils.js.map +1 -0
- package/dist/cjs/utils/init.js +33 -0
- package/dist/cjs/utils/init.js.map +1 -0
- package/dist/cjs/utils/options.js +18 -0
- package/dist/cjs/utils/options.js.map +1 -0
- package/dist/cjs/utils/request.js +95 -0
- package/dist/cjs/utils/request.js.map +1 -0
- package/dist/esm/api/bundle.js +95 -0
- package/dist/esm/api/bundle.js.map +1 -0
- package/dist/esm/api/cdn.js +98 -0
- package/dist/esm/api/cdn.js.map +1 -0
- package/dist/esm/constants/api.js +4 -0
- package/dist/esm/constants/api.js.map +1 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/mappers/cdn.js +57 -0
- package/dist/esm/mappers/cdn.js.map +1 -0
- package/dist/esm/mappers/utils.js +34 -0
- package/dist/esm/mappers/utils.js.map +1 -0
- package/dist/esm/utils/init.js +28 -0
- package/dist/esm/utils/init.js.map +1 -0
- package/dist/esm/utils/options.js +13 -0
- package/dist/esm/utils/options.js.map +1 -0
- package/dist/esm/utils/request.js +86 -0
- package/dist/esm/utils/request.js.map +1 -0
- package/dist/index.d.ts +419 -0
- package/dist/umd/recharge-storefront-client.min.js +24 -0
- package/dist/umd/recharge-storefront-client.min.js.map +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { toLineItemProperty } from '@recharge-packages/bundling-data';
|
|
2
|
+
import { request } from '../utils/request.js';
|
|
3
|
+
import { getOptions } from '../utils/options.js';
|
|
4
|
+
import { getBundleSettings } from './cdn.js';
|
|
5
|
+
|
|
6
|
+
var __async = (__this, __arguments, generator) => {
|
|
7
|
+
return new Promise((resolve, reject) => {
|
|
8
|
+
var fulfilled = (value) => {
|
|
9
|
+
try {
|
|
10
|
+
step(generator.next(value));
|
|
11
|
+
} catch (e) {
|
|
12
|
+
reject(e);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
var rejected = (value) => {
|
|
16
|
+
try {
|
|
17
|
+
step(generator.throw(value));
|
|
18
|
+
} catch (e) {
|
|
19
|
+
reject(e);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
23
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
const STORE_FRONT_MANAGER_URL = "https://us-east4-recharge-prod-services-f818.cloudfunctions.net/bundling-storefront-manager";
|
|
27
|
+
function getTimestampSecondsFromClient() {
|
|
28
|
+
return Math.ceil(Date.now() / 1e3);
|
|
29
|
+
}
|
|
30
|
+
function getTimestampSecondsFromServer(request2) {
|
|
31
|
+
return __async(this, null, function* () {
|
|
32
|
+
const url = `${STORE_FRONT_MANAGER_URL}/t`;
|
|
33
|
+
try {
|
|
34
|
+
const { timestamp } = yield request2("get", url, {
|
|
35
|
+
headers: { "X-Recharge-App": "storefront-client" }
|
|
36
|
+
});
|
|
37
|
+
return timestamp;
|
|
38
|
+
} catch (ex) {
|
|
39
|
+
console.error(`Fetch failed: ${ex}. Using client-side date.`);
|
|
40
|
+
return getTimestampSecondsFromClient();
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
const getBundleId = (bundle) => __async(void 0, null, function* () {
|
|
45
|
+
const opts = getOptions();
|
|
46
|
+
const isValid = yield validateBundle(bundle);
|
|
47
|
+
if (!isValid) {
|
|
48
|
+
throw new Error("Bundle selection is invalid.");
|
|
49
|
+
}
|
|
50
|
+
const timestampSeconds = yield getTimestampSecondsFromServer(request);
|
|
51
|
+
const bundleData = toLineItemProperty({
|
|
52
|
+
variantId: bundle.externalVariantId,
|
|
53
|
+
version: timestampSeconds,
|
|
54
|
+
items: bundle.selections.map((item) => {
|
|
55
|
+
return {
|
|
56
|
+
collectionId: item.collectionId,
|
|
57
|
+
productId: item.externalProductId,
|
|
58
|
+
variantId: item.externalVariantId,
|
|
59
|
+
quantity: item.quantity,
|
|
60
|
+
sku: ""
|
|
61
|
+
};
|
|
62
|
+
})
|
|
63
|
+
});
|
|
64
|
+
try {
|
|
65
|
+
const STORE_FRONT_BUNDLE_URL = `${STORE_FRONT_MANAGER_URL}/api/v1/bundles`;
|
|
66
|
+
const payload = yield request("post", STORE_FRONT_BUNDLE_URL, {
|
|
67
|
+
data: {
|
|
68
|
+
bundle: bundleData
|
|
69
|
+
},
|
|
70
|
+
headers: {
|
|
71
|
+
"Content-Type": "application/json",
|
|
72
|
+
Origin: `https://${opts.storeIdentifier}`,
|
|
73
|
+
"X-Recharge-App": "storefront-client"
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
if (!payload.id || payload.code !== 200) {
|
|
77
|
+
throw new Error(`1: failed generating rb_id: ${JSON.stringify(payload)}`);
|
|
78
|
+
}
|
|
79
|
+
return payload.id;
|
|
80
|
+
} catch (e) {
|
|
81
|
+
throw new Error(`2: failed generating rb_id ${e}`);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
const validateBundle = (bundle) => __async(void 0, null, function* () {
|
|
85
|
+
try {
|
|
86
|
+
const bundleSettings = yield getBundleSettings(bundle.externalProductId);
|
|
87
|
+
return !!bundle && !!bundleSettings;
|
|
88
|
+
} catch (e) {
|
|
89
|
+
console.error("Error fetching bundle settings");
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
export { getBundleId, validateBundle };
|
|
95
|
+
//# sourceMappingURL=bundle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle.js","sources":["../../../src/api/bundle.ts"],"sourcesContent":["import { toLineItemProperty } from '@recharge-packages/bundling-data';\nimport { Request, Bundle } from '../types';\nimport { request } from '../utils/request';\nimport { getOptions } from '../utils/options';\nimport { getBundleSettings } from './cdn';\n\nconst STORE_FRONT_MANAGER_URL = process.env.BUNDLING_STOREFRONT_URL;\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(request: Request): 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 const url = `${STORE_FRONT_MANAGER_URL}/t`;\n\n try {\n const { timestamp } = await request<{ timestamp: number }>('get', url, {\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 const getBundleId = async (bundle: Bundle): Promise<string> => {\n const opts = getOptions();\n const isValid = await validateBundle(bundle);\n if (!isValid) {\n throw new Error('Bundle selection is invalid.');\n }\n const timestampSeconds = await getTimestampSecondsFromServer(request);\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 STORE_FRONT_BUNDLE_URL = `${STORE_FRONT_MANAGER_URL}/api/v1/bundles`;\n const payload = await request<{ id: string; code: number; message: string }>('post', STORE_FRONT_BUNDLE_URL, {\n data: {\n bundle: bundleData,\n },\n headers: {\n 'Content-Type': 'application/json',\n Origin: `https://${opts.storeIdentifier}`,\n 'X-Recharge-App': 'storefront-client',\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 const validateBundle = async (bundle: Bundle): Promise<boolean> => {\n try {\n const bundleSettings = await getBundleSettings(bundle.externalProductId);\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 return !!bundle && !!bundleSettings;\n } catch (e) {\n console.error('Error fetching bundle settings');\n return false;\n }\n};\n"],"names":[],"mappings":";;;;;AAAA,IAAI,OAAO,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,KAAK;AAClD,EAAE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;AAC1C,IAAI,IAAI,SAAS,GAAG,CAAC,KAAK,KAAK;AAC/B,MAAM,IAAI;AACV,QAAQ,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AACpC,OAAA,CAAA,OAAA,CAAA,EAAA;AACA,QAAQ,MAAM,CAAC,CAAC,CAAC,CAAC;AAClB,OAAA;AACA,KAAK,CAAC;AACN,IAAI,IAAC,QAAA,GAAA,CAAA,KAAA,KAAA;AACL,MAAM,IAAI;AACV,QAAK,IAAA,CAAA,SAAA,CAAA,KAAA,CAAA,KAAA,CAAA,CAAA,CAAA;AACL,OAAO,CAAC,OAAO,CAAC,EAAE;AAClB,QAAC,MAAA,CAAA,CAAA,CAAA,CAAA;AACD,OAAA;AACA,KAAK,CAAC;AACN,IAAI,IAAC,IAAA,GAAA,CAAA,CAAA,KAAA,CAAA,CAAA,IAAA,GAAA,OAAA,CAAA,CAAA,CAAA,KAAA,CAAA,GAAA,OAAA,CAAA,OAAA,CAAA,CAA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AACH,KAAE;AACF,IAAA,OAAA,OAAA,CAAA,EAAA,CAAA;AACA,GAAG,CAAC,OAAO,CAAC,EAAE;AACd,IAAI,MAAG,IAAA,KAAA,CAAA,CAAA,2BAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA;AACP,GAAG;AACH,CAAC,EAAE;AACS,MAAC,cAAc,GAAG,CAAC,MAAM,KAAK,OAAO,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,aAAa;AAC7E,EAAE,IAAI;AACN,IAAI,MAAM,cAAK,GAAA,MAAA,iBAAA,CAAA,MAAA,CAAA,iBAAA,CAAA,CAAA;AACf,IAAI,OAAO,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,cAAc,CAAC;AACxC,GAAG,CAAC,OAAO,CAAC,EAAE;AACd,IAAG,OAAA,CAAA,KAAA,CAAA,gCAAA,CAAA,CAAA;AACH,IAAE,OAAA,KAAA,CAAA;;;;;;"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { RECHARGE_CDN_URL } from '../constants/api.js';
|
|
2
|
+
import { widgetSettingsMapper, productArrayMapper, productMapper } from '../mappers/cdn.js';
|
|
3
|
+
import { request } from '../utils/request.js';
|
|
4
|
+
import { getOptions } from '../utils/options.js';
|
|
5
|
+
|
|
6
|
+
var __async = (__this, __arguments, generator) => {
|
|
7
|
+
return new Promise((resolve, reject) => {
|
|
8
|
+
var fulfilled = (value) => {
|
|
9
|
+
try {
|
|
10
|
+
step(generator.next(value));
|
|
11
|
+
} catch (e) {
|
|
12
|
+
reject(e);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
var rejected = (value) => {
|
|
16
|
+
try {
|
|
17
|
+
step(generator.throw(value));
|
|
18
|
+
} catch (e) {
|
|
19
|
+
reject(e);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
23
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
const CDN_VERSION = "2020-12";
|
|
27
|
+
const DEFAULT_STORE_SETTINGS = {
|
|
28
|
+
store_currency: {
|
|
29
|
+
currency_code: "USD",
|
|
30
|
+
currency_symbol: "$",
|
|
31
|
+
decimal_separator: ".",
|
|
32
|
+
thousands_separator: ",",
|
|
33
|
+
currency_symbol_location: "left"
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const promiseCache = /* @__PURE__ */ new Map();
|
|
37
|
+
function cacheRequest(cacheKey, request2) {
|
|
38
|
+
if (!promiseCache.has(cacheKey)) {
|
|
39
|
+
promiseCache.set(cacheKey, request2());
|
|
40
|
+
}
|
|
41
|
+
return promiseCache.get(cacheKey);
|
|
42
|
+
}
|
|
43
|
+
const getProduct = (externalProductId) => __async(void 0, null, function* () {
|
|
44
|
+
const opts = getOptions();
|
|
45
|
+
const { product } = yield cacheRequest(`product.${externalProductId}`, () => request("get", `${RECHARGE_CDN_URL(opts.environment)}/store/${opts.storeIdentifier}/product/${CDN_VERSION}/${externalProductId}.json`));
|
|
46
|
+
return productMapper(product);
|
|
47
|
+
});
|
|
48
|
+
const getStoreSettings = () => __async(void 0, null, function* () {
|
|
49
|
+
const opts = getOptions();
|
|
50
|
+
const storeSettings = yield cacheRequest("storeSettings", () => request("get", `${RECHARGE_CDN_URL(opts.environment)}/store/${opts.storeIdentifier}/${CDN_VERSION}/store_settings.json`).catch(() => {
|
|
51
|
+
return DEFAULT_STORE_SETTINGS;
|
|
52
|
+
}));
|
|
53
|
+
return storeSettings;
|
|
54
|
+
});
|
|
55
|
+
const getWidgetSettings = () => __async(void 0, null, function* () {
|
|
56
|
+
const opts = getOptions();
|
|
57
|
+
const { widget_settings } = yield cacheRequest("widgetSettings", () => request("get", `${RECHARGE_CDN_URL(opts.environment)}/store/${opts.storeIdentifier}/${CDN_VERSION}/widget_settings.json`));
|
|
58
|
+
const widgetSettings = widgetSettingsMapper(widget_settings);
|
|
59
|
+
return widgetSettings;
|
|
60
|
+
});
|
|
61
|
+
const getProductsAndSettings = () => __async(void 0, null, function* () {
|
|
62
|
+
const opts = getOptions();
|
|
63
|
+
const { products, widget_settings, store_settings, meta } = yield cacheRequest("productsAndSettings", () => request("get", `${RECHARGE_CDN_URL(opts.environment)}/store/${opts.storeIdentifier}/product/${CDN_VERSION}/products.json`));
|
|
64
|
+
if ((meta == null ? void 0 : meta.status) === "error") {
|
|
65
|
+
return Promise.reject(meta.message);
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
products: productArrayMapper(products),
|
|
69
|
+
widget_settings: widgetSettingsMapper(widget_settings),
|
|
70
|
+
store_settings
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
const getProducts = () => __async(void 0, null, function* () {
|
|
74
|
+
const { products } = yield getProductsAndSettings();
|
|
75
|
+
return products;
|
|
76
|
+
});
|
|
77
|
+
const getProductAndSettings = (externalProductId) => __async(void 0, null, function* () {
|
|
78
|
+
const [product, store_settings, widget_settings] = yield Promise.all([
|
|
79
|
+
getProduct(externalProductId),
|
|
80
|
+
getStoreSettings(),
|
|
81
|
+
getWidgetSettings()
|
|
82
|
+
]);
|
|
83
|
+
return {
|
|
84
|
+
product,
|
|
85
|
+
store_settings,
|
|
86
|
+
widget_settings,
|
|
87
|
+
storeSettings: store_settings,
|
|
88
|
+
widgetSettings: widget_settings
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
const getBundleSettings = (externalProductId) => __async(void 0, null, function* () {
|
|
92
|
+
const { bundle_product } = yield getProduct(externalProductId);
|
|
93
|
+
return bundle_product;
|
|
94
|
+
});
|
|
95
|
+
const resetCache = () => Array.from(promiseCache.keys()).forEach((key) => promiseCache.delete(key));
|
|
96
|
+
|
|
97
|
+
export { getBundleSettings, getProduct, getProductAndSettings, getProducts, getProductsAndSettings, getStoreSettings, getWidgetSettings, resetCache };
|
|
98
|
+
//# sourceMappingURL=cdn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cdn.js","sources":["../../../src/api/cdn.ts"],"sourcesContent":["import { RECHARGE_CDN_URL } from '../constants/api';\nimport {\n CDNWidgetSettings,\n CDNStoreSettings,\n CDNWidgetSettingsResource,\n CDNProductsAndSettings,\n CDNProductResource,\n CDNProduct,\n CDNProductAndSettings,\n CDNProductsAndSettingsResource,\n CDNBundleSettings,\n CDNProductKeyObject,\n} from '../types';\nimport { productArrayMapper, productMapper, widgetSettingsMapper } from '../mappers/cdn';\nimport { request } from '../utils/request';\nimport { getOptions } from '../utils/options';\n\nconst CDN_VERSION = '2020-12';\n\n// Default store settings if none are provided from the cdn\nconst DEFAULT_STORE_SETTINGS: CDNStoreSettings = {\n store_currency: {\n currency_code: 'USD',\n currency_symbol: '$',\n decimal_separator: '.',\n thousands_separator: ',',\n currency_symbol_location: 'left',\n },\n};\n\nconst promiseCache = new Map();\n\n// This will cache the request and use the same promise anywhere we call this function. This will never make multiple calls and always return the first request\nfunction cacheRequest<T>(cacheKey: string, request: () => T): T {\n if (!promiseCache.has(cacheKey)) {\n promiseCache.set(cacheKey, request());\n }\n return promiseCache.get(cacheKey);\n}\n\nexport const getProduct = async (externalProductId: string | number): Promise<CDNProduct> => {\n const opts = getOptions();\n const { product } = await cacheRequest(`product.${externalProductId}`, () =>\n request<CDNProductResource>(\n 'get',\n `${RECHARGE_CDN_URL(opts.environment)}/store/${\n opts.storeIdentifier\n }/product/${CDN_VERSION}/${externalProductId}.json`\n )\n );\n\n return productMapper(product);\n};\n\nexport const getStoreSettings = async (): Promise<CDNStoreSettings> => {\n const opts = getOptions();\n const storeSettings = await cacheRequest('storeSettings', () =>\n request<CDNStoreSettings>(\n 'get',\n `${RECHARGE_CDN_URL(opts.environment)}/store/${opts.storeIdentifier}/${CDN_VERSION}/store_settings.json`\n ).catch(() => {\n return DEFAULT_STORE_SETTINGS;\n })\n );\n return storeSettings;\n};\n\nexport const getWidgetSettings = async (): Promise<CDNWidgetSettings> => {\n const opts = getOptions();\n const { widget_settings } = await cacheRequest('widgetSettings', () =>\n request<CDNWidgetSettingsResource>(\n 'get',\n `${RECHARGE_CDN_URL(opts.environment)}/store/${opts.storeIdentifier}/${CDN_VERSION}/widget_settings.json`\n )\n );\n\n const widgetSettings = widgetSettingsMapper(widget_settings);\n\n return widgetSettings;\n};\n\nexport const getProductsAndSettings = async (): Promise<CDNProductsAndSettings> => {\n const opts = getOptions();\n const { products, widget_settings, store_settings, meta } = await cacheRequest('productsAndSettings', () =>\n request<CDNProductsAndSettingsResource>(\n 'get',\n `${RECHARGE_CDN_URL(opts.environment)}/store/${opts.storeIdentifier}/product/${CDN_VERSION}/products.json`\n )\n );\n\n if (meta?.status === 'error') {\n return Promise.reject(meta.message);\n }\n\n return {\n products: productArrayMapper(products),\n widget_settings: widgetSettingsMapper(widget_settings),\n store_settings,\n };\n};\n\nexport const getProducts = async (): Promise<CDNProductKeyObject[]> => {\n const { products } = await getProductsAndSettings();\n return products;\n};\n\nexport const getProductAndSettings = async (externalProductId: string | number): Promise<CDNProductAndSettings> => {\n const [product, store_settings, widget_settings] = await Promise.all([\n getProduct(externalProductId),\n getStoreSettings(),\n getWidgetSettings(),\n ]);\n\n return {\n product,\n store_settings,\n widget_settings,\n storeSettings: store_settings,\n widgetSettings: widget_settings,\n };\n};\n\nexport const getBundleSettings = async (\n externalProductId: string | number\n): Promise<CDNBundleSettings | null | undefined> => {\n const { bundle_product } = await getProduct(externalProductId);\n\n return bundle_product;\n};\n\nexport const resetCache = () => Array.from(promiseCache.keys()).forEach(key => promiseCache.delete(key));\n"],"names":[],"mappings":";;;;;AAAA,IAAI,OAAO,GAAG,CAAC,MAAM,EAAE,WAAW,EAAE,SAAS,KAAK;AAClD,EAAE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK;AAC1C,IAAI,IAAI,SAAS,GAAG,CAAC,KAAK,KAAK;AAC/B,MAAM,IAAI;AACV,QAAQ,IAAI,CAAC,SAAS,CAAC,I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AAK,CAAC,EAAE,IAAI,EAAE,aAAa;AACpE,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,sBAAsB,EAAE,CAAC;AACtD,EAAE,OAAO,QAAQ,CAAC;AAClB,CAAC,EAAE;AACS,MAAC,qBAAqB,GAAG,CAAC,iBAAiB,KAAK,OAAO,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,aAAa;AAC/F,EAAE,MAAM,CAAC,OAAO,EAAE,cAAc,EAAE,eAAe,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;AACvE,IAAI,UAAU,CAAC,iBAAiB,CAAC;AACjC,IAAI,gBAAgB,EAAE;AACtB,IAAI,iBAAiB,EAAE;AACvB,GAAG,CAAC,CAAC;AACL,EAAE,OAAO;AACT,IAAI,OAAO;AACX,IAAI,cAAc;AAClB,IAAI,eAAe;AACnB,IAAI,aAAa,EAAE,cAAc;AACjC,IAAI,cAAc,EAAE,eAAe;AACnC,GAAG,CAAC;AACJ,CAAC,EAAE;AACS,MAAC,iBAAiB,GAAG,CAAC,iBAAiB,KAAK,OAAO,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,aAAa;AAC3F,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,UAAU,CAAC,iBAAiB,CAAC,CAAC;AACjE,EAAE,OAAO,cAAc,CAAC;AACxB,CAAC,EAAE;AACS,MAAC,UAAU,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,KAAK,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sources":["../../../src/constants/api.ts"],"sourcesContent":["export const RECHARGE_API_URL = (environment: 'stage' | 'prod'): string =>\n environment === 'stage' ? 'https://api.stage.rechargeapps.com' : 'https://api.rechargeapps.com';\nexport const RECHARGE_CDN_URL = (environment: 'stage' | 'prod'): string =>\n environment === 'stage' ? 'https://static.stage.rechargecdn.com' : 'https://static.rechargecdn.com';\n"],"names":[],"mappings":"AACY,MAAC,gBAAgB,GAAG,CAAC,WAAW,KAAK,WAAW,KAAK,OAAO,GAAG,sCAAsC,GAAG;;;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { getBundleSettings, getProduct, getProductAndSettings, getProducts, getProductsAndSettings, getStoreSettings, getWidgetSettings, resetCache } from './api/cdn.js';
|
|
2
|
+
export { getBundleId, validateBundle } from './api/bundle.js';
|
|
3
|
+
export { api, initRecharge } from './utils/init.js';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import omit from 'lodash/omit';
|
|
2
|
+
import { parseValues } from './utils.js';
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __defProps = Object.defineProperties;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
function widgetSettingsMapper(widgetSettingsRaw) {
|
|
24
|
+
var _a;
|
|
25
|
+
const parsedSettings = parseValues(widgetSettingsRaw);
|
|
26
|
+
const auto_inject = parsedSettings.auto_inject === void 0 ? true : parsedSettings.auto_inject;
|
|
27
|
+
const valid_pages = (_a = parsedSettings.display_on) != null ? _a : [];
|
|
28
|
+
const is_subscription_first = parsedSettings.first_option === "autodeliver";
|
|
29
|
+
return __spreadProps(__spreadValues({}, omit(parsedSettings, ["display_on", "first_option"])), {
|
|
30
|
+
auto_inject,
|
|
31
|
+
valid_pages,
|
|
32
|
+
is_subscription_first,
|
|
33
|
+
autoInject: auto_inject,
|
|
34
|
+
validPages: valid_pages,
|
|
35
|
+
isSubscriptionFirst: is_subscription_first
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function productMapper(productRaw) {
|
|
39
|
+
var _a;
|
|
40
|
+
const is_subscription_only = ((_a = productRaw.subscription_options) == null ? void 0 : _a.storefront_purchase_options) === "subscription_only";
|
|
41
|
+
return __spreadProps(__spreadValues({}, productRaw), {
|
|
42
|
+
is_subscription_only,
|
|
43
|
+
isSubscriptionOnly: is_subscription_only
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function productArrayMapper(productsArray) {
|
|
47
|
+
return productsArray.map((productObjRaw) => {
|
|
48
|
+
const productObj = {};
|
|
49
|
+
Object.entries(productObjRaw).forEach(([key, value]) => {
|
|
50
|
+
productObj[key] = productMapper(value);
|
|
51
|
+
});
|
|
52
|
+
return productObj;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { productArrayMapper, productMapper, widgetSettingsMapper };
|
|
57
|
+
//# sourceMappingURL=cdn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cdn.js","sources":["../../../src/mappers/cdn.ts"],"sourcesContent":["import omit from 'lodash/omit';\nimport {\n CDNBaseWidgetSettings,\n CDNProductRaw,\n CDNWidgetSettings,\n CDNWidgetSettingsRaw,\n CDNProduct,\n CDNProductKeyObject,\n} from '../types';\nimport { parseValues } from './utils';\n\nexport function widgetSettingsMapper(widgetSettingsRaw: CDNWidgetSettingsRaw): CDNWidgetSettings {\n const parsedSettings = parseValues<CDNBaseWidgetSettings>(widgetSettingsRaw);\n\n const auto_inject = parsedSettings.auto_inject === undefined ? true : parsedSettings.auto_inject;\n const valid_pages = parsedSettings.display_on ?? [];\n const is_subscription_first = parsedSettings.first_option === 'autodeliver';\n\n return {\n ...omit(parsedSettings, ['display_on', 'first_option']),\n auto_inject,\n valid_pages,\n is_subscription_first,\n autoInject: auto_inject,\n validPages: valid_pages,\n isSubscriptionFirst: is_subscription_first,\n };\n}\n\nexport function productMapper(productRaw: CDNProductRaw): CDNProduct {\n const is_subscription_only = productRaw.subscription_options?.storefront_purchase_options === 'subscription_only';\n return {\n ...productRaw,\n is_subscription_only,\n isSubscriptionOnly: is_subscription_only,\n };\n}\n\nexport function productArrayMapper(\n productsArray: {\n [key: string]: CDNProductRaw;\n }[]\n): CDNProductKeyObject[] {\n return productsArray.map(productObjRaw => {\n const productObj: CDNProductKeyObject = {};\n Object.entries(productObjRaw).forEach(([key, value]) => {\n productObj[key] = productMapper(value);\n });\n return productObj;\n });\n}\n"],"names":[],"mappings":";;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACzC,IAAI,iBAAiB,GAAG,MAAM,CAAC,yBAAyB,CAAC;AACzD,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG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;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
function parseValue(value) {
|
|
21
|
+
try {
|
|
22
|
+
return JSON.parse(value);
|
|
23
|
+
} catch (e) {
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function parseValues(json) {
|
|
28
|
+
return Object.entries(json).reduce((memo, [key, value]) => {
|
|
29
|
+
return __spreadProps(__spreadValues({}, memo), { [key]: parseValue(value) });
|
|
30
|
+
}, {});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { parseValues };
|
|
34
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../src/mappers/utils.ts"],"sourcesContent":["/** Trys to parse passed in value. If it doesn't work returns the same passed in value */\nfunction parseValue(value: unknown): any {\n try {\n return JSON.parse(value as string);\n } catch {\n return value;\n }\n}\n\n/** Returns a new object that updates \"string\" values into their correct data type. */\nexport function parseValues<T = any>(json: Record<string, unknown>): T {\n return Object.entries(json).reduce((memo, [key, value]) => {\n return { ...memo, [key]: parseValue(value) };\n }, {}) as T;\n}\n"],"names":[],"mappings":"AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;AACzC,IAAI,iBAAiB,GAAG,MAAM,CAAC,yBAAyB,CAAC;AACzD,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAChK,IAAI,cAAc,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK;AAC/B,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAChC,IAAI,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC;AAClC,MAAM,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACxC,EAAE,IAAI,mBAAmB;AACzB,IAAI,KAAK,IAAI,IAAI,IAAI,mBAAmB,CAAC,CAAC,CAAC,EAAE;AAC7C,MAAM,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC;AACpC,QAAQ,eAAe,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAC1C,KAAK;AACL,EAAE,OAAO,CAAC,CAAC;AACX,CAAC,CAAC;AACF,IAAI,aAAa,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,UAAU,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;AAClE,SAAS,UAAU,CAAC,KAAK,EAAE;AAC3B,EAAE,IAAI;AACN,IAAI,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAC7B,GAAG,CAAC,OAAO,CAAC,EAAE;AACd,IAAI,OAAO,KAAK,CAAC;AACjB,GAAG;AACH,CAAC;AACM,SAAS,WAAW,CAAC,IAAI,EAAE;AAClC,EAAE,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK;AAC7D,IAAI,OAAO,aAAa,CAAC,cAAc,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AACjF,GAAG,EAAE,EAAE,CAAC,CAAC;AACT;;;;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { resetCache } from '../api/cdn.js';
|
|
2
|
+
import { setOptions } from './options.js';
|
|
3
|
+
import { request } from './request.js';
|
|
4
|
+
|
|
5
|
+
const api = {
|
|
6
|
+
get(url, requestOptions) {
|
|
7
|
+
return request("get", url, requestOptions);
|
|
8
|
+
},
|
|
9
|
+
post(url, requestOptions) {
|
|
10
|
+
return request("post", url, requestOptions);
|
|
11
|
+
},
|
|
12
|
+
put(url, requestOptions) {
|
|
13
|
+
return request("put", url, requestOptions);
|
|
14
|
+
},
|
|
15
|
+
delete(url, requestOptions) {
|
|
16
|
+
return request("delete", url, requestOptions);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
function initRecharge(opt) {
|
|
20
|
+
setOptions({
|
|
21
|
+
storeIdentifier: opt.storeIdentifier,
|
|
22
|
+
environment: opt.environment ? opt.environment : "prod"
|
|
23
|
+
});
|
|
24
|
+
resetCache();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { api, initRecharge };
|
|
28
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sources":["../../../src/utils/init.ts"],"sourcesContent":["import { resetCache } from '../api/cdn';\nimport { StorefrontOptions, CRUDRequestOptions, GetRequestOptions } from '../types';\nimport { setOptions } from './options';\nimport { request } from './request';\n\nexport interface InitOptions extends Omit<StorefrontOptions, 'environment'> {\n /** This is only for internal use. Sets the environment where data is fetched from. */\n environment?: StorefrontOptions['environment'];\n}\n\nexport const api = {\n get<T>(url: string, requestOptions?: GetRequestOptions): Promise<T> {\n return request<T>('get', url, requestOptions);\n },\n post<T>(url: string, requestOptions?: CRUDRequestOptions): Promise<T> {\n return request<T>('post', url, requestOptions);\n },\n put<T>(url: string, requestOptions?: CRUDRequestOptions): Promise<T> {\n return request<T>('put', url, requestOptions);\n },\n delete<T>(url: string, requestOptions?: CRUDRequestOptions): Promise<T> {\n return request<T>('delete', url, requestOptions);\n },\n};\n\nexport function initRecharge(opt: InitOptions) {\n setOptions({\n storeIdentifier: opt.storeIdentifier,\n environment: opt.environment ? opt.environment : 'prod',\n });\n\n // When init is called again, reset the cache to make sure we don't have the old cache around\n resetCache();\n}\n"],"names":[],"mappings":";;;;AAGY,MAAC,GAAG,GAAG;AACnB,EAAE,GAAG,CAAC,GAAG,EAAE,cAAc,EAAE;AAC3B,IAAI,OAAO,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,cAAc,CAAC,CAAC;AAC/C,GAAG;AACH,EAAE,IAAI,CAAC,GAAG,EAAE,cAAc,EAAE;AAC5B,IAAI,OAAO,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,cAAc,CAAC,CAAC;AAChD,GAAG;AACH,EAAE,GAAG,CAAC,GAAG,EAAE,cAAc,EAAE;AAC3B,IAAI,OAAO,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,cAAc,CAAC,CAAC;AAC/C,GAAG;AACH,EAAE,MAAM,CAAC,GAAG,EAAE,cAAc,EAAE;AAC9B,IAAI,OAAO,OAAO,CAAC,QAAQ,EAAE,GAAG,EAAE,cAAc,CAAC,CAAC;AAClD,GAAG;AACH,EAAE;AACK,SAAS,YAAY,CAAC,GAAG,EAAE;AAClC,EAAE,UAAU,CAAC;AACb,IAAI,eAAe,EAAE,GAAG,CAAC,eAAe;AACxC,IAAI,WAAW,EAAE,GAAG,CAAC,WAAW,GAAG,GAAG,CAAC,WAAW,GAAG,MAAM;AAC3D,GAAG,CAAC,CAAC;AACL,EAAE,UAAU,EAAE,CAAC;AACf;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sources":["../../../src/utils/options.ts"],"sourcesContent":["import { StorefrontOptions } from '../types';\n\nlet options: StorefrontOptions = {\n storeIdentifier: '',\n environment: 'prod',\n};\n\nexport function setOptions(opts: StorefrontOptions) {\n options = opts;\n}\n\nexport function getOptions() {\n return options;\n}\n"],"names":[],"mappings":"AAAA,IAAI,OAAO,GAAG;AACd,EAAE,eAAe,EAAE,EAAE;AACrB,EAAE,WAAW,EAAE,MAAM;AACrB,CAAC,CAAC;AACK,SAAS,UAAU,CAAC,IAAI,EAAE;AACjC,EAAE,OAAO,GAAG,IAAI,CAAC;AACjB,CAAC;AACM,SAAS,UAAU,GAAG;AAC7B,EAAE,OAAO,OAAO,CAAC;AACjB;;;;"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import 'isomorphic-fetch';
|
|
2
|
+
import { stringify } from 'qs';
|
|
3
|
+
import trimStart from 'lodash/trimStart';
|
|
4
|
+
import trimEnd from 'lodash/trimEnd';
|
|
5
|
+
|
|
6
|
+
var __defProp = Object.defineProperty;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __async = (__this, __arguments, generator) => {
|
|
23
|
+
return new Promise((resolve, reject) => {
|
|
24
|
+
var fulfilled = (value) => {
|
|
25
|
+
try {
|
|
26
|
+
step(generator.next(value));
|
|
27
|
+
} catch (e) {
|
|
28
|
+
reject(e);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
var rejected = (value) => {
|
|
32
|
+
try {
|
|
33
|
+
step(generator.throw(value));
|
|
34
|
+
} catch (e) {
|
|
35
|
+
reject(e);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
39
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
function stringifyQuery(str) {
|
|
43
|
+
return stringify(str, {
|
|
44
|
+
encode: false,
|
|
45
|
+
indices: false,
|
|
46
|
+
arrayFormat: "comma"
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function request(_0, _1) {
|
|
50
|
+
return __async(this, arguments, function* (method, url, { id, query, data, headers } = {}) {
|
|
51
|
+
let reqUrl = url;
|
|
52
|
+
if (id) {
|
|
53
|
+
reqUrl = [trimEnd(url), trimStart(id)].join("/");
|
|
54
|
+
}
|
|
55
|
+
let reqBody;
|
|
56
|
+
if (method === "get") {
|
|
57
|
+
let exQuery;
|
|
58
|
+
[reqUrl, exQuery] = reqUrl.split("?");
|
|
59
|
+
const fullQuery = [exQuery, stringifyQuery(query)].join("&").replace(/^&/, "");
|
|
60
|
+
reqUrl = `${reqUrl}${fullQuery ? `?${fullQuery}` : ""}`;
|
|
61
|
+
} else {
|
|
62
|
+
reqBody = JSON.stringify(data);
|
|
63
|
+
}
|
|
64
|
+
const reqHeaders = __spreadValues({
|
|
65
|
+
Accept: "application/json"
|
|
66
|
+
}, headers ? headers : {});
|
|
67
|
+
const response = yield fetch(reqUrl, {
|
|
68
|
+
method,
|
|
69
|
+
headers: reqHeaders,
|
|
70
|
+
body: reqBody,
|
|
71
|
+
mode: "cors"
|
|
72
|
+
});
|
|
73
|
+
const result = yield response.json();
|
|
74
|
+
if (!response.ok) {
|
|
75
|
+
if (result && result.error) {
|
|
76
|
+
throw new Error(`${response.status}: ${result.error}`);
|
|
77
|
+
} else {
|
|
78
|
+
throw new Error("A connection error occurred while making the request");
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return result;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export { request };
|
|
86
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.js","sources":["../../../src/utils/request.ts"],"sourcesContent":["import 'isomorphic-fetch';\n\nimport { stringify } from 'qs';\nimport trimStart from 'lodash/trimStart';\nimport trimEnd from 'lodash/trimEnd';\n\nimport { Method, RequestHeaders, RequestOptions } from '../types';\n\nfunction stringifyQuery(str: unknown): string {\n return stringify(str, {\n encode: false,\n indices: false,\n arrayFormat: 'comma',\n });\n}\n\nexport async function request<T>(\n method: Method,\n url: string,\n { id, query, data, headers }: RequestOptions = {}\n): Promise<T> {\n let reqUrl = url;\n\n if (id) {\n reqUrl = [trimEnd(url), trimStart(id as string)].join('/');\n }\n\n let reqBody;\n if (method === 'get') {\n let exQuery;\n [reqUrl, exQuery] = reqUrl.split('?');\n const fullQuery = [exQuery, stringifyQuery(query)].join('&').replace(/^&/, '');\n reqUrl = `${reqUrl}${fullQuery ? `?${fullQuery}` : ''}`;\n } else {\n reqBody = JSON.stringify(data);\n }\n\n const reqHeaders: RequestHeaders = {\n Accept: 'application/json',\n // 'Content-Type': 'application/json',\n // 'X-Recharge-App': 'storefront-client',\n ...(headers ? headers : {}),\n };\n\n const response = await fetch(reqUrl, {\n method,\n headers: reqHeaders,\n body: reqBody,\n mode: 'cors',\n });\n\n const result = await response.json();\n\n if (!response.ok) {\n if (result && result.error) {\n throw new Error(`${response.status}: ${result.error}`);\n } else {\n throw new Error('A connection error occurred while making the request');\n }\n }\n\n return result as T;\n}\n"],"names":[],"mappings":";;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC;AACvD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;AACnD,IAAI,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAAC;AACzD,IAAI,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,KAAK,GAAG,IAAI,GAAG,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAChK,IAAI,cAAc,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK;AAC/B,EAAE,KAA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