@merkaly/api 0.2.5-6 → 0.2.5-7

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 (196) hide show
  1. package/.output/abstracts/abstract.entity.d.ts +14 -0
  2. package/.output/abstracts/abstract.validator.d.ts +24 -0
  3. package/.output/abstracts/abstract.validator.js +118 -0
  4. package/.output/exceptions/missing-identity.exception.d.ts +5 -0
  5. package/.output/exceptions/missing-identity.exception.js +30 -0
  6. package/.output/modules/asset/files/file.entity.d.ts +9 -0
  7. package/.output/modules/asset/files/file.schema.d.ts +34 -0
  8. package/.output/modules/asset/files/file.schema.js +10 -0
  9. package/.output/modules/auth/organizations/organization.entity.d.ts +8 -0
  10. package/.output/modules/auth/users/user.entity.d.ts +9 -0
  11. package/.output/modules/auth/users/user.schema.d.ts +34 -0
  12. package/.output/modules/auth/users/user.schema.js +10 -0
  13. package/.output/modules/auth/users/user.validator.d.ts +12 -0
  14. package/.output/modules/auth/users/user.validator.js +58 -0
  15. package/.output/modules/inventory/brands/brand.entity.d.ts +6 -0
  16. package/.output/modules/inventory/brands/brand.schema.d.ts +34 -0
  17. package/.output/modules/inventory/brands/brand.schema.js +10 -0
  18. package/.output/modules/inventory/brands/brand.validator.d.ts +11 -0
  19. package/.output/modules/inventory/brands/brand.validator.js +74 -0
  20. package/.output/modules/inventory/categories/category.entity.d.ts +6 -0
  21. package/.output/modules/inventory/categories/category.schema.d.ts +34 -0
  22. package/.output/modules/inventory/categories/category.schema.js +10 -0
  23. package/.output/modules/inventory/categories/category.validator.d.ts +8 -0
  24. package/.output/modules/inventory/categories/category.validator.js +42 -0
  25. package/.output/modules/inventory/complements/complement.entity.d.ts +6 -0
  26. package/.output/modules/inventory/complements/complement.validator.d.ts +10 -0
  27. package/.output/modules/inventory/complements/complement.validator.js +52 -0
  28. package/.output/modules/inventory/products/documents/attribute.document.d.ts +5 -0
  29. package/.output/modules/inventory/products/documents/attribute.document.js +33 -0
  30. package/.output/modules/inventory/products/documents/dimension.document.d.ts +6 -0
  31. package/.output/modules/inventory/products/documents/dimension.document.js +35 -0
  32. package/.output/modules/inventory/products/product.entity.d.ts +19 -0
  33. package/.output/modules/inventory/products/product.schema.d.ts +34 -0
  34. package/.output/modules/inventory/products/product.schema.js +18 -0
  35. package/.output/modules/inventory/products/product.validator.d.ts +29 -0
  36. package/.output/modules/inventory/products/product.validator.js +179 -0
  37. package/.output/modules/inventory/products/validators/attributes.validator.d.ts +5 -0
  38. package/.output/modules/inventory/products/validators/attributes.validator.js +35 -0
  39. package/.output/modules/inventory/products/validators/dimension.validator.d.ts +6 -0
  40. package/.output/modules/inventory/products/validators/dimension.validator.js +38 -0
  41. package/.output/modules/sale/customers/customer.entity.d.ts +8 -0
  42. package/.output/modules/sale/customers/customer.schema.d.ts +34 -0
  43. package/.output/modules/sale/customers/customer.schema.js +10 -0
  44. package/.output/modules/sale/customers/customer.validator.d.ts +14 -0
  45. package/.output/modules/sale/customers/customer.validator.js +94 -0
  46. package/.output/modules/sale/orders/documents/address.document.d.ts +8 -0
  47. package/.output/modules/sale/orders/documents/address.document.js +43 -0
  48. package/.output/modules/sale/orders/documents/status.document.d.ts +8 -0
  49. package/.output/modules/sale/orders/documents/status.document.js +34 -0
  50. package/.output/modules/sale/orders/entities/item.entity.d.ts +38 -0
  51. package/.output/modules/sale/orders/enums/order.status.d.ts +6 -0
  52. package/.output/modules/sale/orders/enums/order.status.js +10 -0
  53. package/.output/modules/sale/orders/order.entity.d.ts +21 -0
  54. package/.output/modules/sale/orders/order.validator.d.ts +16 -0
  55. package/.output/modules/sale/orders/order.validator.js +86 -0
  56. package/.output/modules/sale/orders/validators/address.validator.d.ts +17 -0
  57. package/.output/modules/sale/orders/validators/address.validator.js +81 -0
  58. package/{src/modules/sale/orders/validators/billing.validator.ts → .output/modules/sale/orders/validators/billing.validator.d.ts} +4 -7
  59. package/.output/modules/sale/orders/validators/billing.validator.js +13 -0
  60. package/.output/modules/sale/orders/validators/item.validator.d.ts +5 -0
  61. package/.output/modules/sale/orders/validators/item.validator.js +32 -0
  62. package/.output/modules/sale/orders/validators/payment.validator.d.ts +10 -0
  63. package/.output/modules/sale/orders/validators/payment.validator.js +62 -0
  64. package/.output/modules/sale/orders/validators/shipping.validator.d.ts +9 -0
  65. package/.output/modules/sale/orders/validators/shipping.validator.js +14 -0
  66. package/.output/modules/sale/payments/entities/status.entity.d.ts +8 -0
  67. package/.output/modules/sale/payments/enums/billing.type.d.ts +6 -0
  68. package/.output/modules/sale/payments/enums/billing.type.js +10 -0
  69. package/.output/modules/sale/payments/enums/payment.status.d.ts +7 -0
  70. package/.output/modules/sale/payments/enums/payment.status.js +11 -0
  71. package/.output/modules/sale/payments/enums/shipping.type.d.ts +4 -0
  72. package/.output/modules/sale/payments/enums/shipping.type.js +8 -0
  73. package/.output/modules/sale/payments/payment.entity.d.ts +12 -0
  74. package/.output/modules/sale/payments/payment.schema.d.ts +34 -0
  75. package/.output/modules/sale/payments/payment.schema.js +14 -0
  76. package/.output/modules/sale/payments/payment.validator.d.ts +16 -0
  77. package/.output/modules/sale/payments/payment.validator.js +77 -0
  78. package/.output/tsconfig.package.tsbuildinfo +1 -0
  79. package/package.json +4 -1
  80. package/.bin/deploy.sh +0 -9
  81. package/.bin/package.sh +0 -12
  82. package/.docker/Dockerfile +0 -21
  83. package/.dockerignore +0 -12
  84. package/.github/dependabot.yml +0 -17
  85. package/.github/semantic.yml +0 -5
  86. package/.github/workflows/pull_request.yml +0 -35
  87. package/.prettierrc +0 -5
  88. package/app.ts +0 -11
  89. package/authCertificate.pem +0 -19
  90. package/nest-cli.json +0 -8
  91. package/src/abstracts/abstarct.repository.ts +0 -62
  92. package/src/abstracts/abstract.controller.ts +0 -18
  93. package/src/abstracts/abstract.entity.ts +0 -22
  94. package/src/abstracts/abstract.router.ts +0 -7
  95. package/src/abstracts/abstract.validator.ts +0 -61
  96. package/src/app.config.ts +0 -59
  97. package/src/app.console.ts +0 -24
  98. package/src/app.guard.ts +0 -39
  99. package/src/app.module.ts +0 -54
  100. package/src/app.strategy.ts +0 -21
  101. package/src/commands/seed.command.ts +0 -263
  102. package/src/decorators/public.decorator.ts +0 -5
  103. package/src/decorators/user.decorator.ts +0 -30
  104. package/src/exceptions/missing-identity.exception.ts +0 -11
  105. package/src/interceptors/mongoose.interceptor.ts +0 -63
  106. package/src/main.ts +0 -27
  107. package/src/middlewares/router.middleware.ts +0 -14
  108. package/src/modules/asset/asset.module.ts +0 -19
  109. package/src/modules/asset/files/file.controller.ts +0 -22
  110. package/src/modules/asset/files/file.entity.ts +0 -24
  111. package/src/modules/asset/files/file.module.ts +0 -21
  112. package/src/modules/asset/files/file.repository.ts +0 -44
  113. package/src/modules/asset/files/file.schema.ts +0 -8
  114. package/src/modules/asset/files/file.service.ts +0 -4
  115. package/src/modules/auth/auth.controller.ts +0 -57
  116. package/src/modules/auth/auth.module.ts +0 -20
  117. package/src/modules/auth/organizations/organization.controller.ts +0 -20
  118. package/src/modules/auth/organizations/organization.entity.ts +0 -22
  119. package/src/modules/auth/organizations/organization.module.ts +0 -21
  120. package/src/modules/auth/organizations/organization.repository.ts +0 -16
  121. package/src/modules/auth/organizations/organization.schema.ts +0 -8
  122. package/src/modules/auth/users/user.controller.ts +0 -23
  123. package/src/modules/auth/users/user.entity.ts +0 -25
  124. package/src/modules/auth/users/user.module.ts +0 -20
  125. package/src/modules/auth/users/user.repository.ts +0 -79
  126. package/src/modules/auth/users/user.schema.ts +0 -8
  127. package/src/modules/auth/users/user.validator.ts +0 -32
  128. package/src/modules/command.module.ts +0 -15
  129. package/src/modules/global.module.ts +0 -46
  130. package/src/modules/inventory/brands/brand.controller.ts +0 -44
  131. package/src/modules/inventory/brands/brand.entity.ts +0 -20
  132. package/src/modules/inventory/brands/brand.module.ts +0 -20
  133. package/src/modules/inventory/brands/brand.repository.ts +0 -40
  134. package/src/modules/inventory/brands/brand.schema.ts +0 -8
  135. package/src/modules/inventory/brands/brand.validator.ts +0 -31
  136. package/src/modules/inventory/categories/category.controller.ts +0 -42
  137. package/src/modules/inventory/categories/category.entity.ts +0 -15
  138. package/src/modules/inventory/categories/category.module.ts +0 -19
  139. package/src/modules/inventory/categories/category.repository.ts +0 -34
  140. package/src/modules/inventory/categories/category.schema.ts +0 -8
  141. package/src/modules/inventory/categories/category.validator.ts +0 -20
  142. package/src/modules/inventory/complements/complement.controller.ts +0 -41
  143. package/src/modules/inventory/complements/complement.entity.ts +0 -15
  144. package/src/modules/inventory/complements/complement.module.ts +0 -19
  145. package/src/modules/inventory/complements/complement.repository.ts +0 -37
  146. package/src/modules/inventory/complements/complement.schema.ts +0 -8
  147. package/src/modules/inventory/complements/complement.validator.ts +0 -28
  148. package/src/modules/inventory/inventory.module.ts +0 -23
  149. package/src/modules/inventory/products/documents/attribute.document.ts +0 -14
  150. package/src/modules/inventory/products/documents/dimension.document.ts +0 -16
  151. package/src/modules/inventory/products/product.controller.ts +0 -62
  152. package/src/modules/inventory/products/product.entity.ts +0 -46
  153. package/src/modules/inventory/products/product.module.ts +0 -19
  154. package/src/modules/inventory/products/product.repository.ts +0 -64
  155. package/src/modules/inventory/products/product.schema.ts +0 -19
  156. package/src/modules/inventory/products/product.validator.ts +0 -132
  157. package/src/modules/inventory/products/validators/attributes.validator.ts +0 -15
  158. package/src/modules/inventory/products/validators/dimension.validator.ts +0 -19
  159. package/src/modules/sale/customers/customer.controller.ts +0 -41
  160. package/src/modules/sale/customers/customer.entity.ts +0 -19
  161. package/src/modules/sale/customers/customer.module.ts +0 -18
  162. package/src/modules/sale/customers/customer.repository.ts +0 -30
  163. package/src/modules/sale/customers/customer.schema.ts +0 -8
  164. package/src/modules/sale/customers/customer.validator.ts +0 -43
  165. package/src/modules/sale/orders/documents/address.document.ts +0 -22
  166. package/src/modules/sale/orders/documents/status.document.ts +0 -17
  167. package/src/modules/sale/orders/entities/item.entity.ts +0 -24
  168. package/src/modules/sale/orders/enums/order.status.ts +0 -6
  169. package/src/modules/sale/orders/order.controller.ts +0 -65
  170. package/src/modules/sale/orders/order.entity.ts +0 -46
  171. package/src/modules/sale/orders/order.module.ts +0 -22
  172. package/src/modules/sale/orders/order.repository.ts +0 -122
  173. package/src/modules/sale/orders/order.schema.ts +0 -36
  174. package/src/modules/sale/orders/order.validator.ts +0 -44
  175. package/src/modules/sale/orders/validators/address.validator.ts +0 -50
  176. package/src/modules/sale/orders/validators/item.validator.ts +0 -14
  177. package/src/modules/sale/orders/validators/payment.validator.ts +0 -44
  178. package/src/modules/sale/orders/validators/shipping.validator.ts +0 -14
  179. package/src/modules/sale/payments/entities/status.entity.ts +0 -17
  180. package/src/modules/sale/payments/enums/billing.type.ts +0 -6
  181. package/src/modules/sale/payments/enums/payment.status.ts +0 -7
  182. package/src/modules/sale/payments/enums/shipping.type.ts +0 -4
  183. package/src/modules/sale/payments/payment.controller.ts +0 -45
  184. package/src/modules/sale/payments/payment.entity.ts +0 -25
  185. package/src/modules/sale/payments/payment.module.ts +0 -20
  186. package/src/modules/sale/payments/payment.repository.ts +0 -57
  187. package/src/modules/sale/payments/payment.schema.ts +0 -14
  188. package/src/modules/sale/payments/payment.validator.ts +0 -32
  189. package/src/modules/sale/sale.module.ts +0 -20
  190. package/src/services/auth0.service.ts +0 -49
  191. package/src/services/mongo.service.ts +0 -52
  192. package/test/auth/auth.spec.ts +0 -20
  193. package/test/main.ts +0 -12
  194. package/tsconfig.build.json +0 -4
  195. package/tsconfig.json +0 -21
  196. package/tsconfig.package.json +0 -22
