@merkaly/api 0.2.2-1 → 0.2.2-2

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.
@@ -9,7 +9,6 @@ export declare abstract class AppConfig {
9
9
  audience: string;
10
10
  client: string;
11
11
  secret: string;
12
- realm: string;
13
12
  };
14
13
  static get sentry(): {
15
14
  dsn: string;
@@ -17,7 +16,7 @@ export declare abstract class AppConfig {
17
16
  environment: string;
18
17
  };
19
18
  static get server(): {
20
- port: string | number;
19
+ port: number;
21
20
  name: string;
22
21
  description: string;
23
22
  version: string;
@@ -3,8 +3,8 @@ export declare abstract class AppDocument {
3
3
  protected abstract transform?(entity: unknown): this;
4
4
  $id: string;
5
5
  $createdAt: Date;
6
- $updatedAt: Date;
7
- $deletedAt: Date;
6
+ $updatedAt?: Date;
7
+ $deletedAt?: Date;
8
8
  private _routing;
9
9
  serialize?(entity: AppEntity): this;
10
10
  }
@@ -16,7 +16,7 @@ export declare abstract class AppRepository<E extends AppEntity, D extends AppDo
16
16
  protected get $index(): string;
17
17
  protected get $routing(): string;
18
18
  find(search?: SearchParams): Promise<import("@elastic/elasticsearch/lib/api/types").SearchHitsMetadata<D>>;
19
- create(validator: AppValidator<any>): Promise<GetResponse<D>>;
19
+ create(validator: AppValidator<E>): Promise<GetResponse<D>>;
20
20
  read(id: Id): Promise<GetResponse<D>>;
21
21
  update(id: Id, validator: AppValidator<any>): Promise<GetResponse<D>>;
22
22
  delete(id: Id): Promise<void>;
@@ -0,0 +1,10 @@
1
+ import { OnModuleInit } from '@nestjs/common';
2
+ import { AuthenticationClient, ManagementClient, ObjectWithId, Organization, User } from 'auth0';
3
+ export declare class AuthRepository implements OnModuleInit {
4
+ $management: ManagementClient;
5
+ readonly $auth0: AuthenticationClient;
6
+ onModuleInit(): Promise<ManagementClient | void>;
7
+ getUser(id: ObjectWithId['id']): Promise<User>;
8
+ getOrganization(): Promise<Organization>;
9
+ }
10
+ //# sourceMappingURL=auth.repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.repository.d.ts","sourceRoot":"","sources":["../../../src/module/auth/auth.repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,YAAY,EAAE,MAAM,gBAAgB,CAAA;AACzD,OAAO,EACL,oBAAoB,EAEpB,gBAAgB,EAEhB,YAAY,EACZ,YAAY,EACZ,IAAI,EACL,MAAM,OAAO,CAAA;AAGd,qBACa,cAAe,YAAW,YAAY;IAC1C,WAAW,EAAE,gBAAgB,CAAA;IACpC,SAAgB,MAAM,uBAIpB;IAEK,YAAY,IAAI,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAoB1C,OAAO,CAAC,EAAE,EAAE,YAAY,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9C,eAAe,IAAI,OAAO,CAAC,YAAY,CAAC;CAGtD"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthRepository = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ const auth0_1 = require("auth0");
6
+ const app_config_1 = require("../../config/app.config");
7
+ let AuthRepository = class AuthRepository {
8
+ constructor() {
9
+ this.$auth0 = new auth0_1.AuthenticationClient({
10
+ domain: app_config_1.AppConfig.auth0.domain,
11
+ clientId: app_config_1.AppConfig.auth0.client,
12
+ clientSecret: app_config_1.AppConfig.auth0.secret
13
+ });
14
+ }
15
+ onModuleInit() {
16
+ const options = {
17
+ audience: app_config_1.AppConfig.auth0.audience
18
+ };
19
+ return this.$auth0.clientCredentialsGrant(options)
20
+ .then(({ access_token }) => __awaiter(this, void 0, void 0, function* () {
21
+ const options = {
22
+ audience: app_config_1.AppConfig.auth0.audience,
23
+ domain: app_config_1.AppConfig.auth0.domain,
24
+ clientId: app_config_1.AppConfig.auth0.client,
25
+ clientSecret: app_config_1.AppConfig.auth0.secret,
26
+ token: access_token
27
+ };
28
+ this.$management = new auth0_1.ManagementClient(options);
29
+ }));
30
+ }
31
+ getUser(id) {
32
+ return __awaiter(this, void 0, void 0, function* () {
33
+ return this.$management.getUser({ id });
34
+ });
35
+ }
36
+ getOrganization() {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ return this.$management.organizations.getByID({ id: app_config_1.AppConfig.server.tenant });
39
+ });
40
+ }
41
+ };
42
+ AuthRepository = __decorate([
43
+ (0, common_1.Injectable)()
44
+ ], AuthRepository);
45
+ exports.AuthRepository = AuthRepository;
46
+ //# sourceMappingURL=auth.repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.repository.js","sourceRoot":"","sources":["../../../src/module/auth/auth.repository.ts"],"names":[],"mappings":";;;AAAA,2CAAyD;AACzD,iCAQc;AACd,wDAAmD;AAGnD,IAAa,cAAc,GAA3B,MAAa,cAAc;IAA3B;QAEkB,WAAM,GAAG,IAAI,4BAAoB,CAAC;YAChD,MAAM,EAAE,sBAAS,CAAC,KAAK,CAAC,MAAM;YAC9B,QAAQ,EAAE,sBAAS,CAAC,KAAK,CAAC,MAAM;YAChC,YAAY,EAAE,sBAAS,CAAC,KAAK,CAAC,MAAM;SACrC,CAAC,CAAA;IA6BJ,CAAC;IA3BQ,YAAY;QACjB,MAAM,OAAO,GAAkC;YAC7C,QAAQ,EAAE,sBAAS,CAAC,KAAK,CAAC,QAAQ;SACnC,CAAA;QAED,OAAO,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,OAAO,CAAC;aAC/C,IAAI,CAAC,CAAO,EAAE,YAAY,EAAE,EAAE,EAAE;YAE/B,MAAM,OAAO,GAA4B;gBACvC,QAAQ,EAAE,sBAAS,CAAC,KAAK,CAAC,QAAQ;gBAClC,MAAM,EAAE,sBAAS,CAAC,KAAK,CAAC,MAAM;gBAC9B,QAAQ,EAAE,sBAAS,CAAC,KAAK,CAAC,MAAM;gBAChC,YAAY,EAAE,sBAAS,CAAC,KAAK,CAAC,MAAM;gBACpC,KAAK,EAAE,YAAY;aACpB,CAAA;YAED,IAAI,CAAC,WAAW,GAAG,IAAI,wBAAgB,CAAC,OAAO,CAAC,CAAA;QAClD,CAAC,CAAA,CAAC,CAAA;IACN,CAAC;IAEY,OAAO,CAAC,EAAsB;;YACzC,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;QACzC,CAAC;KAAA;IAEY,eAAe;;YAC1B,OAAO,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,sBAAS,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAA;QAChF,CAAC;KAAA;CACF,CAAA;AAnCY,cAAc;IAD1B,IAAA,mBAAU,GAAE;GACA,cAAc,CAmC1B;AAnCY,wCAAc"}
@@ -5,10 +5,10 @@ import { MediaEntity } from '../media/media.entity';
5
5
  import { VariantEntity } from '../variants/variant.entity';
