@goweekdays/core 2.4.0 → 2.4.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.4.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 9a24dc7: Remove address resource and refactor index creation
8
+
9
+ ## 2.4.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 661c346: Add getAllByAppUser endpoint to member controller
14
+
3
15
  ## 2.4.0
4
16
 
5
17
  ### Minor 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,17 +284,18 @@ 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>;
321
291
  getAll: ({ search, limit, page, user, org, app, status }?: {
322
- search: string;
323
- limit: number;
324
- page: number;
292
+ search?: string | undefined;
293
+ limit?: number | undefined;
294
+ page?: number | undefined;
325
295
  user?: string | ObjectId | undefined;
326
296
  org?: string | ObjectId | undefined;
327
297
  app: string;
328
- status: string;
298
+ status?: string | undefined;
329
299
  }) => Promise<Record<string, any>>;
330
300
  getOrgsByUserId: ({ search, page, limit, sort, user, status, }?: {
331
301
  user: string | ObjectId;
@@ -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;
@@ -384,6 +354,7 @@ declare function useMemberController(): {
384
354
  updateRoleById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
385
355
  updateStatusById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
386
356
  deleteById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
357
+ getAllByAppUser: (req: Request, res: Response, next: NextFunction) => Promise<void>;
387
358
  };
388
359
 
389
360
  type TOrg = {
@@ -439,51 +410,43 @@ declare function useOrgController(): {
439
410
  updateById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
440
411
  };
441
412
 
442
- type TPSGC = {
413
+ type TPromo = {
443
414
  _id?: ObjectId;
444
415
  code: string;
445
- name: string;
446
- type: string;
447
- };
448
- declare const schemaPSGC: Joi.ObjectSchema<any>;
449
- declare function modelPSGC(data: any): {
450
- code: any;
451
- name: any;
452
- type: any;
416
+ description?: string;
417
+ type: "flat" | "fixed" | "tiered";
418
+ flatRate?: number;
419
+ fixedRate?: number;
420
+ tiers?: Array<{
421
+ minSeats: number;
422
+ maxSeats: number;
423
+ rate: number;
424
+ }>;
425
+ currency: string;
426
+ startDate: Date | string;
427
+ endDate?: Date | string;
428
+ assignedTo?: string | ObjectId;
429
+ status: "active" | "inactive" | "expired";
430
+ assignedAt?: Date | string;
431
+ createdAt?: Date | string;
432
+ updatedAt?: Date | string;
433
+ deletedAt?: Date | string;
453
434
  };
435
+ declare const schemaPromo: Joi.ObjectSchema<any>;
436
+ declare function modelPromo(data: TPromo): TPromo;
454
437
 
455
- declare function usePSGCRepo(): {
438
+ declare function usePromoRepo(): {
456
439
  createIndexes: () => Promise<void>;
457
- add: (value: TPSGC, session?: ClientSession) => Promise<ObjectId>;
458
- getAll: ({ search, page, limit, sort, type, prefix, }?: {
459
- search?: string | undefined;
440
+ add: (value: TPromo) => Promise<string>;
441
+ getAll: ({ page, limit, search, status, }?: {
460
442
  page?: number | undefined;
461
443
  limit?: number | undefined;
462
- sort?: {} | undefined;
463
- type?: string | undefined;
464
- prefix?: string | undefined;
465
- }) => Promise<Record<string, any>>;
466
- getById: (_id: string | ObjectId) => Promise<TPSGC>;
467
- updateFieldById: ({ _id, field, value }?: {
468
- _id: string | ObjectId;
469
- field: string;
470
- value: string;
471
- }, session?: ClientSession) => Promise<string>;
444
+ search?: string | undefined;
445
+ status?: string | undefined;
446
+ }) => Promise<TPaginate<TPromo>>;
447
+ getByCode: (code: string) => Promise<TPromo | null>;
448
+ getById: (_id: string | ObjectId) => Promise<TPromo | null>;
472
449
  deleteById: (_id: string | ObjectId) => Promise<string>;
473
- getByName: ({ name, prefix, type }?: {
474
- name: string;
475
- prefix?: string | undefined;
476
- type?: string | undefined;
477
- }) => Promise<TPSGC | null>;
478
- };
479
-
480
- declare function usePSGCController(): {
481
- add: (req: Request, res: Response, next: NextFunction) => Promise<void>;
482
- getAll: (req: Request, res: Response, next: NextFunction) => Promise<void>;
483
- getById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
484
- getByName: (req: Request, res: Response, next: NextFunction) => Promise<void>;
485
- updateField: (req: Request, res: Response, next: NextFunction) => Promise<void>;
486
- deleteById: (req: Request, res: Response, next: NextFunction) => Promise<void>;
487
450
  };
488
451
 
489
452
  type TRole = {
@@ -781,6 +744,7 @@ declare const schemaPlan: Joi.ObjectSchema<any>;
781
744
  declare function modelPlan(data: any): TPlan;
782
745
 
783
746
  declare function usePlanRepo(): {
747
+ createIndexes: () => Promise<void>;
784
748
  add: (value: TPlan) => Promise<string>;
785
749
  getAll: ({ page, limit, search, status, }?: {
786
750
  page?: number | undefined;
@@ -825,6 +789,7 @@ declare const schemaSubscriptionSeats: Joi.ObjectSchema<any>;
825
789
  declare function modelSubscription(data: any): TSubscription;
826
790
 
827
791
  declare function useSubscriptionRepo(): {
792
+ createIndexes: () => Promise<void>;
828
793
  add: (value: TSubscription, session?: ClientSession) => Promise<string>;
829
794
  getAll: ({ page, limit, search, status, }?: {
830
795
  page?: number | undefined;
@@ -866,6 +831,7 @@ declare const schemaSubscriptionTransaction: Joi.ObjectSchema<any>;
866
831
  declare function modelSubscriptionTransaction(data: TSubscriptionTransaction): TSubscriptionTransaction;
867
832
 
868
833
  declare function useSubscriptionTransactionRepo(): {
834
+ createIndexes: () => Promise<void>;
869
835
  add: (value: TSubscriptionTransaction, session?: ClientSession) => Promise<string>;
870
836
  getAll: ({ page, limit, search, id }?: {
871
837
  page?: number | undefined;
@@ -1064,4 +1030,4 @@ declare const XENDIT_SECRET_KEY: string;
1064
1030
  declare const XENDIT_BASE_URL: string;
1065
1031
  declare const DOMAIN: string;
1066
1032
 
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 };
1033
+ 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, 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, 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 };