UNPKG

@arianaprojects/prisma-nestjs-crud-generator

Version:
96 lines 3.54 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.decoratorGenerator = exports.parameterPipeGenerator = exports.parameterGenerator = exports.parameterPrivateGenerator = exports.parameterPrivateReadonlyGenerator = exports.importGenerator = exports.importAsGenerator = exports.functionPromiseGenerator = exports.asyncFunctionGenerator = exports.functionGenerator = exports.fieldGeneratorGeneral = exports.constructorGenerator = exports.moduleGenerator = exports.classDefaultGenerator = exports.classGenerator = exports.ModuleDecoratorGenerator = void 0; function ModuleDecoratorGenerator(IMPORTS, PROVIDERS, CONTROLLERS, EXPORTS) { return `@Module({ imports: [ ${IMPORTS} ], providers: [ ${PROVIDERS} ], controllers: [ ${CONTROLLERS} ], exports: [ ${EXPORTS} ] })`; } exports.ModuleDecoratorGenerator = ModuleDecoratorGenerator; function classGenerator(name, body, decorator = '') { return `${decorator} export class ${name} { ${body} }`; } exports.classGenerator = classGenerator; function classDefaultGenerator(name, body, decorator = '') { return `${decorator} export default class ${name} { ${body} }`; } exports.classDefaultGenerator = classDefaultGenerator; function moduleGenerator(name, IMPORTS, PROVIDERS, CONTROLLERS, EXPORTS) { return classGenerator(name, '', ModuleDecoratorGenerator(IMPORTS, PROVIDERS, CONTROLLERS, EXPORTS)); } exports.moduleGenerator = moduleGenerator; function constructorGenerator(param, body) { return `constructor(${param}){${body}}`; } exports.constructorGenerator = constructorGenerator; function fieldGeneratorGeneral(name, type, decorator) { return ` ${decorator} ${name}: ${type}`; } exports.fieldGeneratorGeneral = fieldGeneratorGeneral; function functionGenerator(name, param, ret, body) { return `private ${name}(${param}): ${ret}{ ${body} } `; } exports.functionGenerator = functionGenerator; function asyncFunctionGenerator(name, param, ret, body) { return `async ${name}(${param}): ${ret}{ ${body} } `; } exports.asyncFunctionGenerator = asyncFunctionGenerator; function functionPromiseGenerator(name, param, retType, body) { const ret = `Promise<${retType}>`; return asyncFunctionGenerator(name, param, ret, body); } exports.functionPromiseGenerator = functionPromiseGenerator; function importAsGenerator(NAME, MODULE) { return `import * as ${NAME} from ${MODULE}`; } exports.importAsGenerator = importAsGenerator; function importGenerator(NAME, MODULE) { return `import ${NAME} from ${MODULE}`; } exports.importGenerator = importGenerator; function parameterPrivateReadonlyGenerator(name, type) { return `private readonly ${name}:${type}`; } exports.parameterPrivateReadonlyGenerator = parameterPrivateReadonlyGenerator; function parameterPrivateGenerator(name, type) { return `private ${name}:${type}`; } exports.parameterPrivateGenerator = parameterPrivateGenerator; function parameterGenerator(name, type) { return `${name}:${type}`; } exports.parameterGenerator = parameterGenerator; function parameterPipeGenerator(name, type, pipe) { return `${pipe} ${name}:${type}`; } exports.parameterPipeGenerator = parameterPipeGenerator; function decoratorGenerator(name, body) { return `@${name}("${body}")`; } exports.decoratorGenerator = decoratorGenerator; //# sourceMappingURL=templates.js.map