From f39faf61a284d0fada96f4b67671d238272a33d5 Mon Sep 17 00:00:00 2001 From: Ricardo Gonzalez Date: Wed, 27 May 2026 20:34:57 -0500 Subject: [PATCH] forzar conversion de tipos KAPPA a string antes de guardar en Turso --- src/stores/workitems.ts | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/stores/workitems.ts b/src/stores/workitems.ts index edca0bf..df71cc0 100644 --- a/src/stores/workitems.ts +++ b/src/stores/workitems.ts @@ -124,20 +124,25 @@ export const useWorkItemsStore = defineStore('workitems', () => { } } + function safeStr(v: unknown): string | null { + if (v === null || v === undefined) return null + return String(v) + } + async function syncHUsToTurso(projectId: number, hus: KappaUserStory[]) { console.log(`[Alpha] Syncing ${hus.length} HUs to Turso for project ${projectId}`) for (const hu of hus) { try { await tauriDb.saveUserStory({ - id: hu.id ?? 0, + id: Number(hu.id) || 0, initiative_id: projectId, epic_id: null, - code: hu.code ?? null, - title: hu.title, - description: stripHtml(hu.description || ''), - acceptance_criteria: hu.acceptance_criteria ?? null, - status: hu.status ?? null, - priority: hu.priority ?? null, + code: safeStr(hu.code), + title: String(hu.title || ''), + description: stripHtml(String(hu.description || '')), + acceptance_criteria: safeStr(hu.acceptance_criteria), + status: safeStr(hu.status), + priority: safeStr(hu.priority), story_points: null, estimated_hours: null, actual_hours: null, @@ -155,12 +160,12 @@ export const useWorkItemsStore = defineStore('workitems', () => { for (const epic of epicsData) { try { await tauriDb.saveEpic({ - id: epic.id, + id: Number(epic.id) || 0, initiative_id: projectId, - code: epic.code ?? null, - name: epic.name || epic.title || `Épica ${epic.id}`, - description: epic.description ?? null, - status: epic.status ?? null, + code: safeStr(epic.code), + name: String(epic.name || epic.title || `Épica ${epic.id}`), + description: safeStr(epic.description), + status: safeStr(epic.status), client_taker: null, stimated_start_date: null, stimated_end_date: null,