@merkaly/api 0.6.0 → 0.6.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.repository.d.ts +1 -1
- package/dist/account/address/request.validator.d.ts +2 -0
- package/dist/account/address/request.validator.js +13 -0
- package/dist/account/payment/request.validator.d.ts +2 -0
- package/dist/account/payment/request.validator.js +12 -0
- package/dist/account/user/request.validator.d.ts +2 -0
- package/dist/account/user/request.validator.js +11 -0
- package/dist/finance/invoice/request.validator.d.ts +2 -0
- package/dist/finance/invoice/request.validator.js +15 -0
- package/dist/finance/payment/payment.entity.d.ts +5 -4
- package/dist/finance/payment/request.validator.d.ts +2 -0
- package/dist/finance/payment/request.validator.js +11 -0
- package/dist/finance/refund/refund.entity.d.ts +2 -1
- package/dist/finance/refund/request.validator.d.ts +2 -0
- package/dist/finance/refund/request.validator.js +11 -0
- package/dist/inventory/catalog/attribute/request.validator.d.ts +2 -0
- package/dist/inventory/catalog/attribute/request.validator.js +11 -0
- package/dist/inventory/catalog/brand/request.validator.d.ts +2 -0
- package/dist/inventory/catalog/brand/request.validator.js +8 -0
- package/dist/inventory/catalog/category/category.entity.d.ts +3 -1
- package/dist/inventory/catalog/category/request.validator.d.ts +2 -0
- package/dist/inventory/catalog/category/request.validator.js +8 -0
- package/dist/inventory/catalog/collection/request.validator.d.ts +2 -0
- package/dist/inventory/catalog/collection/request.validator.js +10 -0
- package/dist/inventory/catalog/product/product.entity.d.ts +9 -5
- package/dist/inventory/catalog/product/request.validator.d.ts +12 -4
- package/dist/inventory/catalog/product/request.validator.js +50 -16
- package/dist/inventory/catalog/variant/request.validator.d.ts +3 -0
- package/dist/inventory/catalog/variant/request.validator.js +22 -0
- package/dist/inventory/catalog/variant/variant.entity.d.ts +5 -4
- package/dist/inventory/configuration/measurement/request.validator.d.ts +4 -0
- package/dist/inventory/configuration/measurement/request.validator.js +22 -0
- package/dist/inventory/stock/balance/balance.entity.d.ts +2 -0
- package/dist/inventory/stock/balance/balance.status.enum.d.ts +6 -0
- package/dist/inventory/stock/balance/balance.status.enum.js +7 -0
- package/dist/inventory/stock/balance/index.d.ts +1 -0
- package/dist/inventory/stock/balance/index.js +1 -1
- package/dist/inventory/stock/transfer/request.validator.d.ts +6 -2
- package/dist/inventory/stock/transfer/request.validator.js +22 -0
- package/dist/inventory/stock/transfer/transfer.item.entity.d.ts +2 -0
- package/dist/inventory/stock/warehouse/request.validator.d.ts +2 -0
- package/dist/inventory/stock/warehouse/request.validator.js +26 -0
- package/dist/order/purchase/item/item.entity.d.ts +3 -1
- package/dist/order/purchase/item/request.validator.d.ts +3 -0
- package/dist/order/purchase/item/request.validator.js +22 -0
- package/dist/order/purchase/transaction/request.validator.d.ts +5 -2
- package/dist/order/purchase/transaction/request.validator.js +26 -4
- package/dist/order/purchase/vendor/request.validator.d.ts +2 -0
- package/dist/order/purchase/vendor/request.validator.js +14 -0
- package/dist/order/sale/customer/request.validator.d.ts +2 -0
- package/dist/order/sale/customer/request.validator.js +17 -0
- package/dist/order/sale/item/item.entity.d.ts +3 -1
- package/dist/order/sale/item/request.validator.d.ts +3 -0
- package/dist/order/sale/item/request.validator.js +20 -0
- package/dist/order/sale/transaction/request.validator.d.ts +7 -2
- package/dist/order/sale/transaction/request.validator.js +31 -1
- package/dist/transaction.entity.d.ts +3 -1
- package/package.json +1 -1
- package/dist/finance/subscription/index.d.ts +0 -2
- package/dist/finance/subscription/index.js +0 -1
- package/dist/finance/subscription/subscription.entity.d.ts +0 -14
- package/dist/finance/subscription/subscription.enum.d.ts +0 -15
- package/dist/finance/subscription/subscription.enum.js +0 -17
- package/dist/finance/tax/index.d.ts +0 -2
- package/dist/finance/tax/index.js +0 -1
- package/dist/finance/tax/tax.entity.d.ts +0 -10
- package/dist/finance/tax/tax.enum.d.ts +0 -8
- package/dist/finance/tax/tax.enum.js +0 -9
|
@@ -48,7 +48,7 @@ export declare abstract class AbstractRepository<E extends AbstractEntity = Abst
|
|
|
48
48
|
pages: number;
|
|
49
49
|
total: number;
|
|
50
50
|
}>;
|
|
51
|
-
aggregate<
|
|
51
|
+
aggregate<P = any>(pipeline: PipelineStage[], session?: ClientSession): Promise<P[]>;
|
|
52
52
|
read(locator: EntityLocator<E>, options?: ReadMethodOptions): Promise<E>;
|
|
53
53
|
create(payload: UpdateQuery<E>, options: ReadMethodOptions): Promise<E>;
|
|
54
54
|
update(locator: EntityLocator<E>, payload: UpdateQuery<E>, options?: ReadMethodOptions): Promise<E>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AbstractRequestValidator } from '../..';
|
|
2
|
+
import type { AccountAddressEntity } from './';
|
|
2
3
|
export declare class CreateAddressRequestValidator extends AbstractRequestValidator {
|
|
3
4
|
street: string;
|
|
4
5
|
name: string;
|
|
@@ -7,6 +8,7 @@ export declare class CreateAddressRequestValidator extends AbstractRequestValida
|
|
|
7
8
|
code?: string;
|
|
8
9
|
longitude?: number;
|
|
9
10
|
latitude?: number;
|
|
11
|
+
constructor(address?: AccountAddressEntity);
|
|
10
12
|
}
|
|
11
13
|
export declare class UpdateAddressRequestValidator extends CreateAddressRequestValidator {
|
|
12
14
|
street: string;
|
|
@@ -17,6 +17,19 @@ export class CreateAddressRequestValidator extends abstract_validator_1.Abstract
|
|
|
17
17
|
code;
|
|
18
18
|
longitude;
|
|
19
19
|
latitude;
|
|
20
|
+
constructor(address) {
|
|
21
|
+
super();
|
|
22
|
+
if (!address) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
this.street = address.line1;
|
|
26
|
+
this.name = address.name;
|
|
27
|
+
this.complement = address.line2;
|
|
28
|
+
this.country = address.country;
|
|
29
|
+
this.code = address.code;
|
|
30
|
+
this.longitude = address.location?.lng;
|
|
31
|
+
this.latitude = address.location?.lat;
|
|
32
|
+
}
|
|
20
33
|
}
|
|
21
34
|
__decorate([
|
|
22
35
|
(0, class_validator_1.IsString)(),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AbstractRequestValidator } from '../..';
|
|
2
|
+
import type { AccountPaymentEntity } from './';
|
|
2
3
|
export declare class CreatePaymentRequestValidator extends AbstractRequestValidator {
|
|
3
4
|
holder: string;
|
|
4
5
|
hash: string;
|
|
@@ -6,6 +7,7 @@ export declare class CreatePaymentRequestValidator extends AbstractRequestValida
|
|
|
6
7
|
brand: string;
|
|
7
8
|
expMonth: number;
|
|
8
9
|
expYear: number;
|
|
10
|
+
constructor(payment?: AccountPaymentEntity);
|
|
9
11
|
}
|
|
10
12
|
export declare class UpdatePaymentRequestValidator extends CreatePaymentRequestValidator {
|
|
11
13
|
holder: string;
|
|
@@ -16,6 +16,18 @@ export class CreatePaymentRequestValidator extends abstract_validator_1.Abstract
|
|
|
16
16
|
brand;
|
|
17
17
|
expMonth;
|
|
18
18
|
expYear;
|
|
19
|
+
constructor(payment) {
|
|
20
|
+
super();
|
|
21
|
+
if (!payment) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
this.holder = payment.holder;
|
|
25
|
+
this.hash = payment.hash;
|
|
26
|
+
this.last4 = payment.last4;
|
|
27
|
+
this.brand = payment.brand;
|
|
28
|
+
this.expMonth = payment.expMonth;
|
|
29
|
+
this.expYear = payment.expYear;
|
|
30
|
+
}
|
|
19
31
|
}
|
|
20
32
|
__decorate([
|
|
21
33
|
(0, class_validator_1.IsString)(),
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { AbstractRequestValidator } from '../..';
|
|
2
|
+
import type { AccountUserEntity } from './';
|
|
2
3
|
export declare class UpdateUserRequestValidator extends AbstractRequestValidator {
|
|
3
4
|
name: string;
|
|
4
5
|
picture: string;
|
|
5
6
|
email: string;
|
|
6
7
|
phone?: string;
|
|
7
8
|
active: boolean;
|
|
9
|
+
constructor(user?: AccountUserEntity);
|
|
8
10
|
}
|
|
@@ -15,6 +15,17 @@ export class UpdateUserRequestValidator extends abstract_validator_1.AbstractReq
|
|
|
15
15
|
email;
|
|
16
16
|
phone;
|
|
17
17
|
active;
|
|
18
|
+
constructor(user) {
|
|
19
|
+
super();
|
|
20
|
+
if (!user) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
this.name = user.name;
|
|
24
|
+
this.picture = user.picture;
|
|
25
|
+
this.email = user.email;
|
|
26
|
+
this.phone = user.phone;
|
|
27
|
+
this.active = user.active;
|
|
28
|
+
}
|
|
18
29
|
}
|
|
19
30
|
__decorate([
|
|
20
31
|
(0, class_validator_1.IsString)(),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FinanceInvoiceStatusEnum, FinanceInvoiceTypeEnum } from './';
|
|
2
2
|
import { AbstractRequestValidator } from '../..';
|
|
3
|
+
import type { FinanceInvoiceEntity } from './';
|
|
3
4
|
export declare class CreateFinanceInvoiceRequestValidator extends AbstractRequestValidator {
|
|
4
5
|
order: string;
|
|
5
6
|
orderModel: string;
|
|
@@ -11,6 +12,7 @@ export declare class CreateFinanceInvoiceRequestValidator extends AbstractReques
|
|
|
11
12
|
dueDate?: Date;
|
|
12
13
|
notes?: string;
|
|
13
14
|
status?: FinanceInvoiceStatusEnum;
|
|
15
|
+
constructor(invoice?: FinanceInvoiceEntity);
|
|
14
16
|
}
|
|
15
17
|
export declare class UpdateFinanceInvoiceRequestValidator extends CreateFinanceInvoiceRequestValidator {
|
|
16
18
|
order: string;
|
|
@@ -21,6 +21,21 @@ export class CreateFinanceInvoiceRequestValidator extends abstract_validator_1.A
|
|
|
21
21
|
dueDate;
|
|
22
22
|
notes;
|
|
23
23
|
status;
|
|
24
|
+
constructor(invoice) {
|
|
25
|
+
super();
|
|
26
|
+
if (!invoice) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
this.order = (invoice.order?._id || invoice.order);
|
|
30
|
+
this.orderModel = invoice.orderModel;
|
|
31
|
+
this.type = invoice.type;
|
|
32
|
+
this.total = invoice.total;
|
|
33
|
+
this.subtotal = invoice.subtotal;
|
|
34
|
+
this.tax = invoice.tax;
|
|
35
|
+
this.dueDate = invoice.dueDate;
|
|
36
|
+
this.notes = invoice.notes;
|
|
37
|
+
this.status = invoice.status;
|
|
38
|
+
}
|
|
24
39
|
}
|
|
25
40
|
__decorate([
|
|
26
41
|
(0, class_validator_1.IsMongoId)(),
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { PurchaseTransactionEntity } from '../../order/purchase/transaction';
|
|
2
2
|
import { SaleTransactionEntity } from '../../order/sale/transaction';
|
|
3
|
-
import { AbstractEntity
|
|
3
|
+
import { AbstractEntity } from '../..';
|
|
4
4
|
import { StatusEntity } from '../..';
|
|
5
|
+
import { ITransitionable } from '../..';
|
|
5
6
|
import { FinancePaymentMethodEnum, FinancePaymentStatusEnum, FinancePaymentTypeEnum } from './payment.enum.js';
|
|
6
7
|
export type OrderEntity = SaleTransactionEntity | PurchaseTransactionEntity;
|
|
7
|
-
export declare class FinancePaymentEntity extends AbstractEntity {
|
|
8
|
+
export declare class FinancePaymentEntity extends AbstractEntity implements ITransitionable<FinancePaymentStatusEnum> {
|
|
8
9
|
type: FinancePaymentTypeEnum;
|
|
9
10
|
target: string;
|
|
10
|
-
order:
|
|
11
|
-
|
|
11
|
+
order: OrderEntity;
|
|
12
|
+
amount: number;
|
|
12
13
|
fee: number;
|
|
13
14
|
method?: FinancePaymentMethodEnum;
|
|
14
15
|
status: FinancePaymentStatusEnum;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { FinancePaymentMethodEnum, FinancePaymentStatusEnum, FinancePaymentTypeEnum } from './';
|
|
2
2
|
import { AbstractRequestValidator } from '../..';
|
|
3
|
+
import type { FinancePaymentEntity } from './';
|
|
3
4
|
export declare class CreateFinancePaymentRequestValidator extends AbstractRequestValidator {
|
|
4
5
|
type: FinancePaymentTypeEnum;
|
|
5
6
|
order?: string;
|
|
6
7
|
method?: FinancePaymentMethodEnum;
|
|
7
8
|
total?: number;
|
|
8
9
|
status?: FinancePaymentStatusEnum;
|
|
10
|
+
constructor(payment?: FinancePaymentEntity);
|
|
9
11
|
}
|
|
10
12
|
export declare class UpdateFinancePaymentRequestValidator extends CreateFinancePaymentRequestValidator {
|
|
11
13
|
type: FinancePaymentTypeEnum;
|
|
@@ -16,6 +16,17 @@ export class CreateFinancePaymentRequestValidator extends abstract_validator_1.A
|
|
|
16
16
|
method;
|
|
17
17
|
total;
|
|
18
18
|
status;
|
|
19
|
+
constructor(payment) {
|
|
20
|
+
super();
|
|
21
|
+
if (!payment) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
this.type = payment.type;
|
|
25
|
+
this.order = (payment.order?._id || payment.order);
|
|
26
|
+
this.method = payment.method;
|
|
27
|
+
this.total = payment.amount;
|
|
28
|
+
this.status = payment.status;
|
|
29
|
+
}
|
|
19
30
|
}
|
|
20
31
|
__decorate([
|
|
21
32
|
(0, class_validator_1.IsEnum)(payment_enum_1.FinancePaymentTypeEnum),
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { AbstractEntity, MongoEntity } from '../..';
|
|
2
2
|
import { StatusEntity } from '../..';
|
|
3
|
+
import { ITransitionable } from '../..';
|
|
3
4
|
import { FinanceRefundReasonEnum, FinanceRefundStatusEnum } from './refund.enum.js';
|
|
4
5
|
import type { FinancePaymentEntity } from '../payment';
|
|
5
|
-
export declare class FinanceRefundEntity extends AbstractEntity {
|
|
6
|
+
export declare class FinanceRefundEntity extends AbstractEntity implements ITransitionable<FinanceRefundStatusEnum> {
|
|
6
7
|
payment: MongoEntity<FinancePaymentEntity>;
|
|
7
8
|
amount: number;
|
|
8
9
|
status: FinanceRefundStatusEnum;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { FinanceRefundReasonEnum, FinanceRefundStatusEnum } from './';
|
|
2
2
|
import { AbstractRequestValidator } from '../..';
|
|
3
|
+
import type { FinanceRefundEntity } from './';
|
|
3
4
|
export declare class CreateFinanceRefundRequestValidator extends AbstractRequestValidator {
|
|
4
5
|
payment: string;
|
|
5
6
|
reason: FinanceRefundReasonEnum;
|
|
6
7
|
amount: number;
|
|
7
8
|
notes?: string;
|
|
8
9
|
status?: FinanceRefundStatusEnum;
|
|
10
|
+
constructor(refund?: FinanceRefundEntity);
|
|
9
11
|
}
|
|
10
12
|
export declare class UpdateFinanceRefundRequestValidator extends CreateFinanceRefundRequestValidator {
|
|
11
13
|
payment: string;
|
|
@@ -16,6 +16,17 @@ export class CreateFinanceRefundRequestValidator extends abstract_validator_1.Ab
|
|
|
16
16
|
amount;
|
|
17
17
|
notes;
|
|
18
18
|
status;
|
|
19
|
+
constructor(refund) {
|
|
20
|
+
super();
|
|
21
|
+
if (!refund) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
this.payment = (refund.payment?._id || refund.payment);
|
|
25
|
+
this.reason = refund.reason;
|
|
26
|
+
this.amount = refund.amount;
|
|
27
|
+
this.notes = refund.notes;
|
|
28
|
+
this.status = refund.status;
|
|
29
|
+
}
|
|
19
30
|
}
|
|
20
31
|
__decorate([
|
|
21
32
|
(0, class_validator_1.IsMongoId)(),
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { AbstractRequestValidator } from '../../..';
|
|
2
|
+
import type { CatalogAttributeEntity } from './';
|
|
2
3
|
export declare class CreateAttributeRequestValidator extends AbstractRequestValidator {
|
|
3
4
|
name: string;
|
|
4
5
|
values?: string[];
|
|
5
6
|
active?: boolean;
|
|
7
|
+
constructor(attribute?: CatalogAttributeEntity);
|
|
6
8
|
}
|
|
7
9
|
export declare class UpdateAttributeRequestValidator extends CreateAttributeRequestValidator {
|
|
8
10
|
name: string;
|
|
@@ -13,6 +13,17 @@ export class CreateAttributeRequestValidator extends abstract_validator_1.Abstra
|
|
|
13
13
|
name;
|
|
14
14
|
values = [];
|
|
15
15
|
active;
|
|
16
|
+
constructor(attribute) {
|
|
17
|
+
super();
|
|
18
|
+
if (!attribute) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
this.name = attribute.name;
|
|
22
|
+
this.active = attribute.active;
|
|
23
|
+
if (attribute.values !== undefined) {
|
|
24
|
+
this.values = attribute.values;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
16
27
|
}
|
|
17
28
|
__decorate([
|
|
18
29
|
(0, class_validator_1.IsString)(),
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { AbstractRequestValidator } from '../../..';
|
|
2
|
+
import type { CatalogBrandEntity } from './';
|
|
2
3
|
export declare class CreateBrandRequestValidator extends AbstractRequestValidator {
|
|
3
4
|
name: string;
|
|
4
5
|
description?: string;
|
|
6
|
+
constructor(brand?: CatalogBrandEntity);
|
|
5
7
|
}
|
|
6
8
|
export declare class UpdateBrandRequestValidator extends CreateBrandRequestValidator {
|
|
7
9
|
name: string;
|
|
@@ -12,6 +12,14 @@ import * as abstract_validator_1 from '../../../index.js';
|
|
|
12
12
|
export class CreateBrandRequestValidator extends abstract_validator_1.AbstractRequestValidator {
|
|
13
13
|
name;
|
|
14
14
|
description;
|
|
15
|
+
constructor(brand) {
|
|
16
|
+
super();
|
|
17
|
+
if (!brand) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
this.name = brand.name;
|
|
21
|
+
this.description = brand.description;
|
|
22
|
+
}
|
|
15
23
|
}
|
|
16
24
|
__decorate([
|
|
17
25
|
(0, class_validator_1.IsString)(),
|
|
@@ -3,7 +3,9 @@ import { CatalogRelationStatusEnum } from '../../..';
|
|
|
3
3
|
import { CatalogProductEntity } from '../product';
|
|
4
4
|
export declare class CatalogCategoryEntity extends AbstractEntity {
|
|
5
5
|
name: string;
|
|
6
|
-
description
|
|
6
|
+
description?: string;
|
|
7
|
+
parent?: CatalogCategoryEntity;
|
|
8
|
+
readonly children?: CatalogCategoryEntity[];
|
|
7
9
|
readonly products?: CatalogProductEntity[];
|
|
8
10
|
readonly status: CatalogRelationStatusEnum;
|
|
9
11
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { AbstractRequestValidator } from '../../..';
|
|
2
|
+
import type { CatalogCategoryEntity } from './';
|
|
2
3
|
export declare class CreateCategoryRequestValidator extends AbstractRequestValidator {
|
|
3
4
|
name: string;
|
|
4
5
|
description?: string;
|
|
6
|
+
constructor(category?: CatalogCategoryEntity);
|
|
5
7
|
}
|
|
6
8
|
export declare class UpdateCategoryRequestValidator extends CreateCategoryRequestValidator {
|
|
7
9
|
name: string;
|
|
@@ -12,6 +12,14 @@ import * as abstract_validator_1 from '../../../index.js';
|
|
|
12
12
|
export class CreateCategoryRequestValidator extends abstract_validator_1.AbstractRequestValidator {
|
|
13
13
|
name;
|
|
14
14
|
description;
|
|
15
|
+
constructor(category) {
|
|
16
|
+
super();
|
|
17
|
+
if (!category) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
this.name = category.name;
|
|
21
|
+
this.description = category.description;
|
|
22
|
+
}
|
|
15
23
|
}
|
|
16
24
|
__decorate([
|
|
17
25
|
(0, class_validator_1.IsString)(),
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { AbstractRequestValidator } from '../../..';
|
|
2
|
+
import type { CatalogCollectionEntity } from './';
|
|
2
3
|
export declare class CreateCollectionRequestValidator extends AbstractRequestValidator {
|
|
3
4
|
name: string;
|
|
4
5
|
description?: string;
|
|
5
6
|
products?: string[];
|
|
7
|
+
constructor(collection?: CatalogCollectionEntity);
|
|
6
8
|
}
|
|
7
9
|
export declare class UpdateCollectionRequestValidator extends CreateCollectionRequestValidator {
|
|
8
10
|
name: string;
|
|
@@ -13,6 +13,16 @@ export class CreateCollectionRequestValidator extends abstract_validator_1.Abstr
|
|
|
13
13
|
name;
|
|
14
14
|
description;
|
|
15
15
|
products = [];
|
|
16
|
+
constructor(collection) {
|
|
17
|
+
super();
|
|
18
|
+
if (!collection) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
this.name = collection.name;
|
|
22
|
+
this.description = collection.description;
|
|
23
|
+
this.products =
|
|
24
|
+
collection.products?.map((product) => (product?._id || product)) ?? [];
|
|
25
|
+
}
|
|
16
26
|
}
|
|
17
27
|
__decorate([
|
|
18
28
|
(0, class_validator_1.IsString)(),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AssetEntity } from '../../../assets/asset';
|
|
2
|
-
import { StockBalanceStatusEnum } from '../../..';
|
|
3
|
-
import { AbstractEntity } from '../../..';
|
|
4
2
|
import { StockBalanceEntity } from '../../stock/balance';
|
|
3
|
+
import { StockBalanceStatusEnum } from '../../stock/balance';
|
|
4
|
+
import { AbstractEntity } from '../../..';
|
|
5
5
|
import { CatalogAttributeEntity } from '../attribute';
|
|
6
6
|
import type { CatalogBrandEntity } from '../brand';
|
|
7
7
|
import type { CatalogCategoryEntity } from '../category';
|
|
@@ -13,8 +13,9 @@ export declare class CatalogProductEntity extends AbstractEntity {
|
|
|
13
13
|
name: string;
|
|
14
14
|
description?: string;
|
|
15
15
|
price: number;
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
sellPrice: number;
|
|
17
|
+
cost: number;
|
|
18
|
+
buyPrice: number;
|
|
18
19
|
category?: CatalogCategoryEntity;
|
|
19
20
|
brand?: CatalogBrandEntity;
|
|
20
21
|
attributes: {
|
|
@@ -28,9 +29,12 @@ export declare class CatalogProductEntity extends AbstractEntity {
|
|
|
28
29
|
selected?: ConfigurationUnitEntity;
|
|
29
30
|
};
|
|
30
31
|
hashtags: string[];
|
|
32
|
+
readonly picture: AssetEntity;
|
|
33
|
+
readonly pictures: AssetEntity[];
|
|
31
34
|
readonly variants: CatalogVariantEntity[];
|
|
32
35
|
readonly stock: number;
|
|
33
36
|
readonly status: StockBalanceStatusEnum;
|
|
34
37
|
readonly balance: StockBalanceEntity;
|
|
35
|
-
readonly
|
|
38
|
+
readonly balances: StockBalanceEntity[];
|
|
39
|
+
readonly 'measure.selected': ConfigurationUnitEntity;
|
|
36
40
|
}
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import { AbstractRequestValidator } from '../../..';
|
|
2
|
+
import type { CatalogProductEntity } from './';
|
|
3
|
+
type CatalogProductRequestSource = CatalogProductEntity & {
|
|
4
|
+
minStockLevel?: number;
|
|
5
|
+
policy?: {
|
|
6
|
+
minStock?: number;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
2
9
|
export declare class ProductAttributeRequestValidator extends AbstractRequestValidator {
|
|
3
10
|
type: string;
|
|
4
11
|
values: string[];
|
|
12
|
+
constructor(attribute?: CatalogProductEntity['attributes'][number]);
|
|
5
13
|
}
|
|
6
14
|
export declare class CreateProductRequestValidator extends AbstractRequestValidator {
|
|
7
15
|
name: string;
|
|
8
16
|
sku?: string;
|
|
9
17
|
description?: string;
|
|
10
|
-
|
|
18
|
+
sellPrice?: number;
|
|
19
|
+
buyPrice?: number;
|
|
11
20
|
minStockLevel?: number;
|
|
12
21
|
measure: {
|
|
13
22
|
amount: any;
|
|
@@ -19,11 +28,10 @@ export declare class CreateProductRequestValidator extends AbstractRequestValida
|
|
|
19
28
|
brand?: string;
|
|
20
29
|
hashtags: string[];
|
|
21
30
|
attributes: ProductAttributeRequestValidator[];
|
|
31
|
+
constructor(product?: CatalogProductRequestSource);
|
|
22
32
|
}
|
|
23
33
|
export declare class UpdateProductRequestValidator extends CreateProductRequestValidator {
|
|
24
34
|
name: string;
|
|
25
|
-
price: number;
|
|
26
35
|
measure: CreateProductRequestValidator['measure'];
|
|
27
|
-
hashtags: string[];
|
|
28
|
-
attributes: ProductAttributeRequestValidator[];
|
|
29
36
|
}
|
|
37
|
+
export {};
|
|
@@ -13,6 +13,14 @@ import * as abstract_validator_1 from '../../../index.js';
|
|
|
13
13
|
export class ProductAttributeRequestValidator extends abstract_validator_1.AbstractRequestValidator {
|
|
14
14
|
type;
|
|
15
15
|
values = [];
|
|
16
|
+
constructor(attribute) {
|
|
17
|
+
super();
|
|
18
|
+
if (!attribute) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
this.type = (attribute.type?._id || attribute.type);
|
|
22
|
+
this.values = attribute.values ?? [];
|
|
23
|
+
}
|
|
16
24
|
}
|
|
17
25
|
__decorate([
|
|
18
26
|
(0, class_validator_1.IsMongoId)(),
|
|
@@ -28,14 +36,43 @@ export class CreateProductRequestValidator extends abstract_validator_1.Abstract
|
|
|
28
36
|
name;
|
|
29
37
|
sku;
|
|
30
38
|
description;
|
|
31
|
-
|
|
39
|
+
sellPrice;
|
|
40
|
+
buyPrice;
|
|
32
41
|
minStockLevel;
|
|
33
|
-
measure = { amount:
|
|
42
|
+
measure = { amount: null, kind: null, unit: null };
|
|
34
43
|
pictures = [];
|
|
35
44
|
category;
|
|
36
45
|
brand;
|
|
37
46
|
hashtags = [];
|
|
38
47
|
attributes = [];
|
|
48
|
+
constructor(product) {
|
|
49
|
+
super();
|
|
50
|
+
if (!product) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
this.name = product.name;
|
|
54
|
+
this.sku = product.sku;
|
|
55
|
+
this.description = product.description;
|
|
56
|
+
this.sellPrice = product.sellPrice ?? product.price;
|
|
57
|
+
this.buyPrice = product.buyPrice ?? product.cost;
|
|
58
|
+
this.minStockLevel = product.minStockLevel ?? product.policy?.minStock;
|
|
59
|
+
this.category = (product.category?._id || product.category);
|
|
60
|
+
this.brand = (product.brand?._id || product.brand);
|
|
61
|
+
this.hashtags = product.hashtags ?? [];
|
|
62
|
+
if (product.measure !== undefined) {
|
|
63
|
+
const measureUnit = product.measure?.unit;
|
|
64
|
+
this.measure = {
|
|
65
|
+
amount: product.measure?.amount ?? null,
|
|
66
|
+
kind: (product.measure?.kind?._id || product.measure?.kind),
|
|
67
|
+
unit: (measureUnit?._id || measureUnit),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
this.pictures =
|
|
71
|
+
product.pictures?.map((picture) => (picture?._id || picture)) ?? this.pictures;
|
|
72
|
+
this.attributes =
|
|
73
|
+
product.attributes?.map((attribute) => new ProductAttributeRequestValidator(attribute)) ??
|
|
74
|
+
this.attributes;
|
|
75
|
+
}
|
|
39
76
|
}
|
|
40
77
|
__decorate([
|
|
41
78
|
(0, class_validator_1.IsString)(),
|
|
@@ -57,9 +94,16 @@ __decorate([
|
|
|
57
94
|
], CreateProductRequestValidator.prototype, "description", void 0);
|
|
58
95
|
__decorate([
|
|
59
96
|
(0, class_validator_1.IsInt)(),
|
|
60
|
-
(0, class_validator_1.
|
|
97
|
+
(0, class_validator_1.Min)(0),
|
|
98
|
+
(0, class_validator_1.IsOptional)(),
|
|
61
99
|
__metadata("design:type", Number)
|
|
62
|
-
], CreateProductRequestValidator.prototype, "
|
|
100
|
+
], CreateProductRequestValidator.prototype, "sellPrice", void 0);
|
|
101
|
+
__decorate([
|
|
102
|
+
(0, class_validator_1.IsInt)(),
|
|
103
|
+
(0, class_validator_1.Min)(0),
|
|
104
|
+
(0, class_validator_1.IsOptional)(),
|
|
105
|
+
__metadata("design:type", Number)
|
|
106
|
+
], CreateProductRequestValidator.prototype, "buyPrice", void 0);
|
|
63
107
|
__decorate([
|
|
64
108
|
(0, class_validator_1.IsInt)(),
|
|
65
109
|
(0, class_validator_1.Min)(0),
|
|
@@ -90,12 +134,14 @@ __decorate([
|
|
|
90
134
|
(0, class_validator_1.IsArray)(),
|
|
91
135
|
(0, class_validator_1.IsString)({ each: true }),
|
|
92
136
|
(0, class_validator_1.Length)(0, 50, { each: true }),
|
|
137
|
+
(0, class_validator_1.IsOptional)(),
|
|
93
138
|
__metadata("design:type", Array)
|
|
94
139
|
], CreateProductRequestValidator.prototype, "hashtags", void 0);
|
|
95
140
|
__decorate([
|
|
96
141
|
(0, class_validator_1.IsArray)(),
|
|
97
142
|
(0, class_transformer_1.Type)(() => ProductAttributeRequestValidator),
|
|
98
143
|
(0, class_validator_1.ValidateNested)({ each: true }),
|
|
144
|
+
(0, class_validator_1.IsOptional)(),
|
|
99
145
|
__metadata("design:type", Array)
|
|
100
146
|
], CreateProductRequestValidator.prototype, "attributes", void 0);
|
|
101
147
|
export class UpdateProductRequestValidator extends CreateProductRequestValidator {
|
|
@@ -104,19 +150,7 @@ __decorate([
|
|
|
104
150
|
(0, class_validator_1.IsOptional)(),
|
|
105
151
|
__metadata("design:type", String)
|
|
106
152
|
], UpdateProductRequestValidator.prototype, "name", void 0);
|
|
107
|
-
__decorate([
|
|
108
|
-
(0, class_validator_1.IsOptional)(),
|
|
109
|
-
__metadata("design:type", Number)
|
|
110
|
-
], UpdateProductRequestValidator.prototype, "price", void 0);
|
|
111
153
|
__decorate([
|
|
112
154
|
(0, class_validator_1.IsOptional)(),
|
|
113
155
|
__metadata("design:type", Object)
|
|
114
156
|
], UpdateProductRequestValidator.prototype, "measure", void 0);
|
|
115
|
-
__decorate([
|
|
116
|
-
(0, class_validator_1.IsOptional)(),
|
|
117
|
-
__metadata("design:type", Array)
|
|
118
|
-
], UpdateProductRequestValidator.prototype, "hashtags", void 0);
|
|
119
|
-
__decorate([
|
|
120
|
-
(0, class_validator_1.IsOptional)(),
|
|
121
|
-
__metadata("design:type", Array)
|
|
122
|
-
], UpdateProductRequestValidator.prototype, "attributes", void 0);
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { AbstractRequestValidator } from '../../..';
|
|
2
|
+
import type { CatalogVariantEntity } from './';
|
|
2
3
|
export declare class VariantOptionRequestValidator extends AbstractRequestValidator {
|
|
3
4
|
type: string;
|
|
4
5
|
value: string;
|
|
6
|
+
constructor(option?: CatalogVariantEntity['options'][number]);
|
|
5
7
|
}
|
|
6
8
|
export declare class CreateVariantRequestValidator extends AbstractRequestValidator {
|
|
7
9
|
product?: string;
|
|
@@ -11,6 +13,7 @@ export declare class CreateVariantRequestValidator extends AbstractRequestValida
|
|
|
11
13
|
options?: VariantOptionRequestValidator[];
|
|
12
14
|
active?: boolean;
|
|
13
15
|
gtin?: string;
|
|
16
|
+
constructor(variant?: CatalogVariantEntity);
|
|
14
17
|
}
|
|
15
18
|
export declare class UpdateVariantRequestValidator extends CreateVariantRequestValidator {
|
|
16
19
|
}
|
|
@@ -13,6 +13,14 @@ import * as abstract_validator_1 from '../../../index.js';
|
|
|
13
13
|
export class VariantOptionRequestValidator extends abstract_validator_1.AbstractRequestValidator {
|
|
14
14
|
type;
|
|
15
15
|
value;
|
|
16
|
+
constructor(option) {
|
|
17
|
+
super();
|
|
18
|
+
if (!option) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
this.type = (option.type?._id || option.type);
|
|
22
|
+
this.value = option.value;
|
|
23
|
+
}
|
|
16
24
|
}
|
|
17
25
|
__decorate([
|
|
18
26
|
(0, class_validator_1.IsMongoId)(),
|
|
@@ -32,6 +40,20 @@ export class CreateVariantRequestValidator extends abstract_validator_1.Abstract
|
|
|
32
40
|
options = [];
|
|
33
41
|
active;
|
|
34
42
|
gtin;
|
|
43
|
+
constructor(variant) {
|
|
44
|
+
super();
|
|
45
|
+
if (!variant) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
this.product = (variant.product?._id || variant.product);
|
|
49
|
+
this.sku = variant.identifier?.sku;
|
|
50
|
+
this.price = variant.price;
|
|
51
|
+
this.minStockLevel = variant.policy?.minStock;
|
|
52
|
+
this.active = variant.active;
|
|
53
|
+
this.gtin = variant.identifier?.gtin;
|
|
54
|
+
this.options =
|
|
55
|
+
variant.options?.map((option) => new VariantOptionRequestValidator(option)) ?? this.options;
|
|
56
|
+
}
|
|
35
57
|
}
|
|
36
58
|
__decorate([
|
|
37
59
|
(0, class_validator_1.IsMongoId)(),
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { AssetEntity } from '../../../assets/asset';
|
|
2
|
-
import { StockBalanceStatusEnum } from '
|
|
2
|
+
import { StockBalanceStatusEnum } from '../../stock/balance';
|
|
3
3
|
import { AbstractEntity } from '../../..';
|
|
4
|
+
import { VariantIdentifierEntity } from '../../..';
|
|
5
|
+
import { VariantPolicyEntity } from '../../..';
|
|
4
6
|
import type { CatalogAttributeEntity } from '../attribute';
|
|
5
7
|
import type { CatalogProductEntity } from '../product';
|
|
6
8
|
import type { StockBalanceEntity } from '../../stock/balance';
|
|
7
9
|
export declare class CatalogVariantEntity extends AbstractEntity {
|
|
8
10
|
product?: CatalogProductEntity;
|
|
9
|
-
sku?: string;
|
|
10
11
|
price: number;
|
|
11
|
-
|
|
12
|
+
policy: VariantPolicyEntity;
|
|
13
|
+
identifier: VariantIdentifierEntity;
|
|
12
14
|
options: {
|
|
13
15
|
type: CatalogAttributeEntity;
|
|
14
16
|
value: string;
|
|
15
17
|
}[];
|
|
16
18
|
active: boolean;
|
|
17
|
-
gtin?: string;
|
|
18
19
|
pictures: AssetEntity[];
|
|
19
20
|
readonly total: number;
|
|
20
21
|
readonly stock: number;
|