storemw-core-api 1.0.152 → 1.0.154

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 (77) hide show
  1. package/dist/controllers/index.d.ts +1 -0
  2. package/dist/controllers/index.js +8 -1
  3. package/dist/controllers/index.js.map +1 -1
  4. package/dist/controllers/scheduler/schedulerRequestController.d.ts +11 -0
  5. package/dist/controllers/scheduler/schedulerRequestController.js +156 -0
  6. package/dist/controllers/scheduler/schedulerRequestController.js.map +1 -0
  7. package/dist/features/index.d.ts +1 -1
  8. package/dist/features/index.js.map +1 -1
  9. package/dist/features/user_me/userMeRegistry.js +4 -0
  10. package/dist/features/user_me/userMeRegistry.js.map +1 -1
  11. package/dist/features/user_me/userMeType.d.ts +17 -3
  12. package/dist/features/user_me/userMeType.js.map +1 -1
  13. package/dist/lib/index.d.ts +1 -1
  14. package/dist/lib/index.js +4 -1
  15. package/dist/lib/index.js.map +1 -1
  16. package/dist/lib/query_builder/queryScheduler.d.ts +13 -0
  17. package/dist/lib/query_builder/queryScheduler.js +47 -1
  18. package/dist/lib/query_builder/queryScheduler.js.map +1 -1
  19. package/dist/middlewares/route/index.d.ts +2 -1
  20. package/dist/middlewares/route/index.js +13 -7
  21. package/dist/middlewares/route/index.js.map +1 -1
  22. package/dist/middlewares/route/validateScheduler.d.ts +10 -0
  23. package/dist/middlewares/route/validateScheduler.js +39 -0
  24. package/dist/middlewares/route/validateScheduler.js.map +1 -0
  25. package/dist/models/index.d.ts +2 -0
  26. package/dist/models/index.js +4 -1
  27. package/dist/models/index.js.map +1 -1
  28. package/dist/models/scheduler/SchedulerRequestModel.d.ts +327 -0
  29. package/dist/models/scheduler/SchedulerRequestModel.js +13 -0
  30. package/dist/models/scheduler/SchedulerRequestModel.js.map +1 -0
  31. package/dist/routes/scheduler/schedulerRequestRoutes.d.ts +2 -0
  32. package/dist/routes/scheduler/schedulerRequestRoutes.js +15 -0
  33. package/dist/routes/scheduler/schedulerRequestRoutes.js.map +1 -0
  34. package/dist/routes/scheduler/schedulerRequestsRoutes.d.ts +2 -0
  35. package/dist/routes/scheduler/schedulerRequestsRoutes.js +13 -0
  36. package/dist/routes/scheduler/schedulerRequestsRoutes.js.map +1 -0
  37. package/dist/routes/scheduler/schedulersRoutes.js +5 -0
  38. package/dist/routes/scheduler/schedulersRoutes.js.map +1 -1
  39. package/dist/schema/middleware/route/index.d.ts +2 -2
  40. package/dist/schema/middleware/route/index.js +4 -3
  41. package/dist/schema/middleware/route/index.js.map +1 -1
  42. package/dist/schema/middleware/route/schemaScheduler.d.ts +7 -0
  43. package/dist/schema/middleware/route/schemaScheduler.js +15 -0
  44. package/dist/schema/middleware/route/schemaScheduler.js.map +1 -0
  45. package/dist/schema/payload/index.d.ts +2 -0
  46. package/dist/schema/payload/index.js +5 -1
  47. package/dist/schema/payload/index.js.map +1 -1
  48. package/dist/schema/payload/scheduler/schemaSchedulerRequest.d.ts +254 -0
  49. package/dist/schema/payload/scheduler/schemaSchedulerRequest.js +46 -0
  50. package/dist/schema/payload/scheduler/schemaSchedulerRequest.js.map +1 -0
  51. package/dist/services/auth/AuthService.js +2 -2
  52. package/dist/services/auth/AuthService.js.map +1 -1
  53. package/dist/services/file/FileService.js +4 -4
  54. package/dist/services/file/FileService.js.map +1 -1
  55. package/dist/services/gateway/SmtpEmailService.js +5 -4
  56. package/dist/services/gateway/SmtpEmailService.js.map +1 -1
  57. package/dist/services/index.d.ts +2 -0
  58. package/dist/services/index.js +3 -1
  59. package/dist/services/index.js.map +1 -1
  60. package/dist/services/reset_password/ResetPasswordService.js +4 -4
  61. package/dist/services/reset_password/ResetPasswordService.js.map +1 -1
  62. package/dist/services/scheduler/SchedulerRequestService.d.ts +109 -0
  63. package/dist/services/scheduler/SchedulerRequestService.js +141 -0
  64. package/dist/services/scheduler/SchedulerRequestService.js.map +1 -0
  65. package/dist/services/user/UserMeService.js +29 -8
  66. package/dist/services/user/UserMeService.js.map +1 -1
  67. package/dist/utils/featureUtils.d.ts +3 -0
  68. package/dist/utils/featureUtils.js +11 -0
  69. package/dist/utils/featureUtils.js.map +1 -1
  70. package/dist/utils/index.d.ts +1 -0
  71. package/dist/utils/index.js +3 -1
  72. package/dist/utils/index.js.map +1 -1
  73. package/dist/utils/serviceUtils.d.ts +1 -0
  74. package/dist/utils/serviceUtils.js +2 -1
  75. package/dist/utils/serviceUtils.js.map +1 -1
  76. package/package.json +1 -1
  77. package/prisma/schema.prisma +80 -54
