Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('posts to the DataLad /datasets/{dsId}/snapshots/{snapshot} endpoint', async done => {
const tag = 'snapshot'
const dsId = await createDataset()
// Reset call count for request.post
request.post.mockClear()
request.__setMockResponse({ body: {} })
await createSnapshot(dsId, tag, false)
expect(request.post).toHaveBeenCalledTimes(1)
expect(request.post).toHaveBeenCalledWith(
expect.stringContaining(
`${config.datalad.uri}/datasets/${dsId}/snapshots/${tag}`,
),
)
done()
})
})
}
const { url, password, login } = hal_config;
const publication = await EntitiesUtils.retrieve_and_get_source('publication', pid);
if (!publication) {
throw Errors.InvalidEntity;
}
const xml_tei = await HalExporter.transform_publication_to_hal(publication);
const files = Utils.find_value_with_path(publication, 'files'.split('.')) || [];
const my_file = files.find(f => f.is_master) || (files.length > 0 ? files[0] : null);
const skip_files = files.length === 0 || ((my_file.access.restricted || my_file.access.confidential) && !my_file.access.delayed);
// console.log(xml_tei);
const req = Request.post(url)
.set('Packaging', 'http://purl.org/net/sword-types/AOfr')
.auth(encodeURIComponent(login), encodeURIComponent(password));
const result_promise = new Promise((resolve, reject) => {
req
.on('response', result => resolve(result)).on('error', err => reject(err));
});
console.log(xml_tei);
if (skip_files) {
req.set('Content-Type', 'text/xml')
.send(xml_tei)
.end();
} else {
req
.set('Content-Type', 'application/zip')
.set('Content-Disposition', 'attachment; filename=meta.xml');
function changeTheme(themeCredentials) {
var spinner = new Spinner('changing theme...');
spinner.setSpinnerString('/-\\');
spinner.start();
request
.put(registryServer + '/resume')
.send(themeCredentials)
.set('X-API-Key', 'foobar')
.set('Accept', 'application/json')
.end(function(error, res) {
spinner.stop();
// console.log(error, res);
// cannot read property of null
if (error && error.code === 'ENOTFOUND') {
console.log('\nThere has been an error publishing your resume.'.red);
console.log('Please check your network connection.'.cyan);
process.exit();
return;
} else if (error || res.body.message === 'ERRORRRSSSS') {
console.log(error, res.body.message);
console.log('\nThere has been an error publishing your resume.'.red);
syncText: function () {
// Sync to server
console.log(`Syncing text for ${this.sharedState.playerId}`)
request.post('/api/suggest', {
playerId: this.sharedState.playerId,
suggestion: this.sharedState.suggestionText
}, function (err, state) {
// handle error
// https://github.com/groupwrite-io/groupwrite.io/issues/58
if (err) {
window.alert(err + '\r\n' + state.text)
}
})
},
theend: function () {
events.on(PATCH_REPO, function(event) {
const {owner, name} = event.data;
// there is a bug where the input parameter names differ from
// the output parameter names. This attempts to resolve.
if (event.data.allow_deploys !== undefined) {
event.data['allow_deploy'] = event.data.allow_deploys;
}
if (event.data.allow_tags !== undefined) {
event.data['allow_tag'] = event.data.allow_tags;
}
Request.patch(`/api/repos/${owner}/${name}`)
.set('X-CSRF_TOKEN', token)
.send(event.data)
.end((err, response) => {
if (err != null) {
console.error(err);
tree.set(['pages', 'toast'], 'Error updating repository settings');
return
}
let repo = JSON.parse(response.text);
tree.set(['repos', owner, name], repo);
tree.set(['pages', 'toast'], 'Successfully updated repository settings');
});
});
export default function loadFromFile({input, state, output}) {
var seqFileParser = require('bio-parsers/parsers/anyToJSON');
console.log("did it. :3");
if(id && sid)
{
request
.post('rest/parts/sequence')
.set('X-ICE-Authentication-sessionId', sid)
.set('Content-Type', 'application/json')
.send(/* results of seqfileparser? or is that on node server*/)
.end(function(err, result) {
if(err) {
console.log("unable to load file, something went wrong: " + err)
}
}
);
} else {
console.log("something went wrong, unable to upload file");
}
}
featureList[f].id = sequenceData.features[f].id;
featureList[f].type = sequenceData.features[f].type;
featureList[f].name = sequenceData.features[f].name;
featureList[f].strand = sequenceData.features[f].strand;
featureList[f].notes = sequenceData.features[f].notes;
featureList[f].locations = [{}];
featureList[f].locations[0].genbankStart = sequenceData.features[f].start;
featureList[f].locations[0].end = sequenceData.features[f].end;
}
newSequenceData.features = featureList;
// remember to do checks for bad id and sid and sequence length
// parts is always parts, even for plasmids and seeds
request
.post('rest/parts/' + id + '/sequence?sid=' + sid)
.set('X-ICE-Authentication-sessionId', sid)
.set('Content-Type', 'application/json')
.send(newSequenceData)
.end(function(err, result) {
if(err) {
console.log("unable to save to registry, something went wrong: " + err)
}
}
);
}
// prevent IE from caching requests
thisReq.set('If-Modified-Since', 'Mon, 26 Jul 1997 05:00:00 GMT');
if (self._token) {
// do a localized data serialization process
let data = (thisReq as any)._data;
if (typeof data !== 'string') {
let contentType = thisReq.get('Content-Type');
// Parse out just the content type from the header (ignore the charset)
if (contentType) {
contentType = contentType.split(';')[0];
}
let serialize = superagent.serialize[contentType];
if (!serialize && /[\/+]json\b/.test(contentType)) {
serialize = superagent.serialize['application/json'];
}
if (serialize) {
data = serialize(data);
}
}
(thisReq as any)._data = data;
const urlDetails = url.parse(req.url);
let queryString: string | undefined;
const query: string[] = (req as any)._query;
const qs: { [key: string]: string } = (req as any).qs;
if (query && query.length > 0) {
// browser version
queryString = query.join('&');
(req as any)._query = [];
thisReq.set('BitGo-Auth-Version', '2.0');
// prevent IE from caching requests
thisReq.set('If-Modified-Since', 'Mon, 26 Jul 1997 05:00:00 GMT');
if (self._token) {
// do a localized data serialization process
let data = (thisReq as any)._data;
if (typeof data !== 'string') {
let contentType = thisReq.get('Content-Type');
// Parse out just the content type from the header (ignore the charset)
if (contentType) {
contentType = contentType.split(';')[0];
}
let serialize = superagent.serialize[contentType];
if (!serialize && /[\/+]json\b/.test(contentType)) {
serialize = superagent.serialize['application/json'];
}
if (serialize) {
data = serialize(data);
}
}
(thisReq as any)._data = data;
const urlDetails = url.parse(req.url);
let queryString: string | undefined;
const query: string[] = (req as any)._query;
const qs: { [key: string]: string } = (req as any).qs;
if (query && query.length > 0) {
// browser version
query = request.serializeObject(query);
this.url += ~this.url.indexOf('?')
? '&' + query
: '?' + query;
}
// initiate request
xhr.open(this.method, this.url, true);
// CORS
if (this._withCredentials) xhr.withCredentials = true;
// body
if ('GET' != this.method && 'HEAD' != this.method && 'string' != typeof data && !isHost(data)) {
// serialize stuff
var serialize = request.serialize[this.getHeader('Content-Type')];
if (serialize) data = serialize(data);
}
// set header fields
for (var field in this.header) {
if (null == this.header[field]) continue;
xhr.setRequestHeader(field, this.header[field]);
}
// send stuff
this.emit('request', this);
xhr.send(data);
return this;
};