mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
Taskwarrior's task export / task import JSON is the task format of the Taskwarrior command line tool, and WeKan read and wrote neither. It now imports from the import picker, as a JSON array or one task per line as versions before 2.4 write it, and exports from the board's export menu. A completed task goes to Done, a waiting one to Waiting and a started one to In Progress; project and priority become labels, tags become labels, entry, due, scheduled and end become dates, annotations become comments and depends becomes blocked-by dependencies resolved by uuid. WeKan's wekanlist and wekandescription attributes, which Taskwarrior keeps as orphaned UDAs, carry list names and descriptions across a round trip. Deleted tasks, recurring templates, bad dates and unmapped attributes are reported in the loss report instead of guessed. tests/taskwarrior.test.cjs covers the mapping, both input shapes, the round trip and the negatives; the format guards learn the new format and a Playwright case imports a Taskwarrior export through the page. The new instruction text is in English, pending translation. Thanks to xet7 !
24 lines
1.6 KiB
JavaScript
24 lines
1.6 KiB
JavaScript
// Shape validation before creating a board. Unknown/empty objects must not
|
|
// report a successful import which silently contains no source records.
|
|
export function validateImportSourceShape(source, value) {
|
|
const arrayAt = (object, key) => object && Array.isArray(object[key]);
|
|
let valid = false;
|
|
switch (source) {
|
|
case 'wekan': case 'trello': valid = arrayAt(value, 'cards') && arrayAt(value, 'lists'); break;
|
|
case 'kanboard': valid = arrayAt(value, 'tasks'); break;
|
|
case 'jira': valid = arrayAt(value, 'issues'); break;
|
|
case 'github': case 'gitlab': case 'gitea': case 'forgejo':
|
|
valid = Array.isArray(value) || arrayAt(value, 'issues'); break;
|
|
case 'deck': valid = arrayAt(value, 'stacks') || arrayAt(value?.board, 'stacks'); break;
|
|
case 'openproject': valid = Array.isArray(value) || arrayAt(value, 'elements') || arrayAt(value?._embedded, 'elements'); break;
|
|
case 'asana': valid = Array.isArray(value) || arrayAt(value, 'data'); break;
|
|
case 'zenkit': valid = Array.isArray(value) || arrayAt(value, 'items')
|
|
|| (arrayAt(value, 'elements') && (arrayAt(value, 'entries') || arrayAt(value, 'listEntries'))); break;
|
|
case 'csv': valid = Array.isArray(value) && value.length > 0 && value.every(Array.isArray); break;
|
|
case 'excel': valid = typeof value?.excelBase64 === 'string' && value.excelBase64.length > 0; break;
|
|
case 'markdown': case 'todotxt': case 'taskwarrior': valid = typeof value === 'string' && value.trim().length > 0; break;
|
|
case 'leo': valid = typeof value === 'string' && /<leo_file[\s>]/.test(value); break;
|
|
}
|
|
if (!valid) throw new Error(`Invalid ${source} import document shape`);
|
|
}
|