mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 04:49:41 -05:00
A Focalboard board.jsonl, from a .boardarchive zip, imports with or without its version line: Focalboard's own importer reads the same text. The board view's group-by select property becomes the lists. Other select and multi-select properties become labels, and a property called Labels gives labels by their own name. The first date property becomes the due date, or start and due for a range. Text, number, email, url, phone, checkbox and later dates become custom fields. Text and heading blocks become the description, checkbox blocks a checklist, and comment blocks comments. Members, person properties, images, attachments and card templates are reported in the loss report. Export writes the same text: a Status property for the lists, Labels, Due and the custom fields. The field names follow Focalboard's model.Board and model.Block. tests/focalboard.test.cjs covers both board forms, the round trip and the negatives. A Playwright case imports a board.jsonl through the page, and the export audit fetches the new format. New instruction text is in English, pending Transifex. Thanks to xet7 !
24 lines
1.7 KiB
JavaScript
24 lines
1.7 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': case 'focalboard': 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`);
|
|
}
|