@merkaly/api 0.2.0 → 0.2.1-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.
Files changed (80) hide show
  1. package/.output/app.d.ts +28 -2
  2. package/.output/app.js +28 -0
  3. package/.output/config/app.document.d.ts +5 -8
  4. package/.output/config/app.document.js +28 -0
  5. package/.output/config/app.validator.d.ts +0 -1
  6. package/.output/config/app.validator.js +6 -0
  7. package/.output/src/auth/auth.validator.d.ts +0 -1
  8. package/.output/src/auth/auth.validator.js +14 -0
  9. package/.output/src/inventory/brands/brand.document.d.ts +0 -1
  10. package/.output/src/inventory/brands/brand.document.js +22 -0
  11. package/.output/src/inventory/brands/brand.validator.d.ts +0 -1
  12. package/.output/src/inventory/brands/brand.validator.js +43 -0
  13. package/.output/src/inventory/categories/category.document.d.ts +0 -1
  14. package/.output/src/inventory/categories/category.document.js +22 -0
  15. package/.output/src/inventory/categories/category.validator.d.ts +0 -1
  16. package/.output/src/inventory/categories/category.validator.js +47 -0
  17. package/.output/src/inventory/media/media.document.d.ts +0 -1
  18. package/.output/src/inventory/media/media.document.js +22 -0
  19. package/.output/src/inventory/media/media.validator.d.ts +0 -1
  20. package/.output/src/inventory/media/media.validator.js +31 -0
  21. package/.output/src/inventory/products/product.document.d.ts +0 -1
  22. package/.output/src/inventory/products/product.document.js +38 -0
  23. package/.output/src/inventory/products/product.validator.d.ts +0 -1
  24. package/.output/src/inventory/products/product.validator.js +111 -0
  25. package/.output/src/inventory/variants/variant.document.d.ts +0 -1
  26. package/.output/src/inventory/variants/variant.document.js +30 -0
  27. package/.output/src/inventory/variants/variant.validator.d.ts +0 -1
  28. package/.output/src/inventory/variants/variant.validator.js +81 -0
  29. package/.output/src/store/orders/order.document.d.ts +0 -1
  30. package/.output/src/store/orders/order.document.js +22 -0
  31. package/.output/src/store/orders/order.validator.d.ts +0 -1
  32. package/.output/src/store/orders/order.validator.js +18 -0
  33. package/index.ts +26 -0
  34. package/package.json +2 -2
  35. package/.output/config/app.config.d.ts +0 -28
  36. package/.output/config/app.controller.d.ts +0 -11
  37. package/.output/config/app.entity.d.ts +0 -9
  38. package/.output/config/app.exception.d.ts +0 -11
  39. package/.output/config/app.middleware.d.ts +0 -3
  40. package/.output/config/app.module.d.ts +0 -6
  41. package/.output/config/app.repository.d.ts +0 -24
  42. package/.output/config/app.router.d.ts +0 -6
  43. package/.output/src/auth/auth.controller.d.ts +0 -9
  44. package/.output/src/auth/auth.decorator.d.ts +0 -5
  45. package/.output/src/auth/auth.guard.d.ts +0 -16
  46. package/.output/src/auth/auth.module.d.ts +0 -9
  47. package/.output/src/auth/auth.repository.d.ts +0 -11
  48. package/.output/src/auth/auth.strategy.d.ts +0 -18
  49. package/.output/src/inventory/brands/brand.controller.d.ts +0 -15
  50. package/.output/src/inventory/brands/brand.entity.d.ts +0 -8
  51. package/.output/src/inventory/brands/brand.exception.d.ts +0 -6
  52. package/.output/src/inventory/brands/brand.module.d.ts +0 -8
  53. package/.output/src/inventory/brands/brand.repository.d.ts +0 -9
  54. package/.output/src/inventory/categories/category.controller.d.ts +0 -12
  55. package/.output/src/inventory/categories/category.entity.d.ts +0 -8
  56. package/.output/src/inventory/categories/category.exception.d.ts +0 -6
  57. package/.output/src/inventory/categories/category.module.d.ts +0 -8
  58. package/.output/src/inventory/categories/category.repository.d.ts +0 -9
  59. package/.output/src/inventory/inventory.module.d.ts +0 -14
  60. package/.output/src/inventory/media/media.controller.d.ts +0 -6
  61. package/.output/src/inventory/media/media.entity.d.ts +0 -8
  62. package/.output/src/inventory/media/media.exception.d.ts +0 -6
  63. package/.output/src/inventory/media/media.module.d.ts +0 -8
  64. package/.output/src/inventory/media/media.repository.d.ts +0 -9
  65. package/.output/src/inventory/products/product.controller.d.ts +0 -14
  66. package/.output/src/inventory/products/product.entity.d.ts +0 -20
  67. package/.output/src/inventory/products/product.exception.d.ts +0 -6
  68. package/.output/src/inventory/products/product.module.d.ts +0 -8
  69. package/.output/src/inventory/products/product.repository.d.ts +0 -11
  70. package/.output/src/inventory/variants/variant.controller.d.ts +0 -9
  71. package/.output/src/inventory/variants/variant.entity.d.ts +0 -12
  72. package/.output/src/inventory/variants/variant.exception.d.ts +0 -6
  73. package/.output/src/inventory/variants/variant.module.d.ts +0 -8
  74. package/.output/src/inventory/variants/variant.repository.d.ts +0 -9
  75. package/.output/src/store/orders/order.controller.d.ts +0 -12
  76. package/.output/src/store/orders/order.entity.d.ts +0 -6
  77. package/.output/src/store/orders/order.exception.d.ts +0 -6
  78. package/.output/src/store/orders/order.module.d.ts +0 -8
  79. package/.output/src/store/orders/order.repository.d.ts +0 -9
  80. package/.output/src/store/store.module.d.ts +0 -10
