({ hasCustomHelper, hasCustomStepsFile, helperNames, supportObject, importPaths, translations })
| 22 | * @returns {string} |
| 23 | */ |
| 24 | const getDefinitionsFileContent = ({ hasCustomHelper, hasCustomStepsFile, helperNames, supportObject, importPaths, translations }) => { |
| 25 | const getHelperListFragment = ({ hasCustomHelper, hasCustomStepsFile }) => { |
| 26 | if (hasCustomHelper && hasCustomStepsFile) { |
| 27 | return `${['ReturnType<steps_file>', 'WithTranslation<Methods>'].join(', ')}` |
| 28 | } |
| 29 | |
| 30 | if (hasCustomStepsFile) { |
| 31 | return 'ReturnType<steps_file>' |
| 32 | } |
| 33 | |
| 34 | return 'WithTranslation<Methods>' |
| 35 | } |
| 36 | |
| 37 | const helpersListFragment = getHelperListFragment({ |
| 38 | hasCustomHelper, |
| 39 | hasCustomStepsFile, |
| 40 | }) |
| 41 | |
| 42 | const importPathsFragment = importPaths.join('\n') |
| 43 | const supportObjectsTypeFragment = convertMapToType(supportObject) |
| 44 | const methodsTypeFragment = helperNames.length > 0 ? `interface Methods extends ${helperNames.join(', ')} {}` : 'interface Methods {}' |
| 45 | const translatedActionsFragment = JSON.stringify(translations.vocabulary.actions, null, 2) |
| 46 | |
| 47 | return generateDefinitionsContent({ |
| 48 | helpersListFragment, |
| 49 | importPathsFragment, |
| 50 | supportObjectsTypeFragment, |
| 51 | methodsTypeFragment, |
| 52 | translatedActionsFragment, |
| 53 | }) |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Generate content for definitions file from fragments |
no test coverage detected