@merkaly/api 0.2.1-3 → 0.2.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.
Files changed (39) hide show
  1. package/.output/config/app.document.d.ts +2 -2
  2. package/.output/src/inventory/brands/brand.document.d.ts +1 -1
  3. package/.output/src/inventory/brands/brand.validator.d.ts +1 -1
  4. package/.output/src/inventory/categories/category.document.d.ts +1 -1
  5. package/.output/src/inventory/categories/category.validator.d.ts +1 -1
  6. package/.output/src/inventory/media/media.document.d.ts +1 -1
  7. package/.output/src/inventory/media/media.validator.d.ts +1 -1
  8. package/.output/src/inventory/products/product.document.d.ts +6 -7
  9. package/.output/src/inventory/products/product.entity.d.ts +1 -6
  10. package/.output/src/inventory/products/product.validator.d.ts +5 -8
  11. package/.output/src/inventory/variants/variant.document.d.ts +1 -4
  12. package/.output/src/inventory/variants/variant.entity.d.ts +0 -5
  13. package/.output/src/inventory/variants/variant.validator.d.ts +2 -7
  14. package/.output/src/store/orders/order.document.d.ts +1 -1
  15. package/.output/src/store/orders/order.validator.d.ts +1 -1
  16. package/package.json +3 -2
  17. package/.output/app.js +0 -48
  18. package/.output/config/app.document.js +0 -38
  19. package/.output/config/app.entity.js +0 -35
  20. package/.output/config/app.validator.js +0 -6
  21. package/.output/src/auth/auth.validator.js +0 -21
  22. package/.output/src/inventory/brands/brand.document.js +0 -30
  23. package/.output/src/inventory/brands/brand.entity.js +0 -30
  24. package/.output/src/inventory/brands/brand.validator.js +0 -53
  25. package/.output/src/inventory/categories/category.document.js +0 -30
  26. package/.output/src/inventory/categories/category.entity.js +0 -30
  27. package/.output/src/inventory/categories/category.validator.js +0 -56
  28. package/.output/src/inventory/media/media.document.js +0 -30
  29. package/.output/src/inventory/media/media.entity.js +0 -30
  30. package/.output/src/inventory/media/media.validator.js +0 -38
  31. package/.output/src/inventory/products/product.document.js +0 -54
  32. package/.output/src/inventory/products/product.entity.js +0 -67
  33. package/.output/src/inventory/products/product.validator.js +0 -124
  34. package/.output/src/inventory/variants/variant.document.js +0 -40
  35. package/.output/src/inventory/variants/variant.entity.js +0 -44
  36. package/.output/src/inventory/variants/variant.validator.js +0 -83
  37. package/.output/src/store/orders/order.document.js +0 -30
  38. package/.output/src/store/orders/order.entity.js +0 -25
  39. package/.output/src/store/orders/order.validator.js +0 -17
@@ -1,9 +1,9 @@
1
1
  import { AppEntity } from './app.entity';
2
2
  export declare abstract class AppDocument<E extends AppEntity> {
3
- protected abstract transform(entity: E): this;
3
+ protected abstract transform?(entity: E): this;
4
4
  $id: string;
5
5
  $createdAt: Date;
6
6
  $updatedAt: Date;
7
7
  $deletedAt: Date;
8
- serialize(entity: E): this;
8
+ serialize?(entity: E): this;
9
9
  }
@@ -3,5 +3,5 @@ import { BrandEntity } from './brand.entity';
3
3
  export declare class BrandDocument extends AppDocument<BrandEntity> {
4
4
  name: string;
5
5
  description: string;
6
- protected transform(entity: BrandEntity): this;
6
+ protected transform?(entity: BrandEntity): this;
7
7
  }
