@infrab4a/connect 5.0.0-alpha.9 → 5.1.0-beta.0
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 +1154 -533
- package/index.esm.js +1153 -535
- package/package.json +1 -1
- package/src/domain/shopping/enums/index.d.ts +1 -0
- package/src/domain/shopping/enums/pagarme-v5-payment-status.enum.d.ts +24 -0
- package/src/domain/shopping/models/payment-transaction.d.ts +14 -0
- package/src/domain/shopping/models/payment.d.ts +1 -0
- package/src/domain/shopping/types/index.d.ts +1 -0
- package/src/domain/shopping/types/pagarme-credentials-v5.type.d.ts +4 -0
- package/src/infra/firebase/firestore/mixins/helpers/firestore-operations.helper.d.ts +1 -1
- package/src/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +1 -1
- package/src/infra/pagarme/adapters/helpers/index.d.ts +2 -0
- package/src/infra/pagarme/adapters/helpers/pagarme-v5-request.helper.d.ts +12 -0
- package/src/infra/pagarme/adapters/helpers/pagarme-v5-response.helper.d.ts +9 -0
- package/src/infra/pagarme/adapters/index.d.ts +2 -3
- package/src/infra/pagarme/adapters/v4/index.d.ts +3 -0
- package/src/infra/pagarme/adapters/{pagarme-bank-slip-payment-axios.adapter.d.ts → v4/pagarme-bank-slip-payment-axios.adapter.d.ts} +4 -4
- package/src/infra/pagarme/adapters/{pagarme-card-payment-axios.adapter.d.ts → v4/pagarme-card-payment-axios.adapter.d.ts} +5 -5
- package/src/infra/pagarme/adapters/v4/pagarme-pix-payment-axios.adapter.d.ts +11 -0
- package/src/infra/pagarme/adapters/v5/index.d.ts +3 -0
- package/src/infra/pagarme/adapters/v5/pagarmev5-bank-slip-payment-axios.adapter.d.ts +11 -0
- package/src/infra/pagarme/adapters/v5/pagarmev5-card-payment-axios.adapter.d.ts +16 -0
- package/src/infra/pagarme/adapters/v5/pagarmev5-pix-payment-axios.adapter.d.ts +10 -0
- package/src/infra/pagarme/index.d.ts +1 -0
- package/src/infra/pagarme/types/index.d.ts +1 -0
- package/src/infra/pagarme/types/v5/index.d.ts +3 -0
- package/src/infra/pagarme/types/v5/pagarmev5-order-request-payload.type.d.ts +85 -0
- package/src/infra/pagarme/types/v5/pagarmev5-order-response.type.d.ts +126 -0
- package/src/infra/pagarme/types/v5/pagarmev5-postback-response.type.d.ts +11 -0
- package/src/utils/circular-dependencies.d.ts +0 -4
- package/src/infra/pagarme/adapters/pagarme-pix-payment-axios.adapter.d.ts +0 -11
package/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
import { __decorate, __metadata
|
|
2
|
+
import { __decorate, __metadata } from 'tslib';
|
|
3
3
|
import { plainToInstance, instanceToPlain, Type } from 'class-transformer';
|
|
4
4
|
import { parseISO, format, startOfDay, endOfDay, subDays, addDays } from 'date-fns';
|
|
5
5
|
export { add, addBusinessDays, addDays, addMonths, addYears, endOfDay, format, formatISO9075, parseISO, startOfDay, sub, subDays } from 'date-fns';
|
|
@@ -48,6 +48,33 @@ var PagarmePaymentStatus;
|
|
|
48
48
|
PagarmePaymentStatus["Chargedback"] = "chargedback";
|
|
49
49
|
})(PagarmePaymentStatus || (PagarmePaymentStatus = {}));
|
|
50
50
|
|
|
51
|
+
var PagarMeV5PaymentStatus;
|
|
52
|
+
(function (PagarMeV5PaymentStatus) {
|
|
53
|
+
PagarMeV5PaymentStatus["Em processamento"] = "processing";
|
|
54
|
+
PagarMeV5PaymentStatus["Gerado"] = "generated";
|
|
55
|
+
PagarMeV5PaymentStatus["Visualizado"] = "viewed";
|
|
56
|
+
PagarMeV5PaymentStatus["Pago a menor"] = "underpaid";
|
|
57
|
+
PagarMeV5PaymentStatus["Pago a maior"] = "overpaid";
|
|
58
|
+
PagarMeV5PaymentStatus["Aguardando pagamento"] = "waiting_payment";
|
|
59
|
+
PagarMeV5PaymentStatus["Pago"] = "paid";
|
|
60
|
+
PagarMeV5PaymentStatus["Aguardando estorno"] = "pending_refund";
|
|
61
|
+
PagarMeV5PaymentStatus["Autorizada pendente de captura"] = "authorized_pending_capture";
|
|
62
|
+
PagarMeV5PaymentStatus["N\u00E3o autorizada"] = "not_authorized";
|
|
63
|
+
PagarMeV5PaymentStatus["Capturada"] = "captured";
|
|
64
|
+
PagarMeV5PaymentStatus["Aguardando captura"] = "waiting_capture";
|
|
65
|
+
PagarMeV5PaymentStatus["Com erro"] = "with_error";
|
|
66
|
+
PagarMeV5PaymentStatus["Estornado"] = "refunded";
|
|
67
|
+
PagarMeV5PaymentStatus["Cancelado"] = "voided";
|
|
68
|
+
PagarMeV5PaymentStatus["Falha"] = "failed";
|
|
69
|
+
})(PagarMeV5PaymentStatus || (PagarMeV5PaymentStatus = {}));
|
|
70
|
+
var PagarMeV5OrderStatus;
|
|
71
|
+
(function (PagarMeV5OrderStatus) {
|
|
72
|
+
PagarMeV5OrderStatus["Pendente"] = "pending";
|
|
73
|
+
PagarMeV5OrderStatus["Pago"] = "paid";
|
|
74
|
+
PagarMeV5OrderStatus["Cancelado"] = "canceled";
|
|
75
|
+
PagarMeV5OrderStatus["Falha"] = "failed";
|
|
76
|
+
})(PagarMeV5OrderStatus || (PagarMeV5OrderStatus = {}));
|
|
77
|
+
|
|
51
78
|
var PaymentMethods;
|
|
52
79
|
(function (PaymentMethods) {
|
|
53
80
|
PaymentMethods["CARD"] = "card";
|
|
@@ -99,25 +126,15 @@ class PaymentProviderFactory {
|
|
|
99
126
|
}
|
|
100
127
|
}
|
|
101
128
|
|
|
102
|
-
/**
|
|
103
|
-
* Este arquivo define funções para resolver dependências circulares
|
|
104
|
-
* em ambiente ESM, onde não podemos usar require()
|
|
105
|
-
*/
|
|
106
|
-
// Armazenamento global para classes registradas
|
|
107
129
|
const registry = new Map();
|
|
108
|
-
// Registrar uma classe na resolução de dependências circulares
|
|
109
130
|
function registerClass(name, classConstructor) {
|
|
110
131
|
registry.set(name, classConstructor);
|
|
111
132
|
}
|
|
112
|
-
// Obter uma classe registrada
|
|
113
133
|
function getClass(name) {
|
|
114
134
|
return registry.get(name);
|
|
115
135
|
}
|
|
116
|
-
// Função de resolução para class-transformer
|
|
117
136
|
function resolveClass(name) {
|
|
118
137
|
return () => {
|
|
119
|
-
// Forçamos o retorno de uma função que retorna a classe
|
|
120
|
-
// ao invés da classe diretamente para evitar problemas com o decorator
|
|
121
138
|
return getClass(name);
|
|
122
139
|
};
|
|
123
140
|
}
|
|
@@ -191,7 +208,7 @@ class ReflectHelper {
|
|
|
191
208
|
return Reflect.getMetadata(key, target, property) || null;
|
|
192
209
|
}
|
|
193
210
|
}
|
|
194
|
-
catch
|
|
211
|
+
catch {
|
|
195
212
|
return null;
|
|
196
213
|
}
|
|
197
214
|
}
|
|
@@ -501,7 +518,7 @@ function Debug(opts) {
|
|
|
501
518
|
|
|
502
519
|
const ASYNC_IDENTIFIER = 'async';
|
|
503
520
|
function Log(options = {}) {
|
|
504
|
-
return Trace(
|
|
521
|
+
return Trace({ level: 'log', ...options });
|
|
505
522
|
}
|
|
506
523
|
function Trace(options = {}) {
|
|
507
524
|
return function (target, propertyKey, propertyDescriptor) {
|
|
@@ -601,7 +618,7 @@ class BaseModel {
|
|
|
601
618
|
get identifier() {
|
|
602
619
|
const fields = this.constructor.identifiersFields.filter((field) => field !== 'identifier');
|
|
603
620
|
const data = this;
|
|
604
|
-
return fields.reduce((object, field) => (
|
|
621
|
+
return fields.reduce((object, field) => ({ ...object, [field]: data[field] }), {});
|
|
605
622
|
}
|
|
606
623
|
get identifiersFields() {
|
|
607
624
|
return this.constructor.identifiersFields;
|
|
@@ -666,8 +683,7 @@ class Category extends BaseModel {
|
|
|
666
683
|
return ['id'];
|
|
667
684
|
}
|
|
668
685
|
get glamImages() {
|
|
669
|
-
|
|
670
|
-
return ((_a = this.images) === null || _a === void 0 ? void 0 : _a[Shops.GLAMSHOP])
|
|
686
|
+
return this.images?.[Shops.GLAMSHOP]
|
|
671
687
|
? this.images[Shops.GLAMSHOP]
|
|
672
688
|
: {
|
|
673
689
|
brandBanner: null,
|
|
@@ -676,8 +692,7 @@ class Category extends BaseModel {
|
|
|
676
692
|
};
|
|
677
693
|
}
|
|
678
694
|
get mensImages() {
|
|
679
|
-
|
|
680
|
-
return ((_a = this.images) === null || _a === void 0 ? void 0 : _a[Shops.MENSMARKET])
|
|
695
|
+
return this.images?.[Shops.MENSMARKET]
|
|
681
696
|
? this.images[Shops.MENSMARKET]
|
|
682
697
|
: {
|
|
683
698
|
brandBanner: null,
|
|
@@ -692,8 +707,7 @@ class Category extends BaseModel {
|
|
|
692
707
|
return this.metadatas.find((metadata) => metadata.shop === Shops.MENSMARKET);
|
|
693
708
|
}
|
|
694
709
|
getMostRelevantByShop(shop) {
|
|
695
|
-
|
|
696
|
-
return ((_a = this.mostRelevants) === null || _a === void 0 ? void 0 : _a[shop]) || [];
|
|
710
|
+
return this.mostRelevants?.[shop] || [];
|
|
697
711
|
}
|
|
698
712
|
}
|
|
699
713
|
__decorate([
|
|
@@ -1426,10 +1440,18 @@ class Authentication {
|
|
|
1426
1440
|
return signInMethod === SignInMethods.EMAIL_PASSWORD ? 'signInWithEmailAndPassword' : 'signInWithGoogle';
|
|
1427
1441
|
}
|
|
1428
1442
|
async createsUserByCredential(user) {
|
|
1429
|
-
|
|
1430
|
-
const
|
|
1431
|
-
|
|
1432
|
-
|
|
1443
|
+
const [firstName, lastName] = user.displayName?.split(/\s/) ?? [];
|
|
1444
|
+
const person = User.toInstance({
|
|
1445
|
+
...user,
|
|
1446
|
+
cpf: '',
|
|
1447
|
+
birthday: new Date(),
|
|
1448
|
+
firstName,
|
|
1449
|
+
lastName,
|
|
1450
|
+
acceptsNewsletter: false,
|
|
1451
|
+
area: Area.Transactional,
|
|
1452
|
+
officePosition: OfficePosition.Intern,
|
|
1453
|
+
type: UserType.Collaborator,
|
|
1454
|
+
});
|
|
1433
1455
|
return this.userRepository.create(person);
|
|
1434
1456
|
}
|
|
1435
1457
|
}
|
|
@@ -1478,8 +1500,15 @@ class Register {
|
|
|
1478
1500
|
password: params.password,
|
|
1479
1501
|
});
|
|
1480
1502
|
delete params.password;
|
|
1481
|
-
const user = await this.userRepository.create(
|
|
1482
|
-
|
|
1503
|
+
const user = await this.userRepository.create({
|
|
1504
|
+
...params,
|
|
1505
|
+
id: auth.id,
|
|
1506
|
+
email,
|
|
1507
|
+
displayName,
|
|
1508
|
+
type: UserType.B2C,
|
|
1509
|
+
dateCreated: new Date(),
|
|
1510
|
+
dateModified: new Date(),
|
|
1511
|
+
});
|
|
1483
1512
|
return user;
|
|
1484
1513
|
}
|
|
1485
1514
|
}
|
|
@@ -1673,8 +1702,7 @@ class AntifraudBankSlipService {
|
|
|
1673
1702
|
this.MAX_ORDER_VALUE = 5000;
|
|
1674
1703
|
}
|
|
1675
1704
|
async validate(checkout) {
|
|
1676
|
-
|
|
1677
|
-
if (checkout.totalPrice && checkout.totalPrice > this.MAX_ORDER_VALUE && !((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber)) {
|
|
1705
|
+
if (checkout.totalPrice && checkout.totalPrice > this.MAX_ORDER_VALUE && !checkout.user?.isSubscriber) {
|
|
1678
1706
|
await this.orderBlockedRepository.createBlockedOrderOrPayment({
|
|
1679
1707
|
checkout,
|
|
1680
1708
|
blockType: 'Boleto not authorized',
|
|
@@ -1685,7 +1713,7 @@ class AntifraudBankSlipService {
|
|
|
1685
1713
|
checkoutId: checkout.id,
|
|
1686
1714
|
userEmail: checkout.user.email,
|
|
1687
1715
|
info: {
|
|
1688
|
-
isSubscriber:
|
|
1716
|
+
isSubscriber: checkout.user?.isSubscriber,
|
|
1689
1717
|
subtotal: checkout.subTotalPrice,
|
|
1690
1718
|
total: checkout.totalPrice,
|
|
1691
1719
|
},
|
|
@@ -1709,14 +1737,13 @@ class AntifraudCardService {
|
|
|
1709
1737
|
return true;
|
|
1710
1738
|
}
|
|
1711
1739
|
async validateBlockedOrderAttempts(checkout, card) {
|
|
1712
|
-
var _a;
|
|
1713
1740
|
const isValid = await this.verifyBlockedOrderAttempts(checkout, card);
|
|
1714
1741
|
if (!isValid) {
|
|
1715
1742
|
throw new FraudValidationError('Cliente com mais de 5 compras negadas/bloqueadas no dia', {
|
|
1716
1743
|
checkoutId: checkout.id,
|
|
1717
1744
|
userEmail: checkout.user.email,
|
|
1718
1745
|
info: {
|
|
1719
|
-
isSubscriber:
|
|
1746
|
+
isSubscriber: checkout.user?.isSubscriber,
|
|
1720
1747
|
subtotal: checkout.subTotalPrice,
|
|
1721
1748
|
total: checkout.totalPrice,
|
|
1722
1749
|
},
|
|
@@ -1724,14 +1751,13 @@ class AntifraudCardService {
|
|
|
1724
1751
|
}
|
|
1725
1752
|
}
|
|
1726
1753
|
async validateDayAndWeekOrderLimits(checkout, card) {
|
|
1727
|
-
var _a;
|
|
1728
1754
|
const isValid = await this.verifyDayAndWeekOrders(checkout, card);
|
|
1729
1755
|
if (!isValid) {
|
|
1730
1756
|
throw new FraudValidationError('Cliente tentando comprar mais de 2 vezes no dia ou 7 vezes na semana', {
|
|
1731
1757
|
checkoutId: checkout.id,
|
|
1732
1758
|
userEmail: checkout.user.email,
|
|
1733
1759
|
info: {
|
|
1734
|
-
isSubscriber:
|
|
1760
|
+
isSubscriber: checkout.user?.isSubscriber,
|
|
1735
1761
|
subtotal: checkout.subTotalPrice,
|
|
1736
1762
|
total: checkout.totalPrice,
|
|
1737
1763
|
},
|
|
@@ -1760,17 +1786,16 @@ class AntifraudCardService {
|
|
|
1760
1786
|
return { day, endOfDay };
|
|
1761
1787
|
}
|
|
1762
1788
|
async getBlockedOrdersByMultipleCriteria(checkout, dateRange) {
|
|
1763
|
-
var _a, _b, _c, _d;
|
|
1764
1789
|
const { day, endOfDay } = dateRange;
|
|
1765
1790
|
const dateFilter = [
|
|
1766
1791
|
{ operator: Where.GTE, value: new Date(day) },
|
|
1767
1792
|
{ operator: Where.LTE, value: new Date(endOfDay) },
|
|
1768
1793
|
];
|
|
1769
1794
|
const [ordersBlockedWithCpf, ordersBlockedWithEmail, ordersBlockedWithCep, ordersBlockedWithPhone] = await Promise.all([
|
|
1770
|
-
this.getBlockedOrdersByCpf(
|
|
1771
|
-
this.getBlockedOrdersByEmail(
|
|
1772
|
-
this.getBlockedOrdersByZip(
|
|
1773
|
-
this.getBlockedOrdersByPhone(
|
|
1795
|
+
this.getBlockedOrdersByCpf(checkout.user?.cpf, dateFilter),
|
|
1796
|
+
this.getBlockedOrdersByEmail(checkout.user?.email, dateFilter),
|
|
1797
|
+
this.getBlockedOrdersByZip(checkout.shippingAddress?.zip, dateFilter),
|
|
1798
|
+
this.getBlockedOrdersByPhone(checkout.user?.phone, dateFilter),
|
|
1774
1799
|
]);
|
|
1775
1800
|
return {
|
|
1776
1801
|
ordersBlockedWithCpf,
|
|
@@ -1827,18 +1852,15 @@ class AntifraudCardService {
|
|
|
1827
1852
|
return ordersBlockedWithCpf.concat(blockedUniqueEmails).concat(blockedUniqueCeps).concat(blockedUniquePhone).length;
|
|
1828
1853
|
}
|
|
1829
1854
|
filterUniqueEmailBlocked(ordersBlockedWithEmail, checkout) {
|
|
1830
|
-
return ordersBlockedWithEmail.filter((e) =>
|
|
1855
|
+
return ordersBlockedWithEmail.filter((e) => e.customer.cpf !== checkout.user?.cpf);
|
|
1831
1856
|
}
|
|
1832
1857
|
filterUniqueZipBlocked(ordersBlockedWithCep, checkout) {
|
|
1833
|
-
return ordersBlockedWithCep.filter((e) =>
|
|
1858
|
+
return ordersBlockedWithCep.filter((e) => e.customer.cpf !== checkout.user?.cpf && e.customer.email !== checkout.user?.email);
|
|
1834
1859
|
}
|
|
1835
1860
|
filterUniquePhoneBlocked(ordersBlockedWithPhone, checkout) {
|
|
1836
|
-
return ordersBlockedWithPhone.filter((e) =>
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
e.customer.email !== ((_b = checkout.user) === null || _b === void 0 ? void 0 : _b.email) &&
|
|
1840
|
-
((_d = (_c = e.customer.shippingAddress) === null || _c === void 0 ? void 0 : _c.zip) === null || _d === void 0 ? void 0 : _d.toString()) !== ((_f = (_e = checkout.shippingAddress) === null || _e === void 0 ? void 0 : _e.zip) === null || _f === void 0 ? void 0 : _f.toString());
|
|
1841
|
-
});
|
|
1861
|
+
return ordersBlockedWithPhone.filter((e) => e.customer.cpf !== checkout.user?.cpf &&
|
|
1862
|
+
e.customer.email !== checkout.user?.email &&
|
|
1863
|
+
e.customer.shippingAddress?.zip?.toString() !== checkout.shippingAddress?.zip?.toString());
|
|
1842
1864
|
}
|
|
1843
1865
|
async createBlockedOrderRecord(params) {
|
|
1844
1866
|
const { checkout, card, reason, key, period } = params;
|
|
@@ -1859,12 +1881,11 @@ class AntifraudCardService {
|
|
|
1859
1881
|
return isWeekLimitValid;
|
|
1860
1882
|
}
|
|
1861
1883
|
buildValidationParams(checkout, card) {
|
|
1862
|
-
var _a, _b, _c, _d;
|
|
1863
1884
|
return {
|
|
1864
|
-
cpf:
|
|
1865
|
-
email:
|
|
1866
|
-
phone:
|
|
1867
|
-
zip:
|
|
1885
|
+
cpf: checkout.user?.cpf,
|
|
1886
|
+
email: checkout.user?.email,
|
|
1887
|
+
phone: checkout.user?.phone,
|
|
1888
|
+
zip: checkout.shippingAddress?.zip,
|
|
1868
1889
|
card,
|
|
1869
1890
|
};
|
|
1870
1891
|
}
|
|
@@ -1889,7 +1910,7 @@ class AntifraudCardService {
|
|
|
1889
1910
|
async checkOrderLimitsAndBlock(params) {
|
|
1890
1911
|
const { checkout, orderCounts, limit, period } = params;
|
|
1891
1912
|
for (const key in orderCounts) {
|
|
1892
|
-
if (orderCounts[key]
|
|
1913
|
+
if (orderCounts[key] >= limit) {
|
|
1893
1914
|
await this.createBlockedOrderRecord({
|
|
1894
1915
|
checkout,
|
|
1895
1916
|
card: null,
|
|
@@ -1903,18 +1924,20 @@ class AntifraudCardService {
|
|
|
1903
1924
|
return true;
|
|
1904
1925
|
}
|
|
1905
1926
|
async validateOrdersByRange(params, range) {
|
|
1906
|
-
const { cpf, email, phone, zip } = params;
|
|
1907
|
-
const [ordersCpf, ordersByEmail, ordersByPhone, ordersByZip] = await Promise.all([
|
|
1927
|
+
const { cpf, email, phone, zip, card } = params;
|
|
1928
|
+
const [ordersCpf, ordersByEmail, ordersByPhone, ordersByZip, ordersByCard] = await Promise.all([
|
|
1908
1929
|
this.countOrdersByField({ property: 'user', field: 'cpf', value: cpf, range }),
|
|
1909
1930
|
this.countOrdersByField({ property: 'user', field: 'email', value: email, range }),
|
|
1910
1931
|
this.countOrdersByField({ property: 'user', field: 'phone', value: phone, range }),
|
|
1911
1932
|
this.countOrdersByField({ property: 'shippingAddress', field: 'zip', value: zip, range }),
|
|
1933
|
+
this.countOrdersByField({ property: 'payment', field: 'card.id', value: card.cardId, range }),
|
|
1912
1934
|
]);
|
|
1913
1935
|
return {
|
|
1914
1936
|
cpf: ordersCpf,
|
|
1915
1937
|
email: ordersByEmail,
|
|
1916
1938
|
phone: ordersByPhone,
|
|
1917
1939
|
zip: ordersByZip,
|
|
1940
|
+
card: ordersByCard,
|
|
1918
1941
|
};
|
|
1919
1942
|
}
|
|
1920
1943
|
async countOrdersByField(params) {
|
|
@@ -1928,8 +1951,8 @@ class AntifraudCardService {
|
|
|
1928
1951
|
{ operator: Where.LTE, value: range.lastDate },
|
|
1929
1952
|
],
|
|
1930
1953
|
};
|
|
1931
|
-
const
|
|
1932
|
-
return
|
|
1954
|
+
const { count } = await this.orderRepository.find({ filters });
|
|
1955
|
+
return count;
|
|
1933
1956
|
}
|
|
1934
1957
|
getDateRange(range = 'day') {
|
|
1935
1958
|
switch (range) {
|
|
@@ -2000,10 +2023,9 @@ class GlampointsPaymentService {
|
|
|
2000
2023
|
return payment;
|
|
2001
2024
|
}
|
|
2002
2025
|
async rewardByOrder(order, user) {
|
|
2003
|
-
var _a;
|
|
2004
2026
|
try {
|
|
2005
2027
|
const points = order.lineItems.filter((item) => !item.isGift).reduce((acc, li) => acc + li.quantity, 0);
|
|
2006
|
-
const hasGlambeauty =
|
|
2028
|
+
const hasGlambeauty = order.lineItems?.some((doc) => doc.brand && doc.brand.toUpperCase() === 'GLAM BEAUTY');
|
|
2007
2029
|
const result = await axios({
|
|
2008
2030
|
method: 'POST',
|
|
2009
2031
|
url: `${this.glamCredentials.baseUrl}/integration/win/reward`,
|
|
@@ -2264,7 +2286,7 @@ class AdyenPaymentFactoryHelper {
|
|
|
2264
2286
|
checkoutId: checkout.id,
|
|
2265
2287
|
totalPrice: checkout.totalPrice,
|
|
2266
2288
|
paymentProvider: 'adyen',
|
|
2267
|
-
transaction:
|
|
2289
|
+
transaction: { ...adyenResponse, status: 'paid' },
|
|
2268
2290
|
});
|
|
2269
2291
|
return paymentRepository.create(paymentData);
|
|
2270
2292
|
}
|
|
@@ -2275,7 +2297,7 @@ class AdyenPaymentOperationsHelper {
|
|
|
2275
2297
|
return {
|
|
2276
2298
|
amount: {
|
|
2277
2299
|
currency: 'BRL',
|
|
2278
|
-
value: (
|
|
2300
|
+
value: (checkout?.totalPrice || 0) * 100,
|
|
2279
2301
|
},
|
|
2280
2302
|
paymentMethod: {
|
|
2281
2303
|
type: 'scheme',
|
|
@@ -2360,7 +2382,11 @@ class RestCacheAdapter {
|
|
|
2360
2382
|
this.logger = new DebugHelper('RestCacheAdapter');
|
|
2361
2383
|
this.client = axios.create({
|
|
2362
2384
|
baseURL: config.baseURL,
|
|
2363
|
-
headers:
|
|
2385
|
+
headers: {
|
|
2386
|
+
'Content-Type': 'application/json',
|
|
2387
|
+
...(isNil(config.authToken) ? {} : { Authorization: `Bearer ${config.authToken}` }),
|
|
2388
|
+
...(isNil(config.mobileApiKey) ? {} : { 'X-Mobile-API-Key': config.mobileApiKey }),
|
|
2389
|
+
},
|
|
2364
2390
|
});
|
|
2365
2391
|
}
|
|
2366
2392
|
async set(options) {
|
|
@@ -2616,7 +2642,10 @@ class ElasticSearchResultProcessorHelper {
|
|
|
2616
2642
|
});
|
|
2617
2643
|
}
|
|
2618
2644
|
static transformHitsToProducts(hits) {
|
|
2619
|
-
return hits.map((hit) => (
|
|
2645
|
+
return hits.map((hit) => ({
|
|
2646
|
+
...hit._source,
|
|
2647
|
+
stock: hit._source.stock.quantity,
|
|
2648
|
+
}));
|
|
2620
2649
|
}
|
|
2621
2650
|
}
|
|
2622
2651
|
|
|
@@ -2759,11 +2788,11 @@ class FirestoreDataConverterHelper {
|
|
|
2759
2788
|
return (data &&
|
|
2760
2789
|
!Array.isArray(data) &&
|
|
2761
2790
|
typeof data === 'object' &&
|
|
2762
|
-
|
|
2791
|
+
data?.constructor.name !== 'Timestamp' &&
|
|
2763
2792
|
!('seconds' in data));
|
|
2764
2793
|
}
|
|
2765
2794
|
static convertToDate(data, keyName) {
|
|
2766
|
-
if (
|
|
2795
|
+
if (data?.constructor.name === 'Timestamp')
|
|
2767
2796
|
return data.toDate();
|
|
2768
2797
|
if (data && typeof data === 'object' && 'seconds' in data)
|
|
2769
2798
|
return new Date(data.seconds * 1000);
|
|
@@ -2808,7 +2837,7 @@ class FirestoreModelConverterHelper {
|
|
|
2808
2837
|
}
|
|
2809
2838
|
buildToFirestoreConverter() {
|
|
2810
2839
|
return (data) => {
|
|
2811
|
-
const plain =
|
|
2840
|
+
const plain = data?.toPlain ? data.toPlain() : data;
|
|
2812
2841
|
return FirestoreModelConverterHelper.omitByRecursivelyInPlace(plain, (value) => value === undefined);
|
|
2813
2842
|
};
|
|
2814
2843
|
}
|
|
@@ -2818,7 +2847,7 @@ class FirestoreModelConverterHelper {
|
|
|
2818
2847
|
const data = snap.data();
|
|
2819
2848
|
const ids = { id: snap.id };
|
|
2820
2849
|
const bindedData = FirestoreDataConverterHelper.bindAllDateFromObject(data);
|
|
2821
|
-
return this.model.toInstance(
|
|
2850
|
+
return this.model.toInstance({ ...bindedData, ...ids });
|
|
2822
2851
|
}
|
|
2823
2852
|
catch (error) {
|
|
2824
2853
|
this.handleConversionError(snap.id, snap.data(), error);
|
|
@@ -2886,18 +2915,17 @@ const withHelpers = (MixinBase) => {
|
|
|
2886
2915
|
class AttributeOptionHelper {
|
|
2887
2916
|
}
|
|
2888
2917
|
AttributeOptionHelper.FindByAttribute = (attributeName, fields) => {
|
|
2889
|
-
var _a;
|
|
2890
2918
|
if (fields.includes(attributeName))
|
|
2891
2919
|
return { columnName: attributeName.toString(), attributeName, to: (value) => value, from: (value) => value };
|
|
2892
2920
|
const field = fields.find((columnOption) => isObject(columnOption) && Object.keys(columnOption).includes(attributeName.toString()));
|
|
2893
|
-
const fieldOption =
|
|
2921
|
+
const fieldOption = is(field)?.[attributeName];
|
|
2894
2922
|
if (isNil(fieldOption))
|
|
2895
2923
|
return { columnName: attributeName.toString(), attributeName };
|
|
2896
2924
|
if (Array.isArray(fieldOption))
|
|
2897
2925
|
return { columnName: attributeName.toString(), attributeName, fields: fieldOption };
|
|
2898
|
-
return
|
|
2926
|
+
return { attributeName, columnName: attributeName.toString(), ...fieldOption };
|
|
2899
2927
|
};
|
|
2900
|
-
AttributeOptionHelper.CheckIsColumnOption = (fieldValue) => !!
|
|
2928
|
+
AttributeOptionHelper.CheckIsColumnOption = (fieldValue) => !!fieldValue?.columnName;
|
|
2901
2929
|
AttributeOptionHelper.FindColumnOptionFromList = (columnName, fields) => {
|
|
2902
2930
|
if (fields.includes(columnName))
|
|
2903
2931
|
return { columnName, attributeName: columnName };
|
|
@@ -2905,13 +2933,17 @@ AttributeOptionHelper.FindColumnOptionFromList = (columnName, fields) => {
|
|
|
2905
2933
|
if (!isObject(field))
|
|
2906
2934
|
return false;
|
|
2907
2935
|
const columnOption = Object.values(field).find((option) => AttributeOptionHelper.CheckIsColumnOption(option) && option.columnName === columnName ? option : {});
|
|
2908
|
-
return AttributeOptionHelper.CheckIsColumnOption(columnOption) &&
|
|
2936
|
+
return AttributeOptionHelper.CheckIsColumnOption(columnOption) && columnOption?.columnName === columnName;
|
|
2909
2937
|
}) || {});
|
|
2910
2938
|
const attributeName = Object.keys(field).find((fieldOptionFromList) => AttributeOptionHelper.CheckIsColumnOption(field[fieldOptionFromList]) || Array.isArray(field[fieldOptionFromList]));
|
|
2911
|
-
const fieldOption = field
|
|
2939
|
+
const fieldOption = field?.[attributeName];
|
|
2912
2940
|
if (Array.isArray(fieldOption))
|
|
2913
2941
|
return { attributeName: attributeName, fields: fieldOption };
|
|
2914
|
-
return
|
|
2942
|
+
return {
|
|
2943
|
+
attributeName: attributeName || columnName,
|
|
2944
|
+
columnName,
|
|
2945
|
+
...fieldOption,
|
|
2946
|
+
};
|
|
2915
2947
|
};
|
|
2916
2948
|
|
|
2917
2949
|
var HasuraGraphQLWhere;
|
|
@@ -2949,7 +2981,7 @@ var HasuraGraphQLColumnType;
|
|
|
2949
2981
|
|
|
2950
2982
|
class FilterOptionHelper {
|
|
2951
2983
|
}
|
|
2952
|
-
FilterOptionHelper.CheckIfIsFilterOption = (filter) => !isNil(filter
|
|
2984
|
+
FilterOptionHelper.CheckIfIsFilterOption = (filter) => !isNil(filter?.operator);
|
|
2953
2985
|
FilterOptionHelper.GetValueFromFilter = (filter, fieldOption) => {
|
|
2954
2986
|
if (!FilterOptionHelper.CheckIfIsFilterOption(filter))
|
|
2955
2987
|
return filter;
|
|
@@ -3010,25 +3042,37 @@ class BindFilterQueryHelper {
|
|
|
3010
3042
|
BindFilterQueryHelper.MakeGraphQLWhere = (filter, fields) => Object.keys(filter).reduce((variables, fieldName) => {
|
|
3011
3043
|
const columnOption = AttributeOptionHelper.FindByAttribute(fieldName, fields);
|
|
3012
3044
|
if (!columnOption.bindFindFilter)
|
|
3013
|
-
return
|
|
3014
|
-
|
|
3015
|
-
|
|
3045
|
+
return {
|
|
3046
|
+
...variables,
|
|
3047
|
+
...{
|
|
3048
|
+
[columnOption.columnName]: BindFilterQueryHelper.BuildWhereSentence(fieldName, filter[fieldName], fields),
|
|
3049
|
+
},
|
|
3050
|
+
};
|
|
3016
3051
|
const builtFilter = columnOption.bindFindFilter(filter[fieldName]);
|
|
3017
|
-
return
|
|
3052
|
+
return {
|
|
3053
|
+
...variables,
|
|
3054
|
+
...Object.keys(builtFilter).reduce((variablesList, columnName) => ({
|
|
3055
|
+
...variablesList,
|
|
3056
|
+
[columnName]: BindFilterQueryHelper.BuildWhereSentence(fieldName, builtFilter[columnName], fields),
|
|
3057
|
+
}), {}),
|
|
3058
|
+
};
|
|
3018
3059
|
}, {});
|
|
3019
3060
|
BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
|
|
3020
3061
|
const fieldSentenceOptions = AttributeOptionHelper.FindByAttribute(field, fields);
|
|
3021
3062
|
const isNestedField = !Array.isArray(options) &&
|
|
3022
3063
|
isObject(options) &&
|
|
3023
|
-
isNil(options
|
|
3024
|
-
isNil(options
|
|
3025
|
-
isNil(fieldSentenceOptions
|
|
3064
|
+
isNil(options?.operator) &&
|
|
3065
|
+
isNil(options?.value) &&
|
|
3066
|
+
isNil(fieldSentenceOptions?.to);
|
|
3026
3067
|
if (isNestedField)
|
|
3027
3068
|
return Object.keys(options).reduce((variables, key) => {
|
|
3028
|
-
const fieldOptions = AttributeOptionHelper.FindByAttribute(key,
|
|
3069
|
+
const fieldOptions = AttributeOptionHelper.FindByAttribute(key, fieldSentenceOptions?.fields || fields);
|
|
3029
3070
|
const columnName = fieldOptions.columnName;
|
|
3030
3071
|
const columnFields = fieldOptions.fields;
|
|
3031
|
-
return
|
|
3072
|
+
return {
|
|
3073
|
+
...variables,
|
|
3074
|
+
[columnName]: BindFilterQueryHelper.BuildWhereSentence(key, is(is(options)[key]), fieldSentenceOptions?.fields || columnFields || fields),
|
|
3075
|
+
};
|
|
3032
3076
|
}, {});
|
|
3033
3077
|
if (!Array.isArray(options) && !isNil(fieldSentenceOptions.fields))
|
|
3034
3078
|
return {
|
|
@@ -3037,7 +3081,10 @@ BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
|
|
|
3037
3081
|
if (!Array.isArray(options) && isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
|
|
3038
3082
|
options = Object.values(options)[0];
|
|
3039
3083
|
return Array.isArray(options)
|
|
3040
|
-
? options.reduce((whereSentence, option) => (
|
|
3084
|
+
? options.reduce((whereSentence, option) => ({
|
|
3085
|
+
...whereSentence,
|
|
3086
|
+
...BindFilterQueryHelper.BuildOperatorSentence(option, fieldSentenceOptions),
|
|
3087
|
+
}), {})
|
|
3041
3088
|
: BindFilterQueryHelper.BuildOperatorSentence(options, fieldSentenceOptions);
|
|
3042
3089
|
};
|
|
3043
3090
|
BindFilterQueryHelper.BuildOperatorSentence = (options, fieldOption) => ({
|
|
@@ -3053,14 +3100,14 @@ BindFilterQueryHelper.GetHasuraOperator = (options, fieldOption) => FilterOption
|
|
|
3053
3100
|
: options.operator === Where.LIKE && options.ignoreCase
|
|
3054
3101
|
? HasuraGraphQLWhere.ILIKE
|
|
3055
3102
|
: HasuraGraphQLWhere[Object.keys(HasuraGraphQLWhere).find((graphQLOperator) => graphQLOperator ===
|
|
3056
|
-
Object.keys(Where).find((operator) => Where[operator] ===
|
|
3103
|
+
Object.keys(Where).find((operator) => Where[operator] === options?.operator))]
|
|
3057
3104
|
: HasuraGraphQLWhere.EQUALS;
|
|
3058
3105
|
BindFilterQueryHelper.GetHasuraJsonbOperator = (options) => options.operator === Where.IN
|
|
3059
3106
|
? HasuraGraphQLWhere.JSON_CONTAINS
|
|
3060
3107
|
: options.operator === Where.LIKE
|
|
3061
3108
|
? HasuraGraphQLWhere.JSON_HAS_KEYS_ANY
|
|
3062
3109
|
: HasuraGraphQLWhere[Object.keys(HasuraGraphQLWhere).find((graphQLOperator) => graphQLOperator ===
|
|
3063
|
-
Object.keys(Where).find((operator) => Where[operator] ===
|
|
3110
|
+
Object.keys(Where).find((operator) => Where[operator] === options?.operator))];
|
|
3064
3111
|
|
|
3065
3112
|
class CacheKeyGeneratorHelper {
|
|
3066
3113
|
static generateCacheKeyFromIdentifiers(modelOrModelName, identifiers) {
|
|
@@ -3075,7 +3122,8 @@ class GraphQLFieldHelper {
|
|
|
3075
3122
|
}
|
|
3076
3123
|
GraphQLFieldHelper.CheckIsGraphQLParams = (params) => !isString(params) && Array.isArray(params) && params.length >= 0 && !!params[0].operation;
|
|
3077
3124
|
GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields = (fields) => {
|
|
3078
|
-
return fields
|
|
3125
|
+
return fields
|
|
3126
|
+
?.map((field) => {
|
|
3079
3127
|
if (isString(field))
|
|
3080
3128
|
return field.toString();
|
|
3081
3129
|
if (field === 'affected_rows')
|
|
@@ -3090,41 +3138,55 @@ GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields = (fields) => {
|
|
|
3090
3138
|
if (isNestedField)
|
|
3091
3139
|
return GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields(fieldName, fieldValue);
|
|
3092
3140
|
return fieldValue.columnName;
|
|
3093
|
-
})
|
|
3141
|
+
})
|
|
3142
|
+
.filter((field) => !!field);
|
|
3094
3143
|
};
|
|
3095
3144
|
GraphQLFieldHelper.ConvertFieldValueFrom = (data, fields) => Object.keys(data).reduce((result, columnName) => {
|
|
3096
3145
|
const { attributeName, fields: attributeFields, from, } = AttributeOptionHelper.FindColumnOptionFromList(columnName, fields);
|
|
3097
3146
|
if (!!attributeFields && Array.isArray(attributeFields)) {
|
|
3098
3147
|
if (Array.isArray(data[columnName]))
|
|
3099
|
-
return
|
|
3148
|
+
return {
|
|
3149
|
+
...result,
|
|
3150
|
+
[attributeName]: from
|
|
3100
3151
|
? from(data[columnName], data)
|
|
3101
|
-
: is(data[columnName]).map((value) => GraphQLFieldHelper.ConvertFieldValueFrom(is(value), attributeFields))
|
|
3152
|
+
: is(data[columnName]).map((value) => GraphQLFieldHelper.ConvertFieldValueFrom(is(value), attributeFields)),
|
|
3153
|
+
};
|
|
3102
3154
|
if (isObject(data[columnName]))
|
|
3103
|
-
return
|
|
3155
|
+
return {
|
|
3156
|
+
...result,
|
|
3157
|
+
[attributeName]: from
|
|
3104
3158
|
? from(data[columnName])
|
|
3105
|
-
: GraphQLFieldHelper.ConvertFieldValueFrom(is(data[columnName]), attributeFields)
|
|
3159
|
+
: GraphQLFieldHelper.ConvertFieldValueFrom(is(data[columnName]), attributeFields),
|
|
3160
|
+
};
|
|
3106
3161
|
}
|
|
3107
3162
|
if (from)
|
|
3108
|
-
return
|
|
3109
|
-
return
|
|
3163
|
+
return { ...result, [attributeName]: from(data[columnName], data) };
|
|
3164
|
+
return {
|
|
3165
|
+
...result,
|
|
3166
|
+
[attributeName]: isString(data[columnName]) ? parseDateTime(data[columnName].toString()) : data[columnName],
|
|
3167
|
+
};
|
|
3110
3168
|
}, {});
|
|
3111
3169
|
GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
3112
|
-
|
|
3113
|
-
const data = ((_a = instance.toPlain) === null || _a === void 0 ? void 0 : _a.call(instance)) || instance;
|
|
3170
|
+
const data = instance.toPlain?.() || instance;
|
|
3114
3171
|
return Object.keys(data).reduce((result, attributeName) => {
|
|
3115
3172
|
const { columnName, fields: attributeFields, foreignKeyColumn, to, bindPersistData, } = AttributeOptionHelper.FindByAttribute(attributeName, fields);
|
|
3116
3173
|
if (bindPersistData)
|
|
3117
|
-
return
|
|
3174
|
+
return {
|
|
3175
|
+
...result,
|
|
3176
|
+
...bindPersistData(data[attributeName], instance),
|
|
3177
|
+
};
|
|
3118
3178
|
if (isNil(columnName))
|
|
3119
3179
|
return result;
|
|
3120
3180
|
if (!!foreignKeyColumn &&
|
|
3121
3181
|
!isEmpty(foreignKeyColumn) &&
|
|
3122
|
-
!Object.keys(foreignKeyColumn).filter((key) =>
|
|
3182
|
+
!Object.keys(foreignKeyColumn).filter((key) => !is(data[attributeName])?.[key]).length)
|
|
3123
3183
|
return Object.keys(foreignKeyColumn).reduce((object, current) => {
|
|
3124
|
-
var _a;
|
|
3125
3184
|
const { columnName: foreignColumnName } = AttributeOptionHelper.FindByAttribute(foreignKeyColumn[current], fields);
|
|
3126
|
-
return
|
|
3127
|
-
|
|
3185
|
+
return {
|
|
3186
|
+
...object,
|
|
3187
|
+
[foreignColumnName]: data[attributeName]?.[current],
|
|
3188
|
+
};
|
|
3189
|
+
}, { ...result });
|
|
3128
3190
|
if (update &&
|
|
3129
3191
|
isObject(data[attributeName]) &&
|
|
3130
3192
|
!isNil(attributeFields) &&
|
|
@@ -3136,19 +3198,25 @@ GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
|
|
|
3136
3198
|
const converted = !isNil(columnName) && to
|
|
3137
3199
|
? to(instance[attributeName], instance)
|
|
3138
3200
|
: data[attributeName];
|
|
3139
|
-
return
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
:
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3201
|
+
return {
|
|
3202
|
+
...result,
|
|
3203
|
+
...(converted !== undefined
|
|
3204
|
+
? {
|
|
3205
|
+
[columnName]: {
|
|
3206
|
+
data: instance[attributeName] instanceof BaseModel
|
|
3207
|
+
? GraphQLFieldHelper.ConvertFieldValueTo(data[attributeName], attributeFields)
|
|
3208
|
+
: converted,
|
|
3209
|
+
},
|
|
3210
|
+
}
|
|
3211
|
+
: {}),
|
|
3212
|
+
};
|
|
3148
3213
|
}
|
|
3149
3214
|
if (to)
|
|
3150
|
-
return
|
|
3151
|
-
|
|
3215
|
+
return {
|
|
3216
|
+
...result,
|
|
3217
|
+
[columnName]: to(instance[attributeName], instance),
|
|
3218
|
+
};
|
|
3219
|
+
return { ...result, [columnName]: data[attributeName] };
|
|
3152
3220
|
}, {});
|
|
3153
3221
|
};
|
|
3154
3222
|
GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields = (fieldName, fieldValue) => {
|
|
@@ -3206,13 +3274,17 @@ class MD5GeneratorHelper {
|
|
|
3206
3274
|
|
|
3207
3275
|
class HasuraAuthHelper {
|
|
3208
3276
|
static buildHeaders(authOptions) {
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
? {}
|
|
3212
|
-
: {
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3277
|
+
return {
|
|
3278
|
+
'Content-Type': 'application/json',
|
|
3279
|
+
...(isNil(authOptions?.authToken) ? {} : { Authorization: authOptions?.authToken }),
|
|
3280
|
+
...(isNil(authOptions?.adminSecret) ? {} : { 'X-Hasura-Admin-Secret': authOptions?.adminSecret }),
|
|
3281
|
+
...(isNil(authOptions?.authRole)
|
|
3282
|
+
? {}
|
|
3283
|
+
: {
|
|
3284
|
+
'X-Hasura-Role': authOptions.authRole.role,
|
|
3285
|
+
'X-Hasura-User-Id': authOptions?.authRole?.userId,
|
|
3286
|
+
}),
|
|
3287
|
+
};
|
|
3216
3288
|
}
|
|
3217
3289
|
}
|
|
3218
3290
|
|
|
@@ -3302,17 +3374,21 @@ class HasuraGraphQLOperationsHelper {
|
|
|
3302
3374
|
return this.executeFetch({ query: resultQuery, operationParams });
|
|
3303
3375
|
}
|
|
3304
3376
|
static async executeQuery(params) {
|
|
3305
|
-
var _a, _b, _c, _d;
|
|
3306
3377
|
const { operation, fields, variables, operationParams, buildHasuraQueryFields } = params;
|
|
3307
3378
|
const builded = buildHasuraQueryFields({ operation, fields, variables });
|
|
3308
|
-
const intercepted = (await
|
|
3379
|
+
const intercepted = (await operationParams.interceptors?.request?.(builded)) || builded;
|
|
3309
3380
|
const resultQuery = HasuraQueryBuilderHelper.buildQuery(intercepted);
|
|
3310
3381
|
const result = await this.executeFetch({ query: resultQuery, operationParams });
|
|
3311
|
-
return (await
|
|
3382
|
+
return (await operationParams.interceptors?.response?.(result, intercepted)) || result;
|
|
3312
3383
|
}
|
|
3313
3384
|
static async executeFetch(params) {
|
|
3314
3385
|
const { query, operationParams } = params;
|
|
3315
|
-
return HasuraRequestHelper.fetch(
|
|
3386
|
+
return HasuraRequestHelper.fetch({
|
|
3387
|
+
...query,
|
|
3388
|
+
endpoint: operationParams.endpoint,
|
|
3389
|
+
headers: HasuraAuthHelper.buildHeaders(operationParams.authOptions),
|
|
3390
|
+
logger: operationParams.logger,
|
|
3391
|
+
});
|
|
3316
3392
|
}
|
|
3317
3393
|
}
|
|
3318
3394
|
|
|
@@ -3326,12 +3402,10 @@ class HasuraColumnHelper {
|
|
|
3326
3402
|
const columnOptions = Object.values(field).shift();
|
|
3327
3403
|
return (AttributeOptionHelper.CheckIsColumnOption(columnOptions) &&
|
|
3328
3404
|
columnOptions.foreignKeyColumn && [
|
|
3329
|
-
...Object.values(columnOptions.foreignKeyColumn).map((foreignKeyName) =>
|
|
3405
|
+
...Object.values(columnOptions.foreignKeyColumn).map((foreignKeyName) => AttributeOptionHelper.FindByAttribute(foreignKeyName, fields)?.columnName),
|
|
3330
3406
|
{
|
|
3331
|
-
[columnOptions.columnName]: Object.keys(columnOptions.foreignKeyColumn).map((foreignKeyField) =>
|
|
3332
|
-
|
|
3333
|
-
return ((_a = AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions === null || columnOptions === void 0 ? void 0 : columnOptions.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || foreignKeyField;
|
|
3334
|
-
}),
|
|
3407
|
+
[columnOptions.columnName]: Object.keys(columnOptions.foreignKeyColumn).map((foreignKeyField) => AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions?.fields)
|
|
3408
|
+
?.columnName || foreignKeyField),
|
|
3335
3409
|
},
|
|
3336
3410
|
]);
|
|
3337
3411
|
})
|
|
@@ -3356,7 +3430,7 @@ class HasuraCreateOperationsHelper {
|
|
|
3356
3430
|
const { model } = params;
|
|
3357
3431
|
params.repository.logger = DebugHelper.from(params.repository, 'create');
|
|
3358
3432
|
const instance = model.toInstance(data);
|
|
3359
|
-
const newData = await this.executeSave(
|
|
3433
|
+
const newData = await this.executeSave({ ...params, data: instance });
|
|
3360
3434
|
return model.toInstance(newData);
|
|
3361
3435
|
}
|
|
3362
3436
|
static async executeSave(params) {
|
|
@@ -3370,14 +3444,14 @@ class HasuraCreateOperationsHelper {
|
|
|
3370
3444
|
},
|
|
3371
3445
|
});
|
|
3372
3446
|
const convertedResult = repository.convertDataFromHasura(result[insertGraphQLOperation]);
|
|
3373
|
-
return
|
|
3447
|
+
return { ...data.toPlain(), ...convertedResult.toPlain() };
|
|
3374
3448
|
}
|
|
3375
3449
|
}
|
|
3376
3450
|
|
|
3377
3451
|
class HasuraCacheOperationsHelper {
|
|
3378
3452
|
static async removeCacheData(cache, params) {
|
|
3379
3453
|
const { model, identifiers, logger } = params;
|
|
3380
|
-
if (!
|
|
3454
|
+
if (!cache?.cacheAdapter)
|
|
3381
3455
|
return;
|
|
3382
3456
|
const cacheKey = CacheKeyGeneratorHelper.generateCacheKeyFromIdentifiers(model, identifiers);
|
|
3383
3457
|
await cache.cacheAdapter.remove(cacheKey);
|
|
@@ -3397,13 +3471,16 @@ class HasuraDeleteVariablesHelper {
|
|
|
3397
3471
|
if (isNil(instance.identifier[identifierBinded]))
|
|
3398
3472
|
return ids;
|
|
3399
3473
|
const columnOption = AttributeOptionHelper.FindByAttribute(identifier, fields);
|
|
3400
|
-
const value =
|
|
3474
|
+
const value = columnOption?.to(identifiers[identifier], instance) ||
|
|
3401
3475
|
identifiers[identifier];
|
|
3402
|
-
return
|
|
3476
|
+
return {
|
|
3477
|
+
...ids,
|
|
3478
|
+
[columnOption.columnName]: {
|
|
3403
3479
|
type: repository.getAttributeGraphQLTypeOf(columnOption.type || value),
|
|
3404
3480
|
value,
|
|
3405
3481
|
required: true,
|
|
3406
|
-
}
|
|
3482
|
+
},
|
|
3483
|
+
};
|
|
3407
3484
|
}, {});
|
|
3408
3485
|
}
|
|
3409
3486
|
}
|
|
@@ -3441,16 +3518,15 @@ class HasuraFindBindingHelper {
|
|
|
3441
3518
|
], []);
|
|
3442
3519
|
}
|
|
3443
3520
|
static bindAggregateAttributes(aggregates, fields) {
|
|
3444
|
-
var _a, _b;
|
|
3445
3521
|
return [
|
|
3446
|
-
...(
|
|
3522
|
+
...(aggregates?.minimal?.length
|
|
3447
3523
|
? [
|
|
3448
3524
|
{
|
|
3449
3525
|
min: this.bindAttributesToColumns(aggregates.minimal, fields),
|
|
3450
3526
|
},
|
|
3451
3527
|
]
|
|
3452
3528
|
: []),
|
|
3453
|
-
...(
|
|
3529
|
+
...(aggregates?.maximum?.length
|
|
3454
3530
|
? [
|
|
3455
3531
|
{
|
|
3456
3532
|
max: this.bindAttributesToColumns(aggregates.maximum, fields),
|
|
@@ -3477,7 +3553,7 @@ class HasuraFindBindingHelper {
|
|
|
3477
3553
|
});
|
|
3478
3554
|
if (typeof fieldOption === 'object' && fieldOption !== null) {
|
|
3479
3555
|
const columnOption = fieldOption[attributeName];
|
|
3480
|
-
return
|
|
3556
|
+
return columnOption?.columnName || attributeName;
|
|
3481
3557
|
}
|
|
3482
3558
|
return attributeName;
|
|
3483
3559
|
}
|
|
@@ -3490,27 +3566,27 @@ class HasuraFindCacheHelper {
|
|
|
3490
3566
|
}
|
|
3491
3567
|
static async getCachedResult(params) {
|
|
3492
3568
|
const { cache, model, findParams, cacheOptions, logger } = params;
|
|
3493
|
-
if (!
|
|
3569
|
+
if (!cache?.cacheAdapter || !cacheOptions?.enabled)
|
|
3494
3570
|
return null;
|
|
3495
3571
|
const cacheKey = this.generateCacheKey(model, findParams);
|
|
3496
3572
|
const cachedData = await cache.cacheAdapter.get(cacheKey);
|
|
3497
3573
|
if (cachedData) {
|
|
3498
|
-
logger
|
|
3574
|
+
logger?.log(`Dados recuperados do cache: ${cacheKey}`);
|
|
3499
3575
|
return deserialize(cachedData);
|
|
3500
3576
|
}
|
|
3501
3577
|
return null;
|
|
3502
3578
|
}
|
|
3503
3579
|
static async setCachedResult(params) {
|
|
3504
3580
|
const { cache, model, findParams, cacheOptions, result, logger } = params;
|
|
3505
|
-
if (!
|
|
3581
|
+
if (!cache?.cacheAdapter || !cacheOptions?.enabled)
|
|
3506
3582
|
return;
|
|
3507
3583
|
const cacheKey = this.generateCacheKey(model, findParams);
|
|
3508
3584
|
await cache.cacheAdapter.set({
|
|
3509
3585
|
key: cacheKey,
|
|
3510
3586
|
data: serialize(result),
|
|
3511
|
-
expirationInSeconds:
|
|
3587
|
+
expirationInSeconds: cacheOptions?.ttl || cache.ttlDefault,
|
|
3512
3588
|
});
|
|
3513
|
-
logger
|
|
3589
|
+
logger?.log(`Dados salvos no cache: ${cacheKey}`);
|
|
3514
3590
|
}
|
|
3515
3591
|
}
|
|
3516
3592
|
|
|
@@ -3518,27 +3594,40 @@ class HasuraFindResultHelper {
|
|
|
3518
3594
|
static processResult(params) {
|
|
3519
3595
|
const { result, tableName, enableCount, findOptions, tableFiltersNamed, fields, convertDataFromHasura, lastDistinct, } = params;
|
|
3520
3596
|
const data = result[tableName].map((row) => convertDataFromHasura(row));
|
|
3521
|
-
const findResult =
|
|
3597
|
+
const findResult = {
|
|
3598
|
+
data,
|
|
3599
|
+
count: enableCount ? result[`${tableName}_aggregate`].aggregate.count : Infinity,
|
|
3600
|
+
...this.processMinimalAggregates({ result, tableName, findOptions, fields }),
|
|
3601
|
+
...this.processMaximumAggregates({ result, tableName, findOptions, fields }),
|
|
3602
|
+
...this.processDistinctResults({ result, tableName, findOptions, tableFiltersNamed, fields, lastDistinct }),
|
|
3603
|
+
};
|
|
3522
3604
|
return findResult;
|
|
3523
3605
|
}
|
|
3524
3606
|
static bindAggregateAttributes(params) {
|
|
3525
|
-
var _a, _b;
|
|
3526
3607
|
const { aggregates, fields } = params;
|
|
3527
3608
|
const convertFieldName = (fieldName) => {
|
|
3528
|
-
var _a, _b;
|
|
3529
3609
|
const finalFieldName = fieldName.toString().split('.').pop();
|
|
3530
|
-
const fieldOption =
|
|
3531
|
-
|
|
3610
|
+
const fieldOption = fields.find((fieldOption) => {
|
|
3611
|
+
if (typeof fieldOption === 'string')
|
|
3612
|
+
return fieldOption === finalFieldName;
|
|
3613
|
+
const key = Object.keys(fieldOption)[0];
|
|
3614
|
+
return key === finalFieldName;
|
|
3615
|
+
});
|
|
3616
|
+
if (fieldOption && typeof fieldOption !== 'string') {
|
|
3617
|
+
const fieldValue = Object.values(fieldOption)[0];
|
|
3618
|
+
return fieldValue?.columnName || finalFieldName;
|
|
3619
|
+
}
|
|
3620
|
+
return finalFieldName;
|
|
3532
3621
|
};
|
|
3533
3622
|
return [
|
|
3534
|
-
...(
|
|
3623
|
+
...(aggregates?.minimal?.length
|
|
3535
3624
|
? [
|
|
3536
3625
|
{
|
|
3537
3626
|
min: aggregates.minimal.map(convertFieldName),
|
|
3538
3627
|
},
|
|
3539
3628
|
]
|
|
3540
3629
|
: []),
|
|
3541
|
-
...(
|
|
3630
|
+
...(aggregates?.maximum?.length
|
|
3542
3631
|
? [
|
|
3543
3632
|
{
|
|
3544
3633
|
max: aggregates.maximum.map(convertFieldName),
|
|
@@ -3548,48 +3637,52 @@ class HasuraFindResultHelper {
|
|
|
3548
3637
|
];
|
|
3549
3638
|
}
|
|
3550
3639
|
static processMinimalAggregates(params) {
|
|
3551
|
-
var _a;
|
|
3552
3640
|
const { result, tableName, findOptions, fields } = params;
|
|
3553
|
-
return
|
|
3641
|
+
return findOptions?.minimal?.length
|
|
3554
3642
|
? {
|
|
3555
3643
|
minimal: findOptions.minimal.reduce((minimals, current) => {
|
|
3556
|
-
|
|
3557
|
-
return
|
|
3644
|
+
const columnName = AttributeOptionHelper.FindByAttribute(current.toString().split('.').pop(), fields)?.columnName || current;
|
|
3645
|
+
return {
|
|
3646
|
+
...minimals,
|
|
3647
|
+
...set(minimals, current, result[`${tableName}_aggregate`].aggregate.min[columnName]),
|
|
3648
|
+
};
|
|
3558
3649
|
}, {}),
|
|
3559
3650
|
}
|
|
3560
3651
|
: {};
|
|
3561
3652
|
}
|
|
3562
3653
|
static processMaximumAggregates(params) {
|
|
3563
|
-
var _a;
|
|
3564
3654
|
const { result, tableName, findOptions, fields } = params;
|
|
3565
|
-
return
|
|
3655
|
+
return findOptions?.maximum?.length
|
|
3566
3656
|
? {
|
|
3567
3657
|
maximum: findOptions.maximum.reduce((maximums, current) => {
|
|
3568
|
-
|
|
3569
|
-
return
|
|
3658
|
+
const columnName = AttributeOptionHelper.FindByAttribute(current.toString().split('.').pop(), fields)?.columnName || current;
|
|
3659
|
+
return {
|
|
3660
|
+
...maximums,
|
|
3661
|
+
...set(maximums, current, result[`${tableName}_aggregate`].aggregate.max[columnName]),
|
|
3662
|
+
};
|
|
3570
3663
|
}, {}),
|
|
3571
3664
|
}
|
|
3572
3665
|
: {};
|
|
3573
3666
|
}
|
|
3574
3667
|
static processDistinctResults(params) {
|
|
3575
|
-
var _a, _b;
|
|
3576
3668
|
const { result, tableName, findOptions, tableFiltersNamed, fields, lastDistinct } = params;
|
|
3577
|
-
return
|
|
3669
|
+
return findOptions?.distinct?.length
|
|
3578
3670
|
? {
|
|
3579
|
-
distinct:
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3671
|
+
distinct: lastDistinct[tableFiltersNamed] ??
|
|
3672
|
+
(lastDistinct[tableFiltersNamed] = findOptions?.distinct.reduce((distinct, current) => {
|
|
3673
|
+
const distinctOption = fields.find((fieldOption) => fieldOption === current) ??
|
|
3674
|
+
fields.find((fieldOption) => Object.keys(fieldOption).shift() === current);
|
|
3675
|
+
const fieldName = Object.values(distinctOption).shift()?.columnName || current;
|
|
3676
|
+
return {
|
|
3677
|
+
...distinct,
|
|
3678
|
+
[current.toString()]: result[`${tableName}_${current.toString()}_distinct`].map((obj) => obj[fieldName]),
|
|
3679
|
+
};
|
|
3680
|
+
}, {})),
|
|
3585
3681
|
}
|
|
3586
3682
|
: {};
|
|
3587
3683
|
}
|
|
3588
3684
|
static bindAttributesToColumns(attributes, fields) {
|
|
3589
|
-
return attributes.map((attr) =>
|
|
3590
|
-
var _a;
|
|
3591
|
-
return ((_a = AttributeOptionHelper.FindByAttribute(attr.toString().split('.').pop(), fields)) === null || _a === void 0 ? void 0 : _a.columnName) || attr;
|
|
3592
|
-
});
|
|
3685
|
+
return attributes.map((attr) => AttributeOptionHelper.FindByAttribute(attr.toString().split('.').pop(), fields)?.columnName || attr);
|
|
3593
3686
|
}
|
|
3594
3687
|
}
|
|
3595
3688
|
|
|
@@ -3619,16 +3712,19 @@ class HasuraFindVariablesHelper {
|
|
|
3619
3712
|
};
|
|
3620
3713
|
}
|
|
3621
3714
|
static buildDistinctVariables(params) {
|
|
3622
|
-
var _a, _b;
|
|
3623
3715
|
const { distinct, tableName, fields, filtersVariables } = params;
|
|
3624
|
-
const distinctOption =
|
|
3625
|
-
|
|
3626
|
-
|
|
3716
|
+
const distinctOption = fields.find((fieldOption) => fieldOption === distinct) ??
|
|
3717
|
+
fields.find((fieldOption) => Object.keys(fieldOption).shift() === distinct);
|
|
3718
|
+
const fieldName = Object.values(distinctOption).shift()?.columnName || distinct;
|
|
3719
|
+
return {
|
|
3720
|
+
...filtersVariables,
|
|
3721
|
+
[`${tableName}_${fieldName}_distinct`]: {
|
|
3627
3722
|
type: `${tableName}_select_column!`,
|
|
3628
3723
|
list: true,
|
|
3629
3724
|
value: fieldName,
|
|
3630
3725
|
name: 'distinct_on',
|
|
3631
|
-
}
|
|
3726
|
+
},
|
|
3727
|
+
};
|
|
3632
3728
|
}
|
|
3633
3729
|
static bindOrderByAttributes(orderBy, fields) {
|
|
3634
3730
|
return Object.keys(orderBy).reduce((acc, current) => [
|
|
@@ -3648,11 +3744,17 @@ class HasuraFindQueryBuilderHelper {
|
|
|
3648
3744
|
const { tableName, fields, params, lastDistinct } = queryParams;
|
|
3649
3745
|
const { filters, limits, orderBy, options: findOptions } = params || {};
|
|
3650
3746
|
const filtersVariables = HasuraFindVariablesHelper.buildFiltersVariables({ filters, tableName, fields });
|
|
3651
|
-
const countVariables =
|
|
3652
|
-
|
|
3747
|
+
const countVariables = {
|
|
3748
|
+
...HasuraFindVariablesHelper.buildOrderByVariables({ orderBy, tableName, fields }),
|
|
3749
|
+
...filtersVariables,
|
|
3750
|
+
};
|
|
3751
|
+
const mainVariables = {
|
|
3752
|
+
...(isNil(limits) ? {} : limits),
|
|
3753
|
+
...countVariables,
|
|
3754
|
+
};
|
|
3653
3755
|
const queries = [
|
|
3654
3756
|
this.buildMainQuery({ tableName, fields, params, mainVariables }),
|
|
3655
|
-
...this.buildAggregateQuery({ tableName, findOptions, countVariables }),
|
|
3757
|
+
...this.buildAggregateQuery({ tableName, findOptions, countVariables, fields }),
|
|
3656
3758
|
...this.buildDistinctQueries({ tableName, fields, findOptions, filtersVariables, lastDistinct }),
|
|
3657
3759
|
];
|
|
3658
3760
|
return queries.filter(Boolean);
|
|
@@ -3661,26 +3763,23 @@ class HasuraFindQueryBuilderHelper {
|
|
|
3661
3763
|
const { tableName, fields, params: findParams, mainVariables } = params;
|
|
3662
3764
|
return {
|
|
3663
3765
|
operation: tableName,
|
|
3664
|
-
fields:
|
|
3766
|
+
fields: findParams?.fields
|
|
3665
3767
|
? findParams.fields
|
|
3666
|
-
.map((fieldName) =>
|
|
3667
|
-
|
|
3668
|
-
return (_a = fields.find((fieldOption) => fieldOption === fieldName)) !== null && _a !== void 0 ? _a : fields.find((fieldOption) => Object.keys(fieldOption).shift() === fieldName);
|
|
3669
|
-
})
|
|
3768
|
+
.map((fieldName) => fields.find((fieldOption) => fieldOption === fieldName) ??
|
|
3769
|
+
fields.find((fieldOption) => Object.keys(fieldOption).shift() === fieldName))
|
|
3670
3770
|
.filter(Boolean)
|
|
3671
3771
|
: fields,
|
|
3672
3772
|
variables: mainVariables,
|
|
3673
3773
|
};
|
|
3674
3774
|
}
|
|
3675
3775
|
static buildAggregateQuery(params) {
|
|
3676
|
-
var _a;
|
|
3677
3776
|
const { tableName, findOptions, countVariables } = params;
|
|
3678
|
-
const enableCount =
|
|
3777
|
+
const enableCount = findOptions?.enableCount ?? true;
|
|
3679
3778
|
const aggregateFields = [
|
|
3680
3779
|
...(enableCount ? ['count'] : []),
|
|
3681
3780
|
...HasuraFindResultHelper.bindAggregateAttributes({
|
|
3682
|
-
aggregates: { minimal: findOptions
|
|
3683
|
-
fields:
|
|
3781
|
+
aggregates: { minimal: findOptions?.minimal, maximum: findOptions?.maximum },
|
|
3782
|
+
fields: params.fields,
|
|
3684
3783
|
}),
|
|
3685
3784
|
];
|
|
3686
3785
|
return aggregateFields.length > 0
|
|
@@ -3698,15 +3797,14 @@ class HasuraFindQueryBuilderHelper {
|
|
|
3698
3797
|
: [];
|
|
3699
3798
|
}
|
|
3700
3799
|
static buildDistinctQueries(params) {
|
|
3701
|
-
var _a;
|
|
3702
3800
|
const { tableName, fields, findOptions, filtersVariables, lastDistinct } = params;
|
|
3703
3801
|
const tableFiltersNamed = `${tableName}:${JSON.stringify(filtersVariables)}`;
|
|
3704
|
-
if (!
|
|
3802
|
+
if (!findOptions?.distinct?.length || lastDistinct[tableFiltersNamed]) {
|
|
3705
3803
|
return [];
|
|
3706
3804
|
}
|
|
3707
3805
|
return findOptions.distinct.map((distinct) => {
|
|
3708
|
-
|
|
3709
|
-
|
|
3806
|
+
const distinctOption = fields.find((fieldOption) => fieldOption === distinct) ??
|
|
3807
|
+
fields.find((fieldOption) => Object.keys(fieldOption).shift() === distinct);
|
|
3710
3808
|
return {
|
|
3711
3809
|
operation: {
|
|
3712
3810
|
name: tableName,
|
|
@@ -3726,18 +3824,16 @@ class HasuraFindQueryBuilderHelper {
|
|
|
3726
3824
|
|
|
3727
3825
|
class HasuraFindOperationsHelper {
|
|
3728
3826
|
static async executeFindOperation(operationParams) {
|
|
3729
|
-
var _a;
|
|
3730
3827
|
const { params, cacheOptions, model, tableName, fields, cache, query, convertDataFromHasura, lastDistinct } = operationParams;
|
|
3731
3828
|
const logger = DebugHelper.from(operationParams, 'find');
|
|
3732
3829
|
const { filters, options: findOptions } = params || {};
|
|
3733
3830
|
const tableFiltersNamed = `${tableName}:${JSON.stringify(filters)}`;
|
|
3734
|
-
const enableCount =
|
|
3735
|
-
// Verifica cache primeiro
|
|
3831
|
+
const enableCount = findOptions?.enableCount ?? true;
|
|
3736
3832
|
const cachedResult = await HasuraFindCacheHelper.getCachedResult({
|
|
3737
3833
|
cache,
|
|
3738
3834
|
model,
|
|
3739
3835
|
findParams: params,
|
|
3740
|
-
cacheOptions: cacheOptions
|
|
3836
|
+
cacheOptions: cacheOptions?.cache,
|
|
3741
3837
|
logger,
|
|
3742
3838
|
});
|
|
3743
3839
|
if (cachedResult) {
|
|
@@ -3752,7 +3848,6 @@ class HasuraFindOperationsHelper {
|
|
|
3752
3848
|
lastDistinct,
|
|
3753
3849
|
});
|
|
3754
3850
|
}
|
|
3755
|
-
// Constrói e executa queries
|
|
3756
3851
|
const queries = HasuraFindQueryBuilderHelper.buildCompleteQuery({
|
|
3757
3852
|
tableName,
|
|
3758
3853
|
fields,
|
|
@@ -3760,16 +3855,14 @@ class HasuraFindOperationsHelper {
|
|
|
3760
3855
|
lastDistinct,
|
|
3761
3856
|
});
|
|
3762
3857
|
const result = await query(queries);
|
|
3763
|
-
// Salva no cache se habilitado
|
|
3764
3858
|
await HasuraFindCacheHelper.setCachedResult({
|
|
3765
3859
|
cache,
|
|
3766
3860
|
model,
|
|
3767
3861
|
findParams: params,
|
|
3768
|
-
cacheOptions: cacheOptions
|
|
3862
|
+
cacheOptions: cacheOptions?.cache,
|
|
3769
3863
|
result,
|
|
3770
3864
|
logger,
|
|
3771
3865
|
});
|
|
3772
|
-
// Processa e retorna resultado
|
|
3773
3866
|
return HasuraFindResultHelper.processResult({
|
|
3774
3867
|
result,
|
|
3775
3868
|
tableName,
|
|
@@ -3788,9 +3881,8 @@ class HasuraGetCacheHelper {
|
|
|
3788
3881
|
return CacheKeyGeneratorHelper.generateCacheKeyFromIdentifiers(model, identifiers);
|
|
3789
3882
|
}
|
|
3790
3883
|
static async getCachedData(cache, params) {
|
|
3791
|
-
var _a;
|
|
3792
3884
|
const { identifiers, options, model, logger } = params;
|
|
3793
|
-
if (!
|
|
3885
|
+
if (!cache?.cacheAdapter || !options?.cache?.enabled)
|
|
3794
3886
|
return null;
|
|
3795
3887
|
const cacheKey = this.generateCacheKey(model, identifiers);
|
|
3796
3888
|
const cachedData = await cache.cacheAdapter.get(cacheKey);
|
|
@@ -3800,15 +3892,14 @@ class HasuraGetCacheHelper {
|
|
|
3800
3892
|
return model.toInstance(deserialize(cachedData));
|
|
3801
3893
|
}
|
|
3802
3894
|
static async saveCacheData(cache, params) {
|
|
3803
|
-
var _a, _b;
|
|
3804
3895
|
const { identifiers, options, data, logger } = params;
|
|
3805
|
-
if (!
|
|
3896
|
+
if (!cache?.cacheAdapter || !options?.cache?.enabled)
|
|
3806
3897
|
return;
|
|
3807
3898
|
const cacheKey = this.generateCacheKey(params.data.constructor, identifiers);
|
|
3808
3899
|
await cache.cacheAdapter.set({
|
|
3809
3900
|
key: cacheKey,
|
|
3810
3901
|
data: serialize(data),
|
|
3811
|
-
expirationInSeconds:
|
|
3902
|
+
expirationInSeconds: options?.cache?.ttl || cache.ttlDefault,
|
|
3812
3903
|
});
|
|
3813
3904
|
logger.log(`Dados salvos no cache: ${cacheKey}`);
|
|
3814
3905
|
}
|
|
@@ -3819,18 +3910,20 @@ class HasuraGetVariablesHelper {
|
|
|
3819
3910
|
const { model, fields, repository } = params;
|
|
3820
3911
|
const instance = model.toInstance(identifiers);
|
|
3821
3912
|
return model.identifiersFields.reduce((ids, identifier) => {
|
|
3822
|
-
var _a;
|
|
3823
3913
|
const identifierBinded = identifier;
|
|
3824
3914
|
if (isNil(instance[identifierBinded]))
|
|
3825
3915
|
return ids;
|
|
3826
3916
|
const columnOption = AttributeOptionHelper.FindByAttribute(identifier, fields);
|
|
3827
|
-
const value =
|
|
3917
|
+
const value = columnOption?.to?.(identifiers[identifier], instance) ||
|
|
3828
3918
|
identifiers[identifier];
|
|
3829
|
-
return
|
|
3919
|
+
return {
|
|
3920
|
+
...ids,
|
|
3921
|
+
[columnOption.columnName]: {
|
|
3830
3922
|
type: repository.getAttributeGraphQLTypeOf(columnOption.type || value),
|
|
3831
3923
|
value,
|
|
3832
3924
|
required: true,
|
|
3833
|
-
}
|
|
3925
|
+
},
|
|
3926
|
+
};
|
|
3834
3927
|
}, {});
|
|
3835
3928
|
}
|
|
3836
3929
|
}
|
|
@@ -3887,7 +3980,7 @@ class HasuraUpdateDataHelper {
|
|
|
3887
3980
|
static getValueByAction(options) {
|
|
3888
3981
|
if (options instanceof BaseModel)
|
|
3889
3982
|
return options.toPlain();
|
|
3890
|
-
if (isNil(options
|
|
3983
|
+
if (isNil(options?.action))
|
|
3891
3984
|
return options;
|
|
3892
3985
|
if ([UpdateOptionActions.REMOVE_FIELD.toString(), UpdateOptionActions.NULL.toString()].includes(options.action))
|
|
3893
3986
|
return null;
|
|
@@ -3896,9 +3989,12 @@ class HasuraUpdateDataHelper {
|
|
|
3896
3989
|
static paramsToPlain(params, model) {
|
|
3897
3990
|
if (model.isModel(params))
|
|
3898
3991
|
return params.toPlain();
|
|
3899
|
-
return Object.keys(params).reduce((data, currentKey) => (
|
|
3900
|
-
|
|
3901
|
-
|
|
3992
|
+
return Object.keys(params).reduce((data, currentKey) => ({
|
|
3993
|
+
...data,
|
|
3994
|
+
...(params[currentKey] !== undefined && {
|
|
3995
|
+
[currentKey]: this.getValueByAction(is(params[currentKey])),
|
|
3996
|
+
}),
|
|
3997
|
+
}), {});
|
|
3902
3998
|
}
|
|
3903
3999
|
static getIdentifiersFromData(data, model) {
|
|
3904
4000
|
const instance = model.toInstance(data);
|
|
@@ -3917,13 +4013,15 @@ class HasuraUpdateVariablesHelper {
|
|
|
3917
4013
|
static getUpdateModelKeys(data, model, fields) {
|
|
3918
4014
|
const instance = model.toInstance(data);
|
|
3919
4015
|
return model.identifiersFields.reduce((ids, identifier) => {
|
|
3920
|
-
var _a;
|
|
3921
4016
|
const identifierBinded = identifier;
|
|
3922
4017
|
if (isNil(instance.identifier[identifierBinded]))
|
|
3923
4018
|
return ids;
|
|
3924
4019
|
const columnOption = AttributeOptionHelper.FindByAttribute(identifierBinded, fields);
|
|
3925
|
-
const value =
|
|
3926
|
-
return
|
|
4020
|
+
const value = columnOption?.to?.(data[identifierBinded], instance) || data[columnOption.attributeName];
|
|
4021
|
+
return {
|
|
4022
|
+
...ids,
|
|
4023
|
+
[columnOption.columnName]: value,
|
|
4024
|
+
};
|
|
3927
4025
|
}, {});
|
|
3928
4026
|
}
|
|
3929
4027
|
static getIdentifierFields(model, fields) {
|
|
@@ -3951,9 +4049,7 @@ class HasuraUpdateOperationsHelper {
|
|
|
3951
4049
|
const { data, updateGraphQLOperation, updateGraphQLObjectType, updateGraphQLPKType, model, fields, cache, mutation, convertDataToHasura, } = params;
|
|
3952
4050
|
const logger = DebugHelper.from(params, 'update');
|
|
3953
4051
|
const plainData = HasuraUpdateDataHelper.paramsToPlain(data, model);
|
|
3954
|
-
// Gerencia cache se disponível
|
|
3955
4052
|
await this.handleCacheRemoval({ plainData, model, cache, logger });
|
|
3956
|
-
// Executa mutation
|
|
3957
4053
|
const identifierFields = HasuraUpdateVariablesHelper.getIdentifierFields(model, fields);
|
|
3958
4054
|
const mutationVariables = HasuraUpdateVariablesHelper.buildMutationVariables({
|
|
3959
4055
|
plainData,
|
|
@@ -3968,13 +4064,13 @@ class HasuraUpdateOperationsHelper {
|
|
|
3968
4064
|
}
|
|
3969
4065
|
static async handleCacheRemoval(params) {
|
|
3970
4066
|
const { plainData, model, cache, logger } = params;
|
|
3971
|
-
if (!
|
|
4067
|
+
if (!cache?.cacheAdapter)
|
|
3972
4068
|
return;
|
|
3973
4069
|
const identifiers = HasuraUpdateDataHelper.getIdentifiersFromData(plainData, model);
|
|
3974
4070
|
if (Object.keys(identifiers).length > 0) {
|
|
3975
4071
|
const cacheKey = CacheKeyGeneratorHelper.generateCacheKeyFromIdentifiers(model, identifiers);
|
|
3976
4072
|
await cache.cacheAdapter.remove(cacheKey);
|
|
3977
|
-
logger
|
|
4073
|
+
logger?.log(`Cache removido: ${cacheKey}`);
|
|
3978
4074
|
}
|
|
3979
4075
|
}
|
|
3980
4076
|
}
|
|
@@ -3996,9 +4092,8 @@ class FirestoreCacheKeyGeneratorHelper {
|
|
|
3996
4092
|
|
|
3997
4093
|
class FirestoreCacheHelper {
|
|
3998
4094
|
static async getCachedData(cache, params) {
|
|
3999
|
-
var _a;
|
|
4000
4095
|
const { model, identifiers, options, logger, req } = params;
|
|
4001
|
-
if (!
|
|
4096
|
+
if (!cache?.cacheAdapter || options?.cache?.enabled === false)
|
|
4002
4097
|
return null;
|
|
4003
4098
|
const cacheKey = FirestoreCacheKeyGeneratorHelper.generateGetCacheKey(model, identifiers);
|
|
4004
4099
|
const cachedData = await cache.cacheAdapter.get(cacheKey);
|
|
@@ -4009,9 +4104,8 @@ class FirestoreCacheHelper {
|
|
|
4009
4104
|
return null;
|
|
4010
4105
|
}
|
|
4011
4106
|
static async getCachedFindData(cache, params) {
|
|
4012
|
-
var _a;
|
|
4013
4107
|
const { model, find, options, logger } = params;
|
|
4014
|
-
if (!
|
|
4108
|
+
if (!cache?.cacheAdapter || options?.cache?.enabled === false)
|
|
4015
4109
|
return null;
|
|
4016
4110
|
const cacheKey = FirestoreCacheKeyGeneratorHelper.generateFindCacheKey(model, find);
|
|
4017
4111
|
const cachedData = await cache.cacheAdapter.get(cacheKey);
|
|
@@ -4023,7 +4117,7 @@ class FirestoreCacheHelper {
|
|
|
4023
4117
|
}
|
|
4024
4118
|
static async saveCacheData(cache, params) {
|
|
4025
4119
|
const { cacheKey, data, expirationInSeconds, logger, req } = params;
|
|
4026
|
-
if (!
|
|
4120
|
+
if (!cache?.cacheAdapter)
|
|
4027
4121
|
return;
|
|
4028
4122
|
await cache.cacheAdapter.set({
|
|
4029
4123
|
key: cacheKey,
|
|
@@ -4035,7 +4129,7 @@ class FirestoreCacheHelper {
|
|
|
4035
4129
|
}
|
|
4036
4130
|
static async removeCacheData(cache, params) {
|
|
4037
4131
|
const { cacheKey, logger } = params;
|
|
4038
|
-
if (!
|
|
4132
|
+
if (!cache?.cacheAdapter)
|
|
4039
4133
|
return;
|
|
4040
4134
|
await cache.cacheAdapter.remove(cacheKey);
|
|
4041
4135
|
logger.log(`Cache removido: ${cacheKey}`);
|
|
@@ -4053,7 +4147,7 @@ class FirestoreOperationsHelper {
|
|
|
4053
4147
|
this.model = model;
|
|
4054
4148
|
}
|
|
4055
4149
|
buildInstanceFromIdentifiers(identifiers) {
|
|
4056
|
-
return this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => (
|
|
4150
|
+
return this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => ({ ...acc, [field]: identifiers[field] }), {}));
|
|
4057
4151
|
}
|
|
4058
4152
|
async validateDocumentExists(docRef, collectionName, identifiers) {
|
|
4059
4153
|
const docSnapshot = await docRef.get();
|
|
@@ -4075,7 +4169,7 @@ class FirestoreOperationsHelper {
|
|
|
4075
4169
|
calculateCount(data, limits) {
|
|
4076
4170
|
if (data.length <= 0)
|
|
4077
4171
|
return 0;
|
|
4078
|
-
if (data.length
|
|
4172
|
+
if (data.length)
|
|
4079
4173
|
return data.length;
|
|
4080
4174
|
return Infinity;
|
|
4081
4175
|
}
|
|
@@ -4088,8 +4182,8 @@ class FirestoreOperationsHelper {
|
|
|
4088
4182
|
const { isSubCollection, collectionName, parentRepository, parentIdField, identifiers } = params;
|
|
4089
4183
|
if (!isSubCollection)
|
|
4090
4184
|
return collectionName;
|
|
4091
|
-
const parentId = identifiers
|
|
4092
|
-
return `${parentRepository
|
|
4185
|
+
const parentId = identifiers?.[parentIdField];
|
|
4186
|
+
return `${parentRepository?.collectionName}/${parentId}/${collectionName}`;
|
|
4093
4187
|
}
|
|
4094
4188
|
getKeyField() {
|
|
4095
4189
|
const model = new this.model();
|
|
@@ -4140,27 +4234,25 @@ const createGetFirestoreClass = (MixinBase) => {
|
|
|
4140
4234
|
}
|
|
4141
4235
|
}
|
|
4142
4236
|
async executeGet(params) {
|
|
4143
|
-
var _a, _b, _c, _d;
|
|
4144
4237
|
const { instance, collectionName, identifiers, logger, req } = params;
|
|
4145
|
-
const intercepted = await
|
|
4146
|
-
const builded =
|
|
4238
|
+
const intercepted = await this.interceptors?.request?.({ instance });
|
|
4239
|
+
const builded = intercepted?.instance || instance;
|
|
4147
4240
|
const docRef = await this.operationsHelper.getDocumentSnapshot(this.collection(collectionName), builded);
|
|
4148
4241
|
const data = docRef.data();
|
|
4149
4242
|
this.operationsHelper.validateDocumentData(data, collectionName, identifiers);
|
|
4150
|
-
const result = (await
|
|
4243
|
+
const result = (await this.interceptors?.response?.(data, intercepted)) || data;
|
|
4151
4244
|
logger.log({ req, res: result });
|
|
4152
4245
|
return result;
|
|
4153
4246
|
}
|
|
4154
4247
|
async saveCacheData(params) {
|
|
4155
|
-
var _a, _b, _c;
|
|
4156
4248
|
const { identifiers, options, result, logger, req } = params;
|
|
4157
|
-
if (!
|
|
4249
|
+
if (!this.cache?.cacheAdapter || options?.cache?.enabled === false)
|
|
4158
4250
|
return;
|
|
4159
4251
|
const cacheKey = FirestoreCacheHelper.generateGetCacheKey(this.model, identifiers);
|
|
4160
4252
|
await FirestoreCacheHelper.saveCacheData(this.cache, {
|
|
4161
4253
|
cacheKey,
|
|
4162
4254
|
data: result,
|
|
4163
|
-
expirationInSeconds:
|
|
4255
|
+
expirationInSeconds: options?.cache?.ttl,
|
|
4164
4256
|
logger,
|
|
4165
4257
|
req,
|
|
4166
4258
|
});
|
|
@@ -4191,14 +4283,13 @@ class FirestoreQueryBuilderHelper {
|
|
|
4191
4283
|
this.config = config;
|
|
4192
4284
|
}
|
|
4193
4285
|
buildWhereSentence(fieldName, options) {
|
|
4194
|
-
|
|
4195
|
-
if (((_b = (_a = this.config).isSubCollection) === null || _b === void 0 ? void 0 : _b.call(_a, this)) && fieldName === this.config.parentIdField)
|
|
4286
|
+
if (this.config.isSubCollection?.(this) && fieldName === this.config.parentIdField)
|
|
4196
4287
|
return [];
|
|
4197
4288
|
const firestoreFieldName = this.getFirestoreFieldName(fieldName, options);
|
|
4198
4289
|
return this.buildWhereConditions(firestoreFieldName, options, fieldName);
|
|
4199
4290
|
}
|
|
4200
4291
|
getFirestoreFieldName(fieldName, options) {
|
|
4201
|
-
const value =
|
|
4292
|
+
const value = options?.value || options;
|
|
4202
4293
|
const object = {};
|
|
4203
4294
|
set(object, fieldName.toString(), value);
|
|
4204
4295
|
const plainInstance = new this.config.model(object).toPlain();
|
|
@@ -4207,19 +4298,19 @@ class FirestoreQueryBuilderHelper {
|
|
|
4207
4298
|
: Object.keys(plainInstance).find((key) => plainInstance[key]);
|
|
4208
4299
|
}
|
|
4209
4300
|
buildWhereConditions(firestoreFieldName, options, fieldName) {
|
|
4210
|
-
if (
|
|
4301
|
+
if (options?.operator === Where.LIKE) {
|
|
4211
4302
|
return this.buildLikeConditions(firestoreFieldName, options);
|
|
4212
4303
|
}
|
|
4213
|
-
if (
|
|
4304
|
+
if (options?.operator === Where.IN && Array.isArray(options?.value)) {
|
|
4214
4305
|
return this.buildInConditions(firestoreFieldName, options);
|
|
4215
4306
|
}
|
|
4216
4307
|
if (this.isNestedObjectFilter(options)) {
|
|
4217
4308
|
return this.buildNestedObjectConditions(fieldName, options);
|
|
4218
4309
|
}
|
|
4219
|
-
return [[firestoreFieldName, (
|
|
4310
|
+
return [[firestoreFieldName, (options?.operator || '=='), options?.value || options]];
|
|
4220
4311
|
}
|
|
4221
4312
|
buildLikeConditions(firestoreFieldName, options) {
|
|
4222
|
-
if (this.isArrayField(firestoreFieldName) && Array.isArray(options
|
|
4313
|
+
if (this.isArrayField(firestoreFieldName) && Array.isArray(options?.value)) {
|
|
4223
4314
|
return [[firestoreFieldName, 'array-contains-any', options.value]];
|
|
4224
4315
|
}
|
|
4225
4316
|
return [
|
|
@@ -4236,17 +4327,16 @@ class FirestoreQueryBuilderHelper {
|
|
|
4236
4327
|
buildNestedObjectConditions(fieldName, options) {
|
|
4237
4328
|
return Object.keys(options).reduce((queries, key) => [
|
|
4238
4329
|
...queries,
|
|
4239
|
-
...this.buildWhereSentence(`${fieldName.toString()}.${key}`, is(options)[key]),
|
|
4330
|
+
...this.buildWhereSentence(Array.isArray(options) ? fieldName : `${fieldName.toString()}.${key}`, is(options)[key]),
|
|
4240
4331
|
], []);
|
|
4241
4332
|
}
|
|
4242
4333
|
isArrayField(firestoreFieldName) {
|
|
4243
|
-
|
|
4244
|
-
return (((_a = this.config.fields) === null || _a === void 0 ? void 0 : _a[firestoreFieldName]) ===
|
|
4334
|
+
return (this.config.fields?.[firestoreFieldName] ===
|
|
4245
4335
|
FirestoreFieldType.Array ||
|
|
4246
|
-
!
|
|
4336
|
+
!this.config.fields?.[firestoreFieldName]);
|
|
4247
4337
|
}
|
|
4248
4338
|
isNestedObjectFilter(options) {
|
|
4249
|
-
return isObject(options) && isNil(options
|
|
4339
|
+
return isObject(options) && isNil(options?.operator) && isNil(options?.value);
|
|
4250
4340
|
}
|
|
4251
4341
|
buildOrderBy(filters, fieldsToOrderBy) {
|
|
4252
4342
|
const orderByKeys = Object.keys(fieldsToOrderBy || {});
|
|
@@ -4262,8 +4352,8 @@ class FirestoreQueryBuilderHelper {
|
|
|
4262
4352
|
filtersKeysWithUnordered.forEach((filterKey) => {
|
|
4263
4353
|
const filterValue = filters[filterKey];
|
|
4264
4354
|
const filterOptions = is(filterValue);
|
|
4265
|
-
if (
|
|
4266
|
-
updatedOrderBy =
|
|
4355
|
+
if (filterOptions?.operator && ![Where.EQUALS].includes(filterOptions.operator)) {
|
|
4356
|
+
updatedOrderBy = { [filterKey]: 'asc', ...updatedOrderBy };
|
|
4267
4357
|
}
|
|
4268
4358
|
});
|
|
4269
4359
|
return updatedOrderBy;
|
|
@@ -4277,21 +4367,21 @@ class FirestoreQueryBuilderHelper {
|
|
|
4277
4367
|
async buildLimits(params) {
|
|
4278
4368
|
const { filters, limits, collection, buildCollectionPath } = params;
|
|
4279
4369
|
const queries = [];
|
|
4280
|
-
if (limits
|
|
4370
|
+
if (limits?.offset) {
|
|
4281
4371
|
await this.addOffsetQuery({ queries, limits, filters, collection, buildCollectionPath });
|
|
4282
4372
|
}
|
|
4283
|
-
if (limits
|
|
4373
|
+
if (limits?.limit) {
|
|
4284
4374
|
queries.push(['limit', limits.limit]);
|
|
4285
4375
|
}
|
|
4286
4376
|
return queries;
|
|
4287
4377
|
}
|
|
4288
4378
|
async addOffsetQuery(params) {
|
|
4289
|
-
var _a;
|
|
4290
4379
|
const { queries, limits, filters, collection, buildCollectionPath } = params;
|
|
4291
4380
|
if (this.config.model.isModel(limits.offset)) {
|
|
4292
4381
|
const docSnapshot = await collection(buildCollectionPath(filters))
|
|
4293
|
-
.getDoc(
|
|
4294
|
-
.shift()
|
|
4382
|
+
.getDoc(Object.values(limits.offset.identifier)
|
|
4383
|
+
.shift()
|
|
4384
|
+
?.toString())
|
|
4295
4385
|
.get();
|
|
4296
4386
|
queries.push(['fromStartAfter', docSnapshot]);
|
|
4297
4387
|
}
|
|
@@ -4306,7 +4396,7 @@ class FirestoreQueryBuilderHelper {
|
|
|
4306
4396
|
}
|
|
4307
4397
|
|
|
4308
4398
|
const createFilterHelpers = () => {
|
|
4309
|
-
const checkIfIsFilterOption = (filter) => !isNil(filter
|
|
4399
|
+
const checkIfIsFilterOption = (filter) => !isNil(filter?.operator);
|
|
4310
4400
|
const getValueFromFilter = (filter) => {
|
|
4311
4401
|
return checkIfIsFilterOption(filter) ? filter.value : filter;
|
|
4312
4402
|
};
|
|
@@ -4364,20 +4454,19 @@ const withFindFirestore = (MixinBase) => {
|
|
|
4364
4454
|
}
|
|
4365
4455
|
}
|
|
4366
4456
|
async executeFind(params) {
|
|
4367
|
-
var _a, _b, _c, _d, _e, _f;
|
|
4368
4457
|
const { find, collectionName, logger, req } = params;
|
|
4369
4458
|
const collection = this.collection(collectionName);
|
|
4370
|
-
const enableCount =
|
|
4371
|
-
const intercepted = await
|
|
4372
|
-
const { filters, limits, orderBy } =
|
|
4459
|
+
const enableCount = find?.options?.enableCount ?? true;
|
|
4460
|
+
const intercepted = await this.interceptors?.request?.({ find });
|
|
4461
|
+
const { filters, limits, orderBy } = intercepted?.find || find;
|
|
4373
4462
|
const queryData = await this.buildQueryData(filters, orderBy, limits);
|
|
4374
4463
|
const docs = await this.executeQuery(collection, queryData);
|
|
4375
4464
|
const data = docs.docs.map((doc) => doc.data());
|
|
4376
4465
|
const result = {
|
|
4377
|
-
data: (await
|
|
4466
|
+
data: (await this.interceptors?.response?.(data, intercepted)) || data,
|
|
4378
4467
|
count: enableCount ? this.operationsHelper.calculateCount(data, limits) : Infinity,
|
|
4379
4468
|
};
|
|
4380
|
-
logger.log(
|
|
4469
|
+
logger.log({ req, ...queryData, res: result });
|
|
4381
4470
|
return result;
|
|
4382
4471
|
}
|
|
4383
4472
|
async buildQueryData(filters, orderBy, limits) {
|
|
@@ -4393,19 +4482,21 @@ const withFindFirestore = (MixinBase) => {
|
|
|
4393
4482
|
}
|
|
4394
4483
|
async executeQuery(collection, queryData) {
|
|
4395
4484
|
return this.queryBuilder
|
|
4396
|
-
.buildQuery(
|
|
4485
|
+
.buildQuery({
|
|
4486
|
+
collection,
|
|
4487
|
+
...queryData,
|
|
4488
|
+
})
|
|
4397
4489
|
.getDocs();
|
|
4398
4490
|
}
|
|
4399
4491
|
async saveCacheData(params) {
|
|
4400
|
-
var _a, _b, _c;
|
|
4401
4492
|
const { find, options, result, logger } = params;
|
|
4402
|
-
if (!
|
|
4493
|
+
if (!this.cache?.cacheAdapter || options?.cache?.enabled === false)
|
|
4403
4494
|
return;
|
|
4404
4495
|
const cacheKey = this.generateCacheKey(find);
|
|
4405
4496
|
await FirestoreCacheHelper.saveCacheData(this.cache, {
|
|
4406
4497
|
cacheKey,
|
|
4407
4498
|
data: result,
|
|
4408
|
-
expirationInSeconds:
|
|
4499
|
+
expirationInSeconds: options?.cache?.ttl,
|
|
4409
4500
|
logger,
|
|
4410
4501
|
});
|
|
4411
4502
|
}
|
|
@@ -4413,7 +4504,7 @@ const withFindFirestore = (MixinBase) => {
|
|
|
4413
4504
|
if (!this.isSubCollection(this))
|
|
4414
4505
|
return this.collectionName;
|
|
4415
4506
|
const parentIdField = this.parentIdField;
|
|
4416
|
-
const parentId = getValueFromFilter(filters
|
|
4507
|
+
const parentId = getValueFromFilter(filters?.[parentIdField]);
|
|
4417
4508
|
return `${this.parentRepository.collectionName}/${parentId}/${this.collectionName}`;
|
|
4418
4509
|
}
|
|
4419
4510
|
};
|
|
@@ -4422,16 +4513,15 @@ const withFindFirestore = (MixinBase) => {
|
|
|
4422
4513
|
const withCreateFirestore = (MixinBase) => {
|
|
4423
4514
|
return class CreateFirestore extends MixinBase {
|
|
4424
4515
|
async create(data) {
|
|
4425
|
-
var _a, _b, _c, _d;
|
|
4426
4516
|
const logger = this.logger.with('create');
|
|
4427
4517
|
const instance = this.model.toInstance(data);
|
|
4428
|
-
const intercepted = await
|
|
4429
|
-
const builded =
|
|
4518
|
+
const intercepted = await this.interceptors?.request?.({ instance });
|
|
4519
|
+
const builded = intercepted?.instance || instance;
|
|
4430
4520
|
const req = { collection: this.buildCollectionPathForAdd(builded), data };
|
|
4431
4521
|
try {
|
|
4432
4522
|
const docRef = await this.save(builded);
|
|
4433
4523
|
const doc = (await docRef.get()).data();
|
|
4434
|
-
const docBuilded = (await
|
|
4524
|
+
const docBuilded = (await this.interceptors?.response?.(doc, intercepted)) || doc;
|
|
4435
4525
|
logger.log({ req, res: docBuilded });
|
|
4436
4526
|
return docBuilded;
|
|
4437
4527
|
}
|
|
@@ -4442,10 +4532,9 @@ const withCreateFirestore = (MixinBase) => {
|
|
|
4442
4532
|
}
|
|
4443
4533
|
}
|
|
4444
4534
|
async save(data) {
|
|
4445
|
-
var _a, _b;
|
|
4446
4535
|
const collectionPath = this.buildCollectionPathForAdd(data);
|
|
4447
4536
|
const collection = this.collection(collectionPath);
|
|
4448
|
-
return collection.add(data,
|
|
4537
|
+
return collection.add(data, Object.values(data.identifier).shift()?.toString?.());
|
|
4449
4538
|
}
|
|
4450
4539
|
buildCollectionPathForAdd(identifiers) {
|
|
4451
4540
|
return this.isSubCollection(this)
|
|
@@ -4456,26 +4545,23 @@ const withCreateFirestore = (MixinBase) => {
|
|
|
4456
4545
|
};
|
|
4457
4546
|
|
|
4458
4547
|
const createUpdateHelpers = () => {
|
|
4459
|
-
const getValueFromParams = (params, field) =>
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
? is(params[field])
|
|
4463
|
-
: is(params[field]).value) || null;
|
|
4464
|
-
};
|
|
4548
|
+
const getValueFromParams = (params, field) => (isNil(is(params[field])?.value)
|
|
4549
|
+
? is(params[field])
|
|
4550
|
+
: is(params[field]).value) || null;
|
|
4465
4551
|
const getValueByAction = (options) => {
|
|
4466
|
-
if (isNil(options
|
|
4552
|
+
if (isNil(options?.action))
|
|
4467
4553
|
return options;
|
|
4468
|
-
if (
|
|
4554
|
+
if (options?.action === UpdateOptionActions.REMOVE_FIELD)
|
|
4469
4555
|
return deleteField();
|
|
4470
|
-
if (
|
|
4556
|
+
if (options?.action === UpdateOptionActions.NULL)
|
|
4471
4557
|
return null;
|
|
4472
|
-
if (Array.isArray(options
|
|
4473
|
-
if (
|
|
4558
|
+
if (Array.isArray(options?.value)) {
|
|
4559
|
+
if (options?.action === UpdateOptionActions.MERGE)
|
|
4474
4560
|
return arrayUnion(...options.value);
|
|
4475
|
-
if (
|
|
4561
|
+
if (options?.action === UpdateOptionActions.REMOVE)
|
|
4476
4562
|
return arrayRemove(...options.value);
|
|
4477
4563
|
}
|
|
4478
|
-
return options
|
|
4564
|
+
return options?.value;
|
|
4479
4565
|
};
|
|
4480
4566
|
return { getValueFromParams, getValueByAction };
|
|
4481
4567
|
};
|
|
@@ -4526,14 +4612,13 @@ const createUpdateFirestoreClass = (MixinBase, helpers) => {
|
|
|
4526
4612
|
await FirestoreCacheHelper.removeCacheData(this.cache, { cacheKey, logger });
|
|
4527
4613
|
}
|
|
4528
4614
|
async executeUpdate(params) {
|
|
4529
|
-
var _a, _b, _c, _d;
|
|
4530
4615
|
const { data, docRef, logger, req, identifiers } = params;
|
|
4531
4616
|
const plainFromData = this.model.toInstance(this.paramsToPlain(data));
|
|
4532
|
-
const intercepted = await
|
|
4533
|
-
const builded =
|
|
4617
|
+
const intercepted = await this.interceptors?.request?.({ instance: plainFromData });
|
|
4618
|
+
const builded = intercepted?.instance || plainFromData;
|
|
4534
4619
|
await docRef.save(builded.toPlain());
|
|
4535
4620
|
const docData = await docRef.get();
|
|
4536
|
-
const result =
|
|
4621
|
+
const result = this.interceptors?.response?.(docData.data(), intercepted) || docData.data();
|
|
4537
4622
|
logger.log({ req, res: result, identifiers });
|
|
4538
4623
|
return result;
|
|
4539
4624
|
}
|
|
@@ -4549,7 +4634,10 @@ const createUpdateFirestoreClass = (MixinBase, helpers) => {
|
|
|
4549
4634
|
return this.convertParamsToPlainObject(params);
|
|
4550
4635
|
}
|
|
4551
4636
|
convertParamsToPlainObject(params) {
|
|
4552
|
-
return Object.keys(params).reduce((data, currentKey) => (
|
|
4637
|
+
return Object.keys(params).reduce((data, currentKey) => ({
|
|
4638
|
+
...data,
|
|
4639
|
+
...this.processParamValue(currentKey, params[currentKey]),
|
|
4640
|
+
}), {});
|
|
4553
4641
|
}
|
|
4554
4642
|
processParamValue(key, value) {
|
|
4555
4643
|
const processedValue = getValueByAction(value);
|
|
@@ -4590,12 +4678,11 @@ const createDeleteFirestoreClass = (MixinBase) => {
|
|
|
4590
4678
|
await FirestoreCacheHelper.removeCacheData(this.cache, { cacheKey, logger });
|
|
4591
4679
|
}
|
|
4592
4680
|
async executeDeleteOperation(params) {
|
|
4593
|
-
var _a, _b, _c, _d;
|
|
4594
4681
|
const { instance, collectionName, logger, req } = params;
|
|
4595
|
-
const intercepted = await
|
|
4596
|
-
const builded =
|
|
4682
|
+
const intercepted = await this.interceptors?.request?.({ instance });
|
|
4683
|
+
const builded = intercepted?.instance || instance;
|
|
4597
4684
|
await this.operationsHelper.executeDelete(this.collection(collectionName), builded);
|
|
4598
|
-
await
|
|
4685
|
+
await this.interceptors?.response?.(instance, intercepted);
|
|
4599
4686
|
logger.log({ req, res: undefined });
|
|
4600
4687
|
}
|
|
4601
4688
|
buildCollectionPathForRemove(identifiers) {
|
|
@@ -4675,15 +4762,15 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
|
|
|
4675
4762
|
const products = [];
|
|
4676
4763
|
const wheres = [];
|
|
4677
4764
|
for (const productIds of chunks) {
|
|
4678
|
-
if (
|
|
4765
|
+
if (options?.limit && products.length >= options?.limit)
|
|
4679
4766
|
break;
|
|
4680
4767
|
wheres.push(['published', '==', true], ['id', 'in', productIds]);
|
|
4681
|
-
if (options
|
|
4768
|
+
if (options?.hasStock)
|
|
4682
4769
|
wheres.push(['stock.quantity', '>', 0]);
|
|
4683
|
-
if (options
|
|
4684
|
-
wheres.push(['tags', 'array-contains', options
|
|
4770
|
+
if (options?.gender)
|
|
4771
|
+
wheres.push(['tags', 'array-contains', options?.gender]);
|
|
4685
4772
|
const productSnap = await wheres
|
|
4686
|
-
.reduce((collection, where) => collection.where(...where),
|
|
4773
|
+
.reduce((collection, where) => collection.where(...where), options?.limit
|
|
4687
4774
|
? this.collection('productsErpVitrine').limit(options.limit)
|
|
4688
4775
|
: this.collection('productsErpVitrine'))
|
|
4689
4776
|
.getDocs();
|
|
@@ -4748,19 +4835,17 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
|
|
|
4748
4835
|
throw new Error('Method not implemented.');
|
|
4749
4836
|
}
|
|
4750
4837
|
async getBySlug(slug) {
|
|
4751
|
-
var _a;
|
|
4752
4838
|
const result = await this.find({
|
|
4753
4839
|
filters: {
|
|
4754
4840
|
slug: { operator: Where.EQUALS, value: slug },
|
|
4755
4841
|
},
|
|
4756
4842
|
});
|
|
4757
|
-
return
|
|
4843
|
+
return result?.data?.shift();
|
|
4758
4844
|
}
|
|
4759
4845
|
async fetchReviews(status) {
|
|
4760
4846
|
const { data: products } = await this.find();
|
|
4761
4847
|
products.forEach((product) => {
|
|
4762
|
-
|
|
4763
|
-
if ([undefined, 0].includes((_a = product.reviews) === null || _a === void 0 ? void 0 : _a.length))
|
|
4848
|
+
if ([undefined, 0].includes(product.reviews?.length))
|
|
4764
4849
|
return;
|
|
4765
4850
|
const productInfo = {
|
|
4766
4851
|
productId: product.id,
|
|
@@ -4772,11 +4857,11 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
|
|
|
4772
4857
|
this.reviews.rejected = [];
|
|
4773
4858
|
product.reviews.forEach((review) => {
|
|
4774
4859
|
if ([null, undefined].includes(review.status))
|
|
4775
|
-
return this.reviews.pending.push(
|
|
4860
|
+
return this.reviews.pending.push({ ...review, ...productInfo });
|
|
4776
4861
|
if (review.status === false)
|
|
4777
|
-
return this.reviews.rejected.push(
|
|
4862
|
+
return this.reviews.rejected.push({ ...review, ...productInfo });
|
|
4778
4863
|
if (review.status)
|
|
4779
|
-
return this.reviews.approved.push(
|
|
4864
|
+
return this.reviews.approved.push({ ...review, ...productInfo });
|
|
4780
4865
|
return review;
|
|
4781
4866
|
});
|
|
4782
4867
|
});
|
|
@@ -4863,22 +4948,18 @@ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
|
|
|
4863
4948
|
interceptors,
|
|
4864
4949
|
cache,
|
|
4865
4950
|
});
|
|
4866
|
-
this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
|
|
4879
|
-
products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
|
|
4880
|
-
});
|
|
4881
|
-
};
|
|
4951
|
+
this.homeCategoryGroupToPlain = (homeCategoryGroup) => ({
|
|
4952
|
+
category: homeCategoryGroup?.category?.toPlain
|
|
4953
|
+
? homeCategoryGroup?.category?.toPlain()
|
|
4954
|
+
: homeCategoryGroup?.category,
|
|
4955
|
+
products: homeCategoryGroup?.products
|
|
4956
|
+
?.map((product) => (product?.toPlain ? product?.toPlain() : product))
|
|
4957
|
+
.filter(Boolean) || [],
|
|
4958
|
+
});
|
|
4959
|
+
this.plainToHomeCategoryGroup = (homeCategoryGroup) => ({
|
|
4960
|
+
category: Category.toInstance(homeCategoryGroup?.category),
|
|
4961
|
+
products: homeCategoryGroup.products?.map((product) => Product.toInstance(product)),
|
|
4962
|
+
});
|
|
4882
4963
|
}
|
|
4883
4964
|
buildModelInstance() {
|
|
4884
4965
|
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
@@ -4894,17 +4975,15 @@ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
|
|
|
4894
4975
|
};
|
|
4895
4976
|
}
|
|
4896
4977
|
homeToFirestore(home) {
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
home.data.data.
|
|
4900
|
-
home.data.data.
|
|
4901
|
-
home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
|
|
4978
|
+
if (home.data?.data) {
|
|
4979
|
+
home.data.data.discoverProducts = home.data.data.discoverProducts?.map(this.homeCategoryGroupToPlain) || [];
|
|
4980
|
+
home.data.data.featuredProducts = home.data.data.featuredProducts?.map(this.homeCategoryGroupToPlain) || [];
|
|
4981
|
+
home.data.data.verticalProducts = home.data.data.verticalProducts?.map(this.homeCategoryGroupToPlain) || [];
|
|
4902
4982
|
}
|
|
4903
4983
|
return home;
|
|
4904
4984
|
}
|
|
4905
4985
|
homeFromFirestore(home) {
|
|
4906
|
-
|
|
4907
|
-
if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
|
|
4986
|
+
if (home.data?.data) {
|
|
4908
4987
|
home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
|
|
4909
4988
|
home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
|
|
4910
4989
|
home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
|
|
@@ -5043,8 +5122,7 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
|
|
|
5043
5122
|
},
|
|
5044
5123
|
});
|
|
5045
5124
|
this.orderFromFirestore = (order) => {
|
|
5046
|
-
|
|
5047
|
-
if ((_a = order === null || order === void 0 ? void 0 : order.lineItems) === null || _a === void 0 ? void 0 : _a.length) {
|
|
5125
|
+
if (order?.lineItems?.length) {
|
|
5048
5126
|
order.lineItems = order.lineItems.map((lineItem) => {
|
|
5049
5127
|
const prices = !!lineItem.price;
|
|
5050
5128
|
const shopPrice = prices[order.shop];
|
|
@@ -5059,7 +5137,7 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
|
|
|
5059
5137
|
buildModelInstance() {
|
|
5060
5138
|
const { fromFirestore, toFirestore } = super.buildModelInstance();
|
|
5061
5139
|
return {
|
|
5062
|
-
toFirestore: (data) => toFirestore(
|
|
5140
|
+
toFirestore: (data) => toFirestore(data?.toPlain ? data.toPlain() : data),
|
|
5063
5141
|
fromFirestore: (snap) => {
|
|
5064
5142
|
const instance = fromFirestore(snap);
|
|
5065
5143
|
return this.orderFromFirestore(instance);
|
|
@@ -5090,18 +5168,20 @@ class OrderBlockedFirestoreRepository extends withCrudFirestore(withHelpers(with
|
|
|
5090
5168
|
});
|
|
5091
5169
|
}
|
|
5092
5170
|
async createBlockedOrderOrPayment(params) {
|
|
5093
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
5094
5171
|
const { checkout, blockType, type, limiteRange, card = null } = params;
|
|
5095
5172
|
return this.create(OrderBlocked.toInstance({
|
|
5096
5173
|
customer: {
|
|
5097
|
-
name:
|
|
5098
|
-
cpf:
|
|
5099
|
-
id:
|
|
5100
|
-
email:
|
|
5101
|
-
phoneNumber: '+55' +
|
|
5102
|
-
isSubscriber:
|
|
5103
|
-
subscriptionPlan:
|
|
5104
|
-
shippingAddress:
|
|
5174
|
+
name: checkout.user?.displayName || '',
|
|
5175
|
+
cpf: checkout.user?.cpf || '',
|
|
5176
|
+
id: checkout.user?.id,
|
|
5177
|
+
email: checkout.user?.email || '',
|
|
5178
|
+
phoneNumber: '+55' + checkout.user?.phone,
|
|
5179
|
+
isSubscriber: checkout.user?.isSubscriber,
|
|
5180
|
+
subscriptionPlan: checkout.user?.subscriptionPlan || '',
|
|
5181
|
+
shippingAddress: {
|
|
5182
|
+
...checkout.shippingAddress,
|
|
5183
|
+
zip: this.formatZip(checkout.shippingAddress?.zip),
|
|
5184
|
+
},
|
|
5105
5185
|
},
|
|
5106
5186
|
blockType,
|
|
5107
5187
|
limiteRange,
|
|
@@ -5349,7 +5429,7 @@ class ConnectDocumentService {
|
|
|
5349
5429
|
this.reference = doc(this.firestore, this.path).withConverter({
|
|
5350
5430
|
toFirestore: (data) => data,
|
|
5351
5431
|
fromFirestore: (snapshot) => {
|
|
5352
|
-
return
|
|
5432
|
+
return { id: snapshot.id, ...snapshot.data() };
|
|
5353
5433
|
},
|
|
5354
5434
|
});
|
|
5355
5435
|
}
|
|
@@ -5387,7 +5467,7 @@ class ConnectCollectionService {
|
|
|
5387
5467
|
this.reference = collection(firestore, path).withConverter({
|
|
5388
5468
|
toFirestore: (data) => data,
|
|
5389
5469
|
fromFirestore: (snapshot) => {
|
|
5390
|
-
return
|
|
5470
|
+
return { id: snapshot.id, ...snapshot.data() };
|
|
5391
5471
|
},
|
|
5392
5472
|
});
|
|
5393
5473
|
}
|
|
@@ -5482,10 +5562,10 @@ class FirebaseFileUploaderService {
|
|
|
5482
5562
|
function createCreateHasuraGraphQLClass(MixinBase) {
|
|
5483
5563
|
return class CreateHasuraGraphQLMixin extends MixinBase {
|
|
5484
5564
|
constructor(...params) {
|
|
5485
|
-
const options = params
|
|
5565
|
+
const options = params?.[0];
|
|
5486
5566
|
super(...params);
|
|
5487
|
-
this.insertGraphQLOperation = HasuraCreateOperationsHelper.buildInsertOperationName(this.tableName, options
|
|
5488
|
-
this.insertGraphQLObjectType = HasuraCreateOperationsHelper.buildInsertObjectType(this.tableName, options
|
|
5567
|
+
this.insertGraphQLOperation = HasuraCreateOperationsHelper.buildInsertOperationName(this.tableName, options?.insertGraphQLOperation);
|
|
5568
|
+
this.insertGraphQLObjectType = HasuraCreateOperationsHelper.buildInsertObjectType(this.tableName, options?.insertGraphQLObjectType);
|
|
5489
5569
|
}
|
|
5490
5570
|
async create(data) {
|
|
5491
5571
|
return HasuraCreateOperationsHelper.executeCreate(data, {
|
|
@@ -5512,9 +5592,9 @@ function createCreateHasuraGraphQLClass(MixinBase) {
|
|
|
5512
5592
|
function createDeleteHasuraGraphQLClass(MixinBase) {
|
|
5513
5593
|
return class DeleteHasuraGraphQLMixin extends MixinBase {
|
|
5514
5594
|
constructor(...params) {
|
|
5515
|
-
const options = params
|
|
5595
|
+
const options = params?.[0];
|
|
5516
5596
|
super(...params);
|
|
5517
|
-
this.deleteGraphQLOperation = HasuraDeleteOperationsHelper.buildDeleteOperationName(this.tableName, options
|
|
5597
|
+
this.deleteGraphQLOperation = HasuraDeleteOperationsHelper.buildDeleteOperationName(this.tableName, options?.deleteGraphQLOperation);
|
|
5518
5598
|
}
|
|
5519
5599
|
async delete(identifiers) {
|
|
5520
5600
|
await HasuraDeleteOperationsHelper.executeDelete({
|
|
@@ -5560,9 +5640,9 @@ function createFindHasuraGraphQLClass(MixinBase) {
|
|
|
5560
5640
|
function createGetHasuraGraphQLClass(MixinBase) {
|
|
5561
5641
|
return class GetHasuraGraphQLMixin extends MixinBase {
|
|
5562
5642
|
constructor(...params) {
|
|
5563
|
-
const options = params
|
|
5643
|
+
const options = params?.[0];
|
|
5564
5644
|
super(...params);
|
|
5565
|
-
this.getGraphQLOperation = HasuraGetOperationsHelper.buildGetOperationName(this.tableName, options
|
|
5645
|
+
this.getGraphQLOperation = HasuraGetOperationsHelper.buildGetOperationName(this.tableName, options?.getGraphQLOperation);
|
|
5566
5646
|
}
|
|
5567
5647
|
generateCacheKey(identifiers) {
|
|
5568
5648
|
return HasuraGetCacheHelper.generateCacheKey(this.model, identifiers);
|
|
@@ -5638,11 +5718,11 @@ function createHasuraGraphQLClass(MixinBase) {
|
|
|
5638
5718
|
function createUpdateHasuraGraphQLClass(MixinBase) {
|
|
5639
5719
|
return class UpdateHasuraGraphQLMixin extends MixinBase {
|
|
5640
5720
|
constructor(...params) {
|
|
5641
|
-
const options = params
|
|
5721
|
+
const options = params?.[0];
|
|
5642
5722
|
super(...params);
|
|
5643
|
-
this.updateGraphQLOperation =
|
|
5644
|
-
this.updateGraphQLObjectType =
|
|
5645
|
-
this.updateGraphQLPKType =
|
|
5723
|
+
this.updateGraphQLOperation = options?.updateGraphQLOperation || `update_${this.tableName}_by_pk`;
|
|
5724
|
+
this.updateGraphQLObjectType = options?.updateGraphQLObjectType || `${this.tableName}_set_input`;
|
|
5725
|
+
this.updateGraphQLPKType = options?.updateGraphQLPKType || `${this.tableName}_pk_columns_input`;
|
|
5646
5726
|
}
|
|
5647
5727
|
getIdentifiersFromData(data) {
|
|
5648
5728
|
return HasuraUpdateDataHelper.getIdentifiersFromData(data, this.model);
|
|
@@ -5832,7 +5912,7 @@ const fieldsConfiguration$5 = [
|
|
|
5832
5912
|
categories: { data: value.map((category) => ({ category_id: +category })) },
|
|
5833
5913
|
}),
|
|
5834
5914
|
to: (categories) => categories.map((categoryId) => +categoryId),
|
|
5835
|
-
from: (categories) =>
|
|
5915
|
+
from: (categories) => categories?.map((category) => category?.category_id?.toString()) || [],
|
|
5836
5916
|
},
|
|
5837
5917
|
},
|
|
5838
5918
|
],
|
|
@@ -5913,8 +5993,7 @@ class CategoryCacheOperationsHelper {
|
|
|
5913
5993
|
logger.log(`Dados salvos no cache: ${cacheKey}`);
|
|
5914
5994
|
}
|
|
5915
5995
|
static shouldUseCache(cacheAdapter, optionsCache) {
|
|
5916
|
-
|
|
5917
|
-
return !!(cacheAdapter && ((_a = optionsCache === null || optionsCache === void 0 ? void 0 : optionsCache.cache) === null || _a === void 0 ? void 0 : _a.enabled));
|
|
5996
|
+
return !!(cacheAdapter && optionsCache?.cache?.enabled);
|
|
5918
5997
|
}
|
|
5919
5998
|
}
|
|
5920
5999
|
|
|
@@ -6082,19 +6161,25 @@ class CategoryProductOperationsHelper {
|
|
|
6082
6161
|
}
|
|
6083
6162
|
static buildProductQuery(params) {
|
|
6084
6163
|
const { productIds, fields, hasStock, limit } = params;
|
|
6085
|
-
return
|
|
6164
|
+
return {
|
|
6165
|
+
filters: this.buildProductFilters(productIds, hasStock),
|
|
6166
|
+
...(limit ? { limits: { limit } } : {}),
|
|
6167
|
+
fields,
|
|
6168
|
+
options: { enableCount: false },
|
|
6169
|
+
orderBy: {
|
|
6086
6170
|
stock: 'desc',
|
|
6087
6171
|
shoppingCount: 'desc',
|
|
6088
6172
|
rate: 'desc',
|
|
6089
6173
|
name: 'asc',
|
|
6090
|
-
}
|
|
6174
|
+
},
|
|
6175
|
+
};
|
|
6091
6176
|
}
|
|
6092
6177
|
static getGenderParam(shop) {
|
|
6093
6178
|
return shop === Shops.MENSMARKET ? 'male' : 'female';
|
|
6094
6179
|
}
|
|
6095
6180
|
static async fetchMostRelevantProducts(params) {
|
|
6096
6181
|
const { productRepository, mostRelevantsIds, fields, shop, hasStock, optionsCache } = params;
|
|
6097
|
-
if (!
|
|
6182
|
+
if (!mostRelevantsIds?.length)
|
|
6098
6183
|
return [];
|
|
6099
6184
|
const query = this.buildProductQuery({ productIds: mostRelevantsIds, fields, hasStock });
|
|
6100
6185
|
const { data } = await productRepository.findCatalog(query, this.getGenderParam(shop), optionsCache);
|
|
@@ -6123,9 +6208,8 @@ class CategoryProductOperationsHelper {
|
|
|
6123
6208
|
|
|
6124
6209
|
class CategoryMountOperationsHelper {
|
|
6125
6210
|
static async executeMount(params, dependencies) {
|
|
6126
|
-
var _a;
|
|
6127
6211
|
const { category, shop, options = {}, optionsCache } = params;
|
|
6128
|
-
if (!
|
|
6212
|
+
if (!category?.products?.length)
|
|
6129
6213
|
return [];
|
|
6130
6214
|
const cachedResult = await this.tryGetFromCache({
|
|
6131
6215
|
category,
|
|
@@ -6146,7 +6230,7 @@ class CategoryMountOperationsHelper {
|
|
|
6146
6230
|
optionsCache,
|
|
6147
6231
|
dependencies,
|
|
6148
6232
|
});
|
|
6149
|
-
if (mostRelevantProducts.length >= mostRelevantsIds.length) {
|
|
6233
|
+
if (mostRelevantsIds.length && mostRelevantProducts.length >= mostRelevantsIds.length) {
|
|
6150
6234
|
return this.finalizeMountWithMostRelevants({
|
|
6151
6235
|
mostRelevantProducts,
|
|
6152
6236
|
mostRelevantsIds,
|
|
@@ -6223,7 +6307,6 @@ class CategoryMountOperationsHelper {
|
|
|
6223
6307
|
return result;
|
|
6224
6308
|
}
|
|
6225
6309
|
static async saveToCacheIfNeeded(params) {
|
|
6226
|
-
var _a;
|
|
6227
6310
|
const { category, shop, options, optionsCache, result, dependencies } = params;
|
|
6228
6311
|
const shouldUseCache = CategoryCacheOperationsHelper.shouldUseCache(dependencies.cacheAdapter, optionsCache);
|
|
6229
6312
|
if (!shouldUseCache)
|
|
@@ -6233,7 +6316,7 @@ class CategoryMountOperationsHelper {
|
|
|
6233
6316
|
cacheAdapter: dependencies.cacheAdapter,
|
|
6234
6317
|
cacheKey,
|
|
6235
6318
|
products: result,
|
|
6236
|
-
ttl:
|
|
6319
|
+
ttl: optionsCache?.cache?.ttl || dependencies.defaultCacheTtl,
|
|
6237
6320
|
logger: dependencies.logger,
|
|
6238
6321
|
});
|
|
6239
6322
|
}
|
|
@@ -6259,7 +6342,12 @@ class ProductFetchReviewsHelper {
|
|
|
6259
6342
|
...reviews,
|
|
6260
6343
|
...product.reviews
|
|
6261
6344
|
.filter((review) => this.matchesStatus(review, status))
|
|
6262
|
-
.map((review) => (
|
|
6345
|
+
.map((review) => ({
|
|
6346
|
+
...bindReviewToModel(review),
|
|
6347
|
+
productId: product.id,
|
|
6348
|
+
productName: product.name,
|
|
6349
|
+
productSku: product.sku,
|
|
6350
|
+
})),
|
|
6263
6351
|
], []);
|
|
6264
6352
|
}
|
|
6265
6353
|
static matchesStatus(review, status) {
|
|
@@ -6306,8 +6394,7 @@ class ProductReviewCacheHelper {
|
|
|
6306
6394
|
dependencies.logger.log(`Dados salvos no cache: ${key}`);
|
|
6307
6395
|
}
|
|
6308
6396
|
static shouldUseCache(cacheAdapter, options) {
|
|
6309
|
-
|
|
6310
|
-
return !!(cacheAdapter && ((_a = options === null || options === void 0 ? void 0 : options.cache) === null || _a === void 0 ? void 0 : _a.enabled));
|
|
6397
|
+
return !!(cacheAdapter && options?.cache?.enabled);
|
|
6311
6398
|
}
|
|
6312
6399
|
}
|
|
6313
6400
|
|
|
@@ -6318,9 +6405,12 @@ class ProductReviewOperationsHelper {
|
|
|
6318
6405
|
let count = 0;
|
|
6319
6406
|
let offset = 0;
|
|
6320
6407
|
do {
|
|
6321
|
-
const result = await repository.find(
|
|
6322
|
-
|
|
6323
|
-
|
|
6408
|
+
const result = await repository.find({
|
|
6409
|
+
fields: ['id', 'name', 'sku', 'reviews'],
|
|
6410
|
+
...(limit && {
|
|
6411
|
+
limits: { offset, limit },
|
|
6412
|
+
}),
|
|
6413
|
+
});
|
|
6324
6414
|
data = data.concat(result.data);
|
|
6325
6415
|
count = result.data.length;
|
|
6326
6416
|
offset += limit;
|
|
@@ -6331,7 +6421,13 @@ class ProductReviewOperationsHelper {
|
|
|
6331
6421
|
const { data, getReviewStatus } = params;
|
|
6332
6422
|
return data.reduce((reviews, product) => [
|
|
6333
6423
|
...reviews,
|
|
6334
|
-
...product.reviews.map((review) => (
|
|
6424
|
+
...product.reviews.map((review) => ({
|
|
6425
|
+
...review,
|
|
6426
|
+
reviewStatus: getReviewStatus(review),
|
|
6427
|
+
productId: product.id,
|
|
6428
|
+
productName: product.name,
|
|
6429
|
+
productSku: product.sku,
|
|
6430
|
+
})),
|
|
6335
6431
|
], []);
|
|
6336
6432
|
}
|
|
6337
6433
|
static applyReviewFilters(params) {
|
|
@@ -6375,7 +6471,7 @@ class ProductReviewUpdateHelper {
|
|
|
6375
6471
|
const { productId, reviews, dependencies } = params;
|
|
6376
6472
|
const reviewIds = await Promise.all(reviews.value.map(async (reviewData) => {
|
|
6377
6473
|
const review = await dependencies.findReview(reviewData, productId);
|
|
6378
|
-
return review
|
|
6474
|
+
return review?.id;
|
|
6379
6475
|
}));
|
|
6380
6476
|
await dependencies.mutation('delete_product_review', ['affected_rows'], {
|
|
6381
6477
|
where: {
|
|
@@ -6414,7 +6510,7 @@ class ProductReviewUpdateHelper {
|
|
|
6414
6510
|
static async insertNewReview(reviewData, productId, dependencies) {
|
|
6415
6511
|
const result = await dependencies.mutation('insert_product_review_one', dependencies.reviewsFields, {
|
|
6416
6512
|
object: {
|
|
6417
|
-
value: omit(
|
|
6513
|
+
value: omit({ ...dependencies.bindReviewToHasura(reviewData), product_id: productId.toString() }, ['id']),
|
|
6418
6514
|
type: 'product_review_insert_input',
|
|
6419
6515
|
required: true,
|
|
6420
6516
|
},
|
|
@@ -6507,11 +6603,14 @@ const fieldsConfiguration$4 = [
|
|
|
6507
6603
|
bindPersistData: (value) => {
|
|
6508
6604
|
return {
|
|
6509
6605
|
brand_condition: value.brand,
|
|
6510
|
-
tag_condition:
|
|
6606
|
+
tag_condition: value?.tags || [],
|
|
6511
6607
|
};
|
|
6512
6608
|
},
|
|
6513
6609
|
bindFindFilter: (sentence) => {
|
|
6514
|
-
return
|
|
6610
|
+
return {
|
|
6611
|
+
...(sentence.brand ? { brand_condition: sentence.brand } : {}),
|
|
6612
|
+
...(sentence.tags ? { tag_condition: sentence.tags } : {}),
|
|
6613
|
+
};
|
|
6515
6614
|
},
|
|
6516
6615
|
},
|
|
6517
6616
|
},
|
|
@@ -6523,7 +6622,7 @@ const fieldsConfiguration$4 = [
|
|
|
6523
6622
|
bindPersistData: (value) => ({
|
|
6524
6623
|
filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
|
|
6525
6624
|
}),
|
|
6526
|
-
from: (filters) =>
|
|
6625
|
+
from: (filters) => filters?.map((filter) => filter?.filter).filter((filter) => filter.enabled) || [],
|
|
6527
6626
|
},
|
|
6528
6627
|
},
|
|
6529
6628
|
{ createdAt: { columnName: 'created_at' } },
|
|
@@ -6588,11 +6687,16 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6588
6687
|
this.categoryFilterRepository = categoryFilterRepository;
|
|
6589
6688
|
}
|
|
6590
6689
|
async create(params) {
|
|
6591
|
-
const { images, mostRelevants, metadatas
|
|
6592
|
-
return super.create(
|
|
6690
|
+
const { images, mostRelevants, metadatas, ...data } = params;
|
|
6691
|
+
return super.create({
|
|
6692
|
+
...data,
|
|
6693
|
+
isWishlist: false,
|
|
6694
|
+
metadatas: metadatas || [{ shop: null, description: null, title: null }],
|
|
6695
|
+
mostRelevants: mostRelevants || {
|
|
6593
6696
|
[Shops.GLAMSHOP]: null,
|
|
6594
6697
|
[Shops.MENSMARKET]: null,
|
|
6595
|
-
},
|
|
6698
|
+
},
|
|
6699
|
+
images: images || {
|
|
6596
6700
|
[Shops.GLAMSHOP]: {
|
|
6597
6701
|
brandBanner: null,
|
|
6598
6702
|
brandBannerMobile: null,
|
|
@@ -6603,17 +6707,18 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6603
6707
|
brandBannerMobile: null,
|
|
6604
6708
|
image: null,
|
|
6605
6709
|
},
|
|
6606
|
-
}
|
|
6710
|
+
},
|
|
6711
|
+
});
|
|
6607
6712
|
}
|
|
6608
6713
|
async get(identifiers, optionsCache) {
|
|
6609
6714
|
const id = await this.getId(identifiers.id);
|
|
6610
6715
|
return super.get({ id }, optionsCache);
|
|
6611
6716
|
}
|
|
6612
6717
|
async update(params) {
|
|
6613
|
-
const { id, products, metadatas, filters
|
|
6718
|
+
const { id, products, metadatas, filters, ...data } = params;
|
|
6614
6719
|
const categoryId = +(await this.getId(id));
|
|
6615
6720
|
const [category] = await Promise.all([
|
|
6616
|
-
super.update(
|
|
6721
|
+
super.update({ id: categoryId?.toString(), ...data }),
|
|
6617
6722
|
...(products ? [this.updateProducts(categoryId, { products })] : []),
|
|
6618
6723
|
...(metadatas ? [this.updateMetadata(categoryId, { metadatas })] : []),
|
|
6619
6724
|
...(filters ? [this.updateFilters(categoryId, { filters })] : []),
|
|
@@ -6653,7 +6758,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6653
6758
|
}
|
|
6654
6759
|
async getCategoriesForHome(params) {
|
|
6655
6760
|
const { categoryIds, shop, limit = 4, optionsCache } = params;
|
|
6656
|
-
if (!
|
|
6761
|
+
if (!categoryIds?.length)
|
|
6657
6762
|
return [];
|
|
6658
6763
|
const { firestore, hasura } = CategoryHomeOperationsHelper.separateCategoryIds(categoryIds);
|
|
6659
6764
|
const categories = [];
|
|
@@ -6674,11 +6779,10 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6674
6779
|
});
|
|
6675
6780
|
}
|
|
6676
6781
|
async mountCategory(params) {
|
|
6677
|
-
var _a, _b;
|
|
6678
6782
|
return CategoryMountOperationsHelper.executeMount(params, {
|
|
6679
6783
|
productRepository: this.productRepository,
|
|
6680
|
-
cacheAdapter:
|
|
6681
|
-
defaultCacheTtl:
|
|
6784
|
+
cacheAdapter: this.cache?.cacheAdapter,
|
|
6785
|
+
defaultCacheTtl: this.cache?.ttlDefault,
|
|
6682
6786
|
logger: this.logger,
|
|
6683
6787
|
});
|
|
6684
6788
|
}
|
|
@@ -6697,12 +6801,11 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6697
6801
|
return categoryTree.some((c) => c.id == id.toString());
|
|
6698
6802
|
}
|
|
6699
6803
|
async getId(id) {
|
|
6700
|
-
var _a, _b;
|
|
6701
6804
|
if (!Number.isNaN(+id))
|
|
6702
6805
|
return id;
|
|
6703
6806
|
const { data } = await this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
|
|
6704
|
-
if (
|
|
6705
|
-
return
|
|
6807
|
+
if (data?.[0]?.id)
|
|
6808
|
+
return data?.[0]?.id;
|
|
6706
6809
|
throw new NotFoundError(`Category with id ${id} not found`);
|
|
6707
6810
|
}
|
|
6708
6811
|
async updateProducts(categoryId, { products }) {
|
|
@@ -6756,7 +6859,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
6756
6859
|
objects: {
|
|
6757
6860
|
type: '[category_metadata_insert_input!]',
|
|
6758
6861
|
required: true,
|
|
6759
|
-
value: metadatas.map((m) => (
|
|
6862
|
+
value: metadatas.map((m) => ({ category_id: categoryId, ...m })),
|
|
6760
6863
|
},
|
|
6761
6864
|
});
|
|
6762
6865
|
return metadatas;
|
|
@@ -6922,7 +7025,7 @@ const fieldsConfiguration$3 = [
|
|
|
6922
7025
|
bindPersistData: (value) => ({
|
|
6923
7026
|
categories: { data: value.map((filter) => ({ filter_id: filter.id })) },
|
|
6924
7027
|
}),
|
|
6925
|
-
from: (categories) =>
|
|
7028
|
+
from: (categories) => categories?.map((category) => category?.category) || [],
|
|
6926
7029
|
},
|
|
6927
7030
|
},
|
|
6928
7031
|
];
|
|
@@ -6941,7 +7044,7 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
|
|
|
6941
7044
|
this.categoryFilterRepository = categoryFilterRepository;
|
|
6942
7045
|
}
|
|
6943
7046
|
async update(params) {
|
|
6944
|
-
const { options
|
|
7047
|
+
const { options, ...data } = params;
|
|
6945
7048
|
const filter = await super.update(data);
|
|
6946
7049
|
filter.options = await this.updateOptions(+data.id, { options });
|
|
6947
7050
|
return filter;
|
|
@@ -6963,8 +7066,8 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
|
|
|
6963
7066
|
if (hasFilter)
|
|
6964
7067
|
filterOptions.push(hasFilter);
|
|
6965
7068
|
}
|
|
6966
|
-
catch
|
|
6967
|
-
const newOption = await this.filterOptionRepository.create(
|
|
7069
|
+
catch {
|
|
7070
|
+
const newOption = await this.filterOptionRepository.create({ ...options.value[i], filterId });
|
|
6968
7071
|
filterOptions.push(newOption);
|
|
6969
7072
|
}
|
|
6970
7073
|
}
|
|
@@ -6978,8 +7081,8 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
|
|
|
6978
7081
|
if (hasFilter)
|
|
6979
7082
|
filterOptions.push(hasFilter);
|
|
6980
7083
|
}
|
|
6981
|
-
catch
|
|
6982
|
-
const newOption = await this.filterOptionRepository.create(
|
|
7084
|
+
catch {
|
|
7085
|
+
const newOption = await this.filterOptionRepository.create({ ...options[i], filterId });
|
|
6983
7086
|
filterOptions.push(newOption);
|
|
6984
7087
|
}
|
|
6985
7088
|
}
|
|
@@ -7100,13 +7203,13 @@ class ProductErrorsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHas
|
|
|
7100
7203
|
filters: {
|
|
7101
7204
|
id: {
|
|
7102
7205
|
operator: Where.IN,
|
|
7103
|
-
value: Array.from(new Set(variantsWithNoData.map((item) =>
|
|
7206
|
+
value: Array.from(new Set(variantsWithNoData.map((item) => item.product.productId?.toString()))),
|
|
7104
7207
|
},
|
|
7105
7208
|
},
|
|
7106
7209
|
});
|
|
7107
7210
|
products.forEach((product) => {
|
|
7108
7211
|
result.data
|
|
7109
|
-
.filter((variant) =>
|
|
7212
|
+
.filter((variant) => variant.product.productId?.toString() === product.id.toString())
|
|
7110
7213
|
.forEach((variant) => {
|
|
7111
7214
|
variant.product.name = product.name;
|
|
7112
7215
|
variant.product.group = product.group;
|
|
@@ -7139,21 +7242,37 @@ const commonFields = [
|
|
|
7139
7242
|
purpose: data.purpose,
|
|
7140
7243
|
}),
|
|
7141
7244
|
bindFindFilter: (filters) => {
|
|
7142
|
-
return
|
|
7143
|
-
|
|
7144
|
-
|
|
7145
|
-
|
|
7146
|
-
|
|
7147
|
-
|
|
7148
|
-
|
|
7149
|
-
|
|
7150
|
-
|
|
7151
|
-
|
|
7152
|
-
|
|
7245
|
+
return {
|
|
7246
|
+
...(filters?.description && { description: filters.description }),
|
|
7247
|
+
...(filters.differentials && { differentials: filters.differentials }),
|
|
7248
|
+
...(filters.whoMustUse && {
|
|
7249
|
+
who_must_use: filters.whoMustUse,
|
|
7250
|
+
}),
|
|
7251
|
+
...(filters.howToUse && {
|
|
7252
|
+
how_to_use: filters.howToUse,
|
|
7253
|
+
}),
|
|
7254
|
+
...(filters.brand && {
|
|
7255
|
+
brand_description: filters.brand,
|
|
7256
|
+
}),
|
|
7257
|
+
...(filters.ingredients && {
|
|
7258
|
+
ingredients: filters.ingredients,
|
|
7259
|
+
}),
|
|
7260
|
+
...(filters.purpose && {
|
|
7261
|
+
purpose: filters.purpose,
|
|
7262
|
+
}),
|
|
7263
|
+
};
|
|
7153
7264
|
},
|
|
7154
|
-
bindPersistData: (descriptionData) => (
|
|
7155
|
-
|
|
7156
|
-
|
|
7265
|
+
bindPersistData: (descriptionData) => ({
|
|
7266
|
+
...(descriptionData?.description && { description: descriptionData.description }),
|
|
7267
|
+
...(descriptionData.differentials && { differentials: descriptionData.differentials }),
|
|
7268
|
+
...(descriptionData.whoMustUse && {
|
|
7269
|
+
who_must_use: descriptionData.whoMustUse,
|
|
7270
|
+
}),
|
|
7271
|
+
...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
|
|
7272
|
+
...(descriptionData.brand && { brand_description: descriptionData.brand }),
|
|
7273
|
+
...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
|
|
7274
|
+
...(descriptionData.purpose && { purpose: descriptionData.purpose }),
|
|
7275
|
+
}),
|
|
7157
7276
|
},
|
|
7158
7277
|
},
|
|
7159
7278
|
{ differentials: { columnName: 'differentials' } },
|
|
@@ -7166,13 +7285,13 @@ const commonFields = [
|
|
|
7166
7285
|
{
|
|
7167
7286
|
images: {
|
|
7168
7287
|
columnName: 'images',
|
|
7169
|
-
to: (value) =>
|
|
7288
|
+
to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
|
|
7170
7289
|
},
|
|
7171
7290
|
},
|
|
7172
7291
|
{
|
|
7173
7292
|
miniatures: {
|
|
7174
7293
|
columnName: 'miniatures',
|
|
7175
|
-
to: (value) =>
|
|
7294
|
+
to: (value) => (value?.length > 0 ? `{"${value?.join?.('","') || ''}"}` : '{}'),
|
|
7176
7295
|
},
|
|
7177
7296
|
},
|
|
7178
7297
|
'name',
|
|
@@ -7187,19 +7306,31 @@ const commonFields = [
|
|
|
7187
7306
|
subscriberPrice: data.subscriber_price,
|
|
7188
7307
|
}),
|
|
7189
7308
|
bindFindFilter: (filters) => {
|
|
7190
|
-
return
|
|
7191
|
-
|
|
7192
|
-
|
|
7193
|
-
|
|
7194
|
-
|
|
7195
|
-
|
|
7196
|
-
|
|
7309
|
+
return {
|
|
7310
|
+
...((filters?.price || filters?.price === 0) && { price: filters.price }),
|
|
7311
|
+
...((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice }),
|
|
7312
|
+
...((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
|
|
7313
|
+
subscriber_discount_percentage: filters.subscriberDiscountPercentage,
|
|
7314
|
+
}),
|
|
7315
|
+
...((filters.subscriberPrice || filters.subscriberPrice === 0) && {
|
|
7316
|
+
subscriber_price: filters.subscriberPrice,
|
|
7317
|
+
}),
|
|
7318
|
+
...((filters.fullPriceDiscountPercentage || filters.fullPriceDiscountPercentage === 0) && {
|
|
7319
|
+
full_price_discount_percentage: filters.fullPriceDiscountPercentage,
|
|
7320
|
+
}),
|
|
7321
|
+
};
|
|
7197
7322
|
},
|
|
7198
|
-
bindPersistData: (priceData) => (
|
|
7199
|
-
|
|
7200
|
-
|
|
7201
|
-
|
|
7202
|
-
|
|
7323
|
+
bindPersistData: (priceData) => ({
|
|
7324
|
+
...(priceData?.price >= 0 && { price: priceData.price }),
|
|
7325
|
+
...(priceData.fullPrice >= 0 && { full_price: priceData.fullPrice }),
|
|
7326
|
+
...(priceData.subscriberDiscountPercentage >= 0 && {
|
|
7327
|
+
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
7328
|
+
}),
|
|
7329
|
+
...(priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }),
|
|
7330
|
+
...(priceData.fullPriceDiscountPercentage >= 0 && {
|
|
7331
|
+
full_price_discount_percentage: priceData.fullPriceDiscountPercentage,
|
|
7332
|
+
}),
|
|
7333
|
+
}),
|
|
7203
7334
|
},
|
|
7204
7335
|
},
|
|
7205
7336
|
{ fullPrice: { columnName: 'full_price' } },
|
|
@@ -7214,7 +7345,7 @@ const commonFields = [
|
|
|
7214
7345
|
stock: {
|
|
7215
7346
|
columnName: 'stock',
|
|
7216
7347
|
from: (quantity) => ({ quantity }),
|
|
7217
|
-
to: (value) => (isNil(value
|
|
7348
|
+
to: (value) => (isNil(value?.quantity) ? value : value?.quantity),
|
|
7218
7349
|
},
|
|
7219
7350
|
},
|
|
7220
7351
|
{ hasStock: { columnName: 'has_stock' } },
|
|
@@ -7253,7 +7384,7 @@ const fieldsConfiguration$2 = [
|
|
|
7253
7384
|
categories: { data: value.map((category) => ({ category_id: +category })) },
|
|
7254
7385
|
}),
|
|
7255
7386
|
to: (categories) => categories.map((categoryId) => +categoryId),
|
|
7256
|
-
from: (categories) =>
|
|
7387
|
+
from: (categories) => categories?.map((category) => category?.category_id?.toString()) || [],
|
|
7257
7388
|
},
|
|
7258
7389
|
},
|
|
7259
7390
|
{
|
|
@@ -7329,12 +7460,22 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
7329
7460
|
fields: fieldsConfiguration$2,
|
|
7330
7461
|
cache,
|
|
7331
7462
|
});
|
|
7332
|
-
this.bindReviewToModel = (plain) => ProductReview.toInstance(
|
|
7333
|
-
|
|
7463
|
+
this.bindReviewToModel = (plain) => ProductReview.toInstance({
|
|
7464
|
+
...is(omit(plain, ['product_id', 'created_at', 'updated_at', 'person_id', 'order_id'])),
|
|
7465
|
+
createdAt: typeof plain.created_at === 'string' ? new Date(plain.created_at) : plain.created_at,
|
|
7466
|
+
updatedAt: typeof plain.updated_at === 'string' ? new Date(plain.updated_at) : plain.updated_at,
|
|
7467
|
+
personId: plain.person_id,
|
|
7468
|
+
orderId: plain.order_id,
|
|
7469
|
+
});
|
|
7470
|
+
this.bindReviewToHasura = (review) => ({
|
|
7471
|
+
...is(omit(review, ['productId', 'createdAt', 'updatedAt', 'personId', 'orderId'])),
|
|
7472
|
+
person_id: review.personId,
|
|
7473
|
+
order_id: review.orderId,
|
|
7474
|
+
});
|
|
7334
7475
|
}
|
|
7335
7476
|
async create(params) {
|
|
7336
|
-
const { metadata
|
|
7337
|
-
const product = await super.create(omit(
|
|
7477
|
+
const { metadata, ...data } = params;
|
|
7478
|
+
const product = await super.create(omit({ ...data, metadata: metadata || { description: null, title: null } }, ['reviews']));
|
|
7338
7479
|
try {
|
|
7339
7480
|
product.reviews = data.reviews && (await this.updateReviews(+product.id, data));
|
|
7340
7481
|
}
|
|
@@ -7345,10 +7486,9 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
7345
7486
|
return product;
|
|
7346
7487
|
}
|
|
7347
7488
|
async get(identifiers, options) {
|
|
7348
|
-
var _a;
|
|
7349
7489
|
const product = Number.isNaN(+identifiers.id)
|
|
7350
|
-
? (
|
|
7351
|
-
.data
|
|
7490
|
+
? (await this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } }, options))
|
|
7491
|
+
.data?.[0]
|
|
7352
7492
|
: await super.get(identifiers, options);
|
|
7353
7493
|
if (product.productId)
|
|
7354
7494
|
throw new NotFoundError('Product not found, it is a variant');
|
|
@@ -7356,19 +7496,21 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
7356
7496
|
return product;
|
|
7357
7497
|
}
|
|
7358
7498
|
async find(params, optionsParams) {
|
|
7359
|
-
|
|
7360
|
-
const _o = params || {}, { filters, fields } = _o, options = __rest(_o, ["filters", "fields"]);
|
|
7499
|
+
const { filters, fields, ...options } = params || {};
|
|
7361
7500
|
const bindFields = fields ||
|
|
7362
7501
|
this.fields
|
|
7363
7502
|
.map((field) => (typeof field === 'string' ? field : Object.keys(field).shift()))
|
|
7364
7503
|
.filter((field) => field !== 'reviews' && field !== 'categories');
|
|
7365
|
-
if (
|
|
7366
|
-
|
|
7367
|
-
if (
|
|
7368
|
-
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
return super.find(
|
|
7504
|
+
if (options.options?.minimal?.includes('price'))
|
|
7505
|
+
options.options?.minimal.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
|
|
7506
|
+
if (options.options?.maximum?.includes('price'))
|
|
7507
|
+
options.options?.maximum.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
|
|
7508
|
+
options.options?.minimal?.splice(options.options?.minimal.indexOf('price'), 1);
|
|
7509
|
+
options.options?.maximum?.splice(options.options?.maximum.indexOf('price'), 1);
|
|
7510
|
+
return super.find({
|
|
7511
|
+
...options,
|
|
7512
|
+
filters: { ...filters, productId: { operator: Where.ISNULL } },
|
|
7513
|
+
fields: [
|
|
7372
7514
|
...bindFields,
|
|
7373
7515
|
...(bindFields.includes('price')
|
|
7374
7516
|
? [
|
|
@@ -7377,11 +7519,11 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
7377
7519
|
'fullPrice',
|
|
7378
7520
|
]
|
|
7379
7521
|
: []),
|
|
7380
|
-
]
|
|
7522
|
+
],
|
|
7523
|
+
}, optionsParams);
|
|
7381
7524
|
}
|
|
7382
7525
|
async getBySlug(slug, options) {
|
|
7383
|
-
|
|
7384
|
-
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)) {
|
|
7526
|
+
if (this.cache?.cacheAdapter && options?.cache?.enabled) {
|
|
7385
7527
|
const cacheKey = `${this.model.name.toLowerCase()}:slug:${slug}`;
|
|
7386
7528
|
const cachedData = await this.cache.cacheAdapter.get(cacheKey);
|
|
7387
7529
|
if (cachedData) {
|
|
@@ -7400,70 +7542,68 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
7400
7542
|
});
|
|
7401
7543
|
if (!result.data.length)
|
|
7402
7544
|
return null;
|
|
7403
|
-
const product =
|
|
7545
|
+
const product = result?.data?.shift();
|
|
7404
7546
|
RoundProductPricesHelper.roundProductPrices(product);
|
|
7405
|
-
if (
|
|
7547
|
+
if (this.cache?.cacheAdapter && options?.cache?.enabled && product) {
|
|
7406
7548
|
const cacheKey = `${this.model.name.toLowerCase()}:slug:${slug}`;
|
|
7407
7549
|
await this.cache.cacheAdapter.set({
|
|
7408
7550
|
key: cacheKey,
|
|
7409
7551
|
data: serialize(product),
|
|
7410
|
-
expirationInSeconds:
|
|
7552
|
+
expirationInSeconds: options?.cache?.ttl || this.cache.ttlDefault,
|
|
7411
7553
|
});
|
|
7412
7554
|
this.logger.log(`Dados salvos no cache: ${cacheKey}`);
|
|
7413
7555
|
}
|
|
7414
7556
|
return product;
|
|
7415
7557
|
}
|
|
7416
7558
|
async update(params) {
|
|
7417
|
-
const
|
|
7559
|
+
const { kitProducts, reviews, id: checkId, metadata, ...data } = omit(params, ['categories', 'rate']);
|
|
7418
7560
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
7419
7561
|
const id = await this.getId(plainData.id);
|
|
7420
|
-
const product = await super.update(
|
|
7562
|
+
const product = await super.update({ id, ...data });
|
|
7421
7563
|
product.kitProducts = kitProducts && (await this.updateKitProducts(+id, { kitProducts }));
|
|
7422
7564
|
product.reviews = reviews && (await this.updateReviews(+id, { reviews }));
|
|
7423
7565
|
product.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
|
|
7424
7566
|
return product;
|
|
7425
7567
|
}
|
|
7426
7568
|
async fetchProductReviews(filters, options) {
|
|
7427
|
-
var _a, _b, _c, _d, _e;
|
|
7428
7569
|
const cacheKey = ProductReviewCacheHelper.generateProductReviewsCacheKey(filters, this.model.name);
|
|
7429
7570
|
const dependencies = {
|
|
7430
|
-
cacheAdapter:
|
|
7571
|
+
cacheAdapter: this.cache?.cacheAdapter,
|
|
7431
7572
|
logger: this.logger,
|
|
7432
7573
|
modelName: this.model.name,
|
|
7433
|
-
defaultTtl:
|
|
7574
|
+
defaultTtl: this.cache?.ttlDefault,
|
|
7434
7575
|
};
|
|
7435
|
-
if (ProductReviewCacheHelper.shouldUseCache(
|
|
7576
|
+
if (ProductReviewCacheHelper.shouldUseCache(this.cache?.cacheAdapter, options)) {
|
|
7436
7577
|
const cachedData = await ProductReviewCacheHelper.tryGetFromCache({ key: cacheKey, dependencies });
|
|
7437
7578
|
if (cachedData)
|
|
7438
7579
|
return cachedData;
|
|
7439
7580
|
}
|
|
7440
|
-
const limit =
|
|
7581
|
+
const limit = filters?.limit || 500;
|
|
7441
7582
|
const data = await ProductReviewOperationsHelper.fetchAllProductsWithReviews({ repository: this, limit });
|
|
7442
7583
|
const reviews = ProductReviewOperationsHelper.processProductsToReviews({
|
|
7443
7584
|
data,
|
|
7444
7585
|
getReviewStatus: this.getReviewStatus.bind(this),
|
|
7445
7586
|
});
|
|
7446
7587
|
const filteredReviews = ProductReviewOperationsHelper.applyReviewFilters({ reviews, filters });
|
|
7447
|
-
if (ProductReviewCacheHelper.shouldUseCache(
|
|
7588
|
+
if (ProductReviewCacheHelper.shouldUseCache(this.cache?.cacheAdapter, options)) {
|
|
7448
7589
|
await ProductReviewCacheHelper.saveToCache({
|
|
7449
7590
|
key: cacheKey,
|
|
7450
7591
|
data: filteredReviews,
|
|
7451
|
-
ttl:
|
|
7592
|
+
ttl: options?.cache?.ttl,
|
|
7452
7593
|
dependencies,
|
|
7453
7594
|
});
|
|
7454
7595
|
}
|
|
7455
7596
|
return filteredReviews;
|
|
7456
7597
|
}
|
|
7457
7598
|
async fetchReviews(status, options) {
|
|
7458
|
-
var _a, _b, _c, _d, _e;
|
|
7459
7599
|
const cacheKey = ProductReviewCacheHelper.generateReviewsStatusCacheKey(status, this.model.name);
|
|
7460
7600
|
const dependencies = {
|
|
7461
|
-
cacheAdapter:
|
|
7601
|
+
cacheAdapter: this.cache?.cacheAdapter,
|
|
7462
7602
|
logger: this.logger,
|
|
7463
7603
|
modelName: this.model.name,
|
|
7464
|
-
defaultTtl:
|
|
7604
|
+
defaultTtl: this.cache?.ttlDefault,
|
|
7465
7605
|
};
|
|
7466
|
-
if (ProductReviewCacheHelper.shouldUseCache(
|
|
7606
|
+
if (ProductReviewCacheHelper.shouldUseCache(this.cache?.cacheAdapter, options)) {
|
|
7467
7607
|
const cachedData = await ProductReviewCacheHelper.tryGetFromCache({ key: cacheKey, dependencies });
|
|
7468
7608
|
if (cachedData)
|
|
7469
7609
|
return cachedData;
|
|
@@ -7474,18 +7614,26 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
7474
7614
|
reviewsFields: this.reviewsFields,
|
|
7475
7615
|
};
|
|
7476
7616
|
const reviews = await ProductFetchReviewsHelper.executeQuery(status, fetchDependencies);
|
|
7477
|
-
if (ProductReviewCacheHelper.shouldUseCache(
|
|
7617
|
+
if (ProductReviewCacheHelper.shouldUseCache(this.cache?.cacheAdapter, options)) {
|
|
7478
7618
|
await ProductReviewCacheHelper.saveToCache({
|
|
7479
7619
|
key: cacheKey,
|
|
7480
7620
|
data: reviews,
|
|
7481
|
-
ttl:
|
|
7621
|
+
ttl: options?.cache?.ttl,
|
|
7482
7622
|
dependencies,
|
|
7483
7623
|
});
|
|
7484
7624
|
}
|
|
7485
7625
|
return reviews;
|
|
7486
7626
|
}
|
|
7487
7627
|
async findCatalog(params, mainGender, options) {
|
|
7488
|
-
const result = await this.find(
|
|
7628
|
+
const result = await this.find({
|
|
7629
|
+
...params,
|
|
7630
|
+
filters: { ...params.filters, published: true },
|
|
7631
|
+
orderBy: {
|
|
7632
|
+
hasStock: 'desc',
|
|
7633
|
+
...(!mainGender ? {} : { intGender: mainGender === 'female' ? 'desc' : 'asc' }),
|
|
7634
|
+
...omit(params.orderBy, ['hasStock', 'intGender']),
|
|
7635
|
+
},
|
|
7636
|
+
}, options);
|
|
7489
7637
|
return result;
|
|
7490
7638
|
}
|
|
7491
7639
|
async cleanShoppingCountFromIds(ids) {
|
|
@@ -7556,17 +7704,15 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
7556
7704
|
return plainData.metadata;
|
|
7557
7705
|
}
|
|
7558
7706
|
async getId(id) {
|
|
7559
|
-
var _a, _b;
|
|
7560
7707
|
if (!Number.isNaN(+id))
|
|
7561
7708
|
return id;
|
|
7562
7709
|
const { data } = await this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
|
|
7563
|
-
if (
|
|
7564
|
-
return
|
|
7710
|
+
if (data?.[0]?.id)
|
|
7711
|
+
return data?.[0]?.id;
|
|
7565
7712
|
throw new NotFoundError(`Product with id ${id} not found`);
|
|
7566
7713
|
}
|
|
7567
7714
|
async findReviewsByProduct(productId, options) {
|
|
7568
|
-
|
|
7569
|
-
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)) {
|
|
7715
|
+
if (this.cache?.cacheAdapter && options?.cache?.enabled) {
|
|
7570
7716
|
const cacheKey = `${this.model.name.toLowerCase()}:reviews:product:${productId}`;
|
|
7571
7717
|
const cachedData = await this.cache.cacheAdapter.get(cacheKey);
|
|
7572
7718
|
if (cachedData) {
|
|
@@ -7583,13 +7729,13 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
7583
7729
|
required: true,
|
|
7584
7730
|
},
|
|
7585
7731
|
});
|
|
7586
|
-
const reviews = data
|
|
7587
|
-
if (
|
|
7732
|
+
const reviews = data?.map((review) => this.bindReviewToModel(review));
|
|
7733
|
+
if (this.cache?.cacheAdapter && options?.cache?.enabled && reviews) {
|
|
7588
7734
|
const cacheKey = `${this.model.name.toLowerCase()}:reviews:product:${productId}`;
|
|
7589
7735
|
await this.cache.cacheAdapter.set({
|
|
7590
7736
|
key: cacheKey,
|
|
7591
7737
|
data: serialize(reviews),
|
|
7592
|
-
expirationInSeconds:
|
|
7738
|
+
expirationInSeconds: options?.cache?.ttl || this.cache.ttlDefault,
|
|
7593
7739
|
});
|
|
7594
7740
|
this.logger.log(`Dados salvos no cache: ${cacheKey}`);
|
|
7595
7741
|
}
|
|
@@ -7613,23 +7759,32 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
7613
7759
|
async getReviewByPersonId(personId, productId, orderId) {
|
|
7614
7760
|
const { product_review: data } = await this.query('product_review', this.reviewsFields, {
|
|
7615
7761
|
where: {
|
|
7616
|
-
value:
|
|
7762
|
+
value: {
|
|
7763
|
+
product_id: { _eq: productId },
|
|
7764
|
+
person_id: { _eq: personId },
|
|
7765
|
+
...(orderId && { order_id: { _eq: orderId } }),
|
|
7766
|
+
},
|
|
7617
7767
|
type: 'product_review_bool_exp',
|
|
7618
7768
|
required: true,
|
|
7619
7769
|
},
|
|
7620
7770
|
});
|
|
7621
|
-
return
|
|
7771
|
+
return data?.[0] && this.bindReviewToModel(data[0]);
|
|
7622
7772
|
}
|
|
7623
7773
|
async getReviewByAuthorAndEmail(params) {
|
|
7624
7774
|
const { author, email, productId, orderId } = params;
|
|
7625
7775
|
const { product_review: data } = await this.query('product_review', this.reviewsFields, {
|
|
7626
7776
|
where: {
|
|
7627
|
-
value:
|
|
7777
|
+
value: {
|
|
7778
|
+
product_id: { _eq: productId },
|
|
7779
|
+
author: { _eq: author },
|
|
7780
|
+
email: { _eq: email },
|
|
7781
|
+
...(orderId && { order_id: { _eq: orderId } }),
|
|
7782
|
+
},
|
|
7628
7783
|
type: 'product_review_bool_exp',
|
|
7629
7784
|
required: true,
|
|
7630
7785
|
},
|
|
7631
7786
|
});
|
|
7632
|
-
return
|
|
7787
|
+
return data?.[0] && this.bindReviewToModel(data[0]);
|
|
7633
7788
|
}
|
|
7634
7789
|
async productVariantFullReport() {
|
|
7635
7790
|
const dependencies = {
|
|
@@ -7778,7 +7933,16 @@ class ProductStockNotificationHasuraGraphQLRepository extends withCrudHasuraGrap
|
|
|
7778
7933
|
});
|
|
7779
7934
|
}
|
|
7780
7935
|
async getNotificationsReport(params, orderBy, pagination) {
|
|
7781
|
-
const query =
|
|
7936
|
+
const query = {
|
|
7937
|
+
...(params.productId && { product_id: { _eq: params.productId } }),
|
|
7938
|
+
...(params.ean && { ean: { _eq: params.ean } }),
|
|
7939
|
+
...(params.sku && { sku: { _eq: params.sku } }),
|
|
7940
|
+
...(params.name && { name: { _iregex: params.name } }),
|
|
7941
|
+
...(params.categoryId && { category_id: { _eq: params.categoryId } }),
|
|
7942
|
+
...(params.category && { category: { _iregex: params.category } }),
|
|
7943
|
+
...(params.reference && { category_reference: { _eq: params.reference } }),
|
|
7944
|
+
...(params.emailsCount && { emails_registered: { _eq: params.emailsCount } }),
|
|
7945
|
+
};
|
|
7782
7946
|
const orderByField = {
|
|
7783
7947
|
[orderBy.field]: orderBy.direction,
|
|
7784
7948
|
};
|
|
@@ -7794,8 +7958,8 @@ class ProductStockNotificationHasuraGraphQLRepository extends withCrudHasuraGrap
|
|
|
7794
7958
|
required: true,
|
|
7795
7959
|
},
|
|
7796
7960
|
});
|
|
7797
|
-
const data =
|
|
7798
|
-
? reportStockNotification.slice(pagination
|
|
7961
|
+
const data = pagination?.limit
|
|
7962
|
+
? reportStockNotification.slice(pagination?.offset, pagination?.offset + pagination?.limit)
|
|
7799
7963
|
: reportStockNotification;
|
|
7800
7964
|
return {
|
|
7801
7965
|
data,
|
|
@@ -7811,7 +7975,7 @@ const fieldsConfiguration$1 = [
|
|
|
7811
7975
|
productId: {
|
|
7812
7976
|
columnName: 'main_product_id',
|
|
7813
7977
|
to: (value) => +value,
|
|
7814
|
-
from: (value) => value
|
|
7978
|
+
from: (value) => value?.toString(),
|
|
7815
7979
|
},
|
|
7816
7980
|
},
|
|
7817
7981
|
{ EAN: { columnName: 'ean' } },
|
|
@@ -7828,19 +7992,31 @@ const fieldsConfiguration$1 = [
|
|
|
7828
7992
|
}),
|
|
7829
7993
|
bindFindFilter: (sentence) => {
|
|
7830
7994
|
const filters = Object.values(sentence).shift();
|
|
7831
|
-
return
|
|
7832
|
-
|
|
7833
|
-
|
|
7834
|
-
|
|
7835
|
-
|
|
7836
|
-
|
|
7837
|
-
|
|
7995
|
+
return {
|
|
7996
|
+
...((filters?.price || filters?.price === 0) && { price: filters.price }),
|
|
7997
|
+
...((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice }),
|
|
7998
|
+
...((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
|
|
7999
|
+
subscriber_discount_percentage: filters.subscriberDiscountPercentage,
|
|
8000
|
+
}),
|
|
8001
|
+
...((filters.subscriberPrice || filters.subscriberPrice === 0) && {
|
|
8002
|
+
subscriber_price: filters.subscriberPrice,
|
|
8003
|
+
}),
|
|
8004
|
+
...((filters.fullPriceDiscountPercentage || filters.fullPriceDiscountPercentage === 0) && {
|
|
8005
|
+
full_price_discount_percentage: filters.fullPriceDiscountPercentage,
|
|
8006
|
+
}),
|
|
8007
|
+
};
|
|
7838
8008
|
},
|
|
7839
|
-
bindPersistData: (priceData) => (
|
|
7840
|
-
|
|
7841
|
-
|
|
7842
|
-
|
|
7843
|
-
|
|
8009
|
+
bindPersistData: (priceData) => ({
|
|
8010
|
+
...((priceData?.price || 0) >= 0 && { price: priceData.price }),
|
|
8011
|
+
...((priceData?.fullPrice || 0) >= 0 && { full_price: priceData.fullPrice }),
|
|
8012
|
+
...((priceData?.subscriberDiscountPercentage || 0) >= 0 && {
|
|
8013
|
+
subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
|
|
8014
|
+
}),
|
|
8015
|
+
...((priceData?.subscriberPrice || 0) >= 0 && { subscriber_price: priceData.subscriberPrice }),
|
|
8016
|
+
...(priceData.fullPriceDiscountPercentage >= 0 && {
|
|
8017
|
+
full_price_discount_percentage: priceData.fullPriceDiscountPercentage,
|
|
8018
|
+
}),
|
|
8019
|
+
}),
|
|
7844
8020
|
},
|
|
7845
8021
|
},
|
|
7846
8022
|
{ fullPrice: { columnName: 'full_price' } },
|
|
@@ -7852,7 +8028,7 @@ const fieldsConfiguration$1 = [
|
|
|
7852
8028
|
stock: {
|
|
7853
8029
|
columnName: 'stock',
|
|
7854
8030
|
from: (quantity) => ({ quantity }),
|
|
7855
|
-
to: (value) => (isNil(value
|
|
8031
|
+
to: (value) => (isNil(value?.quantity) ? value : value?.quantity),
|
|
7856
8032
|
},
|
|
7857
8033
|
},
|
|
7858
8034
|
{ hasStock: { columnName: 'has_stock' } },
|
|
@@ -7885,41 +8061,39 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
7885
8061
|
});
|
|
7886
8062
|
}
|
|
7887
8063
|
async get(identifiers) {
|
|
7888
|
-
var _a;
|
|
7889
8064
|
if (!identifiers.id) {
|
|
7890
8065
|
throw new NotFoundError('Variant ID is required');
|
|
7891
8066
|
}
|
|
7892
8067
|
const variant = Number.isNaN(+identifiers.id)
|
|
7893
|
-
? (
|
|
8068
|
+
? (await this.find({ filters: { firestoreId: identifiers.id } })).data?.[0]
|
|
7894
8069
|
: await super.get(identifiers);
|
|
7895
8070
|
if (!variant.productId)
|
|
7896
8071
|
throw new NotFoundError('Variant not found, it is a product');
|
|
7897
8072
|
return variant;
|
|
7898
8073
|
}
|
|
7899
8074
|
async find(params) {
|
|
7900
|
-
const
|
|
7901
|
-
return super.find(
|
|
8075
|
+
const { filters, ...options } = params || {};
|
|
8076
|
+
return super.find({ ...options, filters: { productId: { operator: Where.ISNOTNULL }, ...filters } });
|
|
7902
8077
|
}
|
|
7903
8078
|
async update(params) {
|
|
7904
|
-
const { productId, id: checkId
|
|
8079
|
+
const { productId, id: checkId, ...data } = params;
|
|
7905
8080
|
const dataWithProductId = this.paramsToPlain({ id: checkId, productId });
|
|
7906
8081
|
if (!dataWithProductId.id) {
|
|
7907
8082
|
throw new NotFoundError('Variant ID is required for update');
|
|
7908
8083
|
}
|
|
7909
8084
|
const id = await this.getId(dataWithProductId.id);
|
|
7910
|
-
const product = await super.update(
|
|
8085
|
+
const product = await super.update({ id, ...data });
|
|
7911
8086
|
if (dataWithProductId.productId) {
|
|
7912
8087
|
product.productId = dataWithProductId.productId;
|
|
7913
8088
|
}
|
|
7914
8089
|
return product;
|
|
7915
8090
|
}
|
|
7916
8091
|
async getId(id) {
|
|
7917
|
-
var _a, _b;
|
|
7918
8092
|
if (!Number.isNaN(+id))
|
|
7919
8093
|
return id;
|
|
7920
8094
|
const { data } = await this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
|
|
7921
|
-
if (
|
|
7922
|
-
return
|
|
8095
|
+
if (data?.[0]?.id)
|
|
8096
|
+
return data?.[0]?.id;
|
|
7923
8097
|
throw new NotFoundError(`Product with id ${id} not found`);
|
|
7924
8098
|
}
|
|
7925
8099
|
}
|
|
@@ -7950,11 +8124,14 @@ const fieldsConfiguration = [
|
|
|
7950
8124
|
bindPersistData: (value) => {
|
|
7951
8125
|
return {
|
|
7952
8126
|
brand_condition: value.brand,
|
|
7953
|
-
tag_condition:
|
|
8127
|
+
tag_condition: value?.tags || [],
|
|
7954
8128
|
};
|
|
7955
8129
|
},
|
|
7956
8130
|
bindFindFilter: (sentence) => {
|
|
7957
|
-
return
|
|
8131
|
+
return {
|
|
8132
|
+
...(sentence.brand ? { brand_condition: sentence.brand } : {}),
|
|
8133
|
+
...(sentence.tags ? { tag_condition: sentence.tags } : {}),
|
|
8134
|
+
};
|
|
7958
8135
|
},
|
|
7959
8136
|
},
|
|
7960
8137
|
},
|
|
@@ -7966,7 +8143,7 @@ const fieldsConfiguration = [
|
|
|
7966
8143
|
bindPersistData: (value) => ({
|
|
7967
8144
|
filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
|
|
7968
8145
|
}),
|
|
7969
|
-
from: (filters) =>
|
|
8146
|
+
from: (filters) => filters?.map((filter) => filter?.filter) || [],
|
|
7970
8147
|
},
|
|
7971
8148
|
},
|
|
7972
8149
|
{ createdAt: { columnName: 'created_at' } },
|
|
@@ -8034,12 +8211,18 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
8034
8211
|
this.categoryProductRepository = categoryProductRepository;
|
|
8035
8212
|
}
|
|
8036
8213
|
async create(params) {
|
|
8037
|
-
|
|
8038
|
-
|
|
8039
|
-
|
|
8214
|
+
const { images, mostRelevants, metadatas, ...data } = params;
|
|
8215
|
+
return super.create({
|
|
8216
|
+
...data,
|
|
8217
|
+
isWishlist: true,
|
|
8218
|
+
isCollection: true,
|
|
8219
|
+
brandCategory: false,
|
|
8220
|
+
metadatas: metadatas || [{ shop: data.shop ?? null, description: data.description, title: data.name }],
|
|
8221
|
+
mostRelevants: mostRelevants || {
|
|
8040
8222
|
[Shops.GLAMSHOP]: null,
|
|
8041
8223
|
[Shops.MENSMARKET]: null,
|
|
8042
|
-
},
|
|
8224
|
+
},
|
|
8225
|
+
images: images || {
|
|
8043
8226
|
[Shops.GLAMSHOP]: {
|
|
8044
8227
|
brandBanner: null,
|
|
8045
8228
|
brandBannerMobile: null,
|
|
@@ -8050,7 +8233,8 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
8050
8233
|
brandBannerMobile: null,
|
|
8051
8234
|
image: null,
|
|
8052
8235
|
},
|
|
8053
|
-
}
|
|
8236
|
+
},
|
|
8237
|
+
});
|
|
8054
8238
|
}
|
|
8055
8239
|
async get(identifiers) {
|
|
8056
8240
|
const data = await super.get(identifiers);
|
|
@@ -8059,14 +8243,20 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
8059
8243
|
return data;
|
|
8060
8244
|
}
|
|
8061
8245
|
async find(params) {
|
|
8062
|
-
const { filters
|
|
8063
|
-
return await super.find(
|
|
8246
|
+
const { filters, ...rest } = params;
|
|
8247
|
+
return await super.find({
|
|
8248
|
+
...rest,
|
|
8249
|
+
filters: {
|
|
8250
|
+
...filters,
|
|
8251
|
+
isWishlist: { operator: Where.EQUALS, value: true },
|
|
8252
|
+
},
|
|
8253
|
+
});
|
|
8064
8254
|
}
|
|
8065
8255
|
async update(params) {
|
|
8066
|
-
const
|
|
8256
|
+
const { id: checkId, metadatas, ...data } = omit(params, ['products', 'filters']);
|
|
8067
8257
|
const plainData = this.paramsToPlain({ id: checkId });
|
|
8068
8258
|
const id = plainData.id;
|
|
8069
|
-
const category = await super.update(
|
|
8259
|
+
const category = await super.update({ id, ...data, isWishlist: true, isCollection: true, brandCategory: false });
|
|
8070
8260
|
category.metadatas = metadatas && (await this.updateMetadata(+id, { metadatas }));
|
|
8071
8261
|
return category;
|
|
8072
8262
|
}
|
|
@@ -8129,11 +8319,22 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
8129
8319
|
return data;
|
|
8130
8320
|
}
|
|
8131
8321
|
async findBfluOrGlamgirlWishlists(params, shops) {
|
|
8132
|
-
|
|
8133
|
-
|
|
8322
|
+
return this.find({
|
|
8323
|
+
...params,
|
|
8324
|
+
filters: {
|
|
8325
|
+
...params.filters,
|
|
8326
|
+
published: true,
|
|
8327
|
+
shops: { operator: Where.LIKE, value: shops },
|
|
8328
|
+
personType: params.filters?.personType ?? {
|
|
8134
8329
|
operator: Where.IN,
|
|
8135
8330
|
value: [PersonTypes.BFLU, PersonTypes.GLAMGIRL],
|
|
8136
|
-
}
|
|
8331
|
+
},
|
|
8332
|
+
},
|
|
8333
|
+
orderBy: {
|
|
8334
|
+
personHasPhoto: 'desc',
|
|
8335
|
+
...omit(params.orderBy, ['personHasPhoto']),
|
|
8336
|
+
},
|
|
8337
|
+
});
|
|
8137
8338
|
}
|
|
8138
8339
|
getCategoriesForHome() {
|
|
8139
8340
|
return;
|
|
@@ -8341,7 +8542,7 @@ class PagarmePaymentFactoryHelper {
|
|
|
8341
8542
|
checkoutId: checkout.id,
|
|
8342
8543
|
totalPrice: checkout.totalPrice,
|
|
8343
8544
|
paymentProvider: PaymentProviders.PAGARME,
|
|
8344
|
-
transaction:
|
|
8545
|
+
transaction: { ...resultData, paidAt: new Date() },
|
|
8345
8546
|
});
|
|
8346
8547
|
return payment;
|
|
8347
8548
|
}
|
|
@@ -8361,6 +8562,178 @@ class PagarmePaymentOperationsHelper {
|
|
|
8361
8562
|
}
|
|
8362
8563
|
}
|
|
8363
8564
|
|
|
8565
|
+
class PagarMeV5RequestHelper {
|
|
8566
|
+
static build(checkout, type, card) {
|
|
8567
|
+
return {
|
|
8568
|
+
items: this.buildItems(checkout),
|
|
8569
|
+
customer: this.buildCustomer(checkout),
|
|
8570
|
+
shipping: this.buildShipping(checkout),
|
|
8571
|
+
payments: this.buildPayment(checkout, type, card),
|
|
8572
|
+
};
|
|
8573
|
+
}
|
|
8574
|
+
static buildItems(checkout) {
|
|
8575
|
+
return checkout.lineItems.map((item) => {
|
|
8576
|
+
return {
|
|
8577
|
+
amount: Math.floor(item.pricePaid * 100),
|
|
8578
|
+
description: item.name,
|
|
8579
|
+
quantity: item.quantity,
|
|
8580
|
+
};
|
|
8581
|
+
});
|
|
8582
|
+
}
|
|
8583
|
+
static buildCustomer(checkout) {
|
|
8584
|
+
return {
|
|
8585
|
+
name: checkout.user.displayName,
|
|
8586
|
+
email: checkout.user.email,
|
|
8587
|
+
type: 'individual',
|
|
8588
|
+
document: checkout.user.cpf,
|
|
8589
|
+
phones: {
|
|
8590
|
+
mobile_phone: {
|
|
8591
|
+
country_code: '55',
|
|
8592
|
+
number: checkout.user.phone.slice(2),
|
|
8593
|
+
area_code: checkout.user.phone.slice(0, 1),
|
|
8594
|
+
},
|
|
8595
|
+
},
|
|
8596
|
+
address: {
|
|
8597
|
+
line_1: `${checkout.billingAddress.number}, ${checkout.billingAddress.street}, ${checkout.billingAddress.district}`,
|
|
8598
|
+
line_2: `${checkout.billingAddress.extension}`,
|
|
8599
|
+
zip_code: checkout.shippingAddress.zip,
|
|
8600
|
+
city: checkout.billingAddress.city,
|
|
8601
|
+
state: checkout.billingAddress.state,
|
|
8602
|
+
country: checkout.billingAddress.country,
|
|
8603
|
+
},
|
|
8604
|
+
};
|
|
8605
|
+
}
|
|
8606
|
+
static buildShipping(checkout) {
|
|
8607
|
+
return {
|
|
8608
|
+
amount: checkout.shipping.ShippingPrice,
|
|
8609
|
+
description: '',
|
|
8610
|
+
recipient_name: checkout.shippingAddress.recipient,
|
|
8611
|
+
recipient_phone: checkout.user.phone,
|
|
8612
|
+
address: {
|
|
8613
|
+
line_1: `${checkout.shippingAddress.number}, ${checkout.shippingAddress.street}, ${checkout.shippingAddress.district}`,
|
|
8614
|
+
line_2: `${checkout.shippingAddress.extension}`,
|
|
8615
|
+
zip_code: checkout.shippingAddress.zip,
|
|
8616
|
+
city: checkout.shippingAddress.city,
|
|
8617
|
+
state: checkout.shippingAddress.state,
|
|
8618
|
+
country: checkout.shippingAddress.country,
|
|
8619
|
+
},
|
|
8620
|
+
};
|
|
8621
|
+
}
|
|
8622
|
+
static buildPayment(checkout, type, card) {
|
|
8623
|
+
return [
|
|
8624
|
+
{
|
|
8625
|
+
payment_method: type,
|
|
8626
|
+
amount: Math.floor(checkout.totalPrice * 100),
|
|
8627
|
+
...(type === 'pix' && {
|
|
8628
|
+
pix: this.getPixOrder(),
|
|
8629
|
+
}),
|
|
8630
|
+
...(type === 'boleto' && {
|
|
8631
|
+
boleto: this.getBoletoOrder(),
|
|
8632
|
+
}),
|
|
8633
|
+
...(type === 'credit_card' && {
|
|
8634
|
+
credit_card: this.getCardOrder(checkout, card),
|
|
8635
|
+
}),
|
|
8636
|
+
},
|
|
8637
|
+
];
|
|
8638
|
+
}
|
|
8639
|
+
static getPixOrder() {
|
|
8640
|
+
return {
|
|
8641
|
+
expires_at: format(addDays(new Date(), 1), 'yyyy-MM-dd'),
|
|
8642
|
+
};
|
|
8643
|
+
}
|
|
8644
|
+
static getBoletoOrder() {
|
|
8645
|
+
return {
|
|
8646
|
+
due_at: format(addDays(new Date(), 3), 'yyyy-MM-dd'),
|
|
8647
|
+
instructions: 'Sr. Caixa, NÃO aceitar o pagamento após o vencimento.',
|
|
8648
|
+
type: 'DM',
|
|
8649
|
+
document_number: new Date().getTime().toString(),
|
|
8650
|
+
};
|
|
8651
|
+
}
|
|
8652
|
+
static getCardOrder(checkout, card) {
|
|
8653
|
+
return {
|
|
8654
|
+
installments: card.installments,
|
|
8655
|
+
statement_descriptor: checkout.shop === Shops.GLAMSHOP ? 'Glam' : "Men's Market",
|
|
8656
|
+
card_id: card.cardId,
|
|
8657
|
+
card: {
|
|
8658
|
+
cvv: card.cardCvv,
|
|
8659
|
+
},
|
|
8660
|
+
};
|
|
8661
|
+
}
|
|
8662
|
+
}
|
|
8663
|
+
|
|
8664
|
+
class PagarMeV5ResponseHelper {
|
|
8665
|
+
static build(checkout, response) {
|
|
8666
|
+
return Payment.toInstance({
|
|
8667
|
+
createdAt: new Date(),
|
|
8668
|
+
updatedAt: new Date(),
|
|
8669
|
+
userId: checkout.user.id,
|
|
8670
|
+
checkoutId: checkout.id,
|
|
8671
|
+
totalPrice: checkout.totalPrice,
|
|
8672
|
+
paymentProvider: PaymentProviders.PAGARME,
|
|
8673
|
+
pagarMeOrderId: response.id,
|
|
8674
|
+
transaction: this.buildPaymentTransaction(response),
|
|
8675
|
+
});
|
|
8676
|
+
}
|
|
8677
|
+
static buildPaymentTransaction(response) {
|
|
8678
|
+
const charger = response.charges.at(0);
|
|
8679
|
+
const transaction = charger.last_transaction;
|
|
8680
|
+
return PaymentTransaction.toInstance({
|
|
8681
|
+
acquirer_name: 'pagar_me',
|
|
8682
|
+
amount: charger.amount,
|
|
8683
|
+
currency: charger.currency,
|
|
8684
|
+
gateway_id: charger.gateway_id,
|
|
8685
|
+
status: charger.status,
|
|
8686
|
+
payment_method: charger.payment_method,
|
|
8687
|
+
date_created: charger.created_at,
|
|
8688
|
+
date_updated: charger.updated_at,
|
|
8689
|
+
paid_amount: charger.paid_amount,
|
|
8690
|
+
paid_at: charger.paid_at,
|
|
8691
|
+
order_id: response.id,
|
|
8692
|
+
tid: +transaction.id,
|
|
8693
|
+
id: +transaction.id,
|
|
8694
|
+
...this.getBoletoReponse(transaction),
|
|
8695
|
+
...this.getPixReponse(transaction),
|
|
8696
|
+
...this.getCardReponse(transaction),
|
|
8697
|
+
});
|
|
8698
|
+
}
|
|
8699
|
+
static getBoletoReponse(transaction) {
|
|
8700
|
+
return {
|
|
8701
|
+
boleto_url: transaction.url?.toString(),
|
|
8702
|
+
boleto_barcode: transaction.barcode?.toString(),
|
|
8703
|
+
boleto_qr_code: transaction.qr_code?.toString(),
|
|
8704
|
+
boleto_expiration_date: transaction.due_at?.toString(),
|
|
8705
|
+
boleto_instructions: transaction.instructions?.toString(),
|
|
8706
|
+
boleto_nosso_numero: transaction.nosso_numero?.toString(),
|
|
8707
|
+
boleto_type: transaction.type?.toString(),
|
|
8708
|
+
boleto_document_number: transaction.document_number?.toString(),
|
|
8709
|
+
};
|
|
8710
|
+
}
|
|
8711
|
+
static getPixReponse(transaction) {
|
|
8712
|
+
return {
|
|
8713
|
+
pix_qr_code: transaction.qr_code?.toString(),
|
|
8714
|
+
pix_qr_code_url: transaction.qr_code_url?.toString(),
|
|
8715
|
+
pix_expiration_date: transaction.expires_at?.toString(),
|
|
8716
|
+
};
|
|
8717
|
+
}
|
|
8718
|
+
static getCardReponse(transaction) {
|
|
8719
|
+
return {
|
|
8720
|
+
soft_descriptor: transaction.statement_descriptor?.toString(),
|
|
8721
|
+
acquirer_name: transaction.acquirer_name?.toString(),
|
|
8722
|
+
acquirer_id: transaction.acquirer_tid?.toString(),
|
|
8723
|
+
acquirer_nsu: transaction.acquirer_nsu?.toString(),
|
|
8724
|
+
acquirer_auth_code: transaction.acquirer_auth_code?.toString(),
|
|
8725
|
+
acquirer_message: transaction.acquirer_message?.toString(),
|
|
8726
|
+
acquirer_return_code: transaction.acquirer_return_code?.toString(),
|
|
8727
|
+
installments: transaction.installments ?? null,
|
|
8728
|
+
card_holder_name: transaction.card.holder_name?.toString(),
|
|
8729
|
+
card_last_digits: transaction.card.last_four_digits?.toString(),
|
|
8730
|
+
card_first_digits: transaction.card.first_six_digits?.toString(),
|
|
8731
|
+
card_brand: transaction.card.brand?.toString(),
|
|
8732
|
+
card_id: transaction.card.id?.toString(),
|
|
8733
|
+
};
|
|
8734
|
+
}
|
|
8735
|
+
}
|
|
8736
|
+
|
|
8364
8737
|
class PagarmeCardAxiosAdapter {
|
|
8365
8738
|
constructor(credentials, paymentRepository, orderBlockedRepository) {
|
|
8366
8739
|
this.credentials = credentials;
|
|
@@ -8368,7 +8741,6 @@ class PagarmeCardAxiosAdapter {
|
|
|
8368
8741
|
this.orderBlockedRepository = orderBlockedRepository;
|
|
8369
8742
|
}
|
|
8370
8743
|
async pay(checkout, card) {
|
|
8371
|
-
var _a;
|
|
8372
8744
|
try {
|
|
8373
8745
|
const result = await PagarmePaymentOperationsHelper.executePaymentRequest({
|
|
8374
8746
|
checkout,
|
|
@@ -8394,7 +8766,7 @@ class PagarmeCardAxiosAdapter {
|
|
|
8394
8766
|
if (error instanceof PaymentError) {
|
|
8395
8767
|
throw error;
|
|
8396
8768
|
}
|
|
8397
|
-
throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout,
|
|
8769
|
+
throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout, error.response?.data);
|
|
8398
8770
|
}
|
|
8399
8771
|
}
|
|
8400
8772
|
async addCard(card) {
|
|
@@ -8461,7 +8833,10 @@ class PagarmeCardAxiosAdapter {
|
|
|
8461
8833
|
const { data } = await axios({
|
|
8462
8834
|
method: 'POST',
|
|
8463
8835
|
url: `${this.credentials.URL}/transactions`,
|
|
8464
|
-
data:
|
|
8836
|
+
data: {
|
|
8837
|
+
...info,
|
|
8838
|
+
api_key: this.credentials.API_KEY,
|
|
8839
|
+
},
|
|
8465
8840
|
});
|
|
8466
8841
|
return data;
|
|
8467
8842
|
}
|
|
@@ -8472,7 +8847,6 @@ class PagarmeCardAxiosAdapter {
|
|
|
8472
8847
|
}
|
|
8473
8848
|
}
|
|
8474
8849
|
createCardPayment(checkout, card) {
|
|
8475
|
-
var _a, _b, _c, _d, _e, _f;
|
|
8476
8850
|
return {
|
|
8477
8851
|
api_key: this.credentials.API_KEY,
|
|
8478
8852
|
amount: Math.floor(checkout.totalPrice * 100),
|
|
@@ -8499,14 +8873,14 @@ class PagarmeCardAxiosAdapter {
|
|
|
8499
8873
|
name: checkout.user.displayName,
|
|
8500
8874
|
address: {
|
|
8501
8875
|
country: 'br',
|
|
8502
|
-
state: checkout.billingAddress ? checkout.billingAddress.state :
|
|
8503
|
-
city: checkout.billingAddress ? checkout.billingAddress.city :
|
|
8504
|
-
neighborhood: checkout.billingAddress ? checkout.billingAddress.district :
|
|
8505
|
-
street: checkout.billingAddress ? checkout.billingAddress.street :
|
|
8506
|
-
street_number: checkout.billingAddress ? checkout.billingAddress.number :
|
|
8876
|
+
state: checkout.billingAddress ? checkout.billingAddress.state : checkout.shippingAddress?.state,
|
|
8877
|
+
city: checkout.billingAddress ? checkout.billingAddress.city : checkout.shippingAddress?.city,
|
|
8878
|
+
neighborhood: checkout.billingAddress ? checkout.billingAddress.district : checkout.shippingAddress?.district,
|
|
8879
|
+
street: checkout.billingAddress ? checkout.billingAddress.street : checkout.shippingAddress?.street,
|
|
8880
|
+
street_number: checkout.billingAddress ? checkout.billingAddress.number : checkout.shippingAddress?.number,
|
|
8507
8881
|
zipcode: checkout.billingAddress
|
|
8508
8882
|
? checkout.billingAddress.zip.replace('-', '')
|
|
8509
|
-
:
|
|
8883
|
+
: checkout.shippingAddress?.zip.replace('-', ''),
|
|
8510
8884
|
},
|
|
8511
8885
|
},
|
|
8512
8886
|
items: checkout.lineItems.map((item) => {
|
|
@@ -8528,7 +8902,6 @@ class PagarmePixAxiosAdapter {
|
|
|
8528
8902
|
this.paymentRepository = paymentRepository;
|
|
8529
8903
|
}
|
|
8530
8904
|
async pay(checkout) {
|
|
8531
|
-
var _a;
|
|
8532
8905
|
try {
|
|
8533
8906
|
const payload = this.createPixPayment(checkout);
|
|
8534
8907
|
const result = await axios({
|
|
@@ -8552,7 +8925,7 @@ class PagarmePixAxiosAdapter {
|
|
|
8552
8925
|
throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
|
|
8553
8926
|
checkoutId: checkout.id,
|
|
8554
8927
|
userEmail: checkout.user.email,
|
|
8555
|
-
info:
|
|
8928
|
+
info: error.response?.data,
|
|
8556
8929
|
});
|
|
8557
8930
|
}
|
|
8558
8931
|
}
|
|
@@ -8581,6 +8954,251 @@ class PagarmePixAxiosAdapter {
|
|
|
8581
8954
|
}
|
|
8582
8955
|
}
|
|
8583
8956
|
|
|
8957
|
+
/* eslint-disable no-console */
|
|
8958
|
+
class PagarmeV5BankSlipAxiosAdapter {
|
|
8959
|
+
constructor(credentials, paymentRepository) {
|
|
8960
|
+
this.credentials = credentials;
|
|
8961
|
+
this.paymentRepository = paymentRepository;
|
|
8962
|
+
}
|
|
8963
|
+
async pay(checkout) {
|
|
8964
|
+
try {
|
|
8965
|
+
const payload = PagarMeV5RequestHelper.build(checkout, 'boleto');
|
|
8966
|
+
console.warn('[PAGARME BOLETO DATA TO SEND]', JSON.stringify(payload));
|
|
8967
|
+
const { data } = await axios({
|
|
8968
|
+
method: 'POST',
|
|
8969
|
+
url: `${this.credentials.URL}/orders`,
|
|
8970
|
+
headers: {
|
|
8971
|
+
Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
|
|
8972
|
+
'Content-Type': 'application/json',
|
|
8973
|
+
},
|
|
8974
|
+
data: payload,
|
|
8975
|
+
});
|
|
8976
|
+
console.warn('[PAGARME RESPONSE BOLETO DATA]', JSON.stringify(data));
|
|
8977
|
+
if (data.charges.at(0).status !== PagarMeV5OrderStatus['Em processamento'] ||
|
|
8978
|
+
data.charges.at(0).status !== PagarMeV5PaymentStatus['Falha']) {
|
|
8979
|
+
return Promise.reject(new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
|
|
8980
|
+
checkoutId: checkout.id,
|
|
8981
|
+
userEmail: checkout.user.email,
|
|
8982
|
+
info: data,
|
|
8983
|
+
}));
|
|
8984
|
+
}
|
|
8985
|
+
const paymentData = PagarMeV5ResponseHelper.build(checkout, data);
|
|
8986
|
+
const payment = await this.paymentRepository.create(paymentData);
|
|
8987
|
+
return payment;
|
|
8988
|
+
}
|
|
8989
|
+
catch (error) {
|
|
8990
|
+
console.log(error.response?.data?.errors);
|
|
8991
|
+
console.log(error.response?.data?.request);
|
|
8992
|
+
throw new PaymentError('Houve uma falha ao gerar o boleto. Tente novamente', {
|
|
8993
|
+
checkoutId: checkout.id,
|
|
8994
|
+
userEmail: checkout.user.email,
|
|
8995
|
+
info: error.response.data,
|
|
8996
|
+
});
|
|
8997
|
+
}
|
|
8998
|
+
}
|
|
8999
|
+
async getBoletoTransaction(paymentId) {
|
|
9000
|
+
try {
|
|
9001
|
+
const { data } = await axios({
|
|
9002
|
+
method: 'GET',
|
|
9003
|
+
url: `${this.credentials.URL}/charges/${paymentId}`,
|
|
9004
|
+
headers: {
|
|
9005
|
+
Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
|
|
9006
|
+
'Content-Type': 'application/json',
|
|
9007
|
+
},
|
|
9008
|
+
});
|
|
9009
|
+
const payment = await this.paymentRepository.get({
|
|
9010
|
+
id: +data.id,
|
|
9011
|
+
});
|
|
9012
|
+
return payment.transaction;
|
|
9013
|
+
}
|
|
9014
|
+
catch (error) {
|
|
9015
|
+
throw new BusinessError('Houve uma falha buscar o boleto com paymentId: ' + paymentId, {
|
|
9016
|
+
paymentId,
|
|
9017
|
+
info: error.response.data,
|
|
9018
|
+
});
|
|
9019
|
+
}
|
|
9020
|
+
}
|
|
9021
|
+
}
|
|
9022
|
+
|
|
9023
|
+
class PagarmeV5CardAxiosAdapter {
|
|
9024
|
+
constructor(credentials, paymentRepository, orderBlockedRepository) {
|
|
9025
|
+
this.credentials = credentials;
|
|
9026
|
+
this.paymentRepository = paymentRepository;
|
|
9027
|
+
this.orderBlockedRepository = orderBlockedRepository;
|
|
9028
|
+
}
|
|
9029
|
+
async pay(checkout, card) {
|
|
9030
|
+
try {
|
|
9031
|
+
const payload = PagarMeV5RequestHelper.build(checkout, 'credit_card', card);
|
|
9032
|
+
console.warn('[PAGARME CARD DATA TO SEND]', JSON.stringify(payload));
|
|
9033
|
+
const { data } = await axios({
|
|
9034
|
+
method: 'POST',
|
|
9035
|
+
url: `${this.credentials.URL}/orders`,
|
|
9036
|
+
headers: {
|
|
9037
|
+
Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
|
|
9038
|
+
'Content-Type': 'application/json',
|
|
9039
|
+
},
|
|
9040
|
+
data: payload,
|
|
9041
|
+
});
|
|
9042
|
+
console.warn('[RESPONSE PAGARME CARD DATA]', JSON.stringify(data));
|
|
9043
|
+
if (data.charges.at(0).status !== PagarMeV5PaymentStatus.Pago ||
|
|
9044
|
+
data.charges.at(0).status !== PagarMeV5PaymentStatus.Capturada) {
|
|
9045
|
+
await PagarmeBlockedOrderHelper.createBlockedOrderForUnauthorizedCard({
|
|
9046
|
+
checkout,
|
|
9047
|
+
card,
|
|
9048
|
+
orderBlockedRepository: this.orderBlockedRepository,
|
|
9049
|
+
});
|
|
9050
|
+
throw PagarmeBlockedOrderHelper.createPaymentError(checkout, data);
|
|
9051
|
+
}
|
|
9052
|
+
const paymentData = PagarMeV5ResponseHelper.build(checkout, data);
|
|
9053
|
+
const payment = await this.paymentRepository.create(paymentData);
|
|
9054
|
+
return payment;
|
|
9055
|
+
}
|
|
9056
|
+
catch (error) {
|
|
9057
|
+
if (error instanceof PaymentError) {
|
|
9058
|
+
throw error;
|
|
9059
|
+
}
|
|
9060
|
+
throw PagarmeBlockedOrderHelper.createGenericPaymentError(checkout, error.response?.data);
|
|
9061
|
+
}
|
|
9062
|
+
}
|
|
9063
|
+
// Dúvidas: preciso criar um cliente? como faz na mens?
|
|
9064
|
+
async addCard(card) {
|
|
9065
|
+
try {
|
|
9066
|
+
const { data } = await axios({
|
|
9067
|
+
method: 'POST',
|
|
9068
|
+
url: `${this.credentials.URL}/cards`,
|
|
9069
|
+
data: {
|
|
9070
|
+
api_key: this.credentials.API_KEY,
|
|
9071
|
+
card_number: card.number,
|
|
9072
|
+
card_expiration_date: card.expirationDate.replace('/', ''),
|
|
9073
|
+
card_holder_name: card.name,
|
|
9074
|
+
card_cvv: card.cvv,
|
|
9075
|
+
// number: '4000000000000010',
|
|
9076
|
+
// holder_name: 'Tony Stark',
|
|
9077
|
+
// holder_document: '93095135270',
|
|
9078
|
+
// exp_month: 1,
|
|
9079
|
+
// exp_year: 30,
|
|
9080
|
+
// cvv: '351',
|
|
9081
|
+
// brand: 'Mastercard',
|
|
9082
|
+
// label: 'Sua bandeira',
|
|
9083
|
+
// billing_address: {
|
|
9084
|
+
// line_1: '375, Av. General Osorio, Centro',
|
|
9085
|
+
// line_2: '7º Andar',
|
|
9086
|
+
// zip_code: '220000111',
|
|
9087
|
+
// city: 'Rio de Janeiro',
|
|
9088
|
+
// state: 'RJ',
|
|
9089
|
+
// country: 'BR',
|
|
9090
|
+
// },
|
|
9091
|
+
// options: {
|
|
9092
|
+
// verify_card: true,
|
|
9093
|
+
// },
|
|
9094
|
+
},
|
|
9095
|
+
});
|
|
9096
|
+
return data;
|
|
9097
|
+
}
|
|
9098
|
+
catch (error) {
|
|
9099
|
+
throw new BusinessError('Houve uma falha adicionar o cartão', {
|
|
9100
|
+
info: error.response.data,
|
|
9101
|
+
});
|
|
9102
|
+
}
|
|
9103
|
+
}
|
|
9104
|
+
async createCardHash(bu) {
|
|
9105
|
+
const key = bu === BusinessUnitEnum.SHOP ? this.credentials.SHOP_API_KEY : this.credentials.SUBSCRIPTION_API_KEY;
|
|
9106
|
+
try {
|
|
9107
|
+
const { data } = await axios({
|
|
9108
|
+
method: 'GET',
|
|
9109
|
+
headers: {
|
|
9110
|
+
'content-type': 'application/json',
|
|
9111
|
+
},
|
|
9112
|
+
url: `${this.credentials.URL}/transactions/card_hash_key`,
|
|
9113
|
+
data: JSON.stringify({
|
|
9114
|
+
api_key: key,
|
|
9115
|
+
}),
|
|
9116
|
+
});
|
|
9117
|
+
return data;
|
|
9118
|
+
}
|
|
9119
|
+
catch (error) {
|
|
9120
|
+
throw new BusinessError('Houve uma falha gerar o hash', {
|
|
9121
|
+
info: error.response.data,
|
|
9122
|
+
});
|
|
9123
|
+
}
|
|
9124
|
+
}
|
|
9125
|
+
async getCardByToken(id) {
|
|
9126
|
+
try {
|
|
9127
|
+
const { data } = await axios({
|
|
9128
|
+
method: 'POST',
|
|
9129
|
+
url: `${this.credentials.URL}/cards/${id}`,
|
|
9130
|
+
data: {
|
|
9131
|
+
api_key: this.credentials.API_KEY,
|
|
9132
|
+
},
|
|
9133
|
+
});
|
|
9134
|
+
return data;
|
|
9135
|
+
}
|
|
9136
|
+
catch (error) {
|
|
9137
|
+
throw new BusinessError('Houve uma falha buscar o cartão com id: ' + id, {
|
|
9138
|
+
info: error.response.data,
|
|
9139
|
+
});
|
|
9140
|
+
}
|
|
9141
|
+
}
|
|
9142
|
+
async createTransaction(info) {
|
|
9143
|
+
try {
|
|
9144
|
+
const { data } = await axios({
|
|
9145
|
+
method: 'POST',
|
|
9146
|
+
url: `${this.credentials.URL}/transactions`,
|
|
9147
|
+
headers: {
|
|
9148
|
+
Authorization: 'Basic ' + Buffer.from(this.credentials.API_KEY).toString('base64'),
|
|
9149
|
+
'Content-Type': 'application/json',
|
|
9150
|
+
},
|
|
9151
|
+
data: {
|
|
9152
|
+
...info,
|
|
9153
|
+
api_key: this.credentials.API_KEY,
|
|
9154
|
+
},
|
|
9155
|
+
});
|
|
9156
|
+
return data;
|
|
9157
|
+
}
|
|
9158
|
+
catch (error) {
|
|
9159
|
+
throw new BusinessError('Houve uma falha ao criar a transação', {
|
|
9160
|
+
info: error.response.data,
|
|
9161
|
+
});
|
|
9162
|
+
}
|
|
9163
|
+
}
|
|
9164
|
+
}
|
|
9165
|
+
|
|
9166
|
+
/* eslint-disable no-console */
|
|
9167
|
+
class PagarmeV5PixAxiosAdapter {
|
|
9168
|
+
constructor(credentials, paymentRepository) {
|
|
9169
|
+
this.credentials = credentials;
|
|
9170
|
+
this.paymentRepository = paymentRepository;
|
|
9171
|
+
}
|
|
9172
|
+
async pay(checkout) {
|
|
9173
|
+
try {
|
|
9174
|
+
const payload = PagarMeV5RequestHelper.build(checkout, 'pix');
|
|
9175
|
+
console.warn('[PAGARME PIX DATA TO SEND]', payload);
|
|
9176
|
+
const { data } = await axios({
|
|
9177
|
+
method: 'POST',
|
|
9178
|
+
url: `${this.credentials.URL}/orders`,
|
|
9179
|
+
headers: {
|
|
9180
|
+
Authorization: 'Basic ' + Buffer.from(`${this.credentials.API_KEY}:`).toString('base64'),
|
|
9181
|
+
'Content-Type': 'application/json',
|
|
9182
|
+
},
|
|
9183
|
+
data: payload,
|
|
9184
|
+
});
|
|
9185
|
+
console.warn('[RESPONSE PAGARME PIX DATA]', JSON.stringify(data));
|
|
9186
|
+
const paymentData = PagarMeV5ResponseHelper.build(checkout, data);
|
|
9187
|
+
const payment = await this.paymentRepository.create(paymentData);
|
|
9188
|
+
return payment;
|
|
9189
|
+
}
|
|
9190
|
+
catch (error) {
|
|
9191
|
+
console.log(error.response?.data?.errors);
|
|
9192
|
+
console.log(error.response?.data?.request);
|
|
9193
|
+
throw new PaymentError('Houve uma falha ao processar pagamento com pix', {
|
|
9194
|
+
checkoutId: checkout.id,
|
|
9195
|
+
userEmail: checkout.user.email,
|
|
9196
|
+
info: error.response?.data,
|
|
9197
|
+
});
|
|
9198
|
+
}
|
|
9199
|
+
}
|
|
9200
|
+
}
|
|
9201
|
+
|
|
8584
9202
|
class VertexAxiosAdapter {
|
|
8585
9203
|
constructor(config) {
|
|
8586
9204
|
this.config = config;
|
|
@@ -8734,4 +9352,4 @@ class ProductsVertexSearch {
|
|
|
8734
9352
|
}
|
|
8735
9353
|
}
|
|
8736
9354
|
|
|
8737
|
-
export { AccessoryImportances, Address, AdyenCardAxiosAdapter, AdyenPaymentMethodFactory, AntifraudBankSlipService, AntifraudCardService, AntifraudGlampointsService, AntifraudPixService, AntifraudProviderFactory, AntifraudProviders, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, BrandEquityOptions, BusinessError, BusinessUnitEnum, Buy2Win, Buy2WinFirestoreRepository, Campaign, CampaignBanner, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, CategoryProduct, CategoryProductHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, ConnectBaseDocumentSnapshot, ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, Coupon, CouponCategories, CouponCategory, CouponChannels, CouponFirestoreRepository, CouponOldCategories, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FirebaseFileUploaderService, FragranceImportances, FraudValidationError, GenderDestination, GlampointsPaymentMethodFactory, GlampointsPaymentService, Group, GroupFirestoreRepository, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, LogDocument, LogFirestoreRepository, Logger, NotFoundError, ObsEmitter, OfficePosition, Order, OrderBlocked, OrderBlockedFirestoreRepository, OrderBlockedType, OrderFirestoreRepository, OrderStatus, PagarmeBankSlipAxiosAdapter, PagarmeCardAxiosAdapter, PagarmePaymentMethodFactory, PagarmePaymentStatus, PagarmePixAxiosAdapter, Payment, PaymentError, PaymentFirestoreRepository, PaymentMethods, PaymentProviderFactory, PaymentProviders, PaymentTransaction, PaymentType, PersonTypes, Plans, Product, ProductErrors, ProductErrorsHasuraGraphQL, ProductErrorsHasuraGraphQLRepository, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductLabelEnum, ProductReview, ProductReviewHasuraGraphQLRepository, ProductSpents, ProductStockNotification, ProductStockNotificationHasuraGraphQLRepository, ProductVariantFirestoreRepository, ProductsIndex, ProductsVertexSearch, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RestCacheAdapter, RoundProductPricesHelper, Sequence, SequenceFirestoreRepository, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopPageName, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, StockLimitError, StockOutError, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionMaterialization, SubscriptionMaterializationFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionSummary, SubscriptionSummaryFirestoreRepository, Trace, UnauthorizedError, UpdateOptionActions, UpdateUserImage, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, VertexAxiosAdapter, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, WishlistLogType, deserialize, getClass, is, isDebuggable, isUUID, parseDateTime, registerClass, resolveClass, serialize, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|
|
9355
|
+
export { AccessoryImportances, Address, AdyenCardAxiosAdapter, AdyenPaymentMethodFactory, AntifraudBankSlipService, AntifraudCardService, AntifraudGlampointsService, AntifraudPixService, AntifraudProviderFactory, AntifraudProviders, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, BrandEquityOptions, BusinessError, BusinessUnitEnum, Buy2Win, Buy2WinFirestoreRepository, Campaign, CampaignBanner, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, CategoryProduct, CategoryProductHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, ConnectBaseDocumentSnapshot, ConnectCollectionService, ConnectDocumentService, ConnectFirestoreService, Coupon, CouponCategories, CouponCategory, CouponChannels, CouponFirestoreRepository, CouponOldCategories, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FirebaseFileUploaderService, FragranceImportances, FraudValidationError, GenderDestination, GlampointsPaymentMethodFactory, GlampointsPaymentService, Group, GroupFirestoreRepository, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, LogDocument, LogFirestoreRepository, Logger, NotFoundError, ObsEmitter, OfficePosition, Order, OrderBlocked, OrderBlockedFirestoreRepository, OrderBlockedType, OrderFirestoreRepository, OrderStatus, PagarMeV5OrderStatus, PagarMeV5PaymentStatus, PagarmeBankSlipAxiosAdapter, PagarmeCardAxiosAdapter, PagarmePaymentMethodFactory, PagarmePaymentStatus, PagarmePixAxiosAdapter, PagarmeV5BankSlipAxiosAdapter, PagarmeV5CardAxiosAdapter, PagarmeV5PixAxiosAdapter, Payment, PaymentError, PaymentFirestoreRepository, PaymentMethods, PaymentProviderFactory, PaymentProviders, PaymentTransaction, PaymentType, PersonTypes, Plans, Product, ProductErrors, ProductErrorsHasuraGraphQL, ProductErrorsHasuraGraphQLRepository, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductLabelEnum, ProductReview, ProductReviewHasuraGraphQLRepository, ProductSpents, ProductStockNotification, ProductStockNotificationHasuraGraphQLRepository, ProductVariantFirestoreRepository, ProductsIndex, ProductsVertexSearch, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RestCacheAdapter, RoundProductPricesHelper, Sequence, SequenceFirestoreRepository, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopPageName, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, StockLimitError, StockOutError, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionMaterialization, SubscriptionMaterializationFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionSummary, SubscriptionSummaryFirestoreRepository, Trace, UnauthorizedError, UpdateOptionActions, UpdateUserImage, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, VertexAxiosAdapter, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, WishlistLogType, deserialize, getClass, is, isDebuggable, isUUID, parseDateTime, registerClass, resolveClass, serialize, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|