storemw-core-api 1.0.165 → 1.0.167

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.
@@ -1 +1 @@
1
- {"version":3,"file":"UserMeService.js","sourceRoot":"","sources":["../../../src/services/user/UserMeService.ts"],"names":[],"mappings":";;;AAAA,qCAGkB;AAElB,mCAAuG;AAEvG,+BAAuC;AAEvC,yCAAyD;AAEzD,yCAAkJ;AAElJ,mCAAmD;AAEtC,QAAA,SAAS,GAAG;IACrB,QAAQ,EAAE,UAAU;IACpB,aAAa,EAAE,eAAe;IAC9B,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;CACR,CAAA;AAoBV,mCAAmC;AACnC,0BAA0B;AAC1B,uCAAuC;AACvC,iBAAiB;AACjB,+BAA+B;AAC/B,8BAA8B;AAC9B,QAAQ;AACR,SAAS;AAET,4BAA4B;AAE5B,+GAA+G;AAE/G,mBAAmB;AACnB,8EAA8E;AAC9E,sGAAsG;AACtG,iEAAiE;AACjE,gFAAgF;AAChF,gFAAgF;AAChF,6DAA6D;AAC7D,qEAAqE;AACrE,mEAAmE;AACnE,wEAAwE;AACxE,8DAA8D;AAC9D,YAAY;AACZ,QAAQ;AAER,mBAAmB;AAEnB,IAAI;AAEG,MAAM,aAAa,GAAG,CAAC,KAAyB,EAAE,EAAE;IAEvD,MAAM,EACF,GAAG,IAAI,EACV,GAAG,KAAK,CAAA;IAET,MAAM,QAAQ,GAAG,IAAI,CAAC,cAA0B,CAAA;IAChD,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAA;IAEhC,MAAM,WAAW,GAAG,IAAA,sBAAW,EAAC,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAA;IACtD,MAAM,SAAS,GA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;QACzG,YAAY,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,gBAAgB,EAAE;KACnF,CAAC;IAEF,OAAO,IAAA,oBAAc,EAAC,eAAe,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;AAEhE,CAAC,CAAA;AA9LY,QAAA,aAAa,iBA8LzB","sourcesContent":["import {\n UserModel,\n ModelUserFields\n} from \"@/models\";\n\nimport { verifyPassword, validateLoginPasswordFormat, DefaultServiceProps, throwError } from \"@/utils\";\n\nimport { ServiceFactory } from \"@/lib\";\n\nimport { UserService, AccountService } from \"@/services\";\n\nimport { UserMeHook, FeatureUserMeSuccessUpdateProps, FeatureUserMeSuccessChangePasswordProps, FeatureUserMeSuccessRemoveProps } from \"@/features\"\n\nimport { buildFeatureCallbackProps } from \"@/utils\"\n\nexport const userTypes = {\n operator: \"operator\",\n administrator: \"administrator\",\n worker: \"worker\",\n supplier: \"supplier\",\n customer: \"customer\",\n driver: \"driver\",\n retailer: \"retailer\",\n member: \"member\",\n agent: \"agent\",\n} as const\n\nexport type UserType = typeof userTypes[keyof typeof userTypes]\n\nexport type UserMeServiceProps = DefaultServiceProps & {\n // userType: UserType\n};\n\nexport type UserMeChangePasswordProps = {\n currentPassword: string\n newPassword: string\n confirmPassword: string\n};\n\nexport type UserMeUpdateProps = {\n firstName: string\n lastName: string\n address: string\n};\n\n// const getUpdatePayload = async (\n// userType: UserType,\n// data: UserMeUpdateProps[\"data\"],\n// contact: {\n// countryCode: number,\n// phoneNumber: string\n// }\n// ) => {\n\n// if (\"user\" in data) {\n\n// const newHashPassword = data?.user?.loginPassword ? await hashPassword(data.user.loginPassword) : \"\"\n\n// return {\n// [`${ModelUserFields.login_username}`]: data.user.loginUsername,\n// ...(newHashPassword ? { [`${ModelUserFields.login_password}`]: newHashPassword } : {}),\n// [`${ModelUserFields.address}`]: data.user.address,\n// [`${ModelUserFields.contact_country_code}`]: contact.countryCode,\n// [`${ModelUserFields.contact_phone_number}`]: contact.phoneNumber,\n// [`${ModelUserFields.email}`]: data.user.email,\n// [`${ModelUserFields.firstname}`]: data.user.firstname,\n// [`${ModelUserFields.lastname}`]: data.user.lastname,\n// [`${ModelUserFields.status}`]: Boolean(data.user.status),\n// [`${ModelUserFields.user_type}`]: `${userType}`\n// }\n// }\n\n// return false\n\n// }\n\nexport const UserMeService = (props: UserMeServiceProps) => {\n\n const {\n ...rest\n } = props\n\n const userType = rest.actionUserType as UserType\n const userId = rest.actionUserId\n\n const userService = UserService({ ...rest, userType })\n const userModel = UserModel({ ...rest })\n\n const getUserMe = async () => {\n\n const id = userId\n\n let data = await userService.getUser({ id: userId, datatypes: [] })\n\n // Call the consumer hook, if registered\n if (UserMeHook?.onRequestGetMe) {\n let customData = await UserMeHook.onRequestGetMe(buildFeatureCallbackProps({\n defaultServiceProps: rest,\n callbackParams: {\n userMe: data\n }\n }))\n if (customData) data = customData\n }\n\n return data\n };\n\n const updateUserMe = async ({\n firstName = \"\",\n lastName = \"\",\n address = \"\"\n }: UserMeUpdateProps) => {\n\n const user = await userService.getUser({ id: Number(userId), datatypes: [] })\n\n // console.log('user', user)\n\n // check the userId is valid\n if (!user?.user_id) {\n throwError(`Invalid user id in auth token`)\n }\n\n // Call the consumer hook, if registered\n if (UserMeHook?.onRequestUpdateMe) {\n await UserMeHook.onRequestUpdateMe(buildFeatureCallbackProps({\n defaultServiceProps: rest,\n callbackParams: {\n userMe: user\n }\n }))\n }\n\n // change user information\n await userModel.update({\n id: Number(userId),\n data: {\n [`${ModelUserFields.firstname}`]: firstName,\n [`${ModelUserFields.lastname}`]: lastName,\n [`${ModelUserFields.address}`]: address,\n }\n })\n\n const userMe = await userService.getUser({ id: Number(userId), datatypes: [] })\n\n // Call the consumer hook, if success\n if (UserMeHook?.onSuccessUpdateMe) {\n await UserMeHook.onSuccessUpdateMe(buildFeatureCallbackProps({\n defaultServiceProps: rest,\n callbackParams: {\n userMe\n }\n }))\n }\n\n return userMe\n\n }\n\n const removeUserMe = async () => {\n\n const currentMe = await userService.getUser({ id: Number(userId), datatypes: [] })\n\n const response = await userService.suspendUsers({ ids: [BigInt(userId)] })\n\n // Call the consumer hook, if remove\n if (UserMeHook?.onSuccessRemoveMe) {\n await UserMeHook.onSuccessRemoveMe(buildFeatureCallbackProps({\n defaultServiceProps: rest,\n callbackParams: {\n userMe: currentMe\n }\n }))\n }\n\n return response\n };\n\n const changePasswordUserMe = async ({\n currentPassword,\n confirmPassword,\n newPassword\n }: UserMeChangePasswordProps) => {\n\n const accountId = rest?.accountId ?? 0\n const accountService = AccountService({ ...rest, isOperator: true })\n\n const user = await userService.getUser({ id: Number(userId), datatypes: [], includePassword: true })\n const account = await accountService.getAccount({ id: Number(accountId), datatypes: [] })\n\n // console.log('user', user)\n // console.log('account', account)\n\n // check the accountId / userId is valid\n if (!user?.user_id) {\n throwError(`Invalid user id in auth token`)\n }\n\n if (Object.keys(account).length <= 0) { // must have account id record\n throwError(`Invalid account id in auth token`)\n }\n\n // new password cannot same with current password\n if (newPassword === currentPassword) {\n throwError(`New and current password cannot be same`)\n }\n\n // new password must same with confirm\n if (newPassword !== confirmPassword) {\n throwError(`New and confirm password not matched`)\n }\n\n // validate the login password new format\n validateLoginPasswordFormat(newPassword);\n\n // check the current password\n try {\n const decryptedPass = await verifyPassword(currentPassword, user?.password)\n // console.log('decryptedPass', decryptedPass)\n\n if (!decryptedPass) {\n throw Error(`Invalid current password`)\n }\n\n } catch (error: any) {\n throwError(`Auth Token: ${error?.message}`)\n }\n\n // perform update credential\n const responseUser = await userService.replacePassword({\n id: Number(userId),\n data: {\n unhashLoginPassword: newPassword\n },\n isOperator: Boolean(userType === \"operator\")\n })\n\n // Call the consumer hook, if change password\n if (UserMeHook?.onSuccessChangePasswordMe) {\n\n // remove the password\n delete user.password\n\n await UserMeHook.onSuccessChangePasswordMe({\n defaultServiceProps: rest,\n callbackParams: {\n userMe: user\n }\n })\n }\n\n return responseUser\n\n }\n\n const allowUserTypes = [\"any\"] as const\n\n const methodConfigs = {\n getUserMe: { fn: getUserMe, allowUserTypes, actionName: \"get user/me\" },\n updateUserMe: { fn: updateUserMe, allowUserTypes, actionName: \"update user/me\" },\n changePasswordUserMe: { fn: changePasswordUserMe, allowUserTypes, actionName: \"change password user/me\" },\n removeUserMe: { fn: removeUserMe, allowUserTypes, actionName: \"remove user/me\" },\n };\n\n return ServiceFactory(\"UserMeService\", rest, methodConfigs);\n\n}\n\n"]}
1
+ {"version":3,"file":"UserMeService.js","sourceRoot":"","sources":["../../../src/services/user/UserMeService.ts"],"names":[],"mappings":";;;AAAA,qCAGkB;AAElB,mCAAuG;AAEvG,+BAAuC;AAEvC,yCAAyD;AAEzD,yCAAkJ;AAElJ,mCAAmD;AAEtC,QAAA,SAAS,GAAG;IACrB,QAAQ,EAAE,UAAU;IACpB,aAAa,EAAE,eAAe;IAC9B,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;CACR,CAAA;AAqBV,mCAAmC;AACnC,0BAA0B;AAC1B,uCAAuC;AACvC,iBAAiB;AACjB,+BAA+B;AAC/B,8BAA8B;AAC9B,QAAQ;AACR,SAAS;AAET,4BAA4B;AAE5B,+GAA+G;AAE/G,mBAAmB;AACnB,8EAA8E;AAC9E,sGAAsG;AACtG,iEAAiE;AACjE,gFAAgF;AAChF,gFAAgF;AAChF,6DAA6D;AAC7D,qEAAqE;AACrE,mEAAmE;AACnE,wEAAwE;AACxE,8DAA8D;AAC9D,YAAY;AACZ,QAAQ;AAER,mBAAmB;AAEnB,IAAI;AAEG,MAAM,aAAa,GAAG,CAAC,KAAyB,EAAE,EAAE;IAEvD,MAAM,EACF,GAAG,IAAI,EACV,GAAG,KAAK,CAAA;IAET,MAAM,QAAQ,GAAG,IAAI,CAAC,cAA0B,CAAA;IAChD,MAA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E,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU,EAAE,aAAa,EAAE;QACvE,YAAY,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,gBAAgB,EAAE;QAChF,oBAAoB,EAAE,EAAE,EAAE,EAAE,oBAAoB,EAAE,cAAc,EAAE,UAAU,EAAE,yBAAyB,EAAE;QACzG,YAAY,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE,cAAc,EAAE,UAAU,EAAE,gBAAgB,EAAE;KACnF,CAAC;IAEF,OAAO,IAAA,oBAAc,EAAC,eAAe,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;AAEhE,CAAC,CAAA;AAjMY,QAAA,aAAa,iBAiMzB","sourcesContent":["import {\n UserModel,\n ModelUserFields\n} from \"@/models\";\n\nimport { verifyPassword, validateLoginPasswordFormat, DefaultServiceProps, throwError } from \"@/utils\";\n\nimport { ServiceFactory } from \"@/lib\";\n\nimport { UserService, AccountService } from \"@/services\";\n\nimport { UserMeHook, FeatureUserMeSuccessUpdateProps, FeatureUserMeSuccessChangePasswordProps, FeatureUserMeSuccessRemoveProps } from \"@/features\"\n\nimport { buildFeatureCallbackProps } from \"@/utils\"\n\nexport const userTypes = {\n operator: \"operator\",\n administrator: \"administrator\",\n worker: \"worker\",\n supplier: \"supplier\",\n customer: \"customer\",\n driver: \"driver\",\n retailer: \"retailer\",\n member: \"member\",\n agent: \"agent\",\n} as const\n\nexport type UserType = typeof userTypes[keyof typeof userTypes]\n\nexport type UserMeServiceProps = DefaultServiceProps & {\n // userType: UserType\n};\n\nexport type UserMeChangePasswordProps = {\n currentPassword: string\n newPassword: string\n confirmPassword: string,\n skipLoginPasswordValidation?: boolean\n};\n\nexport type UserMeUpdateProps = {\n firstName: string\n lastName: string\n address: string\n};\n\n// const getUpdatePayload = async (\n// userType: UserType,\n// data: UserMeUpdateProps[\"data\"],\n// contact: {\n// countryCode: number,\n// phoneNumber: string\n// }\n// ) => {\n\n// if (\"user\" in data) {\n\n// const newHashPassword = data?.user?.loginPassword ? await hashPassword(data.user.loginPassword) : \"\"\n\n// return {\n// [`${ModelUserFields.login_username}`]: data.user.loginUsername,\n// ...(newHashPassword ? { [`${ModelUserFields.login_password}`]: newHashPassword } : {}),\n// [`${ModelUserFields.address}`]: data.user.address,\n// [`${ModelUserFields.contact_country_code}`]: contact.countryCode,\n// [`${ModelUserFields.contact_phone_number}`]: contact.phoneNumber,\n// [`${ModelUserFields.email}`]: data.user.email,\n// [`${ModelUserFields.firstname}`]: data.user.firstname,\n// [`${ModelUserFields.lastname}`]: data.user.lastname,\n// [`${ModelUserFields.status}`]: Boolean(data.user.status),\n// [`${ModelUserFields.user_type}`]: `${userType}`\n// }\n// }\n\n// return false\n\n// }\n\nexport const UserMeService = (props: UserMeServiceProps) => {\n\n const {\n ...rest\n } = props\n\n const userType = rest.actionUserType as UserType\n const userId = rest.actionUserId\n\n const userService = UserService({ ...rest, userType })\n const userModel = UserModel({ ...rest })\n\n const getUserMe = async () => {\n\n const id = userId\n\n let data = await userService.getUser({ id: userId, datatypes: [] })\n\n // Call the consumer hook, if registered\n if (UserMeHook?.onRequestGetMe) {\n let customData = await UserMeHook.onRequestGetMe(buildFeatureCallbackProps({\n defaultServiceProps: rest,\n callbackParams: {\n userMe: data\n }\n }))\n if (customData) data = customData\n }\n\n return data\n };\n\n const updateUserMe = async ({\n firstName = \"\",\n lastName = \"\",\n address = \"\"\n }: UserMeUpdateProps) => {\n\n const user = await userService.getUser({ id: Number(userId), datatypes: [] })\n\n // console.log('user', user)\n\n // check the userId is valid\n if (!user?.user_id) {\n throwError(`Invalid user id in auth token`)\n }\n\n // Call the consumer hook, if registered\n if (UserMeHook?.onRequestUpdateMe) {\n await UserMeHook.onRequestUpdateMe(buildFeatureCallbackProps({\n defaultServiceProps: rest,\n callbackParams: {\n userMe: user\n }\n }))\n }\n\n // change user information\n await userModel.update({\n id: Number(userId),\n data: {\n [`${ModelUserFields.firstname}`]: firstName,\n [`${ModelUserFields.lastname}`]: lastName,\n [`${ModelUserFields.address}`]: address,\n }\n })\n\n const userMe = await userService.getUser({ id: Number(userId), datatypes: [] })\n\n // Call the consumer hook, if success\n if (UserMeHook?.onSuccessUpdateMe) {\n await UserMeHook.onSuccessUpdateMe(buildFeatureCallbackProps({\n defaultServiceProps: rest,\n callbackParams: {\n userMe\n }\n }))\n }\n\n return userMe\n\n }\n\n const removeUserMe = async () => {\n\n const currentMe = await userService.getUser({ id: Number(userId), datatypes: [] })\n\n const response = await userService.suspendUsers({ ids: [BigInt(userId)] })\n\n // Call the consumer hook, if remove\n if (UserMeHook?.onSuccessRemoveMe) {\n await UserMeHook.onSuccessRemoveMe(buildFeatureCallbackProps({\n defaultServiceProps: rest,\n callbackParams: {\n userMe: currentMe\n }\n }))\n }\n\n return response\n };\n\n const changePasswordUserMe = async ({\n currentPassword,\n confirmPassword,\n newPassword,\n skipLoginPasswordValidation = false\n }: UserMeChangePasswordProps) => {\n\n const accountId = rest?.accountId ?? 0\n const accountService = AccountService({ ...rest, isOperator: true })\n\n const user = await userService.getUser({ id: Number(userId), datatypes: [], includePassword: true })\n const account = await accountService.getAccount({ id: Number(accountId), datatypes: [] })\n\n // console.log('user', user)\n // console.log('account', account)\n\n // check the accountId / userId is valid\n if (!user?.user_id) {\n throwError(`Invalid user id in auth token`)\n }\n\n if (Object.keys(account).length <= 0) { // must have account id record\n throwError(`Invalid account id in auth token`)\n }\n\n // new password cannot same with current password\n if (newPassword === currentPassword) {\n throwError(`New and current password cannot be same`)\n }\n\n // new password must same with confirm\n if (newPassword !== confirmPassword) {\n throwError(`New and confirm password not matched`)\n }\n\n // validate the login password new format\n if (skipLoginPasswordValidation === false) {\n validateLoginPasswordFormat(newPassword);\n }\n\n // check the current password\n try {\n const decryptedPass = await verifyPassword(currentPassword, user?.password)\n // console.log('decryptedPass', decryptedPass)\n\n if (!decryptedPass) {\n throw Error(`Invalid current password`)\n }\n\n } catch (error: any) {\n throwError(`Auth Token: ${error?.message}`)\n }\n\n // perform update credential\n const responseUser = await userService.replacePassword({\n id: Number(userId),\n data: {\n unhashLoginPassword: newPassword\n },\n isOperator: Boolean(userType === \"operator\")\n })\n\n // Call the consumer hook, if change password\n if (UserMeHook?.onSuccessChangePasswordMe) {\n\n // remove the password\n delete user.password\n\n await UserMeHook.onSuccessChangePasswordMe({\n defaultServiceProps: rest,\n callbackParams: {\n userMe: user\n }\n })\n }\n\n return responseUser\n\n }\n\n const allowUserTypes = [\"any\"] as const\n\n const methodConfigs = {\n getUserMe: { fn: getUserMe, allowUserTypes, actionName: \"get user/me\" },\n updateUserMe: { fn: updateUserMe, allowUserTypes, actionName: \"update user/me\" },\n changePasswordUserMe: { fn: changePasswordUserMe, allowUserTypes, actionName: \"change password user/me\" },\n removeUserMe: { fn: removeUserMe, allowUserTypes, actionName: \"remove user/me\" },\n };\n\n return ServiceFactory(\"UserMeService\", rest, methodConfigs);\n\n}\n\n"]}
@@ -68,6 +68,9 @@ export type UserOptionalLoginPassword = Omit<User, "loginPassword"> & {
68
68
  };
