@infrab4a/connect-angular 4.0.1-beta.0 → 4.0.2-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/angular-connect.module.d.ts +22 -19
  2. package/angular-elastic-search.module.d.ts +9 -9
  3. package/angular-firebase-auth.module.d.ts +12 -10
  4. package/angular-firestore.module.d.ts +18 -15
  5. package/angular-hasura-graphql.module.d.ts +16 -16
  6. package/consts/backend-url.const.d.ts +1 -1
  7. package/consts/category-structure.d.ts +1 -0
  8. package/consts/default-shop.const.d.ts +1 -1
  9. package/consts/es-config.const.d.ts +1 -1
  10. package/consts/firebase-const.d.ts +3 -0
  11. package/consts/hasura-options.const.d.ts +1 -1
  12. package/consts/index.d.ts +6 -4
  13. package/esm2020/angular-connect.module.mjs +66 -0
  14. package/esm2020/angular-elastic-search.module.mjs +34 -0
  15. package/esm2020/angular-firebase-auth.module.mjs +130 -0
  16. package/esm2020/angular-firestore.module.mjs +459 -0
  17. package/esm2020/angular-hasura-graphql.module.mjs +243 -0
  18. package/{esm2015/consts/backend-url.const.js → esm2020/consts/backend-url.const.mjs} +1 -1
  19. package/esm2020/consts/category-structure.mjs +2 -0
  20. package/{esm2015/consts/default-shop.const.js → esm2020/consts/default-shop.const.mjs} +2 -2
  21. package/{esm2015/consts/es-config.const.js → esm2020/consts/es-config.const.mjs} +2 -2
  22. package/esm2020/consts/firebase-const.mjs +4 -0
  23. package/{esm2015/consts/hasura-options.const.js → esm2020/consts/hasura-options.const.mjs} +2 -2
  24. package/esm2020/consts/index.mjs +7 -0
  25. package/esm2020/helpers/index.mjs +2 -0
  26. package/esm2020/helpers/mobile-operation-system-checker.helper.mjs +7 -0
  27. package/esm2020/index.mjs +6 -0
  28. package/{esm2015/infrab4a-connect-angular.js → esm2020/infrab4a-connect-angular.mjs} +4 -4
  29. package/esm2020/services/auth.service.mjs +37 -0
  30. package/esm2020/services/cart.service.mjs +281 -0
  31. package/esm2020/services/catalog/adapters/category-structure.adapter.mjs +2 -0
  32. package/esm2020/services/catalog/adapters/index.mjs +4 -0
  33. package/esm2020/services/catalog/adapters/new-category-structure.adapter.mjs +41 -0
  34. package/esm2020/services/catalog/adapters/old-category-structure.adapter.mjs +23 -0
  35. package/esm2020/services/catalog/catalog.service.mjs +122 -0
  36. package/esm2020/services/catalog/category.service.mjs +51 -0
  37. package/esm2020/services/catalog/enums/index.mjs +2 -0
  38. package/esm2020/services/catalog/enums/product-sorts.enum.mjs +11 -0
  39. package/esm2020/services/catalog/index.mjs +7 -0
  40. package/esm2020/services/catalog/models/category-with-tree.model.mjs +10 -0
  41. package/esm2020/services/catalog/models/index.mjs +2 -0
  42. package/esm2020/services/catalog/types/index.mjs +2 -0
  43. package/esm2020/services/catalog/types/product-sort.type.mjs +2 -0
  44. package/esm2020/services/catalog/wishlist.service.mjs +102 -0
  45. package/esm2020/services/checkout-subscription.service.mjs +53 -0
  46. package/esm2020/services/checkout.service.mjs +71 -0
  47. package/esm2020/services/coupon.service.mjs +218 -0
  48. package/esm2020/services/helpers/index.mjs +2 -0
  49. package/esm2020/services/helpers/util.helper.mjs +18 -0
  50. package/esm2020/services/home-shop.service.mjs +114 -0
  51. package/esm2020/services/index.mjs +11 -0
  52. package/esm2020/services/order.service.mjs +30 -0
  53. package/esm2020/services/shipping.service.mjs +96 -0
  54. package/{esm2015/services/types/index.js → esm2020/services/types/index.mjs} +3 -3
  55. package/{esm2015/services/types/required-checkout-data.type.js → esm2020/services/types/required-checkout-data.type.mjs} +2 -2
  56. package/{esm2015/services/types/required-checkout-subscription-data.type.js → esm2020/services/types/required-checkout-subscription-data.type.mjs} +2 -2
  57. package/esm2020/services/types/shipping-methods.type.mjs +2 -0
  58. package/esm2020/types/firebase-app-config.type.mjs +2 -0
  59. package/esm2020/types/index.mjs +2 -0
  60. package/fesm2015/infrab4a-connect-angular.mjs +2188 -0
  61. package/fesm2015/infrab4a-connect-angular.mjs.map +1 -0
  62. package/fesm2020/infrab4a-connect-angular.mjs +2121 -0
  63. package/fesm2020/infrab4a-connect-angular.mjs.map +1 -0
  64. package/helpers/index.d.ts +1 -0
  65. package/helpers/mobile-operation-system-checker.helper.d.ts +3 -0
  66. package/index.d.ts +5 -5
  67. package/package.json +25 -13
  68. package/services/auth.service.d.ts +18 -19
  69. package/services/cart.service.d.ts +42 -35
  70. package/services/catalog/adapters/category-structure.adapter.d.ts +4 -0
  71. package/services/catalog/adapters/index.d.ts +3 -0
  72. package/services/catalog/adapters/new-category-structure.adapter.d.ts +12 -0
  73. package/services/catalog/adapters/old-category-structure.adapter.d.ts +10 -0
  74. package/services/catalog/catalog.service.d.ts +80 -0
  75. package/services/catalog/category.service.d.ts +15 -0
  76. package/services/catalog/enums/index.d.ts +1 -0
  77. package/services/catalog/enums/product-sorts.enum.d.ts +9 -0
  78. package/services/catalog/index.d.ts +6 -0
  79. package/services/catalog/models/category-with-tree.model.d.ts +4 -0
  80. package/services/catalog/models/index.d.ts +1 -0
  81. package/services/catalog/types/index.d.ts +1 -0
  82. package/services/catalog/types/product-sort.type.d.ts +2 -0
  83. package/services/catalog/wishlist.service.d.ts +22 -0
  84. package/services/checkout-subscription.service.d.ts +18 -18
  85. package/services/checkout.service.d.ts +23 -23
  86. package/services/coupon.service.d.ts +28 -26
  87. package/services/helpers/index.d.ts +1 -0
  88. package/services/helpers/util.helper.d.ts +3 -0
  89. package/services/home-shop.service.d.ts +25 -25
  90. package/services/index.d.ts +10 -8
  91. package/services/order.service.d.ts +13 -13
  92. package/services/shipping.service.d.ts +19 -19
  93. package/services/types/index.d.ts +2 -2
  94. package/services/types/required-checkout-data.type.d.ts +2 -2
  95. package/services/types/required-checkout-subscription-data.type.d.ts +2 -2
  96. package/services/types/shipping-methods.type.d.ts +12 -12
  97. package/types/firebase-app-config.type.d.ts +1 -0
  98. package/types/index.d.ts +1 -0
  99. package/bundles/infrab4a-connect-angular.umd.js +0 -1978
  100. package/bundles/infrab4a-connect-angular.umd.js.map +0 -1
  101. package/esm2015/angular-connect.module.js +0 -52
  102. package/esm2015/angular-elastic-search.module.js +0 -38
  103. package/esm2015/angular-firebase-auth.module.js +0 -113
  104. package/esm2015/angular-firestore.module.js +0 -366
  105. package/esm2015/angular-hasura-graphql.module.js +0 -90
  106. package/esm2015/consts/index.js +0 -5
  107. package/esm2015/index.js +0 -6
  108. package/esm2015/services/auth.service.js +0 -42
  109. package/esm2015/services/cart.service.js +0 -148
  110. package/esm2015/services/checkout-subscription.service.js +0 -51
  111. package/esm2015/services/checkout.service.js +0 -75
  112. package/esm2015/services/coupon.service.js +0 -266
  113. package/esm2015/services/errors/group-invalid-coupon.error.js +0 -8
  114. package/esm2015/services/errors/index.js +0 -3
  115. package/esm2015/services/errors/invalid-coupon.error.js +0 -8
  116. package/esm2015/services/home-shop.service.js +0 -116
  117. package/esm2015/services/index.js +0 -9
  118. package/esm2015/services/order.service.js +0 -32
  119. package/esm2015/services/shipping.service.js +0 -99
  120. package/esm2015/services/types/shipping-methods.type.js +0 -2
  121. package/fesm2015/infrab4a-connect-angular.js +0 -1432
  122. package/fesm2015/infrab4a-connect-angular.js.map +0 -1
  123. package/infrab4a-connect-angular.d.ts +0 -5
  124. package/services/errors/group-invalid-coupon.error.d.ts +0 -6
  125. package/services/errors/index.d.ts +0 -2
  126. package/services/errors/invalid-coupon.error.d.ts +0 -5
