@merkaly/api 0.6.0 → 0.6.3

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.
Files changed (81) hide show
  1. package/dist/account/address/request.validator.d.ts +2 -0
  2. package/dist/account/address/request.validator.js +13 -0
  3. package/dist/account/payment/request.validator.d.ts +2 -0
  4. package/dist/account/payment/request.validator.js +12 -0
  5. package/dist/account/user/request.validator.d.ts +2 -0
  6. package/dist/account/user/request.validator.js +11 -0
  7. package/dist/account/user/user.entity.d.ts +6 -1
  8. package/dist/app.schemas.d.ts +54 -0
  9. package/dist/app.types.d.ts +20 -0
  10. package/dist/finance/invoice/request.validator.d.ts +2 -0
  11. package/dist/finance/invoice/request.validator.js +15 -0
  12. package/dist/finance/payment/payment.entity.d.ts +5 -4
  13. package/dist/finance/payment/request.validator.d.ts +2 -0
  14. package/dist/finance/payment/request.validator.js +11 -0
  15. package/dist/finance/refund/refund.entity.d.ts +2 -1
  16. package/dist/finance/refund/request.validator.d.ts +2 -0
  17. package/dist/finance/refund/request.validator.js +11 -0
  18. package/dist/index.d.ts +32 -7
  19. package/dist/index.js +26 -2
  20. package/dist/inventory/catalog/attribute/request.validator.d.ts +2 -0
  21. package/dist/inventory/catalog/attribute/request.validator.js +11 -0
  22. package/dist/inventory/catalog/brand/request.validator.d.ts +2 -0
  23. package/dist/inventory/catalog/brand/request.validator.js +8 -0
  24. package/dist/inventory/catalog/category/category.entity.d.ts +3 -1
  25. package/dist/inventory/catalog/category/request.validator.d.ts +2 -0
  26. package/dist/inventory/catalog/category/request.validator.js +8 -0
  27. package/dist/inventory/catalog/collection/request.validator.d.ts +2 -0
  28. package/dist/inventory/catalog/collection/request.validator.js +10 -0
  29. package/dist/inventory/catalog/product/product.entity.d.ts +9 -5
  30. package/dist/inventory/catalog/product/request.validator.d.ts +12 -4
  31. package/dist/inventory/catalog/product/request.validator.js +50 -16
  32. package/dist/inventory/catalog/variant/request.validator.d.ts +3 -0
  33. package/dist/inventory/catalog/variant/request.validator.js +22 -0
  34. package/dist/inventory/catalog/variant/variant.entity.d.ts +5 -4
  35. package/dist/inventory/configuration/measurement/request.validator.d.ts +4 -0
  36. package/dist/inventory/configuration/measurement/request.validator.js +22 -0
  37. package/dist/inventory/stock/balance/balance.entity.d.ts +2 -0
  38. package/dist/inventory/stock/balance/balance.status.enum.d.ts +6 -0
  39. package/dist/inventory/stock/balance/balance.status.enum.js +7 -0
  40. package/dist/inventory/stock/balance/index.d.ts +1 -0
  41. package/dist/inventory/stock/balance/index.js +1 -1
  42. package/dist/inventory/stock/transfer/request.validator.d.ts +6 -2
  43. package/dist/inventory/stock/transfer/request.validator.js +22 -0
  44. package/dist/inventory/stock/transfer/transfer.item.entity.d.ts +2 -0
  45. package/dist/inventory/stock/warehouse/request.validator.d.ts +2 -0
  46. package/dist/inventory/stock/warehouse/request.validator.js +26 -0
  47. package/dist/order/purchase/item/item.entity.d.ts +3 -1
  48. package/dist/order/purchase/item/request.validator.d.ts +3 -0
  49. package/dist/order/purchase/item/request.validator.js +22 -0
  50. package/dist/order/purchase/transaction/request.validator.d.ts +5 -2
  51. package/dist/order/purchase/transaction/request.validator.js +26 -4
  52. package/dist/order/purchase/vendor/request.validator.d.ts +2 -0
  53. package/dist/order/purchase/vendor/request.validator.js +14 -0
  54. package/dist/order/sale/customer/request.validator.d.ts +2 -0
  55. package/dist/order/sale/customer/request.validator.js +17 -0
  56. package/dist/order/sale/item/item.entity.d.ts +3 -1
  57. package/dist/order/sale/item/request.validator.d.ts +3 -0
  58. package/dist/order/sale/item/request.validator.js +20 -0
  59. package/dist/order/sale/transaction/request.validator.d.ts +7 -2
  60. package/dist/order/sale/transaction/request.validator.js +31 -1
  61. package/dist/settings/organization/index.d.ts +1 -0
  62. package/dist/settings/organization/index.js +1 -0
  63. package/dist/settings/organization/organization.enum.d.ts +8 -12
  64. package/dist/settings/organization/organization.enum.js +8 -12
  65. package/dist/settings/organization/request.validator.d.ts +51 -0
  66. package/dist/settings/organization/request.validator.js +244 -0
  67. package/dist/transaction.entity.d.ts +3 -1
  68. package/package.json +16 -6
  69. package/dist/abstract.repository.d.ts +0 -63
  70. package/dist/finance/subscription/index.d.ts +0 -2
  71. package/dist/finance/subscription/index.js +0 -1
  72. package/dist/finance/subscription/subscription.entity.d.ts +0 -14
  73. package/dist/finance/subscription/subscription.enum.d.ts +0 -15
  74. package/dist/finance/subscription/subscription.enum.js +0 -17
  75. package/dist/finance/tax/index.d.ts +0 -2
  76. package/dist/finance/tax/index.js +0 -1
  77. package/dist/finance/tax/tax.entity.d.ts +0 -10
  78. package/dist/finance/tax/tax.enum.d.ts +0 -8
  79. package/dist/finance/tax/tax.enum.js +0 -9
  80. package/dist/not-equal-to.decorator.d.ts +0 -2
  81. package/dist/not-equal-to.decorator.js +0 -22