69
69
  export type UserCreateProps = {
70
70
  userType?: UserType;
71
+ skipLoginUsernameValidation?: boolean;
72
+ skipLoginPasswordValidation?: boolean;
73
+ skipContactValidation?: boolean;
71
74
  data: {
72
75
  user: User;
73
76
  } & ({
@@ -100,6 +103,9 @@ export type UserCreateProps = {
100
103
  export type UserUpdateProps = {
101
104
  id: number;
102
105
  userType?: UserType;
106
+ skipLoginUsernameValidation?: boolean;
107
+ skipLoginPasswordValidation?: boolean;
108
+ skipContactValidation?: boolean;
103
109
  data: {
104
110
  user: UserOptionalLoginPassword;
105
111
  } & ({
@@ -135,6 +141,7 @@ export type UserReplacePasswordProps = {
135
141
  unhashLoginPassword: string;
136
142
  };
137
143
  isOperator: boolean;
144
+ skipLoginPasswordValidation?: boolean;
138
145
  };
139
146
  export declare const userParentSqlSelect: {
140
147
  [x: string]: string;
@@ -191,7 +191,7 @@ const UserService = (props) => {
191
191
  throw err;
192
192
  }
193
193
  };
194
- const createUser = async ({ data, userType: overrideUserType }) => {
194
+ const createUser = async ({ data, userType: overrideUserType, skipLoginPasswordValidation = false, skipLoginUsernameValidation = false, skipContactValidation = false }) => {
195
195
  const _userType = overrideUserType || userType;
196
196
  // validate the credential contact no
197
197
  const userLoginUsername = data.user.loginUsername;
@@ -200,11 +200,17 @@ const UserService = (props) => {
200
200
  const userContactPhoneNumber = data.user.contact.phoneNumber;
201
201
  // validate the contact no only can be digit in text only
202
202
  // validate the country code in prefix
203
- await validateUserContact(userContactCountryCode, userContactPhoneNumber);
203
+ if (skipContactValidation === false) {
204
+ await validateUserContact(userContactCountryCode, userContactPhoneNumber);
205
+ }
204
206
  // validate login username
205
- validateLoginUsernameFormat(userLoginUsername);
207
+ if (skipLoginUsernameValidation === false) {
208
+ validateLoginUsernameFormat(userLoginUsername);
209
+ }
206
210
  // validate login password
207
- (0, utils_1.validateLoginPasswordFormat)(userLoginPassword);
211
+ if (skipLoginPasswordValidation === false) {
212
+ (0, utils_1.validateLoginPasswordFormat)(userLoginPassword);
213
+ }
208
214
  // check the username duplicated?
209
215
  const checkUsername = await userModel.list({
210
216
  limit: 1,
@@ -389,7 +395,7 @@ const UserService = (props) => {
389
395
  }
390
396
  return response;
391
397
  };
392
- const updateUser = async ({ id, data, userType: overrideUserType }) => {
398
+ const updateUser = async ({ id, data, userType: overrideUserType, skipLoginUsernameValidation = false, skipLoginPasswordValidation = false, skipContactValidation = false }) => {
393
399
  const _userType = overrideUserType || userType;
394
400
  // validate the credential contact no
395
401
  const userLoginUsername = data.user.loginUsername;
@@ -398,12 +404,18 @@ const UserService = (props) => {
398
404
  const userContactPhoneNumber = data.user.contact.phoneNumber;
399
405
  // validate the contact no only can be digit in text only
400
406
  // validate the country code in prefix
401
- await validateUserContact(userContactCountryCode, userContactPhoneNumber);
407
+ if (skipContactValidation === false) {
408
+ await validateUserContact(userContactCountryCode, userContactPhoneNumber);
409
+ }
402
410
  // validate login username
403
- validateLoginUsernameFormat(userLoginUsername);
411
+ if (skipLoginUsernameValidation === false) {
412
+ validateLoginUsernameFormat(userLoginUsername);
413
+ }
404
414
  // validate login password
405
415
  if (userLoginPassword) {
406
- (0, utils_1.validateLoginPasswordFormat)(userLoginPassword);
416
+ if (skipLoginPasswordValidation === false) {
417
+ (0, utils_1.validateLoginPasswordFormat)(userLoginPassword);
418
+ }
407
419
  }
408
420
  // check the username duplicated?
409
421
  const checkUsername = await userModel.list({
@@ -781,11 +793,15 @@ const UserService = (props) => {
781
793
  });
782
794
  return response;
783
795
  };
784
- const replacePassword = async ({ id, data, isOperator = false }) => {
796
+ const replacePassword = async ({ id, data, isOperator = false, skipLoginPasswordValidation = false }) => {
785
797
  const passwordUserModel = (0, models_1.UserModel)({
786
798
  ...rest,
787
799
  ...(isOperator === true ? { isOperator } : {})
788
800
  });
801
+ // validate login password
802
+ if (skipLoginPasswordValidation === false) {
803
+ (0, utils_1.validateLoginPasswordFormat)(data?.unhashLoginPassword);
804
+ }
789
805
  // update user password
790
806
  let responseUser = await passwordUserModel.update({
791
807
  id,
@@ -1 +1 @@
1
- {"version":3,"file":"UserService.js","sourceRoot":"","sources":["../../../src/services/user/UserService.ts"],"names":[],"mappings":";;;AAAA,qCAOkB;AAElB,6BAAwB;AAExB,uDAA0E;AAC1E,uDAAmI;AACnI,iEAAiK;AACjK,mDAAuH;AACvH,mDAAuH;AACvH,uDAAmI;AACnI,mDAAuH;AACvH,iDAAiH;AAGjH,+BAAgK;AAEhK,mCAAuF;AAEvF,mCAAuC;AACvC,uDAAmI;AAEnI,+BAAuC;AAE1B,QAAA,SAAS,GAAG;IACrB,QAAQ,EAAE,UAAU;IACpB,aAAa,EAAE,eAAe;IAC9B,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;CACR,CAAA;AAuLV,I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AE,EAAE,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC,UAAU,EAAE,eAAe,CAAU,EAAE,UAAU,EAAE,cAAc,EAAE;QACpH,YAAY,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC,KAAK,CAAU,EAAE,UAAU,EAAE,eAAe,EAAE;QACjG,YAAY,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC,UAAU,EAAE,eAAe,CAAU,EAAE,UAAU,EAAE,oBAAoB,EAAE;QAC5H,mBAAmB,EAAE,EAAE,EAAE,EAAE,mBAAmB,EAAE,cAAc,EAAE,CAAC,UAAU,EAAE,eAAe,CAAU,EAAE,UAAU,EAAE,uBAAuB,EAAE;KAChJ,CAAC;IAEF,OAAO,IAAA,oBAAc,EAAC,aAAa,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;AAE9D,CAAC,CAAA;AAv+BY,QAAA,WAAW,eAu+BvB","sourcesContent":["import {\n UserModel,\n ModelCountry,\n CountryModel,\n ModelUserFields,\n ModelAdministratorFields,\n ModelCountryFields\n} from \"@/models\";\n\nimport { z } from \"zod\";\n\nimport { UserPropService, UserPropReplaceProps } from \"./UserPropService\";\nimport { CustomerGetProps, CustomerCreateProps, CustomerListProps, CustomerUpdateProps, CustomerService } from \"./CustomerService\";\nimport { AdministratorGetProps, AdministratorCreateProps, AdministratorUpdateProps, AdministratorListProps, AdministratorService } from \"./AdministratorService\";\nimport { WorkerCreateProps, WorkerGetProps, WorkerUpdateProps, WorkerListProps, WorkerService } from \"./WorkerService\";\nimport { DriverCreateProps, DriverGetProps, DriverUpdateProps, DriverListProps, DriverService } from \"./DriverService\";\nimport { RetailerCreateProps, RetailerGetProps, RetailerUpdateProps, RetailerListProps, RetailerService } from \"./RetailerService\";\nimport { MemberCreateProps, MemberGetProps, MemberUpdateProps, MemberListProps, MemberService } from \"./MemberService\";\nimport { AgentCreateProps, AgentGetProps, AgentUpdateProps, AgentListProps, AgentService } from \"./AgentService\";\n\nimport { QueryList, QueryGet } from \"@/schema/common\";\nimport { buildSqlRelation, buildSqlRawSelect, buildSqlWhere, buildSqlSelect, buildSqlLimitOffset, buildSqlOrderBy, buildInjectionFieldsSqlSelect } from \"@/lib\";\n\nimport { validateLoginPasswordFormat, DefaultServiceProps, throwError } from \"@/utils\";\n\nimport { hashPassword } from \"@/utils\";\nimport { OperatorCreateProps, OperatorGetProps, OperatorListProps, OperatorService, OperatorUpdateProps } from \"./OperatorService\";\n\nimport { ServiceFactory } from \"@/lib\";\n\nexport const userTypes = {\n operator: \"operator\",\n administrator: \"administrator\",\n worker: \"worker\",\n supplier: \"supplier\",\n customer: \"customer\",\n driver: \"driver\",\n retailer: \"retailer\",\n member: \"member\",\n agent: \"agent\",\n} as const\n\nexport type UserType = typeof userTypes[keyof typeof userTypes]\n\nexport type UserServiceProps = DefaultServiceProps & {\n userType: UserType\n};\n\nexport type UserGetProps = QueryGet & {\n id: number,\n overrideUserType?: UserType | \"\"\n includePassword?: boolean,\n skipFilterAccountId?: boolean\n skipFilterUserType?: boolean\n};\n\nexport type UserGetByUsernameProps = QueryGet & {\n username: string,\n overrideUserType?: UserType | \"\"\n includePassword?: boolean,\n skipFilterAccountId?: boolean\n};\n\nexport type UserListProps = QueryList & {\n // id: number,\n includePassword?: boolean\n skipFilterAccountId?: boolean\n skipFilterUserType?: boolean\n};\n\nexport type UserRemoveProps = {\n ids: BigInt[]\n};\n\nexport type UserSuspendProps = {\n ids: BigInt[]\n};\n\nexport type User = {\n loginUsername: string\n loginPassword: string\n address: string\n // contact: string\n contact: {\n countryCode: number; // e.g., 1 for Canada\n phoneNumber: string; // digits only, mobile or landline\n }\n email: string\n firstname: string\n lastname: string\n status: boolean\n parentUserId?: number // optional for all user types\n}\n\nexport type UserOptionalLoginPassword = Omit<User, \"loginPassword\"> & {\n loginPassword?: string\n}\n\nexport type UserCreateProps = {\n userType?: UserType,\n data: {\n user: User\n } & (\n // operator\n {\n operator: Omit<OperatorCreateProps[\"data\"][\"operator\"], \"userId\">,\n } |\n // customer\n {\n customer: Omit<CustomerCreateProps[\"data\"][\"customer\"], \"userId\">,\n } |\n // administrator\n {\n administrator: Omit<AdministratorCreateProps[\"data\"][\"administrator\"], \"userId\">\n props: {\n locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n }\n } |\n // worker\n {\n worker: Omit<WorkerCreateProps[\"data\"][\"worker\"], \"userId\">\n props: {\n locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n }\n } |\n // driver\n {\n driver: Omit<DriverCreateProps[\"data\"][\"driver\"], \"userId\">\n props: {\n locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n }\n } |\n // member\n {\n member: Omit<MemberCreateProps[\"data\"][\"member\"], \"userId\">\n // props: {\n // locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n // }\n } |\n // agent\n {\n agent: Omit<AgentCreateProps[\"data\"][\"agent\"], \"userId\">\n // props: {\n // locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n // }\n } |\n // retailer\n {\n retailer: Omit<RetailerCreateProps[\"data\"][\"retailer\"], \"userId\">\n // props: {\n // locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n // }\n }\n )\n}\n\nexport type UserUpdateProps = {\n id: number,\n userType?: UserType,\n data: {\n user: UserOptionalLoginPassword\n } & (\n // operator\n {\n operator: Omit<OperatorUpdateProps[\"data\"][\"operator\"], \"userId\">\n } |\n // customer\n {\n customer: Omit<CustomerUpdateProps[\"data\"][\"customer\"], \"userId\">\n } |\n // administrator\n {\n administrator: Omit<AdministratorUpdateProps[\"data\"][\"administrator\"], \"userId\">\n props: {\n locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n }\n } |\n // worker\n {\n worker: Omit<WorkerUpdateProps[\"data\"][\"worker\"], \"userId\">\n props: {\n locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n }\n } |\n // driver\n {\n driver: Omit<DriverUpdateProps[\"data\"][\"driver\"], \"userId\">\n props: {\n locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n }\n } |\n // member\n {\n member: Omit<MemberUpdateProps[\"data\"][\"member\"], \"userId\">\n // props: {\n // locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n // }\n } |\n // agent\n {\n agent: Omit<AgentUpdateProps[\"data\"][\"agent\"], \"userId\">\n // props: {\n // locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n // }\n } |\n // retailer\n {\n retailer: Omit<RetailerUpdateProps[\"data\"][\"retailer\"], \"userId\">\n // props: {\n // locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n // }\n }\n )\n}\n\nexport type UserReplacePasswordProps = {\n id: number,\n data: {\n unhashLoginPassword: string\n },\n isOperator: boolean\n}\n\nlet mainSqlSelect = {\n [`usr.${ModelUserFields.user_id}`]: \"user_id\",\n [`usr.${ModelUserFields.user_type}`]: \"user_type\",\n [`usr.${ModelUserFields.login_username}`]: \"username\",\n [`usr.${ModelUserFields.firstname}`]: \"firstname\",\n [`usr.${ModelUserFields.lastname}`]: \"lastname\",\n [`CONCAT(usr.${ModelUserFields.contact_country_code}, usr.${ModelUserFields.contact_phone_number})`]: \"contact\",\n [`usr.${ModelUserFields.contact_country_code}`]: \"contact_country_code\",\n [`usr.${ModelUserFields.contact_phone_number}`]: \"contact_phone_number\",\n [`usr.${ModelUserFields.email}`]: \"email\",\n [`usr.${ModelUserFields.address}`]: \"address\",\n [`usr.${ModelUserFields.parent_user_id}`]: \"parent_user_id\",\n [`usr.${ModelUserFields.status}`]: \"status\",\n}\n\nlet defaultSqlSelect = {\n [`usr.${ModelUserFields.createdatetime}`]: \"createdatetime\",\n [`creator.${ModelUserFields.login_username}`]: \"createusername\",\n [`usr.${ModelUserFields.updatedatetime}`]: \"updatedatetime\",\n [`updater.${ModelUserFields.login_username}`]: \"updateusername\",\n [`usr.${ModelUserFields.isdelete}`]: \"isdelete\",\n [`usr.${ModelUserFields.istrash}`]: \"istrash\",\n [`usr.${ModelUserFields.accountid}`]: \"accountid\",\n}\n\nexport const userParentSqlSelect = {\n [`parentuser.${ModelUserFields.user_id}`]: \"parent_user_id\",\n [`parentuser.${ModelUserFields.login_username}`]: \"parent_username\",\n [`parentuser.${ModelUserFields.user_type}`]: \"parent_user_type\",\n [`parentuser.${ModelUserFields.firstname}`]: \"parent_firstname\",\n [`parentuser.${ModelUserFields.lastname}`]: \"parent_lastname\",\n [`CONCAT(parentuser.${ModelUserFields.contact_country_code}, parentuser.${ModelUserFields.contact_phone_number})`]: \"parent_contact\",\n [`parentuser.${ModelUserFields.contact_country_code}`]: \"parent_contact_country_code\",\n [`parentuser.${ModelUserFields.contact_phone_number}`]: \"parent_contact_phone_number\",\n [`parentuser.${ModelUserFields.email}`]: \"parent_email\",\n [`parentuser.${ModelUserFields.address}`]: \"parent_address\",\n [`parentuser.${ModelUserFields.status}`]: \"parent_user_status\"\n}\n\nconst getCreatePayload = async (\n userType: UserType,\n data: UserCreateProps[\"data\"],\n contact: {\n countryCode: number,\n phoneNumber: string\n }\n) => {\n\n if (\"user\" in data) {\n\n // have to hash the password\n\n return {\n [`${ModelUserFields.login_username}`]: data.user.loginUsername,\n [`${ModelUserFields.login_password}`]: await hashPassword(data.user.loginPassword),\n [`${ModelUserFields.address}`]: data.user.address,\n [`${ModelUserFields.contact_country_code}`]: contact.countryCode,\n [`${ModelUserFields.contact_phone_number}`]: contact.phoneNumber,\n [`${ModelUserFields.email}`]: data.user.email,\n [`${ModelUserFields.firstname}`]: data.user.firstname,\n [`${ModelUserFields.lastname}`]: data.user.lastname,\n [`${ModelUserFields.status}`]: Boolean(data.user.status),\n [`${ModelUserFields.user_type}`]: `${userType}`,\n ...(data?.user?.parentUserId ? { [`${ModelUserFields.parent_user_id}`]: Number(data.user.parentUserId) } : {})\n }\n }\n\n return false\n\n}\n\nconst getUpdatePayload = async (\n userType: UserType,\n data: UserUpdateProps[\"data\"],\n contact: {\n countryCode: number,\n phoneNumber: string\n }\n) => {\n\n if (\"user\" in data) {\n\n const newHashPassword = data?.user?.loginPassword ? await hashPassword(data.user.loginPassword) : \"\"\n\n return {\n [`${ModelUserFields.login_username}`]: data.user.loginUsername,\n ...(newHashPassword ? { [`${ModelUserFields.login_password}`]: newHashPassword } : {}),\n [`${ModelUserFields.address}`]: data.user.address,\n [`${ModelUserFields.contact_country_code}`]: contact.countryCode,\n [`${ModelUserFields.contact_phone_number}`]: contact.phoneNumber,\n [`${ModelUserFields.email}`]: data.user.email,\n [`${ModelUserFields.firstname}`]: data.user.firstname,\n [`${ModelUserFields.lastname}`]: data.user.lastname,\n [`${ModelUserFields.status}`]: Boolean(data.user.status),\n [`${ModelUserFields.user_type}`]: `${userType}`,\n ...(data?.user?.parentUserId ? { [`${ModelUserFields.parent_user_id}`]: Number(data.user.parentUserId) } : {})\n }\n }\n\n return false\n\n}\n\n// Example reserved words for username\nexport const loginUsernameReservedWords = [\n \"admin\", \"administrator\", \"root\", \"system\", \"operator\", \"moderator\", \"owner\", \"manager\",\n \"user\", \"users\", \"account\", \"guest\", \"login\", \"logout\", \"signup\", \"register\", \"auth\",\n \"api\", \"www\", \"app\", \"support\", \"help\", \"dashboard\", \"portal\", \"console\", \"control\", \"ops\",\n \"test\", \"demo\", \"beta\", \"alpha\", \"dev\", \"development\", \"staging\", \"prod\", \"production\",\n \"security\", \"privacy\", \"terms\", \"policy\", \"legal\", \"about\", \"company\", \"team\", \"teams\",\n \"billing\", \"payment\", \"invoice\", \"finance\", \"financeadmin\", \"subscription\", \"plan\", \"plans\",\n \"rootadmin\", \"superuser\", \"staff\", \"moderation\", \"systemadmin\", \"sysadmin\", \"internal\",\n \"management\", \"supportdesk\", \"helpdesk\", \"contact\", \"feedback\", \"news\", \"blog\", \"media\",\n \"press\", \"events\", \"calendar\", \"forum\", \"community\", \"chat\", \"messaging\", \"notifications\",\n \"alerts\", \"reports\", \"analytics\", \"metrics\", \"logs\", \"history\", \"archive\", \"backup\",\n \"restore\", \"files\", \"documents\", \"resources\", \"library\", \"gallery\", \"images\", \"videos\",\n \"downloads\", \"uploads\", \"templates\", \"home\", \"index\", \"static\", \"public\", \"webmaster\"\n];\n\n// Zod schema for username\nexport const loginUsernameSchema = z\n .string()\n .min(5, { message: \"Login username must be at least 5 characters\" })\n .max(63, { message: \"Login username must be at most 63 characters\" })\n .regex(\n /^[a-z0-9]([a-z0-9-_]{3,61}[a-z0-9])?$/,\n \"Login username can only contain lowercase letters, numbers, hyphens, and underscores, cannot start or end with a hyphen or underscore\"\n )\n .transform((val) => val.toLowerCase().trim()) // normalize\n .refine((val) => !loginUsernameReservedWords.includes(val), {\n message: \"This login username is reserved. Please choose another one\",\n });\n\nexport const UserService = (props: UserServiceProps) => {\n\n const {\n userType = \"administrator\",\n ...rest\n } = props\n\n const userModel = UserModel({ ...rest })\n const countryModel = CountryModel({ ...rest })\n\n const userPropService = UserPropService({ ...rest, userPropType: \"LOCATION_ID\" })\n const customerService = CustomerService({ ...rest })\n const administratorService = AdministratorService({ ...rest })\n const operatorService = OperatorService({ ...rest })\n const workerService = WorkerService({ ...rest })\n const driverService = DriverService({ ...rest })\n const retailerService = RetailerService({ ...rest })\n const memberService = MemberService({ ...rest })\n const agentService = AgentService({ ...rest })\n\n const validateUserContactPhoneNumber = (val: string) => {\n // Must be numeric\n if (!/^\\d+$/.test(val)) {\n throw new Error(`Contact No. only allowed numbers`);\n }\n\n // Must have realistic length (4 to 15 digits)\n if (val.length < 4 || val.length > 15) {\n throw new Error(`Contact No. length must be between 4 and 15 digits`);\n }\n\n return true;\n };\n\n const validateUserContactCountryCode = async (countryCode: number) => {\n\n // 1. Load active countries\n const activeCountries: ModelCountry[] = await countryModel.list({\n where: {\n [`${ModelCountryFields.isdelete}`]: false,\n [`${ModelCountryFields.istrash}`]: false,\n [`${ModelCountryFields.status}`]: true\n }\n })\n\n // Check if country code exists\n const exists = activeCountries.some(c => c.phone_code === countryCode);\n\n if (!exists) {\n throw new Error(`Invalid country code: ${countryCode}`);\n }\n\n return true; // valid\n\n }\n\n const validateUserContact = async (countryCode: number, phoneNumber: string) => {\n\n try {\n // validate the phone number without country code\n validateUserContactPhoneNumber(phoneNumber)\n\n // validate user contact country code\n await validateUserContactCountryCode(countryCode)\n\n return true\n\n } catch (error: unknown) {\n const msg = error instanceof Error ? error.message : String(error);\n throw new Error(`Invalid user contact no.: ${msg}, provided: ${countryCode} ${phoneNumber}`);\n }\n\n }\n\n const validateLoginUsernameFormat = (loginUsername: string) => {\n try {\n return loginUsernameSchema.parse(loginUsername); // throws if invalid\n } catch (err) {\n if (err instanceof z.ZodError) {\n throw new Error(\n `Invalid login username: \"${loginUsername}\". ` +\n err.errors.map((e) => e.message).join(\"; \")\n );\n }\n throw err;\n }\n };\n\n const createUser = async ({ data, userType: overrideUserType }: UserCreateProps) => {\n\n const _userType = overrideUserType || userType\n\n // validate the credential contact no\n const userLoginUsername = data.user.loginUsername\n const userLoginPassword = data.user.loginPassword\n const userContactCountryCode = data.user.contact.countryCode\n const userContactPhoneNumber = data.user.contact.phoneNumber\n\n // validate the contact no only can be digit in text only\n // validate the country code in prefix\n await validateUserContact(userContactCountryCode, userContactPhoneNumber)\n\n // validate login username\n validateLoginUsernameFormat(userLoginUsername)\n\n // validate login password\n validateLoginPasswordFormat(userLoginPassword)\n\n // check the username duplicated?\n const checkUsername = await userModel.list({\n limit: 1,\n offset: 0,\n orderBy: {\n [`${ModelUserFields.user_id}`]: \"asc\"\n },\n include: [],\n where: {\n [`${ModelUserFields.login_username}`]: data.user.loginUsername,\n [`${ModelUserFields.accountid}`]: Number(rest.accountId),\n [`${ModelUserFields.isdelete}`]: false,\n [`${ModelUserFields.istrash}`]: false\n },\n })\n\n // console.log('ch', checkUsername)\n\n if (checkUsername.length > 0) throwError(`Duplicated username: ${data.user.loginUsername}(${checkUsername[0]?.user_type})`)\n\n // validation before insertion\n // if (_userType === \"member\" && \"member\" in data) {\n\n // const memberOwnerUserId = data?.member?.ownerUserId ?? \"\";\n\n // validate owner user id\n // if (memberOwnerUserId) {\n // await memberService.validateMemberOwnerUserId(memberOwnerUserId)\n // }\n\n // }\n\n // if (_userType === \"agent\" && \"agent\" in data) {\n\n // const agentOwnerUserId = data?.agent?.ownerUserId ?? \"\";\n\n // validate owner user id\n // if (agentOwnerUserId) {\n // await agentService.validateAgentOwnerUserId(agentOwnerUserId)\n // }\n\n // }\n\n const _data = await getCreatePayload(\n _userType,\n data,\n {\n countryCode: userContactCountryCode,\n phoneNumber: userContactPhoneNumber\n }\n )\n\n if (!_data) {\n throw new Error(`Invalid create payload: ${JSON.stringify(_data)}`);\n }\n\n // create user\n let responseUser = await userModel.create({ data: _data })\n\n let newUserId = responseUser.user_id\n\n let response: any = {}\n\n if (_userType === \"customer\" && \"customer\" in data) {\n\n let dataCustomer: CustomerCreateProps[\"data\"] = {\n customer: {\n ...data.customer,\n userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create customer\n await customerService.createCustomer({ data: dataCustomer })\n\n response = await customerService.getCustomer({ id: Number(newUserId), datatypes: [] })\n }\n\n if (_userType === \"administrator\" && \"administrator\" in data) {\n\n let dataAdministrator: AdministratorCreateProps[\"data\"] = {\n administrator: {\n ...data.administrator,\n userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create administrator\n await administratorService.createAdministrator({ data: dataAdministrator })\n\n // replace user prop\n await userPropService.replaceUserProp({\n userPropType: \"LOCATION_ID\",\n data: {\n userProp: {\n userId: Number(newUserId),\n locationIds: data.props.locationIds\n }\n }\n })\n\n response = await administratorService.getAdministrator({ id: Number(newUserId), datatypes: [] })\n }\n\n if (_userType === \"operator\" && \"operator\" in data) {\n\n let dataOperator: OperatorCreateProps[\"data\"] = {\n operator: {\n ...data.operator,\n userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create operator\n await operatorService.createOperator({ data: dataOperator })\n\n response = await operatorService.getOperator({ id: Number(newUserId), datatypes: [] })\n }\n\n if (_userType === \"worker\" && \"worker\" in data) {\n\n let dataWorker: WorkerCreateProps[\"data\"] = {\n worker: {\n ...data.worker,\n userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create worker\n await workerService.createWorker({ data: dataWorker })\n\n // replace user prop\n await userPropService.replaceUserProp({\n userPropType: \"LOCATION_ID\",\n data: {\n userProp: {\n userId: Number(newUserId),\n locationIds: data.props.locationIds\n }\n }\n })\n\n response = await workerService.getWorker({ id: Number(newUserId), datatypes: [] })\n }\n\n if (_userType === \"driver\" && \"driver\" in data) {\n\n let dataDriver: DriverCreateProps[\"data\"] = {\n driver: {\n ...data.driver,\n userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create driver\n await driverService.createDriver({ data: dataDriver })\n\n // replace user prop\n await userPropService.replaceUserProp({\n userPropType: \"LOCATION_ID\",\n data: {\n userProp: {\n userId: Number(newUserId),\n locationIds: data.props.locationIds\n }\n }\n })\n\n response = await driverService.getDriver({ id: Number(newUserId), datatypes: [] })\n }\n\n if (_userType === \"member\" && \"member\" in data) {\n\n let dataMember: MemberCreateProps[\"data\"] = {\n member: {\n ...data.member,\n // userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create member\n await memberService.createMember({ userId: Number(newUserId), data: dataMember })\n\n // replace user prop\n // await userPropService.replaceUserProp({\n // userPropType: \"LOCATION_ID\",\n // data: {\n // userProp: {\n // userId: Number(newUserId),\n // locationIds: data.props.locationIds\n // }\n // }\n // })\n\n response = await memberService.getMember({ id: Number(newUserId), datatypes: [] })\n }\n\n if (_userType === \"agent\" && \"agent\" in data) {\n\n let dataAgent: AgentCreateProps[\"data\"] = {\n agent: {\n ...data.agent,\n // userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create agent\n await agentService.createAgent({ userId: Number(newUserId), data: dataAgent })\n\n // replace user prop\n // await userPropService.replaceUserProp({\n // userPropType: \"LOCATION_ID\",\n // data: {\n // userProp: {\n // userId: Number(newUserId),\n // locationIds: data.props.locationIds\n // }\n // }\n // })\n\n response = await agentService.getAgent({ id: Number(newUserId), datatypes: [] })\n }\n\n if (_userType === \"retailer\" && \"retailer\" in data) {\n\n let dataRetailer: RetailerCreateProps[\"data\"] = {\n retailer: {\n ...data.retailer,\n userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create retailer\n await retailerService.createRetailer({ data: dataRetailer })\n\n response = await retailerService.getRetailer({ id: Number(newUserId), datatypes: [] })\n }\n\n return response\n }\n\n const updateUser = async ({ id, data, userType: overrideUserType }: UserUpdateProps) => {\n\n const _userType = overrideUserType || userType\n\n // validate the credential contact no\n const userLoginUsername = data.user.loginUsername\n const userLoginPassword = data.user?.loginPassword ?? \"\"\n const userContactCountryCode = data.user.contact.countryCode\n const userContactPhoneNumber = data.user.contact.phoneNumber\n\n // validate the contact no only can be digit in text only\n // validate the country code in prefix\n await validateUserContact(userContactCountryCode, userContactPhoneNumber)\n\n // validate login username\n validateLoginUsernameFormat(userLoginUsername)\n\n // validate login password\n if (userLoginPassword) {\n validateLoginPasswordFormat(userLoginPassword)\n }\n\n // check the username duplicated?\n const checkUsername = await userModel.list({\n limit: 1,\n offset: 0,\n orderBy: {\n [`${ModelUserFields.user_id}`]: \"asc\"\n },\n include: [],\n where: {\n [`${ModelUserFields.login_username}`]: data.user.loginUsername,\n [`${ModelUserFields.isdelete}`]: false,\n [`${ModelUserFields.istrash}`]: false,\n [`${ModelUserFields.accountid}`]: rest.accountId,\n },\n })\n\n // console.log('ch', checkUsername)\n\n if (checkUsername.length > 0) {\n if (Number(checkUsername[0]?.user_id) !== Number(id)) { // if not self user id\n throwError(`Duplicated username: ${data.user.loginUsername}(${checkUsername[0]?.user_type})`)\n }\n }\n\n // validation before insertion\n // if (_userType === \"member\" && \"member\" in data) {\n // }\n\n const _data = await getUpdatePayload(\n _userType,\n data,\n {\n countryCode: userContactCountryCode,\n phoneNumber: userContactPhoneNumber\n }\n )\n\n if (!_data) {\n throw new Error(`Invalid update payload: ${JSON.stringify(_data)}`);\n }\n\n // update user\n let responseUser = await userModel.update({ id, data: _data })\n\n let updateUserId = responseUser.user_id\n\n let response: any = {}\n\n if (_userType === \"customer\" && \"customer\" in data) {\n\n let dataCustomer: CustomerUpdateProps[\"data\"] = {\n customer: {\n ...data.customer\n }\n }\n\n await customerService.updateCustomer({ userId: Number(updateUserId), data: dataCustomer })\n\n response = await customerService.getCustomer({ id: Number(updateUserId), datatypes: [] })\n\n }\n\n if (_userType === \"operator\" && \"operator\" in data) {\n\n let dataOperator: OperatorUpdateProps[\"data\"] = {\n operator: {\n ...data.operator\n }\n }\n\n await operatorService.updateOperator({ userId: Number(updateUserId), data: dataOperator })\n\n response = await operatorService.getOperator({ id: Number(updateUserId), datatypes: [] })\n\n }\n\n if (_userType === \"administrator\" && \"administrator\" in data) {\n\n let dataCustomer: AdministratorUpdateProps[\"data\"] = {\n administrator: {\n ...data.administrator\n }\n }\n\n await administratorService.updateAdministrator({ userId: Number(updateUserId), data: dataCustomer })\n\n // replace user prop\n await userPropService.replaceUserProp({\n userPropType: \"LOCATION_ID\",\n data: {\n userProp: {\n userId: Number(updateUserId),\n locationIds: data.props.locationIds\n }\n }\n })\n\n response = await administratorService.getAdministrator({ id: Number(updateUserId), datatypes: [] })\n\n }\n\n if (_userType === \"worker\" && \"worker\" in data) {\n\n let dataWorker: WorkerUpdateProps[\"data\"] = {\n worker: {\n ...data.worker\n }\n }\n\n await workerService.updateWorker({ userId: Number(updateUserId), data: dataWorker })\n\n // replace user prop\n await userPropService.replaceUserProp({\n userPropType: \"LOCATION_ID\",\n data: {\n userProp: {\n userId: Number(updateUserId),\n locationIds: data.props.locationIds\n }\n }\n })\n\n response = await workerService.getWorker({ id: Number(updateUserId), datatypes: [] })\n\n }\n\n if (_userType === \"driver\" && \"driver\" in data) {\n\n let dataDriver: DriverUpdateProps[\"data\"] = {\n driver: {\n ...data.driver\n }\n }\n\n await driverService.updateDriver({ userId: Number(updateUserId), data: dataDriver })\n\n // replace user prop\n await userPropService.replaceUserProp({\n userPropType: \"LOCATION_ID\",\n data: {\n userProp: {\n userId: Number(updateUserId),\n locationIds: data.props.locationIds\n }\n }\n })\n\n response = await driverService.getDriver({ id: Number(updateUserId), datatypes: [] })\n\n }\n\n if (_userType === \"member\" && \"member\" in data) {\n\n let dataMember: MemberUpdateProps[\"data\"] = {\n member: {\n ...data.member\n }\n }\n\n await memberService.updateMember({ userId: Number(updateUserId), data: dataMember })\n\n // replace user prop\n // await userPropService.replaceUserProp({\n // userPropType: \"LOCATION_ID\",\n // data: {\n // userProp: {\n // userId: Number(updateUserId),\n // locationIds: data.props.locationIds\n // }\n // }\n // })\n\n response = await memberService.getMember({ id: Number(updateUserId), datatypes: [] })\n\n }\n\n if (_userType === \"agent\" && \"agent\" in data) {\n\n let dataAgent: AgentUpdateProps[\"data\"] = {\n agent: {\n ...data.agent\n }\n }\n\n await agentService.updateAgent({ userId: Number(updateUserId), data: dataAgent })\n\n // replace user prop\n // await userPropService.replaceUserProp({\n // userPropType: \"LOCATION_ID\",\n // data: {\n // userProp: {\n // userId: Number(updateUserId),\n // locationIds: data.props.locationIds\n // }\n // }\n // })\n\n response = await agentService.getAgent({ id: Number(updateUserId), datatypes: [] })\n\n }\n\n if (_userType === \"retailer\" && \"retailer\" in data) {\n\n let dataRetailer: RetailerUpdateProps[\"data\"] = {\n retailer: {\n ...data.retailer\n }\n }\n\n await retailerService.updateRetailer({ userId: Number(updateUserId), data: dataRetailer })\n\n response = await retailerService.getRetailer({ id: Number(updateUserId), datatypes: [] })\n\n }\n\n return response\n }\n\n const getUser = async ({ id, datatypes = [], includePassword = false, overrideUserType = \"\", skipFilterAccountId = false, skipFilterUserType = false }: UserGetProps) => {\n\n let data: any = {}\n\n if (skipFilterUserType === true) {\n\n let { data } = await listUsers({\n includePassword,\n limit: 1,\n offset: 0,\n filters: [{ field: \"user_id\", operator: \"=\", value: id }],\n sortfield: \"user_id\",\n sortorder: \"ASC\",\n datatypes,\n skipFilterAccountId,\n skipFilterUserType\n })\n\n return data[0] ?? null;\n }\n\n const _userType = overrideUserType ? overrideUserType : userType\n\n if (_userType === \"customer\") {\n data = await customerService.getCustomer({ id, datatypes: datatypes as CustomerGetProps[\"datatypes\"], includePassword })\n }\n\n if (_userType === \"operator\") {\n data = await operatorService.getOperator({ id, datatypes: datatypes as OperatorGetProps[\"datatypes\"], includePassword })\n }\n\n if (_userType === \"administrator\") {\n data = await administratorService.getAdministrator({ id, datatypes: datatypes as AdministratorGetProps[\"datatypes\"], includePassword, skipFilterAccountId })\n }\n\n if (_userType === \"worker\") {\n data = await workerService.getWorker({ id, datatypes: datatypes as WorkerGetProps[\"datatypes\"], includePassword })\n }\n\n if (_userType === \"driver\") {\n data = await driverService.getDriver({ id, datatypes: datatypes as DriverGetProps[\"datatypes\"], includePassword })\n }\n\n if (_userType === \"member\") {\n data = await memberService.getMember({ id, datatypes: datatypes as MemberGetProps[\"datatypes\"], includePassword })\n }\n\n if (_userType === \"agent\") {\n data = await agentService.getAgent({ id, datatypes: datatypes as AgentGetProps[\"datatypes\"], includePassword })\n }\n\n if (_userType === \"retailer\") {\n data = await retailerService.getRetailer({ id, datatypes: datatypes as RetailerGetProps[\"datatypes\"], includePassword })\n }\n\n if (!data) {\n throw new Error(`Invalid id: ${id}`);\n }\n\n return data\n };\n\n const getUserByUsername = async ({ username, datatypes = [], includePassword = false, overrideUserType = \"\", skipFilterAccountId = false }: UserGetByUsernameProps) => {\n\n let data: any = {}\n\n const _userType = overrideUserType ? overrideUserType : userType\n\n // if (_userType === \"customer\") {\n // data = await customerService.getCustomer({ id, datatypes: datatypes as CustomerGetProps[\"datatypes\"], includePassword })\n // }\n\n if (_userType === \"operator\") {\n data = await operatorService.getOperatorByUsername({ username, datatypes: datatypes as OperatorGetProps[\"datatypes\"], includePassword })\n }\n\n if (_userType === \"administrator\") {\n data = await administratorService.getAdministratorByUsername({ username, datatypes: datatypes as AdministratorGetProps[\"datatypes\"], includePassword, skipFilterAccountId })\n }\n\n // if (_userType === \"worker\") {\n // data = await workerService.getWorker({ id, datatypes: datatypes as WorkerGetProps[\"datatypes\"], includePassword })\n // }\n\n // if (_userType === \"driver\") {\n // data = await driverService.getDriver({ id, datatypes: datatypes as DriverGetProps[\"datatypes\"], includePassword })\n // }\n\n // if (_userType === \"member\") {\n // data = await memberService.getMember({ id, datatypes: datatypes as MemberGetProps[\"datatypes\"], includePassword })\n // }\n\n // if (_userType === \"agent\") {\n // data = await agentService.getAgent({ id, datatypes: datatypes as AgentGetProps[\"datatypes\"], includePassword })\n // }\n\n // if (_userType === \"retailer\") {\n // data = await retailerService.getRetailer({ id, datatypes: datatypes as RetailerGetProps[\"datatypes\"], includePassword })\n // }\n\n if (!data) {\n throw new Error(`Invalid username: ${username}`);\n }\n\n return data\n };\n\n const listUsers = async ({ limit, offset, filters = [], sortfield, sortorder, datatypes, includePassword = false, skipFilterAccountId = false, skipFilterUserType = false }: UserListProps) => {\n\n let data: any[] = [];\n let total = 0;\n\n if (skipFilterUserType === true) {\n\n mainSqlSelect = {\n ...mainSqlSelect,\n ...(includePassword ? { [`usr.${ModelUserFields.login_password}`]: \"password\" } : {}),\n }\n\n let sqlSelect = [\n `COUNT(*) OVER() as filtered_count`,\n buildSqlSelect(``, mainSqlSelect),\n buildSqlSelect(``, defaultSqlSelect)\n ]\n\n let sqlRelation = [\n buildSqlRelation(\"left\", \"usr\", \"users\", \"parentuser\", [\"usr.parent_user_id = parentuser.user_id\", \"parentuser.isdelete = false\", \"parentuser.istrash = false\"]),\n buildSqlRelation(\"left\", \"usr\", \"users\", \"creator\", [\"usr.createuserid = creator.user_id\", \"creator.isdelete = false\", \"creator.istrash = false\"]),\n buildSqlRelation(\"left\", \"usr\", \"users\", \"updater\", [\"usr.updateuserid = updater.user_id\", \"updater.isdelete = false\", \"updater.istrash = false\"])\n ]\n\n let sqlGroupBy: string[] = [\n ...Object.keys(mainSqlSelect),\n ...Object.keys(defaultSqlSelect)\n ]\n\n let filterColumns = {\n ...mainSqlSelect,\n ...defaultSqlSelect\n }\n\n let sqlWhere = [\n `usr.isdelete = false`,\n `usr.istrash = false`,\n ...(filters.length ? [buildSqlWhere(filters, filterColumns)?.where] : []),\n ]\n\n let sqlOrderby = buildSqlOrderBy(sortfield, sortorder)\n let sqlLimitOffset = buildSqlLimitOffset(limit, offset)\n\n const sqlRaw = buildSqlRawSelect({\n tableName: \"users\",\n mainAlias: \"usr\",\n accountId: rest.accountId,\n sqlSelect,\n sqlRelation,\n sqlWhere,\n sqlGroupBy,\n sqlOrderby,\n sqlLimitOffset,\n skipFilterAccountId\n })\n\n data = await userModel.raw(sqlRaw)\n\n const response = {\n data: data.map(({ filtered_count, ...rest }) => rest),\n total: data.length ? Number(data[0].filtered_count) : 0\n }\n\n return response\n }\n\n if (userType === \"customer\") {\n ({ data, total } = await customerService.listCustomers(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as CustomerListProps[\"datatypes\"] }\n ))\n }\n\n if (userType === \"operator\") {\n ({ data, total } = await operatorService.listOperators(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as OperatorListProps[\"datatypes\"] }\n ))\n }\n\n if (userType === \"administrator\") {\n ({ data, total } = await administratorService.listAdministrators(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as AdministratorListProps[\"datatypes\"], skipFilterAccountId }\n ))\n }\n\n if (userType === \"worker\") {\n ({ data, total } = await workerService.listWorkers(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as WorkerListProps[\"datatypes\"] }\n ))\n }\n\n if (userType === \"driver\") {\n ({ data, total } = await driverService.listDrivers(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as DriverListProps[\"datatypes\"] }\n ))\n }\n\n if (userType === \"member\") {\n ({ data, total } = await memberService.listMembers(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as MemberListProps[\"datatypes\"] }\n ))\n }\n\n if (userType === \"agent\") {\n ({ data, total } = await agentService.listAgents(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as AgentListProps[\"datatypes\"] }\n ))\n }\n\n if (userType === \"retailer\") {\n ({ data, total } = await retailerService.listRetailers(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as RetailerListProps[\"datatypes\"] }\n ))\n }\n\n return {\n data,\n total\n }\n };\n\n const removeUsers = async ({ ids }: UserRemoveProps) => {\n\n if (!ids.length) throwError('id is required');\n\n let response: any[] = []\n\n if (userType === \"customer\") {\n response = await customerService.removeCustomers({ userIds: ids })\n }\n\n if (userType === \"operator\") {\n response = await operatorService.removeOperators({ userIds: ids })\n }\n\n if (userType === \"administrator\") {\n\n // have to check the ids is is_owner account\n const { data: administrators } = await administratorService.listAdministrators({\n limit: 9999,\n offset: 0,\n filters: [{\n field: `${ModelAdministratorFields.user_id}`,\n operator: \"where_in\",\n value: ids\n }],\n sortfield: `${ModelAdministratorFields.administrator_id}`,\n sortorder: \"ASC\",\n datatypes: []\n })\n\n const ownerAdministrators = administrators.filter(i => i.is_owner === true)\n\n if (ownerAdministrators.length > 0) {\n throw new Error(`Cannot delete on administrator owner user ids: ${ownerAdministrators.map(i => i.user_id)}`);\n }\n\n response = await administratorService.removeAdministrators({ userIds: ids })\n await userPropService.removeUserProps({ userIds: ids })\n }\n\n if (userType === \"worker\") {\n response = await workerService.removeWorkers({ userIds: ids })\n await userPropService.removeUserProps({ userIds: ids })\n }\n\n if (userType === \"driver\") {\n response = await driverService.removeDrivers({ userIds: ids })\n await userPropService.removeUserProps({ userIds: ids })\n }\n\n if (userType === \"member\") {\n response = await memberService.removeMembers({ userIds: ids })\n // await userPropService.removeUserProps({ userIds: ids })\n }\n\n if (userType === \"agent\") {\n response = await agentService.removeAgents({ userIds: ids })\n // await userPropService.removeUserProps({ userIds: ids })\n }\n\n if (userType === \"retailer\") {\n response = await retailerService.removeRetailers({ userIds: ids })\n // await userPropService.removeUserProps({ userIds: ids })\n }\n\n // remove user\n let responseUser = await userModel.remove({ ids: ids.map(i => Number(i)) })\n\n response.forEach((i, index) => {\n i.user = responseUser[index]\n })\n\n return response\n };\n\n const replacePassword = async ({ id, data, isOperator = false }: UserReplacePasswordProps) => {\n\n const passwordUserModel = UserModel({\n ...rest,\n ...(isOperator === true ? { isOperator } : {})\n })\n\n // update user password\n let responseUser = await passwordUserModel.update({\n id,\n data: {\n login_password: await hashPassword(data?.unhashLoginPassword)\n }\n })\n\n let updateUserId = responseUser.user_id\n\n let response = await getUser({ id: Number(updateUserId), includePassword: false, datatypes: [] })\n\n return response\n }\n\n const suspendUsers = async ({ ids }: UserSuspendProps) => {\n\n if (!ids.length) throwError('id is required');\n\n // change users status\n let response = await userModel.update({\n where: {\n [`${ModelUserFields.user_id}`]: {\n in: ids.map((i: any) => Number(i))\n }\n },\n data: {\n [`${ModelUserFields.status}`]: false\n }\n })\n\n const { login_password, ...safeResponse } = response;\n\n return safeResponse\n };\n\n const getDataTypes = () => {\n\n let data: any[] = [];\n let total = 0;\n\n if (userType === \"customer\") {\n data = customerService.getDataTypes()\n }\n\n if (userType === \"operator\") {\n data = operatorService.getDataTypes()\n }\n\n if (userType === \"administrator\") {\n data = administratorService.getDataTypes()\n }\n\n if (userType === \"worker\") {\n data = workerService.getDataTypes()\n }\n\n if (userType === \"driver\") {\n data = driverService.getDataTypes()\n }\n\n if (userType === \"member\") {\n data = memberService.getDataTypes()\n }\n\n if (userType === \"agent\") {\n data = agentService.getDataTypes()\n }\n\n if (userType === \"retailer\") {\n data = retailerService.getDataTypes()\n }\n\n return data\n };\n\n // return {\n // createUser,\n // updateUser,\n // getUser,\n // listUsers,\n // removeUsers,\n // replacePassword,\n // getUserDataTypes\n // }\n\n const methodConfigs = {\n getUser: { fn: getUser, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"get user\" },\n getUserByUsername: { fn: getUserByUsername, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"get user by username\" },\n listUsers: { fn: listUsers, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"list users\" },\n createUser: { fn: createUser, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"create user\" },\n updateUser: { fn: updateUser, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"update user\" },\n replacePassword: { fn: replacePassword, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"replace user password\" },\n removeUsers: { fn: removeUsers, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"remove users\" },\n suspendUsers: { fn: suspendUsers, allowUserTypes: [\"any\"] as const, actionName: \"suspend users\" },\n getDataTypes: { fn: getDataTypes, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"get user datatypes\" },\n validateUserContact: { fn: validateUserContact, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"validate user contact\" },\n };\n\n return ServiceFactory(\"UserService\", rest, methodConfigs);\n\n}\n\n"]}
1
+ {"version":3,"file":"UserService.js","sourceRoot":"","sources":["../../../src/services/user/UserService.ts"],"names":[],"mappings":";;;AAAA,qCAOkB;AAElB,6BAAwB;AAExB,uDAA0E;AAC1E,uDAAmI;AACnI,iEAAiK;AACjK,mDAAuH;AACvH,mDAAuH;AACvH,uDAAmI;AACnI,mDAAuH;AACvH,iDAAiH;AAGjH,+BAAgK;AAEhK,mCAAuF;AAEvF,mCAAuC;AACvC,uDAAmI;AAEnI,+BAAuC;AAE1B,QAAA,SAAS,GAAG;IACrB,QAAQ,EAAE,UAAU;IACpB,aAAa,EAAE,eAAe;IAC9B,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;CACR,CAAA;AA8LV,IAAI,aAAa,GAAG;IAChB,CAAC,OAAO,wBAAe,CAAC,OAAO,EAAE,CAAC,EAAE,SAAS;IAC7C,CAAC,OAAO,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n\nimport { z } from \"zod\";\n\nimport { UserPropService, UserPropReplaceProps } from \"./UserPropService\";\nimport { CustomerGetProps, CustomerCreateProps, CustomerListProps, CustomerUpdateProps, CustomerService } from \"./CustomerService\";\nimport { AdministratorGetProps, AdministratorCreateProps, AdministratorUpdateProps, AdministratorListProps, AdministratorService } from \"./AdministratorService\";\nimport { WorkerCreateProps, WorkerGetProps, WorkerUpdateProps, WorkerListProps, WorkerService } from \"./WorkerService\";\nimport { DriverCreateProps, DriverGetProps, DriverUpdateProps, DriverListProps, DriverService } from \"./DriverService\";\nimport { RetailerCreateProps, RetailerGetProps, RetailerUpdateProps, RetailerListProps, RetailerService } from \"./RetailerService\";\nimport { MemberCreateProps, MemberGetProps, MemberUpdateProps, MemberListProps, MemberService } from \"./MemberService\";\nimport { AgentCreateProps, AgentGetProps, AgentUpdateProps, AgentListProps, AgentService } from \"./AgentService\";\n\nimport { QueryList, QueryGet } from \"@/schema/common\";\nimport { buildSqlRelation, buildSqlRawSelect, buildSqlWhere, buildSqlSelect, buildSqlLimitOffset, buildSqlOrderBy, buildInjectionFieldsSqlSelect } from \"@/lib\";\n\nimport { validateLoginPasswordFormat, DefaultServiceProps, throwError } from \"@/utils\";\n\nimport { hashPassword } from \"@/utils\";\nimport { OperatorCreateProps, OperatorGetProps, OperatorListProps, OperatorService, OperatorUpdateProps } from \"./OperatorService\";\n\nimport { ServiceFactory } from \"@/lib\";\n\nexport const userTypes = {\n operator: \"operator\",\n administrator: \"administrator\",\n worker: \"worker\",\n supplier: \"supplier\",\n customer: \"customer\",\n driver: \"driver\",\n retailer: \"retailer\",\n member: \"member\",\n agent: \"agent\",\n} as const\n\nexport type UserType = typeof userTypes[keyof typeof userTypes]\n\nexport type UserServiceProps = DefaultServiceProps & {\n userType: UserType\n};\n\nexport type UserGetProps = QueryGet & {\n id: number,\n overrideUserType?: UserType | \"\"\n includePassword?: boolean,\n skipFilterAccountId?: boolean\n skipFilterUserType?: boolean\n};\n\nexport type UserGetByUsernameProps = QueryGet & {\n username: string,\n overrideUserType?: UserType | \"\"\n includePassword?: boolean,\n skipFilterAccountId?: boolean\n};\n\nexport type UserListProps = QueryList & {\n // id: number,\n includePassword?: boolean\n skipFilterAccountId?: boolean\n skipFilterUserType?: boolean\n};\n\nexport type UserRemoveProps = {\n ids: BigInt[]\n};\n\nexport type UserSuspendProps = {\n ids: BigInt[]\n};\n\nexport type User = {\n loginUsername: string\n loginPassword: string\n address: string\n // contact: string\n contact: {\n countryCode: number; // e.g., 1 for Canada\n phoneNumber: string; // digits only, mobile or landline\n }\n email: string\n firstname: string\n lastname: string\n status: boolean\n parentUserId?: number // optional for all user types\n}\n\nexport type UserOptionalLoginPassword = Omit<User, \"loginPassword\"> & {\n loginPassword?: string\n}\n\nexport type UserCreateProps = {\n userType?: UserType,\n skipLoginUsernameValidation?: boolean,\n skipLoginPasswordValidation?: boolean,\n skipContactValidation?: boolean,\n data: {\n user: User\n } & (\n // operator\n {\n operator: Omit<OperatorCreateProps[\"data\"][\"operator\"], \"userId\">,\n } |\n // customer\n {\n customer: Omit<CustomerCreateProps[\"data\"][\"customer\"], \"userId\">,\n } |\n // administrator\n {\n administrator: Omit<AdministratorCreateProps[\"data\"][\"administrator\"], \"userId\">\n props: {\n locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n }\n } |\n // worker\n {\n worker: Omit<WorkerCreateProps[\"data\"][\"worker\"], \"userId\">\n props: {\n locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n }\n } |\n // driver\n {\n driver: Omit<DriverCreateProps[\"data\"][\"driver\"], \"userId\">\n props: {\n locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n }\n } |\n // member\n {\n member: Omit<MemberCreateProps[\"data\"][\"member\"], \"userId\">\n // props: {\n // locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n // }\n } |\n // agent\n {\n agent: Omit<AgentCreateProps[\"data\"][\"agent\"], \"userId\">\n // props: {\n // locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n // }\n } |\n // retailer\n {\n retailer: Omit<RetailerCreateProps[\"data\"][\"retailer\"], \"userId\">\n // props: {\n // locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n // }\n }\n )\n}\n\nexport type UserUpdateProps = {\n id: number,\n userType?: UserType,\n skipLoginUsernameValidation?: boolean,\n skipLoginPasswordValidation?: boolean,\n skipContactValidation?: boolean,\n data: {\n user: UserOptionalLoginPassword\n } & (\n // operator\n {\n operator: Omit<OperatorUpdateProps[\"data\"][\"operator\"], \"userId\">\n } |\n // customer\n {\n customer: Omit<CustomerUpdateProps[\"data\"][\"customer\"], \"userId\">\n } |\n // administrator\n {\n administrator: Omit<AdministratorUpdateProps[\"data\"][\"administrator\"], \"userId\">\n props: {\n locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n }\n } |\n // worker\n {\n worker: Omit<WorkerUpdateProps[\"data\"][\"worker\"], \"userId\">\n props: {\n locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n }\n } |\n // driver\n {\n driver: Omit<DriverUpdateProps[\"data\"][\"driver\"], \"userId\">\n props: {\n locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n }\n } |\n // member\n {\n member: Omit<MemberUpdateProps[\"data\"][\"member\"], \"userId\">\n // props: {\n // locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n // }\n } |\n // agent\n {\n agent: Omit<AgentUpdateProps[\"data\"][\"agent\"], \"userId\">\n // props: {\n // locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n // }\n } |\n // retailer\n {\n retailer: Omit<RetailerUpdateProps[\"data\"][\"retailer\"], \"userId\">\n // props: {\n // locationIds: UserPropReplaceProps[\"data\"][\"userProp\"][\"locationIds\"]\n // }\n }\n )\n}\n\nexport type UserReplacePasswordProps = {\n id: number,\n data: {\n unhashLoginPassword: string\n },\n isOperator: boolean,\n skipLoginPasswordValidation?: boolean,\n}\n\nlet mainSqlSelect = {\n [`usr.${ModelUserFields.user_id}`]: \"user_id\",\n [`usr.${ModelUserFields.user_type}`]: \"user_type\",\n [`usr.${ModelUserFields.login_username}`]: \"username\",\n [`usr.${ModelUserFields.firstname}`]: \"firstname\",\n [`usr.${ModelUserFields.lastname}`]: \"lastname\",\n [`CONCAT(usr.${ModelUserFields.contact_country_code}, usr.${ModelUserFields.contact_phone_number})`]: \"contact\",\n [`usr.${ModelUserFields.contact_country_code}`]: \"contact_country_code\",\n [`usr.${ModelUserFields.contact_phone_number}`]: \"contact_phone_number\",\n [`usr.${ModelUserFields.email}`]: \"email\",\n [`usr.${ModelUserFields.address}`]: \"address\",\n [`usr.${ModelUserFields.parent_user_id}`]: \"parent_user_id\",\n [`usr.${ModelUserFields.status}`]: \"status\",\n}\n\nlet defaultSqlSelect = {\n [`usr.${ModelUserFields.createdatetime}`]: \"createdatetime\",\n [`creator.${ModelUserFields.login_username}`]: \"createusername\",\n [`usr.${ModelUserFields.updatedatetime}`]: \"updatedatetime\",\n [`updater.${ModelUserFields.login_username}`]: \"updateusername\",\n [`usr.${ModelUserFields.isdelete}`]: \"isdelete\",\n [`usr.${ModelUserFields.istrash}`]: \"istrash\",\n [`usr.${ModelUserFields.accountid}`]: \"accountid\",\n}\n\nexport const userParentSqlSelect = {\n [`parentuser.${ModelUserFields.user_id}`]: \"parent_user_id\",\n [`parentuser.${ModelUserFields.login_username}`]: \"parent_username\",\n [`parentuser.${ModelUserFields.user_type}`]: \"parent_user_type\",\n [`parentuser.${ModelUserFields.firstname}`]: \"parent_firstname\",\n [`parentuser.${ModelUserFields.lastname}`]: \"parent_lastname\",\n [`CONCAT(parentuser.${ModelUserFields.contact_country_code}, parentuser.${ModelUserFields.contact_phone_number})`]: \"parent_contact\",\n [`parentuser.${ModelUserFields.contact_country_code}`]: \"parent_contact_country_code\",\n [`parentuser.${ModelUserFields.contact_phone_number}`]: \"parent_contact_phone_number\",\n [`parentuser.${ModelUserFields.email}`]: \"parent_email\",\n [`parentuser.${ModelUserFields.address}`]: \"parent_address\",\n [`parentuser.${ModelUserFields.status}`]: \"parent_user_status\"\n}\n\nconst getCreatePayload = async (\n userType: UserType,\n data: UserCreateProps[\"data\"],\n contact: {\n countryCode: number,\n phoneNumber: string\n }\n) => {\n\n if (\"user\" in data) {\n\n // have to hash the password\n\n return {\n [`${ModelUserFields.login_username}`]: data.user.loginUsername,\n [`${ModelUserFields.login_password}`]: await hashPassword(data.user.loginPassword),\n [`${ModelUserFields.address}`]: data.user.address,\n [`${ModelUserFields.contact_country_code}`]: contact.countryCode,\n [`${ModelUserFields.contact_phone_number}`]: contact.phoneNumber,\n [`${ModelUserFields.email}`]: data.user.email,\n [`${ModelUserFields.firstname}`]: data.user.firstname,\n [`${ModelUserFields.lastname}`]: data.user.lastname,\n [`${ModelUserFields.status}`]: Boolean(data.user.status),\n [`${ModelUserFields.user_type}`]: `${userType}`,\n ...(data?.user?.parentUserId ? { [`${ModelUserFields.parent_user_id}`]: Number(data.user.parentUserId) } : {})\n }\n }\n\n return false\n\n}\n\nconst getUpdatePayload = async (\n userType: UserType,\n data: UserUpdateProps[\"data\"],\n contact: {\n countryCode: number,\n phoneNumber: string\n }\n) => {\n\n if (\"user\" in data) {\n\n const newHashPassword = data?.user?.loginPassword ? await hashPassword(data.user.loginPassword) : \"\"\n\n return {\n [`${ModelUserFields.login_username}`]: data.user.loginUsername,\n ...(newHashPassword ? { [`${ModelUserFields.login_password}`]: newHashPassword } : {}),\n [`${ModelUserFields.address}`]: data.user.address,\n [`${ModelUserFields.contact_country_code}`]: contact.countryCode,\n [`${ModelUserFields.contact_phone_number}`]: contact.phoneNumber,\n [`${ModelUserFields.email}`]: data.user.email,\n [`${ModelUserFields.firstname}`]: data.user.firstname,\n [`${ModelUserFields.lastname}`]: data.user.lastname,\n [`${ModelUserFields.status}`]: Boolean(data.user.status),\n [`${ModelUserFields.user_type}`]: `${userType}`,\n ...(data?.user?.parentUserId ? { [`${ModelUserFields.parent_user_id}`]: Number(data.user.parentUserId) } : {})\n }\n }\n\n return false\n\n}\n\n// Example reserved words for username\nexport const loginUsernameReservedWords = [\n \"admin\", \"administrator\", \"root\", \"system\", \"operator\", \"moderator\", \"owner\", \"manager\",\n \"user\", \"users\", \"account\", \"guest\", \"login\", \"logout\", \"signup\", \"register\", \"auth\",\n \"api\", \"www\", \"app\", \"support\", \"help\", \"dashboard\", \"portal\", \"console\", \"control\", \"ops\",\n \"test\", \"demo\", \"beta\", \"alpha\", \"dev\", \"development\", \"staging\", \"prod\", \"production\",\n \"security\", \"privacy\", \"terms\", \"policy\", \"legal\", \"about\", \"company\", \"team\", \"teams\",\n \"billing\", \"payment\", \"invoice\", \"finance\", \"financeadmin\", \"subscription\", \"plan\", \"plans\",\n \"rootadmin\", \"superuser\", \"staff\", \"moderation\", \"systemadmin\", \"sysadmin\", \"internal\",\n \"management\", \"supportdesk\", \"helpdesk\", \"contact\", \"feedback\", \"news\", \"blog\", \"media\",\n \"press\", \"events\", \"calendar\", \"forum\", \"community\", \"chat\", \"messaging\", \"notifications\",\n \"alerts\", \"reports\", \"analytics\", \"metrics\", \"logs\", \"history\", \"archive\", \"backup\",\n \"restore\", \"files\", \"documents\", \"resources\", \"library\", \"gallery\", \"images\", \"videos\",\n \"downloads\", \"uploads\", \"templates\", \"home\", \"index\", \"static\", \"public\", \"webmaster\"\n];\n\n// Zod schema for username\nexport const loginUsernameSchema = z\n .string()\n .min(5, { message: \"Login username must be at least 5 characters\" })\n .max(63, { message: \"Login username must be at most 63 characters\" })\n .regex(\n /^[a-z0-9]([a-z0-9-_]{3,61}[a-z0-9])?$/,\n \"Login username can only contain lowercase letters, numbers, hyphens, and underscores, cannot start or end with a hyphen or underscore\"\n )\n .transform((val) => val.toLowerCase().trim()) // normalize\n .refine((val) => !loginUsernameReservedWords.includes(val), {\n message: \"This login username is reserved. Please choose another one\",\n });\n\nexport const UserService = (props: UserServiceProps) => {\n\n const {\n userType = \"administrator\",\n ...rest\n } = props\n\n const userModel = UserModel({ ...rest })\n const countryModel = CountryModel({ ...rest })\n\n const userPropService = UserPropService({ ...rest, userPropType: \"LOCATION_ID\" })\n const customerService = CustomerService({ ...rest })\n const administratorService = AdministratorService({ ...rest })\n const operatorService = OperatorService({ ...rest })\n const workerService = WorkerService({ ...rest })\n const driverService = DriverService({ ...rest })\n const retailerService = RetailerService({ ...rest })\n const memberService = MemberService({ ...rest })\n const agentService = AgentService({ ...rest })\n\n const validateUserContactPhoneNumber = (val: string) => {\n // Must be numeric\n if (!/^\\d+$/.test(val)) {\n throw new Error(`Contact No. only allowed numbers`);\n }\n\n // Must have realistic length (4 to 15 digits)\n if (val.length < 4 || val.length > 15) {\n throw new Error(`Contact No. length must be between 4 and 15 digits`);\n }\n\n return true;\n };\n\n const validateUserContactCountryCode = async (countryCode: number) => {\n\n // 1. Load active countries\n const activeCountries: ModelCountry[] = await countryModel.list({\n where: {\n [`${ModelCountryFields.isdelete}`]: false,\n [`${ModelCountryFields.istrash}`]: false,\n [`${ModelCountryFields.status}`]: true\n }\n })\n\n // Check if country code exists\n const exists = activeCountries.some(c => c.phone_code === countryCode);\n\n if (!exists) {\n throw new Error(`Invalid country code: ${countryCode}`);\n }\n\n return true; // valid\n\n }\n\n const validateUserContact = async (countryCode: number, phoneNumber: string) => {\n\n try {\n // validate the phone number without country code\n validateUserContactPhoneNumber(phoneNumber)\n\n // validate user contact country code\n await validateUserContactCountryCode(countryCode)\n\n return true\n\n } catch (error: unknown) {\n const msg = error instanceof Error ? error.message : String(error);\n throw new Error(`Invalid user contact no.: ${msg}, provided: ${countryCode} ${phoneNumber}`);\n }\n\n }\n\n const validateLoginUsernameFormat = (loginUsername: string) => {\n try {\n return loginUsernameSchema.parse(loginUsername); // throws if invalid\n } catch (err) {\n if (err instanceof z.ZodError) {\n throw new Error(\n `Invalid login username: \"${loginUsername}\". ` +\n err.errors.map((e) => e.message).join(\"; \")\n );\n }\n throw err;\n }\n };\n\n const createUser = async ({\n data,\n userType: overrideUserType,\n skipLoginPasswordValidation = false,\n skipLoginUsernameValidation = false,\n skipContactValidation = false\n }: UserCreateProps) => {\n\n const _userType = overrideUserType || userType\n\n // validate the credential contact no\n const userLoginUsername = data.user.loginUsername\n const userLoginPassword = data.user.loginPassword\n const userContactCountryCode = data.user.contact.countryCode\n const userContactPhoneNumber = data.user.contact.phoneNumber\n\n // validate the contact no only can be digit in text only\n // validate the country code in prefix\n if (skipContactValidation === false) {\n await validateUserContact(userContactCountryCode, userContactPhoneNumber)\n }\n\n // validate login username\n if (skipLoginUsernameValidation === false) {\n validateLoginUsernameFormat(userLoginUsername)\n }\n\n // validate login password\n if (skipLoginPasswordValidation === false) {\n validateLoginPasswordFormat(userLoginPassword)\n }\n\n // check the username duplicated?\n const checkUsername = await userModel.list({\n limit: 1,\n offset: 0,\n orderBy: {\n [`${ModelUserFields.user_id}`]: \"asc\"\n },\n include: [],\n where: {\n [`${ModelUserFields.login_username}`]: data.user.loginUsername,\n [`${ModelUserFields.accountid}`]: Number(rest.accountId),\n [`${ModelUserFields.isdelete}`]: false,\n [`${ModelUserFields.istrash}`]: false\n },\n })\n\n // console.log('ch', checkUsername)\n\n if (checkUsername.length > 0) throwError(`Duplicated username: ${data.user.loginUsername}(${checkUsername[0]?.user_type})`)\n\n // validation before insertion\n // if (_userType === \"member\" && \"member\" in data) {\n\n // const memberOwnerUserId = data?.member?.ownerUserId ?? \"\";\n\n // validate owner user id\n // if (memberOwnerUserId) {\n // await memberService.validateMemberOwnerUserId(memberOwnerUserId)\n // }\n\n // }\n\n // if (_userType === \"agent\" && \"agent\" in data) {\n\n // const agentOwnerUserId = data?.agent?.ownerUserId ?? \"\";\n\n // validate owner user id\n // if (agentOwnerUserId) {\n // await agentService.validateAgentOwnerUserId(agentOwnerUserId)\n // }\n\n // }\n\n const _data = await getCreatePayload(\n _userType,\n data,\n {\n countryCode: userContactCountryCode,\n phoneNumber: userContactPhoneNumber\n }\n )\n\n if (!_data) {\n throw new Error(`Invalid create payload: ${JSON.stringify(_data)}`);\n }\n\n // create user\n let responseUser = await userModel.create({ data: _data })\n\n let newUserId = responseUser.user_id\n\n let response: any = {}\n\n if (_userType === \"customer\" && \"customer\" in data) {\n\n let dataCustomer: CustomerCreateProps[\"data\"] = {\n customer: {\n ...data.customer,\n userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create customer\n await customerService.createCustomer({ data: dataCustomer })\n\n response = await customerService.getCustomer({ id: Number(newUserId), datatypes: [] })\n }\n\n if (_userType === \"administrator\" && \"administrator\" in data) {\n\n let dataAdministrator: AdministratorCreateProps[\"data\"] = {\n administrator: {\n ...data.administrator,\n userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create administrator\n await administratorService.createAdministrator({ data: dataAdministrator })\n\n // replace user prop\n await userPropService.replaceUserProp({\n userPropType: \"LOCATION_ID\",\n data: {\n userProp: {\n userId: Number(newUserId),\n locationIds: data.props.locationIds\n }\n }\n })\n\n response = await administratorService.getAdministrator({ id: Number(newUserId), datatypes: [] })\n }\n\n if (_userType === \"operator\" && \"operator\" in data) {\n\n let dataOperator: OperatorCreateProps[\"data\"] = {\n operator: {\n ...data.operator,\n userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create operator\n await operatorService.createOperator({ data: dataOperator })\n\n response = await operatorService.getOperator({ id: Number(newUserId), datatypes: [] })\n }\n\n if (_userType === \"worker\" && \"worker\" in data) {\n\n let dataWorker: WorkerCreateProps[\"data\"] = {\n worker: {\n ...data.worker,\n userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create worker\n await workerService.createWorker({ data: dataWorker })\n\n // replace user prop\n await userPropService.replaceUserProp({\n userPropType: \"LOCATION_ID\",\n data: {\n userProp: {\n userId: Number(newUserId),\n locationIds: data.props.locationIds\n }\n }\n })\n\n response = await workerService.getWorker({ id: Number(newUserId), datatypes: [] })\n }\n\n if (_userType === \"driver\" && \"driver\" in data) {\n\n let dataDriver: DriverCreateProps[\"data\"] = {\n driver: {\n ...data.driver,\n userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create driver\n await driverService.createDriver({ data: dataDriver })\n\n // replace user prop\n await userPropService.replaceUserProp({\n userPropType: \"LOCATION_ID\",\n data: {\n userProp: {\n userId: Number(newUserId),\n locationIds: data.props.locationIds\n }\n }\n })\n\n response = await driverService.getDriver({ id: Number(newUserId), datatypes: [] })\n }\n\n if (_userType === \"member\" && \"member\" in data) {\n\n let dataMember: MemberCreateProps[\"data\"] = {\n member: {\n ...data.member,\n // userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create member\n await memberService.createMember({ userId: Number(newUserId), data: dataMember })\n\n // replace user prop\n // await userPropService.replaceUserProp({\n // userPropType: \"LOCATION_ID\",\n // data: {\n // userProp: {\n // userId: Number(newUserId),\n // locationIds: data.props.locationIds\n // }\n // }\n // })\n\n response = await memberService.getMember({ id: Number(newUserId), datatypes: [] })\n }\n\n if (_userType === \"agent\" && \"agent\" in data) {\n\n let dataAgent: AgentCreateProps[\"data\"] = {\n agent: {\n ...data.agent,\n // userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create agent\n await agentService.createAgent({ userId: Number(newUserId), data: dataAgent })\n\n // replace user prop\n // await userPropService.replaceUserProp({\n // userPropType: \"LOCATION_ID\",\n // data: {\n // userProp: {\n // userId: Number(newUserId),\n // locationIds: data.props.locationIds\n // }\n // }\n // })\n\n response = await agentService.getAgent({ id: Number(newUserId), datatypes: [] })\n }\n\n if (_userType === \"retailer\" && \"retailer\" in data) {\n\n let dataRetailer: RetailerCreateProps[\"data\"] = {\n retailer: {\n ...data.retailer,\n userId: Number(newUserId) ?? \"\"\n }\n }\n\n // create retailer\n await retailerService.createRetailer({ data: dataRetailer })\n\n response = await retailerService.getRetailer({ id: Number(newUserId), datatypes: [] })\n }\n\n return response\n }\n\n const updateUser = async ({\n id,\n data,\n userType: overrideUserType,\n skipLoginUsernameValidation = false,\n skipLoginPasswordValidation = false,\n skipContactValidation = false\n }: UserUpdateProps) => {\n\n const _userType = overrideUserType || userType\n\n // validate the credential contact no\n const userLoginUsername = data.user.loginUsername\n const userLoginPassword = data.user?.loginPassword ?? \"\"\n const userContactCountryCode = data.user.contact.countryCode\n const userContactPhoneNumber = data.user.contact.phoneNumber\n\n // validate the contact no only can be digit in text only\n // validate the country code in prefix\n if (skipContactValidation === false) {\n await validateUserContact(userContactCountryCode, userContactPhoneNumber)\n }\n\n // validate login username\n if (skipLoginUsernameValidation === false) {\n validateLoginUsernameFormat(userLoginUsername)\n }\n\n // validate login password\n if (userLoginPassword) {\n if (skipLoginPasswordValidation === false) {\n validateLoginPasswordFormat(userLoginPassword)\n }\n }\n\n // check the username duplicated?\n const checkUsername = await userModel.list({\n limit: 1,\n offset: 0,\n orderBy: {\n [`${ModelUserFields.user_id}`]: \"asc\"\n },\n include: [],\n where: {\n [`${ModelUserFields.login_username}`]: data.user.loginUsername,\n [`${ModelUserFields.isdelete}`]: false,\n [`${ModelUserFields.istrash}`]: false,\n [`${ModelUserFields.accountid}`]: rest.accountId,\n },\n })\n\n // console.log('ch', checkUsername)\n\n if (checkUsername.length > 0) {\n if (Number(checkUsername[0]?.user_id) !== Number(id)) { // if not self user id\n throwError(`Duplicated username: ${data.user.loginUsername}(${checkUsername[0]?.user_type})`)\n }\n }\n\n // validation before insertion\n // if (_userType === \"member\" && \"member\" in data) {\n // }\n\n const _data = await getUpdatePayload(\n _userType,\n data,\n {\n countryCode: userContactCountryCode,\n phoneNumber: userContactPhoneNumber\n }\n )\n\n if (!_data) {\n throw new Error(`Invalid update payload: ${JSON.stringify(_data)}`);\n }\n\n // update user\n let responseUser = await userModel.update({ id, data: _data })\n\n let updateUserId = responseUser.user_id\n\n let response: any = {}\n\n if (_userType === \"customer\" && \"customer\" in data) {\n\n let dataCustomer: CustomerUpdateProps[\"data\"] = {\n customer: {\n ...data.customer\n }\n }\n\n await customerService.updateCustomer({ userId: Number(updateUserId), data: dataCustomer })\n\n response = await customerService.getCustomer({ id: Number(updateUserId), datatypes: [] })\n\n }\n\n if (_userType === \"operator\" && \"operator\" in data) {\n\n let dataOperator: OperatorUpdateProps[\"data\"] = {\n operator: {\n ...data.operator\n }\n }\n\n await operatorService.updateOperator({ userId: Number(updateUserId), data: dataOperator })\n\n response = await operatorService.getOperator({ id: Number(updateUserId), datatypes: [] })\n\n }\n\n if (_userType === \"administrator\" && \"administrator\" in data) {\n\n let dataCustomer: AdministratorUpdateProps[\"data\"] = {\n administrator: {\n ...data.administrator\n }\n }\n\n await administratorService.updateAdministrator({ userId: Number(updateUserId), data: dataCustomer })\n\n // replace user prop\n await userPropService.replaceUserProp({\n userPropType: \"LOCATION_ID\",\n data: {\n userProp: {\n userId: Number(updateUserId),\n locationIds: data.props.locationIds\n }\n }\n })\n\n response = await administratorService.getAdministrator({ id: Number(updateUserId), datatypes: [] })\n\n }\n\n if (_userType === \"worker\" && \"worker\" in data) {\n\n let dataWorker: WorkerUpdateProps[\"data\"] = {\n worker: {\n ...data.worker\n }\n }\n\n await workerService.updateWorker({ userId: Number(updateUserId), data: dataWorker })\n\n // replace user prop\n await userPropService.replaceUserProp({\n userPropType: \"LOCATION_ID\",\n data: {\n userProp: {\n userId: Number(updateUserId),\n locationIds: data.props.locationIds\n }\n }\n })\n\n response = await workerService.getWorker({ id: Number(updateUserId), datatypes: [] })\n\n }\n\n if (_userType === \"driver\" && \"driver\" in data) {\n\n let dataDriver: DriverUpdateProps[\"data\"] = {\n driver: {\n ...data.driver\n }\n }\n\n await driverService.updateDriver({ userId: Number(updateUserId), data: dataDriver })\n\n // replace user prop\n await userPropService.replaceUserProp({\n userPropType: \"LOCATION_ID\",\n data: {\n userProp: {\n userId: Number(updateUserId),\n locationIds: data.props.locationIds\n }\n }\n })\n\n response = await driverService.getDriver({ id: Number(updateUserId), datatypes: [] })\n\n }\n\n if (_userType === \"member\" && \"member\" in data) {\n\n let dataMember: MemberUpdateProps[\"data\"] = {\n member: {\n ...data.member\n }\n }\n\n await memberService.updateMember({ userId: Number(updateUserId), data: dataMember })\n\n // replace user prop\n // await userPropService.replaceUserProp({\n // userPropType: \"LOCATION_ID\",\n // data: {\n // userProp: {\n // userId: Number(updateUserId),\n // locationIds: data.props.locationIds\n // }\n // }\n // })\n\n response = await memberService.getMember({ id: Number(updateUserId), datatypes: [] })\n\n }\n\n if (_userType === \"agent\" && \"agent\" in data) {\n\n let dataAgent: AgentUpdateProps[\"data\"] = {\n agent: {\n ...data.agent\n }\n }\n\n await agentService.updateAgent({ userId: Number(updateUserId), data: dataAgent })\n\n // replace user prop\n // await userPropService.replaceUserProp({\n // userPropType: \"LOCATION_ID\",\n // data: {\n // userProp: {\n // userId: Number(updateUserId),\n // locationIds: data.props.locationIds\n // }\n // }\n // })\n\n response = await agentService.getAgent({ id: Number(updateUserId), datatypes: [] })\n\n }\n\n if (_userType === \"retailer\" && \"retailer\" in data) {\n\n let dataRetailer: RetailerUpdateProps[\"data\"] = {\n retailer: {\n ...data.retailer\n }\n }\n\n await retailerService.updateRetailer({ userId: Number(updateUserId), data: dataRetailer })\n\n response = await retailerService.getRetailer({ id: Number(updateUserId), datatypes: [] })\n\n }\n\n return response\n }\n\n const getUser = async ({ id, datatypes = [], includePassword = false, overrideUserType = \"\", skipFilterAccountId = false, skipFilterUserType = false }: UserGetProps) => {\n\n let data: any = {}\n\n if (skipFilterUserType === true) {\n\n let { data } = await listUsers({\n includePassword,\n limit: 1,\n offset: 0,\n filters: [{ field: \"user_id\", operator: \"=\", value: id }],\n sortfield: \"user_id\",\n sortorder: \"ASC\",\n datatypes,\n skipFilterAccountId,\n skipFilterUserType\n })\n\n return data[0] ?? null;\n }\n\n const _userType = overrideUserType ? overrideUserType : userType\n\n if (_userType === \"customer\") {\n data = await customerService.getCustomer({ id, datatypes: datatypes as CustomerGetProps[\"datatypes\"], includePassword })\n }\n\n if (_userType === \"operator\") {\n data = await operatorService.getOperator({ id, datatypes: datatypes as OperatorGetProps[\"datatypes\"], includePassword })\n }\n\n if (_userType === \"administrator\") {\n data = await administratorService.getAdministrator({ id, datatypes: datatypes as AdministratorGetProps[\"datatypes\"], includePassword, skipFilterAccountId })\n }\n\n if (_userType === \"worker\") {\n data = await workerService.getWorker({ id, datatypes: datatypes as WorkerGetProps[\"datatypes\"], includePassword })\n }\n\n if (_userType === \"driver\") {\n data = await driverService.getDriver({ id, datatypes: datatypes as DriverGetProps[\"datatypes\"], includePassword })\n }\n\n if (_userType === \"member\") {\n data = await memberService.getMember({ id, datatypes: datatypes as MemberGetProps[\"datatypes\"], includePassword })\n }\n\n if (_userType === \"agent\") {\n data = await agentService.getAgent({ id, datatypes: datatypes as AgentGetProps[\"datatypes\"], includePassword })\n }\n\n if (_userType === \"retailer\") {\n data = await retailerService.getRetailer({ id, datatypes: datatypes as RetailerGetProps[\"datatypes\"], includePassword })\n }\n\n if (!data) {\n throw new Error(`Invalid id: ${id}`);\n }\n\n return data\n };\n\n const getUserByUsername = async ({ username, datatypes = [], includePassword = false, overrideUserType = \"\", skipFilterAccountId = false }: UserGetByUsernameProps) => {\n\n let data: any = {}\n\n const _userType = overrideUserType ? overrideUserType : userType\n\n // if (_userType === \"customer\") {\n // data = await customerService.getCustomer({ id, datatypes: datatypes as CustomerGetProps[\"datatypes\"], includePassword })\n // }\n\n if (_userType === \"operator\") {\n data = await operatorService.getOperatorByUsername({ username, datatypes: datatypes as OperatorGetProps[\"datatypes\"], includePassword })\n }\n\n if (_userType === \"administrator\") {\n data = await administratorService.getAdministratorByUsername({ username, datatypes: datatypes as AdministratorGetProps[\"datatypes\"], includePassword, skipFilterAccountId })\n }\n\n // if (_userType === \"worker\") {\n // data = await workerService.getWorker({ id, datatypes: datatypes as WorkerGetProps[\"datatypes\"], includePassword })\n // }\n\n // if (_userType === \"driver\") {\n // data = await driverService.getDriver({ id, datatypes: datatypes as DriverGetProps[\"datatypes\"], includePassword })\n // }\n\n // if (_userType === \"member\") {\n // data = await memberService.getMember({ id, datatypes: datatypes as MemberGetProps[\"datatypes\"], includePassword })\n // }\n\n // if (_userType === \"agent\") {\n // data = await agentService.getAgent({ id, datatypes: datatypes as AgentGetProps[\"datatypes\"], includePassword })\n // }\n\n // if (_userType === \"retailer\") {\n // data = await retailerService.getRetailer({ id, datatypes: datatypes as RetailerGetProps[\"datatypes\"], includePassword })\n // }\n\n if (!data) {\n throw new Error(`Invalid username: ${username}`);\n }\n\n return data\n };\n\n const listUsers = async ({ limit, offset, filters = [], sortfield, sortorder, datatypes, includePassword = false, skipFilterAccountId = false, skipFilterUserType = false }: UserListProps) => {\n\n let data: any[] = [];\n let total = 0;\n\n if (skipFilterUserType === true) {\n\n mainSqlSelect = {\n ...mainSqlSelect,\n ...(includePassword ? { [`usr.${ModelUserFields.login_password}`]: \"password\" } : {}),\n }\n\n let sqlSelect = [\n `COUNT(*) OVER() as filtered_count`,\n buildSqlSelect(``, mainSqlSelect),\n buildSqlSelect(``, defaultSqlSelect)\n ]\n\n let sqlRelation = [\n buildSqlRelation(\"left\", \"usr\", \"users\", \"parentuser\", [\"usr.parent_user_id = parentuser.user_id\", \"parentuser.isdelete = false\", \"parentuser.istrash = false\"]),\n buildSqlRelation(\"left\", \"usr\", \"users\", \"creator\", [\"usr.createuserid = creator.user_id\", \"creator.isdelete = false\", \"creator.istrash = false\"]),\n buildSqlRelation(\"left\", \"usr\", \"users\", \"updater\", [\"usr.updateuserid = updater.user_id\", \"updater.isdelete = false\", \"updater.istrash = false\"])\n ]\n\n let sqlGroupBy: string[] = [\n ...Object.keys(mainSqlSelect),\n ...Object.keys(defaultSqlSelect)\n ]\n\n let filterColumns = {\n ...mainSqlSelect,\n ...defaultSqlSelect\n }\n\n let sqlWhere = [\n `usr.isdelete = false`,\n `usr.istrash = false`,\n ...(filters.length ? [buildSqlWhere(filters, filterColumns)?.where] : []),\n ]\n\n let sqlOrderby = buildSqlOrderBy(sortfield, sortorder)\n let sqlLimitOffset = buildSqlLimitOffset(limit, offset)\n\n const sqlRaw = buildSqlRawSelect({\n tableName: \"users\",\n mainAlias: \"usr\",\n accountId: rest.accountId,\n sqlSelect,\n sqlRelation,\n sqlWhere,\n sqlGroupBy,\n sqlOrderby,\n sqlLimitOffset,\n skipFilterAccountId\n })\n\n data = await userModel.raw(sqlRaw)\n\n const response = {\n data: data.map(({ filtered_count, ...rest }) => rest),\n total: data.length ? Number(data[0].filtered_count) : 0\n }\n\n return response\n }\n\n if (userType === \"customer\") {\n ({ data, total } = await customerService.listCustomers(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as CustomerListProps[\"datatypes\"] }\n ))\n }\n\n if (userType === \"operator\") {\n ({ data, total } = await operatorService.listOperators(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as OperatorListProps[\"datatypes\"] }\n ))\n }\n\n if (userType === \"administrator\") {\n ({ data, total } = await administratorService.listAdministrators(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as AdministratorListProps[\"datatypes\"], skipFilterAccountId }\n ))\n }\n\n if (userType === \"worker\") {\n ({ data, total } = await workerService.listWorkers(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as WorkerListProps[\"datatypes\"] }\n ))\n }\n\n if (userType === \"driver\") {\n ({ data, total } = await driverService.listDrivers(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as DriverListProps[\"datatypes\"] }\n ))\n }\n\n if (userType === \"member\") {\n ({ data, total } = await memberService.listMembers(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as MemberListProps[\"datatypes\"] }\n ))\n }\n\n if (userType === \"agent\") {\n ({ data, total } = await agentService.listAgents(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as AgentListProps[\"datatypes\"] }\n ))\n }\n\n if (userType === \"retailer\") {\n ({ data, total } = await retailerService.listRetailers(\n { includePassword, limit, offset, filters, sortfield, sortorder, datatypes: datatypes as RetailerListProps[\"datatypes\"] }\n ))\n }\n\n return {\n data,\n total\n }\n };\n\n const removeUsers = async ({ ids }: UserRemoveProps) => {\n\n if (!ids.length) throwError('id is required');\n\n let response: any[] = []\n\n if (userType === \"customer\") {\n response = await customerService.removeCustomers({ userIds: ids })\n }\n\n if (userType === \"operator\") {\n response = await operatorService.removeOperators({ userIds: ids })\n }\n\n if (userType === \"administrator\") {\n\n // have to check the ids is is_owner account\n const { data: administrators } = await administratorService.listAdministrators({\n limit: 9999,\n offset: 0,\n filters: [{\n field: `${ModelAdministratorFields.user_id}`,\n operator: \"where_in\",\n value: ids\n }],\n sortfield: `${ModelAdministratorFields.administrator_id}`,\n sortorder: \"ASC\",\n datatypes: []\n })\n\n const ownerAdministrators = administrators.filter(i => i.is_owner === true)\n\n if (ownerAdministrators.length > 0) {\n throw new Error(`Cannot delete on administrator owner user ids: ${ownerAdministrators.map(i => i.user_id)}`);\n }\n\n response = await administratorService.removeAdministrators({ userIds: ids })\n await userPropService.removeUserProps({ userIds: ids })\n }\n\n if (userType === \"worker\") {\n response = await workerService.removeWorkers({ userIds: ids })\n await userPropService.removeUserProps({ userIds: ids })\n }\n\n if (userType === \"driver\") {\n response = await driverService.removeDrivers({ userIds: ids })\n await userPropService.removeUserProps({ userIds: ids })\n }\n\n if (userType === \"member\") {\n response = await memberService.removeMembers({ userIds: ids })\n // await userPropService.removeUserProps({ userIds: ids })\n }\n\n if (userType === \"agent\") {\n response = await agentService.removeAgents({ userIds: ids })\n // await userPropService.removeUserProps({ userIds: ids })\n }\n\n if (userType === \"retailer\") {\n response = await retailerService.removeRetailers({ userIds: ids })\n // await userPropService.removeUserProps({ userIds: ids })\n }\n\n // remove user\n let responseUser = await userModel.remove({ ids: ids.map(i => Number(i)) })\n\n response.forEach((i, index) => {\n i.user = responseUser[index]\n })\n\n return response\n };\n\n const replacePassword = async ({ id, data, isOperator = false, skipLoginPasswordValidation = false }: UserReplacePasswordProps) => {\n\n const passwordUserModel = UserModel({\n ...rest,\n ...(isOperator === true ? { isOperator } : {})\n })\n\n // validate login password\n if (skipLoginPasswordValidation === false) {\n validateLoginPasswordFormat(data?.unhashLoginPassword)\n }\n\n // update user password\n let responseUser = await passwordUserModel.update({\n id,\n data: {\n login_password: await hashPassword(data?.unhashLoginPassword)\n }\n })\n\n let updateUserId = responseUser.user_id\n\n let response = await getUser({ id: Number(updateUserId), includePassword: false, datatypes: [] })\n\n return response\n }\n\n const suspendUsers = async ({ ids }: UserSuspendProps) => {\n\n if (!ids.length) throwError('id is required');\n\n // change users status\n let response = await userModel.update({\n where: {\n [`${ModelUserFields.user_id}`]: {\n in: ids.map((i: any) => Number(i))\n }\n },\n data: {\n [`${ModelUserFields.status}`]: false\n }\n })\n\n const { login_password, ...safeResponse } = response;\n\n return safeResponse\n };\n\n const getDataTypes = () => {\n\n let data: any[] = [];\n let total = 0;\n\n if (userType === \"customer\") {\n data = customerService.getDataTypes()\n }\n\n if (userType === \"operator\") {\n data = operatorService.getDataTypes()\n }\n\n if (userType === \"administrator\") {\n data = administratorService.getDataTypes()\n }\n\n if (userType === \"worker\") {\n data = workerService.getDataTypes()\n }\n\n if (userType === \"driver\") {\n data = driverService.getDataTypes()\n }\n\n if (userType === \"member\") {\n data = memberService.getDataTypes()\n }\n\n if (userType === \"agent\") {\n data = agentService.getDataTypes()\n }\n\n if (userType === \"retailer\") {\n data = retailerService.getDataTypes()\n }\n\n return data\n };\n\n // return {\n // createUser,\n // updateUser,\n // getUser,\n // listUsers,\n // removeUsers,\n // replacePassword,\n // getUserDataTypes\n // }\n\n const methodConfigs = {\n getUser: { fn: getUser, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"get user\" },\n getUserByUsername: { fn: getUserByUsername, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"get user by username\" },\n listUsers: { fn: listUsers, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"list users\" },\n createUser: { fn: createUser, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"create user\" },\n updateUser: { fn: updateUser, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"update user\" },\n replacePassword: { fn: replacePassword, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"replace user password\" },\n removeUsers: { fn: removeUsers, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"remove users\" },\n suspendUsers: { fn: suspendUsers, allowUserTypes: [\"any\"] as const, actionName: \"suspend users\" },\n getDataTypes: { fn: getDataTypes, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"get user datatypes\" },\n validateUserContact: { fn: validateUserContact, allowUserTypes: [\"operator\", \"administrator\"] as const, actionName: \"validate user contact\" },\n };\n\n return ServiceFactory(\"UserService\", rest, methodConfigs);\n\n}\n\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "storemw-core-api",
3
- "version": "1.0.165",
3
+ "version": "1.0.167",
4
4
  "description": "STOREMW Core API",
5
5
  "main": "dist/app.js",
6
6
  "types": "dist/app.d.ts",