package/.output/app.d.ts CHANGED
@@ -1,2 +1,28 @@
1
- export {};
2
- //# sourceMappingURL=app.d.ts.map
1
+ export declare namespace Inventory {
2
+ const brand: {
3
+ document: any;
4
+ validators: any;
5
+ };
6
+ const category: {
7
+ document: any;
8
+ validators: any;
9
+ };
10
+ const product: {
11
+ document: any;
12
+ validators: any;
13
+ };
14
+ const media: {
15
+ document: any;
16
+ validators: any;
17
+ };
18
+ const variant: {
19
+ document: any;
20
+ validators: any;
21
+ };
22
+ }
23
+ export declare namespace Store {
24
+ const order: {
25
+ document: any;
26
+ validators: any;
27
+ };
28
+ }
package/.output/app.js ADDED
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Store = exports.Inventory = void 0;
4
+ const brand_document_1 = require("./src/inventory/brands/brand.document");
5
+ const BrandValidators = __importStar(require("./src/inventory/brands/brand.validator"));
6
+ const category_document_1 = require("./src/inventory/categories/category.document");
7
+ const CategoryValidators = __importStar(require("./src/inventory/categories/category.validator"));
8
+ const media_document_1 = require("./src/inventory/media/media.document");
9
+ const MediaValidators = __importStar(require("./src/inventory/media/media.validator"));
10
+ const product_document_1 = require("./src/inventory/products/product.document");
11
+ const ProductValidators = __importStar(require("./src/inventory/products/product.validator"));
12
+ const variant_document_1 = require("./src/inventory/variants/variant.document");
13
+ const VariantValidators = __importStar(require("./src/inventory/variants/variant.validator"));
14
+ const order_document_1 = require("./src/store/orders/order.document");
15
+ const OrderValidators = __importStar(require("./src/store/orders/order.validator"));
16
+ const create = (document, validators) => ({ document, validators });
17
+ var Inventory;
18
+ (function (Inventory) {
19
+ Inventory.brand = create(brand_document_1.BrandDocument, BrandValidators);
20
+ Inventory.category = create(category_document_1.CategoryDocument, CategoryValidators);
21
+ Inventory.product = create(product_document_1.ProductDocument, ProductValidators);
22
+ Inventory.media = create(media_document_1.MediaDocument, MediaValidators);
23
+ Inventory.variant = create(variant_document_1.VariantDocument, VariantValidators);
24
+ })(Inventory = exports.Inventory || (exports.Inventory = {}));
25
+ var Store;
26
+ (function (Store) {
27
+ Store.order = create(order_document_1.OrderDocument, OrderValidators);
28
+ })(Store = exports.Store || (exports.Store = {}));
@@ -1,12 +1,9 @@
1
- import { EntityManager } from 'typeorm';
2
1
  import { AppEntity } from './app.entity';
