@infrab4a/connect 3.9.0-beta.6 → 3.9.0-beta.8
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/bundles/infrab4a-connect.umd.js +107 -23
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/esm2015/infra/elasticsearch/adapters/elastic.adapter.js +63 -0
- package/esm2015/infra/elasticsearch/adapters/index.js +2 -2
- package/esm2015/infra/elasticsearch/indexes/products-index.js +28 -19
- package/fesm2015/infrab4a-connect.js +88 -20
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/infra/elasticsearch/adapters/elastic.adapter.d.ts +23 -0
- package/infra/elasticsearch/adapters/index.d.ts +1 -0
- package/package.json +2 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('reflect-metadata'), require('class-transformer'), require('date-fns'), require('lodash'), require('ts-custom-error'), require('axios'), require('firebase'), require('gql-query-builder')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define('@infrab4a/connect', ['exports', 'reflect-metadata', 'class-transformer', 'date-fns', 'lodash', 'ts-custom-error', 'axios', 'firebase', 'gql-query-builder'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.infrab4a = global.infrab4a || {}, global.infrab4a.connect = {}), null, global["class-transformer"], global["date-fns"], global.lodash, global["ts-custom-error"], global.axios, global.firebase, global["gql-query-builder"]));
|
|
5
|
-
})(this, (function (exports, reflectMetadata, classTransformer, dateFns, lodash, tsCustomError, axios, firebase, gqlQueryBuilder) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('reflect-metadata'), require('class-transformer'), require('date-fns'), require('lodash'), require('ts-custom-error'), require('axios'), require('@elastic/elasticsearch'), require('firebase'), require('gql-query-builder')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('@infrab4a/connect', ['exports', 'reflect-metadata', 'class-transformer', 'date-fns', 'lodash', 'ts-custom-error', 'axios', '@elastic/elasticsearch', 'firebase', 'gql-query-builder'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.infrab4a = global.infrab4a || {}, global.infrab4a.connect = {}), null, global["class-transformer"], global["date-fns"], global.lodash, global["ts-custom-error"], global.axios, global["@elastic/elasticsearch"], global.firebase, global["gql-query-builder"]));
|
|
5
|
+
})(this, (function (exports, reflectMetadata, classTransformer, dateFns, lodash, tsCustomError, axios, elasticsearch, firebase, gqlQueryBuilder) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -1856,7 +1856,81 @@
|
|
|
1856
1856
|
return AxiosAdapter;
|
|
1857
1857
|
}());
|
|
1858
1858
|
|
|
1859
|
-
|
|
1859
|
+
var ElasticAdapter = /** @class */ (function () {
|
|
1860
|
+
function ElasticAdapter(config) {
|
|
1861
|
+
this.config = config;
|
|
1862
|
+
this.client = new elasticsearch.Client(config);
|
|
1863
|
+
}
|
|
1864
|
+
ElasticAdapter.prototype.get = function (index, id) {
|
|
1865
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1866
|
+
var data, erro_1;
|
|
1867
|
+
return __generator(this, function (_a) {
|
|
1868
|
+
switch (_a.label) {
|
|
1869
|
+
case 0:
|
|
1870
|
+
_a.trys.push([0, 2, , 3]);
|
|
1871
|
+
return [4 /*yield*/, this.client.get({ index: index, id: id })];
|
|
1872
|
+
case 1:
|
|
1873
|
+
data = _a.sent();
|
|
1874
|
+
return [2 /*return*/, data._source];
|
|
1875
|
+
case 2:
|
|
1876
|
+
erro_1 = _a.sent();
|
|
1877
|
+
throw new NotFoundError(erro_1.message);
|
|
1878
|
+
case 3: return [2 /*return*/];
|
|
1879
|
+
}
|
|
1880
|
+
});
|
|
1881
|
+
});
|
|
1882
|
+
};
|
|
1883
|
+
ElasticAdapter.prototype.query = function (index, query) {
|
|
1884
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1885
|
+
var result;
|
|
1886
|
+
return __generator(this, function (_a) {
|
|
1887
|
+
switch (_a.label) {
|
|
1888
|
+
case 0: return [4 /*yield*/, this.client.search({
|
|
1889
|
+
index: index,
|
|
1890
|
+
query: query,
|
|
1891
|
+
})];
|
|
1892
|
+
case 1:
|
|
1893
|
+
result = _a.sent();
|
|
1894
|
+
return [2 /*return*/, {
|
|
1895
|
+
total: result.hits.total,
|
|
1896
|
+
hits: result.hits.hits,
|
|
1897
|
+
}];
|
|
1898
|
+
}
|
|
1899
|
+
});
|
|
1900
|
+
});
|
|
1901
|
+
};
|
|
1902
|
+
ElasticAdapter.prototype.save = function (index, data) {
|
|
1903
|
+
return this.client.index({
|
|
1904
|
+
index: index,
|
|
1905
|
+
document: data,
|
|
1906
|
+
});
|
|
1907
|
+
};
|
|
1908
|
+
ElasticAdapter.prototype.update = function (index, id, data) {
|
|
1909
|
+
try {
|
|
1910
|
+
return this.client.update({
|
|
1911
|
+
index: index,
|
|
1912
|
+
id: id,
|
|
1913
|
+
doc: data,
|
|
1914
|
+
});
|
|
1915
|
+
}
|
|
1916
|
+
catch (error) {
|
|
1917
|
+
console.log(error);
|
|
1918
|
+
throw new Error(error.message);
|
|
1919
|
+
}
|
|
1920
|
+
};
|
|
1921
|
+
ElasticAdapter.prototype.delete = function (index, id) {
|
|
1922
|
+
try {
|
|
1923
|
+
this.client.delete({
|
|
1924
|
+
index: index,
|
|
1925
|
+
id: id,
|
|
1926
|
+
});
|
|
1927
|
+
}
|
|
1928
|
+
catch (error) {
|
|
1929
|
+
console.log(error);
|
|
1930
|
+
}
|
|
1931
|
+
};
|
|
1932
|
+
return ElasticAdapter;
|
|
1933
|
+
}());
|
|
1860
1934
|
|
|
1861
1935
|
var ProductsIndex = /** @class */ (function () {
|
|
1862
1936
|
function ProductsIndex(adapter) {
|
|
@@ -1929,28 +2003,37 @@
|
|
|
1929
2003
|
filter.push({ term: { tags: shop == exports.Shops.GLAMSHOP ? 'feminino' : 'masculino' } });
|
|
1930
2004
|
}
|
|
1931
2005
|
return [4 /*yield*/, this.adapter.query(this.index, {
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
2006
|
+
size: size,
|
|
2007
|
+
_source: fields,
|
|
2008
|
+
query: {
|
|
2009
|
+
bool: {
|
|
2010
|
+
must: {
|
|
2011
|
+
multi_match: {
|
|
2012
|
+
query: "" + searchTerm,
|
|
2013
|
+
type: 'bool_prefix',
|
|
2014
|
+
fields: [
|
|
2015
|
+
'name',
|
|
2016
|
+
'name.folded',
|
|
2017
|
+
'name.search',
|
|
2018
|
+
'description',
|
|
2019
|
+
'description.search',
|
|
2020
|
+
'description.folded',
|
|
2021
|
+
'brand',
|
|
2022
|
+
'brand.search',
|
|
2023
|
+
'brand.folded',
|
|
2024
|
+
],
|
|
2025
|
+
fuzziness: 2,
|
|
1943
2026
|
},
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
2027
|
+
},
|
|
2028
|
+
should: {
|
|
2029
|
+
match_phrase_prefix: {
|
|
2030
|
+
'name.search': {
|
|
2031
|
+
query: "" + searchTerm,
|
|
2032
|
+
slop: 10,
|
|
1950
2033
|
},
|
|
1951
2034
|
},
|
|
1952
|
-
filter: filter,
|
|
1953
2035
|
},
|
|
2036
|
+
filter: filter,
|
|
1954
2037
|
},
|
|
1955
2038
|
},
|
|
1956
2039
|
})];
|
|
@@ -5602,6 +5685,7 @@
|
|
|
5602
5685
|
exports.CouponFirestoreRepository = CouponFirestoreRepository;
|
|
5603
5686
|
exports.DuplicatedResultsError = DuplicatedResultsError;
|
|
5604
5687
|
exports.Edition = Edition;
|
|
5688
|
+
exports.ElasticAdapter = ElasticAdapter;
|
|
5605
5689
|
exports.Filter = Filter;
|
|
5606
5690
|
exports.FilterHasuraGraphQLRepository = FilterHasuraGraphQLRepository;
|
|
5607
5691
|
exports.FilterOption = FilterOption;
|