@infrab4a/connect 4.16.0 → 4.16.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +12 -7
- package/index.esm.js +12 -7
- package/package.json +1 -1
- package/src/domain/catalog/repositories/category.repository.d.ts +2 -2
- 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
|
@@ -3293,7 +3293,7 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
3293
3293
|
throw new NotFoundError(`Document with slug ${slug} not found`);
|
|
3294
3294
|
return categoryDocs.docs[0].data();
|
|
3295
3295
|
}
|
|
3296
|
-
async getCategoriesForHome(categoryIds, limit = 4
|
|
3296
|
+
async getCategoriesForHome(categoryIds, gender, limit = 4) {
|
|
3297
3297
|
const categorySnap = await this.collection(this.collectionName)
|
|
3298
3298
|
.where('id', 'in', categoryIds.filter(Boolean))
|
|
3299
3299
|
.where('published', '==', true)
|
|
@@ -3351,7 +3351,7 @@ tslib.__decorate([
|
|
|
3351
3351
|
tslib.__decorate([
|
|
3352
3352
|
Log(),
|
|
3353
3353
|
tslib.__metadata("design:type", Function),
|
|
3354
|
-
tslib.__metadata("design:paramtypes", [Array,
|
|
3354
|
+
tslib.__metadata("design:paramtypes", [Array, String, Object]),
|
|
3355
3355
|
tslib.__metadata("design:returntype", Promise)
|
|
3356
3356
|
], CategoryFirestoreRepository.prototype, "getCategoriesForHome", null);
|
|
3357
3357
|
tslib.__decorate([
|
|
@@ -4920,7 +4920,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4920
4920
|
});
|
|
4921
4921
|
return data;
|
|
4922
4922
|
}
|
|
4923
|
-
async getCategoriesForHome(categoryIds, limit = 4
|
|
4923
|
+
async getCategoriesForHome(categoryIds, gender, limit = 4) {
|
|
4924
4924
|
if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
|
|
4925
4925
|
return [];
|
|
4926
4926
|
const categoriesFirestore = categoryIds.filter((categoryId) => Number.isNaN(+categoryId));
|
|
@@ -4946,8 +4946,13 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4946
4946
|
var _a;
|
|
4947
4947
|
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
4948
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);
|
|
4949
4952
|
const products = [];
|
|
4950
|
-
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: [
|
|
4951
4956
|
'id',
|
|
4952
4957
|
'name',
|
|
4953
4958
|
'slug',
|
|
@@ -4974,7 +4979,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4974
4979
|
'gender',
|
|
4975
4980
|
'createdAt',
|
|
4976
4981
|
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})), { options: { enableCount: false } }));
|
|
4977
|
-
products.push(...productsData);
|
|
4982
|
+
products.push(...productsData.sort((a, b) => mostRelevants.indexOf(a.id) - mostRelevants.indexOf(b.id)));
|
|
4978
4983
|
return products;
|
|
4979
4984
|
}
|
|
4980
4985
|
async getChildren(parentId) {
|
|
@@ -5149,7 +5154,7 @@ tslib.__decorate([
|
|
|
5149
5154
|
tslib.__decorate([
|
|
5150
5155
|
Log(),
|
|
5151
5156
|
tslib.__metadata("design:type", Function),
|
|
5152
|
-
tslib.__metadata("design:paramtypes", [Array,
|
|
5157
|
+
tslib.__metadata("design:paramtypes", [Array, String, Object]),
|
|
5153
5158
|
tslib.__metadata("design:returntype", Promise)
|
|
5154
5159
|
], CategoryHasuraGraphQLRepository.prototype, "getCategoriesForHome", null);
|
|
5155
5160
|
tslib.__decorate([
|
|
@@ -6286,7 +6291,7 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6286
6291
|
value: [exports.PersonTypes.BFLU, exports.PersonTypes.GLAMGIRL],
|
|
6287
6292
|
} }), orderBy: Object.assign({ personHasPhoto: 'desc' }, lodash.omit(params.orderBy, ['personHasPhoto'])) }));
|
|
6288
6293
|
}
|
|
6289
|
-
getCategoriesForHome(categoryIds,
|
|
6294
|
+
getCategoriesForHome(categoryIds, gender, limit) {
|
|
6290
6295
|
return;
|
|
6291
6296
|
}
|
|
6292
6297
|
mountCategory(category, options) {
|
package/index.esm.js
CHANGED
|
@@ -3287,7 +3287,7 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
3287
3287
|
throw new NotFoundError(`Document with slug ${slug} not found`);
|
|
3288
3288
|
return categoryDocs.docs[0].data();
|
|
3289
3289
|
}
|
|
3290
|
-
async getCategoriesForHome(categoryIds, limit = 4
|
|
3290
|
+
async getCategoriesForHome(categoryIds, gender, limit = 4) {
|
|
3291
3291
|
const categorySnap = await this.collection(this.collectionName)
|
|
3292
3292
|
.where('id', 'in', categoryIds.filter(Boolean))
|
|
3293
3293
|
.where('published', '==', true)
|
|
@@ -3345,7 +3345,7 @@ __decorate([
|
|
|
3345
3345
|
__decorate([
|
|
3346
3346
|
Log(),
|
|
3347
3347
|
__metadata("design:type", Function),
|
|
3348
|
-
__metadata("design:paramtypes", [Array,
|
|
3348
|
+
__metadata("design:paramtypes", [Array, String, Object]),
|
|
3349
3349
|
__metadata("design:returntype", Promise)
|
|
3350
3350
|
], CategoryFirestoreRepository.prototype, "getCategoriesForHome", null);
|
|
3351
3351
|
__decorate([
|
|
@@ -4914,7 +4914,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4914
4914
|
});
|
|
4915
4915
|
return data;
|
|
4916
4916
|
}
|
|
4917
|
-
async getCategoriesForHome(categoryIds, limit = 4
|
|
4917
|
+
async getCategoriesForHome(categoryIds, gender, limit = 4) {
|
|
4918
4918
|
if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
|
|
4919
4919
|
return [];
|
|
4920
4920
|
const categoriesFirestore = categoryIds.filter((categoryId) => Number.isNaN(+categoryId));
|
|
@@ -4940,8 +4940,13 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4940
4940
|
var _a;
|
|
4941
4941
|
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
4942
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);
|
|
4943
4946
|
const products = [];
|
|
4944
|
-
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: [
|
|
4945
4950
|
'id',
|
|
4946
4951
|
'name',
|
|
4947
4952
|
'slug',
|
|
@@ -4968,7 +4973,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4968
4973
|
'gender',
|
|
4969
4974
|
'createdAt',
|
|
4970
4975
|
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})), { options: { enableCount: false } }));
|
|
4971
|
-
products.push(...productsData);
|
|
4976
|
+
products.push(...productsData.sort((a, b) => mostRelevants.indexOf(a.id) - mostRelevants.indexOf(b.id)));
|
|
4972
4977
|
return products;
|
|
4973
4978
|
}
|
|
4974
4979
|
async getChildren(parentId) {
|
|
@@ -5143,7 +5148,7 @@ __decorate([
|
|
|
5143
5148
|
__decorate([
|
|
5144
5149
|
Log(),
|
|
5145
5150
|
__metadata("design:type", Function),
|
|
5146
|
-
__metadata("design:paramtypes", [Array,
|
|
5151
|
+
__metadata("design:paramtypes", [Array, String, Object]),
|
|
5147
5152
|
__metadata("design:returntype", Promise)
|
|
5148
5153
|
], CategoryHasuraGraphQLRepository.prototype, "getCategoriesForHome", null);
|
|
5149
5154
|
__decorate([
|
|
@@ -6280,7 +6285,7 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6280
6285
|
value: [PersonTypes.BFLU, PersonTypes.GLAMGIRL],
|
|
6281
6286
|
} }), orderBy: Object.assign({ personHasPhoto: 'desc' }, omit(params.orderBy, ['personHasPhoto'])) }));
|
|
6282
6287
|
}
|
|
6283
|
-
getCategoriesForHome(categoryIds,
|
|
6288
|
+
getCategoriesForHome(categoryIds, gender, limit) {
|
|
6284
6289
|
return;
|
|
6285
6290
|
}
|
|
6286
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;
|