@merkaly/api 0.2.2-10 → 0.2.2-11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/.output/modules/auth/organizations/organization.controller.d.ts +16 -0
  2. package/.output/modules/auth/organizations/organization.controller.d.ts.map +1 -0
  3. package/.output/modules/auth/organizations/organization.controller.js +101 -0
  4. package/.output/modules/auth/organizations/organization.controller.js.map +1 -0
  5. package/.output/modules/auth/organizations/organization.module.d.ts +9 -0
  6. package/.output/modules/auth/organizations/organization.module.d.ts.map +1 -0
  7. package/.output/modules/auth/organizations/organization.module.js +24 -0
  8. package/.output/modules/auth/organizations/organization.module.js.map +1 -0
  9. package/.output/modules/auth/organizations/organization.repository.d.ts +9 -0
  10. package/.output/modules/auth/organizations/organization.repository.d.ts.map +1 -0
  11. package/.output/modules/auth/organizations/organization.repository.js +42 -0
  12. package/.output/modules/auth/organizations/organization.repository.js.map +1 -0
  13. package/.output/modules/auth/organizations/organization.validator.d.ts +1 -0
  14. package/.output/modules/auth/organizations/organization.validator.d.ts.map +1 -0
  15. package/.output/modules/auth/organizations/organization.validator.js +1 -12
  16. package/.output/modules/auth/organizations/organization.validator.js.map +1 -0
  17. package/.output/modules/settings/organization/organization.entity.d.ts +10 -0
  18. package/.output/modules/settings/organization/organization.entity.d.ts.map +1 -0
  19. package/.output/modules/settings/organization/organization.entity.js +11 -0
  20. package/.output/modules/settings/organization/organization.entity.js.map +1 -0
  21. package/.output/modules/settings/organization/organization.validator.d.ts +15 -0
  22. package/.output/modules/settings/organization/organization.validator.js +71 -0
  23. package/.output/modules/settings/organizations/organization.controller.d.ts +16 -0
  24. package/.output/modules/settings/organizations/organization.controller.d.ts.map +1 -0
  25. package/.output/modules/settings/organizations/organization.controller.js +101 -0
  26. package/.output/modules/settings/organizations/organization.controller.js.map +1 -0
  27. package/.output/modules/settings/organizations/organization.module.d.ts +9 -0
  28. package/.output/modules/settings/organizations/organization.module.d.ts.map +1 -0
  29. package/.output/modules/settings/organizations/organization.module.js +24 -0
  30. package/.output/modules/settings/organizations/organization.module.js.map +1 -0
  31. package/.output/modules/settings/organizations/organization.repository.d.ts +9 -0
  32. package/.output/modules/settings/organizations/organization.repository.d.ts.map +1 -0
  33. package/.output/modules/settings/organizations/organization.repository.js +42 -0
  34. package/.output/modules/settings/organizations/organization.repository.js.map +1 -0
  35. package/.output/modules/settings/organizations/organization.validator.d.ts +7 -0
  36. package/.output/modules/settings/organizations/organization.validator.d.ts.map +1 -0
  37. package/.output/modules/settings/organizations/organization.validator.js +22 -0
  38. package/.output/modules/settings/organizations/organization.validator.js.map +1 -0
  39. package/package.json +1 -1
