@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 { Type } from 'class-transformer';
2
- import { IsEnum, IsMongoId, IsNotEmptyObject, IsPositive, ValidateNested } from 'class-validator';
3
- import { IdMongoValidator } from '../../../abstracts/abstract.validator';
4
- import { PaymentValidator } from '../orders/validators/payment.validator';
5
- import { BillingType } from './enums/billing.type';
6
- import { PaymentStatus } from './enums/payment.status';
7
-
8
- export class CreatePaymentValidator {
9
- @IsEnum(BillingType)
10
- public type: BillingType;
11
-
12
- @IsPositive()
13
- public total: number;
14
-
15
- @IsMongoId()
16
- public order: string;
17
-
18
- @IsMongoId()
19
- public user: string;
20
-
21
- @ValidateNested()
22
- @Type(() => PaymentValidator)
23
- @IsNotEmptyObject()
24
- public payload: PaymentValidator;
25
- }
26
-
27
- export class UpdatePaymentValidator {}
28
-
29
- export class UpdatePaymentStatusValidator extends IdMongoValidator {
30
- @IsEnum(PaymentStatus)
31
- public type: PaymentStatus;
32
- }
@@ -1,20 +0,0 @@
1
- import { Module, type ModuleMetadata } from '@nestjs/common';
2
- import { CustomerModule } from './customers/customer.module';
3
- import { OrderModule } from './orders/order.module';
4
- import { PaymentModule } from './payments/payment.module';
5
-
6
- export const metadata: ModuleMetadata = {
7
- controllers: [],
8
- exports: [OrderModule, PaymentModule, CustomerModule],
9
- imports: [OrderModule, PaymentModule, CustomerModule],
10
- providers: [],
11
- };
12
-
13
- @Module(metadata)
14
- export class SaleModule {
15
- public static readonly path = '/sale';
16
-
17
- public static readonly module = SaleModule;
18
-
19
- public static readonly children = metadata.imports;
20
- }
@@ -1,49 +0,0 @@
1
- import { Injectable, OnModuleInit } from '@nestjs/common';
2
- import type { GetOrganizations200ResponseOneOfInner, ManagementClientOptionsWithClientCredentials } from 'auth0';
3
- import { ManagementClient } from 'auth0';
4
- import { AppConfig } from '../app.config';
5
-
6
- @Injectable()
7
- export class Auth0Service implements OnModuleInit {
8
- protected $auth0: ManagementClient;
9
-
10
- public get organizations() {
11
- const parseOrg = (org: GetOrganizations200ResponseOneOfInner) => {
12
- if (!org.metadata) {
13
- org.metadata = {};
14
- }
15
-
16
- for (const key in org.metadata) {
17
- try {
18
- org.metadata[key] = JSON.parse(org.metadata[key]);
19
- } catch (e: unknown) {}
20
- }
21
-
22
- return org;
23
- };
24
-
25
- return {
26
- find: async () => {
27
- const { data } = await this.$auth0.organizations.getAll();
28
-
29
- return data.map(parseOrg);
30
- },
31
- read: async (id: string) => {
32
- const { data } = await this.$auth0.organizations.get({ id });
33
-
34
- return parseOrg(data);
35
- },
36
- };
37
- }
38
-
39
- public async onModuleInit() {
40
- const options: ManagementClientOptionsWithClientCredentials = {
41
- audience: AppConfig.AUTH0.audience,
42
- clientId: AppConfig.AUTH0.client,
43
- clientSecret: AppConfig.AUTH0.secret,
44
- domain: AppConfig.AUTH0.domain,
45
- };
46
-
47
- this.$auth0 = new ManagementClient(options);
48
- }
49
- }
@@ -1,52 +0,0 @@
1
- import { Inject, Injectable } from '@nestjs/common';
2
- import { REQUEST } from '@nestjs/core';
3
- import { MongooseModuleOptions, MongooseOptionsFactory } from '@nestjs/mongoose';
4
- import { Request } from 'express';
5
- import { AppConfig } from '../app.config';
6
- import { MissingIdentityException } from '../exceptions/missing-identity.exception';
7
- import { Auth0Service } from './auth0.service';
8
-
9
- @Injectable()
10
- export class MongoService implements MongooseOptionsFactory {
11
- @Inject(REQUEST)
12
- protected readonly $request: Request;
13
-
14
- @Inject()
15
- protected readonly $auth0: Auth0Service;
16
-
17
- public static extractIdentityFromRequest(request: Request) {
18
- const identity = request.header?.('identity') || request.query['identity'];
19
-
20
- if (!identity && request.path !== '/auth/resolve') {
21
- throw new MissingIdentityException();
22
- }
23
-
24
- return identity;
25
- }
26
-
27
- public async createMongooseOptions(): Promise<MongooseModuleOptions> {
28
- const { host, pass, user, retryWrites, w } = AppConfig.MONGO;
29
- const uri = `mongodb+srv://${user}:${pass}@${host}`;
30
- const [, entrypoint] = process.argv;
31
-
32
- let DSN: URL;
33
-
34
- // if is command running
35
- if (entrypoint.endsWith('console.ts')) {
36
- const { ORG_ID = 'not_defined_organization' } = process.env;
37
-
38
- DSN = new URL(`${uri}/${ORG_ID}`);
39
-
40
- return { uri: DSN.toString() };
41
- }
42
-
43
- const identity = MongoService.extractIdentityFromRequest(this.$request);
44
-
45
- DSN = new URL(`${uri}/${identity}`);
46
-
47
- DSN.searchParams.set('retryWrites', String(retryWrites));
48
- DSN.searchParams.set('w', String(w));
49
-
50
- return { uri: DSN.toString() };
51
- }
52
- }
@@ -1,20 +0,0 @@
1
- import { INestApplication } from '@nestjs/common';
2
- import { setupApp } from '../main';
3
-
4
- describe('When payment is requested', () => {
5
- let app: INestApplication;
6
-
7
- beforeAll(async () => {
8
- app = await setupApp();
9
-
10
- await app.init();
11
- });
12
-
13
- afterAll(async () => {
14
- await app.close();
15
- });
16
-
17
- it('If is a lost card', () => {
18
- console.log('WORK');
19
- });
20
- });
package/test/main.ts DELETED
@@ -1,12 +0,0 @@
1
- import { Test } from '@nestjs/testing';
2
- import { type INestApplication } from '@nestjs/common';
3
- import { type ModuleMetadata } from '@nestjs/common/interfaces/modules/module-metadata.interface';
4
- import { AppModule } from '../src/app.module';
5
- import { createNestApp } from '../app';
6
-
7
- export async function setupApp(): Promise<INestApplication> {
8
- const metadata: ModuleMetadata = { imports: [AppModule] };
9
- const module = await Test.createTestingModule(metadata).compile();
10
-
11
- return createNestApp(module.createNestApplication());
12
- }
@@ -1,4 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
4
- }
package/tsconfig.json DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "commonjs",
4
- "declaration": true,
5
- "removeComments": true,
6
- "emitDecoratorMetadata": true,
7
- "experimentalDecorators": true,
8
- "allowSyntheticDefaultImports": true,
9
- "target": "es2017",
10
- "sourceMap": true,
11
- "outDir": "./dist",
12
- "baseUrl": "./",
13
- "incremental": true,
14
- "skipLibCheck": true,
15
- "strictNullChecks": false,
16
- "noImplicitAny": false,
17
- "strictBindCallApply": false,
18
- "forceConsistentCasingInFileNames": false,
19
- "noFallthroughCasesInSwitch": false
20
- }
21
- }
@@ -1,22 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "target": "es5",
5
- "declarationMap": false,
6
- "sourceMap": false,
7
- "emitDeclarationOnly": false,
8
- "declarationDir": null,
9
- "noEmitHelpers": false,
10
- "outDir": "./.output",
11
- "emitDecoratorMetadata": true
12
- },
13
- "include": [
14
- "./src/types.ts",
15
- "./src/**/*.entity.ts",
16
- "./src/**/*.document.ts",
17
- "./src/**/*.fixture.ts",
18
- "./src/**/*.exception.ts",
19
- "./src/**/*.types.ts",
20
- "./src/**/*.validator.ts"
21
- ]
22
- }