storemw-core-api 1.0.144 → 1.0.146

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.
Files changed (33) hide show
  1. package/dist/controllers/subscription/plan/subscribePlanController.js +4 -0
  2. package/dist/controllers/subscription/plan/subscribePlanController.js.map +1 -1
  3. package/dist/features/auth_token/authTokenType.d.ts +1 -1
  4. package/dist/features/auth_token/authTokenType.js.map +1 -1
  5. package/dist/features/index.d.ts +3 -0
  6. package/dist/features/index.js +5 -1
  7. package/dist/features/index.js.map +1 -1
  8. package/dist/features/user_me/userMeRegister.d.ts +5 -0
  9. package/dist/features/user_me/userMeRegister.js +11 -0
  10. package/dist/features/user_me/userMeRegister.js.map +1 -0
  11. package/dist/features/user_me/userMeRegistry.d.ts +2 -0
  12. package/dist/features/user_me/userMeRegistry.js +32 -0
  13. package/dist/features/user_me/userMeRegistry.js.map +1 -0
  14. package/dist/features/user_me/userMeType.d.ts +8 -0
  15. package/dist/features/user_me/userMeType.js +3 -0
  16. package/dist/features/user_me/userMeType.js.map +1 -0
  17. package/dist/models/subscription/plan/SubscribePlanModel.d.ts +13 -2
  18. package/dist/schema/payload/subscription/schemaSubscribePlan.d.ts +17 -0
  19. package/dist/schema/payload/subscription/schemaSubscribePlan.js +1 -0
  20. package/dist/schema/payload/subscription/schemaSubscribePlan.js.map +1 -1
  21. package/dist/services/auth/AuthService.js +4 -1
  22. package/dist/services/auth/AuthService.js.map +1 -1
  23. package/dist/services/index.d.ts +1 -1
  24. package/dist/services/index.js.map +1 -1
  25. package/dist/services/subscription/account/AccountSubscribeService.js +21 -0
  26. package/dist/services/subscription/account/AccountSubscribeService.js.map +1 -1
  27. package/dist/services/subscription/plan/SubscribePlanService.d.ts +2 -0
  28. package/dist/services/subscription/plan/SubscribePlanService.js +3 -0
  29. package/dist/services/subscription/plan/SubscribePlanService.js.map +1 -1
  30. package/dist/services/user/UserMeService.js +24 -211
  31. package/dist/services/user/UserMeService.js.map +1 -1
  32. package/package.json +1 -1
  33. package/prisma/schema.prisma +16 -15
@@ -47,6 +47,7 @@ const createSubcribePlan = async (req, res, next) => {
47
47
  price: reqPayload?.subscribe_plan?.price ?? "",
48
48
  billingCycle: reqPayload?.subscribe_plan?.billing_cycle ?? "",
49
49
  currency: reqPayload?.subscribe_plan?.currency ?? "",
50
+ isSingleSubscription: reqPayload?.subscribe_plan?.is_single_subscription,
50
51
  status: reqPayload?.subscribe_plan?.status
51
52
  }
52
53
  }
@@ -59,6 +60,7 @@ const createSubcribePlan = async (req, res, next) => {
59
60
  price: request.payload.subscribePlan.price,
60
61
  billingCycle: request.payload.subscribePlan.billingCycle,
61
62
  currency: request.payload.subscribePlan.currency,
63
+ isSingleSubscription: request.payload.subscribePlan.isSingleSubscription,
62
64
  status: request.payload.subscribePlan.status
63
65
  }
64
66
  };
@@ -95,6 +97,7 @@ const updateSubscribePlan = async (req, res, next) => {
95
97
  price: reqPayload?.subscribe_plan?.price ?? "",
96
98
  billingCycle: reqPayload?.subscribe_plan?.billing_cycle ?? "",
97
99
  currency: reqPayload?.subscribe_plan?.currency ?? "",
100
+ isSingleSubscription: reqPayload?.subscribe_plan?.is_single_subscription,
98
101
  status: reqPayload?.subscribe_plan?.status
99
102
  }
100
103
  }
@@ -108,6 +111,7 @@ const updateSubscribePlan = async (req, res, next) => {
108
111
  price: request.payload.subscribePlan.price,
109
112
  billingCycle: request.payload.subscribePlan.billingCycle,
110
113
  currency: request.payload.subscribePlan.currency,
114
+ isSingleSubscription: request.payload.subscribePlan.isSingleSubscription,
111
115
  status: request.payload.subscribePlan.status
112
116
  }
113
117
  };
