@infrab4a/connect 2.0.9-beta.1 → 2.0.10

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.
@@ -1831,7 +1831,7 @@
1831
1831
  return [3 /*break*/, 6];
1832
1832
  case 4:
1833
1833
  error_1 = _a.sent();
1834
- console.info(error_1.message);
1834
+ console.error(error_1.message);
1835
1835
  return [4 /*yield*/, this.adapter.save("products/_doc/" + product.id, product.toPlain())];
1836
1836
  case 5:
1837
1837
  _a.sent();
@@ -2235,6 +2235,32 @@
2235
2235
  }(withUpdateFirestore(withGetFirestore(withFindFirestore(withDeleteFirestore(withCreateFirestore(MixinBase)))))));
2236
2236
  };
2237
2237
 
2238
+ var LeadFirestoreRepository = /** @class */ (function (_super) {
2239
+ __extends(LeadFirestoreRepository, _super);
2240
+ function LeadFirestoreRepository(firestore) {
2241
+ var _this = _super.call(this) || this;
2242
+ _this.firestore = firestore;
2243
+ _this.collectionName = 'leads';
2244
+ _this.model = Lead;
2245
+ return _this;
2246
+ }
2247
+ return LeadFirestoreRepository;
2248
+ }(withCrudFirestore(withHelpers(withFirestore(Base)))));
2249
+
2250
+ var SubscriptionEditionFirestoreRepository = /** @class */ (function (_super) {
2251
+ __extends(SubscriptionEditionFirestoreRepository, _super);
2252
+ function SubscriptionEditionFirestoreRepository(firestore, parentRepository) {
2253
+ var _this = _super.call(this) || this;
2254
+ _this.firestore = firestore;
2255
+ _this.parentRepository = parentRepository;
2256
+ _this.collectionName = 'editions';
2257
+ _this.parentIdField = 'subscriptionId';
2258
+ _this.model = Edition;
2259
+ return _this;
2260
+ }
2261
+ return SubscriptionEditionFirestoreRepository;
2262
+ }(withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription)));
2263
+
2238
2264
  var SubscriptionFirestoreRepository = /** @class */ (function (_super) {
2239
2265
  __extends(SubscriptionFirestoreRepository, _super);
2240
2266
  function SubscriptionFirestoreRepository(firestore) {
@@ -2247,40 +2273,53 @@
2247
2273
  return SubscriptionFirestoreRepository;
2248
2274
  }(withCrudFirestore(withHelpers(withFirestore(Base)))));
2249
2275
 
2250
- var UserSearch = /** @class */ (function (_super) {
2251
- __extends(UserSearch, _super);
2252
- function UserSearch() {
2253
- return _super !== null && _super.apply(this, arguments) || this;
2276
+ var SubscriptionPaymentFirestoreRepository = /** @class */ (function (_super) {
2277
+ __extends(SubscriptionPaymentFirestoreRepository, _super);
2278
+ function SubscriptionPaymentFirestoreRepository(firestore, parentRepository) {
2279
+ var _this = _super.call(this) || this;
2280
+ _this.firestore = firestore;
2281
+ _this.parentRepository = parentRepository;
2282
+ _this.collectionName = 'payments';
2283
+ _this.parentIdField = 'subscriptionId';
2284
+ _this.model = SubscriptionPayment;
2285
+ return _this;
2254
2286
  }
2255
- Object.defineProperty(UserSearch, "identifiersFields", {
2256
- get: function () {
2257
- return ['id'];
2258
- },
2259
- enumerable: false,
2260
- configurable: true
2261
- });
2262
- return UserSearch;
2263
- }(BaseModel));
2287
+ return SubscriptionPaymentFirestoreRepository;
2288
+ }(withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription)));
2264
2289
 
2265
- var UserSearchFirestoreRepository = /** @class */ (function (_super) {
2266
- __extends(UserSearchFirestoreRepository, _super);
2267
- function UserSearchFirestoreRepository(firestore) {
2290
+ var UserAddressFirestoreRepository = /** @class */ (function (_super) {
2291
+ __extends(UserAddressFirestoreRepository, _super);
2292
+ function UserAddressFirestoreRepository(firestore, parentRepository) {
2268
2293
  var _this = _super.call(this) || this;
2269
2294
  _this.firestore = firestore;
2270
- _this.collectionName = 'userSearch';
2271
- _this.model = UserSearch;
2295
+ _this.parentRepository = parentRepository;
2296
+ _this.collectionName = 'address';
2297
+ _this.parentIdField = 'userId';
2298
+ _this.model = UserAddress;
2272
2299
  return _this;
2273
2300
  }
2274
- return UserSearchFirestoreRepository;
2275
- }(withCrudFirestore(withHelpers(withFirestore(Base)))));
2301
+ return UserAddressFirestoreRepository;
2302
+ }(withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User)));
2303
+
2304
+ var UserBeautyProfileFirestoreRepository = /** @class */ (function (_super) {
2305
+ __extends(UserBeautyProfileFirestoreRepository, _super);
2306
+ function UserBeautyProfileFirestoreRepository(firestore, parentRepository) {
2307
+ var _this = _super.call(this) || this;
2308
+ _this.firestore = firestore;
2309
+ _this.parentRepository = parentRepository;
2310
+ _this.collectionName = 'CX';
2311
+ _this.parentIdField = 'userId';
2312
+ _this.model = BeautyProfile;
2313
+ return _this;
2314
+ }
2315
+ return UserBeautyProfileFirestoreRepository;
2316
+ }(withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User)));
2276
2317
 
