@infrab4a/connect-angular 3.11.0 → 4.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/angular-connect.module.d.ts +7 -9
  2. package/angular-firebase-auth.module.d.ts +6 -4
  3. package/angular-firestore.module.d.ts +7 -5
  4. package/consts/firebase-const.d.ts +3 -0
  5. package/consts/index.d.ts +1 -2
  6. package/esm2020/angular-connect.module.mjs +49 -0
  7. package/esm2020/angular-elastic-search.module.mjs +38 -0
  8. package/esm2020/angular-firebase-auth.module.mjs +130 -0
  9. package/esm2020/angular-firestore.module.mjs +358 -0
  10. package/esm2020/angular-hasura-graphql.module.mjs +90 -0
  11. package/esm2020/consts/firebase-const.mjs +4 -0
  12. package/esm2020/consts/index.mjs +5 -0
  13. package/esm2020/index.mjs +6 -0
  14. package/esm2020/services/auth.service.mjs +37 -0
  15. package/esm2020/services/cart.service.mjs +143 -0
  16. package/esm2020/services/checkout-subscription.service.mjs +51 -0
  17. package/esm2020/services/checkout.service.mjs +73 -0
  18. package/esm2020/services/coupon.service.mjs +226 -0
  19. package/esm2020/services/errors/group-invalid-coupon.error.mjs +8 -0
  20. package/esm2020/services/errors/index.mjs +3 -0
  21. package/esm2020/services/errors/invalid-coupon.error.mjs +7 -0
  22. package/esm2020/services/home-shop.service.mjs +114 -0
  23. package/esm2020/services/index.mjs +8 -0
  24. package/esm2020/services/order.service.mjs +30 -0
  25. package/esm2020/types/firebase-app-config.type.mjs +2 -0
  26. package/esm2020/types/index.mjs +2 -0
  27. package/fesm2015/infrab4a-connect-angular.mjs +1336 -0
  28. package/fesm2015/infrab4a-connect-angular.mjs.map +1 -0
  29. package/fesm2020/infrab4a-connect-angular.mjs +1291 -0
  30. package/fesm2020/infrab4a-connect-angular.mjs.map +1 -0
  31. package/index.d.ts +2 -2
  32. package/package.json +24 -12
  33. package/services/auth.service.d.ts +3 -4
  34. package/services/cart.service.d.ts +2 -9
  35. package/services/coupon.service.d.ts +10 -13
  36. package/services/errors/group-invalid-coupon.error.d.ts +6 -0
  37. package/services/errors/index.d.ts +2 -0
  38. package/services/errors/invalid-coupon.error.d.ts +4 -0
  39. package/services/index.d.ts +2 -5
  40. package/services/order.service.d.ts +2 -2
  41. package/types/firebase-app-config.type.d.ts +1 -0
  42. package/types/index.d.ts +1 -0
  43. package/bundles/infrab4a-connect-angular.umd.js +0 -2872
  44. package/bundles/infrab4a-connect-angular.umd.js.map +0 -1
  45. package/consts/backend-url.const.d.ts +0 -1
  46. package/consts/category-structure.d.ts +0 -1
  47. package/esm2015/angular-connect.module.js +0 -66
  48. package/esm2015/angular-elastic-search.module.js +0 -34
  49. package/esm2015/angular-firebase-auth.module.js +0 -113
  50. package/esm2015/angular-firestore.module.js +0 -394
  51. package/esm2015/angular-hasura-graphql.module.js +0 -196
  52. package/esm2015/consts/backend-url.const.js +0 -2
  53. package/esm2015/consts/category-structure.js +0 -2
  54. package/esm2015/consts/index.js +0 -6
  55. package/esm2015/index.js +0 -6
  56. package/esm2015/services/auth.service.js +0 -42
  57. package/esm2015/services/cart.service.js +0 -281
  58. package/esm2015/services/catalog/adapters/category-structure.adapter.js +0 -2
  59. package/esm2015/services/catalog/adapters/index.js +0 -4
  60. package/esm2015/services/catalog/adapters/new-category-structure.adapter.js +0 -51
  61. package/esm2015/services/catalog/adapters/old-category-structure.adapter.js +0 -27
  62. package/esm2015/services/catalog/catalog.service.js +0 -126
  63. package/esm2015/services/catalog/category.service.js +0 -56
  64. package/esm2015/services/catalog/enums/index.js +0 -2
  65. package/esm2015/services/catalog/enums/product-sorts.enum.js +0 -11
  66. package/esm2015/services/catalog/index.js +0 -7
  67. package/esm2015/services/catalog/models/category-with-tree.model.js +0 -10
  68. package/esm2015/services/catalog/models/index.js +0 -2
  69. package/esm2015/services/catalog/types/index.js +0 -2
  70. package/esm2015/services/catalog/types/product-sort.type.js +0 -2
  71. package/esm2015/services/catalog/wishlist.service.js +0 -112
  72. package/esm2015/services/checkout-subscription.service.js +0 -53
  73. package/esm2015/services/checkout.service.js +0 -70
  74. package/esm2015/services/coupon.service.js +0 -244
  75. package/esm2015/services/helpers/index.js +0 -2
  76. package/esm2015/services/helpers/util.helper.js +0 -18
  77. package/esm2015/services/home-shop.service.js +0 -116
  78. package/esm2015/services/index.js +0 -11
  79. package/esm2015/services/order.service.js +0 -32
  80. package/esm2015/services/shipping.service.js +0 -98
  81. package/esm2015/services/types/shipping-methods.type.js +0 -2
  82. package/fesm2015/infrab4a-connect-angular.js +0 -2048
  83. package/fesm2015/infrab4a-connect-angular.js.map +0 -1
  84. package/infrab4a-connect-angular.d.ts +0 -5
  85. package/services/catalog/adapters/category-structure.adapter.d.ts +0 -4
  86. package/services/catalog/adapters/index.d.ts +0 -3
  87. package/services/catalog/adapters/new-category-structure.adapter.d.ts +0 -14
  88. package/services/catalog/adapters/old-category-structure.adapter.d.ts +0 -10
  89. package/services/catalog/catalog.service.d.ts +0 -80
  90. package/services/catalog/category.service.d.ts +0 -15
  91. package/services/catalog/enums/index.d.ts +0 -1
  92. package/services/catalog/enums/product-sorts.enum.d.ts +0 -9
  93. package/services/catalog/index.d.ts +0 -6
  94. package/services/catalog/models/category-with-tree.model.d.ts +0 -4
  95. package/services/catalog/models/index.d.ts +0 -1
  96. package/services/catalog/types/index.d.ts +0 -1
  97. package/services/catalog/types/product-sort.type.d.ts +0 -2
  98. package/services/catalog/wishlist.service.d.ts +0 -22
  99. package/services/helpers/index.d.ts +0 -1
  100. package/services/helpers/util.helper.d.ts +0 -3
  101. package/services/shipping.service.d.ts +0 -19
  102. package/services/types/shipping-methods.type.d.ts +0 -12
  103. /package/{esm2015/consts/default-shop.const.js → esm2020/consts/default-shop.const.mjs} +0 -0
  104. /package/{esm2015/consts/es-config.const.js → esm2020/consts/es-config.const.mjs} +0 -0
  105. /package/{esm2015/consts/hasura-options.const.js → esm2020/consts/hasura-options.const.mjs} +0 -0
  106. /package/{esm2015/infrab4a-connect-angular.js → esm2020/infrab4a-connect-angular.mjs} +0 -0
  107. /package/{esm2015/services/types/index.js → esm2020/services/types/index.mjs} +0 -0
  108. /package/{esm2015/services/types/required-checkout-data.type.js → esm2020/services/types/required-checkout-data.type.mjs} +0 -0
  109. /package/{esm2015/services/types/required-checkout-subscription-data.type.js → esm2020/services/types/required-checkout-subscription-data.type.mjs} +0 -0