@@ -1 +1 @@
1
- {"version":3,"file":"subscribePlanController.js","sourceRoot":"","sources":["../../../../src/controllers/subscription/plan/subscribePlanController.ts"],"names":[],"mappings":";;;AAEA,mCAAqF;AAIrF,yCAAqG;AACrG,8CAI0B;AAE1B,MAAM,WAAW,GAAG,CAAC,UAAmB,EAAE,EAAE;IAExC,IAAI,QAAQ,GA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AAC,KAAK,CAAC,CAAA;IACf,CAAC;AACL,CAAC,CAAC;AArBW,QAAA,oBAAoB,wBAqB/B","sourcesContent":["import { Request, Response, NextFunction } from \"express\";\n\nimport { getDefaultServiceProps, sendSuccess, sendError, HTTP_STATUS } from \"@/utils\"\n\nimport { QueryList } from \"@/schema/middleware/route\";\n\nimport { SubscribePlanService, SubscribePlanCreateProps, SubscribePlanUpdateProps } from \"@/services\"\nimport {\n schemaSubscribePlanCreatePayload,\n schemaSubscribePlanUpdatePayload,\n schemaSubscribePlanDeletePayload\n} from \"@/schema/payload\";\n\nconst getRootName = (toSingular: boolean) => {\n\n let rootName = toSingular ? \"subscribe_plan\" : \"subscribe_plans\";\n\n return rootName\n}\n\n/** subscriptions/plan/:planId : get subscribe plan */\nexport const getSubscribePlan = async (req: Request, res: Response, next: NextFunction): Promise<any> => {\n try {\n\n const { planId } = req.params;\n const requestQuery = req.query as unknown as QueryList;\n\n const subscribePlanService = SubscribePlanService({\n ...getDefaultServiceProps(req),\n })\n\n const data = await subscribePlanService.getSubscribePlan({ id: Number(planId), datatypes: requestQuery.datatypes })\n\n return sendSuccess(res, data, \"Retrieved successfully\", getRootName(true));\n\n } catch (error: any) {\n next(error)\n }\n}\n\n/** subscriptions/plan : create subscribe plan */\nexport const createSubcribePlan = async (req: Request, res: Response, next: NextFunction): Promise<void> => {\n try {\n\n // const requestUserType = req.body.scope.target as SubscribePlanServiceProps[\"userType\"]\n\n const subscribePlanService = SubscribePlanService({\n ...getDefaultServiceProps(req),\n })\n\n let response: any = {}\n\n let reqScope = req.body.scope\n let reqPayload = req.body.payload\n\n let request = schemaSubscribePlanCreatePayload.parse({\n scope: {\n target: reqScope.target,\n action: reqScope.action\n },\n payload: {\n subscribePlan: {\n name: reqPayload?.subscribe_plan?.name ?? \"\",\n shortDescription: reqPayload?.subscribe_plan?.short_description ?? \"\",\n fullDescription: reqPayload?.subscribe_plan?.full_description ?? \"\",\n price: reqPayload?.subscribe_plan?.price ?? \"\",\n billingCycle: reqPayload?.subscribe_plan?.billing_cycle ?? \"\",\n currency: reqPayload?.subscribe_plan?.currency ?? \"\",\n status: reqPayload?.subscribe_plan?.status\n }\n }\n })\n\n let payload: SubscribePlanCreateProps = {\n data: {\n name: request.payload.subscribePlan.name,\n shortDescription: request.payload.subscribePlan.shortDescription,\n fullDescription: request.payload.subscribePlan.fullDescription,\n price: request.payload.subscribePlan.price,\n billingCycle: request.payload.subscribePlan.billingCycle,\n currency: request.payload.subscribePlan.currency,\n status: request.payload.subscribePlan.status\n }\n }\n\n response = {\n [`${getRootName(true)}`]: await subscribePlanService.createSubscribePlan(payload)\n }\n\n sendSuccess(res, response, `Subscribe plan created successfully`)\n\n } catch (error: any) {\n next(error)\n }\n};\n\n/** subscriptions/plan/:planId : update subscribe plan */\nexport const updateSubscribePlan = async (req: Request, res: Response, next: NextFunction): Promise<void> => {\n try {\n\n const { planId } = req.params;\n\n const subscribePlanService = SubscribePlanService({\n ...getDefaultServiceProps(req),\n })\n\n let response: any = {}\n\n let reqScope = req.body.scope\n let reqPayload = req.body.payload\n\n\n let request = schemaSubscribePlanUpdatePayload.parse({\n scope: {\n target: reqScope.target,\n action: reqScope.action\n },\n payload: {\n subscribePlan: {\n name: reqPayload?.subscribe_plan?.name ?? \"\",\n shortDescription: reqPayload?.subscribe_plan?.short_description ?? \"\",\n fullDescription: reqPayload?.subscribe_plan?.full_description ?? \"\",\n price: reqPayload?.subscribe_plan?.price ?? \"\",\n billingCycle: reqPayload?.subscribe_plan?.billing_cycle ?? \"\",\n currency: reqPayload?.subscribe_plan?.currency ?? \"\",\n status: reqPayload?.subscribe_plan?.status\n }\n }\n })\n\n let payload: SubscribePlanUpdateProps = {\n subscribePlanId: Number(planId),\n data: {\n name: request.payload.subscribePlan.name,\n shortDescription: request.payload.subscribePlan.shortDescription,\n fullDescription: request.payload.subscribePlan.fullDescription,\n price: request.payload.subscribePlan.price,\n billingCycle: request.payload.subscribePlan.billingCycle,\n currency: request.payload.subscribePlan.currency,\n status: request.payload.subscribePlan.status\n }\n }\n\n response = {\n [`${getRootName(true)}`]: await subscribePlanService.updateSubscribePlan(payload)\n }\n\n sendSuccess(res, response, `Subscribe plan updated successfully`)\n\n } catch (error: any) {\n next(error)\n }\n};\n\n/** subscriptions/plans : list subscribe plans */\nexport const listSubscribePlans = async (req: Request, res: Response, next: NextFunction): Promise<any> => {\n\n try {\n\n const requestQuery = req.query as unknown as QueryList;\n\n const subscribePlanService = SubscribePlanService({\n ...getDefaultServiceProps(req),\n })\n\n const { data, total } = await subscribePlanService.listSubscribePlans({\n ...requestQuery\n });\n\n let response = {\n [`${getRootName(false)}`]: data,\n total,\n }\n\n return sendSuccess(res, response, \"Retrieved successfully\");\n\n } catch (error: any) {\n next(error)\n }\n};\n\n/** subscriptions/plans/delete : delete subscribe plans */\nexport const deleteSubscribePlans = async (req: Request, res: Response, next: NextFunction): Promise<any> => {\n\n try {\n\n const request = schemaSubscribePlanDeletePayload.parse(req.body)\n\n const subscribePlanService = SubscribePlanService({\n ...getDefaultServiceProps(req),\n })\n\n const payload = {\n subscribePlanIds: request.payload.ids.map(i => BigInt(i))\n }\n\n const data = await subscribePlanService.removeSubscribePlans(payload);\n\n return sendSuccess(res, data, \"Deleted\", getRootName(false));\n\n } catch (error: any) {\n next(error)\n }\n};"]}
1
+ {"version":3,"file":"subscribePlanController.js","sourceRoot":"","sources":["../../../../src/controllers/subscription/plan/subscribePlanController.ts"],"names":[],"mappings":";;;AAEA,mCAAqF;AAIrF,yCAAqG;AACrG,8CAI0B;AAE1B,MAAM,WAAW,GAAG,CAAC,UAAmB,EAAE,EAAE;IAExC,IAAI,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,iBAAiB,CAAC;IAEjE,OAAO,QAAQ,CAAA;AACnB,CAAC,CAAA;AAED,sDAAsD;AAC/C,MAAM,gBAAgB,GAAG,KAAK,EAAE,GAAY,EAAE,GAAa,EAAE,IAAkB,EAAgB,EAAE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,KAAU,EAAE,CAAC;QAClB,IAAI,CAAC,KAAK,CAAC,CAAA;IACf,CAAC;AACL,CAAC,CAAC;AArBW,QAAA,oBAAoB,wBAqB/B","sourcesContent":["import { Request, Response, NextFunction } from \"express\";\n\nimport { getDefaultServiceProps, sendSuccess, sendError, HTTP_STATUS } from \"@/utils\"\n\nimport { QueryList } from \"@/schema/middleware/route\";\n\nimport { SubscribePlanService, SubscribePlanCreateProps, SubscribePlanUpdateProps } from \"@/services\"\nimport {\n schemaSubscribePlanCreatePayload,\n schemaSubscribePlanUpdatePayload,\n schemaSubscribePlanDeletePayload\n} from \"@/schema/payload\";\n\nconst getRootName = (toSingular: boolean) => {\n\n let rootName = toSingular ? \"subscribe_plan\" : \"subscribe_plans\";\n\n return rootName\n}\n\n/** subscriptions/plan/:planId : get subscribe plan */\nexport const getSubscribePlan = async (req: Request, res: Response, next: NextFunction): Promise<any> => {\n try {\n\n const { planId } = req.params;\n const requestQuery = req.query as unknown as QueryList;\n\n const subscribePlanService = SubscribePlanService({\n ...getDefaultServiceProps(req),\n })\n\n const data = await subscribePlanService.getSubscribePlan({ id: Number(planId), datatypes: requestQuery.datatypes })\n\n return sendSuccess(res, data, \"Retrieved successfully\", getRootName(true));\n\n } catch (error: any) {\n next(error)\n }\n}\n\n/** subscriptions/plan : create subscribe plan */\nexport const createSubcribePlan = async (req: Request, res: Response, next: NextFunction): Promise<void> => {\n try {\n\n // const requestUserType = req.body.scope.target as SubscribePlanServiceProps[\"userType\"]\n\n const subscribePlanService = SubscribePlanService({\n ...getDefaultServiceProps(req),\n })\n\n let response: any = {}\n\n let reqScope = req.body.scope\n let reqPayload = req.body.payload\n\n let request = schemaSubscribePlanCreatePayload.parse({\n scope: {\n target: reqScope.target,\n action: reqScope.action\n },\n payload: {\n subscribePlan: {\n name: reqPayload?.subscribe_plan?.name ?? \"\",\n shortDescription: reqPayload?.subscribe_plan?.short_description ?? \"\",\n fullDescription: reqPayload?.subscribe_plan?.full_description ?? \"\",\n price: reqPayload?.subscribe_plan?.price ?? \"\",\n billingCycle: reqPayload?.subscribe_plan?.billing_cycle ?? \"\",\n currency: reqPayload?.subscribe_plan?.currency ?? \"\",\n isSingleSubscription: reqPayload?.subscribe_plan?.is_single_subscription,\n status: reqPayload?.subscribe_plan?.status\n }\n }\n })\n\n let payload: SubscribePlanCreateProps = {\n data: {\n name: request.payload.subscribePlan.name,\n shortDescription: request.payload.subscribePlan.shortDescription,\n fullDescription: request.payload.subscribePlan.fullDescription,\n price: request.payload.subscribePlan.price,\n billingCycle: request.payload.subscribePlan.billingCycle,\n currency: request.payload.subscribePlan.currency,\n isSingleSubscription: request.payload.subscribePlan.isSingleSubscription,\n status: request.payload.subscribePlan.status\n }\n }\n\n response = {\n [`${getRootName(true)}`]: await subscribePlanService.createSubscribePlan(payload)\n }\n\n sendSuccess(res, response, `Subscribe plan created successfully`)\n\n } catch (error: any) {\n next(error)\n }\n};\n\n/** subscriptions/plan/:planId : update subscribe plan */\nexport const updateSubscribePlan = async (req: Request, res: Response, next: NextFunction): Promise<void> => {\n try {\n\n const { planId } = req.params;\n\n const subscribePlanService = SubscribePlanService({\n ...getDefaultServiceProps(req),\n })\n\n let response: any = {}\n\n let reqScope = req.body.scope\n let reqPayload = req.body.payload\n\n\n let request = schemaSubscribePlanUpdatePayload.parse({\n scope: {\n target: reqScope.target,\n action: reqScope.action\n },\n payload: {\n subscribePlan: {\n name: reqPayload?.subscribe_plan?.name ?? \"\",\n shortDescription: reqPayload?.subscribe_plan?.short_description ?? \"\",\n fullDescription: reqPayload?.subscribe_plan?.full_description ?? \"\",\n price: reqPayload?.subscribe_plan?.price ?? \"\",\n billingCycle: reqPayload?.subscribe_plan?.billing_cycle ?? \"\",\n currency: reqPayload?.subscribe_plan?.currency ?? \"\",\n isSingleSubscription: reqPayload?.subscribe_plan?.is_single_subscription,\n status: reqPayload?.subscribe_plan?.status\n }\n }\n })\n\n let payload: SubscribePlanUpdateProps = {\n subscribePlanId: Number(planId),\n data: {\n name: request.payload.subscribePlan.name,\n shortDescription: request.payload.subscribePlan.shortDescription,\n fullDescription: request.payload.subscribePlan.fullDescription,\n price: request.payload.subscribePlan.price,\n billingCycle: request.payload.subscribePlan.billingCycle,\n currency: request.payload.subscribePlan.currency,\n isSingleSubscription: request.payload.subscribePlan.isSingleSubscription,\n status: request.payload.subscribePlan.status\n }\n }\n\n response = {\n [`${getRootName(true)}`]: await subscribePlanService.updateSubscribePlan(payload)\n }\n\n sendSuccess(res, response, `Subscribe plan updated successfully`)\n\n } catch (error: any) {\n next(error)\n }\n};\n\n/** subscriptions/plans : list subscribe plans */\nexport const listSubscribePlans = async (req: Request, res: Response, next: NextFunction): Promise<any> => {\n\n try {\n\n const requestQuery = req.query as unknown as QueryList;\n\n const subscribePlanService = SubscribePlanService({\n ...getDefaultServiceProps(req),\n })\n\n const { data, total } = await subscribePlanService.listSubscribePlans({\n ...requestQuery\n });\n\n let response = {\n [`${getRootName(false)}`]: data,\n total,\n }\n\n return sendSuccess(res, response, \"Retrieved successfully\");\n\n } catch (error: any) {\n next(error)\n }\n};\n\n/** subscriptions/plans/delete : delete subscribe plans */\nexport const deleteSubscribePlans = async (req: Request, res: Response, next: NextFunction): Promise<any> => {\n\n try {\n\n const request = schemaSubscribePlanDeletePayload.parse(req.body)\n\n const subscribePlanService = SubscribePlanService({\n ...getDefaultServiceProps(req),\n })\n\n const payload = {\n subscribePlanIds: request.payload.ids.map(i => BigInt(i))\n }\n\n const data = await subscribePlanService.removeSubscribePlans(payload);\n\n return sendSuccess(res, data, \"Deleted\", getRootName(false));\n\n } catch (error: any) {\n next(error)\n }\n};"]}
@@ -1,5 +1,5 @@
1
1
  import { AuthTokenResult } from "../../services";
2
2
  export type FeatureAuthTokenSuccessAuthenticateProps = AuthTokenResult & {};
3
3
  export type FeatureAuthTokenProps = {
4
- onSuccessAuthenticate: (payload: FeatureAuthTokenSuccessAuthenticateProps) => Promise<any>;
4
+ onSuccessAuthenticate?: (payload: FeatureAuthTokenSuccessAuthenticateProps) => Promise<any>;
5
5
  };
