@punks/backend-entity-manager 0.0.56 → 0.0.60

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.
@@ -23,6 +23,7 @@ export declare class UserLoginResponse {
23
23
  }
24
24
  export declare class UserRegisterRequest {
25
25
  email: string;
26
+ userName: string;
26
27
  password: string;
27
28
  data: UserRegistrationData;
28
29
  userContext: UserContext;
@@ -1 +1,4 @@
1
- export declare const WpAppInitializer: () => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol | undefined, descriptor?: TypedPropertyDescriptor<Y> | undefined) => void;
1
+ export interface WpAppInitializerProps {
2
+ priority?: number;
3
+ }
4
+ export declare const WpAppInitializer: (props?: WpAppInitializerProps) => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol | undefined, descriptor?: TypedPropertyDescriptor<Y> | undefined) => void;
@@ -6,6 +6,7 @@ export type UserRegisterCallbackTemplate = {
6
6
  };
7
7
  export interface UserRegistrationInput<TUserRegistrationInfo, TUserContext extends IUserContext> {
8
8
  email: string;
9
+ userName: string;
9
10
  password: string;
10
11
  registrationInfo: TUserRegistrationInfo;
11
12
  callback: UserRegisterCallbackTemplate;
@@ -2,7 +2,6 @@ import { EventEmitter2 } from "@nestjs/event-emitter";
2
2
  import { IEventEmitter } from "../../../../abstractions/events";
3
3
  export declare class NestEventEmitter implements IEventEmitter {
4
4
  private eventEmitter;
5
- constructor();
6
- setEmitter(eventEmitter: EventEmitter2): void;
5
+ constructor(eventEmitter: EventEmitter2);
7
6
  emit(event: string, ...args: any[]): Promise<void>;
8
7
  }
package/dist/esm/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { applyDecorators, Injectable, SetMetadata, Global, Module, Scope, Logger, HttpStatus, HttpException } from '@nestjs/common';
2
2
  import { AsyncLocalStorage } from 'async_hooks';
3
3
  import { hash } from 'bcrypt';
4
- import { Log, toDict, newUuid as newUuid$1, removeUndefinedProps } from '@punks/backend-core';
4
+ import { Log, toDict, sort, byField, newUuid as newUuid$1, removeUndefinedProps } from '@punks/backend-core';
5
5
  import { PATH_METADATA } from '@nestjs/common/constants';
6
6
  import { STATIC_CONTEXT } from '@nestjs/core/injector/constants';
7
7
  import { MetadataScanner } from '@nestjs/core/metadata-scanner';
8
8
  import { JwtService, JwtModule } from '@nestjs/jwt';
9
- import { EventEmitterModule } from '@nestjs/event-emitter';
9
+ import { EventEmitter2, EventEmitterModule } from '@nestjs/event-emitter';
10
10
  import { In } from 'typeorm';
11
11
  import { Reflector } from '@nestjs/core';
12
12
  import { SendEmailCommand, SESClient } from '@aws-sdk/client-ses';
@@ -171,7 +171,7 @@ const WpEntity = (name, props = {}) => applyDecorators(SetMetadata(EntityManager
171
171
  ...props,
172
172
  }));
173
173
 
174
- const WpAppInitializer = () => applyDecorators(Injectable(), SetMetadata(EntityManagerSymbols.AppInitializer, true));
174
+ const WpAppInitializer = (props = {}) => applyDecorators(Injectable(), SetMetadata(EntityManagerSymbols.AppInitializer, props));
175
175
 
176
176
  const WpEntityRepository = (entityName, props = {}) => applyDecorators(Injectable(), SetMetadata(EntityManagerSymbols.EntityRepository, {
177
177
  entityName,
@@ -19080,7 +19080,8 @@ let UserRegistrationHandler = class UserRegistrationHandler {
19080
19080
  this.jwtProvider = jwtProvider;
19081
19081
  }
19082
19082
  async execute(input) {
19083
- const user = await this.resolveUser(input.email, input.context);
19083
+ const user = (await this.resolveUser(input.email, input.context)) ??
19084
+ (await this.resolveUser(input.userName, input.context));
19084
19085
  if (user && user.verified) {
19085
19086
  return {
19086
19087
  success: false,
@@ -19542,17 +19543,19 @@ const Services = [
19542
19543
  const IoC = [EntityManagerRegistry];
19543
19544
 
19544
19545
  let NestEventEmitter = class NestEventEmitter {
19545
- constructor() { }
19546
- setEmitter(eventEmitter) {
19546
+ constructor(eventEmitter) {
19547
19547
  this.eventEmitter = eventEmitter;
19548
19548
  }
19549
+ // setEmitter(eventEmitter: EventEmitter2) {
19550
+ // this.eventEmitter = eventEmitter
19551
+ // }
19549
19552
  async emit(event, ...args) {
19550
19553
  await this.eventEmitter.emitAsync(event, ...args);
19551
19554
  }
19552
19555
  };
19553
19556
  NestEventEmitter = __decorate([
19554
19557
  Injectable(),
19555
- __metadata("design:paramtypes", [])
19558
+ __metadata("design:paramtypes", [EventEmitter2])
19556
19559
  ], NestEventEmitter);
19557
19560
 
19558
19561
  class EmailTemplatesCollection {
@@ -19645,7 +19648,8 @@ let EntityManagerInitializer = EntityManagerInitializer_1 = class EntityManagerI
19645
19648
  }
19646
19649
  async executeInitializers(app) {
19647
19650
  const initializers = await this.discoverAppInitializers();
19648
- for (const initializer of initializers) {
19651
+ const sortedInitializers = sort(initializers, byField((x) => x.meta.priority ?? Number.MAX_VALUE), byField((x) => x.discoveredClass.name));
19652
+ for (const initializer of sortedInitializers) {
19649
19653
  await initializer.discoveredClass.instance.initialize(app);
19650
19654
  this.logger.log(`Entity manager app initializer ${initializer.discoveredClass.name} initialized 💪`);
19651
19655
  }
@@ -19692,7 +19696,7 @@ let EntityManagerInitializer = EntityManagerInitializer_1 = class EntityManagerI
19692
19696
  app
19693
19697
  .get(ModulesContainerProvider)
19694
19698
  .setModulesContainer(staticProviders.modulesContainer);
19695
- app.get(NestEventEmitter).setEmitter(staticProviders.eventEmitter);
19699
+ // app.get(NestEventEmitter).setEmitter(staticProviders.eventEmitter)
19696
19700
  }
19697
19701
  async discoverRepositories() {
19698
19702
  return await this.discover.providersWithMetaAtKey(EntityManagerSymbols.EntityRepository);