Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const filterTerms = function(field, values) {
if (_.isEmpty(values)) {
return null;
}
const filter = { terms: {} };
if (_.isArray(values)) {
// We've been given a static terms array on query
const terms = _.compact(values);
if (_.isEmpty(terms)) {
return null;
}
filter.terms[field] = terms;
} else {
// We've been given an ElasticSearch terms lookup path, so apply that rather than a list of values
filter.terms[field] = values;
}
return filter;
};
function(developer, auth, callback){
// set auth so they dont get prompted again
program.auth = auth;
// only lookup alks account if they didnt provide
if(_.isEmpty(alksAccount) || _.isEmpty(alksRole)){
utils.log(program, logger, 'getting accounts');
Developer.getALKSAccount(program, { iamOnly: true, filterFavorites: filterFavorites }, function(err, data){
if(err) callback(err);
else callback(null, developer, auth, data.alksAccount, data.alksRole);
});
}
else{
utils.log(program, logger, 'using provided account/role' + alksAccount + ' ' + alksRole);
callback(null, developer, auth, alksAccount, alksRole);
}
}
], cb);
{
// remove all table highlights
mainMutationView.tableView.clearHighlights();
// get all selected elements
var selected = mutationData.getState().selected;
var filtered = mutationData.getState().filtered;
// if there are selected mutations, then only show selected
if (!_.isEmpty(selected))
{
// filter table for the selected mutations
mainMutationView.tableView.filter(selected);
}
// if currently no selected mutations, then show only filtered ones
else if (!_.isEmpty(filtered))
{
// filter table for the selected mutations
mainMutationView.tableView.filter(filtered);
}
// nothing selected, nothing filtered, show nothing
else
{
// TODO hide everything!
// (currently we don't need this because, table filter handles this internally)
}
}
}
const propertyData: { description: string; type: string } = properties[parentObjName];
if (propertyData) {
const propertyType = properties[parentObjName].type;
const typeData = types[propertyType];
if (typeData && typeData.properties && typeData.properties.length) {
let completionProperty;
if (properties[parentObjName]) {
completionProperty = properties[parentObjName].type;
}
for (const property of types[completionProperty].properties) {
innerProperties[property] = {};
}
}
}
const candidateProperties = _.isEmpty(innerProperties) ? properties : innerProperties;
for (const property in candidateProperties) {
if (!prefix || utils.matches(property, prefix)) {
//
// Object types
//
const jsObjectTypes = [ 'Font' ];
if (jsObjectTypes.indexOf(properties[property].type) > -1) {
completions.push({
label: property,
kind: CompletionItemKind.Property,
insertText: new SnippetString(`${property}: {\n\t\${1}\t\n}`),
});
//
SubscriptionService.prototype.createWithAll = function(payment, client, offer, amount, currency, interval, startAt,
name,periodOfValidity, cb) {
try {
var map = {};
map.payment = getIdFromObject(payment, Payment);
if (!__.isEmpty(client)) {
map.client = getIdFromObject(client, Client);
}
if (!__.isEmpty(offer)) {
map.offer = getIdFromObject(offer, Offer);
}
if (__.isNumber(amount)) {
map.amount = amount;
}
if (!__.isEmpty(currency)) {
map.currency = currency;
}
if (!__.isEmpty(interval)) {
map.interval = interval.toString();
}
if (startAt) {
map.start_at = getUnixTimeFromParam(startAt,"startAt");
}
if (!__.isEmpty(name)) {
map.name = name;
}
if (!__.isEmpty(periodOfValidity)) {
map.period_of_validity = periodOfValidity.toString();
}
return this._create(map, Subscription, cb);
} catch (e) {
callback =
callback ||
function(err) {
if (err) {
log().error(
{
err,
principalIds,
meetingId: meeting.id
},
'Error updating meeting for principal libraries'
);
}
};
if (_.isEmpty(principalIds) || !meeting) {
return callback();
}
const entries = _.map(principalIds, principalId => {
return {
id: principalId,
oldRank: oldLastModified,
newRank: meeting.lastModified,
resource: meeting
};
});
LibraryAPI.Index.update(MeetingsConstants.library.MEETINGS_LIBRARY_INDEX_NAME, entries, callback);
};
try {
var map = {};
map.payment = getIdFromObject(payment, Payment);
if (!__.isEmpty(client)) {
map.client = getIdFromObject(client, Client);
}
if (!__.isEmpty(offer)) {
map.offer = getIdFromObject(offer, Offer);
}
if (__.isNumber(amount)) {
map.amount = amount;
}
if (!__.isEmpty(currency)) {
map.currency = currency;
}
if (!__.isEmpty(interval)) {
map.interval = interval.toString();
}
if (startAt) {
map.start_at = getUnixTimeFromParam(startAt,"startAt");
}
if (!__.isEmpty(name)) {
map.name = name;
}
if (!__.isEmpty(periodOfValidity)) {
map.period_of_validity = periodOfValidity.toString();
}
return this._create(map, Subscription, cb);
} catch (e) {
return this._reject(e);
}
};
try {
chain = this.util.pathToEntityChain(path, true);
entityName = chain[chain.length - 1].entity.name;
} catch (e) {
return results;
}
entityData = entityData[entityName];
entityFields = this.callbacks.dataFilter.call(this, entityName, entityData.fields);
if (!_.isEmpty(this.exclude)) {
entityFields = Util.filterFields(entityFields, this.exclude);
}
if (!_.isEmpty(this.include)) {
entityFields = Util.filterFields(entityFields, this.include, true);
}
$.each(entityFields, function() {
var field = this;
var chainItem = {field: field};
var item = {
id: util.entityChainToPath(chain.concat(chainItem)),
text: field.label
};
if (field.related_entity) {
chainItem.entity = field.related_entity;
item.pagePath = util.entityChainToPath(chain.concat(chainItem));
item.related_entity = field.related_entity;
delete item.id;
relations.push(item);
function validateMandatory(field,fieldName) {
if (__.isEmpty(field)) {
throw new PMError(PMError.Type.WRONG_PARAMS, fieldName + " is mandatory");
}
}
function validateNumber(field, fieldname, optional) {
if ( !relations[ name ] ) throw new Error(
'%s does not have relation `%s`'.format( this.class_name, name )
);
if ( this[ name ] != null && !refresh && _.isEmpty( params ) )
return this.app.tools.next_tick( this[ name ] );
this.log( 'Load relation `%s`'.format( name ), 'trace' );
var relation = relations[ name ];
if ( this.is_new && ( relation instanceof active_relations[ 'has_one' ] || relation instanceof active_relations[ 'has_many' ] ) )
return this.app.tools.next_tick( relation instanceof active_relations[ 'has_one' ] ? null : [] );
var saved_relation = null;
var With = {};
if ( !_.isEmpty( params ) ) {
saved_relation = this[ name ] == null ? null : this[ name ];
With[ name ] = params;
}
else With = name;
delete this._[ name ];
var finder = new ActiveFinder({
app : this.app,
model : this,
With : With
});
var emitter = new Emitter;
var self = this;
finder.lazy_find( this, function( err ){