Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import * as Inflector from "inflected";
Inflector.pluralize("Category");
Inflector.singularize("Categories");
Inflector.camelize("nerd_bar", false);
Inflector.underscore('FooBar') // => 'foo_bar'
//Inflector.humanize('employee_salary') // => 'Employee salary'
//Inflector.humanize('author_id') // => 'Author'
Inflector.humanize('author_id', { capitalize: false }) // => 'author'
Inflector.titleize('man from the boondocks') // => 'Man From The Boondocks'
Inflector.titleize('x-men: the last stand') // => 'X Men: The Last Stand'
Inflector.titleize('TheManWithoutAPast') // => 'The Man Without A Past'
Inflector.titleize('raiders_of_the_lost_ark') // => 'Raiders Of The Lost Ark'
Inflector.tableize('RawScaledScorer') // => 'raw_scaled_scorers'
Inflector.tableize('egg_and_ham') // => 'egg_and_hams'
Inflector.tableize('fancyCategory') // => 'fancy_categories'
Inflector.classify('egg_and_hams') // => 'EggAndHam'
var modulePath;
this.projectName = this.config.get('projectName');
var self = this;
var capitalModuleName = [];
// controller name cannot have a dot or dash in it and must be unique in the app
this.name.split(/[\.-]/).forEach(function (value) {
capitalModuleName.push(self._.capitalize(value));
});
this.capitalModuleName = capitalModuleName.join('');
this.routeFriendlyName = this.name.replace('.', '-');
this.camelModuleName = _.camelCase(this.capitalModuleName, false);
this.resourceInstance = inflector.singularize(this.camelModuleName);
this.resourceName = this._.capitalize(this.resourceInstance);
this.kebabModuleName = _.kebabCase(this.name);
this.singularKebabModuleName = _.kebabCase(inflector.singularize(this.name));
if (this.isSubmodule) {
this.lowerModuleName = this.name.toLowerCase().replace('.', '/');
this.filePrefix = this.name.substr(this.name.lastIndexOf('.') + 1);
this.path = this.name.replace(/\./g, '/')
modulePath = path.join('src', this.rootFolder, this.path);
this.resourceInstance = inflector.singularize(_.camelCase(this._.capitalize(this.filePrefix), false));
this.resourceName = this._.capitalize(this.resourceInstance);
this.singularKebabModuleName = _.kebabCase(inflector.singularize(this.filePrefix));
} else {
this.lowerModuleName = this.name.toLowerCase();
this.filePrefix = this.name;
this.path = this.name;
modulePath = path.join('src', this.rootFolder, this.name);
structNameForPropertyName(propertyName: string) {
return pascalCase(Inflector.singularize(propertyName));
}
structNameForPropertyName(propertyName: string) {
return pascalCase(Inflector.singularize(propertyName));
}
export function caseClassNameForPropertyName(propertyName) {
return pascalCase(Inflector.singularize(propertyName));
}
): GraphQLInputField & Property {
const name = field.name;
const unescapedPropertyName = isMetaFieldName(name) ? name : camelCase(name);
const propertyName = escapeIdentifierIfNeeded(unescapedPropertyName);
const type = field.type;
const isList = isListType(type);
const isOptional = !isNonNullType(type);
const bareType = getNamedType(type);
const bareTypeName = isCompositeType(bareType)
? join(
[
namespace,
parentTraitName,
escapeIdentifierIfNeeded(pascalCase(Inflector.singularize(name)))
],
"."
)
: undefined;
const typeName = typeNameFromGraphQLType(
context,
type,
bareTypeName,
isOptional,
true
);
return {
...field,
propertyName,
typeName,
isOptional,
const entityName = this.context.router.getCurrentParams().entity;
const view = this.getView(entityName);
const dataStore = this.state.data.get('dataStore').first();
const entry = dataStore.getFirstEntry(view.entity.uniqueId);
if (!entry) {
return null;
}
return (
<div>
<div>
<h1>{view.title() || 'Edit one ' + Inflector.singularize(entityName)}</h1>
<p>{view.description()}</p>
</div>
<div id="edit-view">
<form>
{this.buildFields(view, entry, dataStore)}
<div>
<div>
<button type="submit"><span></span> Save Changes</button>
</div>
</div>
</form>
</div>
</div>
Update({ customer, address, body, token = null }) {
return this.request.send(
`customers/${customer}/${this.endpoint}/${address}`,
'PUT',
{ ...body, type: singularize(this.endpoint) },
token
)
}
}
identityManagerFor(name) {
return this._identityManagers[singularize(name)] || this._identityManagers.application || IdentityManager;
}