3
2
  export declare abstract class AppDocument<E extends AppEntity> {
4
- protected $id: string;
5
- protected $updatedAt: Date;
6
- protected $createdAt: Date;
7
- protected $deletedAt: Date;
8
- protected $manager: EntityManager;
9
- serialize(entity: E): this;
10
3
  protected abstract transform(entity: E): this;
4
+ $id: string;
5
+ $createdAt: Date;
6
+ $updatedAt: Date;
7
+ $deletedAt: Date;
8
+ serialize(entity: E): this;
11
9
  }
12
- //# sourceMappingURL=app.document.d.ts.map
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AppDocument = void 0;
4
+ const class_transformer_1 = require("class-transformer");
5
+ const es_mapping_ts_1 = require("es-mapping-ts");
6
+ class AppDocument {
7
+ serialize(entity) {
8
+ this.$id = entity.id;
9
+ this.$createdAt = entity.createdAt;
10
+ this.$updatedAt = entity.updatedAt;
11
+ this.$deletedAt = entity.deletedAt;
12
+ this.transform(entity);
13
+ return (0, class_transformer_1.instanceToPlain)(this);
14
+ }
15
+ }
16
+ __decorate([
17
+ (0, es_mapping_ts_1.EsField)({ type: 'text' })
18
+ ], AppDocument.prototype, "$id", void 0);
19
+ __decorate([
20
+ (0, es_mapping_ts_1.EsField)({ type: 'date' })
21
+ ], AppDocument.prototype, "$createdAt", void 0);
22
+ __decorate([
23
+ (0, es_mapping_ts_1.EsField)({ type: 'date' })
24
+ ], AppDocument.prototype, "$updatedAt", void 0);
25
+ __decorate([
26
+ (0, es_mapping_ts_1.EsField)({ type: 'date' })
27
+ ], AppDocument.prototype, "$deletedAt", void 0);
28
+ exports.AppDocument = AppDocument;
@@ -4,4 +4,3 @@ export declare abstract class AppValidator<E extends AppEntity> {
4
4
  abstract toEntity(...variadic: unknown[]): E;
5
5
  }
6
6
  export declare type SearchQuery = Omit<SearchRequest, 'index' | 'routing'>;
7
- //# sourceMappingURL=app.validator.d.ts.map
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AppValidator = void 0;
4
+ class AppValidator {
5
+ }
6
+ exports.AppValidator = AppValidator;
@@ -3,4 +3,3 @@ export declare class LoginValidator {
3
3
  username: string;
4
4
  password: string;
5
5
  }
6
- //# sourceMappingURL=auth.validator.d.ts.map
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LoginValidator = void 0;
4
+ const class_validator_1 = require("class-validator");
5
+ require("reflect-metadata");
6
+ class LoginValidator {
7
+ }
8
+ __decorate([
9
+ (0, class_validator_1.IsEmail)()
10
+ ], LoginValidator.prototype, "username", void 0);
11
+ __decorate([
12
+ (0, class_validator_1.IsNotEmpty)()
13
+ ], LoginValidator.prototype, "password", void 0);
14
+ exports.LoginValidator = LoginValidator;
@@ -5,4 +5,3 @@ export declare class BrandDocument extends AppDocument<BrandEntity> {
5
5
  description: string;
6
6
  protected transform(entity: BrandEntity): this;
7
7
  }
8
- //# sourceMappingURL=brand.document.d.ts.map
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BrandDocument = void 0;
4
+ const es_mapping_ts_1 = require("es-mapping-ts");
5
+ const app_document_1 = require("../../../config/app.document");
6
+ let BrandDocument = class BrandDocument extends app_document_1.AppDocument {
7
+ transform(entity) {
8
+ this.name = entity.name;
9
+ this.description = entity.description;
10
+ return this;
11
+ }
12
+ };
13
+ __decorate([
14
+ (0, es_mapping_ts_1.EsField)({ type: 'keyword' })
15
+ ], BrandDocument.prototype, "name", void 0);
16
+ __decorate([
17
+ (0, es_mapping_ts_1.EsField)({ type: 'text' })
18
+ ], BrandDocument.prototype, "description", void 0);
19
+ BrandDocument = __decorate([
20
+ (0, es_mapping_ts_1.EsEntity)({ mixins: [app_document_1.AppDocument] })
21
+ ], BrandDocument);
22
+ exports.BrandDocument = BrandDocument;
@@ -10,4 +10,3 @@ export declare class UpdateBrandValidator extends AppValidator<BrandEntity> {
10
10
  description?: string;
11
11
  toEntity(entity: BrandEntity): BrandEntity;
12
12
  }
