@merkaly/api 0.2.4-7 → 0.2.4-9

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 (273) hide show
  1. package/.output/abstract/abstract.entity.d.ts +1 -1
  2. package/.output/abstract/abstract.exception.d.ts +11 -0
  3. package/.output/abstract/abstract.exception.js +53 -0
  4. package/.output/exceptions/missing-identity.exception.d.ts +5 -0
  5. package/.output/{modules/setting/organization/organization.entity.js → exceptions/missing-identity.exception.js} +12 -10
  6. package/.output/exceptions/store-not-implemented.exception.d.ts +5 -0
  7. package/.output/exceptions/store-not-implemented.exception.js +31 -0
  8. package/.output/exceptions/store-not-recognized.exception.d.ts +5 -0
  9. package/.output/exceptions/store-not-recognized.exception.js +30 -0
  10. package/.output/modules/inventory/brands/brand.exception.d.ts +5 -0
  11. package/.output/modules/{setting/theme/theme.entity.js → inventory/brands/brand.exception.js} +15 -21
  12. package/.output/modules/inventory/categories/category.exception.d.ts +5 -0
  13. package/.output/modules/{setting/layout/layout.entity.js → inventory/categories/category.exception.js} +15 -21
  14. package/.output/modules/inventory/products/product.entity.d.ts +1 -0
  15. package/.output/modules/inventory/products/product.exception.d.ts +5 -0
  16. package/.output/modules/inventory/products/{entities/price.entity.js → product.exception.js} +15 -24
  17. package/.output/modules/inventory/products/product.validator.d.ts +2 -1
  18. package/.output/modules/inventory/products/product.validator.js +7 -0
  19. package/.output/modules/inventory/properties/property.exception.d.ts +5 -0
  20. package/.output/modules/inventory/{brands/brand.entity.js → properties/property.exception.js} +15 -25
  21. package/.output/modules/sales/clients/client.exception.d.ts +5 -0
  22. package/.output/modules/sales/clients/client.exception.js +40 -0
  23. package/.output/modules/sales/orders/order.exception.d.ts +13 -0
  24. package/.output/modules/sales/orders/order.exception.js +46 -0
  25. package/.output/services/logger.service.d.ts +11 -0
  26. package/.output/services/logger.service.js +54 -0
  27. package/.output/types.d.ts +4 -1
  28. package/package.json +2 -3
  29. package/.DS_Store +0 -0
  30. package/.bin/deploy.sh +0 -9
  31. package/.bin/package.sh +0 -7
  32. package/.docker/Dockerfile +0 -21
  33. package/.dockerignore +0 -12
  34. package/.env +0 -21
  35. package/.eslintignore +0 -8
  36. package/.eslintrc.js +0 -35
  37. package/.github/dependabot.yml +0 -17
  38. package/.github/semantic.yml +0 -5
  39. package/.github/workflows/pull_request.yml +0 -35
  40. package/.gitignore +0 -42
  41. package/.husky/.gitignore +0 -1
  42. package/.husky/commit-msg +0 -5
  43. package/.husky/common.sh +0 -8
  44. package/.husky/pre-commit +0 -5
  45. package/.husky/pre-push +0 -4
  46. package/.idea/.gitignore +0 -5
  47. package/.idea/api.iml +0 -13
  48. package/.idea/codeStyles/codeStyleConfig.xml +0 -5
  49. package/.idea/inspectionProfiles/Project_Default.xml +0 -11
  50. package/.idea/modules.xml +0 -8
  51. package/.idea/vcs.xml +0 -12
  52. package/.idea/workspace.xml +0 -2320
  53. package/.output/abstract/abstract.entity.js +0 -53
  54. package/.output/modules/assets/asset.entity.js +0 -69
  55. package/.output/modules/content/banners/banner.entity.js +0 -54
  56. package/.output/modules/content/pages/page.entity.js +0 -69
  57. package/.output/modules/inventory/categories/category.entity.js +0 -61
  58. package/.output/modules/inventory/products/entities/code.entity.js +0 -53
  59. package/.output/modules/inventory/products/entities/dimension.entity.js +0 -57
  60. package/.output/modules/inventory/products/entities/seo.entity.js +0 -53
  61. package/.output/modules/inventory/products/product.entity.js +0 -101
  62. package/.output/modules/inventory/properties/property.entity.js +0 -55
  63. package/.output/modules/sales/clients/client.entity.js +0 -64
  64. package/.output/modules/sales/orders/billing/billing.entity.js +0 -64
  65. package/.output/modules/sales/orders/billing/entities/address.entity.js +0 -68
  66. package/.output/modules/sales/orders/billing/entities/customer.entity.js +0 -52
  67. package/.output/modules/sales/orders/billing/entities/status.entity.js +0 -37
  68. package/.output/modules/sales/orders/customer/customer.entity.js +0 -52
  69. package/.output/modules/sales/orders/item/item.entity.js +0 -58
  70. package/.output/modules/sales/orders/order.entity.js +0 -89
  71. package/.output/modules/sales/orders/shipping/entities/address.entity.js +0 -68
  72. package/.output/modules/sales/orders/shipping/entities/customer.entity.js +0 -52
  73. package/.output/modules/sales/orders/shipping/entities/status.entity.js +0 -37
  74. package/.output/modules/sales/orders/shipping/shipping.entity.js +0 -68
  75. package/.output/modules/sales/orders/status/status.entity.js +0 -37
  76. package/authCertificate.pem +0 -19
  77. package/cloudbuild.yaml +0 -20
  78. package/commitlint.config.js +0 -3
  79. package/jest.config.js +0 -14
  80. package/merkaly-api-0.2.4-6.tgz +0 -0
  81. package/nest-cli.json +0 -9
  82. package/serviceAccount.json +0 -7
  83. package/src/abstract/absctract.listener.ts +0 -2
  84. package/src/abstract/abstract.controller.ts +0 -27
  85. package/src/abstract/abstract.entity.ts +0 -19
  86. package/src/abstract/abstract.exception.ts +0 -56
  87. package/src/abstract/abstract.fixture.ts +0 -7
  88. package/src/abstract/abstract.migration.ts +0 -13
  89. package/src/abstract/abstract.repository.ts +0 -79
  90. package/src/abstract/abstract.router.ts +0 -7
  91. package/src/abstract/abstract.validator.ts +0 -62
  92. package/src/app.config.ts +0 -57
  93. package/src/app.console.ts +0 -30
  94. package/src/app.controller.ts +0 -48
  95. package/src/app.migration.ts +0 -7
  96. package/src/app.module.ts +0 -92
  97. package/src/app.strategy.ts +0 -25
  98. package/src/commands/assets.command.ts +0 -38
  99. package/src/commands/deploy.command.ts +0 -6
  100. package/src/commands/fixture.command.ts +0 -11
  101. package/src/commands/generate.command.ts +0 -286
  102. package/src/decorators/public.decorator.ts +0 -5
  103. package/src/decorators/user.decorator.ts +0 -21
  104. package/src/exceptions/missing-identity.exception.ts +0 -11
  105. package/src/exceptions/store-not-implemented.exception.ts +0 -13
  106. package/src/exceptions/store-not-recognized.exception.ts +0 -11
  107. package/src/guards/auth.guard.ts +0 -43
  108. package/src/guards/organization.guard.ts +0 -39
  109. package/src/interceptors/mongo.interceptor.ts +0 -16
  110. package/src/main.ts +0 -37
  111. package/src/middlewares/logger.middleware.ts +0 -15
  112. package/src/middlewares/organization.middleware.ts +0 -76
  113. package/src/migrations/1667226478717-product_price_enhance.ts +0 -29
  114. package/src/migrations/1667329249561-product_add_seo_code_dimension.ts +0 -37
  115. package/src/migrations/1667601099139-product_activve_and_hashtag.ts +0 -35
  116. package/src/migrations/1668136428972-content_banners-use-as-image.ts +0 -56
  117. package/src/migrations/1680483744321-order-billing-shipping-status.ts +0 -32
  118. package/src/modules/assets/asset.controller.ts +0 -33
  119. package/src/modules/assets/asset.entity.ts +0 -26
  120. package/src/modules/assets/asset.module.ts +0 -21
  121. package/src/modules/assets/asset.repository.ts +0 -51
  122. package/src/modules/assets/asset.schema.ts +0 -4
  123. package/src/modules/assets/asset.service.ts +0 -41
  124. package/src/modules/auth/auth.controller.ts +0 -42
  125. package/src/modules/auth/auth.module.ts +0 -18
  126. package/src/modules/auth/logout.ts +0 -0
  127. package/src/modules/command.module.ts +0 -19
  128. package/src/modules/content/banners/banner.controller.ts +0 -56
  129. package/src/modules/content/banners/banner.entity.ts +0 -17
  130. package/src/modules/content/banners/banner.fixture.ts +0 -19
  131. package/src/modules/content/banners/banner.listener.ts +0 -6
  132. package/src/modules/content/banners/banner.module.ts +0 -21
  133. package/src/modules/content/banners/banner.repository.ts +0 -38
  134. package/src/modules/content/banners/banner.schema.ts +0 -4
  135. package/src/modules/content/banners/banner.types.ts +0 -7
  136. package/src/modules/content/banners/banner.validator.ts +0 -19
  137. package/src/modules/content/content.module.ts +0 -20
  138. package/src/modules/content/pages/page.controller.ts +0 -53
  139. package/src/modules/content/pages/page.entity.ts +0 -27
  140. package/src/modules/content/pages/page.fixture.ts +0 -19
  141. package/src/modules/content/pages/page.listener.ts +0 -6
  142. package/src/modules/content/pages/page.module.ts +0 -21
  143. package/src/modules/content/pages/page.repository.ts +0 -44
  144. package/src/modules/content/pages/page.schema.ts +0 -4
  145. package/src/modules/content/pages/page.types.ts +0 -9
  146. package/src/modules/content/pages/page.validator.ts +0 -29
  147. package/src/modules/global.module.ts +0 -70
  148. package/src/modules/insight/controllers/address.controller.ts +0 -29
  149. package/src/modules/insight/controllers/order.controller.ts +0 -70
  150. package/src/modules/insight/controllers/products.controller.ts +0 -18
  151. package/src/modules/insight/insight.module.ts +0 -24
  152. package/src/modules/insight/validators/order.validator.ts +0 -10
  153. package/src/modules/inventory/brands/brand.controller.ts +0 -59
  154. package/src/modules/inventory/brands/brand.entity.ts +0 -14
  155. package/src/modules/inventory/brands/brand.exception.ts +0 -9
  156. package/src/modules/inventory/brands/brand.listener.ts +0 -18
  157. package/src/modules/inventory/brands/brand.module.ts +0 -19
  158. package/src/modules/inventory/brands/brand.repository.ts +0 -39
  159. package/src/modules/inventory/brands/brand.schema.ts +0 -4
  160. package/src/modules/inventory/brands/brand.validator.ts +0 -23
  161. package/src/modules/inventory/categories/category.controller.ts +0 -59
  162. package/src/modules/inventory/categories/category.entity.ts +0 -21
  163. package/src/modules/inventory/categories/category.exception.ts +0 -9
  164. package/src/modules/inventory/categories/category.fixture.ts +0 -18
  165. package/src/modules/inventory/categories/category.listener.ts +0 -17
  166. package/src/modules/inventory/categories/category.module.ts +0 -19
  167. package/src/modules/inventory/categories/category.repository.ts +0 -40
  168. package/src/modules/inventory/categories/category.schema.ts +0 -4
  169. package/src/modules/inventory/categories/category.validator.ts +0 -30
  170. package/src/modules/inventory/inventory.module.ts +0 -22
  171. package/src/modules/inventory/products/entities/code.entity.ts +0 -15
  172. package/src/modules/inventory/products/entities/dimension.entity.ts +0 -18
  173. package/src/modules/inventory/products/entities/price.entity.ts +0 -12
  174. package/src/modules/inventory/products/entities/seo.entity.ts +0 -15
  175. package/src/modules/inventory/products/product.controller.ts +0 -59
  176. package/src/modules/inventory/products/product.entity.ts +0 -53
  177. package/src/modules/inventory/products/product.exception.ts +0 -9
  178. package/src/modules/inventory/products/product.fixture.ts +0 -19
  179. package/src/modules/inventory/products/product.listener.ts +0 -27
  180. package/src/modules/inventory/products/product.module.ts +0 -20
  181. package/src/modules/inventory/products/product.repository.ts +0 -108
  182. package/src/modules/inventory/products/product.schema.ts +0 -15
  183. package/src/modules/inventory/products/product.validator.ts +0 -71
  184. package/src/modules/inventory/products/validators/code.validator.ts +0 -15
  185. package/src/modules/inventory/products/validators/dimension.validator.ts +0 -19
  186. package/src/modules/inventory/products/validators/price.validator.ts +0 -10
  187. package/src/modules/inventory/products/validators/seo.validator.ts +0 -15
  188. package/src/modules/inventory/properties/property.controller.ts +0 -56
  189. package/src/modules/inventory/properties/property.entity.ts +0 -18
  190. package/src/modules/inventory/properties/property.exception.ts +0 -9
  191. package/src/modules/inventory/properties/property.listener.ts +0 -20
  192. package/src/modules/inventory/properties/property.module.ts +0 -21
  193. package/src/modules/inventory/properties/property.repository.ts +0 -23
  194. package/src/modules/inventory/properties/property.schema.ts +0 -4
  195. package/src/modules/inventory/properties/property.validator.ts +0 -27
  196. package/src/modules/sales/clients/client.controller.ts +0 -60
  197. package/src/modules/sales/clients/client.entity.ts +0 -25
  198. package/src/modules/sales/clients/client.exception.ts +0 -9
  199. package/src/modules/sales/clients/client.listener.ts +0 -20
  200. package/src/modules/sales/clients/client.module.ts +0 -19
  201. package/src/modules/sales/clients/client.repository.ts +0 -37
  202. package/src/modules/sales/clients/client.schema.ts +0 -4
  203. package/src/modules/sales/clients/client.validator.ts +0 -43
  204. package/src/modules/sales/orders/billing/billing.entity.ts +0 -22
  205. package/src/modules/sales/orders/billing/billing.types.ts +0 -10
  206. package/src/modules/sales/orders/billing/billing.validator.ts +0 -21
  207. package/src/modules/sales/orders/billing/entities/address.entity.ts +0 -27
  208. package/src/modules/sales/orders/billing/entities/customer.entity.ts +0 -14
  209. package/src/modules/sales/orders/billing/entities/status.entity.ts +0 -16
  210. package/src/modules/sales/orders/billing/validators/address.validator.ts +0 -28
  211. package/src/modules/sales/orders/billing/validators/customer.validator.ts +0 -14
  212. package/src/modules/sales/orders/customer/customer.entity.ts +0 -14
  213. package/src/modules/sales/orders/customer/customer.validator.ts +0 -14
  214. package/src/modules/sales/orders/item/item.entity.ts +0 -21
  215. package/src/modules/sales/orders/item/item.schema.ts +0 -8
  216. package/src/modules/sales/orders/item/item.validator.ts +0 -10
  217. package/src/modules/sales/orders/order.controller.ts +0 -93
  218. package/src/modules/sales/orders/order.entity.ts +0 -47
  219. package/src/modules/sales/orders/order.listener.ts +0 -20
  220. package/src/modules/sales/orders/order.module.ts +0 -19
  221. package/src/modules/sales/orders/order.repository.ts +0 -189
  222. package/src/modules/sales/orders/order.schema.ts +0 -35
  223. package/src/modules/sales/orders/order.validator.ts +0 -72
  224. package/src/modules/sales/orders/shipping/entities/address.entity.ts +0 -27
  225. package/src/modules/sales/orders/shipping/entities/customer.entity.ts +0 -14
  226. package/src/modules/sales/orders/shipping/entities/status.entity.ts +0 -16
  227. package/src/modules/sales/orders/shipping/shipping.entity.ts +0 -25
  228. package/src/modules/sales/orders/shipping/shipping.types.ts +0 -12
  229. package/src/modules/sales/orders/shipping/shipping.validator.ts +0 -25
  230. package/src/modules/sales/orders/shipping/validators/address.validator.ts +0 -28
  231. package/src/modules/sales/orders/shipping/validators/customer.validator.ts +0 -14
  232. package/src/modules/sales/orders/status/status.entity.ts +0 -16
  233. package/src/modules/sales/orders/status/status.validator.ts +0 -8
  234. package/src/modules/sales/sales.module.ts +0 -20
  235. package/src/modules/setting/connections/connection.controller.ts +0 -27
  236. package/src/modules/setting/connections/connection.module.ts +0 -17
  237. package/src/modules/setting/connections/connection.validator.ts +0 -15
  238. package/src/modules/setting/layout/layout.controller.ts +0 -34
  239. package/src/modules/setting/layout/layout.entity.ts +0 -13
  240. package/src/modules/setting/layout/layout.listener.ts +0 -7
  241. package/src/modules/setting/layout/layout.module.ts +0 -21
  242. package/src/modules/setting/layout/layout.repository.ts +0 -29
  243. package/src/modules/setting/layout/layout.schema.ts +0 -4
  244. package/src/modules/setting/members/member.controller.ts +0 -22
  245. package/src/modules/setting/members/member.module.ts +0 -17
  246. package/src/modules/setting/members/member.validator.ts +0 -3
  247. package/src/modules/setting/organization/organization.controller.ts +0 -33
  248. package/src/modules/setting/organization/organization.entity.ts +0 -27
  249. package/src/modules/setting/organization/organization.listener.ts +0 -46
  250. package/src/modules/setting/organization/organization.module.ts +0 -21
  251. package/src/modules/setting/organization/organization.repository.ts +0 -55
  252. package/src/modules/setting/organization/organization.types.ts +0 -65
  253. package/src/modules/setting/organization/organization.validator.ts +0 -56
  254. package/src/modules/setting/setting.module.ts +0 -23
  255. package/src/modules/setting/theme/theme.controller.ts +0 -34
  256. package/src/modules/setting/theme/theme.entity.ts +0 -13
  257. package/src/modules/setting/theme/theme.listener.ts +0 -6
  258. package/src/modules/setting/theme/theme.module.ts +0 -21
  259. package/src/modules/setting/theme/theme.repository.ts +0 -23
  260. package/src/modules/setting/theme/theme.schema.ts +0 -4
  261. package/src/modules/users/user.controller.ts +0 -75
  262. package/src/modules/users/user.module.ts +0 -20
  263. package/src/modules/users/user.validator.ts +0 -28
  264. package/src/providers/auth0.provider.ts +0 -36
  265. package/src/providers/storage.provider.ts +0 -22
  266. package/src/services/auth0.service.ts +0 -7
  267. package/src/services/logger.service.ts +0 -33
  268. package/src/services/mongo.service.ts +0 -44
  269. package/src/services/storage.service.ts +0 -39
  270. package/src/types.ts +0 -19
  271. package/tsconfig.json +0 -40
  272. package/tsconfig.package.json +0 -20
  273. package/yarn.lock +0 -8782