6
6
  export declare class ProductEntity extends AppEntity {
7
7
  name: string;
8
- description?: string;
8
+ description: string;
9
9
  price: number;
10
- category?: CategoryEntity;
11
- brand?: BrandEntity;
10
+ category: CategoryEntity;
11
+ brand: BrandEntity;
12
12
  variants: VariantEntity[];
13
13
  media: MediaEntity[];
14
14
  }
@@ -1,8 +1,8 @@
1
1
  import { AppDocument } from '../../../config/app.document';
2
- import { ProductEntity } from '../../inventory/products/product.entity';
2
+ import { ProductDocument } from '../../inventory/products/product.document';
3
3
  import { ItemEntity } from './item.entity';
4
4
  export declare class ItemDocument extends AppDocument {
5
- product: Pick<ProductEntity, 'id' | 'name' | 'price'>;
5
+ product: Pick<ProductDocument, '$id' | 'name' | 'price'>;
6
6
  quantity: number;
7
7
  protected transform?(entity: ItemEntity): this;
8
8
  }
@@ -1,4 +1,5 @@
1
+ import { ProductDocument } from '../../inventory/products/product.document';
1
2
  export declare class CreateItemValidator {
2
- product?: string;
3
+ product: ProductDocument;
3
4
  quantity: number;
4
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@merkaly/api",
3
- "version": "0.2.2-1",
3
+ "version": "0.2.2-2",
4
4
  "description": "NestJS Backend ApiRest Service",
5
5
  "author": "Randy Tellez Galan <kronhyx@gmail.com>",
6
6
  "license": "UNLICENSED",