@punks/backend-entity-manager 0.0.406 → 0.0.408

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
  }
@@ -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>;
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import { DataExportFile, DataExportInput } from "./types";
2
3
  import { EntityManagerRegistry } from "../../ioc/registry";
3
4
  export declare class DataExportService {
@@ -5,10 +6,15 @@ export declare class DataExportService {
5
6
  constructor(registry: EntityManagerRegistry);
6
7
  exportData<TSheetItem>(data: TSheetItem[], input: DataExportInput<TSheetItem>): Promise<{
7
8
  downloadUrl: import("../../../../abstractions/files").FileProviderDownloadUrl;
8
- file: DataExportFile;
9
+ file: {
10
+ fileName: string;
11
+ content: Buffer;
12
+ contentType: string;
13
+ };
9
14
  }>;
10
15
  extractData<TSheetItem>(data: TSheetItem[], input: Omit<DataExportInput<TSheetItem>, "fileName">): Promise<DataExportFile>;
11
16
  private uploadExportFile;
17
+ private buildExportFileName;
12
18
  private buildExportFilePath;
13
19
  private get defaultFileProvider();
14
20
  private get defaultBucketProvider();
package/dist/esm/index.js CHANGED
@@ -22850,14 +22850,18 @@ let DataExportService = class DataExportService {
22850
22850
  }
22851
22851
  async exportData(data, input) {
22852
22852
  const file = await this.extractData(data, input);
22853
- const downloadUrl = await this.uploadExportFile(file, {
22853
+ const { downloadUrl, fileName } = await this.uploadExportFile(file, {
22854
22854
  dataName: input.dataName,
22855
22855
  fileName: input.fileName,
22856
22856
  format: input.format,
22857
22857
  });
22858
22858
  return {
22859
22859
  downloadUrl,
22860
- file,
22860
+ file: {
22861
+ fileName,
22862
+ content: file.content,
22863
+ contentType: file.contentType,
22864
+ },
22861
22865
  };
22862
22866
  }
22863
22867
  async extractData(data, input) {
@@ -22872,19 +22876,27 @@ let DataExportService = class DataExportService {
22872
22876
  };
22873
22877
  }
22874
22878
  async uploadExportFile(file, { dataName, fileName, format, }) {
22875
- const filePath = this.buildExportFilePath(dataName, fileName, format);
22879
+ const fileNameWithExtension = this.buildExportFileName(fileName, format);
22880
+ const filePath = this.buildExportFilePath(dataName, fileNameWithExtension);
22876
22881
  await this.defaultBucketProvider.fileUpload({
22877
22882
  bucket: this.defaultFileProvider.defaultBucket,
22878
22883
  filePath,
22879
22884
  content: file.content,
22880
22885
  contentType: file.contentType,
22881
22886
  });
22882
- return await this.defaultFileProvider.getFileProviderDownloadUrl({
22887
+ const downloadUrl = await this.defaultFileProvider.getFileProviderDownloadUrl({
22883
22888
  reference: filePath,
22884
22889
  });
22890
+ return {
22891
+ downloadUrl,
22892
+ fileName: fileNameWithExtension,
22893
+ };
22894
+ }
22895
+ buildExportFileName(fileName, format) {
22896
+ return `${fileName}.${format}`;
22885
22897
  }
22886
- buildExportFilePath(dataName, fileName, format) {
22887
- return `/data-export/${dataName}/${createDayPath$2(new Date())}/${newUuid$1()}_${fileName}.${format}`;
22898
+ buildExportFilePath(dataName, fileName) {
22899
+ return `/data-export/${dataName}/${createDayPath$2(new Date())}/${newUuid$1()}_${fileName}`;
22888
22900
  }
22889
22901
  get defaultFileProvider() {
22890
22902
  return this.registry
@@ -23738,18 +23750,20 @@ let UserInvitationSendHandler = class UserInvitationSendHandler {
23738
23750
  if (!user) {
23739
23751
  throw new Error(`User not found ${input.userId}`);
23740
23752
  }
23741
- await this.sendRegistrationEmail({
23742
- user,
23743
- callback: {
23744
- tokenPlaceholder: input.callback.tokenPlaceholder,
23745
- urlTemplate: input.callback.urlTemplate,
23746
- },
23747
- languageId: input.languageId,
23748
- emailTemplateId: input.emailTemplateId,
23749
- });
23750
- }
23751
- async sendRegistrationEmail({ user, callback, languageId, emailTemplateId, }) {
23752
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, }) {
23753
23767
  await this.emailService.sendTemplatedEmail({
23754
23768
  to: [user.email],
23755
23769
  templateId: emailTemplateId ?? AuthenticationEmailTemplates.Registration,
@@ -23757,7 +23771,7 @@ let UserInvitationSendHandler = class UserInvitationSendHandler {
23757
23771
  payload: {
23758
23772
  firstName: user.profile.firstName,
23759
23773
  lastName: user.profile.lastName,
23760
- callbackUrl: callback.urlTemplate.replace(callback.tokenPlaceholder, token),
23774
+ callbackUrl,
23761
23775
  },
23762
23776
  });
23763
23777
  }
@@ -23797,8 +23811,8 @@ let AuthenticationService = class AuthenticationService {
23797
23811
  async userCreate(input) {
23798
23812
  return await this.userCreationHandler.execute(input);
23799
23813
  }
23800
- async userInvitationSend(input) {
23801
- await this.userInvitationHandler.execute(input);
23814
+ async userInvite(input) {
23815
+ return await this.userInvitationHandler.execute(input);
23802
23816
  }
23803
23817
  async userDisable(input) {
23804
23818
  await this.userDisableHandler.execute(input);