@merkaly/api 0.24.0 → 0.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,8 @@
1
1
  export * from './payment.entity';
2
+ export * from './payment.attempt.entity';
2
3
  export * from './payment.gateway.entity';
3
4
  export * from './payment.enum';
4
5
  export * from './request.validator';
5
6
  export * from './payment.transition';
7
+ export * from './report';
8
+ export * from './report.request.validator';
@@ -1,3 +1,4 @@
1
1
  export * from './payment.enum.js';
2
2
  export * from './request.validator.js';
3
3
  export * from './payment.transition.js';
4
+ export * from './report.request.validator.js';
@@ -0,0 +1,26 @@
1
+ import { Schema as MongoSchema } from 'mongoose';
2
+ import { FinancePaymentMethodEnum } from './payment.enum.js';
3
+ import { FinancePaymentGatewayCardEntity } from './payment.gateway.entity.js';
4
+ import type { PaymentChargeStatusEnum } from '../../integration/payment';
5
+ export type FinancePaymentAttemptStatus = PaymentChargeStatusEnum | 'UNKNOWN';
6
+ export declare class FinancePaymentAttemptEntity {
7
+ reference?: string | null;
8
+ method: FinancePaymentMethodEnum;
9
+ status: FinancePaymentAttemptStatus;
10
+ rawStatus: string;
11
+ amount: number;
12
+ message?: string | null;
13
+ card?: FinancePaymentGatewayCardEntity | null;
14
+ expiresAt?: Date | null;
15
+ createdAt: Date;
16
+ syncedAt: Date;
17
+ }
18
+ export declare const FinancePaymentAttemptSchema: MongoSchema<FinancePaymentAttemptEntity, import("mongoose").Model<FinancePaymentAttemptEntity, any, any, any, import("mongoose").Document<unknown, any, FinancePaymentAttemptEntity, any, {}> & FinancePaymentAttemptEntity & {
19
+ _id: import("mongoose").Types.ObjectId;
20
+ } & {
21
+ __v: number;
22
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, FinancePaymentAttemptEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<FinancePaymentAttemptEntity>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<FinancePaymentAttemptEntity> & {
23
+ _id: import("mongoose").Types.ObjectId;
24
+ } & {
25
+ __v: number;
26
+ }>;
@@ -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 { FinancePaymentAttemptEntity } from './payment.attempt.entity.js';
7
8
  import { FinancePaymentGatewayEntity } from './payment.gateway.entity.js';
8
9
  export type OrderEntity = OrderSaleEntity | OrderPurchaseEntity;
9
10
  export declare class FinancePaymentEntity extends AbstractEntity implements ITransitionable<FinancePaymentStatusEnum> {
@@ -14,6 +15,7 @@ export declare class FinancePaymentEntity extends AbstractEntity implements ITra
14
15
  fee: number;
15
16
  method?: FinancePaymentMethodEnum | null;
16
17
  gateway?: FinancePaymentGatewayEntity | null;
18
+ attempts?: FinancePaymentAttemptEntity[];
17
19
  status: FinancePaymentStatusEnum;
18
20
  history: StatusEntity<FinancePaymentStatusEnum>[];
19
21
  readonly number: string;
@@ -0,0 +1,65 @@
1
+ import type { FinancePaymentAttemptStatus } from './payment.attempt.entity.js';
2
+ import type { FinancePaymentMethodEnum, FinancePaymentStatusEnum } from './payment.enum.js';
3
+ export type FinancePaymentReportStatus = FinancePaymentAttemptStatus;
4
+ export interface FinancePaymentReportTotal {
5
+ amount: number;
6
+ count: number;
7
+ }
8
+ export interface FinancePaymentReportFailure {
9
+ message: string;
10
+ orgId: string;
11
+ orgName: string;
12
+ }
13
+ export interface FinancePaymentReportStore {
14
+ attemptCount: number;
15
+ expiredCount: number;
16
+ lastPaymentAt: Date | null;
17
+ orgId: string;
18
+ orgName: string;
19
+ paidAmount: number;
20
+ paidCount: number;
21
+ rejectedCount: number;
22
+ }
23
+ export interface FinancePaymentReportSummary {
24
+ attempts: Partial<Record<FinancePaymentReportStatus, number>> & {
25
+ total: number;
26
+ };
27
+ failures: FinancePaymentReportFailure[];
28
+ from: Date;
29
+ methods: Partial<Record<FinancePaymentMethodEnum, FinancePaymentReportTotal>>;
30
+ paid: FinancePaymentReportTotal;
31
+ storeCount: number;
32
+ stores: FinancePaymentReportStore[];
33
+ to: Date;
34
+ }
35
+ export interface FinancePaymentReportCard {
36
+ brand: string | null;
37
+ last4: string | null;
38
+ }
39
+ export interface FinancePaymentReportItem {
40
+ amount: number;
41
+ attempt: number;
42
+ card: FinancePaymentReportCard | null;
43
+ createdAt: Date;
44
+ message: string | null;
45
+ method: FinancePaymentMethodEnum;
46
+ orgId: string;
47
+ orgName: string;
48
+ paid: boolean;
49
+ paymentId: string;
50
+ paymentStatus: FinancePaymentStatusEnum;
51
+ provider: string;
52
+ rawStatus: string;
53
+ reference: string | null;
54
+ saleId: string | null;
55
+ saleNumber: string | null;
56
+ status: FinancePaymentReportStatus;
57
+ syncedAt: Date;
58
+ }
59
+ export interface FinancePaymentReportList {
60
+ failures: FinancePaymentReportFailure[];
61
+ items: FinancePaymentReportItem[];
62
+ limit: number;
63
+ page: number;
64
+ total: number;
65
+ }
@@ -0,0 +1,14 @@
1
+ import { AbstractRequestValidator } from '../../abstract.validator.js';
2
+ import { FinancePaymentMethodEnum } from './payment.enum.js';
3
+ import type { FinancePaymentReportStatus } from './report.js';
4
+ export declare class FinancePaymentReportRangeRequestValidator extends AbstractRequestValidator {
5
+ from: string;
6
+ to: string;
7
+ }
8
+ export declare class FinancePaymentReportSearchRequestValidator extends FinancePaymentReportRangeRequestValidator {
9
+ org?: string;
10
+ status?: FinancePaymentReportStatus;
11
+ method?: FinancePaymentMethodEnum;
12
+ page?: number;
13
+ limit?: number;
14
+ }
@@ -0,0 +1,68 @@
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 class_transformer_1 from "class-transformer";
12
+ import * as class_validator_1 from "class-validator";
13
+ import * as charge_enum_1 from '../../integration/payment/index.js';
14
+ import * as abstract_validator_1 from '../../abstract.validator.js';
15
+ import * as payment_enum_1 from './payment.enum.js';
16
+ const REPORT_STATUSES = [
17
+ ...Object.values(charge_enum_1.PaymentChargeStatusEnum),
18
+ 'UNKNOWN',
19
+ ];
20
+ export class FinancePaymentReportRangeRequestValidator extends abstract_validator_1.AbstractRequestValidator {
21
+ from;
22
+ to;
23
+ }
24
+ __decorate([
25
+ (0, class_validator_1.IsISO8601)(),
26
+ __metadata("design:type", String)
27
+ ], FinancePaymentReportRangeRequestValidator.prototype, "from", void 0);
28
+ __decorate([
29
+ (0, class_validator_1.IsISO8601)(),
30
+ __metadata("design:type", String)
31
+ ], FinancePaymentReportRangeRequestValidator.prototype, "to", void 0);
32
+ export class FinancePaymentReportSearchRequestValidator extends FinancePaymentReportRangeRequestValidator {
33
+ org;
34
+ status;
35
+ method;
36
+ page = 1;
37
+ limit = 25;
38
+ }
39
+ __decorate([
40
+ (0, class_validator_1.IsString)(),
41
+ (0, class_validator_1.IsOptional)(),
42
+ __metadata("design:type", String)
43
+ ], FinancePaymentReportSearchRequestValidator.prototype, "org", void 0);
44
+ __decorate([
45
+ (0, class_validator_1.IsIn)(REPORT_STATUSES),
46
+ (0, class_validator_1.IsOptional)(),
47
+ __metadata("design:type", String)
48
+ ], FinancePaymentReportSearchRequestValidator.prototype, "status", void 0);
49
+ __decorate([
50
+ (0, class_validator_1.IsEnum)(payment_enum_1.FinancePaymentMethodEnum),
51
+ (0, class_validator_1.IsOptional)(),
52
+ __metadata("design:type", String)
53
+ ], FinancePaymentReportSearchRequestValidator.prototype, "method", void 0);
54
+ __decorate([
55
+ (0, class_transformer_1.Transform)(({ value }) => (value ? Number(value) : 1)),
56
+ (0, class_validator_1.IsInt)(),
57
+ (0, class_validator_1.Min)(1),
58
+ (0, class_validator_1.IsOptional)(),
59
+ __metadata("design:type", Number)
60
+ ], FinancePaymentReportSearchRequestValidator.prototype, "page", void 0);
61
+ __decorate([
62
+ (0, class_transformer_1.Transform)(({ value }) => (value ? Number(value) : 25)),
63
+ (0, class_validator_1.IsInt)(),
64
+ (0, class_validator_1.Min)(1),
65
+ (0, class_validator_1.Max)(100),
66
+ (0, class_validator_1.IsOptional)(),
67
+ __metadata("design:type", Number)
68
+ ], FinancePaymentReportSearchRequestValidator.prototype, "limit", void 0);
@@ -9,7 +9,6 @@ export interface PaymentAccountApproval {
9
9
  export interface PaymentAccountWithdrawal {
10
10
  pixKeyType: PaymentPixKeyTypeEnum;
11
11
  pixKeyMasked: string;
12
- automatic: boolean;
13
12
  }
14
13
  export interface PaymentAccountSummary {
15
14
  accountId: string;
@@ -48,8 +47,14 @@ export interface PaymentAccountOnboarding {
48
47
  documents: PaymentAccountDocument[];
49
48
  rejectReasons: string | null;
50
49
  }
50
+ export interface PaymentAccountPending {
51
+ amount: number;
52
+ count: number;
53
+ nextCreditDate: string | null;
54
+ }
51
55
  export interface PaymentAccountBalance {
52
56
  balance: number;
57
+ pending: PaymentAccountPending | null;
53
58
  }
54
59
  export interface PaymentAccountTransfer {
55
60
  id: string;
@@ -68,9 +73,7 @@ export interface PaymentAccountCommercialInfo {
68
73
  birthDate: string | null;
69
74
  email: string | null;
70
75
  mobilePhone: string | null;
71
- phone: string | null;
72
76
  incomeValue: number | null;
73
- site: string | null;
74
77
  address: {
75
78
  postalCode: string | null;
76
79
  street: string | null;
@@ -18,7 +18,6 @@ export declare const IntegrationPaymentAccountApprovalSchema: MongoSchema<Integr
18
18
  export declare class IntegrationPaymentAccountWithdrawalEntity {
19
19
  pixKeyType: PaymentPixKeyTypeEnum;
20
20
  pixKey: string;
21
- automatic: boolean;
22
21
  }
23
22
  export declare const IntegrationPaymentAccountWithdrawalSchema: MongoSchema<IntegrationPaymentAccountWithdrawalEntity, import("mongoose").Model<IntegrationPaymentAccountWithdrawalEntity, any, any, any, import("mongoose").Document<unknown, any, IntegrationPaymentAccountWithdrawalEntity, any, {}> & IntegrationPaymentAccountWithdrawalEntity & {
24
23
  _id: import("mongoose").Types.ObjectId;
@@ -13,9 +13,7 @@ export declare class PaymentAccountAddressRequestValidator extends AbstractReque
13
13
  declare abstract class PaymentAccountContactRequestValidator extends AbstractRequestValidator {
14
14
  email: string;
15
15
  mobilePhone: string;
16
- phone?: string;
17
16
  incomeValue: number;
18
- site?: string;
19
17
  address: PaymentAccountAddressRequestValidator;
20
18
  }
21
19
  export declare class CreatePaymentAccountRequestValidator extends PaymentAccountContactRequestValidator {
@@ -29,9 +27,7 @@ export declare class CreatePaymentAccountRequestValidator extends PaymentAccount
29
27
  export declare class UpdatePaymentAccountRequestValidator extends AbstractRequestValidator {
30
28
  email?: string;
31
29
  mobilePhone?: string;
32
- phone?: string;
33
30
  incomeValue?: number;
34
- site?: string;
35
31
  birthDate?: string;
36
32
  companyType?: PaymentAccountCompanyTypeEnum;
37
33
  address?: PaymentAccountAddressRequestValidator;
@@ -39,7 +35,6 @@ export declare class UpdatePaymentAccountRequestValidator extends AbstractReques
39
35
  export declare class UpdatePaymentWithdrawalRequestValidator extends AbstractRequestValidator {
40
36
  pixKeyType: PaymentPixKeyTypeEnum;
41
37
  pixKey: string;
42
- automatic?: boolean;
43
38
  }
44
39
  export declare class CreatePaymentWithdrawalRequestValidator extends AbstractRequestValidator {
45
40
  amount?: number;
@@ -116,9 +116,7 @@ __decorate([
116
116
  class PaymentAccountContactRequestValidator extends abstract_validator_1.AbstractRequestValidator {
117
117
  email;
118
118
  mobilePhone;
119
- phone;
120
119
  incomeValue;
121
- site;
122
120
  address;
123
121
  }
124
122
  __decorate([
@@ -132,23 +130,11 @@ __decorate([
132
130
  (0, class_transformer_1.Transform)(shipping_request_validator_1.digits),
133
131
  __metadata("design:type", String)
134
132
  ], 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
133
  __decorate([
142
134
  (0, class_validator_1.IsInt)(),
143
135
  (0, class_validator_1.Min)(1),
144
136
  __metadata("design:type", Number)
145
137
  ], 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
138
  __decorate([
153
139
  (0, class_validator_1.IsDefined)(),
154
140
  (0, class_validator_1.ValidateNested)(),
@@ -196,9 +182,7 @@ __decorate([
196
182
  export class UpdatePaymentAccountRequestValidator extends abstract_validator_1.AbstractRequestValidator {
197
183
  email;
198
184
  mobilePhone;
199
- phone;
200
185
  incomeValue;
201
- site;
202
186
  birthDate;
203
187
  companyType;
204
188
  address;
@@ -216,24 +200,12 @@ __decorate([
216
200
  (0, class_transformer_1.Transform)(shipping_request_validator_1.digits),
217
201
  __metadata("design:type", String)
218
202
  ], 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
203
  __decorate([
226
204
  (0, class_validator_1.IsInt)(),
227
205
  (0, class_validator_1.Min)(1),
228
206
  (0, class_validator_1.IsOptional)(),
229
207
  __metadata("design:type", Number)
230
208
  ], 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
209
  __decorate([
238
210
  (0, shipping_request_validator_1.IsBirthday)(),
239
211
  (0, class_validator_1.IsOptional)(),
@@ -254,7 +226,6 @@ __decorate([
254
226
  export class UpdatePaymentWithdrawalRequestValidator extends abstract_validator_1.AbstractRequestValidator {
255
227
  pixKeyType;
256
228
  pixKey;
257
- automatic;
258
229
  }
259
230
  __decorate([
260
231
  (0, class_validator_1.IsEnum)(account_enum_1.PaymentPixKeyTypeEnum),
@@ -265,11 +236,6 @@ __decorate([
265
236
  (0, class_transformer_1.Transform)(pixKey),
266
237
  __metadata("design:type", String)
267
238
  ], 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
239
  export class CreatePaymentWithdrawalRequestValidator extends abstract_validator_1.AbstractRequestValidator {
274
240
  amount;
275
241
  }
@@ -9,4 +9,6 @@ export declare class OrderSaleEntity extends TransactionEntity<OrderSaleStatusEn
9
9
  items: ItemEntity[];
10
10
  shipping?: OrderSaleShippingEntity;
11
11
  readonly purchases: OrderPurchaseEntity[];
12
+ readonly cost: number | null;
13
+ readonly profit: number | null;
12
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@merkaly/api",
3
- "version": "0.24.0",
3
+ "version": "0.25.1",
4
4
  "type": "module",
5
5
  "description": "Shared TypeScript interfaces and enums for Merkaly API",
6
6
  "repository": {