@merkaly/api 0.26.3 → 0.27.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/abstract.validator.d.ts +5 -0
- package/dist/abstract.validator.js +66 -0
- package/dist/app.schemas.d.ts +3 -0
- package/dist/finance/payment/index.d.ts +0 -2
- package/dist/finance/payment/payment.entity.d.ts +75 -2
- package/dist/finance/payment/report.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/integration/payment/charge.request.validator.js +8 -8
- package/dist/integration/payment/request.validator.js +16 -16
- package/dist/integration/supplier/order.d.ts +22 -6
- package/dist/logistics/shipment/index.d.ts +3 -0
- package/dist/logistics/shipment/index.js +1 -0
- package/dist/logistics/shipment/shipment.d.ts +26 -0
- package/dist/logistics/shipment/shipment.entity.d.ts +36 -0
- package/dist/logistics/shipment/shipment.enum.d.ts +24 -0
- package/dist/logistics/shipment/shipment.enum.js +28 -0
- package/dist/order/purchase/index.d.ts +0 -2
- package/dist/order/purchase/index.js +0 -1
- package/dist/order/purchase/purchase.entity.d.ts +20 -1
- package/dist/order/purchase/purchase.enum.d.ts +9 -5
- package/dist/order/purchase/purchase.enum.js +20 -8
- package/dist/order/purchase/purchase.transition.js +8 -5
- package/dist/order/purchase/request.validator.js +2 -2
- package/dist/order/purchase/supplier.order.request.validator.js +2 -2
- package/dist/order/sale/attention.d.ts +2 -2
- package/dist/order/sale/attention.enum.d.ts +1 -0
- package/dist/order/sale/attention.enum.js +1 -0
- package/dist/order/sale/checkout.request.validator.d.ts +2 -2
- package/dist/order/sale/checkout.request.validator.js +4 -4
- package/dist/order/sale/{shipping.request.validator.d.ts → delivery.request.validator.d.ts} +7 -7
- package/dist/order/sale/{shipping.request.validator.js → delivery.request.validator.js} +26 -26
- package/dist/order/sale/{shipping.update.request.validator.d.ts → delivery.update.request.validator.d.ts} +5 -5
- package/dist/order/sale/{shipping.update.request.validator.js → delivery.update.request.validator.js} +36 -36
- package/dist/order/sale/fulfillment.d.ts +11 -10
- package/dist/order/sale/fulfillment.enum.d.ts +6 -14
- package/dist/order/sale/fulfillment.enum.js +9 -21
- package/dist/order/sale/import.request.validator.d.ts +4 -0
- package/dist/order/sale/import.request.validator.js +20 -0
- package/dist/order/sale/index.d.ts +4 -3
- package/dist/order/sale/index.js +3 -2
- package/dist/order/sale/request.validator.js +2 -2
- package/dist/order/sale/sale.entity.d.ts +84 -3
- package/dist/order/sale/sale.enum.d.ts +11 -6
- package/dist/order/sale/sale.enum.js +15 -9
- package/dist/order/sale/sale.import.d.ts +28 -0
- package/dist/order/sale/sale.transition.js +7 -6
- package/dist/order/sale/search.request.validator.d.ts +2 -1
- package/dist/order/sale/search.request.validator.js +1 -0
- package/package.json +1 -1
- package/dist/finance/payment/payment.attempt.entity.d.ts +0 -26
- package/dist/finance/payment/payment.gateway.entity.d.ts +0 -53
- package/dist/order/purchase/purchase.supplier.order.entity.d.ts +0 -24
- package/dist/order/purchase/supplier.order.enum.d.ts +0 -11
- package/dist/order/purchase/supplier.order.enum.js +0 -23
- package/dist/order/sale/sale.shipping.entity.d.ts +0 -80
|
@@ -11,7 +11,12 @@ export declare class ReadValidator extends AbstractRequestValidator {
|
|
|
11
11
|
join?: PopulateOptions[];
|
|
12
12
|
select?: string;
|
|
13
13
|
}
|
|
14
|
+
export interface SearchRules {
|
|
15
|
+
filters: readonly string[];
|
|
16
|
+
sort: readonly string[];
|
|
17
|
+
}
|
|
14
18
|
export declare class SearchValidator<E = AbstractEntity> extends ReadValidator {
|
|
19
|
+
static readonly rules: SearchRules;
|
|
15
20
|
pagination?: PaginationValidator;
|
|
16
21
|
sort?: {
|
|
17
22
|
[key: string]: SortOrder;
|
|
@@ -42,6 +42,7 @@ __decorate([
|
|
|
42
42
|
__metadata("design:type", String)
|
|
43
43
|
], ReadValidator.prototype, "select", void 0);
|
|
44
44
|
export class SearchValidator extends ReadValidator {
|
|
45
|
+
static rules = { filters: [], sort: [] };
|
|
45
46
|
pagination = new PaginationValidator();
|
|
46
47
|
sort = {};
|
|
47
48
|
filters = {};
|
|
@@ -61,11 +62,13 @@ __decorate([
|
|
|
61
62
|
], SearchValidator.prototype, "pagination", void 0);
|
|
62
63
|
__decorate([
|
|
63
64
|
(0, class_transformer_1.Transform)(({ key, value }) => assertSortOrder(transformStructuredValue(key, value))),
|
|
65
|
+
AllowedBy('sort', sortViolation),
|
|
64
66
|
(0, class_validator_1.IsOptional)(),
|
|
65
67
|
__metadata("design:type", Object)
|
|
66
68
|
], SearchValidator.prototype, "sort", void 0);
|
|
67
69
|
__decorate([
|
|
68
70
|
(0, class_transformer_1.Transform)(({ key, value }) => transformStructuredValue(key, value)),
|
|
71
|
+
AllowedBy('filters', filterViolation),
|
|
69
72
|
(0, class_validator_1.IsOptional)(),
|
|
70
73
|
__metadata("design:type", Object)
|
|
71
74
|
], SearchValidator.prototype, "filters", void 0);
|
|
@@ -73,6 +76,69 @@ class QueryValidationError extends Error {
|
|
|
73
76
|
statusCode = 400;
|
|
74
77
|
}
|
|
75
78
|
const FORBIDDEN_OPERATORS = new Set(['$where', '$function', '$accumulator']);
|
|
79
|
+
const FIELD_OPERATORS = new Set([
|
|
80
|
+
'$eq',
|
|
81
|
+
'$ne',
|
|
82
|
+
'$in',
|
|
83
|
+
'$nin',
|
|
84
|
+
'$gt',
|
|
85
|
+
'$gte',
|
|
86
|
+
'$lt',
|
|
87
|
+
'$lte',
|
|
88
|
+
'$regex',
|
|
89
|
+
'$options',
|
|
90
|
+
'$exists',
|
|
91
|
+
]);
|
|
92
|
+
const LOGICAL_OPERATORS = new Set(['$and', '$or']);
|
|
93
|
+
const rulesOf = (object) => object.constructor.rules ?? SearchValidator.rules;
|
|
94
|
+
function AllowedBy(name, violation) {
|
|
95
|
+
return (0, class_validator_1.ValidateBy)({
|
|
96
|
+
name: `${name}Allowed`,
|
|
97
|
+
validator: {
|
|
98
|
+
defaultMessage: (args) => violation(args?.value, rulesOf(args?.object ?? {})) ?? `${name} is not allowed`,
|
|
99
|
+
validate: (value, args) => !violation(value, rulesOf(args?.object ?? {})),
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
const isScalar = (value) => value === null || ['string', 'number', 'boolean'].includes(typeof value);
|
|
104
|
+
const isPlainValue = (value) => isScalar(value) || ((0, class_validator_1.isArray)(value) && value.every(isScalar));
|
|
105
|
+
function filterViolation(value, rules, path = 'filters') {
|
|
106
|
+
if (value === undefined || value === null)
|
|
107
|
+
return undefined;
|
|
108
|
+
if (!(0, class_validator_1.isObject)(value))
|
|
109
|
+
return `${path} must be an object`;
|
|
110
|
+
for (const [field, condition] of Object.entries(value)) {
|
|
111
|
+
if (LOGICAL_OPERATORS.has(field)) {
|
|
112
|
+
if (!(0, class_validator_1.isArray)(condition))
|
|
113
|
+
return `${path}.${field} must be an array`;
|
|
114
|
+
const nested = condition
|
|
115
|
+
.map((item) => filterViolation(item ?? {}, rules, `${path}.${field}`))
|
|
116
|
+
.find(Boolean);
|
|
117
|
+
if (nested)
|
|
118
|
+
return nested;
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
if (!rules.filters.includes(field))
|
|
122
|
+
return `${path}.${field} is not filterable`;
|
|
123
|
+
if (isPlainValue(condition))
|
|
124
|
+
continue;
|
|
125
|
+
if (!(0, class_validator_1.isObject)(condition))
|
|
126
|
+
return `${path}.${field} must be a value or an operator object`;
|
|
127
|
+
for (const [operator, operand] of Object.entries(condition)) {
|
|
128
|
+
if (!FIELD_OPERATORS.has(operator))
|
|
129
|
+
return `${path}.${field} must not use ${operator}`;
|
|
130
|
+
if (!isPlainValue(operand))
|
|
131
|
+
return `${path}.${field}.${operator} must be a plain value`;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
function sortViolation(value, rules) {
|
|
137
|
+
if (!(0, class_validator_1.isObject)(value))
|
|
138
|
+
return undefined;
|
|
139
|
+
const field = Object.keys(value).find((key) => !rules.sort.includes(key));
|
|
140
|
+
return field ? `sort.${field} is not sortable` : undefined;
|
|
141
|
+
}
|
|
76
142
|
const SORT_ORDERS = new Set([1, -1, 'asc', 'desc', 'ascending', 'descending']);
|
|
77
143
|
function assertSortOrder(sort) {
|
|
78
144
|
if (!sort)
|
package/dist/app.schemas.d.ts
CHANGED
|
@@ -1,12 +1,85 @@
|
|
|
1
|
+
import { Schema as MongoSchema } from 'mongoose';
|
|
2
|
+
import { PaymentChargeAccountEnum } from '../../integration/payment';
|
|
1
3
|
import { OrderPurchaseEntity } from '../../order/purchase';
|
|
2
4
|
import { OrderSaleEntity } from '../../order/sale';
|
|
3
5
|
import { AbstractEntity } from '../../abstract.entity.js';
|
|
4
6
|
import { StatusEntity } from '../../status.plugin.js';
|
|
5
7
|
import { ITransitionable } from '../../transitionable.interface.js';
|
|
6
8
|
import { FinancePaymentMethodEnum, FinancePaymentStatusEnum, FinancePaymentTypeEnum } from './payment.enum.js';
|
|
7
|
-
import {
|
|
8
|
-
import { FinancePaymentGatewayEntity } from './payment.gateway.entity.js';
|
|
9
|
+
import type { PaymentChargeStatusEnum } from '../../integration/payment';
|
|
9
10
|
export type OrderEntity = OrderSaleEntity | OrderPurchaseEntity;
|
|
11
|
+
export declare class FinancePaymentGatewayPixEntity {
|
|
12
|
+
qrCode?: string | null;
|
|
13
|
+
qrCodeImage?: string | null;
|
|
14
|
+
}
|
|
15
|
+
export declare const FinancePaymentGatewayPixSchema: MongoSchema<FinancePaymentGatewayPixEntity, import("mongoose").Model<FinancePaymentGatewayPixEntity, any, any, any, import("mongoose").Document<unknown, any, FinancePaymentGatewayPixEntity, any, {}> & FinancePaymentGatewayPixEntity & {
|
|
16
|
+
_id: import("mongoose").Types.ObjectId;
|
|
17
|
+
} & {
|
|
18
|
+
__v: number;
|
|
19
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, FinancePaymentGatewayPixEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<FinancePaymentGatewayPixEntity>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<FinancePaymentGatewayPixEntity> & {
|
|
20
|
+
_id: import("mongoose").Types.ObjectId;
|
|
21
|
+
} & {
|
|
22
|
+
__v: number;
|
|
23
|
+
}>;
|
|
24
|
+
export declare class FinancePaymentGatewayCardEntity {
|
|
25
|
+
brand?: string | null;
|
|
26
|
+
last4?: string | null;
|
|
27
|
+
}
|
|
28
|
+
export declare const FinancePaymentGatewayCardSchema: MongoSchema<FinancePaymentGatewayCardEntity, import("mongoose").Model<FinancePaymentGatewayCardEntity, any, any, any, import("mongoose").Document<unknown, any, FinancePaymentGatewayCardEntity, any, {}> & FinancePaymentGatewayCardEntity & {
|
|
29
|
+
_id: import("mongoose").Types.ObjectId;
|
|
30
|
+
} & {
|
|
31
|
+
__v: number;
|
|
32
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, FinancePaymentGatewayCardEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<FinancePaymentGatewayCardEntity>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<FinancePaymentGatewayCardEntity> & {
|
|
33
|
+
_id: import("mongoose").Types.ObjectId;
|
|
34
|
+
} & {
|
|
35
|
+
__v: number;
|
|
36
|
+
}>;
|
|
37
|
+
export declare class FinancePaymentGatewayEntity {
|
|
38
|
+
provider: string;
|
|
39
|
+
reference?: string | null;
|
|
40
|
+
account?: PaymentChargeAccountEnum | null;
|
|
41
|
+
method: FinancePaymentMethodEnum;
|
|
42
|
+
status: string;
|
|
43
|
+
message?: string | null;
|
|
44
|
+
attempt: number;
|
|
45
|
+
cardAttempts: number;
|
|
46
|
+
amount: number;
|
|
47
|
+
pix?: FinancePaymentGatewayPixEntity | null;
|
|
48
|
+
card?: FinancePaymentGatewayCardEntity | null;
|
|
49
|
+
expiresAt?: Date | null;
|
|
50
|
+
syncedAt: Date;
|
|
51
|
+
}
|
|
52
|
+
export declare const FinancePaymentGatewaySchema: MongoSchema<FinancePaymentGatewayEntity, import("mongoose").Model<FinancePaymentGatewayEntity, any, any, any, import("mongoose").Document<unknown, any, FinancePaymentGatewayEntity, any, {}> & FinancePaymentGatewayEntity & {
|
|
53
|
+
_id: import("mongoose").Types.ObjectId;
|
|
54
|
+
} & {
|
|
55
|
+
__v: number;
|
|
56
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, FinancePaymentGatewayEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<FinancePaymentGatewayEntity>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<FinancePaymentGatewayEntity> & {
|
|
57
|
+
_id: import("mongoose").Types.ObjectId;
|
|
58
|
+
} & {
|
|
59
|
+
__v: number;
|
|
60
|
+
}>;
|
|
61
|
+
export type FinancePaymentAttemptStatus = PaymentChargeStatusEnum | 'UNKNOWN';
|
|
62
|
+
export declare class FinancePaymentAttemptEntity {
|
|
63
|
+
reference?: string | null;
|
|
64
|
+
method: FinancePaymentMethodEnum;
|
|
65
|
+
status: FinancePaymentAttemptStatus;
|
|
66
|
+
rawStatus: string;
|
|
67
|
+
amount: number;
|
|
68
|
+
message?: string | null;
|
|
69
|
+
card?: FinancePaymentGatewayCardEntity | null;
|
|
70
|
+
expiresAt?: Date | null;
|
|
71
|
+
createdAt: Date;
|
|
72
|
+
syncedAt: Date;
|
|
73
|
+
}
|
|
74
|
+
export declare const FinancePaymentAttemptSchema: MongoSchema<FinancePaymentAttemptEntity, import("mongoose").Model<FinancePaymentAttemptEntity, any, any, any, import("mongoose").Document<unknown, any, FinancePaymentAttemptEntity, any, {}> & FinancePaymentAttemptEntity & {
|
|
75
|
+
_id: import("mongoose").Types.ObjectId;
|
|
76
|
+
} & {
|
|
77
|
+
__v: number;
|
|
78
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, FinancePaymentAttemptEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<FinancePaymentAttemptEntity>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<FinancePaymentAttemptEntity> & {
|
|
79
|
+
_id: import("mongoose").Types.ObjectId;
|
|
80
|
+
} & {
|
|
81
|
+
__v: number;
|
|
82
|
+
}>;
|
|
10
83
|
export declare class FinancePaymentEntity extends AbstractEntity implements ITransitionable<FinancePaymentStatusEnum> {
|
|
11
84
|
type: FinancePaymentTypeEnum;
|
|
12
85
|
target: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FinancePaymentAttemptStatus } from './payment.
|
|
1
|
+
import type { FinancePaymentAttemptStatus } from './payment.entity.js';
|
|
2
2
|
import type { FinancePaymentMethodEnum, FinancePaymentStatusEnum } from './payment.enum.js';
|
|
3
3
|
export type FinancePaymentReportStatus = FinancePaymentAttemptStatus;
|
|
4
4
|
export interface FinancePaymentReportTotal {
|
package/dist/index.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export * from './inventory/catalog/brand';
|
|
|
22
22
|
export * from './inventory/catalog/category';
|
|
23
23
|
export * from './inventory/catalog/product';
|
|
24
24
|
export * from './inventory/catalog/variant';
|
|
25
|
+
export * from './logistics/shipment';
|
|
25
26
|
export * from './order/purchase';
|
|
26
27
|
export * from './order/sale';
|
|
27
28
|
export * from './order/item';
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,7 @@ export * from './inventory/catalog/brand/index.js';
|
|
|
14
14
|
export * from './inventory/catalog/category/index.js';
|
|
15
15
|
export * from './inventory/catalog/product/index.js';
|
|
16
16
|
export * from './inventory/catalog/variant/index.js';
|
|
17
|
+
export * from './logistics/shipment/index.js';
|
|
17
18
|
export * from './order/purchase/index.js';
|
|
18
19
|
export * from './order/sale/index.js';
|
|
19
20
|
export * from './order/item/index.js';
|
|
@@ -15,7 +15,7 @@ const card_validator_1 = __importDefault(require("card-validator"));
|
|
|
15
15
|
import * as class_transformer_1 from "class-transformer";
|
|
16
16
|
import * as class_validator_1 from "class-validator";
|
|
17
17
|
import * as payment_enum_1 from '../../finance/payment/index.js';
|
|
18
|
-
import * as
|
|
18
|
+
import * as delivery_request_validator_1 from '../../order/sale/index.js';
|
|
19
19
|
import * as abstract_validator_1 from '../../abstract.validator.js';
|
|
20
20
|
import * as request_validator_1 from './request.validator.js';
|
|
21
21
|
export function isCardNumber(value) {
|
|
@@ -51,13 +51,13 @@ function IsCpfOrCnpj() {
|
|
|
51
51
|
name: 'isCpfOrCnpj',
|
|
52
52
|
validator: {
|
|
53
53
|
defaultMessage: () => '$property must be a valid CPF or CNPJ',
|
|
54
|
-
validate: (value) => (0,
|
|
54
|
+
validate: (value) => (0, delivery_request_validator_1.isCpf)(value) || (0, request_validator_1.isCnpj)(value),
|
|
55
55
|
},
|
|
56
56
|
});
|
|
57
57
|
}
|
|
58
|
-
const twoDigits = ({ value }) => typeof value === 'number' ? String(value).padStart(2, '0') : (0,
|
|
58
|
+
const twoDigits = ({ value }) => typeof value === 'number' ? String(value).padStart(2, '0') : (0, delivery_request_validator_1.digits)({ value });
|
|
59
59
|
const fourDigits = ({ value }) => {
|
|
60
|
-
const year = typeof value === 'number' ? String(value) : (0,
|
|
60
|
+
const year = typeof value === 'number' ? String(value) : (0, delivery_request_validator_1.digits)({ value });
|
|
61
61
|
return typeof year === 'string' && year.length === 2 ? `20${year}` : year;
|
|
62
62
|
};
|
|
63
63
|
export class PaymentCardRequestValidator extends abstract_validator_1.AbstractRequestValidator {
|
|
@@ -71,12 +71,12 @@ export class PaymentCardRequestValidator extends abstract_validator_1.AbstractRe
|
|
|
71
71
|
__decorate([
|
|
72
72
|
(0, class_validator_1.IsString)(),
|
|
73
73
|
(0, class_validator_1.Length)(2, 100, { message: 'card.holderName must have 2 to 100 characters' }),
|
|
74
|
-
(0, class_transformer_1.Transform)(
|
|
74
|
+
(0, class_transformer_1.Transform)(delivery_request_validator_1.trim),
|
|
75
75
|
__metadata("design:type", String)
|
|
76
76
|
], PaymentCardRequestValidator.prototype, "holderName", void 0);
|
|
77
77
|
__decorate([
|
|
78
78
|
IsCardNumber(),
|
|
79
|
-
(0, class_transformer_1.Transform)(
|
|
79
|
+
(0, class_transformer_1.Transform)(delivery_request_validator_1.digits),
|
|
80
80
|
__metadata("design:type", String)
|
|
81
81
|
], PaymentCardRequestValidator.prototype, "number", void 0);
|
|
82
82
|
__decorate([
|
|
@@ -91,13 +91,13 @@ __decorate([
|
|
|
91
91
|
], PaymentCardRequestValidator.prototype, "expiryYear", void 0);
|
|
92
92
|
__decorate([
|
|
93
93
|
(0, class_validator_1.Matches)(/^\d{3,4}$/, { message: 'card.ccv must have 3 or 4 digits' }),
|
|
94
|
-
(0, class_transformer_1.Transform)(
|
|
94
|
+
(0, class_transformer_1.Transform)(delivery_request_validator_1.digits),
|
|
95
95
|
__metadata("design:type", String)
|
|
96
96
|
], PaymentCardRequestValidator.prototype, "ccv", void 0);
|
|
97
97
|
__decorate([
|
|
98
98
|
IsCpfOrCnpj(),
|
|
99
99
|
(0, class_validator_1.IsOptional)(),
|
|
100
|
-
(0, class_transformer_1.Transform)(
|
|
100
|
+
(0, class_transformer_1.Transform)(delivery_request_validator_1.digits),
|
|
101
101
|
__metadata("design:type", String)
|
|
102
102
|
], PaymentCardRequestValidator.prototype, "holderDocument", void 0);
|
|
103
103
|
const isCard = (body) => body.method === payment_enum_1.FinancePaymentMethodEnum.CARD;
|
|
@@ -11,7 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
import * as brazilian_utils_1 from "@brazilian-utils/brazilian-utils";
|
|
12
12
|
import * as class_transformer_1 from "class-transformer";
|
|
13
13
|
import * as class_validator_1 from "class-validator";
|
|
14
|
-
import * as
|
|
14
|
+
import * as delivery_request_validator_1 from '../../order/sale/index.js';
|
|
15
15
|
import * as abstract_validator_1 from '../../abstract.validator.js';
|
|
16
16
|
import * as account_enum_1 from './account.enum.js';
|
|
17
17
|
const lower = ({ value }) => typeof value === 'string' ? value.trim().toLowerCase() : value;
|
|
@@ -32,7 +32,7 @@ export function isPixKey(type, key) {
|
|
|
32
32
|
return false;
|
|
33
33
|
switch (type) {
|
|
34
34
|
case account_enum_1.PaymentPixKeyTypeEnum.CPF:
|
|
35
|
-
return (0,
|
|
35
|
+
return (0, delivery_request_validator_1.isCpf)(key);
|
|
36
36
|
case account_enum_1.PaymentPixKeyTypeEnum.CNPJ:
|
|
37
37
|
return isCnpj(key);
|
|
38
38
|
case account_enum_1.PaymentPixKeyTypeEnum.EMAIL:
|
|
@@ -70,7 +70,7 @@ function IsAccountDocument() {
|
|
|
70
70
|
name: 'isAccountDocument',
|
|
71
71
|
validator: {
|
|
72
72
|
defaultMessage: () => '$property must be a valid CPF (individual) or CNPJ (company)',
|
|
73
|
-
validate: (value, args) => (isCompany(args.object) ? isCnpj(value) : (0,
|
|
73
|
+
validate: (value, args) => (isCompany(args.object) ? isCnpj(value) : (0, delivery_request_validator_1.isCpf)(value)),
|
|
74
74
|
},
|
|
75
75
|
});
|
|
76
76
|
}
|
|
@@ -85,32 +85,32 @@ export class PaymentAccountAddressRequestValidator extends abstract_validator_1.
|
|
|
85
85
|
}
|
|
86
86
|
__decorate([
|
|
87
87
|
(0, class_validator_1.Matches)(/^\d{8}$/, { message: '$property must be a CEP with 8 digits' }),
|
|
88
|
-
(0, class_transformer_1.Transform)(
|
|
88
|
+
(0, class_transformer_1.Transform)(delivery_request_validator_1.digits),
|
|
89
89
|
__metadata("design:type", String)
|
|
90
90
|
], PaymentAccountAddressRequestValidator.prototype, "postalCode", void 0);
|
|
91
91
|
__decorate([
|
|
92
92
|
(0, class_validator_1.IsString)(),
|
|
93
93
|
(0, class_validator_1.Length)(2, 200),
|
|
94
|
-
(0, class_transformer_1.Transform)(
|
|
94
|
+
(0, class_transformer_1.Transform)(delivery_request_validator_1.trim),
|
|
95
95
|
__metadata("design:type", String)
|
|
96
96
|
], PaymentAccountAddressRequestValidator.prototype, "street", void 0);
|
|
97
97
|
__decorate([
|
|
98
98
|
(0, class_validator_1.IsString)(),
|
|
99
99
|
(0, class_validator_1.Length)(1, 20),
|
|
100
|
-
(0, class_transformer_1.Transform)(
|
|
100
|
+
(0, class_transformer_1.Transform)(delivery_request_validator_1.trim),
|
|
101
101
|
__metadata("design:type", String)
|
|
102
102
|
], PaymentAccountAddressRequestValidator.prototype, "number", void 0);
|
|
103
103
|
__decorate([
|
|
104
104
|
(0, class_validator_1.IsString)(),
|
|
105
105
|
(0, class_validator_1.Length)(1, 120),
|
|
106
106
|
(0, class_validator_1.IsOptional)(),
|
|
107
|
-
(0, class_transformer_1.Transform)(
|
|
107
|
+
(0, class_transformer_1.Transform)(delivery_request_validator_1.trim),
|
|
108
108
|
__metadata("design:type", String)
|
|
109
109
|
], PaymentAccountAddressRequestValidator.prototype, "complement", void 0);
|
|
110
110
|
__decorate([
|
|
111
111
|
(0, class_validator_1.IsString)(),
|
|
112
112
|
(0, class_validator_1.Length)(2, 120),
|
|
113
|
-
(0, class_transformer_1.Transform)(
|
|
113
|
+
(0, class_transformer_1.Transform)(delivery_request_validator_1.trim),
|
|
114
114
|
__metadata("design:type", String)
|
|
115
115
|
], PaymentAccountAddressRequestValidator.prototype, "district", void 0);
|
|
116
116
|
class PaymentAccountContactRequestValidator extends abstract_validator_1.AbstractRequestValidator {
|
|
@@ -127,7 +127,7 @@ __decorate([
|
|
|
127
127
|
], PaymentAccountContactRequestValidator.prototype, "email", void 0);
|
|
128
128
|
__decorate([
|
|
129
129
|
(0, class_validator_1.Matches)(/^\d{10,11}$/, { message: '$property must be the DDD and number (10 or 11 digits)' }),
|
|
130
|
-
(0, class_transformer_1.Transform)(
|
|
130
|
+
(0, class_transformer_1.Transform)(delivery_request_validator_1.digits),
|
|
131
131
|
__metadata("design:type", String)
|
|
132
132
|
], PaymentAccountContactRequestValidator.prototype, "mobilePhone", void 0);
|
|
133
133
|
__decorate([
|
|
@@ -160,18 +160,18 @@ __decorate([
|
|
|
160
160
|
__decorate([
|
|
161
161
|
(0, class_validator_1.IsString)(),
|
|
162
162
|
(0, class_validator_1.Length)(2, 120),
|
|
163
|
-
(0, class_transformer_1.Transform)(
|
|
163
|
+
(0, class_transformer_1.Transform)(delivery_request_validator_1.trim),
|
|
164
164
|
__metadata("design:type", String)
|
|
165
165
|
], CreatePaymentAccountRequestValidator.prototype, "name", void 0);
|
|
166
166
|
__decorate([
|
|
167
167
|
IsAccountDocument(),
|
|
168
|
-
(0, class_transformer_1.Transform)(
|
|
168
|
+
(0, class_transformer_1.Transform)(delivery_request_validator_1.digits),
|
|
169
169
|
__metadata("design:type", String)
|
|
170
170
|
], CreatePaymentAccountRequestValidator.prototype, "cpfCnpj", void 0);
|
|
171
171
|
__decorate([
|
|
172
172
|
(0, class_validator_1.ValidateIf)(isIndividual),
|
|
173
|
-
(0,
|
|
174
|
-
(0, class_transformer_1.Transform)(
|
|
173
|
+
(0, delivery_request_validator_1.IsBirthday)(),
|
|
174
|
+
(0, class_transformer_1.Transform)(delivery_request_validator_1.trim),
|
|
175
175
|
__metadata("design:type", String)
|
|
176
176
|
], CreatePaymentAccountRequestValidator.prototype, "birthDate", void 0);
|
|
177
177
|
__decorate([
|
|
@@ -197,7 +197,7 @@ __decorate([
|
|
|
197
197
|
__decorate([
|
|
198
198
|
(0, class_validator_1.Matches)(/^\d{10,11}$/, { message: '$property must be the DDD and number (10 or 11 digits)' }),
|
|
199
199
|
(0, class_validator_1.IsOptional)(),
|
|
200
|
-
(0, class_transformer_1.Transform)(
|
|
200
|
+
(0, class_transformer_1.Transform)(delivery_request_validator_1.digits),
|
|
201
201
|
__metadata("design:type", String)
|
|
202
202
|
], UpdatePaymentAccountRequestValidator.prototype, "mobilePhone", void 0);
|
|
203
203
|
__decorate([
|
|
@@ -207,9 +207,9 @@ __decorate([
|
|
|
207
207
|
__metadata("design:type", Number)
|
|
208
208
|
], UpdatePaymentAccountRequestValidator.prototype, "incomeValue", void 0);
|
|
209
209
|
__decorate([
|
|
210
|
-
(0,
|
|
210
|
+
(0, delivery_request_validator_1.IsBirthday)(),
|
|
211
211
|
(0, class_validator_1.IsOptional)(),
|
|
212
|
-
(0, class_transformer_1.Transform)(
|
|
212
|
+
(0, class_transformer_1.Transform)(delivery_request_validator_1.trim),
|
|
213
213
|
__metadata("design:type", String)
|
|
214
214
|
], UpdatePaymentAccountRequestValidator.prototype, "birthDate", void 0);
|
|
215
215
|
__decorate([
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { LogisticsParcelInput } from '../../logistics/shipment';
|
|
2
|
+
import type { OrderPurchaseStatusEnum } from '../../order/purchase';
|
|
2
3
|
export interface SupplierOrderLine {
|
|
3
4
|
externalProductId: string;
|
|
4
5
|
externalVariantId: string;
|
|
@@ -29,13 +30,28 @@ export interface SupplierOrderRequest {
|
|
|
29
30
|
}
|
|
30
31
|
export interface SupplierOrderPlacement {
|
|
31
32
|
externalOrderIds: string[];
|
|
32
|
-
status:
|
|
33
|
+
status: OrderPurchaseStatusEnum;
|
|
33
34
|
warning?: string;
|
|
34
35
|
}
|
|
35
36
|
export interface SupplierOrderSnapshot {
|
|
36
|
-
status?:
|
|
37
|
+
status?: OrderPurchaseStatusEnum;
|
|
38
|
+
received: boolean;
|
|
37
39
|
rawStatus: string;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
parcels: LogisticsParcelInput[];
|
|
41
|
+
}
|
|
42
|
+
export interface SupplierOrderImportLine {
|
|
43
|
+
externalProductId: string;
|
|
44
|
+
externalVariantId: string;
|
|
45
|
+
name: string;
|
|
46
|
+
quantity: number;
|
|
47
|
+
paid: number;
|
|
48
|
+
shipping: number;
|
|
49
|
+
}
|
|
50
|
+
export interface SupplierOrderImport extends SupplierOrderSnapshot {
|
|
51
|
+
externalOrderId: string;
|
|
52
|
+
currency: string;
|
|
53
|
+
lines: SupplierOrderImportLine[];
|
|
54
|
+
placedAt: Date;
|
|
55
|
+
store?: string;
|
|
56
|
+
total: number;
|
|
41
57
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './shipment.enum.js';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { LogisticsShipmentStatusEnum, LogisticsTrackingEventCodeEnum } from './shipment.enum.js';
|
|
2
|
+
export interface LogisticsTrackingInput {
|
|
3
|
+
at: Date;
|
|
4
|
+
description: string;
|
|
5
|
+
location?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface LogisticsParcelInput {
|
|
8
|
+
trackingNumber: string;
|
|
9
|
+
carrier?: string;
|
|
10
|
+
trackingUrl?: string;
|
|
11
|
+
events: LogisticsTrackingInput[];
|
|
12
|
+
received?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface LogisticsBuyerShipment {
|
|
15
|
+
status: LogisticsShipmentStatusEnum;
|
|
16
|
+
trackingNumber?: string;
|
|
17
|
+
carrier?: string;
|
|
18
|
+
trackingUrl?: string;
|
|
19
|
+
shippedAt?: Date;
|
|
20
|
+
deliveredAt?: Date;
|
|
21
|
+
events: {
|
|
22
|
+
at: Date;
|
|
23
|
+
code: LogisticsTrackingEventCodeEnum;
|
|
24
|
+
location?: string;
|
|
25
|
+
}[];
|
|
26
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Schema as MongoSchema } from 'mongoose';
|
|
2
|
+
import { AbstractEntity } from '../../abstract.entity.js';
|
|
3
|
+
import { LogisticsShipmentDirectionEnum, LogisticsShipmentSourceEnum, LogisticsShipmentStatusEnum, LogisticsTrackingEventCodeEnum } from './shipment.enum.js';
|
|
4
|
+
import type { OrderPurchaseEntity } from '../../order/purchase';
|
|
5
|
+
import type { OrderSaleEntity } from '../../order/sale';
|
|
6
|
+
import type { StatusEntity } from '../../status.plugin.js';
|
|
7
|
+
export declare class LogisticsShipmentEventEntity {
|
|
8
|
+
at: Date;
|
|
9
|
+
code: LogisticsTrackingEventCodeEnum;
|
|
10
|
+
description: string;
|
|
11
|
+
location?: string | null;
|
|
12
|
+
}
|
|
13
|
+
export declare const LogisticsShipmentEventSchema: MongoSchema<LogisticsShipmentEventEntity, import("mongoose").Model<LogisticsShipmentEventEntity, any, any, any, import("mongoose").Document<unknown, any, LogisticsShipmentEventEntity, any, {}> & LogisticsShipmentEventEntity & {
|
|
14
|
+
_id: import("mongoose").Types.ObjectId;
|
|
15
|
+
} & {
|
|
16
|
+
__v: number;
|
|
17
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, LogisticsShipmentEventEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<LogisticsShipmentEventEntity>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<LogisticsShipmentEventEntity> & {
|
|
18
|
+
_id: import("mongoose").Types.ObjectId;
|
|
19
|
+
} & {
|
|
20
|
+
__v: number;
|
|
21
|
+
}>;
|
|
22
|
+
export declare class LogisticsShipmentEntity extends AbstractEntity {
|
|
23
|
+
order: OrderSaleEntity;
|
|
24
|
+
purchase?: OrderPurchaseEntity | null;
|
|
25
|
+
direction: LogisticsShipmentDirectionEnum;
|
|
26
|
+
source: LogisticsShipmentSourceEnum;
|
|
27
|
+
trackingNumber?: string | null;
|
|
28
|
+
carrier?: string | null;
|
|
29
|
+
trackingUrl?: string | null;
|
|
30
|
+
shippedAt?: Date | null;
|
|
31
|
+
deliveredAt?: Date | null;
|
|
32
|
+
receivedBy?: LogisticsShipmentSourceEnum | null;
|
|
33
|
+
events: LogisticsShipmentEventEntity[];
|
|
34
|
+
status: LogisticsShipmentStatusEnum;
|
|
35
|
+
history: StatusEntity<LogisticsShipmentStatusEnum>[];
|
|
36
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare enum LogisticsShipmentStatusEnum {
|
|
2
|
+
PENDING = "PENDING",
|
|
3
|
+
IN_TRANSIT = "IN_TRANSIT",
|
|
4
|
+
DELIVERED = "DELIVERED",
|
|
5
|
+
EXCEPTION = "EXCEPTION"
|
|
6
|
+
}
|
|
7
|
+
export declare enum LogisticsShipmentDirectionEnum {
|
|
8
|
+
OUTBOUND = "OUTBOUND",
|
|
9
|
+
RETURN = "RETURN"
|
|
10
|
+
}
|
|
11
|
+
export declare enum LogisticsShipmentSourceEnum {
|
|
12
|
+
SUPPLIER = "SUPPLIER",
|
|
13
|
+
MERCHANT = "MERCHANT",
|
|
14
|
+
CARRIER = "CARRIER",
|
|
15
|
+
BUYER = "BUYER"
|
|
16
|
+
}
|
|
17
|
+
export declare enum LogisticsTrackingEventCodeEnum {
|
|
18
|
+
POSTED = "POSTED",
|
|
19
|
+
IN_TRANSIT = "IN_TRANSIT",
|
|
20
|
+
CUSTOMS = "CUSTOMS",
|
|
21
|
+
OUT_FOR_DELIVERY = "OUT_FOR_DELIVERY",
|
|
22
|
+
DELIVERED = "DELIVERED",
|
|
23
|
+
EXCEPTION = "EXCEPTION"
|
|
24
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export var LogisticsShipmentStatusEnum;
|
|
2
|
+
(function (LogisticsShipmentStatusEnum) {
|
|
3
|
+
LogisticsShipmentStatusEnum["PENDING"] = "PENDING";
|
|
4
|
+
LogisticsShipmentStatusEnum["IN_TRANSIT"] = "IN_TRANSIT";
|
|
5
|
+
LogisticsShipmentStatusEnum["DELIVERED"] = "DELIVERED";
|
|
6
|
+
LogisticsShipmentStatusEnum["EXCEPTION"] = "EXCEPTION";
|
|
7
|
+
})(LogisticsShipmentStatusEnum || (LogisticsShipmentStatusEnum = {}));
|
|
8
|
+
export var LogisticsShipmentDirectionEnum;
|
|
9
|
+
(function (LogisticsShipmentDirectionEnum) {
|
|
10
|
+
LogisticsShipmentDirectionEnum["OUTBOUND"] = "OUTBOUND";
|
|
11
|
+
LogisticsShipmentDirectionEnum["RETURN"] = "RETURN";
|
|
12
|
+
})(LogisticsShipmentDirectionEnum || (LogisticsShipmentDirectionEnum = {}));
|
|
13
|
+
export var LogisticsShipmentSourceEnum;
|
|
14
|
+
(function (LogisticsShipmentSourceEnum) {
|
|
15
|
+
LogisticsShipmentSourceEnum["SUPPLIER"] = "SUPPLIER";
|
|
16
|
+
LogisticsShipmentSourceEnum["MERCHANT"] = "MERCHANT";
|
|
17
|
+
LogisticsShipmentSourceEnum["CARRIER"] = "CARRIER";
|
|
18
|
+
LogisticsShipmentSourceEnum["BUYER"] = "BUYER";
|
|
19
|
+
})(LogisticsShipmentSourceEnum || (LogisticsShipmentSourceEnum = {}));
|
|
20
|
+
export var LogisticsTrackingEventCodeEnum;
|
|
21
|
+
(function (LogisticsTrackingEventCodeEnum) {
|
|
22
|
+
LogisticsTrackingEventCodeEnum["POSTED"] = "POSTED";
|
|
23
|
+
LogisticsTrackingEventCodeEnum["IN_TRANSIT"] = "IN_TRANSIT";
|
|
24
|
+
LogisticsTrackingEventCodeEnum["CUSTOMS"] = "CUSTOMS";
|
|
25
|
+
LogisticsTrackingEventCodeEnum["OUT_FOR_DELIVERY"] = "OUT_FOR_DELIVERY";
|
|
26
|
+
LogisticsTrackingEventCodeEnum["DELIVERED"] = "DELIVERED";
|
|
27
|
+
LogisticsTrackingEventCodeEnum["EXCEPTION"] = "EXCEPTION";
|
|
28
|
+
})(LogisticsTrackingEventCodeEnum || (LogisticsTrackingEventCodeEnum = {}));
|
|
@@ -3,6 +3,4 @@ export * from './purchase.enum';
|
|
|
3
3
|
export * from './purchase.transition';
|
|
4
4
|
export * from './request.validator';
|
|
5
5
|
export * from './item.request.validator';
|
|
6
|
-
export * from './purchase.supplier.order.entity';
|
|
7
|
-
export * from './supplier.order.enum';
|
|
8
6
|
export * from './supplier.order.request.validator';
|
|
@@ -1,9 +1,28 @@
|
|
|
1
|
+
import { Schema as MongoSchema } from 'mongoose';
|
|
1
2
|
import { ContactVendorEntity } from '../../contact/vendor';
|
|
3
|
+
import { SupplierProviderEnum } from '../../integration/supplier';
|
|
2
4
|
import { ItemEntity } from '../item';
|
|
3
5
|
import { TransactionEntity } from '../../transaction.entity.js';
|
|
4
6
|
import { OrderPurchaseStatusEnum } from './purchase.enum.js';
|
|
5
|
-
import { OrderPurchaseSupplierOrderEntity } from './purchase.supplier.order.entity.js';
|
|
6
7
|
import type { OrderSaleEntity } from '../sale';
|
|
8
|
+
export declare class OrderPurchaseSupplierOrderEntity {
|
|
9
|
+
provider: SupplierProviderEnum;
|
|
10
|
+
externalOrderIds: string[];
|
|
11
|
+
reference?: string;
|
|
12
|
+
rawStatus?: string;
|
|
13
|
+
placedAt: Date;
|
|
14
|
+
syncedAt?: Date;
|
|
15
|
+
error?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare const OrderPurchaseSupplierOrderSchema: MongoSchema<OrderPurchaseSupplierOrderEntity, import("mongoose").Model<OrderPurchaseSupplierOrderEntity, any, any, any, import("mongoose").Document<unknown, any, OrderPurchaseSupplierOrderEntity, any, {}> & OrderPurchaseSupplierOrderEntity & {
|
|
18
|
+
_id: import("mongoose").Types.ObjectId;
|
|
19
|
+
} & {
|
|
20
|
+
__v: number;
|
|
21
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, OrderPurchaseSupplierOrderEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<OrderPurchaseSupplierOrderEntity>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<OrderPurchaseSupplierOrderEntity> & {
|
|
22
|
+
_id: import("mongoose").Types.ObjectId;
|
|
23
|
+
} & {
|
|
24
|
+
__v: number;
|
|
25
|
+
}>;
|
|
7
26
|
export declare class OrderPurchaseEntity extends TransactionEntity<OrderPurchaseStatusEnum> {
|
|
8
27
|
vendor?: ContactVendorEntity;
|
|
9
28
|
customerOrder?: OrderSaleEntity;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
export declare enum OrderPurchaseStatusEnum {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
TO_PLACE = "TO_PLACE",
|
|
3
|
+
PLACED = "PLACED",
|
|
4
|
+
AWAITING_PAYMENT = "AWAITING_PAYMENT",
|
|
5
|
+
PAID = "PAID",
|
|
6
|
+
SHIPPED = "SHIPPED",
|
|
7
|
+
FAILED = "FAILED",
|
|
5
8
|
CANCELLED = "CANCELLED"
|
|
6
9
|
}
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const
|
|
10
|
+
export declare const PURCHASE_PLACEABLE_STATUSES: readonly OrderPurchaseStatusEnum[];
|
|
11
|
+
export declare const PURCHASE_SYNCABLE_STATUSES: readonly OrderPurchaseStatusEnum[];
|
|
12
|
+
export declare const PURCHASE_PROGRESS: readonly OrderPurchaseStatusEnum[];
|