@nestjs-mod/common
Version:
A collection of utilities for unifying NestJS applications and modules
37 lines • 2.29 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getFeatureDotEnvPropertyNameFormatter = getFeatureDotEnvPropertyNameFormatter;
const case_anything_1 = require("case-anything");
const default_context_name_1 = require("../../utils/default-context-name");
const name_it_class_1 = require("../../utils/name-it-class");
const dot_env_property_name_formatter_1 = require("./dot-env-property-name.formatter");
function getFeatureDotEnvPropertyNameFormatter(featureName, rootOptions, options) {
class FeatureDotEnvPropertyNameFormatter extends dot_env_property_name_formatter_1.DotEnvPropertyNameFormatter {
format({ modelOptions, propertyOptions, modelRootOptions, }) {
const modelRootOptionsName = (rootOptions !== undefined ? rootOptions : modelRootOptions)?.name
?.trim()
.split(' ')
.join('_');
const modelOptionsName = (options !== undefined ? options : modelOptions)?.name?.trim().split(' ').join('_');
const modelFeatureName = featureName?.trim().split(' ').join('_');
const prepareFullname = [
(0, default_context_name_1.defaultContextName)() !== modelRootOptionsName && modelRootOptionsName ? modelRootOptionsName : null,
!modelRootOptionsName?.endsWith(modelFeatureName) ? modelFeatureName : '',
(0, default_context_name_1.defaultContextName)() !== modelOptionsName && modelOptionsName ? modelOptionsName : null,
String(propertyOptions.name !== undefined ? propertyOptions.name : propertyOptions.originalName),
]
.filter(Boolean)
.map((v) => {
v = (0, case_anything_1.constantCase)(v);
for (const word of dot_env_property_name_formatter_1.CLEAR_WORDS) {
v = v.replace(word, '');
}
return v;
})
.join('_');
return prepareFullname.split('_').filter(Boolean).join('_');
}
}
return (0, name_it_class_1.nameItClass)(`${(0, case_anything_1.upperCamelCase)(featureName)}DotEnvPropertyNameFormatter`, FeatureDotEnvPropertyNameFormatter);
}
//# sourceMappingURL=feature-dot-env-property-name.formatter.js.map