@@ -1,1978 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('@angular/fire/auth'), require('@infrab4a/connect'), require('js-cookie'), require('ts-custom-error'), require('@angular/fire/firestore'), require('@angular/common/http'), require('@angular/fire')) :
3
- typeof define === 'function' && define.amd ? define('@infrab4a/connect-angular', ['exports', '@angular/core', 'rxjs', 'rxjs/operators', '@angular/fire/auth', '@infrab4a/connect', 'js-cookie', 'ts-custom-error', '@angular/fire/firestore', '@angular/common/http', '@angular/fire'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.infrab4a = global.infrab4a || {}, global.infrab4a["connect-angular"] = {}), global.ng.core, global.rxjs, global.rxjs.operators, global.ng.fire.auth, global["@infrab4a/connect"], global["js-cookie"], global["ts-custom-error"], global.ng.fire.firestore, global.ng.common.http, global.ng.fire));
5
- })(this, (function (exports, i0, rxjs, operators, i1, i1$1, cookie, tsCustomError, i1$2, i1$3, fire) { '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 = /*#__PURE__*/_interopNamespace(i1);
29
- var i1__namespace$1 = /*#__PURE__*/_interopNamespace(i1$1);
30
- var cookie__default = /*#__PURE__*/_interopDefaultLegacy(cookie);
31
- var i1__namespace$2 = /*#__PURE__*/_interopNamespace(i1$2);
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 AuthService = /** @class */ (function () {
353
- function AuthService(angularFireAuth, userRepository) {
354
- this.angularFireAuth = angularFireAuth;
355
- this.userRepository = userRepository;
356
- }
357
- AuthService.prototype.getAuthstate = function () {
358
- var observables = [
359
- this.angularFireAuth.authState.pipe(operators.catchError(function () { return rxjs.of(null); })),
360
- this.getUser().pipe(operators.catchError(function () { return rxjs.of(null); })),
361
- ];
362
- return rxjs.combineLatest(observables).pipe(operators.map(function (_a) {
363
- var _b = __read(_a, 2), fireUser = _b[0], user = _b[1];
364
- return {
365
- user: user,
366
- isAnonymous: fireUser === null || fireUser === void 0 ? void 0 : fireUser.isAnonymous,
367
- };
368
- }));
369
- };
370
- AuthService.prototype.getUser = function () {
371
- var _this = this;
372
- return this.getFireUser().pipe(operators.map(function (user) { return user === null || user === void 0 ? void 0 : user.uid; }), operators.mergeMap(function (id) { return (id ? _this.userRepository.get({ id: id }) : rxjs.of(null)); }));
373
- };
374
- AuthService.prototype.getTokenId = function () {
375
- return this.angularFireAuth.idToken;
376
- };
377
- AuthService.prototype.getFireUser = function () {
378
- return this.angularFireAuth.user.pipe(operators.catchError(function () { return rxjs.of(null); }));
379
- };
380
- return AuthService;
381
- }());
382
- 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 });
383
- AuthService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AuthService });
384
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AuthService, decorators: [{
385
- type: i0.Injectable
386
- }], ctorParameters: function () {
387
- return [{ type: i1__namespace.AngularFireAuth }, { type: undefined, decorators: [{
388
- type: i0.Inject,
389
- args: ['UserRepository']
390
- }] }];
391
- } });
392
-
393
- var BACKEND_URL = 'BACKEND_URL';
394
-
395
- var DEFAULT_SHOP = 'DEFAULT_SHOP';
396
-
397
- var ES_CONFIG = 'ES_CONFIG';
398
-
399
- var HASURA_OPTIONS = 'HASURA_OPTIONS';
400
-
401
- var InvalidCouponError = /** @class */ (function (_super) {
402
- __extends(InvalidCouponError, _super);
403
- function InvalidCouponError(message) {
404
- var _this = _super.call(this, message) || this;
405
- _this.message = message;
406
- return _this;
407
- }
408
- return InvalidCouponError;
409
- }(tsCustomError.CustomError));
410
-
411
- var GroupInvalidCouponError = /** @class */ (function (_super) {
412
- __extends(GroupInvalidCouponError, _super);
413
- function GroupInvalidCouponError(errors) {
414
- var _this = _super.call(this, 'Many coupon errors throw') || this;
415
- _this.errors = errors;
416
- return _this;
417
- }
418
- return GroupInvalidCouponError;
419
- }(tsCustomError.CustomError));
420
-
421
- var CouponService = /** @class */ (function () {
422
- function CouponService(couponRepository, defaultShop, orderRepository, subscriptionRepository, categoryRepository) {
423
- var _this = this;
424
- this.couponRepository = couponRepository;
425
- this.defaultShop = defaultShop;
426
- this.orderRepository = orderRepository;
427
- this.subscriptionRepository = subscriptionRepository;
428
- this.categoryRepository = categoryRepository;
429
- this.emailIsFromCollaborator = function (userEmail) { return !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g)); };
430
- this.separateValidCoupons = function (coupons, userEmail) { return coupons
431
- .map(function (coupon) {
432
- try {
433
- if (!(coupon instanceof i1$1.Coupon))
434
- throw new InvalidCouponError('Cupom inválido.');
435
- if (_this.isValidCoupon(coupon, userEmail))
436
- return coupon;
437
- }
438
- catch (error) {
439
- return error;
440
- }
441
- })
442
- .reduce(function (current, coupon) { return (Object.assign(Object.assign({}, current), (coupon instanceof i1$1.Coupon
443
- ? { valids: __spreadArray(__spreadArray([], __read(current.valids)), [coupon]) }
444
- : { invalids: __spreadArray(__spreadArray([], __read(current.invalids)), [coupon]) }))); }, {
445
- valids: [],
446
- invalids: [],
447
- }); };
448
- }
449
- CouponService.prototype.checkCoupon = function (nickname, userEmail, checkoutType, plan, checkout, isSubscription) {
450
- var _this = this;
451
- return rxjs.from(this.couponRepository.find({
452
- filters: {
453
- nickname: { operator: i1$1.Where.EQUALS, value: nickname },
454
- active: { operator: i1$1.Where.EQUALS, value: true },
455
- },
456
- })).pipe(operators.concatMap(function (coupons) { return _this.checkCouponRules(coupons, checkoutType, plan, checkout, isSubscription); }), operators.concatMap(function (coupon) { return _this.checkCouponUseAndLimit(coupon, userEmail, checkout); }), operators.map(function (coupon) { return _this.isValidCoupon(coupon, userEmail); }), operators.map(function (coupon) { return coupon; }));
457
- };
458
- CouponService.prototype.checkCouponRules = function (coupons, checkoutType, plan, checkout, isSubscription) {
459
- // Caso não ache nenhum cupom, retorna erro
460
- if (coupons.count < 1) {
461
- return rxjs.throwError('Cupom inválido.');
462
- }
463
- // Get Primeiro Cupom (o find do repository retorna um array)
464
- var coupon = coupons.data.shift();
465
- // Verifica se o cupom é aplicavel na loja
466
- var isInShop = coupon.shopAvailability === i1$1.Shops.ALL || coupon.shopAvailability === this.defaultShop;
467
- // Cupon não aplicavel a loja retorna erro
468
- if (!isInShop)
469
- return rxjs.throwError('Cupom inválido para loja.');
470
- // Verifica se o coupon é aplicado no checkout que está sendo realizado
471
- var isCheckoutType = coupon.checkoutType === i1$1.CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
472
- // Cupon não aplicavel ao checkout retorna erro
473
- if (!isCheckoutType)
474
- return rxjs.throwError('Cupom inválido. Erro de checkout.');
475
- // Verifica se o cupom é ou pode ser aplicado para subscription
476
- if (checkoutType === i1$1.CheckoutTypes.ALL || checkoutType === i1$1.CheckoutTypes.SUBSCRIPTION) {
477
- // Se o cupom tiver um plano associado, verifica se é o mesmo plano do checkout da assinatura
478
- if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase())
479
- return rxjs.throwError('Cupom inválido para sua assinatura.');
480
- }
481
- if (isSubscription)
482
- return rxjs.of(coupon);
483
- // Verifica se possui o valor minimo de compra para utilização do cupom
484
- var hasMinSubTotal = this.hasMinSubTotal(coupon, checkout);
485
- // Se não tem valor mínimo atingido, retorna erro
486
- if (!hasMinSubTotal)
487
- return rxjs.throwError('Valor mínimo não atingido');
488
- return rxjs.of(coupon);
489
- };
490
- CouponService.prototype.isValidCoupon = function (coupon, userEmail) {
491
- // Verifica a data de inicio de validade do cupom
492
- if ((coupon === null || coupon === void 0 ? void 0 : coupon.beginAt) > new Date())
493
- throw new InvalidCouponError('Cupom ainda não liberado.');
494
- // Verifica a data de validade do cupom
495
- if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) < new Date())
496
- throw new InvalidCouponError('Cupom expirado.');
497
- return coupon;
498
- };
499
- CouponService.prototype.checkCouponUseAndLimit = function (coupon, userEmail, checkout) {
500
- return __awaiter(this, void 0, void 0, function () {
501
- var orders, ordersUserCoupon, validUser, hasProductCategories;
502
- return __generator(this, function (_d) {
503
- switch (_d.label) {
504
- case 0: return [4 /*yield*/, this.orderRepository.find({
505
- filters: {
506
- coupon: { id: coupon.id },
507
- payment: { status: 'paid' },
508
- },
509
- })];
510
- case 1:
511
- orders = _d.sent();
512
- ordersUserCoupon = orders.data.filter(function (o) { return o.user.email == userEmail; });
513
- // Verifica o limite de uso de cupom por usuario
514
- if (coupon.useLimitPerUser && ordersUserCoupon.length)
515
- throw new InvalidCouponError('Limite de uso por usuário atingido.');
516
- // Verifica o limite de uso geral por usuario
517
- if (coupon.useLimit && orders.data.length >= coupon.useLimit)
518
- throw new InvalidCouponError('Limite de uso atingido.');
519
- return [4 /*yield*/, this.userValidationAndSubscriptionStatus(coupon, userEmail)];
520
- case 2:
521
- validUser = _d.sent();
522
- if (!validUser)
523
- throw new InvalidCouponError('Usuário não elegível.');
524
- return [4 /*yield*/, this.hasProductCategories(coupon, checkout)];
525
- case 3:
526
- hasProductCategories = _d.sent();
527
- if (!hasProductCategories)
528
- throw 'Seu carrinho não possui produtos elegíveis para desconto.';
529
- return [2 /*return*/, coupon];
530
- }
531
- });
532
- });
533
- };
534
- CouponService.prototype.calcDiscountSubscription = function (coupon, checkout) {
535
- //
536
- var discount = 0;
537
- if (coupon.type === i1$1.CouponTypes.ABSOLUTE)
538
- discount = coupon.discount;
539
- else if (coupon.type === i1$1.CouponTypes.PERCENTAGE)
540
- discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount / 100);
541
- return rxjs.of(discount);
542
- };
543
- CouponService.prototype.calcDiscountShopping = function (coupon, checkout) {
544
- return __awaiter(this, void 0, void 0, function () {
545
- var discount, _d;
546
- return __generator(this, function (_e) {
547
- switch (_e.label) {
548
- case 0:
549
- discount = 0;
550
- _d = coupon.type;
551
- switch (_d) {
552
- case i1$1.CouponTypes.ABSOLUTE: return [3 /*break*/, 1];
553
- case i1$1.CouponTypes.PERCENTAGE: return [3 /*break*/, 2];
554
- }
555
- return [3 /*break*/, 4];
556
- case 1:
557
- {
558
- discount = coupon.discount;
559
- return [3 /*break*/, 4];
560
- }
561
- _e.label = 2;
562
- case 2: return [4 /*yield*/, this.calcShoppingPercentageDiscount(coupon, checkout)];
563
- case 3:
564
- discount = _e.sent();
565
- return [3 /*break*/, 4];
566
- case 4: return [2 /*return*/, discount];
567
- }
568
- });
569
- });
570
- };
571
- CouponService.prototype.calcShoppingPercentageDiscount = function (coupon, checkout) {
572
- var _a;
573
- return __awaiter(this, void 0, void 0, function () {
574
- var discount, shop, lineItensDiscount, couponCategories, subTotal;
575
- return __generator(this, function (_d) {
576
- switch (_d.label) {
577
- case 0:
578
- discount = 0;
579
- shop = checkout.shop;
580
- lineItensDiscount = [];
581
- return [4 /*yield*/, this.getCouponCategoriesId(coupon)];
582
- case 1:
583
- couponCategories = _d.sent();
584
- if (coupon.productsCategories && coupon.productsCategories.length) {
585
- lineItensDiscount = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter(function (i) {
586
- var _a;
587
- if ((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length) {
588
- return i.categories.some(function (c) { return couponCategories.some(function (cat) { return (cat.id == c || cat.firestoreId == c); }); });
589
- }
590
- return true;
591
- });
592
- }
593
- else {
594
- lineItensDiscount = checkout.lineItems;
595
- }
596
- subTotal = lineItensDiscount.reduce(function (acc, curr) {
597
- var _a, _b, _c;
598
- return ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber) && ((_b = curr.price[shop]) === null || _b === void 0 ? void 0 : _b.subscriberPrice)
599
- ? acc + ((_c = curr.price[shop]) === null || _c === void 0 ? void 0 : _c.subscriberPrice) * curr.quantity
600
- : acc + curr.pricePaid * curr.quantity;
601
- }, 0) || 0;
602
- discount = subTotal * (coupon.discount / 100);
603
- return [2 /*return*/, discount];
604
- }
605
- });
606
- });
607
- };
608
- CouponService.prototype.hasMinSubTotal = function (coupon, checkout) {
609
- var _a;
610
- if (!coupon.minSubTotalValue)
611
- return true;
612
- var shop = checkout.shop;
613
- var subTotal = ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.reduce(function (acc, curr) {
614
- var _a, _b, _c;
615
- return ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber) && ((_b = curr.price[shop]) === null || _b === void 0 ? void 0 : _b.subscriberPrice)
616
- ? acc + ((_c = curr.price[shop]) === null || _c === void 0 ? void 0 : _c.subscriberPrice) * curr.quantity
617
- : acc + curr.pricePaid * curr.quantity;
618
- }, 0)) || 0;
619
- if (coupon.minSubTotalValue <= subTotal)
620
- return true;
621
- return false;
622
- };
623
- CouponService.prototype.hasProductCategories = function (coupon, checkout) {
624
- var _a;
625
- return __awaiter(this, void 0, void 0, function () {
626
- var couponCategories, hasCategories;
627
- return __generator(this, function (_d) {
628
- switch (_d.label) {
629
- case 0:
630
- if (!coupon.productsCategories || !coupon.productsCategories.length) {
631
- return [2 /*return*/, true];
632
- }
633
- return [4 /*yield*/, this.getCouponCategoriesId(coupon)];
634
- case 1:
635
- couponCategories = _d.sent();
636
- hasCategories = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter(function (i) {
637
- var _a;
638
- if (!i.categories || !((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length))
639
- return true;
640
- return i.categories.some(function (c) { return couponCategories.some(function (cat) { return (cat.id == c || cat.firestoreId == c); }); });
641
- });
642
- return [2 /*return*/, hasCategories.length ? true : false];
643
- }
644
- });
645
- });
646
- };
647
- CouponService.prototype.userValidationAndSubscriptionStatus = function (coupon, userEmail) {
648
- return __awaiter(this, void 0, void 0, function () {
649
- var couponRuleSubscription, sub, activeSubs;
650
- return __generator(this, function (_d) {
651
- switch (_d.label) {
652
- case 0:
653
- // Verifica se o email do usuário é coorporativo
654
- if (!this.emailIsFromCollaborator(userEmail) && coupon.exclusivityType === i1$1.Exclusivities.COLLABORATORS)
655
- throw new InvalidCouponError('Você não é colaborador.');
656
- // Verifica se o email do usuário é associado ao cupom de uso por usuario
657
- if (coupon.exclusivityType === i1$1.Exclusivities.SPECIFIC_USER && coupon.userExclusiveEmail !== userEmail)
658
- throw new InvalidCouponError('Cupom não é válido para este usuário.');
659
- couponRuleSubscription = coupon.exclusivityType === i1$1.Exclusivities.ACTIVE_SUBSCRIBER ||
660
- coupon.exclusivityType === i1$1.Exclusivities.INACTIVE_SUBSCRIBER ||
661
- coupon.exclusivityType === i1$1.Exclusivities.NON_SUBSCRIBER;
662
- if (!(couponRuleSubscription && userEmail)) return [3 /*break*/, 2];
663
- return [4 /*yield*/, this.subscriptionRepository
664
- .find({
665
- filters: {
666
- user: {
667
- email: { operator: i1$1.Where.EQUALS, value: userEmail },
668
- },
669
- },
670
- })
671
- .then(function (sub) { return sub.data; })];
672
- case 1:
673
- sub = _d.sent();
674
- activeSubs = sub === null || sub === void 0 ? void 0 : sub.filter(function (s) { return s.status === i1$1.Status.ACTIVE; });
675
- switch (coupon.exclusivityType) {
676
- case i1$1.Exclusivities.ACTIVE_SUBSCRIBER:
677
- return [2 /*return*/, activeSubs.length > 0];
678
- case i1$1.Exclusivities.INACTIVE_SUBSCRIBER:
679
- return [2 /*return*/, activeSubs.length === 0];
680
- case i1$1.Exclusivities.NON_SUBSCRIBER:
681
- return [2 /*return*/, sub.length === 0];
682
- default:
683
- return [2 /*return*/, false];
684
- }
685
- _d.label = 2;
686
- case 2: return [2 /*return*/, true];
687
- }
688
- });
689
- });
690
- };
691
- CouponService.prototype.getCouponCategoriesId = function (coupon) {
692
- return __awaiter(this, void 0, void 0, function () {
693
- var couponCategories, index, c;
694
- return __generator(this, function (_d) {
695
- switch (_d.label) {
696
- case 0:
697
- couponCategories = [];
698
- index = 0;
699
- _d.label = 1;
700
- case 1:
701
- if (!(index < coupon.productsCategories.length)) return [3 /*break*/, 4];
702
- return [4 /*yield*/, this.categoryRepository.get({ id: coupon.productsCategories[index] })];
703
- case 2:
704
- c = _d.sent();
705
- couponCategories.push({ id: c.id, firestoreId: c.firestoreId });
706
- _d.label = 3;
707
- case 3:
708
- index++;
709
- return [3 /*break*/, 1];
710
- case 4: return [2 /*return*/, couponCategories];
711
- }
712
- });
713
- });
714
- };
715
- return CouponService;
716
- }());
717
- 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: 'SubscriptionRepository' }, { token: 'CategoryRepository' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
718
- CouponService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CouponService, providedIn: 'root' });
719
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CouponService, decorators: [{
720
- type: i0.Injectable,
721
- args: [{
722
- providedIn: 'root',
723
- }]
724
- }], ctorParameters: function () {
725
- return [{ type: undefined, decorators: [{
726
- type: i0.Inject,
727
- args: ['CouponRepository']
728
- }] }, { type: i1__namespace$1.Shops, decorators: [{
729
- type: i0.Inject,
730
- args: [DEFAULT_SHOP]
731
- }] }, { type: undefined, decorators: [{
732
- type: i0.Inject,
733
- args: ['OrderRepository']
734
- }] }, { type: undefined, decorators: [{
735
- type: i0.Inject,
736
- args: ['SubscriptionRepository']
737
- }] }, { type: undefined, decorators: [{
738
- type: i0.Inject,
739
- args: ['CategoryRepository']
740
- }] }];
741
- } });
742
-
743
- var CheckoutService = /** @class */ (function () {
744
- function CheckoutService(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
745
- this.couponService = couponService;
746
- this.checkoutRepository = checkoutRepository;
747
- this.orderRepository = orderRepository;
748
- this.userRepository = userRepository;
749
- this.defaultShop = defaultShop;
750
- }
751
- CheckoutService.prototype.getCheckout = function (checkoutData) {
752
- var checkoutId = cookie__default["default"].get('checkoutId');
753
- if (!i1$1.isNil(checkoutId))
754
- return rxjs.from(this.checkoutRepository.get({ id: checkoutId }));
755
- return rxjs.from(this.createCheckout(checkoutData));
756
- };
757
- CheckoutService.prototype.getUserByCheckout = function (checkoutId) {
758
- var _this = this;
759
- 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$1.NotFoundError('User is not found'); }); }));
760
- };
761
- CheckoutService.prototype.updateCheckoutLineItems = function (checkout) {
762
- return rxjs.from(this.checkoutRepository.update(i1$1.Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
763
- };
764
- CheckoutService.prototype.updateCheckoutUser = function (checkout) {
765
- return rxjs.from(this.checkoutRepository.update(i1$1.Checkout.toInstance({ id: checkout.id, user: checkout.user })));
766
- };
767
- CheckoutService.prototype.clearCheckoutFromSession = function () {
768
- cookie__default["default"].remove('checkoutId');
769
- return rxjs.of();
770
- };
771
- CheckoutService.prototype.calcDiscount = function (coupon) {
772
- var _this = this;
773
- return this.getCheckout().pipe(operators.concatMap(function (checkout) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_b) {
774
- switch (_b.label) {
775
- case 0: return [4 /*yield*/, this.couponService.calcDiscountShopping(coupon, checkout)];
776
- case 1: return [2 /*return*/, _b.sent()];
777
- }
778
- }); }); }));
779
- };
780
- CheckoutService.prototype.checkCoupon = function (nickname, checkoutType) {
781
- var _this = this;
782
- return this.getCheckout().pipe(operators.concatMap(function (checkout) {
783
- var _a;
784
- return _this.couponService
785
- .checkCoupon(nickname, (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email, i1$1.CheckoutTypes.ECOMMERCE, checkout.user.subscriptionPlan, checkout, false)
786
- .pipe();
787
- }));
788
- };
789
- CheckoutService.prototype.createCheckout = function (checkoutData) {
790
- return __awaiter(this, void 0, void 0, function () {
791
- var checkout;
792
- return __generator(this, function (_b) {
793
- switch (_b.label) {
794
- case 0: return [4 /*yield*/, this.checkoutRepository.create(Object.assign(Object.assign({ createdAt: new Date() }, i1$1.Checkout.toInstance(i1$1.pick(checkoutData, ['user', 'shop'])).toPlain()), { shop: (checkoutData === null || checkoutData === void 0 ? void 0 : checkoutData.shop) || this.defaultShop }))];
795
- case 1:
796
- checkout = _b.sent();
797
- cookie__default["default"].set('checkoutId', checkout.id);
798
- return [2 /*return*/, checkout];
799
- }
800
- });
801
- });
802
- };
803
- return CheckoutService;
804
- }());
805
- 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 });
806
- CheckoutService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutService });
807
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutService, decorators: [{
808
- type: i0.Injectable
809
- }], ctorParameters: function () {
810
- return [{ type: CouponService }, { type: undefined, decorators: [{
811
- type: i0.Inject,
812
- args: ['CheckoutRepository']
813
- }] }, { type: undefined, decorators: [{
814
- type: i0.Inject,
815
- args: ['OrderRepository']
816
- }] }, { type: undefined, decorators: [{
817
- type: i0.Inject,
818
- args: ['UserRepository']
819
- }] }, { type: i1__namespace$1.Shops, decorators: [{
820
- type: i0.Inject,
821
- args: [DEFAULT_SHOP]
822
- }] }];
823
- } });
824
-
825
- var CartService = /** @class */ (function () {
826
- function CartService(authService, checkoutService, defaultShop, productRepository) {
827
- var _this = this;
828
- this.authService = authService;
829
- this.checkoutService = checkoutService;
830
- this.defaultShop = defaultShop;
831
- this.productRepository = productRepository;
832
- this.cartSubject = new rxjs.Subject();
833
- this.updateLineItemInCart = function (lineItem, quantity, checkout) { return (i1$1.isNil(checkout) ? _this.checkoutService.getCheckout() : rxjs.of(checkout)).pipe(operators.concatMap(function (checkoutLoaded) {
834
- var _a;
835
- var items = [];
836
- var index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map(function (checkoutItem) { return checkoutItem.sku; }).indexOf(lineItem.sku);
837
- if (index > -1) {
838
- checkoutLoaded.lineItems[index].quantity += quantity;
839
- checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
840
- }
841
- else
842
- checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
843
- return _this.checkoutService
844
- .updateCheckoutLineItems(checkoutLoaded)
845
- .pipe(operators.map(function (updatedCheckout) { return _this.generateCartObject(updatedCheckout.lineItems); }));
846
- })); };
847
- this.generateCartObject = function (items) {
848
- var cart = {};
849
- items === null || items === void 0 ? void 0 : items.forEach(function (item) {
850
- var _a;
851
- return (cart[item.sku] = i1$1.LineItem.toInstance(Object.assign(Object.assign({}, (cart[item.sku] || item)), { quantity: (((_a = cart[item.sku]) === null || _a === void 0 ? void 0 : _a.quantity) || 0) + (item.quantity ? item.quantity : 1) })));
852
- });
853
- return cart;
854
- };
855
- this.buildLineItem = function (_h) {
856
- var checkout = _h.checkout, item = _h.item, quantity = _h.quantity;
857
- return __awaiter(_this, void 0, void 0, function () {
858
- var _a, _b, _c, _d, _e, _f, _g, product, image, id, name, EAN, brand, slug, stock, price, weight, categories, sku, type, isGift, pricePaid;
859
- return __generator(this, function (_h) {
860
- switch (_h.label) {
861
- case 0: return [4 /*yield*/, this.productRepository.get({ id: item.id })];
862
- case 1:
863
- product = _h.sent();
864
- 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.sku === item.sku; })) === null || _b === void 0 ? void 0 : _b.quantity) || 0;
865
- if (this.checkMaxStock(item, quantity || 0))
866
- throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
867
- image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
868
- id = item.id, name = item.name, EAN = item.EAN, brand = item.brand, slug = item.slug, stock = item.stock, price = item.price, weight = item.weight, categories = item.categories, sku = item.sku, type = item.type;
869
- isGift = item.isGift || null;
870
- pricePaid = this.getProductPrice({
871
- product: item,
872
- shop: checkout.shop || this.defaultShop,
873
- isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
874
- });
875
- return [2 /*return*/, {
876
- checkout: checkout,
877
- lineItem: i1$1.LineItem.toInstance({
878
- id: id,
879
- name: name !== null && name !== void 0 ? name : product.name,
880
- EAN: EAN !== null && EAN !== void 0 ? EAN : product.EAN,
881
- brand: product.brand,
882
- slug: slug !== null && slug !== void 0 ? slug : product.slug,
883
- sku: sku !== null && sku !== void 0 ? sku : product.sku,
884
- stock: stock,
885
- price: price,
886
- image: image,
887
- weight: weight !== null && weight !== void 0 ? weight : product.weight,
888
- quantity: (item.quantity || 0) + (quantity || 0),
889
- pricePaid: pricePaid,
890
- categories: (_f = product.categories) !== null && _f !== void 0 ? _f : [],
891
- isGift: isGift !== null && isGift !== void 0 ? isGift : null,
892
- costPrice: (_g = product.costPrice) !== null && _g !== void 0 ? _g : 0,
893
- type: type,
894
- }),
895
- }];
896
- }
897
- });
898
- });
899
- };
900
- this.getProductPrice = function (_h) {
901
- var product = _h.product, isSubscriber = _h.isSubscriber;
902
- var info = product.price;
903
- if (product.isGift)
904
- return 0;
905
- return isSubscriber && info.subscriberPrice > 0 ? info.subscriberPrice : info.price;
906
- };
907
- this.checkMaxStock = function (item, quantity) {
908
- var _a;
909
- var maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
910
- var currentItemAmount = item.quantity || 0;
911
- return currentItemAmount + quantity > maxStock;
912
- };
913
- }
914
- CartService.prototype.addItem = function (item, quantity) {
915
- var _this = this;
916
- if (quantity === void 0) { quantity = 1; }
917
- return rxjs.from(this.checkoutService.getCheckout()).pipe(operators.concatMap(function (checkout) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_h) {
918
- switch (_h.label) {
919
- case 0: return [4 /*yield*/, this.buildLineItem({ checkout: checkout, item: item, quantity: quantity || 1 })];
920
- case 1: return [2 /*return*/, _h.sent()];
921
- }
922
- }); }); }), operators.mergeMap(function (_h) {
923
- var checkout = _h.checkout, lineItem = _h.lineItem;
924
- return _this.updateLineItemInCart(lineItem, quantity || 1, checkout);
925
- }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
926
- };
927
- CartService.prototype.decreaseItem = function (item) {
928
- var _this = this;
929
- return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
930
- var _a;
931
- var checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find(function (lineItem) { return lineItem.sku === item.sku; });
932
- if (!i1$1.isNil(checkoutItem))
933
- checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
934
- return checkout;
935
- }), 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); }));
936
- };
937
- CartService.prototype.getCart = function (checkout) {
938
- var _this = this;
939
- this.buildCartFromCheckout(checkout).subscribe(function (cart) { return _this.cartSubject.next(cart); });
940
- return this.cartSubject;
941
- };
942
- /**
943
- * @deprecated The method should not be used
944
- */
945
- CartService.prototype.getVariantPriceDiscount = function (item) {
946
- 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); }));
947
- };
948
- CartService.prototype.removeItem = function (item) {
949
- var _this = this;
950
- return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
951
- var index = checkout.lineItems.findIndex(function (lineItem) { return lineItem.sku === item.sku; });
952
- if (index >= 0)
953
- checkout.lineItems.splice(index, 1);
954
- return checkout;
955
- }), 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); }));
956
- };
957
- CartService.prototype.updateUserCart = function (user) {
958
- var _this = this;
959
- return this.checkoutService.getCheckout().pipe(operators.concatMap(function (checkout) { return _this.checkoutService.updateCheckoutUser(i1$1.Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user: user }))); }), operators.concatMap(function (checkout) { return __awaiter(_this, void 0, void 0, function () {
960
- var _a, _b, _h, _j, _k, _l, _m, _o, _p, _q, _r;
961
- var _this = this;
962
- return __generator(this, function (_s) {
963
- switch (_s.label) {
964
- case 0:
965
- _j = (_h = this.checkoutService).updateCheckoutLineItems;
966
- _l = (_k = i1$1.Checkout).toInstance;
967
- _o = (_m = Object).assign;
968
- _p = [Object.assign({}, checkout.toPlain())];
969
- _q = {};
970
- if (!((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.length)) return [3 /*break*/, 2];
971
- 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) {
972
- switch (_h.label) {
973
- case 0: return [4 /*yield*/, this.buildLineItem({ checkout: checkout, item: item })];
974
- case 1: return [2 /*return*/, (_h.sent()).lineItem];
975
- }
976
- }); }); }))];
977
- case 1:
978
- _r = _s.sent();
979
- return [3 /*break*/, 3];
980
- case 2:
981
- _r = [];
982
- _s.label = 3;
983
- case 3: return [2 /*return*/, _j.apply(_h, [_l.apply(_k, [_o.apply(_m, _p.concat([(_q.lineItems = _r, _q)]))])]).toPromise()];
984
- }
985
- });
986
- }); }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
987
- };
988
- CartService.prototype.clearCart = function () {
989
- var _this = this;
990
- return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
991
- _this.checkoutService.clearCheckoutFromSession();
992
- return checkout;
993
- }), operators.concatMap(function (oldCheckout) { return _this.buildCartFromCheckout(oldCheckout); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
994
- };
995
- CartService.prototype.buildCartFromCheckout = function (checkoutData) {
996
- var _this = this;
997
- return this.checkoutService.getCheckout(checkoutData).pipe(operators.map(function (checkout) { return checkout.lineItems; }), operators.concatMap(function (lineItems) { return rxjs.of(_this.generateCartObject(lineItems)); }));
998
- };
999
- return CartService;
1000
- }());
1001
- 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' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1002
- CartService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService });
1003
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService, decorators: [{
1004
- type: i0.Injectable
1005
- }], ctorParameters: function () {
1006
- return [{ type: AuthService }, { type: CheckoutService }, { type: i1__namespace$1.Shops, decorators: [{
1007
- type: i0.Inject,
1008
- args: [DEFAULT_SHOP]
1009
- }] }, { type: undefined, decorators: [{
1010
- type: i0.Inject,
1011
- args: ['ProductRepository']
1012
- }] }];
1013
- } });
1014
-
1015
- var CheckoutSubscriptionService = /** @class */ (function () {
1016
- function CheckoutSubscriptionService(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
1017
- this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
1018
- this.subscriptionRepository = subscriptionRepository;
1019
- this.couponService = couponService;
1020
- }
1021
- CheckoutSubscriptionService.prototype.getCheckoutSubscription = function (checkoutData) {
1022
- var checkoutId = cookie__default["default"].get('checkoutSubscriptionId');
1023
- if (!i1$1.isNil(checkoutId))
1024
- return rxjs.from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
1025
- return rxjs.from(this.createCheckoutSubscription(checkoutData));
1026
- };
1027
- CheckoutSubscriptionService.prototype.createCheckoutSubscription = function (checkoutData) {
1028
- return __awaiter(this, void 0, void 0, function () {
1029
- var checkout;
1030
- return __generator(this, function (_a) {
1031
- switch (_a.label) {
1032
- case 0: return [4 /*yield*/, this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, i1$1.CheckoutSubscription.toInstance(i1$1.pick(checkoutData, ['user', 'shop'])).toPlain()))];
1033
- case 1:
1034
- checkout = _a.sent();
1035
- cookie__default["default"].set('checkoutSubscriptionId', checkout.id);
1036
- return [2 /*return*/, checkout];
1037
- }
1038
- });
1039
- });
1040
- };
1041
- CheckoutSubscriptionService.prototype.clearCheckoutSubscriptionFromSession = function () {
1042
- cookie__default["default"].remove('checkoutSubscriptionId');
1043
- return rxjs.of();
1044
- };
1045
- CheckoutSubscriptionService.prototype.checkCoupon = function (nickname, userEmail) {
1046
- var _this = this;
1047
- return this.getCheckoutSubscription().pipe(operators.concatMap(function (checkout) { return _this.couponService.checkCoupon(nickname, userEmail, i1$1.CheckoutTypes.SUBSCRIPTION, checkout.subscriptionPlan.name, null, true).pipe(); }));
1048
- };
1049
- CheckoutSubscriptionService.prototype.calcDiscountSubscription = function (coupon) {
1050
- var _this = this;
1051
- return this.getCheckoutSubscription().pipe(operators.concatMap(function (checkout) { return _this.couponService.calcDiscountSubscription(coupon, checkout).pipe(); }));
1052
- };
1053
- return CheckoutSubscriptionService;
1054
- }());
1055
- 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 });
1056
- CheckoutSubscriptionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService });
1057
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService, decorators: [{
1058
- type: i0.Injectable
1059
- }], ctorParameters: function () {
1060
- return [{ type: undefined, decorators: [{
1061
- type: i0.Inject,
1062
- args: ['CheckoutSubscriptionRepository']
1063
- }] }, { type: undefined, decorators: [{
1064
- type: i0.Inject,
1065
- args: ['SubscriptionRepository']
1066
- }] }, { type: CouponService }];
1067
- } });
1068
-
1069
- var HomeShopService = /** @class */ (function () {
1070
- function HomeShopService(categoryRepository, homeRepository, productRepository, defaultShop) {
1071
- this.categoryRepository = categoryRepository;
1072
- this.homeRepository = homeRepository;
1073
- this.productRepository = productRepository;
1074
- this.defaultShop = defaultShop;
1075
- this.buildCategoryGroupWithRequiredData = function (group) {
1076
- var _a, _b;
1077
- return ({
1078
- category: i1$1.Category.toInstance(i1$1.pick(((_a = group === null || group === void 0 ? void 0 : group.category) === null || _a === void 0 ? void 0 : _a.toPlain()) || {}, ['id', 'name', 'slug', 'conditions'])),
1079
- products: ((_b = group === null || group === void 0 ? void 0 : group.products) === null || _b === void 0 ? void 0 : _b.map(function (product) { return i1$1.Product.toInstance(i1$1.pick((product === null || product === void 0 ? void 0 : product.toPlain()) || {}, [
1080
- 'id',
1081
- 'price',
1082
- 'reviews',
1083
- 'hasVariants',
1084
- 'slug',
1085
- 'sku',
1086
- 'stock',
1087
- 'costPrice',
1088
- 'images',
1089
- 'miniatures',
1090
- 'name',
1091
- 'weight',
1092
- 'rate',
1093
- 'type',
1094
- ])); })) || [],
1095
- });
1096
- };
1097
- }
1098
- Object.defineProperty(HomeShopService.prototype, "homeId", {
1099
- get: function () {
1100
- if (this.defaultShop === i1$1.Shops.GLAMSHOP)
1101
- return 'glamshop';
1102
- if (this.defaultShop === i1$1.Shops.MENSMARKET)
1103
- return 'mens_market';
1104
- return null;
1105
- },
1106
- enumerable: false,
1107
- configurable: true
1108
- });
1109
- HomeShopService.prototype.getHomeData = function () {
1110
- var _this = this;
1111
- 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
1112
- ? rxjs.of(home)
1113
- : rxjs.forkJoin([_this.getDiscoverProducts(), _this.getFeaturedProducts(), _this.getVerticalProducts()]).pipe(operators.map(function (_c) {
1114
- var _d = __read(_c, 3), discoverProducts = _d[0], featuredProducts = _d[1], verticalProducts = _d[2];
1115
- return ({
1116
- discoverProducts: discoverProducts,
1117
- featuredProducts: featuredProducts,
1118
- verticalProducts: verticalProducts,
1119
- });
1120
- }), operators.concatMap(function (data) { return _this.saveHomeData(data); })); }));
1121
- };
1122
- HomeShopService.prototype.getBanners = function (type) {
1123
- return this.getHomeConfiguration().pipe(operators.map(function (home) {
1124
- if (type === 'brand')
1125
- return home.brandsCarousel;
1126
- if (type === 'buyToWin')
1127
- return [home.buyToWinBanner];
1128
- if (type === 'block')
1129
- return home.blockBanners;
1130
- if (type === 'blog')
1131
- return [home.blogBanner];
1132
- }));
1133
- };
1134
- HomeShopService.prototype.getMinValueForFreeShipping = function () {
1135
- return this.getHomeConfiguration().pipe(operators.map(function (home) { return home.minValueForFreeShipping; }));
1136
- };
1137
- HomeShopService.prototype.getDiscoverProducts = function () {
1138
- var _this = this;
1139
- 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); })); }));
1140
- };
1141
- HomeShopService.prototype.getFeaturedProducts = function () {
1142
- var _this = this;
1143
- 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); })); }));
1144
- };
1145
- HomeShopService.prototype.getVerticalProducts = function () {
1146
- var _this = this;
1147
- 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({
1148
- filters: { categories: { operator: i1$1.Where.IN, value: [category.id] } },
1149
- limits: { limit: 12 },
1150
- })).pipe(operators.map(function (products) { return ({ category: category, products: products }); })); }), operators.map(function (_c) {
1151
- var category = _c.category, products = _c.products;
1152
- return ({ category: category, products: products.data });
1153
- }), operators.map(_this.buildCategoryGroupWithRequiredData)); })); }));
1154
- };
1155
- HomeShopService.prototype.getHomeConfiguration = function () {
1156
- var _this = this;
1157
- return rxjs.of(this.homeConfiguration).pipe(operators.concatMap(function (home) { return home
1158
- ? rxjs.of(home)
1159
- : !_this.homeId
1160
- ? rxjs.throwError(new i1$1.RequiredArgumentError(['homeId']))
1161
- : rxjs.from(_this.homeRepository.get({ id: _this.homeId })).pipe(operators.tap(function (homeLoaded) { return (_this.homeConfiguration = homeLoaded); })); }));
1162
- };
1163
- HomeShopService.prototype.saveHomeData = function (homeData) {
1164
- var _this = this;
1165
- var data = {
1166
- createdAt: new Date(),
1167
- expiresAt: i1$1.add(new Date(), { hours: 1 }),
1168
- data: homeData,
1169
- };
1170
- return rxjs.from(this.homeRepository.update({
1171
- id: this.homeId,
1172
- data: data,
1173
- })).pipe(operators.tap(function () { return (_this.homeConfiguration.data = data); }), operators.map(function () { return _this.homeConfiguration; }));
1174
- };
1175
- return HomeShopService;
1176
- }());
1177
- 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 });
1178
- HomeShopService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: HomeShopService });
1179
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: HomeShopService, decorators: [{
1180
- type: i0.Injectable
1181
- }], ctorParameters: function () {
1182
- return [{ type: undefined, decorators: [{
1183
- type: i0.Inject,
1184
- args: ['CategoryRepository']
1185
- }] }, { type: undefined, decorators: [{
1186
- type: i0.Inject,
1187
- args: ['HomeRepository']
1188
- }] }, { type: undefined, decorators: [{
1189
- type: i0.Inject,
1190
- args: ['ProductRepository']
1191
- }] }, { type: i1__namespace$1.Shops, decorators: [{
1192
- type: i0.Inject,
1193
- args: [DEFAULT_SHOP]
1194
- }] }];
1195
- } });
1196
-
1197
- var OrderService = /** @class */ (function () {
1198
- function OrderService(angularFirestore, orderRepository) {
1199
- this.angularFirestore = angularFirestore;
1200
- this.orderRepository = orderRepository;
1201
- this.orderSubject = new rxjs.Subject();
1202
- }
1203
- OrderService.prototype.getOrder = function (id) {
1204
- var _this = this;
1205
- this.angularFirestore
1206
- .doc(this.orderRepository.collectionName + "/" + id)
1207
- .valueChanges()
1208
- .pipe(operators.map(function (doc) { return i1$1.Order.toInstance(doc); }))
1209
- .subscribe(function (doc) { return _this.orderSubject.next(doc); });
1210
- return this.orderSubject;
1211
- };
1212
- return OrderService;
1213
- }());
1214
- 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 });
1215
- OrderService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService });
1216
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService, decorators: [{
1217
- type: i0.Injectable
1218
- }], ctorParameters: function () {
1219
- return [{ type: i1__namespace$2.AngularFirestore }, { type: i1__namespace$1.OrderFirestoreRepository, decorators: [{
1220
- type: i0.Inject,
1221
- args: ['OrderRepository']
1222
- }] }];
1223
- } });
1224
-
1225
- var ShippingService = /** @class */ (function () {
1226
- function ShippingService(http, apiUrl, homeService) {
1227
- this.http = http;
1228
- this.apiUrl = apiUrl;
1229
- this.homeService = homeService;
1230
- }
1231
- ShippingService.prototype.getShippingMethods = function (shop, zip, weightGrams, totalPrice, personId, subscriptionPlan) {
1232
- var _this = this;
1233
- return rxjs.combineLatest([
1234
- this.homeService.getHomeData(),
1235
- this.http.get(this.apiUrl + "open/checkshippingcompany?personId=" + personId + "&postalCode=" + zip + "&weightGrams=" + weightGrams)
1236
- ])
1237
- .pipe(operators.map(function (_a) {
1238
- var _b = __read(_a, 2), datas = _b[0], shippingMethodsResponse = _b[1];
1239
- var shippingMethods = shippingMethodsResponse.result;
1240
- if (!shippingMethods.length)
1241
- return [];
1242
- shippingMethods = shippingMethods.map(function (s) {
1243
- if (s.ShippingCompanyName == 'Same Day EG')
1244
- s.ShippingCompanyName = 'Same Day';
1245
- else
1246
- return s;
1247
- });
1248
- var datasSameDayNotAvaliable = datas.sameDayNotAvaliable;
1249
- if (_this.isHolidays(datasSameDayNotAvaliable)) {
1250
- shippingMethods = shippingMethods.filter(function (method) { return method.ShippingCompanyName !== 'Same Day'; });
1251
- }
1252
- if (totalPrice >= 200) {
1253
- shippingMethods = shippingMethods.map(function (s) {
1254
- if (s.serviceName !== 'Same Day')
1255
- return Object.assign(Object.assign({}, s), { totalPrice: 0 });
1256
- else
1257
- return s;
1258
- });
1259
- }
1260
- if (shop == i1$1.Shops.GLAMSHOP)
1261
- return shippingMethods;
1262
- if (_this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
1263
- shippingMethods = shippingMethods.map(function (s) {
1264
- if (s.serviceName == 'Same Day')
1265
- return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
1266
- else
1267
- return Object.assign(Object.assign({}, s), { totalPrice: 0 });
1268
- });
1269
- }
1270
- if (_this.isHalfShippingBySubscription(shop, subscriptionPlan)) {
1271
- shippingMethods = shippingMethods.map(function (s) {
1272
- return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
1273
- });
1274
- }
1275
- return shippingMethods;
1276
- }));
1277
- };
1278
- ShippingService.prototype.isFreeShippingBySubscription = function (shop, subscriptionPlan) {
1279
- if (!subscriptionPlan)
1280
- return false;
1281
- if (shop == i1$1.Shops.MENSMARKET && subscriptionPlan == 'SELECT') {
1282
- return true;
1283
- }
1284
- return false;
1285
- };
1286
- ShippingService.prototype.isHalfShippingBySubscription = function (shop, subscriptionPlan) {
1287
- if (!subscriptionPlan)
1288
- return false;
1289
- if (shop == i1$1.Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
1290
- return true;
1291
- }
1292
- return false;
1293
- };
1294
- ShippingService.prototype.isHolidays = function (datas) {
1295
- var today = new Date();
1296
- for (var key in datas) {
1297
- var start = new Date(today.getFullYear() + "-" + datas[key].beginDate);
1298
- var end = new Date(today.getFullYear() + "-" + datas[key].endDate);
1299
- if (start > end)
1300
- end = new Date(today.getFullYear() + 1 + "-" + datas[key].endDate);
1301
- if (today >= start && today <= end)
1302
- return true;
1303
- }
1304
- return false;
1305
- };
1306
- return ShippingService;
1307
- }());
1308
- 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 });
1309
- ShippingService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: ShippingService });
1310
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: ShippingService, decorators: [{
1311
- type: i0.Injectable
1312
- }], ctorParameters: function () {
1313
- return [{ type: i1__namespace$3.HttpClient }, { type: undefined, decorators: [{
1314
- type: i0.Inject,
1315
- args: [BACKEND_URL]
1316
- }] }, { type: HomeShopService }];
1317
- } });
1318
-
1319
- var AngularFirebaseAuthModule = /** @class */ (function () {
1320
- function AngularFirebaseAuthModule() {
1321
- }
1322
- AngularFirebaseAuthModule.initializeApp = function (options, nameOrConfig) {
1323
- return {
1324
- ngModule: AngularFirebaseAuthModule,
1325
- providers: [
1326
- { provide: fire.FIREBASE_OPTIONS, useValue: options },
1327
- { provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
1328
- ],
1329
- };
1330
- };
1331
- return AngularFirebaseAuthModule;
1332
- }());
1333
- AngularFirebaseAuthModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1334
- AngularFirebaseAuthModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, imports: [fire.AngularFireModule] });
1335
- AngularFirebaseAuthModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, providers: [
1336
- {
1337
- provide: 'Authentication',
1338
- useFactory: function (authenticationService, userRepository) {
1339
- return new i1$1.Authentication(authenticationService, userRepository);
1340
- },
1341
- deps: ['AuthenticationService', 'UserRepository'],
1342
- },
1343
- {
1344
- provide: 'AuthenticationService',
1345
- useFactory: function (angularFireAuth) {
1346
- return new i1$1.AuthenticationFirebaseAuthService(angularFireAuth);
1347
- },
1348
- deps: [i1.AngularFireAuth],
1349
- },
1350
- {
1351
- provide: 'Register',
1352
- useFactory: function (registerService, userRepository) {
1353
- return new i1$1.Register(registerService, userRepository);
1354
- },
1355
- deps: ['RegisterService', 'UserRepository'],
1356
- },
1357
- {
1358
- provide: 'RegisterService',
1359
- useFactory: function (angularFireAuth) {
1360
- return new i1$1.RegisterFirebaseAuthService(angularFireAuth);
1361
- },
1362
- deps: [i1.AngularFireAuth],
1363
- },
1364
- {
1365
- provide: 'SignOut',
1366
- useFactory: function (authenticationService) {
1367
- return new i1$1.SignOut(authenticationService);
1368
- },
1369
- deps: ['AuthenticationService'],
1370
- },
1371
- {
1372
- provide: 'RecoveryPassword',
1373
- useFactory: function (authenticationService) {
1374
- return new i1$1.RecoveryPassword(authenticationService);
1375
- },
1376
- deps: ['AuthenticationService'],
1377
- },
1378
- ], imports: [[fire.AngularFireModule]] });
1379
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, decorators: [{
1380
- type: i0.NgModule,
1381
- args: [{
1382
- imports: [fire.AngularFireModule],
1383
- providers: [
1384
- {
1385
- provide: 'Authentication',
1386
- useFactory: function (authenticationService, userRepository) {
1387
- return new i1$1.Authentication(authenticationService, userRepository);
1388
- },
1389
- deps: ['AuthenticationService', 'UserRepository'],
1390
- },
1391
- {
1392
- provide: 'AuthenticationService',
1393
- useFactory: function (angularFireAuth) {
1394
- return new i1$1.AuthenticationFirebaseAuthService(angularFireAuth);
1395
- },
1396
- deps: [i1.AngularFireAuth],
1397
- },
1398
- {
1399
- provide: 'Register',
1400
- useFactory: function (registerService, userRepository) {
1401
- return new i1$1.Register(registerService, userRepository);
1402
- },
1403
- deps: ['RegisterService', 'UserRepository'],
1404
- },
1405
- {
1406
- provide: 'RegisterService',
1407
- useFactory: function (angularFireAuth) {
1408
- return new i1$1.RegisterFirebaseAuthService(angularFireAuth);
1409
- },
1410
- deps: [i1.AngularFireAuth],
1411
- },
1412
- {
1413
- provide: 'SignOut',
1414
- useFactory: function (authenticationService) {
1415
- return new i1$1.SignOut(authenticationService);
1416
- },
1417
- deps: ['AuthenticationService'],
1418
- },
1419
- {
1420
- provide: 'RecoveryPassword',
1421
- useFactory: function (authenticationService) {
1422
- return new i1$1.RecoveryPassword(authenticationService);
1423
- },
1424
- deps: ['AuthenticationService'],
1425
- },
1426
- ],
1427
- }]
1428
- }] });
1429
-
1430
- var AngularElasticSeachModule = /** @class */ (function () {
1431
- function AngularElasticSeachModule() {
1432
- }
1433
- AngularElasticSeachModule.initializeApp = function (options) {
1434
- return {
1435
- ngModule: AngularElasticSeachModule,
1436
- providers: [{ provide: ES_CONFIG, useValue: options }],
1437
- };
1438
- };
1439
- return AngularElasticSeachModule;
1440
- }());
1441
- AngularElasticSeachModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1442
- AngularElasticSeachModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule });
1443
- AngularElasticSeachModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, providers: [
1444
- {
1445
- provide: i1$1.ProductsIndex,
1446
- useFactory: function (configuration) {
1447
- return new i1$1.ProductsIndex(new i1$1.AxiosAdapter(configuration));
1448
- },
1449
- deps: [ES_CONFIG],
1450
- },
1451
- ] });
1452
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, decorators: [{
1453
- type: i0.NgModule,
1454
- args: [{
1455
- providers: [
1456
- {
1457
- provide: i1$1.ProductsIndex,
1458
- useFactory: function (configuration) {
1459
- return new i1$1.ProductsIndex(new i1$1.AxiosAdapter(configuration));
1460
- },
1461
- deps: [ES_CONFIG],
1462
- },
1463
- ],
1464
- }]
1465
- }] });
1466
-
1467
- var AngularFirestoreModule = /** @class */ (function () {
1468
- function AngularFirestoreModule() {
1469
- }
1470
- AngularFirestoreModule.initializeApp = function (options, nameOrConfig) {
1471
- return {
1472
- ngModule: AngularFirestoreModule,
1473
- providers: [
1474
- { provide: fire.FIREBASE_OPTIONS, useValue: options.firebase },
1475
- { provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
1476
- { provide: ES_CONFIG, useValue: options.elasticSearch },
1477
- ],
1478
- };
1479
- };
1480
- return AngularFirestoreModule;
1481
- }());
1482
- AngularFirestoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1483
- AngularFirestoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, imports: [fire.AngularFireModule, AngularElasticSeachModule] });
1484
- AngularFirestoreModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, providers: [
1485
- {
1486
- provide: 'BeautyProfileRepository',
1487
- useFactory: function (firestore, userRepository) {
1488
- return new i1$1.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
1489
- },
1490
- deps: [i1$2.AngularFirestore, 'UserRepository'],
1491
- },
1492
- {
1493
- provide: 'Buy2WinRepository',
1494
- useFactory: function (firestore) {
1495
- return new i1$1.Buy2WinFirestoreRepository(firestore.firestore);
1496
- },
1497
- deps: [i1$2.AngularFirestore],
1498
- },
1499
- {
1500
- provide: i1$1.CategoryFirestoreRepository,
1501
- useFactory: function (firestore) {
1502
- return new i1$1.CategoryFirestoreRepository(firestore.firestore);
1503
- },
1504
- deps: [i1$2.AngularFirestore],
1505
- },
1506
- {
1507
- provide: 'CheckoutRepository',
1508
- useFactory: function (firestore) {
1509
- return new i1$1.CheckoutFirestoreRepository(firestore.firestore);
1510
- },
1511
- deps: [i1$2.AngularFirestore],
1512
- },
1513
- {
1514
- provide: 'CheckoutSubscriptionRepository',
1515
- useFactory: function (firestore) {
1516
- return new i1$1.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
1517
- },
1518
- deps: [i1$2.AngularFirestore],
1519
- },
1520
- {
1521
- provide: 'CouponRepository',
1522
- useFactory: function (firestore) {
1523
- return new i1$1.CouponFirestoreRepository(firestore.firestore);
1524
- },
1525
- deps: [i1$2.AngularFirestore],
1526
- },
1527
- {
1528
- provide: 'EditionRepository',
1529
- useFactory: function (firestore, subscriptionRepository) {
1530
- return new i1$1.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
1531
- },
1532
- deps: [i1$2.AngularFirestore, 'SubscriptionRepository'],
1533
- },
1534
- {
1535
- provide: 'HomeRepository',
1536
- useFactory: function (firestore) {
1537
- return new i1$1.HomeFirestoreRepository(firestore.firestore);
1538
- },
1539
- deps: [i1$2.AngularFirestore],
1540
- },
1541
- {
1542
- provide: 'LeadRepository',
1543
- useFactory: function (firestore) {
1544
- return new i1$1.LeadFirestoreRepository(firestore.firestore);
1545
- },
1546
- deps: [i1$2.AngularFirestore],
1547
- },
1548
- {
1549
- provide: 'LegacyOrderRepository',
1550
- useFactory: function (firestore) {
1551
- return new i1$1.LegacyOrderFirestoreRepository(firestore.firestore);
1552
- },
1553
- deps: [i1$2.AngularFirestore],
1554
- },
1555
- {
1556
- provide: 'ShopMenuRepository',
1557
- useFactory: function (firestore) {
1558
- return new i1$1.ShopMenuFirestoreRepository(firestore.firestore);
1559
- },
1560
- deps: [i1$2.AngularFirestore],
1561
- },
1562
- {
1563
- provide: 'OrderRepository',
1564
- useFactory: function (firestore) {
1565
- return new i1$1.OrderFirestoreRepository(firestore.firestore);
1566
- },
1567
- deps: [i1$2.AngularFirestore],
1568
- },
1569
- {
1570
- provide: 'PaymentRepository',
1571
- useFactory: function (firestore) {
1572
- return new i1$1.PaymentFirestoreRepository(firestore.firestore);
1573
- },
1574
- deps: [i1$2.AngularFirestore],
1575
- },
1576
- {
1577
- provide: i1$1.ProductFirestoreRepository,
1578
- useFactory: function (firestore) {
1579
- return new i1$1.ProductFirestoreRepository(firestore.firestore);
1580
- },
1581
- deps: [i1$2.AngularFirestore],
1582
- },
1583
- {
1584
- provide: 'ShopSettingsRepository',
1585
- useFactory: function (firestore) {
1586
- return new i1$1.ShopSettingsFirestoreRepository(firestore.firestore);
1587
- },
1588
- deps: [i1$2.AngularFirestore],
1589
- },
1590
- {
1591
- provide: 'SubscriptionPaymentRepository',
1592
- useFactory: function (firestore, subscriptionRepository) {
1593
- return new i1$1.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
1594
- },
1595
- deps: [i1$2.AngularFirestore, 'SubscriptionRepository'],
1596
- },
1597
- {
1598
- provide: 'SubscriptionPlanRepository',
1599
- useFactory: function (firestore) {
1600
- return new i1$1.SubscriptionPlanFirestoreRepository(firestore.firestore);
1601
- },
1602
- deps: [i1$2.AngularFirestore],
1603
- },
1604
- {
1605
- provide: 'SubscriptionProductRepository',
1606
- useFactory: function (firestore) {
1607
- return new i1$1.SubscriptionProductFirestoreRepository(firestore.firestore);
1608
- },
1609
- deps: [i1$2.AngularFirestore],
1610
- },
1611
- {
1612
- provide: 'SubscriptionRepository',
1613
- useFactory: function (firestore) {
1614
- return new i1$1.SubscriptionFirestoreRepository(firestore.firestore);
1615
- },
1616
- deps: [i1$2.AngularFirestore],
1617
- },
1618
- {
1619
- provide: 'UserRepository',
1620
- useFactory: function (firestore) {
1621
- return new i1$1.UserFirestoreRepository(firestore.firestore);
1622
- },
1623
- deps: [i1$2.AngularFirestore],
1624
- },
1625
- {
1626
- provide: 'UserAddressRepository',
1627
- useFactory: function (firestore, userRepository) {
1628
- return new i1$1.UserAddressFirestoreRepository(firestore.firestore, userRepository);
1629
- },
1630
- deps: [i1$2.AngularFirestore, 'UserRepository'],
1631
- },
1632
- {
1633
- provide: 'UserPaymentMethodRepository',
1634
- useFactory: function (firestore, userRepository) {
1635
- return new i1$1.UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
1636
- },
1637
- deps: [i1$2.AngularFirestore, 'UserRepository'],
1638
- },
1639
- {
1640
- provide: i1$1.ProductVariantFirestoreRepository,
1641
- useFactory: function (firestore, productRepository) {
1642
- return new i1$1.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
1643
- },
1644
- deps: [i1$2.AngularFirestore, i1$1.ProductFirestoreRepository],
1645
- },
1646
- {
1647
- provide: i0.APP_INITIALIZER,
1648
- useFactory: function (firestore) { return function () { return firestore.firestore.settings({ ignoreUndefinedProperties: true }); }; },
1649
- deps: [i1$2.AngularFirestore],
1650
- multi: true,
1651
- },
1652
- ], imports: [[fire.AngularFireModule, AngularElasticSeachModule]] });
1653
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, decorators: [{
1654
- type: i0.NgModule,
1655
- args: [{
1656
- imports: [fire.AngularFireModule, AngularElasticSeachModule],
1657
- providers: [
1658
- {
1659
- provide: 'BeautyProfileRepository',
1660
- useFactory: function (firestore, userRepository) {
1661
- return new i1$1.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
1662
- },
1663
- deps: [i1$2.AngularFirestore, 'UserRepository'],
1664
- },
1665
- {
1666
- provide: 'Buy2WinRepository',
1667
- useFactory: function (firestore) {
1668
- return new i1$1.Buy2WinFirestoreRepository(firestore.firestore);
1669
- },
1670
- deps: [i1$2.AngularFirestore],
1671
- },
1672
- {
1673
- provide: i1$1.CategoryFirestoreRepository,
1674
- useFactory: function (firestore) {
1675
- return new i1$1.CategoryFirestoreRepository(firestore.firestore);
1676
- },
1677
- deps: [i1$2.AngularFirestore],
1678
- },
1679
- {
1680
- provide: 'CheckoutRepository',
1681
- useFactory: function (firestore) {
1682
- return new i1$1.CheckoutFirestoreRepository(firestore.firestore);
1683
- },
1684
- deps: [i1$2.AngularFirestore],
1685
- },
1686
- {
1687
- provide: 'CheckoutSubscriptionRepository',
1688
- useFactory: function (firestore) {
1689
- return new i1$1.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
1690
- },
1691
- deps: [i1$2.AngularFirestore],
1692
- },
1693
- {
1694
- provide: 'CouponRepository',
1695
- useFactory: function (firestore) {
1696
- return new i1$1.CouponFirestoreRepository(firestore.firestore);
1697
- },
1698
- deps: [i1$2.AngularFirestore],
1699
- },
1700
- {
1701
- provide: 'EditionRepository',
1702
- useFactory: function (firestore, subscriptionRepository) {
1703
- return new i1$1.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
1704
- },
1705
- deps: [i1$2.AngularFirestore, 'SubscriptionRepository'],
1706
- },
1707
- {
1708
- provide: 'HomeRepository',
1709
- useFactory: function (firestore) {
1710
- return new i1$1.HomeFirestoreRepository(firestore.firestore);
1711
- },
1712
- deps: [i1$2.AngularFirestore],
1713
- },
1714
- {
1715
- provide: 'LeadRepository',
1716
- useFactory: function (firestore) {
1717
- return new i1$1.LeadFirestoreRepository(firestore.firestore);
1718
- },
1719
- deps: [i1$2.AngularFirestore],
1720
- },
1721
- {
1722
- provide: 'LegacyOrderRepository',
1723
- useFactory: function (firestore) {
1724
- return new i1$1.LegacyOrderFirestoreRepository(firestore.firestore);
1725
- },
1726
- deps: [i1$2.AngularFirestore],
1727
- },
1728
- {
1729
- provide: 'ShopMenuRepository',
1730
- useFactory: function (firestore) {
1731
- return new i1$1.ShopMenuFirestoreRepository(firestore.firestore);
1732
- },
1733
- deps: [i1$2.AngularFirestore],
1734
- },
1735
- {
1736
- provide: 'OrderRepository',
1737
- useFactory: function (firestore) {
1738
- return new i1$1.OrderFirestoreRepository(firestore.firestore);
1739
- },
1740
- deps: [i1$2.AngularFirestore],
1741
- },
1742
- {
1743
- provide: 'PaymentRepository',
1744
- useFactory: function (firestore) {
1745
- return new i1$1.PaymentFirestoreRepository(firestore.firestore);
1746
- },
1747
- deps: [i1$2.AngularFirestore],
1748
- },
1749
- {
1750
- provide: i1$1.ProductFirestoreRepository,
1751
- useFactory: function (firestore) {
1752
- return new i1$1.ProductFirestoreRepository(firestore.firestore);
1753
- },
1754
- deps: [i1$2.AngularFirestore],
1755
- },
1756
- {
1757
- provide: 'ShopSettingsRepository',
1758
- useFactory: function (firestore) {
1759
- return new i1$1.ShopSettingsFirestoreRepository(firestore.firestore);
1760
- },
1761
- deps: [i1$2.AngularFirestore],
1762
- },
1763
- {
1764
- provide: 'SubscriptionPaymentRepository',
1765
- useFactory: function (firestore, subscriptionRepository) {
1766
- return new i1$1.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
1767
- },
1768
- deps: [i1$2.AngularFirestore, 'SubscriptionRepository'],
1769
- },
1770
- {
1771
- provide: 'SubscriptionPlanRepository',
1772
- useFactory: function (firestore) {
1773
- return new i1$1.SubscriptionPlanFirestoreRepository(firestore.firestore);
1774
- },
1775
- deps: [i1$2.AngularFirestore],
1776
- },
1777
- {
1778
- provide: 'SubscriptionProductRepository',
1779
- useFactory: function (firestore) {
1780
- return new i1$1.SubscriptionProductFirestoreRepository(firestore.firestore);
1781
- },
1782
- deps: [i1$2.AngularFirestore],
1783
- },
1784
- {
1785
- provide: 'SubscriptionRepository',
1786
- useFactory: function (firestore) {
1787
- return new i1$1.SubscriptionFirestoreRepository(firestore.firestore);
1788
- },
1789
- deps: [i1$2.AngularFirestore],
1790
- },
1791
- {
1792
- provide: 'UserRepository',
1793
- useFactory: function (firestore) {
1794
- return new i1$1.UserFirestoreRepository(firestore.firestore);
1795
- },
1796
- deps: [i1$2.AngularFirestore],
1797
- },
1798
- {
1799
- provide: 'UserAddressRepository',
1800
- useFactory: function (firestore, userRepository) {
1801
- return new i1$1.UserAddressFirestoreRepository(firestore.firestore, userRepository);
1802
- },
1803
- deps: [i1$2.AngularFirestore, 'UserRepository'],
1804
- },
1805
- {
1806
- provide: 'UserPaymentMethodRepository',
1807
- useFactory: function (firestore, userRepository) {
1808
- return new i1$1.UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
1809
- },
1810
- deps: [i1$2.AngularFirestore, 'UserRepository'],
1811
- },
1812
- {
1813
- provide: i1$1.ProductVariantFirestoreRepository,
1814
- useFactory: function (firestore, productRepository) {
1815
- return new i1$1.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
1816
- },
1817
- deps: [i1$2.AngularFirestore, i1$1.ProductFirestoreRepository],
1818
- },
1819
- {
1820
- provide: i0.APP_INITIALIZER,
1821
- useFactory: function (firestore) { return function () { return firestore.firestore.settings({ ignoreUndefinedProperties: true }); }; },
1822
- deps: [i1$2.AngularFirestore],
1823
- multi: true,
1824
- },
1825
- ],
1826
- }]
1827
- }] });
1828
-
1829
- var AngularHasuraGraphQLModule = /** @class */ (function () {
1830
- function AngularHasuraGraphQLModule() {
1831
- }
1832
- AngularHasuraGraphQLModule.initializeApp = function (options) {
1833
- return {
1834
- ngModule: AngularHasuraGraphQLModule,
1835
- providers: [{ provide: HASURA_OPTIONS, useValue: options }],
1836
- };
1837
- };
1838
- return AngularHasuraGraphQLModule;
1839
- }());
1840
- AngularHasuraGraphQLModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularHasuraGraphQLModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1841
- AngularHasuraGraphQLModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularHasuraGraphQLModule });
1842
- AngularHasuraGraphQLModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularHasuraGraphQLModule, providers: [
1843
- {
1844
- provide: 'CategoryRepository',
1845
- useExisting: i1$1.CategoryHasuraGraphQLRepository,
1846
- },
1847
- {
1848
- provide: i1$1.CategoryHasuraGraphQLRepository,
1849
- useFactory: function (options, productRepository) {
1850
- return new i1$1.CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository);
1851
- },
1852
- deps: [HASURA_OPTIONS, i1$1.ProductHasuraGraphQLRepository],
1853
- },
1854
- {
1855
- provide: 'ProductRepository',
1856
- useExisting: i1$1.ProductHasuraGraphQLRepository,
1857
- },
1858
- {
1859
- provide: i1$1.ProductHasuraGraphQLRepository,
1860
- useFactory: function (options) {
1861
- return new i1$1.ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
1862
- },
1863
- deps: [HASURA_OPTIONS],
1864
- },
1865
- {
1866
- provide: 'VariantRepository',
1867
- useExisting: i1$1.VariantHasuraGraphQLRepository,
1868
- },
1869
- {
1870
- provide: i1$1.VariantHasuraGraphQLRepository,
1871
- useFactory: function (options) {
1872
- return new i1$1.VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
1873
- },
1874
- deps: [HASURA_OPTIONS],
1875
- },
1876
- ] });
1877
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularHasuraGraphQLModule, decorators: [{
1878
- type: i0.NgModule,
1879
- args: [{
1880
- providers: [
1881
- {
1882
- provide: 'CategoryRepository',
1883
- useExisting: i1$1.CategoryHasuraGraphQLRepository,
1884
- },
1885
- {
1886
- provide: i1$1.CategoryHasuraGraphQLRepository,
1887
- useFactory: function (options, productRepository) {
1888
- return new i1$1.CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository);
1889
- },
1890
- deps: [HASURA_OPTIONS, i1$1.ProductHasuraGraphQLRepository],
1891
- },
1892
- {
1893
- provide: 'ProductRepository',
1894
- useExisting: i1$1.ProductHasuraGraphQLRepository,
1895
- },
1896
- {
1897
- provide: i1$1.ProductHasuraGraphQLRepository,
1898
- useFactory: function (options) {
1899
- return new i1$1.ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
1900
- },
1901
- deps: [HASURA_OPTIONS],
1902
- },
1903
- {
1904
- provide: 'VariantRepository',
1905
- useExisting: i1$1.VariantHasuraGraphQLRepository,
1906
- },
1907
- {
1908
- provide: i1$1.VariantHasuraGraphQLRepository,
1909
- useFactory: function (options) {
1910
- return new i1$1.VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
1911
- },
1912
- deps: [HASURA_OPTIONS],
1913
- },
1914
- ],
1915
- }]
1916
- }] });
1917
-
1918
- var AngularConnectModule = /** @class */ (function () {
1919
- function AngularConnectModule() {
1920
- }
1921
- AngularConnectModule.initializeApp = function (defaultShop, options, nameOrConfig) {
1922
- return {
1923
- ngModule: AngularConnectModule,
1924
- providers: __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], __read((i1$1.isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]))), __read((i1$1.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$1.isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig }]))), __read((i1$1.isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]))), __read((i1$1.isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]))), __read((i1$1.isNil(options === null || options === void 0 ? void 0 : options.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]))),
1925
- };
1926
- };
1927
- return AngularConnectModule;
1928
- }());
1929
- AngularConnectModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1930
- AngularConnectModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, imports: [fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule] });
1931
- AngularConnectModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, providers: [
1932
- AuthService,
1933
- CartService,
1934
- CheckoutService,
1935
- CheckoutSubscriptionService,
1936
- CouponService,
1937
- HomeShopService,
1938
- OrderService,
1939
- ShippingService
1940
- ], imports: [[fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule]] });
1941
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, decorators: [{
1942
- type: i0.NgModule,
1943
- args: [{
1944
- imports: [fire.AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule],
1945
- providers: [
1946
- AuthService,
1947
- CartService,
1948
- CheckoutService,
1949
- CheckoutSubscriptionService,
1950
- CouponService,
1951
- HomeShopService,
1952
- OrderService,
1953
- ShippingService
1954
- ],
1955
- }]
1956
- }] });
1957
-
1958
- /**
1959
- * Generated bundle index. Do not edit.
1960
- */
1961
-
1962
- exports.AngularConnectModule = AngularConnectModule;
1963
- exports.AngularFirebaseAuthModule = AngularFirebaseAuthModule;
1964
- exports.AngularFirestoreModule = AngularFirestoreModule;
1965
- exports.AngularHasuraGraphQLModule = AngularHasuraGraphQLModule;
1966
- exports.AuthService = AuthService;
1967
- exports.CartService = CartService;
1968
- exports.CheckoutService = CheckoutService;
1969
- exports.CheckoutSubscriptionService = CheckoutSubscriptionService;
1970
- exports.CouponService = CouponService;
1971
- exports.HomeShopService = HomeShopService;
1972
- exports.OrderService = OrderService;
1973
- exports.ShippingService = ShippingService;
1974
-
1975
- Object.defineProperty(exports, '__esModule', { value: true });
1976
-
1977
- }));
1978
- //# sourceMappingURL=infrab4a-connect-angular.umd.js.map