@infrab4a/connect 3.0.0-beta.1 → 3.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/infrab4a-connect.umd.js +232 -136
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/domain/generic/repository/enums/where.enum.d.ts +1 -0
- package/esm2015/domain/catalog/repositories/product.repository.js +1 -1
- package/esm2015/domain/generic/repository/enums/where.enum.js +2 -1
- package/esm2015/domain/shop-settings/models/home.js +1 -1
- package/esm2015/infra/elasticsearch/indexes/products-index.js +2 -2
- package/esm2015/infra/firebase/firestore/repositories/users/index.js +6 -7
- package/esm2015/infra/firebase/firestore/repositories/users/user-firestore.repository.js +4 -6
- package/esm2015/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.js +59 -3
- package/esm2015/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.js +31 -8
- package/esm2015/infra/hasura-graphql/types/hasura-graphql-fields.type.js +1 -1
- package/fesm2015/infrab4a-connect.js +136 -72
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/infra/firebase/firestore/repositories/users/index.d.ts +5 -6
- package/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +1 -3
- package/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +4 -1
- package/infra/hasura-graphql/types/hasura-graphql-fields.type.d.ts +1 -1
- package/package.json +1 -1
- package/esm2015/infra/firebase/firestore/models/user-search.js +0 -7
- package/esm2015/infra/firebase/firestore/repositories/users/user-search-firestore.repository.js +0 -12
- package/infra/firebase/firestore/models/user-search.d.ts +0 -9
- package/infra/firebase/firestore/repositories/users/user-search-firestore.repository.d.ts +0 -9
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
exports.Where = void 0;
|
|
49
49
|
(function (Where) {
|
|
50
50
|
Where["EQUALS"] = "==";
|
|
51
|
+
Where["NOTEQUALS"] = "!=";
|
|
51
52
|
Where["GT"] = ">";
|
|
52
53
|
Where["GTE"] = ">=";
|
|
53
54
|
Where["IN"] = "in";
|
|
@@ -1824,7 +1825,7 @@
|
|
|
1824
1825
|
return [3 /*break*/, 6];
|
|
1825
1826
|
case 4:
|
|
1826
1827
|
error_1 = _a.sent();
|
|
1827
|
-
console.
|
|
1828
|
+
console.error(error_1.message);
|
|
1828
1829
|
return [4 /*yield*/, this.adapter.save("products/_doc/" + product.id, product.toPlain())];
|
|
1829
1830
|
case 5:
|
|
1830
1831
|
_a.sent();
|
|
@@ -2228,6 +2229,32 @@
|
|
|
2228
2229
|
}(withUpdateFirestore(withGetFirestore(withFindFirestore(withDeleteFirestore(withCreateFirestore(MixinBase)))))));
|
|
2229
2230
|
};
|
|
2230
2231
|
|
|
2232
|
+
var LeadFirestoreRepository = /** @class */ (function (_super) {
|
|
2233
|
+
__extends(LeadFirestoreRepository, _super);
|
|
2234
|
+
function LeadFirestoreRepository(firestore) {
|
|
2235
|
+
var _this = _super.call(this) || this;
|
|
2236
|
+
_this.firestore = firestore;
|
|
2237
|
+
_this.collectionName = 'leads';
|
|
2238
|
+
_this.model = Lead;
|
|
2239
|
+
return _this;
|
|
2240
|
+
}
|
|
2241
|
+
return LeadFirestoreRepository;
|
|
2242
|
+
}(withCrudFirestore(withHelpers(withFirestore(Base)))));
|
|
2243
|
+
|
|
2244
|
+
var SubscriptionEditionFirestoreRepository = /** @class */ (function (_super) {
|
|
2245
|
+
__extends(SubscriptionEditionFirestoreRepository, _super);
|
|
2246
|
+
function SubscriptionEditionFirestoreRepository(firestore, parentRepository) {
|
|
2247
|
+
var _this = _super.call(this) || this;
|
|
2248
|
+
_this.firestore = firestore;
|
|
2249
|
+
_this.parentRepository = parentRepository;
|
|
2250
|
+
_this.collectionName = 'editions';
|
|
2251
|
+
_this.parentIdField = 'subscriptionId';
|
|
2252
|
+
_this.model = Edition;
|
|
2253
|
+
return _this;
|
|
2254
|
+
}
|
|
2255
|
+
return SubscriptionEditionFirestoreRepository;
|
|
2256
|
+
}(withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription)));
|
|
2257
|
+
|
|
2231
2258
|
var SubscriptionFirestoreRepository = /** @class */ (function (_super) {
|
|
2232
2259
|
__extends(SubscriptionFirestoreRepository, _super);
|
|
2233
2260
|
function SubscriptionFirestoreRepository(firestore) {
|
|
@@ -2240,40 +2267,53 @@
|
|
|
2240
2267
|
return SubscriptionFirestoreRepository;
|
|
2241
2268
|
}(withCrudFirestore(withHelpers(withFirestore(Base)))));
|
|
2242
2269
|
|
|
2243
|
-
var
|
|
2244
|
-
__extends(
|
|
2245
|
-
function
|
|
2246
|
-
|
|
2270
|
+
var SubscriptionPaymentFirestoreRepository = /** @class */ (function (_super) {
|
|
2271
|
+
__extends(SubscriptionPaymentFirestoreRepository, _super);
|
|
2272
|
+
function SubscriptionPaymentFirestoreRepository(firestore, parentRepository) {
|
|
2273
|
+
var _this = _super.call(this) || this;
|
|
2274
|
+
_this.firestore = firestore;
|
|
2275
|
+
_this.parentRepository = parentRepository;
|
|
2276
|
+
_this.collectionName = 'payments';
|
|
2277
|
+
_this.parentIdField = 'subscriptionId';
|
|
2278
|
+
_this.model = SubscriptionPayment;
|
|
2279
|
+
return _this;
|
|
2247
2280
|
}
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
return ['id'];
|
|
2251
|
-
},
|
|
2252
|
-
enumerable: false,
|
|
2253
|
-
configurable: true
|
|
2254
|
-
});
|
|
2255
|
-
return UserSearch;
|
|
2256
|
-
}(BaseModel));
|
|
2281
|
+
return SubscriptionPaymentFirestoreRepository;
|
|
2282
|
+
}(withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription)));
|
|
2257
2283
|
|
|
2258
|
-
var
|
|
2259
|
-
__extends(
|
|
2260
|
-
function
|
|
2284
|
+
var UserAddressFirestoreRepository = /** @class */ (function (_super) {
|
|
2285
|
+
__extends(UserAddressFirestoreRepository, _super);
|
|
2286
|
+
function UserAddressFirestoreRepository(firestore, parentRepository) {
|
|
2261
2287
|
var _this = _super.call(this) || this;
|
|
2262
2288
|
_this.firestore = firestore;
|
|
2263
|
-
_this.
|
|
2264
|
-
_this.
|
|
2289
|
+
_this.parentRepository = parentRepository;
|
|
2290
|
+
_this.collectionName = 'address';
|
|
2291
|
+
_this.parentIdField = 'userId';
|
|
2292
|
+
_this.model = UserAddress;
|
|
2265
2293
|
return _this;
|
|
2266
2294
|
}
|
|
2267
|
-
return
|
|
2268
|
-
}(withCrudFirestore(withHelpers(withFirestore(Base)))));
|
|
2295
|
+
return UserAddressFirestoreRepository;
|
|
2296
|
+
}(withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User)));
|
|
2297
|
+
|
|
2298
|
+
var UserBeautyProfileFirestoreRepository = /** @class */ (function (_super) {
|
|
2299
|
+
__extends(UserBeautyProfileFirestoreRepository, _super);
|
|
2300
|
+
function UserBeautyProfileFirestoreRepository(firestore, parentRepository) {
|
|
2301
|
+
var _this = _super.call(this) || this;
|
|
2302
|
+
_this.firestore = firestore;
|
|
2303
|
+
_this.parentRepository = parentRepository;
|
|
2304
|
+
_this.collectionName = 'CX';
|
|
2305
|
+
_this.parentIdField = 'userId';
|
|
2306
|
+
_this.model = BeautyProfile;
|
|
2307
|
+
return _this;
|
|
2308
|
+
}
|
|
2309
|
+
return UserBeautyProfileFirestoreRepository;
|
|
2310
|
+
}(withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User)));
|
|
2269
2311
|
|
|
2270
2312
|
var UserFirestoreRepository = /** @class */ (function (_super_1) {
|
|
2271
2313
|
__extends(UserFirestoreRepository, _super_1);
|
|
2272
|
-
function UserFirestoreRepository(firestore
|
|
2273
|
-
if (userSearchFirestoreRepository === void 0) { userSearchFirestoreRepository = new UserSearchFirestoreRepository(firestore); }
|
|
2314
|
+
function UserFirestoreRepository(firestore) {
|
|
2274
2315
|
var _this = _super_1.call(this) || this;
|
|
2275
2316
|
_this.firestore = firestore;
|
|
2276
|
-
_this.userSearchFirestoreRepository = userSearchFirestoreRepository;
|
|
2277
2317
|
_this.collectionName = 'users';
|
|
2278
2318
|
_this.model = User;
|
|
2279
2319
|
return _this;
|
|
@@ -2308,7 +2348,7 @@
|
|
|
2308
2348
|
var _a;
|
|
2309
2349
|
return __generator(this, function (_b) {
|
|
2310
2350
|
switch (_b.label) {
|
|
2311
|
-
case 0: return [4 /*yield*/, this.
|
|
2351
|
+
case 0: return [4 /*yield*/, this.find({ filters: (_a = {}, _a[field] = value, _a) })];
|
|
2312
2352
|
case 1:
|
|
2313
2353
|
result = _b.sent();
|
|
2314
2354
|
return [2 /*return*/, result.count > 0];
|
|
@@ -2371,48 +2411,6 @@
|
|
|
2371
2411
|
return UserFirestoreRepository;
|
|
2372
2412
|
}(withCrudFirestore(withHelpers(withFirestore(Base)))));
|
|
2373
2413
|
|
|
2374
|
-
var SubscriptionEditionFirestoreRepository = /** @class */ (function (_super) {
|
|
2375
|
-
__extends(SubscriptionEditionFirestoreRepository, _super);
|
|
2376
|
-
function SubscriptionEditionFirestoreRepository(firestore, parentRepository) {
|
|
2377
|
-
var _this = _super.call(this) || this;
|
|
2378
|
-
_this.firestore = firestore;
|
|
2379
|
-
_this.parentRepository = parentRepository;
|
|
2380
|
-
_this.collectionName = 'editions';
|
|
2381
|
-
_this.parentIdField = 'subscriptionId';
|
|
2382
|
-
_this.model = Edition;
|
|
2383
|
-
return _this;
|
|
2384
|
-
}
|
|
2385
|
-
return SubscriptionEditionFirestoreRepository;
|
|
2386
|
-
}(withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription)));
|
|
2387
|
-
|
|
2388
|
-
var UserBeautyProfileFirestoreRepository = /** @class */ (function (_super) {
|
|
2389
|
-
__extends(UserBeautyProfileFirestoreRepository, _super);
|
|
2390
|
-
function UserBeautyProfileFirestoreRepository(firestore, parentRepository) {
|
|
2391
|
-
var _this = _super.call(this) || this;
|
|
2392
|
-
_this.firestore = firestore;
|
|
2393
|
-
_this.parentRepository = parentRepository;
|
|
2394
|
-
_this.collectionName = 'CX';
|
|
2395
|
-
_this.parentIdField = 'userId';
|
|
2396
|
-
_this.model = BeautyProfile;
|
|
2397
|
-
return _this;
|
|
2398
|
-
}
|
|
2399
|
-
return UserBeautyProfileFirestoreRepository;
|
|
2400
|
-
}(withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User)));
|
|
2401
|
-
|
|
2402
|
-
var UserAddressFirestoreRepository = /** @class */ (function (_super) {
|
|
2403
|
-
__extends(UserAddressFirestoreRepository, _super);
|
|
2404
|
-
function UserAddressFirestoreRepository(firestore, parentRepository) {
|
|
2405
|
-
var _this = _super.call(this) || this;
|
|
2406
|
-
_this.firestore = firestore;
|
|
2407
|
-
_this.parentRepository = parentRepository;
|
|
2408
|
-
_this.collectionName = 'address';
|
|
2409
|
-
_this.parentIdField = 'userId';
|
|
2410
|
-
_this.model = UserAddress;
|
|
2411
|
-
return _this;
|
|
2412
|
-
}
|
|
2413
|
-
return UserAddressFirestoreRepository;
|
|
2414
|
-
}(withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User)));
|
|
2415
|
-
|
|
2416
2414
|
var UserPaymentMethodFirestoreRepository = /** @class */ (function (_super) {
|
|
2417
2415
|
__extends(UserPaymentMethodFirestoreRepository, _super);
|
|
2418
2416
|
function UserPaymentMethodFirestoreRepository(firestore, parentRepository) {
|
|
@@ -2427,32 +2425,6 @@
|
|
|
2427
2425
|
return UserPaymentMethodFirestoreRepository;
|
|
2428
2426
|
}(withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User)));
|
|
2429
2427
|
|
|
2430
|
-
var SubscriptionPaymentFirestoreRepository = /** @class */ (function (_super) {
|
|
2431
|
-
__extends(SubscriptionPaymentFirestoreRepository, _super);
|
|
2432
|
-
function SubscriptionPaymentFirestoreRepository(firestore, parentRepository) {
|
|
2433
|
-
var _this = _super.call(this) || this;
|
|
2434
|
-
_this.firestore = firestore;
|
|
2435
|
-
_this.parentRepository = parentRepository;
|
|
2436
|
-
_this.collectionName = 'payments';
|
|
2437
|
-
_this.parentIdField = 'subscriptionId';
|
|
2438
|
-
_this.model = SubscriptionPayment;
|
|
2439
|
-
return _this;
|
|
2440
|
-
}
|
|
2441
|
-
return SubscriptionPaymentFirestoreRepository;
|
|
2442
|
-
}(withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription)));
|
|
2443
|
-
|
|
2444
|
-
var LeadFirestoreRepository = /** @class */ (function (_super) {
|
|
2445
|
-
__extends(LeadFirestoreRepository, _super);
|
|
2446
|
-
function LeadFirestoreRepository(firestore) {
|
|
2447
|
-
var _this = _super.call(this) || this;
|
|
2448
|
-
_this.firestore = firestore;
|
|
2449
|
-
_this.collectionName = 'leads';
|
|
2450
|
-
_this.model = Lead;
|
|
2451
|
-
return _this;
|
|
2452
|
-
}
|
|
2453
|
-
return LeadFirestoreRepository;
|
|
2454
|
-
}(withCrudFirestore(withHelpers(withFirestore(Base)))));
|
|
2455
|
-
|
|
2456
2428
|
var CategoryFirestoreRepository = /** @class */ (function (_super) {
|
|
2457
2429
|
__extends(CategoryFirestoreRepository, _super);
|
|
2458
2430
|
function CategoryFirestoreRepository(firestore) {
|
|
@@ -3699,34 +3671,65 @@
|
|
|
3699
3671
|
});
|
|
3700
3672
|
var _a;
|
|
3701
3673
|
return __awaiter(this, void 0, void 0, function () {
|
|
3702
|
-
var
|
|
3703
|
-
return __generator(this, function (
|
|
3704
|
-
switch (
|
|
3674
|
+
var _c;
|
|
3675
|
+
return __generator(this, function (_d) {
|
|
3676
|
+
switch (_d.label) {
|
|
3705
3677
|
case 0:
|
|
3706
3678
|
if (!Number.isNaN(+identifiers.id)) return [3 /*break*/, 2];
|
|
3707
3679
|
return [4 /*yield*/, this.find({ filters: { firestoreId: identifiers.id } })];
|
|
3708
3680
|
case 1:
|
|
3709
|
-
|
|
3681
|
+
_c = (_a = (_d.sent()).data) === null || _a === void 0 ? void 0 : _a[0];
|
|
3710
3682
|
return [3 /*break*/, 3];
|
|
3711
3683
|
case 2:
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
case 3: return [2 /*return*/,
|
|
3684
|
+
_c = _super.get.call(this, identifiers);
|
|
3685
|
+
_d.label = 3;
|
|
3686
|
+
case 3: return [2 /*return*/, _c];
|
|
3687
|
+
}
|
|
3688
|
+
});
|
|
3689
|
+
});
|
|
3690
|
+
};
|
|
3691
|
+
CategoryHasuraGraphQLRepository.prototype.update = function (params) {
|
|
3692
|
+
var _super = Object.create(null, {
|
|
3693
|
+
update: { get: function () { return _super_1.prototype.update; } }
|
|
3694
|
+
});
|
|
3695
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3696
|
+
var products, checkId, data, plainData, id, category, _c, _d;
|
|
3697
|
+
return __generator(this, function (_e) {
|
|
3698
|
+
switch (_e.label) {
|
|
3699
|
+
case 0:
|
|
3700
|
+
products = params.products, checkId = params.id, data = __rest(params, ["products", "id"]);
|
|
3701
|
+
plainData = this.paramsToPlain({ id: checkId });
|
|
3702
|
+
return [4 /*yield*/, this.getId(plainData.id)];
|
|
3703
|
+
case 1:
|
|
3704
|
+
id = _e.sent();
|
|
3705
|
+
return [4 /*yield*/, _super.update.call(this, Object.assign({ id: id }, data))];
|
|
3706
|
+
case 2:
|
|
3707
|
+
category = _e.sent();
|
|
3708
|
+
_c = category;
|
|
3709
|
+
_d = products;
|
|
3710
|
+
if (!_d) return [3 /*break*/, 4];
|
|
3711
|
+
return [4 /*yield*/, this.updateProducts(+id, { products: products })];
|
|
3712
|
+
case 3:
|
|
3713
|
+
_d = (_e.sent());
|
|
3714
|
+
_e.label = 4;
|
|
3715
|
+
case 4:
|
|
3716
|
+
_c.products = _d;
|
|
3717
|
+
return [2 /*return*/, category];
|
|
3715
3718
|
}
|
|
3716
3719
|
});
|
|
3717
3720
|
});
|
|
3718
3721
|
};
|
|
3719
3722
|
CategoryHasuraGraphQLRepository.prototype.getCategoryBySlug = function (slug, shop) {
|
|
3720
3723
|
return __awaiter(this, void 0, void 0, function () {
|
|
3721
|
-
var
|
|
3722
|
-
return __generator(this, function (
|
|
3723
|
-
switch (
|
|
3724
|
+
var _c, data, count;
|
|
3725
|
+
return __generator(this, function (_d) {
|
|
3726
|
+
switch (_d.label) {
|
|
3724
3727
|
case 0:
|
|
3725
3728
|
if (!slug)
|
|
3726
3729
|
return [2 /*return*/];
|
|
3727
3730
|
return [4 /*yield*/, this.find({ filters: { slug: slug, shop: shop, published: true } })];
|
|
3728
3731
|
case 1:
|
|
3729
|
-
|
|
3732
|
+
_c = _d.sent(), data = _c.data, count = _c.count;
|
|
3730
3733
|
if (count > 1)
|
|
3731
3734
|
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
3732
3735
|
if (!count)
|
|
@@ -3739,33 +3742,33 @@
|
|
|
3739
3742
|
CategoryHasuraGraphQLRepository.prototype.getCategoriesForHome = function (categoryIds, limit) {
|
|
3740
3743
|
if (limit === void 0) { limit = 4; }
|
|
3741
3744
|
return __awaiter(this, void 0, void 0, function () {
|
|
3742
|
-
var
|
|
3745
|
+
var _c, categories, count, homeSections;
|
|
3743
3746
|
var _this = this;
|
|
3744
|
-
return __generator(this, function (
|
|
3745
|
-
switch (
|
|
3747
|
+
return __generator(this, function (_d) {
|
|
3748
|
+
switch (_d.label) {
|
|
3746
3749
|
case 0: return [4 /*yield*/, this.find({
|
|
3747
3750
|
filters: { firestoreId: { operator: exports.Where.IN, value: categoryIds.filter(Boolean) }, published: true },
|
|
3748
3751
|
})];
|
|
3749
3752
|
case 1:
|
|
3750
|
-
|
|
3753
|
+
_c = _d.sent(), categories = _c.data, count = _c.count;
|
|
3751
3754
|
if (!count)
|
|
3752
3755
|
throw new NotFoundError('Categories not found');
|
|
3753
3756
|
return [4 /*yield*/, Promise.all(categories.map(function (category) { return __awaiter(_this, void 0, void 0, function () {
|
|
3754
|
-
var
|
|
3755
|
-
return __generator(this, function (
|
|
3756
|
-
switch (
|
|
3757
|
+
var _c;
|
|
3758
|
+
return __generator(this, function (_d) {
|
|
3759
|
+
switch (_d.label) {
|
|
3757
3760
|
case 0:
|
|
3758
|
-
|
|
3761
|
+
_c = {
|
|
3759
3762
|
category: category
|
|
3760
3763
|
};
|
|
3761
3764
|
return [4 /*yield*/, this.mountCategory(category, { limit: limit, hasStock: true })];
|
|
3762
|
-
case 1: return [2 /*return*/, (
|
|
3763
|
-
|
|
3765
|
+
case 1: return [2 /*return*/, (_c.products = _d.sent(),
|
|
3766
|
+
_c)];
|
|
3764
3767
|
}
|
|
3765
3768
|
});
|
|
3766
3769
|
}); }))];
|
|
3767
3770
|
case 2:
|
|
3768
|
-
homeSections =
|
|
3771
|
+
homeSections = _d.sent();
|
|
3769
3772
|
return [2 /*return*/, homeSections];
|
|
3770
3773
|
}
|
|
3771
3774
|
});
|
|
@@ -3774,8 +3777,8 @@
|
|
|
3774
3777
|
CategoryHasuraGraphQLRepository.prototype.mountCategory = function (category, options) {
|
|
3775
3778
|
return __awaiter(this, void 0, void 0, function () {
|
|
3776
3779
|
var products, productsData;
|
|
3777
|
-
return __generator(this, function (
|
|
3778
|
-
switch (
|
|
3780
|
+
return __generator(this, function (_c) {
|
|
3781
|
+
switch (_c.label) {
|
|
3779
3782
|
case 0:
|
|
3780
3783
|
if (!category.products)
|
|
3781
3784
|
throw new RequiredArgumentError(['Category products is empty']);
|
|
@@ -3804,13 +3807,77 @@
|
|
|
3804
3807
|
'tags',
|
|
3805
3808
|
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})))];
|
|
3806
3809
|
case 1:
|
|
3807
|
-
productsData = (
|
|
3810
|
+
productsData = (_c.sent()).data;
|
|
3808
3811
|
products.push.apply(products, __spreadArray([], __read(productsData)));
|
|
3809
3812
|
return [2 /*return*/, products];
|
|
3810
3813
|
}
|
|
3811
3814
|
});
|
|
3812
3815
|
});
|
|
3813
3816
|
};
|
|
3817
|
+
CategoryHasuraGraphQLRepository.prototype.getId = function (id) {
|
|
3818
|
+
var _a, _b;
|
|
3819
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3820
|
+
var data;
|
|
3821
|
+
return __generator(this, function (_c) {
|
|
3822
|
+
switch (_c.label) {
|
|
3823
|
+
case 0:
|
|
3824
|
+
if (!Number.isNaN(+id))
|
|
3825
|
+
return [2 /*return*/, id];
|
|
3826
|
+
return [4 /*yield*/, this.find({ filters: { firestoreId: id } })];
|
|
3827
|
+
case 1:
|
|
3828
|
+
data = (_c.sent()).data;
|
|
3829
|
+
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
3830
|
+
return [2 /*return*/, (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id];
|
|
3831
|
+
throw new NotFoundError("Category with id " + id + " not found");
|
|
3832
|
+
}
|
|
3833
|
+
});
|
|
3834
|
+
});
|
|
3835
|
+
};
|
|
3836
|
+
CategoryHasuraGraphQLRepository.prototype.updateProducts = function (categoryId, _c) {
|
|
3837
|
+
var products = _c.products;
|
|
3838
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3839
|
+
var plainData;
|
|
3840
|
+
return __generator(this, function (_c) {
|
|
3841
|
+
switch (_c.label) {
|
|
3842
|
+
case 0:
|
|
3843
|
+
if (!('action' in products && products.action === 'remove')) return [3 /*break*/, 2];
|
|
3844
|
+
return [4 /*yield*/, this.mutation('delete_category_product', ['affected_rows'], {
|
|
3845
|
+
where: {
|
|
3846
|
+
type: 'category_product_bool_exp',
|
|
3847
|
+
required: true,
|
|
3848
|
+
value: { category_id: { _eq: categoryId } },
|
|
3849
|
+
},
|
|
3850
|
+
})];
|
|
3851
|
+
case 1:
|
|
3852
|
+
_c.sent();
|
|
3853
|
+
return [2 /*return*/, []];
|
|
3854
|
+
case 2:
|
|
3855
|
+
plainData = this.paramsToPlain({ products: products });
|
|
3856
|
+
if (!plainData.products || plainData.products.length <= 0)
|
|
3857
|
+
return [2 /*return*/, []];
|
|
3858
|
+
return [4 /*yield*/, this.mutation('delete_category_product', ['affected_rows'], {
|
|
3859
|
+
where: {
|
|
3860
|
+
type: 'category_product_bool_exp',
|
|
3861
|
+
required: true,
|
|
3862
|
+
value: { category_id: { _eq: categoryId } },
|
|
3863
|
+
},
|
|
3864
|
+
})];
|
|
3865
|
+
case 3:
|
|
3866
|
+
_c.sent();
|
|
3867
|
+
return [4 /*yield*/, this.mutation('insert_category_product', ['affected_rows'], {
|
|
3868
|
+
objects: {
|
|
3869
|
+
type: '[category_product_insert_input!]',
|
|
3870
|
+
required: true,
|
|
3871
|
+
value: plainData.products.map(function (productId) { return ({ category_id: categoryId, product_id: productId }); }),
|
|
3872
|
+
},
|
|
3873
|
+
})];
|
|
3874
|
+
case 4:
|
|
3875
|
+
_c.sent();
|
|
3876
|
+
return [2 /*return*/, plainData.products];
|
|
3877
|
+
}
|
|
3878
|
+
});
|
|
3879
|
+
});
|
|
3880
|
+
};
|
|
3814
3881
|
return CategoryHasuraGraphQLRepository;
|
|
3815
3882
|
}(withCrudHasuraGraphQL(withHasuraGraphQL(Base))));
|
|
3816
3883
|
|
|
@@ -3921,6 +3988,13 @@
|
|
|
3921
3988
|
],
|
|
3922
3989
|
},
|
|
3923
3990
|
},
|
|
3991
|
+
{
|
|
3992
|
+
reviews: {
|
|
3993
|
+
columnName: 'reviews',
|
|
3994
|
+
foreignKeyColumn: { productId: 'id' },
|
|
3995
|
+
fields: _this.reviewsFields,
|
|
3996
|
+
},
|
|
3997
|
+
},
|
|
3924
3998
|
{
|
|
3925
3999
|
metadata: {
|
|
3926
4000
|
columnName: 'metadata',
|
|
@@ -3991,27 +4065,32 @@
|
|
|
3991
4065
|
});
|
|
3992
4066
|
var _a;
|
|
3993
4067
|
return __awaiter(this, void 0, void 0, function () {
|
|
3994
|
-
var product, _c, _d;
|
|
3995
|
-
return __generator(this, function (
|
|
3996
|
-
switch (
|
|
4068
|
+
var product, _c, _d, _e;
|
|
4069
|
+
return __generator(this, function (_f) {
|
|
4070
|
+
switch (_f.label) {
|
|
3997
4071
|
case 0:
|
|
3998
4072
|
if (!Number.isNaN(+identifiers.id)) return [3 /*break*/, 2];
|
|
3999
4073
|
return [4 /*yield*/, this.find({ filters: { firestoreId: identifiers.id } })];
|
|
4000
4074
|
case 1:
|
|
4001
|
-
_c = (_a = (
|
|
4075
|
+
_c = (_a = (_f.sent()).data) === null || _a === void 0 ? void 0 : _a[0];
|
|
4002
4076
|
return [3 /*break*/, 4];
|
|
4003
4077
|
case 2: return [4 /*yield*/, _super.get.call(this, identifiers)];
|
|
4004
4078
|
case 3:
|
|
4005
|
-
_c =
|
|
4006
|
-
|
|
4079
|
+
_c = _f.sent();
|
|
4080
|
+
_f.label = 4;
|
|
4007
4081
|
case 4:
|
|
4008
4082
|
product = _c;
|
|
4009
4083
|
if (product.productId)
|
|
4010
4084
|
throw new NotFoundError('Product not found, it is a variant');
|
|
4011
4085
|
_d = product;
|
|
4086
|
+
_e = product.reviews;
|
|
4087
|
+
if (_e) return [3 /*break*/, 6];
|
|
4012
4088
|
return [4 /*yield*/, this.findReviewsByProduct(+product.id)];
|
|
4013
4089
|
case 5:
|
|
4014
|
-
|
|
4090
|
+
_e = (_f.sent());
|
|
4091
|
+
_f.label = 6;
|
|
4092
|
+
case 6:
|
|
4093
|
+
_d.reviews = _e;
|
|
4015
4094
|
return [2 /*return*/, product];
|
|
4016
4095
|
}
|
|
4017
4096
|
});
|
|
@@ -4022,10 +4101,14 @@
|
|
|
4022
4101
|
find: { get: function () { return _super_1.prototype.find; } }
|
|
4023
4102
|
});
|
|
4024
4103
|
return __awaiter(this, void 0, void 0, function () {
|
|
4025
|
-
var _a, filters, options;
|
|
4104
|
+
var _a, filters, fields, options, bindFields;
|
|
4026
4105
|
return __generator(this, function (_c) {
|
|
4027
|
-
_a = params || {}, filters = _a.filters, options = __rest(_a, ["filters"]);
|
|
4028
|
-
|
|
4106
|
+
_a = params || {}, filters = _a.filters, fields = _a.fields, options = __rest(_a, ["filters", "fields"]);
|
|
4107
|
+
bindFields = fields ||
|
|
4108
|
+
this.fields
|
|
4109
|
+
.map(function (field) { return (typeof field === 'string' ? field : Object.keys(field).shift()); })
|
|
4110
|
+
.filter(function (field) { return field !== 'reviews'; });
|
|
4111
|
+
return [2 /*return*/, _super.find.call(this, Object.assign(Object.assign({}, options), { filters: Object.assign(Object.assign({}, filters), { productId: { operator: exports.Where.ISNULL } }), fields: bindFields }))];
|
|
4029
4112
|
});
|
|
4030
4113
|
});
|
|
4031
4114
|
};
|
|
@@ -4103,18 +4186,18 @@
|
|
|
4103
4186
|
};
|
|
4104
4187
|
ProductHasuraGraphQLRepository.prototype.fetchReviews = function (status) {
|
|
4105
4188
|
return __awaiter(this, void 0, void 0, function () {
|
|
4106
|
-
var
|
|
4189
|
+
var reviewsExpression, data;
|
|
4107
4190
|
var _c, _d;
|
|
4108
4191
|
var _this = this;
|
|
4109
4192
|
return __generator(this, function (_e) {
|
|
4110
4193
|
switch (_e.label) {
|
|
4111
4194
|
case 0:
|
|
4112
|
-
|
|
4195
|
+
reviewsExpression = {
|
|
4113
4196
|
status: status === 'pending'
|
|
4114
4197
|
? (_c = {}, _c[HasuraGraphQLWhere.ISNULL] = true, _c) : (_d = {}, _d[HasuraGraphQLWhere.EQUALS] = status === 'approved', _d),
|
|
4115
4198
|
};
|
|
4116
4199
|
return [4 /*yield*/, this.query('product', ['id', 'name', 'sku', { reviews: { columnName: 'reviews', fields: this.reviewsFields } }], {
|
|
4117
|
-
where: { value: { reviews:
|
|
4200
|
+
where: { value: { reviews: reviewsExpression }, type: 'product_bool_exp', required: true },
|
|
4118
4201
|
})];
|
|
4119
4202
|
case 1:
|
|
4120
4203
|
data = (_e.sent()).product;
|
|
@@ -4134,7 +4217,7 @@
|
|
|
4134
4217
|
return __generator(this, function (_c) {
|
|
4135
4218
|
switch (_c.label) {
|
|
4136
4219
|
case 0:
|
|
4137
|
-
|
|
4220
|
+
if (!('action' in categories && categories.action === 'remove')) return [3 /*break*/, 2];
|
|
4138
4221
|
return [4 /*yield*/, this.mutation('delete_category_product', ['affected_rows'], {
|
|
4139
4222
|
where: {
|
|
4140
4223
|
type: 'category_product_bool_exp',
|
|
@@ -4143,6 +4226,20 @@
|
|
|
4143
4226
|
},
|
|
4144
4227
|
})];
|
|
4145
4228
|
case 1:
|
|
4229
|
+
_c.sent();
|
|
4230
|
+
return [2 /*return*/, []];
|
|
4231
|
+
case 2:
|
|
4232
|
+
plainData = this.paramsToPlain({ categories: categories });
|
|
4233
|
+
if (!plainData.categories || plainData.categories.length <= 0)
|
|
4234
|
+
return [2 /*return*/, []];
|
|
4235
|
+
return [4 /*yield*/, this.mutation('delete_category_product', ['affected_rows'], {
|
|
4236
|
+
where: {
|
|
4237
|
+
type: 'category_product_bool_exp',
|
|
4238
|
+
required: true,
|
|
4239
|
+
value: { product_id: { _eq: productId } },
|
|
4240
|
+
},
|
|
4241
|
+
})];
|
|
4242
|
+
case 3:
|
|
4146
4243
|
_c.sent();
|
|
4147
4244
|
return [4 /*yield*/, this.mutation('insert_category_product', ['affected_rows'], {
|
|
4148
4245
|
objects: {
|
|
@@ -4151,7 +4248,7 @@
|
|
|
4151
4248
|
value: plainData.categories.map(function (categoryId) { return ({ category_id: categoryId, product_id: productId }); }),
|
|
4152
4249
|
},
|
|
4153
4250
|
})];
|
|
4154
|
-
case
|
|
4251
|
+
case 4:
|
|
4155
4252
|
_c.sent();
|
|
4156
4253
|
return [2 /*return*/, plainData.categories];
|
|
4157
4254
|
}
|
|
@@ -4201,8 +4298,6 @@
|
|
|
4201
4298
|
return __generator(this, function (_c) {
|
|
4202
4299
|
switch (_c.label) {
|
|
4203
4300
|
case 0:
|
|
4204
|
-
if (!reviews)
|
|
4205
|
-
return [2 /*return*/, []];
|
|
4206
4301
|
if (!('action' in reviews && reviews.action === 'remove')) return [3 /*break*/, 3];
|
|
4207
4302
|
return [4 /*yield*/, Promise.all(reviews.value.map(function (reviewData) { return __awaiter(_this, void 0, void 0, function () {
|
|
4208
4303
|
var review;
|
|
@@ -4225,6 +4320,8 @@
|
|
|
4225
4320
|
return [2 /*return*/, reviews.value.map(function (review, index) { return !reviewIds_1[index] && review; }).filter(Boolean)];
|
|
4226
4321
|
case 3:
|
|
4227
4322
|
plainData = this.paramsToPlain({ reviews: reviews });
|
|
4323
|
+
if (!plainData.reviews || plainData.reviews.length <= 0)
|
|
4324
|
+
return [2 /*return*/, []];
|
|
4228
4325
|
return [2 /*return*/, Promise.all(plainData.reviews.map(function (reviewData) { return __awaiter(_this, void 0, void 0, function () {
|
|
4229
4326
|
var review, _c, _d;
|
|
4230
4327
|
return __generator(this, function (_e) {
|
|
@@ -4694,7 +4791,6 @@
|
|
|
4694
4791
|
exports.UserFirestoreRepository = UserFirestoreRepository;
|
|
4695
4792
|
exports.UserPaymentMethod = UserPaymentMethod;
|
|
4696
4793
|
exports.UserPaymentMethodFirestoreRepository = UserPaymentMethodFirestoreRepository;
|
|
4697
|
-
exports.UserSearchFirestoreRepository = UserSearchFirestoreRepository;
|
|
4698
4794
|
exports.Variant = Variant;
|
|
4699
4795
|
exports.VariantHasuraGraphQL = VariantHasuraGraphQL;
|
|
4700
4796
|
exports.VariantHasuraGraphQLRepository = VariantHasuraGraphQLRepository;
|