@infrab4a/connect 4.25.0-beta.12 → 4.25.0-beta.13
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
|
@@ -5712,9 +5712,17 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5712
5712
|
return homeSections;
|
|
5713
5713
|
}
|
|
5714
5714
|
async mountCategory(category, shop, options, optionsCache) {
|
|
5715
|
-
var _a;
|
|
5715
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
5716
5716
|
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
5717
5717
|
return [];
|
|
5718
|
+
if (((_b = this.cache) === null || _b === void 0 ? void 0 : _b.cacheAdapter) && ((_c = optionsCache === null || optionsCache === void 0 ? void 0 : optionsCache.cache) === null || _c === void 0 ? void 0 : _c.enabled)) {
|
|
5719
|
+
const cacheKey = `${this.model.name.toLowerCase()}:mountCategory:${category.id}:${shop}:${MD5GeneratorHelper.generateMD5(options)}`;
|
|
5720
|
+
const cachedData = await this.cache.cacheAdapter.get(cacheKey);
|
|
5721
|
+
if (cachedData) {
|
|
5722
|
+
this.logger.log(`Dados recuperados do cache: ${cacheKey}`);
|
|
5723
|
+
return JSON.parse(cachedData);
|
|
5724
|
+
}
|
|
5725
|
+
}
|
|
5718
5726
|
const fields = [
|
|
5719
5727
|
'id',
|
|
5720
5728
|
'name',
|
|
@@ -5759,8 +5767,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5759
5767
|
name: 'asc',
|
|
5760
5768
|
},
|
|
5761
5769
|
}, shop === exports.Shops.MENSMARKET ? 'male' : 'female', optionsCache);
|
|
5762
|
-
if (mostRelevants.length >= mostRelevantsIds.length)
|
|
5763
|
-
|
|
5770
|
+
if (mostRelevants.length >= mostRelevantsIds.length) {
|
|
5771
|
+
const result = this.reorganizeMostRelevantsProducts(mostRelevants, mostRelevantsIds, options.limit);
|
|
5772
|
+
if (((_d = this.cache) === null || _d === void 0 ? void 0 : _d.cacheAdapter) && ((_e = optionsCache === null || optionsCache === void 0 ? void 0 : optionsCache.cache) === null || _e === void 0 ? void 0 : _e.enabled))
|
|
5773
|
+
await this.saveToCache(category, shop, options, optionsCache, result);
|
|
5774
|
+
return result;
|
|
5775
|
+
}
|
|
5764
5776
|
products.push(...mostRelevants);
|
|
5765
5777
|
}
|
|
5766
5778
|
const productIds = category.products.filter((productId) => !mostRelevantsIds.includes(productId));
|
|
@@ -5773,7 +5785,10 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5773
5785
|
rate: 'desc',
|
|
5774
5786
|
name: 'asc',
|
|
5775
5787
|
} }), shop === exports.Shops.MENSMARKET ? 'male' : 'female', optionsCache);
|
|
5776
|
-
|
|
5788
|
+
const result = this.reorganizeMostRelevantsProducts([...products, ...productsData], mostRelevantsIds, options.limit);
|
|
5789
|
+
if (((_f = this.cache) === null || _f === void 0 ? void 0 : _f.cacheAdapter) && ((_g = optionsCache === null || optionsCache === void 0 ? void 0 : optionsCache.cache) === null || _g === void 0 ? void 0 : _g.enabled))
|
|
5790
|
+
await this.saveToCache(category, shop, options, optionsCache, result);
|
|
5791
|
+
return result;
|
|
5777
5792
|
}
|
|
5778
5793
|
async getChildren(parentId, _optionsCache) {
|
|
5779
5794
|
const { category_tree } = await this.query('category_tree', ['id', 'name', 'parent_id', 'slug', 'reference', 'published', 'shops'], {
|
|
@@ -5909,6 +5924,16 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5909
5924
|
return filters;
|
|
5910
5925
|
}
|
|
5911
5926
|
}
|
|
5927
|
+
async saveToCache(category, shop, options, optionsCache, result) {
|
|
5928
|
+
var _a;
|
|
5929
|
+
const cacheKey = `${this.model.name.toLowerCase()}:mountCategory:${category.id}:${shop}:${MD5GeneratorHelper.generateMD5(options)}`;
|
|
5930
|
+
await this.cache.cacheAdapter.set({
|
|
5931
|
+
key: cacheKey,
|
|
5932
|
+
data: JSON.stringify(result),
|
|
5933
|
+
expirationInSeconds: ((_a = optionsCache === null || optionsCache === void 0 ? void 0 : optionsCache.cache) === null || _a === void 0 ? void 0 : _a.ttl) || this.cache.ttlDefault,
|
|
5934
|
+
});
|
|
5935
|
+
this.logger.log(`Dados salvos no cache: ${cacheKey}`);
|
|
5936
|
+
}
|
|
5912
5937
|
}
|
|
5913
5938
|
tslib.__decorate([
|
|
5914
5939
|
Log(),
|
|
@@ -5929,6 +5954,7 @@ tslib.__decorate([
|
|
|
5929
5954
|
tslib.__metadata("design:returntype", Promise)
|
|
5930
5955
|
], CategoryHasuraGraphQLRepository.prototype, "getCategoriesForHome", null);
|
|
5931
5956
|
tslib.__decorate([
|
|
5957
|
+
Log(),
|
|
5932
5958
|
Log(),
|
|
5933
5959
|
tslib.__metadata("design:type", Function),
|
|
5934
5960
|
tslib.__metadata("design:paramtypes", [Category, String, Object, Object]),
|
package/index.esm.js
CHANGED
|
@@ -5706,9 +5706,17 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5706
5706
|
return homeSections;
|
|
5707
5707
|
}
|
|
5708
5708
|
async mountCategory(category, shop, options, optionsCache) {
|
|
5709
|
-
var _a;
|
|
5709
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
5710
5710
|
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
5711
5711
|
return [];
|
|
5712
|
+
if (((_b = this.cache) === null || _b === void 0 ? void 0 : _b.cacheAdapter) && ((_c = optionsCache === null || optionsCache === void 0 ? void 0 : optionsCache.cache) === null || _c === void 0 ? void 0 : _c.enabled)) {
|
|
5713
|
+
const cacheKey = `${this.model.name.toLowerCase()}:mountCategory:${category.id}:${shop}:${MD5GeneratorHelper.generateMD5(options)}`;
|
|
5714
|
+
const cachedData = await this.cache.cacheAdapter.get(cacheKey);
|
|
5715
|
+
if (cachedData) {
|
|
5716
|
+
this.logger.log(`Dados recuperados do cache: ${cacheKey}`);
|
|
5717
|
+
return JSON.parse(cachedData);
|
|
5718
|
+
}
|
|
5719
|
+
}
|
|
5712
5720
|
const fields = [
|
|
5713
5721
|
'id',
|
|
5714
5722
|
'name',
|
|
@@ -5753,8 +5761,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5753
5761
|
name: 'asc',
|
|
5754
5762
|
},
|
|
5755
5763
|
}, shop === Shops.MENSMARKET ? 'male' : 'female', optionsCache);
|
|
5756
|
-
if (mostRelevants.length >= mostRelevantsIds.length)
|
|
5757
|
-
|
|
5764
|
+
if (mostRelevants.length >= mostRelevantsIds.length) {
|
|
5765
|
+
const result = this.reorganizeMostRelevantsProducts(mostRelevants, mostRelevantsIds, options.limit);
|
|
5766
|
+
if (((_d = this.cache) === null || _d === void 0 ? void 0 : _d.cacheAdapter) && ((_e = optionsCache === null || optionsCache === void 0 ? void 0 : optionsCache.cache) === null || _e === void 0 ? void 0 : _e.enabled))
|
|
5767
|
+
await this.saveToCache(category, shop, options, optionsCache, result);
|
|
5768
|
+
return result;
|
|
5769
|
+
}
|
|
5758
5770
|
products.push(...mostRelevants);
|
|
5759
5771
|
}
|
|
5760
5772
|
const productIds = category.products.filter((productId) => !mostRelevantsIds.includes(productId));
|
|
@@ -5767,7 +5779,10 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5767
5779
|
rate: 'desc',
|
|
5768
5780
|
name: 'asc',
|
|
5769
5781
|
} }), shop === Shops.MENSMARKET ? 'male' : 'female', optionsCache);
|
|
5770
|
-
|
|
5782
|
+
const result = this.reorganizeMostRelevantsProducts([...products, ...productsData], mostRelevantsIds, options.limit);
|
|
5783
|
+
if (((_f = this.cache) === null || _f === void 0 ? void 0 : _f.cacheAdapter) && ((_g = optionsCache === null || optionsCache === void 0 ? void 0 : optionsCache.cache) === null || _g === void 0 ? void 0 : _g.enabled))
|
|
5784
|
+
await this.saveToCache(category, shop, options, optionsCache, result);
|
|
5785
|
+
return result;
|
|
5771
5786
|
}
|
|
5772
5787
|
async getChildren(parentId, _optionsCache) {
|
|
5773
5788
|
const { category_tree } = await this.query('category_tree', ['id', 'name', 'parent_id', 'slug', 'reference', 'published', 'shops'], {
|
|
@@ -5903,6 +5918,16 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
5903
5918
|
return filters;
|
|
5904
5919
|
}
|
|
5905
5920
|
}
|
|
5921
|
+
async saveToCache(category, shop, options, optionsCache, result) {
|
|
5922
|
+
var _a;
|
|
5923
|
+
const cacheKey = `${this.model.name.toLowerCase()}:mountCategory:${category.id}:${shop}:${MD5GeneratorHelper.generateMD5(options)}`;
|
|
5924
|
+
await this.cache.cacheAdapter.set({
|
|
5925
|
+
key: cacheKey,
|
|
5926
|
+
data: JSON.stringify(result),
|
|
5927
|
+
expirationInSeconds: ((_a = optionsCache === null || optionsCache === void 0 ? void 0 : optionsCache.cache) === null || _a === void 0 ? void 0 : _a.ttl) || this.cache.ttlDefault,
|
|
5928
|
+
});
|
|
5929
|
+
this.logger.log(`Dados salvos no cache: ${cacheKey}`);
|
|
5930
|
+
}
|
|
5906
5931
|
}
|
|
5907
5932
|
__decorate([
|
|
5908
5933
|
Log(),
|
|
@@ -5923,6 +5948,7 @@ __decorate([
|
|
|
5923
5948
|
__metadata("design:returntype", Promise)
|
|
5924
5949
|
], CategoryHasuraGraphQLRepository.prototype, "getCategoriesForHome", null);
|
|
5925
5950
|
__decorate([
|
|
5951
|
+
Log(),
|
|
5926
5952
|
Log(),
|
|
5927
5953
|
__metadata("design:type", Function),
|
|
5928
5954
|
__metadata("design:paramtypes", [Category, String, Object, Object]),
|
package/package.json
CHANGED