@infrab4a/connect 2.0.13-beta.1 → 3.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/infrab4a-connect.umd.js +187 -318
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/domain/catalog/models/product.d.ts +4 -8
- package/domain/catalog/models/types/index.d.ts +3 -2
- package/domain/catalog/models/types/product-metadata.type.d.ts +4 -0
- package/domain/catalog/models/types/shop-description.type.d.ts +7 -0
- package/domain/catalog/models/types/{shops-price.type.d.ts → shop-price.type.d.ts} +0 -4
- package/domain/catalog/models/variant.d.ts +2 -2
- package/domain/generic/repository/enums/where.enum.d.ts +0 -1
- package/esm2015/domain/catalog/models/product.js +1 -5
- package/esm2015/domain/catalog/models/types/index.js +4 -3
- package/esm2015/domain/catalog/models/types/product-metadata.type.js +2 -0
- package/esm2015/domain/catalog/models/types/shop-description.type.js +2 -0
- package/esm2015/domain/catalog/models/types/shop-price.type.js +2 -0
- package/esm2015/domain/catalog/models/variant.js +1 -1
- package/esm2015/domain/catalog/repositories/product.repository.js +1 -1
- package/esm2015/domain/generic/repository/enums/where.enum.js +1 -2
- package/esm2015/domain/shop-settings/models/home.js +1 -1
- package/esm2015/infra/elasticsearch/indexes/products-index.js +4 -6
- package/esm2015/infra/firebase/firestore/models/user-search.js +7 -0
- package/esm2015/infra/firebase/firestore/repositories/catalog/category-firestore.repository.js +4 -5
- package/esm2015/infra/firebase/firestore/repositories/users/index.js +7 -6
- package/esm2015/infra/firebase/firestore/repositories/users/user-firestore.repository.js +6 -4
- package/esm2015/infra/firebase/firestore/repositories/users/user-search-firestore.repository.js +12 -0
- package/esm2015/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.js +4 -65
- package/esm2015/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.js +28 -55
- package/esm2015/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.js +11 -14
- package/esm2015/infra/hasura-graphql/types/hasura-graphql-fields.type.js +1 -1
- package/fesm2015/infrab4a-connect.js +103 -186
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/infra/firebase/firestore/models/user-search.d.ts +9 -0
- package/infra/firebase/firestore/repositories/users/index.d.ts +6 -5
- package/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +3 -1
- package/infra/firebase/firestore/repositories/users/user-search-firestore.repository.d.ts +9 -0
- package/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +1 -4
- package/infra/hasura-graphql/types/hasura-graphql-fields.type.d.ts +1 -1
- package/package.json +1 -1
- package/domain/catalog/models/types/shops-description.type.d.ts +0 -7
- package/esm2015/domain/catalog/models/types/shops-description.type.js +0 -2
- package/esm2015/domain/catalog/models/types/shops-price.type.js +0 -2
|
@@ -48,7 +48,6 @@
|
|
|
48
48
|
exports.Where = void 0;
|
|
49
49
|
(function (Where) {
|
|
50
50
|
Where["EQUALS"] = "==";
|
|
51
|
-
Where["NOTEQUALS"] = "!=";
|
|
52
51
|
Where["GT"] = ">";
|
|
53
52
|
Where["GTE"] = ">=";
|
|
54
53
|
Where["IN"] = "in";
|
|
@@ -1293,10 +1292,6 @@
|
|
|
1293
1292
|
Product.prototype.identifierFields = function () {
|
|
1294
1293
|
return ['id'];
|
|
1295
1294
|
};
|
|
1296
|
-
Product.prototype.getInfoByShop = function (shop) {
|
|
1297
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1298
|
-
return Object.assign(Object.assign(Object.assign({}, (((_b = (_a = this.description) === null || _a === void 0 ? void 0 : _a[shop]) === null || _b === void 0 ? void 0 : _b.description) ? { description: (_d = (_c = this.description) === null || _c === void 0 ? void 0 : _c[shop]) === null || _d === void 0 ? void 0 : _d.description } : {})), (((_e = this.price) === null || _e === void 0 ? void 0 : _e[shop]) || {})), (((_f = this.stock) === null || _f === void 0 ? void 0 : _f[shop]) || {}));
|
|
1299
|
-
};
|
|
1300
1295
|
Object.defineProperty(Product, "identifiersFields", {
|
|
1301
1296
|
get: function () {
|
|
1302
1297
|
return ['id'];
|
|
@@ -1751,12 +1746,10 @@
|
|
|
1751
1746
|
};
|
|
1752
1747
|
ProductsIndex.prototype.findById = function (ids, options) {
|
|
1753
1748
|
return __awaiter(this, void 0, void 0, function () {
|
|
1754
|
-
var
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
switch (_b.label) {
|
|
1749
|
+
var fields, hits;
|
|
1750
|
+
return __generator(this, function (_a) {
|
|
1751
|
+
switch (_a.label) {
|
|
1758
1752
|
case 0:
|
|
1759
|
-
publishedField = options.shop === exports.Shops.GLAMSHOP ? 'publishedGlam' : 'published';
|
|
1760
1753
|
fields = [
|
|
1761
1754
|
'brand',
|
|
1762
1755
|
'id',
|
|
@@ -1774,7 +1767,6 @@
|
|
|
1774
1767
|
'weight',
|
|
1775
1768
|
'tags',
|
|
1776
1769
|
'hasVariants',
|
|
1777
|
-
'type'
|
|
1778
1770
|
];
|
|
1779
1771
|
return [4 /*yield*/, this.adapter.query('products/_search', Object.assign({ _source: fields, query: {
|
|
1780
1772
|
bool: {
|
|
@@ -1785,9 +1777,9 @@
|
|
|
1785
1777
|
},
|
|
1786
1778
|
},
|
|
1787
1779
|
{
|
|
1788
|
-
term:
|
|
1789
|
-
|
|
1790
|
-
|
|
1780
|
+
term: {
|
|
1781
|
+
published: true,
|
|
1782
|
+
},
|
|
1791
1783
|
}
|
|
1792
1784
|
], __read((options.hasStock
|
|
1793
1785
|
? [
|
|
@@ -1803,7 +1795,7 @@
|
|
|
1803
1795
|
},
|
|
1804
1796
|
} }, (options.size ? { size: options.size } : {})))];
|
|
1805
1797
|
case 1:
|
|
1806
|
-
hits = (
|
|
1798
|
+
hits = (_a.sent()).hits;
|
|
1807
1799
|
return [2 /*return*/, hits.map(function (hit) { return Product.toInstance(hit._source); })];
|
|
1808
1800
|
}
|
|
1809
1801
|
});
|
|
@@ -1832,7 +1824,7 @@
|
|
|
1832
1824
|
return [3 /*break*/, 6];
|
|
1833
1825
|
case 4:
|
|
1834
1826
|
error_1 = _a.sent();
|
|
1835
|
-
console.
|
|
1827
|
+
console.info(error_1.message);
|
|
1836
1828
|
return [4 /*yield*/, this.adapter.save("products/_doc/" + product.id, product.toPlain())];
|
|
1837
1829
|
case 5:
|
|
1838
1830
|
_a.sent();
|
|
@@ -2236,32 +2228,6 @@
|
|
|
2236
2228
|
}(withUpdateFirestore(withGetFirestore(withFindFirestore(withDeleteFirestore(withCreateFirestore(MixinBase)))))));
|
|
2237
2229
|
};
|
|
2238
2230
|
|
|
2239
|
-
var LeadFirestoreRepository = /** @class */ (function (_super) {
|
|
2240
|
-
__extends(LeadFirestoreRepository, _super);
|
|
2241
|
-
function LeadFirestoreRepository(firestore) {
|
|
2242
|
-
var _this = _super.call(this) || this;
|
|
2243
|
-
_this.firestore = firestore;
|
|
2244
|
-
_this.collectionName = 'leads';
|
|
2245
|
-
_this.model = Lead;
|
|
2246
|
-
return _this;
|
|
2247
|
-
}
|
|
2248
|
-
return LeadFirestoreRepository;
|
|
2249
|
-
}(withCrudFirestore(withHelpers(withFirestore(Base)))));
|
|
2250
|
-
|
|
2251
|
-
var SubscriptionEditionFirestoreRepository = /** @class */ (function (_super) {
|
|
2252
|
-
__extends(SubscriptionEditionFirestoreRepository, _super);
|
|
2253
|
-
function SubscriptionEditionFirestoreRepository(firestore, parentRepository) {
|
|
2254
|
-
var _this = _super.call(this) || this;
|
|
2255
|
-
_this.firestore = firestore;
|
|
2256
|
-
_this.parentRepository = parentRepository;
|
|
2257
|
-
_this.collectionName = 'editions';
|
|
2258
|
-
_this.parentIdField = 'subscriptionId';
|
|
2259
|
-
_this.model = Edition;
|
|
2260
|
-
return _this;
|
|
2261
|
-
}
|
|
2262
|
-
return SubscriptionEditionFirestoreRepository;
|
|
2263
|
-
}(withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription)));
|
|
2264
|
-
|
|
2265
2231
|
var SubscriptionFirestoreRepository = /** @class */ (function (_super) {
|
|
2266
2232
|
__extends(SubscriptionFirestoreRepository, _super);
|
|
2267
2233
|
function SubscriptionFirestoreRepository(firestore) {
|
|
@@ -2274,53 +2240,40 @@
|
|
|
2274
2240
|
return SubscriptionFirestoreRepository;
|
|
2275
2241
|
}(withCrudFirestore(withHelpers(withFirestore(Base)))));
|
|
2276
2242
|
|
|
2277
|
-
var
|
|
2278
|
-
__extends(
|
|
2279
|
-
function
|
|
2280
|
-
|
|
2281
|
-
_this.firestore = firestore;
|
|
2282
|
-
_this.parentRepository = parentRepository;
|
|
2283
|
-
_this.collectionName = 'payments';
|
|
2284
|
-
_this.parentIdField = 'subscriptionId';
|
|
2285
|
-
_this.model = SubscriptionPayment;
|
|
2286
|
-
return _this;
|
|
2243
|
+
var UserSearch = /** @class */ (function (_super) {
|
|
2244
|
+
__extends(UserSearch, _super);
|
|
2245
|
+
function UserSearch() {
|
|
2246
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
2287
2247
|
}
|
|
2288
|
-
|
|
2289
|
-
|
|
2248
|
+
Object.defineProperty(UserSearch, "identifiersFields", {
|
|
2249
|
+
get: function () {
|
|
2250
|
+
return ['id'];
|
|
2251
|
+
},
|
|
2252
|
+
enumerable: false,
|
|
2253
|
+
configurable: true
|
|
2254
|
+
});
|
|
2255
|
+
return UserSearch;
|
|
2256
|
+
}(BaseModel));
|
|
2290
2257
|
|
|
2291
|
-
var
|
|
2292
|
-
__extends(
|
|
2293
|
-
function
|
|
2258
|
+
var UserSearchFirestoreRepository = /** @class */ (function (_super) {
|
|
2259
|
+
__extends(UserSearchFirestoreRepository, _super);
|
|
2260
|
+
function UserSearchFirestoreRepository(firestore) {
|
|
2294
2261
|
var _this = _super.call(this) || this;
|
|
2295
2262
|
_this.firestore = firestore;
|
|
2296
|
-
_this.
|
|
2297
|
-
_this.
|
|
2298
|
-
_this.parentIdField = 'userId';
|
|
2299
|
-
_this.model = UserAddress;
|
|
2263
|
+
_this.collectionName = 'userSearch';
|
|
2264
|
+
_this.model = UserSearch;
|
|
2300
2265
|
return _this;
|
|
2301
2266
|
}
|
|
2302
|
-
return
|
|
2303
|
-
}(
|
|
2304
|
-
|
|
2305
|
-
var UserBeautyProfileFirestoreRepository = /** @class */ (function (_super) {
|
|
2306
|
-
__extends(UserBeautyProfileFirestoreRepository, _super);
|
|
2307
|
-
function UserBeautyProfileFirestoreRepository(firestore, parentRepository) {
|
|
2308
|
-
var _this = _super.call(this) || this;
|
|
2309
|
-
_this.firestore = firestore;
|
|
2310
|
-
_this.parentRepository = parentRepository;
|
|
2311
|
-
_this.collectionName = 'CX';
|
|
2312
|
-
_this.parentIdField = 'userId';
|
|
2313
|
-
_this.model = BeautyProfile;
|
|
2314
|
-
return _this;
|
|
2315
|
-
}
|
|
2316
|
-
return UserBeautyProfileFirestoreRepository;
|
|
2317
|
-
}(withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User)));
|
|
2267
|
+
return UserSearchFirestoreRepository;
|
|
2268
|
+
}(withCrudFirestore(withHelpers(withFirestore(Base)))));
|
|
2318
2269
|
|
|
2319
2270
|
var UserFirestoreRepository = /** @class */ (function (_super_1) {
|
|
2320
2271
|
__extends(UserFirestoreRepository, _super_1);
|
|
2321
|
-
function UserFirestoreRepository(firestore) {
|
|
2272
|
+
function UserFirestoreRepository(firestore, userSearchFirestoreRepository) {
|
|
2273
|
+
if (userSearchFirestoreRepository === void 0) { userSearchFirestoreRepository = new UserSearchFirestoreRepository(firestore); }
|
|
2322
2274
|
var _this = _super_1.call(this) || this;
|
|
2323
2275
|
_this.firestore = firestore;
|
|
2276
|
+
_this.userSearchFirestoreRepository = userSearchFirestoreRepository;
|
|
2324
2277
|
_this.collectionName = 'users';
|
|
2325
2278
|
_this.model = User;
|
|
2326
2279
|
return _this;
|
|
@@ -2355,7 +2308,7 @@
|
|
|
2355
2308
|
var _a;
|
|
2356
2309
|
return __generator(this, function (_b) {
|
|
2357
2310
|
switch (_b.label) {
|
|
2358
|
-
case 0: return [4 /*yield*/, this.find(
|
|
2311
|
+
case 0: return [4 /*yield*/, this.userSearchFirestoreRepository.find((_a = {}, _a[field] = { operator: exports.Where.EQUALS, value: value }, _a))];
|
|
2359
2312
|
case 1:
|
|
2360
2313
|
result = _b.sent();
|
|
2361
2314
|
return [2 /*return*/, result.count > 0];
|
|
@@ -2418,6 +2371,48 @@
|
|
|
2418
2371
|
return UserFirestoreRepository;
|
|
2419
2372
|
}(withCrudFirestore(withHelpers(withFirestore(Base)))));
|
|
2420
2373
|
|
|
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
|
+
|
|
2421
2416
|
var UserPaymentMethodFirestoreRepository = /** @class */ (function (_super) {
|
|
2422
2417
|
__extends(UserPaymentMethodFirestoreRepository, _super);
|
|
2423
2418
|
function UserPaymentMethodFirestoreRepository(firestore, parentRepository) {
|
|
@@ -2432,6 +2427,32 @@
|
|
|
2432
2427
|
return UserPaymentMethodFirestoreRepository;
|
|
2433
2428
|
}(withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User)));
|
|
2434
2429
|
|
|
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
|
+
|
|
2435
2456
|
var CategoryFirestoreRepository = /** @class */ (function (_super) {
|
|
2436
2457
|
__extends(CategoryFirestoreRepository, _super);
|
|
2437
2458
|
function CategoryFirestoreRepository(firestore) {
|
|
@@ -2495,7 +2516,7 @@
|
|
|
2495
2516
|
};
|
|
2496
2517
|
CategoryFirestoreRepository.prototype.mountCategory = function (category, options) {
|
|
2497
2518
|
return __awaiter(this, void 0, void 0, function () {
|
|
2498
|
-
var chunks, products,
|
|
2519
|
+
var chunks, products, chunks_1, chunks_1_1, productIds, query, productSnap, e_1_1;
|
|
2499
2520
|
var e_1, _a;
|
|
2500
2521
|
return __generator(this, function (_b) {
|
|
2501
2522
|
switch (_b.label) {
|
|
@@ -2504,7 +2525,6 @@
|
|
|
2504
2525
|
throw new RequiredArgumentError(['Category products is empty']);
|
|
2505
2526
|
chunks = lodash.chunk(category.products, 10);
|
|
2506
2527
|
products = [];
|
|
2507
|
-
publishedField = category.shop === exports.Shops.GLAMSHOP ? 'publishedGlam' : 'published';
|
|
2508
2528
|
_b.label = 1;
|
|
2509
2529
|
case 1:
|
|
2510
2530
|
_b.trys.push([1, 7, 8, 9]);
|
|
@@ -2516,7 +2536,7 @@
|
|
|
2516
2536
|
if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
|
|
2517
2537
|
return [3 /*break*/, 6];
|
|
2518
2538
|
return [4 /*yield*/, this.collection('productsErpVitrine')
|
|
2519
|
-
.where(
|
|
2539
|
+
.where('published', '==', true)
|
|
2520
2540
|
.where('id', 'in', productIds)];
|
|
2521
2541
|
case 3:
|
|
2522
2542
|
query = _b.sent();
|
|
@@ -3679,65 +3699,34 @@
|
|
|
3679
3699
|
});
|
|
3680
3700
|
var _a;
|
|
3681
3701
|
return __awaiter(this, void 0, void 0, function () {
|
|
3682
|
-
var
|
|
3683
|
-
return __generator(this, function (
|
|
3684
|
-
switch (
|
|
3702
|
+
var _b;
|
|
3703
|
+
return __generator(this, function (_c) {
|
|
3704
|
+
switch (_c.label) {
|
|
3685
3705
|
case 0:
|
|
3686
3706
|
if (!Number.isNaN(+identifiers.id)) return [3 /*break*/, 2];
|
|
3687
3707
|
return [4 /*yield*/, this.find({ filters: { firestoreId: identifiers.id } })];
|
|
3688
3708
|
case 1:
|
|
3689
|
-
|
|
3709
|
+
_b = (_a = (_c.sent()).data) === null || _a === void 0 ? void 0 : _a[0];
|
|
3690
3710
|
return [3 /*break*/, 3];
|
|
3691
3711
|
case 2:
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
case 3: return [2 /*return*/,
|
|
3695
|
-
}
|
|
3696
|
-
});
|
|
3697
|
-
});
|
|
3698
|
-
};
|
|
3699
|
-
CategoryHasuraGraphQLRepository.prototype.update = function (params) {
|
|
3700
|
-
var _super = Object.create(null, {
|
|
3701
|
-
update: { get: function () { return _super_1.prototype.update; } }
|
|
3702
|
-
});
|
|
3703
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
3704
|
-
var products, checkId, data, plainData, id, category, _c, _d;
|
|
3705
|
-
return __generator(this, function (_e) {
|
|
3706
|
-
switch (_e.label) {
|
|
3707
|
-
case 0:
|
|
3708
|
-
products = params.products, checkId = params.id, data = __rest(params, ["products", "id"]);
|
|
3709
|
-
plainData = this.paramsToPlain({ id: checkId });
|
|
3710
|
-
return [4 /*yield*/, this.getId(plainData.id)];
|
|
3711
|
-
case 1:
|
|
3712
|
-
id = _e.sent();
|
|
3713
|
-
return [4 /*yield*/, _super.update.call(this, Object.assign({ id: id }, data))];
|
|
3714
|
-
case 2:
|
|
3715
|
-
category = _e.sent();
|
|
3716
|
-
_c = category;
|
|
3717
|
-
_d = products;
|
|
3718
|
-
if (!_d) return [3 /*break*/, 4];
|
|
3719
|
-
return [4 /*yield*/, this.updateProducts(+id, { products: products })];
|
|
3720
|
-
case 3:
|
|
3721
|
-
_d = (_e.sent());
|
|
3722
|
-
_e.label = 4;
|
|
3723
|
-
case 4:
|
|
3724
|
-
_c.products = _d;
|
|
3725
|
-
return [2 /*return*/, category];
|
|
3712
|
+
_b = _super.get.call(this, identifiers);
|
|
3713
|
+
_c.label = 3;
|
|
3714
|
+
case 3: return [2 /*return*/, _b];
|
|
3726
3715
|
}
|
|
3727
3716
|
});
|
|
3728
3717
|
});
|
|
3729
3718
|
};
|
|
3730
3719
|
CategoryHasuraGraphQLRepository.prototype.getCategoryBySlug = function (slug, shop) {
|
|
3731
3720
|
return __awaiter(this, void 0, void 0, function () {
|
|
3732
|
-
var
|
|
3733
|
-
return __generator(this, function (
|
|
3734
|
-
switch (
|
|
3721
|
+
var _b, data, count;
|
|
3722
|
+
return __generator(this, function (_c) {
|
|
3723
|
+
switch (_c.label) {
|
|
3735
3724
|
case 0:
|
|
3736
3725
|
if (!slug)
|
|
3737
3726
|
return [2 /*return*/];
|
|
3738
3727
|
return [4 /*yield*/, this.find({ filters: { slug: slug, shop: shop, published: true } })];
|
|
3739
3728
|
case 1:
|
|
3740
|
-
|
|
3729
|
+
_b = _c.sent(), data = _b.data, count = _b.count;
|
|
3741
3730
|
if (count > 1)
|
|
3742
3731
|
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
3743
3732
|
if (!count)
|
|
@@ -3750,33 +3739,33 @@
|
|
|
3750
3739
|
CategoryHasuraGraphQLRepository.prototype.getCategoriesForHome = function (categoryIds, limit) {
|
|
3751
3740
|
if (limit === void 0) { limit = 4; }
|
|
3752
3741
|
return __awaiter(this, void 0, void 0, function () {
|
|
3753
|
-
var
|
|
3742
|
+
var _b, categories, count, homeSections;
|
|
3754
3743
|
var _this = this;
|
|
3755
|
-
return __generator(this, function (
|
|
3756
|
-
switch (
|
|
3744
|
+
return __generator(this, function (_c) {
|
|
3745
|
+
switch (_c.label) {
|
|
3757
3746
|
case 0: return [4 /*yield*/, this.find({
|
|
3758
3747
|
filters: { firestoreId: { operator: exports.Where.IN, value: categoryIds.filter(Boolean) }, published: true },
|
|
3759
3748
|
})];
|
|
3760
3749
|
case 1:
|
|
3761
|
-
|
|
3750
|
+
_b = _c.sent(), categories = _b.data, count = _b.count;
|
|
3762
3751
|
if (!count)
|
|
3763
3752
|
throw new NotFoundError('Categories not found');
|
|
3764
3753
|
return [4 /*yield*/, Promise.all(categories.map(function (category) { return __awaiter(_this, void 0, void 0, function () {
|
|
3765
|
-
var
|
|
3766
|
-
return __generator(this, function (
|
|
3767
|
-
switch (
|
|
3754
|
+
var _b;
|
|
3755
|
+
return __generator(this, function (_c) {
|
|
3756
|
+
switch (_c.label) {
|
|
3768
3757
|
case 0:
|
|
3769
|
-
|
|
3758
|
+
_b = {
|
|
3770
3759
|
category: category
|
|
3771
3760
|
};
|
|
3772
3761
|
return [4 /*yield*/, this.mountCategory(category, { limit: limit, hasStock: true })];
|
|
3773
|
-
case 1: return [2 /*return*/, (
|
|
3774
|
-
|
|
3762
|
+
case 1: return [2 /*return*/, (_b.products = _c.sent(),
|
|
3763
|
+
_b)];
|
|
3775
3764
|
}
|
|
3776
3765
|
});
|
|
3777
3766
|
}); }))];
|
|
3778
3767
|
case 2:
|
|
3779
|
-
homeSections =
|
|
3768
|
+
homeSections = _c.sent();
|
|
3780
3769
|
return [2 /*return*/, homeSections];
|
|
3781
3770
|
}
|
|
3782
3771
|
});
|
|
@@ -3784,16 +3773,14 @@
|
|
|
3784
3773
|
};
|
|
3785
3774
|
CategoryHasuraGraphQLRepository.prototype.mountCategory = function (category, options) {
|
|
3786
3775
|
return __awaiter(this, void 0, void 0, function () {
|
|
3787
|
-
var products,
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
switch (_d.label) {
|
|
3776
|
+
var products, productsData;
|
|
3777
|
+
return __generator(this, function (_b) {
|
|
3778
|
+
switch (_b.label) {
|
|
3791
3779
|
case 0:
|
|
3792
3780
|
if (!category.products)
|
|
3793
3781
|
throw new RequiredArgumentError(['Category products is empty']);
|
|
3794
3782
|
products = [];
|
|
3795
|
-
|
|
3796
|
-
return [4 /*yield*/, this.productRepository.find(Object.assign({ filters: Object.assign((_c = { id: { operator: exports.Where.IN, value: category.products } }, _c[publishedField] = true, _c), ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: exports.Where.GT, value: 0 } } } : {})), fields: [
|
|
3783
|
+
return [4 /*yield*/, this.productRepository.find(Object.assign({ filters: Object.assign({ id: { operator: exports.Where.IN, value: category.products }, published: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: exports.Where.GT, value: 0 } } } : {})), fields: [
|
|
3797
3784
|
'id',
|
|
3798
3785
|
'name',
|
|
3799
3786
|
'slug',
|
|
@@ -3805,7 +3792,6 @@
|
|
|
3805
3792
|
'subscriberPrice',
|
|
3806
3793
|
'stock',
|
|
3807
3794
|
'published',
|
|
3808
|
-
'publishedGlam',
|
|
3809
3795
|
'CEST',
|
|
3810
3796
|
'EAN',
|
|
3811
3797
|
'NCM',
|
|
@@ -3813,85 +3799,18 @@
|
|
|
3813
3799
|
'costPrice',
|
|
3814
3800
|
'hasVariants',
|
|
3815
3801
|
'isKit',
|
|
3816
|
-
'shopAvailability',
|
|
3817
3802
|
'sku',
|
|
3818
3803
|
'rate',
|
|
3819
3804
|
'tags',
|
|
3820
|
-
'type',
|
|
3821
|
-
'shoppingCount',
|
|
3822
3805
|
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})))];
|
|
3823
3806
|
case 1:
|
|
3824
|
-
productsData = (
|
|
3807
|
+
productsData = (_b.sent()).data;
|
|
3825
3808
|
products.push.apply(products, __spreadArray([], __read(productsData)));
|
|
3826
3809
|
return [2 /*return*/, products];
|
|
3827
3810
|
}
|
|
3828
3811
|
});
|
|
3829
3812
|
});
|
|
3830
3813
|
};
|
|
3831
|
-
CategoryHasuraGraphQLRepository.prototype.getId = function (id) {
|
|
3832
|
-
var _a, _b;
|
|
3833
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
3834
|
-
var data;
|
|
3835
|
-
return __generator(this, function (_c) {
|
|
3836
|
-
switch (_c.label) {
|
|
3837
|
-
case 0:
|
|
3838
|
-
if (!Number.isNaN(+id))
|
|
3839
|
-
return [2 /*return*/, id];
|
|
3840
|
-
return [4 /*yield*/, this.find({ filters: { firestoreId: id } })];
|
|
3841
|
-
case 1:
|
|
3842
|
-
data = (_c.sent()).data;
|
|
3843
|
-
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
3844
|
-
return [2 /*return*/, (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id];
|
|
3845
|
-
throw new NotFoundError("Category with id " + id + " not found");
|
|
3846
|
-
}
|
|
3847
|
-
});
|
|
3848
|
-
});
|
|
3849
|
-
};
|
|
3850
|
-
CategoryHasuraGraphQLRepository.prototype.updateProducts = function (categoryId, _c) {
|
|
3851
|
-
var products = _c.products;
|
|
3852
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
3853
|
-
var plainData;
|
|
3854
|
-
return __generator(this, function (_c) {
|
|
3855
|
-
switch (_c.label) {
|
|
3856
|
-
case 0:
|
|
3857
|
-
if (!('action' in products && products.action === 'remove')) return [3 /*break*/, 2];
|
|
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 1:
|
|
3866
|
-
_c.sent();
|
|
3867
|
-
return [2 /*return*/, []];
|
|
3868
|
-
case 2:
|
|
3869
|
-
plainData = this.paramsToPlain({ products: products });
|
|
3870
|
-
if (!plainData.products || plainData.products.length <= 0)
|
|
3871
|
-
return [2 /*return*/, []];
|
|
3872
|
-
return [4 /*yield*/, this.mutation('delete_category_product', ['affected_rows'], {
|
|
3873
|
-
where: {
|
|
3874
|
-
type: 'category_product_bool_exp',
|
|
3875
|
-
required: true,
|
|
3876
|
-
value: { category_id: { _eq: categoryId } },
|
|
3877
|
-
},
|
|
3878
|
-
})];
|
|
3879
|
-
case 3:
|
|
3880
|
-
_c.sent();
|
|
3881
|
-
return [4 /*yield*/, this.mutation('insert_category_product', ['affected_rows'], {
|
|
3882
|
-
objects: {
|
|
3883
|
-
type: '[category_product_insert_input!]',
|
|
3884
|
-
required: true,
|
|
3885
|
-
value: plainData.products.map(function (productId) { return ({ category_id: categoryId, product_id: productId }); }),
|
|
3886
|
-
},
|
|
3887
|
-
})];
|
|
3888
|
-
case 4:
|
|
3889
|
-
_c.sent();
|
|
3890
|
-
return [2 /*return*/, plainData.products];
|
|
3891
|
-
}
|
|
3892
|
-
});
|
|
3893
|
-
});
|
|
3894
|
-
};
|
|
3895
3814
|
return CategoryHasuraGraphQLRepository;
|
|
3896
3815
|
}(withCrudHasuraGraphQL(withHasuraGraphQL(Base))));
|
|
3897
3816
|
|
|
@@ -3919,11 +3838,8 @@
|
|
|
3919
3838
|
{
|
|
3920
3839
|
description: {
|
|
3921
3840
|
columnName: 'description',
|
|
3922
|
-
from: function (description) { return
|
|
3923
|
-
|
|
3924
|
-
return (Object.assign(Object.assign({}, shops), (_c = {}, _c[shop] = { description: description }, _c)));
|
|
3925
|
-
}, {}); },
|
|
3926
|
-
to: function (value) { return Object.values(value).shift().description; },
|
|
3841
|
+
from: function (description) { return ({ description: description }); },
|
|
3842
|
+
to: function (value) { return value.description; },
|
|
3927
3843
|
},
|
|
3928
3844
|
},
|
|
3929
3845
|
{ hasVariants: { columnName: 'has_variants' } },
|
|
@@ -3933,15 +3849,12 @@
|
|
|
3933
3849
|
{
|
|
3934
3850
|
price: {
|
|
3935
3851
|
columnName: 'price',
|
|
3936
|
-
from: function (price, data) { return
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
subscriberPrice: data.subscriber_price,
|
|
3943
|
-
}, _c)));
|
|
3944
|
-
}, {}); },
|
|
3852
|
+
from: function (price, data) { return ({
|
|
3853
|
+
price: price,
|
|
3854
|
+
fullPrice: data.full_price,
|
|
3855
|
+
subscriberDiscountPercentage: data.subscriber_discount_percentage,
|
|
3856
|
+
subscriberPrice: data.subscriber_price,
|
|
3857
|
+
}); },
|
|
3945
3858
|
bindFindFilter: function (sentence) {
|
|
3946
3859
|
var filters = Object.values(sentence).shift();
|
|
3947
3860
|
return Object.assign(Object.assign(Object.assign(Object.assign({}, (((filters === null || filters === void 0 ? void 0 : filters.price) || (filters === null || filters === void 0 ? void 0 : filters.price) === 0) && { price: filters.price })), ((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice })), ((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
|
|
@@ -3950,19 +3863,15 @@
|
|
|
3950
3863
|
subscriber_price: filters.subscriberPrice,
|
|
3951
3864
|
}));
|
|
3952
3865
|
},
|
|
3953
|
-
bindPersistData: function (
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
3957
|
-
})), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }));
|
|
3958
|
-
},
|
|
3866
|
+
bindPersistData: function (priceData) { return (Object.assign(Object.assign(Object.assign(Object.assign({}, ((priceData === null || priceData === void 0 ? void 0 : priceData.price) >= 0 && { price: priceData.price })), (priceData.fullPrice >= 0 && { full_price: priceData.fullPrice })), (priceData.subscriberDiscountPercentage >= 0 && {
|
|
3867
|
+
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
3868
|
+
})), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }))); },
|
|
3959
3869
|
},
|
|
3960
3870
|
},
|
|
3961
3871
|
{ fullPrice: { columnName: 'full_price' } },
|
|
3962
3872
|
{ subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
|
|
3963
3873
|
{ subscriberPrice: { columnName: 'subscriber_price' } },
|
|
3964
3874
|
'published',
|
|
3965
|
-
{ publishedGlam: { columnName: 'published_glam' } },
|
|
3966
3875
|
'sku',
|
|
3967
3876
|
{
|
|
3968
3877
|
stock: {
|
|
@@ -3976,14 +3885,6 @@
|
|
|
3976
3885
|
'video',
|
|
3977
3886
|
'weight',
|
|
3978
3887
|
'gender',
|
|
3979
|
-
{
|
|
3980
|
-
shopAvailability: {
|
|
3981
|
-
columnName: 'shop_availabilities',
|
|
3982
|
-
fields: ['shop'],
|
|
3983
|
-
from: function (shop) { return (Array.isArray(shop) ? shop.map(function (row) { return row.shop; }) : []); },
|
|
3984
|
-
bindPersistData: function (shops) { return ({ shop_availabilities: { data: shops.map(function (shop) { return ({ shop: shop }); }) } }); },
|
|
3985
|
-
},
|
|
3986
|
-
},
|
|
3987
3888
|
{ tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
|
|
3988
3889
|
{ isKit: { columnName: 'is_kit' } },
|
|
3989
3890
|
{ createdAt: { columnName: 'created_at' } },
|
|
@@ -3995,7 +3896,6 @@
|
|
|
3995
3896
|
from: function (value) { return value.aggregate.avg.rate; },
|
|
3996
3897
|
},
|
|
3997
3898
|
},
|
|
3998
|
-
{ shoppingCount: { columnName: 'shopping_count' } },
|
|
3999
3899
|
];
|
|
4000
3900
|
_this.fields = __spreadArray(__spreadArray([], __read(commonFields)), [
|
|
4001
3901
|
{
|
|
@@ -4022,10 +3922,12 @@
|
|
|
4022
3922
|
},
|
|
4023
3923
|
},
|
|
4024
3924
|
{
|
|
4025
|
-
|
|
4026
|
-
columnName: '
|
|
4027
|
-
|
|
4028
|
-
|
|
3925
|
+
metadata: {
|
|
3926
|
+
columnName: 'metadata',
|
|
3927
|
+
fields: ['title', 'description'],
|
|
3928
|
+
bindPersistData: function (value) { return ({
|
|
3929
|
+
metadata: { data: value },
|
|
3930
|
+
}); },
|
|
4029
3931
|
},
|
|
4030
3932
|
},
|
|
4031
3933
|
]);
|
|
@@ -4058,32 +3960,27 @@
|
|
|
4058
3960
|
create: { get: function () { return _super_1.prototype.create; } }
|
|
4059
3961
|
});
|
|
4060
3962
|
return __awaiter(this, void 0, void 0, function () {
|
|
4061
|
-
var product, _c,
|
|
4062
|
-
return __generator(this, function (
|
|
4063
|
-
switch (
|
|
3963
|
+
var product, _c, error_1;
|
|
3964
|
+
return __generator(this, function (_d) {
|
|
3965
|
+
switch (_d.label) {
|
|
4064
3966
|
case 0: return [4 /*yield*/, _super.create.call(this, lodash.omit(data, ['reviews']))];
|
|
4065
3967
|
case 1:
|
|
4066
|
-
product =
|
|
4067
|
-
|
|
3968
|
+
product = _d.sent();
|
|
3969
|
+
_d.label = 2;
|
|
4068
3970
|
case 2:
|
|
4069
|
-
|
|
3971
|
+
_d.trys.push([2, 4, , 6]);
|
|
4070
3972
|
_c = product;
|
|
4071
|
-
_d = data.reviews;
|
|
4072
|
-
if (!_d) return [3 /*break*/, 4];
|
|
4073
3973
|
return [4 /*yield*/, this.updateReviews(+product.id, data)];
|
|
4074
3974
|
case 3:
|
|
4075
|
-
|
|
4076
|
-
|
|
3975
|
+
_c.reviews = _d.sent();
|
|
3976
|
+
return [3 /*break*/, 6];
|
|
4077
3977
|
case 4:
|
|
4078
|
-
|
|
4079
|
-
return [3 /*break*/, 7];
|
|
4080
|
-
case 5:
|
|
4081
|
-
error_1 = _e.sent();
|
|
3978
|
+
error_1 = _d.sent();
|
|
4082
3979
|
return [4 /*yield*/, this.delete({ id: product.id })];
|
|
4083
|
-
case
|
|
4084
|
-
|
|
3980
|
+
case 5:
|
|
3981
|
+
_d.sent();
|
|
4085
3982
|
throw error_1;
|
|
4086
|
-
case
|
|
3983
|
+
case 6: return [2 /*return*/, product];
|
|
4087
3984
|
}
|
|
4088
3985
|
});
|
|
4089
3986
|
});
|
|
@@ -4094,32 +3991,27 @@
|
|
|
4094
3991
|
});
|
|
4095
3992
|
var _a;
|
|
4096
3993
|
return __awaiter(this, void 0, void 0, function () {
|
|
4097
|
-
var product, _c, _d
|
|
4098
|
-
return __generator(this, function (
|
|
4099
|
-
switch (
|
|
3994
|
+
var product, _c, _d;
|
|
3995
|
+
return __generator(this, function (_e) {
|
|
3996
|
+
switch (_e.label) {
|
|
4100
3997
|
case 0:
|
|
4101
3998
|
if (!Number.isNaN(+identifiers.id)) return [3 /*break*/, 2];
|
|
4102
3999
|
return [4 /*yield*/, this.find({ filters: { firestoreId: identifiers.id } })];
|
|
4103
4000
|
case 1:
|
|
4104
|
-
_c = (_a = (
|
|
4001
|
+
_c = (_a = (_e.sent()).data) === null || _a === void 0 ? void 0 : _a[0];
|
|
4105
4002
|
return [3 /*break*/, 4];
|
|
4106
4003
|
case 2: return [4 /*yield*/, _super.get.call(this, identifiers)];
|
|
4107
4004
|
case 3:
|
|
4108
|
-
_c =
|
|
4109
|
-
|
|
4005
|
+
_c = _e.sent();
|
|
4006
|
+
_e.label = 4;
|
|
4110
4007
|
case 4:
|
|
4111
4008
|
product = _c;
|
|
4112
4009
|
if (product.productId)
|
|
4113
4010
|
throw new NotFoundError('Product not found, it is a variant');
|
|
4114
4011
|
_d = product;
|
|
4115
|
-
_e = product.reviews;
|
|
4116
|
-
if (_e) return [3 /*break*/, 6];
|
|
4117
4012
|
return [4 /*yield*/, this.findReviewsByProduct(+product.id)];
|
|
4118
4013
|
case 5:
|
|
4119
|
-
|
|
4120
|
-
_f.label = 6;
|
|
4121
|
-
case 6:
|
|
4122
|
-
_d.reviews = _e;
|
|
4014
|
+
_d.reviews = _e.sent();
|
|
4123
4015
|
return [2 /*return*/, product];
|
|
4124
4016
|
}
|
|
4125
4017
|
});
|
|
@@ -4130,14 +4022,10 @@
|
|
|
4130
4022
|
find: { get: function () { return _super_1.prototype.find; } }
|
|
4131
4023
|
});
|
|
4132
4024
|
return __awaiter(this, void 0, void 0, function () {
|
|
4133
|
-
var _a, filters,
|
|
4025
|
+
var _a, filters, options;
|
|
4134
4026
|
return __generator(this, function (_c) {
|
|
4135
|
-
_a = params || {}, filters = _a.filters,
|
|
4136
|
-
|
|
4137
|
-
this.fields
|
|
4138
|
-
.map(function (field) { return (typeof field === 'string' ? field : Object.keys(field).shift()); })
|
|
4139
|
-
.filter(function (field) { return field !== 'reviews'; });
|
|
4140
|
-
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 }))];
|
|
4027
|
+
_a = params || {}, filters = _a.filters, options = __rest(_a, ["filters"]);
|
|
4028
|
+
return [2 /*return*/, _super.find.call(this, Object.assign(Object.assign({}, options), { filters: Object.assign(Object.assign({}, filters), { productId: { operator: exports.Where.ISNULL } }) }))];
|
|
4141
4029
|
});
|
|
4142
4030
|
});
|
|
4143
4031
|
};
|
|
@@ -4169,11 +4057,11 @@
|
|
|
4169
4057
|
update: { get: function () { return _super_1.prototype.update; } }
|
|
4170
4058
|
});
|
|
4171
4059
|
return __awaiter(this, void 0, void 0, function () {
|
|
4172
|
-
var categories, kitProducts, reviews, checkId,
|
|
4060
|
+
var categories, kitProducts, reviews, checkId, rate, data, plainData, id, product, _c, _d, _e, _f, _g, _h;
|
|
4173
4061
|
return __generator(this, function (_j) {
|
|
4174
4062
|
switch (_j.label) {
|
|
4175
4063
|
case 0:
|
|
4176
|
-
categories = params.categories, kitProducts = params.kitProducts, reviews = params.reviews, checkId = params.id,
|
|
4064
|
+
categories = params.categories, kitProducts = params.kitProducts, reviews = params.reviews, checkId = params.id, rate = params.rate, data = __rest(params, ["categories", "kitProducts", "reviews", "id", "rate"]);
|
|
4177
4065
|
plainData = this.paramsToPlain({ id: checkId });
|
|
4178
4066
|
return [4 /*yield*/, this.getId(plainData.id)];
|
|
4179
4067
|
case 1:
|
|
@@ -4215,18 +4103,18 @@
|
|
|
4215
4103
|
};
|
|
4216
4104
|
ProductHasuraGraphQLRepository.prototype.fetchReviews = function (status) {
|
|
4217
4105
|
return __awaiter(this, void 0, void 0, function () {
|
|
4218
|
-
var
|
|
4106
|
+
var reviews, data;
|
|
4219
4107
|
var _c, _d;
|
|
4220
4108
|
var _this = this;
|
|
4221
4109
|
return __generator(this, function (_e) {
|
|
4222
4110
|
switch (_e.label) {
|
|
4223
4111
|
case 0:
|
|
4224
|
-
|
|
4112
|
+
reviews = {
|
|
4225
4113
|
status: status === 'pending'
|
|
4226
4114
|
? (_c = {}, _c[HasuraGraphQLWhere.ISNULL] = true, _c) : (_d = {}, _d[HasuraGraphQLWhere.EQUALS] = status === 'approved', _d),
|
|
4227
4115
|
};
|
|
4228
4116
|
return [4 /*yield*/, this.query('product', ['id', 'name', 'sku', { reviews: { columnName: 'reviews', fields: this.reviewsFields } }], {
|
|
4229
|
-
where: { value: { reviews:
|
|
4117
|
+
where: { value: { reviews: reviews }, type: 'product_bool_exp', required: true },
|
|
4230
4118
|
})];
|
|
4231
4119
|
case 1:
|
|
4232
4120
|
data = (_e.sent()).product;
|
|
@@ -4246,21 +4134,7 @@
|
|
|
4246
4134
|
return __generator(this, function (_c) {
|
|
4247
4135
|
switch (_c.label) {
|
|
4248
4136
|
case 0:
|
|
4249
|
-
if (!('action' in categories && categories.action === 'remove')) return [3 /*break*/, 2];
|
|
4250
|
-
return [4 /*yield*/, this.mutation('delete_category_product', ['affected_rows'], {
|
|
4251
|
-
where: {
|
|
4252
|
-
type: 'category_product_bool_exp',
|
|
4253
|
-
required: true,
|
|
4254
|
-
value: { product_id: { _eq: productId } },
|
|
4255
|
-
},
|
|
4256
|
-
})];
|
|
4257
|
-
case 1:
|
|
4258
|
-
_c.sent();
|
|
4259
|
-
return [2 /*return*/, []];
|
|
4260
|
-
case 2:
|
|
4261
4137
|
plainData = this.paramsToPlain({ categories: categories });
|
|
4262
|
-
if (!plainData.categories || plainData.categories.length <= 0)
|
|
4263
|
-
return [2 /*return*/, []];
|
|
4264
4138
|
return [4 /*yield*/, this.mutation('delete_category_product', ['affected_rows'], {
|
|
4265
4139
|
where: {
|
|
4266
4140
|
type: 'category_product_bool_exp',
|
|
@@ -4268,7 +4142,7 @@
|
|
|
4268
4142
|
value: { product_id: { _eq: productId } },
|
|
4269
4143
|
},
|
|
4270
4144
|
})];
|
|
4271
|
-
case
|
|
4145
|
+
case 1:
|
|
4272
4146
|
_c.sent();
|
|
4273
4147
|
return [4 /*yield*/, this.mutation('insert_category_product', ['affected_rows'], {
|
|
4274
4148
|
objects: {
|
|
@@ -4277,7 +4151,7 @@
|
|
|
4277
4151
|
value: plainData.categories.map(function (categoryId) { return ({ category_id: categoryId, product_id: productId }); }),
|
|
4278
4152
|
},
|
|
4279
4153
|
})];
|
|
4280
|
-
case
|
|
4154
|
+
case 2:
|
|
4281
4155
|
_c.sent();
|
|
4282
4156
|
return [2 /*return*/, plainData.categories];
|
|
4283
4157
|
}
|
|
@@ -4327,6 +4201,8 @@
|
|
|
4327
4201
|
return __generator(this, function (_c) {
|
|
4328
4202
|
switch (_c.label) {
|
|
4329
4203
|
case 0:
|
|
4204
|
+
if (!reviews)
|
|
4205
|
+
return [2 /*return*/, []];
|
|
4330
4206
|
if (!('action' in reviews && reviews.action === 'remove')) return [3 /*break*/, 3];
|
|
4331
4207
|
return [4 /*yield*/, Promise.all(reviews.value.map(function (reviewData) { return __awaiter(_this, void 0, void 0, function () {
|
|
4332
4208
|
var review;
|
|
@@ -4349,8 +4225,6 @@
|
|
|
4349
4225
|
return [2 /*return*/, reviews.value.map(function (review, index) { return !reviewIds_1[index] && review; }).filter(Boolean)];
|
|
4350
4226
|
case 3:
|
|
4351
4227
|
plainData = this.paramsToPlain({ reviews: reviews });
|
|
4352
|
-
if (!plainData.reviews || plainData.reviews.length <= 0)
|
|
4353
|
-
return [2 /*return*/, []];
|
|
4354
4228
|
return [2 /*return*/, Promise.all(plainData.reviews.map(function (reviewData) { return __awaiter(_this, void 0, void 0, function () {
|
|
4355
4229
|
var review, _c, _d;
|
|
4356
4230
|
return __generator(this, function (_e) {
|
|
@@ -4520,15 +4394,12 @@
|
|
|
4520
4394
|
{
|
|
4521
4395
|
price: {
|
|
4522
4396
|
columnName: 'price',
|
|
4523
|
-
from: function (price, data) { return
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
subscriberPrice: data.subscriber_price,
|
|
4530
|
-
}, _c)));
|
|
4531
|
-
}, {}); },
|
|
4397
|
+
from: function (price, data) { return ({
|
|
4398
|
+
price: price,
|
|
4399
|
+
fullPrice: data.full_price,
|
|
4400
|
+
subscriberDiscountPercentage: data.subscriber_discount_percentage,
|
|
4401
|
+
subscriberPrice: data.subscriber_price,
|
|
4402
|
+
}); },
|
|
4532
4403
|
bindFindFilter: function (sentence) {
|
|
4533
4404
|
var filters = Object.values(sentence).shift();
|
|
4534
4405
|
return Object.assign(Object.assign(Object.assign(Object.assign({}, (((filters === null || filters === void 0 ? void 0 : filters.price) || (filters === null || filters === void 0 ? void 0 : filters.price) === 0) && { price: filters.price })), ((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice })), ((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
|
|
@@ -4537,12 +4408,9 @@
|
|
|
4537
4408
|
subscriber_price: filters.subscriberPrice,
|
|
4538
4409
|
}));
|
|
4539
4410
|
},
|
|
4540
|
-
bindPersistData: function (
|
|
4541
|
-
|
|
4542
|
-
|
|
4543
|
-
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
4544
|
-
})), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }));
|
|
4545
|
-
},
|
|
4411
|
+
bindPersistData: function (priceData) { return (Object.assign(Object.assign(Object.assign(Object.assign({}, ((priceData === null || priceData === void 0 ? void 0 : priceData.price) >= 0 && { price: priceData.price })), (priceData.fullPrice >= 0 && { full_price: priceData.fullPrice })), (priceData.subscriberDiscountPercentage >= 0 && {
|
|
4412
|
+
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
4413
|
+
})), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }))); },
|
|
4546
4414
|
},
|
|
4547
4415
|
},
|
|
4548
4416
|
{ fullPrice: { columnName: 'full_price' } },
|
|
@@ -4826,6 +4694,7 @@
|
|
|
4826
4694
|
exports.UserFirestoreRepository = UserFirestoreRepository;
|
|
4827
4695
|
exports.UserPaymentMethod = UserPaymentMethod;
|
|
4828
4696
|
exports.UserPaymentMethodFirestoreRepository = UserPaymentMethodFirestoreRepository;
|
|
4697
|
+
exports.UserSearchFirestoreRepository = UserSearchFirestoreRepository;
|
|
4829
4698
|
exports.Variant = Variant;
|
|
4830
4699
|
exports.VariantHasuraGraphQL = VariantHasuraGraphQL;
|
|
4831
4700
|
exports.VariantHasuraGraphQLRepository = VariantHasuraGraphQLRepository;
|