@punks/backend-entity-manager 0.0.58 → 0.0.61

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.
package/dist/cjs/index.js CHANGED
@@ -179,7 +179,7 @@ const WpEntity = (name, props = {}) => common.applyDecorators(common.SetMetadata
179
179
  ...props,
180
180
  }));
181
181
 
182
- const WpAppInitializer = () => common.applyDecorators(common.Injectable(), common.SetMetadata(EntityManagerSymbols.AppInitializer, true));
182
+ const WpAppInitializer = (props = {}) => common.applyDecorators(common.Injectable(), common.SetMetadata(EntityManagerSymbols.AppInitializer, props));
183
183
 
184
184
  const WpEntityRepository = (entityName, props = {}) => common.applyDecorators(common.Injectable(), common.SetMetadata(EntityManagerSymbols.EntityRepository, {
185
185
  entityName,
@@ -19086,11 +19086,13 @@ let UserRegistrationHandler = class UserRegistrationHandler {
19086
19086
  this.passwordHashingProvider = passwordHashingProvider;
19087
19087
  this.emailService = emailService;
19088
19088
  this.jwtProvider = jwtProvider;
19089
+ this.logger = backendCore.Log.getLogger("UserRegistration");
19089
19090
  }
19090
19091
  async execute(input) {
19091
19092
  const user = (await this.resolveUser(input.email, input.context)) ??
19092
19093
  (await this.resolveUser(input.userName, input.context));
19093
19094
  if (user && user.verified) {
19095
+ this.logger.debug(`User already exists: ${input.email} - ${input.userName}`, { user });
19094
19096
  return {
19095
19097
  success: false,
19096
19098
  error: exports.UserRegistrationError.UserAlreadyExists,
@@ -19103,6 +19105,7 @@ let UserRegistrationHandler = class UserRegistrationHandler {
19103
19105
  passwordUpdateTimestamp: new Date(),
19104
19106
  });
19105
19107
  await this.sendRegistrationEmail(user, input.callback, input.languageId);
19108
+ this.logger.debug(`User already exists but not verified. Sending new verification email: ${input.email} - ${input.userName}`, { user });
19106
19109
  return {
19107
19110
  success: true,
19108
19111
  };
@@ -19114,6 +19117,9 @@ let UserRegistrationHandler = class UserRegistrationHandler {
19114
19117
  passwordUpdateTimestamp: new Date(),
19115
19118
  });
19116
19119
  await this.sendRegistrationEmail(newUser, input.callback, input.languageId);
19120
+ this.logger.debug(`New user created: ${input.email} - ${input.userName}`, {
19121
+ user: newUser,
19122
+ });
19117
19123
  return {
19118
19124
  success: true,
19119
19125
  };
@@ -19551,8 +19557,7 @@ const Services = [
19551
19557
  const IoC = [exports.EntityManagerRegistry];
19552
19558
 
19553
19559
  let NestEventEmitter = class NestEventEmitter {
19554
- constructor() { }
19555
- setEmitter(eventEmitter) {
19560
+ constructor(eventEmitter) {
19556
19561
  this.eventEmitter = eventEmitter;
19557
19562
  }
19558
19563
  async emit(event, ...args) {
@@ -19561,7 +19566,7 @@ let NestEventEmitter = class NestEventEmitter {
19561
19566
  };
19562
19567
  NestEventEmitter = __decorate([
19563
19568
  common.Injectable(),
19564
- __metadata("design:paramtypes", [])
19569
+ __metadata("design:paramtypes", [eventEmitter.EventEmitter2])
19565
19570
  ], NestEventEmitter);
19566
19571
 
19567
19572
  class EmailTemplatesCollection {
@@ -19654,7 +19659,8 @@ exports.EntityManagerInitializer = EntityManagerInitializer_1 = class EntityMana
19654
19659
  }
19655
19660
  async executeInitializers(app) {
19656
19661
  const initializers = await this.discoverAppInitializers();
19657
- for (const initializer of initializers) {
19662
+ const sortedInitializers = backendCore.sort(initializers, backendCore.byField((x) => x.meta.priority ?? Number.MAX_VALUE), backendCore.byField((x) => x.discoveredClass.name));
19663
+ for (const initializer of sortedInitializers) {
19658
19664
  await initializer.discoveredClass.instance.initialize(app);
19659
19665
  this.logger.log(`Entity manager app initializer ${initializer.discoveredClass.name} initialized 💪`);
19660
19666
  }
@@ -19701,7 +19707,6 @@ exports.EntityManagerInitializer = EntityManagerInitializer_1 = class EntityMana
19701
19707
  app
19702
19708
  .get(exports.ModulesContainerProvider)
19703
19709
  .setModulesContainer(staticProviders.modulesContainer);
19704
- app.get(NestEventEmitter).setEmitter(staticProviders.eventEmitter);
19705
19710
  }
19706
19711
  async discoverRepositories() {
19707
19712
  return await this.discover.providersWithMetaAtKey(EntityManagerSymbols.EntityRepository);