@merkaly/api 0.23.0 → 0.24.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/dist/finance/payment/index.d.ts +1 -0
- package/dist/finance/payment/payment.entity.d.ts +2 -0
- package/dist/finance/payment/payment.gateway.entity.d.ts +51 -0
- package/dist/integration/payment/account.d.ts +85 -0
- package/dist/integration/payment/account.enum.d.ts +30 -0
- package/dist/integration/payment/account.enum.js +35 -0
- package/dist/integration/payment/charge.d.ts +25 -0
- package/dist/integration/payment/charge.enum.d.ts +9 -0
- package/dist/integration/payment/charge.enum.js +10 -0
- package/dist/integration/payment/charge.request.validator.d.ts +16 -0
- package/dist/integration/payment/charge.request.validator.js +118 -0
- package/dist/integration/payment/index.d.ts +6 -3
- package/dist/integration/payment/index.js +3 -1
- package/dist/integration/payment/payment.account.entity.d.ts +68 -0
- package/dist/integration/payment/payment.entity.d.ts +3 -2
- package/dist/integration/payment/provider.enum.d.ts +1 -1
- package/dist/integration/payment/provider.enum.js +1 -1
- package/dist/integration/payment/request.validator.d.ts +37 -69
- package/dist/integration/payment/request.validator.js +145 -303
- package/dist/order/sale/attention.d.ts +8 -0
- package/dist/order/sale/attention.enum.d.ts +9 -0
- package/dist/order/sale/attention.enum.js +10 -0
- package/dist/order/sale/index.d.ts +2 -0
- package/dist/order/sale/index.js +1 -0
- package/dist/order/sale/shipping.request.validator.js +2 -11
- package/package.json +3 -1
- package/dist/integration/payment/payment.recipient.entity.d.ts +0 -53
- package/dist/integration/payment/recipient.d.ts +0 -40
- package/dist/integration/payment/recipient.enum.d.ts +0 -22
- package/dist/integration/payment/recipient.enum.js +0 -26
|
@@ -8,25 +8,15 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
+
import * as brazilian_utils_1 from "@brazilian-utils/brazilian-utils";
|
|
11
12
|
import * as class_transformer_1 from "class-transformer";
|
|
12
13
|
import * as class_validator_1 from "class-validator";
|
|
13
14
|
import * as shipping_request_validator_1 from '../../order/sale/index.js';
|
|
14
15
|
import * as abstract_validator_1 from '../../abstract.validator.js';
|
|
15
|
-
import * as
|
|
16
|
+
import * as account_enum_1 from './account.enum.js';
|
|
16
17
|
const lower = ({ value }) => typeof value === 'string' ? value.trim().toLowerCase() : value;
|
|
17
18
|
export function isCnpj(value) {
|
|
18
|
-
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
const digit = (length) => {
|
|
22
|
-
const weights = length === 12
|
|
23
|
-
? [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]
|
|
24
|
-
: [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
|
|
25
|
-
const sum = weights.reduce((acc, weight, index) => acc + Number(value[index]) * weight, 0);
|
|
26
|
-
const rest = sum % 11;
|
|
27
|
-
return rest < 2 ? 0 : 11 - rest;
|
|
28
|
-
};
|
|
29
|
-
return digit(12) === Number(value[12]) && digit(13) === Number(value[13]);
|
|
19
|
+
return typeof value === 'string' && /^\d{14}$/.test(value) && (0, brazilian_utils_1.isValidCnpj)(value);
|
|
30
20
|
}
|
|
31
21
|
export function IsCnpj() {
|
|
32
22
|
return (0, class_validator_1.ValidateBy)({
|
|
@@ -37,403 +27,255 @@ export function IsCnpj() {
|
|
|
37
27
|
},
|
|
38
28
|
});
|
|
39
29
|
}
|
|
40
|
-
export function
|
|
41
|
-
|
|
42
|
-
if (!y)
|
|
30
|
+
export function isPixKey(type, key) {
|
|
31
|
+
if (typeof key !== 'string')
|
|
43
32
|
return false;
|
|
44
|
-
|
|
45
|
-
|
|
33
|
+
switch (type) {
|
|
34
|
+
case account_enum_1.PaymentPixKeyTypeEnum.CPF:
|
|
35
|
+
return (0, shipping_request_validator_1.isCpf)(key);
|
|
36
|
+
case account_enum_1.PaymentPixKeyTypeEnum.CNPJ:
|
|
37
|
+
return isCnpj(key);
|
|
38
|
+
case account_enum_1.PaymentPixKeyTypeEnum.EMAIL:
|
|
39
|
+
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(key) && key.length <= 77;
|
|
40
|
+
case account_enum_1.PaymentPixKeyTypeEnum.PHONE:
|
|
41
|
+
return /^\d{10,11}$/.test(key);
|
|
42
|
+
case account_enum_1.PaymentPixKeyTypeEnum.EVP:
|
|
43
|
+
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(key);
|
|
44
|
+
default:
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
46
47
|
}
|
|
47
|
-
function
|
|
48
|
+
function IsPixKey() {
|
|
48
49
|
return (0, class_validator_1.ValidateBy)({
|
|
49
|
-
name: '
|
|
50
|
+
name: 'isPixKey',
|
|
50
51
|
validator: {
|
|
51
|
-
defaultMessage: () => '$property must be a
|
|
52
|
-
validate: (
|
|
52
|
+
defaultMessage: () => '$property must be a valid Pix key of the given pixKeyType',
|
|
53
|
+
validate: (key, args) => isPixKey(args.object.pixKeyType, key),
|
|
53
54
|
},
|
|
54
55
|
});
|
|
55
56
|
}
|
|
56
|
-
|
|
57
|
-
if (
|
|
58
|
-
return
|
|
59
|
-
const
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return value
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
function IsTransferDay() {
|
|
57
|
+
const pixKey = ({ value, obj }) => {
|
|
58
|
+
if (typeof value !== 'string')
|
|
59
|
+
return value;
|
|
60
|
+
const type = obj?.pixKeyType;
|
|
61
|
+
if (type === account_enum_1.PaymentPixKeyTypeEnum.CPF ||
|
|
62
|
+
type === account_enum_1.PaymentPixKeyTypeEnum.CNPJ ||
|
|
63
|
+
type === account_enum_1.PaymentPixKeyTypeEnum.PHONE) {
|
|
64
|
+
return value.replace(/\D/g, '');
|
|
65
|
+
}
|
|
66
|
+
return type === account_enum_1.PaymentPixKeyTypeEnum.EMAIL ? value.trim().toLowerCase() : value.trim();
|
|
67
|
+
};
|
|
68
|
+
function IsAccountDocument() {
|
|
69
69
|
return (0, class_validator_1.ValidateBy)({
|
|
70
|
-
name: '
|
|
70
|
+
name: 'isAccountDocument',
|
|
71
71
|
validator: {
|
|
72
|
-
defaultMessage: () => '$property must be
|
|
73
|
-
validate: (
|
|
72
|
+
defaultMessage: () => '$property must be a valid CPF (individual) or CNPJ (company)',
|
|
73
|
+
validate: (value, args) => (isCompany(args.object) ? isCnpj(value) : (0, shipping_request_validator_1.isCpf)(value)),
|
|
74
74
|
},
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
const isIndividual = (body) => body.personType === account_enum_1.PaymentAccountPersonTypeEnum.INDIVIDUAL;
|
|
78
|
+
const isCompany = (body) => body.personType === account_enum_1.PaymentAccountPersonTypeEnum.COMPANY;
|
|
79
|
+
export class PaymentAccountAddressRequestValidator extends abstract_validator_1.AbstractRequestValidator {
|
|
80
|
+
postalCode;
|
|
79
81
|
street;
|
|
80
82
|
number;
|
|
81
83
|
complement;
|
|
82
|
-
|
|
83
|
-
city;
|
|
84
|
-
state;
|
|
85
|
-
referencePoint;
|
|
84
|
+
district;
|
|
86
85
|
}
|
|
87
86
|
__decorate([
|
|
88
87
|
(0, class_validator_1.Matches)(/^\d{8}$/, { message: '$property must be a CEP with 8 digits' }),
|
|
89
88
|
(0, class_transformer_1.Transform)(shipping_request_validator_1.digits),
|
|
90
89
|
__metadata("design:type", String)
|
|
91
|
-
],
|
|
90
|
+
], PaymentAccountAddressRequestValidator.prototype, "postalCode", void 0);
|
|
92
91
|
__decorate([
|
|
93
92
|
(0, class_validator_1.IsString)(),
|
|
94
93
|
(0, class_validator_1.Length)(2, 200),
|
|
95
94
|
(0, class_transformer_1.Transform)(shipping_request_validator_1.trim),
|
|
96
95
|
__metadata("design:type", String)
|
|
97
|
-
],
|
|
96
|
+
], PaymentAccountAddressRequestValidator.prototype, "street", void 0);
|
|
98
97
|
__decorate([
|
|
99
98
|
(0, class_validator_1.IsString)(),
|
|
100
99
|
(0, class_validator_1.Length)(1, 20),
|
|
101
100
|
(0, class_transformer_1.Transform)(shipping_request_validator_1.trim),
|
|
102
101
|
__metadata("design:type", String)
|
|
103
|
-
],
|
|
102
|
+
], PaymentAccountAddressRequestValidator.prototype, "number", void 0);
|
|
104
103
|
__decorate([
|
|
105
104
|
(0, class_validator_1.IsString)(),
|
|
106
105
|
(0, class_validator_1.Length)(1, 120),
|
|
106
|
+
(0, class_validator_1.IsOptional)(),
|
|
107
107
|
(0, class_transformer_1.Transform)(shipping_request_validator_1.trim),
|
|
108
108
|
__metadata("design:type", String)
|
|
109
|
-
],
|
|
110
|
-
__decorate([
|
|
111
|
-
(0, class_validator_1.IsString)(),
|
|
112
|
-
(0, class_validator_1.Length)(2, 120),
|
|
113
|
-
(0, class_transformer_1.Transform)(shipping_request_validator_1.trim),
|
|
114
|
-
__metadata("design:type", String)
|
|
115
|
-
], PaymentRecipientAddressRequestValidator.prototype, "neighborhood", void 0);
|
|
109
|
+
], PaymentAccountAddressRequestValidator.prototype, "complement", void 0);
|
|
116
110
|
__decorate([
|
|
117
111
|
(0, class_validator_1.IsString)(),
|
|
118
112
|
(0, class_validator_1.Length)(2, 120),
|
|
119
113
|
(0, class_transformer_1.Transform)(shipping_request_validator_1.trim),
|
|
120
114
|
__metadata("design:type", String)
|
|
121
|
-
],
|
|
122
|
-
|
|
123
|
-
(0, class_validator_1.IsIn)(shipping_request_validator_1.BRAZIL_STATES, { message: '$property must be a Brazilian UF' }),
|
|
124
|
-
(0, class_transformer_1.Transform)(shipping_request_validator_1.upper),
|
|
125
|
-
__metadata("design:type", String)
|
|
126
|
-
], PaymentRecipientAddressRequestValidator.prototype, "state", void 0);
|
|
127
|
-
__decorate([
|
|
128
|
-
(0, class_validator_1.IsString)(),
|
|
129
|
-
(0, class_validator_1.Length)(1, 200),
|
|
130
|
-
(0, class_transformer_1.Transform)(shipping_request_validator_1.trim),
|
|
131
|
-
__metadata("design:type", String)
|
|
132
|
-
], PaymentRecipientAddressRequestValidator.prototype, "referencePoint", void 0);
|
|
133
|
-
export class PaymentRecipientPhoneRequestValidator extends abstract_validator_1.AbstractRequestValidator {
|
|
134
|
-
ddd;
|
|
135
|
-
number;
|
|
136
|
-
}
|
|
137
|
-
__decorate([
|
|
138
|
-
(0, class_validator_1.Matches)(/^\d{2}$/, { message: '$property must be the 2 digit area code' }),
|
|
139
|
-
(0, class_transformer_1.Transform)(shipping_request_validator_1.digits),
|
|
140
|
-
__metadata("design:type", String)
|
|
141
|
-
], PaymentRecipientPhoneRequestValidator.prototype, "ddd", void 0);
|
|
142
|
-
__decorate([
|
|
143
|
-
(0, class_validator_1.Matches)(/^\d{8,9}$/, { message: '$property must have 8 or 9 digits' }),
|
|
144
|
-
(0, class_transformer_1.Transform)(shipping_request_validator_1.digits),
|
|
145
|
-
__metadata("design:type", String)
|
|
146
|
-
], PaymentRecipientPhoneRequestValidator.prototype, "number", void 0);
|
|
147
|
-
export class PaymentRecipientPersonBaseRequestValidator extends abstract_validator_1.AbstractRequestValidator {
|
|
148
|
-
name;
|
|
115
|
+
], PaymentAccountAddressRequestValidator.prototype, "district", void 0);
|
|
116
|
+
class PaymentAccountContactRequestValidator extends abstract_validator_1.AbstractRequestValidator {
|
|
149
117
|
email;
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
118
|
+
mobilePhone;
|
|
119
|
+
phone;
|
|
120
|
+
incomeValue;
|
|
121
|
+
site;
|
|
122
|
+
address;
|
|
155
123
|
}
|
|
156
|
-
__decorate([
|
|
157
|
-
(0, class_validator_1.IsString)(),
|
|
158
|
-
(0, class_validator_1.Length)(2, 120),
|
|
159
|
-
(0, class_transformer_1.Transform)(shipping_request_validator_1.trim),
|
|
160
|
-
__metadata("design:type", String)
|
|
161
|
-
], PaymentRecipientPersonBaseRequestValidator.prototype, "name", void 0);
|
|
162
124
|
__decorate([
|
|
163
125
|
(0, class_validator_1.IsEmail)(),
|
|
164
126
|
(0, class_validator_1.Length)(3, 254),
|
|
165
127
|
(0, class_transformer_1.Transform)(lower),
|
|
166
128
|
__metadata("design:type", String)
|
|
167
|
-
],
|
|
129
|
+
], PaymentAccountContactRequestValidator.prototype, "email", void 0);
|
|
168
130
|
__decorate([
|
|
169
|
-
(0,
|
|
131
|
+
(0, class_validator_1.Matches)(/^\d{10,11}$/, { message: '$property must be the DDD and number (10 or 11 digits)' }),
|
|
170
132
|
(0, class_transformer_1.Transform)(shipping_request_validator_1.digits),
|
|
171
133
|
__metadata("design:type", String)
|
|
172
|
-
],
|
|
134
|
+
], PaymentAccountContactRequestValidator.prototype, "mobilePhone", void 0);
|
|
173
135
|
__decorate([
|
|
174
|
-
(0,
|
|
175
|
-
(0,
|
|
136
|
+
(0, class_validator_1.Matches)(/^\d{10,11}$/, { message: '$property must be the DDD and number (10 or 11 digits)' }),
|
|
137
|
+
(0, class_validator_1.IsOptional)(),
|
|
138
|
+
(0, class_transformer_1.Transform)(shipping_request_validator_1.digits),
|
|
176
139
|
__metadata("design:type", String)
|
|
177
|
-
],
|
|
140
|
+
], PaymentAccountContactRequestValidator.prototype, "phone", void 0);
|
|
178
141
|
__decorate([
|
|
179
142
|
(0, class_validator_1.IsInt)(),
|
|
180
143
|
(0, class_validator_1.Min)(1),
|
|
181
144
|
__metadata("design:type", Number)
|
|
182
|
-
],
|
|
183
|
-
__decorate([
|
|
184
|
-
(0, class_validator_1.IsString)(),
|
|
185
|
-
(0, class_validator_1.Length)(2, 120),
|
|
186
|
-
(0, class_transformer_1.Transform)(shipping_request_validator_1.trim),
|
|
187
|
-
__metadata("design:type", String)
|
|
188
|
-
], PaymentRecipientPersonBaseRequestValidator.prototype, "professionalOccupation", void 0);
|
|
189
|
-
__decorate([
|
|
190
|
-
(0, class_validator_1.IsString)(),
|
|
191
|
-
(0, class_validator_1.Length)(2, 120),
|
|
192
|
-
(0, class_validator_1.IsOptional)(),
|
|
193
|
-
(0, class_transformer_1.Transform)(shipping_request_validator_1.trim),
|
|
194
|
-
__metadata("design:type", String)
|
|
195
|
-
], PaymentRecipientPersonBaseRequestValidator.prototype, "motherName", void 0);
|
|
196
|
-
export class PaymentRecipientIndividualRequestValidator extends PaymentRecipientPersonBaseRequestValidator {
|
|
197
|
-
siteUrl;
|
|
198
|
-
}
|
|
145
|
+
], PaymentAccountContactRequestValidator.prototype, "incomeValue", void 0);
|
|
199
146
|
__decorate([
|
|
200
147
|
(0, class_validator_1.IsUrl)({ require_protocol: true }),
|
|
201
148
|
(0, class_validator_1.IsOptional)(),
|
|
202
149
|
(0, class_transformer_1.Transform)(shipping_request_validator_1.trim),
|
|
203
150
|
__metadata("design:type", String)
|
|
204
|
-
],
|
|
205
|
-
export class PaymentRecipientPartnerRequestValidator extends PaymentRecipientPersonBaseRequestValidator {
|
|
206
|
-
address;
|
|
207
|
-
phone;
|
|
208
|
-
constructor() {
|
|
209
|
-
super();
|
|
210
|
-
this.address = new PaymentRecipientAddressRequestValidator();
|
|
211
|
-
this.phone = new PaymentRecipientPhoneRequestValidator();
|
|
212
|
-
}
|
|
213
|
-
}
|
|
151
|
+
], PaymentAccountContactRequestValidator.prototype, "site", void 0);
|
|
214
152
|
__decorate([
|
|
215
153
|
(0, class_validator_1.IsDefined)(),
|
|
216
154
|
(0, class_validator_1.ValidateNested)(),
|
|
217
|
-
(0, class_transformer_1.Type)(() =>
|
|
218
|
-
__metadata("design:type",
|
|
219
|
-
],
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
export class PaymentRecipientCorporationRequestValidator extends abstract_validator_1.AbstractRequestValidator {
|
|
227
|
-
companyName;
|
|
228
|
-
tradingName;
|
|
229
|
-
email;
|
|
230
|
-
document;
|
|
231
|
-
siteUrl;
|
|
232
|
-
annualRevenue;
|
|
233
|
-
corporationType;
|
|
234
|
-
foundingDate;
|
|
235
|
-
partner;
|
|
155
|
+
(0, class_transformer_1.Type)(() => PaymentAccountAddressRequestValidator),
|
|
156
|
+
__metadata("design:type", PaymentAccountAddressRequestValidator)
|
|
157
|
+
], PaymentAccountContactRequestValidator.prototype, "address", void 0);
|
|
158
|
+
export class CreatePaymentAccountRequestValidator extends PaymentAccountContactRequestValidator {
|
|
159
|
+
personType;
|
|
160
|
+
name;
|
|
161
|
+
cpfCnpj;
|
|
162
|
+
birthDate;
|
|
163
|
+
companyType;
|
|
236
164
|
constructor() {
|
|
237
165
|
super();
|
|
238
|
-
this.
|
|
166
|
+
this.personType = account_enum_1.PaymentAccountPersonTypeEnum.INDIVIDUAL;
|
|
167
|
+
this.address = new PaymentAccountAddressRequestValidator();
|
|
239
168
|
}
|
|
240
169
|
}
|
|
170
|
+
__decorate([
|
|
171
|
+
(0, class_validator_1.IsEnum)(account_enum_1.PaymentAccountPersonTypeEnum),
|
|
172
|
+
__metadata("design:type", String)
|
|
173
|
+
], CreatePaymentAccountRequestValidator.prototype, "personType", void 0);
|
|
241
174
|
__decorate([
|
|
242
175
|
(0, class_validator_1.IsString)(),
|
|
243
|
-
(0, class_validator_1.Length)(2,
|
|
176
|
+
(0, class_validator_1.Length)(2, 120),
|
|
244
177
|
(0, class_transformer_1.Transform)(shipping_request_validator_1.trim),
|
|
245
178
|
__metadata("design:type", String)
|
|
246
|
-
],
|
|
179
|
+
], CreatePaymentAccountRequestValidator.prototype, "name", void 0);
|
|
247
180
|
__decorate([
|
|
248
|
-
(
|
|
249
|
-
(0,
|
|
181
|
+
IsAccountDocument(),
|
|
182
|
+
(0, class_transformer_1.Transform)(shipping_request_validator_1.digits),
|
|
183
|
+
__metadata("design:type", String)
|
|
184
|
+
], CreatePaymentAccountRequestValidator.prototype, "cpfCnpj", void 0);
|
|
185
|
+
__decorate([
|
|
186
|
+
(0, class_validator_1.ValidateIf)(isIndividual),
|
|
187
|
+
(0, shipping_request_validator_1.IsBirthday)(),
|
|
250
188
|
(0, class_transformer_1.Transform)(shipping_request_validator_1.trim),
|
|
251
189
|
__metadata("design:type", String)
|
|
252
|
-
],
|
|
190
|
+
], CreatePaymentAccountRequestValidator.prototype, "birthDate", void 0);
|
|
191
|
+
__decorate([
|
|
192
|
+
(0, class_validator_1.ValidateIf)(isCompany),
|
|
193
|
+
(0, class_validator_1.IsEnum)(account_enum_1.PaymentAccountCompanyTypeEnum),
|
|
194
|
+
__metadata("design:type", String)
|
|
195
|
+
], CreatePaymentAccountRequestValidator.prototype, "companyType", void 0);
|
|
196
|
+
export class UpdatePaymentAccountRequestValidator extends abstract_validator_1.AbstractRequestValidator {
|
|
197
|
+
email;
|
|
198
|
+
mobilePhone;
|
|
199
|
+
phone;
|
|
200
|
+
incomeValue;
|
|
201
|
+
site;
|
|
202
|
+
birthDate;
|
|
203
|
+
companyType;
|
|
204
|
+
address;
|
|
205
|
+
}
|
|
253
206
|
__decorate([
|
|
254
207
|
(0, class_validator_1.IsEmail)(),
|
|
255
208
|
(0, class_validator_1.Length)(3, 254),
|
|
209
|
+
(0, class_validator_1.IsOptional)(),
|
|
256
210
|
(0, class_transformer_1.Transform)(lower),
|
|
257
211
|
__metadata("design:type", String)
|
|
258
|
-
],
|
|
212
|
+
], UpdatePaymentAccountRequestValidator.prototype, "email", void 0);
|
|
259
213
|
__decorate([
|
|
260
|
-
|
|
214
|
+
(0, class_validator_1.Matches)(/^\d{10,11}$/, { message: '$property must be the DDD and number (10 or 11 digits)' }),
|
|
215
|
+
(0, class_validator_1.IsOptional)(),
|
|
261
216
|
(0, class_transformer_1.Transform)(shipping_request_validator_1.digits),
|
|
262
217
|
__metadata("design:type", String)
|
|
263
|
-
],
|
|
218
|
+
], UpdatePaymentAccountRequestValidator.prototype, "mobilePhone", void 0);
|
|
264
219
|
__decorate([
|
|
265
|
-
(0, class_validator_1.
|
|
220
|
+
(0, class_validator_1.Matches)(/^\d{10,11}$/, { message: '$property must be the DDD and number (10 or 11 digits)' }),
|
|
266
221
|
(0, class_validator_1.IsOptional)(),
|
|
267
|
-
(0, class_transformer_1.Transform)(shipping_request_validator_1.
|
|
222
|
+
(0, class_transformer_1.Transform)(shipping_request_validator_1.digits),
|
|
268
223
|
__metadata("design:type", String)
|
|
269
|
-
],
|
|
224
|
+
], UpdatePaymentAccountRequestValidator.prototype, "phone", void 0);
|
|
270
225
|
__decorate([
|
|
271
226
|
(0, class_validator_1.IsInt)(),
|
|
272
227
|
(0, class_validator_1.Min)(1),
|
|
228
|
+
(0, class_validator_1.IsOptional)(),
|
|
273
229
|
__metadata("design:type", Number)
|
|
274
|
-
],
|
|
230
|
+
], UpdatePaymentAccountRequestValidator.prototype, "incomeValue", void 0);
|
|
275
231
|
__decorate([
|
|
276
|
-
(0, class_validator_1.
|
|
277
|
-
(0, class_validator_1.Length)(2, 40),
|
|
232
|
+
(0, class_validator_1.IsUrl)({ require_protocol: true }),
|
|
278
233
|
(0, class_validator_1.IsOptional)(),
|
|
279
|
-
(0, class_transformer_1.Transform)(shipping_request_validator_1.
|
|
234
|
+
(0, class_transformer_1.Transform)(shipping_request_validator_1.trim),
|
|
280
235
|
__metadata("design:type", String)
|
|
281
|
-
],
|
|
236
|
+
], UpdatePaymentAccountRequestValidator.prototype, "site", void 0);
|
|
282
237
|
__decorate([
|
|
283
|
-
|
|
238
|
+
(0, shipping_request_validator_1.IsBirthday)(),
|
|
284
239
|
(0, class_validator_1.IsOptional)(),
|
|
285
240
|
(0, class_transformer_1.Transform)(shipping_request_validator_1.trim),
|
|
286
241
|
__metadata("design:type", String)
|
|
287
|
-
],
|
|
288
|
-
__decorate([
|
|
289
|
-
(0, class_validator_1.IsDefined)(),
|
|
290
|
-
(0, class_validator_1.ValidateNested)(),
|
|
291
|
-
(0, class_transformer_1.Type)(() => PaymentRecipientPartnerRequestValidator),
|
|
292
|
-
__metadata("design:type", PaymentRecipientPartnerRequestValidator)
|
|
293
|
-
], PaymentRecipientCorporationRequestValidator.prototype, "partner", void 0);
|
|
294
|
-
export class PaymentRecipientBankAccountRequestValidator extends abstract_validator_1.AbstractRequestValidator {
|
|
295
|
-
bank;
|
|
296
|
-
branchNumber;
|
|
297
|
-
branchCheckDigit;
|
|
298
|
-
accountNumber;
|
|
299
|
-
accountCheckDigit;
|
|
300
|
-
type;
|
|
301
|
-
}
|
|
302
|
-
__decorate([
|
|
303
|
-
(0, class_validator_1.Matches)(/^\d{3}$/, { message: '$property must be the 3 digit bank code' }),
|
|
304
|
-
(0, class_transformer_1.Transform)(shipping_request_validator_1.digits),
|
|
305
|
-
__metadata("design:type", String)
|
|
306
|
-
], PaymentRecipientBankAccountRequestValidator.prototype, "bank", void 0);
|
|
307
|
-
__decorate([
|
|
308
|
-
(0, class_validator_1.Matches)(/^\d{1,4}$/, { message: '$property must have up to 4 digits' }),
|
|
309
|
-
(0, class_transformer_1.Transform)(shipping_request_validator_1.digits),
|
|
310
|
-
__metadata("design:type", String)
|
|
311
|
-
], PaymentRecipientBankAccountRequestValidator.prototype, "branchNumber", void 0);
|
|
242
|
+
], UpdatePaymentAccountRequestValidator.prototype, "birthDate", void 0);
|
|
312
243
|
__decorate([
|
|
313
|
-
(0, class_validator_1.
|
|
244
|
+
(0, class_validator_1.IsEnum)(account_enum_1.PaymentAccountCompanyTypeEnum),
|
|
314
245
|
(0, class_validator_1.IsOptional)(),
|
|
315
|
-
(0, class_transformer_1.Transform)(shipping_request_validator_1.upper),
|
|
316
246
|
__metadata("design:type", String)
|
|
317
|
-
],
|
|
247
|
+
], UpdatePaymentAccountRequestValidator.prototype, "companyType", void 0);
|
|
318
248
|
__decorate([
|
|
319
|
-
(0, class_validator_1.
|
|
320
|
-
(0, class_transformer_1.Transform)(shipping_request_validator_1.digits),
|
|
321
|
-
__metadata("design:type", String)
|
|
322
|
-
], PaymentRecipientBankAccountRequestValidator.prototype, "accountNumber", void 0);
|
|
323
|
-
__decorate([
|
|
324
|
-
(0, class_validator_1.Matches)(/^[0-9xX]{1,2}$/, { message: '$property must be 1 or 2 digits' }),
|
|
325
|
-
(0, class_transformer_1.Transform)(shipping_request_validator_1.upper),
|
|
326
|
-
__metadata("design:type", String)
|
|
327
|
-
], PaymentRecipientBankAccountRequestValidator.prototype, "accountCheckDigit", void 0);
|
|
328
|
-
__decorate([
|
|
329
|
-
(0, class_validator_1.IsEnum)(recipient_enum_1.PaymentBankAccountTypeEnum),
|
|
330
|
-
__metadata("design:type", String)
|
|
331
|
-
], PaymentRecipientBankAccountRequestValidator.prototype, "type", void 0);
|
|
332
|
-
export class PaymentRecipientTransferSettingsRequestValidator extends abstract_validator_1.AbstractRequestValidator {
|
|
333
|
-
interval;
|
|
334
|
-
day;
|
|
335
|
-
constructor() {
|
|
336
|
-
super();
|
|
337
|
-
this.interval = recipient_enum_1.PaymentTransferIntervalEnum.DAILY;
|
|
338
|
-
this.day = 0;
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
__decorate([
|
|
342
|
-
(0, class_validator_1.IsEnum)(recipient_enum_1.PaymentTransferIntervalEnum),
|
|
343
|
-
__metadata("design:type", String)
|
|
344
|
-
], PaymentRecipientTransferSettingsRequestValidator.prototype, "interval", void 0);
|
|
345
|
-
__decorate([
|
|
346
|
-
(0, class_validator_1.IsInt)(),
|
|
347
|
-
(0, class_validator_1.Min)(0),
|
|
348
|
-
(0, class_validator_1.Max)(31),
|
|
349
|
-
IsTransferDay(),
|
|
350
|
-
__metadata("design:type", Number)
|
|
351
|
-
], PaymentRecipientTransferSettingsRequestValidator.prototype, "day", void 0);
|
|
352
|
-
export class CreatePaymentRecipientRequestValidator extends abstract_validator_1.AbstractRequestValidator {
|
|
353
|
-
type;
|
|
354
|
-
individual;
|
|
355
|
-
corporation;
|
|
356
|
-
address;
|
|
357
|
-
phone;
|
|
358
|
-
bankAccount;
|
|
359
|
-
transferSettings;
|
|
360
|
-
constructor() {
|
|
361
|
-
super();
|
|
362
|
-
this.type = recipient_enum_1.PaymentRecipientTypeEnum.INDIVIDUAL;
|
|
363
|
-
this.individual = new PaymentRecipientIndividualRequestValidator();
|
|
364
|
-
this.corporation = new PaymentRecipientCorporationRequestValidator();
|
|
365
|
-
this.address = new PaymentRecipientAddressRequestValidator();
|
|
366
|
-
this.phone = new PaymentRecipientPhoneRequestValidator();
|
|
367
|
-
this.bankAccount = new PaymentRecipientBankAccountRequestValidator();
|
|
368
|
-
this.transferSettings = new PaymentRecipientTransferSettingsRequestValidator();
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
__decorate([
|
|
372
|
-
(0, class_validator_1.IsEnum)(recipient_enum_1.PaymentRecipientTypeEnum),
|
|
373
|
-
__metadata("design:type", String)
|
|
374
|
-
], CreatePaymentRecipientRequestValidator.prototype, "type", void 0);
|
|
375
|
-
__decorate([
|
|
376
|
-
(0, class_validator_1.ValidateIf)((body) => body.type === recipient_enum_1.PaymentRecipientTypeEnum.INDIVIDUAL),
|
|
377
|
-
(0, class_validator_1.IsDefined)(),
|
|
378
|
-
(0, class_validator_1.ValidateNested)(),
|
|
379
|
-
(0, class_transformer_1.Type)(() => PaymentRecipientIndividualRequestValidator),
|
|
380
|
-
__metadata("design:type", PaymentRecipientIndividualRequestValidator)
|
|
381
|
-
], CreatePaymentRecipientRequestValidator.prototype, "individual", void 0);
|
|
382
|
-
__decorate([
|
|
383
|
-
(0, class_validator_1.ValidateIf)((body) => body.type === recipient_enum_1.PaymentRecipientTypeEnum.CORPORATION),
|
|
384
|
-
(0, class_validator_1.IsDefined)(),
|
|
385
|
-
(0, class_validator_1.ValidateNested)(),
|
|
386
|
-
(0, class_transformer_1.Type)(() => PaymentRecipientCorporationRequestValidator),
|
|
387
|
-
__metadata("design:type", PaymentRecipientCorporationRequestValidator)
|
|
388
|
-
], CreatePaymentRecipientRequestValidator.prototype, "corporation", void 0);
|
|
389
|
-
__decorate([
|
|
390
|
-
(0, class_validator_1.IsDefined)(),
|
|
391
|
-
(0, class_validator_1.ValidateNested)(),
|
|
392
|
-
(0, class_transformer_1.Type)(() => PaymentRecipientAddressRequestValidator),
|
|
393
|
-
__metadata("design:type", PaymentRecipientAddressRequestValidator)
|
|
394
|
-
], CreatePaymentRecipientRequestValidator.prototype, "address", void 0);
|
|
395
|
-
__decorate([
|
|
396
|
-
(0, class_validator_1.IsDefined)(),
|
|
397
|
-
(0, class_validator_1.ValidateNested)(),
|
|
398
|
-
(0, class_transformer_1.Type)(() => PaymentRecipientPhoneRequestValidator),
|
|
399
|
-
__metadata("design:type", PaymentRecipientPhoneRequestValidator)
|
|
400
|
-
], CreatePaymentRecipientRequestValidator.prototype, "phone", void 0);
|
|
401
|
-
__decorate([
|
|
402
|
-
(0, class_validator_1.IsDefined)(),
|
|
403
|
-
(0, class_validator_1.ValidateNested)(),
|
|
404
|
-
(0, class_transformer_1.Type)(() => PaymentRecipientBankAccountRequestValidator),
|
|
405
|
-
__metadata("design:type", PaymentRecipientBankAccountRequestValidator)
|
|
406
|
-
], CreatePaymentRecipientRequestValidator.prototype, "bankAccount", void 0);
|
|
407
|
-
__decorate([
|
|
408
|
-
(0, class_validator_1.IsDefined)(),
|
|
249
|
+
(0, class_validator_1.IsOptional)(),
|
|
409
250
|
(0, class_validator_1.ValidateNested)(),
|
|
410
|
-
(0, class_transformer_1.Type)(() =>
|
|
411
|
-
__metadata("design:type",
|
|
412
|
-
],
|
|
413
|
-
export class
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
251
|
+
(0, class_transformer_1.Type)(() => PaymentAccountAddressRequestValidator),
|
|
252
|
+
__metadata("design:type", PaymentAccountAddressRequestValidator)
|
|
253
|
+
], UpdatePaymentAccountRequestValidator.prototype, "address", void 0);
|
|
254
|
+
export class UpdatePaymentWithdrawalRequestValidator extends abstract_validator_1.AbstractRequestValidator {
|
|
255
|
+
pixKeyType;
|
|
256
|
+
pixKey;
|
|
257
|
+
automatic;
|
|
417
258
|
}
|
|
418
259
|
__decorate([
|
|
419
|
-
(0, class_validator_1.
|
|
420
|
-
(0, class_validator_1.Length)(2, 200),
|
|
421
|
-
(0, class_validator_1.IsOptional)(),
|
|
422
|
-
(0, class_transformer_1.Transform)(shipping_request_validator_1.trim),
|
|
260
|
+
(0, class_validator_1.IsEnum)(account_enum_1.PaymentPixKeyTypeEnum),
|
|
423
261
|
__metadata("design:type", String)
|
|
424
|
-
],
|
|
262
|
+
], UpdatePaymentWithdrawalRequestValidator.prototype, "pixKeyType", void 0);
|
|
425
263
|
__decorate([
|
|
426
|
-
(
|
|
427
|
-
(0,
|
|
428
|
-
(0, class_validator_1.IsOptional)(),
|
|
429
|
-
(0, class_transformer_1.Transform)(lower),
|
|
264
|
+
IsPixKey(),
|
|
265
|
+
(0, class_transformer_1.Transform)(pixKey),
|
|
430
266
|
__metadata("design:type", String)
|
|
431
|
-
],
|
|
267
|
+
], UpdatePaymentWithdrawalRequestValidator.prototype, "pixKey", void 0);
|
|
432
268
|
__decorate([
|
|
269
|
+
(0, class_validator_1.IsBoolean)(),
|
|
433
270
|
(0, class_validator_1.IsOptional)(),
|
|
434
|
-
(
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
export class UpdatePaymentTransferSettingsRequestValidator extends PaymentRecipientTransferSettingsRequestValidator {
|
|
271
|
+
__metadata("design:type", Boolean)
|
|
272
|
+
], UpdatePaymentWithdrawalRequestValidator.prototype, "automatic", void 0);
|
|
273
|
+
export class CreatePaymentWithdrawalRequestValidator extends abstract_validator_1.AbstractRequestValidator {
|
|
274
|
+
amount;
|
|
439
275
|
}
|
|
276
|
+
__decorate([
|
|
277
|
+
(0, class_validator_1.IsInt)(),
|
|
278
|
+
(0, class_validator_1.Min)(1),
|
|
279
|
+
(0, class_validator_1.IsOptional)(),
|
|
280
|
+
__metadata("design:type", Number)
|
|
281
|
+
], CreatePaymentWithdrawalRequestValidator.prototype, "amount", void 0);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { OrderSaleAttentionEnum } from './attention.enum.js';
|
|
2
|
+
import type { OrderFulfillmentStageEnum } from './fulfillment.enum.js';
|
|
3
|
+
export interface OrderSaleAttentionSummary {
|
|
4
|
+
attention: Record<OrderSaleAttentionEnum, number>;
|
|
5
|
+
stages: Record<OrderFulfillmentStageEnum, number>;
|
|
6
|
+
shipmentDelayDays: number;
|
|
7
|
+
paymentConfirmDays: number;
|
|
8
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare enum OrderSaleAttentionEnum {
|
|
2
|
+
SUPPLIER_ORDER_FAILED = "SUPPLIER_ORDER_FAILED",
|
|
3
|
+
SUPPLIER_PAYMENT_PENDING = "SUPPLIER_PAYMENT_PENDING",
|
|
4
|
+
TO_ORDER = "TO_ORDER",
|
|
5
|
+
PAYMENT_TO_CONFIRM = "PAYMENT_TO_CONFIRM",
|
|
6
|
+
SHIPMENT_DELAYED = "SHIPMENT_DELAYED"
|
|
7
|
+
}
|
|
8
|
+
export declare const SALE_SHIPMENT_DELAY_DAYS = 7;
|
|
9
|
+
export declare const SALE_PAYMENT_CONFIRM_DAYS = 7;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export var OrderSaleAttentionEnum;
|
|
2
|
+
(function (OrderSaleAttentionEnum) {
|
|
3
|
+
OrderSaleAttentionEnum["SUPPLIER_ORDER_FAILED"] = "SUPPLIER_ORDER_FAILED";
|
|
4
|
+
OrderSaleAttentionEnum["SUPPLIER_PAYMENT_PENDING"] = "SUPPLIER_PAYMENT_PENDING";
|
|
5
|
+
OrderSaleAttentionEnum["TO_ORDER"] = "TO_ORDER";
|
|
6
|
+
OrderSaleAttentionEnum["PAYMENT_TO_CONFIRM"] = "PAYMENT_TO_CONFIRM";
|
|
7
|
+
OrderSaleAttentionEnum["SHIPMENT_DELAYED"] = "SHIPMENT_DELAYED";
|
|
8
|
+
})(OrderSaleAttentionEnum || (OrderSaleAttentionEnum = {}));
|
|
9
|
+
export const SALE_SHIPMENT_DELAY_DAYS = 7;
|
|
10
|
+
export const SALE_PAYMENT_CONFIRM_DAYS = 7;
|
package/dist/order/sale/index.js
CHANGED
|
@@ -8,6 +8,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
+
import * as brazilian_utils_1 from "@brazilian-utils/brazilian-utils";
|
|
11
12
|
import * as class_transformer_1 from "class-transformer";
|
|
12
13
|
import * as class_validator_1 from "class-validator";
|
|
13
14
|
import * as abstract_validator_1 from '../../abstract.validator.js';
|
|
@@ -44,17 +45,7 @@ const trim = ({ value }) => typeof value === 'string' ? value.trim() : value;
|
|
|
44
45
|
const digits = ({ value }) => typeof value === 'string' ? value.replace(/\D/g, '') : value;
|
|
45
46
|
const upper = ({ value }) => typeof value === 'string' ? value.trim().toUpperCase() : value;
|
|
46
47
|
export function isCpf(value) {
|
|
47
|
-
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
const digit = (length) => {
|
|
51
|
-
const sum = value
|
|
52
|
-
.slice(0, length)
|
|
53
|
-
.split('')
|
|
54
|
-
.reduce((acc, char, index) => acc + Number(char) * (length + 1 - index), 0);
|
|
55
|
-
return ((sum * 10) % 11) % 10;
|
|
56
|
-
};
|
|
57
|
-
return digit(9) === Number(value[9]) && digit(10) === Number(value[10]);
|
|
48
|
+
return typeof value === 'string' && /^\d{11}$/.test(value) && (0, brazilian_utils_1.isValidCpf)(value);
|
|
58
49
|
}
|
|
59
50
|
export function IsCpf() {
|
|
60
51
|
return (0, class_validator_1.ValidateBy)({
|