@goweekdays/core 2.2.0 → 2.2.2

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.2.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 1cd6d1e: Fix sign up and member invite
8
+
9
+ ## 2.2.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 5973888: Fix org creation
14
+
3
15
  ## 2.2.0
4
16
 
5
17
  ### Minor Changes
package/dist/index.d.ts CHANGED
@@ -305,13 +305,14 @@ 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
- createdAt?: string;
311
- updatedAt?: string;
312
- deletedAt?: string;
310
+ createdAt?: string | Date;
311
+ updatedAt?: string | Date;
312
+ deletedAt?: string | Date;
313
313
  };
314
- declare function MMember(value: TMember): TMember;
314
+ declare const schemaMember: Joi.ObjectSchema<any>;
315
+ declare function modelMember(value: TMember): TMember;
315
316
 
316
317
  declare function useMemberRepo(): {
317
318
  createIndex: () => Promise<void>;
@@ -320,13 +321,13 @@ declare function useMemberRepo(): {
320
321
  add: (value: TMember, session?: ClientSession) => Promise<string>;
321
322
  getById: (_id: string | ObjectId) => Promise<TMember | null>;
322
323
  getByRole: (role: string | ObjectId) => Promise<TMember | null>;
323
- getAll: ({ search, limit, page, user, org, type, status }?: {
324
+ getAll: ({ search, limit, page, user, org, app, status }?: {
324
325
  search: string;
325
326
  limit: number;
326
327
  page: number;
327
328
  user?: string | ObjectId | undefined;
328
329
  org?: string | ObjectId | undefined;
329
- type: string;
330
+ app: string;
330
331
  status: string;
331
332
  }) => Promise<Record<string, any>>;
332
333
  getOrgsByUserId: ({ search, page, limit, sort, user, status, }?: {
@@ -363,9 +364,15 @@ declare function useMemberRepo(): {
363
364
  countByOrg: (org: string | ObjectId) => Promise<number>;
364
365
  countByUser: (user: string | ObjectId) => Promise<number>;
365
366
  getByUserType: (user: string | ObjectId, type: string, org?: string | ObjectId) => Promise<TMember | null>;
367
+ getByApp: (options: {
368
+ app: string;
369
+ user?: string | ObjectId;
370
+ org?: string | ObjectId;
371
+ }) => Promise<TMember | null>;
366
372
  };
367
373
 
368
374
  declare function useMemberController(): {
375
+ getByApp: (req: Request, res: Response, next: NextFunction) => Promise<void>;
369
376
  getByUserId: (req: Request, res: Response, next: NextFunction) => Promise<void>;
370
377
  getAll: (req: Request, res: Response, next: NextFunction) => Promise<void>;
371
378
  getOrgsByMembership: (req: Request, res: Response, next: NextFunction) => Promise<void>;
@@ -376,8 +383,7 @@ declare function useMemberController(): {
376
383
  type TOrg = {
377
384
  _id?: ObjectId;
378
385
  name: string;
379
- description: string;
380
- type?: string;
386
+ description?: string;
381
387
  email?: string;
382
388
  contact?: string;
383
389
  createdBy: string | ObjectId;
@@ -386,9 +392,8 @@ type TOrg = {
386
392
  updatedAt?: string | Date;
387
393
  deletedAt?: string | Date;
388
394
  };
389
- declare const OrgTypes: string[];
390
395
  declare const schemaOrg: Joi.ObjectSchema<any>;
391
- declare function MOrg(value: TOrg): TOrg;
396
+ declare function modelOrg(value: TOrg): TOrg;
392
397
 
393
398
  declare function useOrgRepo(): {
394
399
  createIndexes: () => Promise<void>;
@@ -415,7 +420,7 @@ declare function useOrgService(): {
415
420
  };
416
421
 
417
422
  declare function useOrgController(): {
418
- createOrg: (req: Request, res: Response, next: NextFunction) => Promise<void>;
423
+ add: (req: Request, res: Response, next: NextFunction) => Promise<void>;
419
424
  getOrgsByUserId: (req: Request, res: Response, next: NextFunction) => Promise<void>;
420
425
  getByName: (req: Request, res: Response, next: NextFunction) => Promise<void>;
421
426
  getAll: (req: Request, res: Response, next: NextFunction) => Promise<void>;
@@ -475,10 +480,9 @@ type TRole = {
475
480
  name?: string;
476
481
  description?: string;
477
482
  permissions?: Array<string>;
478
- type?: string;
479
483
  org?: string | ObjectId;
484
+ app: string;
480
485
  status?: string;
481
- default?: boolean;
482
486
  createdBy?: string | ObjectId;
483
487
  createdAt?: string | Date;
484
488
  updatedAt?: string | Date;
@@ -489,17 +493,15 @@ declare const schemaRole: Joi.ObjectSchema<any>;
489
493
  declare function modelRole(value: TRole): TRole;
490
494
 
491
495
  declare function useRoleRepo(): {
492
- createIndex: () => Promise<void>;
493
- createTextIndex: () => Promise<void>;
494
- createUniqueIndex: () => Promise<void>;
496
+ createIndexes: () => Promise<void>;
495
497
  addRole: (value: TRole, session?: ClientSession, clearCache?: boolean) => Promise<ObjectId>;
496
- getRoles: ({ search, page, limit, sort, type, id, }?: {
498
+ getRoles: ({ search, page, limit, sort, app, org, }?: {
497
499
  search?: string | undefined;
498
500
  page?: number | undefined;
499
501
  limit?: number | undefined;
500
502
  sort?: any;
501
- type?: string | undefined;
502
- id?: string | ObjectId | undefined;
503
+ app?: string | undefined;
504
+ org?: string | ObjectId | undefined;
503
505
  }) => Promise<{
504
506
  items: any[];
505
507
  pages: number;
@@ -528,75 +530,40 @@ declare function useRoleController(): {
528
530
  updatePermissionsById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
529
531
  };
530
532
 
531
- type TUserRole = {
532
- name: string;
533
- app: string;
534
- role: ObjectId | string;
535
- status?: string;
536
- };
537
- declare class MUserRole implements TUserRole {
538
- name: string;
539
- app: string;
540
- role: ObjectId | string;
541
- status?: string;
542
- constructor(value: TUserRole);
543
- }
544
533
  type TUser = {
545
534
  _id?: ObjectId;
546
535
  email: string;
547
536
  password: string;
548
- prefix?: string;
549
537
  firstName: string;
550
538
  middleName?: string;
551
539
  lastName: string;
552
- suffix?: string;
553
- birthMonth?: string;
554
- birthDay?: number;
555
- birthYear?: number;
556
- gender?: string;
557
540
  defaultOrg?: ObjectId | string;
558
- xenditCustomerId?: string;
559
- type?: string;
560
541
  status?: string;
561
- referralCode?: string;
562
- referredBy?: string;
563
- createdAt?: string;
564
- updatedAt?: string;
565
- deletedAt?: string;
542
+ createdAt?: string | Date;
543
+ updatedAt?: string | Date;
544
+ deletedAt?: string | Date;
566
545
  };
567
- declare class MUser implements TUser {
568
- _id?: ObjectId;
546
+ declare const schemaUser: Joi.ObjectSchema<any>;
547
+ declare function modelUser(data: TUser): {
548
+ _id: ObjectId | undefined;
569
549
  email: string;
570
550
  password: string;
571
- prefix?: string;
572
551
  firstName: string;
573
- middleName?: string;
552
+ middleName: string;
574
553
  lastName: string;
575
- suffix?: string;
576
- birthMonth?: string;
577
- birthDay?: number;
578
- birthYear?: number;
579
- gender?: string;
580
- roles?: TUserRole[];
581
- status?: string;
582
- type?: string;
583
- xenditCustomerId?: string | undefined;
584
- referralCode?: string;
585
- referredBy?: string;
586
- createdAt?: string;
587
- updatedAt?: string;
588
- deletedAt?: string;
589
- defaultOrg?: ObjectId | string;
590
- constructor(value: TUser);
591
- }
554
+ defaultOrg: string | ObjectId;
555
+ status: string;
556
+ createdAt: string | Date;
557
+ updatedAt: string | Date;
558
+ deletedAt: string | Date;
559
+ };
592
560
 
593
561
  declare function useUserRepo(): {
594
- createTextIndex: () => Promise<void>;
595
- createUniqueIndex: () => Promise<void>;
596
- createUser: (value: TUser, session?: ClientSession) => Promise<ObjectId>;
562
+ createIndexes: () => Promise<void>;
563
+ add: (value: TUser, session?: ClientSession) => Promise<ObjectId>;
597
564
  getUserByEmail: (email: string) => Promise<TUser | null>;
598
565
  getUserById: (_id: string | ObjectId) => Promise<TUser | null>;
599
- getUsers: ({ search, page, limit, sort, status, type, }?: {
566
+ getAll: ({ search, page, limit, sort, status, type, }?: {
600
567
  search?: string | undefined;
601
568
  page?: number | undefined;
602
569
  limit?: number | undefined;
@@ -624,22 +591,11 @@ declare function useUserRepo(): {
624
591
  field: string;
625
592
  value: string | ObjectId;
626
593
  }, session?: ClientSession) => Promise<mongodb.UpdateResult<bson.Document>>;
627
- addUserRole: ({ _id, role }?: {
628
- _id: string | ObjectId;
629
- role: TUserRole;
630
- }, session?: ClientSession) => Promise<void>;
631
594
  getUserByReferralCode: (referralCode: string) => Promise<TUser | null>;
632
595
  };
633
596
 
634
597
  declare function useUserService(): {
635
- getUsers: ({ search, page, status, type, limit, }?: {
636
- search?: string | undefined;
637
- page?: number | undefined;
638
- status?: string | undefined;
639
- type?: string | undefined;
640
- limit?: number | undefined;
641
- }) => Promise<Record<string, any>>;
642
- createUser: (value: Pick<TUser, "prefix" | "firstName" | "middleName" | "lastName" | "email" | "password" | "suffix">) => Promise<ObjectId>;
598
+ createUser: (value: TUser) => Promise<ObjectId>;
643
599
  resetPassword: (id: string, newPassword: string, passwordConfirmation: string) => Promise<string>;
644
600
  updateName: (_id: string, firstName?: string, lastName?: string) => Promise<string>;
645
601
  updateBirthday: (_id: string, month: string, day: number, year: number) => Promise<string>;
@@ -653,7 +609,7 @@ declare function useUserService(): {
653
609
  user: string;
654
610
  previousProfile?: string | undefined;
655
611
  }) => Promise<string>;
656
- createUserByInvite: ({ id, firstName, lastName, password, }?: {
612
+ addViaInvite: ({ id, firstName, lastName, password, }?: {
657
613
  id?: string | undefined;
658
614
  firstName?: string | undefined;
659
615
  lastName?: string | undefined;
@@ -669,13 +625,13 @@ declare function useUserService(): {
669
625
  };
670
626
 
671
627
  declare function useUserController(): {
672
- getUsers: (req: Request, res: Response, next: NextFunction) => Promise<void>;
628
+ getAll: (req: Request, res: Response, next: NextFunction) => Promise<void>;
673
629
  getUserById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
674
630
  updateName: (req: Request, res: Response, next: NextFunction) => Promise<void>;
675
631
  updateBirthday: (req: Request, res: Response, next: NextFunction) => Promise<void>;
676
632
  updateUserFieldById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
677
633
  updateUserProfile: (req: Request, res: Response, next: NextFunction) => Promise<void>;
678
- createUserByVerification: (req: Request, res: Response, next: NextFunction) => Promise<void>;
634
+ addViaInvite: (req: Request, res: Response, next: NextFunction) => Promise<void>;
679
635
  };
680
636
 
681
637
  declare function useGitHubService(): {
@@ -698,7 +654,7 @@ declare const transactionSchema: Joi.ObjectSchema<any>;
698
654
  type TVerificationMetadata = {
699
655
  name?: string;
700
656
  app?: string;
701
- role?: string;
657
+ role?: string | ObjectId;
702
658
  roleName?: string;
703
659
  referralCode?: string;
704
660
  org?: string | ObjectId;
@@ -710,21 +666,13 @@ type TVerification = {
710
666
  email: string;
711
667
  metadata?: TVerificationMetadata;
712
668
  status?: string;
713
- createdAt: string | Date;
714
- updatedAt?: string | Date | null;
715
- expireAt: string | Date;
669
+ createdAt?: string | Date;
670
+ updatedAt?: string | Date;
671
+ expireAt?: string | Date;
716
672
  };
717
- declare class MVerification implements TVerification {
718
- _id?: ObjectId;
719
- type: string;
720
- email: string;
721
- metadata?: TVerificationMetadata;
722
- status?: string;
723
- createdAt: string | Date;
724
- updatedAt?: string | Date | null;
725
- expireAt: string | Date;
726
- constructor(value: TVerification);
727
- }
673
+ declare const schemaInviteMember: Joi.ObjectSchema<any>;
674
+ declare const schemaVerification: Joi.ObjectSchema<any>;
675
+ declare function modelVerification(value: TVerification): TVerification;
728
676
 
729
677
  declare function useVerificationRepo(): {
730
678
  createIndexes: () => Promise<void>;
@@ -773,7 +721,13 @@ declare function useVerificationService(): {
773
721
  updateStatusById: (_id: string, status: string) => Promise<string>;
774
722
  signUp: ({ email, metadata, }: {
775
723
  email: string;
776
- metadata: Record<string, any>;
724
+ metadata?: TVerificationMetadata | undefined;
725
+ }) => Promise<bson.ObjectId>;
726
+ inviteMember: (value: {
727
+ email: string;
728
+ role: string;
729
+ app: string;
730
+ org?: string;
777
731
  }) => Promise<bson.ObjectId>;
778
732
  };
779
733
 
@@ -783,6 +737,8 @@ declare function useVerificationController(): {
783
737
  createForgetPassword: (req: Request, res: Response, next: NextFunction) => Promise<void>;
784
738
  verify: (req: Request, res: Response, next: NextFunction) => Promise<void>;
785
739
  cancelUserInvitation: (req: Request, res: Response, next: NextFunction) => Promise<Response<any, Record<string, any>> | undefined>;
740
+ inviteMember: (req: Request, res: Response, next: NextFunction) => Promise<void>;
741
+ signUp: (req: Request, res: Response, next: NextFunction) => Promise<void>;
786
742
  };
787
743
 
788
744
  type TApp = {
@@ -970,4 +926,4 @@ declare const XENDIT_SECRET_KEY: string;
970
926
  declare const XENDIT_BASE_URL: string;
971
927
  declare const DOMAIN: string;
972
928
 
973
- 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, MOrg, MUser, MUserRole, MVerification, OrgTypes, 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, modelPSGC, modelPermission, modelPermissionGroup, modelRole, schemaApp, schemaAppUpdate, schemaBuilding, schemaBuildingUnit, 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 };
929
+ 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, TMiniRole, 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, schemaOrg, schemaPSGC, schemaPermission, schemaPermissionGroup, schemaPermissionGroupUpdate, schemaPermissionUpdate, schemaRole, 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 };