@merkaly/api 0.2.2-11 → 0.2.2-13

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 (69) hide show
  1. package/.output/{configs/app.entity.d.ts → abstract/abstract.entity.d.ts} +3 -3
  2. package/.output/{configs/app.entity.js → abstract/abstract.entity.js} +10 -10
  3. package/.output/abstract/abstract.validator.d.ts +9 -0
  4. package/.output/abstract/abstract.validator.js +41 -0
  5. package/.output/modules/assets/asset.entity.d.ts +2 -2
  6. package/.output/modules/assets/asset.entity.js +2 -2
  7. package/.output/modules/inventory/brands/brand.entity.d.ts +2 -2
  8. package/.output/modules/inventory/brands/brand.entity.js +2 -2
  9. package/.output/modules/inventory/categories/category.entity.d.ts +5 -2
  10. package/.output/modules/inventory/categories/category.entity.js +13 -2
  11. package/.output/modules/inventory/categories/category.validator.d.ts +2 -0
  12. package/.output/modules/inventory/categories/category.validator.js +12 -0
  13. package/.output/modules/inventory/products/product.entity.d.ts +2 -2
  14. package/.output/modules/inventory/products/product.entity.js +2 -2
  15. package/.output/modules/inventory/properties/property.entity.d.ts +7 -0
  16. package/.output/modules/inventory/properties/property.entity.js +38 -0
  17. package/.output/modules/inventory/properties/property.validator.d.ts +12 -0
  18. package/.output/modules/inventory/properties/property.validator.js +50 -0
  19. package/.output/modules/{auth → settings}/connections/connection.validator.d.ts +0 -0
  20. package/.output/modules/{auth → settings}/connections/connection.validator.js +0 -0
  21. package/.output/modules/{auth → settings}/members/member.validator.d.ts +0 -0
  22. package/.output/modules/{auth → settings}/members/member.validator.js +0 -0
  23. package/.output/modules/settings/organization/organization.validator.d.ts +1 -1
  24. package/.output/modules/settings/organization/organization.validator.js +2 -2
  25. package/.output/modules/settings/payments/payment.entity.d.ts +2 -2
  26. package/.output/modules/settings/payments/payment.entity.js +2 -2
  27. package/.output/modules/store/cart/cart.entity.d.ts +2 -2
  28. package/.output/modules/store/cart/cart.entity.js +2 -2
  29. package/.output/modules/store/orders/item/item.entity.d.ts +2 -2
  30. package/.output/modules/store/orders/item/item.entity.js +2 -2
  31. package/.output/modules/store/orders/order.entity.d.ts +2 -2
  32. package/.output/modules/store/orders/order.entity.js +2 -2
  33. package/package.json +7 -3
  34. package/.output/modules/auth/organizations/organization.controller.d.ts +0 -16
  35. package/.output/modules/auth/organizations/organization.controller.d.ts.map +0 -1
  36. package/.output/modules/auth/organizations/organization.controller.js +0 -101
  37. package/.output/modules/auth/organizations/organization.controller.js.map +0 -1
  38. package/.output/modules/auth/organizations/organization.module.d.ts +0 -9
  39. package/.output/modules/auth/organizations/organization.module.d.ts.map +0 -1
  40. package/.output/modules/auth/organizations/organization.module.js +0 -24
  41. package/.output/modules/auth/organizations/organization.module.js.map +0 -1
  42. package/.output/modules/auth/organizations/organization.repository.d.ts +0 -9
  43. package/.output/modules/auth/organizations/organization.repository.d.ts.map +0 -1
  44. package/.output/modules/auth/organizations/organization.repository.js +0 -42
  45. package/.output/modules/auth/organizations/organization.repository.js.map +0 -1
  46. package/.output/modules/auth/organizations/organization.validator.d.ts +0 -7
  47. package/.output/modules/auth/organizations/organization.validator.d.ts.map +0 -1
  48. package/.output/modules/auth/organizations/organization.validator.js +0 -22
  49. package/.output/modules/auth/organizations/organization.validator.js.map +0 -1
  50. package/.output/modules/settings/organization/organization.entity.d.ts +0 -10
  51. package/.output/modules/settings/organization/organization.entity.d.ts.map +0 -1
  52. package/.output/modules/settings/organization/organization.entity.js +0 -11
  53. package/.output/modules/settings/organization/organization.entity.js.map +0 -1
  54. package/.output/modules/settings/organizations/organization.controller.d.ts +0 -16
  55. package/.output/modules/settings/organizations/organization.controller.d.ts.map +0 -1
  56. package/.output/modules/settings/organizations/organization.controller.js +0 -101
  57. package/.output/modules/settings/organizations/organization.controller.js.map +0 -1
  58. package/.output/modules/settings/organizations/organization.module.d.ts +0 -9
  59. package/.output/modules/settings/organizations/organization.module.d.ts.map +0 -1
  60. package/.output/modules/settings/organizations/organization.module.js +0 -24
  61. package/.output/modules/settings/organizations/organization.module.js.map +0 -1
  62. package/.output/modules/settings/organizations/organization.repository.d.ts +0 -9
  63. package/.output/modules/settings/organizations/organization.repository.d.ts.map +0 -1
  64. package/.output/modules/settings/organizations/organization.repository.js +0 -42
  65. package/.output/modules/settings/organizations/organization.repository.js.map +0 -1
  66. package/.output/modules/settings/organizations/organization.validator.d.ts +0 -7
  67. package/.output/modules/settings/organizations/organization.validator.d.ts.map +0 -1
  68. package/.output/modules/settings/organizations/organization.validator.js +0 -22
  69. package/.output/modules/settings/organizations/organization.validator.js.map +0 -1