@@ -1,32 +0,0 @@
1
- import { IsEmail, IsLocale, IsOptional, IsString } from 'class-validator';
2
-
3
- export class CreateUserValidator {
4
- @IsString()
5
- public auth0: string;
6
-
7
- @IsString()
8
- public name: string;
9
-
10
- @IsEmail()
11
- public email: string;
12
-
13
- @IsString()
14
- public picture: string;
15
-
16
- @IsLocale()
17
- public locale: string;
18
- }
19
-
20
- export class UpdatedUserValidator {
21
- @IsString()
22
- @IsOptional()
23
- public name?: string;
24
-
25
- @IsString()
26
- @IsOptional()
27
- public picture?: string;
28
-
29
- @IsLocale()
30
- @IsOptional()
31
- public locale?: string;
32
- }
@@ -1,15 +0,0 @@
1
- import { DynamicModule } from '@nestjs/common';
2
- import { ConsoleModule } from 'nestjs-console';
3
- import { router } from '../app.module';
4
- import { SeedCommand } from '../commands/seed.command';
5
-
6
- export class CommandsModule {
7
- public static register(): DynamicModule {
8
- return {
9
- global: true,
10
- imports: [ConsoleModule, ...router],
11
- module: CommandsModule,
12
- providers: [SeedCommand],
13
- };
14
- }
15
- }
@@ -1,46 +0,0 @@
1
- import { DynamicModule } from '@nestjs/common';
2
- import { MongooseModule } from '@nestjs/mongoose';
3
- import { Auth0Service } from '../services/auth0.service';
4
- import { MongoService } from '../services/mongo.service';
5
- import { FileSchema } from './asset/files/file.schema';
6
- import { OrganizationSchema } from './auth/organizations/organization.schema';
7
- import { UserSchema } from './auth/users/user.schema';
8
- import { BrandSchema } from './inventory/brands/brand.schema';
9
- import { CategorySchema } from './inventory/categories/category.schema';
10
- import { ComplementSchema } from './inventory/complements/complement.schema';
11
- import { ProductSchema } from './inventory/products/product.schema';
12
- import { CustomerSchema } from './sale/customers/customer.schema';
13
- import { OrderSchema } from './sale/orders/order.schema';
14
- import { PaymentSchema } from './sale/payments/payment.schema';
15
-
16
- const mongooseEntities = MongooseModule.forFeature([
17
- // Assets
18
- FileSchema,
19
-
20
- // Auth
21
- UserSchema,
22
- OrganizationSchema,
23
-
24
- // Sale
25
- OrderSchema,
26
- PaymentSchema,
27
- CustomerSchema,
28
-
29
- // Inventory
30
- BrandSchema,
31
- ProductSchema,
32
- CategorySchema,
33
- ComplementSchema,
34
- ]);
35
-
36
- export class GlobalModule {
37
- public static register(): DynamicModule {
38
- return {
39
- exports: [mongooseEntities, Auth0Service],
40
- global: true,
41
- imports: [MongooseModule.forRootAsync({ useClass: MongoService }), mongooseEntities],
42
- module: GlobalModule,
43
- providers: [Auth0Service],
44
- };
45
- }
46
- }
@@ -1,44 +0,0 @@
1
- import { Body, Controller, Delete, Get, HttpCode, HttpStatus, Inject, Param, Patch, Post, Query } from '@nestjs/common';
2
- import { ApiTags } from '@nestjs/swagger';
3
- import { AbstractController } from '../../../abstracts/abstract.controller';
4
- import { FindValidator, IdMongoValidator, ReadValidator } from '../../../abstracts/abstract.validator';
5
- import { Public } from '../../../decorators/public.decorator';
6
- import { BrandEntity } from './brand.entity';
7
- import { BrandRepository } from './brand.repository';
8
- import { CreateBrandValidator, UpdateBrandValidator } from './brand.validator';
9
-
10
- @Controller()
11
- @ApiTags('inventory')
12
- export class BrandController extends AbstractController {
13
- @Inject()
14
- protected readonly $repository: BrandRepository;
15
-
16
- @Get('/')
17
- @Public()
18
- public async find(@Query() validator: FindValidator<BrandEntity>) {
19
- return super.find(validator);
20
- }
21
-
22
- @Get('/:id')
23
- @Public()
24
- public async read(@Param() { id }: IdMongoValidator, @Query() validator?: ReadValidator) {
25
- return this.$repository.read(id, validator);
26
- }
27
-
28
- @Post('/')
29
- @HttpCode(HttpStatus.CREATED)
30
- public async create(@Body() validator: CreateBrandValidator) {
31
- return this.$repository.create(validator);
32
- }
33
-
34
- @Patch('/:id')
35
- public async update(@Param('id') id: string, @Body() validator: UpdateBrandValidator) {
36
- return this.$repository.update(id, validator);
37
- }
38
-
39
- @Delete('/:id')
40
- @HttpCode(HttpStatus.NO_CONTENT)
41
- public delete(@Param() { id }: IdMongoValidator) {
42
- return this.$repository.delete(id);
43
- }
44
- }
@@ -1,20 +0,0 @@
1
- import { Prop } from '@nestjs/mongoose';
2
- import { Schema as Collection } from '@nestjs/mongoose/dist/decorators/schema.decorator';
3
- import { Schema as MongoSchema } from 'mongoose';
4
- import { $collection, AbstractEntity } from '../../../abstracts/abstract.entity';
5
-
6
- @Collection($collection)
7
- export class BrandEntity extends AbstractEntity {
8
- @Prop({
9
- type: MongoSchema.Types.String,
10
- required: true,
11
- unique: true,
12
- length: 32,
13
- })
14
- public name: string;
15
-
16
- @Prop({ type: MongoSchema.Types.String })
17
- public description: string;
18
-
19
- public readonly picture: string;
20
- }
@@ -1,20 +0,0 @@
1
- import { Module, ModuleMetadata } from '@nestjs/common';
2
- import { AbstractRouter } from '../../../abstracts/abstract.router';
3
- import { BrandController } from './brand.controller';
4
- import { BrandRepository } from './brand.repository';
5
-
6
- export const metadata: ModuleMetadata = {
7
- controllers: [BrandController],
8
- exports: [BrandRepository],
9
- imports: [],
10
- providers: [BrandRepository],
11
- };
12
-
13
- @Module(metadata)
14
- export class BrandModule extends AbstractRouter {
15
- public static readonly path = '/brands';
16
-
17
- public static readonly module = BrandModule;
18
-
19
- public static readonly children = metadata.imports;
20
- }
@@ -1,40 +0,0 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { InjectModel } from '@nestjs/mongoose';
3
- import { Model } from 'mongoose';
4
- import { AbstractRepository } from '../../../abstracts/abstarct.repository';
5
- import { BrandEntity } from './brand.entity';
6
- import { BrandSchema } from './brand.schema';
7
- import { CreateBrandValidator, UpdateBrandValidator } from './brand.validator';
8
-
9
- @Injectable()
10
- export class BrandRepository extends AbstractRepository<BrandEntity> {
11
- @InjectModel(BrandSchema.name)
12
- protected readonly $model: Model<BrandEntity>;
13
-
14
- public async create(validator: CreateBrandValidator) {
15
- const brand = new this.$model();
16
-
17
- brand.name = validator.name;
18
- brand.description = validator.description;
19
-
20
- await brand.save();
21
-
22
- return brand;
23
- }
24
-
25
- public async update(id: string, validator: UpdateBrandValidator) {
26
- const brand = await this.read(id);
27
-
28
- if (validator.name) {
29
- brand.name = validator.name;
30
- }
31
-
32
- if (validator.description) {
33
- brand.description = validator.description;
34
- }
35
-
36
- await brand.save();
37
-
38
- return brand;
39
- }
40
- }
@@ -1,8 +0,0 @@
1
- import { SchemaFactory } from '@nestjs/mongoose';
2
- import { BrandEntity } from './brand.entity';
3
-
4
- export namespace BrandSchema {
5
- export const name = 'inventory_brands';
6
-
7
- export const schema = SchemaFactory.createForClass(BrandEntity);
8
- }
@@ -1,31 +0,0 @@
1
- import { IsMongoId, IsOptional, IsString, Length } from 'class-validator';
2
- import { AbstractValidator } from '../../../abstracts/abstract.validator';
3
-
4
- export class CreateBrandValidator extends AbstractValidator {
5
- @IsString()
6
- @Length(2, 32)
7
- public name: string;
8
-
9
- @IsString()
10
- @IsOptional()
11
- public description?: string;
12
-
13
- @IsMongoId()
14
- @IsOptional()
15
- public image: string;
16
- }
17
-
18
- export class UpdateBrandValidator extends AbstractValidator {
19
- @IsString()
20
- @Length(2, 32)
21
- @IsOptional()
22
- public name?: string;
23
-
24
- @IsString()
25
- @IsOptional()
26
- public description?: string;
27
-
28
- @IsMongoId()
29
- @IsOptional()
30
- public image: string;
31
- }
@@ -1,42 +0,0 @@
1
- import { Body, Controller, Delete, Get, Inject, Param, Patch, Post, Query } from '@nestjs/common';
2
- import { ApiTags } from '@nestjs/swagger';
3
- import { AbstractController } from '../../../abstracts/abstract.controller';
4
- import { FindValidator, IdMongoValidator, ReadValidator } from '../../../abstracts/abstract.validator';
5
- import { Public } from '../../../decorators/public.decorator';
6
- import { CategoryEntity } from './category.entity';
7
- import { CategoryRepository } from './category.repository';
8
- import { CreateCategoryValidator, UpdateCategoryValidator } from './category.validator';
9
-
10
- @Controller('')
11
- @ApiTags('inventory')
12
- export class CategoryController extends AbstractController {
13
- @Inject()
14
- protected readonly $repository: CategoryRepository;
15
-
16
- @Public()
17
- @Get('/')
18
- public find(@Query() validator: FindValidator<CategoryEntity>) {
19
- return this.$repository.find(validator);
20
- }
21
-
22
- @Public()
23
- @Get('/:id')
24
- public read(@Param() { id }: IdMongoValidator, @Query() validator?: ReadValidator) {
25
- return this.$repository.read(id, validator);
26
- }
27
-
28
- @Post('/')
29
- public create(@Body() validator: CreateCategoryValidator) {
30
- return this.$repository.create(validator);
31
- }
32
-
33
- @Patch('/:id')
34
- public update(@Param('id') id: string, @Body() validator: UpdateCategoryValidator) {
35
- return this.$repository.update(id, validator);
36
- }
37
-
38
- @Delete('/:id')
39
- public remove(@Param('id') id: string) {
40
- return this.$repository.delete(id);
41
- }
42
- }
@@ -1,15 +0,0 @@
1
- import { Prop, Schema as Collection } from '@nestjs/mongoose';
2
- import { Schema } from 'mongoose';
3
- import { $collection, AbstractEntity } from '../../../abstracts/abstract.entity';
4
-
5
- @Collection($collection)
6
- export class CategoryEntity extends AbstractEntity {
7
- @Prop({ required: true, type: Schema.Types.String, unique: true })
8
- public name: string;
9
-
10
- @Prop({ type: Schema.Types.String })
11
- public description: string;
12
-
13
- @Prop({ type: Schema.Types.String })
14
- public picture: string;
15
- }
@@ -1,19 +0,0 @@
1
- import { Module, ModuleMetadata } from '@nestjs/common';
2
- import { CategoryController } from './category.controller';
3
- import { CategoryRepository } from './category.repository';
4
-
5
- export const metadata: ModuleMetadata = {
6
- controllers: [CategoryController],
7
- exports: [CategoryRepository],
8
- imports: [],
9
- providers: [CategoryRepository],
10
- };
11
-
12
- @Module(metadata)
13
- export class CategoryModule {
14
- public static readonly path = '/categories';
15
-
16
- public static readonly module = CategoryModule;
17
-
18
- public static readonly children = metadata.imports;
19
- }
@@ -1,34 +0,0 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { InjectModel } from '@nestjs/mongoose';
3
- import { Model } from 'mongoose';
4
- import { AbstractRepository } from '../../../abstracts/abstarct.repository';
5
- import { CategoryEntity } from './category.entity';
6
- import { CategorySchema } from './category.schema';
7
- import { CreateCategoryValidator, UpdateCategoryValidator } from './category.validator';
8
-
9
- @Injectable()
10
- export class CategoryRepository extends AbstractRepository<CategoryEntity> {
11
- @InjectModel(CategorySchema.name)
12
- protected readonly $model: Model<CategoryEntity>;
13
-
14
- public async create(validator: CreateCategoryValidator) {
15
- const category = new this.$model();
16
-
17
- category.name = validator.name;
18
- category.description = validator.description;
19
-
20
- await category.save();
21
-
22
- return category;
23
- }
24
-
25
- public async update(id: string, validator: UpdateCategoryValidator) {
26
- const category = await this.read(id);
27
-
28
- category.name = validator.name || category.name;
29
- category.description = validator.description || category.description;
30
-
31
- await category.save();
32
- return category;
33
- }
34
- }
@@ -1,8 +0,0 @@
1
- import { SchemaFactory } from '@nestjs/mongoose';
2
- import { CategoryEntity } from './category.entity';
3
-
4
- export namespace CategorySchema {
5
- export const name = 'inventory_categories';
6
-
7
- export const schema = SchemaFactory.createForClass(CategoryEntity);
8
- }
@@ -1,20 +0,0 @@
1
- import { IsOptional, IsString } from 'class-validator';
2
-
3
- export class CreateCategoryValidator {
4
- @IsString()
5
- public name: string;
6
-
7
- @IsString()
8
- @IsOptional()
9
- public description?: string;
10
- }
11
-
12
- export class UpdateCategoryValidator {
13
- @IsString()
14
- @IsOptional()
15
- public name: string;
16
-
17
- @IsString()
18
- @IsOptional()
19
- public description?: string;
20
- }
@@ -1,41 +0,0 @@
1
- import { Body, Controller, Delete, Get, Inject, Param, Patch, Post, Query } from '@nestjs/common';
2
- import { ApiTags } from '@nestjs/swagger';
3
- import { AbstractController } from '../../../abstracts/abstract.controller';
4
- import { IdMongoValidator, ReadValidator } from '../../../abstracts/abstract.validator';
5
- import { Public } from '../../../decorators/public.decorator';
6
- import { ComplementRepository } from './complement.repository';
7
- import { CreateComplementValidator, UpdateComplementValidator } from './complement.validator';
8
-
9
- @Controller('/')
10
- @ApiTags('inventory')
11
- export class ComplementController extends AbstractController {
12
- @Inject()
13
- protected readonly $repository: ComplementRepository;
14
-
15
- @Public()
16
- @Get('/')
17
- public find() {
18
- return this.$repository.find();
19
- }
20
-
21
- @Public()
22
- @Get('/:id')
23
- public read(@Param() { id }: IdMongoValidator, @Query() validator?: ReadValidator) {
24
- return this.$repository.read(id, validator);
25
- }
26
-
27
- @Post('/')
28
- public create(@Body() validator: CreateComplementValidator) {
29
- return this.$repository.create(validator);
30
- }
31
-
32
- @Patch('/:id')
33
- public update(@Param() { id }: IdMongoValidator, @Body() validator: UpdateComplementValidator) {
34
- return this.$repository.update(id, validator);
35
- }
36
-
37
- @Delete('/:id')
38
- public delete(@Param() { id }: IdMongoValidator) {
39
- return this.$repository.delete(id);
40
- }
41
- }
@@ -1,15 +0,0 @@
1
- import { Prop, Schema as Collection } from '@nestjs/mongoose';
2
- import { Schema } from 'mongoose';
3
- import { $collection, AbstractEntity } from '../../../abstracts/abstract.entity';
4
-
5
- @Collection($collection)
6
- export class ComplementEntity extends AbstractEntity {
7
- @Prop({ required: true, type: Schema.Types.String, unique: true })
8
- public name: string;
9
-
10
- @Prop({ type: Schema.Types.String })
11
- public description: string;
12
-
13
- @Prop({ default: () => 0, type: Schema.Types.Number })
14
- public price: number;
15
- }
@@ -1,19 +0,0 @@
1
- import { Module, ModuleMetadata } from '@nestjs/common';
2
- import { ComplementController } from './complement.controller';
3
- import { ComplementRepository } from './complement.repository';
4
-
5
- export const metadata: ModuleMetadata = {
6
- controllers: [ComplementController],
7
- exports: [ComplementRepository],
8
- imports: [],
9
- providers: [ComplementRepository],
10
- };
11
-
12
- @Module(metadata)
13
- export class ComplementModule {
14
- public static readonly path = '/complements';
15
-
16
- public static readonly module = ComplementModule;
17
-
18
- public static readonly children = metadata.imports;
19
- }
@@ -1,37 +0,0 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { InjectModel } from '@nestjs/mongoose';
3
- import { Model } from 'mongoose';
4
- import { AbstractRepository } from '../../../abstracts/abstarct.repository';
5
- import { ComplementEntity } from './complement.entity';
6
- import { ComplementSchema } from './complement.schema';
7
- import { CreateComplementValidator, UpdateComplementValidator } from './complement.validator';
8
-
9
- @Injectable()
10
- export class ComplementRepository extends AbstractRepository<ComplementEntity> {
11
- @InjectModel(ComplementSchema.name)
12
- protected readonly $model: Model<ComplementEntity>;
13
-
14
- public async create(validator: CreateComplementValidator) {
15
- const complement = new this.$model();
16
-
17
- complement.name = validator.name;
18
- complement.description = validator.description;
19
- complement.price = validator.price;
20
-
21
- await complement.save();
22
-
23
- return complement;
24
- }
25
-
26
- public async update(id: string, validator: UpdateComplementValidator) {
27
- const complement = await this.read(id);
28
-
29
- complement.name = validator.name || complement.name;
30
- complement.description = validator.description || complement.description;
31
- complement.price = validator.price || complement.price;
32
-
33
- complement.save();
34
-
35
- return complement;
36
- }
37
- }
@@ -1,8 +0,0 @@
1
- import { SchemaFactory } from '@nestjs/mongoose';
2
- import { ComplementEntity } from './complement.entity';
3
-
4
- export namespace ComplementSchema {
5
- export const name = 'inventory_complements';
6
-
7
- export const schema = SchemaFactory.createForClass(ComplementEntity);
8
- }
@@ -1,28 +0,0 @@
1
- import { IsNumber, IsOptional, IsPositive, IsString } from 'class-validator';
2
-
3
- export class CreateComplementValidator {
4
- @IsString()
5
- public name: string;
6
-
7
- @IsString()
8
- public description: string;
9
-
10
- @IsNumber()
11
- @IsPositive()
12
- public price: number;
13
- }
14
-
15
- export class UpdateComplementValidator {
16
- @IsOptional()
17
- @IsString()
18
- public name: string;
19
-
20
- @IsOptional()
21
- @IsString()
22
- public description: string;
23
-
24
- @IsOptional()
25
- @IsNumber()
26
- @IsPositive()
27
- public price: number;
28
- }
@@ -1,23 +0,0 @@
1
- import { Module, ModuleMetadata } from '@nestjs/common';
2
- import { BrandModule } from './brands/brand.module';
3
- import { CategoryModule } from './categories/category.module';
4
- import { ComplementModule } from './complements/complement.module';
5
- import { ProductModule } from './products/product.module';
6
-
7
- const modules = [ProductModule, CategoryModule, ComplementModule, BrandModule];
8
-
9
- export const metadata: ModuleMetadata = {
10
- controllers: [],
11
- exports: modules,
12
- imports: modules,
13
- providers: [],
14
- };
15
-
16
- @Module(metadata)
17
- export class InventoryModule {
18
- public static readonly path = '/inventory';
19
-
20
- public static readonly module = InventoryModule;
21
-
22
- public static readonly children = metadata.imports;
23
- }
@@ -1,14 +0,0 @@
1
- import { Prop } from '@nestjs/mongoose';
2
- import { Schema } from 'mongoose';
3
-
4
- export class ProductAttributesDocument {
5
- // Cantidad de unidades que se venden en ese producto
6
- @Prop({ default: () => 1, type: Schema.Types.Number })
7
- public units = 1;
8
-
9
- @Prop({ default: () => null, type: Schema.Types.Number })
10
- public stock: null | number = null;
11
-
12
- @Prop({ default: () => undefined, required: true, type: Schema.Types.String, unique: true })
13
- public sku: string;
14
- }
@@ -1,16 +0,0 @@
1
- import { Prop } from '@nestjs/mongoose';
2
- import { Schema } from 'mongoose';
3
-
4
- export class ProductDimensionDocument {
5
- @Prop({ type: Schema.Types.Number })
6
- public weight: number;
7
-
8
- @Prop({ type: Schema.Types.Number })
9
- public height: number;
10
-
11
- @Prop({ type: Schema.Types.Number })
12
- public width: number;
13
-
14
- @Prop({ type: Schema.Types.Number })
15
- public depth: number;
16
- }