@infrab4a/connect 4.25.0-beta.2 → 4.25.0-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
CHANGED
|
@@ -5048,7 +5048,7 @@ const withGetHasuraGraphQL = (MixinBase) => {
|
|
|
5048
5048
|
return CacheKeyGeneratorHelper.generateCacheKeyFromIdentifiers(this.model, identifiers);
|
|
5049
5049
|
}
|
|
5050
5050
|
async get(identifiers, options) {
|
|
5051
|
-
var _a, _b, _c, _d;
|
|
5051
|
+
var _a, _b, _c, _d, _e;
|
|
5052
5052
|
this.logger = DebugHelper.from(this, 'get');
|
|
5053
5053
|
if (((_a = this.cache) === null || _a === void 0 ? void 0 : _a.cacheAdapter) && ((_b = options === null || options === void 0 ? void 0 : options.cache) === null || _b === void 0 ? void 0 : _b.enabled)) {
|
|
5054
5054
|
const cacheKey = this.generateCacheKey(identifiers);
|
|
@@ -5082,7 +5082,7 @@ const withGetHasuraGraphQL = (MixinBase) => {
|
|
|
5082
5082
|
await this.cache.cacheAdapter.set({
|
|
5083
5083
|
key: cacheKey,
|
|
5084
5084
|
data: JSON.stringify(resultModel.toPlain()),
|
|
5085
|
-
expirationInSeconds: this.cache.ttlDefault,
|
|
5085
|
+
expirationInSeconds: ((_e = options === null || options === void 0 ? void 0 : options.cache) === null || _e === void 0 ? void 0 : _e.ttl) || this.cache.ttlDefault,
|
|
5086
5086
|
});
|
|
5087
5087
|
this.logger.log(`Dados salvos no cache: ${cacheKey}`);
|
|
5088
5088
|
}
|
|
@@ -5135,7 +5135,7 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
5135
5135
|
});
|
|
5136
5136
|
}
|
|
5137
5137
|
async find(params, options) {
|
|
5138
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
5138
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
5139
5139
|
this.logger = DebugHelper.from(this, 'find');
|
|
5140
5140
|
if (((_a = this.cache) === null || _a === void 0 ? void 0 : _a.cacheAdapter) && ((_b = options === null || options === void 0 ? void 0 : options.cache) === null || _b === void 0 ? void 0 : _b.enabled)) {
|
|
5141
5141
|
const cacheKey = generateCacheKey(this.model, params);
|
|
@@ -5246,7 +5246,7 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
5246
5246
|
await this.cache.cacheAdapter.set({
|
|
5247
5247
|
key: cacheKey,
|
|
5248
5248
|
data: JSON.stringify(findResult),
|
|
5249
|
-
expirationInSeconds: this.cache.ttlDefault,
|
|
5249
|
+
expirationInSeconds: ((_m = options === null || options === void 0 ? void 0 : options.cache) === null || _m === void 0 ? void 0 : _m.ttl) || this.cache.ttlDefault,
|
|
5250
5250
|
});
|
|
5251
5251
|
this.logger.log(`Dados salvos no cache: ${cacheKey}`);
|
|
5252
5252
|
}
|
|
@@ -5568,11 +5568,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5568
5568
|
},
|
|
5569
5569
|
} }));
|
|
5570
5570
|
}
|
|
5571
|
-
async get(identifiers) {
|
|
5571
|
+
async get(identifiers, optionsCache) {
|
|
5572
5572
|
var _a;
|
|
5573
5573
|
return Number.isNaN(+identifiers.id)
|
|
5574
|
-
? (_a = (await this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } }))
|
|
5575
|
-
|
|
5574
|
+
? (_a = (await this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } }, optionsCache))
|
|
5575
|
+
.data) === null || _a === void 0 ? void 0 : _a[0]
|
|
5576
|
+
: super.get(identifiers, optionsCache);
|
|
5576
5577
|
}
|
|
5577
5578
|
async update(params) {
|
|
5578
5579
|
const { products, id: checkId, metadatas, filters } = params, data = tslib.__rest(params, ["products", "id", "metadatas", "filters"]);
|
|
@@ -5584,7 +5585,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5584
5585
|
category.filters = filters && (await this.updateFilters(+id, { filters }));
|
|
5585
5586
|
return category;
|
|
5586
5587
|
}
|
|
5587
|
-
async getCategoryBySlug(slug, shop) {
|
|
5588
|
+
async getCategoryBySlug(slug, shop, optionsCache) {
|
|
5588
5589
|
if (!slug)
|
|
5589
5590
|
return null;
|
|
5590
5591
|
const { data } = await this.find({
|
|
@@ -5596,14 +5597,14 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5596
5597
|
options: {
|
|
5597
5598
|
enableCount: false,
|
|
5598
5599
|
},
|
|
5599
|
-
});
|
|
5600
|
+
}, optionsCache);
|
|
5600
5601
|
if (!data.length)
|
|
5601
5602
|
throw new NotFoundError(`Category with slug ${slug} not found`);
|
|
5602
5603
|
if (data.length > 1)
|
|
5603
5604
|
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
5604
5605
|
return data.shift();
|
|
5605
5606
|
}
|
|
5606
|
-
async getCategoryByShop(shop) {
|
|
5607
|
+
async getCategoryByShop(shop, optionsCache) {
|
|
5607
5608
|
if (!shop)
|
|
5608
5609
|
return;
|
|
5609
5610
|
const { data } = await this.find({
|
|
@@ -5615,10 +5616,10 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5615
5616
|
options: {
|
|
5616
5617
|
enableCount: false,
|
|
5617
5618
|
},
|
|
5618
|
-
});
|
|
5619
|
+
}, optionsCache);
|
|
5619
5620
|
return data;
|
|
5620
5621
|
}
|
|
5621
|
-
async getCategoriesForHome(categoryIds, shop, limit = 4) {
|
|
5622
|
+
async getCategoriesForHome(categoryIds, shop, limit = 4, optionsCache) {
|
|
5622
5623
|
if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
|
|
5623
5624
|
return [];
|
|
5624
5625
|
const categoriesFirestore = categoryIds.filter((categoryId) => Number.isNaN(+categoryId));
|
|
@@ -5626,24 +5627,27 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5626
5627
|
const categories = [];
|
|
5627
5628
|
if (categoriesFirestore.length)
|
|
5628
5629
|
categories.push(...(await this.find({
|
|
5629
|
-
filters: {
|
|
5630
|
-
|
|
5630
|
+
filters: {
|
|
5631
|
+
firestoreId: { operator: exports.Where.IN, value: categoriesFirestore.filter(Boolean) },
|
|
5632
|
+
published: true,
|
|
5633
|
+
},
|
|
5634
|
+
}, optionsCache).then(({ data }) => data)));
|
|
5631
5635
|
if (categoriesHasura.length)
|
|
5632
5636
|
categories.push(...(await this.find({
|
|
5633
5637
|
filters: {
|
|
5634
5638
|
id: { operator: exports.Where.IN, value: categoriesHasura.filter(Boolean) },
|
|
5635
5639
|
published: true,
|
|
5636
5640
|
},
|
|
5637
|
-
}).then(({ data }) => data)));
|
|
5641
|
+
}, optionsCache).then(({ data }) => data)));
|
|
5638
5642
|
if (!categories.length)
|
|
5639
5643
|
return [];
|
|
5640
5644
|
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
5641
5645
|
category,
|
|
5642
|
-
products: await this.mountCategory(category, shop, { limit, hasStock: true }),
|
|
5646
|
+
products: await this.mountCategory(category, shop, { limit, hasStock: true }, optionsCache),
|
|
5643
5647
|
})));
|
|
5644
5648
|
return homeSections;
|
|
5645
5649
|
}
|
|
5646
|
-
async mountCategory(category, shop, options) {
|
|
5650
|
+
async mountCategory(category, shop, options, optionsCache) {
|
|
5647
5651
|
var _a;
|
|
5648
5652
|
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
5649
5653
|
return [];
|
|
@@ -5689,7 +5693,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5689
5693
|
stock: 'desc',
|
|
5690
5694
|
name: 'asc',
|
|
5691
5695
|
},
|
|
5692
|
-
}, shop === exports.Shops.MENSMARKET ? 'male' : 'female');
|
|
5696
|
+
}, shop === exports.Shops.MENSMARKET ? 'male' : 'female', optionsCache);
|
|
5693
5697
|
const mostRelevantWithouyStock = productsData.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
|
|
5694
5698
|
const firstProducts = productsData
|
|
5695
5699
|
.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity > 0)
|
|
@@ -5702,7 +5706,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5702
5706
|
products.push(...resultFinal);
|
|
5703
5707
|
return products;
|
|
5704
5708
|
}
|
|
5705
|
-
async getChildren(parentId) {
|
|
5709
|
+
async getChildren(parentId, _optionsCache) {
|
|
5706
5710
|
const { category_tree } = await this.query('category_tree', ['id', 'name', 'parent_id', 'slug', 'reference', 'published', 'shops'], {
|
|
5707
5711
|
args: {
|
|
5708
5712
|
type: 'category_tree_args',
|
|
@@ -5840,31 +5844,31 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5840
5844
|
tslib.__decorate([
|
|
5841
5845
|
Log(),
|
|
5842
5846
|
tslib.__metadata("design:type", Function),
|
|
5843
|
-
tslib.__metadata("design:paramtypes", [String, String]),
|
|
5847
|
+
tslib.__metadata("design:paramtypes", [String, String, Object]),
|
|
5844
5848
|
tslib.__metadata("design:returntype", Promise)
|
|
5845
5849
|
], CategoryHasuraGraphQLRepository.prototype, "getCategoryBySlug", null);
|
|
5846
5850
|
tslib.__decorate([
|
|
5847
5851
|
Log(),
|
|
5848
5852
|
tslib.__metadata("design:type", Function),
|
|
5849
|
-
tslib.__metadata("design:paramtypes", [String]),
|
|
5853
|
+
tslib.__metadata("design:paramtypes", [String, Object]),
|
|
5850
5854
|
tslib.__metadata("design:returntype", Promise)
|
|
5851
5855
|
], CategoryHasuraGraphQLRepository.prototype, "getCategoryByShop", null);
|
|
5852
5856
|
tslib.__decorate([
|
|
5853
5857
|
Log(),
|
|
5854
5858
|
tslib.__metadata("design:type", Function),
|
|
5855
|
-
tslib.__metadata("design:paramtypes", [Array, String, Object]),
|
|
5859
|
+
tslib.__metadata("design:paramtypes", [Array, String, Object, Object]),
|
|
5856
5860
|
tslib.__metadata("design:returntype", Promise)
|
|
5857
5861
|
], CategoryHasuraGraphQLRepository.prototype, "getCategoriesForHome", null);
|
|
5858
5862
|
tslib.__decorate([
|
|
5859
5863
|
Log(),
|
|
5860
5864
|
tslib.__metadata("design:type", Function),
|
|
5861
|
-
tslib.__metadata("design:paramtypes", [Category, String, Object]),
|
|
5865
|
+
tslib.__metadata("design:paramtypes", [Category, String, Object, Object]),
|
|
5862
5866
|
tslib.__metadata("design:returntype", Promise)
|
|
5863
5867
|
], CategoryHasuraGraphQLRepository.prototype, "mountCategory", null);
|
|
5864
5868
|
tslib.__decorate([
|
|
5865
5869
|
Log(),
|
|
5866
5870
|
tslib.__metadata("design:type", Function),
|
|
5867
|
-
tslib.__metadata("design:paramtypes", [Number]),
|
|
5871
|
+
tslib.__metadata("design:paramtypes", [Number, Object]),
|
|
5868
5872
|
tslib.__metadata("design:returntype", Promise)
|
|
5869
5873
|
], CategoryHasuraGraphQLRepository.prototype, "getChildren", null);
|
|
5870
5874
|
tslib.__decorate([
|
package/index.esm.js
CHANGED
|
@@ -5023,7 +5023,7 @@ const withGetHasuraGraphQL = (MixinBase) => {
|
|
|
5023
5023
|
return CacheKeyGeneratorHelper.generateCacheKeyFromIdentifiers(this.model, identifiers);
|
|
5024
5024
|
}
|
|
5025
5025
|
async get(identifiers, options) {
|
|
5026
|
-
var _a, _b, _c, _d;
|
|
5026
|
+
var _a, _b, _c, _d, _e;
|
|
5027
5027
|
this.logger = DebugHelper.from(this, 'get');
|
|
5028
5028
|
if (((_a = this.cache) === null || _a === void 0 ? void 0 : _a.cacheAdapter) && ((_b = options === null || options === void 0 ? void 0 : options.cache) === null || _b === void 0 ? void 0 : _b.enabled)) {
|
|
5029
5029
|
const cacheKey = this.generateCacheKey(identifiers);
|
|
@@ -5057,7 +5057,7 @@ const withGetHasuraGraphQL = (MixinBase) => {
|
|
|
5057
5057
|
await this.cache.cacheAdapter.set({
|
|
5058
5058
|
key: cacheKey,
|
|
5059
5059
|
data: JSON.stringify(resultModel.toPlain()),
|
|
5060
|
-
expirationInSeconds: this.cache.ttlDefault,
|
|
5060
|
+
expirationInSeconds: ((_e = options === null || options === void 0 ? void 0 : options.cache) === null || _e === void 0 ? void 0 : _e.ttl) || this.cache.ttlDefault,
|
|
5061
5061
|
});
|
|
5062
5062
|
this.logger.log(`Dados salvos no cache: ${cacheKey}`);
|
|
5063
5063
|
}
|
|
@@ -5110,7 +5110,7 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
5110
5110
|
});
|
|
5111
5111
|
}
|
|
5112
5112
|
async find(params, options) {
|
|
5113
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
5113
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
5114
5114
|
this.logger = DebugHelper.from(this, 'find');
|
|
5115
5115
|
if (((_a = this.cache) === null || _a === void 0 ? void 0 : _a.cacheAdapter) && ((_b = options === null || options === void 0 ? void 0 : options.cache) === null || _b === void 0 ? void 0 : _b.enabled)) {
|
|
5116
5116
|
const cacheKey = generateCacheKey(this.model, params);
|
|
@@ -5221,7 +5221,7 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
5221
5221
|
await this.cache.cacheAdapter.set({
|
|
5222
5222
|
key: cacheKey,
|
|
5223
5223
|
data: JSON.stringify(findResult),
|
|
5224
|
-
expirationInSeconds: this.cache.ttlDefault,
|
|
5224
|
+
expirationInSeconds: ((_m = options === null || options === void 0 ? void 0 : options.cache) === null || _m === void 0 ? void 0 : _m.ttl) || this.cache.ttlDefault,
|
|
5225
5225
|
});
|
|
5226
5226
|
this.logger.log(`Dados salvos no cache: ${cacheKey}`);
|
|
5227
5227
|
}
|
|
@@ -5543,11 +5543,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5543
5543
|
},
|
|
5544
5544
|
} }));
|
|
5545
5545
|
}
|
|
5546
|
-
async get(identifiers) {
|
|
5546
|
+
async get(identifiers, optionsCache) {
|
|
5547
5547
|
var _a;
|
|
5548
5548
|
return Number.isNaN(+identifiers.id)
|
|
5549
|
-
? (_a = (await this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } }))
|
|
5550
|
-
|
|
5549
|
+
? (_a = (await this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } }, optionsCache))
|
|
5550
|
+
.data) === null || _a === void 0 ? void 0 : _a[0]
|
|
5551
|
+
: super.get(identifiers, optionsCache);
|
|
5551
5552
|
}
|
|
5552
5553
|
async update(params) {
|
|
5553
5554
|
const { products, id: checkId, metadatas, filters } = params, data = __rest(params, ["products", "id", "metadatas", "filters"]);
|
|
@@ -5559,7 +5560,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5559
5560
|
category.filters = filters && (await this.updateFilters(+id, { filters }));
|
|
5560
5561
|
return category;
|
|
5561
5562
|
}
|
|
5562
|
-
async getCategoryBySlug(slug, shop) {
|
|
5563
|
+
async getCategoryBySlug(slug, shop, optionsCache) {
|
|
5563
5564
|
if (!slug)
|
|
5564
5565
|
return null;
|
|
5565
5566
|
const { data } = await this.find({
|
|
@@ -5571,14 +5572,14 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5571
5572
|
options: {
|
|
5572
5573
|
enableCount: false,
|
|
5573
5574
|
},
|
|
5574
|
-
});
|
|
5575
|
+
}, optionsCache);
|
|
5575
5576
|
if (!data.length)
|
|
5576
5577
|
throw new NotFoundError(`Category with slug ${slug} not found`);
|
|
5577
5578
|
if (data.length > 1)
|
|
5578
5579
|
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
5579
5580
|
return data.shift();
|
|
5580
5581
|
}
|
|
5581
|
-
async getCategoryByShop(shop) {
|
|
5582
|
+
async getCategoryByShop(shop, optionsCache) {
|
|
5582
5583
|
if (!shop)
|
|
5583
5584
|
return;
|
|
5584
5585
|
const { data } = await this.find({
|
|
@@ -5590,10 +5591,10 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5590
5591
|
options: {
|
|
5591
5592
|
enableCount: false,
|
|
5592
5593
|
},
|
|
5593
|
-
});
|
|
5594
|
+
}, optionsCache);
|
|
5594
5595
|
return data;
|
|
5595
5596
|
}
|
|
5596
|
-
async getCategoriesForHome(categoryIds, shop, limit = 4) {
|
|
5597
|
+
async getCategoriesForHome(categoryIds, shop, limit = 4, optionsCache) {
|
|
5597
5598
|
if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
|
|
5598
5599
|
return [];
|
|
5599
5600
|
const categoriesFirestore = categoryIds.filter((categoryId) => Number.isNaN(+categoryId));
|
|
@@ -5601,24 +5602,27 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5601
5602
|
const categories = [];
|
|
5602
5603
|
if (categoriesFirestore.length)
|
|
5603
5604
|
categories.push(...(await this.find({
|
|
5604
|
-
filters: {
|
|
5605
|
-
|
|
5605
|
+
filters: {
|
|
5606
|
+
firestoreId: { operator: Where.IN, value: categoriesFirestore.filter(Boolean) },
|
|
5607
|
+
published: true,
|
|
5608
|
+
},
|
|
5609
|
+
}, optionsCache).then(({ data }) => data)));
|
|
5606
5610
|
if (categoriesHasura.length)
|
|
5607
5611
|
categories.push(...(await this.find({
|
|
5608
5612
|
filters: {
|
|
5609
5613
|
id: { operator: Where.IN, value: categoriesHasura.filter(Boolean) },
|
|
5610
5614
|
published: true,
|
|
5611
5615
|
},
|
|
5612
|
-
}).then(({ data }) => data)));
|
|
5616
|
+
}, optionsCache).then(({ data }) => data)));
|
|
5613
5617
|
if (!categories.length)
|
|
5614
5618
|
return [];
|
|
5615
5619
|
const homeSections = await Promise.all(categories.map(async (category) => ({
|
|
5616
5620
|
category,
|
|
5617
|
-
products: await this.mountCategory(category, shop, { limit, hasStock: true }),
|
|
5621
|
+
products: await this.mountCategory(category, shop, { limit, hasStock: true }, optionsCache),
|
|
5618
5622
|
})));
|
|
5619
5623
|
return homeSections;
|
|
5620
5624
|
}
|
|
5621
|
-
async mountCategory(category, shop, options) {
|
|
5625
|
+
async mountCategory(category, shop, options, optionsCache) {
|
|
5622
5626
|
var _a;
|
|
5623
5627
|
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
5624
5628
|
return [];
|
|
@@ -5664,7 +5668,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5664
5668
|
stock: 'desc',
|
|
5665
5669
|
name: 'asc',
|
|
5666
5670
|
},
|
|
5667
|
-
}, shop === Shops.MENSMARKET ? 'male' : 'female');
|
|
5671
|
+
}, shop === Shops.MENSMARKET ? 'male' : 'female', optionsCache);
|
|
5668
5672
|
const mostRelevantWithouyStock = productsData.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
|
|
5669
5673
|
const firstProducts = productsData
|
|
5670
5674
|
.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity > 0)
|
|
@@ -5677,7 +5681,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5677
5681
|
products.push(...resultFinal);
|
|
5678
5682
|
return products;
|
|
5679
5683
|
}
|
|
5680
|
-
async getChildren(parentId) {
|
|
5684
|
+
async getChildren(parentId, _optionsCache) {
|
|
5681
5685
|
const { category_tree } = await this.query('category_tree', ['id', 'name', 'parent_id', 'slug', 'reference', 'published', 'shops'], {
|
|
5682
5686
|
args: {
|
|
5683
5687
|
type: 'category_tree_args',
|
|
@@ -5815,31 +5819,31 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5815
5819
|
__decorate([
|
|
5816
5820
|
Log(),
|
|
5817
5821
|
__metadata("design:type", Function),
|
|
5818
|
-
__metadata("design:paramtypes", [String, String]),
|
|
5822
|
+
__metadata("design:paramtypes", [String, String, Object]),
|
|
5819
5823
|
__metadata("design:returntype", Promise)
|
|
5820
5824
|
], CategoryHasuraGraphQLRepository.prototype, "getCategoryBySlug", null);
|
|
5821
5825
|
__decorate([
|
|
5822
5826
|
Log(),
|
|
5823
5827
|
__metadata("design:type", Function),
|
|
5824
|
-
__metadata("design:paramtypes", [String]),
|
|
5828
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
5825
5829
|
__metadata("design:returntype", Promise)
|
|
5826
5830
|
], CategoryHasuraGraphQLRepository.prototype, "getCategoryByShop", null);
|
|
5827
5831
|
__decorate([
|
|
5828
5832
|
Log(),
|
|
5829
5833
|
__metadata("design:type", Function),
|
|
5830
|
-
__metadata("design:paramtypes", [Array, String, Object]),
|
|
5834
|
+
__metadata("design:paramtypes", [Array, String, Object, Object]),
|
|
5831
5835
|
__metadata("design:returntype", Promise)
|
|
5832
5836
|
], CategoryHasuraGraphQLRepository.prototype, "getCategoriesForHome", null);
|
|
5833
5837
|
__decorate([
|
|
5834
5838
|
Log(),
|
|
5835
5839
|
__metadata("design:type", Function),
|
|
5836
|
-
__metadata("design:paramtypes", [Category, String, Object]),
|
|
5840
|
+
__metadata("design:paramtypes", [Category, String, Object, Object]),
|
|
5837
5841
|
__metadata("design:returntype", Promise)
|
|
5838
5842
|
], CategoryHasuraGraphQLRepository.prototype, "mountCategory", null);
|
|
5839
5843
|
__decorate([
|
|
5840
5844
|
Log(),
|
|
5841
5845
|
__metadata("design:type", Function),
|
|
5842
|
-
__metadata("design:paramtypes", [Number]),
|
|
5846
|
+
__metadata("design:paramtypes", [Number, Object]),
|
|
5843
5847
|
__metadata("design:returntype", Promise)
|
|
5844
5848
|
], CategoryHasuraGraphQLRepository.prototype, "getChildren", null);
|
|
5845
5849
|
__decorate([
|
package/package.json
CHANGED
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
import { CrudRepository } from '../../generic/repository/crud.repository';
|
|
2
|
+
import { RepositoryCacheOptions } from '../../generic/repository/types';
|
|
2
3
|
import { Product } from '../models';
|
|
3
4
|
import { Category } from '../models/category';
|
|
4
5
|
import { Shops } from '../models/enums/shops.enum';
|
|
5
6
|
export interface CategoryRepository<T extends Category = Category> extends CrudRepository<T> {
|
|
6
|
-
getCategoryBySlug(slug: string, shop: Shops
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
getCategoryBySlug(slug: string, shop: Shops, optionsCache?: {
|
|
8
|
+
cache?: RepositoryCacheOptions;
|
|
9
|
+
}): Promise<Category>;
|
|
10
|
+
getCategoryByShop(shop: string, optionsCache?: {
|
|
11
|
+
cache?: RepositoryCacheOptions;
|
|
12
|
+
}): Promise<Category[]>;
|
|
13
|
+
getCategoriesForHome(categoryIds: string[], shop: Shops, limit?: number, optionsCache?: {
|
|
14
|
+
cache?: RepositoryCacheOptions;
|
|
15
|
+
}): Promise<{
|
|
9
16
|
category: Category;
|
|
10
17
|
products: Product[];
|
|
11
18
|
}[]>;
|
|
12
19
|
mountCategory(category: Category, shop: Shops, options?: {
|
|
13
20
|
limit?: number;
|
|
14
21
|
hasStock?: boolean;
|
|
22
|
+
}, optionsCache?: {
|
|
23
|
+
cache?: RepositoryCacheOptions;
|
|
15
24
|
}): Promise<Product[]>;
|
|
16
|
-
getChildren(parentId: number
|
|
25
|
+
getChildren(parentId: number, optionsCache?: {
|
|
26
|
+
cache?: RepositoryCacheOptions;
|
|
27
|
+
}): Promise<Category[]>;
|
|
17
28
|
isChild(id: number, parentId: number): Promise<boolean>;
|
|
18
29
|
}
|
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, RepositoryCacheOptions, 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';
|
|
@@ -11,11 +11,19 @@ export declare class CategoryHasuraGraphQLRepository extends CategoryHasuraGraph
|
|
|
11
11
|
private readonly categoryFilterRepository;
|
|
12
12
|
constructor({ endpoint, authOptions, interceptors, cache, }: Pick<HasuraConstructorParams<CategoryHasuraGraphQL>, 'endpoint' | 'authOptions' | 'interceptors' | 'cache'>, productRepository: ProductHasuraGraphQLRepository, categoryFilterRepository: CategoryFilterHasuraGraphQLRepository);
|
|
13
13
|
create(params: CreateRepositoryParams<CategoryHasuraGraphQL>): Promise<CategoryHasuraGraphQL>;
|
|
14
|
-
get(identifiers: GetRepositoryParams<CategoryHasuraGraphQL
|
|
14
|
+
get(identifiers: GetRepositoryParams<CategoryHasuraGraphQL>, optionsCache?: {
|
|
15
|
+
cache?: RepositoryCacheOptions;
|
|
16
|
+
}): Promise<CategoryHasuraGraphQL>;
|
|
15
17
|
update(params: UpdateRepositoryParams<CategoryHasuraGraphQL>): Promise<CategoryHasuraGraphQL>;
|
|
16
|
-
getCategoryBySlug(slug: string, shop: Shops
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
getCategoryBySlug(slug: string, shop: Shops, optionsCache?: {
|
|
19
|
+
cache?: RepositoryCacheOptions;
|
|
20
|
+
}): Promise<Category>;
|
|
21
|
+
getCategoryByShop(shop: string, optionsCache?: {
|
|
22
|
+
cache?: RepositoryCacheOptions;
|
|
23
|
+
}): Promise<Category[]>;
|
|
24
|
+
getCategoriesForHome(categoryIds: string[], shop: Shops, limit?: number, optionsCache?: {
|
|
25
|
+
cache?: RepositoryCacheOptions;
|
|
26
|
+
}): Promise<{
|
|
19
27
|
category: Category;
|
|
20
28
|
products: Product[];
|
|
21
29
|
}[]>;
|
|
@@ -23,8 +31,12 @@ export declare class CategoryHasuraGraphQLRepository extends CategoryHasuraGraph
|
|
|
23
31
|
limit?: number;
|
|
24
32
|
hasStock?: boolean;
|
|
25
33
|
gender?: string;
|
|
34
|
+
}, optionsCache?: {
|
|
35
|
+
cache?: RepositoryCacheOptions;
|
|
26
36
|
}): Promise<Product[]>;
|
|
27
|
-
getChildren(parentId: number
|
|
37
|
+
getChildren(parentId: number, _optionsCache?: {
|
|
38
|
+
cache?: RepositoryCacheOptions;
|
|
39
|
+
}): Promise<Category[]>;
|
|
28
40
|
isChild(id: number, parentId: number): Promise<boolean>;
|
|
29
41
|
private getId;
|
|
30
42
|
private updateProducts;
|