diff --git a/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.ts b/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.ts index a4f9e22..eb5cefd 100644 --- a/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.ts +++ b/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.ts @@ -1,8 +1,17 @@ import { DocumentModelState } from 'document-model/document-model'; import { paramCase } from 'change-case'; +import { Maybe, OperationScope } from 'document-model/document'; import { Args } from '../generate-document-model'; type ModuleArgs = Args & { module: string }; +type Actions = { + name: Maybe; + hasInput: boolean; + hasAttachment: boolean | undefined; + scope: OperationScope; + state: string; +}; + export default { params: ({ args }: { args: ModuleArgs }) => { const documentModel = JSON.parse( @@ -16,20 +25,22 @@ export default { m => m.name === args.module, ); + const actions: Actions[] = + filteredModules.length > 0 + ? filteredModules[0].operations.map(a => ({ + name: a.name, + hasInput: a.schema !== null, + hasAttachment: a.schema?.includes(': Attachment'), + scope: a.scope || 'global', + state: a.scope === 'global' ? '' : a.scope, // the state this action affects + })) + : []; + return { rootDir: args.rootDir, documentType: documentModel.name, module: paramCase(args.module), - actions: - filteredModules.length > 0 - ? filteredModules[0].operations.map(a => ({ - name: a.name, - hasInput: a.schema !== null, - hasAttachment: a.schema?.includes(': Attachment'), - scope: a.scope || 'global', - state: a.scope === 'global' ? '' : a.scope, // the state this action affects - })) - : [], + actions, }; }, -} as any; +};