@things-factory/auth-base 9.0.0-beta.76 → 9.0.0

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 (135) hide show
  1. package/dist-client/auth.js +2 -4
  2. package/dist-client/auth.js.map +1 -1
  3. package/dist-client/reducers/auth.js +9 -2
  4. package/dist-client/reducers/auth.js.map +1 -1
  5. package/dist-client/tsconfig.tsbuildinfo +1 -1
  6. package/dist-server/controllers/change-pwd.js +5 -2
  7. package/dist-server/controllers/change-pwd.js.map +1 -1
  8. package/dist-server/controllers/checkin.js +1 -1
  9. package/dist-server/controllers/checkin.js.map +1 -1
  10. package/dist-server/controllers/delete-user.js +2 -2
  11. package/dist-server/controllers/delete-user.js.map +1 -1
  12. package/dist-server/controllers/profile.js +4 -1
  13. package/dist-server/controllers/profile.js.map +1 -1
  14. package/dist-server/controllers/reset-password.js +5 -2
  15. package/dist-server/controllers/reset-password.js.map +1 -1
  16. package/dist-server/controllers/signin.js +2 -2
  17. package/dist-server/controllers/signin.js.map +1 -1
  18. package/dist-server/controllers/signup.js +8 -1
  19. package/dist-server/controllers/signup.js.map +1 -1
  20. package/dist-server/errors/auth-error.js +3 -1
  21. package/dist-server/errors/auth-error.js.map +1 -1
  22. package/dist-server/middlewares/authenticate-401-middleware.js +22 -9
  23. package/dist-server/middlewares/authenticate-401-middleware.js.map +1 -1
  24. package/dist-server/middlewares/domain-authenticate-middleware.js +1 -1
  25. package/dist-server/middlewares/domain-authenticate-middleware.js.map +1 -1
  26. package/dist-server/middlewares/jwt-authenticate-middleware.js +1 -1
  27. package/dist-server/middlewares/jwt-authenticate-middleware.js.map +1 -1
  28. package/dist-server/migrations/1548206416130-SeedUser.js +11 -3
  29. package/dist-server/migrations/1548206416130-SeedUser.js.map +1 -1
  30. package/dist-server/router/auth-signup-router.js +5 -2
  31. package/dist-server/router/auth-signup-router.js.map +1 -1
  32. package/dist-server/router/oauth2/oauth2-authorize-router.js +5 -2
  33. package/dist-server/router/oauth2/oauth2-authorize-router.js.map +1 -1
  34. package/dist-server/router/oauth2/oauth2-router.js +1 -2
  35. package/dist-server/router/oauth2/oauth2-router.js.map +1 -1
  36. package/dist-server/router/oauth2/oauth2-server.js +21 -3
  37. package/dist-server/router/oauth2/oauth2-server.js.map +1 -1
  38. package/dist-server/router/site-root-router.js +1 -1
  39. package/dist-server/router/site-root-router.js.map +1 -1
  40. package/dist-server/router/webauthn-router.js +1 -1
  41. package/dist-server/router/webauthn-router.js.map +1 -1
  42. package/dist-server/service/app-binding/app-binding-types.js +3 -3
  43. package/dist-server/service/app-binding/app-binding-types.js.map +1 -1
  44. package/dist-server/service/app-binding/app-binding.js +6 -4
  45. package/dist-server/service/app-binding/app-binding.js.map +1 -1
  46. package/dist-server/service/appliance/appliance-mutation.js +20 -4
  47. package/dist-server/service/appliance/appliance-mutation.js.map +1 -1
  48. package/dist-server/service/appliance/appliance-types.js +18 -18
  49. package/dist-server/service/appliance/appliance-types.js.map +1 -1
  50. package/dist-server/service/appliance/appliance.js +22 -18
  51. package/dist-server/service/appliance/appliance.js.map +1 -1
  52. package/dist-server/service/application/application-mutation.js +22 -4
  53. package/dist-server/service/application/application-mutation.js.map +1 -1
  54. package/dist-server/service/application/application-types.js +24 -24
  55. package/dist-server/service/application/application-types.js.map +1 -1
  56. package/dist-server/service/application/application.d.ts +6 -6
  57. package/dist-server/service/application/application.js +22 -22
  58. package/dist-server/service/application/application.js.map +1 -1
  59. package/dist-server/service/auth-provider/auth-provider-mutation.js +29 -7
  60. package/dist-server/service/auth-provider/auth-provider-mutation.js.map +1 -1
  61. package/dist-server/service/auth-provider/auth-provider-parameter-spec.js +12 -7
  62. package/dist-server/service/auth-provider/auth-provider-parameter-spec.js.map +1 -1
  63. package/dist-server/service/auth-provider/auth-provider-type.js +24 -21
  64. package/dist-server/service/auth-provider/auth-provider-type.js.map +1 -1
  65. package/dist-server/service/auth-provider/auth-provider.js +35 -25
  66. package/dist-server/service/auth-provider/auth-provider.js.map +1 -1
  67. package/dist-server/service/domain-generator/domain-generator-mutation.js +1 -2
  68. package/dist-server/service/domain-generator/domain-generator-mutation.js.map +1 -1
  69. package/dist-server/service/domain-generator/domain-generator-types.js +17 -14
  70. package/dist-server/service/domain-generator/domain-generator-types.js.map +1 -1
  71. package/dist-server/service/domain-link/domain-link-mutation.js +23 -6
  72. package/dist-server/service/domain-link/domain-link-mutation.js.map +1 -1
  73. package/dist-server/service/domain-link/domain-link-types.js +13 -13
  74. package/dist-server/service/domain-link/domain-link-types.js.map +1 -1
  75. package/dist-server/service/domain-link/domain-link.d.ts +2 -2
  76. package/dist-server/service/domain-link/domain-link.js +11 -11
  77. package/dist-server/service/domain-link/domain-link.js.map +1 -1
  78. package/dist-server/service/granted-role/granted-role-mutation.js +7 -7
  79. package/dist-server/service/granted-role/granted-role-mutation.js.map +1 -1
  80. package/dist-server/service/granted-role/granted-role.js +4 -4
  81. package/dist-server/service/granted-role/granted-role.js.map +1 -1
  82. package/dist-server/service/invitation/invitation-mutation.js +6 -2
  83. package/dist-server/service/invitation/invitation-mutation.js.map +1 -1
  84. package/dist-server/service/invitation/invitation-types.js +3 -3
  85. package/dist-server/service/invitation/invitation-types.js.map +1 -1
  86. package/dist-server/service/invitation/invitation.js +10 -10
  87. package/dist-server/service/invitation/invitation.js.map +1 -1
  88. package/dist-server/service/login-history/login-history-type.js +3 -3
  89. package/dist-server/service/login-history/login-history-type.js.map +1 -1
  90. package/dist-server/service/login-history/login-history.js +6 -6
  91. package/dist-server/service/login-history/login-history.js.map +1 -1
  92. package/dist-server/service/partner/partner-types.js +3 -3
  93. package/dist-server/service/partner/partner-types.js.map +1 -1
  94. package/dist-server/service/partner/partner.js +8 -8
  95. package/dist-server/service/partner/partner.js.map +1 -1
  96. package/dist-server/service/password-history/password-history.js +3 -3
  97. package/dist-server/service/password-history/password-history.js.map +1 -1
  98. package/dist-server/service/privilege/privilege-directive.js +1 -2
  99. package/dist-server/service/privilege/privilege-directive.js.map +1 -1
  100. package/dist-server/service/privilege/privilege-mutation.js +11 -2
  101. package/dist-server/service/privilege/privilege-mutation.js.map +1 -1
  102. package/dist-server/service/privilege/privilege.js +20 -20
  103. package/dist-server/service/privilege/privilege.js.map +1 -1
  104. package/dist-server/service/role/role-mutation.js +12 -2
  105. package/dist-server/service/role/role-mutation.js.map +1 -1
  106. package/dist-server/service/role/role-query.js +1 -1
  107. package/dist-server/service/role/role-query.js.map +1 -1
  108. package/dist-server/service/role/role-types.js +29 -29
  109. package/dist-server/service/role/role-types.js.map +1 -1
  110. package/dist-server/service/role/role.js +11 -11
  111. package/dist-server/service/role/role.js.map +1 -1
  112. package/dist-server/service/user/user-mutation.js +89 -41
  113. package/dist-server/service/user/user-mutation.js.map +1 -1
  114. package/dist-server/service/user/user-query.js +16 -10
  115. package/dist-server/service/user/user-query.js.map +1 -1
  116. package/dist-server/service/user/user-types.js +33 -32
  117. package/dist-server/service/user/user-types.js.map +1 -1
  118. package/dist-server/service/user/user.d.ts +5 -5
  119. package/dist-server/service/user/user.js +25 -22
  120. package/dist-server/service/user/user.js.map +1 -1
  121. package/dist-server/service/users-auth-providers/users-auth-providers.js +11 -8
  122. package/dist-server/service/users-auth-providers/users-auth-providers.js.map +1 -1
  123. package/dist-server/service/verification-token/verification-token.d.ts +3 -3
  124. package/dist-server/service/verification-token/verification-token.js +8 -8
  125. package/dist-server/service/verification-token/verification-token.js.map +1 -1
  126. package/dist-server/service/web-auth-credential/web-auth-credential.js +11 -10
  127. package/dist-server/service/web-auth-credential/web-auth-credential.js.map +1 -1
  128. package/dist-server/tsconfig.tsbuildinfo +1 -1
  129. package/dist-server/utils/access-token-cookie.js +1 -2
  130. package/dist-server/utils/access-token-cookie.js.map +1 -1
  131. package/dist-server/utils/check-user-belongs-domain.js +1 -2
  132. package/dist-server/utils/check-user-belongs-domain.js.map +1 -1
  133. package/dist-server/utils/get-domain-users.js +2 -2
  134. package/dist-server/utils/get-domain-users.js.map +1 -1
  135. package/package.json +6 -6
@@ -9,58 +9,58 @@ let NewDomainLink = class NewDomainLink {
9
9
  };
10
10
  exports.NewDomainLink = NewDomainLink;
11
11
  tslib_1.__decorate([
12
- (0, type_graphql_1.Field)(() => shell_1.ObjectRef),
12
+ (0, type_graphql_1.Field)(() => shell_1.ObjectRef, { description: 'The source domain in the relationship.' }),
13
13
  tslib_1.__metadata("design:type", shell_1.ObjectRef)
14
14
  ], NewDomainLink.prototype, "sourceDomain", void 0);
15
15
  tslib_1.__decorate([
16
- (0, type_graphql_1.Field)(() => shell_1.ObjectRef),
16
+ (0, type_graphql_1.Field)(() => shell_1.ObjectRef, { description: 'The target domain in the relationship.' }),
17
17
  tslib_1.__metadata("design:type", shell_1.ObjectRef)
18
18
  ], NewDomainLink.prototype, "targetDomain", void 0);
