@infrab4a/connect 4.16.1-beta.0 → 4.16.1-beta.2
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 +10 -13
- package/index.esm.js +10 -13
- package/package.json +1 -1
- package/src/domain/catalog/repositories/category.repository.d.ts +3 -3
- package/src/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +2 -2
- package/src/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +3 -3
- 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,
|
|
3296
|
+
async getCategoriesForHome(categoryIds, shop, limit = 4) {
|
|
3297
3297
|
const categorySnap = await this.collection(this.collectionName)
|
|
3298
3298
|
.where('id', 'in', categoryIds.filter(Boolean))
|
|
3299
3299
|
.where('published', '==', true)
|
|
@@ -3303,11 +3303,11 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
3303
3303
|
const categories = categorySnap.docs.map((doc) => doc.data());
|
|
3304
3304
|
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
3305
3305
|
category,
|
|
3306
|
-
products: await this.mountCategory(category, { limit, hasStock: true
|
|
3306
|
+
products: await this.mountCategory(category, shop, { limit, hasStock: true }),
|
|
3307
3307
|
})));
|
|
3308
3308
|
return homeSections;
|
|
3309
3309
|
}
|
|
3310
|
-
async mountCategory(category, options) {
|
|
3310
|
+
async mountCategory(category, shop, options) {
|
|
3311
3311
|
if (!category.products)
|
|
3312
3312
|
throw new RequiredArgumentError(['Category products is empty']);
|
|
3313
3313
|
const chunks = lodash.chunk(category.products, 10);
|
|
@@ -3357,7 +3357,7 @@ tslib.__decorate([
|
|
|
3357
3357
|
tslib.__decorate([
|
|
3358
3358
|
Log(),
|
|
3359
3359
|
tslib.__metadata("design:type", Function),
|
|
3360
|
-
tslib.__metadata("design:paramtypes", [Category, Object]),
|
|
3360
|
+
tslib.__metadata("design:paramtypes", [Category, String, Object]),
|
|
3361
3361
|
tslib.__metadata("design:returntype", Promise)
|
|
3362
3362
|
], CategoryFirestoreRepository.prototype, "mountCategory", null);
|
|
3363
3363
|
|
|
@@ -4920,7 +4920,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4920
4920
|
});
|
|
4921
4921
|
return data;
|
|
4922
4922
|
}
|
|
4923
|
-
async getCategoriesForHome(categoryIds,
|
|
4923
|
+
async getCategoriesForHome(categoryIds, shop, 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));
|
|
@@ -4938,21 +4938,18 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4938
4938
|
return [];
|
|
4939
4939
|
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
4940
4940
|
category,
|
|
4941
|
-
products: await this.mountCategory(category, { limit, hasStock: true
|
|
4941
|
+
products: await this.mountCategory(category, shop, { limit, hasStock: true }),
|
|
4942
4942
|
})));
|
|
4943
4943
|
return homeSections;
|
|
4944
4944
|
}
|
|
4945
|
-
async mountCategory(category, options) {
|
|
4945
|
+
async mountCategory(category, shop, options) {
|
|
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
4949
|
const mostRelevants = category.getMostRelevantByShop(shop);
|
|
4951
4950
|
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(category.products))].slice(0, options.limit);
|
|
4952
4951
|
const products = [];
|
|
4953
|
-
const { data: productsData } = await this.productRepository.find(Object.assign(Object.assign({ filters: Object.assign(
|
|
4954
|
-
? { gender: { operator: exports.Where.IN, value: [options === null || options === void 0 ? void 0 : options.gender, 'unisex'] } }
|
|
4955
|
-
: {})), fields: [
|
|
4952
|
+
const { data: productsData } = await this.productRepository.find(Object.assign(Object.assign({ filters: 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 } } } : {})), fields: [
|
|
4956
4953
|
'id',
|
|
4957
4954
|
'name',
|
|
4958
4955
|
'slug',
|
|
@@ -5160,7 +5157,7 @@ tslib.__decorate([
|
|
|
5160
5157
|
tslib.__decorate([
|
|
5161
5158
|
Log(),
|
|
5162
5159
|
tslib.__metadata("design:type", Function),
|
|
5163
|
-
tslib.__metadata("design:paramtypes", [Category, Object]),
|
|
5160
|
+
tslib.__metadata("design:paramtypes", [Category, String, Object]),
|
|
5164
5161
|
tslib.__metadata("design:returntype", Promise)
|
|
5165
5162
|
], CategoryHasuraGraphQLRepository.prototype, "mountCategory", null);
|
|
5166
5163
|
tslib.__decorate([
|
|
@@ -6294,7 +6291,7 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6294
6291
|
getCategoriesForHome(categoryIds, gender, limit) {
|
|
6295
6292
|
return;
|
|
6296
6293
|
}
|
|
6297
|
-
mountCategory(category, options) {
|
|
6294
|
+
mountCategory(category, shop, options) {
|
|
6298
6295
|
return;
|
|
6299
6296
|
}
|
|
6300
6297
|
getChildren(parentId) {
|
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,
|
|
3290
|
+
async getCategoriesForHome(categoryIds, shop, limit = 4) {
|
|
3291
3291
|
const categorySnap = await this.collection(this.collectionName)
|
|
3292
3292
|
.where('id', 'in', categoryIds.filter(Boolean))
|
|
3293
3293
|
.where('published', '==', true)
|
|
@@ -3297,11 +3297,11 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
3297
3297
|
const categories = categorySnap.docs.map((doc) => doc.data());
|
|
3298
3298
|
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
3299
3299
|
category,
|
|
3300
|
-
products: await this.mountCategory(category, { limit, hasStock: true
|
|
3300
|
+
products: await this.mountCategory(category, shop, { limit, hasStock: true }),
|
|
3301
3301
|
})));
|
|
3302
3302
|
return homeSections;
|
|
3303
3303
|
}
|
|
3304
|
-
async mountCategory(category, options) {
|
|
3304
|
+
async mountCategory(category, shop, options) {
|
|
3305
3305
|
if (!category.products)
|
|
3306
3306
|
throw new RequiredArgumentError(['Category products is empty']);
|
|
3307
3307
|
const chunks = chunk(category.products, 10);
|
|
@@ -3351,7 +3351,7 @@ __decorate([
|
|
|
3351
3351
|
__decorate([
|
|
3352
3352
|
Log(),
|
|
3353
3353
|
__metadata("design:type", Function),
|
|
3354
|
-
__metadata("design:paramtypes", [Category, Object]),
|
|
3354
|
+
__metadata("design:paramtypes", [Category, String, Object]),
|
|
3355
3355
|
__metadata("design:returntype", Promise)
|
|
3356
3356
|
], CategoryFirestoreRepository.prototype, "mountCategory", null);
|
|
3357
3357
|
|
|
@@ -4914,7 +4914,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4914
4914
|
});
|
|
4915
4915
|
return data;
|
|
4916
4916
|
}
|
|
4917
|
-
async getCategoriesForHome(categoryIds,
|
|
4917
|
+
async getCategoriesForHome(categoryIds, shop, 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));
|
|
@@ -4932,21 +4932,18 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4932
4932
|
return [];
|
|
4933
4933
|
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
4934
4934
|
category,
|
|
4935
|
-
products: await this.mountCategory(category, { limit, hasStock: true
|
|
4935
|
+
products: await this.mountCategory(category, shop, { limit, hasStock: true }),
|
|
4936
4936
|
})));
|
|
4937
4937
|
return homeSections;
|
|
4938
4938
|
}
|
|
4939
|
-
async mountCategory(category, options) {
|
|
4939
|
+
async mountCategory(category, shop, options) {
|
|
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
4943
|
const mostRelevants = category.getMostRelevantByShop(shop);
|
|
4945
4944
|
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(category.products))].slice(0, options.limit);
|
|
4946
4945
|
const products = [];
|
|
4947
|
-
const { data: productsData } = await this.productRepository.find(Object.assign(Object.assign({ filters: Object.assign(
|
|
4948
|
-
? { gender: { operator: Where.IN, value: [options === null || options === void 0 ? void 0 : options.gender, 'unisex'] } }
|
|
4949
|
-
: {})), fields: [
|
|
4946
|
+
const { data: productsData } = await this.productRepository.find(Object.assign(Object.assign({ filters: 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 } } } : {})), fields: [
|
|
4950
4947
|
'id',
|
|
4951
4948
|
'name',
|
|
4952
4949
|
'slug',
|
|
@@ -5154,7 +5151,7 @@ __decorate([
|
|
|
5154
5151
|
__decorate([
|
|
5155
5152
|
Log(),
|
|
5156
5153
|
__metadata("design:type", Function),
|
|
5157
|
-
__metadata("design:paramtypes", [Category, Object]),
|
|
5154
|
+
__metadata("design:paramtypes", [Category, String, Object]),
|
|
5158
5155
|
__metadata("design:returntype", Promise)
|
|
5159
5156
|
], CategoryHasuraGraphQLRepository.prototype, "mountCategory", null);
|
|
5160
5157
|
__decorate([
|
|
@@ -6288,7 +6285,7 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6288
6285
|
getCategoriesForHome(categoryIds, gender, limit) {
|
|
6289
6286
|
return;
|
|
6290
6287
|
}
|
|
6291
|
-
mountCategory(category, options) {
|
|
6288
|
+
mountCategory(category, shop, options) {
|
|
6292
6289
|
return;
|
|
6293
6290
|
}
|
|
6294
6291
|
getChildren(parentId) {
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { CrudRepository } from '../../generic/repository/crud.repository';
|
|
2
|
-
import { Product
|
|
2
|
+
import { Product } 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[], shop: Shops, limit?: number): Promise<{
|
|
9
9
|
category: Category;
|
|
10
10
|
products: Product[];
|
|
11
11
|
}[]>;
|
|
12
|
-
mountCategory(category: Category, options?: {
|
|
12
|
+
mountCategory(category: Category, shop: Shops, options?: {
|
|
13
13
|
limit?: number;
|
|
14
14
|
hasStock?: boolean;
|
|
15
15
|
}): Promise<Product[]>;
|
package/src/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts
CHANGED
|
@@ -4,11 +4,11 @@ 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[], shop: Shops, limit?: number): Promise<{
|
|
8
8
|
category: Category;
|
|
9
9
|
products: Product[];
|
|
10
10
|
}[]>;
|
|
11
|
-
mountCategory(category: Category, options?: {
|
|
11
|
+
mountCategory(category: Category, shop: Shops, options?: {
|
|
12
12
|
limit?: number;
|
|
13
13
|
hasStock?: boolean;
|
|
14
14
|
gender?: string;
|
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,
|
|
1
|
+
import { Category, CategoryRepository, CreateRepositoryParams, GetRepositoryParams, Product, 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,11 +15,11 @@ 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[], shop: Shops, limit?: number): Promise<{
|
|
19
19
|
category: Category;
|
|
20
20
|
products: Product[];
|
|
21
21
|
}[]>;
|
|
22
|
-
mountCategory(category: Category, options?: {
|
|
22
|
+
mountCategory(category: Category, shop: Shops, options?: {
|
|
23
23
|
limit?: number;
|
|
24
24
|
hasStock?: boolean;
|
|
25
25
|
gender?: string;
|
package/src/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export declare class WishlistHasuraGraphQLRepository extends WishlistHasuraGraph
|
|
|
18
18
|
getCategoryByShop(shop: string): Promise<any>;
|
|
19
19
|
findBfluOrGlamgirlWishlists(params: FindRepositoryParams<WishlistHasuraGraphQL>, shops: Shops[]): Promise<RepositoryFindResult<WishlistHasuraGraphQL>>;
|
|
20
20
|
getCategoriesForHome(categoryIds: string[], gender?: string, limit?: number): any;
|
|
21
|
-
mountCategory(category: Category, options?: {
|
|
21
|
+
mountCategory(category: Category, shop: Shops, options?: {
|
|
22
22
|
limit?: number;
|
|
23
23
|
hasStock?: boolean;
|
|
24
24
|
}): Promise<Product[]>;
|