@infrab4a/connect-angular 3.4.0-beta.10 → 3.4.0-beta.3

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.
@@ -11,7 +11,7 @@ export declare class AngularConnectModule {
11
11
  firebase: FirebaseOptions;
12
12
  elasticSearch: AxiosElasticSearchConfig;
13
13
  hasura: HasuraGraphQLOptions;
14
- backendUrl: string;
14
+ apiUrl: string;
15
15
  }, nameOrConfig?: string | FirebaseAppConfig): ModuleWithProviders<AngularFireModule>;
16
16
  static ɵfac: i0.ɵɵFactoryDeclaration<AngularConnectModule, never>;
17
17
  static ɵmod: i0.ɵɵNgModuleDeclaration<AngularConnectModule, never, [typeof i1.AngularFireModule, typeof i2.AngularFirestoreModule, typeof i3.AngularHasuraGraphQLModule], never>;
@@ -1,8 +1,8 @@
1
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';
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('@infrab4a/connect/src'), 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', '@infrab4a/connect/src', '@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.src, global.ng.common.http, global.ng.fire));
5
+ })(this, (function (exports, i0, rxjs, operators, i1, i1$1, cookie, tsCustomError, i1$2, src, i1$3, fire) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -31,7 +31,7 @@
31
31
  var i1__namespace$2 = /*#__PURE__*/_interopNamespace(i1$2);
32
32
  var i1__namespace$3 = /*#__PURE__*/_interopNamespace(i1$3);
33
33
 
34
- /*! *****************************************************************************
34
+ /******************************************************************************
35
35
  Copyright (c) Microsoft Corporation.
36
36
 
37
37
  Permission to use, copy, modify, and/or distribute this software for any
@@ -98,6 +98,64 @@
98
98
  function __param(paramIndex, decorator) {
99
99
  return function (target, key) { decorator(target, key, paramIndex); };
100
100
  }
101
+ function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
102
+ function accept(f) { if (f !== void 0 && typeof f !== "function")
103
+ throw new TypeError("Function expected"); return f; }
104
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
105
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
106
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
107
+ var _, done = false;
108
+ for (var i = decorators.length - 1; i >= 0; i--) {
109
+ var context = {};
110
+ for (var p in contextIn)
111
+ context[p] = p === "access" ? {} : contextIn[p];
112
+ for (var p in contextIn.access)
113
+ context.access[p] = contextIn.access[p];
114
+ context.addInitializer = function (f) { if (done)
115
+ throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
116
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
117
+ if (kind === "accessor") {
118
+ if (result === void 0)
119
+ continue;
120
+ if (result === null || typeof result !== "object")
121
+ throw new TypeError("Object expected");
122
+ if (_ = accept(result.get))
123
+ descriptor.get = _;
124
+ if (_ = accept(result.set))
125
+ descriptor.set = _;
126
+ if (_ = accept(result.init))
127
+ initializers.push(_);
128
+ }
129
+ else if (_ = accept(result)) {
130
+ if (kind === "field")
131
+ initializers.push(_);
132
+ else
133
+ descriptor[key] = _;
134
+ }
135
+ }
136
+ if (target)
137
+ Object.defineProperty(target, contextIn.name, descriptor);
138
+ done = true;
139
+ }
140
+ ;
141
+ function __runInitializers(thisArg, initializers, value) {
142
+ var useValue = arguments.length > 2;
143
+ for (var i = 0; i < initializers.length; i++) {
144
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
145
+ }
146
+ return useValue ? value : void 0;
147
+ }
148
+ ;
149
+ function __propKey(x) {
150
+ return typeof x === "symbol" ? x : "".concat(x);
151
+ }
152
+ ;
153
+ function __setFunctionName(f, name, prefix) {
154
+ if (typeof name === "symbol")
155
+ name = name.description ? "[".concat(name.description, "]") : "";
156
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
157
+ }
158
+ ;
101
159
  function __metadata(metadataKey, metadataValue) {
102
160
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
103
161
  return Reflect.metadata(metadataKey, metadataValue);
@@ -129,7 +187,7 @@
129
187
  function step(op) {
130
188
  if (f)
131
189
  throw new TypeError("Generator is already executing.");
132
- while (_)
190
+ while (g && (g = 0, op[0] && (_ = 0)), _)
133
191
  try {
134
192
  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
193
  return t;
@@ -193,7 +251,11 @@
193
251
  var __createBinding = Object.create ? (function (o, m, k, k2) {
194
252
  if (k2 === undefined)
195
253
  k2 = k;
196
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
254
+ var desc = Object.getOwnPropertyDescriptor(m, k);
255
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
256
+ desc = { enumerable: true, get: function () { return m[k]; } };
257
+ }
258
+ Object.defineProperty(o, k2, desc);
197
259
  }) : (function (o, m, k, k2) {
198
260
  if (k2 === undefined)
199
261
  k2 = k;
@@ -293,7 +355,7 @@
293
355
  function __asyncDelegator(o) {
294
356
  var i, p;
295
357
  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; }
358
+ function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
297
359
  }
298
360
  function __asyncValues(o) {
299
361
  if (!Symbol.asyncIterator)
@@ -347,6 +409,11 @@
347
409
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
348
410
  throw new TypeError("Cannot write private member to an object whose class did not declare it");
349
411
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
412
+ }
413
+ function __classPrivateFieldIn(state, receiver) {
414
+ if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function"))
415
+ throw new TypeError("Cannot use 'in' operator on non-object");
416
+ return typeof state === "function" ? receiver === state : state.has(receiver);
350
417
  }
351
418
 
352
419
  var AuthService = /** @class */ (function () {
@@ -390,7 +457,7 @@
390
457
  }] }];
