easywork-common-lib 1.0.1113 → 1.0.1115

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.
@@ -1,5 +1,6 @@
1
1
  import { User } from '../../entities';
2
2
  import { BaseEntity } from 'typeorm';
3
+ import { CognitoUser } from '../../entities/user-from-cognito.entity';
3
4
  export declare class EntityBase extends BaseEntity {
4
5
  id?: string;
5
6
  isActive?: boolean;
@@ -17,6 +18,7 @@ export declare class EntityBaseWithUser extends BaseEntity {
17
18
  deletedAt?: Date;
18
19
  createdBy?: User;
19
20
  updatedBy?: User;
21
+ cognitoUser?: CognitoUser;
20
22
  }
21
23
  export declare class BaseEntitySimple extends BaseEntity {
22
24
  id?: string;
@@ -13,6 +13,7 @@ exports.BaseEntityOnlyEssential = exports.BaseEntitySimple = exports.EntityBaseW
13
13
  const swagger_1 = require("@nestjs/swagger");
14
14
  const entities_1 = require("../../entities");
15
15
  const typeorm_1 = require("typeorm");
16
+ const user_from_cognito_entity_1 = require("../../entities/user-from-cognito.entity");
16
17
  let EntityBase = class EntityBase extends typeorm_1.BaseEntity {
17
18
  id;
18
19
  isActive;
@@ -58,6 +59,7 @@ let EntityBaseWithUser = class EntityBaseWithUser extends typeorm_1.BaseEntity {
58
59
  deletedAt;
59
60
  createdBy;
60
61
  updatedBy;
62
+ cognitoUser;
61
63
  };
62
64
  exports.EntityBaseWithUser = EntityBaseWithUser;
63
65
  __decorate([
@@ -112,6 +114,20 @@ __decorate([
112
114
  (0, typeorm_1.JoinColumn)(),
113
115
  __metadata("design:type", entities_1.User)
114
116
  ], EntityBaseWithUser.prototype, "updatedBy", void 0);
117
+ __decorate([
118
+ (0, swagger_1.ApiProperty)({
119
+ type: () => user_from_cognito_entity_1.CognitoUser,
120
+ description: 'User who modified the entity',
121
+ required: false,
122
+ }),
123
+ (0, typeorm_1.ManyToOne)(() => user_from_cognito_entity_1.CognitoUser, {
124
+ onDelete: 'SET NULL',
125
+ onUpdate: 'CASCADE',
126
+ nullable: true,
127
+ }),
128
+ (0, typeorm_1.JoinColumn)(),
129
+ __metadata("design:type", user_from_cognito_entity_1.CognitoUser)
130
+ ], EntityBaseWithUser.prototype, "cognitoUser", void 0);
115
131
  exports.EntityBaseWithUser = EntityBaseWithUser = __decorate([
116
132
  (0, typeorm_1.Entity)()
117
133
  ], EntityBaseWithUser);
@@ -1 +1 @@
1
- {"version":3,"file":"base.entity.js","sourceRoot":"","sources":["../../../src/common/database/base.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA8C;AAC9C,6CAAsC;AACtC,qCAA0J;AAGnJ,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,oBAAU;IAExC,EAAE,CAAU;IAGZ,QAAQ,CAAW;IAGnB,SAAS,CAAW;IAGpB,SAAS,CAAQ;IAGjB,SAAS,CAAQ;IAGjB,SAAS,CAAQ;CAClB,CAAA;AAlBY,gCAAU;AAErB;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;sCACnB;AAGZ;IADC,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;4CACP;AAGnB;IADC,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;;6CACP;AAGpB;IADC,IAAA,0BAAgB,GAAE;8BACP,IAAI;6CAAC;AAGjB;IADC,IAAA,0BAAgB,GAAE;8BACP,IAAI;6CAAC;AAGjB;IADC,IAAA,0BAAgB,GAAE;8BACP,IAAI;6CAAC;qBAjBN,UAAU;IADtB,IAAA,gBAAM,GAAE;GACI,UAAU,CAkBtB;AAGM,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,oBAAU;IAEhD,EAAE,CAAU;IAGZ,QAAQ,CAAW;IAGnB,SAAS,CAAW;IAGpB,SAAS,CAAQ;IAGjB,SAAS,CAAQ;IAGjB,SAAS,CAAQ;IAajB,SAAS,CAAQ;IAajB,SAAS,CAAQ;CAClB,CAAA;AA5CY,gDA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B,GAAE;8BACP,IAAI;0DAAC;AAGjB;IADC,IAAA,0BAAgB,GAAE;8BACP,IAAI;0DAAC;kCARN,uBAAuB;IADnC,IAAA,gBAAM,GAAE;GACI,uBAAuB,CASnC"}
@@ -22,6 +22,7 @@ export * from './sales';
22
22
  export * from './tag.entity';
23
23
  export * from './user-invitations.entity';
24
24
  export * from './user.entity';
25
+ export * from './user-from-cognito.entity';
25
26
  export * from './company.entity';
26
27
  export * from './user-special-role.entity';
27
28
  export * from './capacitation';
@@ -38,6 +38,7 @@ __exportStar(require("./sales"), exports);
38
38
  __exportStar(require("./tag.entity"), exports);
39
39
  __exportStar(require("./user-invitations.entity"), exports);
40
40
  __exportStar(require("./user.entity"), exports);
41
+ __exportStar(require("./user-from-cognito.entity"), exports);
41
42
  __exportStar(require("./company.entity"), exports);
42
43
  __exportStar(require("./user-special-role.entity"), exports);
43
44
  __exportStar(require("./capacitation"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/entities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iEAA+C;AAC/C,oDAAkC;AAClC,0CAAwB;AACxB,+DAA6C;AAC7C,iDAA+B;AAC/B,iDAA+B;AAC/B,uDAAqC;AACrC,yDAAuC;AACvC,2DAAyC;AACzC,mDAAiC;AACjC,4DAA0C;AAC1C,kDAAgC;AAChC,mDAAiC;AACjC,sDAAoC;AACpC,iDAA+B;AAC/B,2CAAyB;AACzB,mDAAiC;AACjC,oDAAkC;AAClC,yDAAuC;AACvC,gDAA8B;AAC9B,0CAAwB;AACxB,+CAA6B;AAC7B,4DAA0C;AAC1C,gDAA8B;AAC9B,mDAAiC;AACjC,6DAA2C;AAG3C,iDAA+B;AAG/B,0CAAwB;AAGxB,uDAAqC;AAGrC,sEAAoD;AACpD,0EAAwD;AACxD,8DAA4C;AAC5C,2DAAyC;AAGzC,0DAAwC;AAGxC,6EAA2D;AAC3D,gFAA8D;AAC9D,4DAA0C;AAC1C,uEAAqD;AACrD,oDAAkC;AAGlC,8DAA4C;AAC5C,iEAA+C;AAC/C,sEAAoD;AACpD,sEAAoD;AACpD,yEAAuD;AAGvD,4CAA0B;AAG1B,iDAA+B;AAC/B,0DAAwC;AAGxC,2DAAyC;AAGzC,oDAAkC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/entities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iEAA+C;AAC/C,oDAAkC;AAClC,0CAAwB;AACxB,+DAA6C;AAC7C,iDAA+B;AAC/B,iDAA+B;AAC/B,uDAAqC;AACrC,yDAAuC;AACvC,2DAAyC;AACzC,mDAAiC;AACjC,4DAA0C;AAC1C,kDAAgC;AAChC,mDAAiC;AACjC,sDAAoC;AACpC,iDAA+B;AAC/B,2CAAyB;AACzB,mDAAiC;AACjC,oDAAkC;AAClC,yDAAuC;AACvC,gDAA8B;AAC9B,0CAAwB;AACxB,+CAA6B;AAC7B,4DAA0C;AAC1C,gDAA8B;AAC9B,6DAA2C;AAC3C,mDAAiC;AACjC,6DAA2C;AAG3C,iDAA+B;AAG/B,0CAAwB;AAGxB,uDAAqC;AAGrC,sEAAoD;AACpD,0EAAwD;AACxD,8DAA4C;AAC5C,2DAAyC;AAGzC,0DAAwC;AAGxC,6EAA2D;AAC3D,gFAA8D;AAC9D,4DAA0C;AAC1C,uEAAqD;AACrD,oDAAkC;AAGlC,8DAA4C;AAC5C,iEAA+C;AAC/C,sEAAoD;AACpD,sEAAoD;AACpD,yEAAuD;AAGvD,4CAA0B;AAG1B,iDAA+B;AAC/B,0DAAwC;AAGxC,2DAAyC;AAGzC,oDAAkC"}
@@ -21,6 +21,7 @@ exports.LeadValidationRule = LeadValidationRule;
21
21
  __decorate([
22
22
  (0, typeorm_1.ManyToOne)(() => group_entity_1.Group, { onDelete: "CASCADE", nullable: true }),
23
23
  (0, typeorm_1.JoinColumn)({ name: "group_id" }),
24
+ (0, typeorm_1.Index)({ unique: true }),
24
25
  __metadata("design:type", group_entity_1.Group)
25
26
  ], LeadValidationRule.prototype, "group", void 0);
26
27
  __decorate([
@@ -28,7 +29,6 @@ __decorate([
28
29
  __metadata("design:type", Object)
29
30
  ], LeadValidationRule.prototype, "rules", void 0);
30
31
  exports.LeadValidationRule = LeadValidationRule = __decorate([
31
- (0, typeorm_1.Entity)("lead_validation_rules"),
32
- (0, typeorm_1.Index)(["group_id"])
32
+ (0, typeorm_1.Entity)("lead_validation_rules")
33
33
  ], LeadValidationRule);
34
34
  //# sourceMappingURL=lead-validation-rule.entity.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"lead-validation-rule.entity.js","sourceRoot":"","sources":["../../../src/entities/sales/lead-validation-rule.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mEAAqE;AACrE,qCAAuE;AACvE,kDAAwC;AAKjC,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,8BAAgB;IAGtD,KAAK,CAAe;IAGpB,KAAK,CAAsB;CAC5B,CAAA;AAPY,gDAAkB;AAG7B;IAFC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,oBAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC/D,IAAA,oBAAU,EAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;8BAC1B,oBAAK;iDAAQ;AAGpB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;iDACC;6BANhB,kBAAkB;IAF9B,IAAA,gBAAM,EAAC,uBAAuB,CAAC;IAC/B,IAAA,eAAK,EAAC,CAAC,UAAU,CAAC,CAAC;GACP,kBAAkB,CAO9B"}
1
+ {"version":3,"file":"lead-validation-rule.entity.js","sourceRoot":"","sources":["../../../src/entities/sales/lead-validation-rule.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mEAAqE;AACrE,qCAAuE;AACvE,kDAAwC;AAIjC,IAAM,kBAAkB,GAAxB,MAAM,kBAAmB,SAAQ,8BAAgB;IAItD,KAAK,CAAe;IAGpB,KAAK,CAAsB;CAC5B,CAAA;AARY,gDAAkB;AAI7B;IAHC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,oBAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC/D,IAAA,oBAAU,EAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IAChC,IAAA,eAAK,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;8BACjB,oBAAK;iDAAQ;AAGpB;IADC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;;iDACC;6BAPhB,kBAAkB;IAD9B,IAAA,gBAAM,EAAC,uBAAuB,CAAC;GACnB,kBAAkB,CAQ9B"}
@@ -0,0 +1,15 @@
1
+ import { BaseEntityOnlyEssential } from '../../common/database/base.entity';
2
+ import { PlanFeature } from './plan-feature';
3
+ export declare enum FeatureType {
4
+ BOOLEAN = "boolean",
5
+ LIMIT = "limit",
6
+ TEXT = "text"
7
+ }
8
+ export declare class Feature extends BaseEntityOnlyEssential {
9
+ key: string;
10
+ name: string;
11
+ description: string;
12
+ category: string;
13
+ type: FeatureType;
14
+ planFeatures: PlanFeature[];
15
+ }
@@ -0,0 +1,64 @@
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.Feature = exports.FeatureType = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const base_entity_1 = require("../../common/database/base.entity");
15
+ const swagger_1 = require("@nestjs/swagger");
16
+ const plan_feature_1 = require("./plan-feature");
17
+ var FeatureType;
18
+ (function (FeatureType) {
19
+ FeatureType["BOOLEAN"] = "boolean";
20
+ FeatureType["LIMIT"] = "limit";
21
+ FeatureType["TEXT"] = "text";
22
+ })(FeatureType || (exports.FeatureType = FeatureType = {}));
23
+ let Feature = class Feature extends base_entity_1.BaseEntityOnlyEssential {
24
+ key;
25
+ name;
26
+ description;
27
+ category;
28
+ type;
29
+ planFeatures;
30
+ };
31
+ exports.Feature = Feature;
32
+ __decorate([
33
+ (0, swagger_1.ApiProperty)({ description: 'Nombre único y programático de la característica', example: 'PRO_POLICY_READER' }),
34
+ (0, typeorm_1.Column)({ type: 'varchar', length: 100, unique: true, nullable: false }),
35
+ __metadata("design:type", String)
36
+ ], Feature.prototype, "key", void 0);
37
+ __decorate([
38
+ (0, swagger_1.ApiProperty)({ description: 'Nombre de la característica para mostrar al usuario', example: 'Lector de Pólizas Pro' }),
39
+ (0, typeorm_1.Column)({ type: 'varchar', length: 255, nullable: false }),
40
+ __metadata("design:type", String)
41
+ ], Feature.prototype, "name", void 0);
42
+ __decorate([
43
+ (0, swagger_1.ApiProperty)({ description: 'Descripción detallada de lo que hace la característica', example: 'Permite analizar y extraer datos de pólizas en formato PDF.' }),
44
+ (0, typeorm_1.Column)({ type: 'text', nullable: true }),
45
+ __metadata("design:type", String)
46
+ ], Feature.prototype, "description", void 0);
47
+ __decorate([
48
+ (0, swagger_1.ApiProperty)({ description: 'Categoría para agrupar en la UI', example: 'Reportes' }),
49
+ (0, typeorm_1.Column)({ type: 'varchar', length: 100, nullable: true }),
50
+ __metadata("design:type", String)
51
+ ], Feature.prototype, "category", void 0);
52
+ __decorate([
53
+ (0, swagger_1.ApiProperty)({ description: 'El tipo de valor que esta característica almacena', enum: FeatureType, example: FeatureType.BOOLEAN }),
54
+ (0, typeorm_1.Column)({ type: 'enum', enum: FeatureType, nullable: false }),
55
+ __metadata("design:type", String)
56
+ ], Feature.prototype, "type", void 0);
57
+ __decorate([
58
+ (0, typeorm_1.OneToMany)(() => plan_feature_1.PlanFeature, planFeature => planFeature.feature),
59
+ __metadata("design:type", Array)
60
+ ], Feature.prototype, "planFeatures", void 0);
61
+ exports.Feature = Feature = __decorate([
62
+ (0, typeorm_1.Entity)('features')
63
+ ], Feature);
64
+ //# sourceMappingURL=feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feature.js","sourceRoot":"","sources":["../../../src/entities/subscriptions/feature.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,qCAAoD;AACpD,mEAA4E;AAC5E,6CAA8C;AAC9C,iDAA6C;AAE7C,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,kCAAmB,CAAA;IACnB,8BAAe,CAAA;IACf,4BAAa,CAAA;AACf,CAAC,EAJW,WAAW,2BAAX,WAAW,QAItB;AAGM,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,qCAAuB;IAGlD,GAAG,CAAS;IAIZ,IAAI,CAAS;IAIb,WAAW,CAAS;IAIpB,QAAQ,CAAS;IAIjB,IAAI,CAAc;IAGlB,YAAY,CAAgB;CAC7B,CAAA;AAvBY,0BAAO;AAGlB;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,kDAAkD,EAAE,OAAO,EAAE,mBAAmB,EAAE,CAAC;IAC9G,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;oCAC5D;AAIZ;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,qDAAqD,EAAE,OAAO,EAAE,uBAAuB,EAAE,CAAC;IACrH,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;qCAC7C;AAIb;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,wDAAwD,EAAE,OAAO,EAAE,6DAA6D,EAAE,CAAC;IAC9J,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4CACrB;AAIpB;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,iCAAiC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;IACpF,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCACxC;AAIjB;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,mDAAmD,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,CAAC,OAAO,EAAE,CAAC;IAClI,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;qCAC3C;AAGlB;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,0BAAW,EAAE,WAAW,CAAC,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC;;6CACrC;kBAtBjB,OAAO;IADnB,IAAA,gBAAM,EAAC,UAAU,CAAC;GACN,OAAO,CAuBnB"}
@@ -0,0 +1,8 @@
1
+ import { Plan } from './plan.entity';
2
+ import { Feature } from './feature';
3
+ export declare class PlanFeature {
4
+ id: string;
5
+ value: string;
6
+ plan: Plan;
7
+ feature: Feature;
8
+ }
@@ -0,0 +1,44 @@
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.PlanFeature = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const plan_entity_1 = require("./plan.entity");
15
+ const swagger_1 = require("@nestjs/swagger");
16
+ const feature_1 = require("./feature");
17
+ let PlanFeature = class PlanFeature {
18
+ id;
19
+ value;
20
+ plan;
21
+ feature;
22
+ };
23
+ exports.PlanFeature = PlanFeature;
24
+ __decorate([
25
+ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
26
+ __metadata("design:type", String)
27
+ ], PlanFeature.prototype, "id", void 0);
28
+ __decorate([
29
+ (0, swagger_1.ApiProperty)({ description: 'Valor de la característica para este plan. Puede ser "true", "100", "ilimitado", etc.', example: 'true' }),
30
+ (0, typeorm_1.Column)({ type: 'varchar', length: 255, nullable: false }),
31
+ __metadata("design:type", String)
32
+ ], PlanFeature.prototype, "value", void 0);
33
+ __decorate([
34
+ (0, typeorm_1.ManyToOne)(() => plan_entity_1.Plan, plan => plan.planFeatures, { onDelete: 'CASCADE' }),
35
+ __metadata("design:type", plan_entity_1.Plan)
36
+ ], PlanFeature.prototype, "plan", void 0);
37
+ __decorate([
38
+ (0, typeorm_1.ManyToOne)(() => feature_1.Feature, feature => feature.planFeatures, { onDelete: 'CASCADE', eager: true }),
39
+ __metadata("design:type", feature_1.Feature)
40
+ ], PlanFeature.prototype, "feature", void 0);
41
+ exports.PlanFeature = PlanFeature = __decorate([
42
+ (0, typeorm_1.Entity)('plan_features')
43
+ ], PlanFeature);
44
+ //# sourceMappingURL=plan-feature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-feature.js","sourceRoot":"","sources":["../../../src/entities/subscriptions/plan-feature.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA4E;AAC5E,+CAAqC;AACrC,6CAA8C;AAC9C,uCAAoC;AAG7B,IAAM,WAAW,GAAjB,MAAM,WAAW;IAEtB,EAAE,CAAS;IAIX,KAAK,CAAS;IAGd,IAAI,CAAO;IAGX,OAAO,CAAU;CAClB,CAAA;AAbY,kCAAW;AAEtB;IADC,IAAA,gCAAsB,EAAC,MAAM,CAAC;;uCACpB;AAIX;IAFC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,uFAAuF,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IACtI,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;;0CAC5C;AAGd;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,kBAAI,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;8BACpE,kBAAI;yCAAC;AAGX;IADC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,iBAAO,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;8BACvF,iBAAO;4CAAC;sBAZN,WAAW;IADvB,IAAA,gBAAM,EAAC,eAAe,CAAC;GACX,WAAW,CAavB"}
@@ -0,0 +1,5 @@
1
+ export declare class CognitoUser {
2
+ id?: string;
3
+ createdAt?: Date;
4
+ updatedAt?: Date;
5
+ }
@@ -0,0 +1,35 @@
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.CognitoUser = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ let CognitoUser = class CognitoUser {
15
+ id;
16
+ createdAt;
17
+ updatedAt;
18
+ };
19
+ exports.CognitoUser = CognitoUser;
20
+ __decorate([
21
+ (0, typeorm_1.PrimaryColumn)('uuid'),
22
+ __metadata("design:type", String)
23
+ ], CognitoUser.prototype, "id", void 0);
24
+ __decorate([
25
+ (0, typeorm_1.CreateDateColumn)(),
26
+ __metadata("design:type", Date)
27
+ ], CognitoUser.prototype, "createdAt", void 0);
28
+ __decorate([
29
+ (0, typeorm_1.UpdateDateColumn)(),
30
+ __metadata("design:type", Date)
31
+ ], CognitoUser.prototype, "updatedAt", void 0);
32
+ exports.CognitoUser = CognitoUser = __decorate([
33
+ (0, typeorm_1.Entity)()
34
+ ], CognitoUser);
35
+ //# sourceMappingURL=user-from-cognito.entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user-from-cognito.entity.js","sourceRoot":"","sources":["../../src/entities/user-from-cognito.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAoF;AAG7E,IAAM,WAAW,GAAjB,MAAM,WAAW;IAEtB,EAAE,CAAU;IAGZ,SAAS,CAAQ;IAGjB,SAAS,CAAQ;CAClB,CAAA;AATY,kCAAW;AAEtB;IADC,IAAA,uBAAa,EAAC,MAAM,CAAC;;uCACV;AAGZ;IADC,IAAA,0BAAgB,GAAE;8BACP,IAAI;8CAAC;AAGjB;IADC,IAAA,0BAAgB,GAAE;8BACP,IAAI;8CAAC;sBARN,WAAW;IADvB,IAAA,gBAAM,GAAE;GACI,WAAW,CASvB"}
@@ -19,8 +19,8 @@ export declare class AuthorizationModule {
19
19
  }): {
20
20
  module: typeof AuthorizationModule;
21
21
  imports: import("@nestjs/common").DynamicModule[];
22
- providers: (typeof ResourceAccessFilterService | typeof ResourceAuthorizationService | typeof DynamicFilterService | typeof PermissionEvaluatorService | typeof PermissionCacheService | typeof AuthorizationService | typeof ResourceAuthorizationFactory | typeof ContactAuthorizationService | typeof LeadAuthorizationService | typeof PolicyAuthorizationService | typeof TaskAuthorizationService)[];
23
- exports: (typeof ResourceAccessFilterService | typeof ResourceAuthorizationService | typeof DynamicFilterService | typeof PermissionEvaluatorService | typeof PermissionCacheService | typeof AuthorizationService | typeof ResourceAuthorizationFactory | typeof ContactAuthorizationService | typeof LeadAuthorizationService | typeof PolicyAuthorizationService | typeof TaskAuthorizationService)[];
22
+ providers: (typeof TaskAuthorizationService | typeof PolicyAuthorizationService | typeof LeadAuthorizationService | typeof ContactAuthorizationService | typeof ResourceAuthorizationFactory | typeof PermissionEvaluatorService | typeof ResourceAuthorizationService | typeof ResourceAccessFilterService | typeof DynamicFilterService | typeof PermissionCacheService | typeof AuthorizationService)[];
23
+ exports: (typeof TaskAuthorizationService | typeof PolicyAuthorizationService | typeof LeadAuthorizationService | typeof ContactAuthorizationService | typeof ResourceAuthorizationFactory | typeof PermissionEvaluatorService | typeof ResourceAuthorizationService | typeof ResourceAccessFilterService | typeof DynamicFilterService | typeof PermissionCacheService | typeof AuthorizationService)[];
24
24
  global: boolean;
25
25
  };
26
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easywork-common-lib",
3
- "version": "1.0.1113",
3
+ "version": "1.0.1115",
4
4
  "description": "Librería común de Easywork",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,35 +0,0 @@
1
- export declare class AppModule {
2
- }
3
- import { Repository } from 'typeorm';
4
- import { ContactAuthorizationService, ResourceAuthorizationFactory, PermissionAction } from 'easywork-common-lib/modules';
5
- import { Contact, SubGroup, User } from 'easywork-common-lib/entities';
6
- export declare class ContactService {
7
- private contactRepository;
8
- private subGroupRepository;
9
- private readonly contactAuthService;
10
- private readonly authFactory;
11
- constructor(contactRepository: Repository<Contact>, subGroupRepository: Repository<SubGroup>, contactAuthService: ContactAuthorizationService, authFactory: ResourceAuthorizationFactory);
12
- getAllContacts(user: User): Promise<Contact[]>;
13
- getContactById(id: string, user: User): Promise<Contact>;
14
- }
15
- export declare class PoliciesService {
16
- private subGroupRepository;
17
- private readonly authFactory;
18
- constructor(subGroupRepository: Repository<SubGroup>, authFactory: ResourceAuthorizationFactory);
19
- getAllPolicies(user: User): Promise<any>;
20
- }
21
- import { AuthorizationService } from 'easywork-common-lib/modules';
22
- export declare class GenericResourceService {
23
- private readonly authService;
24
- constructor(authService: AuthorizationService);
25
- checkUserAccess(user: User, action: PermissionAction, resource: string): Promise<any>;
26
- validateMultiplePermissions(user: User): Promise<any>;
27
- }
28
- export declare class ContactController {
29
- private readonly contactService;
30
- constructor(contactService: ContactService);
31
- getAllContacts(user: User): Promise<Contact[]>;
32
- getContactById(id: string, user: User): Promise<Contact>;
33
- }
34
- export declare class ContactModule {
35
- }
@@ -1,180 +0,0 @@
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
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- var _a, _b, _c, _d, _e, _f;
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.ContactModule = exports.ContactController = exports.GenericResourceService = exports.PoliciesService = exports.ContactService = exports.AppModule = void 0;
17
- const common_1 = require("@nestjs/common");
18
- const modules_1 = require("easywork-common-lib/modules");
19
- let AppModule = class AppModule {
20
- };
21
- exports.AppModule = AppModule;
22
- exports.AppModule = AppModule = __decorate([
23
- (0, common_1.Module)({
24
- imports: [
25
- modules_1.AuthorizationModule,
26
- modules_1.AuthorizationModule.forRoot({
27
- cache: {
28
- ttl: 600,
29
- max: 2000,
30
- },
31
- }),
32
- ],
33
- })
34
- ], AppModule);
35
- const common_2 = require("@nestjs/common");
36
- const typeorm_1 = require("typeorm");
37
- const typeorm_2 = require("@nestjs/typeorm");
38
- const modules_2 = require("easywork-common-lib/modules");
39
- const entities_1 = require("easywork-common-lib/entities");
40
- let ContactService = class ContactService {
41
- contactRepository;
42
- subGroupRepository;
43
- contactAuthService;
44
- authFactory;
45
- constructor(contactRepository, subGroupRepository, contactAuthService, authFactory) {
46
- this.contactRepository = contactRepository;
47
- this.subGroupRepository = subGroupRepository;
48
- this.contactAuthService = contactAuthService;
49
- this.authFactory = authFactory;
50
- }
51
- async getAllContacts(user) {
52
- const queryBuilder = this.contactRepository
53
- .createQueryBuilder('contact');
54
- await this.contactAuthService.applyContactPermissionFilters(queryBuilder, user, {
55
- action: modules_2.PermissionAction.READ,
56
- subGroupRepository: this.subGroupRepository,
57
- });
58
- return queryBuilder.getMany();
59
- }
60
- async getContactById(id, user) {
61
- const contact = await this.contactRepository.findOne({ where: { id } });
62
- if (!contact) {
63
- throw new Error('Contact not found');
64
- }
65
- await this.contactAuthService.validateContactAccess(user, modules_2.PermissionAction.READ, contact, this.subGroupRepository);
66
- return contact;
67
- }
68
- };
69
- exports.ContactService = ContactService;
70
- exports.ContactService = ContactService = __decorate([
71
- (0, common_2.Injectable)(),
72
- __param(0, (0, typeorm_2.InjectRepository)(entities_1.Contact)),
73
- __param(1, (0, typeorm_2.InjectRepository)(entities_1.SubGroup)),
74
- __metadata("design:paramtypes", [typeorm_1.Repository,
75
- typeorm_1.Repository, typeof (_a = typeof modules_2.ContactAuthorizationService !== "undefined" && modules_2.ContactAuthorizationService) === "function" ? _a : Object, typeof (_b = typeof modules_2.ResourceAuthorizationFactory !== "undefined" && modules_2.ResourceAuthorizationFactory) === "function" ? _b : Object])
76
- ], ContactService);
77
- let PoliciesService = class PoliciesService {
78
- subGroupRepository;
79
- authFactory;
80
- constructor(subGroupRepository, authFactory) {
81
- this.subGroupRepository = subGroupRepository;
82
- this.authFactory = authFactory;
83
- }
84
- async getAllPolicies(user) {
85
- const queryBuilder = this.policyRepository
86
- .createQueryBuilder('policy');
87
- const policyAuth = this.authFactory.forPolicy(this.subGroupRepository);
88
- await policyAuth.applyPermissionFilters(queryBuilder, user, {
89
- action: modules_2.PermissionAction.READ,
90
- });
91
- return queryBuilder.getMany();
92
- }
93
- };
94
- exports.PoliciesService = PoliciesService;
95
- exports.PoliciesService = PoliciesService = __decorate([
96
- (0, common_2.Injectable)(),
97
- __param(0, (0, typeorm_2.InjectRepository)(entities_1.SubGroup)),
98
- __metadata("design:paramtypes", [typeorm_1.Repository, typeof (_c = typeof modules_2.ResourceAuthorizationFactory !== "undefined" && modules_2.ResourceAuthorizationFactory) === "function" ? _c : Object])
99
- ], PoliciesService);
100
- const modules_3 = require("easywork-common-lib/modules");
101
- let GenericResourceService = class GenericResourceService {
102
- authService;
103
- constructor(authService) {
104
- this.authService = authService;
105
- }
106
- async checkUserAccess(user, action, resource) {
107
- const result = await this.authService.canAccess({
108
- user,
109
- action,
110
- resource,
111
- });
112
- return result.allowed;
113
- }
114
- async validateMultiplePermissions(user) {
115
- const results = await this.authService.canAccessMultiple([
116
- { user, action: modules_2.PermissionAction.READ, resource: 'contact' },
117
- { user, action: modules_2.PermissionAction.CREATE, resource: 'lead' },
118
- { user, action: modules_2.PermissionAction.UPDATE, resource: 'policy' },
119
- ]);
120
- return results;
121
- }
122
- };
123
- exports.GenericResourceService = GenericResourceService;
124
- exports.GenericResourceService = GenericResourceService = __decorate([
125
- (0, common_2.Injectable)(),
126
- __metadata("design:paramtypes", [typeof (_d = typeof modules_3.AuthorizationService !== "undefined" && modules_3.AuthorizationService) === "function" ? _d : Object])
127
- ], GenericResourceService);
128
- const common_3 = require("@nestjs/common");
129
- const modules_4 = require("easywork-common-lib/modules");
130
- const your_auth_decorator_1 = require("your-auth-decorator");
131
- let ContactController = class ContactController {
132
- contactService;
133
- constructor(contactService) {
134
- this.contactService = contactService;
135
- }
136
- async getAllContacts(user) {
137
- return this.contactService.getAllContacts(user);
138
- }
139
- async getContactById(id, user) {
140
- return this.contactService.getContactById(id, user);
141
- }
142
- };
143
- exports.ContactController = ContactController;
144
- __decorate([
145
- (0, common_3.Get)(),
146
- __param(0, (0, your_auth_decorator_1.CurrentUser)()),
147
- __metadata("design:type", Function),
148
- __metadata("design:paramtypes", [typeof (_e = typeof entities_1.User !== "undefined" && entities_1.User) === "function" ? _e : Object]),
149
- __metadata("design:returntype", Promise)
150
- ], ContactController.prototype, "getAllContacts", null);
151
- __decorate([
152
- (0, common_3.Get)(':id'),
153
- __param(0, (0, common_3.Param)('id')),
154
- __param(1, (0, your_auth_decorator_1.CurrentUser)()),
155
- __metadata("design:type", Function),
156
- __metadata("design:paramtypes", [String, typeof (_f = typeof entities_1.User !== "undefined" && entities_1.User) === "function" ? _f : Object]),
157
- __metadata("design:returntype", Promise)
158
- ], ContactController.prototype, "getContactById", null);
159
- exports.ContactController = ContactController = __decorate([
160
- (0, common_3.Controller)('contacts'),
161
- (0, common_3.UseGuards)(modules_4.EnhancedRolesPolicyGuard),
162
- __metadata("design:paramtypes", [ContactService])
163
- ], ContactController);
164
- let ContactModule = class ContactModule {
165
- };
166
- exports.ContactModule = ContactModule;
167
- exports.ContactModule = ContactModule = __decorate([
168
- (0, common_1.Module)({
169
- imports: [
170
- TypeOrmModule.forFeature([entities_1.Contact, entities_1.Lead, Policy]),
171
- ],
172
- controllers: [ContactController],
173
- providers: [
174
- ContactService,
175
- PoliciesService,
176
- GenericResourceService,
177
- ],
178
- })
179
- ], ContactModule);
180
- //# sourceMappingURL=usage-example.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"usage-example.js","sourceRoot":"","sources":["../../../src/modules/authorization/usage-example.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAiBA,2CAAwC;AACxC,yDAAkE;AAoB3D,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,8BAAS;oBAAT,SAAS;IAlBrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YAEP,6BAAmB;YAGnB,6BAAmB,CAAC,OAAO,CAAC;gBAC1B,KAAK,EAAE;oBACL,GAAG,EAAE,GAAG;oBACR,GAAG,EAAE,IAAI;iBAEV;aACF,CAAC;SAGH;KAEF,CAAC;GACW,SAAS,CAAG;AAMzB,2CAA4C;AAC5C,qCAAqC;AACrC,6CAAmD;AACnD,yDAKqC;AACrC,2DAA6E;AAGtE,IAAM,cAAc,GAApB,MAAM,cAAc;IAGf;IAGA;IAGS;IACA;IATnB,YAEU,iBAAsC,EAGtC,kBAAwC,EAG/B,kBAA+C,EAC/C,WAAyC;QAPlD,sBAAiB,GAAjB,iBAAiB,CAAqB;QAGtC,uBAAkB,GAAlB,kBAAkB,CAAsB;QAG/B,uBAAkB,GAAlB,kBAAkB,CAA6B;QAC/C,gBAAW,GAAX,WAAW,CAA8B;IACzD,CAAC;IAEJ,KAAK,CAAC,cAAc,CAAC,IAAU;QAC7B,MAAM,YAAY,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