Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* eslint-disable */
var loopback = require('loopback');
var log = {};
var Log = loopback.getModel('Log');
var updated1 = Log.create(log);
console.log(updated1);
var file = {};
var File = loopback.getModel('File');
var updated2 = File.create(file);
console.log(updated2);
var id = _node.id;
// sort of an hack to return a function in case this method is called by
// node itself.
if (ctx && Object.keys(ctx).length === 0) {
next(id);
} else {
if ( !(ctx.req && ctx.req.callContext && ctx.req.callContext.ctx) ){
console.log("callContext not available")
return next();
}
var Model = loopback.getModel(_modelName, _node.callContext);
if (!utils.compareContext(_node, { Model: Model, options: { ctx: ctx.req.callContext.ctx } })) {
return next();
}
var msg = {};
if (ctx.Model !== undefined) {
msg.payload = ctx.Model.definition.name + '.' + _methodName + ' triggered';
} else {
msg.payload = _modelName + '.' + _methodName + ' triggered';
}
msg.callContext = _node.callContext;
// msg.next = next;
msg.ctx = ctx;
_node.send(msg);
// this check is necessary when we try from swagger usually options is
// defined as cb and cb is undefined.
// and programmatically also if user doesn’t send options then the
// options
// will be function and cb will be undefined.
if (typeof cb === 'undefined') {
if (typeof options === 'function') {
// create(data, cb);
cb = options;
options = {};
}
}
log.debug(options, 'in change-request persistUpdates() called with id[', id, '] and status [', status, ']');
var CrModel = loopback.getModel('ChangeRequest');
log.debug(options, 'Change Request with id [', id, ']');
CrModel.findById(id, options, function changeRequestModelFindCb(err, crResult) {
if (err) {
cb(err, null);
}
if (crResult === null) {
log.error(options, 'No Change Request found with id [', id, ']');
return cb('No Change Request found with id [' + id + ']', null);
}
log.debug(options, 'CR instance found with status [', crResult._status, ']');
var crInstance = crResult;
if (status === PUBLISHED) {
log.debug(options, 'Published the changes to the original entity');
function setupRabbitMqModel(app, settings) {
// Assign ACLs from the component configuration.
modelDef.acls = _.get(settings, 'options.acls', [])
// Create the model.
const RabbitMQ = loopback.createModel(modelDef)
// Apply model customizations.
require('./models/rabbitmq')(RabbitMQ)
// Register the model.
app.model(RabbitMQ)
return loopback.getModel('RabbitMQ')
}
after('delete all the test transfers', function (done) {
var testTransfer = loopback.getModel('TestTransfer', bootstrap.defaultContext);
testTransfer.destroyAll({}, deleteContext, function (err) {
if (err) {
expect(err.message).to.be.equal('Cannot delete journal entry');
return done();
} else {
log.debug('deleted alltest transfers');
return done(new Error('Should not be allowed to delete journal entries!'));
}
});
});
after('delete all the test accounts', function (done) {
var testAccount = loopback.getModel('TestAccount', bootstrap.defaultContext);
testAccount.destroyAll({}, deleteContext, function (err) {
if (err) {
log.error(err);
return done(err);
} else {
return done();
}
});
});
const getPersonalizedModel = (modelName, ctx) => {
let modelDefinition;
if (modelName === 'ModelDefinition') {
modelDefinition = loopback.getModel('ModelDefinition');
} else {
modelDefinition = loopback.getModel('ModelDefinition', { ctx: ctx });
}
const autoscopeFields = modelDefinition.definition.settings.autoscope;
const ctxStr = util.createContextString(autoscopeFields, ctx);
const model = app.personalizedModels[modelName] && app.personalizedModels[modelName][ctxStr] ? app.personalizedModels[modelName][ctxStr] : null;
if (model) {
return model;
}
return getDefaultPersonalizedModels(modelName, autoscopeFields, ctx);
};
function getAssociatedModels(actorType, options) {
if (!associatedModelsMap[actorType]) {
var instanceModel = loopback.getModel(actorType, options);
associatedModelsMap[actorType] = [];
associatedModelsMap[actorType] = instanceModel.prototype.associatedModels.map(function (obj) {
return loopback.getModel(obj, options);
});
}
return associatedModelsMap[actorType];
}
};
function getEventHistoryModel() {
if (!EventHistoryModel) {
EventHistoryModel = loopback.getModel('EventHistory');
}
return EventHistoryModel;
}