@@ -1,8 +1,8 @@
1
1
  import { Document } from 'mongoose';
2
- export declare abstract class AppEntity extends Document {
2
+ export declare abstract class AbstractEntity extends Document {
3
3
  static $index: string;
4
- readonly _id = "";
5
- readonly createdAt: Date;
4
+ readonly _id: string;
5
+ readonly createdAt?: Date;
6
6
  readonly updatedAt?: Date;
7
7
  readonly deletedAt?: Date;
8
8
  }
@@ -9,26 +9,26 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.AppEntity = void 0;
12
+ exports.AbstractEntity = void 0;
13
13
  const mongoose_1 = require("@nestjs/mongoose");
14
14
  const mongoose_2 = require("mongoose");
15
- class AppEntity extends mongoose_2.Document {
15
+ class AbstractEntity extends mongoose_2.Document {
16
16
  static $index;
17
- _id = '';
18
- createdAt = new Date();
17
+ _id = String();
18
+ createdAt = null;
19
19
  updatedAt = null;
20
20
  deletedAt = null;
21
21
  }
22
22
  __decorate([
23
- (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.Date, default: new Date() }),
24
- __metadata("design:type", Object)
25
- ], AppEntity.prototype, "createdAt", void 0);
23
+ (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.Date }),
24
+ __metadata("design:type", Date)
25
+ ], AbstractEntity.prototype, "createdAt", void 0);
26
26
  __decorate([
27
27
  (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.Date }),
28
28
  __metadata("design:type", Date)
29
- ], AppEntity.prototype, "updatedAt", void 0);
29
+ ], AbstractEntity.prototype, "updatedAt", void 0);
30
30
  __decorate([
31
31
  (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.Date }),
32
32
  __metadata("design:type", Date)
33
- ], AppEntity.prototype, "deletedAt", void 0);
34
- exports.AppEntity = AppEntity;
33
+ ], AbstractEntity.prototype, "deletedAt", void 0);
34
+ exports.AbstractEntity = AbstractEntity;
@@ -0,0 +1,9 @@
1
+ import { PopulateOptions, QuerySelector } from 'mongoose';
2
+ export declare class FindValidator {
3
+ limit?: number;
4
+ sort?: {};
5
+ filters?: {
6
+ [x: string]: string | QuerySelector<any>;
7
+ };
8
+ join?: (string | PopulateOptions)[];
9
+ }
@@ -0,0 +1,41 @@
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.FindValidator = void 0;
13
+ const class_transformer_1 = require("class-transformer");
14
+ const class_validator_1 = require("class-validator");
15
+ class FindValidator {
16
+ limit = 10;
17
+ sort = {};
18
+ filters = {};
19
+ join = [];
20
+ }
21
+ __decorate([
22
+ (0, class_transformer_1.Transform)(({ value }) => value ? Number(value) : 10),
23
+ (0, class_validator_1.IsInt)(),
24
+ (0, class_validator_1.IsOptional)(),
25
+ __metadata("design:type", Object)
26
+ ], FindValidator.prototype, "limit", void 0);
27
+ __decorate([
28
+ (0, class_transformer_1.Transform)(({ value }) => value && JSON.parse(value)),
29
+ (0, class_validator_1.IsOptional)(),
30
+ __metadata("design:type", Object)
31
+ ], FindValidator.prototype, "sort", void 0);
32
+ __decorate([
33
+ (0, class_transformer_1.Transform)(({ value }) => value && JSON.parse(value)),
34
+ (0, class_validator_1.IsOptional)(),
35
+ __metadata("design:type", Object)
36
+ ], FindValidator.prototype, "filters", void 0);
37
+ __decorate([
38
+ (0, class_validator_1.IsOptional)(),
39
+ __metadata("design:type", Array)
40
+ ], FindValidator.prototype, "join", void 0);
41
+ exports.FindValidator = FindValidator;
@@ -1,5 +1,5 @@
1
- import { AppEntity } from '../../configs/app.entity';
2
- export declare class AssetEntity extends AppEntity {
1
+ import { AbstractEntity } from '../../abstract/abstract.entity';
2
+ export declare class AssetEntity extends AbstractEntity {
3
3
  static readonly $index = "assets";
4
4
  name: string;
5
5
  url: string;
@@ -12,8 +12,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.AssetEntity = void 0;
13
13
  const mongoose_1 = require("@nestjs/mongoose");
14
14
  const mongoose_2 = require("mongoose");
15
- const app_entity_1 = require("../../configs/app.entity");
16
- let AssetEntity = class AssetEntity extends app_entity_1.AppEntity {
15
+ const abstract_entity_1 = require("../../abstract/abstract.entity");
16
+ let AssetEntity = class AssetEntity extends abstract_entity_1.AbstractEntity {
17
17
  static $index = 'assets';
18
18
  name;
19
19
  url;
@@ -1,5 +1,5 @@
1
- import { AppEntity } from '../../../configs/app.entity';
2
- export declare class BrandEntity extends AppEntity {
1
+ import { AbstractEntity } from '../../../abstract/abstract.entity';
2
+ export declare class BrandEntity extends AbstractEntity {
3
3
  static readonly $index = "inventory_brands";
4
4
  name: string;
5
5
  description: string;
@@ -12,8 +12,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.BrandEntity = void 0;
13
13
  const mongoose_1 = require("@nestjs/mongoose");
14
14
  const mongoose_2 = require("mongoose");
15
- const app_entity_1 = require("../../../configs/app.entity");
16
- let BrandEntity = class BrandEntity extends app_entity_1.AppEntity {
15
+ const abstract_entity_1 = require("../../../abstract/abstract.entity");
16
+ let BrandEntity = class BrandEntity extends abstract_entity_1.AbstractEntity {
17
17
  static $index = 'inventory_brands';
18
18
  name;
19
19
  description;
@@ -1,6 +1,9 @@
1
- import { AppEntity } from '../../../configs/app.entity';
2
- export declare class CategoryEntity extends AppEntity {
1
+ import { AbstractEntity } from '../../../abstract/abstract.entity';
2
+ import { PropertyEntity } from '../properties/property.entity';
3
+ export declare class CategoryEntity extends AbstractEntity {
3
4
  static readonly $index = "inventory_categories";
4
5
  name: string;
5
6
  description: string;
7
+ icon: string;
8
+ properties: PropertyEntity[];
6
9
  }
@@ -12,11 +12,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.CategoryEntity = void 0;
13
13
  const mongoose_1 = require("@nestjs/mongoose");
14
14
  const mongoose_2 = require("mongoose");
15
- const app_entity_1 = require("../../../configs/app.entity");
16
- let CategoryEntity = class CategoryEntity extends app_entity_1.AppEntity {
15
+ const abstract_entity_1 = require("../../../abstract/abstract.entity");
16
+ const property_entity_1 = require("../properties/property.entity");
17
+ let CategoryEntity = class CategoryEntity extends abstract_entity_1.AbstractEntity {
17
18
  static $index = 'inventory_categories';
18
19
  name;
19
20
  description;
21
+ icon;
22
+ properties = [];
20
23
  };
21
24
  __decorate([
22
25
  (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.String, length: 32, unique: true, required: true }),
@@ -26,6 +29,14 @@ __decorate([
26
29
  (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.String }),
27
30
  __metadata("design:type", String)
28
31
  ], CategoryEntity.prototype, "description", void 0);
32
+ __decorate([
33
+ (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.String, length: 32, default: 'tag' }),
34
+ __metadata("design:type", String)
35
+ ], CategoryEntity.prototype, "icon", void 0);
36
+ __decorate([
37
+ (0, mongoose_1.Prop)({ type: [{ type: mongoose_2.Types.ObjectId, ref: property_entity_1.PropertyEntity.$index }] }),
38
+ __metadata("design:type", Array)
39
+ ], CategoryEntity.prototype, "properties", void 0);
29
40
  CategoryEntity = __decorate([
30
41
  (0, mongoose_1.Schema)({ timestamps: true })
31
42
  ], CategoryEntity);
@@ -1,8 +1,10 @@
1
1
  export declare class CreateCategoryValidator {
2
2
  name: string;
3
3
  description?: string;
4
+ icon: string;
4
5
  }
5
6
  export declare class UpdateCategoryValidator {
6
7
  name: string;
7
8
  description?: string;
9
+ icon: string;
8
10
  }
@@ -14,6 +14,7 @@ const class_validator_1 = require("class-validator");
14
14
  class CreateCategoryValidator {
15
15
  name;
16
16
  description;
17
+ icon = 'tag';
17
18
  }
18
19
  __decorate([
19
20
  (0, class_validator_1.IsString)(),
@@ -25,10 +26,16 @@ __decorate([
25
26
  (0, class_validator_1.IsOptional)(),
26
27
  __metadata("design:type", String)
27
28
  ], CreateCategoryValidator.prototype, "description", void 0);
29
+ __decorate([
30
+ (0, class_validator_1.IsString)(),
31
+ (0, class_validator_1.IsOptional)(),
32
+ __metadata("design:type", Object)
33
+ ], CreateCategoryValidator.prototype, "icon", void 0);
28
34
  exports.CreateCategoryValidator = CreateCategoryValidator;
29
35
  class UpdateCategoryValidator {
30
36
  name;
31
37
  description;
38
+ icon = 'tag';
32
39
  }
33
40
  __decorate([
34
41
  (0, class_validator_1.IsString)(),
@@ -40,4 +47,9 @@ __decorate([
40
47
  (0, class_validator_1.IsOptional)(),
41
48
  __metadata("design:type", String)
42
49
  ], UpdateCategoryValidator.prototype, "description", void 0);
50
+ __decorate([
51
+ (0, class_validator_1.IsString)(),
52
+ (0, class_validator_1.IsOptional)(),
53
+ __metadata("design:type", Object)
54
+ ], UpdateCategoryValidator.prototype, "icon", void 0);
43
55
  exports.UpdateCategoryValidator = UpdateCategoryValidator;
@@ -1,8 +1,8 @@
1
- import { AppEntity } from '../../../configs/app.entity';
1
+ import { AbstractEntity } from '../../../abstract/abstract.entity';
2
2
  import { AssetEntity } from '../../assets/asset.entity';
3
3
  import { BrandEntity } from '../brands/brand.entity';
4
4
  import { CategoryEntity } from '../categories/category.entity';
5
- export declare class ProductEntity extends AppEntity {
5
+ export declare class ProductEntity extends AbstractEntity {
6
6
  static readonly $index = "inventory_products";
7
7
  name: string;
8
8
  description: string;
@@ -12,11 +12,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ProductEntity = void 0;
13
13
  const mongoose_1 = require("@nestjs/mongoose");
14
14
  const mongoose_2 = require("mongoose");
15
- const app_entity_1 = require("../../../configs/app.entity");
15
+ const abstract_entity_1 = require("../../../abstract/abstract.entity");
16
16
  const asset_entity_1 = require("../../assets/asset.entity");
17
17
  const brand_entity_1 = require("../brands/brand.entity");
18
18
  const category_entity_1 = require("../categories/category.entity");
19
- let ProductEntity = class ProductEntity extends app_entity_1.AppEntity {
19
+ let ProductEntity = class ProductEntity extends abstract_entity_1.AbstractEntity {
20
20
  static $index = 'inventory_products';
21
21
  name;
22
22
  description;
@@ -0,0 +1,7 @@
1
+ import { AbstractEntity } from '../../../abstract/abstract.entity';
2
+ export declare class PropertyEntity extends AbstractEntity {
3
+ static readonly $index = "inventory_properties";
4
+ name: string;
5
+ title: string;
6
+ type: string;
7
+ }
@@ -0,0 +1,38 @@
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.PropertyEntity = void 0;
13
+ const mongoose_1 = require("@nestjs/mongoose");
14
+ const mongoose_2 = require("mongoose");
15
+ const abstract_entity_1 = require("../../../abstract/abstract.entity");
16
+ const property_validator_1 = require("./property.validator");
17
+ let PropertyEntity = class PropertyEntity extends abstract_entity_1.AbstractEntity {
18
+ static $index = 'inventory_properties';
19
+ name;
20
+ title;
21
+ type;
22
+ };
23
+ __decorate([
24
+ (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.String, required: true, unique: true, length: 32 }),
25
+ __metadata("design:type", String)
26
+ ], PropertyEntity.prototype, "name", void 0);
27
+ __decorate([
28
+ (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.String, required: true, length: 64 }),
29
+ __metadata("design:type", String)
30
+ ], PropertyEntity.prototype, "title", void 0);
31
+ __decorate([
32
+ (0, mongoose_1.Prop)({ type: mongoose_2.Schema.Types.String, default: property_validator_1.PropertyType.STRING }),
33
+ __metadata("design:type", String)
34
+ ], PropertyEntity.prototype, "type", void 0);
35
+ PropertyEntity = __decorate([
36
+ (0, mongoose_1.Schema)({ timestamps: true })
37
+ ], PropertyEntity);
38
+ exports.PropertyEntity = PropertyEntity;
@@ -0,0 +1,12 @@
1
+ export declare enum PropertyType {
2
+ STRING = "STRING"
3
+ }
4
+ export declare class CreatePropertyValidator {
5
+ name: string;
6
+ title: string;
7
+ type: string;
8
+ }
9
+ export declare class UpdatePropertyValidator {
10
+ name?: string;
11
+ title?: string;
12
+ }
@@ -0,0 +1,50 @@
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.UpdatePropertyValidator = exports.CreatePropertyValidator = exports.PropertyType = void 0;
13
+ const class_validator_1 = require("class-validator");
14
+ var PropertyType;
15
+ (function (PropertyType) {
16
+ PropertyType["STRING"] = "STRING";
17
+ })(PropertyType = exports.PropertyType || (exports.PropertyType = {}));
18
+ class CreatePropertyValidator {
19
+ name;
20
+ title;
21
+ type;
22
+ }
23
+ __decorate([
24
+ (0, class_validator_1.IsString)(),
25
+ __metadata("design:type", String)
26
+ ], CreatePropertyValidator.prototype, "name", void 0);
27
+ __decorate([
28
+ (0, class_validator_1.IsString)(),
29
+ __metadata("design:type", String)
30
+ ], CreatePropertyValidator.prototype, "title", void 0);
31
+ __decorate([
32
+ (0, class_validator_1.IsString)(),
33
+ __metadata("design:type", String)
34
+ ], CreatePropertyValidator.prototype, "type", void 0);
35
+ exports.CreatePropertyValidator = CreatePropertyValidator;
36
+ class UpdatePropertyValidator {
37
+ name;
38
+ title;
39
+ }
40
+ __decorate([
41
+ (0, class_validator_1.IsString)(),
42
+ (0, class_validator_1.IsOptional)(),
43
+ __metadata("design:type", String)
44
+ ], UpdatePropertyValidator.prototype, "name", void 0);
45
+ __decorate([
46
+ (0, class_validator_1.IsString)(),
47
+ (0, class_validator_1.IsOptional)(),
48
+ __metadata("design:type", String)
49
+ ], UpdatePropertyValidator.prototype, "title", void 0);
50
+ exports.UpdatePropertyValidator = UpdatePropertyValidator;
@@ -1,7 +1,7 @@
1
1
  import { CreateOrganization, UpdateOrganization } from 'auth0';
2
2
  export declare class OrganizationMetadataValidator {
3
3
  address: string;
4
- legalName: string;
4
+ publicName: string;
5
5
  industry: string;
6
6
  }
7
7
  export declare class CreateOrganizationValidator implements CreateOrganization {
@@ -14,7 +14,7 @@ const class_transformer_1 = require("class-transformer");
14
14
  const class_validator_1 = require("class-validator");
15
15
  class OrganizationMetadataValidator {
16
16
  address;
17
- legalName;
17
+ publicName;
18
18
  industry;
19
19
  }
20
20
  __decorate([
@@ -26,7 +26,7 @@ __decorate([
26
26
  (0, class_validator_1.IsString)(),
27
27
  (0, class_validator_1.IsOptional)(),
28
28
  __metadata("design:type", String)
29
- ], OrganizationMetadataValidator.prototype, "legalName", void 0);
29
+ ], OrganizationMetadataValidator.prototype, "publicName", void 0);
30
30
  __decorate([
31
31
  (0, class_validator_1.IsString)(),
32
32
  (0, class_validator_1.IsOptional)(),
@@ -1,6 +1,6 @@
1
- import { AppEntity } from '../../../configs/app.entity';
1
+ import { AbstractEntity } from '../../../abstract/abstract.entity';
2
2
  import { PaymentType } from './payment.validator';
3
- export declare class PaymentEntity extends AppEntity {
3
+ export declare class PaymentEntity extends AbstractEntity {
4
4
  static readonly $index = "settings_payments";
5
5
  name: PaymentType;
6
6
  active: boolean;
@@ -12,9 +12,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.PaymentEntity = void 0;
13
13
  const mongoose_1 = require("@nestjs/mongoose");
14
14
  const mongoose_2 = require("mongoose");
15
- const app_entity_1 = require("../../../configs/app.entity");
15
+ const abstract_entity_1 = require("../../../abstract/abstract.entity");
16
16
  const payment_validator_1 = require("./payment.validator");
17
- let PaymentEntity = class PaymentEntity extends app_entity_1.AppEntity {
17
+ let PaymentEntity = class PaymentEntity extends abstract_entity_1.AbstractEntity {
18
18
  static $index = 'settings_payments';
19
19
  name;
20
20
  active = true;
@@ -1,7 +1,7 @@
1
- import { AppEntity } from '../../../configs/app.entity';
1
+ import { AbstractEntity } from '../../../abstract/abstract.entity';
2
2
  import { ItemEntity } from '../orders/item/item.entity';
3
3
  import { CartStatus } from './cart.validator';
4
- export declare class CartEntity extends AppEntity {
4
+ export declare class CartEntity extends AbstractEntity {
5
5
  static readonly $index = "store_carts";
6
6
  user: string;
7
7
  status: CartStatus;
@@ -12,10 +12,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.CartEntity = void 0;
13
13
  const mongoose_1 = require("@nestjs/mongoose");
14
14
  const mongoose_2 = require("mongoose");
15
- const app_entity_1 = require("../../../configs/app.entity");
15
+ const abstract_entity_1 = require("../../../abstract/abstract.entity");
16
16
  const item_schema_1 = require("../orders/item/item.schema");
17
17
  const cart_validator_1 = require("./cart.validator");
18
- let CartEntity = class CartEntity extends app_entity_1.AppEntity {
18
+ let CartEntity = class CartEntity extends abstract_entity_1.AbstractEntity {
19
19
  static $index = 'store_carts';
20
20
  user;
21
21
  status = cart_validator_1.CartStatus.EMPTY;
@@ -1,6 +1,6 @@
1
- import { AppEntity } from '../../../../configs/app.entity';
1
+ import { AbstractEntity } from '../../../../abstract/abstract.entity';
2
2
  import { ProductEntity } from '../../../inventory/products/product.entity';
3
- export declare class ItemEntity extends AppEntity {
3
+ export declare class ItemEntity extends AbstractEntity {
4
4
  quantity: number;
5
5
  price: number;
6
6
  product: ProductEntity;
@@ -12,9 +12,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ItemEntity = void 0;
13
13
  const mongoose_1 = require("@nestjs/mongoose");
14
14
  const mongoose_2 = require("mongoose");
15
- const app_entity_1 = require("../../../../configs/app.entity");
15
+ const abstract_entity_1 = require("../../../../abstract/abstract.entity");
16
16
  const product_entity_1 = require("../../../inventory/products/product.entity");
17
- let ItemEntity = class ItemEntity extends app_entity_1.AppEntity {
17
+ let ItemEntity = class ItemEntity extends abstract_entity_1.AbstractEntity {
18
18
  quantity;
19
19
  price;
20
20
  product;
@@ -1,10 +1,10 @@
1
- import { AppEntity } from '../../../configs/app.entity';
1
+ import { AbstractEntity } from '../../../abstract/abstract.entity';
2
2
  import { PaymentEntity } from '../../settings/payments/payment.entity';
3
3
  import { BillingEntity } from './billing/billing.entity';
4
4
  import { ItemEntity } from './item/item.entity';
5
5
  import { ShippingEntity } from './shipping/shipping.entity';
6
6
  import { StatusEntity } from './status/status.entity';
7
- export declare class OrderEntity extends AppEntity {
7
+ export declare class OrderEntity extends AbstractEntity {
8
8
  static readonly $index = "store_orders";
9
9
  number: string;
10
10
  status: StatusEntity[];
@@ -12,12 +12,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.OrderEntity = void 0;
13
13
  const mongoose_1 = require("@nestjs/mongoose");
14
14
  const mongoose_2 = require("mongoose");
15
- const app_entity_1 = require("../../../configs/app.entity");
15
+ const abstract_entity_1 = require("../../../abstract/abstract.entity");
16
16
  const payment_entity_1 = require("../../settings/payments/payment.entity");
17
17
  const billing_entity_1 = require("./billing/billing.entity");
18
18
  const item_schema_1 = require("./item/item.schema");
19
19
  const shipping_entity_1 = require("./shipping/shipping.entity");
20
- let OrderEntity = class OrderEntity extends app_entity_1.AppEntity {
20
+ let OrderEntity = class OrderEntity extends abstract_entity_1.AbstractEntity {
21
21
  static $index = 'store_orders';
22
22
  number;
23
23
  status = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@merkaly/api",
3
- "version": "0.2.2-11",
3
+ "version": "0.2.2-13",
4
4
  "description": "NestJS Backend ApiRest Service",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,7 +19,7 @@
19
19
  "clean": "tsc -b --clean",
20
20
  "console": "ts-node -r tsconfig-paths/register ./src/console.ts",
21
21
  "dev": "yarn start --watch",
22
- "lint": "eslint \"{src,a}/**/*.ts\" . ",
22
+ "lint": "eslint \"{src,test}/**/*.ts\" . ",
23
23
  "prepack": ".bin/package.sh",
24
24
  "postpack": "yarn run clean",
25
25
  "semantic-release": "yarn run build:package && semantic-release",
@@ -31,9 +31,12 @@
31
31
  "test:watch": "yarn test -- --watch"
32
32
  },
33
33
  "dependencies": {
34
+ "@nestjs/axios": "^0.1.0",
35
+ "@nestjs/terminus": "^9.1.1",
34
36
  "@types/auth0": "^2.35.2",
35
37
  "class-transformer": "^0.5.1",
36
- "class-validator": "^0.13.1"
38
+ "class-validator": "^0.13.1",
39
+ "express-session": "^1.17.3"
37
40
  },
38
41
  "devDependencies": {
39
42
  "@commitlint/config-conventional": "^17.0.0",
@@ -52,6 +55,7 @@
52
55
  "@nestjs/testing": "^9.0.11",
53
56
  "@types/cache-manager": "^4.0.1",
54
57
  "@types/express": "^4.17.12",
58
+ "@types/express-session": "^1.17.5",
55
59
  "@types/jest": "^27.0.0",
56
60
  "@types/multer": "^1.4.7",
57
61
  "@types/node": "^18.0.0",
@@ -1,16 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,101 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"organization.controller.js","sourceRoot":"","sources":["../../../../src/modules/auth/organizations/organization.controller.ts"],"names":[],"mappings":"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"}
@@ -1,9 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,24 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,9 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,42 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,7 +0,0 @@
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
@@ -1 +0,0 @@
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,22 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,10 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,11 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,16 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,101 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"organization.controller.js","sourceRoot":"","sources":["../../../../src/modules/settings/organizations/organization.controller.ts"],"names":[],"mappings":"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"}
@@ -1,9 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,24 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,9 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,42 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,7 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,22 +0,0 @@
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
@@ -1 +0,0 @@
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"}