fix: autofix
This commit is contained in:
@@ -86,7 +86,7 @@ class RegionService extends BaseService {
|
||||
* @return {Region} the newly created region
|
||||
*/
|
||||
async create(regionObject) {
|
||||
return this.atomicPhase_(async manager => {
|
||||
return this.atomicPhase_(async (manager) => {
|
||||
const regionRepository = manager.getCustomRepository(
|
||||
this.regionRepository_
|
||||
)
|
||||
@@ -144,7 +144,7 @@ class RegionService extends BaseService {
|
||||
* @return {Promise} the result of the update operation
|
||||
*/
|
||||
async update(regionId, update) {
|
||||
return this.atomicPhase_(async manager => {
|
||||
return this.atomicPhase_(async (manager) => {
|
||||
const regionRepository = manager.getCustomRepository(
|
||||
this.regionRepository_
|
||||
)
|
||||
@@ -217,17 +217,17 @@ class RegionService extends BaseService {
|
||||
|
||||
if (region.countries) {
|
||||
region.countries = await Promise.all(
|
||||
region.countries.map(countryCode =>
|
||||
region.countries.map((countryCode) =>
|
||||
this.validateCountry_(countryCode, id)
|
||||
)
|
||||
).catch(err => {
|
||||
).catch((err) => {
|
||||
throw err
|
||||
})
|
||||
}
|
||||
|
||||
if (region.payment_providers) {
|
||||
region.payment_providers = await Promise.all(
|
||||
region.payment_providers.map(async pId => {
|
||||
region.payment_providers.map(async (pId) => {
|
||||
const pp = await ppRepository.findOne({ where: { id: pId } })
|
||||
if (!pp) {
|
||||
throw new MedusaError(
|
||||
@@ -243,7 +243,7 @@ class RegionService extends BaseService {
|
||||
|
||||
if (region.fulfillment_providers) {
|
||||
region.fulfillment_providers = await Promise.all(
|
||||
region.fulfillment_providers.map(async fId => {
|
||||
region.fulfillment_providers.map(async (fId) => {
|
||||
const fp = await fpRepository.findOne({ where: { id: fId } })
|
||||
if (!fp) {
|
||||
throw new MedusaError(
|
||||
@@ -282,7 +282,7 @@ class RegionService extends BaseService {
|
||||
.withTransaction(this.transactionManager_)
|
||||
.retrieve(["currencies"])
|
||||
|
||||
const storeCurrencies = store.currencies.map(curr => curr.code)
|
||||
const storeCurrencies = store.currencies.map((curr) => curr.code)
|
||||
|
||||
if (!storeCurrencies.includes(currencyCode.toLowerCase())) {
|
||||
throw new MedusaError(
|
||||
@@ -304,7 +304,7 @@ class RegionService extends BaseService {
|
||||
)
|
||||
|
||||
const countryCode = code.toUpperCase()
|
||||
const validCountry = countries.find(c => c.alpha2 === countryCode)
|
||||
const validCountry = countries.find((c) => c.alpha2 === countryCode)
|
||||
if (!validCountry) {
|
||||
throw new MedusaError(
|
||||
MedusaError.Types.INVALID_DATA,
|
||||
@@ -378,7 +378,7 @@ class RegionService extends BaseService {
|
||||
* @return {Promise} the result of the delete operation
|
||||
*/
|
||||
async delete(regionId) {
|
||||
return this.atomicPhase_(async manager => {
|
||||
return this.atomicPhase_(async (manager) => {
|
||||
const regionRepo = manager.getCustomRepository(this.regionRepository_)
|
||||
|
||||
const region = await regionRepo.findOne({ where: { id: regionId } })
|
||||
@@ -400,7 +400,7 @@ class RegionService extends BaseService {
|
||||
* @return {Promise} the result of the update operation
|
||||
*/
|
||||
async addCountry(regionId, code) {
|
||||
return this.atomicPhase_(async manager => {
|
||||
return this.atomicPhase_(async (manager) => {
|
||||
const regionRepo = manager.getCustomRepository(this.regionRepository_)
|
||||
|
||||
const country = await this.validateCountry_(code, regionId)
|
||||
@@ -410,7 +410,7 @@ class RegionService extends BaseService {
|
||||
// Check if region already has country
|
||||
if (
|
||||
region.countries &&
|
||||
region.countries.map(c => c.iso_2).includes(country.iso_2)
|
||||
region.countries.map((c) => c.iso_2).includes(country.iso_2)
|
||||
) {
|
||||
return region
|
||||
}
|
||||
@@ -437,7 +437,7 @@ class RegionService extends BaseService {
|
||||
* @return {Promise} the result of the update operation
|
||||
*/
|
||||
async removeCountry(regionId, code) {
|
||||
return this.atomicPhase_(async manager => {
|
||||
return this.atomicPhase_(async (manager) => {
|
||||
const regionRepo = manager.getCustomRepository(this.regionRepository_)
|
||||
|
||||
const region = await this.retrieve(regionId, { relations: ["countries"] })
|
||||
@@ -445,13 +445,13 @@ class RegionService extends BaseService {
|
||||
// Check if region contains country. If not, we simpy resolve
|
||||
if (
|
||||
region.countries &&
|
||||
!region.countries.map(c => c.iso_2).includes(code)
|
||||
!region.countries.map((c) => c.iso_2).includes(code)
|
||||
) {
|
||||
return region
|
||||
}
|
||||
|
||||
region.countries = region.countries.filter(
|
||||
country => country.iso_2 !== code
|
||||
(country) => country.iso_2 !== code
|
||||
)
|
||||
|
||||
const updated = await regionRepo.save(region)
|
||||
@@ -473,7 +473,7 @@ class RegionService extends BaseService {
|
||||
* @return {Promise} the result of the update operation
|
||||
*/
|
||||
async addPaymentProvider(regionId, providerId) {
|
||||
return this.atomicPhase_(async manager => {
|
||||
return this.atomicPhase_(async (manager) => {
|
||||
const regionRepo = manager.getCustomRepository(this.regionRepository_)
|
||||
const ppRepo = manager.getCustomRepository(
|
||||
this.paymentProviderRepository_
|
||||
@@ -520,7 +520,7 @@ class RegionService extends BaseService {
|
||||
* @return {Promise} the result of the update operation
|
||||
*/
|
||||
async addFulfillmentProvider(regionId, providerId) {
|
||||
return this.atomicPhase_(async manager => {
|
||||
return this.atomicPhase_(async (manager) => {
|
||||
const regionRepo = manager.getCustomRepository(this.regionRepository_)
|
||||
const fpRepo = manager.getCustomRepository(
|
||||
this.fulfillmentProviderRepository_
|
||||
@@ -564,7 +564,7 @@ class RegionService extends BaseService {
|
||||
* @return {Promise} the result of the update operation
|
||||
*/
|
||||
async removePaymentProvider(regionId, providerId) {
|
||||
return this.atomicPhase_(async manager => {
|
||||
return this.atomicPhase_(async (manager) => {
|
||||
const regionRepo = manager.getCustomRepository(this.regionRepository_)
|
||||
|
||||
const region = await this.retrieve(regionId, {
|
||||
@@ -598,7 +598,7 @@ class RegionService extends BaseService {
|
||||
* @return {Promise} the result of the update operation
|
||||
*/
|
||||
async removeFulfillmentProvider(regionId, providerId) {
|
||||
return this.atomicPhase_(async manager => {
|
||||
return this.atomicPhase_(async (manager) => {
|
||||
const regionRepo = manager.getCustomRepository(this.regionRepository_)
|
||||
|
||||
const region = await this.retrieve(regionId, {
|
||||
|
||||
@@ -48,9 +48,7 @@ class UserService extends BaseService {
|
||||
* @return {string} the validated email
|
||||
*/
|
||||
validateEmail_(email) {
|
||||
const schema = Validator.string()
|
||||
.email()
|
||||
.required()
|
||||
const schema = Validator.string().email().required()
|
||||
const { value, error } = schema.validate(email)
|
||||
if (error) {
|
||||
throw new MedusaError(
|
||||
@@ -162,7 +160,7 @@ class UserService extends BaseService {
|
||||
* @return {Promise} the result of create
|
||||
*/
|
||||
async create(user, password) {
|
||||
return this.atomicPhase_(async manager => {
|
||||
return this.atomicPhase_(async (manager) => {
|
||||
const userRepo = manager.getCustomRepository(this.userRepository_)
|
||||
|
||||
const validatedEmail = this.validateEmail_(user.email)
|
||||
@@ -186,7 +184,7 @@ class UserService extends BaseService {
|
||||
* @return {Promise} the result of create
|
||||
*/
|
||||
async update(userId, update) {
|
||||
return this.atomicPhase_(async manager => {
|
||||
return this.atomicPhase_(async (manager) => {
|
||||
const userRepo = manager.getCustomRepository(this.userRepository_)
|
||||
const validatedId = this.validateId_(userId)
|
||||
|
||||
@@ -227,7 +225,7 @@ class UserService extends BaseService {
|
||||
* @return {Promise} the result of the delete operation.
|
||||
*/
|
||||
async delete(userId) {
|
||||
return this.atomicPhase_(async manager => {
|
||||
return this.atomicPhase_(async (manager) => {
|
||||
const userRepo = manager.getCustomRepository(this.userRepository_)
|
||||
|
||||
// Should not fail, if user does not exist, since delete is idempotent
|
||||
@@ -252,7 +250,7 @@ class UserService extends BaseService {
|
||||
* @return {Promise} the result of the update operation
|
||||
*/
|
||||
async setPassword_(userId, password) {
|
||||
return this.atomicPhase_(async manager => {
|
||||
return this.atomicPhase_(async (manager) => {
|
||||
const userRepo = manager.getCustomRepository(this.userRepository_)
|
||||
|
||||
const user = await this.retrieve(userId)
|
||||
|
||||
Reference in New Issue
Block a user