13
- //# sourceMappingURL=brand.validator.d.ts.map
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UpdateBrandValidator = exports.CreateBrandValidator = void 0;
4
+ const class_validator_1 = require("class-validator");
5
+ const app_validator_1 = require("../../../config/app.validator");
6
+ const brand_entity_1 = require("./brand.entity");
7
+ class CreateBrandValidator extends app_validator_1.AppValidator {
8
+ toEntity() {
9
+ const entity = new brand_entity_1.BrandEntity();
10
+ entity.name = this.name;
11
+ entity.description = this.description;
12
+ return entity;
13
+ }
14
+ }
15
+ __decorate([
16
+ (0, class_validator_1.IsString)(),
17
+ (0, class_validator_1.Length)(2, 32)
18
+ ], CreateBrandValidator.prototype, "name", void 0);
19
+ __decorate([
20
+ (0, class_validator_1.IsString)(),
21
+ (0, class_validator_1.IsOptional)()
22
+ ], CreateBrandValidator.prototype, "description", void 0);
23
+ exports.CreateBrandValidator = CreateBrandValidator;
24
+ class UpdateBrandValidator extends app_validator_1.AppValidator {
25
+ toEntity(entity) {
26
+ if (this.name) {
27
+ entity.name = this.name;
28
+ }
29
+ if (this.description) {
30
+ entity.description = this.description;
31
+ }
32
+ return entity;
33
+ }
34
+ }
35
+ __decorate([
36
+ (0, class_validator_1.IsString)(),
37
+ (0, class_validator_1.IsOptional)()
38
+ ], UpdateBrandValidator.prototype, "name", void 0);
39
+ __decorate([
40
+ (0, class_validator_1.IsString)(),
41
+ (0, class_validator_1.IsOptional)()
42
+ ], UpdateBrandValidator.prototype, "description", void 0);
43
+ exports.UpdateBrandValidator = UpdateBrandValidator;
@@ -5,4 +5,3 @@ export declare class CategoryDocument extends AppDocument<CategoryEntity> {
5
5
  description: string;
6
6
  protected transform(entity: CategoryEntity): this;
7
7
  }
8
- //# sourceMappingURL=category.document.d.ts.map
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CategoryDocument = void 0;
4
+ const es_mapping_ts_1 = require("es-mapping-ts");
5
+ const app_document_1 = require("../../../config/app.document");
6
+ let CategoryDocument = class CategoryDocument extends app_document_1.AppDocument {
7
+ transform(entity) {
8
+ this.name = entity.name;
9
+ this.description = entity.description;
10
+ return this;
11
+ }
12
+ };
13
+ __decorate([
14
+ (0, es_mapping_ts_1.EsField)({ type: 'keyword' })
15
+ ], CategoryDocument.prototype, "name", void 0);
16
+ __decorate([
17
+ (0, es_mapping_ts_1.EsField)({ type: 'text' })
18
+ ], CategoryDocument.prototype, "description", void 0);
19
+ CategoryDocument = __decorate([
20
+ (0, es_mapping_ts_1.EsEntity)({ mixins: [app_document_1.AppDocument] })
21
+ ], CategoryDocument);
22
+ exports.CategoryDocument = CategoryDocument;
@@ -13,4 +13,3 @@ export declare class UpdateCategoryValidator extends AppValidator<CategoryEntity
13
13
  description?: string;
14
14
  toEntity(entity: CategoryEntity): CategoryEntity;
15
15
  }