@@ -0,0 +1,16 @@
1
+ import { Organization } from 'auth0';
2
+ import { Auth0Service } from '../../../services/auth0.service';
3
+ import { OrganizationRepository } from './organization.repository';
4
+ import { CreateOrganizationValidator } from './organization.validator';
5
+ export declare class OrganizationController {
6
+ protected readonly $auth0: Auth0Service;
7
+ protected readonly $repository: OrganizationRepository;
8
+ findAll(id: string): Promise<Organization[]>;
9
+ create(validator: CreateOrganizationValidator): Promise<Organization>;
10
+ validate(slug: string): Promise<{
11
+ name: string;
12
+ available: boolean;
13
+ }>;
14
+ current(id: string): Promise<Organization>;
15
+ }
16
+ //# sourceMappingURL=organization.controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.controller.d.ts","sourceRoot":"","sources":["../../../../src/modules/auth/organizations/organization.controller.ts"],"names":[],"mappings":"AAYA,OAAO,EAAwC,YAAY,EAAE,MAAM,OAAO,CAAC;AAI3E,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAEvE,qBAEa,sBAAsB;IACvB,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IACxC,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,sBAAsB,CAAC;IAGpD,OAAO,CAAiB,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAM5D,MAAM,CAAS,SAAS,EAAE,2BAA2B,GAAG,OAAO,CAAC,YAAY,CAAC;IAwB7E,QAAQ,CAAe,IAAI,EAAE,MAAM;;;;IAiBnC,OAAO,CAAoB,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;CAO3E"}
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrganizationController = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ const swagger_1 = require("@nestjs/swagger");
6
+ const organization_decorator_1 = require("../../../decorators/organization.decorator");
7
+ const public_decorator_1 = require("../../../decorators/public.decorator");
8
+ const user_decorator_1 = require("../../../decorators/user.decorator");
9
+ const auth0_service_1 = require("../../../services/auth0.service");
10
+ const organization_repository_1 = require("./organization.repository");
11
+ const organization_validator_1 = require("./organization.validator");
12
+ let OrganizationController = class OrganizationController {
13
+ findAll(id) {
14
+ return __awaiter(this, void 0, void 0, function* () {
15
+ return this.$repository.find(id);
16
+ });
17
+ }
18
+ create(validator) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ const organization = yield this.$repository.create(validator)
21
+ .catch(reason => {
22
+ throw new common_1.ConflictException(reason);
23
+ });
24
+ const { user_id } = yield this.$auth0.createUser({
25
+ email: validator.email,
26
+ password: validator.password,
27
+ connection: 'default',
28
+ });
29
+ const params = { id: organization.id };
30
+ const members = { members: [user_id] };
31
+ yield this.$auth0.organizations.addMembers(params, members);
32
+ return organization;
33
+ });
34
+ }
35
+ validate(slug) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ const result = yield this.$auth0.organizations.getByName({ name: slug })
38
+ .catch(() => ({}));
39
+ if ('id' in result) {
40
+ throw new common_1.ConflictException('Ja existe uma loja com esse nome');
41
+ }
42
+ return ({
43
+ name: slug,
44
+ available: true,
45
+ });
46
+ });
47
+ }
48
+ current(id) {
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ return this.$auth0.organizations.getByID({ id })
51
+ .catch(reason => {
52
+ throw new common_1.HttpException(`${reason.message}: [${id}]`, reason.statusCode);
53
+ });
54
+ });
55
+ }
56
+ };
57
+ __decorate([
58
+ (0, common_1.Inject)(),
59
+ __metadata("design:type", auth0_service_1.Auth0Service)
60
+ ], OrganizationController.prototype, "$auth0", void 0);
61
+ __decorate([
62
+ (0, common_1.Inject)(),
63
+ __metadata("design:type", organization_repository_1.OrganizationRepository)
64
+ ], OrganizationController.prototype, "$repository", void 0);
65
+ __decorate([
66
+ (0, common_1.Get)('/'),
67
+ __param(0, (0, user_decorator_1.GetUser)('sub')),
68
+ __metadata("design:type", Function),
69
+ __metadata("design:paramtypes", [String]),
70
+ __metadata("design:returntype", Promise)
71
+ ], OrganizationController.prototype, "findAll", null);
72
+ __decorate([
73
+ (0, common_1.Post)('/'),
74
+ __param(0, (0, common_1.Body)()),
75
+ __metadata("design:type", Function),
76
+ __metadata("design:paramtypes", [organization_validator_1.CreateOrganizationValidator]),
77
+ __metadata("design:returntype", Promise)
78
+ ], OrganizationController.prototype, "create", null);
79
+ __decorate([
80
+ (0, common_1.Post)('/validate'),
81
+ (0, public_decorator_1.Public)(),
82
+ (0, common_1.HttpCode)(common_1.HttpStatus.ACCEPTED),
83
+ __param(0, (0, common_1.Body)('slug')),
84
+ __metadata("design:type", Function),
85
+ __metadata("design:paramtypes", [String]),
86
+ __metadata("design:returntype", Promise)
87
+ ], OrganizationController.prototype, "validate", null);
88
+ __decorate([
89
+ (0, common_1.Get)('/current'),
90
+ (0, public_decorator_1.Public)(),
91
+ __param(0, (0, organization_decorator_1.GetOrganization)()),
92
+ __metadata("design:type", Function),
93
+ __metadata("design:paramtypes", [String]),
94
+ __metadata("design:returntype", Promise)
95
+ ], OrganizationController.prototype, "current", null);
96
+ OrganizationController = __decorate([
97
+ (0, common_1.Controller)(),
98
+ (0, swagger_1.ApiTags)('auth')
99
+ ], OrganizationController);
100
+ exports.OrganizationController = OrganizationController;
101
+ //# sourceMappingURL=organization.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.controller.js","sourceRoot":"","sources":["../../../../src/modules/auth/organizations/organization.controller.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,9 @@
1
+ import { ModuleMetadata } from '@nestjs/common';
2
+ import { AppRouter } from '../../../configs/app.router';
3
+ export declare const metadata: ModuleMetadata;
4
+ export declare class OrganizationModule extends AppRouter {
5
+ static readonly path = "/organizations";
6
+ static readonly module: typeof OrganizationModule;
7
+ static readonly children: any[];
8
+ }
9
+ //# sourceMappingURL=organization.module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.module.d.ts","sourceRoot":"","sources":["../../../../src/modules/auth/organizations/organization.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAIxD,eAAO,MAAM,QAAQ,EAAE,cAKtB,CAAC;AAEF,qBACa,kBAAmB,SAAQ,SAAS;IAC/C,gBAAuB,IAAI,oBAAoB;IAE/C,gBAAuB,MAAM,4BAAsB;IAEnD,gBAAuB,QAAQ,QAAM;CACtC"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var OrganizationModule_1;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.OrganizationModule = exports.metadata = void 0;
5
+ const common_1 = require("@nestjs/common");
6
+ const app_router_1 = require("../../../configs/app.router");
7
+ const organization_controller_1 = require("./organization.controller");
8
+ const organization_repository_1 = require("./organization.repository");
9
+ exports.metadata = {
10
+ imports: [],
11
+ controllers: [organization_controller_1.OrganizationController],
12
+ providers: [organization_repository_1.OrganizationRepository],
13
+ exports: [organization_repository_1.OrganizationRepository],
14
+ };
15
+ let OrganizationModule = OrganizationModule_1 = class OrganizationModule extends app_router_1.AppRouter {
16
+ };
17
+ OrganizationModule.path = '/organizations';
18
+ OrganizationModule.module = OrganizationModule_1;
19
+ OrganizationModule.children = [];
20
+ OrganizationModule = OrganizationModule_1 = __decorate([
21
+ (0, common_1.Module)(exports.metadata)
22
+ ], OrganizationModule);
23
+ exports.OrganizationModule = OrganizationModule;
24
+ //# sourceMappingURL=organization.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.module.js","sourceRoot":"","sources":["../../../../src/modules/auth/organizations/organization.module.ts"],"names":[],"mappings":";;;;AAAA,2CAAwD;AACxD,4DAAwD;AACxD,uEAAmE;AACnE,uEAAmE;AAEtD,QAAA,QAAQ,GAAmB;IACtC,OAAO,EAAE,EAAE;IACX,WAAW,EAAE,CAAC,gDAAsB,CAAC;IACrC,SAAS,EAAE,CAAC,gDAAsB,CAAC;IACnC,OAAO,EAAE,CAAC,gDAAsB,CAAC;CAClC,CAAC;AAGF,IAAa,kBAAkB,0BAA/B,MAAa,kBAAmB,SAAQ,sBAAS;CAMhD,CAAA;AALwB,uBAAI,GAAG,gBAAiB,CAAA;AAExB,yBAAM,GAAG,oBAAmB,CAAA;AAE5B,2BAAQ,GAAG,EAAG,CAAA;AAL1B,kBAAkB;IAD9B,IAAA,eAAM,EAAC,gBAAQ,CAAC;GACJ,kBAAkB,CAM9B;AANY,gDAAkB"}
@@ -0,0 +1,9 @@
1
+ import { Organization } from 'auth0';
2
+ import { Auth0Service } from '../../../services/auth0.service';
3
+ import { CreateOrganizationValidator } from './organization.validator';
4
+ export declare class OrganizationRepository {
5
+ protected readonly $auth0: Auth0Service;
6
+ find(userId: string): Promise<Organization[]>;
7
+ create(validator: CreateOrganizationValidator): Promise<Organization>;
8
+ }
9
+ //# sourceMappingURL=organization.repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.repository.d.ts","sourceRoot":"","sources":["../../../../src/modules/auth/organizations/organization.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,YAAY,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAEvE,qBACa,sBAAsB;IACvB,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAErC,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAI7C,MAAM,CAAC,SAAS,EAAE,2BAA2B,GAAG,OAAO,CAAC,YAAY,CAAC;CAyBnF"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrganizationRepository = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ const short_unique_id_1 = __importDefault(require("short-unique-id"));
6
+ const auth0_service_1 = require("../../../services/auth0.service");
7
+ let OrganizationRepository = class OrganizationRepository {
8
+ find(userId) {
9
+ return __awaiter(this, void 0, void 0, function* () {
10
+ return this.$auth0.users.getUserOrganizations({ id: userId });
11
+ });
12
+ }
13
+ create(validator) {
14
+ return __awaiter(this, void 0, void 0, function* () {
15
+ const uid = new short_unique_id_1.default({ length: 10 });
16
+ const createOrg = {
17
+ name: uid(),
18
+ display_name: validator.name,
19
+ };
20
+ const organization = yield this.$auth0.organizations.create(createOrg);
21
+ const allConnections = yield this.$auth0.getConnections()
22
+ .then(connections => connections.filter(({ name }) => name !== 'sms'));
23
+ const connectionsPromise = [];
24
+ for (const connection of allConnections) {
25
+ connectionsPromise.push(this.$auth0.organizations.addEnabledConnection({ id: organization.id }, {
26
+ connection_id: connection.id,
27
+ }));
28
+ }
29
+ return Promise.all(connectionsPromise)
30
+ .then(() => organization);
31
+ });
32
+ }
33
+ };
34
+ __decorate([
35
+ (0, common_1.Inject)(),
36
+ __metadata("design:type", auth0_service_1.Auth0Service)
37
+ ], OrganizationRepository.prototype, "$auth0", void 0);
38
+ OrganizationRepository = __decorate([
39
+ (0, common_1.Injectable)()
40
+ ], OrganizationRepository);
41
+ exports.OrganizationRepository = OrganizationRepository;
42
+ //# sourceMappingURL=organization.repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.repository.js","sourceRoot":"","sources":["../../../../src/modules/auth/organizations/organization.repository.ts"],"names":[],"mappings":";;;AAAA,2CAAoD;AAEpD,sEAA4C;AAC5C,mEAA+D;AAI/D,IAAa,sBAAsB,GAAnC,MAAa,sBAAsB;IAGpB,IAAI,CAAC,MAAc;;YAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;QAChE,CAAC;KAAA;IAEY,MAAM,CAAC,SAAsC;;YACxD,MAAM,GAAG,GAAG,IAAI,yBAAa,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;YAE9C,MAAM,SAAS,GAAuB;gBACpC,IAAI,EAAE,GAAG,EAAE;gBACX,YAAY,EAAE,SAAS,CAAC,IAAI;aAC7B,CAAC;YAEF,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAGvE,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE;iBACtD,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC;YAEzE,MAAM,kBAAkB,GAAG,EAAE,CAAC;YAE9B,KAAK,MAAM,UAAU,IAAI,cAAc,EAAE;gBACvC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,oBAAoB,CAAC,EAAE,EAAE,EAAE,YAAY,CAAC,EAAE,EAAE,EAAE;oBAC9F,aAAa,EAAE,UAAU,CAAC,EAAE;iBAC7B,CAAC,CAAC,CAAC;aACL;YAED,OAAO,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;iBACnC,IAAI,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC;QAC9B,CAAC;KAAA;CACF,CAAA;AA/BW;IAAT,IAAA,eAAM,GAAE;8BAA4B,4BAAY;sDAAC;AADvC,sBAAsB;IADlC,IAAA,mBAAU,GAAE;GACA,sBAAsB,CAgClC;AAhCY,wDAAsB"}
@@ -4,3 +4,4 @@ export declare class CreateOrganizationValidator implements CreateOrganization {
4
4
  email: string;
5
5
  password?: string;
6
6
  }
