UNPKG

@rxap/schematics-ts-morph

Version:

This package provides utilities for manipulating TypeScript code using ts-morph, particularly for Angular and NestJS projects. It offers functions to add, coerce, and modify code elements like classes, methods, decorators, and imports. The package also in

22 lines 1.62 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CoerceFormSubmitOperation = CoerceFormSubmitOperation; const utilities_1 = require("@rxap/utilities"); const coerce_get_by_id_operation_1 = require("./coerce-get-by-id-operation"); function CoerceFormSubmitOperation(options) { const { tsMorphTransform = utilities_1.noop, bodyDtoName, isReturnVoid = true, // if not explicitly defined the idProperty is set to null, as not each data grid operation has an id idProperty = null, operationName = idProperty ? 'submitById' : 'submit', dtoClassNameSuffix = '-submit', } = options; return (0, coerce_get_by_id_operation_1.CoerceGetByIdOperation)(Object.assign(Object.assign({}, options), { operationName, isReturnVoid, idProperty, dtoClassNameSuffix, buildOperationDtoClassName: (controllerName, { dtoClassName, dtoClassNameSuffix = '-submit' }) => { return dtoClassName !== null && dtoClassName !== void 0 ? dtoClassName : (0, utilities_1.CoerceSuffix)(bodyDtoName !== null && bodyDtoName !== void 0 ? bodyDtoName : controllerName, dtoClassNameSuffix); }, tsMorphTransform: (project, sourceFile, classDeclaration, controllerName, moduleSourceFile, dto) => { if (!dto) { throw new Error('The dto must be created for an submit operation'); } return Object.assign({ body: dto.className, method: 'post' }, tsMorphTransform(project, sourceFile, classDeclaration, controllerName, moduleSourceFile, dto, options)); } })); } //# sourceMappingURL=coerce-form-submit-operation.js.map