@@ -1 +1 @@
1
- {"version":3,"file":"authTokenType.js","sourceRoot":"","sources":["../../../src/features/auth_token/authTokenType.ts"],"names":[],"mappings":"","sourcesContent":["import { SmtpEmailTransporterOptions } from \"../../services\"\n\nimport { AuthTokenResult } from \"../../services\"\n\nexport type FeatureAuthTokenSuccessAuthenticateProps = AuthTokenResult & {\n}\n\nexport type FeatureAuthTokenProps = {\n onSuccessAuthenticate: (payload: FeatureAuthTokenSuccessAuthenticateProps) => Promise<any>\n}"]}
1
+ {"version":3,"file":"authTokenType.js","sourceRoot":"","sources":["../../../src/features/auth_token/authTokenType.ts"],"names":[],"mappings":"","sourcesContent":["import { AuthTokenResult } from \"../../services\"\n\nexport type FeatureAuthTokenSuccessAuthenticateProps = AuthTokenResult & {\n}\n\nexport type FeatureAuthTokenProps = {\n onSuccessAuthenticate?: (payload: FeatureAuthTokenSuccessAuthenticateProps) => Promise<any>\n}"]}
@@ -13,3 +13,6 @@ export { registerSmtpEmailHook } from "./smtp_email/smtpEmailRegister";
13
13
  export { FeatureFileStorageProps, FeatureFileStorageOptions, FeatureFileStorageConfiguration, FeatureFileStorageLocalOptions, FeatureFileStorageGoogleCloudOptions, FeatureFileStorageStartUploadProps, FeatureFileStorageSuccessUploadProps } from './file_storage/fileStorageType';
14
14
  export { FileStorageHook } from "./file_storage/fileStorageRegistry";
15
15
  export { registerFileStorageHook } from "./file_storage/fileStorageRegister";
16
+ export { FeatureUserMeProps, FeatureUserMeSuccessUpdateProps, FeatureUserMeSuccessChangePasswordProps, FeatureUserMeSuccessRemoveProps } from './user_me/userMeType';
17
+ export { UserMeHook } from "./user_me/userMeRegistry";
18
+ export { registerUserMeHook } from "./user_me/userMeRegister";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.registerFileStorageHook = exports.FileStorageHook = exports.registerSmtpEmailHook = exports.SmtpEmailHook = exports.registerResetPasswordHook = exports.ResetPasswordHook = exports.registerAuthTokenHook = exports.AuthTokenHook = exports.registerCoreConfigHook = exports.CoreConfigHook = void 0;
3
+ exports.registerUserMeHook = exports.UserMeHook = exports.registerFileStorageHook = exports.FileStorageHook = exports.registerSmtpEmailHook = exports.SmtpEmailHook = exports.registerResetPasswordHook = exports.ResetPasswordHook = exports.registerAuthTokenHook = exports.AuthTokenHook = exports.registerCoreConfigHook = exports.CoreConfigHook = void 0;
4
4
  var coreConfigRegistry_1 = require("./core_config/coreConfigRegistry");
5
5
  Object.defineProperty(exports, "CoreConfigHook", { enumerable: true, get: function () { return coreConfigRegistry_1.CoreConfigHook; } });
6
6
  var coreConfigRegister_1 = require("./core_config/coreConfigRegister");
@@ -21,4 +21,8 @@ var fileStorageRegistry_1 = require("./file_storage/fileStorageRegistry");
21
21
  Object.defineProperty(exports, "FileStorageHook", { enumerable: true, get: function () { return fileStorageRegistry_1.FileStorageHook; } });
22
22
  var fileStorageRegister_1 = require("./file_storage/fileStorageRegister");
23
23
  Object.defineProperty(exports, "registerFileStorageHook", { enumerable: true, get: function () { return fileStorageRegister_1.registerFileStorageHook; } });