391
458
  } });
392
459
 
393
- var BACKEND_URL = 'BACKEND_URL';
460
+ var API_URL = 'API_URL';
394
461
 
395
462
  var DEFAULT_SHOP = 'DEFAULT_SHOP';
396
463
 
@@ -1223,62 +1290,58 @@
1223
1290
  } });
1224
1291
 
1225
1292
  var ShippingService = /** @class */ (function () {
1226
- function ShippingService(http, apiUrl, homeService) {
1293
+ function ShippingService(http, homeService, apiUrl) {
1227
1294
  this.http = http;
1228
- this.apiUrl = apiUrl;
1229
1295
  this.homeService = homeService;
1296
+ this.apiUrl = apiUrl;
1230
1297
  }
1231
- ShippingService.prototype.getShippingMethods = function (shop, zip, weightGrams, totalPrice, personId, subscriptionPlan) {
1298
+ ShippingService.prototype.getMensShippingMethods = function (zip, weightGrams, totalPrice, personId, shop, subscriptionPlan) {
1232
1299
  var _this = this;
1233
- return rxjs.combineLatest([
1300
+ rxjs.combineLatest([
1234
1301
  this.homeService.getHomeData(),
1235
1302
  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;
1303
+ ]).pipe(operators.map(function (datas, shippings) { return console.log('combineLatest', datas, shippings); }));
1304
+ return this.http.get(this.apiUrl + "open/checkshippingcompany?personId=" + personId + "&postalCode=" + zip + "&weightGrams=" + weightGrams)
1305
+ .pipe(operators.map(function (data) { return data.result; }), operators.map(function (shippingMethods) { return __awaiter(_this, void 0, void 0, function () {
1306
+ var shippingMethodsResponse, datas;
1307
+ return __generator(this, function (_a) {
1308
+ switch (_a.label) {
1309
+ case 0:
1310
+ shippingMethodsResponse = shippingMethods;
1311
+ console.log('shippingMethods', shippingMethods);
1312
+ if (!shippingMethods.length)
1313
+ return [2 /*return*/, []];
1314
+ return [4 /*yield*/, this.homeService.getHomeData().toPromise().then(function (data) { return data.sameDayNotAvaliable; })];
1315
+ case 1:
1316
+ datas = _a.sent();
1317
+ if (this.isHolidays(datas)) {
1318
+ shippingMethodsResponse = shippingMethods.filter(function (method) { return method.ShippingCompanyName !== 'Same Day'; });
1319
+ }
1320
+ if (totalPrice >= 200 || this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
1321
+ return [2 /*return*/, shippingMethodsResponse.map(function (s) {
1322
+ if (s.serviceName !== 'Same Day')
1323
+ return Object.assign(Object.assign({}, s), { totalPrice: 0 });
1324
+ else
1325
+ return s;
1326
+ })];
1327
+ }
1328
+ if (this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
1329
+ return [2 /*return*/, shippingMethodsResponse.map(function (s) {
1330
+ if (s.serviceName !== 'Same Day')
1331
+ return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
1332
+ else
1333
+ return s;
1334
+ })];
1335
+ }
1336
+ return [2 /*return*/, shippingMethodsResponse];
1337
+ }
1247
1338
  });
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
- }));
1339
+ }); }));
1277
1340
  };
1278
1341
  ShippingService.prototype.isFreeShippingBySubscription = function (shop, subscriptionPlan) {
1279
1342
  if (!subscriptionPlan)
1280
1343
  return false;
1281
- if (shop == i1$1.Shops.MENSMARKET && subscriptionPlan == 'SELECT') {
1344
+ if (shop == src.Shops.MENSMARKET && subscriptionPlan == 'SELECT') {
1282
1345
  return true;
1283
1346
  }
1284
1347
  return false;
@@ -1286,10 +1349,7 @@
1286
1349
  ShippingService.prototype.isHalfShippingBySubscription = function (shop, subscriptionPlan) {
1287
1350
  if (!subscriptionPlan)
1288
1351
  return false;
1289
- if (shop == i1$1.Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
1290
- return true;
1291
- }
1292
- if (shop == i1$1.Shops.GLAMSHOP && subscriptionPlan) {
1352
+ if (shop == src.Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
1293
1353
  return true;
1294
1354
  }
1295
1355
  return false;
@@ -1308,15 +1368,15 @@
1308
1368
  };
1309
1369
  return ShippingService;
1310
1370
  }());
1311
- 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 });
1371
+ 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: HomeShopService }, { token: API_URL }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
1312
1372
  ShippingService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: ShippingService });
1313
1373
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: ShippingService, decorators: [{
1314
1374
  type: i0.Injectable
1315
1375
  }], ctorParameters: function () {
1316
- return [{ type: i1__namespace$3.HttpClient }, { type: undefined, decorators: [{
1376
+ return [{ type: i1__namespace$3.HttpClient }, { type: HomeShopService }, { type: undefined, decorators: [{
1317
1377
  type: i0.Inject,
1318
- args: [BACKEND_URL]
1319
- }] }, { type: HomeShopService }];
1378
+ args: [API_URL]
1379
+ }] }];
1320
1380
  } });
1321
1381
 
1322
1382
  var AngularFirebaseAuthModule = /** @class */ (function () {
@@ -1910,7 +1970,7 @@
1910
1970
  AngularConnectModule.initializeApp = function (defaultShop, options, nameOrConfig) {
1911
1971
  return {
1912
1972
  ngModule: AngularConnectModule,
1913
- 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 }]))),
1973
+ 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.apiUrl) ? [] : [{ provide: API_URL, useValue: options.apiUrl }]))),
1914
1974
  };
1915
1975
  };
1916
1976
  return AngularConnectModule;