@@ -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,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,wEAAwE;IAExE,MAAM,yBAAyB,GAAG,CAAC,QAAkB,EAAE,EAAE;QAErD,IAAI,QAAQ,KAAK,eAAe;YAAE,OAAO,CAAC,gCAAgC,CAAC,CAAA;QAC3E,IAAI,QAAQ,KAAK,UAAU;YAAE,OAAO,CAAC,2BAA2B,CAAC,CAAA;QACjE,IAAI,QAAQ,KAAK,QAAQ;YAAE,OAAO,CAAC,yBAAyB,CAAC,CAAA;QAE7D,OAAO,EAAE,CAAA;IACb,CAAC,CAAA;IAED,MAAM,mBAAmB,GAAG,KAAK,EAAE,WAAmB,EAAE,EAAE;QAEtD,IAAI,WAAW,KAAK,EAAE,EAAE,CAAC;YACrB,OAAO,CAAC,CAAA;QACZ,CA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C,CAAC,CAAC;IAEF,OAAO;QACH,YAAY;QACZ,eAAe,EAAf,uBAAe;KAClB,CAAA;AAEL,CAAC,CAAA;AAhRY,QAAA,WAAW,eAgRvB","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\n const userType: UserType = user?.user_type ?? \"administrator\"\n\n newResult = await AuthTokenHook.onSuccessAuthenticate({\n defaultServiceProps: {\n accountId: Number(account?.account_id),\n actionUserId: Number(user?.user_id),\n actionUserType: user?.user_type ?? \"\",\n authToken: authToken,\n isOperator: Boolean(userType === \"operator\"),\n accessKey: \"\",\n accessKeyId: \"\"\n },\n callbackParams: result\n })\n }\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,mCAAqF;AACrF,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,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AS,IAAI,eAAe,CAAA;YAE7D,SAAS,GAAG,MAAM,wBAAa,CAAC,qBAAqB,CAAC,IAAA,iCAAyB,EAAC;gBAC5E,mBAAmB,EAAE;oBACjB,SAAS,EAAE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC;oBACtC,YAAY,EAAE,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC;oBACnC,cAAc,EAAE,IAAI,EAAE,SAAS,IAAI,EAAE;oBACrC,SAAS,EAAE,SAAS;oBACpB,UAAU,EAAE,OAAO,CAAC,QAAQ,KAAK,UAAU,CAAC;oBAC5C,SAAS,EAAE,EAAE;oBACb,WAAW,EAAE,EAAE;iBAClB;gBACD,cAAc,EAAE,MAAM;aACzB,CAAC,CAAC,CAAA;QACP,CAAC;QAED,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;AAhRY,QAAA,WAAW,eAgRvB","sourcesContent":["// import { QueryList, QueryGet } from \"@/schema/common\";\nimport { buildFeatureCallbackProps, 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\n const userType: UserType = user?.user_type ?? \"administrator\"\n\n newResult = await AuthTokenHook.onSuccessAuthenticate(buildFeatureCallbackProps({\n defaultServiceProps: {\n accountId: Number(account?.account_id),\n actionUserId: Number(user?.user_id),\n actionUserType: user?.user_type ?? \"\",\n authToken: authToken,\n isOperator: Boolean(userType === \"operator\"),\n accessKey: \"\",\n accessKeyId: \"\"\n },\n callbackParams: result\n }))\n }\n\n return newResult ? newResult : result\n };\n\n return {\n getAuthToken,\n verifyAuthToken,\n }\n\n}\n\n"]}
@@ -234,7 +234,7 @@ const FileService = (props) => {
234
234
  const bufferThumbnail = await (0, utils_1.generateFileThumbnailBuffer)(bufferToUpload, mimeType);
235
235
  // Call the consumer hook, if registered
236
236
  if (features_1.FileStorageHook.onStartUpload) {
237
- await features_1.FileStorageHook.onStartUpload({
237
+ await features_1.FileStorageHook.onStartUpload((0, utils_1.buildFeatureCallbackProps)({
238
238
  defaultServiceProps: rest,
239
239
  callbackParams: {
240
240
  fieldRef: field_ref,
@@ -261,7 +261,7 @@ const FileService = (props) => {
261
261
  imageCompressionOptions,
262
262
  videoCompressionOptions
263
263
  }
264
- });
264
+ }));
265
265
  }
266
266
  // upload using the provider - buffer
267
267
  const uploadResult = await provider.uploadFile({
@@ -326,7 +326,7 @@ const FileService = (props) => {
326
326
  let responseFile = await createFile(payload);
327
327
  // Call the consumer hook, if registered
328
328
  if (features_1.FileStorageHook.onSuccessUpload) {
329
- await features_1.FileStorageHook.onSuccessUpload({
329
+ await features_1.FileStorageHook.onSuccessUpload((0, utils_1.buildFeatureCallbackProps)({
330
330
  defaultServiceProps: rest,
331
331
  callbackParams: {
332
332
  fileId: Number(responseFile?.file_id),
@@ -357,7 +357,7 @@ const FileService = (props) => {
357
357
  imageCompressionOptions,
358
358
  videoCompressionOptions
359
359
  }
360
- });
360
+ }));
361
361
  }
362
362
  allResponses.push(responseFile);
363
363
  }
@@ -1 +1 @@
1
- {"version":3,"file":"FileService.js","sourceRoot":"","sources":["../../../src/services/file/FileService.ts"],"names":[],"mappings":";;;;;;AAAA,mCAA+E;AAE/E,gDAAwB;AAExB,qCAGkB;AAElB,yEAAyH;AACzH,qFAAiJ;AACjJ,yEAAyH;AACzH,+EAAgG;AAQhG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C,EAAE,cAAc;SAC1D,CAAC;IACN,CAAC,CAAA;IAED,+BAA+B;IAC/B,2CAA2C;IAC3C,IAAI;IAEJ,OAAO;QACH,WAAW;QACX,cAAc;QACd,cAAc;QACd,OAAO;QACP,SAAS;QACT,WAAW;QACX,gBAAgB;QAChB,mBAAmB;KACtB,CAAA;AAEL,CAAC,CAAA;AAvkBY,QAAA,WAAW,eAukBvB","sourcesContent":["import { _, logError, throwError, generateFileThumbnailBuffer } from \"@/utils\";\n\nimport path from \"path\";\n\nimport {\n FileModel,\n ModelFileFields,\n} from \"@/models\";\n\nimport { FileLocalProviderOptions, FileLocalStorageProvider, FileLocalUploadFileProps } from \"./FileLocalStorageProvider\"\nimport { FileGoogleCloudProviderOptions, FileGoogleCloudStorageProvider, FileGoogleCloudUploadFileProps } from \"./FileGoogleCloudStorageProvider\"\nimport { FileAwsS3ProviderOptions, FileAwsS3StorageProvider, FileAwsS3UploadFileProps } from \"./FileAwsS3StorageProvider\"\nimport { getFileStorageProvider, FileStorageProviderType } from \"./FileStorageProviderRegistry\";\n\nimport { InjectionFieldModuleRef } from \"@/services\"\n\nimport { QueryList, QueryGet } from \"@/schema/common\";\n\nimport { DefaultServiceProps } from \"@/utils\";\n\nimport { getFileSqlRelationMaps, buildSqlSelect, buildSqlLimitOffset, buildSqlOrderBy, getListWithCount } from \"@/lib\";\n\nimport {\n buildFileMainSqlSelect,\n buildFileDefaultSqlSelect\n} from \"@/lib\";\n\nimport { FileImageCompressionOptions, compressImageBuffer } from \"./ImageCompression\";\nexport { FileImageCompressionOptions } from \"./ImageCompression\"\nimport { FileVideoCompressionOptions, compressVideoBuffer } from \"./VideoCompression\";\nimport { FeatureFileStorageOptions, FileStorageHook } from \"@/features\";\nexport { FileVideoCompressionOptions } from \"./VideoCompression\"\n\nexport { FileStorageProviderType } from \"./FileStorageProviderRegistry\";\nexport { FileLocalProviderOptions } from \"./FileLocalStorageProvider\";\nexport { FileGoogleCloudProviderOptions } from \"./FileGoogleCloudStorageProvider\";\nexport { FileAwsS3ProviderOptions } from \"./FileAwsS3StorageProvider\";\n\nexport const fileDataTypes = {\n}\n\nexport type FileModuleRef = InjectionFieldModuleRef\n\nexport type FileDataType = keyof typeof fileDataTypes;\n\nexport type FileServiceProps = DefaultServiceProps & {\n};\n\nexport type FileCategoryName =\n | \"image\"\n | \"video\"\n | \"audio\"\n | \"document\"\n | \"archive\"\n | \"code\"\n | \"other\";\n\n\nexport type FileGetProps = Omit<QueryGet, \"datatypes\"> & {\n id: number,\n // datatypes: FileDataType[]\n};\n\nexport type FileGetUsageSummaryProps = {\n accountId: number,\n};\n\nexport type FileListProps = Omit<QueryList, \"datatypes\"> & {\n // datatypes: FileDataType[]\n}\n\nexport type FileRemoveProps = {\n fileIds: BigInt[],\n // storageProviderOptions: any\n storageSetup?: FeatureFileStorageOptions\n};\n\nexport type File = {\n tagName: string;\n description: string;\n folderPath: string;\n assetUrl: string;\n thumbnailUrl: string;\n assetPath: string;\n fileLabel: string;\n fileName: string;\n contentType: string;\n fileCategoryName: string;\n inputType: string;\n inputFileSizeBytes: number;\n inputFileName: string;\n fileSizeBytes: number;\n fileDurationSeconds: number;\n fileCompressFormat: string;\n storageProviderName: string;\n foldernameDay: number;\n foldernameMonth: number;\n foldernameYear: number;\n batchCode: string;\n referId1: number;\n referId2: number;\n referLabel1: string;\n referLabel2: string;\n remark: string;\n}\n\nexport type FileUploadItem = {\n buffer: Buffer; // Raw file data\n originalName: string; // Client filename\n mimeType: string; // e.g. \"image/png\"\n sizeBytes: number; // File size in bytes\n // providerName?: FileStorageProviderType; // optional: override global provider\n};\n\n\nexport type FileCreateProps = {\n data: File & {\n fieldRef: FileModuleRef[\"field_ref\"],\n fieldModule: FileModuleRef[\"field_module\"]\n }\n}\n\nexport type FileUploadProps = FileModuleRef & {\n description?: string,\n tagName?: string,\n label?: string,\n refId: number\n refId2?: number\n refLabel?: string\n refLabel2?: string\n remark: string\n foldernameDate?: string,\n files: FileUploadItem[]\n storageSetup?: FeatureFileStorageOptions\n}\n\nlet mainSqlSelect = buildFileMainSqlSelect()\nlet defaultSqlSelect = buildFileDefaultSqlSelect()\n\nconst { relationKeys, sqlRelationMaps } = getFileSqlRelationMaps(``)\n\nconst getCreatePayload = (data: FileCreateProps[\"data\"]) => {\n\n return {\n // [`${ModelFileFields.file_id}`]: fileType,\n [`${ModelFileFields.asset_path}`]: data.assetPath,\n [`${ModelFileFields.asset_url}`]: data.assetUrl,\n [`${ModelFileFields.thumbnail_url}`]: data.thumbnailUrl,\n [`${ModelFileFields.batch_code}`]: data.batchCode,\n [`${ModelFileFields.content_type}`]: data.contentType,\n [`${ModelFileFields.file_category_name}`]: data.fileCategoryName,\n [`${ModelFileFields.field_module}`]: data.fieldModule,\n [`${ModelFileFields.field_ref}`]: data.fieldRef,\n [`${ModelFileFields.file_compress_format}`]: data.fileCompressFormat,\n [`${ModelFileFields.file_label}`]: data.fileLabel,\n [`${ModelFileFields.file_name}`]: data.fileName,\n [`${ModelFileFields.file_size_bytes}`]: data.fileSizeBytes,\n [`${ModelFileFields.file_duration_seconds}`]: data.fileDurationSeconds,\n [`${ModelFileFields.tag_name}`]: data.tagName,\n [`${ModelFileFields.description}`]: data.description,\n [`${ModelFileFields.foldername_day}`]: Number(data.foldernameDay),\n [`${ModelFileFields.foldername_month}`]: Number(data.foldernameMonth),\n [`${ModelFileFields.foldername_year}`]: Number(data.foldernameYear),\n [`${ModelFileFields.input_file_name}`]: data.inputFileName,\n [`${ModelFileFields.input_file_size_bytes}`]: data.inputFileSizeBytes,\n [`${ModelFileFields.input_type}`]: data.inputType,\n [`${ModelFileFields.refer_id_1}`]: data.referId1,\n [`${ModelFileFields.refer_id_2}`]: data.referId2,\n [`${ModelFileFields.refer_label_1}`]: data.referLabel1,\n [`${ModelFileFields.refer_label_2}`]: data.referLabel2,\n [`${ModelFileFields.remark}`]: data.remark,\n [`${ModelFileFields.storage_provider_name}`]: data.storageProviderName,\n }\n\n}\n\nexport const getFileCategoryNameByMimeType = (mimeType: string): FileCategoryName => {\n const lower = mimeType.toLowerCase();\n\n if (lower.startsWith(\"image/\")) return \"image\";\n if (lower.startsWith(\"video/\")) return \"video\";\n if (lower.startsWith(\"audio/\")) return \"audio\";\n\n // Edge-case audio MIME types\n if ([\"application/ogg\"].includes(lower)) return \"audio\";\n\n if (\n lower.startsWith(\"text/\") ||\n [\n \"application/pdf\",\n \"application/msword\",\n \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n \"application/vnd.ms-excel\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\n \"application/vnd.ms-powerpoint\",\n \"application/vnd.openxmlformats-officedocument.presentationml.presentation\",\n \"application/rtf\",\n ].includes(lower)\n ) {\n return \"document\";\n }\n\n if (\n [\n \"application/zip\",\n \"application/x-7z-compressed\",\n \"application/x-rar-compressed\",\n \"application/x-tar\",\n \"application/gzip\",\n ].includes(lower)\n ) {\n return \"archive\";\n }\n\n if (\n lower.startsWith(\"application/json\") ||\n lower.startsWith(\"application/javascript\") ||\n lower.startsWith(\"text/html\") ||\n lower.startsWith(\"text/css\") ||\n lower.startsWith(\"text/x-python\") ||\n lower.startsWith(\"text/x-c\") ||\n lower.startsWith(\"text/x-java\")\n ) {\n return \"code\";\n }\n\n return \"other\";\n};\n\nexport const FileService = (props: FileServiceProps) => {\n\n const {\n ...rest\n } = props\n\n const fileModel = FileModel({ ...rest })\n\n const fileGoogleCloudStorageProvider = FileGoogleCloudStorageProvider({\n basePath: ``,\n bucketName: ``\n })\n\n const fileAwsS3StorageProvider = FileAwsS3StorageProvider({\n basePath: ``,\n bucketName: ``\n })\n\n const fileLocalStorageProvider = FileLocalStorageProvider({})\n\n const thumbnailOptions = {\n suffix: \"-thumb\",\n ext: \"jpg\",\n mimeType: \"image/jpeg\",\n }\n\n const initBatchCode = () => {\n return `${Date.now()}_${_.random(0, 999)}`;\n }\n\n const getStorageSetup = async (overrideStorageSetup?: FeatureFileStorageOptions) => {\n\n const hookSetup = overrideStorageSetup ?\n overrideStorageSetup\n :\n await FileStorageHook.onSetup()\n\n if (hookSetup.storageType === \"local\") {\n return {\n storageConfiguration: hookSetup.storageConfiguration,\n storageProviderName: hookSetup.storageType,\n storageProviderOptions: {\n // basePath: `${config.FILE_STORAGE_LOCAL_BASE_PATH}`,\n basePath: `${hookSetup.localStorageOptions.basePath}`,\n // publicBaseUrl: `${config.FILE_STORAGE_LOCAL_BASE_URL}`,\n publicBaseUrl: `${hookSetup.localStorageOptions.baseUrl}`,\n // skipFoldernameByModuleRef: Boolean(config.FILE_STORAGE_LOCAL_SKIP_FOLDERNAME_MODULE_REF),\n skipFoldernameByModuleRef: Boolean(hookSetup.localStorageOptions.skipFolderNameModuleRef),\n // skipFoldernameByDate: Boolean(config.FILE_STORAGE_LOCAL_SKIP_FOLDERNAME_YEAR_MONTH)\n skipFoldernameByDate: Boolean(hookSetup.localStorageOptions.skipFolderNameYearMonth)\n }\n }\n }\n\n if (hookSetup.storageType === \"gcloud\") {\n return {\n storageConfiguration: hookSetup.storageConfiguration,\n storageProviderName: hookSetup.storageType,\n storageProviderOptions: {\n // basePath: `${config.FILE_STORAGE_GCLOUD_BASE_PATH}`,\n basePath: `${hookSetup.gcloudStorageOptions.basePath}`,\n // publicBaseUrl: `${config.FILE_STORAGE_GCLOUD_BASE_URL}`,\n publicBaseUrl: `${hookSetup.gcloudStorageOptions.baseUrl}`,\n // bucketName: `${config.FILE_STORAGE_GCLOUD_BUCKET_NAME}`,\n bucketName: `${hookSetup.gcloudStorageOptions.bucketName}`,\n // credentials: `${path.resolve(process.cwd(), `${config.FILE_STORAGE_GCLOUD_CREDENTIAL_PATH}`)}`,\n credentials: `${path.resolve(process.cwd(), `${hookSetup.gcloudStorageOptions.credentialPath}`)}`,\n // skipFoldernameByModuleRef: Boolean(config.FILE_STORAGE_GCLOUD_SKIP_FOLDERNAME_MODULE_REF),\n skipFoldernameByModuleRef: Boolean(hookSetup.gcloudStorageOptions.skipFolderNameModuleRef),\n // skipFoldernameByDate: Boolean(config.FILE_STORAGE_GCLOUD_SKIP_FOLDERNAME_YEAR_MONTH)\n skipFoldernameByDate: Boolean(hookSetup.gcloudStorageOptions.skipFolderNameYearMonth)\n }\n\n }\n }\n\n if (hookSetup.storageType === \"aws\") {\n return {\n storageConfiguration: hookSetup.storageConfiguration,\n storageProviderName: hookSetup.storageType,\n storageProviderOptions: {\n basePath: `${hookSetup.awsStorageOptions.basePath}`,\n publicBaseUrl: `${hookSetup.awsStorageOptions.baseUrl}`,\n bucketName: `${hookSetup.awsStorageOptions.bucketName}`,\n region: hookSetup.awsStorageOptions?.region ?? \"\",\n credentials: {\n accessKeyId: hookSetup.awsStorageOptions.credentials.accessKeyId,\n secretAccessKey: hookSetup.awsStorageOptions.credentials.secretAccessKey,\n },\n skipFoldernameByModuleRef: Boolean(hookSetup.awsStorageOptions.skipFolderNameModuleRef),\n skipFoldernameByDate: Boolean(hookSetup.awsStorageOptions.skipFolderNameYearMonth)\n }\n\n }\n }\n\n throw new Error(\"Unsupported storage type\")\n }\n\n const uploadFiles = async ({\n field_ref = \"item\",\n field_module = \"item\",\n tagName,\n label,\n refId,\n refId2,\n refLabel,\n refLabel2,\n remark,\n description,\n foldernameDate,\n files = [],\n storageSetup\n }: FileUploadProps) => {\n\n const {\n storageProviderName,\n storageProviderOptions,\n storageConfiguration\n } = await getStorageSetup(storageSetup)\n\n // get the correct provider\n const provider = await getFileStorageProvider(storageProviderName, storageProviderOptions);\n\n // Image Compression\n const imageCompressionOptions: FileImageCompressionOptions | undefined\n = storageConfiguration?.imageMaxWidth && storageConfiguration?.imageMaxWidth\n ? {\n maxWidth: Number(storageConfiguration.imageMaxWidth),\n quality: Number(storageConfiguration.imageQuality),\n }\n : undefined;\n\n // Video Compression\n const videoCompressionOptions: FileVideoCompressionOptions | undefined =\n storageConfiguration?.videoCRF &&\n storageConfiguration?.videoPreset &&\n storageConfiguration?.videoResolution\n ? {\n crf: Number(storageConfiguration.videoCRF),\n preset: storageConfiguration.videoPreset as FileVideoCompressionOptions[\"preset\"],\n resolution: Number(storageConfiguration.videoResolution),\n }\n : undefined;\n\n const allResponses = []\n\n const batchCode = initBatchCode();\n\n const fileLabel = label ?? \"\"\n const referId1 = refId ?? 0\n const referId2 = refId2 ?? 0\n const referLabel1 = refLabel ?? \"\"\n const referLabel2 = refLabel2 ?? \"\"\n const fileRemark = remark ?? \"\"\n\n for (const file of files) {\n\n let bufferToUpload = file.buffer;\n let mimeType = file.mimeType ?? \"\"\n let sizeBytes = file?.sizeBytes\n let fileOriginalName = file.originalName;\n\n let outputSizeBytes = sizeBytes // output file size\n let fileCompressFormat = `` // output image compress\n\n const fileCategoryName = getFileCategoryNameByMimeType(mimeType)\n\n // const ext = file.originalName?.split(\".\").pop()?.toLowerCase() ?? \"\";\n\n // Image :: Only compress if image and options provided\n if (fileCategoryName === \"image\" && imageCompressionOptions) {\n const compressed = await compressImageBuffer(\n bufferToUpload,\n mimeType,\n imageCompressionOptions\n );\n\n fileCompressFormat = compressed.compressFormat,\n bufferToUpload = compressed.buffer;\n outputSizeBytes = compressed.sizeBytes; // update the file size\n }\n\n // Vide :: Only compress if video and options provided\n if (fileCategoryName === \"video\" && videoCompressionOptions) {\n const compressed = await compressVideoBuffer(\n bufferToUpload,\n mimeType,\n videoCompressionOptions\n );\n\n fileCompressFormat = compressed.compressFormat,\n bufferToUpload = compressed.buffer;\n outputSizeBytes = compressed.sizeBytes; // update the file size\n }\n\n // generate thumbnail buffer\n const bufferThumbnail = await generateFileThumbnailBuffer(bufferToUpload, mimeType)\n\n // Call the consumer hook, if registered\n if (FileStorageHook.onStartUpload) {\n\n await FileStorageHook.onStartUpload({\n defaultServiceProps: rest,\n callbackParams: {\n fieldRef: field_ref,\n fieldModule: field_module,\n tagName,\n label,\n refId,\n refId2,\n refLabel,\n refLabel2,\n remark,\n description,\n foldernameDate,\n file,\n storageProviderName,\n storageProviderOptions,\n fileCategoryName,\n batchCode,\n mimeType,\n bufferFilebuffer: bufferToUpload,\n bufferFileThumbnail: bufferThumbnail?.buffer,\n outputSizeBytes,\n fileCompressFormat: fileCompressFormat ? JSON.parse(fileCompressFormat) : \"\",\n imageCompressionOptions,\n videoCompressionOptions\n }\n })\n }\n\n // upload using the provider - buffer\n const uploadResult = await provider.uploadFile({\n field_ref,\n field_module,\n buffer: bufferToUpload,\n bufferThumbnail: bufferThumbnail.buffer,\n thumbnailOptions,\n ...(foldernameDate ? { foldernameDate } : {}),\n mimeType,\n fileName: fileOriginalName\n } as FileModuleRef & (\n FileLocalUploadFileProps |\n FileGoogleCloudUploadFileProps |\n FileAwsS3UploadFileProps\n ));\n\n const fieldRef = field_ref\n const fieldModule = field_module\n\n const fileName = uploadResult?.filename ?? \"\"\n const contentType = mimeType ?? \"\"\n const folderPath = uploadResult.assetPath ?? \"\"\n const assetUrl = uploadResult.assetUrl ?? \"\"\n const thumbnailUrl = uploadResult?.thumbnailUrl ?? \"\"\n const assetPath = uploadResult.assetPath ?? \"\"\n\n const fileDurationSeconds = bufferThumbnail?.durationSeconds ?? 0\n\n const inputType = `buffer`\n const inputFileSizeBytes = sizeBytes ?? 0\n const inputFileName = fileOriginalName ?? \"\"\n\n const fileSizeBytes = outputSizeBytes ?? 0\n // const fileCompressFormat = ``\n\n const foldernameDay = uploadResult?.folderName?.day ?? \"\"\n const foldernameMonth = uploadResult?.folderName?.month ?? \"\"\n const foldernameYear = uploadResult?.folderName?.year ?? \"\"\n\n const payload: FileCreateProps = {\n data: {\n fieldRef,\n fieldModule,\n tagName,\n description,\n remark: fileRemark,\n folderPath,\n assetUrl,\n thumbnailUrl,\n assetPath,\n fileLabel,\n fileName,\n fileCategoryName,\n contentType,\n inputType,\n inputFileSizeBytes,\n inputFileName,\n fileSizeBytes,\n fileDurationSeconds,\n fileCompressFormat,\n storageProviderName,\n foldernameDay,\n foldernameMonth,\n foldernameYear,\n batchCode,\n referId1,\n referId2,\n referLabel1,\n referLabel2\n } as FileCreateProps[\"data\"],\n };\n\n let responseFile = await createFile(payload);\n\n // Call the consumer hook, if registered\n if (FileStorageHook.onSuccessUpload) {\n await FileStorageHook.onSuccessUpload({\n defaultServiceProps: rest,\n callbackParams: {\n fileId: Number(responseFile?.file_id),\n fileThumbnailUrl: thumbnailUrl,\n fileAssetUrl: assetUrl,\n fileDurationSeconds,\n fieldRef: field_ref,\n fieldModule: field_module,\n tagName,\n label,\n refId,\n refId2,\n refLabel,\n refLabel2,\n remark,\n description,\n foldernameDate,\n file,\n storageProviderName,\n storageProviderOptions,\n fileCategoryName,\n batchCode,\n mimeType,\n bufferFilebuffer: bufferToUpload,\n bufferFileThumbnail: bufferThumbnail.buffer,\n outputSizeBytes,\n fileCompressFormat: fileCompressFormat ? JSON.parse(fileCompressFormat) : \"\",\n imageCompressionOptions,\n videoCompressionOptions\n }\n })\n }\n\n allResponses.push(responseFile)\n }\n\n return allResponses\n\n }\n\n // private\n const createFile = async ({ data }: FileCreateProps) => {\n\n const _data = getCreatePayload(data)\n\n if (!_data) {\n throw new Error(`Invalid create file payload: ${JSON.stringify(_data)}`);\n }\n\n const response = await fileModel.create({ data: _data })\n\n const newFileId = response?.file_id ?? \"\"\n\n return newFileId ? await getFile({ id: Number(newFileId) }) : null\n\n }\n\n const getFile = async ({ id }: FileGetProps) => {\n\n let { data } = await listFiles({\n limit: 1,\n offset: 0,\n filters: [{ field: `${ModelFileFields.file_id}`, operator: \"=\", value: id }],\n sortfield: `${ModelFileFields.file_id}`,\n sortorder: \"ASC\"\n })\n\n return data[0] ?? null;\n\n };\n\n const listFiles = async ({ limit, offset, filters = [], sortfield, sortorder }: FileListProps) => {\n\n let sqlSelect: string[] = []\n let sqlRelation: string[] = []\n let sqlGroupBy: string[] = []\n\n let sqlSelectAgg: string[] = []\n let sqlRelationAgg: string[] = []\n\n sqlSelect = [\n buildSqlSelect(``, mainSqlSelect),\n buildSqlSelect(``, defaultSqlSelect)\n ]\n\n sqlRelation = [\n sqlRelationMaps.creator,\n sqlRelationMaps.updater\n ]\n\n // sqlRelationAgg = []\n\n sqlGroupBy = [\n ...Object.keys(mainSqlSelect),\n ...Object.keys(defaultSqlSelect)\n ]\n\n let filterColumns = {\n ...mainSqlSelect,\n ...defaultSqlSelect\n }\n\n let sqlWhere = [\n `mainfile.isdelete = false`,\n `mainfile.istrash = false`,\n // `LOWER(mainfile.doc_type) = LOWER('${documentTypeKey}')`\n ]\n\n let sqlOrderby = buildSqlOrderBy(sortfield, sortorder)\n let sqlLimitOffset = buildSqlLimitOffset(limit, offset)\n\n // get the listing data & count\n const { data, total } = await getListWithCount({\n model: fileModel,\n tableName: \"files\",\n mainAlias: \"mainfile\",\n countKey: `${ModelFileFields.file_id}`,\n accountId: rest.accountId,\n sqlRelationMaps,\n filters,\n filterColumns,\n sqlSelect,\n sqlSelectAgg,\n sqlRelation,\n sqlRelationAgg,\n sqlWhere,\n sqlGroupBy,\n sqlOrderby,\n sqlLimitOffset\n })\n\n const response = {\n data,\n total\n }\n\n return response\n\n };\n\n const removeFiles = async ({ fileIds, storageSetup }: FileRemoveProps) => {\n\n const {\n // storageProviderName,\n storageProviderOptions\n } = await getStorageSetup(storageSetup)\n\n if (!fileIds.length) throwError('fileIds is required');\n\n const filesToDelete = await fileModel.list({\n where: {\n file_id: { in: fileIds }\n }\n });\n\n // console.log('filesToDelete', filesToDelete)\n\n let providerResponse: any[] = []\n\n // 2️⃣ Delete the physical files\n for (const file of filesToDelete) {\n\n // check the provider to choose delete method\n const storageProviderName = file.storage_provider_name as FileStorageProviderType\n const assetUrl = file.asset_url\n const thumbnailUrl = file.thumbnail_url ?? \"\"\n const assetPath = file.asset_path\n\n if (storageProviderName === \"local\" && assetPath) {\n\n try {\n providerResponse.push(\n await fileLocalStorageProvider.removeFile(assetPath, thumbnailOptions)\n )\n } catch (err) {\n providerResponse.push(\n `Failed to delete from Local: ${assetUrl}`\n )\n }\n\n }\n\n if (storageProviderName === \"gcloud\" && assetUrl) {\n\n try {\n providerResponse.push(\n await fileGoogleCloudStorageProvider.removeFile(assetUrl, thumbnailUrl, storageProviderOptions.credentials as any)\n )\n } catch (err) {\n providerResponse.push(\n `Failed to delete from GCloud: ${assetUrl}`\n )\n }\n\n }\n\n if (storageProviderName === \"aws\" && assetUrl) {\n\n try {\n providerResponse.push(\n await fileAwsS3StorageProvider.removeFile(assetUrl, thumbnailUrl)\n )\n } catch (err) {\n providerResponse.push(\n `Failed to delete from Aws S3: ${assetUrl}`\n )\n }\n\n }\n\n }\n\n // remove files\n const response = await fileModel.remove({ where: { [`${ModelFileFields.file_id}`]: { in: fileIds } } });\n\n return {\n files: response,\n providerResponse\n }\n };\n\n const getFileUsageSummary = async ({ accountId = 0 }: FileGetUsageSummaryProps) => {\n\n const summaryCount = await fileModel.aggregate({\n field: `file_id`,\n operation: `count`,\n where: {\n [`${ModelFileFields.accountid}`]: accountId,\n [`${ModelFileFields.istrash}`]: false,\n [`${ModelFileFields.isdelete}`]: false,\n }\n });\n\n const summarySize = await fileModel.aggregate({\n field: `file_size_bytes`,\n operation: `sum`,\n where: {\n [`${ModelFileFields.accountid}`]: accountId,\n [`${ModelFileFields.istrash}`]: false,\n [`${ModelFileFields.isdelete}`]: false,\n }\n });\n\n const totalFiles = summaryCount ?? 0;\n const totalBytes = summarySize ?? 0;\n // const totalFiles = summary._count.id;\n\n // Optional: convert bytes to MB or GB\n const totalMB = totalBytes / (1024 * 1024);\n const totalGB = totalBytes / (1024 * 1024 * 1024);\n\n return {\n totalFiles,\n totalBytes,\n totalMB: parseFloat(totalMB.toFixed(2)), // now decimal\n totalGB: parseFloat(totalGB.toFixed(2)), // now decimal\n };\n }\n\n // const getDataTypes = () => {\n // return Object.values(fileDataTypes);\n // }\n\n return {\n uploadFiles,\n // createFile,\n // updateFile,\n getFile,\n listFiles,\n removeFiles,\n // getDataTypes,\n getFileUsageSummary\n }\n\n}\n\n"]}
1
+ {"version":3,"file":"FileService.js","sourceRoot":"","sources":["../../../src/services/file/FileService.ts"],"names":[],"mappings":";;;;;;AAAA,mCAA0G;AAE1G,gDAAwB;AA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AU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,cAAc;YACvD,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,cAAc;SAC1D,CAAC;IACN,CAAC,CAAA;IAED,+BAA+B;IAC/B,2CAA2C;IAC3C,IAAI;IAEJ,OAAO;QACH,WAAW;QACX,cAAc;QACd,cAAc;QACd,OAAO;QACP,SAAS;QACT,WAAW;QACX,gBAAgB;QAChB,mBAAmB;KACtB,CAAA;AAEL,CAAC,CAAA;AAvkBY,QAAA,WAAW,eAukBvB","sourcesContent":["import { _, logError, throwError, generateFileThumbnailBuffer, buildFeatureCallbackProps } from \"@/utils\";\n\nimport path from \"path\";\n\nimport {\n FileModel,\n ModelFileFields,\n} from \"@/models\";\n\nimport { FileLocalProviderOptions, FileLocalStorageProvider, FileLocalUploadFileProps } from \"./FileLocalStorageProvider\"\nimport { FileGoogleCloudProviderOptions, FileGoogleCloudStorageProvider, FileGoogleCloudUploadFileProps } from \"./FileGoogleCloudStorageProvider\"\nimport { FileAwsS3ProviderOptions, FileAwsS3StorageProvider, FileAwsS3UploadFileProps } from \"./FileAwsS3StorageProvider\"\nimport { getFileStorageProvider, FileStorageProviderType } from \"./FileStorageProviderRegistry\";\n\nimport { InjectionFieldModuleRef } from \"@/services\"\n\nimport { QueryList, QueryGet } from \"@/schema/common\";\n\nimport { DefaultServiceProps } from \"@/utils\";\n\nimport { getFileSqlRelationMaps, buildSqlSelect, buildSqlLimitOffset, buildSqlOrderBy, getListWithCount } from \"@/lib\";\n\nimport {\n buildFileMainSqlSelect,\n buildFileDefaultSqlSelect\n} from \"@/lib\";\n\nimport { FileImageCompressionOptions, compressImageBuffer } from \"./ImageCompression\";\nexport { FileImageCompressionOptions } from \"./ImageCompression\"\nimport { FileVideoCompressionOptions, compressVideoBuffer } from \"./VideoCompression\";\nimport { FeatureFileStorageOptions, FileStorageHook } from \"@/features\";\nexport { FileVideoCompressionOptions } from \"./VideoCompression\"\n\nexport { FileStorageProviderType } from \"./FileStorageProviderRegistry\";\nexport { FileLocalProviderOptions } from \"./FileLocalStorageProvider\";\nexport { FileGoogleCloudProviderOptions } from \"./FileGoogleCloudStorageProvider\";\nexport { FileAwsS3ProviderOptions } from \"./FileAwsS3StorageProvider\";\n\nexport const fileDataTypes = {\n}\n\nexport type FileModuleRef = InjectionFieldModuleRef\n\nexport type FileDataType = keyof typeof fileDataTypes;\n\nexport type FileServiceProps = DefaultServiceProps & {\n};\n\nexport type FileCategoryName =\n | \"image\"\n | \"video\"\n | \"audio\"\n | \"document\"\n | \"archive\"\n | \"code\"\n | \"other\";\n\n\nexport type FileGetProps = Omit<QueryGet, \"datatypes\"> & {\n id: number,\n // datatypes: FileDataType[]\n};\n\nexport type FileGetUsageSummaryProps = {\n accountId: number,\n};\n\nexport type FileListProps = Omit<QueryList, \"datatypes\"> & {\n // datatypes: FileDataType[]\n}\n\nexport type FileRemoveProps = {\n fileIds: BigInt[],\n // storageProviderOptions: any\n storageSetup?: FeatureFileStorageOptions\n};\n\nexport type File = {\n tagName: string;\n description: string;\n folderPath: string;\n assetUrl: string;\n thumbnailUrl: string;\n assetPath: string;\n fileLabel: string;\n fileName: string;\n contentType: string;\n fileCategoryName: string;\n inputType: string;\n inputFileSizeBytes: number;\n inputFileName: string;\n fileSizeBytes: number;\n fileDurationSeconds: number;\n fileCompressFormat: string;\n storageProviderName: string;\n foldernameDay: number;\n foldernameMonth: number;\n foldernameYear: number;\n batchCode: string;\n referId1: number;\n referId2: number;\n referLabel1: string;\n referLabel2: string;\n remark: string;\n}\n\nexport type FileUploadItem = {\n buffer: Buffer; // Raw file data\n originalName: string; // Client filename\n mimeType: string; // e.g. \"image/png\"\n sizeBytes: number; // File size in bytes\n // providerName?: FileStorageProviderType; // optional: override global provider\n};\n\n\nexport type FileCreateProps = {\n data: File & {\n fieldRef: FileModuleRef[\"field_ref\"],\n fieldModule: FileModuleRef[\"field_module\"]\n }\n}\n\nexport type FileUploadProps = FileModuleRef & {\n description?: string,\n tagName?: string,\n label?: string,\n refId: number\n refId2?: number\n refLabel?: string\n refLabel2?: string\n remark: string\n foldernameDate?: string,\n files: FileUploadItem[]\n storageSetup?: FeatureFileStorageOptions\n}\n\nlet mainSqlSelect = buildFileMainSqlSelect()\nlet defaultSqlSelect = buildFileDefaultSqlSelect()\n\nconst { relationKeys, sqlRelationMaps } = getFileSqlRelationMaps(``)\n\nconst getCreatePayload = (data: FileCreateProps[\"data\"]) => {\n\n return {\n // [`${ModelFileFields.file_id}`]: fileType,\n [`${ModelFileFields.asset_path}`]: data.assetPath,\n [`${ModelFileFields.asset_url}`]: data.assetUrl,\n [`${ModelFileFields.thumbnail_url}`]: data.thumbnailUrl,\n [`${ModelFileFields.batch_code}`]: data.batchCode,\n [`${ModelFileFields.content_type}`]: data.contentType,\n [`${ModelFileFields.file_category_name}`]: data.fileCategoryName,\n [`${ModelFileFields.field_module}`]: data.fieldModule,\n [`${ModelFileFields.field_ref}`]: data.fieldRef,\n [`${ModelFileFields.file_compress_format}`]: data.fileCompressFormat,\n [`${ModelFileFields.file_label}`]: data.fileLabel,\n [`${ModelFileFields.file_name}`]: data.fileName,\n [`${ModelFileFields.file_size_bytes}`]: data.fileSizeBytes,\n [`${ModelFileFields.file_duration_seconds}`]: data.fileDurationSeconds,\n [`${ModelFileFields.tag_name}`]: data.tagName,\n [`${ModelFileFields.description}`]: data.description,\n [`${ModelFileFields.foldername_day}`]: Number(data.foldernameDay),\n [`${ModelFileFields.foldername_month}`]: Number(data.foldernameMonth),\n [`${ModelFileFields.foldername_year}`]: Number(data.foldernameYear),\n [`${ModelFileFields.input_file_name}`]: data.inputFileName,\n [`${ModelFileFields.input_file_size_bytes}`]: data.inputFileSizeBytes,\n [`${ModelFileFields.input_type}`]: data.inputType,\n [`${ModelFileFields.refer_id_1}`]: data.referId1,\n [`${ModelFileFields.refer_id_2}`]: data.referId2,\n [`${ModelFileFields.refer_label_1}`]: data.referLabel1,\n [`${ModelFileFields.refer_label_2}`]: data.referLabel2,\n [`${ModelFileFields.remark}`]: data.remark,\n [`${ModelFileFields.storage_provider_name}`]: data.storageProviderName,\n }\n\n}\n\nexport const getFileCategoryNameByMimeType = (mimeType: string): FileCategoryName => {\n const lower = mimeType.toLowerCase();\n\n if (lower.startsWith(\"image/\")) return \"image\";\n if (lower.startsWith(\"video/\")) return \"video\";\n if (lower.startsWith(\"audio/\")) return \"audio\";\n\n // Edge-case audio MIME types\n if ([\"application/ogg\"].includes(lower)) return \"audio\";\n\n if (\n lower.startsWith(\"text/\") ||\n [\n \"application/pdf\",\n \"application/msword\",\n \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n \"application/vnd.ms-excel\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\n \"application/vnd.ms-powerpoint\",\n \"application/vnd.openxmlformats-officedocument.presentationml.presentation\",\n \"application/rtf\",\n ].includes(lower)\n ) {\n return \"document\";\n }\n\n if (\n [\n \"application/zip\",\n \"application/x-7z-compressed\",\n \"application/x-rar-compressed\",\n \"application/x-tar\",\n \"application/gzip\",\n ].includes(lower)\n ) {\n return \"archive\";\n }\n\n if (\n lower.startsWith(\"application/json\") ||\n lower.startsWith(\"application/javascript\") ||\n lower.startsWith(\"text/html\") ||\n lower.startsWith(\"text/css\") ||\n lower.startsWith(\"text/x-python\") ||\n lower.startsWith(\"text/x-c\") ||\n lower.startsWith(\"text/x-java\")\n ) {\n return \"code\";\n }\n\n return \"other\";\n};\n\nexport const FileService = (props: FileServiceProps) => {\n\n const {\n ...rest\n } = props\n\n const fileModel = FileModel({ ...rest })\n\n const fileGoogleCloudStorageProvider = FileGoogleCloudStorageProvider({\n basePath: ``,\n bucketName: ``\n })\n\n const fileAwsS3StorageProvider = FileAwsS3StorageProvider({\n basePath: ``,\n bucketName: ``\n })\n\n const fileLocalStorageProvider = FileLocalStorageProvider({})\n\n const thumbnailOptions = {\n suffix: \"-thumb\",\n ext: \"jpg\",\n mimeType: \"image/jpeg\",\n }\n\n const initBatchCode = () => {\n return `${Date.now()}_${_.random(0, 999)}`;\n }\n\n const getStorageSetup = async (overrideStorageSetup?: FeatureFileStorageOptions) => {\n\n const hookSetup = overrideStorageSetup ?\n overrideStorageSetup\n :\n await FileStorageHook.onSetup()\n\n if (hookSetup.storageType === \"local\") {\n return {\n storageConfiguration: hookSetup.storageConfiguration,\n storageProviderName: hookSetup.storageType,\n storageProviderOptions: {\n // basePath: `${config.FILE_STORAGE_LOCAL_BASE_PATH}`,\n basePath: `${hookSetup.localStorageOptions.basePath}`,\n // publicBaseUrl: `${config.FILE_STORAGE_LOCAL_BASE_URL}`,\n publicBaseUrl: `${hookSetup.localStorageOptions.baseUrl}`,\n // skipFoldernameByModuleRef: Boolean(config.FILE_STORAGE_LOCAL_SKIP_FOLDERNAME_MODULE_REF),\n skipFoldernameByModuleRef: Boolean(hookSetup.localStorageOptions.skipFolderNameModuleRef),\n // skipFoldernameByDate: Boolean(config.FILE_STORAGE_LOCAL_SKIP_FOLDERNAME_YEAR_MONTH)\n skipFoldernameByDate: Boolean(hookSetup.localStorageOptions.skipFolderNameYearMonth)\n }\n }\n }\n\n if (hookSetup.storageType === \"gcloud\") {\n return {\n storageConfiguration: hookSetup.storageConfiguration,\n storageProviderName: hookSetup.storageType,\n storageProviderOptions: {\n // basePath: `${config.FILE_STORAGE_GCLOUD_BASE_PATH}`,\n basePath: `${hookSetup.gcloudStorageOptions.basePath}`,\n // publicBaseUrl: `${config.FILE_STORAGE_GCLOUD_BASE_URL}`,\n publicBaseUrl: `${hookSetup.gcloudStorageOptions.baseUrl}`,\n // bucketName: `${config.FILE_STORAGE_GCLOUD_BUCKET_NAME}`,\n bucketName: `${hookSetup.gcloudStorageOptions.bucketName}`,\n // credentials: `${path.resolve(process.cwd(), `${config.FILE_STORAGE_GCLOUD_CREDENTIAL_PATH}`)}`,\n credentials: `${path.resolve(process.cwd(), `${hookSetup.gcloudStorageOptions.credentialPath}`)}`,\n // skipFoldernameByModuleRef: Boolean(config.FILE_STORAGE_GCLOUD_SKIP_FOLDERNAME_MODULE_REF),\n skipFoldernameByModuleRef: Boolean(hookSetup.gcloudStorageOptions.skipFolderNameModuleRef),\n // skipFoldernameByDate: Boolean(config.FILE_STORAGE_GCLOUD_SKIP_FOLDERNAME_YEAR_MONTH)\n skipFoldernameByDate: Boolean(hookSetup.gcloudStorageOptions.skipFolderNameYearMonth)\n }\n\n }\n }\n\n if (hookSetup.storageType === \"aws\") {\n return {\n storageConfiguration: hookSetup.storageConfiguration,\n storageProviderName: hookSetup.storageType,\n storageProviderOptions: {\n basePath: `${hookSetup.awsStorageOptions.basePath}`,\n publicBaseUrl: `${hookSetup.awsStorageOptions.baseUrl}`,\n bucketName: `${hookSetup.awsStorageOptions.bucketName}`,\n region: hookSetup.awsStorageOptions?.region ?? \"\",\n credentials: {\n accessKeyId: hookSetup.awsStorageOptions.credentials.accessKeyId,\n secretAccessKey: hookSetup.awsStorageOptions.credentials.secretAccessKey,\n },\n skipFoldernameByModuleRef: Boolean(hookSetup.awsStorageOptions.skipFolderNameModuleRef),\n skipFoldernameByDate: Boolean(hookSetup.awsStorageOptions.skipFolderNameYearMonth)\n }\n\n }\n }\n\n throw new Error(\"Unsupported storage type\")\n }\n\n const uploadFiles = async ({\n field_ref = \"item\",\n field_module = \"item\",\n tagName,\n label,\n refId,\n refId2,\n refLabel,\n refLabel2,\n remark,\n description,\n foldernameDate,\n files = [],\n storageSetup\n }: FileUploadProps) => {\n\n const {\n storageProviderName,\n storageProviderOptions,\n storageConfiguration\n } = await getStorageSetup(storageSetup)\n\n // get the correct provider\n const provider = await getFileStorageProvider(storageProviderName, storageProviderOptions);\n\n // Image Compression\n const imageCompressionOptions: FileImageCompressionOptions | undefined\n = storageConfiguration?.imageMaxWidth && storageConfiguration?.imageMaxWidth\n ? {\n maxWidth: Number(storageConfiguration.imageMaxWidth),\n quality: Number(storageConfiguration.imageQuality),\n }\n : undefined;\n\n // Video Compression\n const videoCompressionOptions: FileVideoCompressionOptions | undefined =\n storageConfiguration?.videoCRF &&\n storageConfiguration?.videoPreset &&\n storageConfiguration?.videoResolution\n ? {\n crf: Number(storageConfiguration.videoCRF),\n preset: storageConfiguration.videoPreset as FileVideoCompressionOptions[\"preset\"],\n resolution: Number(storageConfiguration.videoResolution),\n }\n : undefined;\n\n const allResponses = []\n\n const batchCode = initBatchCode();\n\n const fileLabel = label ?? \"\"\n const referId1 = refId ?? 0\n const referId2 = refId2 ?? 0\n const referLabel1 = refLabel ?? \"\"\n const referLabel2 = refLabel2 ?? \"\"\n const fileRemark = remark ?? \"\"\n\n for (const file of files) {\n\n let bufferToUpload = file.buffer;\n let mimeType = file.mimeType ?? \"\"\n let sizeBytes = file?.sizeBytes\n let fileOriginalName = file.originalName;\n\n let outputSizeBytes = sizeBytes // output file size\n let fileCompressFormat = `` // output image compress\n\n const fileCategoryName = getFileCategoryNameByMimeType(mimeType)\n\n // const ext = file.originalName?.split(\".\").pop()?.toLowerCase() ?? \"\";\n\n // Image :: Only compress if image and options provided\n if (fileCategoryName === \"image\" && imageCompressionOptions) {\n const compressed = await compressImageBuffer(\n bufferToUpload,\n mimeType,\n imageCompressionOptions\n );\n\n fileCompressFormat = compressed.compressFormat,\n bufferToUpload = compressed.buffer;\n outputSizeBytes = compressed.sizeBytes; // update the file size\n }\n\n // Vide :: Only compress if video and options provided\n if (fileCategoryName === \"video\" && videoCompressionOptions) {\n const compressed = await compressVideoBuffer(\n bufferToUpload,\n mimeType,\n videoCompressionOptions\n );\n\n fileCompressFormat = compressed.compressFormat,\n bufferToUpload = compressed.buffer;\n outputSizeBytes = compressed.sizeBytes; // update the file size\n }\n\n // generate thumbnail buffer\n const bufferThumbnail = await generateFileThumbnailBuffer(bufferToUpload, mimeType)\n\n // Call the consumer hook, if registered\n if (FileStorageHook.onStartUpload) {\n\n await FileStorageHook.onStartUpload(buildFeatureCallbackProps({\n defaultServiceProps: rest,\n callbackParams: {\n fieldRef: field_ref,\n fieldModule: field_module,\n tagName,\n label,\n refId,\n refId2,\n refLabel,\n refLabel2,\n remark,\n description,\n foldernameDate,\n file,\n storageProviderName,\n storageProviderOptions,\n fileCategoryName,\n batchCode,\n mimeType,\n bufferFilebuffer: bufferToUpload,\n bufferFileThumbnail: bufferThumbnail?.buffer,\n outputSizeBytes,\n fileCompressFormat: fileCompressFormat ? JSON.parse(fileCompressFormat) : \"\",\n imageCompressionOptions,\n videoCompressionOptions\n }\n }))\n }\n\n // upload using the provider - buffer\n const uploadResult = await provider.uploadFile({\n field_ref,\n field_module,\n buffer: bufferToUpload,\n bufferThumbnail: bufferThumbnail.buffer,\n thumbnailOptions,\n ...(foldernameDate ? { foldernameDate } : {}),\n mimeType,\n fileName: fileOriginalName\n } as FileModuleRef & (\n FileLocalUploadFileProps |\n FileGoogleCloudUploadFileProps |\n FileAwsS3UploadFileProps\n ));\n\n const fieldRef = field_ref\n const fieldModule = field_module\n\n const fileName = uploadResult?.filename ?? \"\"\n const contentType = mimeType ?? \"\"\n const folderPath = uploadResult.assetPath ?? \"\"\n const assetUrl = uploadResult.assetUrl ?? \"\"\n const thumbnailUrl = uploadResult?.thumbnailUrl ?? \"\"\n const assetPath = uploadResult.assetPath ?? \"\"\n\n const fileDurationSeconds = bufferThumbnail?.durationSeconds ?? 0\n\n const inputType = `buffer`\n const inputFileSizeBytes = sizeBytes ?? 0\n const inputFileName = fileOriginalName ?? \"\"\n\n const fileSizeBytes = outputSizeBytes ?? 0\n // const fileCompressFormat = ``\n\n const foldernameDay = uploadResult?.folderName?.day ?? \"\"\n const foldernameMonth = uploadResult?.folderName?.month ?? \"\"\n const foldernameYear = uploadResult?.folderName?.year ?? \"\"\n\n const payload: FileCreateProps = {\n data: {\n fieldRef,\n fieldModule,\n tagName,\n description,\n remark: fileRemark,\n folderPath,\n assetUrl,\n thumbnailUrl,\n assetPath,\n fileLabel,\n fileName,\n fileCategoryName,\n contentType,\n inputType,\n inputFileSizeBytes,\n inputFileName,\n fileSizeBytes,\n fileDurationSeconds,\n fileCompressFormat,\n storageProviderName,\n foldernameDay,\n foldernameMonth,\n foldernameYear,\n batchCode,\n referId1,\n referId2,\n referLabel1,\n referLabel2\n } as FileCreateProps[\"data\"],\n };\n\n let responseFile = await createFile(payload);\n\n // Call the consumer hook, if registered\n if (FileStorageHook.onSuccessUpload) {\n await FileStorageHook.onSuccessUpload(buildFeatureCallbackProps({\n defaultServiceProps: rest,\n callbackParams: {\n fileId: Number(responseFile?.file_id),\n fileThumbnailUrl: thumbnailUrl,\n fileAssetUrl: assetUrl,\n fileDurationSeconds,\n fieldRef: field_ref,\n fieldModule: field_module,\n tagName,\n label,\n refId,\n refId2,\n refLabel,\n refLabel2,\n remark,\n description,\n foldernameDate,\n file,\n storageProviderName,\n storageProviderOptions,\n fileCategoryName,\n batchCode,\n mimeType,\n bufferFilebuffer: bufferToUpload,\n bufferFileThumbnail: bufferThumbnail.buffer,\n outputSizeBytes,\n fileCompressFormat: fileCompressFormat ? JSON.parse(fileCompressFormat) : \"\",\n imageCompressionOptions,\n videoCompressionOptions\n }\n }))\n }\n\n allResponses.push(responseFile)\n }\n\n return allResponses\n\n }\n\n // private\n const createFile = async ({ data }: FileCreateProps) => {\n\n const _data = getCreatePayload(data)\n\n if (!_data) {\n throw new Error(`Invalid create file payload: ${JSON.stringify(_data)}`);\n }\n\n const response = await fileModel.create({ data: _data })\n\n const newFileId = response?.file_id ?? \"\"\n\n return newFileId ? await getFile({ id: Number(newFileId) }) : null\n\n }\n\n const getFile = async ({ id }: FileGetProps) => {\n\n let { data } = await listFiles({\n limit: 1,\n offset: 0,\n filters: [{ field: `${ModelFileFields.file_id}`, operator: \"=\", value: id }],\n sortfield: `${ModelFileFields.file_id}`,\n sortorder: \"ASC\"\n })\n\n return data[0] ?? null;\n\n };\n\n const listFiles = async ({ limit, offset, filters = [], sortfield, sortorder }: FileListProps) => {\n\n let sqlSelect: string[] = []\n let sqlRelation: string[] = []\n let sqlGroupBy: string[] = []\n\n let sqlSelectAgg: string[] = []\n let sqlRelationAgg: string[] = []\n\n sqlSelect = [\n buildSqlSelect(``, mainSqlSelect),\n buildSqlSelect(``, defaultSqlSelect)\n ]\n\n sqlRelation = [\n sqlRelationMaps.creator,\n sqlRelationMaps.updater\n ]\n\n // sqlRelationAgg = []\n\n sqlGroupBy = [\n ...Object.keys(mainSqlSelect),\n ...Object.keys(defaultSqlSelect)\n ]\n\n let filterColumns = {\n ...mainSqlSelect,\n ...defaultSqlSelect\n }\n\n let sqlWhere = [\n `mainfile.isdelete = false`,\n `mainfile.istrash = false`,\n // `LOWER(mainfile.doc_type) = LOWER('${documentTypeKey}')`\n ]\n\n let sqlOrderby = buildSqlOrderBy(sortfield, sortorder)\n let sqlLimitOffset = buildSqlLimitOffset(limit, offset)\n\n // get the listing data & count\n const { data, total } = await getListWithCount({\n model: fileModel,\n tableName: \"files\",\n mainAlias: \"mainfile\",\n countKey: `${ModelFileFields.file_id}`,\n accountId: rest.accountId,\n sqlRelationMaps,\n filters,\n filterColumns,\n sqlSelect,\n sqlSelectAgg,\n sqlRelation,\n sqlRelationAgg,\n sqlWhere,\n sqlGroupBy,\n sqlOrderby,\n sqlLimitOffset\n })\n\n const response = {\n data,\n total\n }\n\n return response\n\n };\n\n const removeFiles = async ({ fileIds, storageSetup }: FileRemoveProps) => {\n\n const {\n // storageProviderName,\n storageProviderOptions\n } = await getStorageSetup(storageSetup)\n\n if (!fileIds.length) throwError('fileIds is required');\n\n const filesToDelete = await fileModel.list({\n where: {\n file_id: { in: fileIds }\n }\n });\n\n // console.log('filesToDelete', filesToDelete)\n\n let providerResponse: any[] = []\n\n // 2️⃣ Delete the physical files\n for (const file of filesToDelete) {\n\n // check the provider to choose delete method\n const storageProviderName = file.storage_provider_name as FileStorageProviderType\n const assetUrl = file.asset_url\n const thumbnailUrl = file.thumbnail_url ?? \"\"\n const assetPath = file.asset_path\n\n if (storageProviderName === \"local\" && assetPath) {\n\n try {\n providerResponse.push(\n await fileLocalStorageProvider.removeFile(assetPath, thumbnailOptions)\n )\n } catch (err) {\n providerResponse.push(\n `Failed to delete from Local: ${assetUrl}`\n )\n }\n\n }\n\n if (storageProviderName === \"gcloud\" && assetUrl) {\n\n try {\n providerResponse.push(\n await fileGoogleCloudStorageProvider.removeFile(assetUrl, thumbnailUrl, storageProviderOptions.credentials as any)\n )\n } catch (err) {\n providerResponse.push(\n `Failed to delete from GCloud: ${assetUrl}`\n )\n }\n\n }\n\n if (storageProviderName === \"aws\" && assetUrl) {\n\n try {\n providerResponse.push(\n await fileAwsS3StorageProvider.removeFile(assetUrl, thumbnailUrl)\n )\n } catch (err) {\n providerResponse.push(\n `Failed to delete from Aws S3: ${assetUrl}`\n )\n }\n\n }\n\n }\n\n // remove files\n const response = await fileModel.remove({ where: { [`${ModelFileFields.file_id}`]: { in: fileIds } } });\n\n return {\n files: response,\n providerResponse\n }\n };\n\n const getFileUsageSummary = async ({ accountId = 0 }: FileGetUsageSummaryProps) => {\n\n const summaryCount = await fileModel.aggregate({\n field: `file_id`,\n operation: `count`,\n where: {\n [`${ModelFileFields.accountid}`]: accountId,\n [`${ModelFileFields.istrash}`]: false,\n [`${ModelFileFields.isdelete}`]: false,\n }\n });\n\n const summarySize = await fileModel.aggregate({\n field: `file_size_bytes`,\n operation: `sum`,\n where: {\n [`${ModelFileFields.accountid}`]: accountId,\n [`${ModelFileFields.istrash}`]: false,\n [`${ModelFileFields.isdelete}`]: false,\n }\n });\n\n const totalFiles = summaryCount ?? 0;\n const totalBytes = summarySize ?? 0;\n // const totalFiles = summary._count.id;\n\n // Optional: convert bytes to MB or GB\n const totalMB = totalBytes / (1024 * 1024);\n const totalGB = totalBytes / (1024 * 1024 * 1024);\n\n return {\n totalFiles,\n totalBytes,\n totalMB: parseFloat(totalMB.toFixed(2)), // now decimal\n totalGB: parseFloat(totalGB.toFixed(2)), // now decimal\n };\n }\n\n // const getDataTypes = () => {\n // return Object.values(fileDataTypes);\n // }\n\n return {\n uploadFiles,\n // createFile,\n // updateFile,\n getFile,\n listFiles,\n removeFiles,\n // getDataTypes,\n getFileUsageSummary\n }\n\n}\n\n"]}
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.SmtpEmailService = void 0;
7
+ const utils_1 = require("../../utils");
7
8
  // import { QueryList, QueryGet } from "../../schema/common";
8
9
  // import { buildSqlRelation, buildSqlRawSelect, buildSqlWhere, buildSqlSelect, buildSqlLimitOffset, buildSqlOrderBy } from "../../lib";
9
10
  const features_1 = require("../../features");
@@ -99,13 +100,13 @@ const SmtpEmailService = (props) => {
99
100
  try {
100
101
  // Call the consumer hook, if registered
101
102
  if (features_1.SmtpEmailHook.onStartSend) {
102
- await features_1.SmtpEmailHook.onStartSend({
103
+ await features_1.SmtpEmailHook.onStartSend((0, utils_1.buildFeatureCallbackProps)({
103
104
  defaultServiceProps: rest,
104
105
  callbackParams: {
105
106
  transporterOptions,
106
107
  smtpEmailOptions: hookSetup
107
108
  }
108
- });
109
+ }));
109
110
  }
110
111
  const info = await transporter.sendMail({
111
112
  ...transporterOptions,
@@ -124,7 +125,7 @@ const SmtpEmailService = (props) => {
124
125
  };
125
126
  // Call the consumer hook, if registered
126
127
  if (features_1.SmtpEmailHook.onSuccessSend) {
127
- const responseCustomHook = await features_1.SmtpEmailHook.onSuccessSend({
128
+ const responseCustomHook = await features_1.SmtpEmailHook.onSuccessSend((0, utils_1.buildFeatureCallbackProps)({
128
129
  defaultServiceProps: rest,
129
130
  callbackParams: {
130
131
  transporterOptions,
@@ -132,7 +133,7 @@ const SmtpEmailService = (props) => {
132
133
  previewMessageUrl, // only if the test account smtp
133
134
  gatewayDetails: info
134
135
  }
135
- });
136
+ }));
136
137
  response = { ...response, custom: responseCustomHook };
137
138
  }
138
139
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SmtpEmailService.js","sourceRoot":"","sources":["../../../src/services/gateway/SmtpEmailService.ts"],"names":[],"mappings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A;YAE1D,CAAC;QAEL,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YAElB,QAAQ,GAAG;gBACP,GAAG,QAAQ;gBACX,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,KAAK,CAAC,IAAI,IAAI,eAAe;gBACpC,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,cAAc,EAAE,KAAK;aACxB,CAAA;QACL,CAAC;QAED,OAAO,QAAQ,CAAA;IACnB,CAAC,CAAA;IAED,MAAM,wBAAwB,GAAG,KAAK,IAAI,EAAE;QAExC,MAAM,WAAW,GAAG,MAAM,cAAc,EAAE,CAAA,CAAE,wBAAwB;QAEpE,IAAI,cAAc,GAAY,KAAK,CAAA;QACnC,IAAI,eAAe,GAAW,EAAE,CAAA;QAEhC,IAAI,CAAC;YACD,MAAM,WAAW,CAAC,MAAM,EAAE,CAAC;YAC3B,cAAc,GAAG,IAAI,CAAA;YACrB,eAAe,GAAG,0BAA0B,CAAA;QAEhD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,0DAA0D;YAC1D,cAAc,GAAG,IAAI,CAAA;YACrB,eAAe,GAAG,kCAAkC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAA;QAC/E,CAAC;QAED,OAAO;YACH,MAAM,EAAE,cAAc;YACtB,OAAO,EAAE,eAAe;SAC3B,CAAA;IAEL,CAAC,CAAC;IAEF,OAAO;QACH,SAAS;QACT,wBAAwB;KAC3B,CAAA;AAEL,CAAC,CAAA;AA3NY,QAAA,gBAAgB,oBA2N5B","sourcesContent":["import { DefaultServiceProps, throwError } from \"@/utils\";\n\n// import { QueryList, QueryGet } from \"@/schema/common\";\n\n// import { buildSqlRelation, buildSqlRawSelect, buildSqlWhere, buildSqlSelect, buildSqlLimitOffset, buildSqlOrderBy } from \"@/lib\";\n\nimport { SmtpEmailHook, FeatureSmtpEmailOptions, FeatureSmtpEmailHbsOptions } from \"@/features\"\n\nimport nodemailer, { Transporter, SendMailOptions } from \"nodemailer\"\nimport hbs from \"nodemailer-express-handlebars\";\n\nexport type SmtpEmailServiceProps = DefaultServiceProps & {\n};\n\nexport type SmtpEmailTransporterOptions = SendMailOptions & {\n template?: string;\n context?: Record<string, any>;\n};\n\n// export type SmtpEmailTransporterOptions = {\n// to: string | string[];\n// from?: string;\n// subject: string;\n// text?: string;\n// html?: string;\n// cc?: string | string[];\n// bcc?: string | string[];\n// }\n\nexport type SmtpEmailSendProps = {\n transporterOptions: SmtpEmailTransporterOptions\n overrideTemplate?: string\n overrideContext?: Record<string, any>\n // hbsOptions: FeatureSmtpEmailHbsOptions\n // hbsTemplate?: string\n // hbsContext?: Record<string, any>\n}\n\nexport const SmtpEmailService = (props: SmtpEmailServiceProps) => {\n\n const {\n ...rest\n } = props\n\n // Lazy init storage\n let nodeMailerTransporter: Transporter | null = null\n let hookSetup: FeatureSmtpEmailOptions | null = null\n let hbsRegistered: boolean = false\n\n const validateHookSetup = (hookSetup: FeatureSmtpEmailOptions | null) => {\n\n if (!hookSetup) {\n throw new Error(\"SmtpEmailHook.onSetup() returned null or undefined\");\n }\n\n const { smtpHost, smtpPort, smtpSecure, smtpCredential, connectionTimeout, hbsOptions } = hookSetup;\n\n if (!smtpHost || typeof smtpHost !== \"string\") {\n throw new Error(\"smtpHost is required and must be a string\");\n }\n\n if (!smtpPort || typeof smtpPort !== \"number\") {\n throw new Error(\"smtpPort is required and must be a number\");\n }\n\n if (typeof smtpSecure !== \"boolean\") {\n throw new Error(\"smtpSecure is required and must be boolean\");\n }\n\n if (!smtpCredential || !smtpCredential.username || !smtpCredential.password) {\n throw new Error(\"smtpCredential with username and password is required\");\n }\n\n if (!connectionTimeout || typeof connectionTimeout !== \"number\") {\n throw new Error(\"connectionTimeout is required and must be a number\");\n }\n\n if (!hbsOptions || typeof hbsOptions !== \"object\") {\n throw new Error(\"hbsOptions is required and must be an object\");\n }\n\n return true;\n };\n\n function validateHbsOptions(hbsOptions: FeatureSmtpEmailHbsOptions) {\n\n if (!hbsOptions) throw new Error(\"HBS options are required\");\n\n const { viewEngine, viewPath, extName } = hbsOptions;\n\n if (!viewEngine || typeof viewEngine !== \"object\") {\n throw new Error(\"hbsOptions.viewEngine is required\");\n }\n\n if (!viewEngine.extname || typeof viewEngine.extname !== \"string\") {\n throw new Error(\"hbsOptions.viewEngine.extname is required and must be a string\");\n }\n\n if (!viewEngine.layoutsDir || typeof viewEngine.layoutsDir !== \"string\") {\n throw new Error(\"hbsOptions.viewEngine.layoutsDir is required and must be a string\");\n }\n\n if (viewEngine.defaultLayout !== undefined &&\n viewEngine.defaultLayout !== false &&\n typeof viewEngine.defaultLayout !== \"string\") {\n throw new Error(\"hbsOptions.viewEngine.defaultLayout must be string or false\");\n }\n\n if (!viewPath || typeof viewPath !== \"string\") {\n throw new Error(\"hbsOptions.viewPath is required and must be a string\");\n }\n\n if (!extName || typeof extName !== \"string\") {\n throw new Error(\"hbsOptions.extName is required and must be a string\");\n }\n }\n\n // Lazy getTransporter function\n const getTransporter = async () => {\n\n if (!nodeMailerTransporter) {\n\n hookSetup = await SmtpEmailHook.onSetup()\n\n // validate the setup configurations\n validateHookSetup(hookSetup); // validate smtp\n validateHbsOptions(hookSetup?.hbsOptions) // validate hbs options\n\n // if (!hookSetup) {\n // throw new Error(\"SmtpEmailHook.onSetup() must return FeatureSmtpEmailOptions\");\n // }\n\n nodeMailerTransporter = nodemailer.createTransport({\n host: hookSetup.smtpHost,\n port: Number(hookSetup.smtpPort),\n secure: Boolean(hookSetup.smtpSecure),\n auth: {\n user: hookSetup.smtpCredential.username,\n pass: hookSetup.smtpCredential.password\n },\n connectionTimeout: hookSetup.connectionTimeout,\n })\n\n if (hookSetup?.hbsOptions && !hbsRegistered) {\n nodeMailerTransporter.use(\"compile\", hbs(hookSetup.hbsOptions));\n hbsRegistered = true\n }\n\n }\n\n return nodeMailerTransporter\n\n }\n\n const sendEmail = async ({\n transporterOptions,\n overrideTemplate = '',\n overrideContext = {}\n }: SmtpEmailSendProps) => {\n\n // get the onSetup from hook\n const transporter = await getTransporter() // only initializes once\n\n let response = {}\n\n try {\n\n // Call the consumer hook, if registered\n if (SmtpEmailHook.onStartSend) {\n await SmtpEmailHook.onStartSend({\n defaultServiceProps: rest,\n callbackParams: {\n transporterOptions,\n smtpEmailOptions: hookSetup!\n }\n })\n }\n\n const info = await transporter.sendMail({\n ...transporterOptions,\n ...(overrideTemplate ? { template: overrideTemplate } : {}),\n ...(overrideContext ? { context: overrideContext } : {})\n });\n\n // If using a test account\n let previewMessageUrl = nodemailer.getTestMessageUrl(info);\n\n response = {\n ...response,\n success: true,\n messageId: info.messageId,\n accepted: info.accepted,\n previewMessageUrl,\n gatewayDetails: info\n }\n\n // Call the consumer hook, if registered\n if (SmtpEmailHook.onSuccessSend) {\n\n const responseCustomHook = await SmtpEmailHook.onSuccessSend({\n defaultServiceProps: rest,\n callbackParams: {\n transporterOptions,\n smtpEmailOptions: hookSetup!,\n previewMessageUrl, // only if the test account smtp\n gatewayDetails: info\n }\n })\n\n response = { ...response, custom: responseCustomHook }\n\n }\n\n } catch (error: any) {\n\n response = {\n ...response,\n success: false,\n error: error.code || \"UNKNOWN_ERROR\",\n message: error.message,\n gatewayDetails: error\n }\n }\n\n return response\n }\n\n const validateSmtpEmailOptions = async () => {\n\n const transporter = await getTransporter() // only initializes once\n\n let responseStatus: boolean = false\n let responseMessage: string = ``\n\n try {\n await transporter.verify();\n responseStatus = true\n responseMessage = `Valid smtp email options`\n\n } catch (error) {\n // console.error(\"SMTP Connection verify failed:\", error);\n responseStatus = true\n responseMessage = `Smtp connection verify failed: ${JSON.stringify(error)}`\n }\n\n return {\n status: responseStatus,\n message: responseMessage\n }\n\n };\n\n return {\n sendEmail,\n validateSmtpEmailOptions\n }\n\n}\n\n"]}
1
+ {"version":3,"file":"SmtpEmailService.js","sourceRoot":"","sources":["../../../src/services/gateway/SmtpEmailService.ts"],"names":[],"mappings":";;;;;;AAAA,mCAAqF;AAErF,yDAAyD;AAEzD,oIAAoI;AAE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EAAE,CAAA;YAE1D,CAAC;QAEL,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YAElB,QAAQ,GAAG;gBACP,GAAG,QAAQ;gBACX,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,KAAK,CAAC,IAAI,IAAI,eAAe;gBACpC,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,cAAc,EAAE,KAAK;aACxB,CAAA;QACL,CAAC;QAED,OAAO,QAAQ,CAAA;IACnB,CAAC,CAAA;IAED,MAAM,wBAAwB,GAAG,KAAK,IAAI,EAAE;QAExC,MAAM,WAAW,GAAG,MAAM,cAAc,EAAE,CAAA,CAAE,wBAAwB;QAEpE,IAAI,cAAc,GAAY,KAAK,CAAA;QACnC,IAAI,eAAe,GAAW,EAAE,CAAA;QAEhC,IAAI,CAAC;YACD,MAAM,WAAW,CAAC,MAAM,EAAE,CAAC;YAC3B,cAAc,GAAG,IAAI,CAAA;YACrB,eAAe,GAAG,0BAA0B,CAAA;QAEhD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,0DAA0D;YAC1D,cAAc,GAAG,IAAI,CAAA;YACrB,eAAe,GAAG,kCAAkC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAA;QAC/E,CAAC;QAED,OAAO;YACH,MAAM,EAAE,cAAc;YACtB,OAAO,EAAE,eAAe;SAC3B,CAAA;IAEL,CAAC,CAAC;IAEF,OAAO;QACH,SAAS;QACT,wBAAwB;KAC3B,CAAA;AAEL,CAAC,CAAA;AA3NY,QAAA,gBAAgB,oBA2N5B","sourcesContent":["import { buildFeatureCallbackProps, DefaultServiceProps, throwError } from \"@/utils\";\n\n// import { QueryList, QueryGet } from \"@/schema/common\";\n\n// import { buildSqlRelation, buildSqlRawSelect, buildSqlWhere, buildSqlSelect, buildSqlLimitOffset, buildSqlOrderBy } from \"@/lib\";\n\nimport { SmtpEmailHook, FeatureSmtpEmailOptions, FeatureSmtpEmailHbsOptions } from \"@/features\"\n\nimport nodemailer, { Transporter, SendMailOptions } from \"nodemailer\"\nimport hbs from \"nodemailer-express-handlebars\";\n\nexport type SmtpEmailServiceProps = DefaultServiceProps & {\n};\n\nexport type SmtpEmailTransporterOptions = SendMailOptions & {\n template?: string;\n context?: Record<string, any>;\n};\n\n// export type SmtpEmailTransporterOptions = {\n// to: string | string[];\n// from?: string;\n// subject: string;\n// text?: string;\n// html?: string;\n// cc?: string | string[];\n// bcc?: string | string[];\n// }\n\nexport type SmtpEmailSendProps = {\n transporterOptions: SmtpEmailTransporterOptions\n overrideTemplate?: string\n overrideContext?: Record<string, any>\n // hbsOptions: FeatureSmtpEmailHbsOptions\n // hbsTemplate?: string\n // hbsContext?: Record<string, any>\n}\n\nexport const SmtpEmailService = (props: SmtpEmailServiceProps) => {\n\n const {\n ...rest\n } = props\n\n // Lazy init storage\n let nodeMailerTransporter: Transporter | null = null\n let hookSetup: FeatureSmtpEmailOptions | null = null\n let hbsRegistered: boolean = false\n\n const validateHookSetup = (hookSetup: FeatureSmtpEmailOptions | null) => {\n\n if (!hookSetup) {\n throw new Error(\"SmtpEmailHook.onSetup() returned null or undefined\");\n }\n\n const { smtpHost, smtpPort, smtpSecure, smtpCredential, connectionTimeout, hbsOptions } = hookSetup;\n\n if (!smtpHost || typeof smtpHost !== \"string\") {\n throw new Error(\"smtpHost is required and must be a string\");\n }\n\n if (!smtpPort || typeof smtpPort !== \"number\") {\n throw new Error(\"smtpPort is required and must be a number\");\n }\n\n if (typeof smtpSecure !== \"boolean\") {\n throw new Error(\"smtpSecure is required and must be boolean\");\n }\n\n if (!smtpCredential || !smtpCredential.username || !smtpCredential.password) {\n throw new Error(\"smtpCredential with username and password is required\");\n }\n\n if (!connectionTimeout || typeof connectionTimeout !== \"number\") {\n throw new Error(\"connectionTimeout is required and must be a number\");\n }\n\n if (!hbsOptions || typeof hbsOptions !== \"object\") {\n throw new Error(\"hbsOptions is required and must be an object\");\n }\n\n return true;\n };\n\n function validateHbsOptions(hbsOptions: FeatureSmtpEmailHbsOptions) {\n\n if (!hbsOptions) throw new Error(\"HBS options are required\");\n\n const { viewEngine, viewPath, extName } = hbsOptions;\n\n if (!viewEngine || typeof viewEngine !== \"object\") {\n throw new Error(\"hbsOptions.viewEngine is required\");\n }\n\n if (!viewEngine.extname || typeof viewEngine.extname !== \"string\") {\n throw new Error(\"hbsOptions.viewEngine.extname is required and must be a string\");\n }\n\n if (!viewEngine.layoutsDir || typeof viewEngine.layoutsDir !== \"string\") {\n throw new Error(\"hbsOptions.viewEngine.layoutsDir is required and must be a string\");\n }\n\n if (viewEngine.defaultLayout !== undefined &&\n viewEngine.defaultLayout !== false &&\n typeof viewEngine.defaultLayout !== \"string\") {\n throw new Error(\"hbsOptions.viewEngine.defaultLayout must be string or false\");\n }\n\n if (!viewPath || typeof viewPath !== \"string\") {\n throw new Error(\"hbsOptions.viewPath is required and must be a string\");\n }\n\n if (!extName || typeof extName !== \"string\") {\n throw new Error(\"hbsOptions.extName is required and must be a string\");\n }\n }\n\n // Lazy getTransporter function\n const getTransporter = async () => {\n\n if (!nodeMailerTransporter) {\n\n hookSetup = await SmtpEmailHook.onSetup()\n\n // validate the setup configurations\n validateHookSetup(hookSetup); // validate smtp\n validateHbsOptions(hookSetup?.hbsOptions) // validate hbs options\n\n // if (!hookSetup) {\n // throw new Error(\"SmtpEmailHook.onSetup() must return FeatureSmtpEmailOptions\");\n // }\n\n nodeMailerTransporter = nodemailer.createTransport({\n host: hookSetup.smtpHost,\n port: Number(hookSetup.smtpPort),\n secure: Boolean(hookSetup.smtpSecure),\n auth: {\n user: hookSetup.smtpCredential.username,\n pass: hookSetup.smtpCredential.password\n },\n connectionTimeout: hookSetup.connectionTimeout,\n })\n\n if (hookSetup?.hbsOptions && !hbsRegistered) {\n nodeMailerTransporter.use(\"compile\", hbs(hookSetup.hbsOptions));\n hbsRegistered = true\n }\n\n }\n\n return nodeMailerTransporter\n\n }\n\n const sendEmail = async ({\n transporterOptions,\n overrideTemplate = '',\n overrideContext = {}\n }: SmtpEmailSendProps) => {\n\n // get the onSetup from hook\n const transporter = await getTransporter() // only initializes once\n\n let response = {}\n\n try {\n\n // Call the consumer hook, if registered\n if (SmtpEmailHook.onStartSend) {\n await SmtpEmailHook.onStartSend(buildFeatureCallbackProps({\n defaultServiceProps: rest,\n callbackParams: {\n transporterOptions,\n smtpEmailOptions: hookSetup!\n }\n }))\n }\n\n const info = await transporter.sendMail({\n ...transporterOptions,\n ...(overrideTemplate ? { template: overrideTemplate } : {}),\n ...(overrideContext ? { context: overrideContext } : {})\n });\n\n // If using a test account\n let previewMessageUrl = nodemailer.getTestMessageUrl(info);\n\n response = {\n ...response,\n success: true,\n messageId: info.messageId,\n accepted: info.accepted,\n previewMessageUrl,\n gatewayDetails: info\n }\n\n // Call the consumer hook, if registered\n if (SmtpEmailHook.onSuccessSend) {\n\n const responseCustomHook = await SmtpEmailHook.onSuccessSend(buildFeatureCallbackProps({\n defaultServiceProps: rest,\n callbackParams: {\n transporterOptions,\n smtpEmailOptions: hookSetup!,\n previewMessageUrl, // only if the test account smtp\n gatewayDetails: info\n }\n }))\n\n response = { ...response, custom: responseCustomHook }\n\n }\n\n } catch (error: any) {\n\n response = {\n ...response,\n success: false,\n error: error.code || \"UNKNOWN_ERROR\",\n message: error.message,\n gatewayDetails: error\n }\n }\n\n return response\n }\n\n const validateSmtpEmailOptions = async () => {\n\n const transporter = await getTransporter() // only initializes once\n\n let responseStatus: boolean = false\n let responseMessage: string = ``\n\n try {\n await transporter.verify();\n responseStatus = true\n responseMessage = `Valid smtp email options`\n\n } catch (error) {\n // console.error(\"SMTP Connection verify failed:\", error);\n responseStatus = true\n responseMessage = `Smtp connection verify failed: ${JSON.stringify(error)}`\n }\n\n return {\n status: responseStatus,\n message: responseMessage\n }\n\n };\n\n return {\n sendEmail,\n validateSmtpEmailOptions\n }\n\n}\n\n"]}
@@ -46,5 +46,7 @@ export { SmtpEmailService } from "../services/gateway/SmtpEmailService";
46
46
  export type { SmtpEmailServiceProps, SmtpEmailSendProps, SmtpEmailTransporterOptions } from "../services/gateway/SmtpEmailService";
47
47
  export { SchedulerLogService, schedulerLogTypes } from "../services/scheduler/SchedulerLogService";
48
48
  export type { SchedulerLogServiceProps, SchedulerLogFlowType, SchedulerLogModuleRef, SchedulerLogRemoveProps, SchedulerLogCreateProps, SchedulerLogListProps, SchedulerLogGetProps } from "../services/scheduler/SchedulerLogService";
49
+ export { SchedulerRequestService } from "../services/scheduler/SchedulerRequestService";
50
+ export type { SchedulerRequestServiceProps, SchedulerRequestModuleRef, SchedulerRequestRemoveProps, SchedulerRequestCreateProps, SchedulerRequestExecuteProps, SchedulerRequestListProps, SchedulerRequestGetProps } from "../services/scheduler/SchedulerRequestService";
49
51
  export { AccessKeyUtilService } from "../services/utils/AccessKeyUtilService";
50
52
  export type { AccessKeyUtilServiceProps, AccessKeyUtilValidateProps, AccessKeyUtilAccountOwnerProps } from "../services/utils/AccessKeyUtilService";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AccessKeyUtilService = exports.schedulerLogTypes = exports.SchedulerLogService = exports.SmtpEmailService = exports.oneTimeCodeStatus = exports.oneTimeCodePurposeTypes = exports.oneTimeCodeTypes = exports.OneTimeCodeService = exports.NumberDateSequenceService = exports.injectionFieldDataTypes = exports.injectionFieldTypes = exports.InjectionFieldService = exports.LocationService = exports.FileService = exports.repositoryTypes = exports.RepositoryService = exports.itemTypes = exports.ItemService = exports.DocumentService = exports.RegionService = exports.userBranchTypes = exports.UserBranchService = exports.AccessControlUserService = exports.AccessControlRoleService = exports.UserMeService = exports.userParentSqlSelect = exports.userTypes = exports.UserService = exports.AccountSubscribeService = exports.subscribePlanBillingCycles = exports.subscribeCurrencies = exports.SubscribePlanService = exports.BusinessService = exports.AccountService = exports.resetPasswordMethods = exports.ResetPasswordService = exports.AccessControlService = exports.accessKeyStatus = exports.accessKeyUserTypes = exports.AccessKeyService = exports.authTypes = exports.AuthService = void 0;
3
+ exports.AccessKeyUtilService = exports.SchedulerRequestService = exports.schedulerLogTypes = exports.SchedulerLogService = exports.SmtpEmailService = exports.oneTimeCodeStatus = exports.oneTimeCodePurposeTypes = exports.oneTimeCodeTypes = exports.OneTimeCodeService = exports.NumberDateSequenceService = exports.injectionFieldDataTypes = exports.injectionFieldTypes = exports.InjectionFieldService = exports.LocationService = exports.FileService = exports.repositoryTypes = exports.RepositoryService = exports.itemTypes = exports.ItemService = exports.DocumentService = exports.RegionService = exports.userBranchTypes = exports.UserBranchService = exports.AccessControlUserService = exports.AccessControlRoleService = exports.UserMeService = exports.userParentSqlSelect = exports.userTypes = exports.UserService = exports.AccountSubscribeService = exports.subscribePlanBillingCycles = exports.subscribeCurrencies = exports.SubscribePlanService = exports.BusinessService = exports.AccountService = exports.resetPasswordMethods = exports.ResetPasswordService = exports.AccessControlService = exports.accessKeyStatus = exports.accessKeyUserTypes = exports.AccessKeyService = exports.authTypes = exports.AuthService = void 0;
4
4
  var AuthService_1 = require("../services/auth/AuthService");
5
5
  Object.defineProperty(exports, "AuthService", { enumerable: true, get: function () { return AuthService_1.AuthService; } });
6
6
  Object.defineProperty(exports, "authTypes", { enumerable: true, get: function () { return AuthService_1.authTypes; } });
@@ -66,6 +66,8 @@ Object.defineProperty(exports, "SmtpEmailService", { enumerable: true, get: func
66
66
  var SchedulerLogService_1 = require("../services/scheduler/SchedulerLogService");
67
67
  Object.defineProperty(exports, "SchedulerLogService", { enumerable: true, get: function () { return SchedulerLogService_1.SchedulerLogService; } });
68
68
  Object.defineProperty(exports, "schedulerLogTypes", { enumerable: true, get: function () { return SchedulerLogService_1.schedulerLogTypes; } });
69
+ var SchedulerRequestService_1 = require("../services/scheduler/SchedulerRequestService");
70
+ Object.defineProperty(exports, "SchedulerRequestService", { enumerable: true, get: function () { return SchedulerRequestService_1.SchedulerRequestService; } });
69
71
  // export { ChangePasswordUtilService } from "../services/utils/unuse/ChangePasswordUtilService"
70
72
  // export type { ChangePasswordUtilServiceProps, ChangePasswordUtilChangeProps } from "../services/utils/unuse/ChangePasswordUtilService"
71
73
  var AccessKeyUtilService_1 = require("../services/utils/AccessKeyUtilService");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;AAAA,2DAAoE;AAA3D,0GAAA,WAAW,OAAA;AAAE,wGAAA,SAAS,OAAA;AAE/B,2EAA8G;AAArG,oHAAA,gBAAgB,OAAA;AAAE,sHAAA,kBAAkB,OAAA;AAAE,mHAAA,eAAe,OAAA;AAE9D,uFAAqF;AAA5E,4HAAA,oBAAoB,OAAA;AAE7B,uFAA2G;AAAlG,4HAAA,oBAAoB,OAAA;AAAE,4HAAA,oBAAoB,OAAA;AAEnD,oEAAkE;AAAzD,gHAAA,cAAc,OAAA;AAEvB,uEAAqE;AAA5D,kHAAA,eAAe,OAAA;AAGxB,0FAAyI;AAAhI,4HAAA,oBAAoB,OAAA;AAAE,2HAAA,mBAAmB,OAAA;AAAE,kIAAA,0BAA0B,OAAA;AAE9E,mGAAiG;AAAxF,kIAAA,uBAAuB,OAAA;AAGhC,2DAAyF;AAAhF,0GAAA,WAAW,OAAA;AAAE,wGAAA,SAAS,OAAA;AAAE,kHAAA,mBAAmB,OAAA;AAGpD,+DAA6D;AAApD,8GAAA,aAAa,OAAA;AAGtB,+FAA6F;AAApF,oIAAA,wBAAwB,OAAA;AAGjC,+FAA6F;AAApF,oIAAA,wBAAwB,OAAA;AAGjC,yEAAwF;AAA/E,sHAAA,iBAAiB,OAAA;AAAE,oHAAA,eAAe,OAAA;AAE3C,iEAA+D;AAAtD,8GAAA,aAAa,OAAA;AAEtB,uEAAqE;AAA5D,kHAAA,eAAe,OAAA;AAExB,2DAAoE;AAA3D,0GAAA,WAAW,OAAA;AAAE,wGAAA,SAAS,OAAA;AAE/B,6EAA4F;AAAnF,sHAAA,iBAAiB,OAAA;AAAE,oHAAA,eAAe,OAAA;AAE3C,2DAAyD;AAAhD,0GAAA,WAAW,OAAA;AAEpB,uEAAqE;AAA5D,kHAAA,eAAe,OAAA;AAExB,0FAAsI;AAA7H,8HAAA,qBAAqB,OAAA;AAAE,4HAAA,mBAAmB,OAAA;AAAE,gIAAA,uBAAuB,OAAA;AAE5E,yFAAuF;AAA9E,sIAAA,yBAAyB,OAAA;AAElC,kFAA8I;AAArI,wHAAA,kBAAkB,OAAA;AAAE,sHAAA,gBAAgB,OAAA;AAAE,6HAAA,uBAAuB,OAAA;AAAE,uHAAA,iBAAiB,OAAA;AAEzF,wEAAsE;AAA7D,oHAAA,gBAAgB,OAAA;AAGzB,gFAAiG;AAAxF,0HAAA,mBAAmB,OAAA;AAAE,wHAAA,iBAAiB,OAAA;AAG/C,+FAA+F;AAC/F,wIAAwI;AACxI,8EAA4E;AAAnE,4HAAA,oBAAoB,OAAA","sourcesContent":["export { AuthService, authTypes } from \"@/services/auth/AuthService\"\nexport type { AuthServiceProps, AuthType, AuthTokenResult, AuthJwtToken, AuthGetTokenProps } from \"@/services/auth/AuthService\"\nexport { AccessKeyService, accessKeyUserTypes, accessKeyStatus } from \"@/services/access_key/AccessKeyService\"\nexport type { AccessKeyServiceProps, AccessKeyStatus, AccessKeyUserType, AccessKeyCreateProps, AccessKeyRevokeProps } from \"@/services/access_key/AccessKeyService\"\nexport { AccessControlService } from \"@/services/access_control/AccessControlService\"\nexport type { AccessControlServiceProps, AccessControlScopeOrExtra, AccessControlListOptionsProps } from \"@/services/access_control/AccessControlService\"\nexport { ResetPasswordService, resetPasswordMethods } from \"@/services/reset_password/ResetPasswordService\"\nexport type { ResetPasswordServiceProps, ResetPasswordMethod, ResetPasswordRequestProps, ResetPasswordValidateCodeProps, ResetPasswordPerformProps } from \"@/services/reset_password/ResetPasswordService\"\nexport { AccountService } from \"@/services/account/AccountService\"\nexport type { AccountServiceProps, Account, AccountGetProps, AccountListProps, AccountCreateProps, AccountUpdateProps, AccountRemoveProps } from \"@/services/account/AccountService\"\nexport { BusinessService } from \"@/services/business/BusinessService\"\nexport type { BusinessServiceProps, Business, BusinessGetProps, BusinessListProps, BusinessCreateProps, BusinessUpdateProps } from \"@/services/business/BusinessService\"\n\nexport { SubscribePlanService, subscribeCurrencies, subscribePlanBillingCycles } from \"@/services/subscription/plan/SubscribePlanService\"\nexport type { SubscribePlanServiceProps, SubscribePlan, SubscribePlanBillingCycle, SubscribePlanCurrency, SubscribePlanGetProps, SubscribePlanListProps, SubscribePlanCreateProps, SubscribePlanUpdateProps } from \"@/services/subscription/plan/SubscribePlanService\"\nexport { AccountSubscribeService } from \"@/services/subscription/account/AccountSubscribeService\"\nexport type { AccountSubscribeServiceProps, AccountSubscribe, AccountSubscribeGetProps, AccountSubscribeListProps, AccountSubscribeCreateProps, AccountSubscribeCancelProps } from \"@/services/subscription/account/AccountSubscribeService\"\n\nexport { UserService, userTypes, userParentSqlSelect } from \"@/services/user/UserService\"\nexport type { UserServiceProps, UserType, UserGetProps, UserListProps, UserCreateProps, UserUpdateProps, UserRemoveProps, UserReplacePasswordProps } from \"@/services/user/UserService\"\n\nexport { UserMeService } from \"@/services/user/UserMeService\"\nexport type { UserMeServiceProps, UserMeUpdateProps, UserMeChangePasswordProps } from \"@/services/user/UserMeService\"\n\nexport { AccessControlRoleService } from \"@/services/access_control/AccessControlRoleService\"\nexport type { AccessControlRoleServiceProps, AccessControlRoleUserType, AccessControlRoleGetProps, AccessControlRoleListProps, AccessControlRoleCreateProps, AccessControlRoleUpdateProps, AccessControlRoleRemoveProps } from \"@/services/access_control/AccessControlRoleService\"\n\nexport { AccessControlUserService } from \"@/services/access_control/AccessControlUserService\"\nexport type { AccessControlUserServiceProps, AccessControlUserAssignRolesProps } from \"@/services/access_control/AccessControlUserService\"\n\nexport { UserBranchService, userBranchTypes } from \"@/services/branch/UserBranchService\"\nexport type { UserBranchServiceProps, UserBranchType, UserBranchGetProps, UserBranchListProps, UserBranchCreateProps, UserBranchUpdateProps, UserBranchRemoveProps } from \"@/services/branch/UserBranchService\"\nexport { RegionService } from \"@/services/region/RegionService\"\nexport type { RegionServiceProps, RegionType, RegionGetProps, RegionCreateProps, RegionListProps, RegionUpdateProps, RegionRemoveProps } from \"@/services/region/RegionService\"\nexport { DocumentService } from \"@/services/document/DocumentService\"\nexport type { DocumentServiceProps, DocumentType, DocumentGetProps, DocumentUpdateProps, DocumentCreateProps, DocumentListProps, DocumentRemoveProps } from \"@/services/document/DocumentService\"\nexport { ItemService, itemTypes } from \"@/services/item/ItemService\"\nexport type { ItemServiceProps, ItemType, ItemGetProps, ItemUpdateProps, ItemCreateProps, ItemListProps, ItemRemoveProps } from \"@/services/item/ItemService\"\nexport { RepositoryService, repositoryTypes } from \"@/services/repository/RepositoryService\"\nexport type { RepositoryServiceProps, RepositoryType, RepositoryGetProps, RepositoryUpdateProps, RepositoryCreateProps, RepositoryListProps, RepositoryRemoveProps } from \"@/services/repository/RepositoryService\"\nexport { FileService } from \"@/services/file/FileService\"\nexport type { FileImageCompressionOptions, FileVideoCompressionOptions, FileStorageProviderType, FileLocalProviderOptions, FileGoogleCloudProviderOptions, FileAwsS3ProviderOptions, FileCategoryName, FileUploadItem, FileServiceProps, FileGetProps, FileUploadProps, FileCreateProps, FileListProps, FileRemoveProps } from \"@/services/file/FileService\"\nexport { LocationService } from \"@/services/location/LocationService\"\nexport type { LocationServiceProps, LocationType, LocationGetProps, LocationUpdateProps, LocationCreateProps, LocationListProps, LocationRemoveProps } from \"@/services/location/LocationService\"\nexport { InjectionFieldService, injectionFieldTypes, injectionFieldDataTypes } from \"@/services/injection_field/InjectionFieldService\"\nexport type { InjectionFieldModuleRef, InjectionFieldServiceProps, InjectionFieldType, InjectionFieldDataType, InjectionFieldCreateProps, InjectionFieldListProps, InjectionFieldGetProps, InjectionFieldReplaceProps } from \"@/services/injection_field/InjectionFieldService\"\nexport { NumberDateSequenceService } from \"@/services/others/NumberDateSequenceService\"\nexport type { NumberDateSequenceModuleRef, NumberDateSequenceServiceProps, NumberDateSequenceInitProps, NumberDateSequenceCreateProps } from \"@/services/others/NumberDateSequenceService\"\nexport { OneTimeCodeService, oneTimeCodeTypes, oneTimeCodePurposeTypes, oneTimeCodeStatus } from \"@/services/one_time_code/OneTimeCodeService\"\nexport type { OneTimeCodeModuleRef, OneTimeCodeType, OneTimeCodePurposeType, OneTimeCodeStatus, OneTimeCodeServiceProps, OneTimeCodeCreateProps } from \"@/services/one_time_code/OneTimeCodeService\"\nexport { SmtpEmailService } from \"@/services/gateway/SmtpEmailService\"\nexport type { SmtpEmailServiceProps, SmtpEmailSendProps, SmtpEmailTransporterOptions } from \"@/services/gateway/SmtpEmailService\"\n\nexport { SchedulerLogService, schedulerLogTypes } from \"@/services/scheduler/SchedulerLogService\"\nexport type { SchedulerLogServiceProps, SchedulerLogFlowType, SchedulerLogModuleRef, SchedulerLogRemoveProps, SchedulerLogCreateProps, SchedulerLogListProps, SchedulerLogGetProps } from \"@/services/scheduler/SchedulerLogService\"\n\n// export { ChangePasswordUtilService } from \"@/services/utils/unuse/ChangePasswordUtilService\"\n// export type { ChangePasswordUtilServiceProps, ChangePasswordUtilChangeProps } from \"@/services/utils/unuse/ChangePasswordUtilService\"\nexport { AccessKeyUtilService } from \"@/services/utils/AccessKeyUtilService\"\nexport type { AccessKeyUtilServiceProps, AccessKeyUtilValidateProps, AccessKeyUtilAccountOwnerProps } from \"@/services/utils/AccessKeyUtilService\""]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;AAAA,2DAAoE;AAA3D,0GAAA,WAAW,OAAA;AAAE,wGAAA,SAAS,OAAA;AAE/B,2EAA8G;AAArG,oHAAA,gBAAgB,OAAA;AAAE,sHAAA,kBAAkB,OAAA;AAAE,mHAAA,eAAe,OAAA;AAE9D,uFAAqF;AAA5E,4HAAA,oBAAoB,OAAA;AAE7B,uFAA2G;AAAlG,4HAAA,oBAAoB,OAAA;AAAE,4HAAA,oBAAoB,OAAA;AAEnD,oEAAkE;AAAzD,gHAAA,cAAc,OAAA;AAEvB,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AwI;AACxI,8EAA4E;AAAnE,4HAAA,oBAAoB,OAAA","sourcesContent":["export { AuthService, authTypes } from \"@/services/auth/AuthService\"\nexport type { AuthServiceProps, AuthType, AuthTokenResult, AuthJwtToken, AuthGetTokenProps } from \"@/services/auth/AuthService\"\nexport { AccessKeyService, accessKeyUserTypes, accessKeyStatus } from \"@/services/access_key/AccessKeyService\"\nexport type { AccessKeyServiceProps, AccessKeyStatus, AccessKeyUserType, AccessKeyCreateProps, AccessKeyRevokeProps } from \"@/services/access_key/AccessKeyService\"\nexport { AccessControlService } from \"@/services/access_control/AccessControlService\"\nexport type { AccessControlServiceProps, AccessControlScopeOrExtra, AccessControlListOptionsProps } from \"@/services/access_control/AccessControlService\"\nexport { ResetPasswordService, resetPasswordMethods } from \"@/services/reset_password/ResetPasswordService\"\nexport type { ResetPasswordServiceProps, ResetPasswordMethod, ResetPasswordRequestProps, ResetPasswordValidateCodeProps, ResetPasswordPerformProps } from \"@/services/reset_password/ResetPasswordService\"\nexport { AccountService } from \"@/services/account/AccountService\"\nexport type { AccountServiceProps, Account, AccountGetProps, AccountListProps, AccountCreateProps, AccountUpdateProps, AccountRemoveProps } from \"@/services/account/AccountService\"\nexport { BusinessService } from \"@/services/business/BusinessService\"\nexport type { BusinessServiceProps, Business, BusinessGetProps, BusinessListProps, BusinessCreateProps, BusinessUpdateProps } from \"@/services/business/BusinessService\"\n\nexport { SubscribePlanService, subscribeCurrencies, subscribePlanBillingCycles } from \"@/services/subscription/plan/SubscribePlanService\"\nexport type { SubscribePlanServiceProps, SubscribePlan, SubscribePlanBillingCycle, SubscribePlanCurrency, SubscribePlanGetProps, SubscribePlanListProps, SubscribePlanCreateProps, SubscribePlanUpdateProps } from \"@/services/subscription/plan/SubscribePlanService\"\nexport { AccountSubscribeService } from \"@/services/subscription/account/AccountSubscribeService\"\nexport type { AccountSubscribeServiceProps, AccountSubscribe, AccountSubscribeGetProps, AccountSubscribeListProps, AccountSubscribeCreateProps, AccountSubscribeCancelProps } from \"@/services/subscription/account/AccountSubscribeService\"\n\nexport { UserService, userTypes, userParentSqlSelect } from \"@/services/user/UserService\"\nexport type { UserServiceProps, UserType, UserGetProps, UserListProps, UserCreateProps, UserUpdateProps, UserRemoveProps, UserReplacePasswordProps } from \"@/services/user/UserService\"\n\nexport { UserMeService } from \"@/services/user/UserMeService\"\nexport type { UserMeServiceProps, UserMeUpdateProps, UserMeChangePasswordProps } from \"@/services/user/UserMeService\"\n\nexport { AccessControlRoleService } from \"@/services/access_control/AccessControlRoleService\"\nexport type { AccessControlRoleServiceProps, AccessControlRoleUserType, AccessControlRoleGetProps, AccessControlRoleListProps, AccessControlRoleCreateProps, AccessControlRoleUpdateProps, AccessControlRoleRemoveProps } from \"@/services/access_control/AccessControlRoleService\"\n\nexport { AccessControlUserService } from \"@/services/access_control/AccessControlUserService\"\nexport type { AccessControlUserServiceProps, AccessControlUserAssignRolesProps } from \"@/services/access_control/AccessControlUserService\"\n\nexport { UserBranchService, userBranchTypes } from \"@/services/branch/UserBranchService\"\nexport type { UserBranchServiceProps, UserBranchType, UserBranchGetProps, UserBranchListProps, UserBranchCreateProps, UserBranchUpdateProps, UserBranchRemoveProps } from \"@/services/branch/UserBranchService\"\nexport { RegionService } from \"@/services/region/RegionService\"\nexport type { RegionServiceProps, RegionType, RegionGetProps, RegionCreateProps, RegionListProps, RegionUpdateProps, RegionRemoveProps } from \"@/services/region/RegionService\"\nexport { DocumentService } from \"@/services/document/DocumentService\"\nexport type { DocumentServiceProps, DocumentType, DocumentGetProps, DocumentUpdateProps, DocumentCreateProps, DocumentListProps, DocumentRemoveProps } from \"@/services/document/DocumentService\"\nexport { ItemService, itemTypes } from \"@/services/item/ItemService\"\nexport type { ItemServiceProps, ItemType, ItemGetProps, ItemUpdateProps, ItemCreateProps, ItemListProps, ItemRemoveProps } from \"@/services/item/ItemService\"\nexport { RepositoryService, repositoryTypes } from \"@/services/repository/RepositoryService\"\nexport type { RepositoryServiceProps, RepositoryType, RepositoryGetProps, RepositoryUpdateProps, RepositoryCreateProps, RepositoryListProps, RepositoryRemoveProps } from \"@/services/repository/RepositoryService\"\nexport { FileService } from \"@/services/file/FileService\"\nexport type { FileImageCompressionOptions, FileVideoCompressionOptions, FileStorageProviderType, FileLocalProviderOptions, FileGoogleCloudProviderOptions, FileAwsS3ProviderOptions, FileCategoryName, FileUploadItem, FileServiceProps, FileGetProps, FileUploadProps, FileCreateProps, FileListProps, FileRemoveProps } from \"@/services/file/FileService\"\nexport { LocationService } from \"@/services/location/LocationService\"\nexport type { LocationServiceProps, LocationType, LocationGetProps, LocationUpdateProps, LocationCreateProps, LocationListProps, LocationRemoveProps } from \"@/services/location/LocationService\"\nexport { InjectionFieldService, injectionFieldTypes, injectionFieldDataTypes } from \"@/services/injection_field/InjectionFieldService\"\nexport type { InjectionFieldModuleRef, InjectionFieldServiceProps, InjectionFieldType, InjectionFieldDataType, InjectionFieldCreateProps, InjectionFieldListProps, InjectionFieldGetProps, InjectionFieldReplaceProps } from \"@/services/injection_field/InjectionFieldService\"\nexport { NumberDateSequenceService } from \"@/services/others/NumberDateSequenceService\"\nexport type { NumberDateSequenceModuleRef, NumberDateSequenceServiceProps, NumberDateSequenceInitProps, NumberDateSequenceCreateProps } from \"@/services/others/NumberDateSequenceService\"\nexport { OneTimeCodeService, oneTimeCodeTypes, oneTimeCodePurposeTypes, oneTimeCodeStatus } from \"@/services/one_time_code/OneTimeCodeService\"\nexport type { OneTimeCodeModuleRef, OneTimeCodeType, OneTimeCodePurposeType, OneTimeCodeStatus, OneTimeCodeServiceProps, OneTimeCodeCreateProps } from \"@/services/one_time_code/OneTimeCodeService\"\nexport { SmtpEmailService } from \"@/services/gateway/SmtpEmailService\"\nexport type { SmtpEmailServiceProps, SmtpEmailSendProps, SmtpEmailTransporterOptions } from \"@/services/gateway/SmtpEmailService\"\n\nexport { SchedulerLogService, schedulerLogTypes } from \"@/services/scheduler/SchedulerLogService\"\nexport type { SchedulerLogServiceProps, SchedulerLogFlowType, SchedulerLogModuleRef, SchedulerLogRemoveProps, SchedulerLogCreateProps, SchedulerLogListProps, SchedulerLogGetProps } from \"@/services/scheduler/SchedulerLogService\"\nexport { SchedulerRequestService } from \"@/services/scheduler/SchedulerRequestService\"\nexport type { SchedulerRequestServiceProps, SchedulerRequestModuleRef, SchedulerRequestRemoveProps, SchedulerRequestCreateProps, SchedulerRequestExecuteProps, SchedulerRequestListProps, SchedulerRequestGetProps } from \"@/services/scheduler/SchedulerRequestService\"\n\n// export { ChangePasswordUtilService } from \"@/services/utils/unuse/ChangePasswordUtilService\"\n// export type { ChangePasswordUtilServiceProps, ChangePasswordUtilChangeProps } from \"@/services/utils/unuse/ChangePasswordUtilService\"\nexport { AccessKeyUtilService } from \"@/services/utils/AccessKeyUtilService\"\nexport type { AccessKeyUtilServiceProps, AccessKeyUtilValidateProps, AccessKeyUtilAccountOwnerProps } from \"@/services/utils/AccessKeyUtilService\""]}
@@ -248,7 +248,7 @@ const ResetPasswordService = (props) => {
248
248
  let responseOneTimeCode = await oneTimeCodeService.getOneTimeCode({ id: Number(oneTimeCode?.one_time_code_id ?? 0), datatypes: [] });
249
249
  // Call the consumer hook, if registered
250
250
  if (features_1.ResetPasswordHook.onRequest) {
251
- const responseCustomHook = await features_1.ResetPasswordHook.onRequest({
251
+ const responseCustomHook = await features_1.ResetPasswordHook.onRequest((0, utils_1.buildFeatureCallbackProps)({
252
252
  defaultServiceProps: rest,
253
253
  callbackParams: {
254
254
  userId,
@@ -259,7 +259,7 @@ const ResetPasswordService = (props) => {
259
259
  oneTimeCode: oneTimeCode?.code ?? "",
260
260
  user
261
261
  }
262
- });
262
+ }));
263
263
  responseOneTimeCode = { ...responseOneTimeCode, custom: responseCustomHook };
264
264
  }
265
265
  return responseOneTimeCode;
@@ -415,7 +415,7 @@ const ResetPasswordService = (props) => {
415
415
  });
416
416
  // Call the consumer hook, if registered
417
417
  if (features_1.ResetPasswordHook.onSuccess) {
418
- const responseCustomHook = await features_1.ResetPasswordHook.onSuccess({
418
+ const responseCustomHook = await features_1.ResetPasswordHook.onSuccess((0, utils_1.buildFeatureCallbackProps)({
419
419
  defaultServiceProps: rest,
420
420
  callbackParams: {
421
421
  userId,
@@ -424,7 +424,7 @@ const ResetPasswordService = (props) => {
424
424
  oneTimeCode,
425
425
  user
426
426
  }
427
- });
427
+ }));
428
428
  responseOnSuccess = { ...responseOnSuccess, custom: responseCustomHook };
429
429
  }
430
430
  return {