24
+ var userMeRegistry_1 = require("./user_me/userMeRegistry");
25
+ Object.defineProperty(exports, "UserMeHook", { enumerable: true, get: function () { return userMeRegistry_1.UserMeHook; } });
26
+ var userMeRegister_1 = require("./user_me/userMeRegister");
27
+ Object.defineProperty(exports, "registerUserMeHook", { enumerable: true, get: function () { return userMeRegister_1.registerUserMeHook; } });
24
28
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/features/index.ts"],"names":[],"mappings":";;;AACA,uEAAiE;AAAxD,oHAAA,cAAc,OAAA;AACvB,uEAAyE;AAAhE,4HAAA,sBAAsB,OAAA;AAG/B,oEAA8D;AAArD,kHAAA,aAAa,OAAA;AACtB,oEAAsE;AAA7D,0HAAA,qBAAqB,OAAA;AAG9B,gFAA0E;AAAjE,0HAAA,iBAAiB,OAAA;AAC1B,gFAAkF;AAAzE,kIAAA,yBAAyB,OAAA;AAGlC,oEAA8D;AAArD,kHAAA,aAAa,OAAA;AACtB,oEAAsE;AAA7D,0HAAA,qBAAqB,OAAA;AAG9B,0EAAoE;AAA3D,sHAAA,eAAe,OAAA;AACxB,0EAA4E;AAAnE,8HAAA,uBAAuB,OAAA","sourcesContent":["export { FeatureCoreConfigProps, FeatureCoreConfigOptions } from './core_config/coreConfigType'\nexport { CoreConfigHook } from \"./core_config/coreConfigRegistry\"\nexport { registerCoreConfigHook } from \"./core_config/coreConfigRegister\"\n\nexport { FeatureAuthTokenProps, FeatureAuthTokenSuccessAuthenticateProps } from './auth_token/authTokenType'\nexport { AuthTokenHook } from \"./auth_token/authTokenRegistry\"\nexport { registerAuthTokenHook } from \"./auth_token/authTokenRegister\"\n\nexport { FeatureResetPasswordProps, FeatureResetPasswordSuccessProps, FeatureResetPasswordRequestProps } from './reset_password/resetPasswordType'\nexport { ResetPasswordHook } from \"./reset_password/resetPasswordRegistry\"\nexport { registerResetPasswordHook } from \"./reset_password/resetPasswordRegister\"\n\nexport { FeatureSmtpEmailProps, FeatureSmtpEmailOptions, FeatureSmtpEmailHbsOptions, FeatureSmtpEmailStartSendProps, FeatureSmtpEmailSuccessSendProps } from './smtp_email/smtpEmailType'\nexport { SmtpEmailHook } from \"./smtp_email/smtpEmailRegistry\"\nexport { registerSmtpEmailHook } from \"./smtp_email/smtpEmailRegister\"\n\nexport { FeatureFileStorageProps, FeatureFileStorageOptions, FeatureFileStorageConfiguration, FeatureFileStorageLocalOptions, FeatureFileStorageGoogleCloudOptions, FeatureFileStorageStartUploadProps, FeatureFileStorageSuccessUploadProps } from './file_storage/fileStorageType'\nexport { FileStorageHook } from \"./file_storage/fileStorageRegistry\"\nexport { registerFileStorageHook } from \"./file_storage/fileStorageRegister\""]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/features/index.ts"],"names":[],"mappings":";;;AACA,uEAAiE;AAAxD,oHAAA,cAAc,OAAA;AACvB,uEAAyE;AAAhE,4HAAA,sBAAsB,OAAA;AAG/B,oEAA8D;AAArD,kHAAA,aAAa,OAAA;AACtB,oEAAsE;AAA7D,0HAAA,qBAAqB,OAAA;AAG9B,gFAA0E;AAAjE,0HAAA,iBAAiB,OAAA;AAC1B,gFAAkF;AAAzE,kIAAA,yBAAyB,OAAA;AAGlC,oEAA8D;AAArD,kHAAA,aAAa,OAAA;AACtB,oEAAsE;AAA7D,0HAAA,qBAAqB,OAAA;AAG9B,0EAAoE;AAA3D,sHAAA,eAAe,OAAA;AACxB,0EAA4E;AAAnE,8HAAA,uBAAuB,OAAA;AAGhC,2DAAqD;AAA5C,4GAAA,UAAU,OAAA;AACnB,2DAA6D;AAApD,oHAAA,kBAAkB,OAAA","sourcesContent":["export { FeatureCoreConfigProps, FeatureCoreConfigOptions } from './core_config/coreConfigType'\nexport { CoreConfigHook } from \"./core_config/coreConfigRegistry\"\nexport { registerCoreConfigHook } from \"./core_config/coreConfigRegister\"\n\nexport { FeatureAuthTokenProps, FeatureAuthTokenSuccessAuthenticateProps } from './auth_token/authTokenType'\nexport { AuthTokenHook } from \"./auth_token/authTokenRegistry\"\nexport { registerAuthTokenHook } from \"./auth_token/authTokenRegister\"\n\nexport { FeatureResetPasswordProps, FeatureResetPasswordSuccessProps, FeatureResetPasswordRequestProps } from './reset_password/resetPasswordType'\nexport { ResetPasswordHook } from \"./reset_password/resetPasswordRegistry\"\nexport { registerResetPasswordHook } from \"./reset_password/resetPasswordRegister\"\n\nexport { FeatureSmtpEmailProps, FeatureSmtpEmailOptions, FeatureSmtpEmailHbsOptions, FeatureSmtpEmailStartSendProps, FeatureSmtpEmailSuccessSendProps } from './smtp_email/smtpEmailType'\nexport { SmtpEmailHook } from \"./smtp_email/smtpEmailRegistry\"\nexport { registerSmtpEmailHook } from \"./smtp_email/smtpEmailRegister\"\n\nexport { FeatureFileStorageProps, FeatureFileStorageOptions, FeatureFileStorageConfiguration, FeatureFileStorageLocalOptions, FeatureFileStorageGoogleCloudOptions, FeatureFileStorageStartUploadProps, FeatureFileStorageSuccessUploadProps } from './file_storage/fileStorageType'\nexport { FileStorageHook } from \"./file_storage/fileStorageRegistry\"\nexport { registerFileStorageHook } from \"./file_storage/fileStorageRegister\"\n\nexport { FeatureUserMeProps, FeatureUserMeSuccessUpdateProps, FeatureUserMeSuccessChangePasswordProps, FeatureUserMeSuccessRemoveProps } from './user_me/userMeType'\nexport { UserMeHook } from \"./user_me/userMeRegistry\"\nexport { registerUserMeHook } from \"./user_me/userMeRegister\""]}
@@ -0,0 +1,5 @@
1
+ import { FeatureUserMeProps } from './userMeType';
2
+ /**
3
+ * Register consumer-provided hooks for user/me
4
+ */
5
+ export declare function registerUserMeHook(hooks: FeatureUserMeProps): void;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerUserMeHook = registerUserMeHook;
4
+ const userMeRegistry_1 = require("./userMeRegistry");
5
+ /**
6
+ * Register consumer-provided hooks for user/me
7
+ */
8
+ function registerUserMeHook(hooks) {
9
+ Object.assign(userMeRegistry_1.UserMeHook, hooks);
10
+ }
11
+ //# sourceMappingURL=userMeRegister.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userMeRegister.js","sourceRoot":"","sources":["../../../src/features/user_me/userMeRegister.ts"],"names":[],"mappings":";;AAMA,gDAEC;AAPD,qDAA6C;AAE7C;;GAEG;AACH,SAAgB,kBAAkB,CAAC,KAAyB;IACxD,MAAM,CAAC,MAAM,CAAC,2BAAU,EAAE,KAAK,CAAC,CAAA;AACpC,CAAC","sourcesContent":["import { FeatureUserMeProps } from './userMeType'\nimport { UserMeHook } from './userMeRegistry'\n\n/**\n * Register consumer-provided hooks for user/me\n */\nexport function registerUserMeHook(hooks: FeatureUserMeProps) {\n Object.assign(UserMeHook, hooks)\n}"]}
@@ -0,0 +1,2 @@
1
+ import { FeatureUserMeProps } from './userMeType';
2
+ export declare const UserMeHook: FeatureUserMeProps;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserMeHook = void 0;
4
+ // import { throwError } from '../../utils'
5
+ // Runtime for injected hook
6
+ exports.UserMeHook = {
7
+ onSuccessUpdateMe: async (props) => {
8
+ // console.log('authTokenResult', authTokenResult)
9
+ // example to add custom props into return auth token result
10
+ // return {
11
+ // ...authTokenResult,
12
+ // workerId: 1000
13
+ // }
14
+ },
15
+ onSuccessChangePasswordMe: async (props) => {
16
+ // console.log('authTokenResult', authTokenResult)
17
+ // example to add custom props into return auth token result
18
+ // return {
19
+ // ...authTokenResult,
20
+ // workerId: 1000
21
+ // }
22
+ },
23
+ onSuccessRemoveMe: async (props) => {
24
+ // console.log('authTokenResult', authTokenResult)
25
+ // example to add custom props into return auth token result
26
+ // return {
27
+ // ...authTokenResult,
28
+ // workerId: 1000
29
+ // }
30
+ },
31
+ };
32
+ //# sourceMappingURL=userMeRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userMeRegistry.js","sourceRoot":"","sources":["../../../src/features/user_me/userMeRegistry.ts"],"names":[],"mappings":";;;AAEA,uCAAuC;AAEvC,4BAA4B;AACf,QAAA,UAAU,GAAuB;IAC1C,iBAAiB,EAAE,KAAK,EAAE,KAAsC,EAAE,EAAE;QAEhE,kDAAkD;QAElD,4DAA4D;QAE5D,WAAW;QACX,0BAA0B;QAC1B,qBAAqB;QACrB,IAAI;IAGR,CAAC;IACD,yBAAyB,EAAE,KAAK,EAAE,KAA8C,EAAE,EAAE;QAEhF,kDAAkD;QAElD,4DAA4D;QAE5D,WAAW;QACX,0BAA0B;QAC1B,qBAAqB;QACrB,IAAI;IAGR,CAAC;IACD,iBAAiB,EAAE,KAAK,EAAE,KAAsC,EAAE,EAAE;QAEhE,kDAAkD;QAElD,4DAA4D;QAE5D,WAAW;QACX,0BAA0B;QAC1B,qBAAqB;QACrB,IAAI;IAGR,CAAC;CACJ,CAAA","sourcesContent":["import { FeatureUserMeProps, FeatureUserMeSuccessUpdateProps, FeatureUserMeSuccessChangePasswordProps, FeatureUserMeSuccessRemoveProps } from './userMeType'\n\n// import { throwError } from '@/utils'\n\n// Runtime for injected hook\nexport const UserMeHook: FeatureUserMeProps = {\n onSuccessUpdateMe: async (props: FeatureUserMeSuccessUpdateProps) => {\n\n // console.log('authTokenResult', authTokenResult)\n\n // example to add custom props into return auth token result\n\n // return {\n // ...authTokenResult,\n // workerId: 1000\n // }\n\n\n },\n onSuccessChangePasswordMe: async (props: FeatureUserMeSuccessChangePasswordProps) => {\n\n // console.log('authTokenResult', authTokenResult)\n\n // example to add custom props into return auth token result\n\n // return {\n // ...authTokenResult,\n // workerId: 1000\n // }\n\n\n },\n onSuccessRemoveMe: async (props: FeatureUserMeSuccessRemoveProps) => {\n\n // console.log('authTokenResult', authTokenResult)\n\n // example to add custom props into return auth token result\n\n // return {\n // ...authTokenResult,\n // workerId: 1000\n // }\n\n\n },\n}"]}
@@ -0,0 +1,8 @@
1
+ export type FeatureUserMeSuccessUpdateProps = {};
2
+ export type FeatureUserMeSuccessChangePasswordProps = {};
3
+ export type FeatureUserMeSuccessRemoveProps = {};
4
+ export type FeatureUserMeProps = {
5
+ onSuccessUpdateMe?: (payload: FeatureUserMeSuccessUpdateProps) => Promise<any>;
6
+ onSuccessChangePasswordMe?: (payload: FeatureUserMeSuccessChangePasswordProps) => Promise<any>;
7
+ onSuccessRemoveMe?: (payload: FeatureUserMeSuccessRemoveProps) => Promise<any>;
8
+ };
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=userMeType.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userMeType.js","sourceRoot":"","sources":["../../../src/features/user_me/userMeType.ts"],"names":[],"mappings":"","sourcesContent":["export type FeatureUserMeSuccessUpdateProps = {\n}\n\nexport type FeatureUserMeSuccessChangePasswordProps = {\n}\n\nexport type FeatureUserMeSuccessRemoveProps = {\n}\n\nexport type FeatureUserMeProps = {\n onSuccessUpdateMe?: (payload: FeatureUserMeSuccessUpdateProps) => Promise<any>\n onSuccessChangePasswordMe?: (payload: FeatureUserMeSuccessChangePasswordProps) => Promise<any>\n onSuccessRemoveMe?: (payload: FeatureUserMeSuccessRemoveProps) => Promise<any>\n}"]}
@@ -18,6 +18,7 @@ export declare const ModelSubscribePlanFields: {
18
18
  price: "price";
19
19
  currency: "currency";
20
20
  billing_cycle: "billing_cycle";
21
+ is_single_subscription: "is_single_subscription";
21
22
  };
22
23
  export type ModelSubscribePlan = subscribe_plans;
23
24
  export type ModelSubscribePlanOmitFields = typeof primaryKey | DefaultOmitFields;
@@ -45,7 +46,7 @@ export type ModelSubscribePlanListProps = {
45
46
  };