@@ -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)(),
@@ -5,6 +5,11 @@ export declare class AccountUserEntity extends AbstractEntity {
5
5
  picture: string;
6
6
  email: string;
7
7
  phone?: string;
8
- isMember?: boolean;
9
8
  role?: string;
9
+ status: string;
10
+ verified?: boolean;
11
+ providers: string[];
12
+ locale?: string;
13
+ lastIp?: string;
14
+ loginAt?: Date;
10
15
  }
@@ -0,0 +1,54 @@
1
+ export declare abstract class AppSchemas {
2
+ static get account(): {
3
+ addresses: string;
4
+ payments: string;
5
+ users: string;
6
+ };
7
+ static get assets(): {
8
+ files: string;
9
+ };
10
+ static get finance(): {
11
+ invoices: string;
12
+ payments: string;
13
+ refunds: string;
14
+ subscriptions: string;
15
+ taxes: string;
16
+ };
17
+ static get inventory(): {
18
+ catalog: {
19
+ attributes: string;
20
+ brands: string;
21
+ categories: string;
22
+ collections: string;
23
+ products: string;
24
+ variants: string;
25
+ };
26
+ configuration: {
27
+ measurements: string;
28
+ };
29
+ stock: {
30
+ balances: string;
31
+ transfers: string;
32
+ warehouses: string;
33
+ };
34
+ };
35
+ static get order(): {
36
+ purchase: {
37
+ items: string;
38
+ transactions: string;
39
+ vendors: string;
40
+ };
41
+ sale: {
42
+ customers: string;
43
+ items: string;
44
+ transactions: string;
45
+ };
46
+ service: {
47
+ items: string;
48
+ transactions: string;
49
+ };
50
+ };
51
+ static get settings(): {
52
+ organizations: string;
53
+ };
54
+ }
@@ -0,0 +1,20 @@
1
+ export interface Auth0JwtPayload {
2
+ sub: string;
3
+ iat: number;
4
+ exp: number;
5
+ iss: string;
6
+ aud: string | string[];
7
+ org_id?: string;
8
+ 'https://merka.ly/authorization'?: {
9
+ roles: string[];
10
+ permissions?: string[];
11
+ };
12
+ }
13
+ export interface AppAuth {
14
+ expiresAt: Date;
15
+ issuedAt: Date;
16
+ orgId?: string;
17
+ role: string;
18
+ userId: string;
19
+ }
20
+ export declare const SESSION_COOKIE = "merkaly.sid";
@@ -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, MongoEntity } from '../..';
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: MongoEntity<OrderEntity>;
11
- total: number;
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)(),
package/dist/index.d.ts CHANGED
@@ -1,10 +1,35 @@
1
+ export * from './app.types';
2
+ export * from './app.schemas';
3
+ export * from './status.plugin';
4
+ export * from './address.validator';
5
+ export * from './address.entity';
6
+ export * from './transaction.entity';
1
7
  export * from './abstract.entity';
