data-contracts.ejs 875 B

12345678910111213141516171819202122232425262728
  1. <%
  2. const { modelTypes, utils, config } = it;
  3. const { formatDescription, require, _, Ts } = utils;
  4. const dataContractTemplates = {
  5. enum: (contract) => {
  6. return `enum ${contract.name} {\r\n${contract.content} \r\n }`;
  7. },
  8. interface: (contract) => {
  9. return `interface ${contract.name} {\r\n${contract.content}}`;
  10. },
  11. type: (contract) => {
  12. return `type ${contract.name} = ${contract.content}`;
  13. },
  14. }
  15. %>
  16. <% if (config.internalTemplateOptions.addUtilRequiredKeysType) { %>
  17. type <%~ config.Ts.CodeGenKeyword.UtilRequiredKeys %><T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>
  18. <% } %>
  19. <% modelTypes.forEach((contract) => { %>
  20. <%~ includeFile('./data-contract-jsdoc.ejs', { ...it, data: { ...contract, ...contract.typeData } }) %>
  21. export <%~ (dataContractTemplates[contract.typeIdentifier] || dataContractTemplates.type)(contract) %>
  22. <% }) %>