16
- //# sourceMappingURL=category.validator.d.ts.map
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UpdateCategoryValidator = exports.CreateCategoryValidator = exports.FindCategoryValidator = void 0;
4
+ const class_validator_1 = require("class-validator");
5
+ require("reflect-metadata");
6
+ const app_validator_1 = require("../../../config/app.validator");
7
+ const category_entity_1 = require("./category.entity");
8
+ class FindCategoryValidator {
9
+ }
10
+ exports.FindCategoryValidator = FindCategoryValidator;
11
+ class CreateCategoryValidator extends app_validator_1.AppValidator {
12
+ toEntity() {
13
+ const entity = new category_entity_1.CategoryEntity();
14
+ entity.name = this.name;
15
+ entity.description = this.description;
16
+ return entity;
17
+ }
18
+ }
19
+ __decorate([
20
+ (0, class_validator_1.IsString)(),
21
+ (0, class_validator_1.Length)(5, 32)
22
+ ], CreateCategoryValidator.prototype, "name", void 0);
23
+ __decorate([
24
+ (0, class_validator_1.IsString)(),
25
+ (0, class_validator_1.IsOptional)()
26
+ ], CreateCategoryValidator.prototype, "description", void 0);
27
+ exports.CreateCategoryValidator = CreateCategoryValidator;
28
+ class UpdateCategoryValidator extends app_validator_1.AppValidator {
29
+ toEntity(entity) {
30
+ if (this.name) {
31
+ entity.name = this.name;
32
+ }
33
+ if (this.description) {
34
+ entity.description = this.description;
35
+ }
36
+ return entity;
37
+ }
38
+ }
39
+ __decorate([
40
+ (0, class_validator_1.IsString)(),
41
+ (0, class_validator_1.IsOptional)()
42
+ ], UpdateCategoryValidator.prototype, "name", void 0);
43
+ __decorate([
44
+ (0, class_validator_1.IsString)(),
45
+ (0, class_validator_1.IsOptional)()
46
+ ], UpdateCategoryValidator.prototype, "description", void 0);
47
+ exports.UpdateCategoryValidator = UpdateCategoryValidator;
@@ -5,4 +5,3 @@ export declare class MediaDocument extends AppDocument<MediaEntity> {
5
5
  url: string;
6
6
  protected transform(entity: MediaEntity): this;
7
7
  }
8
- //# sourceMappingURL=media.document.d.ts.map
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MediaDocument = void 0;
4
+ const es_mapping_ts_1 = require("es-mapping-ts");
5
+ const app_document_1 = require("../../../config/app.document");
6
+ let MediaDocument = class MediaDocument extends app_document_1.AppDocument {
7
+ transform(entity) {
8
+ this.name = entity.name;
9
+ this.url = entity.url;
10
+ return this;
11
+ }
12
+ };
13
+ __decorate([
14
+ (0, es_mapping_ts_1.EsField)({ type: 'text' })
15
+ ], MediaDocument.prototype, "name", void 0);
16
+ __decorate([
17
+ (0, es_mapping_ts_1.EsField)({ type: 'text' })
18
+ ], MediaDocument.prototype, "url", void 0);
19
+ MediaDocument = __decorate([
20
+ (0, es_mapping_ts_1.EsEntity)({ mixins: [app_document_1.AppDocument] })
21
+ ], MediaDocument);
22
+ exports.MediaDocument = MediaDocument;
@@ -9,4 +9,3 @@ export declare class UpdateMediaValidator extends AppValidator<MediaEntity> {
9
9
  name: string;
10
10
  toEntity(entity: MediaEntity): MediaEntity;
11
11
  }
12
- //# sourceMappingURL=media.validator.d.ts.map
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UpdateMediaValidator = exports.CreateMediaValidator = void 0;
4
+ const class_validator_1 = require("class-validator");
5
+ require("reflect-metadata");
6
+ const app_validator_1 = require("../../../config/app.validator");
7
+ const media_entity_1 = require("./media.entity");
8
+ class CreateMediaValidator extends app_validator_1.AppValidator {
9
+ toEntity() {
10
+ const entity = new media_entity_1.MediaEntity();
11
+ entity.name = this.name;
12
+ return entity;
13
+ }
14
+ }
15
+ __decorate([
16
+ (0, class_validator_1.IsString)()
17
+ ], CreateMediaValidator.prototype, "name", void 0);
18
+ exports.CreateMediaValidator = CreateMediaValidator;
19
+ class UpdateMediaValidator extends app_validator_1.AppValidator {
20
+ toEntity(entity) {
21
+ if (this.name) {
22
+ entity.name = this.name;
23
+ }
24
+ return entity;
25
+ }
26
+ }
27
+ __decorate([
28
+ (0, class_validator_1.IsString)(),
29
+ (0, class_validator_1.IsOptional)()
30
+ ], UpdateMediaValidator.prototype, "name", void 0);
31
+ exports.UpdateMediaValidator = UpdateMediaValidator;
@@ -10,4 +10,3 @@ export declare class ProductDocument extends AppDocument<ProductEntity> {
10
10
  brand: Id;
11
11
  protected transform(entity: ProductEntity): this;
12
12
  }
