@punks/backend-entity-manager 0.0.407 → 0.0.409

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.
@@ -7,7 +7,10 @@ export declare class UserInvitationSendHandler {
7
7
  private readonly emailService;
8
8
  private readonly jwtProvider;
9
9
  constructor(services: AuthenticationServicesResolver, emailService: EmailService, jwtProvider: JwtProvider);
10
- execute(input: UserInvitationSendInput): Promise<void>;
10
+ execute(input: UserInvitationSendInput): Promise<{
11
+ token: string;
12
+ callbackUrl: string;
13
+ }>;
11
14
  private sendRegistrationEmail;
12
15
  private generateEmailVerifyToken;
13
16
  }
@@ -2,6 +2,10 @@ import { UserRegisterCallbackTemplate } from "../user-register/types";
2
2
  export type UserInvitationSendInput = {
3
3
  userId: string;
4
4
  callback: UserRegisterCallbackTemplate;
5
+ } & ({
6
+ emailTemplateId: string;
5
7
  languageId: string;
6
- emailTemplateId?: string;
7
- };
8
+ } | {
9
+ emailTemplateId?: undefined;
10
+ languageId?: string;
11
+ });
@@ -45,7 +45,10 @@ export declare class AuthenticationService implements IAuthService {
45
45
  private readonly resolver;
46
46
  constructor(userCreationHandler: UserCreationHandler, userDisableHandler: UserDisableHandler, userDeleteHandler: UserDeleteHandler, userEnableHandler: UserEnableHandler, userImpersonateHandler: UserImpersonateHandler, userLoginHandler: UserLoginHandler, userPasswordChangeHandler: UserPasswordChangeHandler, userPasswordResetFinalizeHandler: UserPasswordResetCompleteHandler, userPasswordResetRequestHandler: UserPasswordResetRequestHandler, userRegistrationHandler: UserRegistrationHandler, userTokenVerifyHandler: UserTokenVerifyHandler, userVerifyRequestHandler: UserVerifyRequestHandler, userVerifyCompleteHandler: UserVerifyCompleteHandler, userInvitationHandler: UserInvitationSendHandler, resolver: AuthenticationServicesResolver);
47
47
  userCreate<TUserRegistrationInfo, TUserContext extends IAuthUserContext>(input: UserCreationInput<TUserRegistrationInfo, TUserContext>): Promise<import("../../handlers").UserCreationResult>;
48
- userInvitationSend(input: UserInvitationSendInput): Promise<void>;
48
+ userInvite(input: UserInvitationSendInput): Promise<{
49
+ token: string;
50
+ callbackUrl: string;
51
+ }>;
49
52
  userDisable(input: UserDisableInput): Promise<void>;
50
53
  userDelete(input: UserDeleteInput): Promise<void>;
51
54
  userEnable(input: UserEnableInput): Promise<void>;
package/dist/esm/index.js CHANGED
@@ -23750,18 +23750,20 @@ let UserInvitationSendHandler = class UserInvitationSendHandler {
23750
23750
  if (!user) {
23751
23751
  throw new Error(`User not found ${input.userId}`);
23752
23752
  }
23753
- await this.sendRegistrationEmail({
23754
- user,
23755
- callback: {
23756
- tokenPlaceholder: input.callback.tokenPlaceholder,
23757
- urlTemplate: input.callback.urlTemplate,
23758
- },
23759
- languageId: input.languageId,
23760
- emailTemplateId: input.emailTemplateId,
23761
- });
23762
- }
23763
- async sendRegistrationEmail({ user, callback, languageId, emailTemplateId, }) {
23764
23753
  const token = await this.generateEmailVerifyToken(user);
23754
+ const callbackUrl = input.callback.urlTemplate.replace(input.callback.tokenPlaceholder, token);
23755
+ if (input.emailTemplateId) {
23756
+ await this.sendRegistrationEmail({
23757
+ user,
23758
+ callbackUrl,
23759
+ languageId: input.languageId,
23760
+ emailTemplateId: input.emailTemplateId,
23761
+ token,
23762
+ });
23763
+ }
23764
+ return { token, callbackUrl };
23765
+ }
23766
+ async sendRegistrationEmail({ user, callbackUrl, languageId, emailTemplateId, }) {
23765
23767
  await this.emailService.sendTemplatedEmail({
23766
23768
  to: [user.email],
23767
23769
  templateId: emailTemplateId ?? AuthenticationEmailTemplates.Registration,
@@ -23769,7 +23771,7 @@ let UserInvitationSendHandler = class UserInvitationSendHandler {
23769
23771
  payload: {
23770
23772
  firstName: user.profile.firstName,
23771
23773
  lastName: user.profile.lastName,
23772
- callbackUrl: callback.urlTemplate.replace(callback.tokenPlaceholder, token),
23774
+ callbackUrl,
23773
23775
  },
23774
23776
  });
23775
23777
  }
@@ -23809,8 +23811,8 @@ let AuthenticationService = class AuthenticationService {
23809
23811
  async userCreate(input) {
23810
23812
  return await this.userCreationHandler.execute(input);
23811
23813
  }
23812
- async userInvitationSend(input) {
23813
- await this.userInvitationHandler.execute(input);
23814
+ async userInvite(input) {
23815
+ return await this.userInvitationHandler.execute(input);
23814
23816
  }
23815
23817
  async userDisable(input) {
23816
23818
  await this.userDisableHandler.execute(input);