@goweekdays/core 2.2.1 → 2.3.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @goweekdays/core
2
2
 
3
+ ## 2.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 5a0cab6: Revamp member and verification management
8
+
9
+ ## 2.2.2
10
+
11
+ ### Patch Changes
12
+
13
+ - 1cd6d1e: Fix sign up and member invite
14
+
3
15
  ## 2.2.1
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -305,30 +305,28 @@ type TMember = {
305
305
  user: string | ObjectId;
306
306
  role: string | ObjectId;
307
307
  roleName?: string;
308
- type: string;
308
+ app: string;
309
309
  status?: string;
310
310
  createdAt?: string | Date;
311
311
  updatedAt?: string | Date;
312
312
  deletedAt?: string | Date;
313
313
  };
314
- declare function MMember(value: TMember): TMember;
315
314
  declare const schemaMember: Joi.ObjectSchema<any>;
315
+ declare const schemaMemberRole: Joi.ObjectSchema<any>;
316
+ declare const schemaMemberStatus: Joi.ObjectSchema<any>;
316
317
  declare function modelMember(value: TMember): TMember;
317
318
 
318
319
  declare function useMemberRepo(): {
319
- createIndex: () => Promise<void>;
320
- createUniqueIndex: () => Promise<void>;
321
- createTextIndex: () => Promise<void>;
322
320
  add: (value: TMember, session?: ClientSession) => Promise<string>;
323
321
  getById: (_id: string | ObjectId) => Promise<TMember | null>;
324
322
  getByRole: (role: string | ObjectId) => Promise<TMember | null>;
325
- getAll: ({ search, limit, page, user, org, type, status }?: {
323
+ getAll: ({ search, limit, page, user, org, app, status }?: {
326
324
  search: string;
327
325
  limit: number;
328
326
  page: number;
329
327
  user?: string | ObjectId | undefined;
330
328
  org?: string | ObjectId | undefined;
331
- type: string;
329
+ app: string;
332
330
  status: string;
333
331
  }) => Promise<Record<string, any>>;
334
332
  getOrgsByUserId: ({ search, page, limit, sort, user, status, }?: {
@@ -365,14 +363,29 @@ declare function useMemberRepo(): {
365
363
  countByOrg: (org: string | ObjectId) => Promise<number>;
366
364
  countByUser: (user: string | ObjectId) => Promise<number>;
367
365
  getByUserType: (user: string | ObjectId, type: string, org?: string | ObjectId) => Promise<TMember | null>;
366
+ getByApp: (options: {
367
+ app: string;
368
+ user?: string | ObjectId;
369
+ org?: string | ObjectId;
370
+ }) => Promise<TMember | null>;
371
+ updateRoleById: (_id: string | ObjectId, value: {
372
+ role: string | ObjectId;
373
+ roleName: string;
374
+ }, session?: ClientSession) => Promise<string>;
375
+ updateStatusById: (_id: string | ObjectId, status: string, session?: ClientSession) => Promise<string>;
376
+ deleteById: (_id: string | ObjectId, session?: ClientSession) => Promise<string>;
368
377
  };
369
378
 
370
379
  declare function useMemberController(): {
380
+ getByApp: (req: Request, res: Response, next: NextFunction) => Promise<void>;
371
381
  getByUserId: (req: Request, res: Response, next: NextFunction) => Promise<void>;
372
382
  getAll: (req: Request, res: Response, next: NextFunction) => Promise<void>;
373
383
  getOrgsByMembership: (req: Request, res: Response, next: NextFunction) => Promise<void>;
374
384
  updateStatusByUserId: (req: Request, res: Response, next: NextFunction) => Promise<void>;
375
385
  getByUserType: (req: Request, res: Response, next: NextFunction) => Promise<void>;
386
+ updateRoleById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
387
+ updateStatusById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
388
+ deleteById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
376
389
  };
377
390
 
378
391
  type TOrg = {
@@ -472,33 +485,31 @@ declare function usePSGCController(): {
472
485
  type TRole = {
473
486
  _id?: ObjectId;
474
487
  id?: string | ObjectId;
475
- name?: string;
488
+ name: string;
476
489
  description?: string;
477
490
  permissions?: Array<string>;
478
491
  org?: string | ObjectId;
492
+ app: string;
479
493
  status?: string;
480
- default?: boolean;
481
494
  createdBy?: string | ObjectId;
482
495
  createdAt?: string | Date;
483
496
  updatedAt?: string | Date;
484
497
  deletedAt?: string | Date;
485
498
  };
486
- type TMiniRole = Pick<TRole, "name" | "permissions">;
487
499
  declare const schemaRole: Joi.ObjectSchema<any>;
500
+ declare const schemaRoleUpdate: Joi.ObjectSchema<any>;
488
501
  declare function modelRole(value: TRole): TRole;
489
502
 
490
503
  declare function useRoleRepo(): {
491
- createIndex: () => Promise<void>;
492
- createTextIndex: () => Promise<void>;
493
- createUniqueIndex: () => Promise<void>;
504
+ createIndexes: () => Promise<void>;
494
505
  addRole: (value: TRole, session?: ClientSession, clearCache?: boolean) => Promise<ObjectId>;
495
- getRoles: ({ search, page, limit, sort, type, id, }?: {
506
+ getRoles: ({ search, page, limit, sort, app, org, }?: {
496
507
  search?: string | undefined;
497
508
  page?: number | undefined;
498
509
  limit?: number | undefined;
499
510
  sort?: any;
500
- type?: string | undefined;
501
- id?: string | ObjectId | undefined;
511
+ app?: string | undefined;
512
+ org?: string | ObjectId | undefined;
502
513
  }) => Promise<{
503
514
  items: any[];
504
515
  pages: number;
@@ -507,7 +518,7 @@ declare function useRoleRepo(): {
507
518
  getRoleByUserId: (value: ObjectId | string) => Promise<TRole | null>;
508
519
  getById: (_id: ObjectId | string) => Promise<mongodb.WithId<bson.Document> | TRole | null>;
509
520
  getRoleByName: (name: string) => Promise<mongodb.WithId<bson.Document> | TRole | null>;
510
- updateRole: (_id: string | ObjectId, value: TMiniRole, session?: ClientSession) => Promise<string>;
521
+ updateRole: (_id: string | ObjectId, value: Pick<TRole, "name" | "permissions" | "description">, session?: ClientSession) => Promise<string>;
511
522
  deleteById: (_id: ObjectId | string, session?: ClientSession) => Promise<string>;
512
523
  updatePermissionsById: (_id: string | ObjectId, permissions: TRole["permissions"], session?: ClientSession) => Promise<string>;
513
524
  delCachedData: () => void;
@@ -527,75 +538,40 @@ declare function useRoleController(): {
527
538
  updatePermissionsById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
528
539
  };
529
540
 
530
- type TUserRole = {
531
- name: string;
532
- app: string;
533
- role: ObjectId | string;
534
- status?: string;
535
- };
536
- declare class MUserRole implements TUserRole {
537
- name: string;
538
- app: string;
539
- role: ObjectId | string;
540
- status?: string;
541
- constructor(value: TUserRole);
542
- }
543
541
  type TUser = {
544
542
  _id?: ObjectId;
545
543
  email: string;
546
544
  password: string;
547
- prefix?: string;
548
545
  firstName: string;
549
546
  middleName?: string;
550
547
  lastName: string;
551
- suffix?: string;
552
- birthMonth?: string;
553
- birthDay?: number;
554
- birthYear?: number;
555
- gender?: string;
556
548
  defaultOrg?: ObjectId | string;
557
- xenditCustomerId?: string;
558
- type?: string;
559
549
  status?: string;
560
- referralCode?: string;
561
- referredBy?: string;
562
- createdAt?: string;
563
- updatedAt?: string;
564
- deletedAt?: string;
550
+ createdAt?: string | Date;
551
+ updatedAt?: string | Date;
552
+ deletedAt?: string | Date;
565
553
  };
566
- declare class MUser implements TUser {
567
- _id?: ObjectId;
554
+ declare const schemaUser: Joi.ObjectSchema<any>;
555
+ declare function modelUser(data: TUser): {
556
+ _id: ObjectId | undefined;
568
557
  email: string;
569
558
  password: string;
570
- prefix?: string;
571
559
  firstName: string;
572
- middleName?: string;
560
+ middleName: string;
573
561
  lastName: string;
574
- suffix?: string;
575
- birthMonth?: string;
576
- birthDay?: number;
577
- birthYear?: number;
578
- gender?: string;
579
- roles?: TUserRole[];
580
- status?: string;
581
- type?: string;
582
- xenditCustomerId?: string | undefined;
583
- referralCode?: string;
584
- referredBy?: string;
585
- createdAt?: string;
586
- updatedAt?: string;
587
- deletedAt?: string;
588
- defaultOrg?: ObjectId | string;
589
- constructor(value: TUser);
590
- }
562
+ defaultOrg: string | ObjectId;
563
+ status: string;
564
+ createdAt: string | Date;
565
+ updatedAt: string | Date;
566
+ deletedAt: string | Date;
567
+ };
591
568
 
592
569
  declare function useUserRepo(): {
593
- createTextIndex: () => Promise<void>;
594
- createUniqueIndex: () => Promise<void>;
595
- createUser: (value: TUser, session?: ClientSession) => Promise<ObjectId>;
570
+ createIndexes: () => Promise<void>;
571
+ add: (value: TUser, session?: ClientSession) => Promise<ObjectId>;
596
572
  getUserByEmail: (email: string) => Promise<TUser | null>;
597
573
  getUserById: (_id: string | ObjectId) => Promise<TUser | null>;
598
- getUsers: ({ search, page, limit, sort, status, type, }?: {
574
+ getAll: ({ search, page, limit, sort, status, type, }?: {
599
575
  search?: string | undefined;
600
576
  page?: number | undefined;
601
577
  limit?: number | undefined;
@@ -623,22 +599,11 @@ declare function useUserRepo(): {
623
599
  field: string;
624
600
  value: string | ObjectId;
625
601
  }, session?: ClientSession) => Promise<mongodb.UpdateResult<bson.Document>>;
626
- addUserRole: ({ _id, role }?: {
627
- _id: string | ObjectId;
628
- role: TUserRole;
629
- }, session?: ClientSession) => Promise<void>;
630
602
  getUserByReferralCode: (referralCode: string) => Promise<TUser | null>;
631
603
  };
632
604
 
633
605
  declare function useUserService(): {
634
- getUsers: ({ search, page, status, type, limit, }?: {
635
- search?: string | undefined;
636
- page?: number | undefined;
637
- status?: string | undefined;
638
- type?: string | undefined;
639
- limit?: number | undefined;
640
- }) => Promise<Record<string, any>>;
641
- createUser: (value: Pick<TUser, "prefix" | "firstName" | "middleName" | "lastName" | "email" | "password" | "suffix">) => Promise<ObjectId>;
606
+ createUser: (value: TUser) => Promise<ObjectId>;
642
607
  resetPassword: (id: string, newPassword: string, passwordConfirmation: string) => Promise<string>;
643
608
  updateName: (_id: string, firstName?: string, lastName?: string) => Promise<string>;
644
609
  updateBirthday: (_id: string, month: string, day: number, year: number) => Promise<string>;
@@ -652,7 +617,7 @@ declare function useUserService(): {
652
617
  user: string;
653
618
  previousProfile?: string | undefined;
654
619
  }) => Promise<string>;
655
- createUserByInvite: ({ id, firstName, lastName, password, }?: {
620
+ addViaInvite: ({ id, firstName, lastName, password, }?: {
656
621
  id?: string | undefined;
657
622
  firstName?: string | undefined;
658
623
  lastName?: string | undefined;
@@ -668,13 +633,13 @@ declare function useUserService(): {
668
633
  };
669
634
 
670
635
  declare function useUserController(): {
671
- getUsers: (req: Request, res: Response, next: NextFunction) => Promise<void>;
636
+ getAll: (req: Request, res: Response, next: NextFunction) => Promise<void>;
672
637
  getUserById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
673
638
  updateName: (req: Request, res: Response, next: NextFunction) => Promise<void>;
674
639
  updateBirthday: (req: Request, res: Response, next: NextFunction) => Promise<void>;
675
640
  updateUserFieldById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
676
641
  updateUserProfile: (req: Request, res: Response, next: NextFunction) => Promise<void>;
677
- createUserByVerification: (req: Request, res: Response, next: NextFunction) => Promise<void>;
642
+ addViaInvite: (req: Request, res: Response, next: NextFunction) => Promise<void>;
678
643
  };
679
644
 
680
645
  declare function useGitHubService(): {
@@ -697,7 +662,7 @@ declare const transactionSchema: Joi.ObjectSchema<any>;
697
662
  type TVerificationMetadata = {
698
663
  name?: string;
699
664
  app?: string;
700
- role?: string;
665
+ role?: string | ObjectId;
701
666
  roleName?: string;
702
667
  referralCode?: string;
703
668
  org?: string | ObjectId;
@@ -709,21 +674,13 @@ type TVerification = {
709
674
  email: string;
710
675
  metadata?: TVerificationMetadata;
711
676
  status?: string;
712
- createdAt: string | Date;
713
- updatedAt?: string | Date | null;
714
- expireAt: string | Date;
677
+ createdAt?: string | Date;
678
+ updatedAt?: string | Date;
679
+ expireAt?: string | Date;
715
680
  };
716
- declare class MVerification implements TVerification {
717
- _id?: ObjectId;
718
- type: string;
719
- email: string;
720
- metadata?: TVerificationMetadata;
721
- status?: string;
722
- createdAt: string | Date;
723
- updatedAt?: string | Date | null;
724
- expireAt: string | Date;
725
- constructor(value: TVerification);
726
- }
681
+ declare const schemaInviteMember: Joi.ObjectSchema<any>;
682
+ declare const schemaVerification: Joi.ObjectSchema<any>;
683
+ declare function modelVerification(value: TVerification): TVerification;
727
684
 
728
685
  declare function useVerificationRepo(): {
729
686
  createIndexes: () => Promise<void>;
@@ -772,8 +729,15 @@ declare function useVerificationService(): {
772
729
  updateStatusById: (_id: string, status: string) => Promise<string>;
773
730
  signUp: ({ email, metadata, }: {
774
731
  email: string;
775
- metadata: Record<string, any>;
732
+ metadata?: TVerificationMetadata | undefined;
733
+ }) => Promise<bson.ObjectId>;
734
+ inviteMember: (value: {
735
+ email: string;
736
+ role: string;
737
+ app: string;
738
+ org?: string;
776
739
  }) => Promise<bson.ObjectId>;
740
+ cancelInviteMember: (id: string) => Promise<string>;
777
741
  };
778
742
 
779
743
  declare function useVerificationController(): {
@@ -782,6 +746,9 @@ declare function useVerificationController(): {
782
746
  createForgetPassword: (req: Request, res: Response, next: NextFunction) => Promise<void>;
783
747
  verify: (req: Request, res: Response, next: NextFunction) => Promise<void>;
784
748
  cancelUserInvitation: (req: Request, res: Response, next: NextFunction) => Promise<Response<any, Record<string, any>> | undefined>;
749
+ inviteMember: (req: Request, res: Response, next: NextFunction) => Promise<void>;
750
+ signUp: (req: Request, res: Response, next: NextFunction) => Promise<void>;
751
+ cancelInviteMember: (req: Request, res: Response, next: NextFunction) => Promise<void>;
785
752
  };
786
753
 
787
754
  type TApp = {
@@ -969,4 +936,4 @@ declare const XENDIT_SECRET_KEY: string;
969
936
  declare const XENDIT_BASE_URL: string;
970
937
  declare const DOMAIN: string;
971
938
 
972
- export { ACCESS_TOKEN_EXPIRY, ACCESS_TOKEN_SECRET, APP_ACCOUNT, APP_MAIN, DEFAULT_USER_EMAIL, DEFAULT_USER_FIRST_NAME, DEFAULT_USER_LAST_NAME, DEFAULT_USER_PASSWORD, DOMAIN, MAILER_EMAIL, MAILER_PASSWORD, MAILER_TRANSPORT_HOST, MAILER_TRANSPORT_PORT, MAILER_TRANSPORT_SECURE, MAddress, MBuilding, MBuildingUnit, MFile, MMember, MONGO_DB, MONGO_URI, MUser, MUserRole, MVerification, PAYPAL_API_URL, PAYPAL_CLIENT_ID, PAYPAL_CLIENT_SECRET, PORT, REDIS_HOST, REDIS_PASSWORD, REDIS_PORT, REFRESH_TOKEN_EXPIRY, REFRESH_TOKEN_SECRET, SECRET_KEY, SPACES_ACCESS_KEY, SPACES_BUCKET, SPACES_ENDPOINT, SPACES_REGION, SPACES_SECRET_KEY, TAddress, TApp, TBuilding, TBuildingUnit, TCounter, TFile, TMember, TMiniRole, TOrg, TPSGC, TPermission, TPermissionGroup, TRole, TUser, TUserRole, TVerification, TVerificationMetadata, VERIFICATION_FORGET_PASSWORD_DURATION, VERIFICATION_USER_INVITE_DURATION, XENDIT_BASE_URL, XENDIT_SECRET_KEY, addressSchema, isDev, modelApp, modelMember, modelOrg, modelPSGC, modelPermission, modelPermissionGroup, modelRole, schemaApp, schemaAppUpdate, schemaBuilding, schemaBuildingUnit, schemaMember, schemaOrg, schemaPSGC, schemaPermission, schemaPermissionGroup, schemaPermissionGroupUpdate, schemaPermissionUpdate, schemaRole, schemaUpdateOptions, transactionSchema, useAddressController, useAddressRepo, useAppController, useAppRepo, useAppService, useAuthController, useAuthService, useBuildingController, useBuildingRepo, useBuildingService, useBuildingUnitController, useBuildingUnitRepo, useBuildingUnitService, useCounterModel, useCounterRepo, useFileController, useFileRepo, useFileService, useGitHubService, useMemberController, useMemberRepo, useOrgController, useOrgRepo, useOrgService, usePSGCController, usePSGCRepo, usePermissionController, usePermissionGroupController, usePermissionGroupRepo, usePermissionGroupService, usePermissionRepo, usePermissionService, useRoleController, useRoleRepo, useRoleService, useUserController, useUserRepo, useUserService, useUtilController, useVerificationController, useVerificationRepo, useVerificationService };
939
+ export { ACCESS_TOKEN_EXPIRY, ACCESS_TOKEN_SECRET, APP_ACCOUNT, APP_MAIN, DEFAULT_USER_EMAIL, DEFAULT_USER_FIRST_NAME, DEFAULT_USER_LAST_NAME, DEFAULT_USER_PASSWORD, DOMAIN, MAILER_EMAIL, MAILER_PASSWORD, MAILER_TRANSPORT_HOST, MAILER_TRANSPORT_PORT, MAILER_TRANSPORT_SECURE, MAddress, MBuilding, MBuildingUnit, MFile, MONGO_DB, MONGO_URI, PAYPAL_API_URL, PAYPAL_CLIENT_ID, PAYPAL_CLIENT_SECRET, PORT, REDIS_HOST, REDIS_PASSWORD, REDIS_PORT, REFRESH_TOKEN_EXPIRY, REFRESH_TOKEN_SECRET, SECRET_KEY, SPACES_ACCESS_KEY, SPACES_BUCKET, SPACES_ENDPOINT, SPACES_REGION, SPACES_SECRET_KEY, TAddress, TApp, TBuilding, TBuildingUnit, TCounter, TFile, TMember, TOrg, TPSGC, TPermission, TPermissionGroup, TRole, TUser, TVerification, TVerificationMetadata, VERIFICATION_FORGET_PASSWORD_DURATION, VERIFICATION_USER_INVITE_DURATION, XENDIT_BASE_URL, XENDIT_SECRET_KEY, addressSchema, isDev, modelApp, modelMember, modelOrg, modelPSGC, modelPermission, modelPermissionGroup, modelRole, modelUser, modelVerification, schemaApp, schemaAppUpdate, schemaBuilding, schemaBuildingUnit, schemaInviteMember, schemaMember, schemaMemberRole, schemaMemberStatus, schemaOrg, schemaPSGC, schemaPermission, schemaPermissionGroup, schemaPermissionGroupUpdate, schemaPermissionUpdate, schemaRole, schemaRoleUpdate, schemaUpdateOptions, schemaUser, schemaVerification, transactionSchema, useAddressController, useAddressRepo, useAppController, useAppRepo, useAppService, useAuthController, useAuthService, useBuildingController, useBuildingRepo, useBuildingService, useBuildingUnitController, useBuildingUnitRepo, useBuildingUnitService, useCounterModel, useCounterRepo, useFileController, useFileRepo, useFileService, useGitHubService, useMemberController, useMemberRepo, useOrgController, useOrgRepo, useOrgService, usePSGCController, usePSGCRepo, usePermissionController, usePermissionGroupController, usePermissionGroupRepo, usePermissionGroupService, usePermissionRepo, usePermissionService, useRoleController, useRoleRepo, useRoleService, useUserController, useUserRepo, useUserService, useUtilController, useVerificationController, useVerificationRepo, useVerificationService };