13
- //# sourceMappingURL=product.document.d.ts.map
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProductDocument = void 0;
4
+ const es_mapping_ts_1 = require("es-mapping-ts");
5
+ const app_document_1 = require("../../../config/app.document");
6
+ let ProductDocument = class ProductDocument extends app_document_1.AppDocument {
7
+ transform(entity) {
8
+ this.name = entity.name;
9
+ this.description = entity.description;
10
+ this.active = entity.active;
11
+ this.availableFrom = entity.availableFrom;
12
+ this.category = entity.category.id;
13
+ this.brand = entity.brand.id;
14
+ return this;
15
+ }
16
+ };
17
+ __decorate([
18
+ (0, es_mapping_ts_1.EsField)({ type: 'keyword' })
19
+ ], ProductDocument.prototype, "name", void 0);
20
+ __decorate([
21
+ (0, es_mapping_ts_1.EsField)({ type: 'keyword' })
22
+ ], ProductDocument.prototype, "description", void 0);
23
+ __decorate([
24
+ (0, es_mapping_ts_1.EsField)({ type: 'date' })
25
+ ], ProductDocument.prototype, "availableFrom", void 0);
26
+ __decorate([
27
+ (0, es_mapping_ts_1.EsField)({ type: 'boolean' })
28
+ ], ProductDocument.prototype, "active", void 0);
29
+ __decorate([
30
+ (0, es_mapping_ts_1.EsField)({ type: 'text' })
31
+ ], ProductDocument.prototype, "category", void 0);
32
+ __decorate([
33
+ (0, es_mapping_ts_1.EsField)({ type: 'text' })
34
+ ], ProductDocument.prototype, "brand", void 0);
35
+ ProductDocument = __decorate([
36
+ (0, es_mapping_ts_1.EsEntity)({ mixins: [app_document_1.AppDocument] })
37
+ ], ProductDocument);
38
+ exports.ProductDocument = ProductDocument;
@@ -23,4 +23,3 @@ export declare class UpdateProductValidator extends AppValidator<ProductEntity>
23
23
  active: boolean;
24
24
  toEntity(entity: ProductEntity): ProductEntity;
25
25
  }
