@goweekdays/core 2.7.0 → 2.9.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.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - acc15de: Subscription initial release with full lifecycle support
8
+
9
+ ## 2.8.0
10
+
11
+ ### Minor Changes
12
+
13
+ - baa7fed: Add ledger billing summary with org and status filter
14
+
3
15
  ## 2.7.0
4
16
 
5
17
  ### Minor Changes
package/dist/index.d.ts CHANGED
@@ -4,6 +4,7 @@ import * as mongodb from 'mongodb';
4
4
  import { ObjectId, ClientSession, Db, Collection } from 'mongodb';
5
5
  import * as bson from 'bson';
6
6
  import { z } from 'zod';
7
+ import * as _paypal_paypal_server_sdk from '@paypal/paypal-server-sdk';
7
8
 
8
9
  declare function useAuthService(): {
9
10
  login: ({ email, password }?: {
@@ -394,6 +395,7 @@ declare function useOrgRepo(): {
394
395
  getByName: (name: string) => Promise<TOrg | null>;
395
396
  getByEmail: (email: string) => Promise<TOrg | null>;
396
397
  updateById: (_id: string | ObjectId, options: Pick<TOrg, "name" | "description" | "email" | "contact">) => Promise<void>;
398
+ updateStatusById: (_id: string | ObjectId, status: string, session?: ClientSession) => Promise<string>;
397
399
  };
398
400
 
399
401
  declare function useOrgService(): {
@@ -637,6 +639,35 @@ declare function useUtilController(): {
637
639
 
638
640
  declare const transactionSchema: Joi.ObjectSchema<any>;
639
641
 
642
+ interface PaypalWebhookHeaders {
643
+ "paypal-auth-algo"?: string;
644
+ "paypal-cert-url": string;
645
+ "paypal-transmission-id": string;
646
+ "paypal-transmission-sig": string;
647
+ "paypal-transmission-time": string;
648
+ }
649
+ declare function usePaypalService(): {
650
+ addOrder: ({ amount, currency, customId, returnUrl, cancelUrl, action, }?: {
651
+ amount?: number | undefined;
652
+ currency?: string | undefined;
653
+ customId?: string | undefined;
654
+ returnUrl?: string | undefined;
655
+ cancelUrl?: string | undefined;
656
+ action?: string | undefined;
657
+ }) => Promise<_paypal_paypal_server_sdk.ApiResponse<_paypal_paypal_server_sdk.Order>>;
658
+ captureOrder: (id: string) => Promise<_paypal_paypal_server_sdk.ApiResponse<_paypal_paypal_server_sdk.Order>>;
659
+ verifySignature: (rawBody: Buffer | string, headers: PaypalWebhookHeaders, webhookId?: string) => Promise<boolean>;
660
+ createInvoice: (value: {
661
+ email: string;
662
+ amount: number;
663
+ currency: string;
664
+ note?: string;
665
+ title: string;
666
+ dueDate?: string;
667
+ }) => Promise<any>;
668
+ sendInvoice: (invoiceId: string) => Promise<any>;
669
+ };
670
+
640
671
  type TVerificationMetadata = {
641
672
  name?: string;
642
673
  app?: string;
@@ -794,6 +825,7 @@ type TSubscription = {
794
825
  currency: string;
795
826
  billingCycle: "monthly" | "yearly";
796
827
  promoCode?: string;
828
+ retry?: number;
797
829
  status?: string;
798
830
  nextBillingDate: Date | string;
799
831
  createdAt?: Date | string;
@@ -817,11 +849,17 @@ declare function useSubscriptionRepo(): {
817
849
  getById: (_id: string | ObjectId) => Promise<TSubscription | null>;
818
850
  deleteById: (_id: string | ObjectId) => Promise<string>;
819
851
  updateById: (_id: string | ObjectId, options: {
820
- seats: number;
852
+ seats?: number;
821
853
  paidSeats?: number;
822
854
  amount?: number;
823
855
  promoCode?: string;
856
+ status?: string;
857
+ nextBillingDate?: Date;
824
858
  }, session?: ClientSession) => Promise<string>;
859
+ getByStatus: (status?: string, limit?: number, retry?: number) => Promise<TSubscription[]>;
860
+ updateStatusById: (_id: string | ObjectId, status: string, session?: ClientSession) => Promise<string>;
861
+ updateRetryById: (_id: string | ObjectId, retry: number, session?: ClientSession) => Promise<string>;
862
+ getOverdueForSuspension: (limit?: number, daysOverdue?: number) => Promise<TSubscription[]>;
825
863
  };
826
864
 
827
865
  declare function useSubscriptionController(): {
@@ -831,6 +869,20 @@ declare function useSubscriptionController(): {
831
869
  updateSeats: (req: Request, res: Response, next: NextFunction) => Promise<void>;
832
870
  };
833
871
 
872
+ declare function useSubscriptionService(): {
873
+ updateSeats: ({ id, user, amount, seats, }?: {
874
+ id?: string | undefined;
875
+ user?: string | undefined;
876
+ amount?: number | undefined;
877
+ seats?: number | undefined;
878
+ }) => Promise<string>;
879
+ processInvoices: () => Promise<void>;
880
+ processSuspensions: () => Promise<void>;
881
+ scheduleInvoiceProcessing: () => void;
882
+ scheduleSuspensionProcessing: () => void;
883
+ processPaidInvoice: (invoiceId: string) => Promise<string>;
884
+ };
885
+
834
886
  type TSubscriptionTransaction = {
835
887
  _id?: ObjectId;
836
888
  subscription: string | ObjectId;
@@ -1023,16 +1075,43 @@ type TJobPost = {
1023
1075
  deletedAt?: Date;
1024
1076
  };
1025
1077
  declare const schemaJobPost: Joi.ObjectSchema<any>;
1078
+ declare const schemaJobPostUpdate: Joi.ObjectSchema<any>;
1026
1079
  declare function modelJobPost(value: TJobPost): TJobPost;
1027
1080
 
1028
1081
  declare function useJobPostController(): {
1029
1082
  add: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1083
+ getAll: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1084
+ getJobPostsByOrg: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1085
+ getById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1086
+ updateById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1030
1087
  deleteById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1031
1088
  };
1032
1089
 
1033
1090
  declare function useJobPostRepo(): {
1034
1091
  createIndexes: () => Promise<string>;
1035
1092
  add: (value: TJobPost, session?: ClientSession) => Promise<ObjectId>;
1093
+ getAll: ({ search, page, limit, status, }?: {
1094
+ search?: string | undefined;
1095
+ page?: number | undefined;
1096
+ limit?: number | undefined;
1097
+ status?: string | undefined;
1098
+ }) => Promise<Record<string, any>>;
1099
+ getJobPostsByOrg: ({ search, page, limit, org, status, }?: {
1100
+ org: string | ObjectId;
1101
+ page: number;
1102
+ limit?: number | undefined;
1103
+ search?: string | undefined;
1104
+ status?: string | undefined;
1105
+ }) => Promise<{
1106
+ items: any[];
1107
+ pages: number;
1108
+ pageRange: string;
1109
+ } | {
1110
+ _id: ObjectId;
1111
+ name: string;
1112
+ }[]>;
1113
+ getById: (_id: string | ObjectId) => Promise<TJobPost>;
1114
+ updateById: (_id: string | ObjectId, options: Pick<TJobPost, "title" | "setup" | "location" | "type" | "description">) => Promise<string>;
1036
1115
  deleteById: (_id: string | ObjectId, session?: ClientSession) => Promise<string>;
1037
1116
  };
1038
1117
 
@@ -1047,9 +1126,11 @@ type TLedgerBill = {
1047
1126
  description: string;
1048
1127
  amount: number;
1049
1128
  currency: string;
1050
- status: "pending" | "completed" | "overdue";
1129
+ status: "pending" | "paid" | "overdue";
1051
1130
  billingFrom?: string | Date;
1052
1131
  billingTo?: string | Date;
1132
+ payerViewUrl?: string;
1133
+ invoice?: string;
1053
1134
  paidAt?: string | Date;
1054
1135
  dueDate?: string | Date;
1055
1136
  createdAt?: string | Date;
@@ -1057,6 +1138,7 @@ type TLedgerBill = {
1057
1138
  declare const ledgerBillTypes: string[];
1058
1139
  declare const ledgerBillStatuses: string[];
1059
1140
  declare const schemaLedgerBill: Joi.ObjectSchema<any>;
1141
+ declare const schemaLedgerBillingSummary: Joi.ObjectSchema<any>;
1060
1142
  declare function modelLedgerBill(value: TLedgerBill): TLedgerBill;
1061
1143
 
1062
1144
  declare function useLedgerBillingRepo(): {
@@ -1071,11 +1153,15 @@ declare function useLedgerBillingRepo(): {
1071
1153
  status?: string | undefined;
1072
1154
  }) => Promise<Record<string, any>>;
1073
1155
  getById: (_id: string | ObjectId) => Promise<TLedgerBill | null>;
1156
+ getByInvoice: (invoice: string) => Promise<TLedgerBill | null>;
1157
+ getSummary: (status: string, org: string | ObjectId) => Promise<bson.Document>;
1158
+ updateStatusById: (_id: string | ObjectId, status: string, session?: ClientSession) => Promise<boolean>;
1074
1159
  };
1075
1160
 
1076
1161
  declare function useLedgerBillingController(): {
1077
1162
  getAll: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1078
1163
  getById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1164
+ getSummary: (req: Request, res: Response, next: NextFunction) => Promise<void>;
1079
1165
  };
1080
1166
 
1081
1167
  declare const MONGO_URI: string;
@@ -1117,4 +1203,4 @@ declare const XENDIT_BASE_URL: string;
1117
1203
  declare const DOMAIN: string;
1118
1204
  declare const APP_ORG: string;
1119
1205
 
1120
- export { ACCESS_TOKEN_EXPIRY, ACCESS_TOKEN_SECRET, APP_ACCOUNT, APP_MAIN, APP_ORG, 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, MBuilding, MBuildingUnit, MFile, MONGO_DB, MONGO_URI, PAYPAL_API_URL, PAYPAL_CLIENT_ID, PAYPAL_CLIENT_SECRET, PAYPAL_WEBHOOK_ID, 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, TApp, TBuilding, TBuildingUnit, TCounter, TFile, TJobPost, TLedgerBill, TMember, TOrg, TPermission, TPermissionGroup, TPlan, TPromo, TRole, TSubscription, TSubscriptionTransaction, TUser, TVerification, TVerificationMetadata, VERIFICATION_FORGET_PASSWORD_DURATION, VERIFICATION_USER_INVITE_DURATION, XENDIT_BASE_URL, XENDIT_SECRET_KEY, currencies, isDev, ledgerBillStatuses, ledgerBillTypes, modelApp, modelJobPost, modelLedgerBill, modelMember, modelOrg, modelPermission, modelPermissionGroup, modelPlan, modelPromo, modelRole, modelSubscription, modelSubscriptionTransaction, modelUser, modelVerification, schemaApp, schemaAppUpdate, schemaBuilding, schemaBuildingUnit, schemaInviteMember, schemaJobPost, schemaLedgerBill, schemaMember, schemaMemberRole, schemaMemberStatus, schemaOrg, schemaOrgAdd, schemaOrgUpdate, schemaPermission, schemaPermissionGroup, schemaPermissionGroupUpdate, schemaPermissionUpdate, schemaPlan, schemaPromo, schemaRole, schemaRoleUpdate, schemaSubscription, schemaSubscriptionSeats, schemaSubscriptionTransaction, schemaSubscriptionUpdate, schemaUpdateOptions, schemaUser, schemaVerification, transactionSchema, useAppController, useAppRepo, useAppService, useAuthController, useAuthService, useBuildingController, useBuildingRepo, useBuildingService, useBuildingUnitController, useBuildingUnitRepo, useBuildingUnitService, useCounterModel, useCounterRepo, useFileController, useFileRepo, useFileService, useGitHubService, useJobPostController, useJobPostRepo, useJobPostService, useLedgerBillingController, useLedgerBillingRepo, useMemberController, useMemberRepo, useOrgController, useOrgRepo, useOrgService, usePermissionController, usePermissionGroupController, usePermissionGroupRepo, usePermissionGroupService, usePermissionRepo, usePermissionService, usePlanController, usePlanRepo, usePlanService, usePromoRepo, useRoleController, useRoleRepo, useRoleService, useSubscriptionController, useSubscriptionRepo, useSubscriptionTransactionController, useSubscriptionTransactionRepo, useUserController, useUserRepo, useUserService, useUtilController, useVerificationController, useVerificationRepo, useVerificationService };
1206
+ export { ACCESS_TOKEN_EXPIRY, ACCESS_TOKEN_SECRET, APP_ACCOUNT, APP_MAIN, APP_ORG, 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, MBuilding, MBuildingUnit, MFile, MONGO_DB, MONGO_URI, PAYPAL_API_URL, PAYPAL_CLIENT_ID, PAYPAL_CLIENT_SECRET, PAYPAL_WEBHOOK_ID, PORT, PaypalWebhookHeaders, 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, TApp, TBuilding, TBuildingUnit, TCounter, TFile, TJobPost, TLedgerBill, TMember, TOrg, TPermission, TPermissionGroup, TPlan, TPromo, TRole, TSubscription, TSubscriptionTransaction, TUser, TVerification, TVerificationMetadata, VERIFICATION_FORGET_PASSWORD_DURATION, VERIFICATION_USER_INVITE_DURATION, XENDIT_BASE_URL, XENDIT_SECRET_KEY, currencies, isDev, ledgerBillStatuses, ledgerBillTypes, modelApp, modelJobPost, modelLedgerBill, modelMember, modelOrg, modelPermission, modelPermissionGroup, modelPlan, modelPromo, modelRole, modelSubscription, modelSubscriptionTransaction, modelUser, modelVerification, schemaApp, schemaAppUpdate, schemaBuilding, schemaBuildingUnit, schemaInviteMember, schemaJobPost, schemaJobPostUpdate, schemaLedgerBill, schemaLedgerBillingSummary, schemaMember, schemaMemberRole, schemaMemberStatus, schemaOrg, schemaOrgAdd, schemaOrgUpdate, schemaPermission, schemaPermissionGroup, schemaPermissionGroupUpdate, schemaPermissionUpdate, schemaPlan, schemaPromo, schemaRole, schemaRoleUpdate, schemaSubscription, schemaSubscriptionSeats, schemaSubscriptionTransaction, schemaSubscriptionUpdate, schemaUpdateOptions, schemaUser, schemaVerification, transactionSchema, useAppController, useAppRepo, useAppService, useAuthController, useAuthService, useBuildingController, useBuildingRepo, useBuildingService, useBuildingUnitController, useBuildingUnitRepo, useBuildingUnitService, useCounterModel, useCounterRepo, useFileController, useFileRepo, useFileService, useGitHubService, useJobPostController, useJobPostRepo, useJobPostService, useLedgerBillingController, useLedgerBillingRepo, useMemberController, useMemberRepo, useOrgController, useOrgRepo, useOrgService, usePaypalService, usePermissionController, usePermissionGroupController, usePermissionGroupRepo, usePermissionGroupService, usePermissionRepo, usePermissionService, usePlanController, usePlanRepo, usePlanService, usePromoRepo, useRoleController, useRoleRepo, useRoleService, useSubscriptionController, useSubscriptionRepo, useSubscriptionService, useSubscriptionTransactionController, useSubscriptionTransactionRepo, useUserController, useUserRepo, useUserService, useUtilController, useVerificationController, useVerificationRepo, useVerificationService };