mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
Import and Export have a new group, Website: - WordPress (.xml): WordPress eXtended RSS from Tools -> Export, as Squarespace, Wix and others also write it; written as WordPress reads it. - WordPress REST API (.json): /wp-json/wp/v2/posts and /pages. - Ghost: its JSON export, written as Ghost's importer reads it. - Blogger (.xml): its Atom backup. - Hugo, Jekyll, Eleventy, Astro (.zip): Markdown files with YAML or TOML front matter, and their images; written as content/pages and content/posts. - HTML website, Medium (.zip): a site's .html pages and images, read for their main text; written as the published site itself, ready for any web server, with the cards' attachments beside their pages. - Substack (.zip): posts.csv and the posts' HTML. Each page and post becomes a card in the list of its status (Published, Draft, Pending review, Scheduled, Private), pages in the swimlane Pages and posts in Posts, its content as Markdown, a subpage as a subtask, categories and tags as labels, approved comments as comments, a .zip's images as attachments. A site's HTML is read as text, so no script of it reaches a card; a card's text is written into an exported site escaped, never as markup. Board View / Website shows the board as that website: the cards of its Published list (every list when it has none), Pages as the menu with the subpages, the other cards as posts, newest first, and the cards' attachments - built straight from the board. As a public board's default view in Board Settings / Board View, it is what visitors see at the board's address instead of the kanban; a draft is never shown, not even by its id. Admin Panel / Features can turn it off. The Sandstorm WordPress and Hacker CMS grain imports stay under Sandstorm, by the rule that a platform's apps are listed under it. 12 new strings are translated in every language. Lower-confidence translations: ace, ak, ay, bi, bm, bo, dz, ee, chr, bua, cv, ba, csb, an, co, br, ary, bho, as, am, ckb, iu, kl, ff, fj, gn, gv, kw, ig, ha, haw, ks, kok, fur, hsb, fo, ku, lld, nah, rup, sah, se, sc, scn, nap, qu, sm, pap, lg, nd, ss, nso, rn, om, mg, ny, sn, so, ps, sd, mai, or_IN, my, la, tig, wal, tlh, vo, zgh and ve-PP. Thanks to xet7 !
103 lines
7.7 KiB
JavaScript
103 lines
7.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 'tasksorg': valid = arrayAt(value?.data, 'tasks'); break;
|
|
case 'csv': valid = Array.isArray(value) && value.length > 0 && value.every(Array.isArray); break;
|
|
case 'taiga': valid = arrayAt(value, 'user_stories'); break;
|
|
case 'kanri': valid = arrayAt(value, 'columns') || arrayAt(value, 'boards'); break;
|
|
// What server/apiImport.js fetches (models/lib/apiImport/<key>.js).
|
|
case 'planka': valid = Boolean(value?.planka?.item) && typeof value.planka.included === 'object'; break;
|
|
case 'mstodo': case 'googletasks': valid = arrayAt(value, 'lists'); break;
|
|
case 'kanbanflow': valid = Boolean(value?.board) && arrayAt(value, 'tasks'); break;
|
|
case 'basecamp': valid = Boolean(value?.project) && (arrayAt(value, 'cardTables') || arrayAt(value, 'todolists')); break;
|
|
case 'googlekeep': valid = arrayAt(value, 'notes'); break;
|
|
// Vikunja: the export .zip as { zipBase64 }, or the text of its data.json.
|
|
// Notion: the Markdown & CSV export .zip as { zipBase64 }, or one database CSV.
|
|
case 'notion':
|
|
case 'vikunja': valid = (typeof value?.zipBase64 === 'string' && value.zipBase64.length > 0)
|
|
|| typeof value?.zipFile === 'string'
|
|
|| (typeof value === 'string' && value.trim().length > 0); break;
|
|
// Plane: the export .zip as { zipBase64 }, a workbook as { xlsxBase64 },
|
|
// or the text of a JSON or CSV export file.
|
|
case 'plane': valid = (typeof value?.zipBase64 === 'string' && value.zipBase64.length > 0)
|
|
|| typeof value?.zipFile === 'string'
|
|
|| (typeof value?.xlsxBase64 === 'string' && value.xlsxBase64.length > 0)
|
|
|| (typeof value === 'string' && value.trim().length > 0); break;
|
|
case 'excel': case 'planner': case 'monday': case 'wrike': case 'teamwork': case 'businessmap': valid = typeof value?.excelBase64 === 'string' && value.excelBase64.length > 0; break;
|
|
case 'markdown': case 'todotxt': case 'taskwarrior': case 'focalboard': case 'todoist': case 'meistertask': case 'obsidian': case 'linear': case 'ticktick': case 'clickup': case 'nullboard': case 'pivotal': case 'redmine': case 'superproductivity': case 'quire': case 'orgmode': valid = typeof value === 'string' && value.trim().length > 0; break;
|
|
case 'leo': valid = typeof value === 'string' && /<leo_file[\s>]/.test(value); break;
|
|
// Mail, calendar, chat and note exports (models/lib/mailFormat.js,
|
|
// icalendarFormat.js, chatExportFormats.js, enexFormat.js,
|
|
// googleTakeoutFormat.js).
|
|
case 'mail': valid = (typeof value === 'string' && value.trim().length > 0) || typeof value?.mboxFile === 'string'; break;
|
|
case 'whatsapp': valid = typeof value === 'string' && value.trim().length > 0; break;
|
|
case 'ical': valid = typeof value === 'string' && /BEGIN:VCALENDAR/i.test(value); break;
|
|
case 'mattermost': valid = (typeof value === 'string' && /"type"\s*:\s*"version"/.test(value))
|
|
|| (Array.isArray(value?.jsonLines) && value.jsonLines.some(line => line && line.type === 'version')); break;
|
|
// Rocket.Chat and Fizzy: an export .zip, or the text of one room's or
|
|
// card's .json.
|
|
case 'fizzy':
|
|
case 'rocketchat': valid = (typeof value?.zipBase64 === 'string' && value.zipBase64.length > 0)
|
|
|| typeof value?.zipFile === 'string'
|
|
|| (typeof value === 'string' && value.trim().length > 0); break;
|
|
// Azure DevOps and Microsoft Lists CSV, Microsoft Project XML: text.
|
|
case 'azuredevops':
|
|
case 'mslists': valid = typeof value === 'string' && value.trim().length > 0; break;
|
|
case 'msproject': valid = typeof value === 'string' && /<Project[\s>]/.test(value); break;
|
|
// Outlook: a .msg as bytes, or a .zip of .msg and .eml files.
|
|
case 'outlook': valid = (typeof value?.binaryBase64 === 'string' && value.binaryBase64.length > 0)
|
|
|| typeof value?.binaryFile === 'string'
|
|
|| (typeof value?.zipBase64 === 'string' && value.zipBase64.length > 0)
|
|
|| typeof value?.zipFile === 'string'; break;
|
|
// Teams and OneNote: JSON (fetched, or a file), a .zip, or Teams' .tar.
|
|
case 'teams': valid = (value && typeof value === 'object' && (value.teams === true || Array.isArray(value.value)
|
|
|| Array.isArray(value.conversations) || typeof value.binaryBase64 === 'string' || typeof value.binaryFile === 'string'
|
|
|| typeof value.zipBase64 === 'string' || typeof value.zipFile === 'string')) || Array.isArray(value)
|
|
|| (typeof value === 'string' && value.trim().length > 0); break;
|
|
case 'onenote': valid = (value && typeof value === 'object' && (value.onenote === true
|
|
|| typeof value.zipBase64 === 'string' || typeof value.zipFile === 'string'))
|
|
|| (typeof value === 'string' && value.trim().length > 0); break;
|
|
// A Sandstorm grain backup: a .zip, read on the server.
|
|
case 'sandstormwekan':
|
|
case 'sandstormprioritize':
|
|
case 'sandstormyatl':
|
|
case 'sandstormmutodo':
|
|
case 'sandstormsandchat':
|
|
case 'sandstormethercalc':
|
|
case 'sandstormradicalecalendar':
|
|
case 'sandstormradicalecontacts':
|
|
case 'sandstormdavros':
|
|
case 'sandstormhackercms':
|
|
case 'sandstormgogs':
|
|
case 'sandstormwordpress': valid = (typeof value?.zipBase64 === 'string' && value.zipBase64.length > 0) || typeof value?.zipFile === 'string'; break;
|
|
case 'evernote': valid = typeof value === 'string' && /<en-export[\s>]/.test(value); break;
|
|
case 'telegram': valid = arrayAt(value, 'messages') || arrayAt(value?.chats, 'list'); break;
|
|
case 'discord': valid = (Array.isArray(value) ? value : [value]).every(e => e && e.channel && Array.isArray(e.messages)); break;
|
|
// A .zip sent in the call, or one streamed to the local disk (zipFile).
|
|
case 'slack': case 'googletakeout': valid = (typeof value?.zipBase64 === 'string' && value.zipBase64.length > 0)
|
|
|| typeof value?.zipFile === 'string'; break;
|
|
case 'opml': valid = typeof value === 'string' && /<opml[\s>]/.test(value); break;
|
|
// Websites (server/lib/websiteImport.js reads them, and says what is wrong).
|
|
case 'wordpress': valid = typeof value === 'string' && /<rss[\s>]/.test(value); break;
|
|
case 'blogger': valid = typeof value === 'string' && /<feed[\s>]/.test(value); break;
|
|
case 'wordpressjson': valid = Array.isArray(value) || arrayAt(value, 'posts') || arrayAt(value, 'pages'); break;
|
|
case 'ghost': valid = arrayAt(value, 'db') || arrayAt(value?.data, 'posts') || arrayAt(value, 'posts'); break;
|
|
case 'markdownsite': case 'htmlsite': case 'substack': valid = (typeof value?.zipBase64 === 'string' && value.zipBase64.length > 0)
|
|
|| typeof value?.zipFile === 'string'; break;
|
|
}
|
|
if (!valid) throw new Error(`Invalid ${source} import document shape`);
|
|
}
|