Run Prettier JS (#6795)
This commit is contained in:
@@ -7,7 +7,7 @@ export class AnalyticsController extends AdaptableController {
|
||||
.then(() => {
|
||||
return this.adapter.appOpened(req.body, req);
|
||||
})
|
||||
.then(response => {
|
||||
.then((response) => {
|
||||
return { response: response || {} };
|
||||
})
|
||||
.catch(() => {
|
||||
@@ -20,7 +20,7 @@ export class AnalyticsController extends AdaptableController {
|
||||
.then(() => {
|
||||
return this.adapter.trackEvent(req.params.eventName, req.body, req);
|
||||
})
|
||||
.then(response => {
|
||||
.then((response) => {
|
||||
return { response: response || {} };
|
||||
})
|
||||
.catch(() => {
|
||||
|
||||
@@ -27,9 +27,9 @@ export class HooksController {
|
||||
}
|
||||
|
||||
load() {
|
||||
return this._getHooks().then(hooks => {
|
||||
return this._getHooks().then((hooks) => {
|
||||
hooks = hooks || [];
|
||||
hooks.forEach(hook => {
|
||||
hooks.forEach((hook) => {
|
||||
this.addHookToTriggers(hook);
|
||||
});
|
||||
});
|
||||
@@ -37,7 +37,7 @@ export class HooksController {
|
||||
|
||||
getFunction(functionName) {
|
||||
return this._getHooks({ functionName: functionName }).then(
|
||||
results => results[0]
|
||||
(results) => results[0]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ export class HooksController {
|
||||
return this._getHooks({
|
||||
className: className,
|
||||
triggerName: triggerName,
|
||||
}).then(results => results[0]);
|
||||
}).then((results) => results[0]);
|
||||
}
|
||||
|
||||
getTriggers() {
|
||||
@@ -75,8 +75,8 @@ export class HooksController {
|
||||
_getHooks(query = {}) {
|
||||
return this.database
|
||||
.find(DefaultHooksCollectionName, query)
|
||||
.then(results => {
|
||||
return results.map(result => {
|
||||
.then((results) => {
|
||||
return results.map((result) => {
|
||||
delete result.objectId;
|
||||
return result;
|
||||
});
|
||||
@@ -156,7 +156,7 @@ export class HooksController {
|
||||
|
||||
createHook(aHook) {
|
||||
if (aHook.functionName) {
|
||||
return this.getFunction(aHook.functionName).then(result => {
|
||||
return this.getFunction(aHook.functionName).then((result) => {
|
||||
if (result) {
|
||||
throw new Parse.Error(
|
||||
143,
|
||||
@@ -168,13 +168,11 @@ export class HooksController {
|
||||
});
|
||||
} else if (aHook.className && aHook.triggerName) {
|
||||
return this.getTrigger(aHook.className, aHook.triggerName).then(
|
||||
result => {
|
||||
(result) => {
|
||||
if (result) {
|
||||
throw new Parse.Error(
|
||||
143,
|
||||
`class ${aHook.className} already has trigger ${
|
||||
aHook.triggerName
|
||||
}`
|
||||
`class ${aHook.className} already has trigger ${aHook.triggerName}`
|
||||
);
|
||||
}
|
||||
return this.createOrUpdateHook(aHook);
|
||||
@@ -187,7 +185,7 @@ export class HooksController {
|
||||
|
||||
updateHook(aHook) {
|
||||
if (aHook.functionName) {
|
||||
return this.getFunction(aHook.functionName).then(result => {
|
||||
return this.getFunction(aHook.functionName).then((result) => {
|
||||
if (result) {
|
||||
return this.createOrUpdateHook(aHook);
|
||||
}
|
||||
@@ -198,7 +196,7 @@ export class HooksController {
|
||||
});
|
||||
} else if (aHook.className && aHook.triggerName) {
|
||||
return this.getTrigger(aHook.className, aHook.triggerName).then(
|
||||
result => {
|
||||
(result) => {
|
||||
if (result) {
|
||||
return this.createOrUpdateHook(aHook);
|
||||
}
|
||||
@@ -211,7 +209,7 @@ export class HooksController {
|
||||
}
|
||||
|
||||
function wrapToHTTPRequest(hook, key) {
|
||||
return req => {
|
||||
return (req) => {
|
||||
const jsonBody = {};
|
||||
for (var i in req) {
|
||||
jsonBody[i] = req[i];
|
||||
@@ -245,7 +243,7 @@ function wrapToHTTPRequest(hook, key) {
|
||||
'Making outgoing webhook request without webhookKey being set!'
|
||||
);
|
||||
}
|
||||
return request(jsonRequest).then(response => {
|
||||
return request(jsonRequest).then((response) => {
|
||||
let err;
|
||||
let result;
|
||||
let body = response.data;
|
||||
|
||||
@@ -61,7 +61,7 @@ export class LoggerController extends AdaptableController {
|
||||
}
|
||||
|
||||
maskSensitive(argArray) {
|
||||
return argArray.map(e => {
|
||||
return argArray.map((e) => {
|
||||
if (!e) {
|
||||
return e;
|
||||
}
|
||||
@@ -78,7 +78,7 @@ export class LoggerController extends AdaptableController {
|
||||
e.url = this.maskSensitiveUrl(e.url);
|
||||
} else if (Array.isArray(e.url)) {
|
||||
// for strings in array
|
||||
e.url = e.url.map(item => {
|
||||
e.url = e.url.map((item) => {
|
||||
if (typeof item === 'string') {
|
||||
return this.maskSensitiveUrl(item);
|
||||
}
|
||||
@@ -115,7 +115,7 @@ export class LoggerController extends AdaptableController {
|
||||
args = this.maskSensitive([...args]);
|
||||
args = [].concat(
|
||||
level,
|
||||
args.map(arg => {
|
||||
args.map((arg) => {
|
||||
if (typeof arg === 'function') {
|
||||
return arg();
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ class ParseGraphQLController {
|
||||
}
|
||||
if (classConfigs !== null) {
|
||||
if (Array.isArray(classConfigs)) {
|
||||
classConfigs.forEach(classConfig => {
|
||||
classConfigs.forEach((classConfig) => {
|
||||
const errorMessage = this._validateClassConfig(classConfig);
|
||||
if (errorMessage) {
|
||||
errorMessages.push(
|
||||
@@ -332,9 +332,9 @@ class ParseGraphQLController {
|
||||
}
|
||||
}
|
||||
|
||||
const isValidStringArray = function(array): boolean {
|
||||
const isValidStringArray = function (array): boolean {
|
||||
return Array.isArray(array)
|
||||
? !array.some(s => typeof s !== 'string' || s.trim().length < 1)
|
||||
? !array.some((s) => typeof s !== 'string' || s.trim().length < 1)
|
||||
: false;
|
||||
};
|
||||
/**
|
||||
@@ -342,7 +342,7 @@ const isValidStringArray = function(array): boolean {
|
||||
* object, i.e. not an array, null, date
|
||||
* etc.
|
||||
*/
|
||||
const isValidSimpleObject = function(obj): boolean {
|
||||
const isValidSimpleObject = function (obj): boolean {
|
||||
return (
|
||||
typeof obj === 'object' &&
|
||||
!Array.isArray(obj) &&
|
||||
|
||||
@@ -137,7 +137,7 @@ export class PushController {
|
||||
pushStatus
|
||||
);
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
return pushStatus.fail(err).then(() => {
|
||||
throw err;
|
||||
});
|
||||
|
||||
@@ -41,9 +41,9 @@ export default class SchemaCache {
|
||||
if (!this.ttl) {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
return this.cache.get(this.prefix + MAIN_SCHEMA).then(cachedSchemas => {
|
||||
return this.cache.get(this.prefix + MAIN_SCHEMA).then((cachedSchemas) => {
|
||||
cachedSchemas = cachedSchemas || [];
|
||||
const schema = cachedSchemas.find(cachedSchema => {
|
||||
const schema = cachedSchemas.find((cachedSchema) => {
|
||||
return cachedSchema.className === className;
|
||||
});
|
||||
if (schema) {
|
||||
|
||||
@@ -545,7 +545,7 @@ class SchemaData {
|
||||
constructor(allSchemas = [], protectedFields = {}) {
|
||||
this.__data = {};
|
||||
this.__protectedFields = protectedFields;
|
||||
allSchemas.forEach(schema => {
|
||||
allSchemas.forEach((schema) => {
|
||||
if (volatileClasses.includes(schema.className)) {
|
||||
return;
|
||||
}
|
||||
@@ -580,7 +580,7 @@ class SchemaData {
|
||||
});
|
||||
|
||||
// Inject the in-memory classes
|
||||
volatileClasses.forEach(className => {
|
||||
volatileClasses.forEach((className) => {
|
||||
Object.defineProperty(this, className, {
|
||||
get: () => {
|
||||
if (!this.__data[className]) {
|
||||
@@ -721,11 +721,11 @@ export default class SchemaController {
|
||||
}
|
||||
this.reloadDataPromise = this.getAllClasses(options)
|
||||
.then(
|
||||
allSchemas => {
|
||||
(allSchemas) => {
|
||||
this.schemaData = new SchemaData(allSchemas, this.protectedFields);
|
||||
delete this.reloadDataPromise;
|
||||
},
|
||||
err => {
|
||||
(err) => {
|
||||
this.schemaData = new SchemaData();
|
||||
delete this.reloadDataPromise;
|
||||
throw err;
|
||||
@@ -741,7 +741,7 @@ export default class SchemaController {
|
||||
if (options.clearCache) {
|
||||
return this.setAllClasses();
|
||||
}
|
||||
return this._cache.getAllClasses().then(allClasses => {
|
||||
return this._cache.getAllClasses().then((allClasses) => {
|
||||
if (allClasses && allClasses.length) {
|
||||
return Promise.resolve(allClasses);
|
||||
}
|
||||
@@ -752,12 +752,12 @@ export default class SchemaController {
|
||||
setAllClasses(): Promise<Array<Schema>> {
|
||||
return this._dbAdapter
|
||||
.getAllClasses()
|
||||
.then(allSchemas => allSchemas.map(injectDefaultSchema))
|
||||
.then(allSchemas => {
|
||||
.then((allSchemas) => allSchemas.map(injectDefaultSchema))
|
||||
.then((allSchemas) => {
|
||||
/* eslint-disable no-console */
|
||||
this._cache
|
||||
.setAllClasses(allSchemas)
|
||||
.catch(error =>
|
||||
.catch((error) =>
|
||||
console.error('Error saving schema to cache:', error)
|
||||
);
|
||||
/* eslint-enable no-console */
|
||||
@@ -784,13 +784,13 @@ export default class SchemaController {
|
||||
indexes: data.indexes,
|
||||
});
|
||||
}
|
||||
return this._cache.getOneSchema(className).then(cached => {
|
||||
return this._cache.getOneSchema(className).then((cached) => {
|
||||
if (cached && !options.clearCache) {
|
||||
return Promise.resolve(cached);
|
||||
}
|
||||
return this.setAllClasses().then(allSchemas => {
|
||||
return this.setAllClasses().then((allSchemas) => {
|
||||
const oneSchema = allSchemas.find(
|
||||
schema => schema.className === className
|
||||
(schema) => schema.className === className
|
||||
);
|
||||
if (!oneSchema) {
|
||||
return Promise.reject(undefined);
|
||||
@@ -841,7 +841,7 @@ export default class SchemaController {
|
||||
})
|
||||
)
|
||||
.then(convertAdapterSchemaToParseSchema)
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
if (error && error.code === Parse.Error.DUPLICATE_VALUE) {
|
||||
throw new Parse.Error(
|
||||
Parse.Error.INVALID_CLASS_NAME,
|
||||
@@ -861,9 +861,9 @@ export default class SchemaController {
|
||||
database: DatabaseController
|
||||
) {
|
||||
return this.getOneSchema(className)
|
||||
.then(schema => {
|
||||
.then((schema) => {
|
||||
const existingFields = schema.fields;
|
||||
Object.keys(submittedFields).forEach(name => {
|
||||
Object.keys(submittedFields).forEach((name) => {
|
||||
const field = submittedFields[name];
|
||||
if (existingFields[name] && field.__op !== 'Delete') {
|
||||
throw new Parse.Error(255, `Field ${name} exists, cannot update.`);
|
||||
@@ -899,7 +899,7 @@ export default class SchemaController {
|
||||
// Do all deletions first, then a single save to _SCHEMA collection to handle all additions.
|
||||
const deletedFields: string[] = [];
|
||||
const insertedFields = [];
|
||||
Object.keys(submittedFields).forEach(fieldName => {
|
||||
Object.keys(submittedFields).forEach((fieldName) => {
|
||||
if (submittedFields[fieldName].__op === 'Delete') {
|
||||
deletedFields.push(fieldName);
|
||||
} else {
|
||||
@@ -916,14 +916,14 @@ export default class SchemaController {
|
||||
deletePromise // Delete Everything
|
||||
.then(() => this.reloadData({ clearCache: true })) // Reload our Schema, so we have all the new values
|
||||
.then(() => {
|
||||
const promises = insertedFields.map(fieldName => {
|
||||
const promises = insertedFields.map((fieldName) => {
|
||||
const type = submittedFields[fieldName];
|
||||
return this.enforceFieldExists(className, fieldName, type);
|
||||
});
|
||||
return Promise.all(promises);
|
||||
})
|
||||
.then(results => {
|
||||
enforceFields = results.filter(result => !!result);
|
||||
.then((results) => {
|
||||
enforceFields = results.filter((result) => !!result);
|
||||
return this.setPermissions(
|
||||
className,
|
||||
classLevelPermissions,
|
||||
@@ -955,7 +955,7 @@ export default class SchemaController {
|
||||
})
|
||||
);
|
||||
})
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
if (error === undefined) {
|
||||
throw new Parse.Error(
|
||||
Parse.Error.INVALID_CLASS_NAME,
|
||||
@@ -1095,7 +1095,7 @@ export default class SchemaController {
|
||||
}
|
||||
|
||||
const geoPoints = Object.keys(fields).filter(
|
||||
key => fields[key] && fields[key].type === 'GeoPoint'
|
||||
(key) => fields[key] && fields[key].type === 'GeoPoint'
|
||||
);
|
||||
if (geoPoints.length > 1) {
|
||||
return {
|
||||
@@ -1180,7 +1180,7 @@ export default class SchemaController {
|
||||
|
||||
return this._dbAdapter
|
||||
.addFieldIfNotExists(className, fieldName, type)
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
if (error.code == Parse.Error.INCORRECT_TYPE) {
|
||||
// Make sure that we throw errors when it is appropriate to do so.
|
||||
throw error;
|
||||
@@ -1244,7 +1244,7 @@ export default class SchemaController {
|
||||
);
|
||||
}
|
||||
|
||||
fieldNames.forEach(fieldName => {
|
||||
fieldNames.forEach((fieldName) => {
|
||||
if (!fieldNameIsValid(fieldName)) {
|
||||
throw new Parse.Error(
|
||||
Parse.Error.INVALID_KEY_NAME,
|
||||
@@ -1258,7 +1258,7 @@ export default class SchemaController {
|
||||
});
|
||||
|
||||
return this.getOneSchema(className, false, { clearCache: true })
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
if (error === undefined) {
|
||||
throw new Parse.Error(
|
||||
Parse.Error.INVALID_CLASS_NAME,
|
||||
@@ -1268,8 +1268,8 @@ export default class SchemaController {
|
||||
throw error;
|
||||
}
|
||||
})
|
||||
.then(schema => {
|
||||
fieldNames.forEach(fieldName => {
|
||||
.then((schema) => {
|
||||
fieldNames.forEach((fieldName) => {
|
||||
if (!schema.fields[fieldName]) {
|
||||
throw new Parse.Error(
|
||||
255,
|
||||
@@ -1283,7 +1283,7 @@ export default class SchemaController {
|
||||
.deleteFields(className, schema, fieldNames)
|
||||
.then(() => {
|
||||
return Promise.all(
|
||||
fieldNames.map(fieldName => {
|
||||
fieldNames.map((fieldName) => {
|
||||
const field = schemaFields[fieldName];
|
||||
if (field && field.type === 'Relation') {
|
||||
//For relations, drop the _Join table
|
||||
@@ -1335,7 +1335,7 @@ export default class SchemaController {
|
||||
promises.push(schema.enforceFieldExists(className, fieldName, expected));
|
||||
}
|
||||
const results = await Promise.all(promises);
|
||||
const enforceFields = results.filter(result => !!result);
|
||||
const enforceFields = results.filter((result) => !!result);
|
||||
|
||||
if (enforceFields.length !== 0) {
|
||||
await this.reloadData({ clearCache: true });
|
||||
@@ -1353,7 +1353,7 @@ export default class SchemaController {
|
||||
return Promise.resolve(this);
|
||||
}
|
||||
|
||||
const missingColumns = columns.filter(function(column) {
|
||||
const missingColumns = columns.filter(function (column) {
|
||||
if (query && query.objectId) {
|
||||
if (object[column] && typeof object[column] === 'object') {
|
||||
// Trying to delete a required column
|
||||
@@ -1401,7 +1401,7 @@ export default class SchemaController {
|
||||
}
|
||||
// Check permissions against the aclGroup provided (array of userId/roles)
|
||||
if (
|
||||
aclGroup.some(acl => {
|
||||
aclGroup.some((acl) => {
|
||||
return perms[acl] === true;
|
||||
})
|
||||
) {
|
||||
@@ -1594,7 +1594,7 @@ function buildMergedSchemaObject(
|
||||
// Given a schema promise, construct another schema promise that
|
||||
// validates this field once the schema loads.
|
||||
function thenValidateRequiredColumns(schemaPromise, className, object, query) {
|
||||
return schemaPromise.then(schema => {
|
||||
return schemaPromise.then((schema) => {
|
||||
return schema.validateRequiredColumns(className, object, query);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ export class UserController extends AdaptableController {
|
||||
'_User',
|
||||
{ username: username, emailVerified: true }
|
||||
);
|
||||
return checkIfAlreadyVerified.execute().then(result => {
|
||||
return checkIfAlreadyVerified.execute().then((result) => {
|
||||
if (result.results.length) {
|
||||
return Promise.resolve(result.results.length[0]);
|
||||
}
|
||||
@@ -88,7 +88,7 @@ export class UserController extends AdaptableController {
|
||||
},
|
||||
{ limit: 1 }
|
||||
)
|
||||
.then(results => {
|
||||
.then((results) => {
|
||||
if (results.length != 1) {
|
||||
throw 'Failed to reset password: username / email / token is invalid';
|
||||
}
|
||||
@@ -127,7 +127,7 @@ export class UserController extends AdaptableController {
|
||||
'_User',
|
||||
where
|
||||
);
|
||||
return query.execute().then(function(result) {
|
||||
return query.execute().then(function (result) {
|
||||
if (result.results.length != 1) {
|
||||
throw undefined;
|
||||
}
|
||||
@@ -141,7 +141,7 @@ export class UserController extends AdaptableController {
|
||||
}
|
||||
const token = encodeURIComponent(user._email_verify_token);
|
||||
// We may need to fetch the user in case of update email
|
||||
this.getUserIfNeeded(user).then(user => {
|
||||
this.getUserIfNeeded(user).then((user) => {
|
||||
const username = encodeURIComponent(user.username);
|
||||
|
||||
const link = buildEmailLink(
|
||||
@@ -179,7 +179,7 @@ export class UserController extends AdaptableController {
|
||||
}
|
||||
|
||||
resendVerificationEmail(username) {
|
||||
return this.getUserIfNeeded({ username: username }).then(aUser => {
|
||||
return this.getUserIfNeeded({ username: username }).then((aUser) => {
|
||||
if (!aUser || aUser.emailVerified) {
|
||||
throw undefined;
|
||||
}
|
||||
@@ -216,7 +216,7 @@ export class UserController extends AdaptableController {
|
||||
// TODO: No adapter?
|
||||
}
|
||||
|
||||
return this.setPasswordResetToken(email).then(user => {
|
||||
return this.setPasswordResetToken(email).then((user) => {
|
||||
const token = encodeURIComponent(user._perishable_token);
|
||||
const username = encodeURIComponent(user.username);
|
||||
|
||||
@@ -244,8 +244,8 @@ export class UserController extends AdaptableController {
|
||||
|
||||
updatePassword(username, token, password) {
|
||||
return this.checkResetTokenValidity(username, token)
|
||||
.then(user => updateUserPassword(user.objectId, password, this.config))
|
||||
.catch(error => {
|
||||
.then((user) => updateUserPassword(user.objectId, password, this.config))
|
||||
.catch((error) => {
|
||||
if (error && error.message) {
|
||||
// in case of Parse.Error, fail with the error message only
|
||||
return Promise.reject(error.message);
|
||||
|
||||
Reference in New Issue
Block a user