7
+ //# sourceMappingURL=organization.validator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.validator.d.ts","sourceRoot":"","sources":["../../../../src/modules/auth/organizations/organization.validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAG3C,qBAAa,2BAA4B,YAAW,kBAAkB;IAG7D,IAAI,EAAE,MAAM,CAAC;IAIb,KAAK,EAAE,MAAM,CAAC;IAGd,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC1B"}
@@ -1,20 +1,8 @@
1
1
  "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.CreateOrganizationValidator = void 0;
13
4
  const class_validator_1 = require("class-validator");
14
5
  class CreateOrganizationValidator {
15
- name;
16
- email;
17
- password;
18
6
  }
19
7
  __decorate([
20
8
  (0, class_validator_1.IsString)(),
@@ -31,3 +19,4 @@ __decorate([
31
19
  __metadata("design:type", String)
32
20
  ], CreateOrganizationValidator.prototype, "password", void 0);
33
21
  exports.CreateOrganizationValidator = CreateOrganizationValidator;
22
+ //# sourceMappingURL=organization.validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.validator.js","sourceRoot":"","sources":["../../../../src/modules/auth/organizations/organization.validator.ts"],"names":[],"mappings":";;;AACA,qDAA4D;AAE5D,MAAa,2BAA2B;CAWvC;AARC;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,wBAAM,EAAC,CAAC,EAAE,GAAG,CAAC;;yDACK;AAIpB;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,yBAAO,GAAE;;0DACW;AAGrB;IADC,IAAA,0BAAQ,GAAE;;6DACc;AAV3B,kEAWC"}
@@ -0,0 +1,10 @@
1
+ export declare class OrganizationEntity {
2
+ _id: string;
3
+ active: boolean;
4
+ description: string;
5
+ legalName: string;
6
+ name: string;
7
+ logoUrl: string;
8
+ address: string;
9
+ }
10
+ //# sourceMappingURL=organization.entity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.entity.d.ts","sourceRoot":"","sources":["../../../../src/modules/settings/organization/organization.entity.ts"],"names":[],"mappings":"AAAA,qBAAa,kBAAkB;IACtB,GAAG,SAAM;IAET,MAAM,UAAQ;IAEd,WAAW,EAAE,MAAM,CAAC;IAEpB,SAAS,EAAE,MAAM,CAAC;IAElB,IAAI,EAAE,MAAM,CAAC;IAEb,OAAO,EAAE,MAAM,CAAC;IAEhB,OAAO,EAAE,MAAM,CAAC;CACxB"}
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrganizationEntity = void 0;
4
+ class OrganizationEntity {
5
+ constructor() {
6
+ this._id = '';
7
+ this.active = true;
8
+ }
9
+ }
10
+ exports.OrganizationEntity = OrganizationEntity;
11
+ //# sourceMappingURL=organization.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.entity.js","sourceRoot":"","sources":["../../../../src/modules/settings/organization/organization.entity.ts"],"names":[],"mappings":";;;AAAA,MAAa,kBAAkB;IAA/B;QACS,QAAG,GAAG,EAAE,CAAC;QAET,WAAM,GAAG,IAAI,CAAC;IAWvB,CAAC;CAAA;AAdD,gDAcC"}
@@ -0,0 +1,15 @@
1
+ import { CreateOrganization, UpdateOrganization } from 'auth0';
2
+ export declare class OrganizationMetadataValidator {
3
+ address: string;
4
+ legalName: string;
5
+ industry: string;
6
+ }
7
+ export declare class CreateOrganizationValidator implements CreateOrganization {
8
+ name: string;
9
+ email: string;
10
+ password?: string;
11
+ }
12
+ export declare class UpdateOrganizationValidator implements UpdateOrganization {
13
+ display_name: string;
14
+ metadata: OrganizationMetadataValidator;
15
+ }
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.UpdateOrganizationValidator = exports.CreateOrganizationValidator = exports.OrganizationMetadataValidator = void 0;
13
+ const class_transformer_1 = require("class-transformer");
14
+ const class_validator_1 = require("class-validator");
15
+ class OrganizationMetadataValidator {
16
+ address;
17
+ legalName;
18
+ industry;
19
+ }
20
+ __decorate([
21
+ (0, class_validator_1.IsString)(),
22
+ (0, class_validator_1.IsOptional)(),
23
+ __metadata("design:type", String)
24
+ ], OrganizationMetadataValidator.prototype, "address", void 0);
25
+ __decorate([
26
+ (0, class_validator_1.IsString)(),
27
+ (0, class_validator_1.IsOptional)(),
28
+ __metadata("design:type", String)
29
+ ], OrganizationMetadataValidator.prototype, "legalName", void 0);
30
+ __decorate([
31
+ (0, class_validator_1.IsString)(),
32
+ (0, class_validator_1.IsOptional)(),
33
+ __metadata("design:type", String)
34
+ ], OrganizationMetadataValidator.prototype, "industry", void 0);
35
+ exports.OrganizationMetadataValidator = OrganizationMetadataValidator;
36
+ class CreateOrganizationValidator {
37
+ name;
38
+ email;
39
+ password;
40
+ }
41
+ __decorate([
42
+ (0, class_validator_1.IsString)(),
43
+ (0, class_validator_1.Length)(3, 255),
44
+ __metadata("design:type", String)
45
+ ], CreateOrganizationValidator.prototype, "name", void 0);
46
+ __decorate([
47
+ (0, class_validator_1.IsString)(),
48
+ (0, class_validator_1.IsEmail)(),
49
+ __metadata("design:type", String)
50
+ ], CreateOrganizationValidator.prototype, "email", void 0);
51
+ __decorate([
52
+ (0, class_validator_1.IsString)(),
53
+ __metadata("design:type", String)
54
+ ], CreateOrganizationValidator.prototype, "password", void 0);
55
+ exports.CreateOrganizationValidator = CreateOrganizationValidator;
56
+ class UpdateOrganizationValidator {
57
+ display_name;
58
+ metadata;
59
+ }
60
+ __decorate([
61
+ (0, class_validator_1.IsString)(),
62
+ (0, class_validator_1.IsOptional)(),
63
+ (0, class_validator_1.Length)(3, 255),
64
+ __metadata("design:type", String)
65
+ ], UpdateOrganizationValidator.prototype, "display_name", void 0);
66
+ __decorate([
67
+ (0, class_validator_1.ValidateNested)(),
68
+ (0, class_transformer_1.Type)(() => OrganizationMetadataValidator),
69
+ __metadata("design:type", OrganizationMetadataValidator)
70
+ ], UpdateOrganizationValidator.prototype, "metadata", void 0);
71
+ exports.UpdateOrganizationValidator = UpdateOrganizationValidator;
@@ -0,0 +1,16 @@
1
+ import { Organization } from 'auth0';
2
+ import { Auth0Service } from '../../../services/auth0.service';
3
+ import { OrganizationRepository } from './organization.repository';
4
+ import { CreateOrganizationValidator } from './organization.validator';
5
+ export declare class OrganizationController {
6
+ protected readonly $auth0: Auth0Service;
7
+ protected readonly $repository: OrganizationRepository;
8
+ findAll(id: string): Promise<Organization[]>;
9
+ create(validator: CreateOrganizationValidator): Promise<Organization>;
10
+ validate(slug: string): Promise<{
11
+ name: string;
12
+ available: boolean;
13
+ }>;
14
+ current(id: string): Promise<Organization>;
15
+ }
16
+ //# sourceMappingURL=organization.controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.controller.d.ts","sourceRoot":"","sources":["../../../../src/modules/settings/organizations/organization.controller.ts"],"names":[],"mappings":"AAYA,OAAO,EAAwC,YAAY,EAAE,MAAM,OAAO,CAAC;AAI3E,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAEvE,qBAEa,sBAAsB;IACvB,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IACxC,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,sBAAsB,CAAC;IAGpD,OAAO,CAAiB,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAM5D,MAAM,CAAS,SAAS,EAAE,2BAA2B,GAAG,OAAO,CAAC,YAAY,CAAC;IAwB7E,QAAQ,CAAe,IAAI,EAAE,MAAM;;;;IAiBnC,OAAO,CAAoB,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;CAO3E"}
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrganizationController = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ const swagger_1 = require("@nestjs/swagger");
6
+ const organization_decorator_1 = require("../../../decorators/organization.decorator");
7
+ const public_decorator_1 = require("../../../decorators/public.decorator");
8
+ const user_decorator_1 = require("../../../decorators/user.decorator");
9
+ const auth0_service_1 = require("../../../services/auth0.service");
10
+ const organization_repository_1 = require("./organization.repository");
11
+ const organization_validator_1 = require("./organization.validator");
12
+ let OrganizationController = class OrganizationController {
13
+ findAll(id) {
14
+ return __awaiter(this, void 0, void 0, function* () {
15
+ return this.$repository.find(id);
16
+ });
17
+ }
18
+ create(validator) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ const organization = yield this.$repository.create(validator)
21
+ .catch(reason => {
22
+ throw new common_1.ConflictException(reason);
23
+ });
24
+ const { user_id } = yield this.$auth0.createUser({
25
+ email: validator.email,
26
+ password: validator.password,
27
+ connection: 'default',
28
+ });
29
+ const params = { id: organization.id };
30
+ const members = { members: [user_id] };
31
+ yield this.$auth0.organizations.addMembers(params, members);
32
+ return organization;
33
+ });
34
+ }
35
+ validate(slug) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ const result = yield this.$auth0.organizations.getByName({ name: slug })
38
+ .catch(() => ({}));
39
+ if ('id' in result) {
40
+ throw new common_1.ConflictException('Ja existe uma loja com esse nome');
41
+ }
42
+ return ({
43
+ name: slug,
44
+ available: true,
45
+ });
46
+ });
47
+ }
48
+ current(id) {
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ return this.$auth0.organizations.getByID({ id })
51
+ .catch(reason => {
52
+ throw new common_1.HttpException(`${reason.message}: [${id}]`, reason.statusCode);
53
+ });
54
+ });
55
+ }
56
+ };
57
+ __decorate([
58
+ (0, common_1.Inject)(),
59
+ __metadata("design:type", auth0_service_1.Auth0Service)
60
+ ], OrganizationController.prototype, "$auth0", void 0);
61
+ __decorate([
62
+ (0, common_1.Inject)(),
63
+ __metadata("design:type", organization_repository_1.OrganizationRepository)
64
+ ], OrganizationController.prototype, "$repository", void 0);
65
+ __decorate([
66
+ (0, common_1.Get)('/'),
67
+ __param(0, (0, user_decorator_1.GetUser)('sub')),
68
+ __metadata("design:type", Function),
69
+ __metadata("design:paramtypes", [String]),
70
+ __metadata("design:returntype", Promise)
71
+ ], OrganizationController.prototype, "findAll", null);
72
+ __decorate([
73
+ (0, common_1.Post)('/'),
74
+ __param(0, (0, common_1.Body)()),
75
+ __metadata("design:type", Function),
76
+ __metadata("design:paramtypes", [organization_validator_1.CreateOrganizationValidator]),
77
+ __metadata("design:returntype", Promise)
78
+ ], OrganizationController.prototype, "create", null);
79
+ __decorate([
80
+ (0, common_1.Post)('/validate'),
81
+ (0, public_decorator_1.Public)(),
82
+ (0, common_1.HttpCode)(common_1.HttpStatus.ACCEPTED),
83
+ __param(0, (0, common_1.Body)('slug')),
84
+ __metadata("design:type", Function),
85
+ __metadata("design:paramtypes", [String]),
86
+ __metadata("design:returntype", Promise)
87
+ ], OrganizationController.prototype, "validate", null);
88
+ __decorate([
89
+ (0, common_1.Get)('/current'),
90
+ (0, public_decorator_1.Public)(),
91
+ __param(0, (0, organization_decorator_1.GetOrganization)()),
92
+ __metadata("design:type", Function),
93
+ __metadata("design:paramtypes", [String]),
94
+ __metadata("design:returntype", Promise)
95
+ ], OrganizationController.prototype, "current", null);
96
+ OrganizationController = __decorate([
97
+ (0, common_1.Controller)(),
98
+ (0, swagger_1.ApiTags)('auth')
99
+ ], OrganizationController);
100
+ exports.OrganizationController = OrganizationController;
101
+ //# sourceMappingURL=organization.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.controller.js","sourceRoot":"","sources":["../../../../src/modules/settings/organizations/organization.controller.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,9 @@
1
+ import { ModuleMetadata } from '@nestjs/common';
2
+ import { AppRouter } from '../../../configs/app.router';
3
+ export declare const metadata: ModuleMetadata;
4
+ export declare class OrganizationModule extends AppRouter {
5
+ static readonly path = "/organizations";
6
+ static readonly module: typeof OrganizationModule;
7
+ static readonly children: any[];
8
+ }
9
+ //# sourceMappingURL=organization.module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.module.d.ts","sourceRoot":"","sources":["../../../../src/modules/settings/organizations/organization.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAIxD,eAAO,MAAM,QAAQ,EAAE,cAKtB,CAAC;AAEF,qBACa,kBAAmB,SAAQ,SAAS;IAC/C,gBAAuB,IAAI,oBAAoB;IAE/C,gBAAuB,MAAM,4BAAsB;IAEnD,gBAAuB,QAAQ,QAAM;CACtC"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var OrganizationModule_1;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.OrganizationModule = exports.metadata = void 0;
5
+ const common_1 = require("@nestjs/common");
6
+ const app_router_1 = require("../../../configs/app.router");
7
+ const organization_controller_1 = require("./organization.controller");
8
+ const organization_repository_1 = require("./organization.repository");
9
+ exports.metadata = {
10
+ imports: [],
11
+ controllers: [organization_controller_1.OrganizationController],
12
+ providers: [organization_repository_1.OrganizationRepository],
13
+ exports: [organization_repository_1.OrganizationRepository],
14
+ };
15
+ let OrganizationModule = OrganizationModule_1 = class OrganizationModule extends app_router_1.AppRouter {
16
+ };
17
+ OrganizationModule.path = '/organizations';
18
+ OrganizationModule.module = OrganizationModule_1;
19
+ OrganizationModule.children = [];
20
+ OrganizationModule = OrganizationModule_1 = __decorate([
21
+ (0, common_1.Module)(exports.metadata)
22
+ ], OrganizationModule);
23
+ exports.OrganizationModule = OrganizationModule;
24
+ //# sourceMappingURL=organization.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.module.js","sourceRoot":"","sources":["../../../../src/modules/settings/organizations/organization.module.ts"],"names":[],"mappings":";;;;AAAA,2CAAwD;AACxD,4DAAwD;AACxD,uEAAmE;AACnE,uEAAmE;AAEtD,QAAA,QAAQ,GAAmB;IACtC,OAAO,EAAE,EAAE;IACX,WAAW,EAAE,CAAC,gDAAsB,CAAC;IACrC,SAAS,EAAE,CAAC,gDAAsB,CAAC;IACnC,OAAO,EAAE,CAAC,gDAAsB,CAAC;CAClC,CAAC;AAGF,IAAa,kBAAkB,0BAA/B,MAAa,kBAAmB,SAAQ,sBAAS;CAMhD,CAAA;AALwB,uBAAI,GAAG,gBAAiB,CAAA;AAExB,yBAAM,GAAG,oBAAmB,CAAA;AAE5B,2BAAQ,GAAG,EAAG,CAAA;AAL1B,kBAAkB;IAD9B,IAAA,eAAM,EAAC,gBAAQ,CAAC;GACJ,kBAAkB,CAM9B;AANY,gDAAkB"}
@@ -0,0 +1,9 @@
1
+ import { Organization } from 'auth0';
2
+ import { Auth0Service } from '../../../services/auth0.service';
3
+ import { CreateOrganizationValidator } from './organization.validator';
4
+ export declare class OrganizationRepository {
5
+ protected readonly $auth0: Auth0Service;
6
+ find(userId: string): Promise<Organization[]>;
7
+ create(validator: CreateOrganizationValidator): Promise<Organization>;
8
+ }
9
+ //# sourceMappingURL=organization.repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.repository.d.ts","sourceRoot":"","sources":["../../../../src/modules/settings/organizations/organization.repository.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,YAAY,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAEvE,qBACa,sBAAsB;IACvB,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAErC,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAI7C,MAAM,CAAC,SAAS,EAAE,2BAA2B,GAAG,OAAO,CAAC,YAAY,CAAC;CAyBnF"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrganizationRepository = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ const short_unique_id_1 = __importDefault(require("short-unique-id"));
6
+ const auth0_service_1 = require("../../../services/auth0.service");
7
+ let OrganizationRepository = class OrganizationRepository {
8
+ find(userId) {
9
+ return __awaiter(this, void 0, void 0, function* () {
10
+ return this.$auth0.users.getUserOrganizations({ id: userId });
11
+ });
12
+ }
13
+ create(validator) {
14
+ return __awaiter(this, void 0, void 0, function* () {
15
+ const uid = new short_unique_id_1.default({ length: 10 });
16
+ const createOrg = {
17
+ name: uid(),
18
+ display_name: validator.name,
19
+ };
20
+ const organization = yield this.$auth0.organizations.create(createOrg);
21
+ const allConnections = yield this.$auth0.getConnections()
22
+ .then(connections => connections.filter(({ name }) => name !== 'sms'));
23
+ const connectionsPromise = [];
24
+ for (const connection of allConnections) {
25
+ connectionsPromise.push(this.$auth0.organizations.addEnabledConnection({ id: organization.id }, {
26
+ connection_id: connection.id,
27
+ }));
28
+ }
29
+ return Promise.all(connectionsPromise)
30
+ .then(() => organization);
31
+ });
32
+ }
33
+ };
34
+ __decorate([
35
+ (0, common_1.Inject)(),
36
+ __metadata("design:type", auth0_service_1.Auth0Service)
37
+ ], OrganizationRepository.prototype, "$auth0", void 0);
38
+ OrganizationRepository = __decorate([
39
+ (0, common_1.Injectable)()
40
+ ], OrganizationRepository);
41
+ exports.OrganizationRepository = OrganizationRepository;
42
+ //# sourceMappingURL=organization.repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.repository.js","sourceRoot":"","sources":["../../../../src/modules/settings/organizations/organization.repository.ts"],"names":[],"mappings":";;;AAAA,2CAAoD;AAEpD,sEAA4C;AAC5C,mEAA+D;AAI/D,IAAa,sBAAsB,GAAnC,MAAa,sBAAsB;IAGpB,IAAI,CAAC,MAAc;;YAC9B,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;QAChE,CAAC;KAAA;IAEY,MAAM,CAAC,SAAsC;;YACxD,MAAM,GAAG,GAAG,IAAI,yBAAa,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;YAE9C,MAAM,SAAS,GAAuB;gBACpC,IAAI,EAAE,GAAG,EAAE;gBACX,YAAY,EAAE,SAAS,CAAC,IAAI;aAC7B,CAAC;YAEF,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;YAGvE,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE;iBACtD,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC;YAEzE,MAAM,kBAAkB,GAAG,EAAE,CAAC;YAE9B,KAAK,MAAM,UAAU,IAAI,cAAc,EAAE;gBACvC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,oBAAoB,CAAC,EAAE,EAAE,EAAE,YAAY,CAAC,EAAE,EAAE,EAAE;oBAC9F,aAAa,EAAE,UAAU,CAAC,EAAE;iBAC7B,CAAC,CAAC,CAAC;aACL;YAED,OAAO,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;iBACnC,IAAI,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC;QAC9B,CAAC;KAAA;CACF,CAAA;AA/BW;IAAT,IAAA,eAAM,GAAE;8BAA4B,4BAAY;sDAAC;AADvC,sBAAsB;IADlC,IAAA,mBAAU,GAAE;GACA,sBAAsB,CAgClC;AAhCY,wDAAsB"}
@@ -0,0 +1,7 @@
1
+ import { CreateOrganization } from 'auth0';
2
+ export declare class CreateOrganizationValidator implements CreateOrganization {
3
+ name: string;
4
+ email: string;
5
+ password?: string;
6
+ }
7
+ //# sourceMappingURL=organization.validator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.validator.d.ts","sourceRoot":"","sources":["../../../../src/modules/settings/organizations/organization.validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAG3C,qBAAa,2BAA4B,YAAW,kBAAkB;IAG7D,IAAI,EAAE,MAAM,CAAC;IAIb,KAAK,EAAE,MAAM,CAAC;IAGd,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC1B"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreateOrganizationValidator = void 0;
4
+ const class_validator_1 = require("class-validator");
5
+ class CreateOrganizationValidator {
6
+ }
7
+ __decorate([
8
+ (0, class_validator_1.IsString)(),
9
+ (0, class_validator_1.Length)(3, 255),
10
+ __metadata("design:type", String)
11
+ ], CreateOrganizationValidator.prototype, "name", void 0);
12
+ __decorate([
13
+ (0, class_validator_1.IsString)(),
14
+ (0, class_validator_1.IsEmail)(),
15
+ __metadata("design:type", String)
16
+ ], CreateOrganizationValidator.prototype, "email", void 0);
17
+ __decorate([
18
+ (0, class_validator_1.IsString)(),
19
+ __metadata("design:type", String)
20
+ ], CreateOrganizationValidator.prototype, "password", void 0);
21
+ exports.CreateOrganizationValidator = CreateOrganizationValidator;
22
+ //# sourceMappingURL=organization.validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organization.validator.js","sourceRoot":"","sources":["../../../../src/modules/settings/organizations/organization.validator.ts"],"names":[],"mappings":";;;AACA,qDAA4D;AAE5D,MAAa,2BAA2B;CAWvC;AARC;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,wBAAM,EAAC,CAAC,EAAE,GAAG,CAAC;;yDACK;AAIpB;IAFC,IAAA,0BAAQ,GAAE;IACV,IAAA,yBAAO,GAAE;;0DACW;AAGrB;IADC,IAAA,0BAAQ,GAAE;;6DACc;AAV3B,kEAWC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@merkaly/api",
3
- "version": "0.2.2-10",
3
+ "version": "0.2.2-11",
4
4
  "description": "NestJS Backend ApiRest Service",
5
5
  "repository": {
6
6
  "type": "git",