46
47
  export declare const SubscribePlanModel: ({ ...rest }: DefaultServiceProps) => {
47
48
  selectedPrisma: any;
48
- primaryKey: "createdatetime" | "createuserid" | "updatedatetime" | "updateuserid" | "isdelete" | "istrash" | "accountid" | "status" | "name" | "subscribe_plan_id" | "short_description" | "full_description" | "price" | "currency" | "billing_cycle";
49
+ primaryKey: "createdatetime" | "createuserid" | "updatedatetime" | "updateuserid" | "isdelete" | "istrash" | "accountid" | "status" | "name" | "subscribe_plan_id" | "short_description" | "full_description" | "price" | "currency" | "billing_cycle" | "is_single_subscription";
49
50
  getFields: (prefix?: string, excludeKeywords?: string[]) => Promise<{
50
51
  name: string;
51
52
  type: string;
@@ -68,6 +69,7 @@ export declare const SubscribePlanModel: ({ ...rest }: DefaultServiceProps) => {
68
69
  price: Prisma.Decimal;
69
70
  currency: string;
70
71
  billing_cycle: string;
72
+ is_single_subscription: boolean;
71
73
  }>;
72
74
  createMany: ({ dataList, disableRollback, }: {
73
75
  dataList: Omit<any, DefaultOmitFields>[];
@@ -88,6 +90,7 @@ export declare const SubscribePlanModel: ({ ...rest }: DefaultServiceProps) => {
88
90
  price: Prisma.Decimal;
89
91
  currency: string;
90
92
  billing_cycle: string;
93
+ is_single_subscription: boolean;
91
94
  }[]>;
92
95
  get: ({ id, where, include, }: {
93
96
  id?: number;
@@ -109,6 +112,7 @@ export declare const SubscribePlanModel: ({ ...rest }: DefaultServiceProps) => {
109
112
  price: Prisma.Decimal;
110
113
  currency: string;
111
114
  billing_cycle: string;
115
+ is_single_subscription: boolean;
112
116
  } | null>;
113
117
  list: ({ where, orderBy, offset, limit, include }?: any) => Promise<{
114
118
  createdatetime: Date | null;
@@ -126,12 +130,13 @@ export declare const SubscribePlanModel: ({ ...rest }: DefaultServiceProps) => {
126
130
  price: Prisma.Decimal;
127
131
  currency: string;
128
132
  billing_cycle: string;
133
+ is_single_subscription: boolean;
129
134
  }[]>;
130
135
  count: ({ where }?: {
131
136
  where?: Record<string, any>;
132
137
  }) => Promise<number>;
133
138
  aggregate: ({ field, operation, where, }: {
134
- field: "createdatetime" | "createuserid" | "updatedatetime" | "updateuserid" | "isdelete" | "istrash" | "accountid" | "status" | "name" | "subscribe_plan_id" | "short_description" | "full_description" | "price" | "currency" | "billing_cycle";
139
+ field: "createdatetime" | "createuserid" | "updatedatetime" | "updateuserid" | "isdelete" | "istrash" | "accountid" | "status" | "name" | "subscribe_plan_id" | "short_description" | "full_description" | "price" | "currency" | "billing_cycle" | "is_single_subscription";
135
140
  operation?: "sum" | "avg" | "min" | "max" | "count";
136
141
  where?: Record<string, any>;
137
142
  }) => Promise<number>;
@@ -154,6 +159,7 @@ export declare const SubscribePlanModel: ({ ...rest }: DefaultServiceProps) => {
154
159
  price: Prisma.Decimal;
155
160
  currency: string;
156
161
  billing_cycle: string;
162
+ is_single_subscription: boolean;
157
163
  }>;
158
164
  disableRollback?: Boolean;
159
165
  }) => Promise<{
@@ -172,6 +178,7 @@ export declare const SubscribePlanModel: ({ ...rest }: DefaultServiceProps) => {
172
178
  price: Prisma.Decimal;
173
179
  currency: string;
174
180
  billing_cycle: string;
181
+ is_single_subscription: boolean;
175
182
  }>;
176
183
  updateMany: ({ dataList, disableRollback, }: {
177
184
  dataList: {
@@ -192,6 +199,7 @@ export declare const SubscribePlanModel: ({ ...rest }: DefaultServiceProps) => {
192
199
  price: Prisma.Decimal;
193
200
  currency: string;
194
201
  billing_cycle: string;
202
+ is_single_subscription: boolean;
195
203
  }>;
196
204
  }[];
197
205
  disableRollback?: boolean;
@@ -211,6 +219,7 @@ export declare const SubscribePlanModel: ({ ...rest }: DefaultServiceProps) => {
211
219
  price: Prisma.Decimal;
212
220
  currency: string;
213
221
  billing_cycle: string;
222
+ is_single_subscription: boolean;
214
223
  }[]>;
215
224
  trash: ({ ids }: {
216
225
  ids: number[];
@@ -230,6 +239,7 @@ export declare const SubscribePlanModel: ({ ...rest }: DefaultServiceProps) => {
230
239
  price: Prisma.Decimal;
231
240
  currency: string;
232
241
  billing_cycle: string;
242
+ is_single_subscription: boolean;
233
243
  }[]>;
234
244
  remove: ({ ids, where }: {
235
245
  ids?: number[];
@@ -250,6 +260,7 @@ export declare const SubscribePlanModel: ({ ...rest }: DefaultServiceProps) => {
250
260
  price: Prisma.Decimal;
251
261
  currency: string;
252
262
  billing_cycle: string;
263
+ is_single_subscription: boolean;
253
264
  }[]>;
254
265
  raw: <T = any>(query: string, params?: any[]) => Promise<T[]>;
255
266
  rawExec: (query: string, params?: any[]) => Promise<number>;
@@ -16,6 +16,7 @@ export declare const schemaSubscribePlan: z.ZodObject<{
16
16
  price: z.ZodNumber;
17
17
  billingCycle: z.ZodEnum<["monthly" | "yearly", ...("monthly" | "yearly")[]]>;
18
18
  currency: z.ZodEnum<["myr" | "usd", ...("myr" | "usd")[]]>;
19
+ isSingleSubscription: z.ZodBoolean;
19
20
  status: z.ZodBoolean;
20
21
  }, "strip", z.ZodTypeAny, {
21
22
  status: boolean;
@@ -25,6 +26,7 @@ export declare const schemaSubscribePlan: z.ZodObject<{
25
26
  shortDescription: string;
26
27
  fullDescription: string;
27
28
  billingCycle: "monthly" | "yearly";
29
+ isSingleSubscription: boolean;
28
30
  }, {
29
31
  status: boolean;
30
32
  name: string;
@@ -33,6 +35,7 @@ export declare const schemaSubscribePlan: z.ZodObject<{
33
35
  shortDescription: string;
34
36
  fullDescription: string;
35
37
  billingCycle: "monthly" | "yearly";
38
+ isSingleSubscription: boolean;
36
39
  }>;
37
40
  /** Create */
38
41
  export declare const schemaSubscribePlanCreatePayload: z.ZodObject<{
@@ -54,6 +57,7 @@ export declare const schemaSubscribePlanCreatePayload: z.ZodObject<{
54
57
  price: z.ZodNumber;
55
58
  billingCycle: z.ZodEnum<["monthly" | "yearly", ...("monthly" | "yearly")[]]>;
56
59
  currency: z.ZodEnum<["myr" | "usd", ...("myr" | "usd")[]]>;
60
+ isSingleSubscription: z.ZodBoolean;
57
61
  status: z.ZodBoolean;
58
62
  }, "strip", z.ZodTypeAny, {
59
63
  status: boolean;
@@ -63,6 +67,7 @@ export declare const schemaSubscribePlanCreatePayload: z.ZodObject<{
63
67
  shortDescription: string;
64
68
  fullDescription: string;
65
69
  billingCycle: "monthly" | "yearly";
70
+ isSingleSubscription: boolean;
66
71
  }, {
67
72
  status: boolean;
68
73
  name: string;
@@ -71,6 +76,7 @@ export declare const schemaSubscribePlanCreatePayload: z.ZodObject<{
71
76
  shortDescription: string;
72
77
  fullDescription: string;
73
78
  billingCycle: "monthly" | "yearly";
79
+ isSingleSubscription: boolean;
74
80
  }>;
75
81
  }, "strip", z.ZodTypeAny, {
76
82
  subscribePlan: {
@@ -81,6 +87,7 @@ export declare const schemaSubscribePlanCreatePayload: z.ZodObject<{
81
87
  shortDescription: string;
82
88
  fullDescription: string;
83
89
  billingCycle: "monthly" | "yearly";
90
+ isSingleSubscription: boolean;
84
91
  };
85
92
  }, {
86
93
  subscribePlan: {
@@ -91,6 +98,7 @@ export declare const schemaSubscribePlanCreatePayload: z.ZodObject<{
91
98
  shortDescription: string;
92
99
  fullDescription: string;
93
100
  billingCycle: "monthly" | "yearly";
101
+ isSingleSubscription: boolean;
94
102
  };
95
103
  }>;
96
104
  }, "strip", z.ZodTypeAny, {
@@ -107,6 +115,7 @@ export declare const schemaSubscribePlanCreatePayload: z.ZodObject<{
107
115
  shortDescription: string;
108
116
  fullDescription: string;
109
117
  billingCycle: "monthly" | "yearly";
118
+ isSingleSubscription: boolean;
110
119
  };
111
120
  };
112
121
  }, {
@@ -123,6 +132,7 @@ export declare const schemaSubscribePlanCreatePayload: z.ZodObject<{
123
132
  shortDescription: string;
124
133
  fullDescription: string;
125
134
  billingCycle: "monthly" | "yearly";
135
+ isSingleSubscription: boolean;
126
136
  };
127
137
  };
128
138
  }>;
@@ -147,6 +157,7 @@ export declare const schemaSubscribePlanUpdatePayload: z.ZodObject<{
147
157
  price: z.ZodNumber;
148
158
  billingCycle: z.ZodEnum<["monthly" | "yearly", ...("monthly" | "yearly")[]]>;
149
159
  currency: z.ZodEnum<["myr" | "usd", ...("myr" | "usd")[]]>;
160
+ isSingleSubscription: z.ZodBoolean;
150
161
  status: z.ZodBoolean;
151
162
  }, "strip", z.ZodTypeAny, {
152
163
  status: boolean;
@@ -156,6 +167,7 @@ export declare const schemaSubscribePlanUpdatePayload: z.ZodObject<{
156
167
  shortDescription: string;
157
168
  fullDescription: string;
158
169
  billingCycle: "monthly" | "yearly";
170
+ isSingleSubscription: boolean;
159
171
  }, {
160
172
  status: boolean;
161
173
  name: string;
@@ -164,6 +176,7 @@ export declare const schemaSubscribePlanUpdatePayload: z.ZodObject<{
164
176
  shortDescription: string;
165
177
  fullDescription: string;
166
178
  billingCycle: "monthly" | "yearly";
179
+ isSingleSubscription: boolean;
167
180
  }>;
168
181
  }, "strip", z.ZodTypeAny, {
169
182
  subscribePlan: {
@@ -174,6 +187,7 @@ export declare const schemaSubscribePlanUpdatePayload: z.ZodObject<{
174
187
  shortDescription: string;
175
188
  fullDescription: string;
176
189
  billingCycle: "monthly" | "yearly";
190
+ isSingleSubscription: boolean;
177
191
  };
178
192
  }, {
179
193
  subscribePlan: {
@@ -184,6 +198,7 @@ export declare const schemaSubscribePlanUpdatePayload: z.ZodObject<{
184
198
  shortDescription: string;
185
199
  fullDescription: string;
186
200
  billingCycle: "monthly" | "yearly";
201
+ isSingleSubscription: boolean;
187
202
  };
188
203
  }>;
189
204
  }, "strip", z.ZodTypeAny, {
@@ -200,6 +215,7 @@ export declare const schemaSubscribePlanUpdatePayload: z.ZodObject<{
200
215
  shortDescription: string;
201
216
  fullDescription: string;
202
217
  billingCycle: "monthly" | "yearly";
218
+ isSingleSubscription: boolean;
203
219
  };
204
220
  };
205
221
  }, {
@@ -216,6 +232,7 @@ export declare const schemaSubscribePlanUpdatePayload: z.ZodObject<{
216
232
  shortDescription: string;
217
233
  fullDescription: string;
218
234
  billingCycle: "monthly" | "yearly";
235
+ isSingleSubscription: boolean;
219
236
  };
220
237
  };
221
238
  }>;
@@ -15,6 +15,7 @@ exports.schemaSubscribePlan = zod_1.z.object({
15
15
  price: zod_1.z.number(),
16
16
  billingCycle: zod_1.z.enum(Object.values(services_1.subscribePlanBillingCycles)),
17
17
  currency: zod_1.z.enum(Object.values(services_2.subscribeCurrencies)),
18
+ isSingleSubscription: zod_1.z.boolean(),
18
19
  status: zod_1.z.boolean(),
19
20
  });
20
21
  /** Create */
@@ -1 +1 @@
1
- {"version":3,"file":"schemaSubscribePlan.js","sourceRoot":"","sources":["../../../../src/schema/payload/subscription/schemaSubscribePlan.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAIxB,yCAAkF;AAClF,yCAAuE;AAE1D,QAAA,kBAAkB,GAAG,OAAC,CAAC,MAAM,CAAC;IACvC,MAAM,EAAE,OAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC;IACnC,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;CACrB,CAAC,CAAA;AAEW,QAAA,mBAAmB,GAAG,OAAC,CAAC,MAAM,CAAC;IACxC,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;IAChB,gBAAgB,EAAE,OAAC,CAAC,MAAM,EAAE;IAC5B,eAAe,EAAE,OAAC,CAAC,MAAM,EAAE;IAC3B,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;IACjB,YAAY,EAAE,OAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,qCAA0B,CAAgE,CAAC;IAC9H,QAAQ,EAAE,OAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,8BAAmB,CAAwD,CAAC;IAC3G,MAAM,EAAE,OAAC,CAAC,OAAO,EAAE;CACtB,CAAC,CAAA;AAEF,aAAa;AACA,QAAA,gCAAgC,GAAG,OAAC,CAAC,MAAM,CAAC;IACrD,KAAK,EAAE,0BAAkB;IACzB,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC;QACd,aAAa,EAAE,2BAAmB;KACrC,CAAC;CACL,CAAC,CAAC;AAIH,aAAa;AACA,QAAA,gCAAgC,GAAG,OAAC,CAAC,MAAM,CAAC;IACrD,KAAK,EAAE,0BAAkB;IACzB,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC;QACd,aAAa,EAAE,2BAAmB;KACrC,CAAC;CACL,CAAC,CAAC;AAIH,aAAa;AACA,QAAA,gCAAgC,GAAG,OAAC,CAAC,MAAM,CAAC;IACrD,KAAK,EAAE,0BAAkB;IACzB,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC;QACd,GAAG,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,sCAAsC,CAAC;KAC1E,CAAC;CACL,CAAC,CAAC","sourcesContent":["import { z } from \"zod\";\n\nimport { _, dayjs } from \"@/utils\";\n\nimport { subscribePlanBillingCycles, SubscribePlanBillingCycle } from \"@/services\"\nimport { subscribeCurrencies, SubscribePlanCurrency } from \"@/services\"\n\nexport const schemePayloadScope = z.object({\n target: z.literal(\"subscribe_plan\"),\n action: z.string(),\n})\n\nexport const schemaSubscribePlan = z.object({\n name: z.string(),\n shortDescription: z.string(),\n fullDescription: z.string(),\n price: z.number(),\n billingCycle: z.enum(Object.values(subscribePlanBillingCycles) as [SubscribePlanBillingCycle, ...SubscribePlanBillingCycle[]]),\n currency: z.enum(Object.values(subscribeCurrencies) as [SubscribePlanCurrency, ...SubscribePlanCurrency[]]),\n status: z.boolean(),\n})\n\n/** Create */\nexport const schemaSubscribePlanCreatePayload = z.object({\n scope: schemePayloadScope,\n payload: z.object({\n subscribePlan: schemaSubscribePlan\n })\n});\n\nexport type SchemaSubscribePlanCreatePayload = z.infer<typeof schemaSubscribePlanCreatePayload>;\n\n/** Update */\nexport const schemaSubscribePlanUpdatePayload = z.object({\n scope: schemePayloadScope,\n payload: z.object({\n subscribePlan: schemaSubscribePlan\n })\n});\n\nexport type SchemaSubscribePlanUpdatePayload = z.infer<typeof schemaSubscribePlanUpdatePayload>;\n\n/** Delete */\nexport const schemaSubscribePlanDeletePayload = z.object({\n scope: schemePayloadScope,\n payload: z.object({\n ids: z.array(z.number()).min(1, \"ids must contain at least one number\"),\n }),\n});\n\nexport type SchemaSubscribePlanDeletePayload = z.infer<typeof schemaSubscribePlanDeletePayload>;"]}
1
+ {"version":3,"file":"schemaSubscribePlan.js","sourceRoot":"","sources":["../../../../src/schema/payload/subscription/schemaSubscribePlan.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAIxB,yCAAkF;AAClF,yCAAuE;AAE1D,QAAA,kBAAkB,GAAG,OAAC,CAAC,MAAM,CAAC;IACvC,MAAM,EAAE,OAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC;IACnC,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE;CACrB,CAAC,CAAA;AAEW,QAAA,mBAAmB,GAAG,OAAC,CAAC,MAAM,CAAC;IACxC,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE;IAChB,gBAAgB,EAAE,OAAC,CAAC,MAAM,EAAE;IAC5B,eAAe,EAAE,OAAC,CAAC,MAAM,EAAE;IAC3B,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE;IACjB,YAAY,EAAE,OAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,qCAA0B,CAAgE,CAAC;IAC9H,QAAQ,EAAE,OAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,8BAAmB,CAAwD,CAAC;IAC3G,oBAAoB,EAAE,OAAC,CAAC,OAAO,EAAE;IACjC,MAAM,EAAE,OAAC,CAAC,OAAO,EAAE;CACtB,CAAC,CAAA;AAEF,aAAa;AACA,QAAA,gCAAgC,GAAG,OAAC,CAAC,MAAM,CAAC;IACrD,KAAK,EAAE,0BAAkB;IACzB,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC;QACd,aAAa,EAAE,2BAAmB;KACrC,CAAC;CACL,CAAC,CAAC;AAIH,aAAa;AACA,QAAA,gCAAgC,GAAG,OAAC,CAAC,MAAM,CAAC;IACrD,KAAK,EAAE,0BAAkB;IACzB,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC;QACd,aAAa,EAAE,2BAAmB;KACrC,CAAC;CACL,CAAC,CAAC;AAIH,aAAa;AACA,QAAA,gCAAgC,GAAG,OAAC,CAAC,MAAM,CAAC;IACrD,KAAK,EAAE,0BAAkB;IACzB,OAAO,EAAE,OAAC,CAAC,MAAM,CAAC;QACd,GAAG,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,sCAAsC,CAAC;KAC1E,CAAC;CACL,CAAC,CAAC","sourcesContent":["import { z } from \"zod\";\n\nimport { _, dayjs } from \"@/utils\";\n\nimport { subscribePlanBillingCycles, SubscribePlanBillingCycle } from \"@/services\"\nimport { subscribeCurrencies, SubscribePlanCurrency } from \"@/services\"\n\nexport const schemePayloadScope = z.object({\n target: z.literal(\"subscribe_plan\"),\n action: z.string(),\n})\n\nexport const schemaSubscribePlan = z.object({\n name: z.string(),\n shortDescription: z.string(),\n fullDescription: z.string(),\n price: z.number(),\n billingCycle: z.enum(Object.values(subscribePlanBillingCycles) as [SubscribePlanBillingCycle, ...SubscribePlanBillingCycle[]]),\n currency: z.enum(Object.values(subscribeCurrencies) as [SubscribePlanCurrency, ...SubscribePlanCurrency[]]),\n isSingleSubscription: z.boolean(),\n status: z.boolean(),\n})\n\n/** Create */\nexport const schemaSubscribePlanCreatePayload = z.object({\n scope: schemePayloadScope,\n payload: z.object({\n subscribePlan: schemaSubscribePlan\n })\n});\n\nexport type SchemaSubscribePlanCreatePayload = z.infer<typeof schemaSubscribePlanCreatePayload>;\n\n/** Update */\nexport const schemaSubscribePlanUpdatePayload = z.object({\n scope: schemePayloadScope,\n payload: z.object({\n subscribePlan: schemaSubscribePlan\n })\n});\n\nexport type SchemaSubscribePlanUpdatePayload = z.infer<typeof schemaSubscribePlanUpdatePayload>;\n\n/** Delete */\nexport const schemaSubscribePlanDeletePayload = z.object({\n scope: schemePayloadScope,\n payload: z.object({\n ids: z.array(z.number()).min(1, \"ids must contain at least one number\"),\n }),\n});\n\nexport type SchemaSubscribePlanDeletePayload = z.infer<typeof schemaSubscribePlanDeletePayload>;"]}
@@ -194,8 +194,11 @@ const AuthService = (props) => {
194
194
  is_owner: Boolean(user?.is_owner),
195
195
  // owner_id: 0
196
196
  };
197
+ let newResult;
197
198
  // Call the consumer hook, if registered
198
- const newResult = await features_1.AuthTokenHook.onSuccessAuthenticate(result);
199
+ if (features_1.AuthTokenHook?.onSuccessAuthenticate) {
200
+ newResult = await features_1.AuthTokenHook.onSuccessAuthenticate(result);
201
+ }
199
202
  return newResult ? newResult : result;
200
203
  };
201
204
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"AuthService.js","sourceRoot":"","sources":["../../../src/services/auth/AuthService.ts"],"names":[],"mappings":";;;AAAA,yDAAyD;AACzD,mCAA0D;AAC1D,yCASoB;AAIpB,mCAA0F;AAC1F,qCAA0E;AAE1E,yCAAoF;AAEvE,QAAA,SAAS,GAAG;IACrB,QAAQ,EAAE,UAAU;IACpB,aAAa,EAAE,eAAe;IAC9B,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,MAAM,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AwC;QACxC,MAAM,SAAS,GAAG,MAAM,wBAAa,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAA;QAEnE,OAAO,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAA;IACzC,CAAC,CAAC;IAEF,OAAO;QACH,YAAY;QACZ,eAAe,EAAf,uBAAe;KAClB,CAAA;AAEL,CAAC,CAAA;AA9PY,QAAA,WAAW,eA8PvB","sourcesContent":["// import { QueryList, QueryGet } from \"@/schema/common\";\nimport { DefaultServiceProps, throwError } from \"@/utils\";\nimport {\n UserService,\n // UserGetProps,\n UserType,\n UserListProps,\n // userTypes,\n AccountService,\n LocationService,\n LocationListProps\n} from \"@/services\";\n\nimport jwt, { JwtPayload } from \"jsonwebtoken\";\n\nimport { generateAuthToken, verifyPassword, verifyAuthToken, hashPassword } from \"@/utils\"\nimport { ModelAccountFields, ModelUserFields, UserModel } from \"@/models\";\n\nimport { AuthTokenHook, FeatureAuthTokenSuccessAuthenticateProps } from \"@/features\"\n\nexport const authTypes = {\n operator: \"operator\",\n administrator: \"administrator\",\n worker: \"worker\",\n customer: \"customer\",\n member: \"member\",\n} as const\n\nexport type AuthType = typeof authTypes[keyof typeof authTypes]\n\nexport type AuthTokenResult = {\n token: string\n account: any\n user: any\n user_locations: any[]\n is_owner: boolean\n}\n\nexport type AuthJwtToken = JwtPayload & {\n user?: { id: number, user_id: number, user_type: AuthType };\n account?: { id: number, account_id: number };\n};\n\nexport type AuthServiceProps = DefaultServiceProps & {\n secretKey: string,\n authType: AuthType\n};\n\nexport type AuthGetTokenProps = {\n authType: AuthType,\n // accountId?: number,\n accountCode?: string,\n data:\n // get token\n {\n username: string,\n password: string\n }\n};\n\nexport const AuthService = (props: AuthServiceProps) => {\n\n const {\n secretKey,\n authType = \"administrator\",\n ...rest\n } = props\n\n let hookSetup: FeatureAuthTokenSuccessAuthenticateProps | null = null\n\n const getUserInjectionFieldName = (authType: AuthType) => {\n\n if (authType === \"administrator\") return [\"administrator_injection_fields\"]\n if (authType === \"customer\") return [\"customer_injection_fields\"]\n if (authType === \"worker\") return [\"worker_injection_fields\"]\n\n return []\n }\n\n const validateAuthAccount = async (accountCode: string) => {\n\n if (accountCode === \"\") {\n return 0\n }\n\n // check if the accountId & accountCode is not empty\n // if (!accountId && !accountCode) throwError(`accountId or accountCode is required`)\n\n let selectAccountId = 0\n\n // check account id is choose \n // if (selectAccountId === 0) {\n\n const globalAccountService = AccountService({ ...rest, isOperator: true })\n\n // use account code to find the account id\n if (accountCode) {\n\n let { data: responseAcc } = await globalAccountService.listAccounts({\n limit: 1,\n offset: 0,\n sortfield: `${ModelAccountFields.account_id}`,\n sortorder: `ASC`,\n filters: [{\n field: `${ModelAccountFields.account_code}`,\n operator: `=`,\n value: `${accountCode}`,\n }],\n datatypes: []\n })\n\n selectAccountId = responseAcc.length > 0 ? responseAcc[0].account_id : \"\"\n let selectAccountStatus = responseAcc.length > 0 ? responseAcc[0].account_status : \"\"\n\n if (selectAccountStatus !== true) throwError(`Inactive account: ${accountCode}`)\n\n }\n\n if (!selectAccountId) {\n throwError(`Invalid account code: ${accountCode}`)\n }\n\n // }\n\n return Number(selectAccountId ?? 0)\n\n }\n\n const getAuthToken = async ({ authType, data, accountCode = \"\" }: AuthGetTokenProps) => {\n\n let _rest = rest\n let _accountId = 0\n\n if (authType !== \"operator\") {\n _accountId = await validateAuthAccount(accountCode)\n }\n\n // _rest.accountId = accountId\n _rest.accountId = _accountId\n\n // check the option pass in using account id or account code\n // if (authType !== \"operator\") {\n // _rest.accountId = accountId\n\n // // check if the accountId & accountCode is not empty\n // if (!accountId && !accountCode) throwError(`accountId or accountCode is required`)\n\n // let selectAccountId = `${accountId}`\n\n // // check account id is choose \n // if (selectAccountId === \"0\") {\n\n // const globalAccountService = AccountService({ ...rest, isOperator: true })\n\n // // use account code to find the account id\n // if (accountCode) {\n\n // let { data: responseAcc } = await globalAccountService.listAccounts({\n // limit: 1,\n // offset: 0,\n // sortfield: `${ModelAccountFields.account_id}`,\n // sortorder: `ASC`,\n // filters: [{\n // field: `${ModelAccountFields.account_code}`,\n // operator: `=`,\n // value: `${accountCode}`,\n // }],\n // datatypes: []\n // })\n\n // selectAccountId = responseAcc.length > 0 ? responseAcc[0].account_id : \"\"\n // let selectAccountStatus = responseAcc.length > 0 ? responseAcc[0].account_status : \"\"\n\n // if (selectAccountStatus !== true) throwError(`Inactive account: ${accountCode}`)\n\n // }\n\n // if (!selectAccountId) {\n // throwError(`Invalid account code: ${accountCode}`)\n // }\n\n // }\n\n // _rest.accountId = Number(selectAccountId)\n\n // } else {\n // _rest.accountId = accountId\n // }\n\n const userService = UserService({ userType: authType as UserType, ...rest })\n const accountService = AccountService({ ...rest, isOperator: true })\n const locationService = LocationService({ ...rest, locationType: \"location\" })\n\n let foundUser: any = {}\n\n // only for operator & administrator\n if (authType === \"operator\" || authType === \"administrator\") {\n\n // const operatorService = UserService({ ...rest })\n\n const _user = await userService.getUserByUsername({\n username: `${data[\"username\"]}`,\n includePassword: true,\n datatypes: getUserInjectionFieldName(authType) as any\n })\n\n foundUser = _user\n\n } else { // other user type\n\n let payload: UserListProps = {\n includePassword: true,\n limit: 1,\n offset: 0,\n sortfield: \"user_id\",\n sortorder: \"DESC\",\n filters: [\n { field: \"username\", operator: \"=\", value: `${data[\"username\"]}` },\n { field: \"user_type\", operator: \"=\", value: `${authType}` }\n ],\n datatypes: getUserInjectionFieldName(authType)\n }\n\n const { data: foundOtherUser } = await userService.listUsers(payload)\n\n foundUser = foundOtherUser.length > 0 ? foundOtherUser[0] : {}\n\n }\n\n if (!foundUser?.user_id) {\n throw Error(`Invalid username: ${data.username}`)\n }\n\n if (foundUser?.status !== true) {\n throw new Error(`User is inactive: ${data.username}`);\n }\n\n let user = foundUser\n // foundUser.length > 0 ? foundUser[0] : {}\n\n let decryptedPass: boolean\n\n try {\n decryptedPass = await verifyPassword(data.password, user.password)\n } catch (error) {\n throw error\n }\n\n if (decryptedPass === false) {\n throw Error(`Invalid credential: ${data[\"username\"]}`)\n }\n\n // dont show out to result\n delete user.password\n\n let account: any = {}\n\n // if (_rest.accountId && authType !== \"operator\") {\n account = await accountService.getAccount({ id: Number(_rest.accountId), datatypes: [] })\n // }\n\n const authToken = generateAuthToken(user, account, secretKey)\n\n // get the locations for user\n const locationIds = user?.location_id ? user.location_id.split(\", \") : []\n\n let locations: any[] = []\n\n if (locationIds.length > 0) {\n const listPayload: LocationListProps = {\n limit: 100,\n offset: 0,\n sortfield: \"location_id\",\n sortorder: \"ASC\",\n filters: [{\n field: \"location_id\",\n operator: \"where_in\",\n value: locationIds.map((i: any) => Number(i))\n }],\n datatypes: []\n }\n\n const { data } = await locationService.listLocations(listPayload)\n locations = data\n }\n\n const result: AuthTokenResult = {\n token: authToken,\n account,\n user,\n user_locations: locations,\n // parent_user_id: 0,\n // roles: [\n // {\n // id: 23,\n // role_name: \"123\"\n // }\n // ],\n // permissions: [],\n is_owner: Boolean(user?.is_owner),\n // owner_id: 0\n }\n\n // Call the consumer hook, if registered\n const newResult = await AuthTokenHook.onSuccessAuthenticate(result)\n\n return newResult ? newResult : result\n };\n\n return {\n getAuthToken,\n verifyAuthToken,\n }\n\n}\n\n"]}
1
+ {"version":3,"file":"AuthService.js","sourceRoot":"","sources":["../../../src/services/auth/AuthService.ts"],"names":[],"mappings":";;;AAAA,yDAAyD;AACzD,mCAA0D;AAC1D,yCASoB;AAIpB,mCAA0F;AAC1F,qCAA0E;AAE1E,yCAAoF;AAEvE,QAAA,SAAS,GAAG;IACrB,QAAQ,EAAE,UAAU;IACpB,aAAa,EAAE,eAAe;IAC9B,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;CACV,CAAA;AAkCH,MAAM,WAAW,GAAG,CAAC,KAAuB,EAAE,EAAE;IAEnD,MAAM,EACF,SAAS,EACT,QAAQ,GAAG,eAAe,EAC1B,GAAG,IAAI,EACV,GAAG,KAAK,CAAA;IAET,IAAI,SAAS,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AC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAA;IACzC,CAAC,CAAC;IAEF,OAAO;QACH,YAAY;QACZ,eAAe,EAAf,uBAAe;KAClB,CAAA;AAEL,CAAC,CAAA;AAlQY,QAAA,WAAW,eAkQvB","sourcesContent":["// import { QueryList, QueryGet } from \"@/schema/common\";\nimport { DefaultServiceProps, throwError } from \"@/utils\";\nimport {\n UserService,\n // UserGetProps,\n UserType,\n UserListProps,\n // userTypes,\n AccountService,\n LocationService,\n LocationListProps\n} from \"@/services\";\n\nimport jwt, { JwtPayload } from \"jsonwebtoken\";\n\nimport { generateAuthToken, verifyPassword, verifyAuthToken, hashPassword } from \"@/utils\"\nimport { ModelAccountFields, ModelUserFields, UserModel } from \"@/models\";\n\nimport { AuthTokenHook, FeatureAuthTokenSuccessAuthenticateProps } from \"@/features\"\n\nexport const authTypes = {\n operator: \"operator\",\n administrator: \"administrator\",\n worker: \"worker\",\n customer: \"customer\",\n member: \"member\",\n} as const\n\nexport type AuthType = typeof authTypes[keyof typeof authTypes]\n\nexport type AuthTokenResult = {\n token: string\n account: any\n user: any\n user_locations: any[]\n is_owner: boolean\n}\n\nexport type AuthJwtToken = JwtPayload & {\n user?: { id: number, user_id: number, user_type: AuthType };\n account?: { id: number, account_id: number };\n};\n\nexport type AuthServiceProps = DefaultServiceProps & {\n secretKey: string,\n authType: AuthType\n};\n\nexport type AuthGetTokenProps = {\n authType: AuthType,\n // accountId?: number,\n accountCode?: string,\n data:\n // get token\n {\n username: string,\n password: string\n }\n};\n\nexport const AuthService = (props: AuthServiceProps) => {\n\n const {\n secretKey,\n authType = \"administrator\",\n ...rest\n } = props\n\n let hookSetup: FeatureAuthTokenSuccessAuthenticateProps | null = null\n\n const getUserInjectionFieldName = (authType: AuthType) => {\n\n if (authType === \"administrator\") return [\"administrator_injection_fields\"]\n if (authType === \"customer\") return [\"customer_injection_fields\"]\n if (authType === \"worker\") return [\"worker_injection_fields\"]\n\n return []\n }\n\n const validateAuthAccount = async (accountCode: string) => {\n\n if (accountCode === \"\") {\n return 0\n }\n\n // check if the accountId & accountCode is not empty\n // if (!accountId && !accountCode) throwError(`accountId or accountCode is required`)\n\n let selectAccountId = 0\n\n // check account id is choose \n // if (selectAccountId === 0) {\n\n const globalAccountService = AccountService({ ...rest, isOperator: true })\n\n // use account code to find the account id\n if (accountCode) {\n\n let { data: responseAcc } = await globalAccountService.listAccounts({\n limit: 1,\n offset: 0,\n sortfield: `${ModelAccountFields.account_id}`,\n sortorder: `ASC`,\n filters: [{\n field: `${ModelAccountFields.account_code}`,\n operator: `=`,\n value: `${accountCode}`,\n }],\n datatypes: []\n })\n\n selectAccountId = responseAcc.length > 0 ? responseAcc[0].account_id : \"\"\n let selectAccountStatus = responseAcc.length > 0 ? responseAcc[0].account_status : \"\"\n\n if (selectAccountStatus !== true) throwError(`Inactive account: ${accountCode}`)\n\n }\n\n if (!selectAccountId) {\n throwError(`Invalid account code: ${accountCode}`)\n }\n\n // }\n\n return Number(selectAccountId ?? 0)\n\n }\n\n const getAuthToken = async ({ authType, data, accountCode = \"\" }: AuthGetTokenProps) => {\n\n let _rest = rest\n let _accountId = 0\n\n if (authType !== \"operator\") {\n _accountId = await validateAuthAccount(accountCode)\n }\n\n // _rest.accountId = accountId\n _rest.accountId = _accountId\n\n // check the option pass in using account id or account code\n // if (authType !== \"operator\") {\n // _rest.accountId = accountId\n\n // // check if the accountId & accountCode is not empty\n // if (!accountId && !accountCode) throwError(`accountId or accountCode is required`)\n\n // let selectAccountId = `${accountId}`\n\n // // check account id is choose \n // if (selectAccountId === \"0\") {\n\n // const globalAccountService = AccountService({ ...rest, isOperator: true })\n\n // // use account code to find the account id\n // if (accountCode) {\n\n // let { data: responseAcc } = await globalAccountService.listAccounts({\n // limit: 1,\n // offset: 0,\n // sortfield: `${ModelAccountFields.account_id}`,\n // sortorder: `ASC`,\n // filters: [{\n // field: `${ModelAccountFields.account_code}`,\n // operator: `=`,\n // value: `${accountCode}`,\n // }],\n // datatypes: []\n // })\n\n // selectAccountId = responseAcc.length > 0 ? responseAcc[0].account_id : \"\"\n // let selectAccountStatus = responseAcc.length > 0 ? responseAcc[0].account_status : \"\"\n\n // if (selectAccountStatus !== true) throwError(`Inactive account: ${accountCode}`)\n\n // }\n\n // if (!selectAccountId) {\n // throwError(`Invalid account code: ${accountCode}`)\n // }\n\n // }\n\n // _rest.accountId = Number(selectAccountId)\n\n // } else {\n // _rest.accountId = accountId\n // }\n\n const userService = UserService({ userType: authType as UserType, ...rest })\n const accountService = AccountService({ ...rest, isOperator: true })\n const locationService = LocationService({ ...rest, locationType: \"location\" })\n\n let foundUser: any = {}\n\n // only for operator & administrator\n if (authType === \"operator\" || authType === \"administrator\") {\n\n // const operatorService = UserService({ ...rest })\n\n const _user = await userService.getUserByUsername({\n username: `${data[\"username\"]}`,\n includePassword: true,\n datatypes: getUserInjectionFieldName(authType) as any\n })\n\n foundUser = _user\n\n } else { // other user type\n\n let payload: UserListProps = {\n includePassword: true,\n limit: 1,\n offset: 0,\n sortfield: \"user_id\",\n sortorder: \"DESC\",\n filters: [\n { field: \"username\", operator: \"=\", value: `${data[\"username\"]}` },\n { field: \"user_type\", operator: \"=\", value: `${authType}` }\n ],\n datatypes: getUserInjectionFieldName(authType)\n }\n\n const { data: foundOtherUser } = await userService.listUsers(payload)\n\n foundUser = foundOtherUser.length > 0 ? foundOtherUser[0] : {}\n\n }\n\n if (!foundUser?.user_id) {\n throw Error(`Invalid username: ${data.username}`)\n }\n\n if (foundUser?.status !== true) {\n throw new Error(`User is inactive: ${data.username}`);\n }\n\n let user = foundUser\n // foundUser.length > 0 ? foundUser[0] : {}\n\n let decryptedPass: boolean\n\n try {\n decryptedPass = await verifyPassword(data.password, user.password)\n } catch (error) {\n throw error\n }\n\n if (decryptedPass === false) {\n throw Error(`Invalid credential: ${data[\"username\"]}`)\n }\n\n // dont show out to result\n delete user.password\n\n let account: any = {}\n\n // if (_rest.accountId && authType !== \"operator\") {\n account = await accountService.getAccount({ id: Number(_rest.accountId), datatypes: [] })\n // }\n\n const authToken = generateAuthToken(user, account, secretKey)\n\n // get the locations for user\n const locationIds = user?.location_id ? user.location_id.split(\", \") : []\n\n let locations: any[] = []\n\n if (locationIds.length > 0) {\n const listPayload: LocationListProps = {\n limit: 100,\n offset: 0,\n sortfield: \"location_id\",\n sortorder: \"ASC\",\n filters: [{\n field: \"location_id\",\n operator: \"where_in\",\n value: locationIds.map((i: any) => Number(i))\n }],\n datatypes: []\n }\n\n const { data } = await locationService.listLocations(listPayload)\n locations = data\n }\n\n const result: AuthTokenResult = {\n token: authToken,\n account,\n user,\n user_locations: locations,\n // parent_user_id: 0,\n // roles: [\n // {\n // id: 23,\n // role_name: \"123\"\n // }\n // ],\n // permissions: [],\n is_owner: Boolean(user?.is_owner),\n // owner_id: 0\n }\n\n let newResult: any\n\n // Call the consumer hook, if registered\n if (AuthTokenHook?.onSuccessAuthenticate) {\n newResult = await AuthTokenHook.onSuccessAuthenticate(result)\n }\n\n return newResult ? newResult : result\n };\n\n return {\n getAuthToken,\n verifyAuthToken,\n }\n\n}\n\n"]}
@@ -7,7 +7,7 @@ export type { AccessControlServiceProps, AccessControlScopeOrExtra, AccessContro
7
7
  export { ResetPasswordService, resetPasswordMethods } from "../services/reset_password/ResetPasswordService";
8
8
  export type { ResetPasswordServiceProps, ResetPasswordMethod, ResetPasswordRequestProps, ResetPasswordValidateCodeProps, ResetPasswordPerformProps } from "../services/reset_password/ResetPasswordService";
9
9
  export { AccountService } from "../services/account/AccountService";
10
- export type { AccountServiceProps, Account, AccountGetProps, AccountListProps, AccountCreateProps, AccountUpdateProps } from "../services/account/AccountService";
10
+ export type { AccountServiceProps, Account, AccountGetProps, AccountListProps, AccountCreateProps, AccountUpdateProps, AccountRemoveProps } from "../services/account/AccountService";
11
11
  export { BusinessService } from "../services/business/BusinessService";
12
12
  export type { BusinessServiceProps, Business, BusinessGetProps, BusinessListProps, BusinessCreateProps, BusinessUpdateProps } from "../services/business/BusinessService";
13
13
  export { SubscribePlanService, subscribeCurrencies, subscribePlanBillingCycles } from "../services/subscription/plan/SubscribePlanService";