@@ -8,5 +8,5 @@ export declare class CreateBrandValidator extends AppValidator<BrandEntity> {
8
8
  export declare class UpdateBrandValidator extends AppValidator<BrandEntity> {
9
9
  name?: string;
10
10
  description?: string;
11
- toEntity(entity: BrandEntity): BrandEntity;
11
+ toEntity?(entity: BrandEntity): BrandEntity;
12
12
  }
@@ -3,5 +3,5 @@ import { CategoryEntity } from './category.entity';
3
3
  export declare class CategoryDocument extends AppDocument<CategoryEntity> {
4
4
  name: string;
5
5
  description: string;
6
- protected transform(entity: CategoryEntity): this;
6
+ protected transform?(entity: CategoryEntity): this;
7
7
  }
@@ -10,5 +10,5 @@ export declare class CreateCategoryValidator extends AppValidator<CategoryEntity
10
10
  export declare class UpdateCategoryValidator extends AppValidator<CategoryEntity> {
11
11
  name: string;
12
12
  description?: string;
13
- toEntity(entity: CategoryEntity): CategoryEntity;
13
+ toEntity?(entity: CategoryEntity): CategoryEntity;
14
14
  }
@@ -3,5 +3,5 @@ import { MediaEntity } from './media.entity';
3
3
  export declare class MediaDocument extends AppDocument<MediaEntity> {
4
4
  name: string;
5
5
  url: string;
6
- protected transform(entity: MediaEntity): this;
6
+ protected transform?(entity: MediaEntity): this;
7
7
  }
@@ -6,5 +6,5 @@ export declare class CreateMediaValidator extends AppValidator<MediaEntity> {
6
6
  }
7
7
  export declare class UpdateMediaValidator extends AppValidator<MediaEntity> {
8
8
  name: string;
9
- toEntity(entity: MediaEntity): MediaEntity;
9
+ toEntity?(entity: MediaEntity): MediaEntity;
10
10
  }
@@ -1,13 +1,12 @@
1
- import { Id } from '@elastic/elasticsearch/lib/api/types';
2
1
  import { AppDocument } from '../../../config/app.document';
2
+ import { BrandEntity } from '../brands/brand.entity';
3
+ import { CategoryEntity } from '../categories/category.entity';
3
4
  import { ProductEntity } from './product.entity';
4
5
  export declare class ProductDocument extends AppDocument<ProductEntity> {
5
6
  name: string;
6
7
  description: string;
7
- availableFrom: Date;
8
- hashtags: string[];
9
- active: boolean;
10
- category: Id;
11
- brand: Id;
12
- protected transform(entity: ProductEntity): this;
8
+ category: Pick<CategoryEntity, 'id' | 'name' | 'description'>;
9
+ brand: Pick<BrandEntity, 'id' | 'name' | 'description'>;
10
+ price: number;
11
+ protected transform?(entity: ProductEntity): this;
13
12
  }
@@ -6,14 +6,9 @@ import { VariantEntity } from '../variants/variant.entity';
6
6
  export declare class ProductEntity extends AppEntity {
7
7
  name: string;
8
8
  description?: string;
9
- active: boolean;
10
- availableFrom: Date;
11
- hashtags: string[];
9
+ price: number;
12
10
  category?: CategoryEntity;
13
11
  brand?: BrandEntity;
14
- variant: VariantEntity;
15
12
  variants: VariantEntity[];
16
13
  media: MediaEntity[];
17
- get isOutOfStock(): boolean;
18
- get isDraft(): boolean;
19
14
  }
@@ -5,20 +5,17 @@ import { ProductEntity } from './product.entity';
5
5
  export declare class CreateProductValidator extends AppValidator<ProductEntity> {
6
6
  name: string;
7
7
  description?: string;
8
- availableFrom: Date;
9
- active: boolean;
10
- category?: Id;
11
- brand?: Id;
12
- hashtags: string[];
8
+ price: number;
9
+ category?: string;
10
+ brand?: string;
13
11
  variants?: CreateVariantValidator[];
14
12
  toEntity?(): ProductEntity;
15
13
  }
16
14
  export declare class UpdateProductValidator extends AppValidator<ProductEntity> {
17
15
  name?: string;
18
16
  description?: string;
17
+ price: number;
19
18
  category?: Id;
20
19
  brand?: Id;
21
- hashtags?: string[];
22
- active: boolean;
23
- toEntity(entity: ProductEntity): ProductEntity;
20
+ toEntity?(entity: ProductEntity): ProductEntity;
24
21
  }
@@ -1,9 +1,6 @@
1
1
  import { AppDocument } from '../../../config/app.document';
2
2
  import { VariantEntity } from './variant.entity';
3
3
  export declare class VariantDocument extends AppDocument<VariantEntity> {
4
- sku: string;
5
- quantity: number;
6
4
  price: number;
7
- active: boolean;
8
- protected transform(entity: VariantEntity): this;
5
+ protected transform?(entity: VariantEntity): this;
9
6
  }
@@ -1,11 +1,6 @@
1
1
  import { AppEntity } from '../../../config/app.entity';
2
2
  import { ProductEntity } from '../products/product.entity';
3
3
  export declare class VariantEntity extends AppEntity {
4
- sku: string;
5
4
  price: number;
6
- quantity: number;
7
- active: boolean;
8
5
  product: ProductEntity;
9
- get isOutOfStock(): boolean;
10
- get isDraft(): boolean;
11
6
  }
@@ -3,15 +3,10 @@ import { ProductEntity } from '../products/product.entity';
3
3
  import { VariantEntity } from './variant.entity';
4
4
  export declare class CreateVariantValidator extends AppValidator<VariantEntity> {
5
5
  price: number;
6
- sku: string;
7
- quantity: number;
8
6
  active: boolean;
9
- toEntity(product?: ProductEntity): VariantEntity;
7
+ toEntity?(product?: ProductEntity): VariantEntity;
10
8
  }
11
9
  export declare class UpdateVariantValidator extends AppValidator<VariantEntity> {
12
10
  price: number;
13
- sku: string;
14
- quantity: number;
15
- active: any;
16
- toEntity(entity: VariantEntity): VariantEntity;
11
+ toEntity?(entity: VariantEntity): VariantEntity;
17
12
  }
@@ -3,5 +3,5 @@ import { OrderEntity } from './order.entity';
3
3
  export declare class OrderDocument extends AppDocument<OrderEntity> {
4
4
  number: string;
5
5
  price: number;
6
- protected transform(entity: OrderEntity): this;
6
+ protected transform?(entity: OrderEntity): this;
7
7
  }
@@ -4,5 +4,5 @@ export declare class CreateOrderValidator extends AppValidator<OrderEntity> {
4
4
  toEntity?(): OrderEntity;
5
5
  }
6
6
  export declare class UpdateOrderValidator extends AppValidator<OrderEntity> {
7
- toEntity(entity: OrderEntity): OrderEntity;
7
+ toEntity?(entity: OrderEntity): OrderEntity;
8
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@merkaly/api",
3
- "version": "0.2.1-3",
3
+ "version": "0.2.1",
4
4
  "description": "NestJS Backend ApiRest Service",
5
5
  "author": "Randy Tellez Galan <kronhyx@gmail.com>",
6
6
  "license": "UNLICENSED",
@@ -18,7 +18,7 @@
18
18
  "clean": "tsc -b --clean",
19
19
  "start": "nest start --preserveWatchOutput",
20
20
  "dev": "yarn build && yarn start --watch",
21
- "start:debug": "yarn dev -- --debug ",
21
+ "console": "ts-node -r tsconfig-paths/register ./console.ts",
22
22
  "start:prod": "node dist/index.js",
23
23
  "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" . ",
24
24
  "test": "jest",
@@ -71,6 +71,7 @@
71
71
  "husky": "^8.0.1",
72
72
  "jest": "27.5.1",
73
73
  "mysql2": "^2.3.3",
74
+ "nestjs-console": "^7.0.1",
74
75
  "passport": "^0.6.0",
75
76
  "passport-jwt": "^4.0.0",
76
77
  "rimraf": "^3.0.2",
package/.output/app.js DELETED
@@ -1,48 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.Store = exports.Inventory = void 0;
27
- const brand_document_1 = require("./src/inventory/brands/brand.document");
28
- const BrandValidators = __importStar(require("./src/inventory/brands/brand.validator"));
29
- const category_document_1 = require("./src/inventory/categories/category.document");
30
- const CategoryValidators = __importStar(require("./src/inventory/categories/category.validator"));
31
- const media_document_1 = require("./src/inventory/media/media.document");
32
- const MediaValidators = __importStar(require("./src/inventory/media/media.validator"));
33
- const product_document_1 = require("./src/inventory/products/product.document");
34
- const ProductValidators = __importStar(require("./src/inventory/products/product.validator"));
35
- const variant_document_1 = require("./src/inventory/variants/variant.document");
36
- const VariantValidators = __importStar(require("./src/inventory/variants/variant.validator"));
37
- const order_document_1 = require("./src/store/orders/order.document");
38
- const OrderValidators = __importStar(require("./src/store/orders/order.validator"));
39
- exports.Inventory = {
40
- Brand: { BrandDocument: brand_document_1.BrandDocument, ...BrandValidators },
41
- Category: { CategoryDocument: category_document_1.CategoryDocument, ...CategoryValidators },
42
- Product: { ProductDocument: product_document_1.ProductDocument, ...ProductValidators },
43
- Media: { MediaDocument: media_document_1.MediaDocument, ...MediaValidators },
44
- Variant: { VariantDocument: variant_document_1.VariantDocument, ...VariantValidators }
45
- };
46
- exports.Store = {
47
- Order: { OrderDocument: order_document_1.OrderDocument, ...OrderValidators }
48
- };
@@ -1,38 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.AppDocument = void 0;
10
- const class_transformer_1 = require("class-transformer");
11
- const es_mapping_ts_1 = require("es-mapping-ts");
12
- class AppDocument {
13
- $id;
14
- $createdAt;
15
- $updatedAt;
16
- $deletedAt;
17
- serialize(entity) {
18
- this.$id = entity.id;
19
- this.$createdAt = entity.createdAt;
20
- this.$updatedAt = entity.updatedAt;
21
- this.$deletedAt = entity.deletedAt;
22
- this.transform(entity);
23
- return (0, class_transformer_1.instanceToPlain)(this);
24
- }
25
- }
26
- __decorate([
27
- (0, es_mapping_ts_1.EsField)({ type: 'text' })
28
- ], AppDocument.prototype, "$id", void 0);
29
- __decorate([
30
- (0, es_mapping_ts_1.EsField)({ type: 'date' })
31
- ], AppDocument.prototype, "$createdAt", void 0);
32
- __decorate([
33
- (0, es_mapping_ts_1.EsField)({ type: 'date' })
34
- ], AppDocument.prototype, "$updatedAt", void 0);
35
- __decorate([
36
- (0, es_mapping_ts_1.EsField)({ type: 'date' })
37
- ], AppDocument.prototype, "$deletedAt", void 0);
38
- exports.AppDocument = AppDocument;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.AppEntity = void 0;
10
- const typeorm_1 = require("typeorm");
11
- let AppEntity = class AppEntity {
12
- constructor(id) {
13
- this.id = id;
14
- }
15
- id;
16
- createdAt = new Date();
17
- updatedAt;
18
- deletedAt;
19
- };
20
- __decorate([
21
- (0, typeorm_1.PrimaryGeneratedColumn)('uuid')
22
- ], AppEntity.prototype, "id", void 0);
23
- __decorate([
24
- (0, typeorm_1.CreateDateColumn)({ type: 'datetime', nullable: false })
25
- ], AppEntity.prototype, "createdAt", void 0);
26
- __decorate([
27
- (0, typeorm_1.UpdateDateColumn)({ type: 'datetime', nullable: true })
28
- ], AppEntity.prototype, "updatedAt", void 0);
29
- __decorate([
30
- (0, typeorm_1.DeleteDateColumn)({ type: 'datetime', nullable: true })
31
- ], AppEntity.prototype, "deletedAt", void 0);
32
- AppEntity = __decorate([
33
- (0, typeorm_1.Entity)()
34
- ], AppEntity);
35
- exports.AppEntity = AppEntity;
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AppValidator = void 0;
4
- class AppValidator {
5
- }
6
- exports.AppValidator = AppValidator;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.LoginValidator = void 0;
10
- const class_validator_1 = require("class-validator");
11
- class LoginValidator {
12
- username;
13
- password;
14
- }
15
- __decorate([
16
- (0, class_validator_1.IsEmail)()
17
- ], LoginValidator.prototype, "username", void 0);
18
- __decorate([
19
- (0, class_validator_1.IsNotEmpty)()
20
- ], LoginValidator.prototype, "password", void 0);
21
- exports.LoginValidator = LoginValidator;
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.BrandDocument = void 0;
10
- const es_mapping_ts_1 = require("es-mapping-ts");
11
- const app_document_1 = require("../../../config/app.document");
12
- let BrandDocument = class BrandDocument extends app_document_1.AppDocument {
13
- name;
14
- description;
15
- transform(entity) {
16
- this.name = entity.name;
17
- this.description = entity.description;
18
- return this;
19
- }
20
- };
21
- __decorate([
22
- (0, es_mapping_ts_1.EsField)({ type: 'keyword' })
23
- ], BrandDocument.prototype, "name", void 0);
24
- __decorate([
25
- (0, es_mapping_ts_1.EsField)({ type: 'text' })
26
- ], BrandDocument.prototype, "description", void 0);
27
- BrandDocument = __decorate([
28
- (0, es_mapping_ts_1.EsEntity)({ mixins: [app_document_1.AppDocument] })
29
- ], BrandDocument);
30
- exports.BrandDocument = BrandDocument;
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.BrandEntity = void 0;
10
- const typeorm_1 = require("typeorm");
11
- const app_entity_1 = require("../../../config/app.entity");
12
- const product_entity_1 = require("../products/product.entity");
13
- let BrandEntity = class BrandEntity extends app_entity_1.AppEntity {
14
- name;
15
- description;
16
- products;
17
- };
18
- __decorate([
19
- (0, typeorm_1.Column)({ length: 32, unique: true })
20
- ], BrandEntity.prototype, "name", void 0);
21
- __decorate([
22
- (0, typeorm_1.Column)({ type: 'text', nullable: true })
23
- ], BrandEntity.prototype, "description", void 0);
24
- __decorate([
25
- (0, typeorm_1.OneToMany)(() => product_entity_1.ProductEntity, ({ brand }) => brand)
26
- ], BrandEntity.prototype, "products", void 0);
27
- BrandEntity = __decorate([
28
- (0, typeorm_1.Entity)('inventory_brands')
29
- ], BrandEntity);
30
- exports.BrandEntity = BrandEntity;
@@ -1,53 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.UpdateBrandValidator = exports.CreateBrandValidator = void 0;
10
- const class_validator_1 = require("class-validator");
11
- const app_validator_1 = require("../../../config/app.validator");
12
- const brand_entity_1 = require("./brand.entity");
13
- class CreateBrandValidator extends app_validator_1.AppValidator {
14
- name;
15
- description;
16
- toEntity() {
17
- const entity = new brand_entity_1.BrandEntity();
18
- entity.name = this.name;
19
- entity.description = this.description;
20
- return entity;
21
- }
22
- }
23
- __decorate([
24
- (0, class_validator_1.IsString)(),
25
- (0, class_validator_1.Length)(2, 32)
26
- ], CreateBrandValidator.prototype, "name", void 0);
27
- __decorate([
28
- (0, class_validator_1.IsString)(),
29
- (0, class_validator_1.IsOptional)()
30
- ], CreateBrandValidator.prototype, "description", void 0);
31
- exports.CreateBrandValidator = CreateBrandValidator;
32
- class UpdateBrandValidator extends app_validator_1.AppValidator {
33
- name;
34
- description;
35
- toEntity(entity) {
36
- if (this.name) {
37
- entity.name = this.name;
38
- }
39
- if (this.description) {
40
- entity.description = this.description;
41
- }
42
- return entity;
43
- }
44
- }
45
- __decorate([
46
- (0, class_validator_1.IsString)(),
47
- (0, class_validator_1.IsOptional)()
48
- ], UpdateBrandValidator.prototype, "name", void 0);
49
- __decorate([
50
- (0, class_validator_1.IsString)(),
51
- (0, class_validator_1.IsOptional)()
52
- ], UpdateBrandValidator.prototype, "description", void 0);
53
- exports.UpdateBrandValidator = UpdateBrandValidator;
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.CategoryDocument = void 0;
10
- const es_mapping_ts_1 = require("es-mapping-ts");
11
- const app_document_1 = require("../../../config/app.document");
12
- let CategoryDocument = class CategoryDocument extends app_document_1.AppDocument {
13
- name;
14
- description;
15
- transform(entity) {
16
- this.name = entity.name;
17
- this.description = entity.description;
18
- return this;
19
- }
20
- };
21
- __decorate([
22
- (0, es_mapping_ts_1.EsField)({ type: 'keyword' })
23
- ], CategoryDocument.prototype, "name", void 0);
24
- __decorate([
25
- (0, es_mapping_ts_1.EsField)({ type: 'text' })
26
- ], CategoryDocument.prototype, "description", void 0);
27
- CategoryDocument = __decorate([
28
- (0, es_mapping_ts_1.EsEntity)({ mixins: [app_document_1.AppDocument] })
29
- ], CategoryDocument);
30
- exports.CategoryDocument = CategoryDocument;
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.CategoryEntity = void 0;
10
- const typeorm_1 = require("typeorm");
11
- const app_entity_1 = require("../../../config/app.entity");
12
- const product_entity_1 = require("../products/product.entity");
13
- let CategoryEntity = class CategoryEntity extends app_entity_1.AppEntity {
14
- name;
15
- description;
16
- products;
17
- };
18
- __decorate([
19
- (0, typeorm_1.Column)({ length: 32, unique: true })
20
- ], CategoryEntity.prototype, "name", void 0);
21
- __decorate([
22
- (0, typeorm_1.Column)({ type: 'text', nullable: true })
23
- ], CategoryEntity.prototype, "description", void 0);
24
- __decorate([
25
- (0, typeorm_1.OneToMany)(() => product_entity_1.ProductEntity, ({ category }) => category)
26
- ], CategoryEntity.prototype, "products", void 0);
27
- CategoryEntity = __decorate([
28
- (0, typeorm_1.Entity)('inventory_categories')
29
- ], CategoryEntity);
30
- exports.CategoryEntity = CategoryEntity;
@@ -1,56 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.UpdateCategoryValidator = exports.CreateCategoryValidator = exports.FindCategoryValidator = void 0;
10
- const class_validator_1 = require("class-validator");
11
- const app_validator_1 = require("../../../config/app.validator");
12
- const category_entity_1 = require("./category.entity");
13
- class FindCategoryValidator {
14
- }
15
- exports.FindCategoryValidator = FindCategoryValidator;
16
- class CreateCategoryValidator extends app_validator_1.AppValidator {
17
- name;
18
- description;
19
- toEntity() {
20
- const entity = new category_entity_1.CategoryEntity();
21
- entity.name = this.name;
22
- entity.description = this.description;
23
- return entity;
24
- }
25
- }
26
- __decorate([
27
- (0, class_validator_1.IsString)(),
28
- (0, class_validator_1.Length)(5, 32)
29
- ], CreateCategoryValidator.prototype, "name", void 0);
30
- __decorate([
31
- (0, class_validator_1.IsString)(),
32
- (0, class_validator_1.IsOptional)()
33
- ], CreateCategoryValidator.prototype, "description", void 0);
34
- exports.CreateCategoryValidator = CreateCategoryValidator;
35
- class UpdateCategoryValidator extends app_validator_1.AppValidator {
36
- name;
37
- description;
38
- toEntity(entity) {
39
- if (this.name) {
40
- entity.name = this.name;
41
- }
42
- if (this.description) {
43
- entity.description = this.description;
44
- }
45
- return entity;
46
- }
47
- }
48
- __decorate([
49
- (0, class_validator_1.IsString)(),
50
- (0, class_validator_1.IsOptional)()
51
- ], UpdateCategoryValidator.prototype, "name", void 0);
52
- __decorate([
53
- (0, class_validator_1.IsString)(),
54
- (0, class_validator_1.IsOptional)()
55
- ], UpdateCategoryValidator.prototype, "description", void 0);
56
- exports.UpdateCategoryValidator = UpdateCategoryValidator;
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.MediaDocument = void 0;
10
- const es_mapping_ts_1 = require("es-mapping-ts");
11
- const app_document_1 = require("../../../config/app.document");
12
- let MediaDocument = class MediaDocument extends app_document_1.AppDocument {
13
- name;
14
- url;
15
- transform(entity) {
16
- this.name = entity.name;
17
- this.url = entity.url;
18
- return this;
19
- }
20
- };
21
- __decorate([
22
- (0, es_mapping_ts_1.EsField)({ type: 'text' })
23
- ], MediaDocument.prototype, "name", void 0);
24
- __decorate([
25
- (0, es_mapping_ts_1.EsField)({ type: 'text' })
26
- ], MediaDocument.prototype, "url", void 0);
27
- MediaDocument = __decorate([
28
- (0, es_mapping_ts_1.EsEntity)({ mixins: [app_document_1.AppDocument] })
29
- ], MediaDocument);
30
- exports.MediaDocument = MediaDocument;
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.MediaEntity = void 0;
10
- const typeorm_1 = require("typeorm");
11
- const app_entity_1 = require("../../../config/app.entity");
12
- const product_entity_1 = require("../products/product.entity");
13
- let MediaEntity = class MediaEntity extends app_entity_1.AppEntity {
14
- name;
15
- url;
16
- product;
17
- };
18
- __decorate([
19
- (0, typeorm_1.Column)({ length: 64 })
20
- ], MediaEntity.prototype, "name", void 0);
21
- __decorate([
22
- (0, typeorm_1.Column)({ length: 2048 })
23
- ], MediaEntity.prototype, "url", void 0);
24
- __decorate([
25
- (0, typeorm_1.ManyToOne)(() => product_entity_1.ProductEntity, ({ media }) => media)
26
- ], MediaEntity.prototype, "product", void 0);
27
- MediaEntity = __decorate([
28
- (0, typeorm_1.Entity)('inventory_media')
29
- ], MediaEntity);
30
- exports.MediaEntity = MediaEntity;
@@ -1,38 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.UpdateMediaValidator = exports.CreateMediaValidator = void 0;
10
- const class_validator_1 = require("class-validator");
11
- const app_validator_1 = require("../../../config/app.validator");
12
- const media_entity_1 = require("./media.entity");
13
- class CreateMediaValidator extends app_validator_1.AppValidator {
14
- name;
15
- toEntity() {
16
- const entity = new media_entity_1.MediaEntity();
17
- entity.name = this.name;
18
- return entity;
19
- }
20
- }
21
- __decorate([
22
- (0, class_validator_1.IsString)()
23
- ], CreateMediaValidator.prototype, "name", void 0);
24
- exports.CreateMediaValidator = CreateMediaValidator;
25
- class UpdateMediaValidator extends app_validator_1.AppValidator {
26
- name;
27
- toEntity(entity) {
28
- if (this.name) {
29
- entity.name = this.name;
30
- }
31
- return entity;
32
- }
33
- }
34
- __decorate([
35
- (0, class_validator_1.IsString)(),
36
- (0, class_validator_1.IsOptional)()
37
- ], UpdateMediaValidator.prototype, "name", void 0);
38
- exports.UpdateMediaValidator = UpdateMediaValidator;
@@ -1,54 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.ProductDocument = void 0;
10
- const es_mapping_ts_1 = require("es-mapping-ts");
11
- const app_document_1 = require("../../../config/app.document");
12
- let ProductDocument = class ProductDocument extends app_document_1.AppDocument {
13
- name;
14
- description;
15
- availableFrom;
16
- hashtags;
17
- active;
18
- category;
19
- brand;
20
- transform(entity) {
21
- this.name = entity.name;
22
- this.description = entity.description;
23
- this.active = entity.active;
24
- this.availableFrom = entity.availableFrom;
25
- this.category = entity.category.id;
26
- this.brand = entity.brand.id;
27
- return this;
28
- }
29
- };
30
- __decorate([
31
- (0, es_mapping_ts_1.EsField)({ type: 'keyword' })
32
- ], ProductDocument.prototype, "name", void 0);
33
- __decorate([
34
- (0, es_mapping_ts_1.EsField)({ type: 'keyword' })
35
- ], ProductDocument.prototype, "description", void 0);
36
- __decorate([
37
- (0, es_mapping_ts_1.EsField)({ type: 'date' })
38
- ], ProductDocument.prototype, "availableFrom", void 0);
39
- __decorate([
40
- (0, es_mapping_ts_1.EsField)({ type: 'nested' })
41
- ], ProductDocument.prototype, "hashtags", void 0);
42
- __decorate([
43
- (0, es_mapping_ts_1.EsField)({ type: 'boolean' })
44
- ], ProductDocument.prototype, "active", void 0);
45
- __decorate([
46
- (0, es_mapping_ts_1.EsField)({ type: 'text' })
47
- ], ProductDocument.prototype, "category", void 0);
48
- __decorate([
49
- (0, es_mapping_ts_1.EsField)({ type: 'text' })
50
- ], ProductDocument.prototype, "brand", void 0);
51
- ProductDocument = __decorate([
52
- (0, es_mapping_ts_1.EsEntity)({ mixins: [app_document_1.AppDocument] })
53
- ], ProductDocument);
54
- exports.ProductDocument = ProductDocument;
@@ -1,67 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.ProductEntity = void 0;
10
- const typeorm_1 = require("typeorm");
11
- const app_entity_1 = require("../../../config/app.entity");
12
- const brand_entity_1 = require("../brands/brand.entity");
13
- const category_entity_1 = require("../categories/category.entity");
14
- const media_entity_1 = require("../media/media.entity");
15
- const variant_entity_1 = require("../variants/variant.entity");
16
- let ProductEntity = class ProductEntity extends app_entity_1.AppEntity {
17
- name;
18
- description;
19
- active = true;
20
- availableFrom = new Date();
21
- hashtags = [];
22
- category;
23
- brand;
24
- variant;
25
- variants;
26
- media;
27
- get isOutOfStock() {
28
- return this.variants.every(variant => variant.isOutOfStock);
29
- }
30
- get isDraft() {
31
- return this.active === true;
32
- }
33
- };
34
- __decorate([
35
- (0, typeorm_1.Column)({ length: 64 })
36
- ], ProductEntity.prototype, "name", void 0);
37
- __decorate([
38
- (0, typeorm_1.Column)({ type: 'text', nullable: true })
39
- ], ProductEntity.prototype, "description", void 0);
40
- __decorate([
41
- (0, typeorm_1.Column)({ type: 'boolean', default: true })
42
- ], ProductEntity.prototype, "active", void 0);
43
- __decorate([
44
- (0, typeorm_1.Column)({ type: 'datetime', nullable: true })
45
- ], ProductEntity.prototype, "availableFrom", void 0);
46
- __decorate([
47
- (0, typeorm_1.Column)({ type: 'simple-array', nullable: true })
48
- ], ProductEntity.prototype, "hashtags", void 0);
49
- __decorate([
50
- (0, typeorm_1.ManyToOne)(() => category_entity_1.CategoryEntity, ({ products }) => products)
51
- ], ProductEntity.prototype, "category", void 0);
52
- __decorate([
53
- (0, typeorm_1.ManyToOne)(() => brand_entity_1.BrandEntity, ({ products }) => products)
54
- ], ProductEntity.prototype, "brand", void 0);
55
- __decorate([
56
- (0, typeorm_1.ManyToOne)(() => variant_entity_1.VariantEntity, ({ product }) => product)
57
- ], ProductEntity.prototype, "variant", void 0);
58
- __decorate([
59
- (0, typeorm_1.OneToMany)(() => variant_entity_1.VariantEntity, ({ product }) => product)
60
- ], ProductEntity.prototype, "variants", void 0);
61
- __decorate([
62
- (0, typeorm_1.OneToMany)(() => media_entity_1.MediaEntity, ({ product }) => product)
63
- ], ProductEntity.prototype, "media", void 0);
64
- ProductEntity = __decorate([
65
- (0, typeorm_1.Entity)('inventory_products')
66
- ], ProductEntity);
67
- exports.ProductEntity = ProductEntity;
@@ -1,124 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.UpdateProductValidator = exports.CreateProductValidator = void 0;
10
- const class_transformer_1 = require("class-transformer");
11
- const class_validator_1 = require("class-validator");
12
- const app_validator_1 = require("../../../config/app.validator");
13
- const brand_entity_1 = require("../brands/brand.entity");
14
- const category_entity_1 = require("../categories/category.entity");
15
- const variant_validator_1 = require("../variants/variant.validator");
16
- const product_entity_1 = require("./product.entity");
17
- class CreateProductValidator extends app_validator_1.AppValidator {
18
- name;
19
- description;
20
- availableFrom;
21
- active = true;
22
- category;
23
- brand;
24
- hashtags = [];
25
- variants = [];
26
- toEntity() {
27
- const entity = new product_entity_1.ProductEntity();
28
- entity.name = this.name;
29
- entity.description = this.description;
30
- entity.brand = new brand_entity_1.BrandEntity(this.brand);
31
- entity.category = new category_entity_1.CategoryEntity(this.category);
32
- entity.active = this.active;
33
- entity.hashtags = this.hashtags;
34
- entity.availableFrom = new Date(this.availableFrom || null);
35
- return entity;
36
- }
37
- }
38
- __decorate([
39
- (0, class_validator_1.IsString)()
40
- ], CreateProductValidator.prototype, "name", void 0);
41
- __decorate([
42
- (0, class_validator_1.IsString)(),
43
- (0, class_validator_1.IsOptional)()
44
- ], CreateProductValidator.prototype, "description", void 0);
45
- __decorate([
46
- (0, class_validator_1.IsDateString)(),
47
- (0, class_validator_1.IsOptional)()
48
- ], CreateProductValidator.prototype, "availableFrom", void 0);
49
- __decorate([
50
- (0, class_validator_1.IsBoolean)(),
51
- (0, class_validator_1.IsOptional)()
52
- ], CreateProductValidator.prototype, "active", void 0);
53
- __decorate([
54
- (0, class_validator_1.IsOptional)(),
55
- (0, class_validator_1.IsUUID)()
56
- ], CreateProductValidator.prototype, "category", void 0);
57
- __decorate([
58
- (0, class_validator_1.IsOptional)(),
59
- (0, class_validator_1.IsUUID)()
60
- ], CreateProductValidator.prototype, "brand", void 0);
61
- __decorate([
62
- (0, class_validator_1.IsOptional)(),
63
- (0, class_validator_1.IsString)({ each: true })
64
- ], CreateProductValidator.prototype, "hashtags", void 0);
65
- __decorate([
66
- (0, class_validator_1.ValidateNested)({ each: true }),
67
- (0, class_transformer_1.Type)(() => variant_validator_1.CreateVariantValidator),
68
- (0, class_validator_1.IsOptional)()
69
- ], CreateProductValidator.prototype, "variants", void 0);
70
- exports.CreateProductValidator = CreateProductValidator;
71
- class UpdateProductValidator extends app_validator_1.AppValidator {
72
- name;
73
- description;
74
- category;
75
- brand;
76
- hashtags;
77
- active;
78
- toEntity(entity) {
79
- if (this.brand) {
80
- entity.brand = new brand_entity_1.BrandEntity(this.brand);
81
- }
82
- if (this.category) {
83
- entity.category = new category_entity_1.CategoryEntity(this.category);
84
- }
85
- if (this.description) {
86
- entity.description = this.description;
87
- }
88
- if (this.hashtags) {
89
- entity.hashtags = this.hashtags;
90
- }
91
- if (this.name) {
92
- entity.name = this.name;
93
- }
94
- if (this.active) {
95
- entity.active = this.active;
96
- }
97
- return entity;
98
- }
99
- }
100
- __decorate([
101
- (0, class_validator_1.IsString)(),
102
- (0, class_validator_1.IsOptional)()
103
- ], UpdateProductValidator.prototype, "name", void 0);
104
- __decorate([
105
- (0, class_validator_1.IsString)(),
106
- (0, class_validator_1.IsOptional)()
107
- ], UpdateProductValidator.prototype, "description", void 0);
108
- __decorate([
109
- (0, class_validator_1.IsOptional)(),
110
- (0, class_validator_1.IsPositive)()
111
- ], UpdateProductValidator.prototype, "category", void 0);
112
- __decorate([
113
- (0, class_validator_1.IsOptional)(),
114
- (0, class_validator_1.IsPositive)()
115
- ], UpdateProductValidator.prototype, "brand", void 0);
116
- __decorate([
117
- (0, class_validator_1.IsOptional)(),
118
- (0, class_validator_1.IsString)({ each: true })
119
- ], UpdateProductValidator.prototype, "hashtags", void 0);
120
- __decorate([
121
- (0, class_validator_1.IsBoolean)(),
122
- (0, class_validator_1.IsOptional)()
123
- ], UpdateProductValidator.prototype, "active", void 0);
124
- exports.UpdateProductValidator = UpdateProductValidator;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.VariantDocument = void 0;
10
- const es_mapping_ts_1 = require("es-mapping-ts");
11
- const app_document_1 = require("../../../config/app.document");
12
- let VariantDocument = class VariantDocument extends app_document_1.AppDocument {
13
- sku;
14
- quantity;
15
- price;
16
- active;
17
- transform(entity) {
18
- this.sku = entity.sku;
19
- this.quantity = entity.quantity;
20
- this.price = entity.price;
21
- this.active = entity.active;
22
- return this;
23
- }
24
- };
25
- __decorate([
26
- (0, es_mapping_ts_1.EsField)({ type: 'keyword' })
27
- ], VariantDocument.prototype, "sku", void 0);
28
- __decorate([
29
- (0, es_mapping_ts_1.EsField)({ type: 'float' })
30
- ], VariantDocument.prototype, "quantity", void 0);
31
- __decorate([
32
- (0, es_mapping_ts_1.EsField)({ type: 'integer' })
33
- ], VariantDocument.prototype, "price", void 0);
34
- __decorate([
35
- (0, es_mapping_ts_1.EsField)({ type: 'boolean' })
36
- ], VariantDocument.prototype, "active", void 0);
37
- VariantDocument = __decorate([
38
- (0, es_mapping_ts_1.EsEntity)({ mixins: [app_document_1.AppDocument] })
39
- ], VariantDocument);
40
- exports.VariantDocument = VariantDocument;
@@ -1,44 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.VariantEntity = void 0;
10
- const typeorm_1 = require("typeorm");
11
- const app_entity_1 = require("../../../config/app.entity");
12
- const product_entity_1 = require("../products/product.entity");
13
- let VariantEntity = class VariantEntity extends app_entity_1.AppEntity {
14
- sku;
15
- price = 0;
16
- quantity = 1;
17
- active = true;
18
- product;
19
- get isOutOfStock() {
20
- return this.quantity === 0;
21
- }
22
- get isDraft() {
23
- return this.active === true;
24
- }
25
- };
26
- __decorate([
27
- (0, typeorm_1.Column)({ length: 32, unique: true })
28
- ], VariantEntity.prototype, "sku", void 0);
29
- __decorate([
30
- (0, typeorm_1.Column)({ type: 'int', default: 0 })
31
- ], VariantEntity.prototype, "price", void 0);
32
- __decorate([
33
- (0, typeorm_1.Column)({ type: 'float', default: 1 })
34
- ], VariantEntity.prototype, "quantity", void 0);
35
- __decorate([
36
- (0, typeorm_1.Column)({ type: 'boolean', default: true })
37
- ], VariantEntity.prototype, "active", void 0);
38
- __decorate([
39
- (0, typeorm_1.ManyToOne)(() => product_entity_1.ProductEntity, ({ variants }) => variants)
40
- ], VariantEntity.prototype, "product", void 0);
41
- VariantEntity = __decorate([
42
- (0, typeorm_1.Entity)('inventory_variants')
43
- ], VariantEntity);
44
- exports.VariantEntity = VariantEntity;
@@ -1,83 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.UpdateVariantValidator = exports.CreateVariantValidator = void 0;
10
- const class_validator_1 = require("class-validator");
11
- const app_validator_1 = require("../../../config/app.validator");
12
- const variant_entity_1 = require("./variant.entity");
13
- class CreateVariantValidator extends app_validator_1.AppValidator {
14
- price = 0;
15
- sku;
16
- quantity = 1;
17
- active = true;
18
- toEntity(product) {
19
- const entity = new variant_entity_1.VariantEntity();
20
- entity.sku = this.sku;
21
- entity.price = this.price;
22
- entity.quantity = this.quantity;
23
- entity.active = this.active;
24
- if (product) {
25
- entity.product = product;
26
- }
27
- return entity;
28
- }
29
- }
30
- __decorate([
31
- (0, class_validator_1.IsNumber)(),
32
- (0, class_validator_1.Min)(0)
33
- ], CreateVariantValidator.prototype, "price", void 0);
34
- __decorate([
35
- (0, class_validator_1.Length)(1, 32)
36
- ], CreateVariantValidator.prototype, "sku", void 0);
37
- __decorate([
38
- (0, class_validator_1.IsPositive)(),
39
- (0, class_validator_1.IsOptional)()
40
- ], CreateVariantValidator.prototype, "quantity", void 0);
41
- __decorate([
42
- (0, class_validator_1.IsBoolean)(),
43
- (0, class_validator_1.IsOptional)()
44
- ], CreateVariantValidator.prototype, "active", void 0);
45
- exports.CreateVariantValidator = CreateVariantValidator;
46
- class UpdateVariantValidator extends app_validator_1.AppValidator {
47
- price = 0;
48
- sku;
49
- quantity = 1;
50
- active;
51
- toEntity(entity) {
52
- if (this.sku) {
53
- entity.sku = this.sku;
54
- }
55
- if (this.price) {
56
- entity.price = this.price;
57
- }
58
- if (this.quantity) {
59
- entity.quantity = this.quantity;
60
- }
61
- if (this.active) {
62
- entity.active = this.active;
63
- }
64
- return entity;
65
- }
66
- }
67
- __decorate([
68
- (0, class_validator_1.IsNumber)(),
69
- (0, class_validator_1.Min)(0),
70
- (0, class_validator_1.IsOptional)()
71
- ], UpdateVariantValidator.prototype, "price", void 0);
72
- __decorate([
73
- (0, class_validator_1.IsOptional)()
74
- ], UpdateVariantValidator.prototype, "sku", void 0);
75
- __decorate([
76
- (0, class_validator_1.IsPositive)(),
77
- (0, class_validator_1.IsOptional)()
78
- ], UpdateVariantValidator.prototype, "quantity", void 0);
79
- __decorate([
80
- (0, class_validator_1.IsBoolean)(),
81
- (0, class_validator_1.IsOptional)()
82
- ], UpdateVariantValidator.prototype, "active", void 0);
83
- exports.UpdateVariantValidator = UpdateVariantValidator;
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.OrderDocument = void 0;
10
- const es_mapping_ts_1 = require("es-mapping-ts");
11
- const app_document_1 = require("../../../config/app.document");
12
- let OrderDocument = class OrderDocument extends app_document_1.AppDocument {
13
- number;
14
- price;
15
- transform(entity) {
16
- this.number = entity.number;
17
- this.price = entity.price;
18
- return this;
19
- }
20
- };
21
- __decorate([
22
- (0, es_mapping_ts_1.EsField)({ type: 'text' })
23
- ], OrderDocument.prototype, "number", void 0);
24
- __decorate([
25
- (0, es_mapping_ts_1.EsField)({ type: 'integer' })
26
- ], OrderDocument.prototype, "price", void 0);
27
- OrderDocument = __decorate([
28
- (0, es_mapping_ts_1.EsEntity)({ mixins: [app_document_1.AppDocument] })
29
- ], OrderDocument);
30
- exports.OrderDocument = OrderDocument;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.OrderEntity = void 0;
10
- const typeorm_1 = require("typeorm");
11
- const app_entity_1 = require("../../../config/app.entity");
12
- let OrderEntity = class OrderEntity extends app_entity_1.AppEntity {
13
- number;
14
- price;
15
- };
16
- __decorate([
17
- (0, typeorm_1.Column)({ type: 'varchar', length: 16 })
18
- ], OrderEntity.prototype, "number", void 0);
19
- __decorate([
20
- (0, typeorm_1.Column)({ type: 'int' })
21
- ], OrderEntity.prototype, "price", void 0);
22
- OrderEntity = __decorate([
23
- (0, typeorm_1.Entity)('store_orders')
24
- ], OrderEntity);
25
- exports.OrderEntity = OrderEntity;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UpdateOrderValidator = exports.CreateOrderValidator = void 0;
4
- const app_validator_1 = require("../../../config/app.validator");
5
- const order_entity_1 = require("./order.entity");
6
- class CreateOrderValidator extends app_validator_1.AppValidator {
7
- toEntity() {
8
- return new order_entity_1.OrderEntity();
9
- }
10
- }
11
- exports.CreateOrderValidator = CreateOrderValidator;
12
- class UpdateOrderValidator extends app_validator_1.AppValidator {
13
- toEntity(entity) {
14
- return entity;
15
- }
16
- }
17
- exports.UpdateOrderValidator = UpdateOrderValidator;