@infrab4a/connect 3.15.0-beta.1 → 3.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/infrab4a-connect.umd.js +706 -227
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/domain/catalog/models/category-base.d.ts +30 -0
- package/domain/catalog/models/category-filter.d.ts +2 -0
- package/domain/catalog/models/category-for-product.d.ts +5 -0
- package/domain/catalog/models/category.d.ts +5 -27
- package/domain/catalog/models/index.d.ts +1 -0
- package/domain/catalog/models/kit-product.d.ts +3 -3
- package/domain/catalog/models/product-base.d.ts +40 -0
- package/domain/catalog/models/product-for-category.d.ts +7 -0
- package/domain/catalog/models/product-for-kit.d.ts +7 -0
- package/domain/catalog/models/product.d.ts +5 -40
- package/domain/catalog/models/wishlist.d.ts +6 -0
- package/domain/catalog/repositories/category-filter.repository.d.ts +1 -0
- package/domain/catalog/repositories/index.d.ts +1 -0
- package/domain/catalog/repositories/product.repository.d.ts +1 -1
- package/domain/catalog/repositories/wishlist.repository.d.ts +6 -0
- package/domain/generic/repository/find.repository.d.ts +1 -0
- package/domain/generic/repository/types/repository-find-result.type.d.ts +3 -0
- package/domain/shop-settings/enums/index.d.ts +0 -1
- package/domain/shop-settings/models/index.d.ts +0 -2
- package/domain/shop-settings/models/shop-settings.d.ts +1 -2
- package/domain/shop-settings/models/types/index.d.ts +0 -4
- package/domain/shop-settings/models/types/shop-section.type.d.ts +0 -3
- package/domain/shop-settings/repositories/index.d.ts +0 -2
- package/esm2015/domain/catalog/models/category-base.js +18 -0
- package/esm2015/domain/catalog/models/category-filter.js +6 -1
- package/esm2015/domain/catalog/models/category-for-product.js +7 -0
- package/esm2015/domain/catalog/models/category.js +6 -10
- package/esm2015/domain/catalog/models/index.js +2 -1
- package/esm2015/domain/catalog/models/kit-product.js +6 -6
- package/esm2015/domain/catalog/models/product-base.js +25 -0
- package/esm2015/domain/catalog/models/product-for-category.js +14 -0
- package/esm2015/domain/catalog/models/product-for-kit.js +14 -0
- package/esm2015/domain/catalog/models/product.js +6 -24
- package/esm2015/domain/catalog/models/wishlist.js +7 -0
- package/esm2015/domain/catalog/repositories/category-filter.repository.js +1 -1
- package/esm2015/domain/catalog/repositories/index.js +2 -1
- package/esm2015/domain/catalog/repositories/product.repository.js +1 -1
- package/esm2015/domain/catalog/repositories/wishlist.repository.js +2 -0
- package/esm2015/domain/generic/repository/find.repository.js +1 -1
- package/esm2015/domain/generic/repository/types/repository-find-result.type.js +1 -1
- package/esm2015/domain/shop-settings/enums/index.js +1 -2
- package/esm2015/domain/shop-settings/models/index.js +1 -3
- package/esm2015/domain/shop-settings/models/shop-settings.js +1 -1
- package/esm2015/domain/shop-settings/models/types/index.js +1 -5
- package/esm2015/domain/shop-settings/models/types/shop-section.type.js +1 -1
- package/esm2015/domain/shop-settings/repositories/index.js +1 -3
- package/esm2015/infra/elasticsearch/indexes/products-index.js +2 -2
- package/esm2015/infra/firebase/firestore/repositories/shop-settings/index.js +1 -3
- package/esm2015/infra/hasura-graphql/mixins/helpers/bind-filter-query.helper.js +2 -2
- package/esm2015/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.js +44 -14
- package/esm2015/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.js +52 -1
- package/esm2015/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.js +36 -50
- package/esm2015/infra/hasura-graphql/repositories/catalog/index.js +2 -1
- package/esm2015/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.js +2 -2
- package/esm2015/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.js +252 -0
- package/esm2015/infra/hasura-graphql/types/graphql.repository.type.js +1 -1
- package/fesm2015/infrab4a-connect.js +469 -155
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/infra/firebase/firestore/repositories/shop-settings/index.d.ts +0 -2
- package/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +3 -2
- package/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.d.ts +2 -2
- package/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.d.ts +1 -0
- package/infra/hasura-graphql/repositories/catalog/index.d.ts +1 -0
- package/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.d.ts +27 -0
- package/infra/hasura-graphql/types/graphql.repository.type.d.ts +4 -3
- package/package.json +1 -1
- package/domain/shop-settings/enums/shop-page-name.enum.d.ts +0 -19
- package/domain/shop-settings/models/campaign-banner.d.ts +0 -11
- package/domain/shop-settings/models/campaign.d.ts +0 -10
- package/domain/shop-settings/models/types/campaign-page.d.ts +0 -17
- package/domain/shop-settings/models/types/sections.type.d.ts +0 -17
- package/domain/shop-settings/models/types/shop-gift.type.d.ts +0 -8
- package/domain/shop-settings/models/types/shop-post.type.d.ts +0 -7
- package/domain/shop-settings/repositories/campaign-banner.repository.d.ts +0 -4
- package/domain/shop-settings/repositories/campaign.repository.d.ts +0 -4
- package/esm2015/domain/shop-settings/enums/shop-page-name.enum.js +0 -21
- package/esm2015/domain/shop-settings/models/campaign-banner.js +0 -7
- package/esm2015/domain/shop-settings/models/campaign.js +0 -7
- package/esm2015/domain/shop-settings/models/types/campaign-page.js +0 -2
- package/esm2015/domain/shop-settings/models/types/sections.type.js +0 -2
- package/esm2015/domain/shop-settings/models/types/shop-gift.type.js +0 -2
- package/esm2015/domain/shop-settings/models/types/shop-post.type.js +0 -2
- package/esm2015/domain/shop-settings/repositories/campaign-banner.repository.js +0 -2
- package/esm2015/domain/shop-settings/repositories/campaign.repository.js +0 -2
- package/esm2015/infra/firebase/firestore/repositories/shop-settings/campaign-banner-firestore.repository.js +0 -12
- package/esm2015/infra/firebase/firestore/repositories/shop-settings/campaign-firestore.repository.js +0 -12
- package/infra/firebase/firestore/repositories/shop-settings/campaign-banner-firestore.repository.d.ts +0 -8
- package/infra/firebase/firestore/repositories/shop-settings/campaign-firestore.repository.d.ts +0 -8
|
@@ -1193,19 +1193,93 @@ class Filter extends BaseModel {
|
|
|
1193
1193
|
}
|
|
1194
1194
|
}
|
|
1195
1195
|
|
|
1196
|
-
class
|
|
1196
|
+
class CategoryBase extends BaseModel {
|
|
1197
1197
|
static get identifiersFields() {
|
|
1198
1198
|
return ['id'];
|
|
1199
1199
|
}
|
|
1200
1200
|
}
|
|
1201
1201
|
__decorate([
|
|
1202
|
-
Type(() =>
|
|
1203
|
-
__metadata("design:type",
|
|
1204
|
-
],
|
|
1202
|
+
Type(() => CategoryBase),
|
|
1203
|
+
__metadata("design:type", CategoryBase)
|
|
1204
|
+
], CategoryBase.prototype, "parent", void 0);
|
|
1205
1205
|
__decorate([
|
|
1206
1206
|
Type(() => Filter),
|
|
1207
1207
|
__metadata("design:type", Array)
|
|
1208
|
-
],
|
|
1208
|
+
], CategoryBase.prototype, "filters", void 0);
|
|
1209
|
+
|
|
1210
|
+
class CategoryForProduct extends CategoryBase {
|
|
1211
|
+
static get identifiersFields() {
|
|
1212
|
+
return ['id'];
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
class ProductBase extends BaseModel {
|
|
1217
|
+
get evaluation() {
|
|
1218
|
+
return {
|
|
1219
|
+
reviews: this.reviews,
|
|
1220
|
+
count: this.reviewsTotal,
|
|
1221
|
+
rating: this.rate,
|
|
1222
|
+
};
|
|
1223
|
+
}
|
|
1224
|
+
set evaluation(evaluation) {
|
|
1225
|
+
if (!evaluation) {
|
|
1226
|
+
this.reviews = null;
|
|
1227
|
+
this.reviewsTotal = null;
|
|
1228
|
+
this.rate = null;
|
|
1229
|
+
return;
|
|
1230
|
+
}
|
|
1231
|
+
this.reviews = evaluation.reviews || this.reviews;
|
|
1232
|
+
this.reviewsTotal = evaluation.count || this.reviewsTotal;
|
|
1233
|
+
this.rate = evaluation.rating || this.rate;
|
|
1234
|
+
}
|
|
1235
|
+
static get identifiersFields() {
|
|
1236
|
+
return ['id'];
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
class ProductForKit extends ProductBase {
|
|
1241
|
+
static get identifiersFields() {
|
|
1242
|
+
return ['id'];
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
__decorate([
|
|
1246
|
+
Type(() => CategoryForProduct),
|
|
1247
|
+
__metadata("design:type", CategoryForProduct)
|
|
1248
|
+
], ProductForKit.prototype, "category", void 0);
|
|
1249
|
+
|
|
1250
|
+
class KitProduct extends BaseModel {
|
|
1251
|
+
static get identifiersFields() {
|
|
1252
|
+
return ['productId', 'kitProductId'];
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
__decorate([
|
|
1256
|
+
Type(() => ProductForKit),
|
|
1257
|
+
__metadata("design:type", ProductForKit)
|
|
1258
|
+
], KitProduct.prototype, "kit", void 0);
|
|
1259
|
+
__decorate([
|
|
1260
|
+
Type(() => ProductForKit),
|
|
1261
|
+
__metadata("design:type", ProductForKit)
|
|
1262
|
+
], KitProduct.prototype, "product", void 0);
|
|
1263
|
+
|
|
1264
|
+
class ProductForCategory extends ProductBase {
|
|
1265
|
+
static get identifiersFields() {
|
|
1266
|
+
return ['id'];
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
__decorate([
|
|
1270
|
+
Type(() => KitProduct),
|
|
1271
|
+
__metadata("design:type", Array)
|
|
1272
|
+
], ProductForCategory.prototype, "kitProducts", void 0);
|
|
1273
|
+
|
|
1274
|
+
class Category extends CategoryBase {
|
|
1275
|
+
static get identifiersFields() {
|
|
1276
|
+
return ['id'];
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
__decorate([
|
|
1280
|
+
Type(() => ProductForCategory),
|
|
1281
|
+
__metadata("design:type", Array)
|
|
1282
|
+
], Category.prototype, "childrenProducts", void 0);
|
|
1209
1283
|
|
|
1210
1284
|
class CategoryCollectionChildren extends BaseModel {
|
|
1211
1285
|
static get identifiersFields() {
|
|
@@ -1226,6 +1300,10 @@ __decorate([
|
|
|
1226
1300
|
Type(() => Filter),
|
|
1227
1301
|
__metadata("design:type", Filter)
|
|
1228
1302
|
], CategoryFilter.prototype, "filter", void 0);
|
|
1303
|
+
__decorate([
|
|
1304
|
+
Type(() => Category),
|
|
1305
|
+
__metadata("design:type", Category)
|
|
1306
|
+
], CategoryFilter.prototype, "category", void 0);
|
|
1229
1307
|
|
|
1230
1308
|
var GenderDestination;
|
|
1231
1309
|
(function (GenderDestination) {
|
|
@@ -1248,55 +1326,29 @@ class FilterOption extends BaseModel {
|
|
|
1248
1326
|
}
|
|
1249
1327
|
}
|
|
1250
1328
|
|
|
1251
|
-
class Product extends
|
|
1252
|
-
get evaluation() {
|
|
1253
|
-
return {
|
|
1254
|
-
reviews: this.reviews,
|
|
1255
|
-
count: this.reviewsTotal,
|
|
1256
|
-
rating: this.rate,
|
|
1257
|
-
};
|
|
1258
|
-
}
|
|
1259
|
-
set evaluation(evaluation) {
|
|
1260
|
-
if (!evaluation) {
|
|
1261
|
-
this.reviews = null;
|
|
1262
|
-
this.reviewsTotal = null;
|
|
1263
|
-
this.rate = null;
|
|
1264
|
-
return;
|
|
1265
|
-
}
|
|
1266
|
-
this.reviews = evaluation.reviews || this.reviews;
|
|
1267
|
-
this.reviewsTotal = evaluation.count || this.reviewsTotal;
|
|
1268
|
-
this.rate = evaluation.rating || this.rate;
|
|
1269
|
-
}
|
|
1329
|
+
class Product extends ProductBase {
|
|
1270
1330
|
static get identifiersFields() {
|
|
1271
1331
|
return ['id'];
|
|
1272
1332
|
}
|
|
1273
1333
|
}
|
|
1274
1334
|
__decorate([
|
|
1275
|
-
Type(() =>
|
|
1276
|
-
__metadata("design:type",
|
|
1335
|
+
Type(() => CategoryForProduct),
|
|
1336
|
+
__metadata("design:type", CategoryForProduct)
|
|
1277
1337
|
], Product.prototype, "category", void 0);
|
|
1278
1338
|
__decorate([
|
|
1279
1339
|
Type(() => KitProduct),
|
|
1280
1340
|
__metadata("design:type", Array)
|
|
1281
1341
|
], Product.prototype, "kitProducts", void 0);
|
|
1282
1342
|
|
|
1283
|
-
class
|
|
1343
|
+
class Variant extends BaseModel {
|
|
1284
1344
|
static get identifiersFields() {
|
|
1285
|
-
return ['
|
|
1345
|
+
return ['id', 'productId'];
|
|
1286
1346
|
}
|
|
1287
1347
|
}
|
|
1288
|
-
__decorate([
|
|
1289
|
-
Type(() => Product),
|
|
1290
|
-
__metadata("design:type", Product)
|
|
1291
|
-
], KitProduct.prototype, "kit", void 0);
|
|
1292
|
-
__decorate([
|
|
1293
|
-
Type(() => Product),
|
|
1294
|
-
__metadata("design:type", Product)
|
|
1295
|
-
], KitProduct.prototype, "product", void 0);
|
|
1296
1348
|
|
|
1297
|
-
class
|
|
1349
|
+
class Wishlist extends Category {
|
|
1298
1350
|
static get identifiersFields() {
|
|
1299
|
-
return ['id'
|
|
1351
|
+
return ['id'];
|
|
1300
1352
|
}
|
|
1301
1353
|
}
|
|
1302
1354
|
|
|
@@ -1458,27 +1510,6 @@ var QuestionsFilters;
|
|
|
1458
1510
|
QuestionsFilters["PRODUCT_SPENT"] = "Qual \u00E9 o seu nivel de gasto mensal em produtos de beleza e cuidados pessoais?";
|
|
1459
1511
|
})(QuestionsFilters || (QuestionsFilters = {}));
|
|
1460
1512
|
|
|
1461
|
-
var ShopPageName;
|
|
1462
|
-
(function (ShopPageName) {
|
|
1463
|
-
ShopPageName["LP_CLUB"] = "LP_CLUBE";
|
|
1464
|
-
ShopPageName["SUBSCRIBER_PANEL"] = "SUBSCRIBER_PANEL";
|
|
1465
|
-
ShopPageName["INVITE_FRIENDS"] = "INVITE_FRIENDS";
|
|
1466
|
-
ShopPageName["INVITE_AND_WIN"] = "INVITE_AND_WIN";
|
|
1467
|
-
ShopPageName["WIN_GLAMPOINTS"] = "WIN_GLAMPOINTS";
|
|
1468
|
-
ShopPageName["POSTS"] = "POSTS";
|
|
1469
|
-
ShopPageName["GLAMPOINTS_SHOWCASE"] = "GLAMPOINTS_SHOWCASE";
|
|
1470
|
-
ShopPageName["LP_EDITIONS"] = "LP_EDITIONS";
|
|
1471
|
-
ShopPageName["LP_GLAMBOX_EDITION"] = "LP_GLAMBOX_EDITION";
|
|
1472
|
-
ShopPageName["LP_GLAMBOX_PROMOTION"] = "LP_GLAMBOX_PROMOTION";
|
|
1473
|
-
ShopPageName["LP_GLAMBAG_PROMOTION"] = "LP_GLAMBAG_PROMOTION";
|
|
1474
|
-
ShopPageName["LP_GLAMPASS_PROMOTION"] = "LP_GLAMPASS_PROMOTION";
|
|
1475
|
-
ShopPageName["LP_SUBSCRIPTION_PROMOTION"] = "LP_SUBSCRIPTION_PROMOTION";
|
|
1476
|
-
ShopPageName["LP_GLAMPARTNER_PROMOTION"] = "LP_GLAMPARTNER_PROMOTION";
|
|
1477
|
-
ShopPageName["LP_GLAMQUEENS"] = "LP_GLAMQUEENS";
|
|
1478
|
-
ShopPageName["LP_INVITE"] = "LP_INVITE";
|
|
1479
|
-
ShopPageName["LP_LIVELO"] = "LP_LIVELO";
|
|
1480
|
-
})(ShopPageName || (ShopPageName = {}));
|
|
1481
|
-
|
|
1482
1513
|
class BeautyQuestionsHelper {
|
|
1483
1514
|
static getAnswers(filter) {
|
|
1484
1515
|
switch (filter) {
|
|
@@ -1523,18 +1554,6 @@ class BeautyQuestionsHelper {
|
|
|
1523
1554
|
}
|
|
1524
1555
|
}
|
|
1525
1556
|
|
|
1526
|
-
class Campaign extends BaseModel {
|
|
1527
|
-
static get identifiersFields() {
|
|
1528
|
-
return ['id'];
|
|
1529
|
-
}
|
|
1530
|
-
}
|
|
1531
|
-
|
|
1532
|
-
class CampaignBanner extends BaseModel {
|
|
1533
|
-
static get identifiersFields() {
|
|
1534
|
-
return ['id'];
|
|
1535
|
-
}
|
|
1536
|
-
}
|
|
1537
|
-
|
|
1538
1557
|
class Home extends BaseModel {
|
|
1539
1558
|
static get identifiersFields() {
|
|
1540
1559
|
return ['id'];
|
|
@@ -1668,7 +1687,7 @@ class ProductsIndex {
|
|
|
1668
1687
|
}
|
|
1669
1688
|
search(searchTerm, total, shop) {
|
|
1670
1689
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1671
|
-
const size = total
|
|
1690
|
+
const size = total || 9;
|
|
1672
1691
|
const fields = [
|
|
1673
1692
|
'EAN',
|
|
1674
1693
|
'brand',
|
|
@@ -2496,24 +2515,6 @@ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(
|
|
|
2496
2515
|
}
|
|
2497
2516
|
}
|
|
2498
2517
|
|
|
2499
|
-
class CampaignBannerFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2500
|
-
constructor(firestore) {
|
|
2501
|
-
super();
|
|
2502
|
-
this.firestore = firestore;
|
|
2503
|
-
this.collectionName = 'banners';
|
|
2504
|
-
this.model = CampaignBanner;
|
|
2505
|
-
}
|
|
2506
|
-
}
|
|
2507
|
-
|
|
2508
|
-
class CampaignFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2509
|
-
constructor(firestore) {
|
|
2510
|
-
super();
|
|
2511
|
-
this.firestore = firestore;
|
|
2512
|
-
this.collectionName = 'campaigns';
|
|
2513
|
-
this.model = Campaign;
|
|
2514
|
-
}
|
|
2515
|
-
}
|
|
2516
|
-
|
|
2517
2518
|
class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
|
|
2518
2519
|
constructor(firestore) {
|
|
2519
2520
|
super();
|
|
@@ -2759,7 +2760,7 @@ BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
|
|
|
2759
2760
|
const fieldOptions = AttributeOptionHelper.FindByAttribute(key, (fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.fields) || fields);
|
|
2760
2761
|
const columnName = fieldOptions.columnName;
|
|
2761
2762
|
const columnFields = fieldOptions.fields;
|
|
2762
|
-
return Object.assign(Object.assign({}, variables), { [columnName]: BindFilterQueryHelper.BuildWhereSentence(key, options[key], columnFields ||
|
|
2763
|
+
return Object.assign(Object.assign({}, variables), { [columnName]: BindFilterQueryHelper.BuildWhereSentence(key, options[key], (fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.fields) || columnFields || fields) });
|
|
2763
2764
|
}, {});
|
|
2764
2765
|
if (!Array.isArray(options) && !isNil(fieldSentenceOptions.fields))
|
|
2765
2766
|
return {
|
|
@@ -3170,17 +3171,27 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
3170
3171
|
: []),
|
|
3171
3172
|
];
|
|
3172
3173
|
};
|
|
3174
|
+
this.bindDistinctAttributes = (distinct, fields) => this.bindAttributesToColumns(distinct, fields);
|
|
3173
3175
|
this.bindAttributesToColumns = (attributes, fields) => attributes.map((attr) => {
|
|
3174
3176
|
var _a;
|
|
3175
3177
|
return ((_a = AttributeOptionHelper.FindByAttribute(attr.toString().split('.').pop(), fields)) === null || _a === void 0 ? void 0 : _a.columnName) || attr;
|
|
3176
3178
|
});
|
|
3177
3179
|
}
|
|
3178
3180
|
find(params) {
|
|
3179
|
-
var _a, _b, _c;
|
|
3181
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
3180
3182
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3181
3183
|
this.logger = DebugHelper.from(this, 'find');
|
|
3182
3184
|
const { filters, limits, orderBy, options } = params || {};
|
|
3183
3185
|
const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
|
|
3186
|
+
const variablesFilters = isNil(filters)
|
|
3187
|
+
? {}
|
|
3188
|
+
: {
|
|
3189
|
+
where: {
|
|
3190
|
+
value: BindFilterQueryHelper.MakeGraphQLWhere(filters, this.fields),
|
|
3191
|
+
type: `${this.tableName}_bool_exp`,
|
|
3192
|
+
required: true,
|
|
3193
|
+
},
|
|
3194
|
+
};
|
|
3184
3195
|
const variablesCount = Object.assign(Object.assign({}, (isNil(orderBy)
|
|
3185
3196
|
? {}
|
|
3186
3197
|
: {
|
|
@@ -3189,15 +3200,7 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
3189
3200
|
list: true,
|
|
3190
3201
|
value: this.bindOrderByAttributes(orderBy, this.fields),
|
|
3191
3202
|
},
|
|
3192
|
-
})),
|
|
3193
|
-
? {}
|
|
3194
|
-
: {
|
|
3195
|
-
where: {
|
|
3196
|
-
value: BindFilterQueryHelper.MakeGraphQLWhere(filters, this.fields),
|
|
3197
|
-
type: `${this.tableName}_bool_exp`,
|
|
3198
|
-
required: true,
|
|
3199
|
-
},
|
|
3200
|
-
}));
|
|
3203
|
+
})), variablesFilters);
|
|
3201
3204
|
const variables = Object.assign(Object.assign({}, (isNil(limits) ? {} : limits)), variablesCount);
|
|
3202
3205
|
const aggregateFields = [
|
|
3203
3206
|
...(enableCount ? ['count'] : []),
|
|
@@ -3229,23 +3232,51 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
3229
3232
|
},
|
|
3230
3233
|
]
|
|
3231
3234
|
: []),
|
|
3235
|
+
...((!((_b = params.limits) === null || _b === void 0 ? void 0 : _b.offset) &&
|
|
3236
|
+
((_d = (_c = params.options) === null || _c === void 0 ? void 0 : _c.distinct) === null || _d === void 0 ? void 0 : _d.map((distinct) => {
|
|
3237
|
+
var _a, _b;
|
|
3238
|
+
const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === distinct)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === distinct);
|
|
3239
|
+
const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || distinct;
|
|
3240
|
+
return {
|
|
3241
|
+
operation: {
|
|
3242
|
+
name: `${this.tableName}`,
|
|
3243
|
+
alias: `${this.tableName}_${distinct}_distinct`,
|
|
3244
|
+
},
|
|
3245
|
+
fields: [distinctOption],
|
|
3246
|
+
variables: Object.assign(Object.assign({}, variablesFilters), { [`${this.tableName}_${fieldName}_distinct`]: {
|
|
3247
|
+
type: `${this.tableName}_select_column!`,
|
|
3248
|
+
list: true,
|
|
3249
|
+
value: fieldName,
|
|
3250
|
+
name: 'distinct_on',
|
|
3251
|
+
} }),
|
|
3252
|
+
};
|
|
3253
|
+
}))) ||
|
|
3254
|
+
[]),
|
|
3232
3255
|
]);
|
|
3233
3256
|
const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
|
|
3234
|
-
return Object.assign(Object.assign({ data, count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity }, (((
|
|
3257
|
+
return Object.assign(Object.assign(Object.assign({ data, count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity }, (((_e = options === null || options === void 0 ? void 0 : options.minimal) === null || _e === void 0 ? void 0 : _e.length)
|
|
3235
3258
|
? {
|
|
3236
3259
|
minimal: options.minimal.reduce((minimals, current) => {
|
|
3237
3260
|
var _a;
|
|
3238
3261
|
return (Object.assign(Object.assign({}, minimals), set(minimals, current, result[`${this.tableName}_aggregate`].aggregate.min[((_a = AttributeOptionHelper.FindByAttribute(current.toString().split('.').pop(), this.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || current])));
|
|
3239
3262
|
}, {}),
|
|
3240
3263
|
}
|
|
3241
|
-
: {})), (((
|
|
3264
|
+
: {})), (((_f = options === null || options === void 0 ? void 0 : options.maximum) === null || _f === void 0 ? void 0 : _f.length)
|
|
3242
3265
|
? {
|
|
3243
3266
|
maximum: options.maximum.reduce((maximums, current) => {
|
|
3244
3267
|
var _a;
|
|
3245
3268
|
return (Object.assign(Object.assign({}, maximums), set(maximums, current, result[`${this.tableName}_aggregate`].aggregate.max[((_a = AttributeOptionHelper.FindByAttribute(current.toString().split('.').pop(), this.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || current])));
|
|
3246
3269
|
}, {}),
|
|
3247
3270
|
}
|
|
3248
|
-
: {}))
|
|
3271
|
+
: {})), (!((_g = params.limits) === null || _g === void 0 ? void 0 : _g.offset) &&
|
|
3272
|
+
((_h = options === null || options === void 0 ? void 0 : options.distinct) === null || _h === void 0 ? void 0 : _h.length) && {
|
|
3273
|
+
distinct: options === null || options === void 0 ? void 0 : options.distinct.reduce((distinct, current) => {
|
|
3274
|
+
var _a, _b;
|
|
3275
|
+
const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === current)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === current);
|
|
3276
|
+
const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || current;
|
|
3277
|
+
return Object.assign(Object.assign({}, distinct), { [current.toString()]: result[`${this.tableName}_${current.toString()}_distinct`].map((obj) => obj[fieldName]) });
|
|
3278
|
+
}, {}),
|
|
3279
|
+
}));
|
|
3249
3280
|
});
|
|
3250
3281
|
}
|
|
3251
3282
|
};
|
|
@@ -3358,9 +3389,60 @@ class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
|
|
|
3358
3389
|
],
|
|
3359
3390
|
},
|
|
3360
3391
|
},
|
|
3392
|
+
{
|
|
3393
|
+
category: {
|
|
3394
|
+
columnName: 'category',
|
|
3395
|
+
foreignKeyColumn: { id: 'categoryId' },
|
|
3396
|
+
fields: [
|
|
3397
|
+
'id',
|
|
3398
|
+
'description',
|
|
3399
|
+
{
|
|
3400
|
+
products: {
|
|
3401
|
+
columnName: 'products',
|
|
3402
|
+
fields: ['product_id'],
|
|
3403
|
+
from: (value) => value.map((product) => product.product_id.toString()),
|
|
3404
|
+
to: (productIds) => productIds.map((productId) => ({
|
|
3405
|
+
product_id: +productId,
|
|
3406
|
+
})),
|
|
3407
|
+
},
|
|
3408
|
+
},
|
|
3409
|
+
{
|
|
3410
|
+
childrenProducts: {
|
|
3411
|
+
columnName: 'children_products',
|
|
3412
|
+
foreignKeyColumn: { category_id: 'id' },
|
|
3413
|
+
fields: [
|
|
3414
|
+
'id',
|
|
3415
|
+
'name',
|
|
3416
|
+
'slug',
|
|
3417
|
+
{
|
|
3418
|
+
categories: {
|
|
3419
|
+
columnName: 'categories',
|
|
3420
|
+
fields: ['category_id'],
|
|
3421
|
+
bindPersistData: (value) => ({
|
|
3422
|
+
categories: { data: value.map((category) => ({ category_id: +category })) },
|
|
3423
|
+
}),
|
|
3424
|
+
to: (categories) => categories.map((categoryId) => +categoryId),
|
|
3425
|
+
from: (categories) => (categories === null || categories === void 0 ? void 0 : categories.map((category) => { var _a; return (_a = category === null || category === void 0 ? void 0 : category.category_id) === null || _a === void 0 ? void 0 : _a.toString(); })) || [],
|
|
3426
|
+
},
|
|
3427
|
+
},
|
|
3428
|
+
],
|
|
3429
|
+
},
|
|
3430
|
+
},
|
|
3431
|
+
],
|
|
3432
|
+
},
|
|
3433
|
+
},
|
|
3361
3434
|
],
|
|
3362
3435
|
});
|
|
3363
3436
|
}
|
|
3437
|
+
deleteByCategory(categoryId) {
|
|
3438
|
+
return this.mutation('delete_category_filter', ['affected_rows'], {
|
|
3439
|
+
where: {
|
|
3440
|
+
type: 'category_filter_bool_exp',
|
|
3441
|
+
required: true,
|
|
3442
|
+
value: { category_id: { _eq: categoryId } },
|
|
3443
|
+
},
|
|
3444
|
+
});
|
|
3445
|
+
}
|
|
3364
3446
|
deleteByCategoryAndFilter(categoryId, filterId) {
|
|
3365
3447
|
return this.mutation('delete_category_filter', ['affected_rows'], {
|
|
3366
3448
|
where: {
|
|
@@ -3443,6 +3525,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3443
3525
|
},
|
|
3444
3526
|
},
|
|
3445
3527
|
{ isCollection: { columnName: 'is_collection' } },
|
|
3528
|
+
{ isWishlist: { columnName: 'is_wishlist' } },
|
|
3446
3529
|
'reference',
|
|
3447
3530
|
{ parentId: { columnName: 'parent_id' } },
|
|
3448
3531
|
{
|
|
@@ -3463,7 +3546,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3463
3546
|
});
|
|
3464
3547
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3465
3548
|
const { metadata } = params, data = __rest(params, ["metadata"]);
|
|
3466
|
-
return _super.create.call(this, Object.assign(Object.assign({}, data), { metadata: metadata || { description: null, title: null } }));
|
|
3549
|
+
return _super.create.call(this, Object.assign(Object.assign({}, data), { isWishlist: false, metadata: metadata || { description: null, title: null } }));
|
|
3467
3550
|
});
|
|
3468
3551
|
}
|
|
3469
3552
|
get(identifiers) {
|
|
@@ -3485,7 +3568,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3485
3568
|
const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
|
|
3486
3569
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
3487
3570
|
const id = yield this.getId(plainData.id);
|
|
3488
|
-
const category = yield _super.update.call(this, Object.assign({ id }, data));
|
|
3571
|
+
const category = yield _super.update.call(this, Object.assign(Object.assign({ id }, data), { isWishlist: false }));
|
|
3489
3572
|
category.products = products && (yield this.updateProducts(+id, { products }));
|
|
3490
3573
|
category.metadata = metadata && (yield this.updateMetadata(+id, { metadata }));
|
|
3491
3574
|
category.filters = filters && (yield this.updateFilters(+id, { filters }));
|
|
@@ -3501,6 +3584,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3501
3584
|
slug,
|
|
3502
3585
|
shops: { operator: Where.IN, value: [shop] },
|
|
3503
3586
|
published: { operator: Where.EQUALS, value: true },
|
|
3587
|
+
isWishlist: { operator: Where.EQUALS, value: false },
|
|
3504
3588
|
},
|
|
3505
3589
|
options: {
|
|
3506
3590
|
enableCount: false,
|
|
@@ -3521,6 +3605,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3521
3605
|
filters: {
|
|
3522
3606
|
shops: { operator: Where.IN, value: [shop] },
|
|
3523
3607
|
published: { operator: Where.EQUALS, value: true },
|
|
3608
|
+
isWishlist: { operator: Where.EQUALS, value: false },
|
|
3524
3609
|
},
|
|
3525
3610
|
options: {
|
|
3526
3611
|
enableCount: false,
|
|
@@ -3665,59 +3750,42 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3665
3750
|
}
|
|
3666
3751
|
if ('action' in filters && filters.action === 'merge' && filters.value.length) {
|
|
3667
3752
|
let filtersList = [];
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
filterId: filters.value[i].id,
|
|
3684
|
-
categoryId,
|
|
3685
|
-
});
|
|
3686
|
-
filtersList.push(newCategoryFilter);
|
|
3687
|
-
}
|
|
3688
|
-
}
|
|
3689
|
-
catch (error) {
|
|
3690
|
-
console.log('catch error: ', error);
|
|
3753
|
+
const currentFilters = yield this.categoryFilterRepository
|
|
3754
|
+
.find({
|
|
3755
|
+
filters: {
|
|
3756
|
+
categoryId,
|
|
3757
|
+
},
|
|
3758
|
+
})
|
|
3759
|
+
.then((res) => res.data);
|
|
3760
|
+
const currentFiltersId = currentFilters.map((f) => f.id);
|
|
3761
|
+
const filtersUpdatedId = filters.value.map((f) => f.id);
|
|
3762
|
+
const filterToBeDeleted = currentFiltersId.filter((c) => !filtersUpdatedId.includes(c));
|
|
3763
|
+
const filterToBeInserted = filtersUpdatedId.filter((c) => !currentFiltersId.includes(c));
|
|
3764
|
+
for (const filter of filterToBeDeleted) {
|
|
3765
|
+
const index = currentFilters.findIndex((f) => f.id == filter);
|
|
3766
|
+
if (index != -1) {
|
|
3767
|
+
currentFilters.splice(index, 1);
|
|
3691
3768
|
}
|
|
3769
|
+
yield this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filter);
|
|
3692
3770
|
}
|
|
3693
|
-
|
|
3771
|
+
for (const filter of filterToBeInserted) {
|
|
3772
|
+
const newCategoryFilter = yield this.categoryFilterRepository.create({
|
|
3773
|
+
filterId: filter,
|
|
3774
|
+
categoryId,
|
|
3775
|
+
});
|
|
3776
|
+
filtersList.push(newCategoryFilter);
|
|
3777
|
+
}
|
|
3778
|
+
return [...currentFilters, ...filtersList];
|
|
3694
3779
|
}
|
|
3695
3780
|
if (Array.isArray(filters) && filters.length) {
|
|
3781
|
+
yield this.categoryFilterRepository.deleteByCategory(categoryId);
|
|
3696
3782
|
let filtersList = [];
|
|
3697
3783
|
for (let i = 0; i < filters.length; i++) {
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
filterId: filters[i].id,
|
|
3704
|
-
},
|
|
3705
|
-
})
|
|
3706
|
-
.then((data) => data.data.shift());
|
|
3707
|
-
if (hasFilter) {
|
|
3708
|
-
filtersList.push(hasFilter);
|
|
3709
|
-
}
|
|
3710
|
-
else {
|
|
3711
|
-
const newCategoryFilter = yield this.categoryFilterRepository.create({
|
|
3712
|
-
filterId: filters[i].id,
|
|
3713
|
-
categoryId,
|
|
3714
|
-
});
|
|
3715
|
-
filtersList.push(newCategoryFilter);
|
|
3716
|
-
}
|
|
3717
|
-
}
|
|
3718
|
-
catch (error) {
|
|
3719
|
-
console.log('catch error: ', error);
|
|
3720
|
-
}
|
|
3784
|
+
const newCategoryFilter = yield this.categoryFilterRepository.create({
|
|
3785
|
+
filterId: filters[i].id,
|
|
3786
|
+
categoryId,
|
|
3787
|
+
});
|
|
3788
|
+
filtersList.push(newCategoryFilter);
|
|
3721
3789
|
}
|
|
3722
3790
|
return filtersList;
|
|
3723
3791
|
}
|
|
@@ -4180,7 +4248,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4180
4248
|
}
|
|
4181
4249
|
findCatalog(params, mainGender) {
|
|
4182
4250
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4183
|
-
return this.find(Object.assign(Object.assign({}, params), { filters: Object.assign(Object.assign({}, params.filters), { published: true }), orderBy: Object.assign({ hasStock: 'desc', intGender: mainGender === 'female' ? 'desc' : 'asc' }, omit(params.orderBy, ['hasStock', 'intGender'])) }));
|
|
4251
|
+
return this.find(Object.assign(Object.assign({}, params), { filters: Object.assign(Object.assign({}, params.filters), { published: true }), orderBy: Object.assign(Object.assign({ hasStock: 'desc' }, (!mainGender ? {} : { intGender: mainGender === 'female' ? 'desc' : 'asc' })), omit(params.orderBy, ['hasStock', 'intGender'])) }));
|
|
4184
4252
|
});
|
|
4185
4253
|
}
|
|
4186
4254
|
updateCategories(productId, { categories }) {
|
|
@@ -4489,9 +4557,255 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4489
4557
|
}
|
|
4490
4558
|
}
|
|
4491
4559
|
|
|
4560
|
+
class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
4561
|
+
constructor(endpoint, authOptions, categoryFilterRepository) {
|
|
4562
|
+
super({
|
|
4563
|
+
tableName: 'category',
|
|
4564
|
+
model: Wishlist,
|
|
4565
|
+
endpoint,
|
|
4566
|
+
authOptions,
|
|
4567
|
+
fields: [
|
|
4568
|
+
{ id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
|
|
4569
|
+
{ firestoreId: { columnName: 'firestore_id' } },
|
|
4570
|
+
'name',
|
|
4571
|
+
'description',
|
|
4572
|
+
'image',
|
|
4573
|
+
'published',
|
|
4574
|
+
'shop',
|
|
4575
|
+
{ shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4576
|
+
'slug',
|
|
4577
|
+
{ brandCategory: { columnName: 'brand_category' } },
|
|
4578
|
+
{ brandCategoryBanner: { columnName: 'brand_banner' } },
|
|
4579
|
+
{ brandCategoryBannerMobile: { columnName: 'brand_banner_mobile' } },
|
|
4580
|
+
{ brandLogo: { columnName: 'brand_logo' } },
|
|
4581
|
+
{ brandCondition: { columnName: 'brand_condition' } },
|
|
4582
|
+
{
|
|
4583
|
+
conditions: {
|
|
4584
|
+
columnName: 'tag_condition',
|
|
4585
|
+
type: HasuraGraphQLColumnType.Jsonb,
|
|
4586
|
+
from: (tags, row) => ({ brand: row.brand_condition, tags: Array.isArray(tags) ? tags : [] }),
|
|
4587
|
+
bindPersistData: (value) => {
|
|
4588
|
+
return {
|
|
4589
|
+
brand_condition: value.brand,
|
|
4590
|
+
tag_condition: (value === null || value === void 0 ? void 0 : value.tags) || [],
|
|
4591
|
+
};
|
|
4592
|
+
},
|
|
4593
|
+
bindFindFilter: (sentence) => {
|
|
4594
|
+
return Object.assign(Object.assign({}, (sentence.brand ? { brand_condition: sentence.brand } : {})), (sentence.tags ? { tag_condition: sentence.tags } : {}));
|
|
4595
|
+
},
|
|
4596
|
+
},
|
|
4597
|
+
},
|
|
4598
|
+
{
|
|
4599
|
+
filters: {
|
|
4600
|
+
columnName: 'filters',
|
|
4601
|
+
foreignKeyColumn: { filter_id: 'id' },
|
|
4602
|
+
fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
|
|
4603
|
+
bindPersistData: (value) => ({
|
|
4604
|
+
filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
|
|
4605
|
+
}),
|
|
4606
|
+
from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
|
|
4607
|
+
},
|
|
4608
|
+
},
|
|
4609
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
4610
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
4611
|
+
{
|
|
4612
|
+
products: {
|
|
4613
|
+
columnName: 'products',
|
|
4614
|
+
fields: ['product_id'],
|
|
4615
|
+
from: (value) => value.map((product) => product.product_id.toString()),
|
|
4616
|
+
to: (productIds) => productIds.map((productId) => ({
|
|
4617
|
+
product_id: +productId,
|
|
4618
|
+
})),
|
|
4619
|
+
},
|
|
4620
|
+
},
|
|
4621
|
+
{
|
|
4622
|
+
metadata: {
|
|
4623
|
+
columnName: 'metadata',
|
|
4624
|
+
fields: ['title', 'description'],
|
|
4625
|
+
bindPersistData: (value) => ({
|
|
4626
|
+
metadata: { data: value },
|
|
4627
|
+
}),
|
|
4628
|
+
},
|
|
4629
|
+
},
|
|
4630
|
+
{ isCollection: { columnName: 'is_collection' } },
|
|
4631
|
+
{ isWishlist: { columnName: 'is_wishlist' } },
|
|
4632
|
+
'reference',
|
|
4633
|
+
{ parentId: { columnName: 'parent_id' } },
|
|
4634
|
+
{
|
|
4635
|
+
parent: {
|
|
4636
|
+
columnName: 'parent',
|
|
4637
|
+
foreignKeyColumn: { id: 'parentId' },
|
|
4638
|
+
fields: ['id', 'name', 'reference', 'slug'],
|
|
4639
|
+
},
|
|
4640
|
+
},
|
|
4641
|
+
{ personId: { columnName: 'person_id' } },
|
|
4642
|
+
],
|
|
4643
|
+
});
|
|
4644
|
+
this.categoryFilterRepository = categoryFilterRepository;
|
|
4645
|
+
}
|
|
4646
|
+
create(params) {
|
|
4647
|
+
const _super = Object.create(null, {
|
|
4648
|
+
create: { get: () => super.create }
|
|
4649
|
+
});
|
|
4650
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4651
|
+
const { metadata } = params, data = __rest(params, ["metadata"]);
|
|
4652
|
+
return _super.create.call(this, Object.assign(Object.assign({}, data), { isWishlist: true, isCollection: true, brandCategory: false, metadata: metadata || { description: data.description, title: data.name } }));
|
|
4653
|
+
});
|
|
4654
|
+
}
|
|
4655
|
+
get(identifiers) {
|
|
4656
|
+
const _super = Object.create(null, {
|
|
4657
|
+
get: { get: () => super.get }
|
|
4658
|
+
});
|
|
4659
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4660
|
+
const data = yield _super.get.call(this, identifiers);
|
|
4661
|
+
if (!data.isWishlist)
|
|
4662
|
+
throw new NotFoundError(`Category with id ${identifiers.id} is not a wishlist`);
|
|
4663
|
+
return data;
|
|
4664
|
+
});
|
|
4665
|
+
}
|
|
4666
|
+
update(params) {
|
|
4667
|
+
const _super = Object.create(null, {
|
|
4668
|
+
update: { get: () => super.update }
|
|
4669
|
+
});
|
|
4670
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4671
|
+
const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
|
|
4672
|
+
const plainData = this.paramsToPlain({ id: checkId });
|
|
4673
|
+
const id = plainData.id;
|
|
4674
|
+
const category = yield _super.update.call(this, Object.assign(Object.assign({ id }, data), { isWishlist: true, isCollection: true, brandCategory: false }));
|
|
4675
|
+
category.products = products && (yield this.updateProducts(+id, { products }));
|
|
4676
|
+
category.metadata = metadata && (yield this.updateMetadata(+id, { metadata }));
|
|
4677
|
+
return category;
|
|
4678
|
+
});
|
|
4679
|
+
}
|
|
4680
|
+
getWishlistBySlug(slug) {
|
|
4681
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4682
|
+
if (!slug)
|
|
4683
|
+
return;
|
|
4684
|
+
const { data } = yield this.find({
|
|
4685
|
+
filters: {
|
|
4686
|
+
slug,
|
|
4687
|
+
isWishlist: { operator: Where.EQUALS, value: true },
|
|
4688
|
+
},
|
|
4689
|
+
options: {
|
|
4690
|
+
enableCount: false,
|
|
4691
|
+
},
|
|
4692
|
+
});
|
|
4693
|
+
if (!data.length)
|
|
4694
|
+
throw new NotFoundError(`Wishlist with slug ${slug} not found`);
|
|
4695
|
+
if (data.length > 1)
|
|
4696
|
+
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
4697
|
+
return data.shift();
|
|
4698
|
+
});
|
|
4699
|
+
}
|
|
4700
|
+
getWishlistByPerson(personId) {
|
|
4701
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4702
|
+
if (!personId)
|
|
4703
|
+
return;
|
|
4704
|
+
const { data } = yield this.find({
|
|
4705
|
+
filters: {
|
|
4706
|
+
personId: { operator: Where.EQUALS, value: personId },
|
|
4707
|
+
isWishlist: { operator: Where.EQUALS, value: true },
|
|
4708
|
+
},
|
|
4709
|
+
options: {
|
|
4710
|
+
enableCount: false,
|
|
4711
|
+
},
|
|
4712
|
+
});
|
|
4713
|
+
if (!data.length)
|
|
4714
|
+
throw new NotFoundError(`Wishlists from person ${personId} not found`);
|
|
4715
|
+
return data;
|
|
4716
|
+
});
|
|
4717
|
+
}
|
|
4718
|
+
updateProducts(categoryId, { products }) {
|
|
4719
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4720
|
+
if ('action' in products && products.action === 'remove') {
|
|
4721
|
+
yield this.mutation('delete_category_product', ['affected_rows'], {
|
|
4722
|
+
where: {
|
|
4723
|
+
type: 'category_product_bool_exp',
|
|
4724
|
+
required: true,
|
|
4725
|
+
value: { category_id: { _eq: categoryId } },
|
|
4726
|
+
},
|
|
4727
|
+
});
|
|
4728
|
+
yield this.categoryFilterRepository.deleteByCategory(categoryId);
|
|
4729
|
+
return [];
|
|
4730
|
+
}
|
|
4731
|
+
const plainData = this.paramsToPlain({ products });
|
|
4732
|
+
if (!plainData.products || plainData.products.length <= 0)
|
|
4733
|
+
return [];
|
|
4734
|
+
yield this.mutation('delete_category_product', ['affected_rows'], {
|
|
4735
|
+
where: {
|
|
4736
|
+
type: 'category_product_bool_exp',
|
|
4737
|
+
required: true,
|
|
4738
|
+
value: { category_id: { _eq: categoryId } },
|
|
4739
|
+
},
|
|
4740
|
+
});
|
|
4741
|
+
yield this.categoryFilterRepository.deleteByCategory(categoryId);
|
|
4742
|
+
yield this.mutation('insert_category_product', ['affected_rows'], {
|
|
4743
|
+
objects: {
|
|
4744
|
+
type: '[category_product_insert_input!]',
|
|
4745
|
+
required: true,
|
|
4746
|
+
value: plainData.products.map((productId) => ({ category_id: categoryId, product_id: productId })),
|
|
4747
|
+
},
|
|
4748
|
+
});
|
|
4749
|
+
return plainData.products;
|
|
4750
|
+
});
|
|
4751
|
+
}
|
|
4752
|
+
updateMetadata(categoryId, { metadata }) {
|
|
4753
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4754
|
+
const plainData = this.paramsToPlain({ metadata });
|
|
4755
|
+
if (!plainData.metadata)
|
|
4756
|
+
return;
|
|
4757
|
+
yield this.mutation('update_category_metadata_by_pk', ['category_id'], {
|
|
4758
|
+
pk_columns: {
|
|
4759
|
+
value: { category_id: categoryId },
|
|
4760
|
+
type: 'category_metadata_pk_columns_input',
|
|
4761
|
+
required: true,
|
|
4762
|
+
},
|
|
4763
|
+
_set: {
|
|
4764
|
+
value: omit(metadata, ['category_id']),
|
|
4765
|
+
type: 'category_metadata_set_input',
|
|
4766
|
+
required: true,
|
|
4767
|
+
},
|
|
4768
|
+
});
|
|
4769
|
+
return plainData.metadata;
|
|
4770
|
+
});
|
|
4771
|
+
}
|
|
4772
|
+
getCategoryBySlug(slug, _shop) {
|
|
4773
|
+
return this.getWishlistBySlug(slug);
|
|
4774
|
+
}
|
|
4775
|
+
getCategoryByShop(shop) {
|
|
4776
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4777
|
+
if (!shop)
|
|
4778
|
+
return;
|
|
4779
|
+
const { data } = yield this.find({
|
|
4780
|
+
filters: {
|
|
4781
|
+
shops: { operator: Where.IN, value: [shop] },
|
|
4782
|
+
published: { operator: Where.EQUALS, value: true },
|
|
4783
|
+
isWishlist: { operator: Where.EQUALS, value: true },
|
|
4784
|
+
},
|
|
4785
|
+
options: {
|
|
4786
|
+
enableCount: false,
|
|
4787
|
+
},
|
|
4788
|
+
});
|
|
4789
|
+
return data;
|
|
4790
|
+
});
|
|
4791
|
+
}
|
|
4792
|
+
getCategoriesForHome(categoryIds, limit, gender) {
|
|
4793
|
+
return;
|
|
4794
|
+
}
|
|
4795
|
+
mountCategory(category, options) {
|
|
4796
|
+
return;
|
|
4797
|
+
}
|
|
4798
|
+
getChildren(parentId) {
|
|
4799
|
+
return;
|
|
4800
|
+
}
|
|
4801
|
+
isChild(id, parentId) {
|
|
4802
|
+
return;
|
|
4803
|
+
}
|
|
4804
|
+
}
|
|
4805
|
+
|
|
4492
4806
|
/**
|
|
4493
4807
|
* Generated bundle index. Do not edit.
|
|
4494
4808
|
*/
|
|
4495
4809
|
|
|
4496
|
-
export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository,
|
|
4810
|
+
export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FragranceImportances, GenderDestination, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, Logger, NotFoundError, OfficePosition, Order, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductSpents, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RoundProductPricesHelper, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, Trace, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, isDebuggable, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|
|
4497
4811
|
//# sourceMappingURL=infrab4a-connect.js.map
|