Spaces:
Sleeping
Sleeping
Commit ·
e4a761a
1
Parent(s): 5613cf3
Optimize prompts for recursive roadmap generation and add goal templates
Browse files
FlowAPI.Application/DTOs/Graph/GraphDtos.cs
CHANGED
|
@@ -47,6 +47,16 @@ namespace FlowAPI.Application.DTOs.Graph
|
|
| 47 |
{
|
| 48 |
public string Title { get; set; } = string.Empty;
|
| 49 |
public string? Description { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
}
|
| 51 |
|
| 52 |
public class UpdateGraphDto
|
|
|
|
| 47 |
{
|
| 48 |
public string Title { get; set; } = string.Empty;
|
| 49 |
public string? Description { get; set; }
|
| 50 |
+
public string? TemplateKey { get; set; }
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
public class TemplateInfoDto
|
| 54 |
+
{
|
| 55 |
+
public string Key { get; set; } = string.Empty;
|
| 56 |
+
public string Title { get; set; } = string.Empty;
|
| 57 |
+
public string Description { get; set; } = string.Empty;
|
| 58 |
+
public string Icon { get; set; } = string.Empty;
|
| 59 |
+
public string Category { get; set; } = string.Empty;
|
| 60 |
}
|
| 61 |
|
| 62 |
public class UpdateGraphDto
|
FlowAPI.Application/Services/AIService.cs
CHANGED
|
@@ -310,26 +310,31 @@ namespace FlowAPI.Application.Services
|
|
| 310 |
}
|
| 311 |
|
| 312 |
// 1. Build prompt for Gemini
|
| 313 |
-
var prompt = $"
|
| 314 |
-
"
|
| 315 |
-
"
|
| 316 |
-
"-
|
| 317 |
-
" 1. 'relationship': 'sequential'
|
| 318 |
-
" 2. 'relationship': 'subgoal'
|
| 319 |
-
"-
|
| 320 |
-
" *
|
| 321 |
-
" *
|
| 322 |
-
" *
|
| 323 |
-
"-
|
| 324 |
-
"
|
| 325 |
-
" *
|
| 326 |
-
" *
|
| 327 |
-
"
|
| 328 |
-
"
|
| 329 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 330 |
|
| 331 |
// 2. Call Gemini API
|
| 332 |
-
var systemInstruction = "You are a friendly, highly professional Roadmap Strategist AI Agent. You design detailed, clean, and logical roadmaps represented as graphs (nodes and edges). You break down complex goals into hierarchical subgoals. You can connect a parent to multiple parallel subgoals using 'subgoal' relationship, or connect a parent to the first subgoal in a sequence using 'subgoal' and chain the remaining subgoals using 'sequential' relationship. You write warm, direct, and conversational explanations in the 'explanation' field.";
|
| 333 |
var responseJson = await CallGeminiApiAsync(prompt, systemInstruction, GoalResponseSchema);
|
| 334 |
responseJson = CleanJson(responseJson);
|
| 335 |
|
|
@@ -442,33 +447,36 @@ namespace FlowAPI.Application.Services
|
|
| 442 |
}
|
| 443 |
|
| 444 |
// 2. Build the prompt
|
| 445 |
-
var prompt = $"
|
| 446 |
-
$"
|
| 447 |
$"{existingNodesText}\n" +
|
| 448 |
$"{existingEdgesText}\n\n" +
|
| 449 |
-
"
|
| 450 |
-
"1.
|
| 451 |
-
" -
|
| 452 |
-
" * 'relationship': 'sequential'
|
| 453 |
-
" * 'relationship': 'subgoal'
|
| 454 |
-
" -
|
| 455 |
-
" *
|
| 456 |
-
" *
|
| 457 |
-
"
|
| 458 |
-
"
|
| 459 |
-
" *
|
| 460 |
-
" *
|
| 461 |
-
"
|
| 462 |
-
"
|
| 463 |
-
" *
|
| 464 |
-
" *
|
| 465 |
-
"
|
| 466 |
-
" -
|
| 467 |
-
"
|
| 468 |
-
"
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
|
|
|
|
|
|
|
|
|
| 472 |
var contentsList = new List<object>();
|
| 473 |
if (request.History != null)
|
| 474 |
{
|
|
|
|
| 310 |
}
|
| 311 |
|
| 312 |
// 1. Build prompt for Gemini
|
| 313 |
+
var prompt = $"������������ ����� ������� ��������� ����: \"{request.Goal}\". " +
|
| 314 |
+
"������� ��������� ������������� �������� �����.\n" +
|
| 315 |
+
"������� ���������� ������ � ��������� (������������� � �����������):\n" +
|
| 316 |
+
"- � ��� ���� ��� ���� ������:\n" +
|
| 317 |
+
" 1. 'relationship': 'sequential' � ���������������� ���� / ����. ������������ ��� �������� ��������� � ��������� ����� ������� ������ ������ ����������, � ����� ��� ���������� ����� ������ ������� ������������ ���� � ������.\n" +
|
| 318 |
+
" 2. 'relationship': 'subgoal' � ������������ � �������. ������������ ��� ���������� ������� ���� �� ������ ������ �����.\n" +
|
| 319 |
+
"- ������� ����������� ������������ (����������):\n" +
|
| 320 |
+
" * ����� ���� �� ����� ������ ����� ���� ���������������! ���� ������� ���� �� ���� �������, �� ������ ������� � �� � ����������� ������� (subgoals) � ���������������� ����.\n" +
|
| 321 |
+
" * �� ������������� ����� ������� ��������. ������� �������� ������ (��������: ������� ���� -> ������� A -> ������� A.1 -> ������� A.1.1) � ��� ��������� � ��������������.\n" +
|
| 322 |
+
" * ������: ������� ���� '������������� �����' ����� ������� '����� �����'. ������� '����� �����' ����� ���� ����������� ������� '���������� �����' � '��������� �������' (��������� ����� 'subgoal' � '����� �����'). '��������� �������' ����� ����� ���� '���������� �����' -> '�������� ������' (��������� ����� 'sequential' ����� �����).\n" +
|
| 323 |
+
"- ��� ��������� ������� ������������ � �������:\n" +
|
| 324 |
+
" * ������������ �������: ���� � ������������ ���� ���� ��������� ����������� ��� ������������ �����������, ��������� �� ��� �������� � �������� ����� ����� 'subgoal' (������� �����������).\n" +
|
| 325 |
+
" * ���������������� �������: ���� ���� ������ ������� ������ ����������� ������ ���� �� ������, �� �������� �������� ����� 'subgoal' ������ � ������ ����� �������, � ��������� ���� ������ ���� ������� �������� ��������������� ����� 'sequential'.\n" +
|
| 326 |
+
" * ��������� ���������: �� ������ �������� ������������� ��� ������� �� ����� ������� �����������.\n" +
|
| 327 |
+
"- �� ��������� ������������ �������� ��� ���������������� �����. ������� �� ����������������� ������ / ������. ������� ��������� / ����������� ������ �������� ������������.\n" +
|
| 328 |
+
"- �������� ����� ������ ���� ����������� ��������� � ������. �� ����� �� �� 2-3 ���! ���� ���� ������� (��� ������� �����, �������� ����������������), ���������� ����������� ����� �� 8-15+ �����, ������������ ��� ������ ���� � �� ���������.\n" +
|
| 329 |
+
"- ������� ��� ����� ����� (����������):\n" +
|
| 330 |
+
" * 'sketch' � ����������� ���/���� (��������� � 99% �������). ����� ������� �������� ���, ���� ���� �� �������� ��������, ����� �������� (��������, '�������� 30 �����', '��������� 1 ���') ��� �������� ��������, ������ ����� ��� 'sketch'!\n" +
|
| 331 |
+
" * 'habit' (��������) � ��������� ������ ������ ���� ������������ ����� ������ ���������� ����������, ���������/����������� ������������� �������� ��� ������������ �������� (��������, '������ ���� ���� ����'). ������� �� ��������� ��� ��� ������� ����� ��������!\n" +
|
| 332 |
+
" * 'condition' (�������) � ��������� ������ ������ ��� ����� ���������� ���������, �������� � ������ (��������, '���� X, �� Y, ����� Z'). ������� �� ��������� ��� ��� ������� ����� � ���������� ����������, ���� ��� ��������� ����!\n" +
|
| 333 |
+
"������� ���� ��� �������� �������� �������� (label) � ��������� �������� (description).\n" +
|
| 334 |
+
"� ���� 'explanation' ������ �����, ����������� � ������������� ����� �� ���� ����������� ������-��������, ������� ������ ������������ ����� � ��� ������ ������.";
|
| 335 |
|
| 336 |
// 2. Call Gemini API
|
| 337 |
+
var systemInstruction = "You are a friendly, highly professional Roadmap Strategist AI Agent. You design detailed, clean, and logical roadmaps represented as graphs (nodes and edges). You break down complex goals into hierarchical, deeply nested subgoals (recursive subgoals, where subgoals can have their own subgoals). You can connect a parent to multiple parallel subgoals using 'subgoal' relationship, or connect a parent to the first subgoal in a sequence using 'subgoal' and chain the remaining subgoals using 'sequential' relationship. Node types MUST follow these rules: 'sketch' for 99% of regular tasks (including tasks with durations/wait times); 'habit' ONLY for repeating daily/weekly actions meant to form a routine, if explicitly requested; 'condition' ONLY for logical forks/branches with conditions. You write warm, direct, and conversational explanations in the 'explanation' field.";
|
| 338 |
var responseJson = await CallGeminiApiAsync(prompt, systemInstruction, GoalResponseSchema);
|
| 339 |
responseJson = CleanJson(responseJson);
|
| 340 |
|
|
|
|
| 447 |
}
|
| 448 |
|
| 449 |
// 2. Build the prompt
|
| 450 |
+
var prompt = $"������������ ���������� � ���� (������-��������) �� ��������� ���������� ��� ��������:\n" +
|
| 451 |
+
$"������ ������������: \"{request.UserPrompt}\"\n\n" +
|
| 452 |
$"{existingNodesText}\n" +
|
| 453 |
$"{existingEdgesText}\n\n" +
|
| 454 |
+
"���� ������:\n" +
|
| 455 |
+
"1. ���� ������ ������������ ������� ���������� ����� ���������, ����������� ��� ���������� �����: ���������� ����� ���� (NewNodes) � ����� ����� (NewEdges). ��� ���� ������ ������ �������� ���������� ������:\n" +
|
| 456 |
+
" - � ��� ���� ��� ���� ������:\n" +
|
| 457 |
+
" * 'relationship': 'sequential' � ���������������� ���� / ����. ������������ ��� �������� ��������� � ��������� ����� ������� ������ ������ ����������, � ����� ��� ���������� ����� ������ ������� ������������ ���� � ������.\n" +
|
| 458 |
+
" * 'relationship': 'subgoal' � ������������ � �������. ������������ ��� ���������� ������� ���� �� ������ ������ �����.\n" +
|
| 459 |
+
" - ������� ����������� ������������ (����������):\n" +
|
| 460 |
+
" * ����� ���� �� ����� ������ ����� ���� ���������������! ���� ������� ���� �� ���� �������, �� ������ ������� � �� � ����������� ������� (subgoals) � ���������������� ����.\n" +
|
| 461 |
+
" * �� ������������� ����� ������� ��������. ������� �������� ������ (��������: ������� ���� -> ������� A -> ������� A.1 -> ������� A.1.1) � ��� ��������� � ��������������.\n" +
|
| 462 |
+
" - ��� ��������� ������� ������������ � �������:\n" +
|
| 463 |
+
" * ������������ �������: ���� � ������������ ���� ���� ��������� ����������� ��� ������������ �����������, ��������� �� ��� �������� � �������� ����� ����� 'subgoal' (������� �����������).\n" +
|
| 464 |
+
" * ���������������� �������: ���� ���� ������ ������� ������ ����������� ������ ���� �� ������, �� �������� �������� ����� 'subgoal' ������ � ������ ����� �������, � ��������� ���� ������ ���� ������� �������� ��������������� ����� 'sequential'.\n" +
|
| 465 |
+
" * ��������� ���������: �� ������ �������� ������������� ��� ������� �� ����� ������� �����������.\n" +
|
| 466 |
+
" - ���� ������������ ������ �������� ������� (������������) ��� ����� ��� ������������ ����:\n" +
|
| 467 |
+
" * ���� ��������������� ������������ ���� ��� �� �����, ������� ������ ������������ ���� (��������, '������������' / 'Configuration') � ����� ��� ��������������� � ���������� ������ ����� 'relationship': 'sequential'.\n" +
|
| 468 |
+
" * ����� ������������ ���� � ��������� (��������� ������� ����������� ��� ������������ ����� ��� ���������������� ������� ��� ��������� �����, ��� ������� ����).\n" +
|
| 469 |
+
" * �� ��������� ������������ �������� ��� ���������������� �����. ������� �� ����������������� ������ / ������. ������� ��������� / ����������� ������ �������� ������������.\n" +
|
| 470 |
+
" - ����������� ���� ����������� �����. �� ��������� 1-2 ����, ���� ������������ ������ ��������� ��� ��������� �����; ������ �����������, ������� � ��������� ���� �� 5-12 �����.\n" +
|
| 471 |
+
" - ������� ��� ����� ����� (����������):\n" +
|
| 472 |
+
" * 'sketch' � ����������� ���/���� (��������� � 99% �������). ����� ������� �������� ���, ���� ���� �� �������� ��������, ����� �������� (��������, '�������� 30 �����', '��������� 1 ���') ��� �������� ��������, ������ ����� ��� 'sketch'!\n" +
|
| 473 |
+
" * 'habit' (��������) � ��������� ������ ������ ���� ������������ ����� ������ ���������� ����������, ���������/����������� ������������� �������� ��� ������������ �������� (��������, '������ ���� ���� ����'). ������� �� ��������� ��� ��� ������� ����� ��������!\n" +
|
| 474 |
+
" * 'condition' (�������) � ��������� ������ ������ ��� ����� ���������� ���������, �������� � ������ (��������, '���� X, �� Y, ����� Z'). ������� �� ��������� ��� ��� ������� ����� � ���������� ����������, ���� ��� ��������� ����!\n" +
|
| 475 |
+
" - �������� ����� ���� � ������������� ��� ���� � ������ � ������� ���������� ��������� ID (��������, new_step_1).\n" +
|
| 476 |
+
"2. ���� ������ ������������ �� ������� ���������� ���������: ������ ������ 'NewNodes' � 'NewEdges' ������� ( [] ).\n" +
|
| 477 |
+
"3. � ���� 'explanation' ������ ������������, ����� � ����������� ����� �� ���� ��������-����������, ������� ��������� ��������� ��� ������� �� �������.";
|
| 478 |
+
|
| 479 |
+
var systemInstruction = "You are a friendly, highly professional Roadmap Strategist AI Agent. You interact with the user, answer their questions, and help them design, extend, or analyze their roadmaps. If changes are needed, you return the new nodes and edges, breaking down complex tasks into hierarchical, deeply nested subgoals (recursive subgoals, where subgoals can have their own subgoals). You can connect a parent to multiple parallel subgoals using 'subgoal' relationship, or connect a parent to the first subgoal in a sequence using 'subgoal' and chain the remaining subgoals using 'sequential' relationship. Node types MUST follow these rules: 'sketch' for 99% of regular tasks (including tasks with durations/wait times); 'habit' ONLY for repeating daily/weekly actions meant to form a routine, if explicitly requested; 'condition' ONLY for logical forks/branches with conditions. You never connect subgoals directly to unrelated nodes without a parent node.";
|
| 480 |
var contentsList = new List<object>();
|
| 481 |
if (request.History != null)
|
| 482 |
{
|
FlowAPI.Application/Services/GraphService.cs
CHANGED
|
@@ -146,9 +146,32 @@ namespace FlowAPI.Application.Services
|
|
| 146 |
CreatedAt = DateTime.UtcNow
|
| 147 |
};
|
| 148 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
var created = await _repo.CreateAsync(graph);
|
| 150 |
|
| 151 |
await _achievementService.ProcessEventAsync(currentUserId, "GraphCreated");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
|
| 153 |
var result = MapToDto(created);
|
| 154 |
result.IsShared = false;
|
|
|
|
| 146 |
CreatedAt = DateTime.UtcNow
|
| 147 |
};
|
| 148 |
|
| 149 |
+
if (!string.IsNullOrEmpty(dto.TemplateKey))
|
| 150 |
+
{
|
| 151 |
+
var (nodes, edges) = TemplateLibrary.GetTemplateContent(dto.TemplateKey, graph.Id);
|
| 152 |
+
if (nodes.Count > 0)
|
| 153 |
+
{
|
| 154 |
+
graph.Nodes = nodes;
|
| 155 |
+
graph.Edges = edges;
|
| 156 |
+
if (string.IsNullOrEmpty(dto.Description) || dto.Description == "New strategy path...")
|
| 157 |
+
{
|
| 158 |
+
graph.Description = $"Побудовано за шаблоном";
|
| 159 |
+
}
|
| 160 |
+
}
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
var created = await _repo.CreateAsync(graph);
|
| 164 |
|
| 165 |
await _achievementService.ProcessEventAsync(currentUserId, "GraphCreated");
|
| 166 |
+
|
| 167 |
+
if (graph.Nodes.Count > 0)
|
| 168 |
+
{
|
| 169 |
+
await _achievementService.ProcessEventAsync(currentUserId, "NodeCreated", graph.Nodes.Count);
|
| 170 |
+
}
|
| 171 |
+
if (graph.Edges.Count > 0)
|
| 172 |
+
{
|
| 173 |
+
await _achievementService.ProcessEventAsync(currentUserId, "EdgeCreated", graph.Edges.Count);
|
| 174 |
+
}
|
| 175 |
|
| 176 |
var result = MapToDto(created);
|
| 177 |
result.IsShared = false;
|
FlowAPI.Application/Services/TemplateLibrary.cs
ADDED
|
@@ -0,0 +1,353 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
using System;
|
| 2 |
+
using System.Collections.Generic;
|
| 3 |
+
using FlowAPI.Application.DTOs.Graph;
|
| 4 |
+
using FlowAPI.Domain.Entities;
|
| 5 |
+
using FlowAPI.Domain.Enums;
|
| 6 |
+
|
| 7 |
+
namespace FlowAPI.Application.Services
|
| 8 |
+
{
|
| 9 |
+
public static class TemplateLibrary
|
| 10 |
+
{
|
| 11 |
+
private class TemplateNodeDef
|
| 12 |
+
{
|
| 13 |
+
public string TempId { get; set; } = string.Empty;
|
| 14 |
+
public string Label { get; set; } = string.Empty;
|
| 15 |
+
public double PosX { get; set; }
|
| 16 |
+
public double PosY { get; set; }
|
| 17 |
+
public string Type { get; set; } = "sketch";
|
| 18 |
+
public string Color { get; set; } = "white";
|
| 19 |
+
public string Description { get; set; } = string.Empty;
|
| 20 |
+
public string DecisionJson { get; set; } = string.Empty;
|
| 21 |
+
public double? Width { get; set; }
|
| 22 |
+
public double? Height { get; set; }
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
private class TemplateEdgeDef
|
| 26 |
+
{
|
| 27 |
+
public string FromTempId { get; set; } = string.Empty;
|
| 28 |
+
public string ToTempId { get; set; } = string.Empty;
|
| 29 |
+
public string Condition { get; set; } = "True";
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
private class TemplateDef
|
| 33 |
+
{
|
| 34 |
+
public string Key { get; set; } = string.Empty;
|
| 35 |
+
public string Title { get; set; } = string.Empty;
|
| 36 |
+
public string Description { get; set; } = string.Empty;
|
| 37 |
+
public string Icon { get; set; } = string.Empty;
|
| 38 |
+
public string Category { get; set; } = string.Empty;
|
| 39 |
+
public List<TemplateNodeDef> Nodes { get; set; } = new();
|
| 40 |
+
public List<TemplateEdgeDef> Edges { get; set; } = new();
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
private static readonly Dictionary<string, TemplateDef> Templates = new()
|
| 44 |
+
{
|
| 45 |
+
{
|
| 46 |
+
"startup",
|
| 47 |
+
new TemplateDef
|
| 48 |
+
{
|
| 49 |
+
Key = "startup",
|
| 50 |
+
Title = "Запуск Стартапу",
|
| 51 |
+
Description = "Шлях від формулювання ціннісної пропозиції та CustDev до запуску MVP та перших 100 користувачів.",
|
| 52 |
+
Icon = "Rocket",
|
| 53 |
+
Category = "Business",
|
| 54 |
+
Nodes = new List<TemplateNodeDef>
|
| 55 |
+
{
|
| 56 |
+
new() { TempId = "vprop", Label = "Формулювання ціннісної пропозиції", PosX = 250, PosY = 50, Color = "purple", Description = "Чітко опишіть, яку проблему вирішує ваш продукт і для кого." },
|
| 57 |
+
new() { TempId = "custdev", Label = "CustDev: Інтерв'ю з клієнтами", PosX = 250, PosY = 170, Color = "blue", Description = "Проведіть принаймні 10 інтерв'ю з потенційними користувачами." },
|
| 58 |
+
new() { TempId = "fit", Label = "Чи підтверджено проблему?", PosX = 250, PosY = 290, Type = "condition", DecisionJson = "{\"options\":[{\"id\":\"opt-yes\",\"label\":\"Так (Є інтерес)\"},{\"id\":\"opt-no\",\"label\":\"Ні (Потрібен півот)\"}],\"selected\":[],\"multiSelect\":false}" },
|
| 59 |
+
new() { TempId = "mvp", Label = "Розробка MVP", PosX = 100, PosY = 420, Color = "green", Description = "Створіть мінімально життєздатний продукт з однією ключовою функцією." },
|
| 60 |
+
new() { TempId = "pivot", Label = "Півот ідеї", PosX = 400, PosY = 420, Color = "orange", Description = "Змініть напрямок або цільову аудиторію на основі фідбеку з інтерв'ю." },
|
| 61 |
+
new() { TempId = "landing", Label = "Лендинг та збір заявок", PosX = 100, PosY = 550, Color = "pink", Description = "Налаштуйте просту сторінку для збору контактів зацікавлених клієнтів." },
|
| 62 |
+
new() { TempId = "users", Label = "Залучення перших 100 користувачів", PosX = 100, PosY = 680, Color = "yellow", Description = "Використовуйте безкоштовні канали (соцмережі, профільні форуми, зв'язки)." }
|
| 63 |
+
},
|
| 64 |
+
Edges = new List<TemplateEdgeDef>
|
| 65 |
+
{
|
| 66 |
+
new() { FromTempId = "vprop", ToTempId = "custdev" },
|
| 67 |
+
new() { FromTempId = "custdev", ToTempId = "fit" },
|
| 68 |
+
new() { FromTempId = "fit", ToTempId = "mvp", Condition = "True" },
|
| 69 |
+
new() { FromTempId = "fit", ToTempId = "pivot", Condition = "False" },
|
| 70 |
+
new() { FromTempId = "pivot", ToTempId = "vprop" },
|
| 71 |
+
new() { FromTempId = "mvp", ToTempId = "landing" },
|
| 72 |
+
new() { FromTempId = "landing", ToTempId = "users" }
|
| 73 |
+
}
|
| 74 |
+
}
|
| 75 |
+
},
|
| 76 |
+
{
|
| 77 |
+
"software",
|
| 78 |
+
new TemplateDef
|
| 79 |
+
{
|
| 80 |
+
Key = "software",
|
| 81 |
+
Title = "Розробка ПЗ (Web App)",
|
| 82 |
+
Description = "Стандартний життєвий цикл розробки веб-додатку: вимоги, дизайн, UI/UX, API, інтеграція та реліз.",
|
| 83 |
+
Icon = "Code",
|
| 84 |
+
Category = "Development",
|
| 85 |
+
Nodes = new List<TemplateNodeDef>
|
| 86 |
+
{
|
| 87 |
+
new() { TempId = "req", Label = "Збір та аналіз вимог", PosX = 250, PosY = 50, Color = "blue", Description = "Опишіть функціонал проекту та підготуйте ТЗ." },
|
| 88 |
+
new() { TempId = "arch", Label = "Архітектура та проектування БД", PosX = 250, PosY = 170, Color = "purple", Description = "Спроектуйте схему бази даних та виберіть стек технологій." },
|
| 89 |
+
new() { TempId = "uiux", Label = "UI/UX макети та дизайн", PosX = 100, PosY = 300, Color = "pink", Description = "Створіть клікабельний прототип у Figma." },
|
| 90 |
+
new() { TempId = "api", Label = "Розробка API та Бекенду", PosX = 400, PosY = 300, Color = "yellow", Description = "Реалізуйте серверу логіку, авторизацію та базу даних." },
|
| 91 |
+
new() { TempId = "integ", Label = "Інтеграція та тестування", PosX = 250, PosY = 440, Color = "green", Description = "З'єднайте фронтенд з бекендом та проведіть ручне тестування." },
|
| 92 |
+
new() { TempId = "staging", Label = "Деплой на Staging сервер", PosX = 250, PosY = 560, Color = "orange", Description = "Розгорніть тестову версію додатку для фінальної перевірки." },
|
| 93 |
+
new() { TempId = "prod", Label = "Реліз у Production та моніторинг", PosX = 250, PosY = 680, Color = "green", Description = "Запустіть додаток для реальних користувачів та підключіть аналітику." }
|
| 94 |
+
},
|
| 95 |
+
Edges = new List<TemplateEdgeDef>
|
| 96 |
+
{
|
| 97 |
+
new() { FromTempId = "req", ToTempId = "arch" },
|
| 98 |
+
new() { FromTempId = "arch", ToTempId = "uiux" },
|
| 99 |
+
new() { FromTempId = "arch", ToTempId = "api" },
|
| 100 |
+
new() { FromTempId = "uiux", ToTempId = "integ" },
|
| 101 |
+
new() { FromTempId = "api", ToTempId = "integ" },
|
| 102 |
+
new() { FromTempId = "integ", ToTempId = "staging" },
|
| 103 |
+
new() { FromTempId = "staging", ToTempId = "prod" }
|
| 104 |
+
}
|
| 105 |
+
}
|
| 106 |
+
},
|
| 107 |
+
{
|
| 108 |
+
"language",
|
| 109 |
+
new TemplateDef
|
| 110 |
+
{
|
| 111 |
+
Key = "language",
|
| 112 |
+
Title = "Вивчення Іноземної Мови",
|
| 113 |
+
Description = "Методика освоєння мови через щоденні звички, проходження базового курсу та вихід у практику.",
|
| 114 |
+
Icon = "Languages",
|
| 115 |
+
Category = "Education",
|
| 116 |
+
Nodes = new List<TemplateNodeDef>
|
| 117 |
+
{
|
| 118 |
+
new() { TempId = "goal", Label = "Визначення цілей та ресурсів", PosX = 250, PosY = 50, Color = "purple", Description = "Оберіть додатки, підручники та поставте чітку ціль (наприклад, рівень B1)." },
|
| 119 |
+
new() { TempId = "words", Label = "Вчити 15 нових слів щодня", PosX = 100, PosY = 170, Type = "habit", Color = "blue", Description = "Використовуйте картки Anki або Quizlet для регулярного повторення.", DecisionJson = "{\"resetRule\":{\"type\":\"daily\",\"time\":\"00:00\"},\"createdAt\":\"" + DateTime.UtcNow.ToString("o") + "\",\"description\":\"Використовуйте картки Anki або Quizlet для регулярного повторення.\",\"tags\":[],\"status\":\"Todo\",\"progress\":0}" },
|
| 120 |
+
new() { TempId = "listen", Label = "Слухати подкаст / дивитись відео", PosX = 400, PosY = 170, Type = "habit", Color = "pink", Description = "Принаймні 20 хвилин фонового або активного слухання щодня.", DecisionJson = "{\"resetRule\":{\"type\":\"daily\",\"time\":\"00:00\"},\"createdAt\":\"" + DateTime.UtcNow.ToString("o") + "\",\"description\":\"Принаймні 20 хвилин фонового або активного слухання щодня.\",\"tags\":[],\"status\":\"Todo\",\"progress\":0}" },
|
| 121 |
+
new() { TempId = "course", Label = "Завершити курс для початківців", PosX = 250, PosY = 300, Color = "yellow", Description = "Пройти базову граматику та отримати розуміння структури мови." },
|
| 122 |
+
new() { TempId = "speak", Label = "Розмовна сесія (1 раз на тиждень)", PosX = 100, PosY = 430, Type = "habit", Color = "green", Description = "Знайдіть партнера для спілкування на Tandem або викладача.", DecisionJson = "{\"resetRule\":{\"type\":\"weekly\",\"time\":\"00:00\"},\"createdAt\":\"" + DateTime.UtcNow.ToString("o") + "\",\"description\":\"Знайдіть партнера для спілкування на Tandem або викладача.\",\"tags\":[],\"status\":\"Todo\",\"progress\":0}" },
|
| 123 |
+
new() { TempId = "read", Label = "Прочитати першу коротку розповідь", PosX = 400, PosY = 430, Color = "orange", Description = "Оберіть адаптовану книгу під ваш поточний рівень." },
|
| 124 |
+
new() { TempId = "exam", Label = "Скласти тестовий іспит", PosX = 250, PosY = 560, Color = "green", Description = "Перевірте свій прогрес за допомогою офіційного пробного тесту." }
|
| 125 |
+
},
|
| 126 |
+
Edges = new List<TemplateEdgeDef>
|
| 127 |
+
{
|
| 128 |
+
new() { FromTempId = "goal", ToTempId = "words" },
|
| 129 |
+
new() { FromTempId = "goal", ToTempId = "listen" },
|
| 130 |
+
new() { FromTempId = "words", ToTempId = "course" },
|
| 131 |
+
new() { FromTempId = "listen", ToTempId = "course" },
|
| 132 |
+
new() { FromTempId = "course", ToTempId = "speak" },
|
| 133 |
+
new() { FromTempId = "course", ToTempId = "read" },
|
| 134 |
+
new() { FromTempId = "speak", ToTempId = "exam" },
|
| 135 |
+
new() { FromTempId = "read", ToTempId = "exam" }
|
| 136 |
+
}
|
| 137 |
+
}
|
| 138 |
+
},
|
| 139 |
+
{
|
| 140 |
+
"fitness",
|
| 141 |
+
new TemplateDef
|
| 142 |
+
{
|
| 143 |
+
Key = "fitness",
|
| 144 |
+
Title = "Фітнес та Здорове Тіло",
|
| 145 |
+
Description = "Збалансований план тренувань, контролю харчування та циклічного аналізу результатів.",
|
| 146 |
+
Icon = "Activity",
|
| 147 |
+
Category = "Health",
|
| 148 |
+
Nodes = new List<TemplateNodeDef>
|
| 149 |
+
{
|
| 150 |
+
new() { TempId = "setup", Label = "Поставити ціль та розрахувати КБЖВ", PosX = 250, PosY = 50, Color = "blue", Description = "Визначте добову норму калорій залежно від мети (схуднення чи набір маси)." },
|
| 151 |
+
new() { TempId = "plan", Label = "Скласти план тренувань та раціон", PosX = 250, PosY = 170, Color = "purple", Description = "Виберіть 3 дні для занять та підготуйте перелік здорових страв." },
|
| 152 |
+
new() { TempId = "diet", Label = "Трекати щоденне харчування та воду", PosX = 100, PosY = 300, Type = "habit", Color = "green", Description = "Записуйте все з'їдене в MyFitnessPal та пийте достатньо води.", DecisionJson = "{\"resetRule\":{\"type\":\"daily\",\"time\":\"00:00\"},\"createdAt\":\"" + DateTime.UtcNow.ToString("o") + "\",\"description\":\"Записуйте все з'їдене в MyFitnessPal та пийте достатньо води.\",\"tags\":[],\"status\":\"Todo\",\"progress\":0}" },
|
| 153 |
+
new() { TempId = "workout", Label = "Силове або кардіо тренування", PosX = 400, PosY = 300, Type = "habit", Color = "orange", Description = "Виконуйте заплановане тренування 3 рази на тиждень.", DecisionJson = "{\"resetRule\":{\"type\":\"weekly\",\"time\":\"00:00\"},\"createdAt\":\"" + DateTime.UtcNow.ToString("o") + "\",\"description\":\"Виконуйте заплановане тренування 3 рази на тиждень.\",\"tags\":[],\"status\":\"Todo\",\"progress\":0}" },
|
| 154 |
+
new() { TempId = "check", Label = "Контрольне зважування та заміри (4 тижні)", PosX = 250, PosY = 430, Color = "yellow", Description = "Порівняйте поточну вагу та об'єми тіла з початковими показниками." },
|
| 155 |
+
new() { TempId = "satisfied", Label = "Чи є прогрес задовільним?", PosX = 250, PosY = 550, Type = "condition", DecisionJson = "{\"options\":[{\"id\":\"opt-yes\",\"label\":\"Так (Продовжуємо)\"},{\"id\":\"opt-no\",\"label\":\"Ні (Потрібні коригування)\"}],\"selected\":[],\"multiSelect\":false}" },
|
| 156 |
+
new() { TempId = "advance", Label = "Ускладнити програму тренувань", PosX = 100, PosY = 680, Color = "pink", Description = "Додайте вагу на снарядах або збільшіть інтенсивність." },
|
| 157 |
+
new() { TempId = "adjust", Label = "Скоригувати КБЖВ та план їжі", PosX = 400, PosY = 680, Color = "yellow", Description = "Зменшіть або збільшіть калорійність раціону на 10%." }
|
| 158 |
+
},
|
| 159 |
+
Edges = new List<TemplateEdgeDef>
|
| 160 |
+
{
|
| 161 |
+
new() { FromTempId = "setup", ToTempId = "plan" },
|
| 162 |
+
new() { FromTempId = "plan", ToTempId = "diet" },
|
| 163 |
+
new() { FromTempId = "plan", ToTempId = "workout" },
|
| 164 |
+
new() { FromTempId = "diet", ToTempId = "check" },
|
| 165 |
+
new() { FromTempId = "workout", ToTempId = "check" },
|
| 166 |
+
new() { FromTempId = "check", ToTempId = "satisfied" },
|
| 167 |
+
new() { FromTempId = "satisfied", ToTempId = "advance", Condition = "True" },
|
| 168 |
+
new() { FromTempId = "satisfied", ToTempId = "adjust", Condition = "False" },
|
| 169 |
+
new() { FromTempId = "adjust", ToTempId = "plan" }
|
| 170 |
+
}
|
| 171 |
+
}
|
| 172 |
+
},
|
| 173 |
+
{
|
| 174 |
+
"gamedev",
|
| 175 |
+
new TemplateDef
|
| 176 |
+
{
|
| 177 |
+
Key = "gamedev",
|
| 178 |
+
Title = "Створення Інді-Гри",
|
| 179 |
+
Description = "Повний цикл геймдеву від ідеї та прототипу до створення сторінки в Steam та релізу.",
|
| 180 |
+
Icon = "Gamepad",
|
| 181 |
+
Category = "Creative",
|
| 182 |
+
Nodes = new List<TemplateNodeDef>
|
| 183 |
+
{
|
| 184 |
+
new() { TempId = "concept", Label = "Концепт та написання GDD", PosX = 250, PosY = 50, Color = "pink", Description = "Сформулюйте основну ідею гри та опишіть її механіки в дизайн-документі." },
|
| 185 |
+
new() { TempId = "proto", Label = "Прототип базового геймплею", PosX = 250, PosY = 170, Color = "purple", Description = "Створіть «сіру коробку» на рушії, щоб перевірити, чи весело грати." },
|
| 186 |
+
new() { TempId = "art", Label = "Стилістика та створення артів", PosX = 100, PosY = 300, Color = "orange", Description = "Визначте художній стиль та підготуйте перші 2D/3D моделі." },
|
| 187 |
+
new() { TempId = "level", Label = "Дизайн рівнів та звуковий супровід", PosX = 400, PosY = 300, Color = "blue", Description = "Створіть тестовий рівень та додайте базові звукові ефекти." },
|
| 188 |
+
new() { TempId = "playable", Label = "Перша грабельна демо-версія", PosX = 250, PosY = 430, Color = "yellow", Description = "Зберіть стабільний білд для тестування друзями." },
|
| 189 |
+
new() { TempId = "test", Label = "Плейтести та виправлення багів", PosX = 100, PosY = 560, Type = "habit", Color = "pink", Description = "Щодня грайте, збирайте фідбек та виправляйте помилки.", DecisionJson = "{\"resetRule\":{\"type\":\"daily\",\"time\":\"00:00\"},\"createdAt\":\"" + DateTime.UtcNow.ToString("o") + "\",\"description\":\"Щодня грайте, збирайте фідбек та виправляйте помилки.\",\"tags\":[],\"status\":\"Todo\",\"progress\":0}" },
|
| 190 |
+
new() { TempId = "steam", Label = "Створення сторінки в Steam", PosX = 400, PosY = 560, Color = "yellow", Description = "Підготуйте красиві скріншоти, трейлер та запустіть сторінку для збору Wishlists." },
|
| 191 |
+
new() { TempId = "release", Label = "Реліз гри в Steam", PosX = 250, PosY = 690, Color = "green", Description = "Опублікуйте фінальний білд та підтримайте запуск маркетинговою кампанією." }
|
| 192 |
+
},
|
| 193 |
+
Edges = new List<TemplateEdgeDef>
|
| 194 |
+
{
|
| 195 |
+
new() { FromTempId = "concept", ToTempId = "proto" },
|
| 196 |
+
new() { FromTempId = "proto", ToTempId = "art" },
|
| 197 |
+
new() { FromTempId = "proto", ToTempId = "level" },
|
| 198 |
+
new() { FromTempId = "art", ToTempId = "playable" },
|
| 199 |
+
new() { FromTempId = "level", ToTempId = "playable" },
|
| 200 |
+
new() { FromTempId = "playable", ToTempId = "test" },
|
| 201 |
+
new() { FromTempId = "playable", ToTempId = "steam" },
|
| 202 |
+
new() { FromTempId = "test", ToTempId = "release" },
|
| 203 |
+
new() { FromTempId = "steam", ToTempId = "release" }
|
| 204 |
+
}
|
| 205 |
+
}
|
| 206 |
+
},
|
| 207 |
+
{
|
| 208 |
+
"finance",
|
| 209 |
+
new TemplateDef
|
| 210 |
+
{
|
| 211 |
+
Key = "finance",
|
| 212 |
+
Title = "Фінансова Свобода",
|
| 213 |
+
Description = "Покроковий план досягнення фінансової незалежності: облік витрат, подушка безпеки та інвестиції.",
|
| 214 |
+
Icon = "DollarSign",
|
| 215 |
+
Category = "Finance",
|
| 216 |
+
Nodes = new List<TemplateNodeDef>
|
| 217 |
+
{
|
| 218 |
+
new() { TempId = "audit", Label = "Аудит активів та боргових зобов'язань", PosX = 250, PosY = 50, Color = "yellow", Description = "Запишіть усі свої збереження, майно та кредити." },
|
| 219 |
+
new() { TempId = "track", Label = "Щоденний облік усіх витрат", PosX = 100, PosY = 170, Type = "habit", Color = "blue", Description = "Записуйте кожну покупку в мобільний додаток або Excel таблицю.", DecisionJson = "{\"resetRule\":{\"type\":\"daily\",\"time\":\"00:00\"},\"createdAt\":\"" + DateTime.UtcNow.ToString("o") + "\",\"description\":\"Записуйте кожну покупку в мобільний додаток або Excel таблицю.\",\"tags\":[],\"status\":\"Todo\",\"progress\":0}" },
|
| 220 |
+
new() { TempId = "emergency", Label = "Сформувати подушку на 3 місяці", PosX = 300, PosY = 170, Color = "orange", Description = "Розрахуйте мінімальний бюджет життя та накопичте цю суму на депозиті." },
|
| 221 |
+
new() { TempId = "debt", Label = "Виплатити всі споживчі кредити", PosX = 250, PosY = 290, Color = "pink", Description = "Спрямуйте вільні кошти на швидке закриття боргів з найвищими відсотками." },
|
| 222 |
+
new() { TempId = "invest", Label = "Інвестувати 20% від доходу", PosX = 100, PosY = 420, Type = "habit", Color = "green", Description = "Регулярно купуйте надійні індекси (ETF) або облігації.", DecisionJson = "{\"resetRule\":{\"type\":\"monthly\",\"time\":\"00:00\"},\"createdAt\":\"" + DateTime.UtcNow.ToString("o") + "\",\"description\":\"Регулярно купуйте надійні індекси (ETF) або облігації.\",\"tags\":[],\"status\":\"Todo\",\"progress\":0}" },
|
| 223 |
+
new() { TempId = "passive", Label = "Створити джерело пасивного доходу", PosX = 400, PosY = 420, Color = "purple", Description = "Створіть власний блог, курс, невеликий онлайн-сервіс чи придбайте дивідендні акції." },
|
| 224 |
+
new() { TempId = "freedom", Label = "Досягти фінансової незалежності", PosX = 250, PosY = 550, Color = "green", Description = "Коли пасивний дохід повністю перекриє ваші щомісячні витрати." }
|
| 225 |
+
},
|
| 226 |
+
Edges = new List<TemplateEdgeDef>
|
| 227 |
+
{
|
| 228 |
+
new() { FromTempId = "audit", ToTempId = "track" },
|
| 229 |
+
new() { FromTempId = "audit", ToTempId = "emergency" },
|
| 230 |
+
new() { FromTempId = "track", ToTempId = "debt" },
|
| 231 |
+
new() { FromTempId = "emergency", ToTempId = "debt" },
|
| 232 |
+
new() { FromTempId = "debt", ToTempId = "invest" },
|
| 233 |
+
new() { FromTempId = "debt", ToTempId = "passive" },
|
| 234 |
+
new() { FromTempId = "invest", ToTempId = "freedom" },
|
| 235 |
+
new() { FromTempId = "passive", ToTempId = "freedom" }
|
| 236 |
+
}
|
| 237 |
+
}
|
| 238 |
+
},
|
| 239 |
+
{
|
| 240 |
+
"writing",
|
| 241 |
+
new TemplateDef
|
| 242 |
+
{
|
| 243 |
+
Key = "writing",
|
| 244 |
+
Title = "Написання та Публікація Книги",
|
| 245 |
+
Description = "Шлях автора: від розробки сюжету та персо��ажів до щоденного написання, редактури та релізу.",
|
| 246 |
+
Icon = "BookOpen",
|
| 247 |
+
Category = "Creative",
|
| 248 |
+
Nodes = new List<TemplateNodeDef>
|
| 249 |
+
{
|
| 250 |
+
new() { TempId = "outline", Label = "Побудова сюжету та анкет персонажів", PosX = 250, PosY = 50, Color = "pink", Description = "Напишіть синопсис та детально розпишіть структуру розділів книги." },
|
| 251 |
+
new() { TempId = "words", Label = "Писати по 1000 слів щодня", PosX = 100, PosY = 170, Type = "habit", Color = "purple", Description = "Формуйте звичку писати без критики та внутрішнього редактора.", DecisionJson = "{\"resetRule\":{\"type\":\"daily\",\"time\":\"00:00\"},\"createdAt\":\"" + DateTime.UtcNow.ToString("o") + "\",\"description\":\"Формуйте звичку писати без критики та внутрішнього редактора.\",\"tags\":[],\"status\":\"Todo\",\"progress\":0}" },
|
| 252 |
+
new() { TempId = "draft", Label = "Завершити першу чернетку", PosX = 350, PosY = 170, Color = "yellow", Description = "Напишіть повну історію від початку до кінця (орієнтовно 50-80 тис. слів)." },
|
| 253 |
+
new() { TempId = "edit", Label = "Самостійна редактура та вичитка", PosX = 250, PosY = 300, Color = "orange", Description = "Виправте логічні помилки, покращіть діалоги та стиль оповідання." },
|
| 254 |
+
new() { TempId = "beta", Label = "Отримати фідбек від бета-рідерів", PosX = 250, PosY = 420, Color = "blue", Description = "Дайте почитати книгу кільком людям із вашої цільової аудиторії." },
|
| 255 |
+
new() { TempId = "professional", Label = "Професійна коректура та верстка", PosX = 250, PosY = 540, Color = "pink", Description = "Знайдіть професійного редактора для виправлення граматики та підготовки макету." },
|
| 256 |
+
new() { TempId = "cover", Label = "Створення обкладинки та форматування", PosX = 100, PosY = 660, Color = "purple", Description = "Замовте обкладинку в дизайнера та підготуйте формати ePub, PDF." },
|
| 257 |
+
new() { TempId = "publish", Label = "Публікація та запуск маркетингу", PosX = 350, PosY = 660, Color = "green", Description = "Опублікуйте книгу на Amazon / Litres та запустіть промо-акції." }
|
| 258 |
+
},
|
| 259 |
+
Edges = new List<TemplateEdgeDef>
|
| 260 |
+
{
|
| 261 |
+
new() { FromTempId = "outline", ToTempId = "words" },
|
| 262 |
+
new() { FromTempId = "words", ToTempId = "draft" },
|
| 263 |
+
new() { FromTempId = "draft", ToTempId = "edit" },
|
| 264 |
+
new() { FromTempId = "edit", ToTempId = "beta" },
|
| 265 |
+
new() { FromTempId = "beta", ToTempId = "professional" },
|
| 266 |
+
new() { FromTempId = "professional", ToTempId = "cover" },
|
| 267 |
+
new() { FromTempId = "professional", ToTempId = "publish" }
|
| 268 |
+
}
|
| 269 |
+
}
|
| 270 |
+
}
|
| 271 |
+
};
|
| 272 |
+
|
| 273 |
+
public static IEnumerable<TemplateInfoDto> GetTemplateInfos()
|
| 274 |
+
{
|
| 275 |
+
var list = new List<TemplateInfoDto>();
|
| 276 |
+
foreach (var kv in Templates)
|
| 277 |
+
{
|
| 278 |
+
list.Add(new TemplateInfoDto
|
| 279 |
+
{
|
| 280 |
+
Key = kv.Value.Key,
|
| 281 |
+
Title = kv.Value.Title,
|
| 282 |
+
Description = kv.Value.Description,
|
| 283 |
+
Icon = kv.Value.Icon,
|
| 284 |
+
Category = kv.Value.Category
|
| 285 |
+
});
|
| 286 |
+
}
|
| 287 |
+
return list;
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
public static (List<TaskNode> Nodes, List<Edge> Edges) GetTemplateContent(string key, Guid graphId)
|
| 291 |
+
{
|
| 292 |
+
if (!Templates.TryGetValue(key.ToLower().Trim(), out var template))
|
| 293 |
+
{
|
| 294 |
+
return (new List<TaskNode>(), new List<Edge>());
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
var nodes = new List<TaskNode>();
|
| 298 |
+
var edges = new List<Edge>();
|
| 299 |
+
var idMapping = new Dictionary<string, Guid>();
|
| 300 |
+
|
| 301 |
+
// 1. Instantiate nodes and map their IDs
|
| 302 |
+
foreach (var nodeDef in template.Nodes)
|
| 303 |
+
{
|
| 304 |
+
var newId = Guid.NewGuid();
|
| 305 |
+
idMapping[nodeDef.TempId] = newId;
|
| 306 |
+
|
| 307 |
+
var taskNode = new TaskNode
|
| 308 |
+
{
|
| 309 |
+
Id = newId,
|
| 310 |
+
GraphId = graphId,
|
| 311 |
+
Label = nodeDef.Label,
|
| 312 |
+
PosX = nodeDef.PosX,
|
| 313 |
+
PosY = nodeDef.PosY,
|
| 314 |
+
Type = nodeDef.Type,
|
| 315 |
+
State = NodeState.Pending,
|
| 316 |
+
CreatedAt = DateTime.UtcNow,
|
| 317 |
+
Description = nodeDef.Description,
|
| 318 |
+
Color = nodeDef.Color,
|
| 319 |
+
IsPinned = false,
|
| 320 |
+
Decision = string.IsNullOrEmpty(nodeDef.DecisionJson) ? null : nodeDef.DecisionJson
|
| 321 |
+
};
|
| 322 |
+
|
| 323 |
+
// For normal sketch nodes without custom Decision JSON, populate standard default JSON
|
| 324 |
+
if (nodeDef.Type == "sketch" && string.IsNullOrEmpty(nodeDef.DecisionJson))
|
| 325 |
+
{
|
| 326 |
+
taskNode.Decision = $"{{\"description\":\"{nodeDef.Description}\",\"progress\":0,\"showProgress\":false,\"decision\":\"bottom\",\"assignees\":[],\"color\":\"{nodeDef.Color}\",\"isPinned\":false,\"tags\":[],\"status\":\"Todo\"}}";
|
| 327 |
+
}
|
| 328 |
+
|
| 329 |
+
nodes.Add(taskNode);
|
| 330 |
+
}
|
| 331 |
+
|
| 332 |
+
// 2. Instantiate edges
|
| 333 |
+
foreach (var edgeDef in template.Edges)
|
| 334 |
+
{
|
| 335 |
+
if (idMapping.TryGetValue(edgeDef.FromTempId, out var fromId) &&
|
| 336 |
+
idMapping.TryGetValue(edgeDef.ToTempId, out var toId))
|
| 337 |
+
{
|
| 338 |
+
var edge = new Edge
|
| 339 |
+
{
|
| 340 |
+
Id = Guid.NewGuid(),
|
| 341 |
+
GraphId = graphId,
|
| 342 |
+
FromNodeId = fromId,
|
| 343 |
+
ToNodeId = toId,
|
| 344 |
+
Condition = edgeDef.Condition
|
| 345 |
+
};
|
| 346 |
+
edges.Add(edge);
|
| 347 |
+
}
|
| 348 |
+
}
|
| 349 |
+
|
| 350 |
+
return (nodes, edges);
|
| 351 |
+
}
|
| 352 |
+
}
|
| 353 |
+
}
|
FlowAPI/Controllers/GraphsController.cs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
using FlowAPI.Application.DTOs.Graph;
|
| 2 |
using FlowAPI.Application.Interfaces;
|
|
|
|
| 3 |
using Microsoft.AspNetCore.Authorization;
|
| 4 |
using Microsoft.AspNetCore.Mvc;
|
| 5 |
using System;
|
|
@@ -30,6 +31,13 @@ namespace FlowAPI.Controllers
|
|
| 30 |
}
|
| 31 |
}
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
[HttpGet("user/{userId:guid}")]
|
| 34 |
public async Task<ActionResult<IEnumerable<GraphResponseDto>>> GetAllByUserId(Guid userId)
|
| 35 |
{
|
|
|
|
| 1 |
using FlowAPI.Application.DTOs.Graph;
|
| 2 |
using FlowAPI.Application.Interfaces;
|
| 3 |
+
using FlowAPI.Application.Services;
|
| 4 |
using Microsoft.AspNetCore.Authorization;
|
| 5 |
using Microsoft.AspNetCore.Mvc;
|
| 6 |
using System;
|
|
|
|
| 31 |
}
|
| 32 |
}
|
| 33 |
|
| 34 |
+
[HttpGet("templates")]
|
| 35 |
+
public ActionResult<IEnumerable<TemplateInfoDto>> GetTemplates()
|
| 36 |
+
{
|
| 37 |
+
var templates = TemplateLibrary.GetTemplateInfos();
|
| 38 |
+
return Ok(templates);
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
[HttpGet("user/{userId:guid}")]
|
| 42 |
public async Task<ActionResult<IEnumerable<GraphResponseDto>>> GetAllByUserId(Guid userId)
|
| 43 |
{
|