Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let opts = Lazy(query).pick([
'limit', 'offset', 'sort', 'direction'
]).value();
if (!opts.limit || opts.limit > 500 || opts.limit < 1) {
opts.limit = 500;
}
let sort = {};
sort[opts.sort || 'name'] = opts.direction ?
(opts.direction == 'asc' ? 1 : -1) : 1;
let res = (await db.cfind(q).sort(sort).limit(opts.limit)
.skip(opts.skip || 0).exec()).map(d => new model(d));
res.query = Lazy(q).merge(opts).value();
return res;
}
// for (let i in this.fields.filter(t => t.type == 'oneToOne')) {
.map(timestamp => {
let reqBody = null;
let headers = {};
if (typeof(config.body) === 'object' && Object.keys(config.body).length > 0) {
if (config.method === 'PUT' || config.method === 'POST') {
// Escape unicode
reqBody = JSON.stringify(config.body).replace(/[\u0080-\uFFFF]/g, function(m) {
return '\\u' + ('0000' + m.charCodeAt(0).toString(16)).slice(-4);
});
headers['Content-Length'] = reqBody.length;
} else {
url += ('?' + querystring.stringify(_(config.body).filter((elm) => elm != null).value()));
config.body = {};
}
}
headers = Object.assign({}, {
'X-Ovh-Consumer': this.opts.consumerKey,
'X-Ovh-Signature': this.getHashedSignature(config.method || 'GET', this.urlRoot + url, Object.keys(config.body).length ? config.body : null, timestamp),
'X-Ovh-Timestamp': timestamp,
'X-Ovh-Application': this.opts.appKey
}, headers);
if (config.method === 'POST' || config.method === 'PUT') {
headers['Content-Type'] = 'application/json';
}
return { headers: new Headers(headers) };
let indices = Lazy(item.next).map((next) => Lazy(this._items).map((f) => f.hash).indexOf(next)) // Find the item's parent's indices
const index = indices.length > 0 ? Math.max(indices.max() + 1, 0) : 0; // find the largest index (latest parent)
}
const schemaCols = Object.assign(
{},
customCols
);
// don't handle abstract tables
if (_options.abstract) continue;
// creating table
if (!exists) {
const query = showCreateTable(table, schemaCols, _options);
this.log.info(`Creating table ${table}: ${query}`);
await this.client.execute(query);
}
// calculating difference and apply changes
else {
const currTableKeys = Lazy(currTable).keys();
const appendCols = Lazy(schemaCols)
.keys()
.without(currTableKeys.toArray())
.toArray();
if (appendCols.length > 0) {
this.log.info({
new_cols: appendCols.join(', ')
}, `Altering table ${table}`);
const query = showAlterTable(
table,
Lazy(schemaCols)
.pick(appendCols)
.toObject(),
_options
);
await this.client.execute(query);
_insert(node) {
let indices = Lazy(node.next).map((next) => Lazy(this._items).map((f) => f.hash).indexOf(next)) // Find the item's parent's indices
const index = indices.toArray().length > 0 ? Math.max(indices.max() + 1, 0) : 0; // find the largest index (latest parent)
this._items.splice(index, 0, node);
return node;
}
await this.client.execute(query);
}
// calculating difference and apply changes
else {
const currTableKeys = Lazy(currTable).keys();
const appendCols = Lazy(schemaCols)
.keys()
.without(currTableKeys.toArray())
.toArray();
if (appendCols.length > 0) {
this.log.info({
new_cols: appendCols.join(', ')
}, `Altering table ${table}`);
const query = showAlterTable(
table,
Lazy(schemaCols)
.pick(appendCols)
.toObject(),
_options
);
await this.client.execute(query);
}
}
}
// rediscover db structure
await this.discover();
this.log.info('Schema sync done');
}
var paths = {};
traverse(self.slap.options).forEach(function (binding) {
if (this.path.indexOf('bindings') !== -1) {
var keyNumber = Number(this.key);
if (Array.isArray(binding)) binding = binding.join(", ");
else if (Array.isArray(this.parent) || !this.isLeaf || !this.key || keyNumber === keyNumber) return;
var path = this.path.slice(0, -1).join('.');
if (!(path in paths)) paths[path] = [];
paths[path].push(this.key + ": " + binding);
}
});
self.helpContent
.readOnly(true)
.text("Keybindings:\n" + _(paths).pairs()
.sortBy(function (pair) { return (pair[0].match(/\./g) || []).length; })
.map(function (pair) {
return "\n[" + pair[0] + "]\n" + pair[1].join("\n");
})
.join("\n")
, false);
self.okButton = new Button({
parent: self,
content: "Okay",
bottom: 1,
right: 1
});
}
HelpDialog.prototype.__proto__ = BaseDialog.prototype;
(resp) => {
let tmpDiv = document.createElement('div');
tmpDiv.innerHTML = resp.text();
let inputs = tmpDiv.getElementsByTagName('input');
let inputSms = _(inputs).find((elt) => elt.id === 'codeSMS');
if (inputSms == null || inputSms.length === 0) {
localStorage.removeItem('connected');
localStorage.setItem('connected', 'true');
return true;
} else {
return false;
}
}
);
const isReferenced = (list, item) => Lazy(list).reverse().find((f) => f === item) !== undefined;
let result = [];
self.remove(self.form);
self.form = null;
self.editor.focus();
self.editor.bottom = 0;
}
if (prompts) {
self.editor.bottom += prompts.length;
self.form = new blessed.Form({
parent: self,
height: prompts.length,
left: 0,
right: 0,
bottom: 0
});
var labelWidth = _(prompts).pluck('length').max() + 3;
var label = new blessed.Box({
parent: self.form,
tags: true,
content: prompts.map(function (prompt) {
return markup(
(' ' + prompt + ':' + _.repeat(' ', labelWidth).join('')).slice(0, labelWidth),
self.options.style.prompt || self.options.style.main);
}).join('\n'),
top: 0,
left: 0,
width: labelWidth,
bottom: 0
});
function done (submit) {
self.prompt(false).done();