@goweekdays/core 2.3.0 → 2.4.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.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - ee525e1: Add plan, promo, and subscription modules
8
+
9
+ ## 2.3.1
10
+
11
+ ### Patch Changes
12
+
13
+ - c39a016: Fix role, member, and user management
14
+
3
15
  ## 2.3.0
4
16
 
5
17
  ### Minor Changes
package/dist/index.d.ts CHANGED
@@ -50,8 +50,6 @@ declare function useAuthService(): {
50
50
  declare function useAuthController(): {
51
51
  login: (req: Request, res: Response, next: NextFunction) => Promise<void>;
52
52
  logout: (req: Request, res: Response, next: NextFunction) => Promise<void>;
53
- resetPassword: (req: Request, res: Response, next: NextFunction) => Promise<void>;
54
- signUp: (req: Request, res: Response, next: NextFunction) => Promise<void>;
55
53
  };
56
54
 
57
55
  type TBuilding = {
@@ -392,7 +390,7 @@ type TOrg = {
392
390
  _id?: ObjectId;
393
391
  name: string;
394
392
  description?: string;
395
- email?: string;
393
+ email: string;
396
394
  contact?: string;
397
395
  createdBy: string | ObjectId;
398
396
  status?: string;
@@ -401,6 +399,8 @@ type TOrg = {
401
399
  deletedAt?: string | Date;
402
400
  };
403
401
  declare const schemaOrg: Joi.ObjectSchema<any>;
402
+ declare const schemaOrgAdd: Joi.ObjectSchema<any>;
403
+ declare const schemaOrgUpdate: Joi.ObjectSchema<any>;
404
404
  declare function modelOrg(value: TOrg): TOrg;
405
405
 
406
406
  declare function useOrgRepo(): {
@@ -421,10 +421,13 @@ declare function useOrgRepo(): {
421
421
  }, session?: ClientSession) => Promise<string>;
422
422
  deleteById: (_id: string | ObjectId) => Promise<string>;
423
423
  getByName: (name: string) => Promise<TOrg>;
424
+ updateById: (_id: string | ObjectId, options: Pick<TOrg, "name" | "description" | "email" | "contact">) => Promise<void>;
424
425
  };
425
426
 
426
427
  declare function useOrgService(): {
427
- add: (value: TOrg) => Promise<string>;
428
+ add: (value: TOrg & {
429
+ seats: number;
430
+ }) => Promise<string>;
428
431
  };
429
432
 
430
433
  declare function useOrgController(): {
@@ -433,6 +436,7 @@ declare function useOrgController(): {
433
436
  getByName: (req: Request, res: Response, next: NextFunction) => Promise<void>;
434
437
  getAll: (req: Request, res: Response, next: NextFunction) => Promise<void>;
435
438
  getById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
439
+ updateById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
436
440
  };
437
441
 
438
442
  type TPSGC = {
@@ -603,8 +607,12 @@ declare function useUserRepo(): {
603
607
  };
604
608
 
605
609
  declare function useUserService(): {
606
- createUser: (value: TUser) => Promise<ObjectId>;
607
- resetPassword: (id: string, newPassword: string, passwordConfirmation: string) => Promise<string>;
610
+ createUser: (value: TUser) => Promise<bson.ObjectId>;
611
+ resetPassword: (value: {
612
+ id: string;
613
+ newPassword: string;
614
+ confirmPassword: string;
615
+ }) => Promise<string>;
608
616
  updateName: (_id: string, firstName?: string, lastName?: string) => Promise<string>;
609
617
  updateBirthday: (_id: string, month: string, day: number, year: number) => Promise<string>;
610
618
  updateUserFieldById: ({ _id, field, value }?: {
@@ -622,13 +630,13 @@ declare function useUserService(): {
622
630
  firstName?: string | undefined;
623
631
  lastName?: string | undefined;
624
632
  password?: string | undefined;
625
- }) => Promise<string | ObjectId>;
633
+ }) => Promise<string | bson.ObjectId>;
626
634
  createUserBySignUp: ({ id, firstName, lastName, password, }?: {
627
635
  id?: string | undefined;
628
636
  firstName?: string | undefined;
629
637
  lastName?: string | undefined;
630
638
  password?: string | undefined;
631
- }) => Promise<ObjectId>;
639
+ }) => Promise<bson.ObjectId>;
632
640
  createDefaultUser: () => Promise<string>;
633
641
  };
634
642
 
@@ -640,6 +648,7 @@ declare function useUserController(): {
640
648
  updateUserFieldById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
641
649
  updateUserProfile: (req: Request, res: Response, next: NextFunction) => Promise<void>;
642
650
  addViaInvite: (req: Request, res: Response, next: NextFunction) => Promise<void>;
651
+ resetPassword: (req: Request, res: Response, next: NextFunction) => Promise<void>;
643
652
  };
644
653
 
645
654
  declare function useGitHubService(): {
@@ -685,7 +694,7 @@ declare function modelVerification(value: TVerification): TVerification;
685
694
  declare function useVerificationRepo(): {
686
695
  createIndexes: () => Promise<void>;
687
696
  add: (value: TVerification, session?: ClientSession) => Promise<ObjectId>;
688
- getVerifications: ({ search, page, limit, sort, status, type, email, app, }?: {
697
+ getVerifications: ({ search, page, limit, sort, status, type, email, app, org, }?: {
689
698
  search?: string | undefined;
690
699
  page?: number | undefined;
691
700
  limit?: number | undefined;
@@ -694,6 +703,7 @@ declare function useVerificationRepo(): {
694
703
  type?: string | string[] | undefined;
695
704
  email?: string | undefined;
696
705
  app?: string | undefined;
706
+ org?: string | ObjectId | undefined;
697
707
  }) => Promise<{
698
708
  items: any[];
699
709
  pages: number;
@@ -738,6 +748,7 @@ declare function useVerificationService(): {
738
748
  org?: string;
739
749
  }) => Promise<bson.ObjectId>;
740
750
  cancelInviteMember: (id: string) => Promise<string>;
751
+ forgetPassword: (email: string) => Promise<string>;
741
752
  };
742
753
 
743
754
  declare function useVerificationController(): {
@@ -749,6 +760,123 @@ declare function useVerificationController(): {
749
760
  inviteMember: (req: Request, res: Response, next: NextFunction) => Promise<void>;
750
761
  signUp: (req: Request, res: Response, next: NextFunction) => Promise<void>;
751
762
  cancelInviteMember: (req: Request, res: Response, next: NextFunction) => Promise<void>;
763
+ forgetPassword: (req: Request, res: Response, next: NextFunction) => Promise<void>;
764
+ };
765
+
766
+ type TPlan = {
767
+ _id?: ObjectId;
768
+ name: string;
769
+ description?: string;
770
+ features?: string[];
771
+ price: number;
772
+ currency: string;
773
+ billingCycle: "monthly" | "yearly";
774
+ default?: boolean;
775
+ status?: "active" | "inactive";
776
+ createdAt?: Date | string;
777
+ updatedAt?: Date | string;
778
+ };
779
+ declare const currencies: string[];
780
+ declare const schemaPlan: Joi.ObjectSchema<any>;
781
+ declare function modelPlan(data: any): TPlan;
782
+
783
+ declare function usePlanRepo(): {
784
+ add: (value: TPlan) => Promise<string>;
785
+ getAll: ({ page, limit, search, status, }?: {
786
+ page?: number | undefined;
787
+ limit?: number | undefined;
788
+ search?: string | undefined;
789
+ status?: string | undefined;
790
+ }) => Promise<TPaginate<TPlan>>;
791
+ getById: (_id: string | ObjectId) => Promise<TPlan | null>;
792
+ getDefault: () => Promise<TPlan | null>;
793
+ deleteById: (_id: string | ObjectId) => Promise<string>;
794
+ };
795
+
796
+ declare function usePlanService(): {
797
+ addDefaultPlan: () => Promise<void>;
798
+ };
799
+
800
+ declare function usePlanController(): {
801
+ add: (req: Request, res: Response, next: NextFunction) => Promise<void>;
802
+ getAll: (req: Request, res: Response, next: NextFunction) => Promise<void>;
803
+ getById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
804
+ deleteById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
805
+ getDefault: (req: Request, res: Response, next: NextFunction) => Promise<void>;
806
+ };
807
+
808
+ type TSubscription = {
809
+ _id?: ObjectId;
810
+ org: string | ObjectId;
811
+ seats: number;
812
+ paidSeats: number;
813
+ amount: number;
814
+ currency: string;
815
+ billingCycle: "monthly" | "yearly";
816
+ promoCode?: string;
817
+ status?: string;
818
+ nextBillingDate: Date | string;
819
+ createdAt?: Date | string;
820
+ updatedAt?: Date | string;
821
+ };
822
+ declare const schemaSubscription: Joi.ObjectSchema<any>;
823
+ declare const schemaSubscriptionUpdate: Joi.ObjectSchema<any>;
824
+ declare const schemaSubscriptionSeats: Joi.ObjectSchema<any>;
825
+ declare function modelSubscription(data: any): TSubscription;
826
+
827
+ declare function useSubscriptionRepo(): {
828
+ add: (value: TSubscription, session?: ClientSession) => Promise<string>;
829
+ getAll: ({ page, limit, search, status, }?: {
830
+ page?: number | undefined;
831
+ limit?: number | undefined;
832
+ search?: string | undefined;
833
+ status?: string | undefined;
834
+ }) => Promise<TPaginate<TSubscription>>;
835
+ getByOrg: (org: string | ObjectId) => Promise<TSubscription | null>;
836
+ getById: (_id: string | ObjectId) => Promise<TSubscription | null>;
837
+ deleteById: (_id: string | ObjectId) => Promise<string>;
838
+ updateById: (_id: string | ObjectId, options: {
839
+ seats: number;
840
+ paidSeats?: number;
841
+ amount?: number;
842
+ promoCode?: string;
843
+ }, session?: ClientSession) => Promise<string>;
844
+ };
845
+
846
+ declare function useSubscriptionController(): {
847
+ getAll: (req: Request, res: Response, next: NextFunction) => Promise<void>;
848
+ getById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
849
+ getByOrg: (req: Request, res: Response, next: NextFunction) => Promise<void>;
850
+ updateSeats: (req: Request, res: Response, next: NextFunction) => Promise<void>;
851
+ };
852
+
853
+ type TSubscriptionTransaction = {
854
+ _id?: ObjectId;
855
+ subscription: string | ObjectId;
856
+ amount: number;
857
+ currency: string;
858
+ type: "initiate" | "add-seat" | "remove-seat" | "renewal";
859
+ description?: string;
860
+ createdBy: string | ObjectId;
861
+ createdByName?: string;
862
+ createdAt?: Date | string;
863
+ updatedAt?: Date | string;
864
+ };
865
+ declare const schemaSubscriptionTransaction: Joi.ObjectSchema<any>;
866
+ declare function modelSubscriptionTransaction(data: TSubscriptionTransaction): TSubscriptionTransaction;
867
+
868
+ declare function useSubscriptionTransactionRepo(): {
869
+ add: (value: TSubscriptionTransaction, session?: ClientSession) => Promise<string>;
870
+ getAll: ({ page, limit, search, id }?: {
871
+ page?: number | undefined;
872
+ limit?: number | undefined;
873
+ search?: string | undefined;
874
+ id?: string | undefined;
875
+ }) => Promise<TPaginate<TSubscriptionTransaction>>;
876
+ };
877
+
878
+ declare function useSubscriptionTransactionController(): {
879
+ getAll: (req: Request, res: Response, next: NextFunction) => Promise<void>;
752
880
  };
753
881
 
754
882
  type TApp = {
@@ -936,4 +1064,4 @@ declare const XENDIT_SECRET_KEY: string;
936
1064
  declare const XENDIT_BASE_URL: string;
937
1065
  declare const DOMAIN: string;
938
1066
 
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 };
1067
+ 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, TPlan, TRole, TSubscription, TSubscriptionTransaction, TUser, TVerification, TVerificationMetadata, VERIFICATION_FORGET_PASSWORD_DURATION, VERIFICATION_USER_INVITE_DURATION, XENDIT_BASE_URL, XENDIT_SECRET_KEY, addressSchema, currencies, isDev, modelApp, modelMember, modelOrg, modelPSGC, modelPermission, modelPermissionGroup, modelPlan, modelRole, modelSubscription, modelSubscriptionTransaction, modelUser, modelVerification, schemaApp, schemaAppUpdate, schemaBuilding, schemaBuildingUnit, schemaInviteMember, schemaMember, schemaMemberRole, schemaMemberStatus, schemaOrg, schemaOrgAdd, schemaOrgUpdate, schemaPSGC, schemaPermission, schemaPermissionGroup, schemaPermissionGroupUpdate, schemaPermissionUpdate, schemaPlan, schemaRole, schemaRoleUpdate, schemaSubscription, schemaSubscriptionSeats, schemaSubscriptionTransaction, schemaSubscriptionUpdate, 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, usePlanController, usePlanRepo, usePlanService, useRoleController, useRoleRepo, useRoleService, useSubscriptionController, useSubscriptionRepo, useSubscriptionTransactionController, useSubscriptionTransactionRepo, useUserController, useUserRepo, useUserService, useUtilController, useVerificationController, useVerificationRepo, useVerificationService };