2277
2318
  var UserFirestoreRepository = /** @class */ (function (_super_1) {
2278
2319
  __extends(UserFirestoreRepository, _super_1);
2279
- function UserFirestoreRepository(firestore, userSearchFirestoreRepository) {
2280
- if (userSearchFirestoreRepository === void 0) { userSearchFirestoreRepository = new UserSearchFirestoreRepository(firestore); }
2320
+ function UserFirestoreRepository(firestore) {
2281
2321
  var _this = _super_1.call(this) || this;
2282
2322
  _this.firestore = firestore;
2283
- _this.userSearchFirestoreRepository = userSearchFirestoreRepository;
2284
2323
  _this.collectionName = 'users';
2285
2324
  _this.model = User;
2286
2325
  return _this;
@@ -2315,7 +2354,7 @@
2315
2354
  var _a;
2316
2355
  return __generator(this, function (_b) {
2317
2356
  switch (_b.label) {
2318
- case 0: return [4 /*yield*/, this.userSearchFirestoreRepository.find((_a = {}, _a[field] = { operator: exports.Where.EQUALS, value: value }, _a))];
2357
+ case 0: return [4 /*yield*/, this.find({ filters: (_a = {}, _a[field] = value, _a) })];
2319
2358
  case 1:
2320
2359
  result = _b.sent();
2321
2360
  return [2 /*return*/, result.count > 0];
@@ -2378,48 +2417,6 @@
2378
2417
  return UserFirestoreRepository;
2379
2418
  }(withCrudFirestore(withHelpers(withFirestore(Base)))));
2380
2419
 
2381
- var SubscriptionEditionFirestoreRepository = /** @class */ (function (_super) {
2382
- __extends(SubscriptionEditionFirestoreRepository, _super);
2383
- function SubscriptionEditionFirestoreRepository(firestore, parentRepository) {
2384
- var _this = _super.call(this) || this;
2385
- _this.firestore = firestore;
2386
- _this.parentRepository = parentRepository;
2387
- _this.collectionName = 'editions';
2388
- _this.parentIdField = 'subscriptionId';
2389
- _this.model = Edition;
2390
- return _this;
2391
- }
2392
- return SubscriptionEditionFirestoreRepository;
2393
- }(withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription)));
2394
-
2395
- var UserBeautyProfileFirestoreRepository = /** @class */ (function (_super) {
2396
- __extends(UserBeautyProfileFirestoreRepository, _super);
2397
- function UserBeautyProfileFirestoreRepository(firestore, parentRepository) {
2398
- var _this = _super.call(this) || this;
2399
- _this.firestore = firestore;
2400
- _this.parentRepository = parentRepository;
2401
- _this.collectionName = 'CX';
2402
- _this.parentIdField = 'userId';
2403
- _this.model = BeautyProfile;
2404
- return _this;
2405
- }
2406
- return UserBeautyProfileFirestoreRepository;
2407
- }(withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User)));
2408
-
2409
- var UserAddressFirestoreRepository = /** @class */ (function (_super) {
2410
- __extends(UserAddressFirestoreRepository, _super);
2411
- function UserAddressFirestoreRepository(firestore, parentRepository) {
2412
- var _this = _super.call(this) || this;
2413
- _this.firestore = firestore;
2414
- _this.parentRepository = parentRepository;
2415
- _this.collectionName = 'address';
2416
- _this.parentIdField = 'userId';
2417
- _this.model = UserAddress;
2418
- return _this;
2419
- }
2420
- return UserAddressFirestoreRepository;
2421
- }(withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User)));
2422
-
2423
2420
  var UserPaymentMethodFirestoreRepository = /** @class */ (function (_super) {
2424
2421
  __extends(UserPaymentMethodFirestoreRepository, _super);
2425
2422
  function UserPaymentMethodFirestoreRepository(firestore, parentRepository) {
@@ -2434,32 +2431,6 @@
2434
2431
  return UserPaymentMethodFirestoreRepository;
2435
2432
  }(withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User)));
2436
2433
 
2437
- var SubscriptionPaymentFirestoreRepository = /** @class */ (function (_super) {
2438
- __extends(SubscriptionPaymentFirestoreRepository, _super);
2439
- function SubscriptionPaymentFirestoreRepository(firestore, parentRepository) {
2440
- var _this = _super.call(this) || this;
2441
- _this.firestore = firestore;
2442
- _this.parentRepository = parentRepository;
2443
- _this.collectionName = 'payments';
2444
- _this.parentIdField = 'subscriptionId';
2445
- _this.model = SubscriptionPayment;
2446
- return _this;
2447
- }
2448
- return SubscriptionPaymentFirestoreRepository;
2449
- }(withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription)));
2450
-
2451
- var LeadFirestoreRepository = /** @class */ (function (_super) {
2452
- __extends(LeadFirestoreRepository, _super);
2453
- function LeadFirestoreRepository(firestore) {
2454
- var _this = _super.call(this) || this;
2455
- _this.firestore = firestore;
2456
- _this.collectionName = 'leads';
2457
- _this.model = Lead;
2458
- return _this;
2459
- }
2460
- return LeadFirestoreRepository;
2461
- }(withCrudFirestore(withHelpers(withFirestore(Base)))));
2462
-
2463
2434
  var CategoryFirestoreRepository = /** @class */ (function (_super) {
2464
2435
  __extends(CategoryFirestoreRepository, _super);
2465
2436
  function CategoryFirestoreRepository(firestore) {
@@ -4114,27 +4085,32 @@
4114
4085
  });
4115
4086
  var _a;
4116
4087
  return __awaiter(this, void 0, void 0, function () {
4117
- var product, _c, _d;
4118
- return __generator(this, function (_e) {
4119
- switch (_e.label) {
4088
+ var product, _c, _d, _e;
4089
+ return __generator(this, function (_f) {
4090
+ switch (_f.label) {
4120
4091
  case 0:
4121
4092
  if (!Number.isNaN(+identifiers.id)) return [3 /*break*/, 2];
4122
4093
  return [4 /*yield*/, this.find({ filters: { firestoreId: identifiers.id } })];
4123
4094
  case 1:
4124
- _c = (_a = (_e.sent()).data) === null || _a === void 0 ? void 0 : _a[0];
4095
+ _c = (_a = (_f.sent()).data) === null || _a === void 0 ? void 0 : _a[0];
4125
4096
  return [3 /*break*/, 4];
4126
4097
  case 2: return [4 /*yield*/, _super.get.call(this, identifiers)];
4127
4098
  case 3:
4128
- _c = _e.sent();
4129
- _e.label = 4;
4099
+ _c = _f.sent();
4100
+ _f.label = 4;
4130
4101
  case 4:
4131
4102
  product = _c;
4132
4103
  if (product.productId)
4133
4104
  throw new NotFoundError('Product not found, it is a variant');
4134
4105
  _d = product;
4106
+ _e = product.reviews;
4107
+ if (_e) return [3 /*break*/, 6];
4135
4108
  return [4 /*yield*/, this.findReviewsByProduct(+product.id)];
4136
4109
  case 5:
4137
- _d.reviews = _e.sent();
4110
+ _e = (_f.sent());
4111
+ _f.label = 6;
4112
+ case 6:
4113
+ _d.reviews = _e;
4138
4114
  return [2 /*return*/, product];
4139
4115
  }
4140
4116
  });
@@ -4230,18 +4206,18 @@
4230
4206
  };
4231
4207
  ProductHasuraGraphQLRepository.prototype.fetchReviews = function (status) {
4232
4208
  return __awaiter(this, void 0, void 0, function () {
4233
- var reviews, data;
4209
+ var reviewsExpression, data;
4234
4210
  var _c, _d;
4235
4211
  var _this = this;
4236
4212
  return __generator(this, function (_e) {
4237
4213
  switch (_e.label) {
4238
4214
  case 0:
4239
- reviews = {
4215
+ reviewsExpression = {
4240
4216
  status: status === 'pending'
4241
4217
  ? (_c = {}, _c[HasuraGraphQLWhere.ISNULL] = true, _c) : (_d = {}, _d[HasuraGraphQLWhere.EQUALS] = status === 'approved', _d),
4242
4218
  };
4243
4219
  return [4 /*yield*/, this.query('product', ['id', 'name', 'sku', { reviews: { columnName: 'reviews', fields: this.reviewsFields } }], {
4244
- where: { value: { reviews: reviews }, type: 'product_bool_exp', required: true },
4220
+ where: { value: { reviews: reviewsExpression }, type: 'product_bool_exp', required: true },
4245
4221
  })];
4246
4222
  case 1:
4247
4223
  data = (_e.sent()).product;
@@ -4841,7 +4817,6 @@
4841
4817
  exports.UserFirestoreRepository = UserFirestoreRepository;
4842
4818
  exports.UserPaymentMethod = UserPaymentMethod;
4843
4819
  exports.UserPaymentMethodFirestoreRepository = UserPaymentMethodFirestoreRepository;
4844
- exports.UserSearchFirestoreRepository = UserSearchFirestoreRepository;
4845
4820
  exports.Variant = Variant;
4846
4821
  exports.VariantHasuraGraphQL = VariantHasuraGraphQL;
4847
4822
  exports.VariantHasuraGraphQLRepository = VariantHasuraGraphQLRepository;