@infrab4a/connect 4.16.0-beta.1 → 4.16.1-beta.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/index.cjs.js +12 -8
- package/index.esm.js +12 -8
- package/package.json +1 -1
- package/src/domain/catalog/repositories/category.repository.d.ts +2 -2
- package/src/domain/shopping/models/coupons/enums/coupon-category.enum.d.ts +0 -1
- package/src/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +1 -1
- package/src/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +2 -2
- package/src/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.d.ts +1 -1
package/index.cjs.js
CHANGED
|
@@ -2130,7 +2130,6 @@ exports.CouponCategory = void 0;
|
|
|
2130
2130
|
CouponCategory["Desculpas"] = "Desculpas";
|
|
2131
2131
|
CouponCategory["BFlu"] = "BFlu";
|
|
2132
2132
|
CouponCategory["ROYAL"] = "Royal";
|
|
2133
|
-
CouponCategory["Glamgirls"] = "Glamgirls";
|
|
2134
2133
|
CouponCategory["Glamdiva"] = "Glamdiva";
|
|
2135
2134
|
CouponCategory["Impulsionamento"] = "Impulsionamento";
|
|
2136
2135
|
CouponCategory["PaidMedia"] = "Paid Media";
|
|
@@ -3294,7 +3293,7 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
3294
3293
|
throw new NotFoundError(`Document with slug ${slug} not found`);
|
|
3295
3294
|
return categoryDocs.docs[0].data();
|
|
3296
3295
|
}
|
|
3297
|
-
async getCategoriesForHome(categoryIds, limit = 4
|
|
3296
|
+
async getCategoriesForHome(categoryIds, gender, limit = 4) {
|
|
3298
3297
|
const categorySnap = await this.collection(this.collectionName)
|
|
3299
3298
|
.where('id', 'in', categoryIds.filter(Boolean))
|
|
3300
3299
|
.where('published', '==', true)
|
|
@@ -3352,7 +3351,7 @@ tslib.__decorate([
|
|
|
3352
3351
|
tslib.__decorate([
|
|
3353
3352
|
Log(),
|
|
3354
3353
|
tslib.__metadata("design:type", Function),
|
|
3355
|
-
tslib.__metadata("design:paramtypes", [Array,
|
|
3354
|
+
tslib.__metadata("design:paramtypes", [Array, String, Object]),
|
|
3356
3355
|
tslib.__metadata("design:returntype", Promise)
|
|
3357
3356
|
], CategoryFirestoreRepository.prototype, "getCategoriesForHome", null);
|
|
3358
3357
|
tslib.__decorate([
|
|
@@ -4921,7 +4920,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4921
4920
|
});
|
|
4922
4921
|
return data;
|
|
4923
4922
|
}
|
|
4924
|
-
async getCategoriesForHome(categoryIds, limit = 4
|
|
4923
|
+
async getCategoriesForHome(categoryIds, gender, limit = 4) {
|
|
4925
4924
|
if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
|
|
4926
4925
|
return [];
|
|
4927
4926
|
const categoriesFirestore = categoryIds.filter((categoryId) => Number.isNaN(+categoryId));
|
|
@@ -4947,8 +4946,13 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4947
4946
|
var _a;
|
|
4948
4947
|
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
4949
4948
|
return [];
|
|
4949
|
+
const shop = options.gender === 'female' ? exports.Shops.GLAMSHOP : exports.Shops.MENSMARKET;
|
|
4950
|
+
const mostRelevants = category.getMostRelevantByShop(shop);
|
|
4951
|
+
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(category.products))].slice(0, options.limit);
|
|
4950
4952
|
const products = [];
|
|
4951
|
-
const { data: productsData } = await this.productRepository.find(Object.assign(Object.assign({ filters: Object.assign(Object.assign({ id: { operator: exports.Where.IN, value:
|
|
4953
|
+
const { data: productsData } = await this.productRepository.find(Object.assign(Object.assign({ filters: Object.assign(Object.assign({ id: { operator: exports.Where.IN, value: mostRelevantProductsIds }, published: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: exports.Where.GT, value: 0 } } } : {})), ((options === null || options === void 0 ? void 0 : options.gender)
|
|
4954
|
+
? { gender: { operator: exports.Where.IN, value: [options === null || options === void 0 ? void 0 : options.gender, 'unisex'] } }
|
|
4955
|
+
: {})), fields: [
|
|
4952
4956
|
'id',
|
|
4953
4957
|
'name',
|
|
4954
4958
|
'slug',
|
|
@@ -4975,7 +4979,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4975
4979
|
'gender',
|
|
4976
4980
|
'createdAt',
|
|
4977
4981
|
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})), { options: { enableCount: false } }));
|
|
4978
|
-
products.push(...productsData);
|
|
4982
|
+
products.push(...productsData.sort((a, b) => mostRelevants.indexOf(a.id) - mostRelevants.indexOf(b.id)));
|
|
4979
4983
|
return products;
|
|
4980
4984
|
}
|
|
4981
4985
|
async getChildren(parentId) {
|
|
@@ -5150,7 +5154,7 @@ tslib.__decorate([
|
|
|
5150
5154
|
tslib.__decorate([
|
|
5151
5155
|
Log(),
|
|
5152
5156
|
tslib.__metadata("design:type", Function),
|
|
5153
|
-
tslib.__metadata("design:paramtypes", [Array,
|
|
5157
|
+
tslib.__metadata("design:paramtypes", [Array, String, Object]),
|
|
5154
5158
|
tslib.__metadata("design:returntype", Promise)
|
|
5155
5159
|
], CategoryHasuraGraphQLRepository.prototype, "getCategoriesForHome", null);
|
|
5156
5160
|
tslib.__decorate([
|
|
@@ -6287,7 +6291,7 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6287
6291
|
value: [exports.PersonTypes.BFLU, exports.PersonTypes.GLAMGIRL],
|
|
6288
6292
|
} }), orderBy: Object.assign({ personHasPhoto: 'desc' }, lodash.omit(params.orderBy, ['personHasPhoto'])) }));
|
|
6289
6293
|
}
|
|
6290
|
-
getCategoriesForHome(categoryIds,
|
|
6294
|
+
getCategoriesForHome(categoryIds, gender, limit) {
|
|
6291
6295
|
return;
|
|
6292
6296
|
}
|
|
6293
6297
|
mountCategory(category, options) {
|
package/index.esm.js
CHANGED
|
@@ -2124,7 +2124,6 @@ var CouponCategory;
|
|
|
2124
2124
|
CouponCategory["Desculpas"] = "Desculpas";
|
|
2125
2125
|
CouponCategory["BFlu"] = "BFlu";
|
|
2126
2126
|
CouponCategory["ROYAL"] = "Royal";
|
|
2127
|
-
CouponCategory["Glamgirls"] = "Glamgirls";
|
|
2128
2127
|
CouponCategory["Glamdiva"] = "Glamdiva";
|
|
2129
2128
|
CouponCategory["Impulsionamento"] = "Impulsionamento";
|
|
2130
2129
|
CouponCategory["PaidMedia"] = "Paid Media";
|
|
@@ -3288,7 +3287,7 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
3288
3287
|
throw new NotFoundError(`Document with slug ${slug} not found`);
|
|
3289
3288
|
return categoryDocs.docs[0].data();
|
|
3290
3289
|
}
|
|
3291
|
-
async getCategoriesForHome(categoryIds, limit = 4
|
|
3290
|
+
async getCategoriesForHome(categoryIds, gender, limit = 4) {
|
|
3292
3291
|
const categorySnap = await this.collection(this.collectionName)
|
|
3293
3292
|
.where('id', 'in', categoryIds.filter(Boolean))
|
|
3294
3293
|
.where('published', '==', true)
|
|
@@ -3346,7 +3345,7 @@ __decorate([
|
|
|
3346
3345
|
__decorate([
|
|
3347
3346
|
Log(),
|
|
3348
3347
|
__metadata("design:type", Function),
|
|
3349
|
-
__metadata("design:paramtypes", [Array,
|
|
3348
|
+
__metadata("design:paramtypes", [Array, String, Object]),
|
|
3350
3349
|
__metadata("design:returntype", Promise)
|
|
3351
3350
|
], CategoryFirestoreRepository.prototype, "getCategoriesForHome", null);
|
|
3352
3351
|
__decorate([
|
|
@@ -4915,7 +4914,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4915
4914
|
});
|
|
4916
4915
|
return data;
|
|
4917
4916
|
}
|
|
4918
|
-
async getCategoriesForHome(categoryIds, limit = 4
|
|
4917
|
+
async getCategoriesForHome(categoryIds, gender, limit = 4) {
|
|
4919
4918
|
if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
|
|
4920
4919
|
return [];
|
|
4921
4920
|
const categoriesFirestore = categoryIds.filter((categoryId) => Number.isNaN(+categoryId));
|
|
@@ -4941,8 +4940,13 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4941
4940
|
var _a;
|
|
4942
4941
|
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
4943
4942
|
return [];
|
|
4943
|
+
const shop = options.gender === 'female' ? Shops.GLAMSHOP : Shops.MENSMARKET;
|
|
4944
|
+
const mostRelevants = category.getMostRelevantByShop(shop);
|
|
4945
|
+
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(category.products))].slice(0, options.limit);
|
|
4944
4946
|
const products = [];
|
|
4945
|
-
const { data: productsData } = await this.productRepository.find(Object.assign(Object.assign({ filters: Object.assign(Object.assign({ id: { operator: Where.IN, value:
|
|
4947
|
+
const { data: productsData } = await this.productRepository.find(Object.assign(Object.assign({ filters: Object.assign(Object.assign({ id: { operator: Where.IN, value: mostRelevantProductsIds }, published: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: Where.GT, value: 0 } } } : {})), ((options === null || options === void 0 ? void 0 : options.gender)
|
|
4948
|
+
? { gender: { operator: Where.IN, value: [options === null || options === void 0 ? void 0 : options.gender, 'unisex'] } }
|
|
4949
|
+
: {})), fields: [
|
|
4946
4950
|
'id',
|
|
4947
4951
|
'name',
|
|
4948
4952
|
'slug',
|
|
@@ -4969,7 +4973,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4969
4973
|
'gender',
|
|
4970
4974
|
'createdAt',
|
|
4971
4975
|
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})), { options: { enableCount: false } }));
|
|
4972
|
-
products.push(...productsData);
|
|
4976
|
+
products.push(...productsData.sort((a, b) => mostRelevants.indexOf(a.id) - mostRelevants.indexOf(b.id)));
|
|
4973
4977
|
return products;
|
|
4974
4978
|
}
|
|
4975
4979
|
async getChildren(parentId) {
|
|
@@ -5144,7 +5148,7 @@ __decorate([
|
|
|
5144
5148
|
__decorate([
|
|
5145
5149
|
Log(),
|
|
5146
5150
|
__metadata("design:type", Function),
|
|
5147
|
-
__metadata("design:paramtypes", [Array,
|
|
5151
|
+
__metadata("design:paramtypes", [Array, String, Object]),
|
|
5148
5152
|
__metadata("design:returntype", Promise)
|
|
5149
5153
|
], CategoryHasuraGraphQLRepository.prototype, "getCategoriesForHome", null);
|
|
5150
5154
|
__decorate([
|
|
@@ -6281,7 +6285,7 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6281
6285
|
value: [PersonTypes.BFLU, PersonTypes.GLAMGIRL],
|
|
6282
6286
|
} }), orderBy: Object.assign({ personHasPhoto: 'desc' }, omit(params.orderBy, ['personHasPhoto'])) }));
|
|
6283
6287
|
}
|
|
6284
|
-
getCategoriesForHome(categoryIds,
|
|
6288
|
+
getCategoriesForHome(categoryIds, gender, limit) {
|
|
6285
6289
|
return;
|
|
6286
6290
|
}
|
|
6287
6291
|
mountCategory(category, options) {
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { CrudRepository } from '../../generic/repository/crud.repository';
|
|
2
|
-
import { Product } from '../models';
|
|
2
|
+
import { Product, ProductGender } from '../models';
|
|
3
3
|
import { Category } from '../models/category';
|
|
4
4
|
import { Shops } from '../models/enums/shops.enum';
|
|
5
5
|
export interface CategoryRepository<T extends Category = Category> extends CrudRepository<T> {
|
|
6
6
|
getCategoryBySlug(slug: string, shop: Shops): Promise<Category>;
|
|
7
7
|
getCategoryByShop(shop: string): Promise<Category[]>;
|
|
8
|
-
getCategoriesForHome(categoryIds: string[],
|
|
8
|
+
getCategoriesForHome(categoryIds: string[], gender?: ProductGender, limit?: number): Promise<{
|
|
9
9
|
category: Category;
|
|
10
10
|
products: Product[];
|
|
11
11
|
}[]>;
|
package/src/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ declare const CategoryFirestoreRepository_base: import("../../../../../utils").M
|
|
|
4
4
|
export declare class CategoryFirestoreRepository extends CategoryFirestoreRepository_base implements CategoryRepository {
|
|
5
5
|
constructor({ firestore, interceptors }: Pick<FirestoreConstructorParams<Category>, 'firestore' | 'interceptors'>);
|
|
6
6
|
getCategoryBySlug(slug: string, shop: Shops): Promise<Category>;
|
|
7
|
-
getCategoriesForHome(categoryIds: string[],
|
|
7
|
+
getCategoriesForHome(categoryIds: string[], gender?: string, limit?: number): Promise<{
|
|
8
8
|
category: Category;
|
|
9
9
|
products: Product[];
|
|
10
10
|
}[]>;
|
package/src/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Category, CategoryRepository, CreateRepositoryParams, GetRepositoryParams, Product, Shops, UpdateRepositoryParams } from '../../../../domain';
|
|
1
|
+
import { Category, CategoryRepository, CreateRepositoryParams, GetRepositoryParams, Product, ProductGender, Shops, UpdateRepositoryParams } from '../../../../domain';
|
|
2
2
|
import { HasuraConstructorParams } from '../../mixins';
|
|
3
3
|
import { CategoryHasuraGraphQL } from '../../models';
|
|
4
4
|
import { CategoryFilterHasuraGraphQLRepository } from './category-filter-hasura-graphql.repository';
|
|
@@ -15,7 +15,7 @@ export declare class CategoryHasuraGraphQLRepository extends CategoryHasuraGraph
|
|
|
15
15
|
update(params: UpdateRepositoryParams<CategoryHasuraGraphQL>): Promise<CategoryHasuraGraphQL>;
|
|
16
16
|
getCategoryBySlug(slug: string, shop: Shops): Promise<Category>;
|
|
17
17
|
getCategoryByShop(shop: string): Promise<Category[]>;
|
|
18
|
-
getCategoriesForHome(categoryIds: string[],
|
|
18
|
+
getCategoriesForHome(categoryIds: string[], gender: ProductGender, limit?: number): Promise<{
|
|
19
19
|
category: Category;
|
|
20
20
|
products: Product[];
|
|
21
21
|
}[]>;
|
package/src/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare class WishlistHasuraGraphQLRepository extends WishlistHasuraGraph
|
|
|
17
17
|
getCategoryBySlug(slug: string, _shop: Shops): Promise<Wishlist>;
|
|
18
18
|
getCategoryByShop(shop: string): Promise<any>;
|
|
19
19
|
findBfluOrGlamgirlWishlists(params: FindRepositoryParams<WishlistHasuraGraphQL>, shops: Shops[]): Promise<RepositoryFindResult<WishlistHasuraGraphQL>>;
|
|
20
|
-
getCategoriesForHome(categoryIds: string[],
|
|
20
|
+
getCategoriesForHome(categoryIds: string[], gender?: string, limit?: number): any;
|
|
21
21
|
mountCategory(category: Category, options?: {
|
|
22
22
|
limit?: number;
|
|
23
23
|
hasStock?: boolean;
|