addio-ecomm-sdk 1.3.74 → 1.3.76
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/.vscode/settings.json +34 -34
- package/README.md +79 -79
- package/dist/index.d.ts +203 -202
- package/dist/index.js +1818 -1818
- package/dist/index.js.map +1 -1
- package/dist/lib/constants/components/CreditCardInput.d.ts +11 -11
- package/dist/lib/constants/components/CreditCardInput.js +79 -79
- package/dist/lib/constants/components/Snackbar.d.ts +11 -11
- package/dist/lib/constants/components/Snackbar.js +39 -39
- package/dist/lib/constants/contexts/CartContext/CartContextProvider.d.ts +7 -7
- package/dist/lib/constants/contexts/CartContext/CartContextProvider.js +980 -980
- package/dist/lib/constants/contexts/CartContext/index.d.ts +79 -79
- package/dist/lib/constants/contexts/CartContext/index.js +127 -127
- package/dist/lib/constants/contexts/DataContext/DataContextProvider.d.ts +15 -15
- package/dist/lib/constants/contexts/DataContext/DataContextProvider.js +304 -304
- package/dist/lib/constants/contexts/DataContext/index.d.ts +47 -47
- package/dist/lib/constants/contexts/DataContext/index.js +67 -67
- package/dist/lib/constants/contexts/LogContext/LogContextProvider.d.ts +6 -6
- package/dist/lib/constants/contexts/LogContext/LogContextProvider.js +103 -103
- package/dist/lib/constants/contexts/LogContext/index.d.ts +7 -7
- package/dist/lib/constants/contexts/LogContext/index.js +45 -45
- package/dist/lib/constants/contexts/ModalContext/ModalContextProvider.d.ts +7 -7
- package/dist/lib/constants/contexts/ModalContext/ModalContextProvider.js +76 -76
- package/dist/lib/constants/contexts/ModalContext/index.d.ts +14 -14
- package/dist/lib/constants/contexts/ModalContext/index.js +18 -18
- package/dist/lib/constants/contexts/SDKContext/SDKProvider.d.ts +8 -8
- package/dist/lib/constants/contexts/SDKContext/SDKProvider.js +79 -79
- package/dist/lib/constants/contexts/SDKContext/index.d.ts +4 -4
- package/dist/lib/constants/contexts/SDKContext/index.js +4 -4
- package/dist/lib/constants/contexts/SnackbarContext/SnackbarContext.d.ts +4 -4
- package/dist/lib/constants/contexts/SnackbarContext/SnackbarContext.js +6 -6
- package/dist/lib/constants/contexts/SnackbarContext/SnackbarContextProvider.d.ts +12 -12
- package/dist/lib/constants/contexts/SnackbarContext/SnackbarContextProvider.js +52 -52
- package/dist/lib/constants/contexts/SnackbarContext/interfaces/ISnackbarContext.d.ts +17 -17
- package/dist/lib/constants/contexts/SnackbarContext/interfaces/ISnackbarContext.js +21 -21
- package/dist/lib/constants/contexts/StockNotifContext/StockNotifContextProvider.d.ts +7 -7
- package/dist/lib/constants/contexts/StockNotifContext/StockNotifContextProvider.js +179 -179
- package/dist/lib/constants/contexts/StockNotifContext/index.d.ts +10 -10
- package/dist/lib/constants/contexts/StockNotifContext/index.js +10 -10
- package/dist/lib/constants/contexts/UserContext/UserContextProvider.d.ts +5 -5
- package/dist/lib/constants/contexts/UserContext/UserContextProvider.js +470 -470
- package/dist/lib/constants/contexts/UserContext/index.d.ts +54 -54
- package/dist/lib/constants/contexts/UserContext/index.js +82 -82
- package/dist/lib/constants/contexts/WishlistContext/WishlistContextProvider.d.ts +6 -6
- package/dist/lib/constants/contexts/WishlistContext/WishlistContextProvider.js +327 -327
- package/dist/lib/constants/contexts/WishlistContext/index.d.ts +12 -12
- package/dist/lib/constants/contexts/WishlistContext/index.js +12 -12
- package/dist/lib/constants/hooks/useCart.d.ts +2 -2
- package/dist/lib/constants/hooks/useCart.js +11 -11
- package/dist/lib/constants/hooks/useData.d.ts +2 -2
- package/dist/lib/constants/hooks/useData.js +11 -11
- package/dist/lib/constants/hooks/useLogs.d.ts +2 -2
- package/dist/lib/constants/hooks/useLogs.js +11 -11
- package/dist/lib/constants/hooks/useModal.d.ts +2 -2
- package/dist/lib/constants/hooks/useModal.js +11 -11
- package/dist/lib/constants/hooks/useSDK.d.ts +2 -2
- package/dist/lib/constants/hooks/useSDK.js +11 -11
- package/dist/lib/constants/hooks/useSnackbar.d.ts +2 -2
- package/dist/lib/constants/hooks/useSnackbar.js +11 -11
- package/dist/lib/constants/hooks/useStockNotif.d.ts +2 -2
- package/dist/lib/constants/hooks/useStockNotif.js +11 -11
- package/dist/lib/constants/hooks/useUser.d.ts +2 -2
- package/dist/lib/constants/hooks/useUser.js +11 -11
- package/dist/lib/constants/hooks/useWishlist.d.ts +2 -2
- package/dist/lib/constants/hooks/useWishlist.js +11 -11
- package/dist/lib/models/image/index.d.ts +6 -6
- package/dist/lib/models/image/index.js +15 -15
- package/dist/lib/models/stockNotification/index.d.ts +13 -13
- package/dist/lib/models/stockNotification/index.js +130 -130
- package/dist/lib/models/wishlist/index.d.ts +14 -14
- package/dist/lib/models/wishlist/index.js +155 -155
- package/dist/utils/StripeErrors.d.ts +24 -24
- package/dist/utils/StripeErrors.js +55 -55
- package/dist/utils/algolia.d.ts +3 -3
- package/dist/utils/algolia.js +81 -81
- package/dist/utils/analytics.d.ts +71 -71
- package/dist/utils/analytics.js +257 -257
- package/dist/utils/cart.d.ts +3 -3
- package/dist/utils/cart.js +66 -66
- package/dist/utils/contentful.d.ts +10 -10
- package/dist/utils/contentful.js +136 -136
- package/dist/utils/functions.d.ts +21 -21
- package/dist/utils/functions.js +200 -200
- package/dist/utils/getSDK.d.ts +4 -4
- package/dist/utils/getSDK.js +77 -77
- package/dist/utils/initStoreData.d.ts +3 -3
- package/dist/utils/initStoreData.js +62 -62
- package/dist/utils/interfaces/IClientCMSData.d.ts +132 -132
- package/dist/utils/interfaces/IClientCMSData.js +2 -2
- package/dist/utils/interfaces/IEndpointResult.d.ts +10 -10
- package/dist/utils/interfaces/IEndpointResult.js +2 -2
- package/dist/utils/interfaces/IFacebookUserProfile.d.ts +10 -10
- package/dist/utils/interfaces/IFacebookUserProfile.js +2 -2
- package/dist/utils/interfaces/IFilter.d.ts +23 -23
- package/dist/utils/interfaces/IFilter.js +2 -2
- package/dist/utils/interfaces/IGoogleUserProfile.d.ts +7 -7
- package/dist/utils/interfaces/IGoogleUserProfile.js +2 -2
- package/dist/utils/interfaces/ISDKConfig.d.ts +7 -7
- package/dist/utils/interfaces/ISDKConfig.js +2 -2
- package/dist/utils/interfaces/ISpaceData.d.ts +18 -18
- package/dist/utils/interfaces/ISpaceData.js +2 -2
- package/dist/utils/larivieremeunier.d.ts +3 -3
- package/dist/utils/larivieremeunier.js +156 -156
- package/dist/utils/technosupply.d.ts +3 -3
- package/dist/utils/technosupply.js +155 -155
- package/package.json +61 -61
- package/publish.sh +132 -132
package/dist/utils/cart.js
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPromoCodeError = exports.getPriceByCurrency = void 0;
|
|
4
|
-
var Cart_1 = require("addio-admin-sdk/dist/Interfaces/Cart");
|
|
5
|
-
var errors_1 = require("addio-admin-sdk/dist/utils/errors");
|
|
6
|
-
var functions_1 = require("./functions");
|
|
7
|
-
var getPriceByCurrency = function (prices, currencyTo) {
|
|
8
|
-
if (typeof prices === 'number')
|
|
9
|
-
return {
|
|
10
|
-
amount: prices,
|
|
11
|
-
currency: currencyTo || 'CAD',
|
|
12
|
-
exchange_from: 'CAD',
|
|
13
|
-
exchange_rate: 1,
|
|
14
|
-
exchange_rate_date: new Date()
|
|
15
|
-
};
|
|
16
|
-
if (!Array.isArray(prices)) {
|
|
17
|
-
if (!!prices.amount)
|
|
18
|
-
return {
|
|
19
|
-
amount: prices.amount,
|
|
20
|
-
currency: currencyTo || 'CAD',
|
|
21
|
-
exchange_from: 'CAD',
|
|
22
|
-
exchange_rate: 1,
|
|
23
|
-
exchange_rate_date: new Date()
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
var price = prices.find(function (a) { return a.currency === currencyTo; });
|
|
27
|
-
if (!!!price)
|
|
28
|
-
throw new Error("Product has'nt been set in that currency ".concat(currencyTo, ". Available currencies: ").concat(prices
|
|
29
|
-
.map(function (a) { return a.currency; })
|
|
30
|
-
.join(', ')));
|
|
31
|
-
return price;
|
|
32
|
-
};
|
|
33
|
-
exports.getPriceByCurrency = getPriceByCurrency;
|
|
34
|
-
var getPromoCodeError = function (errCode, locale) {
|
|
35
|
-
if (locale === void 0) { locale = 'fr'; }
|
|
36
|
-
var message = '';
|
|
37
|
-
switch (errCode) {
|
|
38
|
-
case Cart_1.CartErrorEnum.GENERAL_ERROR_USER:
|
|
39
|
-
message = (0, functions_1.getStringByLang)(errors_1.cartErrorMsgs.generalErrors.user, locale);
|
|
40
|
-
break;
|
|
41
|
-
case Cart_1.CartErrorEnum.PROMO_CODE_WRONG_CODE:
|
|
42
|
-
message = (0, functions_1.getStringByLang)(errors_1.cartErrorMsgs.promoCode.wrongCode, locale);
|
|
43
|
-
break;
|
|
44
|
-
case Cart_1.CartErrorEnum.PROMO_CODE_USED:
|
|
45
|
-
message = (0, functions_1.getStringByLang)(errors_1.cartErrorMsgs.promoCode.used, locale);
|
|
46
|
-
break;
|
|
47
|
-
case Cart_1.CartErrorEnum.PROMO_CODE_CART_ALREADY_DISCOUNTED:
|
|
48
|
-
message = (0, functions_1.getStringByLang)(errors_1.cartErrorMsgs.promoCode.alreadyDiscounted, locale);
|
|
49
|
-
break;
|
|
50
|
-
case Cart_1.CartErrorEnum.PROMO_CODE_NO_SHIPPING_SELECTED:
|
|
51
|
-
message = (0, functions_1.getStringByLang)(errors_1.cartErrorMsgs.promoCode.chooseShippingFirst, locale);
|
|
52
|
-
break;
|
|
53
|
-
case Cart_1.CartErrorEnum.PROMO_CODE_FREE_SHIPPING:
|
|
54
|
-
message = (0, functions_1.getStringByLang)(errors_1.cartErrorMsgs.freeShipping.excludedState, locale);
|
|
55
|
-
break;
|
|
56
|
-
case Cart_1.CartErrorEnum.PROMO_CODE_NOT_ELIGIBLE:
|
|
57
|
-
message = (0, functions_1.getStringByLang)(errors_1.cartErrorMsgs.promoCode.notEligible, locale);
|
|
58
|
-
break;
|
|
59
|
-
case Cart_1.CartErrorEnum.GENERAL_ERROR:
|
|
60
|
-
default:
|
|
61
|
-
message = (0, functions_1.getStringByLang)(errors_1.cartErrorMsgs.generalErrors.global, locale);
|
|
62
|
-
break;
|
|
63
|
-
}
|
|
64
|
-
return message;
|
|
65
|
-
};
|
|
66
|
-
exports.getPromoCodeError = getPromoCodeError;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPromoCodeError = exports.getPriceByCurrency = void 0;
|
|
4
|
+
var Cart_1 = require("addio-admin-sdk/dist/Interfaces/Cart");
|
|
5
|
+
var errors_1 = require("addio-admin-sdk/dist/utils/errors");
|
|
6
|
+
var functions_1 = require("./functions");
|
|
7
|
+
var getPriceByCurrency = function (prices, currencyTo) {
|
|
8
|
+
if (typeof prices === 'number')
|
|
9
|
+
return {
|
|
10
|
+
amount: prices,
|
|
11
|
+
currency: currencyTo || 'CAD',
|
|
12
|
+
exchange_from: 'CAD',
|
|
13
|
+
exchange_rate: 1,
|
|
14
|
+
exchange_rate_date: new Date()
|
|
15
|
+
};
|
|
16
|
+
if (!Array.isArray(prices)) {
|
|
17
|
+
if (!!prices.amount)
|
|
18
|
+
return {
|
|
19
|
+
amount: prices.amount,
|
|
20
|
+
currency: currencyTo || 'CAD',
|
|
21
|
+
exchange_from: 'CAD',
|
|
22
|
+
exchange_rate: 1,
|
|
23
|
+
exchange_rate_date: new Date()
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
var price = prices.find(function (a) { return a.currency === currencyTo; });
|
|
27
|
+
if (!!!price)
|
|
28
|
+
throw new Error("Product has'nt been set in that currency ".concat(currencyTo, ". Available currencies: ").concat(prices
|
|
29
|
+
.map(function (a) { return a.currency; })
|
|
30
|
+
.join(', ')));
|
|
31
|
+
return price;
|
|
32
|
+
};
|
|
33
|
+
exports.getPriceByCurrency = getPriceByCurrency;
|
|
34
|
+
var getPromoCodeError = function (errCode, locale) {
|
|
35
|
+
if (locale === void 0) { locale = 'fr'; }
|
|
36
|
+
var message = '';
|
|
37
|
+
switch (errCode) {
|
|
38
|
+
case Cart_1.CartErrorEnum.GENERAL_ERROR_USER:
|
|
39
|
+
message = (0, functions_1.getStringByLang)(errors_1.cartErrorMsgs.generalErrors.user, locale);
|
|
40
|
+
break;
|
|
41
|
+
case Cart_1.CartErrorEnum.PROMO_CODE_WRONG_CODE:
|
|
42
|
+
message = (0, functions_1.getStringByLang)(errors_1.cartErrorMsgs.promoCode.wrongCode, locale);
|
|
43
|
+
break;
|
|
44
|
+
case Cart_1.CartErrorEnum.PROMO_CODE_USED:
|
|
45
|
+
message = (0, functions_1.getStringByLang)(errors_1.cartErrorMsgs.promoCode.used, locale);
|
|
46
|
+
break;
|
|
47
|
+
case Cart_1.CartErrorEnum.PROMO_CODE_CART_ALREADY_DISCOUNTED:
|
|
48
|
+
message = (0, functions_1.getStringByLang)(errors_1.cartErrorMsgs.promoCode.alreadyDiscounted, locale);
|
|
49
|
+
break;
|
|
50
|
+
case Cart_1.CartErrorEnum.PROMO_CODE_NO_SHIPPING_SELECTED:
|
|
51
|
+
message = (0, functions_1.getStringByLang)(errors_1.cartErrorMsgs.promoCode.chooseShippingFirst, locale);
|
|
52
|
+
break;
|
|
53
|
+
case Cart_1.CartErrorEnum.PROMO_CODE_FREE_SHIPPING:
|
|
54
|
+
message = (0, functions_1.getStringByLang)(errors_1.cartErrorMsgs.freeShipping.excludedState, locale);
|
|
55
|
+
break;
|
|
56
|
+
case Cart_1.CartErrorEnum.PROMO_CODE_NOT_ELIGIBLE:
|
|
57
|
+
message = (0, functions_1.getStringByLang)(errors_1.cartErrorMsgs.promoCode.notEligible, locale);
|
|
58
|
+
break;
|
|
59
|
+
case Cart_1.CartErrorEnum.GENERAL_ERROR:
|
|
60
|
+
default:
|
|
61
|
+
message = (0, functions_1.getStringByLang)(errors_1.cartErrorMsgs.generalErrors.global, locale);
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
return message;
|
|
65
|
+
};
|
|
66
|
+
exports.getPromoCodeError = getPromoCodeError;
|
|
67
67
|
//# sourceMappingURL=cart.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import * as contentful from 'contentful';
|
|
2
|
-
export declare const client: (spaceID: string, accessToken: string) => contentful.ContentfulClientApi;
|
|
3
|
-
interface IContentFulResponse {
|
|
4
|
-
readonly valid: boolean;
|
|
5
|
-
readonly data?: contentful.Entry<any> | contentful.EntryCollection<unknown>;
|
|
6
|
-
readonly err?: any;
|
|
7
|
-
}
|
|
8
|
-
export declare const fetchContentWithId: (id: string, locale: string | undefined, spaceID: string | undefined, accessToken: string | undefined) => Promise<IContentFulResponse>;
|
|
9
|
-
export declare const fetchContentWithContentType: (content_type: string, locale: string | undefined, spaceID: string | undefined, accessToken: string | undefined, query?: string, value?: string) => Promise<IContentFulResponse>;
|
|
10
|
-
export {};
|
|
1
|
+
import * as contentful from 'contentful';
|
|
2
|
+
export declare const client: (spaceID: string, accessToken: string) => contentful.ContentfulClientApi;
|
|
3
|
+
interface IContentFulResponse {
|
|
4
|
+
readonly valid: boolean;
|
|
5
|
+
readonly data?: contentful.Entry<any> | contentful.EntryCollection<unknown>;
|
|
6
|
+
readonly err?: any;
|
|
7
|
+
}
|
|
8
|
+
export declare const fetchContentWithId: (id: string, locale: string | undefined, spaceID: string | undefined, accessToken: string | undefined) => Promise<IContentFulResponse>;
|
|
9
|
+
export declare const fetchContentWithContentType: (content_type: string, locale: string | undefined, spaceID: string | undefined, accessToken: string | undefined, query?: string, value?: string) => Promise<IContentFulResponse>;
|
|
10
|
+
export {};
|
package/dist/utils/contentful.js
CHANGED
|
@@ -1,137 +1,137 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}) : (function(o, m, k, k2) {
|
|
21
|
-
if (k2 === undefined) k2 = k;
|
|
22
|
-
o[k2] = m[k];
|
|
23
|
-
}));
|
|
24
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
-
}) : function(o, v) {
|
|
27
|
-
o["default"] = v;
|
|
28
|
-
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
-
if (mod && mod.__esModule) return mod;
|
|
31
|
-
var result = {};
|
|
32
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
-
__setModuleDefault(result, mod);
|
|
34
|
-
return result;
|
|
35
|
-
};
|
|
36
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
46
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
47
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
|
-
function step(op) {
|
|
50
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
52
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
53
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
|
-
switch (op[0]) {
|
|
55
|
-
case 0: case 1: t = op; break;
|
|
56
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
57
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
58
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
59
|
-
default:
|
|
60
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
61
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
62
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
63
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
64
|
-
if (t[2]) _.ops.pop();
|
|
65
|
-
_.trys.pop(); continue;
|
|
66
|
-
}
|
|
67
|
-
op = body.call(thisArg, _);
|
|
68
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
69
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
73
|
-
exports.fetchContentWithContentType = exports.fetchContentWithId = exports.client = void 0;
|
|
74
|
-
var contentful = __importStar(require("contentful"));
|
|
75
|
-
var host = 'cdn.contentful.com';
|
|
76
|
-
var client = function (spaceID, accessToken) {
|
|
77
|
-
return contentful.createClient({ space: spaceID, accessToken: accessToken, host: host });
|
|
78
|
-
};
|
|
79
|
-
exports.client = client;
|
|
80
|
-
var fetchContentWithId = function (id, locale, spaceID, accessToken) {
|
|
81
|
-
if (locale === void 0) { locale = 'fr'; }
|
|
82
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
83
|
-
var entry, err_1;
|
|
84
|
-
return __generator(this, function (_a) {
|
|
85
|
-
switch (_a.label) {
|
|
86
|
-
case 0:
|
|
87
|
-
if (!!!spaceID || !!!accessToken)
|
|
88
|
-
return [2, { valid: false, err: "Clés d'accès invalides" }];
|
|
89
|
-
_a.label = 1;
|
|
90
|
-
case 1:
|
|
91
|
-
_a.trys.push([1, 3, , 4]);
|
|
92
|
-
return [4, (0, exports.client)(spaceID, accessToken).getEntry(id, { locale: "".concat(locale, "-CA") })];
|
|
93
|
-
case 2:
|
|
94
|
-
entry = _a.sent();
|
|
95
|
-
if (!!!entry) {
|
|
96
|
-
return [2, { valid: false, err: 'Entrée invalide.' }];
|
|
97
|
-
}
|
|
98
|
-
return [2, { valid: true, data: entry }];
|
|
99
|
-
case 3:
|
|
100
|
-
err_1 = _a.sent();
|
|
101
|
-
return [2, { valid: false, err: err_1 }];
|
|
102
|
-
case 4: return [2];
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
};
|
|
107
|
-
exports.fetchContentWithId = fetchContentWithId;
|
|
108
|
-
var fetchContentWithContentType = function (content_type, locale, spaceID, accessToken, query, value) {
|
|
109
|
-
if (locale === void 0) { locale = 'fr'; }
|
|
110
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
111
|
-
var queryToAdd, entry, err_2;
|
|
112
|
-
return __generator(this, function (_a) {
|
|
113
|
-
switch (_a.label) {
|
|
114
|
-
case 0:
|
|
115
|
-
if (!!!spaceID || !!!accessToken)
|
|
116
|
-
return [2, { valid: false, err: "Clés d'accès invalides" }];
|
|
117
|
-
_a.label = 1;
|
|
118
|
-
case 1:
|
|
119
|
-
_a.trys.push([1, 3, , 4]);
|
|
120
|
-
queryToAdd = !!query ? { query: value } : {};
|
|
121
|
-
return [4, (0, exports.client)(spaceID, accessToken).getEntries(__assign({ content_type: content_type, locale: "".concat(locale, "-CA") }, queryToAdd))];
|
|
122
|
-
case 2:
|
|
123
|
-
entry = _a.sent();
|
|
124
|
-
if (!!!entry) {
|
|
125
|
-
return [2, { valid: false, err: 'Contenu invalide.' }];
|
|
126
|
-
}
|
|
127
|
-
return [2, { valid: true, data: entry }];
|
|
128
|
-
case 3:
|
|
129
|
-
err_2 = _a.sent();
|
|
130
|
-
return [2, { valid: false, err: err_2 }];
|
|
131
|
-
case 4: return [2];
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
};
|
|
136
|
-
exports.fetchContentWithContentType = fetchContentWithContentType;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
46
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
47
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
|
+
function step(op) {
|
|
50
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
52
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
53
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
|
+
switch (op[0]) {
|
|
55
|
+
case 0: case 1: t = op; break;
|
|
56
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
57
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
58
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
59
|
+
default:
|
|
60
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
61
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
62
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
63
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
64
|
+
if (t[2]) _.ops.pop();
|
|
65
|
+
_.trys.pop(); continue;
|
|
66
|
+
}
|
|
67
|
+
op = body.call(thisArg, _);
|
|
68
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
69
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
73
|
+
exports.fetchContentWithContentType = exports.fetchContentWithId = exports.client = void 0;
|
|
74
|
+
var contentful = __importStar(require("contentful"));
|
|
75
|
+
var host = 'cdn.contentful.com';
|
|
76
|
+
var client = function (spaceID, accessToken) {
|
|
77
|
+
return contentful.createClient({ space: spaceID, accessToken: accessToken, host: host });
|
|
78
|
+
};
|
|
79
|
+
exports.client = client;
|
|
80
|
+
var fetchContentWithId = function (id, locale, spaceID, accessToken) {
|
|
81
|
+
if (locale === void 0) { locale = 'fr'; }
|
|
82
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
83
|
+
var entry, err_1;
|
|
84
|
+
return __generator(this, function (_a) {
|
|
85
|
+
switch (_a.label) {
|
|
86
|
+
case 0:
|
|
87
|
+
if (!!!spaceID || !!!accessToken)
|
|
88
|
+
return [2, { valid: false, err: "Clés d'accès invalides" }];
|
|
89
|
+
_a.label = 1;
|
|
90
|
+
case 1:
|
|
91
|
+
_a.trys.push([1, 3, , 4]);
|
|
92
|
+
return [4, (0, exports.client)(spaceID, accessToken).getEntry(id, { locale: "".concat(locale, "-CA") })];
|
|
93
|
+
case 2:
|
|
94
|
+
entry = _a.sent();
|
|
95
|
+
if (!!!entry) {
|
|
96
|
+
return [2, { valid: false, err: 'Entrée invalide.' }];
|
|
97
|
+
}
|
|
98
|
+
return [2, { valid: true, data: entry }];
|
|
99
|
+
case 3:
|
|
100
|
+
err_1 = _a.sent();
|
|
101
|
+
return [2, { valid: false, err: err_1 }];
|
|
102
|
+
case 4: return [2];
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
exports.fetchContentWithId = fetchContentWithId;
|
|
108
|
+
var fetchContentWithContentType = function (content_type, locale, spaceID, accessToken, query, value) {
|
|
109
|
+
if (locale === void 0) { locale = 'fr'; }
|
|
110
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
111
|
+
var queryToAdd, entry, err_2;
|
|
112
|
+
return __generator(this, function (_a) {
|
|
113
|
+
switch (_a.label) {
|
|
114
|
+
case 0:
|
|
115
|
+
if (!!!spaceID || !!!accessToken)
|
|
116
|
+
return [2, { valid: false, err: "Clés d'accès invalides" }];
|
|
117
|
+
_a.label = 1;
|
|
118
|
+
case 1:
|
|
119
|
+
_a.trys.push([1, 3, , 4]);
|
|
120
|
+
queryToAdd = !!query ? { query: value } : {};
|
|
121
|
+
return [4, (0, exports.client)(spaceID, accessToken).getEntries(__assign({ content_type: content_type, locale: "".concat(locale, "-CA") }, queryToAdd))];
|
|
122
|
+
case 2:
|
|
123
|
+
entry = _a.sent();
|
|
124
|
+
if (!!!entry) {
|
|
125
|
+
return [2, { valid: false, err: 'Contenu invalide.' }];
|
|
126
|
+
}
|
|
127
|
+
return [2, { valid: true, data: entry }];
|
|
128
|
+
case 3:
|
|
129
|
+
err_2 = _a.sent();
|
|
130
|
+
return [2, { valid: false, err: err_2 }];
|
|
131
|
+
case 4: return [2];
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
exports.fetchContentWithContentType = fetchContentWithContentType;
|
|
137
137
|
//# sourceMappingURL=contentful.js.map
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import ITranslation from 'addio-admin-sdk/dist/Interfaces/Translation';
|
|
2
|
-
import ILang from 'addio-admin-sdk/dist/utils/string';
|
|
3
|
-
import ICategory from 'addio-admin-sdk/dist/Interfaces/Category';
|
|
4
|
-
import { ICartItem, IIndexedDeclination } from 'addio-admin-sdk/dist/Interfaces/Cart';
|
|
5
|
-
export declare const string_to_slug: (str: string) => string;
|
|
6
|
-
export declare const translate: (locale: string | undefined, translation: ITranslation[]) => string;
|
|
7
|
-
export declare const getStringByLang: (lang: ILang, locale: string | undefined) => string;
|
|
8
|
-
export declare const numberWithSpaces: (numStr: number | string) => string;
|
|
9
|
-
export declare const printTree: (categories: ICategory[], parent?: string) => ICategory[];
|
|
10
|
-
export declare const toBase64: (file: File) => Promise<ProgressEvent<FileReader> | string | ArrayBuffer | null>;
|
|
11
|
-
export declare const calculateDistancesFromPoint: (position: {
|
|
12
|
-
lat: number;
|
|
13
|
-
lng: number;
|
|
14
|
-
}, markers: any[]) => any[];
|
|
15
|
-
export declare const getMinPrice: (cartItem: IIndexedDeclination, checkTierPricing?: boolean) => {
|
|
16
|
-
amount: number;
|
|
17
|
-
hasTierPricing: boolean;
|
|
18
|
-
};
|
|
19
|
-
export declare const getFullProdName: (item: IIndexedDeclination | ICartItem, locale: string) => string;
|
|
20
|
-
export declare const isEscompteSupplementaireItem: (itemSku: string) => boolean;
|
|
21
|
-
export declare const moneyFormat: (amount: number, currency?: string, showZeros?: boolean) => string;
|
|
1
|
+
import ITranslation from 'addio-admin-sdk/dist/Interfaces/Translation';
|
|
2
|
+
import ILang from 'addio-admin-sdk/dist/utils/string';
|
|
3
|
+
import ICategory from 'addio-admin-sdk/dist/Interfaces/Category';
|
|
4
|
+
import { ICartItem, IIndexedDeclination } from 'addio-admin-sdk/dist/Interfaces/Cart';
|
|
5
|
+
export declare const string_to_slug: (str: string) => string;
|
|
6
|
+
export declare const translate: (locale: string | undefined, translation: ITranslation[]) => string;
|
|
7
|
+
export declare const getStringByLang: (lang: ILang, locale: string | undefined) => string;
|
|
8
|
+
export declare const numberWithSpaces: (numStr: number | string) => string;
|
|
9
|
+
export declare const printTree: (categories: ICategory[], parent?: string) => ICategory[];
|
|
10
|
+
export declare const toBase64: (file: File) => Promise<ProgressEvent<FileReader> | string | ArrayBuffer | null>;
|
|
11
|
+
export declare const calculateDistancesFromPoint: (position: {
|
|
12
|
+
lat: number;
|
|
13
|
+
lng: number;
|
|
14
|
+
}, markers: any[]) => any[];
|
|
15
|
+
export declare const getMinPrice: (cartItem: IIndexedDeclination, checkTierPricing?: boolean) => {
|
|
16
|
+
amount: number;
|
|
17
|
+
hasTierPricing: boolean;
|
|
18
|
+
};
|
|
19
|
+
export declare const getFullProdName: (item: IIndexedDeclination | ICartItem, locale: string) => string;
|
|
20
|
+
export declare const isEscompteSupplementaireItem: (itemSku: string) => boolean;
|
|
21
|
+
export declare const moneyFormat: (amount: number, currency?: string, showZeros?: boolean) => string;
|