@merkaly/api 0.35.1 → 0.36.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.
- package/dist/abstract.validator.d.ts +2 -0
- package/dist/abstract.validator.js +15 -0
- package/dist/app.schemas.d.ts +1 -0
- package/dist/finance/payment/payment.enum.d.ts +1 -0
- package/dist/finance/payment/payment.enum.js +1 -0
- package/dist/finance/payment/payment.transition.js +2 -1
- package/dist/finance/refund/refund.entity.d.ts +1 -0
- package/dist/integration/payment/account.d.ts +1 -0
- package/dist/integration/payment/account.enum.d.ts +2 -1
- package/dist/integration/payment/account.enum.js +2 -1
- package/dist/integration/payment/charge.d.ts +1 -0
- package/dist/integration/supplier/order.d.ts +1 -0
- package/dist/integration/supplier/provider.enum.d.ts +1 -0
- package/dist/integration/supplier/provider.enum.js +1 -0
- package/dist/integration/supplier/quote.d.ts +1 -0
- package/dist/order/sale/attention.d.ts +4 -0
- package/dist/order/sale/attention.enum.d.ts +1 -0
- package/dist/order/sale/attention.enum.js +2 -0
- package/dist/order/sale/fulfillment.d.ts +2 -0
- package/dist/order/sale/index.d.ts +1 -0
- package/dist/order/sale/receipt.d.ts +14 -0
- package/dist/order/sale/sale.entity.d.ts +2 -0
- package/dist/order/sale/sale.enum.d.ts +2 -0
- package/dist/order/sale/sale.enum.js +2 -0
- package/package.json +1 -1
|
@@ -18,6 +18,7 @@ export declare class ReadValidator extends AbstractRequestValidator {
|
|
|
18
18
|
export interface SearchRules extends ReadRules {
|
|
19
19
|
filters: readonly string[];
|
|
20
20
|
sort?: readonly string[];
|
|
21
|
+
unlimited?: boolean;
|
|
21
22
|
}
|
|
22
23
|
export declare class SearchValidator<E = AbstractEntity> extends ReadValidator {
|
|
23
24
|
static readonly rules: SearchRules;
|
|
@@ -27,4 +28,5 @@ export declare class SearchValidator<E = AbstractEntity> extends ReadValidator {
|
|
|
27
28
|
};
|
|
28
29
|
filters?: FilterQuery<E>;
|
|
29
30
|
}
|
|
31
|
+
export declare const PAGINATION_MAX_LIMIT = 100;
|
|
30
32
|
export {};
|
|
@@ -59,6 +59,7 @@ __decorate([
|
|
|
59
59
|
}),
|
|
60
60
|
(0, class_validator_1.ValidateNested)(),
|
|
61
61
|
(0, class_transformer_1.Type)(() => PaginationValidator),
|
|
62
|
+
AllowedBy('unlimited', paginationViolation),
|
|
62
63
|
(0, class_validator_1.IsOptional)(),
|
|
63
64
|
__metadata("design:type", PaginationValidator)
|
|
64
65
|
], SearchValidator.prototype, "pagination", void 0);
|
|
@@ -92,6 +93,8 @@ const FIELD_OPERATORS = new Set([
|
|
|
92
93
|
'$exists',
|
|
93
94
|
]);
|
|
94
95
|
const LOGICAL_OPERATORS = new Set(['$and', '$or']);
|
|
96
|
+
export const PAGINATION_MAX_LIMIT = 100;
|
|
97
|
+
const UNLIMITED = -1;
|
|
95
98
|
const REGEX_MAX_LENGTH = 100;
|
|
96
99
|
const REGEX_OPTIONS = /^[ims]*$/;
|
|
97
100
|
const REGEX_SPECIALS = /[\\^$.*+?()[\]{}|]/g;
|
|
@@ -143,6 +146,18 @@ function filterViolation(value, rules, path = 'filters') {
|
|
|
143
146
|
}
|
|
144
147
|
return undefined;
|
|
145
148
|
}
|
|
149
|
+
function paginationViolation(value, rules) {
|
|
150
|
+
if (!(0, class_validator_1.isObject)(value))
|
|
151
|
+
return undefined;
|
|
152
|
+
const { limit = 10, page = 1 } = value;
|
|
153
|
+
if (limit === UNLIMITED || page === UNLIMITED)
|
|
154
|
+
return rules.unlimited ? undefined : 'pagination must not ask for every record';
|
|
155
|
+
if (!(limit >= 1 && limit <= PAGINATION_MAX_LIMIT))
|
|
156
|
+
return `pagination.limit must be between 1 and ${PAGINATION_MAX_LIMIT}`;
|
|
157
|
+
if (!(page >= 1))
|
|
158
|
+
return 'pagination.page must be at least 1';
|
|
159
|
+
return undefined;
|
|
160
|
+
}
|
|
146
161
|
function sortViolation(value, rules) {
|
|
147
162
|
if (!(0, class_validator_1.isObject)(value))
|
|
148
163
|
return undefined;
|
package/dist/app.schemas.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export var FinancePaymentStatusEnum;
|
|
|
4
4
|
FinancePaymentStatusEnum["PAID"] = "PAID";
|
|
5
5
|
FinancePaymentStatusEnum["CANCELLED"] = "CANCELLED";
|
|
6
6
|
FinancePaymentStatusEnum["REFUNDED"] = "REFUNDED";
|
|
7
|
+
FinancePaymentStatusEnum["REFUND_PENDING"] = "REFUND_PENDING";
|
|
7
8
|
FinancePaymentStatusEnum["DISPUTED"] = "DISPUTED";
|
|
8
9
|
FinancePaymentStatusEnum["CHARGED_BACK"] = "CHARGED_BACK";
|
|
9
10
|
})(FinancePaymentStatusEnum || (FinancePaymentStatusEnum = {}));
|
|
@@ -4,7 +4,8 @@ import * as payment_enum_1 from './payment.enum.js';
|
|
|
4
4
|
export class FinancePaymentTransition extends AbstractTransition {
|
|
5
5
|
$states = {
|
|
6
6
|
[payment_enum_1.FinancePaymentStatusEnum.PENDING]: [payment_enum_1.FinancePaymentStatusEnum.PAID, payment_enum_1.FinancePaymentStatusEnum.CANCELLED],
|
|
7
|
-
[payment_enum_1.FinancePaymentStatusEnum.PAID]: [payment_enum_1.FinancePaymentStatusEnum.REFUNDED, payment_enum_1.FinancePaymentStatusEnum.DISPUTED],
|
|
7
|
+
[payment_enum_1.FinancePaymentStatusEnum.PAID]: [payment_enum_1.FinancePaymentStatusEnum.REFUNDED, payment_enum_1.FinancePaymentStatusEnum.REFUND_PENDING, payment_enum_1.FinancePaymentStatusEnum.DISPUTED],
|
|
8
|
+
[payment_enum_1.FinancePaymentStatusEnum.REFUND_PENDING]: [payment_enum_1.FinancePaymentStatusEnum.REFUNDED],
|
|
8
9
|
[payment_enum_1.FinancePaymentStatusEnum.DISPUTED]: [payment_enum_1.FinancePaymentStatusEnum.PAID, payment_enum_1.FinancePaymentStatusEnum.CHARGED_BACK],
|
|
9
10
|
[payment_enum_1.FinancePaymentStatusEnum.CANCELLED]: [],
|
|
10
11
|
[payment_enum_1.FinancePaymentStatusEnum.REFUNDED]: [],
|
|
@@ -30,7 +30,8 @@ export declare enum PaymentPixKeyTypeEnum {
|
|
|
30
30
|
}
|
|
31
31
|
export declare enum PaymentAccountReadinessEnum {
|
|
32
32
|
NOT_CONNECTED = "NOT_CONNECTED",
|
|
33
|
-
|
|
33
|
+
PENDING_DOCUMENTS = "PENDING_DOCUMENTS",
|
|
34
|
+
IN_REVIEW = "IN_REVIEW",
|
|
34
35
|
REJECTED = "REJECTED",
|
|
35
36
|
READY = "READY"
|
|
36
37
|
}
|
|
@@ -36,7 +36,8 @@ export var PaymentPixKeyTypeEnum;
|
|
|
36
36
|
export var PaymentAccountReadinessEnum;
|
|
37
37
|
(function (PaymentAccountReadinessEnum) {
|
|
38
38
|
PaymentAccountReadinessEnum["NOT_CONNECTED"] = "NOT_CONNECTED";
|
|
39
|
-
PaymentAccountReadinessEnum["
|
|
39
|
+
PaymentAccountReadinessEnum["PENDING_DOCUMENTS"] = "PENDING_DOCUMENTS";
|
|
40
|
+
PaymentAccountReadinessEnum["IN_REVIEW"] = "IN_REVIEW";
|
|
40
41
|
PaymentAccountReadinessEnum["REJECTED"] = "REJECTED";
|
|
41
42
|
PaymentAccountReadinessEnum["READY"] = "READY";
|
|
42
43
|
})(PaymentAccountReadinessEnum || (PaymentAccountReadinessEnum = {}));
|
|
@@ -3,6 +3,7 @@ import type { PaymentProviderEnum } from './provider.enum.js';
|
|
|
3
3
|
import type { FinancePaymentMethodEnum } from '../../finance/payment';
|
|
4
4
|
export type StorePaymentMethod = FinancePaymentMethodEnum.PIX;
|
|
5
5
|
export interface StorePaymentConfig {
|
|
6
|
+
fees: Partial<Record<StorePaymentMethod, number>>;
|
|
6
7
|
methods: StorePaymentMethod[];
|
|
7
8
|
provider: PaymentProviderEnum | null;
|
|
8
9
|
}
|
|
@@ -5,5 +5,6 @@ export var SupplierProviderEnum;
|
|
|
5
5
|
export var SupplierReadinessEnum;
|
|
6
6
|
(function (SupplierReadinessEnum) {
|
|
7
7
|
SupplierReadinessEnum["NOT_CONNECTED"] = "NOT_CONNECTED";
|
|
8
|
+
SupplierReadinessEnum["EXPIRED"] = "EXPIRED";
|
|
8
9
|
SupplierReadinessEnum["READY"] = "READY";
|
|
9
10
|
})(SupplierReadinessEnum || (SupplierReadinessEnum = {}));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare enum OrderSaleAttentionEnum {
|
|
2
2
|
PAYMENT_AMOUNT_MISMATCH = "PAYMENT_AMOUNT_MISMATCH",
|
|
3
3
|
PAYMENT_DISPUTED = "PAYMENT_DISPUTED",
|
|
4
|
+
REFUND_PENDING = "REFUND_PENDING",
|
|
4
5
|
CHARGED_BACK_WITH_SUPPLIER_ORDER = "CHARGED_BACK_WITH_SUPPLIER_ORDER",
|
|
5
6
|
REFUNDED_OUTSIDE_WITH_SUPPLIER_ORDER = "REFUNDED_OUTSIDE_WITH_SUPPLIER_ORDER",
|
|
6
7
|
SUPPLIER_PAID_AFTER_CANCEL = "SUPPLIER_PAID_AFTER_CANCEL",
|
|
@@ -2,6 +2,7 @@ export var OrderSaleAttentionEnum;
|
|
|
2
2
|
(function (OrderSaleAttentionEnum) {
|
|
3
3
|
OrderSaleAttentionEnum["PAYMENT_AMOUNT_MISMATCH"] = "PAYMENT_AMOUNT_MISMATCH";
|
|
4
4
|
OrderSaleAttentionEnum["PAYMENT_DISPUTED"] = "PAYMENT_DISPUTED";
|
|
5
|
+
OrderSaleAttentionEnum["REFUND_PENDING"] = "REFUND_PENDING";
|
|
5
6
|
OrderSaleAttentionEnum["CHARGED_BACK_WITH_SUPPLIER_ORDER"] = "CHARGED_BACK_WITH_SUPPLIER_ORDER";
|
|
6
7
|
OrderSaleAttentionEnum["REFUNDED_OUTSIDE_WITH_SUPPLIER_ORDER"] = "REFUNDED_OUTSIDE_WITH_SUPPLIER_ORDER";
|
|
7
8
|
OrderSaleAttentionEnum["SUPPLIER_PAID_AFTER_CANCEL"] = "SUPPLIER_PAID_AFTER_CANCEL";
|
|
@@ -17,6 +18,7 @@ export var OrderSaleAttentionEnum;
|
|
|
17
18
|
export const SALE_ACTIONABLE_ATTENTIONS = [
|
|
18
19
|
OrderSaleAttentionEnum.PAYMENT_AMOUNT_MISMATCH,
|
|
19
20
|
OrderSaleAttentionEnum.PAYMENT_DISPUTED,
|
|
21
|
+
OrderSaleAttentionEnum.REFUND_PENDING,
|
|
20
22
|
OrderSaleAttentionEnum.CHARGED_BACK_WITH_SUPPLIER_ORDER,
|
|
21
23
|
OrderSaleAttentionEnum.REFUNDED_OUTSIDE_WITH_SUPPLIER_ORDER,
|
|
22
24
|
OrderSaleAttentionEnum.SUPPLIER_PAID_AFTER_CANCEL,
|
|
@@ -4,6 +4,7 @@ import type { LogisticsBuyerShipment } from '../../logistics/shipment';
|
|
|
4
4
|
import type { OrderFulfillmentActionEnum, OrderSaleCostSourceEnum, OrderSaleHistoryEventEnum } from './fulfillment.enum.js';
|
|
5
5
|
import type { OrderPurchaseStatusEnum } from '../purchase';
|
|
6
6
|
import type { OrderSaleStatusEnum } from './sale.enum.js';
|
|
7
|
+
import type { OrderSaleReceipt } from './receipt.js';
|
|
7
8
|
export interface OrderSaleCosts {
|
|
8
9
|
products: number;
|
|
9
10
|
freight: number;
|
|
@@ -59,4 +60,5 @@ export interface OrderBuyerFulfillment {
|
|
|
59
60
|
status: OrderSaleStatusEnum;
|
|
60
61
|
shipments: LogisticsBuyerShipment[];
|
|
61
62
|
orderedAt: Date | null;
|
|
63
|
+
receipt: OrderSaleReceipt;
|
|
62
64
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { OrderSaleStatusEnum } from './sale.enum.js';
|
|
2
|
+
import type { LogisticsShipmentEntity } from '../../logistics/shipment';
|
|
3
|
+
type ReceiptShipment = Pick<LogisticsShipmentEntity, 'deliveredAt' | 'receivedBy'>;
|
|
4
|
+
export interface OrderSaleReceipt {
|
|
5
|
+
confirmable: boolean;
|
|
6
|
+
until: Date | null;
|
|
7
|
+
}
|
|
8
|
+
export declare const deliveredAtOf: (shipments: ReceiptShipment[]) => Date;
|
|
9
|
+
export declare const confirmedByBuyer: (shipments: ReceiptShipment[]) => boolean;
|
|
10
|
+
export declare function saleReceipt(status: OrderSaleStatusEnum, shipments: ReceiptShipment[], now?: number): {
|
|
11
|
+
confirmable: boolean;
|
|
12
|
+
until: Date;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -86,6 +86,8 @@ export declare const OrderSaleDeliverySchema: MongoSchema<OrderSaleDeliveryEntit
|
|
|
86
86
|
export declare class OrderSaleAutoProcurementEntity {
|
|
87
87
|
attemptedAt: Date;
|
|
88
88
|
error?: string | null;
|
|
89
|
+
attempts?: number;
|
|
90
|
+
retryAt?: Date | null;
|
|
89
91
|
}
|
|
90
92
|
export declare const OrderSaleAutoProcurementSchema: MongoSchema<OrderSaleAutoProcurementEntity, import("mongoose").Model<OrderSaleAutoProcurementEntity, any, any, any, import("mongoose").Document<unknown, any, OrderSaleAutoProcurementEntity, any, {}> & OrderSaleAutoProcurementEntity & {
|
|
91
93
|
_id: import("mongoose").Types.ObjectId;
|
|
@@ -8,6 +8,8 @@ export declare enum OrderSaleStatusEnum {
|
|
|
8
8
|
}
|
|
9
9
|
export declare const SALE_OPEN_STATUSES: readonly OrderSaleStatusEnum[];
|
|
10
10
|
export declare const SALE_CANCELLABLE_STATUSES: readonly OrderSaleStatusEnum[];
|
|
11
|
+
export declare const WITHDRAWAL_HOLD_DAYS = 7;
|
|
12
|
+
export declare const WITHDRAWAL_HOLD_MS: number;
|
|
11
13
|
export declare enum OrderSaleSourceEnum {
|
|
12
14
|
CHECKOUT = "CHECKOUT",
|
|
13
15
|
ADMIN = "ADMIN",
|
|
@@ -18,6 +18,8 @@ export const SALE_CANCELLABLE_STATUSES = [
|
|
|
18
18
|
OrderSaleStatusEnum.PAID,
|
|
19
19
|
OrderSaleStatusEnum.ORDERED,
|
|
20
20
|
];
|
|
21
|
+
export const WITHDRAWAL_HOLD_DAYS = 7;
|
|
22
|
+
export const WITHDRAWAL_HOLD_MS = WITHDRAWAL_HOLD_DAYS * 86_400_000;
|
|
21
23
|
export var OrderSaleSourceEnum;
|
|
22
24
|
(function (OrderSaleSourceEnum) {
|
|
23
25
|
OrderSaleSourceEnum["CHECKOUT"] = "CHECKOUT";
|