AI Skill Report Card
Generated Skill
Quick Start
TypeScriptexport const updateEntityController = async ( id: Entity.Entity['id'], params: Entity.UpdateEntityParams, ): Promise<AxiosResponse<Entity.Entity, any>> => { const url = `/api/entity/${id}/`; const instance = genRequestInstance(); try { const response = await instance.patch(url, params); return response; } catch (error) { console.error('Erro na requisição:', error); return Promise.reject(error); } };
Recommendation▾
Consider adding more specific examples
Workflow
- Analyze requirements - Identify entity name, parameters, and URL structure
- Generate function name - Use pattern:
update{EntityName}Controller - Define parameters - ID (required), additional params (optional), body params (required)
- Build URL - Follow pattern:
/api/{module}/{entity}/{id}/or with extra params - Add JSDoc - Document all parameters, returns, and throws
- Implement function - Use genRequestInstance, patch method, error handling
Progress:
- Identify entity and module
- Determine URL parameters
- Check typings availability
- Generate controller function
- Add proper JSDoc
Recommendation▾
Include edge cases
Examples
Example 1 - Entity with version parameter: Input: Entity "adicional-noturno" with version parameter Output:
TypeScript/** * Updates an adicional noturno record * @param versao - Version ID for the planning * @param id - Adicional noturno ID to update * @param params - Update parameters for adicional noturno * @returns Promise with the updated adicional noturno data * @throws Error if request fails or authentication issues */ export const updateAdicionalNoturnoController = async ( versao: Planejamento.Versao.Versao['id'], id: Pessoal.Premissas.AdicionalNoturno.AdicionalNoturno['id'], params: Pessoal.Premissas.AdicionalNoturno.UpdateAdicionalNoturnoParams, ): Promise< AxiosResponse<Pessoal.Premissas.AdicionalNoturno.AdicionalNoturno, any> > => { const url = `/api/pessoal/versao/${versao}/adicional-noturno/${id}/`; const instance = genRequestInstance(); try { const response = await instance.patch(url, params); return response; } catch (error) { console.error('Erro na requisição:', error); return Promise.reject(error); } };
Example 2 - Simple entity without additional parameters: Input: Entity "area" without additional parameters Output:
TypeScript/** * Updates an area record * @param id - Area ID to update * @param params - Update parameters for area * @returns Promise with the updated area data * @throws Error if request fails or authentication issues */ export const updateAreaController = async ( id: Planejamento.Cadastro.Area.Area['id'], params: Planejamento.Cadastro.Area.UpdateAreaParams, ): Promise<AxiosResponse<Planejamento.Cadastro.Area.Area, any>> => { const url = `/api/planejamento/area/${id}/`; const instance = genRequestInstance(); try { const response = await instance.patch(url, params); return response; } catch (error) { console.error('Erro na requisição:', error); return Promise.reject(error); } };
Best Practices
- Function naming: Use camelCase with "update" prefix and "Controller" suffix
- URL structure: Always end with trailing slash
/ - Parameter order: Extra params first, then entity ID, then body params
- Error handling: Use try-catch but let axios interceptor handle auth errors
- Typing: Use namespace-qualified types for entity references
- JSDoc: Include @param for all parameters, @returns, and @throws
Common Pitfalls
- Missing trailing slash in URL - Always include
/at the end - Wrong parameter order - ID should be last path parameter, body params last overall
- Inconsistent naming - Don't mix snake_case with camelCase in function names
- Missing imports - Ensure genRequestInstance and AxiosResponse are imported
- Hardcoded types - Always check if typings exist in typings.d.ts first