@infrab4a/connect 4.16.1-beta.1 → 4.16.1-beta.3
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 +16 -15
- package/index.esm.js +16 -15
- 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));
|
|
@@ -4932,27 +4932,28 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4932
4932
|
}).then(({ data }) => data)));
|
|
4933
4933
|
if (categoriesHasura.length)
|
|
4934
4934
|
categories.push(...(await this.find({
|
|
4935
|
-
filters: {
|
|
4935
|
+
filters: {
|
|
4936
|
+
id: { operator: exports.Where.IN, value: categoriesHasura.filter(Boolean) },
|
|
4937
|
+
// shops: { operator: Where.IN, value: [shop] },
|
|
4938
|
+
published: true,
|
|
4939
|
+
},
|
|
4936
4940
|
}).then(({ data }) => data)));
|
|
4937
4941
|
if (!categories.length)
|
|
4938
4942
|
return [];
|
|
4939
4943
|
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
4940
4944
|
category,
|
|
4941
|
-
products: await this.mountCategory(category, { limit, hasStock: true
|
|
4945
|
+
products: await this.mountCategory(category, shop, { limit, hasStock: true }),
|
|
4942
4946
|
})));
|
|
4943
4947
|
return homeSections;
|
|
4944
4948
|
}
|
|
4945
|
-
async mountCategory(category, options) {
|
|
4949
|
+
async mountCategory(category, shop, options) {
|
|
4946
4950
|
var _a;
|
|
4947
4951
|
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
4948
4952
|
return [];
|
|
4949
|
-
const shop = options.gender === 'female' ? exports.Shops.GLAMSHOP : exports.Shops.MENSMARKET;
|
|
4950
4953
|
const mostRelevants = category.getMostRelevantByShop(shop);
|
|
4951
|
-
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(category.products))]
|
|
4954
|
+
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(category.products))];
|
|
4952
4955
|
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: [
|
|
4956
|
+
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
4957
|
'id',
|
|
4957
4958
|
'name',
|
|
4958
4959
|
'slug',
|
|
@@ -5160,7 +5161,7 @@ tslib.__decorate([
|
|
|
5160
5161
|
tslib.__decorate([
|
|
5161
5162
|
Log(),
|
|
5162
5163
|
tslib.__metadata("design:type", Function),
|
|
5163
|
-
tslib.__metadata("design:paramtypes", [Category, Object]),
|
|
5164
|
+
tslib.__metadata("design:paramtypes", [Category, String, Object]),
|
|
5164
5165
|
tslib.__metadata("design:returntype", Promise)
|
|
5165
5166
|
], CategoryHasuraGraphQLRepository.prototype, "mountCategory", null);
|
|
5166
5167
|
tslib.__decorate([
|
|
@@ -6294,7 +6295,7 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6294
6295
|
getCategoriesForHome(categoryIds, gender, limit) {
|
|
6295
6296
|
return;
|
|
6296
6297
|
}
|
|
6297
|
-
mountCategory(category, options) {
|
|
6298
|
+
mountCategory(category, shop, options) {
|
|
6298
6299
|
return;
|
|
6299
6300
|
}
|
|
6300
6301
|
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));
|
|
@@ -4926,27 +4926,28 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
4926
4926
|
}).then(({ data }) => data)));
|
|
4927
4927
|
if (categoriesHasura.length)
|
|
4928
4928
|
categories.push(...(await this.find({
|
|
4929
|
-
filters: {
|
|
4929
|
+
filters: {
|
|
4930
|
+
id: { operator: Where.IN, value: categoriesHasura.filter(Boolean) },
|
|
4931
|
+
// shops: { operator: Where.IN, value: [shop] },
|
|
4932
|
+
published: true,
|
|
4933
|
+
},
|
|
4930
4934
|
}).then(({ data }) => data)));
|
|
4931
4935
|
if (!categories.length)
|
|
4932
4936
|
return [];
|
|
4933
4937
|
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
4934
4938
|
category,
|
|
4935
|
-
products: await this.mountCategory(category, { limit, hasStock: true
|
|
4939
|
+
products: await this.mountCategory(category, shop, { limit, hasStock: true }),
|
|
4936
4940
|
})));
|
|
4937
4941
|
return homeSections;
|
|
4938
4942
|
}
|
|
4939
|
-
async mountCategory(category, options) {
|
|
4943
|
+
async mountCategory(category, shop, options) {
|
|
4940
4944
|
var _a;
|
|
4941
4945
|
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
4942
4946
|
return [];
|
|
4943
|
-
const shop = options.gender === 'female' ? Shops.GLAMSHOP : Shops.MENSMARKET;
|
|
4944
4947
|
const mostRelevants = category.getMostRelevantByShop(shop);
|
|
4945
|
-
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(category.products))]
|
|
4948
|
+
const mostRelevantProductsIds = [...new Set(mostRelevants.concat(category.products))];
|
|
4946
4949
|
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: [
|
|
4950
|
+
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
4951
|
'id',
|
|
4951
4952
|
'name',
|
|
4952
4953
|
'slug',
|
|
@@ -5154,7 +5155,7 @@ __decorate([
|
|
|
5154
5155
|
__decorate([
|
|
5155
5156
|
Log(),
|
|
5156
5157
|
__metadata("design:type", Function),
|
|
5157
|
-
__metadata("design:paramtypes", [Category, Object]),
|
|
5158
|
+
__metadata("design:paramtypes", [Category, String, Object]),
|
|
5158
5159
|
__metadata("design:returntype", Promise)
|
|
5159
5160
|
], CategoryHasuraGraphQLRepository.prototype, "mountCategory", null);
|
|
5160
5161
|
__decorate([
|
|
@@ -6288,7 +6289,7 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6288
6289
|
getCategoriesForHome(categoryIds, gender, limit) {
|
|
6289
6290
|
return;
|
|
6290
6291
|
}
|
|
6291
|
-
mountCategory(category, options) {
|
|
6292
|
+
mountCategory(category, shop, options) {
|
|
6292
6293
|
return;
|
|
6293
6294
|
}
|
|
6294
6295
|
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[]>;
|