19
19
  tslib_1.__decorate([
20
- (0, type_graphql_1.Field)(),
20
+ (0, type_graphql_1.Field)({ description: 'The type of the relationship.' }),
21
21
  tslib_1.__metadata("design:type", String)
22
22
  ], NewDomainLink.prototype, "type", void 0);
23
23
  exports.NewDomainLink = NewDomainLink = tslib_1.__decorate([
24
- (0, type_graphql_1.InputType)()
24
+ (0, type_graphql_1.InputType)({ description: 'Input for creating a new domain link.' })
25
25
  ], NewDomainLink);
26
26
  let DomainLinkPatch = class DomainLinkPatch {
27
27
  };
28
28
  exports.DomainLinkPatch = DomainLinkPatch;
29
29
  tslib_1.__decorate([
30
- (0, type_graphql_1.Field)(type => type_graphql_1.ID),
30
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID, { description: 'The unique identifier of the domain link to update.' }),
31
31
  tslib_1.__metadata("design:type", String)
32
32
  ], DomainLinkPatch.prototype, "id", void 0);
33
33
  tslib_1.__decorate([
34
- (0, type_graphql_1.Field)(() => shell_1.ObjectRef, { nullable: true }),
34
+ (0, type_graphql_1.Field)(() => shell_1.ObjectRef, { nullable: true, description: 'The new source domain for the relationship.' }),
35
35
  tslib_1.__metadata("design:type", shell_1.ObjectRef)
36
36
  ], DomainLinkPatch.prototype, "sourceDomain", void 0);
37
37
  tslib_1.__decorate([
38
- (0, type_graphql_1.Field)(() => shell_1.ObjectRef, { nullable: true }),
38
+ (0, type_graphql_1.Field)(() => shell_1.ObjectRef, { nullable: true, description: 'The new target domain for the relationship.' }),
39
39
  tslib_1.__metadata("design:type", shell_1.ObjectRef)
40
40
  ], DomainLinkPatch.prototype, "targetDomain", void 0);
41
41
  tslib_1.__decorate([
42
- (0, type_graphql_1.Field)({ nullable: true }),
42
+ (0, type_graphql_1.Field)({ nullable: true, description: 'The new type for the relationship.' }),
43
43
  tslib_1.__metadata("design:type", String)
44
44
  ], DomainLinkPatch.prototype, "type", void 0);
45
45
  tslib_1.__decorate([
46
- (0, type_graphql_1.Field)({ nullable: true }),
46
+ (0, type_graphql_1.Field)({ nullable: true, description: 'A flag indicating whether the link is being created, updated, or deleted.' }),
47
47
  tslib_1.__metadata("design:type", String)
48
48
  ], DomainLinkPatch.prototype, "cuFlag", void 0);
49
49
  exports.DomainLinkPatch = DomainLinkPatch = tslib_1.__decorate([
50
- (0, type_graphql_1.InputType)()
50
+ (0, type_graphql_1.InputType)({ description: 'Input for updating (patching) an existing domain link.' })
51
51
  ], DomainLinkPatch);
52
52
  let DomainLinkList = class DomainLinkList {
53
53
  };
54
54
  exports.DomainLinkList = DomainLinkList;
55
55
  tslib_1.__decorate([
56
- (0, type_graphql_1.Field)(type => [domain_link_js_1.DomainLink]),
56
+ (0, type_graphql_1.Field)(type => [domain_link_js_1.DomainLink], { description: 'The list of domain link items.' }),
57
57
  tslib_1.__metadata("design:type", Array)
58
58
  ], DomainLinkList.prototype, "items", void 0);
59
59
  tslib_1.__decorate([
60
- (0, type_graphql_1.Field)(type => type_graphql_1.Int),
60
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, { description: 'The total number of domain links.' }),
61
61
  tslib_1.__metadata("design:type", Number)
62
62
  ], DomainLinkList.prototype, "total", void 0);
63
63
  exports.DomainLinkList = DomainLinkList = tslib_1.__decorate([
64
- (0, type_graphql_1.ObjectType)()
64
+ (0, type_graphql_1.ObjectType)({ description: 'A paginated list of domain links.' })
65
65
  ], DomainLinkList);
66
66
  //# sourceMappingURL=domain-link-types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"domain-link-types.js","sourceRoot":"","sources":["../../../server/service/domain-link/domain-link-types.ts"],"names":[],"mappings":";;;;AAAA,+CAAoE;AAEpE,iDAAiD;AAEjD,qDAA6D;AAGtD,IAAM,aAAa,GAAnB,MAAM,aAAa;CASzB,CAAA;AATY,sCAAa;AAExB;IADC,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,iBAAS,CAAC;sCACT,iBAAS;mDAAA;AAGvB;IADC,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,iBAAS,CAAC;sCACT,iBAAS;mDAAA;AAGvB;IADC,IAAA,oBAAK,GAAE;;2CACY;wBART,aAAa;IADzB,IAAA,wBAAS,GAAE;GACC,aAAa,CASzB;AAGM,IAAM,eAAe,GAArB,MAAM,eAAe;CAe3B,CAAA;AAfY,0CAAe;AAE1B;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;2CACP;AAGX;IADC,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,iBAAS,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCAC7B,iBAAS;qDAAA;AAGvB;IADC,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,iBAAS,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCAC7B,iBAAS;qDAAA;AAGvB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACN;AAGpB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;+CACX;0BAdJ,eAAe;IAD3B,IAAA,wBAAS,GAAE;GACC,eAAe,CAe3B;AAGM,IAAM,cAAc,GAApB,MAAM,cAAc;CAM1B,CAAA;AANY,wCAAc;AAEzB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,2BAAU,CAAC,CAAC;;6CACT;AAGnB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;6CACN;yBALF,cAAc;IAD1B,IAAA,yBAAU,GAAE;GACA,cAAc,CAM1B","sourcesContent":["import { ObjectType, Field, InputType, Int, ID } from 'type-graphql'\n\nimport { ObjectRef } from '@things-factory/shell'\n\nimport { DomainLink, DomainLinkType } from './domain-link.js'\n\n@InputType()\nexport class NewDomainLink {\n @Field(() => ObjectRef)\n sourceDomain: ObjectRef\n\n @Field(() => ObjectRef)\n targetDomain: ObjectRef\n\n @Field()\n type: DomainLinkType\n}\n\n@InputType()\nexport class DomainLinkPatch {\n @Field(type => ID)\n id?: string\n\n @Field(() => ObjectRef, { nullable: true })\n sourceDomain: ObjectRef\n\n @Field(() => ObjectRef, { nullable: true })\n targetDomain: ObjectRef\n\n @Field({ nullable: true })\n type: DomainLinkType\n\n @Field({ nullable: true })\n cuFlag?: string\n}\n\n@ObjectType()\nexport class DomainLinkList {\n @Field(type => [DomainLink])\n items: DomainLink[]\n\n @Field(type => Int)\n total: number\n}\n"]}
1
+ {"version":3,"file":"domain-link-types.js","sourceRoot":"","sources":["../../../server/service/domain-link/domain-link-types.ts"],"names":[],"mappings":";;;;AAAA,+CAAoE;AAEpE,iDAAiD;AAEjD,qDAA6D;AAGtD,IAAM,aAAa,GAAnB,MAAM,aAAa;CASzB,CAAA;AATY,sCAAa;AAExB;IADC,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,iBAAS,EAAE,EAAE,WAAW,EAAE,wCAAwC,EAAE,CAAC;sCACpE,iBAAS;mDAAA;AAGvB;IADC,IAAA,oBAAK,EAAC,GAAG,EAAE,CAAC,iBAAS,EAAE,EAAE,WAAW,EAAE,wCAAwC,EAAE,CAAC;sCACpE,iBAAS;mDAAA;AAGvB;IADC,IAAA,oBAAK,EAAC,EAA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c;IAD1B,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,mCAAmC,EAAE,CAAC;GACpD,cAAc,CAM1B","sourcesContent":["import { ObjectType, Field, InputType, Int, ID } from 'type-graphql'\n\nimport { ObjectRef } from '@things-factory/shell'\n\nimport { DomainLink, DomainLinkType } from './domain-link.js'\n\n@InputType({ description: 'Input for creating a new domain link.' })\nexport class NewDomainLink {\n @Field(() => ObjectRef, { description: 'The source domain in the relationship.' })\n sourceDomain: ObjectRef\n\n @Field(() => ObjectRef, { description: 'The target domain in the relationship.' })\n targetDomain: ObjectRef\n\n @Field({ description: 'The type of the relationship.' })\n type: DomainLinkType\n}\n\n@InputType({ description: 'Input for updating (patching) an existing domain link.' })\nexport class DomainLinkPatch {\n @Field(type => ID, { description: 'The unique identifier of the domain link to update.' })\n id?: string\n\n @Field(() => ObjectRef, { nullable: true, description: 'The new source domain for the relationship.' })\n sourceDomain: ObjectRef\n\n @Field(() => ObjectRef, { nullable: true, description: 'The new target domain for the relationship.' })\n targetDomain: ObjectRef\n\n @Field({ nullable: true, description: 'The new type for the relationship.' })\n type: DomainLinkType\n\n @Field({ nullable: true, description: 'A flag indicating whether the link is being created, updated, or deleted.' })\n cuFlag?: string\n}\n\n@ObjectType({ description: 'A paginated list of domain links.' })\nexport class DomainLinkList {\n @Field(type => [DomainLink], { description: 'The list of domain link items.' })\n items: DomainLink[]\n\n @Field(type => Int, { description: 'The total number of domain links.' })\n total: number\n}\n"]}
@@ -1,8 +1,8 @@
1
1
  import { Domain } from '@things-factory/shell';
2
2
  import { User } from '../user/user.js';
3
3
  export declare enum DomainLinkType {
4
- has = "has",
5
- maintains = "maintains",
4
+ has = "has",// Represents a general association or membership.
5
+ maintains = "maintains",// Represents a relationship where the source domain manages or maintains the target domain.
6
6
  owns = "owns"
7
7
  }
