@merkaly/api 0.22.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/app.schemas.d.ts +1 -0
- 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/index.d.ts +1 -0
- package/dist/index.js +1 -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 +9 -0
- package/dist/integration/payment/index.js +5 -0
- package/dist/integration/payment/payment.account.entity.d.ts +68 -0
- package/dist/integration/payment/payment.entity.d.ts +8 -0
- package/dist/integration/payment/provider.enum.d.ts +3 -0
- package/dist/integration/payment/provider.enum.js +4 -0
- package/dist/integration/payment/request.validator.d.ts +47 -0
- package/dist/integration/payment/request.validator.js +281 -0
- 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/app.schemas.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { AbstractEntity } from '../../abstract.entity.js';
|
|
|
4
4
|
import { StatusEntity } from '../../status.plugin.js';
|
|
5
5
|
import { ITransitionable } from '../../transitionable.interface.js';
|
|
6
6
|
import { FinancePaymentMethodEnum, FinancePaymentStatusEnum, FinancePaymentTypeEnum } from './payment.enum.js';
|
|
7
|
+
import { FinancePaymentGatewayEntity } from './payment.gateway.entity.js';
|
|
7
8
|
export type OrderEntity = OrderSaleEntity | OrderPurchaseEntity;
|
|
8
9
|
export declare class FinancePaymentEntity extends AbstractEntity implements ITransitionable<FinancePaymentStatusEnum> {
|
|
9
10
|
type: FinancePaymentTypeEnum;
|
|
@@ -12,6 +13,7 @@ export declare class FinancePaymentEntity extends AbstractEntity implements ITra
|
|
|
12
13
|
amount: number;
|
|
13
14
|
fee: number;
|
|
14
15
|
method?: FinancePaymentMethodEnum | null;
|
|
16
|
+
gateway?: FinancePaymentGatewayEntity | null;
|
|
15
17
|
status: FinancePaymentStatusEnum;
|
|
16
18
|
history: StatusEntity<FinancePaymentStatusEnum>[];
|
|
17
19
|
readonly number: string;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Schema as MongoSchema } from 'mongoose';
|
|
2
|
+
import { FinancePaymentMethodEnum } from './payment.enum.js';
|
|
3
|
+
export declare class FinancePaymentGatewayPixEntity {
|
|
4
|
+
qrCode?: string | null;
|
|
5
|
+
qrCodeImage?: string | null;
|
|
6
|
+
}
|
|
7
|
+
export declare const FinancePaymentGatewayPixSchema: MongoSchema<FinancePaymentGatewayPixEntity, import("mongoose").Model<FinancePaymentGatewayPixEntity, any, any, any, import("mongoose").Document<unknown, any, FinancePaymentGatewayPixEntity, any, {}> & FinancePaymentGatewayPixEntity & {
|
|
8
|
+
_id: import("mongoose").Types.ObjectId;
|
|
9
|
+
} & {
|
|
10
|
+
__v: number;
|
|
11
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, FinancePaymentGatewayPixEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<FinancePaymentGatewayPixEntity>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<FinancePaymentGatewayPixEntity> & {
|
|
12
|
+
_id: import("mongoose").Types.ObjectId;
|
|
13
|
+
} & {
|
|
14
|
+
__v: number;
|
|
15
|
+
}>;
|
|
16
|
+
export declare class FinancePaymentGatewayCardEntity {
|
|
17
|
+
brand?: string | null;
|
|
18
|
+
last4?: string | null;
|
|
19
|
+
}
|
|
20
|
+
export declare const FinancePaymentGatewayCardSchema: MongoSchema<FinancePaymentGatewayCardEntity, import("mongoose").Model<FinancePaymentGatewayCardEntity, any, any, any, import("mongoose").Document<unknown, any, FinancePaymentGatewayCardEntity, any, {}> & FinancePaymentGatewayCardEntity & {
|
|
21
|
+
_id: import("mongoose").Types.ObjectId;
|
|
22
|
+
} & {
|
|
23
|
+
__v: number;
|
|
24
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, FinancePaymentGatewayCardEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<FinancePaymentGatewayCardEntity>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<FinancePaymentGatewayCardEntity> & {
|
|
25
|
+
_id: import("mongoose").Types.ObjectId;
|
|
26
|
+
} & {
|
|
27
|
+
__v: number;
|
|
28
|
+
}>;
|
|
29
|
+
export declare class FinancePaymentGatewayEntity {
|
|
30
|
+
provider: string;
|
|
31
|
+
reference?: string | null;
|
|
32
|
+
method: FinancePaymentMethodEnum;
|
|
33
|
+
status: string;
|
|
34
|
+
message?: string | null;
|
|
35
|
+
attempt: number;
|
|
36
|
+
cardAttempts: number;
|
|
37
|
+
amount: number;
|
|
38
|
+
pix?: FinancePaymentGatewayPixEntity | null;
|
|
39
|
+
card?: FinancePaymentGatewayCardEntity | null;
|
|
40
|
+
expiresAt?: Date | null;
|
|
41
|
+
syncedAt: Date;
|
|
42
|
+
}
|
|
43
|
+
export declare const FinancePaymentGatewaySchema: MongoSchema<FinancePaymentGatewayEntity, import("mongoose").Model<FinancePaymentGatewayEntity, any, any, any, import("mongoose").Document<unknown, any, FinancePaymentGatewayEntity, any, {}> & FinancePaymentGatewayEntity & {
|
|
44
|
+
_id: import("mongoose").Types.ObjectId;
|
|
45
|
+
} & {
|
|
46
|
+
__v: number;
|
|
47
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, FinancePaymentGatewayEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<FinancePaymentGatewayEntity>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<FinancePaymentGatewayEntity> & {
|
|
48
|
+
_id: import("mongoose").Types.ObjectId;
|
|
49
|
+
} & {
|
|
50
|
+
__v: number;
|
|
51
|
+
}>;
|
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export * from './contact/customer';
|
|
|
17
17
|
export * from './contact/vendor';
|
|
18
18
|
export * from './finance/payment';
|
|
19
19
|
export * from './integration/supplier';
|
|
20
|
+
export * from './integration/payment';
|
|
20
21
|
export * from './inventory/catalog/brand';
|
|
21
22
|
export * from './inventory/catalog/category';
|
|
22
23
|
export * from './inventory/catalog/product';
|
package/dist/index.js
CHANGED
|
@@ -9,6 +9,7 @@ export * from './contact/customer/index.js';
|
|
|
9
9
|
export * from './contact/vendor/index.js';
|
|
10
10
|
export * from './finance/payment/index.js';
|
|
11
11
|
export * from './integration/supplier/index.js';
|
|
12
|
+
export * from './integration/payment/index.js';
|
|
12
13
|
export * from './inventory/catalog/brand/index.js';
|
|
13
14
|
export * from './inventory/catalog/category/index.js';
|
|
14
15
|
export * from './inventory/catalog/product/index.js';
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { PaymentAccountApprovalEnum, PaymentAccountCompanyTypeEnum, PaymentAccountDocumentStatusEnum, PaymentAccountPersonTypeEnum, PaymentPixKeyTypeEnum } from './account.enum.js';
|
|
2
|
+
import type { PaymentProviderEnum } from './provider.enum.js';
|
|
3
|
+
export interface PaymentAccountApproval {
|
|
4
|
+
general: PaymentAccountApprovalEnum;
|
|
5
|
+
commercialInfo: PaymentAccountApprovalEnum;
|
|
6
|
+
documentation: PaymentAccountApprovalEnum;
|
|
7
|
+
bankAccountInfo: PaymentAccountApprovalEnum;
|
|
8
|
+
}
|
|
9
|
+
export interface PaymentAccountWithdrawal {
|
|
10
|
+
pixKeyType: PaymentPixKeyTypeEnum;
|
|
11
|
+
pixKeyMasked: string;
|
|
12
|
+
automatic: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface PaymentAccountSummary {
|
|
15
|
+
accountId: string;
|
|
16
|
+
walletId: string;
|
|
17
|
+
personType: PaymentAccountPersonTypeEnum;
|
|
18
|
+
documentMasked: string;
|
|
19
|
+
name: string;
|
|
20
|
+
email: string;
|
|
21
|
+
approval: PaymentAccountApproval | null;
|
|
22
|
+
withdrawal: PaymentAccountWithdrawal | null;
|
|
23
|
+
createdAt: Date;
|
|
24
|
+
syncedAt: Date;
|
|
25
|
+
}
|
|
26
|
+
export interface PaymentAccountStatus {
|
|
27
|
+
configured: boolean;
|
|
28
|
+
connected: boolean;
|
|
29
|
+
provider: PaymentProviderEnum;
|
|
30
|
+
account: PaymentAccountSummary | null;
|
|
31
|
+
canSell: boolean;
|
|
32
|
+
canWithdraw: boolean;
|
|
33
|
+
kycAction: boolean;
|
|
34
|
+
pixReady: boolean;
|
|
35
|
+
warnings: string[];
|
|
36
|
+
accountError: string | null;
|
|
37
|
+
}
|
|
38
|
+
export interface PaymentAccountDocument {
|
|
39
|
+
id: string;
|
|
40
|
+
type: string | null;
|
|
41
|
+
title: string | null;
|
|
42
|
+
description: string | null;
|
|
43
|
+
status: PaymentAccountDocumentStatusEnum;
|
|
44
|
+
onboardingUrl: string | null;
|
|
45
|
+
onboardingUrlExpiresAt: Date | null;
|
|
46
|
+
}
|
|
47
|
+
export interface PaymentAccountOnboarding {
|
|
48
|
+
documents: PaymentAccountDocument[];
|
|
49
|
+
rejectReasons: string | null;
|
|
50
|
+
}
|
|
51
|
+
export interface PaymentAccountBalance {
|
|
52
|
+
balance: number;
|
|
53
|
+
}
|
|
54
|
+
export interface PaymentAccountTransfer {
|
|
55
|
+
id: string;
|
|
56
|
+
amount: number;
|
|
57
|
+
fee: number | null;
|
|
58
|
+
status: string;
|
|
59
|
+
failReason: string | null;
|
|
60
|
+
createdAt: Date | null;
|
|
61
|
+
}
|
|
62
|
+
export interface PaymentAccountCommercialInfo {
|
|
63
|
+
personType: PaymentAccountPersonTypeEnum;
|
|
64
|
+
cpfCnpj: string;
|
|
65
|
+
name: string | null;
|
|
66
|
+
companyName: string | null;
|
|
67
|
+
companyType: PaymentAccountCompanyTypeEnum | null;
|
|
68
|
+
birthDate: string | null;
|
|
69
|
+
email: string | null;
|
|
70
|
+
mobilePhone: string | null;
|
|
71
|
+
phone: string | null;
|
|
72
|
+
incomeValue: number | null;
|
|
73
|
+
site: string | null;
|
|
74
|
+
address: {
|
|
75
|
+
postalCode: string | null;
|
|
76
|
+
street: string | null;
|
|
77
|
+
number: string | null;
|
|
78
|
+
complement: string | null;
|
|
79
|
+
district: string | null;
|
|
80
|
+
city: string | null;
|
|
81
|
+
state: string | null;
|
|
82
|
+
};
|
|
83
|
+
status: PaymentAccountApprovalEnum | null;
|
|
84
|
+
denialReason: string | null;
|
|
85
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare enum PaymentAccountApprovalEnum {
|
|
2
|
+
PENDING = "PENDING",
|
|
3
|
+
AWAITING_APPROVAL = "AWAITING_APPROVAL",
|
|
4
|
+
APPROVED = "APPROVED",
|
|
5
|
+
REJECTED = "REJECTED"
|
|
6
|
+
}
|
|
7
|
+
export declare enum PaymentAccountPersonTypeEnum {
|
|
8
|
+
INDIVIDUAL = "INDIVIDUAL",
|
|
9
|
+
COMPANY = "COMPANY"
|
|
10
|
+
}
|
|
11
|
+
export declare enum PaymentAccountCompanyTypeEnum {
|
|
12
|
+
MEI = "MEI",
|
|
13
|
+
LIMITED = "LIMITED",
|
|
14
|
+
INDIVIDUAL = "INDIVIDUAL",
|
|
15
|
+
ASSOCIATION = "ASSOCIATION"
|
|
16
|
+
}
|
|
17
|
+
export declare enum PaymentAccountDocumentStatusEnum {
|
|
18
|
+
NOT_SENT = "NOT_SENT",
|
|
19
|
+
PENDING = "PENDING",
|
|
20
|
+
APPROVED = "APPROVED",
|
|
21
|
+
REJECTED = "REJECTED",
|
|
22
|
+
IGNORED = "IGNORED"
|
|
23
|
+
}
|
|
24
|
+
export declare enum PaymentPixKeyTypeEnum {
|
|
25
|
+
CPF = "CPF",
|
|
26
|
+
CNPJ = "CNPJ",
|
|
27
|
+
EMAIL = "EMAIL",
|
|
28
|
+
PHONE = "PHONE",
|
|
29
|
+
EVP = "EVP"
|
|
30
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export var PaymentAccountApprovalEnum;
|
|
2
|
+
(function (PaymentAccountApprovalEnum) {
|
|
3
|
+
PaymentAccountApprovalEnum["PENDING"] = "PENDING";
|
|
4
|
+
PaymentAccountApprovalEnum["AWAITING_APPROVAL"] = "AWAITING_APPROVAL";
|
|
5
|
+
PaymentAccountApprovalEnum["APPROVED"] = "APPROVED";
|
|
6
|
+
PaymentAccountApprovalEnum["REJECTED"] = "REJECTED";
|
|
7
|
+
})(PaymentAccountApprovalEnum || (PaymentAccountApprovalEnum = {}));
|
|
8
|
+
export var PaymentAccountPersonTypeEnum;
|
|
9
|
+
(function (PaymentAccountPersonTypeEnum) {
|
|
10
|
+
PaymentAccountPersonTypeEnum["INDIVIDUAL"] = "INDIVIDUAL";
|
|
11
|
+
PaymentAccountPersonTypeEnum["COMPANY"] = "COMPANY";
|
|
12
|
+
})(PaymentAccountPersonTypeEnum || (PaymentAccountPersonTypeEnum = {}));
|
|
13
|
+
export var PaymentAccountCompanyTypeEnum;
|
|
14
|
+
(function (PaymentAccountCompanyTypeEnum) {
|
|
15
|
+
PaymentAccountCompanyTypeEnum["MEI"] = "MEI";
|
|
16
|
+
PaymentAccountCompanyTypeEnum["LIMITED"] = "LIMITED";
|
|
17
|
+
PaymentAccountCompanyTypeEnum["INDIVIDUAL"] = "INDIVIDUAL";
|
|
18
|
+
PaymentAccountCompanyTypeEnum["ASSOCIATION"] = "ASSOCIATION";
|
|
19
|
+
})(PaymentAccountCompanyTypeEnum || (PaymentAccountCompanyTypeEnum = {}));
|
|
20
|
+
export var PaymentAccountDocumentStatusEnum;
|
|
21
|
+
(function (PaymentAccountDocumentStatusEnum) {
|
|
22
|
+
PaymentAccountDocumentStatusEnum["NOT_SENT"] = "NOT_SENT";
|
|
23
|
+
PaymentAccountDocumentStatusEnum["PENDING"] = "PENDING";
|
|
24
|
+
PaymentAccountDocumentStatusEnum["APPROVED"] = "APPROVED";
|
|
25
|
+
PaymentAccountDocumentStatusEnum["REJECTED"] = "REJECTED";
|
|
26
|
+
PaymentAccountDocumentStatusEnum["IGNORED"] = "IGNORED";
|
|
27
|
+
})(PaymentAccountDocumentStatusEnum || (PaymentAccountDocumentStatusEnum = {}));
|
|
28
|
+
export var PaymentPixKeyTypeEnum;
|
|
29
|
+
(function (PaymentPixKeyTypeEnum) {
|
|
30
|
+
PaymentPixKeyTypeEnum["CPF"] = "CPF";
|
|
31
|
+
PaymentPixKeyTypeEnum["CNPJ"] = "CNPJ";
|
|
32
|
+
PaymentPixKeyTypeEnum["EMAIL"] = "EMAIL";
|
|
33
|
+
PaymentPixKeyTypeEnum["PHONE"] = "PHONE";
|
|
34
|
+
PaymentPixKeyTypeEnum["EVP"] = "EVP";
|
|
35
|
+
})(PaymentPixKeyTypeEnum || (PaymentPixKeyTypeEnum = {}));
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { PaymentChargeStatusEnum } from './charge.enum.js';
|
|
2
|
+
import type { PaymentProviderEnum } from './provider.enum.js';
|
|
3
|
+
import type { FinancePaymentMethodEnum } from '../../finance/payment';
|
|
4
|
+
export type StorePaymentMethod = FinancePaymentMethodEnum.PIX | FinancePaymentMethodEnum.CARD;
|
|
5
|
+
export interface StorePaymentConfig {
|
|
6
|
+
methods: StorePaymentMethod[];
|
|
7
|
+
provider: PaymentProviderEnum | null;
|
|
8
|
+
}
|
|
9
|
+
export interface PaymentChargeCard {
|
|
10
|
+
brand: string | null;
|
|
11
|
+
last4: string | null;
|
|
12
|
+
}
|
|
13
|
+
export interface PaymentCharge {
|
|
14
|
+
amount: number;
|
|
15
|
+
attempt: number;
|
|
16
|
+
card: PaymentChargeCard | null;
|
|
17
|
+
expiresAt: Date | null;
|
|
18
|
+
method: StorePaymentMethod;
|
|
19
|
+
message: string | null;
|
|
20
|
+
paid: boolean;
|
|
21
|
+
qrCode: string | null;
|
|
22
|
+
qrCodeImage: string | null;
|
|
23
|
+
status: PaymentChargeStatusEnum;
|
|
24
|
+
statusDetail: string | null;
|
|
25
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export var PaymentChargeStatusEnum;
|
|
2
|
+
(function (PaymentChargeStatusEnum) {
|
|
3
|
+
PaymentChargeStatusEnum["PENDING"] = "PENDING";
|
|
4
|
+
PaymentChargeStatusEnum["IN_PROCESS"] = "IN_PROCESS";
|
|
5
|
+
PaymentChargeStatusEnum["APPROVED"] = "APPROVED";
|
|
6
|
+
PaymentChargeStatusEnum["REJECTED"] = "REJECTED";
|
|
7
|
+
PaymentChargeStatusEnum["CANCELLED"] = "CANCELLED";
|
|
8
|
+
PaymentChargeStatusEnum["EXPIRED"] = "EXPIRED";
|
|
9
|
+
PaymentChargeStatusEnum["REFUNDED"] = "REFUNDED";
|
|
10
|
+
})(PaymentChargeStatusEnum || (PaymentChargeStatusEnum = {}));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { AbstractRequestValidator } from '../../abstract.validator.js';
|
|
2
|
+
import type { StorePaymentMethod } from './charge.js';
|
|
3
|
+
export declare function isCardNumber(value: unknown): boolean;
|
|
4
|
+
export declare function isCardExpiry(month: unknown, year: unknown): boolean;
|
|
5
|
+
export declare class PaymentCardRequestValidator extends AbstractRequestValidator {
|
|
6
|
+
holderName: string;
|
|
7
|
+
number: string;
|
|
8
|
+
expiryMonth: string;
|
|
9
|
+
expiryYear: string;
|
|
10
|
+
ccv: string;
|
|
11
|
+
holderDocument?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class CreatePaymentChargeRequestValidator extends AbstractRequestValidator {
|
|
14
|
+
method: StorePaymentMethod;
|
|
15
|
+
card?: PaymentCardRequestValidator;
|
|
16
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
const card_validator_1 = __importDefault(require("card-validator"));
|
|
15
|
+
import * as class_transformer_1 from "class-transformer";
|
|
16
|
+
import * as class_validator_1 from "class-validator";
|
|
17
|
+
import * as payment_enum_1 from '../../finance/payment/index.js';
|
|
18
|
+
import * as shipping_request_validator_1 from '../../order/sale/index.js';
|
|
19
|
+
import * as abstract_validator_1 from '../../abstract.validator.js';
|
|
20
|
+
import * as request_validator_1 from './request.validator.js';
|
|
21
|
+
export function isCardNumber(value) {
|
|
22
|
+
return (typeof value === 'string' && /^\d{13,19}$/.test(value) && card_validator_1.default.number(value).isValid);
|
|
23
|
+
}
|
|
24
|
+
export function isCardExpiry(month, year) {
|
|
25
|
+
if (typeof month !== 'string' || typeof year !== 'string')
|
|
26
|
+
return false;
|
|
27
|
+
return (/^(0[1-9]|1[0-2])$/.test(month) &&
|
|
28
|
+
/^\d{4}$/.test(year) &&
|
|
29
|
+
card_validator_1.default.expirationDate({ month, year }).isValid);
|
|
30
|
+
}
|
|
31
|
+
function IsCardNumber() {
|
|
32
|
+
return (0, class_validator_1.ValidateBy)({
|
|
33
|
+
name: 'isCardNumber',
|
|
34
|
+
validator: {
|
|
35
|
+
defaultMessage: () => 'card.number is not a valid card number',
|
|
36
|
+
validate: isCardNumber,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function IsCardExpiry() {
|
|
41
|
+
return (0, class_validator_1.ValidateBy)({
|
|
42
|
+
name: 'isCardExpiry',
|
|
43
|
+
validator: {
|
|
44
|
+
defaultMessage: () => 'card expiry must be a valid future month (MM and YYYY)',
|
|
45
|
+
validate: (year, args) => isCardExpiry(args.object.expiryMonth, year),
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function IsCpfOrCnpj() {
|
|
50
|
+
return (0, class_validator_1.ValidateBy)({
|
|
51
|
+
name: 'isCpfOrCnpj',
|
|
52
|
+
validator: {
|
|
53
|
+
defaultMessage: () => '$property must be a valid CPF or CNPJ',
|
|
54
|
+
validate: (value) => (0, shipping_request_validator_1.isCpf)(value) || (0, request_validator_1.isCnpj)(value),
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const twoDigits = ({ value }) => typeof value === 'number' ? String(value).padStart(2, '0') : (0, shipping_request_validator_1.digits)({ value });
|
|
59
|
+
const fourDigits = ({ value }) => {
|
|
60
|
+
const year = typeof value === 'number' ? String(value) : (0, shipping_request_validator_1.digits)({ value });
|
|
61
|
+
return typeof year === 'string' && year.length === 2 ? `20${year}` : year;
|
|
62
|
+
};
|
|
63
|
+
export class PaymentCardRequestValidator extends abstract_validator_1.AbstractRequestValidator {
|
|
64
|
+
holderName;
|
|
65
|
+
number;
|
|
66
|
+
expiryMonth;
|
|
67
|
+
expiryYear;
|
|
68
|
+
ccv;
|
|
69
|
+
holderDocument;
|
|
70
|
+
}
|
|
71
|
+
__decorate([
|
|
72
|
+
(0, class_validator_1.IsString)(),
|
|
73
|
+
(0, class_validator_1.Length)(2, 100, { message: 'card.holderName must have 2 to 100 characters' }),
|
|
74
|
+
(0, class_transformer_1.Transform)(shipping_request_validator_1.trim),
|
|
75
|
+
__metadata("design:type", String)
|
|
76
|
+
], PaymentCardRequestValidator.prototype, "holderName", void 0);
|
|
77
|
+
__decorate([
|
|
78
|
+
IsCardNumber(),
|
|
79
|
+
(0, class_transformer_1.Transform)(shipping_request_validator_1.digits),
|
|
80
|
+
__metadata("design:type", String)
|
|
81
|
+
], PaymentCardRequestValidator.prototype, "number", void 0);
|
|
82
|
+
__decorate([
|
|
83
|
+
(0, class_validator_1.Matches)(/^(0[1-9]|1[0-2])$/, { message: 'card.expiryMonth must be MM (01 to 12)' }),
|
|
84
|
+
(0, class_transformer_1.Transform)(twoDigits),
|
|
85
|
+
__metadata("design:type", String)
|
|
86
|
+
], PaymentCardRequestValidator.prototype, "expiryMonth", void 0);
|
|
87
|
+
__decorate([
|
|
88
|
+
IsCardExpiry(),
|
|
89
|
+
(0, class_transformer_1.Transform)(fourDigits),
|
|
90
|
+
__metadata("design:type", String)
|
|
91
|
+
], PaymentCardRequestValidator.prototype, "expiryYear", void 0);
|
|
92
|
+
__decorate([
|
|
93
|
+
(0, class_validator_1.Matches)(/^\d{3,4}$/, { message: 'card.ccv must have 3 or 4 digits' }),
|
|
94
|
+
(0, class_transformer_1.Transform)(shipping_request_validator_1.digits),
|
|
95
|
+
__metadata("design:type", String)
|
|
96
|
+
], PaymentCardRequestValidator.prototype, "ccv", void 0);
|
|
97
|
+
__decorate([
|
|
98
|
+
IsCpfOrCnpj(),
|
|
99
|
+
(0, class_validator_1.IsOptional)(),
|
|
100
|
+
(0, class_transformer_1.Transform)(shipping_request_validator_1.digits),
|
|
101
|
+
__metadata("design:type", String)
|
|
102
|
+
], PaymentCardRequestValidator.prototype, "holderDocument", void 0);
|
|
103
|
+
const isCard = (body) => body.method === payment_enum_1.FinancePaymentMethodEnum.CARD;
|
|
104
|
+
export class CreatePaymentChargeRequestValidator extends abstract_validator_1.AbstractRequestValidator {
|
|
105
|
+
method;
|
|
106
|
+
card;
|
|
107
|
+
}
|
|
108
|
+
__decorate([
|
|
109
|
+
(0, class_validator_1.IsIn)([payment_enum_1.FinancePaymentMethodEnum.PIX, payment_enum_1.FinancePaymentMethodEnum.CARD]),
|
|
110
|
+
__metadata("design:type", String)
|
|
111
|
+
], CreatePaymentChargeRequestValidator.prototype, "method", void 0);
|
|
112
|
+
__decorate([
|
|
113
|
+
(0, class_validator_1.ValidateIf)(isCard),
|
|
114
|
+
(0, class_validator_1.IsDefined)(),
|
|
115
|
+
(0, class_validator_1.ValidateNested)(),
|
|
116
|
+
(0, class_transformer_1.Type)(() => PaymentCardRequestValidator),
|
|
117
|
+
__metadata("design:type", PaymentCardRequestValidator)
|
|
118
|
+
], CreatePaymentChargeRequestValidator.prototype, "card", void 0);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './payment.entity';
|
|
2
|
+
export * from './payment.account.entity';
|
|
3
|
+
export * from './provider.enum';
|
|
4
|
+
export * from './account.enum';
|
|
5
|
+
export * from './charge.enum';
|
|
6
|
+
export * from './account';
|
|
7
|
+
export * from './charge';
|
|
8
|
+
export * from './request.validator';
|
|
9
|
+
export * from './charge.request.validator';
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Schema as MongoSchema } from 'mongoose';
|
|
2
|
+
import { PaymentAccountApprovalEnum, PaymentAccountPersonTypeEnum, PaymentPixKeyTypeEnum } from './account.enum.js';
|
|
3
|
+
export declare class IntegrationPaymentAccountApprovalEntity {
|
|
4
|
+
general: PaymentAccountApprovalEnum;
|
|
5
|
+
commercialInfo: PaymentAccountApprovalEnum;
|
|
6
|
+
documentation: PaymentAccountApprovalEnum;
|
|
7
|
+
bankAccountInfo: PaymentAccountApprovalEnum;
|
|
8
|
+
}
|
|
9
|
+
export declare const IntegrationPaymentAccountApprovalSchema: MongoSchema<IntegrationPaymentAccountApprovalEntity, import("mongoose").Model<IntegrationPaymentAccountApprovalEntity, any, any, any, import("mongoose").Document<unknown, any, IntegrationPaymentAccountApprovalEntity, any, {}> & IntegrationPaymentAccountApprovalEntity & {
|
|
10
|
+
_id: import("mongoose").Types.ObjectId;
|
|
11
|
+
} & {
|
|
12
|
+
__v: number;
|
|
13
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, IntegrationPaymentAccountApprovalEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<IntegrationPaymentAccountApprovalEntity>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<IntegrationPaymentAccountApprovalEntity> & {
|
|
14
|
+
_id: import("mongoose").Types.ObjectId;
|
|
15
|
+
} & {
|
|
16
|
+
__v: number;
|
|
17
|
+
}>;
|
|
18
|
+
export declare class IntegrationPaymentAccountWithdrawalEntity {
|
|
19
|
+
pixKeyType: PaymentPixKeyTypeEnum;
|
|
20
|
+
pixKey: string;
|
|
21
|
+
automatic: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare const IntegrationPaymentAccountWithdrawalSchema: MongoSchema<IntegrationPaymentAccountWithdrawalEntity, import("mongoose").Model<IntegrationPaymentAccountWithdrawalEntity, any, any, any, import("mongoose").Document<unknown, any, IntegrationPaymentAccountWithdrawalEntity, any, {}> & IntegrationPaymentAccountWithdrawalEntity & {
|
|
24
|
+
_id: import("mongoose").Types.ObjectId;
|
|
25
|
+
} & {
|
|
26
|
+
__v: number;
|
|
27
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, IntegrationPaymentAccountWithdrawalEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<IntegrationPaymentAccountWithdrawalEntity>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<IntegrationPaymentAccountWithdrawalEntity> & {
|
|
28
|
+
_id: import("mongoose").Types.ObjectId;
|
|
29
|
+
} & {
|
|
30
|
+
__v: number;
|
|
31
|
+
}>;
|
|
32
|
+
export declare class IntegrationPaymentAccountPixEntity {
|
|
33
|
+
ready: boolean;
|
|
34
|
+
error?: string | null;
|
|
35
|
+
checkedAt: Date;
|
|
36
|
+
}
|
|
37
|
+
export declare const IntegrationPaymentAccountPixSchema: MongoSchema<IntegrationPaymentAccountPixEntity, import("mongoose").Model<IntegrationPaymentAccountPixEntity, any, any, any, import("mongoose").Document<unknown, any, IntegrationPaymentAccountPixEntity, any, {}> & IntegrationPaymentAccountPixEntity & {
|
|
38
|
+
_id: import("mongoose").Types.ObjectId;
|
|
39
|
+
} & {
|
|
40
|
+
__v: number;
|
|
41
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, IntegrationPaymentAccountPixEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<IntegrationPaymentAccountPixEntity>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<IntegrationPaymentAccountPixEntity> & {
|
|
42
|
+
_id: import("mongoose").Types.ObjectId;
|
|
43
|
+
} & {
|
|
44
|
+
__v: number;
|
|
45
|
+
}>;
|
|
46
|
+
export declare class IntegrationPaymentAccountEntity {
|
|
47
|
+
accountId: string;
|
|
48
|
+
walletId: string;
|
|
49
|
+
apiKey?: string | null;
|
|
50
|
+
personType: PaymentAccountPersonTypeEnum;
|
|
51
|
+
documentMasked: string;
|
|
52
|
+
name: string;
|
|
53
|
+
email: string;
|
|
54
|
+
approval?: IntegrationPaymentAccountApprovalEntity | null;
|
|
55
|
+
pix?: IntegrationPaymentAccountPixEntity | null;
|
|
56
|
+
withdrawal?: IntegrationPaymentAccountWithdrawalEntity | null;
|
|
57
|
+
createdAt: Date;
|
|
58
|
+
syncedAt: Date;
|
|
59
|
+
}
|
|
60
|
+
export declare const IntegrationPaymentAccountSchema: MongoSchema<IntegrationPaymentAccountEntity, import("mongoose").Model<IntegrationPaymentAccountEntity, any, any, any, import("mongoose").Document<unknown, any, IntegrationPaymentAccountEntity, any, {}> & IntegrationPaymentAccountEntity & {
|
|
61
|
+
_id: import("mongoose").Types.ObjectId;
|
|
62
|
+
} & {
|
|
63
|
+
__v: number;
|
|
64
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, IntegrationPaymentAccountEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<IntegrationPaymentAccountEntity>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<IntegrationPaymentAccountEntity> & {
|
|
65
|
+
_id: import("mongoose").Types.ObjectId;
|
|
66
|
+
} & {
|
|
67
|
+
__v: number;
|
|
68
|
+
}>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AbstractEntity } from '../../abstract.entity.js';
|
|
2
|
+
import { PaymentProviderEnum } from './provider.enum.js';
|
|
3
|
+
import { IntegrationPaymentAccountEntity } from './payment.account.entity.js';
|
|
4
|
+
export declare class IntegrationPaymentEntity extends AbstractEntity {
|
|
5
|
+
provider: PaymentProviderEnum;
|
|
6
|
+
account?: IntegrationPaymentAccountEntity | null;
|
|
7
|
+
accountError?: string | null;
|
|
8
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { AbstractRequestValidator } from '../../abstract.validator.js';
|
|
2
|
+
import { PaymentAccountCompanyTypeEnum, PaymentAccountPersonTypeEnum, PaymentPixKeyTypeEnum } from './account.enum.js';
|
|
3
|
+
export declare function isCnpj(value: unknown): boolean;
|
|
4
|
+
export declare function IsCnpj(): PropertyDecorator;
|
|
5
|
+
export declare function isPixKey(type: unknown, key: unknown): boolean;
|
|
6
|
+
export declare class PaymentAccountAddressRequestValidator extends AbstractRequestValidator {
|
|
7
|
+
postalCode: string;
|
|
8
|
+
street: string;
|
|
9
|
+
number: string;
|
|
10
|
+
complement?: string;
|
|
11
|
+
district: string;
|
|
12
|
+
}
|
|
13
|
+
declare abstract class PaymentAccountContactRequestValidator extends AbstractRequestValidator {
|
|
14
|
+
email: string;
|
|
15
|
+
mobilePhone: string;
|
|
16
|
+
phone?: string;
|
|
17
|
+
incomeValue: number;
|
|
18
|
+
site?: string;
|
|
19
|
+
address: PaymentAccountAddressRequestValidator;
|
|
20
|
+
}
|
|
21
|
+
export declare class CreatePaymentAccountRequestValidator extends PaymentAccountContactRequestValidator {
|
|
22
|
+
personType: PaymentAccountPersonTypeEnum;
|
|
23
|
+
name: string;
|
|
24
|
+
cpfCnpj: string;
|
|
25
|
+
birthDate?: string;
|
|
26
|
+
companyType?: PaymentAccountCompanyTypeEnum;
|
|
27
|
+
constructor();
|
|
28
|
+
}
|
|
29
|
+
export declare class UpdatePaymentAccountRequestValidator extends AbstractRequestValidator {
|
|
30
|
+
email?: string;
|
|
31
|
+
mobilePhone?: string;
|
|
32
|
+
phone?: string;
|
|
33
|
+
incomeValue?: number;
|
|
34
|
+
site?: string;
|
|
35
|
+
birthDate?: string;
|
|
36
|
+
companyType?: PaymentAccountCompanyTypeEnum;
|
|
37
|
+
address?: PaymentAccountAddressRequestValidator;
|
|
38
|
+
}
|
|
39
|
+
export declare class UpdatePaymentWithdrawalRequestValidator extends AbstractRequestValidator {
|
|
40
|
+
pixKeyType: PaymentPixKeyTypeEnum;
|
|
41
|
+
pixKey: string;
|
|
42
|
+
automatic?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export declare class CreatePaymentWithdrawalRequestValidator extends AbstractRequestValidator {
|
|
45
|
+
amount?: number;
|
|
46
|
+
}
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
import * as brazilian_utils_1 from "@brazilian-utils/brazilian-utils";
|
|
12
|
+
import * as class_transformer_1 from "class-transformer";
|
|
13
|
+
import * as class_validator_1 from "class-validator";
|
|
14
|
+
import * as shipping_request_validator_1 from '../../order/sale/index.js';
|
|
15
|
+
import * as abstract_validator_1 from '../../abstract.validator.js';
|
|
16
|
+
import * as account_enum_1 from './account.enum.js';
|
|
17
|
+
const lower = ({ value }) => typeof value === 'string' ? value.trim().toLowerCase() : value;
|
|
18
|
+
export function isCnpj(value) {
|
|
19
|
+
return typeof value === 'string' && /^\d{14}$/.test(value) && (0, brazilian_utils_1.isValidCnpj)(value);
|
|
20
|
+
}
|
|
21
|
+
export function IsCnpj() {
|
|
22
|
+
return (0, class_validator_1.ValidateBy)({
|
|
23
|
+
name: 'isCnpj',
|
|
24
|
+
validator: {
|
|
25
|
+
defaultMessage: () => '$property must be a valid CNPJ',
|
|
26
|
+
validate: isCnpj,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export function isPixKey(type, key) {
|
|
31
|
+
if (typeof key !== 'string')
|
|
32
|
+
return false;
|
|
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
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function IsPixKey() {
|
|
49
|
+
return (0, class_validator_1.ValidateBy)({
|
|
50
|
+
name: 'isPixKey',
|
|
51
|
+
validator: {
|
|
52
|
+
defaultMessage: () => '$property must be a valid Pix key of the given pixKeyType',
|
|
53
|
+
validate: (key, args) => isPixKey(args.object.pixKeyType, key),
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
}
|
|
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
|
+
return (0, class_validator_1.ValidateBy)({
|
|
70
|
+
name: 'isAccountDocument',
|
|
71
|
+
validator: {
|
|
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
|
+
},
|
|
75
|
+
});
|
|
76
|
+
}
|
|
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;
|
|
81
|
+
street;
|
|
82
|
+
number;
|
|
83
|
+
complement;
|
|
84
|
+
district;
|
|
85
|
+
}
|
|
86
|
+
__decorate([
|
|
87
|
+
(0, class_validator_1.Matches)(/^\d{8}$/, { message: '$property must be a CEP with 8 digits' }),
|
|
88
|
+
(0, class_transformer_1.Transform)(shipping_request_validator_1.digits),
|
|
89
|
+
__metadata("design:type", String)
|
|
90
|
+
], PaymentAccountAddressRequestValidator.prototype, "postalCode", void 0);
|
|
91
|
+
__decorate([
|
|
92
|
+
(0, class_validator_1.IsString)(),
|
|
93
|
+
(0, class_validator_1.Length)(2, 200),
|
|
94
|
+
(0, class_transformer_1.Transform)(shipping_request_validator_1.trim),
|
|
95
|
+
__metadata("design:type", String)
|
|
96
|
+
], PaymentAccountAddressRequestValidator.prototype, "street", void 0);
|
|
97
|
+
__decorate([
|
|
98
|
+
(0, class_validator_1.IsString)(),
|
|
99
|
+
(0, class_validator_1.Length)(1, 20),
|
|
100
|
+
(0, class_transformer_1.Transform)(shipping_request_validator_1.trim),
|
|
101
|
+
__metadata("design:type", String)
|
|
102
|
+
], PaymentAccountAddressRequestValidator.prototype, "number", void 0);
|
|
103
|
+
__decorate([
|
|
104
|
+
(0, class_validator_1.IsString)(),
|
|
105
|
+
(0, class_validator_1.Length)(1, 120),
|
|
106
|
+
(0, class_validator_1.IsOptional)(),
|
|
107
|
+
(0, class_transformer_1.Transform)(shipping_request_validator_1.trim),
|
|
108
|
+
__metadata("design:type", String)
|
|
109
|
+
], PaymentAccountAddressRequestValidator.prototype, "complement", void 0);
|
|
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
|
+
], PaymentAccountAddressRequestValidator.prototype, "district", void 0);
|
|
116
|
+
class PaymentAccountContactRequestValidator extends abstract_validator_1.AbstractRequestValidator {
|
|
117
|
+
email;
|
|
118
|
+
mobilePhone;
|
|
119
|
+
phone;
|
|
120
|
+
incomeValue;
|
|
121
|
+
site;
|
|
122
|
+
address;
|
|
123
|
+
}
|
|
124
|
+
__decorate([
|
|
125
|
+
(0, class_validator_1.IsEmail)(),
|
|
126
|
+
(0, class_validator_1.Length)(3, 254),
|
|
127
|
+
(0, class_transformer_1.Transform)(lower),
|
|
128
|
+
__metadata("design:type", String)
|
|
129
|
+
], PaymentAccountContactRequestValidator.prototype, "email", void 0);
|
|
130
|
+
__decorate([
|
|
131
|
+
(0, class_validator_1.Matches)(/^\d{10,11}$/, { message: '$property must be the DDD and number (10 or 11 digits)' }),
|
|
132
|
+
(0, class_transformer_1.Transform)(shipping_request_validator_1.digits),
|
|
133
|
+
__metadata("design:type", String)
|
|
134
|
+
], PaymentAccountContactRequestValidator.prototype, "mobilePhone", void 0);
|
|
135
|
+
__decorate([
|
|
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),
|
|
139
|
+
__metadata("design:type", String)
|
|
140
|
+
], PaymentAccountContactRequestValidator.prototype, "phone", void 0);
|
|
141
|
+
__decorate([
|
|
142
|
+
(0, class_validator_1.IsInt)(),
|
|
143
|
+
(0, class_validator_1.Min)(1),
|
|
144
|
+
__metadata("design:type", Number)
|
|
145
|
+
], PaymentAccountContactRequestValidator.prototype, "incomeValue", void 0);
|
|
146
|
+
__decorate([
|
|
147
|
+
(0, class_validator_1.IsUrl)({ require_protocol: true }),
|
|
148
|
+
(0, class_validator_1.IsOptional)(),
|
|
149
|
+
(0, class_transformer_1.Transform)(shipping_request_validator_1.trim),
|
|
150
|
+
__metadata("design:type", String)
|
|
151
|
+
], PaymentAccountContactRequestValidator.prototype, "site", void 0);
|
|
152
|
+
__decorate([
|
|
153
|
+
(0, class_validator_1.IsDefined)(),
|
|
154
|
+
(0, class_validator_1.ValidateNested)(),
|
|
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;
|
|
164
|
+
constructor() {
|
|
165
|
+
super();
|
|
166
|
+
this.personType = account_enum_1.PaymentAccountPersonTypeEnum.INDIVIDUAL;
|
|
167
|
+
this.address = new PaymentAccountAddressRequestValidator();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
__decorate([
|
|
171
|
+
(0, class_validator_1.IsEnum)(account_enum_1.PaymentAccountPersonTypeEnum),
|
|
172
|
+
__metadata("design:type", String)
|
|
173
|
+
], CreatePaymentAccountRequestValidator.prototype, "personType", void 0);
|
|
174
|
+
__decorate([
|
|
175
|
+
(0, class_validator_1.IsString)(),
|
|
176
|
+
(0, class_validator_1.Length)(2, 120),
|
|
177
|
+
(0, class_transformer_1.Transform)(shipping_request_validator_1.trim),
|
|
178
|
+
__metadata("design:type", String)
|
|
179
|
+
], CreatePaymentAccountRequestValidator.prototype, "name", void 0);
|
|
180
|
+
__decorate([
|
|
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)(),
|
|
188
|
+
(0, class_transformer_1.Transform)(shipping_request_validator_1.trim),
|
|
189
|
+
__metadata("design:type", String)
|
|
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
|
+
}
|
|
206
|
+
__decorate([
|
|
207
|
+
(0, class_validator_1.IsEmail)(),
|
|
208
|
+
(0, class_validator_1.Length)(3, 254),
|
|
209
|
+
(0, class_validator_1.IsOptional)(),
|
|
210
|
+
(0, class_transformer_1.Transform)(lower),
|
|
211
|
+
__metadata("design:type", String)
|
|
212
|
+
], UpdatePaymentAccountRequestValidator.prototype, "email", void 0);
|
|
213
|
+
__decorate([
|
|
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)(),
|
|
216
|
+
(0, class_transformer_1.Transform)(shipping_request_validator_1.digits),
|
|
217
|
+
__metadata("design:type", String)
|
|
218
|
+
], UpdatePaymentAccountRequestValidator.prototype, "mobilePhone", void 0);
|
|
219
|
+
__decorate([
|
|
220
|
+
(0, class_validator_1.Matches)(/^\d{10,11}$/, { message: '$property must be the DDD and number (10 or 11 digits)' }),
|
|
221
|
+
(0, class_validator_1.IsOptional)(),
|
|
222
|
+
(0, class_transformer_1.Transform)(shipping_request_validator_1.digits),
|
|
223
|
+
__metadata("design:type", String)
|
|
224
|
+
], UpdatePaymentAccountRequestValidator.prototype, "phone", void 0);
|
|
225
|
+
__decorate([
|
|
226
|
+
(0, class_validator_1.IsInt)(),
|
|
227
|
+
(0, class_validator_1.Min)(1),
|
|
228
|
+
(0, class_validator_1.IsOptional)(),
|
|
229
|
+
__metadata("design:type", Number)
|
|
230
|
+
], UpdatePaymentAccountRequestValidator.prototype, "incomeValue", void 0);
|
|
231
|
+
__decorate([
|
|
232
|
+
(0, class_validator_1.IsUrl)({ require_protocol: true }),
|
|
233
|
+
(0, class_validator_1.IsOptional)(),
|
|
234
|
+
(0, class_transformer_1.Transform)(shipping_request_validator_1.trim),
|
|
235
|
+
__metadata("design:type", String)
|
|
236
|
+
], UpdatePaymentAccountRequestValidator.prototype, "site", void 0);
|
|
237
|
+
__decorate([
|
|
238
|
+
(0, shipping_request_validator_1.IsBirthday)(),
|
|
239
|
+
(0, class_validator_1.IsOptional)(),
|
|
240
|
+
(0, class_transformer_1.Transform)(shipping_request_validator_1.trim),
|
|
241
|
+
__metadata("design:type", String)
|
|
242
|
+
], UpdatePaymentAccountRequestValidator.prototype, "birthDate", void 0);
|
|
243
|
+
__decorate([
|
|
244
|
+
(0, class_validator_1.IsEnum)(account_enum_1.PaymentAccountCompanyTypeEnum),
|
|
245
|
+
(0, class_validator_1.IsOptional)(),
|
|
246
|
+
__metadata("design:type", String)
|
|
247
|
+
], UpdatePaymentAccountRequestValidator.prototype, "companyType", void 0);
|
|
248
|
+
__decorate([
|
|
249
|
+
(0, class_validator_1.IsOptional)(),
|
|
250
|
+
(0, class_validator_1.ValidateNested)(),
|
|
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;
|
|
258
|
+
}
|
|
259
|
+
__decorate([
|
|
260
|
+
(0, class_validator_1.IsEnum)(account_enum_1.PaymentPixKeyTypeEnum),
|
|
261
|
+
__metadata("design:type", String)
|
|
262
|
+
], UpdatePaymentWithdrawalRequestValidator.prototype, "pixKeyType", void 0);
|
|
263
|
+
__decorate([
|
|
264
|
+
IsPixKey(),
|
|
265
|
+
(0, class_transformer_1.Transform)(pixKey),
|
|
266
|
+
__metadata("design:type", String)
|
|
267
|
+
], UpdatePaymentWithdrawalRequestValidator.prototype, "pixKey", void 0);
|
|
268
|
+
__decorate([
|
|
269
|
+
(0, class_validator_1.IsBoolean)(),
|
|
270
|
+
(0, class_validator_1.IsOptional)(),
|
|
271
|
+
__metadata("design:type", Boolean)
|
|
272
|
+
], UpdatePaymentWithdrawalRequestValidator.prototype, "automatic", void 0);
|
|
273
|
+
export class CreatePaymentWithdrawalRequestValidator extends abstract_validator_1.AbstractRequestValidator {
|
|
274
|
+
amount;
|
|
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)({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@merkaly/api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Shared TypeScript interfaces and enums for Merkaly API",
|
|
6
6
|
"repository": {
|
|
@@ -22,6 +22,8 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
+
"@brazilian-utils/brazilian-utils": "^2.5.0",
|
|
26
|
+
"card-validator": "^10.0.4",
|
|
25
27
|
"class-transformer": "^0.5.1",
|
|
26
28
|
"class-validator": "^0.15.1",
|
|
27
29
|
"reflect-metadata": "^0.2.2"
|