26
- //# sourceMappingURL=product.validator.d.ts.map
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UpdateProductValidator = exports.CreateProductValidator = void 0;
4
+ const class_transformer_1 = require("class-transformer");
5
+ const class_validator_1 = require("class-validator");
6
+ require("reflect-metadata");
7
+ const app_validator_1 = require("../../../config/app.validator");
8
+ const brand_entity_1 = require("../brands/brand.entity");
9
+ const category_entity_1 = require("../categories/category.entity");
10
+ const variant_validator_1 = require("../variants/variant.validator");
11
+ const product_entity_1 = require("./product.entity");
12
+ class CreateProductValidator extends app_validator_1.AppValidator {
13
+ constructor() {
14
+ super(...arguments);
15
+ this.active = true;
16
+ this.hashtags = [];
17
+ this.variants = [];
18
+ }
19
+ toEntity() {
20
+ const entity = new product_entity_1.ProductEntity();
21
+ entity.name = this.name;
22
+ entity.description = this.description;
23
+ entity.brand = new brand_entity_1.BrandEntity(this.brand);
24
+ entity.category = new category_entity_1.CategoryEntity(this.category);
25
+ entity.active = this.active;
26
+ entity.hashtags = this.hashtags;
27
+ entity.availableFrom = new Date(this.availableFrom || null);
28
+ return entity;
29
+ }
30
+ }
31
+ __decorate([
32
+ (0, class_validator_1.IsString)()
33
+ ], CreateProductValidator.prototype, "name", void 0);
34
+ __decorate([
35
+ (0, class_validator_1.IsString)(),
36
+ (0, class_validator_1.IsOptional)()
37
+ ], CreateProductValidator.prototype, "description", void 0);
38
+ __decorate([
39
+ (0, class_validator_1.IsDateString)(),
40
+ (0, class_validator_1.IsOptional)()
41
+ ], CreateProductValidator.prototype, "availableFrom", void 0);
42
+ __decorate([
43
+ (0, class_validator_1.IsBoolean)(),
44
+ (0, class_validator_1.IsOptional)()
45
+ ], CreateProductValidator.prototype, "active", void 0);
46
+ __decorate([
47
+ (0, class_validator_1.IsOptional)(),
48
+ (0, class_validator_1.IsUUID)()
49
+ ], CreateProductValidator.prototype, "category", void 0);
50
+ __decorate([
51
+ (0, class_validator_1.IsOptional)(),
52
+ (0, class_validator_1.IsUUID)()
53
+ ], CreateProductValidator.prototype, "brand", void 0);
54
+ __decorate([
55
+ (0, class_validator_1.IsOptional)(),
56
+ (0, class_validator_1.IsString)({ each: true })
57
+ ], CreateProductValidator.prototype, "hashtags", void 0);
58
+ __decorate([
59
+ (0, class_validator_1.ValidateNested)({ each: true }),
60
+ (0, class_transformer_1.Type)(() => variant_validator_1.CreateVariantValidator),
61
+ (0, class_validator_1.IsOptional)()
62
+ ], CreateProductValidator.prototype, "variants", void 0);
63
+ exports.CreateProductValidator = CreateProductValidator;
64
+ class UpdateProductValidator extends app_validator_1.AppValidator {
65
+ toEntity(entity) {
66
+ if (this.brand) {
67
+ entity.brand = new brand_entity_1.BrandEntity(this.brand);
68
+ }
69
+ if (this.category) {
70
+ entity.category = new category_entity_1.CategoryEntity(this.category);
71
+ }
72
+ if (this.description) {
73
+ entity.description = this.description;
74
+ }
75
+ if (this.hashtags) {
76
+ entity.hashtags = this.hashtags;
77
+ }
78
+ if (this.name) {
79
+ entity.name = this.name;
80
+ }
81
+ if (this.active) {
82
+ entity.active = this.active;
83
+ }
84
+ return entity;
85
+ }
86
+ }
87
+ __decorate([
88
+ (0, class_validator_1.IsString)(),
89
+ (0, class_validator_1.IsOptional)()
90
+ ], UpdateProductValidator.prototype, "name", void 0);
91
+ __decorate([
92
+ (0, class_validator_1.IsString)(),
93
+ (0, class_validator_1.IsOptional)()
94
+ ], UpdateProductValidator.prototype, "description", void 0);
95
+ __decorate([
96
+ (0, class_validator_1.IsOptional)(),
97
+ (0, class_validator_1.IsPositive)()
98
+ ], UpdateProductValidator.prototype, "category", void 0);
99
+ __decorate([
100
+ (0, class_validator_1.IsOptional)(),
101
+ (0, class_validator_1.IsPositive)()
102
+ ], UpdateProductValidator.prototype, "brand", void 0);
103
+ __decorate([
104
+ (0, class_validator_1.IsOptional)(),
105
+ (0, class_validator_1.IsString)({ each: true })
106
+ ], UpdateProductValidator.prototype, "hashtags", void 0);
107
+ __decorate([
108
+ (0, class_validator_1.IsBoolean)(),
109
+ (0, class_validator_1.IsOptional)()
110
+ ], UpdateProductValidator.prototype, "active", void 0);
111
+ exports.UpdateProductValidator = UpdateProductValidator;
@@ -7,4 +7,3 @@ export declare class VariantDocument extends AppDocument<VariantEntity> {
7
7
  active: boolean;
8
8
  protected transform(entity: VariantEntity): this;
9
9
  }