8
8
  export declare class DomainLink {
@@ -13,23 +13,23 @@ var DomainLinkType;
13
13
  (function (DomainLinkType) {
14
14
  DomainLinkType["has"] = "has";
15
15
  DomainLinkType["maintains"] = "maintains";
16
- DomainLinkType["owns"] = "owns";
16
+ DomainLinkType["owns"] = "owns"; // Represents an ownership relationship.
17
17
  })(DomainLinkType || (exports.DomainLinkType = DomainLinkType = {}));
18
18
  (0, type_graphql_1.registerEnumType)(DomainLinkType, {
19
19
  name: 'DomainLinkType',
20
- description: 'Link type enumeration of a DomainLink'
20
+ description: 'Enumeration of relationship types between domains.'
21
21
  });
22
22
  let DomainLink = class DomainLink {
23
23
  };
24
24
  exports.DomainLink = DomainLink;
25
25
  tslib_1.__decorate([
26
26
  (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
27
- (0, type_graphql_1.Field)(type => type_graphql_1.ID),
27
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID, { description: 'Unique identifier for the domain link.' }),
28
28
  tslib_1.__metadata("design:type", String)
29
29
  ], DomainLink.prototype, "id", void 0);
30
30
  tslib_1.__decorate([
31
31
  (0, typeorm_1.ManyToOne)(() => shell_1.Domain, { nullable: false, onDelete: 'CASCADE' }),
32
- (0, type_graphql_1.Field)(() => shell_1.Domain),
32
+ (0, type_graphql_1.Field)(() => shell_1.Domain, { description: 'The source domain in the relationship.' }),
33
33
  tslib_1.__metadata("design:type", shell_1.Domain)
34
34
  ], DomainLink.prototype, "sourceDomain", void 0);
35
35
  tslib_1.__decorate([
@@ -38,7 +38,7 @@ tslib_1.__decorate([
38
38
  ], DomainLink.prototype, "sourceDomainId", void 0);
39
39
  tslib_1.__decorate([
40
40
  (0, typeorm_1.ManyToOne)(() => shell_1.Domain, { nullable: false, onDelete: 'CASCADE' }),
41
- (0, type_graphql_1.Field)(() => shell_1.Domain),
41
+ (0, type_graphql_1.Field)(() => shell_1.Domain, { description: 'The target domain in the relationship.' }),
42
42
  tslib_1.__metadata("design:type", shell_1.Domain)
43
43
  ], DomainLink.prototype, "targetDomain", void 0);
44
44
  tslib_1.__decorate([
@@ -60,26 +60,26 @@ tslib_1.__decorate([
60
60
  length: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb' ? undefined : 32,
61
61
  default: DomainLinkType.has
62
62
  }),
63
- (0, type_graphql_1.Field)(),
63
+ (0, type_graphql_1.Field)({ description: 'The type of the relationship (e.g., has, maintains, owns).' }),
64
64
  tslib_1.__metadata("design:type", String)
65
65
  ], DomainLink.prototype, "type", void 0);
66
66
  tslib_1.__decorate([
67
67
  (0, typeorm_1.CreateDateColumn)(),
68
- (0, type_graphql_1.Field)(),
68
+ (0, type_graphql_1.Field)({ description: 'The timestamp when the domain link was created.' }),
69
69
  tslib_1.__metadata("design:type", Date
70
70
  /** Last Update Timestamp */
71
71
  )
72
72
  ], DomainLink.prototype, "createdAt", void 0);
73
73
  tslib_1.__decorate([
74
74
  (0, typeorm_1.UpdateDateColumn)(),
75
- (0, type_graphql_1.Field)(),
75
+ (0, type_graphql_1.Field)({ description: 'The timestamp when the domain link was last updated.' }),
76
76
  tslib_1.__metadata("design:type", Date
77
77
  /** Creator User */
78
78
  )
79
79
  ], DomainLink.prototype, "updatedAt", void 0);
80
80
  tslib_1.__decorate([
81
81
  (0, typeorm_1.ManyToOne)(() => user_js_1.User, { nullable: true }),
82
- (0, type_graphql_1.Field)(() => user_js_1.User, { nullable: true }),
82
+ (0, type_graphql_1.Field)(() => user_js_1.User, { nullable: true, description: 'The user who created the domain link.' }),
83
83
  tslib_1.__metadata("design:type", user_js_1.User)
84
84
  ], DomainLink.prototype, "creator", void 0);
85
85
  tslib_1.__decorate([
@@ -88,7 +88,7 @@ tslib_1.__decorate([
88
88
  ], DomainLink.prototype, "creatorId", void 0);
89
89
  tslib_1.__decorate([
90
90
  (0, typeorm_1.ManyToOne)(() => user_js_1.User, { nullable: true }),
91
- (0, type_graphql_1.Field)(() => user_js_1.User, { nullable: true }),
91
+ (0, type_graphql_1.Field)(() => user_js_1.User, { nullable: true, description: 'The user who last updated the domain link.' }),
92
92
  tslib_1.__metadata("design:type", user_js_1.User)
93
93
  ], DomainLink.prototype, "updater", void 0);
94
94
  tslib_1.__decorate([
@@ -100,6 +100,6 @@ exports.DomainLink = DomainLink = tslib_1.__decorate([
100
100
  (0, typeorm_1.Index)('ix_domain_link_unique', (domainLink) => [domainLink.sourceDomain, domainLink.targetDomain, domainLink.type], { unique: true }),
101
101
  (0, typeorm_1.Index)('ix_domain_link_source', (domainLink) => [domainLink.sourceDomain]),
102
102
  (0, typeorm_1.Index)('ix_domain_link_target', (domainLink) => [domainLink.targetDomain]),
103
- (0, type_graphql_1.ObjectType)({ description: 'Entity for DomainLink representing a connection between two domains' })
103
+ (0, type_graphql_1.ObjectType)({ description: 'Represents a typed relationship between two domains.' })
104
104
  ], DomainLink);
105
105
  //# sourceMappingURL=domain-link.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"domain-link.js","sourceRoot":"","sources":["../../../server/service/domain-link/domain-link.ts"],"names":[],"mappings":";;;;AAAA,qCASgB;AAChB,+CAAsE;AAEtE,6CAA4C;AAC5C,iDAA8C;AAC9C,6CAAsC;AAEtC,MAAM,SAAS,GAAG,YAAM,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AAC7C,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,CAAA;AAEpC,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,6BAAW,CAAA;IACX,yCAAuB,CAAA;IACvB,+BAAa,CAAA;AACf,CAAC,EAJW,cAAc,8BAAd,cAAc,QAIzB;AAED,IAAA,+BAAgB,EAAC,cAAc,EAAE;IAC/B,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,uCAAuC;CACrD,CAAC,CAAA;AAWK,IAAM,UAAU,GAAhB,MAAM,UAAU;CAkEtB,CAAA;AAlEY,gCAAU;AAGZ;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;sCACC;AAKnB;IAFC,IAAA,mBAAS,EAAC,GAAG,EAAE,CAAC,cAAM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,EAAE,CAAC;GACtF,UAAU,CAkEtB","sourcesContent":["import {\n CreateDateColumn,\n UpdateDateColumn,\n Entity,\n Index,\n Column,\n RelationId,\n ManyToOne,\n PrimaryGeneratedColumn\n} from 'typeorm'\nimport { ObjectType, Field, ID, registerEnumType } from 'type-graphql'\n\nimport { config } from '@things-factory/env'\nimport { Domain } from '@things-factory/shell'\nimport { User } from '../user/user.js'\n\nconst ORMCONFIG = config.get('ormconfig', {})\nconst DATABASE_TYPE = ORMCONFIG.type\n\nexport enum DomainLinkType {\n has = 'has',\n maintains = 'maintains',\n owns = 'owns'\n}\n\nregisterEnumType(DomainLinkType, {\n name: 'DomainLinkType',\n description: 'Link type enumeration of a DomainLink'\n})\n\n@Entity()\n@Index(\n 'ix_domain_link_unique',\n (domainLink: DomainLink) => [domainLink.sourceDomain, domainLink.targetDomain, domainLink.type],\n { unique: true }\n)\n@Index('ix_domain_link_source', (domainLink: DomainLink) => [domainLink.sourceDomain])\n@Index('ix_domain_link_target', (domainLink: DomainLink) => [domainLink.targetDomain])\n@ObjectType({ description: 'Entity for DomainLink representing a connection between two domains' })\nexport class DomainLink {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n /** Source Domain */\n @ManyToOne(() => Domain, { nullable: false, onDelete: 'CASCADE' })\n @Field(() => Domain)\n sourceDomain: Domain\n\n @RelationId((domainLink: DomainLink) => domainLink.sourceDomain)\n sourceDomainId: string\n\n /** Target Domain */\n @ManyToOne(() => Domain, { nullable: false, onDelete: 'CASCADE' })\n @Field(() => Domain)\n targetDomain: Domain\n\n @RelationId((domainLink: DomainLink) => domainLink.targetDomain)\n targetDomainId: string\n\n /** Link Type */\n @Column({\n type:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? 'enum'\n : DATABASE_TYPE == 'oracle'\n ? 'varchar2'\n : DATABASE_TYPE == 'mssql'\n ? 'nvarchar'\n : 'varchar',\n enum:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? DomainLinkType\n : undefined,\n length: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb' ? undefined : 32,\n default: DomainLinkType.has\n })\n @Field()\n type: DomainLinkType\n\n /** Creation Timestamp */\n @CreateDateColumn()\n @Field()\n createdAt: Date\n\n /** Last Update Timestamp */\n @UpdateDateColumn()\n @Field()\n updatedAt: Date\n\n /** Creator User */\n @ManyToOne(() => User, { nullable: true })\n @Field(() => User, { nullable: true })\n creator?: User\n\n @RelationId((domainLink: DomainLink) => domainLink.creator)\n creatorId?: string\n\n /** Updater User */\n @ManyToOne(() => User, { nullable: true })\n @Field(() => User, { nullable: true })\n updater?: User\n\n @RelationId((domainLink: DomainLink) => domainLink.updater)\n updaterId?: string\n}\n"]}
1
+ {"version":3,"file":"domain-link.js","sourceRoot":"","sources":["../../../server/service/domain-link/domain-link.ts"],"names":[],"mappings":";;;;AAAA,qCASgB;AAChB,+CAAsE;AAEtE,6CAA4C;AAC5C,iDAA8C;AAC9C,6CAAsC;AAEtC,MAAM,SAAS,GAAG,YAAM,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AAC7C,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,CAAA;AAEpC,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,6BAAW,CAAA;IACX,yCAAuB,CAAA;IACvB,+BAAa,CAAA,CAAC,wCAAwC;AACxD,CAAC,EAJW,cAAc,8BAAd,cAAc,QAIzB;AAED,IAAA,+BAAgB,EAAC,cAAc,EAAE;IAC/B,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,oDAAoD;CAClE,CAAC,CAAA;AAWK,IAAM,UAAU,GAAhB,MAAM,UAAU;CAkEtB,CAAA;AAlEY,gCAAU;AAGZ;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAA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AAE,CAAC,CAAC,UAAU,CAAC,YAAY,EAAE,UAAU,CAAC,YAAY,EAAE,UAAU,CAAC,IAAI,CAAC,EAC/F,EAAE,MAAM,EAAE,IAAI,EAAE,CACjB;IACA,IAAA,eAAK,EAAC,uBAAuB,EAAE,CAAC,UAAsB,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IACrF,IAAA,eAAK,EAAC,uBAAuB,EAAE,CAAC,UAAsB,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IACrF,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,sDAAsD,EAAE,CAAC;GACvE,UAAU,CAkEtB","sourcesContent":["import {\n CreateDateColumn,\n UpdateDateColumn,\n Entity,\n Index,\n Column,\n RelationId,\n ManyToOne,\n PrimaryGeneratedColumn\n} from 'typeorm'\nimport { ObjectType, Field, ID, registerEnumType } from 'type-graphql'\n\nimport { config } from '@things-factory/env'\nimport { Domain } from '@things-factory/shell'\nimport { User } from '../user/user.js'\n\nconst ORMCONFIG = config.get('ormconfig', {})\nconst DATABASE_TYPE = ORMCONFIG.type\n\nexport enum DomainLinkType {\n has = 'has', // Represents a general association or membership.\n maintains = 'maintains', // Represents a relationship where the source domain manages or maintains the target domain.\n owns = 'owns' // Represents an ownership relationship.\n}\n\nregisterEnumType(DomainLinkType, {\n name: 'DomainLinkType',\n description: 'Enumeration of relationship types between domains.'\n})\n\n@Entity()\n@Index(\n 'ix_domain_link_unique',\n (domainLink: DomainLink) => [domainLink.sourceDomain, domainLink.targetDomain, domainLink.type],\n { unique: true }\n)\n@Index('ix_domain_link_source', (domainLink: DomainLink) => [domainLink.sourceDomain])\n@Index('ix_domain_link_target', (domainLink: DomainLink) => [domainLink.targetDomain])\n@ObjectType({ description: 'Represents a typed relationship between two domains.' })\nexport class DomainLink {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { description: 'Unique identifier for the domain link.' })\n readonly id: string\n\n /** Source Domain */\n @ManyToOne(() => Domain, { nullable: false, onDelete: 'CASCADE' })\n @Field(() => Domain, { description: 'The source domain in the relationship.' })\n sourceDomain: Domain\n\n @RelationId((domainLink: DomainLink) => domainLink.sourceDomain)\n sourceDomainId: string\n\n /** Target Domain */\n @ManyToOne(() => Domain, { nullable: false, onDelete: 'CASCADE' })\n @Field(() => Domain, { description: 'The target domain in the relationship.' })\n targetDomain: Domain\n\n @RelationId((domainLink: DomainLink) => domainLink.targetDomain)\n targetDomainId: string\n\n /** Link Type */\n @Column({\n type:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? 'enum'\n : DATABASE_TYPE == 'oracle'\n ? 'varchar2'\n : DATABASE_TYPE == 'mssql'\n ? 'nvarchar'\n : 'varchar',\n enum:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? DomainLinkType\n : undefined,\n length: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb' ? undefined : 32,\n default: DomainLinkType.has\n })\n @Field({ description: 'The type of the relationship (e.g., has, maintains, owns).' })\n type: DomainLinkType\n\n /** Creation Timestamp */\n @CreateDateColumn()\n @Field({ description: 'The timestamp when the domain link was created.' })\n createdAt: Date\n\n /** Last Update Timestamp */\n @UpdateDateColumn()\n @Field({ description: 'The timestamp when the domain link was last updated.' })\n updatedAt: Date\n\n /** Creator User */\n @ManyToOne(() => User, { nullable: true })\n @Field(() => User, { nullable: true, description: 'The user who created the domain link.' })\n creator?: User\n\n @RelationId((domainLink: DomainLink) => domainLink.creator)\n creatorId?: string\n\n /** Updater User */\n @ManyToOne(() => User, { nullable: true })\n @Field(() => User, { nullable: true, description: 'The user who last updated the domain link.' })\n updater?: User\n\n @RelationId((domainLink: DomainLink) => domainLink.updater)\n updaterId?: string\n}\n"]}
@@ -45,7 +45,7 @@ let GrantedRoleMutation = class GrantedRoleMutation {
45
45
  const nonGrantedRoles = await tx.getRepository(role_js_1.Role).find({
46
46
  where: { domain: { id: domain.id }, id: (0, typeorm_1.Not)((0, typeorm_1.In)(grantedRoleIds)) }
47
47
  });
48
- if (nonGrantedRoles === null || nonGrantedRoles === void 0 ? void 0 : nonGrantedRoles.length) {
48
+ if (nonGrantedRoles?.length) {
49
49
  // Find customer's user who has non granted roles already
50
50
  const nonGrantedRoleIds = nonGrantedRoles.map((role) => role.id);
51
51
  let havingRefusedRoleCustomers = await getCustomerUsersByRoles(customerDomain, nonGrantedRoles, tx);
@@ -92,7 +92,7 @@ async function getGrantedCustomerUsers(domain, customerDomain, trx) {
92
92
  async function getCustomerUsersByRoles(customerDomain, roles, trx) {
93
93
  if (!roles.length)
94
94
  return [];
95
- const userRepo = (trx === null || trx === void 0 ? void 0 : trx.getRepository(user_js_1.User)) || (0, shell_1.getRepository)(user_js_1.User);
95
+ const userRepo = trx?.getRepository(user_js_1.User) || (0, shell_1.getRepository)(user_js_1.User);
96
96
  const customerUsers = await userRepo
97
97
  .createQueryBuilder('USER')
98
98
  .select('USER.id')
@@ -114,7 +114,7 @@ async function getCustomerUsersByRoles(customerDomain, roles, trx) {
114
114
  });
115
115
  }
116
116
  async function getGrantedRolesToCustomer(domain, customerDomain, trx) {
117
- const grantedRoleRepo = (trx === null || trx === void 0 ? void 0 : trx.getRepository(granted_role_js_1.GrantedRole)) || (0, shell_1.getRepository)(granted_role_js_1.GrantedRole);
117
+ const grantedRoleRepo = trx?.getRepository(granted_role_js_1.GrantedRole) || (0, shell_1.getRepository)(granted_role_js_1.GrantedRole);
118
118
  const grantedRoleQueryBuilder = grantedRoleRepo.createQueryBuilder('GRANTED_ROLE');
119
119
  return await grantedRoleQueryBuilder
120
120
  .leftJoinAndSelect('GRANTED_ROLE.domain', 'DOMAIN')
@@ -125,16 +125,16 @@ async function getGrantedRolesToCustomer(domain, customerDomain, trx) {
125
125
  .getMany();
126
126
  }
127
127
  async function terminateGrantedRoles(domain, customerDomain, trx) {
128
- const userRepo = (trx === null || trx === void 0 ? void 0 : trx.getRepository(user_js_1.User)) || (0, shell_1.getRepository)(user_js_1.User);
129
- const grantedRoleRepo = (trx === null || trx === void 0 ? void 0 : trx.getRepository(granted_role_js_1.GrantedRole)) || (0, shell_1.getRepository)(granted_role_js_1.GrantedRole);
128
+ const userRepo = trx?.getRepository(user_js_1.User) || (0, shell_1.getRepository)(user_js_1.User);
129
+ const grantedRoleRepo = trx?.getRepository(granted_role_js_1.GrantedRole) || (0, shell_1.getRepository)(granted_role_js_1.GrantedRole);
130
130
  const grantedRoles = await getGrantedRolesToCustomer(domain, customerDomain, trx);
131
131
  const customerUsers = await getGrantedCustomerUsers(domain, customerDomain, trx);
132
132
  for (let i = 0; i < customerUsers.length; i++) {
133
133
  customerUsers[i].roles = customerUsers[i].roles.filter((role) => role.domain.id !== domain.id);
134
134
  }
135
- if (customerUsers === null || customerUsers === void 0 ? void 0 : customerUsers.length)
135
+ if (customerUsers?.length)
136
136
  await userRepo.save(customerUsers);
137
- if (grantedRoles === null || grantedRoles === void 0 ? void 0 : grantedRoles.length)
137
+ if (grantedRoles?.length)
138
138
  await grantedRoleRepo.delete(grantedRoles.map((grantedRole) => grantedRole.id));
139
139
  }
140
140
  //# sourceMappingURL=granted-role-mutation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"granted-role-mutation.js","sourceRoot":"","sources":["../../../server/service/granted-role/granted-role-mutation.ts"],"names":[],"mappings":";;;AAkFA,0DAQC;AAED,0DA4BC;AAkBD,sDAiBC;;AA3JD,+CAAsE;AACtE,qCAA4D;AAE5D,iDAA6D;AAE7D,sDAA+C;AAC/C,6CAAsC;AACtC,yDAAiD;AACjD,6CAAsC;AACtC,uDAA+C;AAGxC,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAIxB,AAAN,KAAK,CAAC,UAAU,CACK,UAAkB,EACF,KAAkB,EAC9C,OAAwB;QAE/B,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,OAA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E,MAAM,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;IAC7D,IAAI,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,MAAM;QAAE,MAAM,eAAe,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,WAAwB,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAA;AACxH,CAAC","sourcesContent":["import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'\nimport { EntityManager, In, Not, Repository } from 'typeorm'\n\nimport { Domain, getRepository } from '@things-factory/shell'\n\nimport { Partner } from '../partner/partner.js'\nimport { Role } from '../role/role.js'\nimport { RolePatch } from '../role/role-types.js'\nimport { User } from '../user/user.js'\nimport { GrantedRole } from './granted-role.js'\n\n@Resolver(GrantedRole)\nexport class GrantedRoleMutation {\n @Directive('@privilege(category: \"partner\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => Boolean)\n async grantRoles(\n @Arg('customerId') customerId: string,\n @Arg('roles', type => [RolePatch]) roles: RolePatch[],\n @Ctx() context: ResolverContext\n ): Promise<Boolean> {\n const { tx, domain } = context.state\n // Check if current domain has partnership with passed `customer`\n const customerDomain: Domain = await tx.getRepository(Domain).findOneBy({ id: customerId })\n const customer: Partner = await tx.getRepository(Partner).findOne({\n where: { domain: { id: domain.id }, partnerDomain: { id: customerDomain.id } }\n })\n\n if (!customer) throw new Error(`Failed to find partnership with customer`)\n\n // Remove existing granted roles\n const grantedRoles: GrantedRole[] = await getGrantedRolesToCustomer(domain, customerDomain, tx)\n if (grantedRoles.length) {\n await tx.getRepository(GrantedRole).delete(grantedRoles.map((gr: GrantedRole) => gr.id))\n }\n\n // Insert newly granted roles\n await tx.getRepository(Role).findBy({\n id: In(roles.map((role: Partial<Role>) => role.id))\n })\n const newlyGrantedRoles: Partial<GrantedRole>[] = roles.map((role: Role) => {\n return {\n domain: customerDomain,\n role\n }\n })\n\n await tx.getRepository(GrantedRole).save(newlyGrantedRoles)\n\n // If there's someone having role which will be removed (refuse roles)\n // user roles should be removed as well\n const grantedRoleIds: string[] = roles.map((role: Partial<Role>) => role.id)\n const nonGrantedRoles: Role[] = await tx.getRepository(Role).find({\n where: { domain: { id: domain.id }, id: Not(In(grantedRoleIds)) }\n })\n\n if (nonGrantedRoles?.length) {\n // Find customer's user who has non granted roles already\n const nonGrantedRoleIds: string[] = nonGrantedRoles.map((role: Role) => role.id)\n\n let havingRefusedRoleCustomers: User[] = await getCustomerUsersByRoles(customerDomain, nonGrantedRoles, tx)\n havingRefusedRoleCustomers = havingRefusedRoleCustomers.map((customerUser: User) => {\n const customerDomains: Domain[] = customerUser.domains\n const customerDomainIds: string[] = customerDomains.map((domain: Domain) => domain.id)\n if (customerDomainIds.indexOf(domain.id) >= 0) {\n // Case for customer user is a member of current domain.\n // If user is a member of current domain user can have any roles of the domain even if the roles is not granted\n return customerUser\n } else {\n // Case for customer user is an user of partner domain.\n // An user of partner domain only can have granted roles\n customerUser.roles = customerUser.roles.filter((role: Role) => nonGrantedRoleIds.indexOf(role.id) < 0)\n return customerUser\n }\n })\n\n await tx.getRepository(User).save(havingRefusedRoleCustomers)\n }\n return true\n }\n}\n\nexport async function getGrantedCustomerUsers(\n domain: Domain,\n customerDomain: Domain,\n trx?: EntityManager\n): Promise<User[]> {\n const grantedRoles: GrantedRole[] = await getGrantedRolesToCustomer(domain, customerDomain, trx)\n const roles: Role[] = grantedRoles.map((grantedRole: GrantedRole) => grantedRole.role)\n return await getCustomerUsersByRoles(customerDomain, roles, trx)\n}\n\nexport async function getCustomerUsersByRoles(\n customerDomain: Domain,\n roles: Role[],\n trx?: EntityManager\n): Promise<User[]> {\n if (!roles.length) return []\n const userRepo: Repository<User> = trx?.getRepository(User) || getRepository(User)\n\n const customerUsers: User[] = await userRepo\n .createQueryBuilder('USER')\n .select('USER.id')\n .distinct(true)\n .leftJoin('USER.domains', 'U_DOMAIN')\n .leftJoin('USER.roles', 'U_ROLE')\n .where('U_DOMAIN.id = :customerDomainId', { customerDomainId: customerDomain.id })\n .groupBy('USER.id')\n .addGroupBy('U_ROLE.id')\n .having('U_ROLE.id IN (:...roleIds)', {\n roleIds: roles.map((role: Role) => role.id)\n })\n .getMany()\n\n return await userRepo.find({\n where: {\n id: In(customerUsers.map((user: User) => user.id))\n },\n relations: ['domains', 'roles', 'roles.domain']\n })\n}\n\nasync function getGrantedRolesToCustomer(\n domain: Domain,\n customerDomain: Domain,\n trx?: EntityManager\n): Promise<GrantedRole[]> {\n const grantedRoleRepo: Repository<GrantedRole> = trx?.getRepository(GrantedRole) || getRepository(GrantedRole)\n const grantedRoleQueryBuilder = grantedRoleRepo.createQueryBuilder('GRANTED_ROLE')\n return await grantedRoleQueryBuilder\n .leftJoinAndSelect('GRANTED_ROLE.domain', 'DOMAIN')\n .leftJoinAndSelect('GRANTED_ROLE.role', 'ROLE')\n .leftJoin('ROLE.domain', 'R_DOMAIN')\n .where('R_DOMAIN.id = :domainId', { domainId: domain.id })\n .andWhere('DOMAIN.id = :customerDomainId', { customerDomainId: customerDomain.id })\n .getMany()\n}\n\nexport async function terminateGrantedRoles(\n domain: Domain,\n customerDomain: Domain,\n trx?: EntityManager\n): Promise<void> {\n const userRepo: Repository<User> = trx?.getRepository(User) || getRepository(User)\n const grantedRoleRepo: Repository<GrantedRole> = trx?.getRepository(GrantedRole) || getRepository(GrantedRole)\n\n const grantedRoles: GrantedRole[] = await getGrantedRolesToCustomer(domain, customerDomain, trx)\n const customerUsers: User[] = await getGrantedCustomerUsers(domain, customerDomain, trx)\n\n for (let i: number = 0; i < customerUsers.length; i++) {\n customerUsers[i].roles = customerUsers[i].roles.filter((role: Role) => role.domain.id !== domain.id)\n }\n\n if (customerUsers?.length) await userRepo.save(customerUsers)\n if (grantedRoles?.length) await grantedRoleRepo.delete(grantedRoles.map((grantedRole: GrantedRole) => grantedRole.id))\n}\n"]}
1
+ {"version":3,"file":"granted-role-mutation.js","sourceRoot":"","sources":["../../../server/service/granted-role/granted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,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAU,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,KAAK,MAAM,CAAC,EAAE,CAAC,CAAA;IACtG,CAAC;IAED,IAAI,aAAa,EAAE,MAAM;QAAE,MAAM,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;IAC7D,IAAI,YAAY,EAAE,MAAM;QAAE,MAAM,eAAe,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,WAAwB,EAAE,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAA;AACxH,CAAC","sourcesContent":["import { Arg, Ctx, Directive, Mutation, Resolver } from 'type-graphql'\nimport { EntityManager, In, Not, Repository } from 'typeorm'\n\nimport { Domain, getRepository } from '@things-factory/shell'\n\nimport { Partner } from '../partner/partner.js'\nimport { Role } from '../role/role.js'\nimport { RolePatch } from '../role/role-types.js'\nimport { User } from '../user/user.js'\nimport { GrantedRole } from './granted-role.js'\n\n@Resolver(GrantedRole)\nexport class GrantedRoleMutation {\n @Directive('@privilege(category: \"partner\", privilege: \"mutation\")')\n @Directive('@transaction')\n @Mutation(returns => Boolean)\n async grantRoles(\n @Arg('customerId') customerId: string,\n @Arg('roles', type => [RolePatch]) roles: RolePatch[],\n @Ctx() context: ResolverContext\n ): Promise<Boolean> {\n const { tx, domain } = context.state\n // Check if current domain has partnership with passed `customer`\n const customerDomain: Domain = await tx.getRepository(Domain).findOneBy({ id: customerId })\n const customer: Partner = await tx.getRepository(Partner).findOne({\n where: { domain: { id: domain.id }, partnerDomain: { id: customerDomain.id } }\n })\n\n if (!customer) throw new Error(`Failed to find partnership with customer`)\n\n // Remove existing granted roles\n const grantedRoles: GrantedRole[] = await getGrantedRolesToCustomer(domain, customerDomain, tx)\n if (grantedRoles.length) {\n await tx.getRepository(GrantedRole).delete(grantedRoles.map((gr: GrantedRole) => gr.id))\n }\n\n // Insert newly granted roles\n await tx.getRepository(Role).findBy({\n id: In(roles.map((role: Partial<Role>) => role.id))\n })\n const newlyGrantedRoles: Partial<GrantedRole>[] = roles.map((role: Role) => {\n return {\n domain: customerDomain,\n role\n }\n })\n\n await tx.getRepository(GrantedRole).save(newlyGrantedRoles)\n\n // If there's someone having role which will be removed (refuse roles)\n // user roles should be removed as well\n const grantedRoleIds: string[] = roles.map((role: Partial<Role>) => role.id)\n const nonGrantedRoles: Role[] = await tx.getRepository(Role).find({\n where: { domain: { id: domain.id }, id: Not(In(grantedRoleIds)) }\n })\n\n if (nonGrantedRoles?.length) {\n // Find customer's user who has non granted roles already\n const nonGrantedRoleIds: string[] = nonGrantedRoles.map((role: Role) => role.id)\n\n let havingRefusedRoleCustomers: User[] = await getCustomerUsersByRoles(customerDomain, nonGrantedRoles, tx)\n havingRefusedRoleCustomers = havingRefusedRoleCustomers.map((customerUser: User) => {\n const customerDomains: Domain[] = customerUser.domains\n const customerDomainIds: string[] = customerDomains.map((domain: Domain) => domain.id)\n if (customerDomainIds.indexOf(domain.id) >= 0) {\n // Case for customer user is a member of current domain.\n // If user is a member of current domain user can have any roles of the domain even if the roles is not granted\n return customerUser\n } else {\n // Case for customer user is an user of partner domain.\n // An user of partner domain only can have granted roles\n customerUser.roles = customerUser.roles.filter((role: Role) => nonGrantedRoleIds.indexOf(role.id) < 0)\n return customerUser\n }\n })\n\n await tx.getRepository(User).save(havingRefusedRoleCustomers)\n }\n return true\n }\n}\n\nexport async function getGrantedCustomerUsers(\n domain: Domain,\n customerDomain: Domain,\n trx?: EntityManager\n): Promise<User[]> {\n const grantedRoles: GrantedRole[] = await getGrantedRolesToCustomer(domain, customerDomain, trx)\n const roles: Role[] = grantedRoles.map((grantedRole: GrantedRole) => grantedRole.role)\n return await getCustomerUsersByRoles(customerDomain, roles, trx)\n}\n\nexport async function getCustomerUsersByRoles(\n customerDomain: Domain,\n roles: Role[],\n trx?: EntityManager\n): Promise<User[]> {\n if (!roles.length) return []\n const userRepo: Repository<User> = trx?.getRepository(User) || getRepository(User)\n\n const customerUsers: User[] = await userRepo\n .createQueryBuilder('USER')\n .select('USER.id')\n .distinct(true)\n .leftJoin('USER.domains', 'U_DOMAIN')\n .leftJoin('USER.roles', 'U_ROLE')\n .where('U_DOMAIN.id = :customerDomainId', { customerDomainId: customerDomain.id })\n .groupBy('USER.id')\n .addGroupBy('U_ROLE.id')\n .having('U_ROLE.id IN (:...roleIds)', {\n roleIds: roles.map((role: Role) => role.id)\n })\n .getMany()\n\n return await userRepo.find({\n where: {\n id: In(customerUsers.map((user: User) => user.id))\n },\n relations: ['domains', 'roles', 'roles.domain']\n })\n}\n\nasync function getGrantedRolesToCustomer(\n domain: Domain,\n customerDomain: Domain,\n trx?: EntityManager\n): Promise<GrantedRole[]> {\n const grantedRoleRepo: Repository<GrantedRole> = trx?.getRepository(GrantedRole) || getRepository(GrantedRole)\n const grantedRoleQueryBuilder = grantedRoleRepo.createQueryBuilder('GRANTED_ROLE')\n return await grantedRoleQueryBuilder\n .leftJoinAndSelect('GRANTED_ROLE.domain', 'DOMAIN')\n .leftJoinAndSelect('GRANTED_ROLE.role', 'ROLE')\n .leftJoin('ROLE.domain', 'R_DOMAIN')\n .where('R_DOMAIN.id = :domainId', { domainId: domain.id })\n .andWhere('DOMAIN.id = :customerDomainId', { customerDomainId: customerDomain.id })\n .getMany()\n}\n\nexport async function terminateGrantedRoles(\n domain: Domain,\n customerDomain: Domain,\n trx?: EntityManager\n): Promise<void> {\n const userRepo: Repository<User> = trx?.getRepository(User) || getRepository(User)\n const grantedRoleRepo: Repository<GrantedRole> = trx?.getRepository(GrantedRole) || getRepository(GrantedRole)\n\n const grantedRoles: GrantedRole[] = await getGrantedRolesToCustomer(domain, customerDomain, trx)\n const customerUsers: User[] = await getGrantedCustomerUsers(domain, customerDomain, trx)\n\n for (let i: number = 0; i < customerUsers.length; i++) {\n customerUsers[i].roles = customerUsers[i].roles.filter((role: Role) => role.domain.id !== domain.id)\n }\n\n if (customerUsers?.length) await userRepo.save(customerUsers)\n if (grantedRoles?.length) await grantedRoleRepo.delete(grantedRoles.map((grantedRole: GrantedRole) => grantedRole.id))\n}\n"]}
@@ -11,12 +11,12 @@ let GrantedRole = class GrantedRole {
11
11
  exports.GrantedRole = GrantedRole;
12
12
  tslib_1.__decorate([
13
13
  (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
14
- (0, type_graphql_1.Field)(type => type_graphql_1.ID),
14
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID, { description: 'Unique identifier for the granted role.' }),
15
15
  tslib_1.__metadata("design:type", String)
16
16
  ], GrantedRole.prototype, "id", void 0);
17
17
  tslib_1.__decorate([
18
18
  (0, typeorm_1.ManyToOne)(type => role_js_1.Role),
19
- (0, type_graphql_1.Field)(),
19
+ (0, type_graphql_1.Field)({ description: 'The role being granted.' }),
20
20
  tslib_1.__metadata("design:type", role_js_1.Role)
21
21
  ], GrantedRole.prototype, "role", void 0);
22
22
  tslib_1.__decorate([
@@ -25,7 +25,7 @@ tslib_1.__decorate([
25
25
  ], GrantedRole.prototype, "roleId", void 0);
26
26
  tslib_1.__decorate([
27
27
  (0, typeorm_1.ManyToOne)(type => shell_1.Domain),
28
- (0, type_graphql_1.Field)(type => shell_1.Domain),
28
+ (0, type_graphql_1.Field)(type => shell_1.Domain, { description: 'The domain to which the role is granted.' }),
29
29
  tslib_1.__metadata("design:type", shell_1.Domain)
30
30
  ], GrantedRole.prototype, "domain", void 0);
31
31
  tslib_1.__decorate([
@@ -35,6 +35,6 @@ tslib_1.__decorate([
35
35
  exports.GrantedRole = GrantedRole = tslib_1.__decorate([
36
36
  (0, typeorm_1.Entity)(),
37
37
  (0, typeorm_1.Index)('ix_granted_role_0', (grantedRole) => [grantedRole.role, grantedRole.domain], { unique: true }),
38
- (0, type_graphql_1.ObjectType)()
38
+ (0, type_graphql_1.ObjectType)({ description: 'Represents a role that is granted to a specific domain.' })
39
39
  ], GrantedRole);
40
40
  //# sourceMappingURL=granted-role.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"granted-role.js","sourceRoot":"","sources":["../../../server/service/granted-role/granted-role.ts"],"names":[],"mappings":";;;;AAAA,iDAA8C;AAC9C,6CAAsC;AACtC,+CAAoD;AACpD,qCAAsF;AAK/E,IAAM,WAAW,GAAjB,MAAM,WAAW;CAkBvB,CAAA;AAlBY,kCAAW;AAGb;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;uCACC;AAInB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAI,CAAC;IACvB,IAAA,oBAAK,GAAE;sCACF,cAAI;yCAAA;AAGV;IADC,IAAA,oBAAU,EAAC,CAAC,WAAwB,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC;;2CAC7C;AAId;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IACzB,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;sCACb,cAAM;2CAAA;AAGf;IADC,IAAA,oBAAU,EAAC,CAAC,WAAwB,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC;;6CAC7C;sBAjBL,WAAW;IAHvB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,mBAAmB,EAAE,CAAC,WAAwB,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAClH,IAAA,yBAAU,GAAE;GACA,WAAW,CAkBvB","sourcesContent":["import { Domain } from '@things-factory/shell'\nimport { Role } from '../role/role.js'\nimport { ObjectType, Field, ID } from 'type-graphql'\nimport { Entity, ManyToOne, PrimaryGeneratedColumn, Index, RelationId } from 'typeorm'\n\n@Entity()\n@Index('ix_granted_role_0', (grantedRole: GrantedRole) => [grantedRole.role, grantedRole.domain], { unique: true })\n@ObjectType()\nexport class GrantedRole {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @ManyToOne(type => Role)\n @Field()\n role: Role\n\n @RelationId((grantedRole: GrantedRole) => grantedRole.role)\n roleId: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain)\n domain?: Domain\n\n @RelationId((grantedRole: GrantedRole) => grantedRole.domain)\n domainId: string\n}\n"]}
1
+ {"version":3,"file":"granted-role.js","sourceRoot":"","sources":["../../../server/service/granted-role/granted-role.ts"],"names":[],"mappings":";;;;AAAA,iDAA8C;AAC9C,6CAAsC;AACtC,+CAAoD;AACpD,qCAAsF;AAK/E,IAAM,WAAW,GAAjB,MAAM,WAAW;CAkBvB,CAAA;AAlBY,kCAAW;AAGb;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,WAAW,EAAE,yCAAyC,EAAE,CAAC;;uCAC3D;AAInB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAI,CAAC;IACvB,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,yBAAyB,EAAE,CAAC;sCAC5C,cAAI;yCAAA;AAGV;IADC,IAAA,oBAAU,EAAC,CAAC,WAAwB,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC;;2CAC7C;AAId;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IACzB,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,EAAE,EAAE,WAAW,EAAE,0CAA0C,EAAE,CAAC;sCAC1E,cAAM;2CAAA;AAGf;IADC,IAAA,oBAAU,EAAC,CAAC,WAAwB,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC;;6CAC7C;sBAjBL,WAAW;IAHvB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,mBAAmB,EAAE,CAAC,WAAwB,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAClH,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,yDAAyD,EAAE,CAAC;GAC1E,WAAW,CAkBvB","sourcesContent":["import { Domain } from '@things-factory/shell'\nimport { Role } from '../role/role.js'\nimport { ObjectType, Field, ID } from 'type-graphql'\nimport { Entity, ManyToOne, PrimaryGeneratedColumn, Index, RelationId } from 'typeorm'\n\n@Entity()\n@Index('ix_granted_role_0', (grantedRole: GrantedRole) => [grantedRole.role, grantedRole.domain], { unique: true })\n@ObjectType({ description: 'Represents a role that is granted to a specific domain.' })\nexport class GrantedRole {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { description: 'Unique identifier for the granted role.' })\n readonly id: string\n\n @ManyToOne(type => Role)\n @Field({ description: 'The role being granted.' })\n role: Role\n\n @RelationId((grantedRole: GrantedRole) => grantedRole.role)\n roleId: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain, { description: 'The domain to which the role is granted.' })\n domain?: Domain\n\n @RelationId((grantedRole: GrantedRole) => grantedRole.domain)\n domainId: string\n}\n"]}
@@ -46,10 +46,14 @@ let InvitationMutation = class InvitationMutation {
46
46
  reference
47
47
  });
48
48
  // update or create
49
- return await invitationRepository.save(Object.assign(Object.assign({ creator: updater }, oldone), { // take only id from oldone for update
49
+ return await invitationRepository.save({
50
+ creator: updater,
51
+ ...oldone, // take only id from oldone for update
50
52
  email,
51
53
  reference,
52
- type, updater: updater }));
54
+ type,
55
+ updater: updater
56
+ });
53
57
  }
54
58
  };
55
59
  exports.InvitationMutation = InvitationMutation;
@@ -1 +1 @@
1
- {"version":3,"file":"invitation-mutation.js","sourceRoot":"","sources":["../../../server/service/invitation/invitation-mutation.ts"],"names":[],"mappings":";;;;AAAA,qCAA+B;AAE/B,+CAA2D;AAC3D,q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M,KAAE,sCAAsC;YACjD,KAAK;YACL,SAAS;YACT,IAAI,EACJ,OAAO,EAAE,OAAO,IAChB,CAAA;IACJ,CAAC;CACF,CAAA;AAjEY,gDAAkB;AAEvB;IADL,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC;IAE1B,mBAAA,IAAA,kBAAG,EAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,qCAAmB,CAAC,CAAA;IACzC,mBAAA,IAAA,kBAAG,EAAC,WAAW,CAAC,CAAA;IAChB,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;;;;0DAWb;AAGK;IADL,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,0BAAU,CAAC;IAE7B,mBAAA,IAAA,kBAAG,EAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,qCAAmB,CAAC,CAAA;IACzC,mBAAA,IAAA,kBAAG,EAAC,WAAW,CAAC,CAAA;IAChB,mBAAA,IAAA,kBAAG,EAAC,MAAM,CAAC,CAAA;IACX,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;wDAyCP;6BAhEU,kBAAkB;IAD9B,IAAA,uBAAQ,EAAC,0BAAU,CAAC;GACR,kBAAkB,CAiE9B","sourcesContent":["import { ILike } from 'typeorm'\n\nimport { Arg, Ctx, Mutation, Resolver } from 'type-graphql'\nimport { GraphQLEmailAddress } from 'graphql-scalars'\n\nimport { getRepository } from '@things-factory/shell'\n\nimport { User, UserStatus } from '../../service/user/user.js'\nimport { sendInvitationEmail } from '../../controllers/invitation.js'\nimport { Invitation } from './invitation.js'\n\n@Resolver(Invitation)\nexport class InvitationMutation {\n @Mutation(returns => Boolean)\n async cancelInvitation(\n @Arg('email', type => GraphQLEmailAddress) email: string,\n @Arg('reference') reference: string,\n @Arg('type') type: string\n ) {\n const repository = getRepository(Invitation)\n\n await repository.delete({\n email,\n reference,\n type\n })\n\n return true\n }\n\n @Mutation(returns => Invitation)\n async sendInvitation(\n @Arg('email', type => GraphQLEmailAddress) email: string,\n @Arg('reference') reference: string,\n @Arg('type') type: string,\n @Ctx() context: ResolverContext\n ) {\n const { user: updater } = context.state\n const invitationRepository = getRepository(Invitation)\n\n var user = await getRepository(User).findOne({\n where: {\n email: ILike(email),\n status: UserStatus.ACTIVATED\n }\n })\n\n if (!user) {\n throw new Error(`user not found: ${email}`)\n }\n\n await sendInvitationEmail({\n invitation: {\n email,\n reference,\n type\n },\n user,\n context\n })\n\n const oldone = await invitationRepository.findOneBy({\n email,\n type,\n reference\n })\n\n // update or create\n return await invitationRepository.save({\n creator: updater,\n ...oldone, // take only id from oldone for update\n email,\n reference,\n type,\n updater: updater\n })\n }\n}\n"]}
1
+ {"version":3,"file":"invitation-mutation.js","sourceRoot":"","sources":["../../../server/service/invitation/invitation-mutation.ts"],"names":[],"mappings":";;;;AAAA,qCAA+B;AAE/B,+CAA2D;AAC3D,qDAAqD;AAErD,iDAAqD;AAErD,wDAA6D;AAC7D,mEAAqE;AACrE,mDAA4C;AAGrC,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAEvB,AAAN,KAAK,CAAC,gBAAgB,CACuB,KAAa,EACtC,SAAiB,EACtB,IAAY;QAEzB,MAAM,UAAU,GAAG,IAAA,qBAAa,EAAC,0BAAU,CAAC,CAAA;QAE5C,MAAM,UAAU,CAAC,MAAM,CAAC;YACtB,KAAK;YACL,SAAS;YACT,IAAI;SACL,CAAC,CAAA;QAEF,OAAO,IAAI,CAAA;IACb,CAAC;IAGK,AAAN,KAAK,CAAC,cAAc,CACyB,KAAa,EACtC,SAAiB,EACtB,IAAY,EAClB,OAAwB;QAE/B,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QACvC,MAAM,oBAAoB,GAAG,IAAA,qBAAa,EAAC,0BAAU,CAAC,CAAA;QAEtD,IAAI,IAAI,GAAG,MAAM,IAAA,qBAAa,EAAC,cAAI,CAAC,CAAC,OAAO,C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CAAC,CAAA;IACX,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;wDAyCP;6BAhEU,kBAAkB;IAD9B,IAAA,uBAAQ,EAAC,0BAAU,CAAC;GACR,kBAAkB,CAiE9B","sourcesContent":["import { ILike } from 'typeorm'\n\nimport { Arg, Ctx, Mutation, Resolver } from 'type-graphql'\nimport { GraphQLEmailAddress } from 'graphql-scalars'\n\nimport { getRepository } from '@things-factory/shell'\n\nimport { User, UserStatus } from '../../service/user/user.js'\nimport { sendInvitationEmail } from '../../controllers/invitation.js'\nimport { Invitation } from './invitation.js'\n\n@Resolver(Invitation)\nexport class InvitationMutation {\n @Mutation(returns => Boolean)\n async cancelInvitation(\n @Arg('email', type => GraphQLEmailAddress) email: string,\n @Arg('reference') reference: string,\n @Arg('type') type: string\n ) {\n const repository = getRepository(Invitation)\n\n await repository.delete({\n email,\n reference,\n type\n })\n\n return true\n }\n\n @Mutation(returns => Invitation)\n async sendInvitation(\n @Arg('email', type => GraphQLEmailAddress) email: string,\n @Arg('reference') reference: string,\n @Arg('type') type: string,\n @Ctx() context: ResolverContext\n ) {\n const { user: updater } = context.state\n const invitationRepository = getRepository(Invitation)\n\n var user = await getRepository(User).findOne({\n where: {\n email: ILike(email),\n status: UserStatus.ACTIVATED\n }\n })\n\n if (!user) {\n throw new Error(`user not found: ${email}`)\n }\n\n await sendInvitationEmail({\n invitation: {\n email,\n reference,\n type\n },\n user,\n context\n })\n\n const oldone = await invitationRepository.findOneBy({\n email,\n type,\n reference\n })\n\n // update or create\n return await invitationRepository.save({\n creator: updater,\n ...oldone, // take only id from oldone for update\n email,\n reference,\n type,\n updater: updater\n })\n }\n}\n"]}
@@ -8,14 +8,14 @@ let InvitationList = class InvitationList {
8
8
  };
9
9
  exports.InvitationList = InvitationList;
10
10
  tslib_1.__decorate([
11
- (0, type_graphql_1.Field)(type => [invitation_js_1.Invitation], { nullable: true }),
11
+ (0, type_graphql_1.Field)(type => [invitation_js_1.Invitation], { nullable: true, description: 'The list of invitation items.' }),
12
12
  tslib_1.__metadata("design:type", Array)
13
13
  ], InvitationList.prototype, "items", void 0);
14
14
  tslib_1.__decorate([
15
- (0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true }),
15
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, { nullable: true, description: 'The total number of invitations.' }),
16
16
  tslib_1.__metadata("design:type", Number)
17
17
  ], InvitationList.prototype, "total", void 0);
18
18
  exports.InvitationList = InvitationList = tslib_1.__decorate([
19
- (0, type_graphql_1.ObjectType)()
19
+ (0, type_graphql_1.ObjectType)({ description: 'A paginated list of invitations.' })
20
20
  ], InvitationList);
21
21
  //# sourceMappingURL=invitation-types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"invitation-types.js","sourceRoot":"","sources":["../../../server/service/invitation/invitation-types.ts"],"names":[],"mappings":";;;;AAAA,mDAA4C;AAC5C,+CAAqD;AAG9C,IAAM,cAAc,GAApB,MAAM,cAAc;CAM1B,CAAA;AANY,wCAAc;AAEzB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,0BAAU,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CAC7B;AAGnB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CAC1B;yBALF,cAAc;IAD1B,IAAA,yBAAU,GAAE;GACA,cAAc,CAM1B","sourcesContent":["import { Invitation } from './invitation.js'\nimport { ObjectType, Field, Int } from 'type-graphql'\n\n@ObjectType()\nexport class InvitationList {\n @Field(type => [Invitation], { nullable: true })\n items: Invitation[]\n\n @Field(type => Int, { nullable: true })\n total: number\n}\n"]}
1
+ {"version":3,"file":"invitation-types.js","sourceRoot":"","sources":["../../../server/service/invitation/invitation-types.ts"],"names":[],"mappings":";;;;AAAA,mDAA4C;AAC5C,+CAAqD;AAG9C,IAAM,cAAc,GAApB,MAAM,cAAc;CAM1B,CAAA;AANY,wCAAc;AAEzB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,0BAAU,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;;6CAC3E;AAGnB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,kCAAkC,EAAE,CAAC;;6CAC3E;yBALF,cAAc;IAD1B,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,kCAAkC,EAAE,CAAC;GACnD,cAAc,CAM1B","sourcesContent":["import { Invitation } from './invitation.js'\nimport { ObjectType, Field, Int } from 'type-graphql'\n\n@ObjectType({ description: 'A paginated list of invitations.' })\nexport class InvitationList {\n @Field(type => [Invitation], { nullable: true, description: 'The list of invitation items.' })\n items: Invitation[]\n\n @Field(type => Int, { nullable: true, description: 'The total number of invitations.' })\n total: number\n}\n"]}
@@ -11,42 +11,42 @@ let Invitation = class Invitation {
11
11
  exports.Invitation = Invitation;
12
12
  tslib_1.__decorate([
13
13
  (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
14
- (0, type_graphql_1.Field)(type => type_graphql_1.ID),
14
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID, { description: 'Unique identifier for the invitation.' }),
15
15
  tslib_1.__metadata("design:type", String)
16
16
  ], Invitation.prototype, "id", void 0);
17
17
  tslib_1.__decorate([
18
18
  (0, typeorm_1.Column)(),
19
- (0, type_graphql_1.Field)(type => graphql_scalars_1.GraphQLEmailAddress),
19
+ (0, type_graphql_1.Field)(type => graphql_scalars_1.GraphQLEmailAddress, { description: 'The email address to which the invitation is sent.' }),
20
20
  tslib_1.__metadata("design:type", String)
21
21
  ], Invitation.prototype, "email", void 0);
22
22
  tslib_1.__decorate([
23
23
  (0, typeorm_1.Column)(),
24
- (0, type_graphql_1.Field)(),
24
+ (0, type_graphql_1.Field)({ description: 'A reference to the resource the user is invited to (e.g., company ID, bizplace ID).' }),
25
25
  tslib_1.__metadata("design:type", String)
26
26
  ], Invitation.prototype, "reference", void 0);
27
27
  tslib_1.__decorate([
28
28
  (0, typeorm_1.Column)(),
29
- (0, type_graphql_1.Field)(),
29
+ (0, type_graphql_1.Field)({ description: 'The type of resource the invitation is for (e.g., company, bizplace).' }),
30
30
  tslib_1.__metadata("design:type", String)
31
31
  ], Invitation.prototype, "type", void 0);
32
32
  tslib_1.__decorate([
33
33
  (0, typeorm_1.Column)(),
34
- (0, type_graphql_1.Field)(),
34
+ (0, type_graphql_1.Field)({ description: 'The unique token used to accept the invitation.' }),
35
35
  tslib_1.__metadata("design:type", String)
36
36
  ], Invitation.prototype, "token", void 0);
37
37
  tslib_1.__decorate([
38
38
  (0, typeorm_1.CreateDateColumn)({ nullable: true }),
39
- (0, type_graphql_1.Field)({ nullable: true }),
39
+ (0, type_graphql_1.Field)({ nullable: true, description: 'The timestamp when the invitation was created.' }),
40
40
  tslib_1.__metadata("design:type", Date)
41
41
  ], Invitation.prototype, "createdAt", void 0);
42
42
  tslib_1.__decorate([
43
43
  (0, typeorm_1.UpdateDateColumn)({ nullable: true }),
44
- (0, type_graphql_1.Field)({ nullable: true }),
44
+ (0, type_graphql_1.Field)({ nullable: true, description: 'The timestamp when the invitation was last updated.' }),
45
45
  tslib_1.__metadata("design:type", Date)
46
46
  ], Invitation.prototype, "updatedAt", void 0);
47
47
  tslib_1.__decorate([
48
48
  (0, typeorm_1.ManyToOne)(type => user_js_1.User, { nullable: true }),
49
- (0, type_graphql_1.Field)({ nullable: true }),
49
+ (0, type_graphql_1.Field)({ nullable: true, description: 'The user who created the invitation.' }),
50
50
  tslib_1.__metadata("design:type", user_js_1.User)
51
51
  ], Invitation.prototype, "creator", void 0);
52
52
  tslib_1.__decorate([
@@ -55,7 +55,7 @@ tslib_1.__decorate([
55
55
  ], Invitation.prototype, "creatorId", void 0);
56
56
  tslib_1.__decorate([
57
57
  (0, typeorm_1.ManyToOne)(type => user_js_1.User, { nullable: true }),
58
- (0, type_graphql_1.Field)({ nullable: true }),
58
+ (0, type_graphql_1.Field)({ nullable: true, description: 'The user who last updated the invitation.' }),
59
59
  tslib_1.__metadata("design:type", user_js_1.User)
60
60
  ], Invitation.prototype, "updater", void 0);
61
61
  tslib_1.__decorate([
@@ -68,6 +68,6 @@ exports.Invitation = Invitation = tslib_1.__decorate([
68
68
  unique: true
69
69
  }),
70
70
  (0, typeorm_1.Index)('ix_invitation_1', (invitation) => [invitation.token], { unique: true }),
71
- (0, type_graphql_1.ObjectType)()
71
+ (0, type_graphql_1.ObjectType)({ description: 'Represents an invitation for a user to join a system or a specific resource.' })
72
72
  ], Invitation);
73
73
  //# sourceMappingURL=invitation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"invitation.js","sourceRoot":"","sources":["../../../server/service/invitation/invitation.ts"],"names":[],"mappings":";;;;AAAA,qCASgB;AAChB,+CAAoD;AACpD,qDAAqD;AACrD,6CAAsC;AAQ/B,IAAM,UAAU,GAAhB,MAAM,UAAU;CA0CtB,CAAA;AA1CY,gCAAU;AAGZ;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;sCACC;AAInB;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,qCAAmB,CAAC;;yCACtB;AAIb;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAK,GAAE;;6CACS;AAIjB;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAK,GAAE;;wCACI;AAIZ;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAK,GAAE;;yCACK;AAIb;IAFC,IAAA,0BAAgB,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACpC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EA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ne,\n RelationId,\n PrimaryGeneratedColumn\n} from 'typeorm'\nimport { ObjectType, Field, ID } from 'type-graphql'\nimport { GraphQLEmailAddress } from 'graphql-scalars'\nimport { User } from '../user/user.js'\n\n@Entity()\n@Index('ix_invitation_0', (invitation: Invitation) => [invitation.email, invitation.reference, invitation.type], {\n unique: true\n})\n@Index('ix_invitation_1', (invitation: Invitation) => [invitation.token], { unique: true })\n@ObjectType()\nexport class Invitation {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @Column()\n @Field(type => GraphQLEmailAddress)\n email: string\n\n @Column()\n @Field()\n reference: string // company, bizplace\n\n @Column()\n @Field()\n type: string // company, bizplace, .. should think whether this column needs.\n\n @Column()\n @Field()\n token: string\n\n @CreateDateColumn({ nullable: true })\n @Field({ nullable: true })\n createdAt: Date\n\n @UpdateDateColumn({ nullable: true })\n @Field({ nullable: true })\n updatedAt: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true })\n creator: User\n\n @RelationId((invitation: Invitation) => invitation.creator)\n creatorId: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true })\n updater: User\n\n @RelationId((invitation: Invitation) => invitation.updater)\n updaterId: string\n}\n"]}
1
+ {"version":3,"file":"invitation.js","sourceRoot":"","sources":["../../../server/service/invitation/invitation.ts"],"names":[],"mappings":";;;;AAAA,qCASgB;AAChB,+CAAoD;AACpD,qDAAqD;AACrD,6CAAsC;AAQ/B,IAAM,UAAU,GAAhB,MAAM,UAAU;CA0CtB,CAAA;AA1CY,gCAAU;AAGZ;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,WAAW,EAAE,uCAAuC,EAAE,CAAC;;sCACzD;AAInB;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,qCAAmB,EAAE,EAAE,WAAW,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AA;AAGb;IADC,IAAA,oBAAU,EAAC,CAAC,UAAsB,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC;;6CAC1C;qBAzCN,UAAU;IANtB,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,iBAAiB,EAAE,CAAC,UAAsB,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,UAAU,CAAC,SAAS,EAAE,UAAU,CAAC,IAAI,CAAC,EAAE;QAC/G,MAAM,EAAE,IAAI;KACb,CAAC;IACD,IAAA,eAAK,EAAC,iBAAiB,EAAE,CAAC,UAAsB,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC1F,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,8EAA8E,EAAE,CAAC;GAC/F,UAAU,CA0CtB","sourcesContent":["import {\n CreateDateColumn,\n UpdateDateColumn,\n Entity,\n Index,\n Column,\n ManyToOne,\n RelationId,\n PrimaryGeneratedColumn\n} from 'typeorm'\nimport { ObjectType, Field, ID } from 'type-graphql'\nimport { GraphQLEmailAddress } from 'graphql-scalars'\nimport { User } from '../user/user.js'\n\n@Entity()\n@Index('ix_invitation_0', (invitation: Invitation) => [invitation.email, invitation.reference, invitation.type], {\n unique: true\n})\n@Index('ix_invitation_1', (invitation: Invitation) => [invitation.token], { unique: true })\n@ObjectType({ description: 'Represents an invitation for a user to join a system or a specific resource.' })\nexport class Invitation {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { description: 'Unique identifier for the invitation.' })\n readonly id: string\n\n @Column()\n @Field(type => GraphQLEmailAddress, { description: 'The email address to which the invitation is sent.' })\n email: string\n\n @Column()\n @Field({ description: 'A reference to the resource the user is invited to (e.g., company ID, bizplace ID).' })\n reference: string // company, bizplace\n\n @Column()\n @Field({ description: 'The type of resource the invitation is for (e.g., company, bizplace).' })\n type: string // company, bizplace, .. should think whether this column needs.\n\n @Column()\n @Field({ description: 'The unique token used to accept the invitation.' })\n token: string\n\n @CreateDateColumn({ nullable: true })\n @Field({ nullable: true, description: 'The timestamp when the invitation was created.' })\n createdAt: Date\n\n @UpdateDateColumn({ nullable: true })\n @Field({ nullable: true, description: 'The timestamp when the invitation was last updated.' })\n updatedAt: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true, description: 'The user who created the invitation.' })\n creator: User\n\n @RelationId((invitation: Invitation) => invitation.creator)\n creatorId: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field({ nullable: true, description: 'The user who last updated the invitation.' })\n updater: User\n\n @RelationId((invitation: Invitation) => invitation.updater)\n updaterId: string\n}\n"]}
@@ -8,14 +8,14 @@ let LoginHistoryList = class LoginHistoryList {
8
8
  };
9
9
  exports.LoginHistoryList = LoginHistoryList;
10
10
  tslib_1.__decorate([
11
- (0, type_graphql_1.Field)(type => [login_history_js_1.LoginHistory]),
11
+ (0, type_graphql_1.Field)(type => [login_history_js_1.LoginHistory], { description: 'The list of login history items.' }),
12
12
  tslib_1.__metadata("design:type", Array)
13
13
  ], LoginHistoryList.prototype, "items", void 0);
14
14
  tslib_1.__decorate([
15
- (0, type_graphql_1.Field)(type => type_graphql_1.Int),
15
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int, { description: 'The total number of login history records.' }),
16
16
  tslib_1.__metadata("design:type", Number)
17
17
  ], LoginHistoryList.prototype, "total", void 0);
18
18
  exports.LoginHistoryList = LoginHistoryList = tslib_1.__decorate([
19
- (0, type_graphql_1.ObjectType)()
19
+ (0, type_graphql_1.ObjectType)({ description: 'A paginated list of login history records.' })
20
20
  ], LoginHistoryList);
21
21
  //# sourceMappingURL=login-history-type.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"login-history-type.js","sourceRoot":"","sources":["../../../server/service/login-history/login-history-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAoE;AAEpE,yDAAiD;AAG1C,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;CAM5B,CAAA;AANY,4CAAgB;AAE3B;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,+BAAY,CAAC,CAAC;;+CACT;AAGrB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC;;+CACN;2BALF,gBAAgB;IAD5B,IAAA,yBAAU,GAAE;GACA,gBAAgB,CAM5B","sourcesContent":["import { Field, ID, InputType, Int, ObjectType } from 'type-graphql'\n\nimport { LoginHistory } from './login-history.js'\n\n@ObjectType()\nexport class LoginHistoryList {\n @Field(type => [LoginHistory])\n items: LoginHistory[]\n\n @Field(type => Int)\n total: number\n}\n"]}
1
+ {"version":3,"file":"login-history-type.js","sourceRoot":"","sources":["../../../server/service/login-history/login-history-type.ts"],"names":[],"mappings":";;;;AAAA,+CAAoE;AAEpE,yDAAiD;AAG1C,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;CAM5B,CAAA;AANY,4CAAgB;AAE3B;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,+BAAY,CAAC,EAAE,EAAE,WAAW,EAAE,kCAAkC,EAAE,CAAC;;+CAC9D;AAGrB;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAG,EAAE,EAAE,WAAW,EAAE,4CAA4C,EAAE,CAAC;;+CACrE;2BALF,gBAAgB;IAD5B,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,4CAA4C,EAAE,CAAC;GAC7D,gBAAgB,CAM5B","sourcesContent":["import { Field, ID, InputType, Int, ObjectType } from 'type-graphql'\n\nimport { LoginHistory } from './login-history.js'\n\n@ObjectType({ description: 'A paginated list of login history records.' })\nexport class LoginHistoryList {\n @Field(type => [LoginHistory], { description: 'The list of login history items.' })\n items: LoginHistory[]\n\n @Field(type => Int, { description: 'The total number of login history records.' })\n total: number\n}\n"]}
@@ -19,12 +19,12 @@ let LoginHistory = LoginHistory_1 = class LoginHistory {
19
19
  exports.LoginHistory = LoginHistory;
20
20
  tslib_1.__decorate([
21
21
  (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
22
- (0, type_graphql_1.Field)(type => type_graphql_1.ID),
22
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID, { description: 'Unique identifier for the login history record.' }),
23
23
  tslib_1.__metadata("design:type", String)
24
24
  ], LoginHistory.prototype, "id", void 0);
25
25
  tslib_1.__decorate([
26
26
  (0, typeorm_1.ManyToOne)(type => shell_1.Domain),
27
- (0, type_graphql_1.Field)(type => shell_1.Domain),
27
+ (0, type_graphql_1.Field)(type => shell_1.Domain, { description: 'The domain the user logged into.' }),
28
28
  tslib_1.__metadata("design:type", shell_1.Domain)
29
29
  ], LoginHistory.prototype, "accessDomain", void 0);
30
30
  tslib_1.__decorate([
@@ -33,7 +33,7 @@ tslib_1.__decorate([
33
33
  ], LoginHistory.prototype, "accessDomainId", void 0);
34
34
  tslib_1.__decorate([
35
35
  (0, typeorm_1.ManyToOne)(type => user_js_1.User),
36
- (0, type_graphql_1.Field)(type => user_js_1.User),
36
+ (0, type_graphql_1.Field)(type => user_js_1.User, { description: 'The user who logged in.' }),
37
37
  tslib_1.__metadata("design:type", user_js_1.User)
38
38
  ], LoginHistory.prototype, "accessUser", void 0);
39
39
  tslib_1.__decorate([
@@ -42,17 +42,17 @@ tslib_1.__decorate([
42
42
  ], LoginHistory.prototype, "accessUserId", void 0);
43
43
  tslib_1.__decorate([
44
44
  (0, typeorm_1.Column)({ nullable: true }),
45
- (0, type_graphql_1.Field)({ nullable: true }),
45
+ (0, type_graphql_1.Field)({ nullable: true, description: 'The IP address from which the login attempt was made.' }),
46
46
  tslib_1.__metadata("design:type", String)
47
47
  ], LoginHistory.prototype, "accessorIp", void 0);
48
48
  tslib_1.__decorate([
49
49
  (0, typeorm_1.CreateDateColumn)(),
50
- (0, type_graphql_1.Field)({ nullable: true }),
50
+ (0, type_graphql_1.Field)({ nullable: true, description: 'The timestamp of the login attempt.' }),
51
51
  tslib_1.__metadata("design:type", Date)
52
52
  ], LoginHistory.prototype, "accessedAt", void 0);
53
53
  exports.LoginHistory = LoginHistory = LoginHistory_1 = tslib_1.__decorate([
54
54
  (0, typeorm_1.Entity)(),
55
55
  (0, typeorm_1.Index)('ix_login_history_0', (loginHistory) => [loginHistory.accessDomain, loginHistory.accessUser]),
56
- (0, type_graphql_1.ObjectType)()
56
+ (0, type_graphql_1.ObjectType)({ description: 'Records user login attempts.' })
57
57
  ], LoginHistory);
58
58
  //# sourceMappingURL=login-history.js.map