@goweekdays/core 2.4.1 → 2.5.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.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - c861819: Initiate paypal service function
8
+
9
+ ## 2.4.2
10
+
11
+ ### Patch Changes
12
+
13
+ - 9a24dc7: Remove address resource and refactor index creation
14
+
3
15
  ## 2.4.1
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,41 +1,10 @@
1
+ import { Request, Response, NextFunction } from 'express';
1
2
  import Joi from 'joi';
2
3
  import * as mongodb from 'mongodb';
3
4
  import { ObjectId, ClientSession, Db, Collection } from 'mongodb';
4
- import { Request, Response, NextFunction } from 'express';
5
5
  import * as bson from 'bson';
6
6
  import { z } from 'zod';
7
7
 
8
- type TAddress = {
9
- _id?: ObjectId;
10
- type: string;
11
- user: ObjectId | string;
12
- org?: ObjectId | string;
13
- country: string;
14
- address: string;
15
- continuedAddress?: string;
16
- city: string;
17
- province: string;
18
- postalCode: string;
19
- taxId: string;
20
- };
21
- declare const addressSchema: Joi.ObjectSchema<any>;
22
- declare function MAddress(value: any): TAddress;
23
-
24
- declare function useAddressRepo(): {
25
- createIndex: () => Promise<void>;
26
- add: (value: TAddress, session?: ClientSession) => Promise<ObjectId>;
27
- getByUserId: (user: string | ObjectId) => Promise<TAddress | null>;
28
- getByOrgId: (org: string | ObjectId) => Promise<TAddress | null>;
29
- updateById: (_id: string | ObjectId, value: Pick<TAddress, "org" | "country" | "address" | "continuedAddress" | "city" | "province" | "postalCode" | "taxId">, session?: ClientSession) => Promise<string>;
30
- };
31
-
32
- declare function useAddressController(): {
33
- add: (req: Request, res: Response, next: NextFunction) => Promise<void>;
34
- getByUserId: (req: Request, res: Response, next: NextFunction) => Promise<void>;
35
- getByOrgId: (req: Request, res: Response, next: NextFunction) => Promise<void>;
36
- updateById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
37
- };
38
-
39
8
  declare function useAuthService(): {
40
9
  login: ({ email, password }?: {
41
10
  email: string;
@@ -208,13 +177,13 @@ declare const TCounter: z.ZodObject<{
208
177
  type: string;
209
178
  createdAt: Date;
210
179
  count: number;
211
- _id?: ObjectId | undefined;
212
180
  deletedAt?: Date | undefined;
181
+ _id?: ObjectId | undefined;
213
182
  updatedAt?: Date | undefined;
214
183
  }, {
215
184
  type: string;
216
- _id?: string | ObjectId | undefined;
217
185
  deletedAt?: Date | undefined;
186
+ _id?: string | ObjectId | undefined;
218
187
  updatedAt?: Date | undefined;
219
188
  createdAt?: Date | undefined;
220
189
  count?: number | undefined;
@@ -225,14 +194,14 @@ declare function useCounterModel(db: Db): {
225
194
  type: string;
226
195
  createdAt: Date;
227
196
  count: number;
228
- _id?: ObjectId | undefined;
229
197
  deletedAt?: Date | undefined;
198
+ _id?: ObjectId | undefined;
230
199
  updatedAt?: Date | undefined;
231
200
  };
232
201
  validateCounter: (data: unknown) => z.SafeParseReturnType<{
233
202
  type: string;
234
- _id?: string | ObjectId | undefined;
235
203
  deletedAt?: Date | undefined;
204
+ _id?: string | ObjectId | undefined;
236
205
  updatedAt?: Date | undefined;
237
206
  createdAt?: Date | undefined;
238
207
  count?: number | undefined;
@@ -240,23 +209,22 @@ declare function useCounterModel(db: Db): {
240
209
  type: string;
241
210
  createdAt: Date;
242
211
  count: number;
243
- _id?: ObjectId | undefined;
244
212
  deletedAt?: Date | undefined;
213
+ _id?: ObjectId | undefined;
245
214
  updatedAt?: Date | undefined;
246
215
  }>;
247
216
  collection: Collection<{
248
217
  type: string;
249
218
  createdAt: Date;
250
219
  count: number;
251
- _id?: ObjectId | undefined;
252
220
  deletedAt?: Date | undefined;
221
+ _id?: ObjectId | undefined;
253
222
  updatedAt?: Date | undefined;
254
223
  }>;
255
224
  };
256
225
 
257
226
  declare function useCounterRepo(): {
258
- createIndex: () => Promise<void>;
259
- createUniqueIndex: () => Promise<void>;
227
+ createIndexes: () => Promise<void>;
260
228
  add: (type: string) => Promise<void>;
261
229
  getByType: (type: string) => Promise<any>;
262
230
  incrementByType: (type: string, session?: ClientSession) => Promise<void>;
@@ -279,6 +247,7 @@ declare class MFile implements TFile {
279
247
  }
280
248
 
281
249
  declare function useFileRepo(): {
250
+ createIndexes: () => Promise<string>;
282
251
  createFile: (value: TFile, session?: ClientSession) => Promise<string>;
283
252
  deleteFileById: (_id: string | ObjectId, session?: ClientSession) => Promise<string>;
284
253
  getAllDraftedFiles: () => Promise<any[]>;
@@ -315,6 +284,7 @@ declare const schemaMemberStatus: Joi.ObjectSchema<any>;
315
284
  declare function modelMember(value: TMember): TMember;
316
285
 
317
286
  declare function useMemberRepo(): {
287
+ createIndexes: () => Promise<string>;
318
288
  add: (value: TMember, session?: ClientSession) => Promise<string>;
319
289
  getById: (_id: string | ObjectId) => Promise<TMember | null>;
320
290
  getByRole: (role: string | ObjectId) => Promise<TMember | null>;
@@ -343,7 +313,7 @@ declare function useMemberRepo(): {
343
313
  name: string;
344
314
  }[]>;
345
315
  updateStatusByUserId: (user: string | ObjectId, status: string) => Promise<string>;
346
- updateName: (value: Pick<TMember, "user" | "name">, session?: ClientSession) => Promise<string>;
316
+ updateName: (value: Pick<TMember, "name" | "user">, session?: ClientSession) => Promise<string>;
347
317
  getByUserId: (user: string | ObjectId) => Promise<TMember | null>;
348
318
  getOrgsByMembership: ({ search, limit, page, user }?: {
349
319
  search: string;
@@ -428,7 +398,10 @@ declare function useOrgRepo(): {
428
398
  declare function useOrgService(): {
429
399
  add: (value: TOrg & {
430
400
  seats: number;
431
- }) => Promise<string>;
401
+ }) => Promise<{
402
+ org: string;
403
+ paypalOrderLink: any;
404
+ }>;
432
405
  };
433
406
 
434
407
  declare function useOrgController(): {
@@ -440,51 +413,43 @@ declare function useOrgController(): {
440
413
  updateById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
441
414
  };
442
415
 
443
- type TPSGC = {
416
+ type TPromo = {
444
417
  _id?: ObjectId;
445
418
  code: string;
446
- name: string;
447
- type: string;
448
- };
449
- declare const schemaPSGC: Joi.ObjectSchema<any>;
450
- declare function modelPSGC(data: any): {
451
- code: any;
452
- name: any;
453
- type: any;
419
+ description?: string;
420
+ type: "flat" | "fixed" | "tiered";
421
+ flatRate?: number;
422
+ fixedRate?: number;
423
+ tiers?: Array<{
424
+ minSeats: number;
425
+ maxSeats: number;
426
+ rate: number;
427
+ }>;
428
+ currency: string;
429
+ startDate: Date | string;
430
+ endDate?: Date | string;
431
+ assignedTo?: string | ObjectId;
432
+ status: "active" | "inactive" | "expired";
433
+ assignedAt?: Date | string;
434
+ createdAt?: Date | string;
435
+ updatedAt?: Date | string;
436
+ deletedAt?: Date | string;
454
437
  };
438
+ declare const schemaPromo: Joi.ObjectSchema<any>;
439
+ declare function modelPromo(data: TPromo): TPromo;
455
440
 
456
- declare function usePSGCRepo(): {
441
+ declare function usePromoRepo(): {
457
442
  createIndexes: () => Promise<void>;
458
- add: (value: TPSGC, session?: ClientSession) => Promise<ObjectId>;
459
- getAll: ({ search, page, limit, sort, type, prefix, }?: {
460
- search?: string | undefined;
443
+ add: (value: TPromo) => Promise<string>;
444
+ getAll: ({ page, limit, search, status, }?: {
461
445
  page?: number | undefined;
462
446
  limit?: number | undefined;
463
- sort?: {} | undefined;
464
- type?: string | undefined;
465
- prefix?: string | undefined;
466
- }) => Promise<Record<string, any>>;
467
- getById: (_id: string | ObjectId) => Promise<TPSGC>;
468
- updateFieldById: ({ _id, field, value }?: {
469
- _id: string | ObjectId;
470
- field: string;
471
- value: string;
472
- }, session?: ClientSession) => Promise<string>;
447
+ search?: string | undefined;
448
+ status?: string | undefined;
449
+ }) => Promise<TPaginate<TPromo>>;
450
+ getByCode: (code: string) => Promise<TPromo | null>;
451
+ getById: (_id: string | ObjectId) => Promise<TPromo | null>;
473
452
  deleteById: (_id: string | ObjectId) => Promise<string>;
474
- getByName: ({ name, prefix, type }?: {
475
- name: string;
476
- prefix?: string | undefined;
477
- type?: string | undefined;
478
- }) => Promise<TPSGC | null>;
479
- };
480
-
481
- declare function usePSGCController(): {
482
- add: (req: Request, res: Response, next: NextFunction) => Promise<void>;
483
- getAll: (req: Request, res: Response, next: NextFunction) => Promise<void>;
484
- getById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
485
- getByName: (req: Request, res: Response, next: NextFunction) => Promise<void>;
486
- updateField: (req: Request, res: Response, next: NextFunction) => Promise<void>;
487
- deleteById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
488
453
  };
489
454
 
490
455
  type TRole = {
@@ -665,6 +630,7 @@ declare function useGitHubService(): {
665
630
  declare function useUtilController(): {
666
631
  healthCheck: (req: Request, res: Response, next: NextFunction) => Promise<void>;
667
632
  setGitHubVariables: (req: Request, res: Response, next: NextFunction) => Promise<void>;
633
+ paypalWebhook: (req: Request, res: Response, next: NextFunction) => Promise<Response<any, Record<string, any>>>;
668
634
  };
669
635
 
670
636
  declare const transactionSchema: Joi.ObjectSchema<any>;
@@ -782,6 +748,7 @@ declare const schemaPlan: Joi.ObjectSchema<any>;
782
748
  declare function modelPlan(data: any): TPlan;
783
749
 
784
750
  declare function usePlanRepo(): {
751
+ createIndexes: () => Promise<void>;
785
752
  add: (value: TPlan) => Promise<string>;
786
753
  getAll: ({ page, limit, search, status, }?: {
787
754
  page?: number | undefined;
@@ -826,6 +793,7 @@ declare const schemaSubscriptionSeats: Joi.ObjectSchema<any>;
826
793
  declare function modelSubscription(data: any): TSubscription;
827
794
 
828
795
  declare function useSubscriptionRepo(): {
796
+ createIndexes: () => Promise<void>;
829
797
  add: (value: TSubscription, session?: ClientSession) => Promise<string>;
830
798
  getAll: ({ page, limit, search, status, }?: {
831
799
  page?: number | undefined;
@@ -867,6 +835,7 @@ declare const schemaSubscriptionTransaction: Joi.ObjectSchema<any>;
867
835
  declare function modelSubscriptionTransaction(data: TSubscriptionTransaction): TSubscriptionTransaction;
868
836
 
869
837
  declare function useSubscriptionTransactionRepo(): {
838
+ createIndexes: () => Promise<void>;
870
839
  add: (value: TSubscriptionTransaction, session?: ClientSession) => Promise<string>;
871
840
  getAll: ({ page, limit, search, id }?: {
872
841
  page?: number | undefined;
@@ -1061,8 +1030,10 @@ declare const SPACES_BUCKET: string;
1061
1030
  declare const PAYPAL_CLIENT_ID: string;
1062
1031
  declare const PAYPAL_CLIENT_SECRET: string;
1063
1032
  declare const PAYPAL_API_URL: string;
1033
+ declare const PAYPAL_WEBHOOK_ID: string;
1064
1034
  declare const XENDIT_SECRET_KEY: string;
1065
1035
  declare const XENDIT_BASE_URL: string;
1066
1036
  declare const DOMAIN: string;
1037
+ declare const APP_ORG: string;
1067
1038
 
1068
- 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 };
1039
+ 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, 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, modelApp, modelMember, modelOrg, modelPermission, modelPermissionGroup, modelPlan, modelPromo, modelRole, modelSubscription, modelSubscriptionTransaction, modelUser, modelVerification, schemaApp, schemaAppUpdate, schemaBuilding, schemaBuildingUnit, schemaInviteMember, 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, 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 };