10
- //# sourceMappingURL=variant.document.d.ts.map
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VariantDocument = void 0;
4
+ const es_mapping_ts_1 = require("es-mapping-ts");
5
+ const app_document_1 = require("../../../config/app.document");
6
+ let VariantDocument = class VariantDocument extends app_document_1.AppDocument {
7
+ transform(entity) {
8
+ this.sku = entity.sku;
9
+ this.quantity = entity.quantity;
10
+ this.price = entity.price;
11
+ this.active = entity.active;
12
+ return this;
13
+ }
14
+ };
15
+ __decorate([
16
+ (0, es_mapping_ts_1.EsField)({ type: 'keyword' })
17
+ ], VariantDocument.prototype, "sku", void 0);
18
+ __decorate([
19
+ (0, es_mapping_ts_1.EsField)({ type: 'float' })
20
+ ], VariantDocument.prototype, "quantity", void 0);
21
+ __decorate([
22
+ (0, es_mapping_ts_1.EsField)({ type: 'integer' })
23
+ ], VariantDocument.prototype, "price", void 0);
24
+ __decorate([
25
+ (0, es_mapping_ts_1.EsField)({ type: 'boolean' })
26
+ ], VariantDocument.prototype, "active", void 0);
27
+ VariantDocument = __decorate([
28
+ (0, es_mapping_ts_1.EsEntity)({ mixins: [app_document_1.AppDocument] })
29
+ ], VariantDocument);
30
+ exports.VariantDocument = VariantDocument;
@@ -16,4 +16,3 @@ export declare class UpdateVariantValidator extends AppValidator<VariantEntity>
16
16
  active: any;
17
17
  toEntity(entity: VariantEntity): VariantEntity;
18
18
  }
19
- //# sourceMappingURL=variant.validator.d.ts.map
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UpdateVariantValidator = exports.CreateVariantValidator = void 0;
4
+ const class_validator_1 = require("class-validator");
5
+ require("reflect-metadata");
6
+ const app_validator_1 = require("../../../config/app.validator");
7
+ const variant_entity_1 = require("./variant.entity");
8
+ class CreateVariantValidator extends app_validator_1.AppValidator {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.price = 0;
12
+ this.quantity = 1;
13
+ this.active = true;
14
+ }
15
+ toEntity(product) {
16
+ const entity = new variant_entity_1.VariantEntity();
17
+ entity.sku = this.sku;
18
+ entity.price = this.price;
19
+ entity.quantity = this.quantity;
20
+ entity.active = this.active;
21
+ if (product) {
22
+ entity.product = product;
23
+ }
24
+ return entity;
25
+ }
26
+ }
27
+ __decorate([
28
+ (0, class_validator_1.IsNumber)(),
29
+ (0, class_validator_1.Min)(0)
30
+ ], CreateVariantValidator.prototype, "price", void 0);
31
+ __decorate([
32
+ (0, class_validator_1.Length)(1, 32)
33
+ ], CreateVariantValidator.prototype, "sku", void 0);
34
+ __decorate([
35
+ (0, class_validator_1.IsPositive)(),
36
+ (0, class_validator_1.IsOptional)()
37
+ ], CreateVariantValidator.prototype, "quantity", void 0);
38
+ __decorate([
39
+ (0, class_validator_1.IsBoolean)(),
40
+ (0, class_validator_1.IsOptional)()
41
+ ], CreateVariantValidator.prototype, "active", void 0);
42
+ exports.CreateVariantValidator = CreateVariantValidator;
43
+ class UpdateVariantValidator extends app_validator_1.AppValidator {
44
+ constructor() {
45
+ super(...arguments);
46
+ this.price = 0;
47
+ this.quantity = 1;
48
+ }
49
+ toEntity(entity) {
50
+ if (this.sku) {
51
+ entity.sku = this.sku;
52
+ }
53
+ if (this.price) {
54
+ entity.price = this.price;
55
+ }
56
+ if (this.quantity) {
57
+ entity.quantity = this.quantity;
58
+ }
59
+ if (this.active) {
60
+ entity.active = this.active;
61
+ }
62
+ return entity;
63
+ }
64
+ }
65
+ __decorate([
66
+ (0, class_validator_1.IsNumber)(),
67
+ (0, class_validator_1.Min)(0),
68
+ (0, class_validator_1.IsOptional)()
69
+ ], UpdateVariantValidator.prototype, "price", void 0);
70
+ __decorate([
71
+ (0, class_validator_1.IsOptional)()
72
+ ], UpdateVariantValidator.prototype, "sku", void 0);
73
+ __decorate([
74
+ (0, class_validator_1.IsPositive)(),
75
+ (0, class_validator_1.IsOptional)()
76
+ ], UpdateVariantValidator.prototype, "quantity", void 0);
77
+ __decorate([
78
+ (0, class_validator_1.IsBoolean)(),
79
+ (0, class_validator_1.IsOptional)()
80
+ ], UpdateVariantValidator.prototype, "active", void 0);
81
+ exports.UpdateVariantValidator = UpdateVariantValidator;