@@ -1,2872 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/fire'), require('@infrab4a/connect'), require('@angular/fire/firestore'), require('rxjs'), require('rxjs/operators'), require('@angular/fire/auth'), require('js-cookie'), require('class-transformer'), require('@angular/common/http')) :
3
- typeof define === 'function' && define.amd ? define('@infrab4a/connect-angular', ['exports', '@angular/core', '@angular/fire', '@infrab4a/connect', '@angular/fire/firestore', 'rxjs', 'rxjs/operators', '@angular/fire/auth', 'js-cookie', 'class-transformer', '@angular/common/http'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.infrab4a = global.infrab4a || {}, global.infrab4a["connect-angular"] = {}), global.ng.core, global.ng.fire, global["@infrab4a/connect"], global.ng.fire.firestore, global.rxjs, global.rxjs.operators, global.ng.fire.auth, global["js-cookie"], global["class-transformer"], global.ng.common.http));
5
- })(this, (function (exports, i0, fire, i1, i1$1, rxjs, operators, i1$2, cookie, classTransformer, i1$3) { 'use strict';
6
-
7
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
-
9
- function _interopNamespace(e) {
10
- if (e && e.__esModule) return e;
11
- var n = Object.create(null);
12
- if (e) {
13
- Object.keys(e).forEach(function (k) {
14
- if (k !== 'default') {
15
- var d = Object.getOwnPropertyDescriptor(e, k);
16
- Object.defineProperty(n, k, d.get ? d : {
17
- enumerable: true,
18
- get: function () { return e[k]; }
19
- });
20
- }
21
- });
22
- }
23
- n["default"] = e;
24
- return Object.freeze(n);
25
- }
26
-
27
- var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
28
- var i1__namespace$1 = /*#__PURE__*/_interopNamespace(i1);
29
- var i1__namespace$2 = /*#__PURE__*/_interopNamespace(i1$1);
30
- var i1__namespace = /*#__PURE__*/_interopNamespace(i1$2);
31
- var cookie__default = /*#__PURE__*/_interopDefaultLegacy(cookie);
32
- var i1__namespace$3 = /*#__PURE__*/_interopNamespace(i1$3);
33
-
34
- /*! *****************************************************************************
35
- Copyright (c) Microsoft Corporation.
36
-
37
- Permission to use, copy, modify, and/or distribute this software for any
38
- purpose with or without fee is hereby granted.
39
-
40
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
41
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
42
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
43
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
44
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
45
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
46
- PERFORMANCE OF THIS SOFTWARE.
47
- ***************************************************************************** */
48
- /* global Reflect, Promise */
49
- var extendStatics = function (d, b) {
50
- extendStatics = Object.setPrototypeOf ||
51
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
52
- function (d, b) { for (var p in b)
53
- if (Object.prototype.hasOwnProperty.call(b, p))
54
- d[p] = b[p]; };
55
- return extendStatics(d, b);
56
- };
57
- function __extends(d, b) {
58
- if (typeof b !== "function" && b !== null)
59
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
60
- extendStatics(d, b);
61
- function __() { this.constructor = d; }
62
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
63
- }
64
- var __assign = function () {
65
- __assign = Object.assign || function __assign(t) {
66
- for (var s, i = 1, n = arguments.length; i < n; i++) {
67
- s = arguments[i];
68
- for (var p in s)
69
- if (Object.prototype.hasOwnProperty.call(s, p))
70
- t[p] = s[p];
71
- }
72
- return t;
73
- };
74
- return __assign.apply(this, arguments);
75
- };
76
- function __rest(s, e) {
77
- var t = {};
78
- for (var p in s)
79
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
80
- t[p] = s[p];
81
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
82
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
83
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
84
- t[p[i]] = s[p[i]];
85
- }
86
- return t;
87
- }
88
- function __decorate(decorators, target, key, desc) {
89
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
90
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
91
- r = Reflect.decorate(decorators, target, key, desc);
92
- else
93
- for (var i = decorators.length - 1; i >= 0; i--)
94
- if (d = decorators[i])
95
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
96
- return c > 3 && r && Object.defineProperty(target, key, r), r;
97
- }
98
- function __param(paramIndex, decorator) {
99
- return function (target, key) { decorator(target, key, paramIndex); };
100
- }
101
- function __metadata(metadataKey, metadataValue) {
102
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
103
- return Reflect.metadata(metadataKey, metadataValue);
104
- }
105
- function __awaiter(thisArg, _arguments, P, generator) {
106
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
107
- return new (P || (P = Promise))(function (resolve, reject) {
108
- function fulfilled(value) { try {
109
- step(generator.next(value));
110
- }
111
- catch (e) {
112
- reject(e);
113
- } }
114
- function rejected(value) { try {
115
- step(generator["throw"](value));
116
- }
117
- catch (e) {
118
- reject(e);
119
- } }
120
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
121
- step((generator = generator.apply(thisArg, _arguments || [])).next());
122
- });
123
- }
124
- function __generator(thisArg, body) {
125
- var _ = { label: 0, sent: function () { if (t[0] & 1)
126
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
127
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
128
- function verb(n) { return function (v) { return step([n, v]); }; }
129
- function step(op) {
130
- if (f)
131
- throw new TypeError("Generator is already executing.");
132
- while (_)
133
- try {
134
- 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)
135
- return t;
136
- if (y = 0, t)
137
- op = [op[0] & 2, t.value];
138
- switch (op[0]) {
139
- case 0:
140
- case 1:
141
- t = op;
142
- break;
143
- case 4:
144
- _.label++;
145
- return { value: op[1], done: false };
146
- case 5:
147
- _.label++;
148
- y = op[1];
149
- op = [0];
150
- continue;
151
- case 7:
152
- op = _.ops.pop();
153
- _.trys.pop();
154
- continue;
155
- default:
156
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
157
- _ = 0;
158
- continue;
159
- }
160
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
161
- _.label = op[1];
162
- break;
163
- }
164
- if (op[0] === 6 && _.label < t[1]) {
165
- _.label = t[1];
166
- t = op;
167
- break;
168
- }
169
- if (t && _.label < t[2]) {
170
- _.label = t[2];
171
- _.ops.push(op);
172
- break;
173
- }
174
- if (t[2])
175
- _.ops.pop();
176
- _.trys.pop();
177
- continue;
178
- }
179
- op = body.call(thisArg, _);
180
- }
181
- catch (e) {
182
- op = [6, e];
183
- y = 0;
184
- }
185
- finally {
186
- f = t = 0;
187
- }
188
- if (op[0] & 5)
189
- throw op[1];
190
- return { value: op[0] ? op[1] : void 0, done: true };
191
- }
192
- }
193
- var __createBinding = Object.create ? (function (o, m, k, k2) {
194
- if (k2 === undefined)
195
- k2 = k;
196
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
197
- }) : (function (o, m, k, k2) {
198
- if (k2 === undefined)
199
- k2 = k;
200
- o[k2] = m[k];
201
- });
202
- function __exportStar(m, o) {
203
- for (var p in m)
204
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
205
- __createBinding(o, m, p);
206
- }
207
- function __values(o) {
208
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
209
- if (m)
210
- return m.call(o);
211
- if (o && typeof o.length === "number")
212
- return {
213
- next: function () {
214
- if (o && i >= o.length)
215
- o = void 0;
216
- return { value: o && o[i++], done: !o };
217
- }
218
- };
219
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
220
- }
221
- function __read(o, n) {
222
- var m = typeof Symbol === "function" && o[Symbol.iterator];
223
- if (!m)
224
- return o;
225
- var i = m.call(o), r, ar = [], e;
226
- try {
227
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
228
- ar.push(r.value);
229
- }
230
- catch (error) {
231
- e = { error: error };
232
- }
233
- finally {
234
- try {
235
- if (r && !r.done && (m = i["return"]))
236
- m.call(i);
237
- }
238
- finally {
239
- if (e)
240
- throw e.error;
241
- }
242
- }
243
- return ar;
244
- }
245
- /** @deprecated */
246
- function __spread() {
247
- for (var ar = [], i = 0; i < arguments.length; i++)
248
- ar = ar.concat(__read(arguments[i]));
249
- return ar;
250
- }
251
- /** @deprecated */
252
- function __spreadArrays() {
253
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
254
- s += arguments[i].length;
255
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
256
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
257
- r[k] = a[j];
258
- return r;
259
- }
260
- function __spreadArray(to, from, pack) {
261
- if (pack || arguments.length === 2)
262
- for (var i = 0, l = from.length, ar; i < l; i++) {
263
- if (ar || !(i in from)) {
264
- if (!ar)
265
- ar = Array.prototype.slice.call(from, 0, i);
266
- ar[i] = from[i];
267
- }
268
- }
269
- return to.concat(ar || Array.prototype.slice.call(from));
270
- }
271
- function __await(v) {
272
- return this instanceof __await ? (this.v = v, this) : new __await(v);
273
- }
274
- function __asyncGenerator(thisArg, _arguments, generator) {
275
- if (!Symbol.asyncIterator)
276
- throw new TypeError("Symbol.asyncIterator is not defined.");
277
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
278
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
279
- function verb(n) { if (g[n])
280
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
281
- function resume(n, v) { try {
282
- step(g[n](v));
283
- }
284
- catch (e) {
285
- settle(q[0][3], e);
286
- } }
287
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
288
- function fulfill(value) { resume("next", value); }
289
- function reject(value) { resume("throw", value); }
290
- function settle(f, v) { if (f(v), q.shift(), q.length)
291
- resume(q[0][0], q[0][1]); }
292
- }
293
- function __asyncDelegator(o) {
294
- var i, p;
295
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
296
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
297
- }
298
- function __asyncValues(o) {
299
- if (!Symbol.asyncIterator)
300
- throw new TypeError("Symbol.asyncIterator is not defined.");
301
- var m = o[Symbol.asyncIterator], i;
302
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
303
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
304
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
305
- }
306
- function __makeTemplateObject(cooked, raw) {
307
- if (Object.defineProperty) {
308
- Object.defineProperty(cooked, "raw", { value: raw });
309
- }
310
- else {
311
- cooked.raw = raw;
312
- }
313
- return cooked;
314
- }
315
- ;
316
- var __setModuleDefault = Object.create ? (function (o, v) {
317
- Object.defineProperty(o, "default", { enumerable: true, value: v });
318
- }) : function (o, v) {
319
- o["default"] = v;
320
- };
321
- function __importStar(mod) {
322
- if (mod && mod.__esModule)
323
- return mod;
324
- var result = {};
325
- if (mod != null)
326
- for (var k in mod)
327
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
328
- __createBinding(result, mod, k);
329
- __setModuleDefault(result, mod);
330
- return result;
331
- }
332
- function __importDefault(mod) {
333
- return (mod && mod.__esModule) ? mod : { default: mod };
334
- }
335
- function __classPrivateFieldGet(receiver, state, kind, f) {
336
- if (kind === "a" && !f)
337
- throw new TypeError("Private accessor was defined without a getter");
338
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
339
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
340
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
341
- }
342
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
343
- if (kind === "m")
344
- throw new TypeError("Private method is not writable");
345
- if (kind === "a" && !f)
346
- throw new TypeError("Private accessor was defined without a setter");
347
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
348
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
349
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
350
- }
351
-
352
- var ES_CONFIG = 'ES_CONFIG';
353
-
354
- var AngularElasticSeachModule = /** @class */ (function () {
355
- function AngularElasticSeachModule() {
356
- }
357
- AngularElasticSeachModule.initializeApp = function (options) {
358
- return {
359
- ngModule: AngularElasticSeachModule,
360
- providers: [{ provide: ES_CONFIG, useValue: options }],
361
- };
362
- };
363
- return AngularElasticSeachModule;
364
- }());
365
- AngularElasticSeachModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
366
- AngularElasticSeachModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule });
367
- AngularElasticSeachModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, providers: [
368
- {
369
- provide: i1.ProductsIndex,
370
- useFactory: function (configuration) { return new i1.ProductsIndex(new i1.AxiosAdapter(configuration)); },
371
- deps: [ES_CONFIG],
372
- },
373
- ] });
374
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, decorators: [{
375
- type: i0.NgModule,
376
- args: [{
377
- providers: [
378
- {
379
- provide: i1.ProductsIndex,
380
- useFactory: function (configuration) { return new i1.ProductsIndex(new i1.AxiosAdapter(configuration)); },
381
- deps: [ES_CONFIG],
382
- },
383
- ],
384
- }]
385
- }] });
386
-
387
- var AngularFirestoreModule = /** @class */ (function () {
388
- function AngularFirestoreModule() {
389
- }
390
- AngularFirestoreModule.initializeApp = function (options, nameOrConfig) {
391
- return {
392
- ngModule: AngularFirestoreModule,
393
- providers: [
394
- { provide: fire.FIREBASE_OPTIONS, useValue: options.firebase },
395
- { provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
396
- { provide: ES_CONFIG, useValue: options.elasticSearch },
397
- ],
398
- };
399
- };
400
- return AngularFirestoreModule;
401
- }());
402
- AngularFirestoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
403
- AngularFirestoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, imports: [fire.AngularFireModule, AngularElasticSeachModule] });
404
- AngularFirestoreModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, providers: [
405
- {
406
- provide: 'BeautyProfileRepository',
407
- useFactory: function (firestore, userRepository) {
408
- return new i1.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
409
- },
410
- deps: [i1$1.AngularFirestore, 'UserRepository'],
411
- },
412
- {
413
- provide: 'Buy2WinRepository',
414
- useFactory: function (firestore) {
415
- return new i1.Buy2WinFirestoreRepository(firestore.firestore);
416
- },
417
- deps: [i1$1.AngularFirestore],
418
- },
419
- {
420
- provide: i1.CategoryFirestoreRepository,
421
- useFactory: function (firestore) {
422
- return new i1.CategoryFirestoreRepository(firestore.firestore);
423
- },
424
- deps: [i1$1.AngularFirestore],
425
- },
426
- {
427
- provide: 'CheckoutRepository',
428
- useFactory: function (firestore) {
429
- return new i1.CheckoutFirestoreRepository(firestore.firestore);
430
- },
431
- deps: [i1$1.AngularFirestore],
432
- },
433
- {
434
- provide: 'CheckoutSubscriptionRepository',
435
- useFactory: function (firestore) {
436
- return new i1.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
437
- },
438
- deps: [i1$1.AngularFirestore],
439
- },
440
- {
441
- provide: 'CouponRepository',
442
- useFactory: function (firestore) {
443
- return new i1.CouponFirestoreRepository(firestore.firestore);
444
- },
445
- deps: [i1$1.AngularFirestore],
446
- },
447
- {
448
- provide: 'CampaignHashtagRepository',
449
- useFactory: function (firestore) {
450
- return new i1.CampaignHashtagFirestoreRepository(firestore.firestore);
451
- },
452
- deps: [i1$1.AngularFirestore],
453
- },
454
- {
455
- provide: 'CampaignDashboardRepository',
456
- useFactory: function (firestore) {
457
- return new i1.CampaignDashboardFirestoreRepository(firestore.firestore);
458
- },
459
- deps: [i1$1.AngularFirestore],
460
- },
461
- {
462
- provide: 'EditionRepository',
463
- useFactory: function (firestore, subscriptionRepository) {
464
- return new i1.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
465
- },
466
- deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
467
- },
468
- {
469
- provide: 'HomeRepository',
470
- useFactory: function (firestore) {
471
- return new i1.HomeFirestoreRepository(firestore.firestore);
472
- },
473
- deps: [i1$1.AngularFirestore],
474
- },
475
- {
476
- provide: 'LeadRepository',
477
- useFactory: function (firestore) {
478
- return new i1.LeadFirestoreRepository(firestore.firestore);
479
- },
480
- deps: [i1$1.AngularFirestore],
481
- },
482
- {
483
- provide: 'LegacyOrderRepository',
484
- useFactory: function (firestore) {
485
- return new i1.LegacyOrderFirestoreRepository(firestore.firestore);
486
- },
487
- deps: [i1$1.AngularFirestore],
488
- },
489
- {
490
- provide: 'ShopMenuRepository',
491
- useFactory: function (firestore) {
492
- return new i1.ShopMenuFirestoreRepository(firestore.firestore);
493
- },
494
- deps: [i1$1.AngularFirestore],
495
- },
496
- {
497
- provide: 'OrderRepository',
498
- useFactory: function (firestore) {
499
- return new i1.OrderFirestoreRepository(firestore.firestore);
500
- },
501
- deps: [i1$1.AngularFirestore],
502
- },
503
- {
504
- provide: 'PaymentRepository',
505
- useFactory: function (firestore) {
506
- return new i1.PaymentFirestoreRepository(firestore.firestore);
507
- },
508
- deps: [i1$1.AngularFirestore],
509
- },
510
- {
511
- provide: i1.ProductFirestoreRepository,
512
- useFactory: function (firestore) {
513
- return new i1.ProductFirestoreRepository(firestore.firestore);
514
- },
515
- deps: [i1$1.AngularFirestore],
516
- },
517
- {
518
- provide: 'ShopSettingsRepository',
519
- useFactory: function (firestore) {
520
- return new i1.ShopSettingsFirestoreRepository(firestore.firestore);
521
- },
522
- deps: [i1$1.AngularFirestore],
523
- },
524
- {
525
- provide: 'SubscriptionPaymentRepository',
526
- useFactory: function (firestore, subscriptionRepository) {
527
- return new i1.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
528
- },
529
- deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
530
- },
531
- {
532
- provide: 'SubscriptionPlanRepository',
533
- useFactory: function (firestore) {
534
- return new i1.SubscriptionPlanFirestoreRepository(firestore.firestore);
535
- },
536
- deps: [i1$1.AngularFirestore],
537
- },
538
- {
539
- provide: 'SubscriptionProductRepository',
540
- useFactory: function (firestore) {
541
- return new i1.SubscriptionProductFirestoreRepository(firestore.firestore);
542
- },
543
- deps: [i1$1.AngularFirestore],
544
- },
545
- {
546
- provide: 'SubscriptionRepository',
547
- useFactory: function (firestore) {
548
- return new i1.SubscriptionFirestoreRepository(firestore.firestore);
549
- },
550
- deps: [i1$1.AngularFirestore],
551
- },
552
- {
553
- provide: 'UserRepository',
554
- useFactory: function (firestore) {
555
- return new i1.UserFirestoreRepository(firestore.firestore);
556
- },
557
- deps: [i1$1.AngularFirestore],
558
- },
559
- {
560
- provide: 'UserAddressRepository',
561
- useFactory: function (firestore, userRepository) {
562
- return new i1.UserAddressFirestoreRepository(firestore.firestore, userRepository);
563
- },
564
- deps: [i1$1.AngularFirestore, 'UserRepository'],
565
- },
566
- {
567
- provide: 'UserPaymentMethodRepository',
568
- useFactory: function (firestore, userRepository) {
569
- return new i1.UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
570
- },
571
- deps: [i1$1.AngularFirestore, 'UserRepository'],
572
- },
573
- {
574
- provide: i1.ProductVariantFirestoreRepository,
575
- useFactory: function (firestore, productRepository) {
576
- return new i1.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
577
- },
578
- deps: [i1$1.AngularFirestore, i1.ProductFirestoreRepository],
579
- },
580
- {
581
- provide: i0.APP_INITIALIZER,
582
- useFactory: function (firestore) { return function () { return firestore.firestore.settings({ ignoreUndefinedProperties: true }); }; },
583
- deps: [i1$1.AngularFirestore],
584
- multi: true,
585
- },
586
- ], imports: [[fire.AngularFireModule, AngularElasticSeachModule]] });
587
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, decorators: [{
588
- type: i0.NgModule,
589
- args: [{
590
- imports: [fire.AngularFireModule, AngularElasticSeachModule],
591
- providers: [
592
- {
593
- provide: 'BeautyProfileRepository',
594
- useFactory: function (firestore, userRepository) {
595
- return new i1.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
596
- },
597
- deps: [i1$1.AngularFirestore, 'UserRepository'],
598
- },
599
- {
600
- provide: 'Buy2WinRepository',
601
- useFactory: function (firestore) {
602
- return new i1.Buy2WinFirestoreRepository(firestore.firestore);
603
- },
604
- deps: [i1$1.AngularFirestore],
605
- },
606
- {
607
- provide: i1.CategoryFirestoreRepository,
608
- useFactory: function (firestore) {
609
- return new i1.CategoryFirestoreRepository(firestore.firestore);
610
- },
611
- deps: [i1$1.AngularFirestore],
612
- },
613
- {
614
- provide: 'CheckoutRepository',
615
- useFactory: function (firestore) {
616
- return new i1.CheckoutFirestoreRepository(firestore.firestore);
617
- },
618
- deps: [i1$1.AngularFirestore],
619
- },
620
- {
621
- provide: 'CheckoutSubscriptionRepository',
622
- useFactory: function (firestore) {
623
- return new i1.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
624
- },
625
- deps: [i1$1.AngularFirestore],
626
- },
627
- {
628
- provide: 'CouponRepository',
629
- useFactory: function (firestore) {
630
- return new i1.CouponFirestoreRepository(firestore.firestore);
631
- },
632
- deps: [i1$1.AngularFirestore],
633
- },
634
- {
635
- provide: 'CampaignHashtagRepository',
636
- useFactory: function (firestore) {
637
- return new i1.CampaignHashtagFirestoreRepository(firestore.firestore);
638
- },
639
- deps: [i1$1.AngularFirestore],
640
- },
641
- {
642
- provide: 'CampaignDashboardRepository',
643
- useFactory: function (firestore) {
644
- return new i1.CampaignDashboardFirestoreRepository(firestore.firestore);
645
- },
646
- deps: [i1$1.AngularFirestore],
647
- },
648
- {
649
- provide: 'EditionRepository',
650
- useFactory: function (firestore, subscriptionRepository) {
651
- return new i1.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
652
- },
653
- deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
654
- },
655
- {
656
- provide: 'HomeRepository',
657
- useFactory: function (firestore) {
658
- return new i1.HomeFirestoreRepository(firestore.firestore);
659
- },
660
- deps: [i1$1.AngularFirestore],
661
- },
662
- {
663
- provide: 'LeadRepository',
664
- useFactory: function (firestore) {
665
- return new i1.LeadFirestoreRepository(firestore.firestore);
666
- },
667
- deps: [i1$1.AngularFirestore],
668
- },
669
- {
670
- provide: 'LegacyOrderRepository',
671
- useFactory: function (firestore) {
672
- return new i1.LegacyOrderFirestoreRepository(firestore.firestore);
673
- },
674
- deps: [i1$1.AngularFirestore],
675
- },
676
- {
677
- provide: 'ShopMenuRepository',
678
- useFactory: function (firestore) {
679
- return new i1.ShopMenuFirestoreRepository(firestore.firestore);
680
- },
681
- deps: [i1$1.AngularFirestore],
682
- },
683
- {
684
- provide: 'OrderRepository',
685
- useFactory: function (firestore) {
686
- return new i1.OrderFirestoreRepository(firestore.firestore);
687
- },
688
- deps: [i1$1.AngularFirestore],
689
- },
690
- {
691
- provide: 'PaymentRepository',
692
- useFactory: function (firestore) {
693
- return new i1.PaymentFirestoreRepository(firestore.firestore);
694
- },
695
- deps: [i1$1.AngularFirestore],
696
- },
697
- {
698
- provide: i1.ProductFirestoreRepository,
699
- useFactory: function (firestore) {
700
- return new i1.ProductFirestoreRepository(firestore.firestore);
701
- },
702
- deps: [i1$1.AngularFirestore],
703
- },
704
- {
705
- provide: 'ShopSettingsRepository',
706
- useFactory: function (firestore) {
707
- return new i1.ShopSettingsFirestoreRepository(firestore.firestore);
708
- },
709
- deps: [i1$1.AngularFirestore],
710
- },
711
- {
712
- provide: 'SubscriptionPaymentRepository',
713
- useFactory: function (firestore, subscriptionRepository) {
714
- return new i1.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
715
- },
716
- deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
717
- },
718
- {
719
- provide: 'SubscriptionPlanRepository',
720
- useFactory: function (firestore) {
721
- return new i1.SubscriptionPlanFirestoreRepository(firestore.firestore);
722
- },
723
- deps: [i1$1.AngularFirestore],
724
- },
725
- {
726
- provide: 'SubscriptionProductRepository',
727
- useFactory: function (firestore) {
728
- return new i1.SubscriptionProductFirestoreRepository(firestore.firestore);
729
- },
730
- deps: [i1$1.AngularFirestore],
731
- },
732
- {
733
- provide: 'SubscriptionRepository',
734
- useFactory: function (firestore) {
735
- return new i1.SubscriptionFirestoreRepository(firestore.firestore);
736
- },
737
- deps: [i1$1.AngularFirestore],
738
- },
739
- {
740
- provide: 'UserRepository',
741
- useFactory: function (firestore) {
742
- return new i1.UserFirestoreRepository(firestore.firestore);
743
- },
744
- deps: [i1$1.AngularFirestore],
745
- },
746
- {
747
- provide: 'UserAddressRepository',
748
- useFactory: function (firestore, userRepository) {
749
- return new i1.UserAddressFirestoreRepository(firestore.firestore, userRepository);
750
- },
751
- deps: [i1$1.AngularFirestore, 'UserRepository'],
752
- },
753
- {
754
- provide: 'UserPaymentMethodRepository',
755
- useFactory: function (firestore, userRepository) {
756
- return new i1.UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
757
- },
758
- deps: [i1$1.AngularFirestore, 'UserRepository'],
759
- },
760
- {
761
- provide: i1.ProductVariantFirestoreRepository,
762
- useFactory: function (firestore, productRepository) {
763
- return new i1.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
764
- },
765
- deps: [i1$1.AngularFirestore, i1.ProductFirestoreRepository],
766
- },
767
- {
768
- provide: i0.APP_INITIALIZER,
769
- useFactory: function (firestore) { return function () { return firestore.firestore.settings({ ignoreUndefinedProperties: true }); }; },
770
- deps: [i1$1.AngularFirestore],
771
- multi: true,
772
- },
773
- ],
774
- }]
775
- }] });
776
-
777
- var BACKEND_URL = 'BACKEND_URL';
778
-
779
- var CATEGORY_STRUCTURE = 'CATEGORY_STRUCTURE';
780
-
781
- var DEFAULT_SHOP = 'DEFAULT_SHOP';
782
-
783
- var HASURA_OPTIONS = 'HASURA_OPTIONS';
784
-
785
- var AngularHasuraGraphQLModule = /** @class */ (function () {
786
- function AngularHasuraGraphQLModule() {
787
- }
788
- AngularHasuraGraphQLModule.initializeApp = function (options) {
789
- return {
790
- ngModule: AngularHasuraGraphQLModule,
791
- providers: [{ provide: HASURA_OPTIONS, useValue: options }],
792
- };
793
- };
794
- return AngularHasuraGraphQLModule;
795
- }());
796
- AngularHasuraGraphQLModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularHasuraGraphQLModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
797
- AngularHasuraGraphQLModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularHasuraGraphQLModule });
798
- AngularHasuraGraphQLModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularHasuraGraphQLModule, providers: [
799
- {
800
- provide: 'CategoryRepository',
801
- useExisting: i1.CategoryHasuraGraphQLRepository,
802
- },
803
- {
804
- provide: i1.CategoryHasuraGraphQLRepository,
805
- useFactory: function (options, productRepository, categoryFilterRepository) {
806
- return new i1.CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
807
- },
808
- deps: [HASURA_OPTIONS, i1.ProductHasuraGraphQLRepository, i1.CategoryFilterHasuraGraphQLRepository],
809
- },
810
- {
811
- provide: 'ProductRepository',
812
- useExisting: i1.ProductHasuraGraphQLRepository,
813
- },
814
- {
815
- provide: i1.ProductHasuraGraphQLRepository,
816
- useFactory: function (options) {
817
- return new i1.ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
818
- },
819
- deps: [HASURA_OPTIONS],
820
- },
821
- {
822
- provide: 'VariantRepository',
823
- useExisting: i1.VariantHasuraGraphQLRepository,
824
- },
825
- {
826
- provide: i1.VariantHasuraGraphQLRepository,
827
- useFactory: function (options) {
828
- return new i1.VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
829
- },
830
- deps: [HASURA_OPTIONS],
831
- },
832
- {
833
- provide: 'CategoryFilterRepository',
834
- useExisting: i1.CategoryFilterHasuraGraphQLRepository,
835
- },
836
- {
837
- provide: i1.CategoryFilterHasuraGraphQLRepository,
838
- useFactory: function (options) {
839
- return new i1.CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
840
- },
841
- deps: [HASURA_OPTIONS],
842
- },
843
- {
844
- provide: 'FilterOptionRepository',
845
- useExisting: i1.FilterOptionHasuraGraphQLRepository,
846
- },
847
- {
848
- provide: i1.FilterOptionHasuraGraphQLRepository,
849
- useFactory: function (options) {
850
- return new i1.FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
851
- },
852
- deps: [HASURA_OPTIONS],
853
- },
854
- {
855
- provide: 'FilterRepository',
856
- useExisting: i1.FilterHasuraGraphQLRepository,
857
- },
858
- {
859
- provide: i1.FilterHasuraGraphQLRepository,
860
- useFactory: function (options, filterOptionRepository, categoryFilterRepository) {
861
- return new i1.FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
862
- },
863
- deps: [HASURA_OPTIONS, i1.FilterOptionHasuraGraphQLRepository, i1.CategoryFilterHasuraGraphQLRepository],
864
- },
865
- {
866
- provide: i1.CategoryCollectionChildrenHasuraGraphQLRepository,
867
- useFactory: function (options) { return new i1.CategoryCollectionChildrenHasuraGraphQLRepository(options.endpoint, options.credentials); },
868
- deps: ['HasuraConfig'],
869
- },
870
- {
871
- provide: 'CategoryCollectionChildrenRepository',
872
- useExisting: i1.CategoryCollectionChildrenHasuraGraphQLRepository,
873
- },
874
- {
875
- provide: i1.WishlistHasuraGraphQLRepository,
876
- useFactory: function (options, categoryFilterRepository) {
877
- return new i1.WishlistHasuraGraphQLRepository(options.endpoint, options.credentials, categoryFilterRepository);
878
- },
879
- deps: ['HasuraConfig', i1.CategoryFilterHasuraGraphQLRepository],
880
- },
881
- {
882
- provide: 'WishlistRepository',
883
- useExisting: i1.WishlistHasuraGraphQLRepository,
884
- },
885
- ] });
886
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularHasuraGraphQLModule, decorators: [{
887
- type: i0.NgModule,
888
- args: [{
889
- providers: [
890
- {
891
- provide: 'CategoryRepository',
892
- useExisting: i1.CategoryHasuraGraphQLRepository,
893
- },
894
- {
895
- provide: i1.CategoryHasuraGraphQLRepository,
896
- useFactory: function (options, productRepository, categoryFilterRepository) {
897
- return new i1.CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
898
- },
899
- deps: [HASURA_OPTIONS, i1.ProductHasuraGraphQLRepository, i1.CategoryFilterHasuraGraphQLRepository],
900
- },
901
- {
902
- provide: 'ProductRepository',
903
- useExisting: i1.ProductHasuraGraphQLRepository,
904
- },
905
- {
906
- provide: i1.ProductHasuraGraphQLRepository,
907
- useFactory: function (options) {
908
- return new i1.ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
909
- },
910
- deps: [HASURA_OPTIONS],
911
- },
912
- {
913
- provide: 'VariantRepository',
914
- useExisting: i1.VariantHasuraGraphQLRepository,
915
- },
916
- {
917
- provide: i1.VariantHasuraGraphQLRepository,
918
- useFactory: function (options) {
919
- return new i1.VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
920
- },
921
- deps: [HASURA_OPTIONS],
922
- },
923
- {
924
- provide: 'CategoryFilterRepository',
925
- useExisting: i1.CategoryFilterHasuraGraphQLRepository,
926
- },
927
- {
928
- provide: i1.CategoryFilterHasuraGraphQLRepository,
929
- useFactory: function (options) {
930
- return new i1.CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
931
- },
932
- deps: [HASURA_OPTIONS],
933
- },
934
- {
935
- provide: 'FilterOptionRepository',
936
- useExisting: i1.FilterOptionHasuraGraphQLRepository,
937
- },
938
- {
939
- provide: i1.FilterOptionHasuraGraphQLRepository,
940
- useFactory: function (options) {
941
- return new i1.FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
942
- },
943
- deps: [HASURA_OPTIONS],
944
- },
945
- {
946
- provide: 'FilterRepository',
947
- useExisting: i1.FilterHasuraGraphQLRepository,
948
- },
949
- {
950
- provide: i1.FilterHasuraGraphQLRepository,
951
- useFactory: function (options, filterOptionRepository, categoryFilterRepository) {
952
- return new i1.FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
953
- },
954
- deps: [HASURA_OPTIONS, i1.FilterOptionHasuraGraphQLRepository, i1.CategoryFilterHasuraGraphQLRepository],
955
- },
956
- {
957
- provide: i1.CategoryCollectionChildrenHasuraGraphQLRepository,
958
- useFactory: function (options) { return new i1.CategoryCollectionChildrenHasuraGraphQLRepository(options.endpoint, options.credentials); },
959
- deps: ['HasuraConfig'],
960
- },
961
- {
962
- provide: 'CategoryCollectionChildrenRepository',
963
- useExisting: i1.CategoryCollectionChildrenHasuraGraphQLRepository,
964
- },
965
- {
966
- provide: i1.WishlistHasuraGraphQLRepository,
967
- useFactory: function (options, categoryFilterRepository) {
968
- return new i1.WishlistHasuraGraphQLRepository(options.endpoint, options.credentials, categoryFilterRepository);
969
- },
970
- deps: ['HasuraConfig', i1.CategoryFilterHasuraGraphQLRepository],
971
- },
972
- {
973
- provide: 'WishlistRepository',
974
- useExisting: i1.WishlistHasuraGraphQLRepository,
975
- },
976
- ],
977
- }]
978
- }] });
979
-
980
- var AuthService = /** @class */ (function () {
981
- function AuthService(angularFireAuth, userRepository) {
982
- this.angularFireAuth = angularFireAuth;
983
- this.userRepository = userRepository;
984
- }
985
- AuthService.prototype.getAuthstate = function () {
986
- var observables = [
987
- this.angularFireAuth.authState.pipe(operators.catchError(function () { return rxjs.of(null); })),
988
- this.getUser().pipe(operators.catchError(function () { return rxjs.of(null); })),
989
- ];
990
- return rxjs.combineLatest(observables).pipe(operators.map(function (_a) {
991
- var _b = __read(_a, 2), fireUser = _b[0], user = _b[1];
992
- return {
993
- user: user,
994
- isAnonymous: fireUser === null || fireUser === void 0 ? void 0 : fireUser.isAnonymous,
995
- };
996
- }));
997
- };
998
- AuthService.prototype.getUser = function () {
999
- var _this = this;
1000
- return this.getFireUser().pipe(operators.map(function (user) { return user === null || user === void 0 ? void 0 : user.uid; }), operators.mergeMap(function (id) { return (id ? rxjs.from(_this.userRepository.get({ id: id })).pipe(operators.catchError(function () { return rxjs.of(null); })) : rxjs.of(null)); }));
1001
- };
1002
- AuthService.prototype.getTokenId = function () {
1003
- return this.angularFireAuth.idToken;
1004
- };
1005
- AuthService.prototype.getFireUser = function () {
1006
- return this.angularFireAuth.user.pipe(operators.catchError(function () { return rxjs.of(null); }));
1007
- };
1008
- return AuthService;
1009
- }());
1010
- AuthService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AuthService, deps: [{ token: i1__namespace.AngularFireAuth }, { token: 'UserRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1011
- AuthService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AuthService });
1012
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AuthService, decorators: [{
1013
- type: i0.Injectable
1014
- }], ctorParameters: function () {
1015
- return [{ type: i1__namespace.AngularFireAuth }, { type: undefined, decorators: [{
1016
- type: i0.Inject,
1017
- args: ['UserRepository']
1018
- }] }];
1019
- } });
1020
-
1021
- var CouponService = /** @class */ (function () {
1022
- function CouponService(couponRepository, defaultShop, orderRepository, categoryRepository) {
1023
- this.couponRepository = couponRepository;
1024
- this.defaultShop = defaultShop;
1025
- this.orderRepository = orderRepository;
1026
- this.categoryRepository = categoryRepository;
1027
- this.emailIsFromCollaborator = function (userEmail) { return !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g)); };
1028
- }
1029
- CouponService.prototype.checkCoupon = function (nickname, checkoutType, checkout, plan) {
1030
- var _this = this;
1031
- return rxjs.from(this.couponRepository
1032
- .find({
1033
- filters: {
1034
- nickname: { operator: i1.Where.EQUALS, value: nickname },
1035
- active: { operator: i1.Where.EQUALS, value: true },
1036
- },
1037
- })
1038
- .then(function (result) { return result.data[0]; })).pipe(operators.concatMap(function (coupon) { return _this.couponValidation(coupon, checkoutType); }), operators.concatMap(function (couponValid) { return _this.couponRulesValidation(couponValid, checkoutType, checkout, plan); }), operators.map(function (couponValidated) { return couponValidated; }));
1039
- };
1040
- CouponService.prototype.couponValidation = function (coupon, checkoutType) {
1041
- return __awaiter(this, void 0, void 0, function () {
1042
- var isInShop, isCheckoutType;
1043
- return __generator(this, function (_c) {
1044
- if (!coupon)
1045
- throw 'Cupom inválido.';
1046
- if ((coupon === null || coupon === void 0 ? void 0 : coupon.beginAt) && (coupon === null || coupon === void 0 ? void 0 : coupon.beginAt.getTime()) > new Date().getTime())
1047
- throw 'Cupom inválido.';
1048
- if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) && (coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn.getTime()) < new Date().getTime())
1049
- throw 'Cupom expirado.';
1050
- isInShop = coupon.shopAvailability === i1.Shops.ALL || coupon.shopAvailability === this.defaultShop;
1051
- if (!isInShop)
1052
- throw 'Cupom inválido para loja.';
1053
- isCheckoutType = coupon.checkoutType === i1.CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
1054
- if (!isCheckoutType)
1055
- throw 'Cupom inválido. Erro de checkout.';
1056
- return [2 /*return*/, coupon];
1057
- });
1058
- });
1059
- };
1060
- CouponService.prototype.couponRulesValidation = function (coupon, checkoutType, checkout, plan) {
1061
- return __awaiter(this, void 0, void 0, function () {
1062
- var validUser, couponUseLimits, orders, ordersWithUser, hasProductCategories, hasMinSubTotal;
1063
- return __generator(this, function (_c) {
1064
- switch (_c.label) {
1065
- case 0:
1066
- if (checkoutType == i1.CheckoutTypes.SUBSCRIPTION) {
1067
- if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase())
1068
- throw 'Cupom inválido para sua assinatura.';
1069
- return [2 /*return*/, coupon];
1070
- }
1071
- validUser = this.coupomUserValidation(coupon, checkout === null || checkout === void 0 ? void 0 : checkout.user);
1072
- if (!validUser)
1073
- throw 'Usuário não elegível.';
1074
- couponUseLimits = this.getCouponUseLimits(coupon, checkoutType, checkout.user);
1075
- if (!(!couponUseLimits.unlimited || couponUseLimits.limitedPerUser)) return [3 /*break*/, 2];
1076
- return [4 /*yield*/, this.getOrdersWithCoupon(coupon)];
1077
- case 1:
1078
- orders = _c.sent();
1079
- if (!couponUseLimits.unlimited && couponUseLimits.total && orders.length >= couponUseLimits.total)
1080
- throw 'Limite de uso atingido.';
1081
- if (couponUseLimits.limitedPerUser) {
1082
- ordersWithUser = this.countOrdersWithUser(orders, checkout.user.email);
1083
- if (ordersWithUser > 0)
1084
- throw 'Limite de uso por usuário atingido.';
1085
- }
1086
- _c.label = 2;
1087
- case 2: return [4 /*yield*/, this.hasProductCategories(coupon, checkout)];
1088
- case 3:
1089
- hasProductCategories = _c.sent();
1090
- if (!hasProductCategories)
1091
- throw 'Seu carrinho não possui produtos elegíveis para desconto.';
1092
- return [4 /*yield*/, this.hasMinSubTotal(coupon, checkout)];
1093
- case 4:
1094
- hasMinSubTotal = _c.sent();
1095
- if (!hasMinSubTotal)
1096
- throw "Valor m\u00EDnimo de " + Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue) + " n\u00E3o atingido";
1097
- return [2 /*return*/, coupon];
1098
- }
1099
- });
1100
- });
1101
- };
1102
- CouponService.prototype.calcDiscountSubscription = function (coupon, checkout) {
1103
- var discount = 0;
1104
- if (coupon.discount.subscription.type == i1.CouponTypes.ABSOLUTE)
1105
- discount = coupon.discount.subscription.value;
1106
- else
1107
- discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount.subscription.value / 100);
1108
- return rxjs.of(discount);
1109
- };
1110
- CouponService.prototype.calcDiscountShopping = function (coupon, checkout) {
1111
- return __awaiter(this, void 0, void 0, function () {
1112
- var discount;
1113
- return __generator(this, function (_c) {
1114
- switch (_c.label) {
1115
- case 0:
1116
- discount = 0;
1117
- if (!(checkout.user.isSubscriber && coupon.discount.subscriber.value)) return [3 /*break*/, 2];
1118
- return [4 /*yield*/, this.calcDiscountByType(coupon.discount.subscriber.type, coupon.discount.subscriber.value, coupon.productsCategories, checkout)];
1119
- case 1:
1120
- discount = _c.sent();
1121
- return [3 /*break*/, 4];
1122
- case 2: return [4 /*yield*/, this.calcDiscountByType(coupon.discount.non_subscriber.type, coupon.discount.non_subscriber.value, coupon.productsCategories, checkout)];
1123
- case 3:
1124
- discount = _c.sent();
1125
- _c.label = 4;
1126
- case 4: return [2 /*return*/, discount];
1127
- }
1128
- });
1129
- });
1130
- };
1131
- CouponService.prototype.calcDiscountByType = function (type, value, categories, checkout) {
1132
- return __awaiter(this, void 0, void 0, function () {
1133
- var discount, lineItensDiscount, subTotal;
1134
- return __generator(this, function (_c) {
1135
- switch (_c.label) {
1136
- case 0:
1137
- discount = 0;
1138
- return [4 /*yield*/, this.getLineItensEligebleForDiscount(categories, checkout)];
1139
- case 1:
1140
- lineItensDiscount = _c.sent();
1141
- subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
1142
- if (type == i1.CouponTypes.ABSOLUTE) {
1143
- discount = value > subTotal ? subTotal : value;
1144
- }
1145
- else {
1146
- discount = subTotal * (value / 100);
1147
- }
1148
- return [2 /*return*/, discount];
1149
- }
1150
- });
1151
- });
1152
- };
1153
- CouponService.prototype.hasMinSubTotal = function (coupon, checkout) {
1154
- return __awaiter(this, void 0, void 0, function () {
1155
- var lineItensDiscount, subTotal;
1156
- return __generator(this, function (_c) {
1157
- switch (_c.label) {
1158
- case 0:
1159
- if (!coupon.minSubTotalValue)
1160
- return [2 /*return*/, true];
1161
- return [4 /*yield*/, this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout)];
1162
- case 1:
1163
- lineItensDiscount = _c.sent();
1164
- subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
1165
- if (coupon.minSubTotalValue <= subTotal)
1166
- return [2 /*return*/, true];
1167
- return [2 /*return*/, false];
1168
- }
1169
- });
1170
- });
1171
- };
1172
- CouponService.prototype.hasProductCategories = function (coupon, checkout) {
1173
- var _a;
1174
- return __awaiter(this, void 0, void 0, function () {
1175
- var couponCategories, hasCategories;
1176
- return __generator(this, function (_c) {
1177
- switch (_c.label) {
1178
- case 0:
1179
- if (!coupon.productsCategories || !coupon.productsCategories.length) {
1180
- return [2 /*return*/, true];
1181
- }
1182
- return [4 /*yield*/, this.getCouponCategoriesId(coupon.productsCategories)];
1183
- case 1:
1184
- couponCategories = _c.sent();
1185
- hasCategories = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter(function (i) {
1186
- var _a;
1187
- if (!i.categories || !((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length))
1188
- return true;
1189
- return i.categories.some(function (c) { return couponCategories.some(function (cat) { return cat == c; }); });
1190
- });
1191
- return [2 /*return*/, hasCategories.length ? true : false];
1192
- }
1193
- });
1194
- });
1195
- };
1196
- CouponService.prototype.coupomUserValidation = function (coupon, user) {
1197
- if (!user || coupon.exclusivityType.includes(i1.Exclusivities.ALL_USERS))
1198
- return true;
1199
- var userTypes = [];
1200
- if (coupon.exclusivityType.includes(i1.Exclusivities.COLLABORATORS) && this.emailIsFromCollaborator(user.email))
1201
- userTypes.push(i1.Exclusivities.COLLABORATORS);
1202
- if (coupon.exclusivityType.includes(i1.Exclusivities.SPECIFIC_USER) && coupon.userExclusiveEmail.includes(user.email))
1203
- userTypes.push(i1.Exclusivities.SPECIFIC_USER);
1204
- if (coupon.exclusivityType.includes(i1.Exclusivities.ACTIVE_SUBSCRIBER) &&
1205
- user.isSubscriber &&
1206
- user.subscriptionPlan != '')
1207
- userTypes.push(i1.Exclusivities.ACTIVE_SUBSCRIBER);
1208
- if (user.isSubscriber &&
1209
- user.subscriptionPlan == '' &&
1210
- coupon.exclusivityType.includes(i1.Exclusivities.INACTIVE_SUBSCRIBER))
1211
- userTypes.push(i1.Exclusivities.INACTIVE_SUBSCRIBER);
1212
- if (coupon.exclusivityType.includes(i1.Exclusivities.NON_SUBSCRIBER) && !user.isSubscriber)
1213
- userTypes.push(i1.Exclusivities.NON_SUBSCRIBER);
1214
- return coupon.exclusivityType.some(function (r) { return userTypes.includes(r); });
1215
- };
1216
- CouponService.prototype.getCouponCategoriesId = function (productsCategories) {
1217
- return __awaiter(this, void 0, void 0, function () {
1218
- var couponCategories, index, category, children;
1219
- return __generator(this, function (_c) {
1220
- switch (_c.label) {
1221
- case 0:
1222
- couponCategories = [];
1223
- index = 0;
1224
- _c.label = 1;
1225
- case 1:
1226
- if (!(index < productsCategories.length)) return [3 /*break*/, 5];
1227
- return [4 /*yield*/, this.categoryRepository.get({
1228
- id: productsCategories[index],
1229
- })];
1230
- case 2:
1231
- category = _c.sent();
1232
- if (!category) return [3 /*break*/, 4];
1233
- return [4 /*yield*/, this.categoryRepository.getChildren(parseInt(productsCategories[index]))];
1234
- case 3:
1235
- children = _c.sent();
1236
- couponCategories.push.apply(couponCategories, __spreadArray([category.id], __read(children.map(function (c) { return c.id.toString(); }))));
1237
- _c.label = 4;
1238
- case 4:
1239
- index++;
1240
- return [3 /*break*/, 1];
1241
- case 5: return [2 /*return*/, __spreadArray([], __read(new Set(couponCategories)))];
1242
- }
1243
- });
1244
- });
1245
- };
1246
- CouponService.prototype.getLineItensEligebleForDiscount = function (productsCategories, checkout) {
1247
- var _a;
1248
- return __awaiter(this, void 0, void 0, function () {
1249
- var lineItensDiscount, couponCategories;
1250
- return __generator(this, function (_c) {
1251
- switch (_c.label) {
1252
- case 0:
1253
- lineItensDiscount = [];
1254
- return [4 /*yield*/, this.getCouponCategoriesId(productsCategories)];
1255
- case 1:
1256
- couponCategories = _c.sent();
1257
- if (productsCategories && productsCategories.length) {
1258
- lineItensDiscount = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter(function (i) {
1259
- var _a;
1260
- if ((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length) {
1261
- return i.categories.some(function (c) { return couponCategories.some(function (cat) { return cat == c; }); });
1262
- }
1263
- return true;
1264
- });
1265
- }
1266
- else {
1267
- lineItensDiscount = checkout.lineItems;
1268
- }
1269
- return [2 /*return*/, lineItensDiscount];
1270
- }
1271
- });
1272
- });
1273
- };
1274
- CouponService.prototype.calcCheckoutSubtotal = function (lineItens, user, shop) {
1275
- return ((lineItens === null || lineItens === void 0 ? void 0 : lineItens.reduce(function (acc, curr) {
1276
- var _a, _b;
1277
- return (user === null || user === void 0 ? void 0 : user.isSubscriber) && ((_a = curr.price[shop]) === null || _a === void 0 ? void 0 : _a.subscriberPrice)
1278
- ? acc + ((_b = curr.price[shop]) === null || _b === void 0 ? void 0 : _b.subscriberPrice) * curr.quantity
1279
- : acc + curr.pricePaid * curr.quantity;
1280
- }, 0)) || 0);
1281
- };
1282
- CouponService.prototype.getOrdersWithCoupon = function (coupon) {
1283
- return __awaiter(this, void 0, void 0, function () {
1284
- return __generator(this, function (_c) {
1285
- switch (_c.label) {
1286
- case 0: return [4 /*yield*/, this.orderRepository
1287
- .find({
1288
- filters: {
1289
- coupon: { id: coupon.id },
1290
- payment: { status: 'paid' },
1291
- },
1292
- })
1293
- .then(function (result) { return result.data; })];
1294
- case 1: return [2 /*return*/, _c.sent()];
1295
- }
1296
- });
1297
- });
1298
- };
1299
- CouponService.prototype.countOrdersWithUser = function (orders, email) {
1300
- return orders.filter(function (o) { return o.user.email == email; }).length;
1301
- };
1302
- CouponService.prototype.getCouponUseLimits = function (coupon, checkoutType, user) {
1303
- var couponUseLimits;
1304
- if (checkoutType == i1.CheckoutTypes.ECOMMERCE || checkoutType == i1.CheckoutTypes.ALL) {
1305
- couponUseLimits = user && user.isSubscriber ? coupon.useLimits.subscriber : coupon.useLimits.non_subscriber;
1306
- }
1307
- else {
1308
- couponUseLimits = coupon.useLimits.subscription;
1309
- }
1310
- return couponUseLimits;
1311
- };
1312
- return CouponService;
1313
- }());
1314
- CouponService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }, { token: 'OrderRepository' }, { token: 'CategoryRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1315
- CouponService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CouponService, providedIn: 'root' });
1316
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CouponService, decorators: [{
1317
- type: i0.Injectable,
1318
- args: [{
1319
- providedIn: 'root',
1320
- }]
1321
- }], ctorParameters: function () {
1322
- return [{ type: undefined, decorators: [{
1323
- type: i0.Inject,
1324
- args: ['CouponRepository']
1325
- }] }, { type: i1__namespace$1.Shops, decorators: [{
1326
- type: i0.Inject,
1327
- args: [DEFAULT_SHOP]
1328
- }] }, { type: undefined, decorators: [{
1329
- type: i0.Inject,
1330
- args: ['OrderRepository']
1331
- }] }, { type: undefined, decorators: [{
1332
- type: i0.Inject,
1333
- args: ['CategoryRepository']
1334
- }] }];
1335
- } });
1336
-
1337
- var CheckoutService = /** @class */ (function () {
1338
- function CheckoutService(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
1339
- this.couponService = couponService;
1340
- this.checkoutRepository = checkoutRepository;
1341
- this.orderRepository = orderRepository;
1342
- this.userRepository = userRepository;
1343
- this.defaultShop = defaultShop;
1344
- }
1345
- CheckoutService.prototype.getCheckout = function (checkoutData) {
1346
- var checkoutId = cookie__default["default"].get('checkoutId');
1347
- if (!i1.isNil(checkoutId))
1348
- return rxjs.from(this.checkoutRepository.get({ id: checkoutId }));
1349
- return rxjs.from(this.createCheckout(checkoutData));
1350
- };
1351
- CheckoutService.prototype.getUserByCheckout = function (checkoutId) {
1352
- var _this = this;
1353
- return rxjs.from(this.checkoutRepository.get({ id: checkoutId })).pipe(operators.concatMap(function (checkout) { var _a; return ((_a = checkout === null || checkout === void 0 ? void 0 : checkout.user) === null || _a === void 0 ? void 0 : _a.id) ? rxjs.of(checkout.user) : rxjs.from(_this.userRepository.get({ id: checkout.user.id })); }), operators.concatMap(function (user) { return rxjs.of(user) || rxjs.throwError(function () { return new i1.NotFoundError('User is not found'); }); }));
1354
- };
1355
- CheckoutService.prototype.updateCheckoutLineItems = function (checkout) {
1356
- return rxjs.from(this.checkoutRepository.update(i1.Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
1357
- };
1358
- CheckoutService.prototype.updateCheckoutUser = function (checkout) {
1359
- return rxjs.from(this.checkoutRepository.update(i1.Checkout.toInstance({ id: checkout.id, user: checkout.user })));
1360
- };
1361
- CheckoutService.prototype.clearCheckoutFromSession = function () {
1362
- cookie__default["default"].remove('checkoutId');
1363
- return rxjs.of();
1364
- };
1365
- CheckoutService.prototype.calcDiscount = function (coupon) {
1366
- var _this = this;
1367
- return this.getCheckout().pipe(operators.concatMap(function (checkout) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_b) {
1368
- switch (_b.label) {
1369
- case 0: return [4 /*yield*/, this.couponService.calcDiscountShopping(coupon, checkout)];
1370
- case 1: return [2 /*return*/, _b.sent()];
1371
- }
1372
- }); }); }));
1373
- };
1374
- CheckoutService.prototype.checkCoupon = function (nickname, checkoutType) {
1375
- var _this = this;
1376
- return this.getCheckout().pipe(operators.concatMap(function (checkout) { return _this.couponService.checkCoupon(nickname, i1.CheckoutTypes.ECOMMERCE, checkout, null).pipe(); }));
1377
- };
1378
- CheckoutService.prototype.createCheckout = function (checkoutData) {
1379
- return __awaiter(this, void 0, void 0, function () {
1380
- var checkout;
1381
- return __generator(this, function (_b) {
1382
- switch (_b.label) {
1383
- case 0: return [4 /*yield*/, this.checkoutRepository.create(Object.assign(Object.assign({ createdAt: new Date() }, i1.Checkout.toInstance(i1.pick(checkoutData, ['user', 'shop'])).toPlain()), { shop: (checkoutData === null || checkoutData === void 0 ? void 0 : checkoutData.shop) || this.defaultShop }))];
1384
- case 1:
1385
- checkout = _b.sent();
1386
- cookie__default["default"].set('checkoutId', checkout.id);
1387
- return [2 /*return*/, checkout];
1388
- }
1389
- });
1390
- });
1391
- };
1392
- return CheckoutService;
1393
- }());
1394
- CheckoutService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: 'OrderRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1395
- CheckoutService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutService });
1396
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutService, decorators: [{
1397
- type: i0.Injectable
1398
- }], ctorParameters: function () {
1399
- return [{ type: CouponService }, { type: undefined, decorators: [{
1400
- type: i0.Inject,
1401
- args: ['CheckoutRepository']
1402
- }] }, { type: undefined, decorators: [{
1403
- type: i0.Inject,
1404
- args: ['OrderRepository']
1405
- }] }, { type: undefined, decorators: [{
1406
- type: i0.Inject,
1407
- args: ['UserRepository']
1408
- }] }, { type: i1__namespace$1.Shops, decorators: [{
1409
- type: i0.Inject,
1410
- args: [DEFAULT_SHOP]
1411
- }] }];
1412
- } });
1413
-
1414
- var CartService = /** @class */ (function () {
1415
- function CartService(authService, checkoutService, defaultShop, productRepository, categoryRepository, variantRepository, buy2WinRepository) {
1416
- var _this = this;
1417
- this.authService = authService;
1418
- this.checkoutService = checkoutService;
1419
- this.defaultShop = defaultShop;
1420
- this.productRepository = productRepository;
1421
- this.categoryRepository = categoryRepository;
1422
- this.variantRepository = variantRepository;
1423
- this.buy2WinRepository = buy2WinRepository;
1424
- this.cartSubject = new rxjs.Subject();
1425
- this.updateLineItemInCart = function (lineItem, quantity, checkout) { return (i1.isNil(checkout) ? _this.checkoutService.getCheckout() : rxjs.of(checkout)).pipe(operators.concatMap(function (checkoutLoaded) {
1426
- var _a;
1427
- var items = [];
1428
- var index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map(function (checkoutItem) { return checkoutItem.id; }).indexOf(lineItem.id);
1429
- if (index > -1) {
1430
- checkoutLoaded.lineItems[index].quantity += quantity;
1431
- checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
1432
- }
1433
- else
1434
- checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
1435
- return _this.checkoutService
1436
- .updateCheckoutLineItems(checkoutLoaded)
1437
- .pipe(operators.map(function (updatedCheckout) { return _this.generateCartObject(updatedCheckout.lineItems); }));
1438
- })); };
1439
- this.generateCartObject = function (items) { return items
1440
- ? items.reduce(function (cart, item) {
1441
- var _h;
1442
- var _a;
1443
- return (Object.assign(Object.assign({}, cart), (_h = {}, _h[item.id] = i1.LineItem.toInstance(Object.assign(Object.assign({}, (cart[item.id] || item)), { quantity: (((_a = cart[item.id]) === null || _a === void 0 ? void 0 : _a.quantity) || 0) + (item.quantity ? item.quantity : 1) })), _h)));
1444
- }, {})
1445
- : []; };
1446
- this.buildLineItem = function (_h) {
1447
- var checkout = _h.checkout, item = _h.item, quantity = _h.quantity;
1448
- return __awaiter(_this, void 0, void 0, function () {
1449
- var _a, _b, _c, _d, _e, _f, _g, product, image, id, name, EAN, slug, stock, price, weight, sku, type, isGift, pricePaid;
1450
- return __generator(this, function (_h) {
1451
- switch (_h.label) {
1452
- case 0: return [4 /*yield*/, this.getProductData(item.id)];
1453
- case 1:
1454
- product = _h.sent();
1455
- item.quantity = (item === null || item === void 0 ? void 0 : item.quantity) || ((_b = (_a = checkout === null || checkout === void 0 ? void 0 : checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find(function (lineItem) { return lineItem.id === item.id; })) === null || _b === void 0 ? void 0 : _b.quantity) || 0;
1456
- if (this.checkMaxStock(item, quantity || 0))
1457
- throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
1458
- image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
1459
- id = item.id, name = item.name, EAN = item.EAN, slug = item.slug, stock = item.stock, price = item.price, weight = item.weight, sku = item.sku, type = item.type;
1460
- isGift = item.isGift || null;
1461
- pricePaid = this.getProductPrice({
1462
- product: item,
1463
- shop: checkout.shop || this.defaultShop,
1464
- isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
1465
- });
1466
- i1.RoundProductPricesHelper.roundProductPrices(item);
1467
- return [2 /*return*/, {
1468
- checkout: checkout,
1469
- lineItem: i1.LineItem.toInstance({
1470
- id: id,
1471
- name: name !== null && name !== void 0 ? name : product.name,
1472
- EAN: EAN !== null && EAN !== void 0 ? EAN : product.EAN,
1473
- brand: product.brand,
1474
- slug: slug !== null && slug !== void 0 ? slug : product.slug,
1475
- sku: sku !== null && sku !== void 0 ? sku : product.sku,
1476
- stock: stock,
1477
- price: this.roundPrice(price),
1478
- image: image,
1479
- weight: weight !== null && weight !== void 0 ? weight : product.weight,
1480
- quantity: (item.quantity || 0) + (quantity || 0),
1481
- pricePaid: pricePaid,
1482
- categories: (_f = product.categories) !== null && _f !== void 0 ? _f : [],
1483
- isGift: isGift !== null && isGift !== void 0 ? isGift : null,
1484
- costPrice: (_g = product.costPrice) !== null && _g !== void 0 ? _g : 0,
1485
- type: type,
1486
- }),
1487
- }];
1488
- }
1489
- });
1490
- });
1491
- };
1492
- this.getProductPrice = function (_h) {
1493
- var product = _h.product, isSubscriber = _h.isSubscriber;
1494
- var info = product.price;
1495
- if (product.isGift)
1496
- return 0;
1497
- return isSubscriber && info.subscriberPrice > 0
1498
- ? Number(info.subscriberPrice.toFixed(2))
1499
- : Number(info.price.toFixed(2));
1500
- };
1501
- this.checkMaxStock = function (item, quantity) {
1502
- var _a;
1503
- var maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
1504
- var currentItemAmount = item.quantity || 0;
1505
- return currentItemAmount + quantity > maxStock;
1506
- };
1507
- }
1508
- CartService.prototype.addItem = function (item, quantity) {
1509
- var _this = this;
1510
- if (quantity === void 0) { quantity = 1; }
1511
- return rxjs.from(this.checkoutService.getCheckout()).pipe(operators.concatMap(function (checkout) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_h) {
1512
- switch (_h.label) {
1513
- case 0: return [4 /*yield*/, this.buildLineItem({ checkout: checkout, item: item, quantity: quantity || 1 })];
1514
- case 1: return [2 /*return*/, _h.sent()];
1515
- }
1516
- }); }); }), operators.mergeMap(function (_h) {
1517
- var checkout = _h.checkout, lineItem = _h.lineItem;
1518
- return _this.updateLineItemInCart(lineItem, quantity || 1, checkout);
1519
- }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
1520
- };
1521
- CartService.prototype.decreaseItem = function (item) {
1522
- var _this = this;
1523
- return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
1524
- var _a;
1525
- var checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find(function (lineItem) { return lineItem.id === item.id; });
1526
- if (!i1.isNil(checkoutItem))
1527
- checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
1528
- return checkout;
1529
- }), operators.concatMap(function (checkout) { return _this.checkoutService.updateCheckoutLineItems(checkout); }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
1530
- };
1531
- CartService.prototype.getCart = function (checkout) {
1532
- var _this = this;
1533
- this.buildCartFromCheckout(checkout).subscribe(function (cart) { return _this.cartSubject.next(cart); });
1534
- return this.cartSubject;
1535
- };
1536
- /**
1537
- * @deprecated The method should not be used
1538
- */
1539
- CartService.prototype.getVariantPriceDiscount = function (item) {
1540
- return this.authService.getUser().pipe(operators.concatMap(function (user) { return rxjs.iif(function () { return user.isSubscriber && !!item.price.subscriberPrice; }, rxjs.of(item.price.subscriberPrice), rxjs.of(item.price.price)); }), operators.catchError(function () { return rxjs.of(item.price.price); }));
1541
- };
1542
- CartService.prototype.removeItem = function (item) {
1543
- var _this = this;
1544
- return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
1545
- var index = checkout.lineItems.findIndex(function (lineItem) { return lineItem.id === item.id; });
1546
- if (index >= 0)
1547
- checkout.lineItems.splice(index, 1);
1548
- return checkout;
1549
- }), operators.concatMap(function (checkout) { return _this.checkoutService.updateCheckoutLineItems(checkout); }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
1550
- };
1551
- CartService.prototype.updateUserCart = function (user) {
1552
- var _this = this;
1553
- return this.checkoutService.getCheckout().pipe(operators.concatMap(function (checkout) { return _this.checkoutService.updateCheckoutUser(i1.Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user: user }))); }), operators.concatMap(function (checkout) { return __awaiter(_this, void 0, void 0, function () {
1554
- var _a, _b, _h, _j, _k, _l, _m, _o, _p, _q, _r;
1555
- var _this = this;
1556
- return __generator(this, function (_s) {
1557
- switch (_s.label) {
1558
- case 0:
1559
- _j = (_h = this.checkoutService)
1560
- .updateCheckoutLineItems;
1561
- _l = (_k = i1.Checkout).toInstance;
1562
- _o = (_m = Object).assign;
1563
- _p = [Object.assign({}, checkout.toPlain())];
1564
- _q = {};
1565
- if (!((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.length)) return [3 /*break*/, 2];
1566
- return [4 /*yield*/, Promise.all((_b = checkout.lineItems) === null || _b === void 0 ? void 0 : _b.map(function (item) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_h) {
1567
- switch (_h.label) {
1568
- case 0: return [4 /*yield*/, this.buildLineItem({ checkout: checkout, item: item })];
1569
- case 1: return [2 /*return*/, (_h.sent()).lineItem];
1570
- }
1571
- }); }); }))];
1572
- case 1:
1573
- _r = _s.sent();
1574
- return [3 /*break*/, 3];
1575
- case 2:
1576
- _r = [];
1577
- _s.label = 3;
1578
- case 3: return [2 /*return*/, _j.apply(_h, [_l.apply(_k, [_o.apply(_m, _p.concat([(_q.lineItems = _r, _q)]))])])
1579
- .toPromise()];
1580
- }
1581
- });
1582
- }); }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
1583
- };
1584
- CartService.prototype.clearCart = function () {
1585
- var _this = this;
1586
- return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
1587
- _this.checkoutService.clearCheckoutFromSession();
1588
- return checkout;
1589
- }), operators.concatMap(function (oldCheckout) { return _this.buildCartFromCheckout(oldCheckout); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
1590
- };
1591
- CartService.prototype.buildCartFromCheckout = function (checkoutData) {
1592
- var _this = this;
1593
- return this.checkoutService.getCheckout(checkoutData).pipe(operators.map(function (checkout) { return checkout.lineItems; }), operators.concatMap(function (lineItems) { return rxjs.of(_this.generateCartObject(lineItems)); }));
1594
- };
1595
- CartService.prototype.roundPrice = function (productPrice) {
1596
- var price = productPrice.price, fullPrice = productPrice.fullPrice, subscriberPrice = productPrice.subscriberPrice;
1597
- return Object.assign(Object.assign(Object.assign({}, productPrice), { price: Number(price.toFixed(2)), fullPrice: Number(fullPrice.toFixed(2)) }), (subscriberPrice && { subscriberPrice: Number(subscriberPrice.toFixed(2)) }));
1598
- };
1599
- CartService.prototype.getProductData = function (productId) {
1600
- return __awaiter(this, void 0, void 0, function () {
1601
- var product, variant, error_1, variants;
1602
- return __generator(this, function (_h) {
1603
- switch (_h.label) {
1604
- case 0:
1605
- _h.trys.push([0, 2, , 5]);
1606
- return [4 /*yield*/, this.productRepository.get({ id: productId })];
1607
- case 1:
1608
- product = _h.sent();
1609
- return [3 /*break*/, 5];
1610
- case 2:
1611
- error_1 = _h.sent();
1612
- if (!(error_1 instanceof i1.NotFoundError))
1613
- throw error_1;
1614
- return [4 /*yield*/, this.variantRepository.find({ filters: { id: productId } })];
1615
- case 3:
1616
- variants = (_h.sent()).data;
1617
- variant = variants.shift();
1618
- if (!variant)
1619
- throw error_1;
1620
- return [4 /*yield*/, this.productRepository.get({ id: variant.productId })];
1621
- case 4:
1622
- product = _h.sent();
1623
- return [3 /*break*/, 5];
1624
- case 5: return [2 /*return*/, Object.assign(Object.assign({}, product.toPlain()), (variant && Object.assign({}, variant.toPlain())))];
1625
- }
1626
- });
1627
- });
1628
- };
1629
- CartService.prototype.getGifts = function () {
1630
- var _this = this;
1631
- return this.checkoutService.getCheckout().pipe(operators.mergeMap(function (checkout) { return __awaiter(_this, void 0, void 0, function () {
1632
- var notGiftItems, cartTotal, campaigns, elegibleCampaigns, _loop_1, this_1, campaigns_1, campaigns_1_1, campaign, e_1_1, campaingnProducts, elegibleCampaigns_1, elegibleCampaigns_1_1, campaign, elegibleProducts, _h, _j, product, productData, gift, e_2_1, e_3_1, gifts;
1633
- var e_1, _k, e_3, _l, e_2, _m;
1634
- return __generator(this, function (_o) {
1635
- switch (_o.label) {
1636
- case 0:
1637
- notGiftItems = checkout.lineItems ? checkout.lineItems.filter(function (item) { return !item.isGift; }) : [];
1638
- if (!notGiftItems.length)
1639
- return [2 /*return*/, Object.assign(Object.assign({}, checkout), { lineItems: [] })];
1640
- cartTotal = notGiftItems.reduce(function (a, b) { return a + b.pricePaid * b.quantity; }, 0);
1641
- return [4 /*yield*/, this.buy2WinRepository
1642
- .find({
1643
- filters: {
1644
- active: { operator: i1.Where.EQUALS, value: true },
1645
- shop: { operator: i1.Where.EQUALS, value: this.defaultShop },
1646
- },
1647
- })
1648
- .then(function (data) { return data.data; })];
1649
- case 1:
1650
- campaigns = _o.sent();
1651
- if (!campaigns.length)
1652
- return [2 /*return*/, Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems })];
1653
- elegibleCampaigns = [];
1654
- _loop_1 = function (campaign) {
1655
- var today, categoriesCampaing, categoriesCampaingFullTree, categoriesCampaing_1, categoriesCampaing_1_1, id, children, e_4_1, categoriesCampaingTree_1, filterProductsCategories, cartTotalCategories;
1656
- var e_4, _p;
1657
- return __generator(this, function (_q) {
1658
- switch (_q.label) {
1659
- case 0:
1660
- today = new Date().getDate();
1661
- if (!(campaign.startDate.getDate() <= today) && !(campaign.endDate.getDate() >= today))
1662
- return [2 /*return*/, "continue"];
1663
- if (!campaign.activeCategory) return [3 /*break*/, 9];
1664
- categoriesCampaing = campaign.categories.map(function (c) { return c.id.toString(); });
1665
- categoriesCampaingFullTree = [];
1666
- _q.label = 1;
1667
- case 1:
1668
- _q.trys.push([1, 6, 7, 8]);
1669
- categoriesCampaing_1 = (e_4 = void 0, __values(categoriesCampaing)), categoriesCampaing_1_1 = categoriesCampaing_1.next();
1670
- _q.label = 2;
1671
- case 2:
1672
- if (!!categoriesCampaing_1_1.done) return [3 /*break*/, 5];
1673
- id = categoriesCampaing_1_1.value;
1674
- return [4 /*yield*/, this_1.categoryRepository.getChildren(parseInt(id))];
1675
- case 3:
1676
- children = _q.sent();
1677
- categoriesCampaingFullTree.push.apply(categoriesCampaingFullTree, __spreadArray([id], __read(children.map(function (c) { return c.id.toString(); }))));
1678
- _q.label = 4;
1679
- case 4:
1680
- categoriesCampaing_1_1 = categoriesCampaing_1.next();
1681
- return [3 /*break*/, 2];
1682
- case 5: return [3 /*break*/, 8];
1683
- case 6:
1684
- e_4_1 = _q.sent();
1685
- e_4 = { error: e_4_1 };
1686
- return [3 /*break*/, 8];
1687
- case 7:
1688
- try {
1689
- if (categoriesCampaing_1_1 && !categoriesCampaing_1_1.done && (_p = categoriesCampaing_1.return)) _p.call(categoriesCampaing_1);
1690
- }
1691
- finally { if (e_4) throw e_4.error; }
1692
- return [7 /*endfinally*/];
1693
- case 8:
1694
- categoriesCampaingTree_1 = __spreadArray([], __read(new Set(categoriesCampaingFullTree)));
1695
- filterProductsCategories = checkout.lineItems.filter(function (l) {
1696
- var _a;
1697
- if (!l.categories || !((_a = l.categories) === null || _a === void 0 ? void 0 : _a.length))
1698
- return true;
1699
- return l.categories.some(function (c) { return categoriesCampaingTree_1.some(function (cat) { return cat == c; }); });
1700
- });
1701
- if (filterProductsCategories.length) {
1702
- cartTotalCategories = filterProductsCategories.reduce(function (a, b) { return a + b.pricePaid * b.quantity; }, 0);
1703
- if (cartTotalCategories >= campaign.cartValueMin)
1704
- elegibleCampaigns.push(campaign);
1705
- }
1706
- return [3 /*break*/, 10];
1707
- case 9:
1708
- if (campaign.cartValue && campaign.cartValue > 0) {
1709
- if (campaign.cartValue <= cartTotal)
1710
- elegibleCampaigns.push(campaign);
1711
- }
1712
- _q.label = 10;
1713
- case 10: return [2 /*return*/];
1714
- }
1715
- });
1716
- };
1717
- this_1 = this;
1718
- _o.label = 2;
1719
- case 2:
1720
- _o.trys.push([2, 7, 8, 9]);
1721
- campaigns_1 = __values(campaigns), campaigns_1_1 = campaigns_1.next();
1722
- _o.label = 3;
1723
- case 3:
1724
- if (!!campaigns_1_1.done) return [3 /*break*/, 6];
1725
- campaign = campaigns_1_1.value;
1726
- return [5 /*yield**/, _loop_1(campaign)];
1727
- case 4:
1728
- _o.sent();
1729
- _o.label = 5;
1730
- case 5:
1731
- campaigns_1_1 = campaigns_1.next();
1732
- return [3 /*break*/, 3];
1733
- case 6: return [3 /*break*/, 9];
1734
- case 7:
1735
- e_1_1 = _o.sent();
1736
- e_1 = { error: e_1_1 };
1737
- return [3 /*break*/, 9];
1738
- case 8:
1739
- try {
1740
- if (campaigns_1_1 && !campaigns_1_1.done && (_k = campaigns_1.return)) _k.call(campaigns_1);
1741
- }
1742
- finally { if (e_1) throw e_1.error; }
1743
- return [7 /*endfinally*/];
1744
- case 9:
1745
- if (!elegibleCampaigns.length)
1746
- return [2 /*return*/, Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems })];
1747
- campaingnProducts = [];
1748
- _o.label = 10;
1749
- case 10:
1750
- _o.trys.push([10, 22, 23, 24]);
1751
- elegibleCampaigns_1 = __values(elegibleCampaigns), elegibleCampaigns_1_1 = elegibleCampaigns_1.next();
1752
- _o.label = 11;
1753
- case 11:
1754
- if (!!elegibleCampaigns_1_1.done) return [3 /*break*/, 21];
1755
- campaign = elegibleCampaigns_1_1.value;
1756
- elegibleProducts = [];
1757
- _o.label = 12;
1758
- case 12:
1759
- _o.trys.push([12, 17, 18, 19]);
1760
- _h = (e_2 = void 0, __values(campaign.products)), _j = _h.next();
1761
- _o.label = 13;
1762
- case 13:
1763
- if (!!_j.done) return [3 /*break*/, 16];
1764
- product = _j.value;
1765
- return [4 /*yield*/, this.productRepository.find({ filters: { sku: product } })];
1766
- case 14:
1767
- productData = (_o.sent()).data;
1768
- if (!productData.length)
1769
- return [3 /*break*/, 15];
1770
- gift = productData.shift();
1771
- if (gift.stock.quantity < 1)
1772
- return [3 /*break*/, 15];
1773
- elegibleProducts.push(gift);
1774
- _o.label = 15;
1775
- case 15:
1776
- _j = _h.next();
1777
- return [3 /*break*/, 13];
1778
- case 16: return [3 /*break*/, 19];
1779
- case 17:
1780
- e_2_1 = _o.sent();
1781
- e_2 = { error: e_2_1 };
1782
- return [3 /*break*/, 19];
1783
- case 18:
1784
- try {
1785
- if (_j && !_j.done && (_m = _h.return)) _m.call(_h);
1786
- }
1787
- finally { if (e_2) throw e_2.error; }
1788
- return [7 /*endfinally*/];
1789
- case 19:
1790
- campaingnProducts.push(elegibleProducts);
1791
- _o.label = 20;
1792
- case 20:
1793
- elegibleCampaigns_1_1 = elegibleCampaigns_1.next();
1794
- return [3 /*break*/, 11];
1795
- case 21: return [3 /*break*/, 24];
1796
- case 22:
1797
- e_3_1 = _o.sent();
1798
- e_3 = { error: e_3_1 };
1799
- return [3 /*break*/, 24];
1800
- case 23:
1801
- try {
1802
- if (elegibleCampaigns_1_1 && !elegibleCampaigns_1_1.done && (_l = elegibleCampaigns_1.return)) _l.call(elegibleCampaigns_1);
1803
- }
1804
- finally { if (e_3) throw e_3.error; }
1805
- return [7 /*endfinally*/];
1806
- case 24:
1807
- if (!campaingnProducts.length)
1808
- return [2 /*return*/, Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems })];
1809
- gifts = this.giftToLineItems([].concat.apply([], __spreadArray([], __read(campaingnProducts))));
1810
- return [2 /*return*/, Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems.concat(gifts) })];
1811
- }
1812
- });
1813
- }); }), operators.concatMap(function (checkout) { return _this.checkoutService.updateCheckoutLineItems(checkout); }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
1814
- };
1815
- CartService.prototype.giftToLineItems = function (items) {
1816
- return items.map(function (item) {
1817
- var _a;
1818
- var brand = item.brand, categories = item.categories, id = item.id, name = item.name, price = item.price, sku = item.sku, slug = item.slug, stock = item.stock, weight = item.weight, EAN = item.EAN;
1819
- var image = ((_a = item === null || item === void 0 ? void 0 : item.miniatures) === null || _a === void 0 ? void 0 : _a.length) ? item.miniatures[0] : item.images[0];
1820
- return i1.LineItem.toInstance({
1821
- brand: brand,
1822
- categories: categories,
1823
- id: id.toString(),
1824
- name: name,
1825
- price: price,
1826
- sku: sku,
1827
- slug: slug,
1828
- stock: stock,
1829
- weight: weight,
1830
- EAN: EAN,
1831
- image: image,
1832
- pricePaid: 0,
1833
- quantity: 1,
1834
- isGift: true,
1835
- });
1836
- });
1837
- };
1838
- return CartService;
1839
- }());
1840
- CartService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: 'VariantRepository' }, { token: 'Buy2WinRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1841
- CartService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService });
1842
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService, decorators: [{
1843
- type: i0.Injectable
1844
- }], ctorParameters: function () {
1845
- return [{ type: AuthService }, { type: CheckoutService }, { type: i1__namespace$1.Shops, decorators: [{
1846
- type: i0.Inject,
1847
- args: [DEFAULT_SHOP]
1848
- }] }, { type: undefined, decorators: [{
1849
- type: i0.Inject,
1850
- args: ['ProductRepository']
1851
- }] }, { type: undefined, decorators: [{
1852
- type: i0.Inject,
1853
- args: ['CategoryRepository']
1854
- }] }, { type: undefined, decorators: [{
1855
- type: i0.Inject,
1856
- args: ['VariantRepository']
1857
- }] }, { type: i1__namespace$1.Buy2WinFirestoreRepository, decorators: [{
1858
- type: i0.Inject,
1859
- args: ['Buy2WinRepository']
1860
- }] }];
1861
- } });
1862
-
1863
- var CatalogService = /** @class */ (function () {
1864
- function CatalogService(productRepository, categoryStructureAdapter, shop, productIndex) {
1865
- this.productRepository = productRepository;
1866
- this.categoryStructureAdapter = categoryStructureAdapter;
1867
- this.shop = shop;
1868
- this.productIndex = productIndex;
1869
- this.buildFilterQuery = function (_j) {
1870
- var clubDiscount = _j.clubDiscount, brands = _j.brands, prices = _j.prices, gender = _j.gender, tags = _j.tags, rate = _j.rate, customOptions = _j.customOptions;
1871
- var filters = {};
1872
- if (clubDiscount === null || clubDiscount === void 0 ? void 0 : clubDiscount.length)
1873
- i1.set(filters, 'price.subscriberDiscountPercentage', { operator: i1.Where.IN, value: clubDiscount });
1874
- if (brands === null || brands === void 0 ? void 0 : brands.length)
1875
- filters.brand = { operator: i1.Where.IN, value: brands };
1876
- if (gender === null || gender === void 0 ? void 0 : gender.length)
1877
- filters.tags = {
1878
- operator: i1.Where.IN,
1879
- value: gender
1880
- .map(function (genderOptions) { return genderOptions === 'female' ? 'feminino' : genderOptions === 'male' ? 'masculino' : null; })
1881
- .filter(Boolean),
1882
- };
1883
- if ((prices === null || prices === void 0 ? void 0 : prices.min) || (prices === null || prices === void 0 ? void 0 : prices.max))
1884
- i1.set(filters, prices.subscriberPrice ? 'price.subscriberPrice' : 'price.price', __spreadArray(__spreadArray([], __read((prices.min ? [{ operator: i1.Where.GTE, value: Math.round(prices.min) }] : []))), __read((prices.max ? [{ operator: i1.Where.LTE, value: Math.ceil(prices.max) }] : []))));
1885
- if (rate)
1886
- filters.rate = { operator: i1.Where.GTE, value: rate };
1887
- if (tags === null || tags === void 0 ? void 0 : tags.length)
1888
- filters.tags = { operator: i1.Where.LIKE, value: tags };
1889
- if (customOptions === null || customOptions === void 0 ? void 0 : customOptions.length)
1890
- filters.filters = { operator: i1.Where.LIKE, value: customOptions };
1891
- return filters;
1892
- };
1893
- this.buildSortQuery = function (sort) {
1894
- if (!sort || sort === 'most-relevant')
1895
- return {};
1896
- if (sort === 'best-sellers')
1897
- return { shoppingCount: 'desc' };
1898
- if (sort === 'biggest-price')
1899
- return { price: 'desc' };
1900
- if (sort === 'lowest-price')
1901
- return { price: 'asc' };
1902
- if (sort === 'best-rating')
1903
- return { rate: 'desc' };
1904
- if (sort === 'news')
1905
- return { createdAt: 'desc' };
1906
- };
1907
- this.buildLimitQuery = function (options) {
1908
- var limit = (options === null || options === void 0 ? void 0 : options.perPage) || 20;
1909
- return {
1910
- limit: limit,
1911
- offset: (((options === null || options === void 0 ? void 0 : options.page) || 1) - 1) * limit,
1912
- };
1913
- };
1914
- this.hasProfile = function (options) { return 'profile' in options; };
1915
- this.hasTerm = function (options) { return 'term' in options; };
1916
- this.hasCategory = function (options) { return 'category' in options; };
1917
- }
1918
- CatalogService.prototype.fetchProducts = function (options) {
1919
- var _a, _b, _c;
1920
- return __awaiter(this, void 0, void 0, function () {
1921
- var limits;
1922
- return __generator(this, function (_j) {
1923
- switch (_j.label) {
1924
- case 0:
1925
- limits = this.buildLimitQuery(options);
1926
- if (this.hasProfile(options) && ((_a = options.filters) === null || _a === void 0 ? void 0 : _a.customOptions))
1927
- throw new i1.InvalidArgumentError("It couldn't filled customOptions when profile is given");
1928
- if (this.hasProfile(options) && ((_b = options.filters) === null || _b === void 0 ? void 0 : _b.tags))
1929
- throw new i1.InvalidArgumentError("It couldn't filled tags when profile is given");
1930
- if (this.hasTerm(options) && ((_c = options.filters) === null || _c === void 0 ? void 0 : _c.customOptions))
1931
- throw new i1.InvalidArgumentError("It couldn't filled customOptions when term is given");
1932
- return [4 /*yield*/, this.findCatalog(options, limits).then(function (_j) {
1933
- var data = _j.data, total = _j.count, maximum = _j.maximum, minimal = _j.minimal, distinct = _j.distinct;
1934
- var _a, _b, _c, _d, _e, _f, _g, _h;
1935
- return ({
1936
- products: { data: data.map(function (product) { return i1.RoundProductPricesHelper.roundProductPrices(product); }), total: total },
1937
- pages: Math.ceil(total / limits.limit),
1938
- prices: {
1939
- price: { min: +((_b = (_a = minimal === null || minimal === void 0 ? void 0 : minimal.price) === null || _a === void 0 ? void 0 : _a.price) === null || _b === void 0 ? void 0 : _b.toFixed(2)), max: +((_d = (_c = maximum === null || maximum === void 0 ? void 0 : maximum.price) === null || _c === void 0 ? void 0 : _c.price) === null || _d === void 0 ? void 0 : _d.toFixed(2)) },
1940
- subscriberPrice: {
1941
- min: +((_f = (_e = minimal === null || minimal === void 0 ? void 0 : minimal.price) === null || _e === void 0 ? void 0 : _e.subscriberPrice) === null || _f === void 0 ? void 0 : _f.toFixed(2)),
1942
- max: +((_h = (_g = maximum === null || maximum === void 0 ? void 0 : maximum.price) === null || _g === void 0 ? void 0 : _g.subscriberPrice) === null || _h === void 0 ? void 0 : _h.toFixed(2)),
1943
- },
1944
- },
1945
- brands: distinct === null || distinct === void 0 ? void 0 : distinct.brand,
1946
- });
1947
- })];
1948
- case 1: return [2 /*return*/, _j.sent()];
1949
- }
1950
- });
1951
- });
1952
- };
1953
- CatalogService.prototype.findCatalog = function (options, limits) {
1954
- return __awaiter(this, void 0, void 0, function () {
1955
- var repoParams, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
1956
- return __generator(this, function (_u) {
1957
- switch (_u.label) {
1958
- case 0:
1959
- _k = (_j = Object).assign;
1960
- _m = (_l = Object).assign;
1961
- _o = {};
1962
- _q = (_p = Object).assign;
1963
- _s = (_r = Object).assign;
1964
- _t = [{}];
1965
- return [4 /*yield*/, this.buildMainFilter(options)];
1966
- case 1:
1967
- repoParams = _k.apply(_j, [_m.apply(_l, [(_o.filters = _q.apply(_p, [_s.apply(_r, _t.concat([(_u.sent())])), this.buildFilterQuery((options === null || options === void 0 ? void 0 : options.filters) || {})]), _o), ((options === null || options === void 0 ? void 0 : options.sort) ? { orderBy: this.buildSortQuery(options === null || options === void 0 ? void 0 : options.sort) } : {})]), { limits: limits, options: Object.assign({ minimal: ['price'], maximum: ['price'] }, (!this.hasCategory(options) ? { distinct: ['brand'] } : {})) }]);
1968
- if (['biggest-price', 'lowest-price', 'biggest-discount', 'best-rating'].includes(options.sort))
1969
- return [2 /*return*/, this.productRepository.findCatalog(repoParams)];
1970
- return [2 /*return*/, this.productRepository.findCatalog(repoParams, (options === null || options === void 0 ? void 0 : options.mainGender) || this.shop === i1.Shops.MENSMARKET ? 'male' : 'female')];
1971
- }
1972
- });
1973
- });
1974
- };
1975
- CatalogService.prototype.buildMainFilter = function (_j) {
1976
- var category = _j.category, profile = _j.profile, term = _j.term;
1977
- return __awaiter(this, void 0, void 0, function () {
1978
- return __generator(this, function (_j) {
1979
- if (category)
1980
- return [2 /*return*/, this.categoryStructureAdapter.buildProductFilterByCategory(category)];
1981
- if (profile)
1982
- return [2 /*return*/, { tags: { operator: i1.Where.LIKE, value: profile } }];
1983
- if (term)
1984
- return [2 /*return*/, this.productIndex
1985
- .search(term, 9999, this.shop)
1986
- .then(function (data) { return ({ id: { operator: i1.Where.IN, value: data.hits.map(function (_j) {
1987
- var _source = _j._source;
1988
- return _source.id;
1989
- }) } }); })];
1990
- return [2 /*return*/];
1991
- });
1992
- });
1993
- };
1994
- return CatalogService;
1995
- }());
1996
- CatalogService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }, { token: i1__namespace$1.ProductsIndex }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1997
- CatalogService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CatalogService });
1998
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CatalogService, decorators: [{
1999
- type: i0.Injectable
2000
- }], ctorParameters: function () {
2001
- return [{ type: undefined, decorators: [{
2002
- type: i0.Inject,
2003
- args: ['ProductRepository']
2004
- }] }, { type: undefined, decorators: [{
2005
- type: i0.Inject,
2006
- args: [CATEGORY_STRUCTURE]
2007
- }] }, { type: i1__namespace$1.Shops, decorators: [{
2008
- type: i0.Inject,
2009
- args: [DEFAULT_SHOP]
2010
- }] }, { type: i1__namespace$1.ProductsIndex }];
2011
- } });
2012
-
2013
- var CategoryService = /** @class */ (function () {
2014
- function CategoryService(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop) {
2015
- this.productRepository = productRepository;
2016
- this.categoryRepository = categoryRepository;
2017
- this.categoryFilterRepository = categoryFilterRepository;
2018
- this.categoryStructureAdapter = categoryStructureAdapter;
2019
- this.shop = shop;
2020
- }
2021
- CategoryService.prototype.fetchBrands = function (category, mainGender) {
2022
- return __awaiter(this, void 0, void 0, function () {
2023
- var brands, _a, _b, _c;
2024
- return __generator(this, function (_d) {
2025
- switch (_d.label) {
2026
- case 0:
2027
- _b = (_a = this.productRepository)
2028
- .findCatalog;
2029
- _c = {};
2030
- return [4 /*yield*/, this.categoryStructureAdapter.buildProductFilterByCategory(category)];
2031
- case 1: return [4 /*yield*/, _b.apply(_a, [(_c.filters = _d.sent(),
2032
- _c.fields = ['brand'],
2033
- _c), mainGender || this.shop === i1.Shops.MENSMARKET ? 'male' : 'female'])
2034
- .then(function (_a) {
2035
- var data = _a.data;
2036
- return Object.keys(data.map(function (product) { return product.brand; }).reduce(function (brands, brand) {
2037
- var _a;
2038
- return (Object.assign(Object.assign({}, brands), (_a = {}, _a[brand] = true, _a)));
2039
- }, {}));
2040
- })];
2041
- case 2:
2042
- brands = _d.sent();
2043
- return [2 /*return*/, this.categoryRepository
2044
- .find({ filters: { brandCategory: true }, orderBy: { name: 'asc' } })
2045
- .then(function (_a) {
2046
- var data = _a.data;
2047
- return data.filter(function (category) { return brands.includes(category.conditions.brand); });
2048
- })];
2049
- }
2050
- });
2051
- });
2052
- };
2053
- CategoryService.prototype.fetchFilterOptions = function (category, filters) {
2054
- return __awaiter(this, void 0, void 0, function () {
2055
- return __generator(this, function (_a) {
2056
- switch (_a.label) {
2057
- case 0: return [4 /*yield*/, this.categoryFilterRepository
2058
- .find({ filters: { categoryId: +category.id } })
2059
- .then(function (_a) {
2060
- var data = _a.data;
2061
- return data.map(function (categoryFilter) { return categoryFilter.filter; });
2062
- })];
2063
- case 1: return [2 /*return*/, _a.sent()];
2064
- }
2065
- });
2066
- });
2067
- };
2068
- return CategoryService;
2069
- }());
2070
- CategoryService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CategoryService, deps: [{ token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: 'CategoryFilterRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
2071
- CategoryService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CategoryService });
2072
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CategoryService, decorators: [{
2073
- type: i0.Injectable
2074
- }], ctorParameters: function () {
2075
- return [{ type: undefined, decorators: [{
2076
- type: i0.Inject,
2077
- args: ['ProductRepository']
2078
- }] }, { type: undefined, decorators: [{
2079
- type: i0.Inject,
2080
- args: ['CategoryRepository']
2081
- }] }, { type: undefined, decorators: [{
2082
- type: i0.Inject,
2083
- args: ['CategoryFilterRepository']
2084
- }] }, { type: undefined, decorators: [{
2085
- type: i0.Inject,
2086
- args: [CATEGORY_STRUCTURE]
2087
- }] }, { type: i1__namespace$1.Shops, decorators: [{
2088
- type: i0.Inject,
2089
- args: [DEFAULT_SHOP]
2090
- }] }];
2091
- } });
2092
-
2093
- exports.ProductSorts = void 0;
2094
- (function (ProductSorts) {
2095
- ProductSorts["MOST_RELEVANT"] = "most-relevant";
2096
- ProductSorts["BEST_SELLER"] = "best-sellers";
2097
- ProductSorts["BIGGEST_PRICE"] = "biggest-price";
2098
- ProductSorts["LOWEST_PRICE"] = "lowest-price";
2099
- ProductSorts["BIGGEST_DISCOUNT"] = "biggest-discount";
2100
- ProductSorts["BEST_RATING"] = "best-rating";
2101
- ProductSorts["NEWS"] = "news";
2102
- })(exports.ProductSorts || (exports.ProductSorts = {}));
2103
-
2104
- var CategoryWithTree = /** @class */ (function (_super) {
2105
- __extends(CategoryWithTree, _super);
2106
- function CategoryWithTree() {
2107
- return _super !== null && _super.apply(this, arguments) || this;
2108
- }
2109
- return CategoryWithTree;
2110
- }(i1.Category));
2111
- __decorate([
2112
- classTransformer.Type(function () { return CategoryWithTree; }),
2113
- __metadata("design:type", Array)
2114
- ], CategoryWithTree.prototype, "children", void 0);
2115
-
2116
- var UtilHelper = /** @class */ (function () {
2117
- function UtilHelper() {
2118
- }
2119
- UtilHelper.createSlug = function (name) {
2120
- return name
2121
- .toLowerCase()
2122
- .replace(/\s+/g, '-') // Replace spaces with -
2123
- .replace(/[ãàáäâ]/g, 'a') // Replace spaces with -
2124
- .replace(/[ẽèéëê]/g, 'e') // Replace spaces with -
2125
- .replace(/[ìíïî]/g, 'i') // Replace spaces with -
2126
- .replace(/[õòóöô]/g, 'o') // Replace spaces with -
2127
- .replace(/[ùúüû]/g, 'u') // Replace spaces with -
2128
- .replace(/[ñ]/g, 'n') // Replace spaces with -
2129
- .replace(/[ç]/g, 'c') // Replace spaces with -
2130
- .replace(/[&]/g, 'and') // Replace spaces with -
2131
- .replace(/[^\w\-]+/g, '') // Remove all non-word chars
2132
- .replace(/\-\-+/g, '-'); // Replace multiple - with single -
2133
- };
2134
- return UtilHelper;
2135
- }());
2136
-
2137
- var NewCategoryStructureAdapter = /** @class */ (function () {
2138
- function NewCategoryStructureAdapter(categoryRepository, categoryCollectionChildrenRepository) {
2139
- this.categoryRepository = categoryRepository;
2140
- this.categoryCollectionChildrenRepository = categoryCollectionChildrenRepository;
2141
- }
2142
- NewCategoryStructureAdapter.prototype.buildProductFilterByCategory = function (category) {
2143
- return __awaiter(this, void 0, void 0, function () {
2144
- var categoriesIds, _a, _b;
2145
- return __generator(this, function (_c) {
2146
- switch (_c.label) {
2147
- case 0: return [4 /*yield*/, this.isCollection(category)];
2148
- case 1:
2149
- if (!(_c.sent())) return [3 /*break*/, 3];
2150
- return [4 /*yield*/, this.getAllCategoriesIdFromCollection(category)];
2151
- case 2:
2152
- _a = _c.sent();
2153
- return [3 /*break*/, 5];
2154
- case 3:
2155
- _b = [[]];
2156
- return [4 /*yield*/, this.getAllCategoriesIdFromCategory(category)];
2157
- case 4:
2158
- _a = __spreadArray.apply(void 0, [__spreadArray.apply(void 0, _b.concat([__read.apply(void 0, [(_c.sent())])])), [category.id.toString()]]);
2159
- _c.label = 5;
2160
- case 5:
2161
- categoriesIds = _a;
2162
- return [2 /*return*/, { category: { id: { operator: i1.Where.IN, value: categoriesIds } } }];
2163
- }
2164
- });
2165
- });
2166
- };
2167
- NewCategoryStructureAdapter.prototype.getAllCategoriesIdFromCategory = function (category) {
2168
- return __awaiter(this, void 0, void 0, function () {
2169
- return __generator(this, function (_a) {
2170
- return [2 /*return*/, this.categoryRepository
2171
- .getChildren(+category.id)
2172
- .then(function (categories) { return categories.map(function (category) { return category.id.toString(); }); })];
2173
- });
2174
- });
2175
- };
2176
- NewCategoryStructureAdapter.prototype.getAllCategoriesIdFromCollection = function (category) {
2177
- return __awaiter(this, void 0, void 0, function () {
2178
- return __generator(this, function (_a) {
2179
- return [2 /*return*/, this.categoryCollectionChildrenRepository
2180
- .find({ filters: { collectionId: +category.id } })
2181
- .then(function (_a) {
2182
- var data = _a.data;
2183
- return data.map(function (categoryCollection) { return categoryCollection.categoryId.toString(); });
2184
- })];
2185
- });
2186
- });
2187
- };
2188
- NewCategoryStructureAdapter.prototype.isCollection = function (category) {
2189
- return __awaiter(this, void 0, void 0, function () {
2190
- return __generator(this, function (_a) {
2191
- return [2 /*return*/, !i1.isNil(category.isCollection)
2192
- ? category.isCollection
2193
- : this.categoryRepository.get({ id: category.id }).then(function (category) { return category.isCollection; })];
2194
- });
2195
- });
2196
- };
2197
- return NewCategoryStructureAdapter;
2198
- }());
2199
- NewCategoryStructureAdapter.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: NewCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }, { token: 'CategoryCollectionChildrenRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
2200
- NewCategoryStructureAdapter.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: NewCategoryStructureAdapter });
2201
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: NewCategoryStructureAdapter, decorators: [{
2202
- type: i0.Injectable
2203
- }], ctorParameters: function () {
2204
- return [{ type: undefined, decorators: [{
2205
- type: i0.Inject,
2206
- args: ['CategoryRepository']
2207
- }] }, { type: undefined, decorators: [{
2208
- type: i0.Inject,
2209
- args: ['CategoryCollectionChildrenRepository']
2210
- }] }];
2211
- } });
2212
-
2213
- var OldCategoryStructureAdapter = /** @class */ (function () {
2214
- function OldCategoryStructureAdapter(categoryRepository) {
2215
- this.categoryRepository = categoryRepository;
2216
- }
2217
- OldCategoryStructureAdapter.prototype.buildProductFilterByCategory = function (category) {
2218
- var _a;
2219
- return __awaiter(this, void 0, void 0, function () {
2220
- var productsIds, _b;
2221
- return __generator(this, function (_c) {
2222
- switch (_c.label) {
2223
- case 0:
2224
- if (!((_a = category.products) === null || _a === void 0 ? void 0 : _a.length)) return [3 /*break*/, 1];
2225
- _b = category.products;
2226
- return [3 /*break*/, 3];
2227
- case 1: return [4 /*yield*/, this.categoryRepository.get({ id: category.id }).then(function (categoryFound) { return categoryFound.products; })];
2228
- case 2:
2229
- _b = _c.sent();
2230
- _c.label = 3;
2231
- case 3:
2232
- productsIds = _b;
2233
- return [2 /*return*/, { id: { operator: i1.Where.IN, value: productsIds } }];
2234
- }
2235
- });
2236
- });
2237
- };
2238
- return OldCategoryStructureAdapter;
2239
- }());
2240
- OldCategoryStructureAdapter.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OldCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
2241
- OldCategoryStructureAdapter.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OldCategoryStructureAdapter });
2242
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OldCategoryStructureAdapter, decorators: [{
2243
- type: i0.Injectable
2244
- }], ctorParameters: function () {
2245
- return [{ type: undefined, decorators: [{
2246
- type: i0.Inject,
2247
- args: ['CategoryRepository']
2248
- }] }];
2249
- } });
2250
-
2251
- var WishlistService = /** @class */ (function () {
2252
- function WishlistService(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryCollectionChildrenRepository, productIndex) {
2253
- this.wishlistRepository = wishlistRepository;
2254
- this.shop = shop;
2255
- var categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository, categoryCollectionChildrenRepository);
2256
- this.catalogService = new CatalogService(productRepository, categoryStructureAdapter, shop, productIndex);
2257
- this.categoryService = new CategoryService(productRepository, wishlistRepository, categoryFilterRepository, categoryStructureAdapter, shop);
2258
- }
2259
- WishlistService.prototype.getCatalogService = function () {
2260
- return this.catalogService;
2261
- };
2262
- WishlistService.prototype.getCategoryService = function () {
2263
- return this.categoryService;
2264
- };
2265
- WishlistService.prototype.create = function (personId, title, description, userFullName) {
2266
- return __awaiter(this, void 0, void 0, function () {
2267
- var data, newWishlist;
2268
- return __generator(this, function (_a) {
2269
- switch (_a.label) {
2270
- case 0:
2271
- data = {
2272
- slug: UtilHelper.createSlug("favoritos " + userFullName + " " + title),
2273
- name: title,
2274
- description: description,
2275
- metadata: {
2276
- title: userFullName + " - " + title,
2277
- description: userFullName + " - " + description,
2278
- },
2279
- shop: this.shop,
2280
- shops: [this.shop],
2281
- personId: personId,
2282
- brandCategory: false,
2283
- published: true,
2284
- };
2285
- return [4 /*yield*/, this.wishlistRepository.create(data)];
2286
- case 1:
2287
- newWishlist = _a.sent();
2288
- return [2 /*return*/, this.wishlistRepository.update({ id: newWishlist.id, slug: newWishlist.id + "-" + newWishlist.slug })];
2289
- }
2290
- });
2291
- });
2292
- };
2293
- WishlistService.prototype.update = function (id, title, description, userFullName) {
2294
- var data = {
2295
- id: id,
2296
- slug: UtilHelper.createSlug(id + "-favoritos " + userFullName + " " + title),
2297
- name: title,
2298
- description: description,
2299
- metadata: {
2300
- title: userFullName + " - " + title,
2301
- description: userFullName + " - " + description,
2302
- },
2303
- };
2304
- return this.wishlistRepository.update(data);
2305
- };
2306
- WishlistService.prototype.delete = function (wishlistId) {
2307
- return this.wishlistRepository.delete({ id: wishlistId });
2308
- };
2309
- WishlistService.prototype.getWishlistBySlug = function (slug) {
2310
- return this.wishlistRepository.getWishlistBySlug(slug);
2311
- };
2312
- WishlistService.prototype.getWishlistsByPerson = function (personId) {
2313
- return this.wishlistRepository.getWishlistByPerson(personId);
2314
- };
2315
- WishlistService.prototype.addProduct = function (wishlistId, productId) {
2316
- return __awaiter(this, void 0, void 0, function () {
2317
- var wishlist, hasProduct;
2318
- return __generator(this, function (_a) {
2319
- switch (_a.label) {
2320
- case 0: return [4 /*yield*/, this.wishlistRepository.get({ id: wishlistId })];
2321
- case 1:
2322
- wishlist = _a.sent();
2323
- hasProduct = wishlist.products.some(function (p) { return p == productId; });
2324
- if (!hasProduct) {
2325
- wishlist.products = __spreadArray(__spreadArray([], __read(wishlist.products)), [productId]);
2326
- return [2 /*return*/, this.wishlistRepository.update({ id: wishlistId, products: wishlist.products })];
2327
- }
2328
- return [2 /*return*/, wishlist];
2329
- }
2330
- });
2331
- });
2332
- };
2333
- WishlistService.prototype.removeProduct = function (wishlistId, productId) {
2334
- return __awaiter(this, void 0, void 0, function () {
2335
- var wishlist, productIndex;
2336
- return __generator(this, function (_a) {
2337
- switch (_a.label) {
2338
- case 0: return [4 /*yield*/, this.wishlistRepository.get({ id: wishlistId })];
2339
- case 1:
2340
- wishlist = _a.sent();
2341
- productIndex = wishlist.products.findIndex(function (p) { return p == productId; });
2342
- if (productIndex != -1) {
2343
- wishlist.products.splice(productIndex, 1);
2344
- if (!wishlist.products.length)
2345
- return [2 /*return*/, this.wishlistRepository.update({ id: wishlistId, products: { action: 'remove' } })];
2346
- return [2 /*return*/, this.wishlistRepository.update({ id: wishlistId, products: wishlist.products })];
2347
- }
2348
- return [2 /*return*/, wishlist];
2349
- }
2350
- });
2351
- });
2352
- };
2353
- return WishlistService;
2354
- }());
2355
- WishlistService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: WishlistService, deps: [{ token: 'WishlistRepository' }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryFilterRepository' }, { token: 'CategoryCollectionChildrenRepository' }, { token: i1__namespace$1.ProductsIndex }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
2356
- WishlistService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: WishlistService });
2357
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: WishlistService, decorators: [{
2358
- type: i0.Injectable
2359
- }], ctorParameters: function () {
2360
- return [{ type: undefined, decorators: [{
2361
- type: i0.Inject,
2362
- args: ['WishlistRepository']
2363
- }] }, { type: i1__namespace$1.Shops, decorators: [{
2364
- type: i0.Inject,
2365
- args: [DEFAULT_SHOP]
2366
- }] }, { type: undefined, decorators: [{
2367
- type: i0.Inject,
2368
- args: ['ProductRepository']
2369
- }] }, { type: undefined, decorators: [{
2370
- type: i0.Inject,
2371
- args: ['CategoryFilterRepository']
2372
- }] }, { type: undefined, decorators: [{
2373
- type: i0.Inject,
2374
- args: ['CategoryCollectionChildrenRepository']
2375
- }] }, { type: i1__namespace$1.ProductsIndex }];
2376
- } });
2377
-
2378
- var CheckoutSubscriptionService = /** @class */ (function () {
2379
- function CheckoutSubscriptionService(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
2380
- this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
2381
- this.subscriptionRepository = subscriptionRepository;
2382
- this.couponService = couponService;
2383
- }
2384
- CheckoutSubscriptionService.prototype.getCheckoutSubscription = function (checkoutData) {
2385
- var checkoutId = cookie__default["default"].get('checkoutSubscriptionId');
2386
- if (!i1.isNil(checkoutId))
2387
- return rxjs.from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
2388
- return rxjs.from(this.createCheckoutSubscription(checkoutData));
2389
- };
2390
- CheckoutSubscriptionService.prototype.createCheckoutSubscription = function (checkoutData) {
2391
- return __awaiter(this, void 0, void 0, function () {
2392
- var checkout;
2393
- return __generator(this, function (_a) {
2394
- switch (_a.label) {
2395
- case 0: return [4 /*yield*/, this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, i1.CheckoutSubscription.toInstance(i1.pick(checkoutData, ['user', 'shop'])).toPlain()))];
2396
- case 1:
2397
- checkout = _a.sent();
2398
- cookie__default["default"].set('checkoutSubscriptionId', checkout.id);
2399
- return [2 /*return*/, checkout];
2400
- }
2401
- });
2402
- });
2403
- };
2404
- CheckoutSubscriptionService.prototype.clearCheckoutSubscriptionFromSession = function () {
2405
- cookie__default["default"].remove('checkoutSubscriptionId');
2406
- return rxjs.of();
2407
- };
2408
- CheckoutSubscriptionService.prototype.checkCoupon = function (nickname, userEmail) {
2409
- var _this = this;
2410
- return this.getCheckoutSubscription().pipe(operators.concatMap(function (checkout) { return _this.couponService
2411
- .checkCoupon(nickname, i1.CheckoutTypes.SUBSCRIPTION, checkout, checkout.subscriptionPlan.name)
2412
- .pipe(); }));
2413
- };
2414
- CheckoutSubscriptionService.prototype.calcDiscountSubscription = function (coupon) {
2415
- var _this = this;
2416
- return this.getCheckoutSubscription().pipe(operators.concatMap(function (checkout) { return _this.couponService.calcDiscountSubscription(coupon, checkout).pipe(); }));
2417
- };
2418
- return CheckoutSubscriptionService;
2419
- }());
2420
- CheckoutSubscriptionService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: 'SubscriptionRepository' }, { token: CouponService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
2421
- CheckoutSubscriptionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService });
2422
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService, decorators: [{
2423
- type: i0.Injectable
2424
- }], ctorParameters: function () {
2425
- return [{ type: undefined, decorators: [{
2426
- type: i0.Inject,
2427
- args: ['CheckoutSubscriptionRepository']
2428
- }] }, { type: undefined, decorators: [{
2429
- type: i0.Inject,
2430
- args: ['SubscriptionRepository']
2431
- }] }, { type: CouponService }];
2432
- } });
2433
-
2434
- var HomeShopService = /** @class */ (function () {
2435
- function HomeShopService(categoryRepository, homeRepository, productRepository, defaultShop) {
2436
- this.categoryRepository = categoryRepository;
2437
- this.homeRepository = homeRepository;
2438
- this.productRepository = productRepository;
2439
- this.defaultShop = defaultShop;
2440
- this.buildCategoryGroupWithRequiredData = function (group) {
2441
- var _a, _b;
2442
- return ({
2443
- category: i1.Category.toInstance(i1.pick(((_a = group === null || group === void 0 ? void 0 : group.category) === null || _a === void 0 ? void 0 : _a.toPlain()) || {}, ['id', 'name', 'slug', 'conditions'])),
2444
- products: ((_b = group === null || group === void 0 ? void 0 : group.products) === null || _b === void 0 ? void 0 : _b.map(function (product) { return i1.Product.toInstance(i1.pick((product === null || product === void 0 ? void 0 : product.toPlain()) || {}, [
2445
- 'id',
2446
- 'price',
2447
- 'reviews',
2448
- 'hasVariants',
2449
- 'slug',
2450
- 'sku',
2451
- 'stock',
2452
- 'costPrice',
2453
- 'images',
2454
- 'miniatures',
2455
- 'name',
2456
- 'weight',
2457
- 'rate',
2458
- 'type',
2459
- ])); })) || [],
2460
- });
2461
- };
2462
- }
2463
- Object.defineProperty(HomeShopService.prototype, "homeId", {
2464
- get: function () {
2465
- if (this.defaultShop === i1.Shops.GLAMSHOP)
2466
- return 'glamshop';
2467
- if (this.defaultShop === i1.Shops.MENSMARKET)
2468
- return 'mens_market';
2469
- return null;
2470
- },
2471
- enumerable: false,
2472
- configurable: true
2473
- });
2474
- HomeShopService.prototype.getHomeData = function () {
2475
- var _this = this;
2476
- return this.getHomeConfiguration().pipe(operators.map(function (home) { var _a; return (((_a = home === null || home === void 0 ? void 0 : home.data) === null || _a === void 0 ? void 0 : _a.expiresAt) > new Date() ? home : null); }), operators.concatMap(function (home) { return home
2477
- ? rxjs.of(home)
2478
- : rxjs.forkJoin([_this.getDiscoverProducts(), _this.getFeaturedProducts(), _this.getVerticalProducts()]).pipe(operators.map(function (_c) {
2479
- var _d = __read(_c, 3), discoverProducts = _d[0], featuredProducts = _d[1], verticalProducts = _d[2];
2480
- return ({
2481
- discoverProducts: discoverProducts,
2482
- featuredProducts: featuredProducts,
2483
- verticalProducts: verticalProducts,
2484
- });
2485
- }), operators.concatMap(function (data) { return _this.saveHomeData(data); })); }));
2486
- };
2487
- HomeShopService.prototype.getBanners = function (type) {
2488
- return this.getHomeConfiguration().pipe(operators.map(function (home) {
2489
- if (type === 'brand')
2490
- return home.brandsCarousel;
2491
- if (type === 'buyToWin')
2492
- return [home.buyToWinBanner];
2493
- if (type === 'block')
2494
- return home.blockBanners;
2495
- if (type === 'blog')
2496
- return [home.blogBanner];
2497
- }));
2498
- };
2499
- HomeShopService.prototype.getMinValueForFreeShipping = function () {
2500
- return this.getHomeConfiguration().pipe(operators.map(function (home) { return home.minValueForFreeShipping; }));
2501
- };
2502
- HomeShopService.prototype.getDiscoverProducts = function () {
2503
- var _this = this;
2504
- return this.getHomeConfiguration().pipe(operators.concatMap(function (home) { return rxjs.from(_this.categoryRepository.getCategoriesForHome(home.discoverCategories)).pipe(operators.map(function (groups) { return groups.map(_this.buildCategoryGroupWithRequiredData); })); }));
2505
- };
2506
- HomeShopService.prototype.getFeaturedProducts = function () {
2507
- var _this = this;
2508
- return this.getHomeConfiguration().pipe(operators.concatMap(function (home) { return rxjs.from(_this.categoryRepository.getCategoriesForHome(home.featuredCategories)).pipe(operators.map(function (groups) { return groups.map(_this.buildCategoryGroupWithRequiredData); })); }));
2509
- };
2510
- HomeShopService.prototype.getVerticalProducts = function () {
2511
- var _this = this;
2512
- return this.getHomeConfiguration().pipe(operators.concatMap(function (home) { return rxjs.forkJoin(home.verticalCarousels.filter(Boolean).map(function (id) { return rxjs.from(_this.categoryRepository.get({ id: id })).pipe(operators.concatMap(function (category) { return rxjs.from(_this.productRepository.find({
2513
- filters: { categories: { operator: i1.Where.IN, value: [category.id] } },
2514
- limits: { limit: 12 },
2515
- })).pipe(operators.map(function (products) { return ({ category: category, products: products }); })); }), operators.map(function (_c) {
2516
- var category = _c.category, products = _c.products;
2517
- return ({ category: category, products: products.data });
2518
- }), operators.map(_this.buildCategoryGroupWithRequiredData)); })); }));
2519
- };
2520
- HomeShopService.prototype.getHomeConfiguration = function () {
2521
- var _this = this;
2522
- return rxjs.of(this.homeConfiguration).pipe(operators.concatMap(function (home) { return home
2523
- ? rxjs.of(home)
2524
- : !_this.homeId
2525
- ? rxjs.throwError(new i1.RequiredArgumentError(['homeId']))
2526
- : rxjs.from(_this.homeRepository.get({ id: _this.homeId })).pipe(operators.tap(function (homeLoaded) { return (_this.homeConfiguration = homeLoaded); })); }));
2527
- };
2528
- HomeShopService.prototype.saveHomeData = function (homeData) {
2529
- var _this = this;
2530
- var data = {
2531
- createdAt: new Date(),
2532
- expiresAt: i1.add(new Date(), { hours: 1 }),
2533
- data: homeData,
2534
- };
2535
- return rxjs.from(this.homeRepository.update({
2536
- id: this.homeId,
2537
- data: data,
2538
- })).pipe(operators.tap(function () { return (_this.homeConfiguration.data = data); }), operators.map(function () { return _this.homeConfiguration; }));
2539
- };
2540
- return HomeShopService;
2541
- }());
2542
- HomeShopService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: HomeShopService, deps: [{ token: 'CategoryRepository' }, { token: 'HomeRepository' }, { token: 'ProductRepository' }, { token: DEFAULT_SHOP }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
2543
- HomeShopService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: HomeShopService });
2544
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: HomeShopService, decorators: [{
2545
- type: i0.Injectable
2546
- }], ctorParameters: function () {
2547
- return [{ type: undefined, decorators: [{
2548
- type: i0.Inject,
2549
- args: ['CategoryRepository']
2550
- }] }, { type: undefined, decorators: [{
2551
- type: i0.Inject,
2552
- args: ['HomeRepository']
2553
- }] }, { type: undefined, decorators: [{
2554
- type: i0.Inject,
2555
- args: ['ProductRepository']
2556
- }] }, { type: i1__namespace$1.Shops, decorators: [{
2557
- type: i0.Inject,
2558
- args: [DEFAULT_SHOP]
2559
- }] }];
2560
- } });
2561
-
2562
- var OrderService = /** @class */ (function () {
2563
- function OrderService(angularFirestore, orderRepository) {
2564
- this.angularFirestore = angularFirestore;
2565
- this.orderRepository = orderRepository;
2566
- this.orderSubject = new rxjs.Subject();
2567
- }
2568
- OrderService.prototype.getOrder = function (id) {
2569
- var _this = this;
2570
- this.angularFirestore
2571
- .doc(this.orderRepository.collectionName + "/" + id)
2572
- .valueChanges()
2573
- .pipe(operators.map(function (doc) { return i1.Order.toInstance(doc); }))
2574
- .subscribe(function (doc) { return _this.orderSubject.next(doc); });
2575
- return this.orderSubject;
2576
- };
2577
- return OrderService;
2578
- }());
2579
- OrderService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService, deps: [{ token: i1__namespace$2.AngularFirestore }, { token: 'OrderRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
2580
- OrderService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService });
2581
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService, decorators: [{
2582
- type: i0.Injectable
2583
- }], ctorParameters: function () {
2584
- return [{ type: i1__namespace$2.AngularFirestore }, { type: i1__namespace$1.OrderFirestoreRepository, decorators: [{
2585
- type: i0.Inject,
2586
- args: ['OrderRepository']
2587
- }] }];
2588
- } });
2589
-
2590
- var ShippingService = /** @class */ (function () {
2591
- function ShippingService(http, apiUrl, homeService) {
2592
- this.http = http;
2593
- this.apiUrl = apiUrl;
2594
- this.homeService = homeService;
2595
- }
2596
- ShippingService.prototype.getShippingMethods = function (shop, zip, weightGrams, totalPrice, personId, subscriptionPlan) {
2597
- var _this = this;
2598
- return rxjs.combineLatest([
2599
- this.homeService.getHomeData(),
2600
- this.http.get(this.apiUrl + "open/checkshippingcompany?personId=" + personId + "&postalCode=" + zip + "&weightGrams=" + weightGrams),
2601
- ]).pipe(operators.map(function (_a) {
2602
- var _b = __read(_a, 2), datas = _b[0], shippingMethodsResponse = _b[1];
2603
- var shippingMethods = shippingMethodsResponse.result;
2604
- if (!shippingMethods.length)
2605
- return [];
2606
- shippingMethods = shippingMethods.map(function (s) {
2607
- if (s.ShippingCompanyName == 'Same Day EG')
2608
- s.ShippingCompanyName = 'Same Day';
2609
- else
2610
- return s;
2611
- });
2612
- var datasSameDayNotAvaliable = datas.sameDayNotAvaliable;
2613
- if (_this.isHolidays(datasSameDayNotAvaliable)) {
2614
- shippingMethods = shippingMethods.filter(function (method) { return method.serviceName !== 'Same Day'; });
2615
- }
2616
- if (totalPrice >= 200) {
2617
- shippingMethods = shippingMethods.map(function (s) {
2618
- if (s.serviceName !== 'Same Day')
2619
- return Object.assign(Object.assign({}, s), { totalPrice: 0 });
2620
- else
2621
- return s;
2622
- });
2623
- }
2624
- if (shop == i1.Shops.GLAMSHOP)
2625
- return shippingMethods;
2626
- if (_this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
2627
- shippingMethods = shippingMethods.map(function (s) {
2628
- if (s.serviceName == 'Same Day')
2629
- return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
2630
- else
2631
- return Object.assign(Object.assign({}, s), { totalPrice: 0 });
2632
- });
2633
- }
2634
- if (_this.isHalfShippingBySubscription(shop, subscriptionPlan)) {
2635
- shippingMethods = shippingMethods.map(function (s) {
2636
- return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
2637
- });
2638
- }
2639
- return shippingMethods;
2640
- }));
2641
- };
2642
- ShippingService.prototype.isFreeShippingBySubscription = function (shop, subscriptionPlan) {
2643
- if (!subscriptionPlan)
2644
- return false;
2645
- if (shop == i1.Shops.MENSMARKET && subscriptionPlan == 'SELECT') {
2646
- return true;
2647
- }
2648
- return false;
2649
- };
2650
- ShippingService.prototype.isHalfShippingBySubscription = function (shop, subscriptionPlan) {
2651
- if (!subscriptionPlan)
2652
- return false;
2653
- if (shop == i1.Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
2654
- return true;
2655
- }
2656
- return false;
2657
- };
2658
- ShippingService.prototype.isHolidays = function (datas) {
2659
- var today = new Date();
2660
- for (var key in datas) {
2661
- var start = new Date(today.getFullYear() + "-" + datas[key].beginDate);
2662
- var end = new Date(today.getFullYear() + "-" + datas[key].endDate);
2663
- if (start > end)
2664
- end = new Date(today.getFullYear() + 1 + "-" + datas[key].endDate);
2665
- if (today >= start && today <= end)
2666
- return true;
2667
- }
2668
- return false;
2669
- };
2670
- return ShippingService;
2671
- }());
2672
- ShippingService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: ShippingService, deps: [{ token: i1__namespace$3.HttpClient }, { token: BACKEND_URL }, { token: HomeShopService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
2673
- ShippingService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: ShippingService });
2674
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: ShippingService, decorators: [{
2675
- type: i0.Injectable
2676
- }], ctorParameters: function () {
2677
- return [{ type: i1__namespace$3.HttpClient }, { type: undefined, decorators: [{
2678
- type: i0.Inject,
2679
- args: [BACKEND_URL]
2680
- }] }, { type: HomeShopService }];
2681
- } });
2682
-
2683
- var AngularConnectModule = /** @class */ (function () {
2684
- function AngularConnectModule() {
2685
- }
2686
- AngularConnectModule.initializeApp = function (defaultShop, options, nameOrConfig) {
2687
- return {
2688
- ngModule: AngularConnectModule,
2689
- providers: __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([
2690
- {
2691
- provide: CATEGORY_STRUCTURE,
2692
- useClass: i1.isNil(options === null || options === void 0 ? void 0 : options.oldCategoryStructure) || (options === null || options === void 0 ? void 0 : options.oldCategoryStructure)
2693
- ? OldCategoryStructureAdapter
2694
- : NewCategoryStructureAdapter,
2695
- }
2696
- ], __read((i1.isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]))), __read((i1.isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: fire.FIREBASE_OPTIONS, useValue: options === null || options === void 0 ? void 0 : options.firebase }]))), __read((i1.isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig }]))), __read((i1.isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]))), __read((i1.isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]))), __read((i1.isNil(options === null || options === void 0 ? void 0 : options.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]))),
2697
- };
2698
- };
2699
- return AngularConnectModule;
2700
- }());
2701
- AngularConnectModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
2702
- AngularConnectModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, imports: [AngularElasticSeachModule, fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule] });
2703
- AngularConnectModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, providers: [
2704
- AuthService,
2705
- CartService,
2706
- CatalogService,
2707
- CategoryService,
2708
- CheckoutService,
2709
- CheckoutSubscriptionService,
2710
- CouponService,
2711
- HomeShopService,
2712
- OrderService,
2713
- ShippingService,
2714
- WishlistService,
2715
- ], imports: [[AngularElasticSeachModule, fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule]] });
2716
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, decorators: [{
2717
- type: i0.NgModule,
2718
- args: [{
2719
- imports: [AngularElasticSeachModule, fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule],
2720
- providers: [
2721
- AuthService,
2722
- CartService,
2723
- CatalogService,
2724
- CategoryService,
2725
- CheckoutService,
2726
- CheckoutSubscriptionService,
2727
- CouponService,
2728
- HomeShopService,
2729
- OrderService,
2730
- ShippingService,
2731
- WishlistService,
2732
- ],
2733
- }]
2734
- }] });
2735
-
2736
- var AngularFirebaseAuthModule = /** @class */ (function () {
2737
- function AngularFirebaseAuthModule() {
2738
- }
2739
- AngularFirebaseAuthModule.initializeApp = function (options, nameOrConfig) {
2740
- return {
2741
- ngModule: AngularFirebaseAuthModule,
2742
- providers: [
2743
- { provide: fire.FIREBASE_OPTIONS, useValue: options },
2744
- { provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
2745
- ],
2746
- };
2747
- };
2748
- return AngularFirebaseAuthModule;
2749
- }());
2750
- AngularFirebaseAuthModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
2751
- AngularFirebaseAuthModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, imports: [fire.AngularFireModule] });
2752
- AngularFirebaseAuthModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, providers: [
2753
- {
2754
- provide: 'Authentication',
2755
- useFactory: function (authenticationService, userRepository) {
2756
- return new i1.Authentication(authenticationService, userRepository);
2757
- },
2758
- deps: ['AuthenticationService', 'UserRepository'],
2759
- },
2760
- {
2761
- provide: 'AuthenticationService',
2762
- useFactory: function (angularFireAuth) {
2763
- return new i1.AuthenticationFirebaseAuthService(angularFireAuth);
2764
- },
2765
- deps: [i1$2.AngularFireAuth],
2766
- },
2767
- {
2768
- provide: 'Register',
2769
- useFactory: function (registerService, userRepository) {
2770
- return new i1.Register(registerService, userRepository);
2771
- },
2772
- deps: ['RegisterService', 'UserRepository'],
2773
- },
2774
- {
2775
- provide: 'RegisterService',
2776
- useFactory: function (angularFireAuth) {
2777
- return new i1.RegisterFirebaseAuthService(angularFireAuth);
2778
- },
2779
- deps: [i1$2.AngularFireAuth],
2780
- },
2781
- {
2782
- provide: 'SignOut',
2783
- useFactory: function (authenticationService) {
2784
- return new i1.SignOut(authenticationService);
2785
- },
2786
- deps: ['AuthenticationService'],
2787
- },
2788
- {
2789
- provide: 'RecoveryPassword',
2790
- useFactory: function (authenticationService) {
2791
- return new i1.RecoveryPassword(authenticationService);
2792
- },
2793
- deps: ['AuthenticationService'],
2794
- },
2795
- ], imports: [[fire.AngularFireModule]] });
2796
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, decorators: [{
2797
- type: i0.NgModule,
2798
- args: [{
2799
- imports: [fire.AngularFireModule],
2800
- providers: [
2801
- {
2802
- provide: 'Authentication',
2803
- useFactory: function (authenticationService, userRepository) {
2804
- return new i1.Authentication(authenticationService, userRepository);
2805
- },
2806
- deps: ['AuthenticationService', 'UserRepository'],
2807
- },
2808
- {
2809
- provide: 'AuthenticationService',
2810
- useFactory: function (angularFireAuth) {
2811
- return new i1.AuthenticationFirebaseAuthService(angularFireAuth);
2812
- },
2813
- deps: [i1$2.AngularFireAuth],
2814
- },
2815
- {
2816
- provide: 'Register',
2817
- useFactory: function (registerService, userRepository) {
2818
- return new i1.Register(registerService, userRepository);
2819
- },
2820
- deps: ['RegisterService', 'UserRepository'],
2821
- },
2822
- {
2823
- provide: 'RegisterService',
2824
- useFactory: function (angularFireAuth) {
2825
- return new i1.RegisterFirebaseAuthService(angularFireAuth);
2826
- },
2827
- deps: [i1$2.AngularFireAuth],
2828
- },
2829
- {
2830
- provide: 'SignOut',
2831
- useFactory: function (authenticationService) {
2832
- return new i1.SignOut(authenticationService);
2833
- },
2834
- deps: ['AuthenticationService'],
2835
- },
2836
- {
2837
- provide: 'RecoveryPassword',
2838
- useFactory: function (authenticationService) {
2839
- return new i1.RecoveryPassword(authenticationService);
2840
- },
2841
- deps: ['AuthenticationService'],
2842
- },
2843
- ],
2844
- }]
2845
- }] });
2846
-
2847
- /**
2848
- * Generated bundle index. Do not edit.
2849
- */
2850
-
2851
- exports.AngularConnectModule = AngularConnectModule;
2852
- exports.AngularFirebaseAuthModule = AngularFirebaseAuthModule;
2853
- exports.AngularFirestoreModule = AngularFirestoreModule;
2854
- exports.AngularHasuraGraphQLModule = AngularHasuraGraphQLModule;
2855
- exports.AuthService = AuthService;
2856
- exports.CartService = CartService;
2857
- exports.CatalogService = CatalogService;
2858
- exports.CategoryService = CategoryService;
2859
- exports.CategoryWithTree = CategoryWithTree;
2860
- exports.CheckoutService = CheckoutService;
2861
- exports.CheckoutSubscriptionService = CheckoutSubscriptionService;
2862
- exports.CouponService = CouponService;
2863
- exports.HomeShopService = HomeShopService;
2864
- exports.OrderService = OrderService;
2865
- exports.ShippingService = ShippingService;
2866
- exports.UtilHelper = UtilHelper;
2867
- exports.WishlistService = WishlistService;
2868
-
2869
- Object.defineProperty(exports, '__esModule', { value: true });
2870
-
2871
- }));
2872
- //# sourceMappingURL=infrab4a-connect-angular.umd.js.map