@infrab4a/connect 5.7.6 → 5.7.8-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 +29 -117
- package/index.esm.js +28 -96
- package/package.json +1 -1
- package/src/domain/shopping/index.d.ts +0 -1
- package/src/domain/shopping/models/line-item.d.ts +0 -4
- package/src/domain/shopping/models/order.d.ts +0 -1
- package/src/domain/shopping/models/types/line-item-recurrence.type.d.ts +1 -1
- package/src/domain/shopping/types/create-recurrency-payload.type.d.ts +2 -0
- package/src/domain/shopping/types/index.d.ts +0 -1
- package/src/infra/cache/index.d.ts +0 -1
- package/src/infra/cache/restcache.adapter.d.ts +0 -3
- package/src/utils/index.d.ts +1 -0
- package/src/utils/to-cents.d.ts +5 -0
- package/src/domain/shopping/mappers/index.d.ts +0 -1
- package/src/domain/shopping/mappers/line-item-recurrence.mapper.d.ts +0 -5
- package/src/domain/shopping/types/shopping-recurrence-update-payloads.type.d.ts +0 -35
- package/src/infra/cache/resolve-cache-config.d.ts +0 -2
package/index.cjs.js
CHANGED
|
@@ -20,25 +20,7 @@ var storage = require('firebase/storage');
|
|
|
20
20
|
|
|
21
21
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
if (e && e.__esModule) return e;
|
|
25
|
-
var n = Object.create(null);
|
|
26
|
-
if (e) {
|
|
27
|
-
Object.keys(e).forEach(function (k) {
|
|
28
|
-
if (k !== 'default') {
|
|
29
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
30
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () { return e[k]; }
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
n["default"] = e;
|
|
38
|
-
return Object.freeze(n);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
var serializeJavascript__namespace = /*#__PURE__*/_interopNamespace(serializeJavascript);
|
|
23
|
+
var serializeJavascript__default = /*#__PURE__*/_interopDefaultLegacy(serializeJavascript);
|
|
42
24
|
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
43
25
|
|
|
44
26
|
exports.AntifraudProviders = void 0;
|
|
@@ -175,51 +157,6 @@ class PaymentProviderFactory {
|
|
|
175
157
|
}
|
|
176
158
|
}
|
|
177
159
|
|
|
178
|
-
function toLineItemRecurrence(item) {
|
|
179
|
-
if (item.recurrenceCycle == null) {
|
|
180
|
-
throw new Error(`Line item ${item.id ?? item.sku ?? 'unknown'} is missing recurrenceCycle`);
|
|
181
|
-
}
|
|
182
|
-
return {
|
|
183
|
-
id: item.id,
|
|
184
|
-
EAN: item.EAN,
|
|
185
|
-
sku: item.sku,
|
|
186
|
-
slug: item.slug,
|
|
187
|
-
name: item.name,
|
|
188
|
-
description: item.description,
|
|
189
|
-
brand: item.brand,
|
|
190
|
-
gender: item.gender,
|
|
191
|
-
costPrice: item.costPrice,
|
|
192
|
-
discount: item.discount,
|
|
193
|
-
weight: item.weight,
|
|
194
|
-
pricePaid: item.pricePaid,
|
|
195
|
-
quantity: item.quantity,
|
|
196
|
-
images: item.images,
|
|
197
|
-
miniatures: item.miniatures,
|
|
198
|
-
recurrenceCycle: item.recurrenceCycle,
|
|
199
|
-
recurrenceDiscountPercentage: item.recurrenceDiscountPercentage,
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
function groupRecurringLineItemsByCycle(items) {
|
|
203
|
-
const groups = new Map();
|
|
204
|
-
for (const item of items) {
|
|
205
|
-
if (!item.recurrenceCartItem) {
|
|
206
|
-
continue;
|
|
207
|
-
}
|
|
208
|
-
if (item.recurrenceCycle == null) {
|
|
209
|
-
throw new Error(`Line item ${item.id ?? item.sku ?? 'unknown'} has recurrenceCartItem but is missing recurrenceCycle`);
|
|
210
|
-
}
|
|
211
|
-
const mapped = toLineItemRecurrence(item);
|
|
212
|
-
const existing = groups.get(item.recurrenceCycle);
|
|
213
|
-
if (existing) {
|
|
214
|
-
existing.push(mapped);
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
groups.set(item.recurrenceCycle, [mapped]);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
return groups;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
160
|
const registry = new Map();
|
|
224
161
|
function registerClass(name, classConstructor) {
|
|
225
162
|
registry.set(name, classConstructor);
|
|
@@ -705,9 +642,22 @@ const deserialize = (data) => {
|
|
|
705
642
|
return eval('(' + data + ')');
|
|
706
643
|
};
|
|
707
644
|
const serialize = (data) => {
|
|
708
|
-
return
|
|
645
|
+
return serializeJavascript__default["default"](data);
|
|
709
646
|
};
|
|
710
647
|
|
|
648
|
+
/**
|
|
649
|
+
* Converts a BRL major-unit amount (e.g. 10.5) to integer cents (1050).
|
|
650
|
+
* Uses fixed 2-decimal normalization to avoid IEEE-754 artifacts like 19.99 * 100.
|
|
651
|
+
*/
|
|
652
|
+
function toCents(amount) {
|
|
653
|
+
if (!Number.isFinite(amount)) {
|
|
654
|
+
throw new Error(`Invalid amount: ${amount}`);
|
|
655
|
+
}
|
|
656
|
+
const sign = amount < 0 ? -1 : 1;
|
|
657
|
+
const [whole, fraction = '0'] = Math.abs(amount).toFixed(2).split('.');
|
|
658
|
+
return sign * (Number(whole) * 100 + Number(fraction));
|
|
659
|
+
}
|
|
660
|
+
|
|
711
661
|
class BaseModel {
|
|
712
662
|
get identifier() {
|
|
713
663
|
const fields = this.constructor.identifiersFields.filter((field) => field !== 'identifier');
|
|
@@ -2765,39 +2715,11 @@ class AdyenCardAxiosAdapter {
|
|
|
2765
2715
|
}
|
|
2766
2716
|
}
|
|
2767
2717
|
|
|
2768
|
-
function resolveCacheConfig(cache) {
|
|
2769
|
-
if (lodash.isNil(cache) || typeof cache !== 'object')
|
|
2770
|
-
return undefined;
|
|
2771
|
-
const candidate = cache;
|
|
2772
|
-
const cacheAdapter = candidate.cacheAdapter;
|
|
2773
|
-
if (!cacheAdapter)
|
|
2774
|
-
return undefined;
|
|
2775
|
-
if (!isCacheAdapter(cacheAdapter))
|
|
2776
|
-
return undefined;
|
|
2777
|
-
if (typeof cacheAdapter.isConfigured === 'function' && !cacheAdapter.isConfigured()) {
|
|
2778
|
-
return undefined;
|
|
2779
|
-
}
|
|
2780
|
-
return {
|
|
2781
|
-
cacheAdapter,
|
|
2782
|
-
ttlDefault: candidate.ttlDefault,
|
|
2783
|
-
};
|
|
2784
|
-
}
|
|
2785
|
-
function isCacheAdapter(adapter) {
|
|
2786
|
-
return (typeof adapter.get === 'function' &&
|
|
2787
|
-
typeof adapter.set === 'function' &&
|
|
2788
|
-
typeof adapter.remove === 'function' &&
|
|
2789
|
-
typeof adapter.clear === 'function');
|
|
2790
|
-
}
|
|
2791
|
-
|
|
2792
2718
|
class RestCacheAdapter {
|
|
2793
2719
|
constructor(config) {
|
|
2794
|
-
this.client = null;
|
|
2795
2720
|
this.logger = new DebugHelper('RestCacheAdapter');
|
|
2796
|
-
this.configured = this.isValidBaseURL(config.baseURL);
|
|
2797
|
-
if (!this.configured)
|
|
2798
|
-
return;
|
|
2799
2721
|
this.client = axios__default["default"].create({
|
|
2800
|
-
baseURL: config.baseURL
|
|
2722
|
+
baseURL: config.baseURL,
|
|
2801
2723
|
headers: {
|
|
2802
2724
|
'Content-Type': 'application/json',
|
|
2803
2725
|
...(lodash.isNil(config.authToken) ? {} : { Authorization: `Bearer ${config.authToken}` }),
|
|
@@ -2805,12 +2727,7 @@ class RestCacheAdapter {
|
|
|
2805
2727
|
},
|
|
2806
2728
|
});
|
|
2807
2729
|
}
|
|
2808
|
-
isConfigured() {
|
|
2809
|
-
return this.configured;
|
|
2810
|
-
}
|
|
2811
2730
|
async set(options) {
|
|
2812
|
-
if (!this.client)
|
|
2813
|
-
return false;
|
|
2814
2731
|
try {
|
|
2815
2732
|
const response = await this.client.post('/redis/set', {
|
|
2816
2733
|
key: options.key,
|
|
@@ -2826,8 +2743,6 @@ class RestCacheAdapter {
|
|
|
2826
2743
|
}
|
|
2827
2744
|
}
|
|
2828
2745
|
async get(key) {
|
|
2829
|
-
if (!this.client)
|
|
2830
|
-
return null;
|
|
2831
2746
|
try {
|
|
2832
2747
|
const response = await this.client.post('/redis/get', {
|
|
2833
2748
|
key,
|
|
@@ -2844,8 +2759,6 @@ class RestCacheAdapter {
|
|
|
2844
2759
|
}
|
|
2845
2760
|
}
|
|
2846
2761
|
async remove(key) {
|
|
2847
|
-
if (!this.client)
|
|
2848
|
-
return false;
|
|
2849
2762
|
try {
|
|
2850
2763
|
const response = await this.client.post('/redis/del', {
|
|
2851
2764
|
key,
|
|
@@ -2859,8 +2772,6 @@ class RestCacheAdapter {
|
|
|
2859
2772
|
}
|
|
2860
2773
|
}
|
|
2861
2774
|
async clear() {
|
|
2862
|
-
if (!this.client)
|
|
2863
|
-
return false;
|
|
2864
2775
|
try {
|
|
2865
2776
|
const response = await this.client.post('/redis/flushdb', {});
|
|
2866
2777
|
return response.data.success;
|
|
@@ -2871,9 +2782,6 @@ class RestCacheAdapter {
|
|
|
2871
2782
|
return false;
|
|
2872
2783
|
}
|
|
2873
2784
|
}
|
|
2874
|
-
isValidBaseURL(baseURL) {
|
|
2875
|
-
return lodash.isString(baseURL) && baseURL.trim().length > 0;
|
|
2876
|
-
}
|
|
2877
2785
|
}
|
|
2878
2786
|
|
|
2879
2787
|
class AxiosAdapter {
|
|
@@ -6220,7 +6128,7 @@ function createHasuraGraphQLClass(MixinBase) {
|
|
|
6220
6128
|
this.model = options.model;
|
|
6221
6129
|
this.fields = options.fields || this.model.identifiersFields;
|
|
6222
6130
|
this.logger = DebugHelper.from(this);
|
|
6223
|
-
this.cache =
|
|
6131
|
+
this.cache = options.cache;
|
|
6224
6132
|
}
|
|
6225
6133
|
get headers() {
|
|
6226
6134
|
return HasuraAuthHelper.buildHeaders(this.authOptions);
|
|
@@ -11217,9 +11125,9 @@ class PagarmeV5BaseAxiosAdapter {
|
|
|
11217
11125
|
}
|
|
11218
11126
|
async refund(order, amount) {
|
|
11219
11127
|
try {
|
|
11220
|
-
console.warn('[PAGARME REFUND] Starting refund process for order', order.id, order.payment, 'with amount', amount);
|
|
11221
|
-
const
|
|
11222
|
-
console.warn('[PAGARME REFUND] Amount to send in cents',
|
|
11128
|
+
console.warn('[PAGARME REFUND] Starting refund process for order', order.id, order.payment.payment_method, order.payment.amount, 'to refund with amount', amount);
|
|
11129
|
+
const amountInCents = toCents(amount);
|
|
11130
|
+
console.warn('[PAGARME REFUND] Amount to send in cents', amountInCents);
|
|
11223
11131
|
const { data } = await axios__default["default"]({
|
|
11224
11132
|
method: 'DELETE',
|
|
11225
11133
|
url: `${this.credentials.URL}/charges/${order.payment.charger_id}`,
|
|
@@ -11228,7 +11136,7 @@ class PagarmeV5BaseAxiosAdapter {
|
|
|
11228
11136
|
'Content-Type': 'application/json',
|
|
11229
11137
|
},
|
|
11230
11138
|
data: {
|
|
11231
|
-
amount:
|
|
11139
|
+
amount: amountInCents,
|
|
11232
11140
|
},
|
|
11233
11141
|
});
|
|
11234
11142
|
console.warn('[RESPONSE PAGARME REFUND]', JSON.stringify(data));
|
|
@@ -11244,7 +11152,13 @@ class PagarmeV5BaseAxiosAdapter {
|
|
|
11244
11152
|
});
|
|
11245
11153
|
return {
|
|
11246
11154
|
status: this.getRefundStatus(data.status),
|
|
11247
|
-
success: [
|
|
11155
|
+
success: [
|
|
11156
|
+
exports.PagarMeV5OrderStatus.Pago,
|
|
11157
|
+
exports.PagarMeV5OrderStatus.Cancelado,
|
|
11158
|
+
exports.PagarMeV5PaymentStatus['Em processamento'],
|
|
11159
|
+
].includes(data.status)
|
|
11160
|
+
? true
|
|
11161
|
+
: false,
|
|
11248
11162
|
};
|
|
11249
11163
|
}
|
|
11250
11164
|
catch (error) {
|
|
@@ -11941,16 +11855,14 @@ exports.Wishlist = Wishlist;
|
|
|
11941
11855
|
exports.WishlistHasuraGraphQLRepository = WishlistHasuraGraphQLRepository;
|
|
11942
11856
|
exports.deserialize = deserialize;
|
|
11943
11857
|
exports.getClass = getClass;
|
|
11944
|
-
exports.groupRecurringLineItemsByCycle = groupRecurringLineItemsByCycle;
|
|
11945
11858
|
exports.is = is;
|
|
11946
11859
|
exports.isDebuggable = isDebuggable;
|
|
11947
11860
|
exports.isUUID = isUUID;
|
|
11948
11861
|
exports.parseDateTime = parseDateTime;
|
|
11949
11862
|
exports.registerClass = registerClass;
|
|
11950
|
-
exports.resolveCacheConfig = resolveCacheConfig;
|
|
11951
11863
|
exports.resolveClass = resolveClass;
|
|
11952
11864
|
exports.serialize = serialize;
|
|
11953
|
-
exports.
|
|
11865
|
+
exports.toCents = toCents;
|
|
11954
11866
|
exports.withCreateFirestore = withCreateFirestore;
|
|
11955
11867
|
exports.withCreateHasuraGraphQL = withCreateHasuraGraphQL;
|
|
11956
11868
|
exports.withCrudFirestore = withCrudFirestore;
|
package/index.esm.js
CHANGED
|
@@ -8,7 +8,7 @@ export { formatInTimeZone } from 'date-fns-tz';
|
|
|
8
8
|
import { compact, get, isNil, isArray, first, last, flatten, isString, omit, each, unset, isObject, isEmpty, isDate, isBoolean, isInteger, isNumber, isNaN as isNaN$1, set, chunk, sortBy } from 'lodash';
|
|
9
9
|
export { chunk, each, get, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, pick, set, sortBy, unset } from 'lodash';
|
|
10
10
|
import { debug } from 'debug';
|
|
11
|
-
import
|
|
11
|
+
import serializeJavascript from 'serialize-javascript';
|
|
12
12
|
import { CustomError } from 'ts-custom-error';
|
|
13
13
|
import axios, { AxiosError } from 'axios';
|
|
14
14
|
import { signInWithEmailAndPassword, signInWithPopup, GoogleAuthProvider, browserPopupRedirectResolver, signInAnonymously, sendPasswordResetEmail, createUserWithEmailAndPassword, sendEmailVerification } from 'firebase/auth';
|
|
@@ -151,51 +151,6 @@ class PaymentProviderFactory {
|
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
function toLineItemRecurrence(item) {
|
|
155
|
-
if (item.recurrenceCycle == null) {
|
|
156
|
-
throw new Error(`Line item ${item.id ?? item.sku ?? 'unknown'} is missing recurrenceCycle`);
|
|
157
|
-
}
|
|
158
|
-
return {
|
|
159
|
-
id: item.id,
|
|
160
|
-
EAN: item.EAN,
|
|
161
|
-
sku: item.sku,
|
|
162
|
-
slug: item.slug,
|
|
163
|
-
name: item.name,
|
|
164
|
-
description: item.description,
|
|
165
|
-
brand: item.brand,
|
|
166
|
-
gender: item.gender,
|
|
167
|
-
costPrice: item.costPrice,
|
|
168
|
-
discount: item.discount,
|
|
169
|
-
weight: item.weight,
|
|
170
|
-
pricePaid: item.pricePaid,
|
|
171
|
-
quantity: item.quantity,
|
|
172
|
-
images: item.images,
|
|
173
|
-
miniatures: item.miniatures,
|
|
174
|
-
recurrenceCycle: item.recurrenceCycle,
|
|
175
|
-
recurrenceDiscountPercentage: item.recurrenceDiscountPercentage,
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
function groupRecurringLineItemsByCycle(items) {
|
|
179
|
-
const groups = new Map();
|
|
180
|
-
for (const item of items) {
|
|
181
|
-
if (!item.recurrenceCartItem) {
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
if (item.recurrenceCycle == null) {
|
|
185
|
-
throw new Error(`Line item ${item.id ?? item.sku ?? 'unknown'} has recurrenceCartItem but is missing recurrenceCycle`);
|
|
186
|
-
}
|
|
187
|
-
const mapped = toLineItemRecurrence(item);
|
|
188
|
-
const existing = groups.get(item.recurrenceCycle);
|
|
189
|
-
if (existing) {
|
|
190
|
-
existing.push(mapped);
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
groups.set(item.recurrenceCycle, [mapped]);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
return groups;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
154
|
const registry = new Map();
|
|
200
155
|
function registerClass(name, classConstructor) {
|
|
201
156
|
registry.set(name, classConstructor);
|
|
@@ -684,6 +639,19 @@ const serialize = (data) => {
|
|
|
684
639
|
return serializeJavascript(data);
|
|
685
640
|
};
|
|
686
641
|
|
|
642
|
+
/**
|
|
643
|
+
* Converts a BRL major-unit amount (e.g. 10.5) to integer cents (1050).
|
|
644
|
+
* Uses fixed 2-decimal normalization to avoid IEEE-754 artifacts like 19.99 * 100.
|
|
645
|
+
*/
|
|
646
|
+
function toCents(amount) {
|
|
647
|
+
if (!Number.isFinite(amount)) {
|
|
648
|
+
throw new Error(`Invalid amount: ${amount}`);
|
|
649
|
+
}
|
|
650
|
+
const sign = amount < 0 ? -1 : 1;
|
|
651
|
+
const [whole, fraction = '0'] = Math.abs(amount).toFixed(2).split('.');
|
|
652
|
+
return sign * (Number(whole) * 100 + Number(fraction));
|
|
653
|
+
}
|
|
654
|
+
|
|
687
655
|
class BaseModel {
|
|
688
656
|
get identifier() {
|
|
689
657
|
const fields = this.constructor.identifiersFields.filter((field) => field !== 'identifier');
|
|
@@ -2741,39 +2709,11 @@ class AdyenCardAxiosAdapter {
|
|
|
2741
2709
|
}
|
|
2742
2710
|
}
|
|
2743
2711
|
|
|
2744
|
-
function resolveCacheConfig(cache) {
|
|
2745
|
-
if (isNil(cache) || typeof cache !== 'object')
|
|
2746
|
-
return undefined;
|
|
2747
|
-
const candidate = cache;
|
|
2748
|
-
const cacheAdapter = candidate.cacheAdapter;
|
|
2749
|
-
if (!cacheAdapter)
|
|
2750
|
-
return undefined;
|
|
2751
|
-
if (!isCacheAdapter(cacheAdapter))
|
|
2752
|
-
return undefined;
|
|
2753
|
-
if (typeof cacheAdapter.isConfigured === 'function' && !cacheAdapter.isConfigured()) {
|
|
2754
|
-
return undefined;
|
|
2755
|
-
}
|
|
2756
|
-
return {
|
|
2757
|
-
cacheAdapter,
|
|
2758
|
-
ttlDefault: candidate.ttlDefault,
|
|
2759
|
-
};
|
|
2760
|
-
}
|
|
2761
|
-
function isCacheAdapter(adapter) {
|
|
2762
|
-
return (typeof adapter.get === 'function' &&
|
|
2763
|
-
typeof adapter.set === 'function' &&
|
|
2764
|
-
typeof adapter.remove === 'function' &&
|
|
2765
|
-
typeof adapter.clear === 'function');
|
|
2766
|
-
}
|
|
2767
|
-
|
|
2768
2712
|
class RestCacheAdapter {
|
|
2769
2713
|
constructor(config) {
|
|
2770
|
-
this.client = null;
|
|
2771
2714
|
this.logger = new DebugHelper('RestCacheAdapter');
|
|
2772
|
-
this.configured = this.isValidBaseURL(config.baseURL);
|
|
2773
|
-
if (!this.configured)
|
|
2774
|
-
return;
|
|
2775
2715
|
this.client = axios.create({
|
|
2776
|
-
baseURL: config.baseURL
|
|
2716
|
+
baseURL: config.baseURL,
|
|
2777
2717
|
headers: {
|
|
2778
2718
|
'Content-Type': 'application/json',
|
|
2779
2719
|
...(isNil(config.authToken) ? {} : { Authorization: `Bearer ${config.authToken}` }),
|
|
@@ -2781,12 +2721,7 @@ class RestCacheAdapter {
|
|
|
2781
2721
|
},
|
|
2782
2722
|
});
|
|
2783
2723
|
}
|
|
2784
|
-
isConfigured() {
|
|
2785
|
-
return this.configured;
|
|
2786
|
-
}
|
|
2787
2724
|
async set(options) {
|
|
2788
|
-
if (!this.client)
|
|
2789
|
-
return false;
|
|
2790
2725
|
try {
|
|
2791
2726
|
const response = await this.client.post('/redis/set', {
|
|
2792
2727
|
key: options.key,
|
|
@@ -2802,8 +2737,6 @@ class RestCacheAdapter {
|
|
|
2802
2737
|
}
|
|
2803
2738
|
}
|
|
2804
2739
|
async get(key) {
|
|
2805
|
-
if (!this.client)
|
|
2806
|
-
return null;
|
|
2807
2740
|
try {
|
|
2808
2741
|
const response = await this.client.post('/redis/get', {
|
|
2809
2742
|
key,
|
|
@@ -2820,8 +2753,6 @@ class RestCacheAdapter {
|
|
|
2820
2753
|
}
|
|
2821
2754
|
}
|
|
2822
2755
|
async remove(key) {
|
|
2823
|
-
if (!this.client)
|
|
2824
|
-
return false;
|
|
2825
2756
|
try {
|
|
2826
2757
|
const response = await this.client.post('/redis/del', {
|
|
2827
2758
|
key,
|
|
@@ -2835,8 +2766,6 @@ class RestCacheAdapter {
|
|
|
2835
2766
|
}
|
|
2836
2767
|
}
|
|
2837
2768
|
async clear() {
|
|
2838
|
-
if (!this.client)
|
|
2839
|
-
return false;
|
|
2840
2769
|
try {
|
|
2841
2770
|
const response = await this.client.post('/redis/flushdb', {});
|
|
2842
2771
|
return response.data.success;
|
|
@@ -2847,9 +2776,6 @@ class RestCacheAdapter {
|
|
|
2847
2776
|
return false;
|
|
2848
2777
|
}
|
|
2849
2778
|
}
|
|
2850
|
-
isValidBaseURL(baseURL) {
|
|
2851
|
-
return isString(baseURL) && baseURL.trim().length > 0;
|
|
2852
|
-
}
|
|
2853
2779
|
}
|
|
2854
2780
|
|
|
2855
2781
|
class AxiosAdapter {
|
|
@@ -6196,7 +6122,7 @@ function createHasuraGraphQLClass(MixinBase) {
|
|
|
6196
6122
|
this.model = options.model;
|
|
6197
6123
|
this.fields = options.fields || this.model.identifiersFields;
|
|
6198
6124
|
this.logger = DebugHelper.from(this);
|
|
6199
|
-
this.cache =
|
|
6125
|
+
this.cache = options.cache;
|
|
6200
6126
|
}
|
|
6201
6127
|
get headers() {
|
|
6202
6128
|
return HasuraAuthHelper.buildHeaders(this.authOptions);
|
|
@@ -11193,9 +11119,9 @@ class PagarmeV5BaseAxiosAdapter {
|
|
|
11193
11119
|
}
|
|
11194
11120
|
async refund(order, amount) {
|
|
11195
11121
|
try {
|
|
11196
|
-
console.warn('[PAGARME REFUND] Starting refund process for order', order.id, order.payment, 'with amount', amount);
|
|
11197
|
-
const
|
|
11198
|
-
console.warn('[PAGARME REFUND] Amount to send in cents',
|
|
11122
|
+
console.warn('[PAGARME REFUND] Starting refund process for order', order.id, order.payment.payment_method, order.payment.amount, 'to refund with amount', amount);
|
|
11123
|
+
const amountInCents = toCents(amount);
|
|
11124
|
+
console.warn('[PAGARME REFUND] Amount to send in cents', amountInCents);
|
|
11199
11125
|
const { data } = await axios({
|
|
11200
11126
|
method: 'DELETE',
|
|
11201
11127
|
url: `${this.credentials.URL}/charges/${order.payment.charger_id}`,
|
|
@@ -11204,7 +11130,7 @@ class PagarmeV5BaseAxiosAdapter {
|
|
|
11204
11130
|
'Content-Type': 'application/json',
|
|
11205
11131
|
},
|
|
11206
11132
|
data: {
|
|
11207
|
-
amount:
|
|
11133
|
+
amount: amountInCents,
|
|
11208
11134
|
},
|
|
11209
11135
|
});
|
|
11210
11136
|
console.warn('[RESPONSE PAGARME REFUND]', JSON.stringify(data));
|
|
@@ -11220,7 +11146,13 @@ class PagarmeV5BaseAxiosAdapter {
|
|
|
11220
11146
|
});
|
|
11221
11147
|
return {
|
|
11222
11148
|
status: this.getRefundStatus(data.status),
|
|
11223
|
-
success: [
|
|
11149
|
+
success: [
|
|
11150
|
+
PagarMeV5OrderStatus.Pago,
|
|
11151
|
+
PagarMeV5OrderStatus.Cancelado,
|
|
11152
|
+
PagarMeV5PaymentStatus['Em processamento'],
|
|
11153
|
+
].includes(data.status)
|
|
11154
|
+
? true
|
|
11155
|
+
: false,
|
|
11224
11156
|
};
|
|
11225
11157
|
}
|
|
11226
11158
|
catch (error) {
|
|
@@ -11607,4 +11539,4 @@ class ProductsVertexSearch {
|
|
|
11607
11539
|
}
|
|
11608
11540
|
}
|
|
11609
11541
|
|
|
11610
|
-
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, BrandCategory, BrandCategoryFirestoreRepository, 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, ErrorsCode, 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, InvalidCheckoutError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, LogDocument, LogFirestoreRepository, Logger, MercadoPagoBankSlipAxiosAdapter, MercadoPagoCardAxiosAdapter, MercadoPagoErrorHelper, MercadoPagoPaymentMethodFactory, MercadoPagoPixAxiosAdapter, MercadoPagoRequestHelper, MercadoPagoResponseHelper, MercadoPagoStatusDetailEnum, MercadoPagoStatusEnum, NotFoundError, ObsEmitter, OfficePosition, Order, OrderBlocked, OrderBlockedFirestoreRepository, OrderBlockedType, OrderFirestoreRepository, OrderPaymentStatus, OrderStatus, PagarMeV5OrderStatus, PagarMeV5PaymentStatus, PagarmeBankSlipAxiosAdapter, PagarmeCardAxiosAdapter, PagarmePaymentMethodFactory, PagarmePaymentStatus, PagarmePixAxiosAdapter, PagarmeV5BankSlipAxiosAdapter, PagarmeV5BaseAxiosAdapter, PagarmeV5CardAxiosAdapter, PagarmeV5PixAxiosAdapter, Payment, PaymentError, PaymentFirestoreRepository, PaymentMethods, PaymentProviderFactory, PaymentProviders, PaymentTransaction, PaymentType, PersonTypes, Plans, Product, ProductCatalogHasuraGraphQL, ProductCatalogHasuraGraphQLRepository, ProductErrors, ProductErrorsHasuraGraphQL, ProductErrorsHasuraGraphQLRepository, ProductFirestoreRepository, ProductGroup, ProductGroupHasuraGraphQLRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductLabelEnum, ProductPriceLog, ProductPriceLogHasuraGraphQLRepository, ProductReview, ProductReviewHasuraGraphQLRepository, ProductSpents, ProductStockEntry, ProductStockEntryHasuraGraphQL, ProductStockEntryHasuraGraphQLRepository, ProductStockNotification, ProductStockNotificationHasuraGraphQLRepository, ProductVariantFirestoreRepository, ProductsIndex, ProductsVertexSearch, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RestCacheAdapter, RoundProductPricesHelper, Sequence, SequenceFirestoreRepository, ShippingMethod, ShopConfigs, ShopConfigsFirestoreRepository, ShopMenu, ShopMenuFirestoreRepository, ShopPageName, ShopSettings, ShopSettingsFirestoreRepository, ShoppingRecurrence, ShoppingRecurrenceCycle, ShoppingRecurrenceEdition, ShoppingRecurrenceEditionFirestoreRepository, ShoppingRecurrenceEditionStatus, ShoppingRecurrenceErrorLog, ShoppingRecurrenceErrorLogFirestoreRepository, ShoppingRecurrenceFirestoreRepository, ShoppingRecurrenceStatus, Shops, SignInMethods, SignOut, Status, StockLimitError, StockOutError, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionMaterialization, SubscriptionMaterializationFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionSummary, SubscriptionSummaryFirestoreRepository, Trace, TransactionPaymentMethods, UnauthorizedError, UpdateOptionActions, UpdateUserImage, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, VertexAxiosAdapter, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, WishlistLogType, deserialize, getClass,
|
|
11542
|
+
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, BrandCategory, BrandCategoryFirestoreRepository, 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, ErrorsCode, 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, InvalidCheckoutError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, LogDocument, LogFirestoreRepository, Logger, MercadoPagoBankSlipAxiosAdapter, MercadoPagoCardAxiosAdapter, MercadoPagoErrorHelper, MercadoPagoPaymentMethodFactory, MercadoPagoPixAxiosAdapter, MercadoPagoRequestHelper, MercadoPagoResponseHelper, MercadoPagoStatusDetailEnum, MercadoPagoStatusEnum, NotFoundError, ObsEmitter, OfficePosition, Order, OrderBlocked, OrderBlockedFirestoreRepository, OrderBlockedType, OrderFirestoreRepository, OrderPaymentStatus, OrderStatus, PagarMeV5OrderStatus, PagarMeV5PaymentStatus, PagarmeBankSlipAxiosAdapter, PagarmeCardAxiosAdapter, PagarmePaymentMethodFactory, PagarmePaymentStatus, PagarmePixAxiosAdapter, PagarmeV5BankSlipAxiosAdapter, PagarmeV5BaseAxiosAdapter, PagarmeV5CardAxiosAdapter, PagarmeV5PixAxiosAdapter, Payment, PaymentError, PaymentFirestoreRepository, PaymentMethods, PaymentProviderFactory, PaymentProviders, PaymentTransaction, PaymentType, PersonTypes, Plans, Product, ProductCatalogHasuraGraphQL, ProductCatalogHasuraGraphQLRepository, ProductErrors, ProductErrorsHasuraGraphQL, ProductErrorsHasuraGraphQLRepository, ProductFirestoreRepository, ProductGroup, ProductGroupHasuraGraphQLRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductLabelEnum, ProductPriceLog, ProductPriceLogHasuraGraphQLRepository, ProductReview, ProductReviewHasuraGraphQLRepository, ProductSpents, ProductStockEntry, ProductStockEntryHasuraGraphQL, ProductStockEntryHasuraGraphQLRepository, ProductStockNotification, ProductStockNotificationHasuraGraphQLRepository, ProductVariantFirestoreRepository, ProductsIndex, ProductsVertexSearch, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RestCacheAdapter, RoundProductPricesHelper, Sequence, SequenceFirestoreRepository, ShippingMethod, ShopConfigs, ShopConfigsFirestoreRepository, ShopMenu, ShopMenuFirestoreRepository, ShopPageName, ShopSettings, ShopSettingsFirestoreRepository, ShoppingRecurrence, ShoppingRecurrenceCycle, ShoppingRecurrenceEdition, ShoppingRecurrenceEditionFirestoreRepository, ShoppingRecurrenceEditionStatus, ShoppingRecurrenceErrorLog, ShoppingRecurrenceErrorLogFirestoreRepository, ShoppingRecurrenceFirestoreRepository, ShoppingRecurrenceStatus, Shops, SignInMethods, SignOut, Status, StockLimitError, StockOutError, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionMaterialization, SubscriptionMaterializationFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionSummary, SubscriptionSummaryFirestoreRepository, Trace, TransactionPaymentMethods, 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, toCents, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
|
package/package.json
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Product } from '../../catalog/models/product';
|
|
2
|
-
import { ShoppingRecurrenceCycle } from './enums';
|
|
3
2
|
export declare class LineItem extends Product {
|
|
4
3
|
parentId?: string;
|
|
5
4
|
quantity: number;
|
|
@@ -8,8 +7,5 @@ export declare class LineItem extends Product {
|
|
|
8
7
|
discount?: number;
|
|
9
8
|
image?: string;
|
|
10
9
|
refunded?: boolean;
|
|
11
|
-
recurrenceCartItem?: boolean;
|
|
12
|
-
recurrenceCycle?: ShoppingRecurrenceCycle;
|
|
13
|
-
recurrenceDiscountPercentage?: number;
|
|
14
10
|
get pricePaidWithDiscount(): number;
|
|
15
11
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { LineItem } from '../line-item';
|
|
2
|
-
export type LineItemRecurrence = Pick<LineItem, 'id' | 'EAN' | 'sku' | 'slug' | 'name' | 'description' | 'brand' | 'gender' | 'costPrice' | 'discount' | 'weight' | 'pricePaid' | 'quantity' | 'images' | 'miniatures'
|
|
2
|
+
export type LineItemRecurrence = Pick<LineItem, 'id' | 'EAN' | 'sku' | 'slug' | 'name' | 'description' | 'brand' | 'gender' | 'costPrice' | 'discount' | 'weight' | 'pricePaid' | 'quantity' | 'images' | 'miniatures'>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { ShoppingRecurrenceCycle } from '../models/enums/shopping-recurrence-cycle.enum';
|
|
1
2
|
import { PaymentCardInfo } from './payment-card-info.type';
|
|
2
3
|
export type CreateShoppingRecurrencyPayload = {
|
|
3
4
|
shopId: string;
|
|
4
5
|
cards?: PaymentCardInfo[];
|
|
5
6
|
orderId: string;
|
|
7
|
+
recurrence: ShoppingRecurrenceCycle;
|
|
6
8
|
};
|
|
@@ -7,12 +7,9 @@ export interface RESTCacheConfig {
|
|
|
7
7
|
export declare class RestCacheAdapter implements CacheAdapter {
|
|
8
8
|
private client;
|
|
9
9
|
private readonly logger;
|
|
10
|
-
private readonly configured;
|
|
11
10
|
constructor(config: RESTCacheConfig);
|
|
12
|
-
isConfigured(): boolean;
|
|
13
11
|
set(options: CacheOptions): Promise<boolean>;
|
|
14
12
|
get<T = any>(key: string): Promise<T | null>;
|
|
15
13
|
remove(key: string): Promise<boolean>;
|
|
16
14
|
clear(): Promise<boolean>;
|
|
17
|
-
private isValidBaseURL;
|
|
18
15
|
}
|
package/src/utils/index.d.ts
CHANGED
|
@@ -13,5 +13,6 @@ export * from './mixins';
|
|
|
13
13
|
export * from './obs-emitter';
|
|
14
14
|
export * from './parse-datetime';
|
|
15
15
|
export * from './serialize';
|
|
16
|
+
export * from './to-cents';
|
|
16
17
|
export * from './types';
|
|
17
18
|
export { add, addBusinessDays, addHours, addDays, addMonths, addYears, formatInTimeZone, chunk, each, endOfDay, format, formatISO9075, get, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, parseISO, pick, set, sortBy, startOfDay, sub, subDays, unset, };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './line-item-recurrence.mapper';
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { ShoppingRecurrenceCycle } from '../models/enums/shopping-recurrence-cycle.enum';
|
|
2
|
-
import { LineItem } from '../models/line-item';
|
|
3
|
-
import { LineItemRecurrence } from '../models/types/line-item-recurrence.type';
|
|
4
|
-
export declare function toLineItemRecurrence(item: LineItem): LineItemRecurrence;
|
|
5
|
-
export declare function groupRecurringLineItemsByCycle(items: LineItem[]): Map<ShoppingRecurrenceCycle, LineItemRecurrence[]>;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { UserAddress } from '../../users';
|
|
2
|
-
import { ShoppingRecurrenceCycle } from '../models/enums/shopping-recurrence-cycle.enum';
|
|
3
|
-
import { LineItemRecurrence } from '../models/types/line-item-recurrence.type';
|
|
4
|
-
import { CardForPaymentInfo } from './payment-card-info.type';
|
|
5
|
-
export type UpdateShoppingRecurrencePaymentMethodPayload = {
|
|
6
|
-
recurrenceId: string;
|
|
7
|
-
cards: CardForPaymentInfo[];
|
|
8
|
-
};
|
|
9
|
-
export type GetShoppingRecurrenceAvailableShippingPayload = {
|
|
10
|
-
recurrenceId: string;
|
|
11
|
-
shippingAddress?: UserAddress;
|
|
12
|
-
};
|
|
13
|
-
export type UpdateShoppingRecurrenceShippingAddressPayload = {
|
|
14
|
-
recurrenceId: string;
|
|
15
|
-
shippingAddress: UserAddress;
|
|
16
|
-
shippingOption: string;
|
|
17
|
-
};
|
|
18
|
-
export type CancelShoppingRecurrencePayload = {
|
|
19
|
-
recurrenceId: string;
|
|
20
|
-
};
|
|
21
|
-
export type EnableOrDisableShoppingRecurrencePayload = {
|
|
22
|
-
recurrenceId: string;
|
|
23
|
-
active: boolean;
|
|
24
|
-
};
|
|
25
|
-
export type SkipShoppingRecurrenceEditionPayload = {
|
|
26
|
-
recurrenceEditionId: string;
|
|
27
|
-
};
|
|
28
|
-
export type UpdateShoppingRecurrenceFrequencyPayload = {
|
|
29
|
-
recurrenceId: string;
|
|
30
|
-
frequency: ShoppingRecurrenceCycle;
|
|
31
|
-
};
|
|
32
|
-
export type UpdateShoppingRecurrenceLineItemsPayload = {
|
|
33
|
-
recurrenceId: string;
|
|
34
|
-
lineItems: LineItemRecurrence[];
|
|
35
|
-
};
|