@infrab4a/connect 3.14.3-beta.3 → 3.14.4
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 +552 -105
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/domain/catalog/models/category-base.d.ts +30 -0
- package/domain/catalog/models/category-for-product.d.ts +5 -0
- package/domain/catalog/models/category.d.ts +3 -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 +0 -4
- package/domain/catalog/models/product-for-category.d.ts +2 -0
- package/domain/catalog/models/product-for-kit.d.ts +7 -0
- package/domain/catalog/models/product.d.ts +4 -0
- 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/wishlist.repository.d.ts +6 -0
- package/esm2015/domain/catalog/models/category-base.js +18 -0
- package/esm2015/domain/catalog/models/category-for-product.js +7 -0
- package/esm2015/domain/catalog/models/category.js +3 -12
- 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 +1 -13
- package/esm2015/domain/catalog/models/product-for-category.js +8 -1
- package/esm2015/domain/catalog/models/product-for-kit.js +14 -0
- package/esm2015/domain/catalog/models/product.js +13 -1
- 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/wishlist.repository.js +2 -0
- package/esm2015/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.js +10 -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/wishlist-hasura-graphql.repository.js +252 -0
- package/fesm2015/infrab4a-connect.js +349 -76
- package/fesm2015/infrab4a-connect.js.map +1 -1
- 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/package.json +1 -1
|
@@ -1193,25 +1193,25 @@ 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
|
+
__decorate([
|
|
1202
|
+
Type(() => CategoryBase),
|
|
1203
|
+
__metadata("design:type", CategoryBase)
|
|
1204
|
+
], CategoryBase.prototype, "parent", void 0);
|
|
1205
|
+
__decorate([
|
|
1206
|
+
Type(() => Filter),
|
|
1207
|
+
__metadata("design:type", Array)
|
|
1208
|
+
], CategoryBase.prototype, "filters", void 0);
|
|
1201
1209
|
|
|
1202
|
-
class
|
|
1210
|
+
class CategoryForProduct extends CategoryBase {
|
|
1203
1211
|
static get identifiersFields() {
|
|
1204
|
-
return ['
|
|
1212
|
+
return ['id'];
|
|
1205
1213
|
}
|
|
1206
1214
|
}
|
|
1207
|
-
__decorate([
|
|
1208
|
-
Type(() => Product),
|
|
1209
|
-
__metadata("design:type", Product)
|
|
1210
|
-
], KitProduct.prototype, "kit", void 0);
|
|
1211
|
-
__decorate([
|
|
1212
|
-
Type(() => Product),
|
|
1213
|
-
__metadata("design:type", Product)
|
|
1214
|
-
], KitProduct.prototype, "product", void 0);
|
|
1215
1215
|
|
|
1216
1216
|
class ProductBase extends BaseModel {
|
|
1217
1217
|
get evaluation() {
|
|
@@ -1236,34 +1236,46 @@ class ProductBase extends BaseModel {
|
|
|
1236
1236
|
return ['id'];
|
|
1237
1237
|
}
|
|
1238
1238
|
}
|
|
1239
|
+
|
|
1240
|
+
class ProductForKit extends ProductBase {
|
|
1241
|
+
static get identifiersFields() {
|
|
1242
|
+
return ['id'];
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1239
1245
|
__decorate([
|
|
1240
|
-
Type(() =>
|
|
1241
|
-
__metadata("design:type",
|
|
1242
|
-
],
|
|
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
|
+
}
|
|
1243
1255
|
__decorate([
|
|
1244
|
-
Type(() =>
|
|
1245
|
-
__metadata("design:type",
|
|
1246
|
-
],
|
|
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);
|
|
1247
1263
|
|
|
1248
1264
|
class ProductForCategory extends ProductBase {
|
|
1249
1265
|
static get identifiersFields() {
|
|
1250
1266
|
return ['id'];
|
|
1251
1267
|
}
|
|
1252
1268
|
}
|
|
1269
|
+
__decorate([
|
|
1270
|
+
Type(() => KitProduct),
|
|
1271
|
+
__metadata("design:type", Array)
|
|
1272
|
+
], ProductForCategory.prototype, "kitProducts", void 0);
|
|
1253
1273
|
|
|
1254
|
-
class Category extends
|
|
1274
|
+
class Category extends CategoryBase {
|
|
1255
1275
|
static get identifiersFields() {
|
|
1256
1276
|
return ['id'];
|
|
1257
1277
|
}
|
|
1258
1278
|
}
|
|
1259
|
-
__decorate([
|
|
1260
|
-
Type(() => Category),
|
|
1261
|
-
__metadata("design:type", Category)
|
|
1262
|
-
], Category.prototype, "parent", void 0);
|
|
1263
|
-
__decorate([
|
|
1264
|
-
Type(() => Filter),
|
|
1265
|
-
__metadata("design:type", Array)
|
|
1266
|
-
], Category.prototype, "filters", void 0);
|
|
1267
1279
|
__decorate([
|
|
1268
1280
|
Type(() => ProductForCategory),
|
|
1269
1281
|
__metadata("design:type", Array)
|
|
@@ -1314,12 +1326,32 @@ class FilterOption extends BaseModel {
|
|
|
1314
1326
|
}
|
|
1315
1327
|
}
|
|
1316
1328
|
|
|
1329
|
+
class Product extends ProductBase {
|
|
1330
|
+
static get identifiersFields() {
|
|
1331
|
+
return ['id'];
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
__decorate([
|
|
1335
|
+
Type(() => CategoryForProduct),
|
|
1336
|
+
__metadata("design:type", CategoryForProduct)
|
|
1337
|
+
], Product.prototype, "category", void 0);
|
|
1338
|
+
__decorate([
|
|
1339
|
+
Type(() => KitProduct),
|
|
1340
|
+
__metadata("design:type", Array)
|
|
1341
|
+
], Product.prototype, "kitProducts", void 0);
|
|
1342
|
+
|
|
1317
1343
|
class Variant extends BaseModel {
|
|
1318
1344
|
static get identifiersFields() {
|
|
1319
1345
|
return ['id', 'productId'];
|
|
1320
1346
|
}
|
|
1321
1347
|
}
|
|
1322
1348
|
|
|
1349
|
+
class Wishlist extends Category {
|
|
1350
|
+
static get identifiersFields() {
|
|
1351
|
+
return ['id'];
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1323
1355
|
class Buy2Win extends BaseModel {
|
|
1324
1356
|
static get identifiersFields() {
|
|
1325
1357
|
return ['id'];
|
|
@@ -3372,6 +3404,15 @@ class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
|
|
|
3372
3404
|
],
|
|
3373
3405
|
});
|
|
3374
3406
|
}
|
|
3407
|
+
deleteByCategory(categoryId) {
|
|
3408
|
+
return this.mutation('delete_category_filter', ['affected_rows'], {
|
|
3409
|
+
where: {
|
|
3410
|
+
type: 'category_filter_bool_exp',
|
|
3411
|
+
required: true,
|
|
3412
|
+
value: { category_id: { _eq: categoryId } },
|
|
3413
|
+
},
|
|
3414
|
+
});
|
|
3415
|
+
}
|
|
3375
3416
|
deleteByCategoryAndFilter(categoryId, filterId) {
|
|
3376
3417
|
return this.mutation('delete_category_filter', ['affected_rows'], {
|
|
3377
3418
|
where: {
|
|
@@ -3454,6 +3495,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3454
3495
|
},
|
|
3455
3496
|
},
|
|
3456
3497
|
{ isCollection: { columnName: 'is_collection' } },
|
|
3498
|
+
{ isWishlist: { columnName: 'is_wishlist' } },
|
|
3457
3499
|
'reference',
|
|
3458
3500
|
{ parentId: { columnName: 'parent_id' } },
|
|
3459
3501
|
{
|
|
@@ -3474,7 +3516,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3474
3516
|
});
|
|
3475
3517
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3476
3518
|
const { metadata } = params, data = __rest(params, ["metadata"]);
|
|
3477
|
-
return _super.create.call(this, Object.assign(Object.assign({}, data), { metadata: metadata || { description: null, title: null } }));
|
|
3519
|
+
return _super.create.call(this, Object.assign(Object.assign({}, data), { isWishlist: false, metadata: metadata || { description: null, title: null } }));
|
|
3478
3520
|
});
|
|
3479
3521
|
}
|
|
3480
3522
|
get(identifiers) {
|
|
@@ -3496,7 +3538,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3496
3538
|
const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
|
|
3497
3539
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
3498
3540
|
const id = yield this.getId(plainData.id);
|
|
3499
|
-
const category = yield _super.update.call(this, Object.assign({ id }, data));
|
|
3541
|
+
const category = yield _super.update.call(this, Object.assign(Object.assign({ id }, data), { isWishlist: false }));
|
|
3500
3542
|
category.products = products && (yield this.updateProducts(+id, { products }));
|
|
3501
3543
|
category.metadata = metadata && (yield this.updateMetadata(+id, { metadata }));
|
|
3502
3544
|
category.filters = filters && (yield this.updateFilters(+id, { filters }));
|
|
@@ -3512,6 +3554,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3512
3554
|
slug,
|
|
3513
3555
|
shops: { operator: Where.IN, value: [shop] },
|
|
3514
3556
|
published: { operator: Where.EQUALS, value: true },
|
|
3557
|
+
isWishlist: { operator: Where.EQUALS, value: false },
|
|
3515
3558
|
},
|
|
3516
3559
|
options: {
|
|
3517
3560
|
enableCount: false,
|
|
@@ -3532,6 +3575,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3532
3575
|
filters: {
|
|
3533
3576
|
shops: { operator: Where.IN, value: [shop] },
|
|
3534
3577
|
published: { operator: Where.EQUALS, value: true },
|
|
3578
|
+
isWishlist: { operator: Where.EQUALS, value: false },
|
|
3535
3579
|
},
|
|
3536
3580
|
options: {
|
|
3537
3581
|
enableCount: false,
|
|
@@ -3676,59 +3720,42 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3676
3720
|
}
|
|
3677
3721
|
if ('action' in filters && filters.action === 'merge' && filters.value.length) {
|
|
3678
3722
|
let filtersList = [];
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
filterId: filters.value[i].id,
|
|
3695
|
-
categoryId,
|
|
3696
|
-
});
|
|
3697
|
-
filtersList.push(newCategoryFilter);
|
|
3698
|
-
}
|
|
3699
|
-
}
|
|
3700
|
-
catch (error) {
|
|
3701
|
-
console.log('catch error: ', error);
|
|
3723
|
+
const currentFilters = yield this.categoryFilterRepository
|
|
3724
|
+
.find({
|
|
3725
|
+
filters: {
|
|
3726
|
+
categoryId,
|
|
3727
|
+
},
|
|
3728
|
+
})
|
|
3729
|
+
.then((res) => res.data);
|
|
3730
|
+
const currentFiltersId = currentFilters.map((f) => f.id);
|
|
3731
|
+
const filtersUpdatedId = filters.value.map((f) => f.id);
|
|
3732
|
+
const filterToBeDeleted = currentFiltersId.filter((c) => !filtersUpdatedId.includes(c));
|
|
3733
|
+
const filterToBeInserted = filtersUpdatedId.filter((c) => !currentFiltersId.includes(c));
|
|
3734
|
+
for (const filter of filterToBeDeleted) {
|
|
3735
|
+
const index = currentFilters.findIndex((f) => f.id == filter);
|
|
3736
|
+
if (index != -1) {
|
|
3737
|
+
currentFilters.splice(index, 1);
|
|
3702
3738
|
}
|
|
3739
|
+
yield this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filter);
|
|
3703
3740
|
}
|
|
3704
|
-
|
|
3741
|
+
for (const filter of filterToBeInserted) {
|
|
3742
|
+
const newCategoryFilter = yield this.categoryFilterRepository.create({
|
|
3743
|
+
filterId: filter,
|
|
3744
|
+
categoryId,
|
|
3745
|
+
});
|
|
3746
|
+
filtersList.push(newCategoryFilter);
|
|
3747
|
+
}
|
|
3748
|
+
return [...currentFilters, ...filtersList];
|
|
3705
3749
|
}
|
|
3706
3750
|
if (Array.isArray(filters) && filters.length) {
|
|
3751
|
+
yield this.categoryFilterRepository.deleteByCategory(categoryId);
|
|
3707
3752
|
let filtersList = [];
|
|
3708
3753
|
for (let i = 0; i < filters.length; i++) {
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
filterId: filters[i].id,
|
|
3715
|
-
},
|
|
3716
|
-
})
|
|
3717
|
-
.then((data) => data.data.shift());
|
|
3718
|
-
if (hasFilter) {
|
|
3719
|
-
filtersList.push(hasFilter);
|
|
3720
|
-
}
|
|
3721
|
-
else {
|
|
3722
|
-
const newCategoryFilter = yield this.categoryFilterRepository.create({
|
|
3723
|
-
filterId: filters[i].id,
|
|
3724
|
-
categoryId,
|
|
3725
|
-
});
|
|
3726
|
-
filtersList.push(newCategoryFilter);
|
|
3727
|
-
}
|
|
3728
|
-
}
|
|
3729
|
-
catch (error) {
|
|
3730
|
-
console.log('catch error: ', error);
|
|
3731
|
-
}
|
|
3754
|
+
const newCategoryFilter = yield this.categoryFilterRepository.create({
|
|
3755
|
+
filterId: filters[i].id,
|
|
3756
|
+
categoryId,
|
|
3757
|
+
});
|
|
3758
|
+
filtersList.push(newCategoryFilter);
|
|
3732
3759
|
}
|
|
3733
3760
|
return filtersList;
|
|
3734
3761
|
}
|
|
@@ -4500,9 +4527,255 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4500
4527
|
}
|
|
4501
4528
|
}
|
|
4502
4529
|
|
|
4530
|
+
class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
|
|
4531
|
+
constructor(endpoint, authOptions, categoryFilterRepository) {
|
|
4532
|
+
super({
|
|
4533
|
+
tableName: 'category',
|
|
4534
|
+
model: Wishlist,
|
|
4535
|
+
endpoint,
|
|
4536
|
+
authOptions,
|
|
4537
|
+
fields: [
|
|
4538
|
+
{ id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
|
|
4539
|
+
{ firestoreId: { columnName: 'firestore_id' } },
|
|
4540
|
+
'name',
|
|
4541
|
+
'description',
|
|
4542
|
+
'image',
|
|
4543
|
+
'published',
|
|
4544
|
+
'shop',
|
|
4545
|
+
{ shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
|
|
4546
|
+
'slug',
|
|
4547
|
+
{ brandCategory: { columnName: 'brand_category' } },
|
|
4548
|
+
{ brandCategoryBanner: { columnName: 'brand_banner' } },
|
|
4549
|
+
{ brandCategoryBannerMobile: { columnName: 'brand_banner_mobile' } },
|
|
4550
|
+
{ brandLogo: { columnName: 'brand_logo' } },
|
|
4551
|
+
{ brandCondition: { columnName: 'brand_condition' } },
|
|
4552
|
+
{
|
|
4553
|
+
conditions: {
|
|
4554
|
+
columnName: 'tag_condition',
|
|
4555
|
+
type: HasuraGraphQLColumnType.Jsonb,
|
|
4556
|
+
from: (tags, row) => ({ brand: row.brand_condition, tags: Array.isArray(tags) ? tags : [] }),
|
|
4557
|
+
bindPersistData: (value) => {
|
|
4558
|
+
return {
|
|
4559
|
+
brand_condition: value.brand,
|
|
4560
|
+
tag_condition: (value === null || value === void 0 ? void 0 : value.tags) || [],
|
|
4561
|
+
};
|
|
4562
|
+
},
|
|
4563
|
+
bindFindFilter: (sentence) => {
|
|
4564
|
+
return Object.assign(Object.assign({}, (sentence.brand ? { brand_condition: sentence.brand } : {})), (sentence.tags ? { tag_condition: sentence.tags } : {}));
|
|
4565
|
+
},
|
|
4566
|
+
},
|
|
4567
|
+
},
|
|
4568
|
+
{
|
|
4569
|
+
filters: {
|
|
4570
|
+
columnName: 'filters',
|
|
4571
|
+
foreignKeyColumn: { filter_id: 'id' },
|
|
4572
|
+
fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
|
|
4573
|
+
bindPersistData: (value) => ({
|
|
4574
|
+
filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
|
|
4575
|
+
}),
|
|
4576
|
+
from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
|
|
4577
|
+
},
|
|
4578
|
+
},
|
|
4579
|
+
{ createdAt: { columnName: 'created_at' } },
|
|
4580
|
+
{ updatedAt: { columnName: 'updated_at' } },
|
|
4581
|
+
{
|
|
4582
|
+
products: {
|
|
4583
|
+
columnName: 'products',
|
|
4584
|
+
fields: ['product_id'],
|
|
4585
|
+
from: (value) => value.map((product) => product.product_id.toString()),
|
|
4586
|
+
to: (productIds) => productIds.map((productId) => ({
|
|
4587
|
+
product_id: +productId,
|
|
4588
|
+
})),
|
|
4589
|
+
},
|
|
4590
|
+
},
|
|
4591
|
+
{
|
|
4592
|
+
metadata: {
|
|
4593
|
+
columnName: 'metadata',
|
|
4594
|
+
fields: ['title', 'description'],
|
|
4595
|
+
bindPersistData: (value) => ({
|
|
4596
|
+
metadata: { data: value },
|
|
4597
|
+
}),
|
|
4598
|
+
},
|
|
4599
|
+
},
|
|
4600
|
+
{ isCollection: { columnName: 'is_collection' } },
|
|
4601
|
+
{ isWishlist: { columnName: 'is_wishlist' } },
|
|
4602
|
+
'reference',
|
|
4603
|
+
{ parentId: { columnName: 'parent_id' } },
|
|
4604
|
+
{
|
|
4605
|
+
parent: {
|
|
4606
|
+
columnName: 'parent',
|
|
4607
|
+
foreignKeyColumn: { id: 'parentId' },
|
|
4608
|
+
fields: ['id', 'name', 'reference', 'slug'],
|
|
4609
|
+
},
|
|
4610
|
+
},
|
|
4611
|
+
{ personId: { columnName: 'person_id' } },
|
|
4612
|
+
],
|
|
4613
|
+
});
|
|
4614
|
+
this.categoryFilterRepository = categoryFilterRepository;
|
|
4615
|
+
}
|
|
4616
|
+
create(params) {
|
|
4617
|
+
const _super = Object.create(null, {
|
|
4618
|
+
create: { get: () => super.create }
|
|
4619
|
+
});
|
|
4620
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4621
|
+
const { metadata } = params, data = __rest(params, ["metadata"]);
|
|
4622
|
+
return _super.create.call(this, Object.assign(Object.assign({}, data), { isWishlist: true, isCollection: true, brandCategory: false, metadata: metadata || { description: data.description, title: data.name } }));
|
|
4623
|
+
});
|
|
4624
|
+
}
|
|
4625
|
+
get(identifiers) {
|
|
4626
|
+
const _super = Object.create(null, {
|
|
4627
|
+
get: { get: () => super.get }
|
|
4628
|
+
});
|
|
4629
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4630
|
+
const data = yield _super.get.call(this, identifiers);
|
|
4631
|
+
if (!data.isWishlist)
|
|
4632
|
+
throw new NotFoundError(`Category with id ${identifiers.id} is not a wishlist`);
|
|
4633
|
+
return data;
|
|
4634
|
+
});
|
|
4635
|
+
}
|
|
4636
|
+
update(params) {
|
|
4637
|
+
const _super = Object.create(null, {
|
|
4638
|
+
update: { get: () => super.update }
|
|
4639
|
+
});
|
|
4640
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4641
|
+
const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
|
|
4642
|
+
const plainData = this.paramsToPlain({ id: checkId });
|
|
4643
|
+
const id = plainData.id;
|
|
4644
|
+
const category = yield _super.update.call(this, Object.assign(Object.assign({ id }, data), { isWishlist: true, isCollection: true, brandCategory: false }));
|
|
4645
|
+
category.products = products && (yield this.updateProducts(+id, { products }));
|
|
4646
|
+
category.metadata = metadata && (yield this.updateMetadata(+id, { metadata }));
|
|
4647
|
+
return category;
|
|
4648
|
+
});
|
|
4649
|
+
}
|
|
4650
|
+
getWishlistBySlug(slug) {
|
|
4651
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4652
|
+
if (!slug)
|
|
4653
|
+
return;
|
|
4654
|
+
const { data } = yield this.find({
|
|
4655
|
+
filters: {
|
|
4656
|
+
slug,
|
|
4657
|
+
isWishlist: { operator: Where.EQUALS, value: true },
|
|
4658
|
+
},
|
|
4659
|
+
options: {
|
|
4660
|
+
enableCount: false,
|
|
4661
|
+
},
|
|
4662
|
+
});
|
|
4663
|
+
if (!data.length)
|
|
4664
|
+
throw new NotFoundError(`Wishlist with slug ${slug} not found`);
|
|
4665
|
+
if (data.length > 1)
|
|
4666
|
+
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
4667
|
+
return data.shift();
|
|
4668
|
+
});
|
|
4669
|
+
}
|
|
4670
|
+
getWishlistByPerson(personId) {
|
|
4671
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4672
|
+
if (!personId)
|
|
4673
|
+
return;
|
|
4674
|
+
const { data } = yield this.find({
|
|
4675
|
+
filters: {
|
|
4676
|
+
personId: { operator: Where.EQUALS, value: personId },
|
|
4677
|
+
isWishlist: { operator: Where.EQUALS, value: true },
|
|
4678
|
+
},
|
|
4679
|
+
options: {
|
|
4680
|
+
enableCount: false,
|
|
4681
|
+
},
|
|
4682
|
+
});
|
|
4683
|
+
if (!data.length)
|
|
4684
|
+
throw new NotFoundError(`Wishlists from person ${personId} not found`);
|
|
4685
|
+
return data;
|
|
4686
|
+
});
|
|
4687
|
+
}
|
|
4688
|
+
updateProducts(categoryId, { products }) {
|
|
4689
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4690
|
+
if ('action' in products && products.action === 'remove') {
|
|
4691
|
+
yield this.mutation('delete_category_product', ['affected_rows'], {
|
|
4692
|
+
where: {
|
|
4693
|
+
type: 'category_product_bool_exp',
|
|
4694
|
+
required: true,
|
|
4695
|
+
value: { category_id: { _eq: categoryId } },
|
|
4696
|
+
},
|
|
4697
|
+
});
|
|
4698
|
+
yield this.categoryFilterRepository.deleteByCategory(categoryId);
|
|
4699
|
+
return [];
|
|
4700
|
+
}
|
|
4701
|
+
const plainData = this.paramsToPlain({ products });
|
|
4702
|
+
if (!plainData.products || plainData.products.length <= 0)
|
|
4703
|
+
return [];
|
|
4704
|
+
yield this.mutation('delete_category_product', ['affected_rows'], {
|
|
4705
|
+
where: {
|
|
4706
|
+
type: 'category_product_bool_exp',
|
|
4707
|
+
required: true,
|
|
4708
|
+
value: { category_id: { _eq: categoryId } },
|
|
4709
|
+
},
|
|
4710
|
+
});
|
|
4711
|
+
yield this.categoryFilterRepository.deleteByCategory(categoryId);
|
|
4712
|
+
yield this.mutation('insert_category_product', ['affected_rows'], {
|
|
4713
|
+
objects: {
|
|
4714
|
+
type: '[category_product_insert_input!]',
|
|
4715
|
+
required: true,
|
|
4716
|
+
value: plainData.products.map((productId) => ({ category_id: categoryId, product_id: productId })),
|
|
4717
|
+
},
|
|
4718
|
+
});
|
|
4719
|
+
return plainData.products;
|
|
4720
|
+
});
|
|
4721
|
+
}
|
|
4722
|
+
updateMetadata(categoryId, { metadata }) {
|
|
4723
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4724
|
+
const plainData = this.paramsToPlain({ metadata });
|
|
4725
|
+
if (!plainData.metadata)
|
|
4726
|
+
return;
|
|
4727
|
+
yield this.mutation('update_category_metadata_by_pk', ['category_id'], {
|
|
4728
|
+
pk_columns: {
|
|
4729
|
+
value: { category_id: categoryId },
|
|
4730
|
+
type: 'category_metadata_pk_columns_input',
|
|
4731
|
+
required: true,
|
|
4732
|
+
},
|
|
4733
|
+
_set: {
|
|
4734
|
+
value: omit(metadata, ['category_id']),
|
|
4735
|
+
type: 'category_metadata_set_input',
|
|
4736
|
+
required: true,
|
|
4737
|
+
},
|
|
4738
|
+
});
|
|
4739
|
+
return plainData.metadata;
|
|
4740
|
+
});
|
|
4741
|
+
}
|
|
4742
|
+
getCategoryBySlug(slug, _shop) {
|
|
4743
|
+
return this.getWishlistBySlug(slug);
|
|
4744
|
+
}
|
|
4745
|
+
getCategoryByShop(shop) {
|
|
4746
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
4747
|
+
if (!shop)
|
|
4748
|
+
return;
|
|
4749
|
+
const { data } = yield this.find({
|
|
4750
|
+
filters: {
|
|
4751
|
+
shops: { operator: Where.IN, value: [shop] },
|
|
4752
|
+
published: { operator: Where.EQUALS, value: true },
|
|
4753
|
+
isWishlist: { operator: Where.EQUALS, value: true },
|
|
4754
|
+
},
|
|
4755
|
+
options: {
|
|
4756
|
+
enableCount: false,
|
|
4757
|
+
},
|
|
4758
|
+
});
|
|
4759
|
+
return data;
|
|
4760
|
+
});
|
|
4761
|
+
}
|
|
4762
|
+
getCategoriesForHome(categoryIds, limit, gender) {
|
|
4763
|
+
return;
|
|
4764
|
+
}
|
|
4765
|
+
mountCategory(category, options) {
|
|
4766
|
+
return;
|
|
4767
|
+
}
|
|
4768
|
+
getChildren(parentId) {
|
|
4769
|
+
return;
|
|
4770
|
+
}
|
|
4771
|
+
isChild(id, parentId) {
|
|
4772
|
+
return;
|
|
4773
|
+
}
|
|
4774
|
+
}
|
|
4775
|
+
|
|
4503
4776
|
/**
|
|
4504
4777
|
* Generated bundle index. Do not edit.
|
|
4505
4778
|
*/
|
|
4506
4779
|
|
|
4507
|
-
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, isDebuggable, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|
|
4780
|
+
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 };
|
|
4508
4781
|
//# sourceMappingURL=infrab4a-connect.js.map
|