@infrab4a/connect 4.29.1-alpha.0 → 4.29.1-alpha.1

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
@@ -1908,7 +1908,7 @@ class AntifraudCardService {
1908
1908
  async checkOrderLimitsAndBlock(params) {
1909
1909
  const { checkout, orderCounts, limit, period } = params;
1910
1910
  for (const key in orderCounts) {
1911
- if (orderCounts[key] > limit) {
1911
+ if (orderCounts[key] >= limit) {
1912
1912
  await this.createBlockedOrderRecord({
1913
1913
  checkout,
1914
1914
  card: null,
@@ -1922,18 +1922,20 @@ class AntifraudCardService {
1922
1922
  return true;
1923
1923
  }
1924
1924
  async validateOrdersByRange(params, range) {
1925
- const { cpf, email, phone, zip } = params;
1926
- const [ordersCpf, ordersByEmail, ordersByPhone, ordersByZip] = await Promise.all([
1925
+ const { cpf, email, phone, zip, card } = params;
1926
+ const [ordersCpf, ordersByEmail, ordersByPhone, ordersByZip, ordersByCard] = await Promise.all([
1927
1927
  this.countOrdersByField({ property: 'user', field: 'cpf', value: cpf, range }),
1928
1928
  this.countOrdersByField({ property: 'user', field: 'email', value: email, range }),
1929
1929
  this.countOrdersByField({ property: 'user', field: 'phone', value: phone, range }),
1930
1930
  this.countOrdersByField({ property: 'shippingAddress', field: 'zip', value: zip, range }),
1931
+ this.countOrdersByField({ property: 'payment', field: 'card.id', value: card.cardId, range }),
1931
1932
  ]);
1932
1933
  return {
1933
1934
  cpf: ordersCpf,
1934
1935
  email: ordersByEmail,
1935
1936
  phone: ordersByPhone,
1936
1937
  zip: ordersByZip,
1938
+ card: ordersByCard,
1937
1939
  };
1938
1940
  }
1939
1941
  async countOrdersByField(params) {
@@ -1947,8 +1949,8 @@ class AntifraudCardService {
1947
1949
  { operator: exports.Where.LTE, value: range.lastDate },
1948
1950
  ],
1949
1951
  };
1950
- const docs = await (await this.orderRepository.find({ filters })).count;
1951
- return docs;
1952
+ const { count } = await this.orderRepository.find({ filters });
1953
+ return count;
1952
1954
  }
1953
1955
  getDateRange(range = 'day') {
1954
1956
  switch (range) {
package/index.esm.js CHANGED
@@ -1883,7 +1883,7 @@ class AntifraudCardService {
1883
1883
  async checkOrderLimitsAndBlock(params) {
1884
1884
  const { checkout, orderCounts, limit, period } = params;
1885
1885
  for (const key in orderCounts) {
1886
- if (orderCounts[key] > limit) {
1886
+ if (orderCounts[key] >= limit) {
1887
1887
  await this.createBlockedOrderRecord({
1888
1888
  checkout,
1889
1889
  card: null,
@@ -1897,18 +1897,20 @@ class AntifraudCardService {
1897
1897
  return true;
1898
1898
  }
1899
1899
  async validateOrdersByRange(params, range) {
1900
- const { cpf, email, phone, zip } = params;
1901
- const [ordersCpf, ordersByEmail, ordersByPhone, ordersByZip] = await Promise.all([
1900
+ const { cpf, email, phone, zip, card } = params;
1901
+ const [ordersCpf, ordersByEmail, ordersByPhone, ordersByZip, ordersByCard] = await Promise.all([
1902
1902
  this.countOrdersByField({ property: 'user', field: 'cpf', value: cpf, range }),
1903
1903
  this.countOrdersByField({ property: 'user', field: 'email', value: email, range }),
1904
1904
  this.countOrdersByField({ property: 'user', field: 'phone', value: phone, range }),
1905
1905
  this.countOrdersByField({ property: 'shippingAddress', field: 'zip', value: zip, range }),
1906
+ this.countOrdersByField({ property: 'payment', field: 'card.id', value: card.cardId, range }),
1906
1907
  ]);
1907
1908
  return {
1908
1909
  cpf: ordersCpf,
1909
1910
  email: ordersByEmail,
1910
1911
  phone: ordersByPhone,
1911
1912
  zip: ordersByZip,
1913
+ card: ordersByCard,
1912
1914
  };
1913
1915
  }
1914
1916
  async countOrdersByField(params) {
@@ -1922,8 +1924,8 @@ class AntifraudCardService {
1922
1924
  { operator: Where.LTE, value: range.lastDate },
1923
1925
  ],
1924
1926
  };
1925
- const docs = await (await this.orderRepository.find({ filters })).count;
1926
- return docs;
1927
+ const { count } = await this.orderRepository.find({ filters });
1928
+ return count;
1927
1929
  }
1928
1930
  getDateRange(range = 'day') {
1929
1931
  switch (range) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "4.29.1-alpha.0",
3
+ "version": "4.29.1-alpha.1",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },