Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
locals: function(options) {
var attrs = [];
var needs = [];
var entityOptions = options.entity.options;
for (var name in entityOptions) {
var type = entityOptions[name] || '';
var dasherizedName = stringUtils.dasherize(name);
var dasherizedNameSingular = inflection.singularize(dasherizedName);
var camelizedName = stringUtils.camelize(name);
var dasherizedType = stringUtils.dasherize(type);
if (/has-many/.test(dasherizedType)) {
var camelizedNamePlural = inflection.pluralize(camelizedName);
attrs.push(camelizedNamePlural + ': ' + dsAttr(dasherizedName, dasherizedType));
} else {
attrs.push(camelizedName + ': ' + dsAttr(dasherizedName, dasherizedType));
}
if (/has-many|belongs-to/.test(dasherizedType)) {
needs.push("'model:" + dasherizedNameSingular + "'");
}
}
attrs = attrs.join(',' + EOL + ' ');
needs = ' needs: [' + needs.join(', ') + ']';
return {
attrs: attrs,
needs: needs
export default (name: string, attrs: Array): string => {
let normalized = chain(name)
.pipe(underscore)
.pipe(classify)
.value()
if (!normalized.endsWith('Application')) {
normalized = pluralize(normalized)
}
const body = entries(
attrs
.filter(attr => /^(\w|-)+:(\w|-)+$/g.test(attr))
.map(attr => attr.split(':')[0])
.reduce((obj, attr) => ({
...obj,
params: [
...obj.params,
`${indent(8)}'${camelize(underscore(attr), true)}'`
]
}), { params: [] })
).reduce((result, group, index) => {
const [key] = group
let [, value] = group
function inflections(key) {
var single = inflect.singularize(key);
var plural = inflect.pluralize(key);
return [single, plural].join('|');
}
resource(resourceName, options = {}) {
let plural = pluralize(resourceName);
let collection = '/' + plural;
let resource = collection + '/:id';
let relationship = resource + '/relationships/:relation';
let related = resource + '/:relation';
if (options.related === false) {
options.except = [ 'related', 'fetch-related', 'replace-related', 'add-related', 'remove-related' ].concat(options.except);
}
let hasWhitelist = Boolean(options.only);
options.only = ensureArray(options.only);
options.except = ensureArray(options.except);
function include(action) {
let whitelisted = contains(options.only, action);
__resource__: function(options) {
if (options.pod) {
return 'service';
}
return inflector.pluralize(options.locals.resource);
},
__path__: function(options) {
exports.pluralize = function pluralize(str, plural) {
return i8n.pluralize(str, plural);
};
function multi(name){
var names = {};
names.single = {};
names.plural = {};
names.slug = _str.slugify(name);
names.single.slug = inflect.singularize(names.slug);
names.single.camel = _str.camelize(names.single.slug);
names.single.classed = _str.classify(names.single.slug);
names.single.humanized = _str.humanize(names.single.slug)
names.plural.slug = inflect.pluralize(names.single.slug);
names.plural.camel = _str.camelize(names.plural.slug);
names.plural.classed = _str.classify(names.plural.slug);
names.plural.humanized = _str.humanize(names.plural.slug);
return names;
}
}
_addTable: function(T)
{
var tName = inflection.pluralize(T.__name__);
this[tName] = new Queryable(T, this.DataService);
},
public executeMultiple(entities: TEntity[], options: ExecuteOptions = {}) {
this._trackAction(entities.length);
if (this.confirm && !options.skipConfirm) {
if (this.confirm instanceof Function) {
this.confirm(entities).subscribe((options) => {
this._executeMultiple(entities, options);
});
} else {
const type = inflection.pluralize(this.definition.typeName.toLowerCase());
const label = this.label(entities.first());
const message = this.i18n.t("entity-command.confirm.multiple.title", {
action: label.toLowerCase(),
count: entities.length,
type,
});
this.dialogService.confirm(
message,
{
yes: () => {
this._executeMultiple(entities);
},
});
}
} else {
propertyNames.forEach(function(propertyName) {
var property = allProperties[propertyName];
if(!property.options.isPrivate) {
if(property.isAssociation()) {
if(property.options.relationshipVia && (property.options.autoFetch || property.options.relationshipVia.options.autoFetch)) {
autoFetchedAssociationNames.push('\'' + property.options.relationshipVia.model.getName() + '\'');
}
if(property.isManyToMany()) {
methodMaps.push({
isXToMany: true,
pluralMethodName: utils.ucfirst(inflection.pluralize(propertyName)),
singularMethodName: utils.ucfirst(inflection.singularize(propertyName)),
resource: inflection.transform(propertyName, ['tableize', 'dasherize']).toLowerCase(),
propertyName: propertyName,
modelName: property.options.relationshipVia.model.getName()
});
}
else if(property.options.hasMany) {
if(!property.options.relationshipVia) {
throw new Error('Found has many relationship but could not find link. Did you call HasMany-BelongsTo on the correct models?');
}
methodMaps.push({
isXToMany: true,