@@ -1,108 +0,0 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { InjectModel } from '@nestjs/mongoose';
3
- import { Model, Types } from 'mongoose';
4
- import { AbstractRepository } from '../../../abstract/abstract.repository';
5
- import { AssetEntity } from '../../assets/asset.entity';
6
- import { BrandEntity } from '../brands/brand.entity';
7
- import { CategoryEntity } from '../categories/category.entity';
8
- import { ProductEntity } from './product.entity';
9
- import { ProductEvent } from './product.listener';
10
- import { CreateProductValidator, UpdateProductValidator } from './product.validator';
11
- import { FindValidator } from "../../../abstract/abstract.validator";
12
-
13
- @Injectable()
14
- export class ProductRepository extends AbstractRepository<ProductEntity> {
15
- @InjectModel(ProductEntity.$index)
16
- public readonly $model: Model<ProductEntity>;
17
-
18
- @InjectModel(AssetEntity.$index)
19
- public readonly $asset: Model<AssetEntity>;
20
-
21
- @InjectModel(BrandEntity.$index)
22
- public readonly $brand: Model<BrandEntity>;
23
-
24
- @InjectModel(CategoryEntity.$index)
25
- public readonly $category: Model<CategoryEntity>;
26
-
27
- public async create(validator: CreateProductValidator) {
28
- const product: ProductEntity = new this.$model();
29
-
30
- product.name = validator.name;
31
- product.measurement = validator.measurement;
32
- product.description = validator.description;
33
- product.hashtags = validator.hashtags;
34
- product.active = validator.active;
35
- product.files = validator.files.map<AssetEntity>(file => new Types.ObjectId(file) as any);
36
-
37
- product.brand = (validator.brand ? new Types.ObjectId(validator.brand) : product.brand) as any;
38
- product.category = (validator.category ? new Types.ObjectId(validator.category) : product.category) as any;
39
-
40
- product.price.set('sale', validator.price.sale);
41
- product.price.set('purchase', validator.price.purchase);
42
-
43
- product.seo.set('slug', validator.seo.slug);
44
- product.seo.set('title', validator.seo.title);
45
- product.seo.set('description', validator.seo.description);
46
-
47
- product.code.set('gtin', validator.code.gtin);
48
- product.code.set('sku', validator.code.sku);
49
- product.code.set('mpn', validator.code.mpn);
50
-
51
- product.dimension.set('depth', validator.dimension.depth);
52
- product.dimension.set('height', validator.dimension.height);
53
- product.dimension.set('weight', validator.dimension.weight);
54
- product.dimension.set('width', validator.dimension.width);
55
-
56
- await this.$model.create(product);
57
-
58
- await this.$event.emitAsync(ProductEvent.LINK_FILES, product);
59
-
60
- return product;
61
- }
62
-
63
- public async read(id: string, params: FindValidator<ProductEntity>): Promise<ProductEntity> {
64
- return this.$model
65
- .findOne({ [Types.ObjectId.isValid(id) ? '_id' : 'seo.slug']: id })
66
- .populate(params.join)
67
- }
68
-
69
- public async update(id: string, validator: UpdateProductValidator) {
70
- const product: ProductEntity = await this.$model.findById(id);
71
-
72
- product.name = validator.name || product.name;
73
- product.measurement = validator.measurement || product.measurement;
74
- product.description = validator.description || product.description;
75
- product.hashtags = validator.hashtags ?? product.hashtags;
76
- product.active = validator.active ?? product.active;
77
- product.files = validator.files.map<AssetEntity>(file => new Types.ObjectId(file) as any);
78
-
79
- product.brand = (validator.brand ? new Types.ObjectId(validator.brand) : product.brand) as any;
80
- product.category = (validator.category ? new Types.ObjectId(validator.category) : product.category) as any;
81
-
82
- product.price.set('sale', validator.price.sale || product.price.get('sale'));
83
- product.price.set('purchase', validator.price.purchase || product.price.get('purchase'));
84
-
85
- product.seo.set('slug', validator.seo.slug ?? product.seo.slug);
86
- product.seo.set('title', validator.seo.title ?? product.seo.title);
87
- product.seo.set('description', validator.seo.description ?? product.seo.description);
88
-
89
- product.code.set('gtin', validator.code.gtin ?? product.code.gtin);
90
- product.code.set('sku', validator.code.sku ?? product.code.sku);
91
- product.code.set('mpn', validator.code.mpn ?? product.code.mpn);
92
-
93
- product.dimension.set('depth', validator.dimension.depth ?? product.dimension.depth);
94
- product.dimension.set('height', validator.dimension.height ?? product.dimension.height);
95
- product.dimension.set('weight', validator.dimension.weight ?? product.dimension.weight);
96
- product.dimension.set('width', validator.dimension.width ?? product.dimension.width);
97
-
98
- await this.$event.emitAsync(ProductEvent.LINK_FILES, product);
99
-
100
- await product.save();
101
-
102
- return product;
103
- }
104
-
105
- public async delete(id: string) {
106
- return this.$delete(id);
107
- }
108
- }
@@ -1,15 +0,0 @@
1
- import { SchemaFactory } from '@nestjs/mongoose';
2
- import { ProductEntity } from './product.entity';
3
-
4
- export const ProductSchema = SchemaFactory.createForClass(ProductEntity);
5
-
6
- ProductSchema.virtual('picture').get<ProductEntity>(function () {
7
- const [first] = this.files
8
-
9
- return first?.url;
10
- });
11
-
12
- ProductSchema.index({
13
- name: 'text',
14
- description: 'text',
15
- })
@@ -1,71 +0,0 @@
1
- import { Type } from 'class-transformer';
2
- import {
3
- IsBoolean,
4
- IsMongoId,
5
- IsNotEmpty,
6
- IsNotEmptyObject,
7
- IsOptional,
8
- IsString,
9
- ValidateNested
10
- } from 'class-validator';
11
- import 'reflect-metadata';
12
- import { ProductCodeValidator } from './validators/code.validator';
13
- import { ProductDimensionValidator } from './validators/dimension.validator';
14
- import { ProductPriceValidator } from './validators/price.validator';
15
- import { ProductSeoValidator } from './validators/seo.validator';
16
- import { AbstractValidator } from "../../../abstract/abstract.validator";
17
-
18
- export class CreateProductValidator extends AbstractValidator {
19
- @IsString()
20
- @IsNotEmpty()
21
- public name = String();
22
-
23
- @IsString()
24
- @IsOptional()
25
- public description = String();
26
-
27
- @IsString()
28
- public measurement = String();
29
-
30
- @IsBoolean()
31
- @IsOptional()
32
- public active = Boolean(1);
33
-
34
- @IsOptional()
35
- @IsMongoId()
36
- public category?: string = null;
37
-
38
- @IsOptional()
39
- @IsMongoId()
40
- public brand?: string = null;
41
-
42
- @IsMongoId({ each: true })
43
- @IsOptional()
44
- public files: string[] = [];
45
-
46
- @IsString({ each: true })
47
- public hashtags: string[] = [];
48
-
49
- @ValidateNested()
50
- @IsNotEmptyObject()
51
- @Type(() => ProductPriceValidator)
52
- public price = new ProductPriceValidator();
53
-
54
- @ValidateNested()
55
- @Type(() => ProductSeoValidator)
56
- public seo = new ProductSeoValidator();
57
-
58
- @ValidateNested()
59
- @Type(() => ProductDimensionValidator)
60
- public dimension = new ProductDimensionValidator();
61
-
62
- @ValidateNested()
63
- @Type(() => ProductCodeValidator)
64
- public code = new ProductCodeValidator();
65
- }
66
-
67
- export class UpdateProductValidator extends CreateProductValidator {
68
- @IsString()
69
- @IsOptional()
70
- public name: string;
71
- }
@@ -1,15 +0,0 @@
1
- import { IsOptional, IsString } from 'class-validator';
2
-
3
- export class ProductCodeValidator {
4
- @IsString()
5
- @IsOptional()
6
- public sku? = String();
7
-
8
- @IsString()
9
- @IsOptional()
10
- public gtin? = String();
11
-
12
- @IsString()
13
- @IsOptional()
14
- public mpn? = String();
15
- }
@@ -1,19 +0,0 @@
1
- import { IsNumber, IsOptional } from 'class-validator';
2
-
3
- export class ProductDimensionValidator {
4
- @IsNumber()
5
- @IsOptional()
6
- public weight? = 0;
7
-
8
- @IsNumber()
9
- @IsOptional()
10
- public height? = 0;
11
-
12
- @IsNumber()
13
- @IsOptional()
14
- public width? = 0;
15
-
16
- @IsNumber()
17
- @IsOptional()
18
- public depth? = 0;
19
- }
@@ -1,10 +0,0 @@
1
- import { IsNumber, IsOptional } from 'class-validator';
2
-
3
- export class ProductPriceValidator {
4
- @IsNumber()
5
- public sale = 0;
6
-
7
- @IsNumber()
8
- @IsOptional()
9
- public purchase? = 0;
10
- }
@@ -1,15 +0,0 @@
1
- import { IsOptional, IsString } from 'class-validator';
2
-
3
- export class ProductSeoValidator {
4
- @IsString()
5
- @IsOptional()
6
- public title? = String();
7
-
8
- @IsString()
9
- @IsOptional()
10
- public slug? = String();
11
-
12
- @IsString()
13
- @IsOptional()
14
- public description? = String();
15
- }
@@ -1,56 +0,0 @@
1
- import {
2
- Body,
3
- Controller,
4
- Delete,
5
- Get,
6
- HttpCode,
7
- HttpStatus,
8
- Inject,
9
- Param,
10
- Patch,
11
- Post,
12
- Query,
13
- UseFilters,
14
- } from '@nestjs/common';
15
- import { ApiTags } from '@nestjs/swagger';
16
- import { AbstractController } from '../../../abstract/abstract.controller';
17
- import { FindValidator } from '../../../abstract/abstract.validator';
18
- import { PropertyEntity } from './property.entity';
19
- import { PropertyException } from './property.exception';
20
- import { PropertyRepository } from './property.repository';
21
- import { CreatePropertyValidator, UpdatePropertyValidator } from './property.validator';
22
-
23
- @Controller()
24
- @UseFilters(PropertyException)
25
- @ApiTags('inventory')
26
- export class PropertyController extends AbstractController<PropertyEntity> {
27
- @Inject()
28
- protected readonly $repository: PropertyRepository;
29
-
30
- @Get('/')
31
- public async find(@Query() validator: FindValidator<PropertyEntity>) {
32
- return super.find(validator);
33
- }
34
-
35
- @Post('/')
36
- @HttpCode(HttpStatus.CREATED)
37
- public async create(@Body() validator: CreatePropertyValidator) {
38
- return super.create(validator);
39
- }
40
-
41
- @Get('/:id')
42
- public async read(@Param('id') id: string) {
43
- return super.read(id);
44
- }
45
-
46
- @Patch('/:id')
47
- public async update(@Param('id') id: string, @Body() validator: UpdatePropertyValidator) {
48
- return super.update(id, validator);
49
- }
50
-
51
- @Delete('/:id')
52
- @HttpCode(HttpStatus.NO_CONTENT)
53
- public async delete(@Param('id') id: string) {
54
- return super.delete(id);
55
- }
56
- }
@@ -1,18 +0,0 @@
1
- import { Prop, Schema } from '@nestjs/mongoose';
2
- import { Schema as MongoSchema } from 'mongoose';
3
- import { AbstractEntity } from '../../../abstract/abstract.entity';
4
- import { PropertyType } from './property.validator';
5
-
6
- @Schema({ timestamps: true })
7
- export class PropertyEntity extends AbstractEntity {
8
- public static readonly $index = 'inventory_properties';
9
-
10
- @Prop({ type: MongoSchema.Types.String, required: true, unique: true, length: 32 })
11
- public name: string;
12
-
13
- @Prop({ type: MongoSchema.Types.String, required: true, length: 64 })
14
- public title: string;
15
-
16
- @Prop({ type: MongoSchema.Types.String, default: PropertyType.STRING })
17
- public type: string;
18
- }
@@ -1,9 +0,0 @@
1
- import { Catch, HttpException } from '@nestjs/common';
2
- import { AbstractException } from '../../../abstract/abstract.exception';
3
-
4
- @Catch()
5
- export class PropertyException extends AbstractException {
6
- public handleError(exception: HttpException) {
7
- return exception;
8
- }
9
- }
@@ -1,20 +0,0 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { AbsctractListener } from '../../../abstract/absctract.listener';
3
-
4
- export enum PropertyEvent {
5
- ALL_EVENTS = 'database.inventory.property.**',
6
-
7
- PRE_CREATE = 'database.inventory.property.create.pre',
8
- POST_CREATE = 'database.inventory.property.create.post',
9
-
10
- PRE_UPDATE = 'database.inventory.property.update.pre',
11
- POST_UPDATE = 'database.inventory.property.update.post',
12
-
13
- PRE_DELETE = 'database.inventory.property.delete.pre',
14
- POST_DELETE = 'database.inventory.property.delete.post',
15
- }
16
-
17
- @Injectable()
18
- export class PropertyListener extends AbsctractListener {
19
-
20
- }
@@ -1,21 +0,0 @@
1
- import { Module, ModuleMetadata } from '@nestjs/common';
2
- import { AbstractRouter } from '../../../abstract/abstract.router';
3
- import { PropertyController } from './property.controller';
4
- import { PropertyListener } from './property.listener';
5
- import { PropertyRepository } from './property.repository';
6
-
7
- export const metadata: ModuleMetadata = {
8
- imports: [],
9
- controllers: [PropertyController],
10
- providers: [PropertyRepository, PropertyListener],
11
- exports: [PropertyRepository],
12
- };
13
-
14
- @Module(metadata)
15
- export class PropertyModule extends AbstractRouter {
16
- public static readonly path = '/properties';
17
-
18
- public static readonly module = PropertyModule;
19
-
20
- public static readonly children = metadata.imports;
21
- }
@@ -1,23 +0,0 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { InjectModel } from '@nestjs/mongoose';
3
- import { Model } from 'mongoose';
4
- import { AbstractRepository } from '../../../abstract/abstract.repository';
5
- import { PropertyEntity } from './property.entity';
6
-
7
- @Injectable()
8
- export class PropertyRepository extends AbstractRepository<PropertyEntity> {
9
- @InjectModel(PropertyEntity.$index)
10
- public readonly $model: Model<PropertyEntity>;
11
-
12
- public create(params: any): Promise<PropertyEntity> {
13
- return Promise.resolve(undefined);
14
- }
15
-
16
- public delete(id: string): Promise<void> {
17
- return Promise.resolve(undefined);
18
- }
19
-
20
- public update(id: string, params: unknown): Promise<PropertyEntity> {
21
- return Promise.resolve(undefined);
22
- }
23
- }
@@ -1,4 +0,0 @@
1
- import { SchemaFactory } from '@nestjs/mongoose';
2
- import { PropertyEntity } from './property.entity';
3
-
4
- export const PropertySchema = SchemaFactory.createForClass(PropertyEntity);
@@ -1,27 +0,0 @@
1
- import { IsOptional, IsString } from 'class-validator';
2
- import { AbstractValidator } from "../../../abstract/abstract.validator";
3
-
4
- export enum PropertyType {
5
- STRING = 'STRING',
6
- }
7
-
8
- export class CreatePropertyValidator extends AbstractValidator {
9
- @IsString()
10
- public name: string;
11
-
12
- @IsString()
13
- public title: string;
14
-
15
- @IsString()
16
- public type: string;
17
- }
18
-
19
- export class UpdatePropertyValidator extends AbstractValidator {
20
- @IsString()
21
- @IsOptional()
22
- public name?: string;
23
-
24
- @IsString()
25
- @IsOptional()
26
- public title?: string;
27
- }
@@ -1,60 +0,0 @@
1
- import {
2
- Body,
3
- Controller,
4
- Delete,
5
- Get,
6
- HttpCode,
7
- HttpStatus,
8
- Inject,
9
- Param,
10
- Patch,
11
- Post,
12
- Query,
13
- UseFilters,
14
- } from '@nestjs/common';
15
- import { ApiTags } from '@nestjs/swagger';
16
- import { AbstractController } from '../../../abstract/abstract.controller';
17
- import { FindValidator } from '../../../abstract/abstract.validator';
18
- import { Auth0Service } from '../../../services/auth0.service';
19
- import { ClientEntity } from './client.entity';
20
- import { ClientException } from './client.exception';
21
- import { ClientRepository } from './client.repository';
22
- import { CreateClientValidator, UpdateClientValidator } from './client.validator';
23
-
24
- @Controller()
25
- @UseFilters(ClientException)
26
- @ApiTags('orders')
27
- export class ClientController extends AbstractController<ClientEntity> {
28
- @Inject()
29
- protected readonly $repository: ClientRepository;
30
-
31
- @Inject()
32
- protected readonly $auth0: Auth0Service;
33
-
34
- @Get('/')
35
- public async find(@Query() validator: FindValidator<ClientEntity>) {
36
- return this.$repository.find(validator);
37
- }
38
-
39
- @Get('/:id')
40
- public async read(@Param('id') id: string) {
41
- return this.$repository.read(id);
42
- }
43
-
44
- @Post('/')
45
- @HttpCode(HttpStatus.CREATED)
46
- public async create(@Body() validator: CreateClientValidator) {
47
- return this.$repository.create(validator);
48
- }
49
-
50
- @Patch('/:id')
51
- public async update(@Param('id') id: string, @Body() validator: UpdateClientValidator) {
52
- return this.$repository.update(id, validator);
53
- }
54
-
55
- @Delete('/:id')
56
- @HttpCode(HttpStatus.NO_CONTENT)
57
- public async delete(@Param('id') id: string) {
58
- return this.$repository.delete(id);
59
- }
60
- }
@@ -1,25 +0,0 @@
1
- import { Prop, Schema as Collection } from '@nestjs/mongoose';
2
- import { User } from 'auth0';
3
- import { Schema } from 'mongoose';
4
- import { AbstractEntity } from '../../../abstract/abstract.entity';
5
- import { MetaAddress } from "../../../types";
6
-
7
- @Collection({ timestamps: true })
8
- export class ClientEntity extends AbstractEntity implements User {
9
- public static readonly $index = 'store_clients';
10
-
11
- @Prop({ type: Schema.Types.String, required: true })
12
- public readonly name: string;
13
-
14
- @Prop({ type: Schema.Types.String, unique: true, required: true })
15
- public readonly email: string;
16
-
17
- @Prop({ type: Schema.Types.String, default: null })
18
- public readonly phone?: string;
19
-
20
- @Prop({ type: Schema.Types.String, unique: true })
21
- public readonly identificationNumber: string;
22
-
23
- @Prop({ type: Schema.Types.Array, default: [] })
24
- public readonly addresses: MetaAddress[] = [];
25
- }
@@ -1,9 +0,0 @@
1
- import { Catch, HttpException } from '@nestjs/common';
2
- import { AbstractException } from '../../../abstract/abstract.exception';
3
-
4
- @Catch()
5
- export class ClientException extends AbstractException {
6
- public handleError(exception: HttpException) {
7
- return exception;
8
- }
9
- }
@@ -1,20 +0,0 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { AbsctractListener } from '../../../abstract/absctract.listener';
3
-
4
- export enum ClientEvent {
5
- ALL_EVENTS = 'database.store.client.**',
6
-
7
- PRE_CREATE = 'database.store.client.create.pre',
8
- POST_CREATE = 'database.store.client.create.post',
9
-
10
- PRE_UPDATE = 'database.store.client.update.pre',
11
- POST_UPDATE = 'database.store.client.update.post',
12
-
13
- PRE_DELETE = 'database.store.client.delete.pre',
14
- POST_DELETE = 'database.store.client.delete.post',
15
- }
16
-
17
- @Injectable()
18
- export class ClientListener extends AbsctractListener {
19
-
20
- }
@@ -1,19 +0,0 @@
1
- import { Module, ModuleMetadata } from '@nestjs/common';
2
- import { AbstractRouter } from '../../../abstract/abstract.router';
3
- import { ClientController } from './client.controller';
4
- import { ClientListener } from './client.listener';
5
- import { ClientRepository } from './client.repository';
6
-
7
- export const metadata: ModuleMetadata = {
8
- imports: [],
9
- controllers: [ClientController],
10
- providers: [ClientRepository, ClientListener],
11
- exports: [ClientRepository],
12
- };
13
-
14
- @Module(metadata)
15
- export class ClientModule extends AbstractRouter {
16
- public static readonly path = '/clients';
17
-
18
- public static readonly module = ClientModule;
19
- }
@@ -1,37 +0,0 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { InjectModel } from '@nestjs/mongoose';
3
- import { Model, UpdateQuery } from 'mongoose';
4
- import { Mutable } from 'type-fest';
5
- import { AbstractRepository } from '../../../abstract/abstract.repository';
6
- import { ClientEntity } from './client.entity';
7
- import { CreateClientValidator, UpdateClientValidator } from './client.validator';
8
-
9
- @Injectable()
10
- export class ClientRepository extends AbstractRepository<ClientEntity> {
11
- @InjectModel(ClientEntity.$index)
12
- public readonly $model: Model<ClientEntity>;
13
-
14
- public async create(validator: CreateClientValidator) {
15
- const client: Mutable<ClientEntity> = new this.$model();
16
-
17
- client.name = validator.name;
18
- client.email = validator.email;
19
- client.phone = validator.phone;
20
- client.identificationNumber = validator.identificationNumber;
21
- client.addresses = validator.addresses;
22
-
23
- return super.$create(client);
24
- }
25
-
26
- public async update(id: string, validator: UpdateClientValidator): Promise<ClientEntity> {
27
- const query: UpdateQuery<ClientEntity> = {
28
- $set: {},
29
- };
30
-
31
- return super.$update(id, query);
32
- }
33
-
34
- public delete(id: string): Promise<void> {
35
- return super.$delete(id);
36
- }
37
- }
@@ -1,4 +0,0 @@
1
- import { SchemaFactory } from '@nestjs/mongoose';
2
- import { ClientEntity } from './client.entity';
3
-
4
- export const ClientSchema = SchemaFactory.createForClass(ClientEntity);
@@ -1,43 +0,0 @@
1
- import { Transform } from 'class-transformer';
2
- import { IsArray, IsEmail, IsOptional, IsPhoneNumber, IsString } from 'class-validator';
3
- import { MetaAddress } from "../../../types";
4
- import { AbstractValidator } from "../../../abstract/abstract.validator";
5
-
6
- export class CreateClientValidator extends AbstractValidator {
7
- @IsString()
8
- public name: string;
9
-
10
- @IsEmail()
11
- @Transform(({ value }) => String(value).toLowerCase())
12
- public email: string;
13
-
14
- @IsString()
15
- @IsOptional()
16
- public phone?: string;
17
-
18
- @IsString()
19
- public identificationNumber: string;
20
-
21
- @IsArray()
22
- public addresses: MetaAddress[];
23
- }
24
-
25
- export class UpdateClientValidator extends CreateClientValidator {
26
- @IsString()
27
- @IsOptional()
28
- public name: string;
29
-
30
- @IsEmail()
31
- @Transform(({ value }) => String(value).toLowerCase())
32
- @IsOptional()
33
- public email: string;
34
-
35
- @IsPhoneNumber()
36
- @IsOptional()
37
- public phone: string;
38
-
39
- @IsString()
40
- @IsOptional()
41
- public identificationNumber: string;
42
- }
43
-