Linkta-org / core

Core Repo for MVP
MIT License
5 stars 10 forks source link

Ensure Consistent LinktaFlow ID Handling and Move ID Mapping from Controller to Service #328

Closed kinskiwu closed 6 days ago

kinskiwu commented 2 months ago

Related Ticket

329

Description Currently, the ID mapping logic is handled within the controllers. This should be moved to the service layer to maintain a clean separation of concerns and ensure consistent ID mapping across the application.

Additionally, the LinktaFlow ID handling in the backend have inconsistencies, particularly in the ID mapping logic between different service methods. For example, the createLinktaFlow and fetchLinktaFlow methods have inconsistent ID mappings which can lead to bugs and maintenance challenges.

Examples of Inconsistencies:

Create LinktaFlow:

const mappedNodes = nodes.map((node: CustomNode) => ({
  ...node._doc,
  id: node._id,
  _id: undefined,
}));

Fetch LinktaFlow:

const mappedNodes = nodes.map((node: CustomNode) => ({
  ...node._doc,
  id: node.id,
}));

Objective

Tasks Refactor Service:

Update the controllers:

Acceptance Criteria

kinskiwu commented 1 month ago

This issue is partially resolved in #364 after removing id mapping from generateLinktaFlowfromUserInput

kinskiwu commented 6 days ago

Closing this ticket because it is no longer uncessary