2
8
  export * from './abstract.transition';
3
9
  export * from './abstract.validator';
4
- export * from './abstract.repository';
5
- export * from './not-equal-to.decorator';
6
- export * from './address.entity';
7
- export * from './transaction.entity';
8
- export * from './address.validator';
9
- export type { StatusEntity } from './status.plugin';
10
- export type { CreateEntityArgs } from './repository.types';
10
+ export * from './account/address';
11
+ export * from './account/payment';
12
+ export * from './account/user';
13
+ export * from './assets/asset';
14
+ export * from './finance/invoice';
15
+ export * from './finance/payment';
16
+ export * from './finance/refund';
17
+ export * from './inventory/catalog/attribute';
18
+ export * from './inventory/catalog/brand';
19
+ export * from './inventory/catalog/category';
20
+ export * from './inventory/catalog/collection';
21
+ export * from './inventory/catalog/product';
22
+ export * from './inventory/catalog/variant';
23
+ export * from './inventory/configuration/measurement';
24
+ export * from './inventory/configuration/unit';
25
+ export * from './inventory/stock/balance';
26
+ export * from './inventory/stock/transfer';
27
+ export * from './inventory/stock/warehouse';
28
+ export * from './order/purchase/item';
29
+ export * from './order/purchase/transaction';
30
+ export * from './order/purchase/vendor';
31
+ export * from './order/sale/customer';
32
+ export * from './order/sale/item';
33
+ export * from './order/sale/transaction';
34
+ export * from './settings/organization';
35
+ export type { SaveEntityArgs } from './repository.types';
package/dist/index.js CHANGED
@@ -1,4 +1,28 @@
1
+ export * from './address.validator.js';
1
2
  export * from './abstract.transition.js';
2
3
  export * from './abstract.validator.js';
3
- export * from './not-equal-to.decorator.js';
4
- export * from './address.validator.js';
4
+ export * from './account/address/index.js';
5
+ export * from './account/payment/index.js';
6
+ export * from './account/user/index.js';
7
+ export * from './assets/asset/index.js';
8
+ export * from './finance/invoice/index.js';
9
+ export * from './finance/payment/index.js';
10
+ export * from './finance/refund/index.js';
11
+ export * from './inventory/catalog/attribute/index.js';
12
+ export * from './inventory/catalog/brand/index.js';
13
+ export * from './inventory/catalog/category/index.js';
14
+ export * from './inventory/catalog/collection/index.js';
15
+ export * from './inventory/catalog/product/index.js';
16
+ export * from './inventory/catalog/variant/index.js';
17
+ export * from './inventory/configuration/measurement/index.js';
18
+ export * from './inventory/configuration/unit/index.js';
19
+ export * from './inventory/stock/balance/index.js';
20
+ export * from './inventory/stock/transfer/index.js';
21
+ export * from './inventory/stock/warehouse/index.js';
22
+ export * from './order/purchase/item/index.js';
23
+ export * from './order/purchase/transaction/index.js';
24
+ export * from './order/purchase/vendor/index.js';
25
+ export * from './order/sale/customer/index.js';
26
+ export * from './order/sale/item/index.js';
27
+ export * from './order/sale/transaction/index.js';
28
+ export * from './settings/organization/index.js';
@@ -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: string;
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
- minStockLevel: number;
17
- pictures: AssetEntity[];
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 image: AssetEntity;
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
- price: number;
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 {};