@infrab4a/connect 3.14.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 +578 -101
- 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 +5 -29
- 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/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 +5 -14
- 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/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 +358 -73
- 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,21 +1193,27 @@ class Filter extends BaseModel {
|
|
|
1193
1193
|
}
|
|
1194
1194
|
}
|
|
1195
1195
|
|
|
1196
|
-
class
|
|
1196
|
+
class CategoryBase extends BaseModel {
|
|
1197
1197
|
static get identifiersFields() {
|
|
1198
|
-
return ['
|
|
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
|
-
Type(() =>
|
|
1207
|
-
__metadata("design:type",
|
|
1208
|
-
],
|
|
1206
|
+
Type(() => Filter),
|
|
1207
|
+
__metadata("design:type", Array)
|
|
1208
|
+
], CategoryBase.prototype, "filters", void 0);
|
|
1209
|
+
|
|
1210
|
+
class CategoryForProduct extends CategoryBase {
|
|
1211
|
+
static get identifiersFields() {
|
|
1212
|
+
return ['id'];
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1209
1215
|
|
|
1210
|
-
class
|
|
1216
|
+
class ProductBase extends BaseModel {
|
|
1211
1217
|
get evaluation() {
|
|
1212
1218
|
return {
|
|
1213
1219
|
reviews: this.reviews,
|
|
@@ -1230,30 +1236,48 @@ class Product extends BaseModel {
|
|
|
1230
1236
|
return ['id'];
|
|
1231
1237
|
}
|
|
1232
1238
|
}
|
|
1239
|
+
|
|
1240
|
+
class ProductForKit extends ProductBase {
|
|
1241
|
+
static get identifiersFields() {
|
|
1242
|
+
return ['id'];
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1233
1245
|
__decorate([
|
|
1234
|
-
Type(() =>
|
|
1235
|
-
__metadata("design:type",
|
|
1236
|
-
],
|
|
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
|
+
}
|
|
1237
1255
|
__decorate([
|
|
1238
|
-
Type(() =>
|
|
1239
|
-
__metadata("design:type",
|
|
1240
|
-
],
|
|
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);
|
|
1241
1263
|
|
|
1242
|
-
class
|
|
1264
|
+
class ProductForCategory extends ProductBase {
|
|
1243
1265
|
static get identifiersFields() {
|
|
1244
1266
|
return ['id'];
|
|
1245
1267
|
}
|
|
1246
1268
|
}
|
|
1247
1269
|
__decorate([
|
|
1248
|
-
Type(() =>
|
|
1249
|
-
__metadata("design:type", Category)
|
|
1250
|
-
], Category.prototype, "parent", void 0);
|
|
1251
|
-
__decorate([
|
|
1252
|
-
Type(() => Filter),
|
|
1270
|
+
Type(() => KitProduct),
|
|
1253
1271
|
__metadata("design:type", Array)
|
|
1254
|
-
],
|
|
1272
|
+
], ProductForCategory.prototype, "kitProducts", void 0);
|
|
1273
|
+
|
|
1274
|
+
class Category extends CategoryBase {
|
|
1275
|
+
static get identifiersFields() {
|
|
1276
|
+
return ['id'];
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1255
1279
|
__decorate([
|
|
1256
|
-
Type(() =>
|
|
1280
|
+
Type(() => ProductForCategory),
|
|
1257
1281
|
__metadata("design:type", Array)
|
|
1258
1282
|
], Category.prototype, "childrenProducts", void 0);
|
|
1259
1283
|
|
|
@@ -1302,12 +1326,32 @@ class FilterOption extends BaseModel {
|
|
|
1302
1326
|
}
|
|
1303
1327
|
}
|
|
1304
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
|
+
|
|
1305
1343
|
class Variant extends BaseModel {
|
|
1306
1344
|
static get identifiersFields() {
|
|
1307
1345
|
return ['id', 'productId'];
|
|
1308
1346
|
}
|
|
1309
1347
|
}
|
|
1310
1348
|
|
|
1349
|
+
class Wishlist extends Category {
|
|
1350
|
+
static get identifiersFields() {
|
|
1351
|
+
return ['id'];
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1354
|
+
|
|
1311
1355
|
class Buy2Win extends BaseModel {
|
|
1312
1356
|
static get identifiersFields() {
|
|
1313
1357
|
return ['id'];
|
|
@@ -3360,6 +3404,15 @@ class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHa
|
|
|
3360
3404
|
],
|
|
3361
3405
|
});
|
|
3362
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
|
+
}
|
|
3363
3416
|
deleteByCategoryAndFilter(categoryId, filterId) {
|
|
3364
3417
|
return this.mutation('delete_category_filter', ['affected_rows'], {
|
|
3365
3418
|
where: {
|
|
@@ -3442,6 +3495,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3442
3495
|
},
|
|
3443
3496
|
},
|
|
3444
3497
|
{ isCollection: { columnName: 'is_collection' } },
|
|
3498
|
+
{ isWishlist: { columnName: 'is_wishlist' } },
|
|
3445
3499
|
'reference',
|
|
3446
3500
|
{ parentId: { columnName: 'parent_id' } },
|
|
3447
3501
|
{
|
|
@@ -3462,7 +3516,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3462
3516
|
});
|
|
3463
3517
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3464
3518
|
const { metadata } = params, data = __rest(params, ["metadata"]);
|
|
3465
|
-
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 } }));
|
|
3466
3520
|
});
|
|
3467
3521
|
}
|
|
3468
3522
|
get(identifiers) {
|
|
@@ -3484,7 +3538,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3484
3538
|
const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
|
|
3485
3539
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
3486
3540
|
const id = yield this.getId(plainData.id);
|
|
3487
|
-
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 }));
|
|
3488
3542
|
category.products = products && (yield this.updateProducts(+id, { products }));
|
|
3489
3543
|
category.metadata = metadata && (yield this.updateMetadata(+id, { metadata }));
|
|
3490
3544
|
category.filters = filters && (yield this.updateFilters(+id, { filters }));
|
|
@@ -3500,6 +3554,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3500
3554
|
slug,
|
|
3501
3555
|
shops: { operator: Where.IN, value: [shop] },
|
|
3502
3556
|
published: { operator: Where.EQUALS, value: true },
|
|
3557
|
+
isWishlist: { operator: Where.EQUALS, value: false },
|
|
3503
3558
|
},
|
|
3504
3559
|
options: {
|
|
3505
3560
|
enableCount: false,
|
|
@@ -3520,6 +3575,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3520
3575
|
filters: {
|
|
3521
3576
|
shops: { operator: Where.IN, value: [shop] },
|
|
3522
3577
|
published: { operator: Where.EQUALS, value: true },
|
|
3578
|
+
isWishlist: { operator: Where.EQUALS, value: false },
|
|
3523
3579
|
},
|
|
3524
3580
|
options: {
|
|
3525
3581
|
enableCount: false,
|
|
@@ -3664,59 +3720,42 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
3664
3720
|
}
|
|
3665
3721
|
if ('action' in filters && filters.action === 'merge' && filters.value.length) {
|
|
3666
3722
|
let filtersList = [];
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
filterId: filters.value[i].id,
|
|
3683
|
-
categoryId,
|
|
3684
|
-
});
|
|
3685
|
-
filtersList.push(newCategoryFilter);
|
|
3686
|
-
}
|
|
3687
|
-
}
|
|
3688
|
-
catch (error) {
|
|
3689
|
-
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);
|
|
3690
3738
|
}
|
|
3739
|
+
yield this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filter);
|
|
3691
3740
|
}
|
|
3692
|
-
|
|
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];
|
|
3693
3749
|
}
|
|
3694
3750
|
if (Array.isArray(filters) && filters.length) {
|
|
3751
|
+
yield this.categoryFilterRepository.deleteByCategory(categoryId);
|
|
3695
3752
|
let filtersList = [];
|
|
3696
3753
|
for (let i = 0; i < filters.length; i++) {
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
filterId: filters[i].id,
|
|
3703
|
-
},
|
|
3704
|
-
})
|
|
3705
|
-
.then((data) => data.data.shift());
|
|
3706
|
-
if (hasFilter) {
|
|
3707
|
-
filtersList.push(hasFilter);
|
|
3708
|
-
}
|
|
3709
|
-
else {
|
|
3710
|
-
const newCategoryFilter = yield this.categoryFilterRepository.create({
|
|
3711
|
-
filterId: filters[i].id,
|
|
3712
|
-
categoryId,
|
|
3713
|
-
});
|
|
3714
|
-
filtersList.push(newCategoryFilter);
|
|
3715
|
-
}
|
|
3716
|
-
}
|
|
3717
|
-
catch (error) {
|
|
3718
|
-
console.log('catch error: ', error);
|
|
3719
|
-
}
|
|
3754
|
+
const newCategoryFilter = yield this.categoryFilterRepository.create({
|
|
3755
|
+
filterId: filters[i].id,
|
|
3756
|
+
categoryId,
|
|
3757
|
+
});
|
|
3758
|
+
filtersList.push(newCategoryFilter);
|
|
3720
3759
|
}
|
|
3721
3760
|
return filtersList;
|
|
3722
3761
|
}
|
|
@@ -4488,9 +4527,255 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
4488
4527
|
}
|
|
4489
4528
|
}
|
|
4490
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
|
+
|
|
4491
4776
|
/**
|
|
4492
4777
|
* Generated bundle index. Do not edit.
|
|
4493
4778
|
*/
|
|
4494
4779
|
|
|
4495
|
-
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 };
|
|
4496
4781
|
//# sourceMappingURL=infrab4a-connect.js.map
|