Files
wekan/models/lib/externalExportFormatters.js
T
Lauri Ojansivu 2e8549032e Website: import and export WordPress, Ghost, Blogger, static and HTML sites, and the board as a website at a public board's address.
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 !
2026-11-21 23:44:34 +02:00

628 lines
36 KiB
JavaScript

// Export to other tools: one formatter per format, each emitting the shape that
// WeKan's own importer for that tool reads (externalParsers.js, jiraCreator.js,
// jiraIssueExtras.js), so a board round-trips. Pure - the collection from the
// database is externalExporters.js - so tests/externalExportRoundTrip.test.cjs
// runs every export back through its parser in plain Node.
//
// Each exported item is what collect() gathered for one card, already gated by
// the export selection (#1173): title, description, listTitle, swimlaneTitle,
// labels, dueAt, and - when selected and the format has a place for them -
// startAt, endAt, createdAt, owner, assignees, creator, requestedBy, comments,
// checklists, parentCardId and customFields. A format drops what it has no
// field for; that is the honest answer, not a loss this module invents.
import { pagingOf, blockersOf } from './exportPaging.js';
import { kanboardRecurrenceOf, KANBOARD_ESTIMATE_FIELD, kanboardColorId } from './kanboardFields.js';
import { formatMarkdownKanban } from './markdownKanbanFormat.js';
import { formatLeo } from './leoOutlineFormat.js';
import { formatTodoTxt } from './todoTxtFormat.js';
import { formatTaskwarrior } from './taskwarriorFormat.js';
import { formatFocalboard } from './focalboardFormat.js';
import { formatTodoistCsv } from './todoistCsvFormat.js';
import { formatPlannerRows } from './plannerFormat.js';
import { formatMeisterTaskCsv } from './meistertaskCsvFormat.js';
import { formatObsidianKanban } from './obsidianKanbanFormat.js';
import { formatLinearCsv } from './linearCsvFormat.js';
import { formatTickTickCsv } from './ticktickCsvFormat.js';
import { formatClickUpCsv } from './clickupCsvFormat.js';
import { formatNullboard } from './nullboardFormat.js';
import { formatKanri } from './kanriFormat.js';
import { formatPivotalCsv } from './pivotalCsvFormat.js';
import { formatRedmineCsv } from './redmineCsvFormat.js';
import { formatTasksOrgBackup } from './tasksorgFormat.js';
import { formatMondaySheets } from './mondayFormat.js';
import { formatBusinessmapSheets } from './businessmapFormat.js';
import { formatSuperProductivity } from './superProductivityFormat.js';
import { formatTaiga } from './taigaFormat.js';
import { formatVikunja } from './vikunjaFormat.js';
import { formatFizzy } from './fizzyFormat.js';
import { formatAzureDevOpsCsv } from './azureDevOpsCsvFormat.js';
import { formatMsListsCsv } from './msListsCsvFormat.js';
import { formatMsProjectXml } from './msProjectXmlFormat.js';
import { formatOutlookEml } from './outlookMsgFormat.js';
import { formatOnenote } from './onenoteApiFormat.js';
import { SANDSTORM_APPS, formatSandstormGrain } from './sandstorm/grainApps.js';
import { formatWrikeRows } from './wrikeFormat.js';
import { formatWrikeWorkflow } from './wrikeWorkflow.js';
import { formatTeamworkSheet } from './teamworkFormat.js';
import { formatQuireCsv } from './quireCsvFormat.js';
import { formatNotionCsv } from './notionFormat.js';
import { formatOpml } from './opmlOutlineFormat.js';
import { formatMbox } from './mailFormat.js';
import { formatEnex } from './enexFormat.js';
import { formatWxr, formatWordPressJson, formatGhost, formatBlogger, markdownSiteFiles, htmlSiteFiles } from './websiteFormat.js';
import { formatMattermostBulk, formatRocketChat, formatTeams } from './chatExportFormats.js';
import { formatOrgMode } from './orgModeFormat.js';
// A WeKan list maps to a "closed" issue state when its name looks terminal.
function isClosed(listTitle) {
return /done|closed|complete|archiv|finished/i.test(listTitle || '');
}
const has = value => value !== undefined && value !== null && value !== '';
const list = value => (Array.isArray(value) ? value : []);
const checklistItems = item => list(item.checklists).flatMap(c => list(c.items));
// The comments go along as comments_data, the embedded comments the issues
// parser reads (models/lib/externalParsers.js issueComments) - the shape
// `gh issue view --json comments` and similar clients write.
const githubLike = ({ items }) =>
items.map(i => ({
title: i.title,
body: i.description,
state: isClosed(i.listTitle) ? 'closed' : 'open',
labels: i.labels.map(name => ({ name })),
due_date: i.dueAt,
// What parseGithub / parseGitea read back: who it is for and who asked,
// when it was made and closed, and Gitea's time estimate in seconds.
...(has(i.owner) ? { assignee: { login: i.owner }, assignees: [i.owner, ...list(i.assignees)].filter(has).map(login => ({ login })) } : {}),
...(has(i.creator) ? { user: { login: i.creator } } : {}),
...(has(i.createdAt) ? { created_at: i.createdAt } : {}),
...(isClosed(i.listTitle) && has(i.endAt) ? { closed_at: i.endAt } : {}),
...(Number((i.customFields || {})['Time estimate (hours)']) > 0 ? { time_estimate: Math.round(Number(i.customFields['Time estimate (hours)']) * 3600) } : {}),
...(list(i.comments).some(c => c && has(c.text)) ? { comments_data: list(i.comments).filter(c => c && has(c.text)).map(c => ({
body: String(c.text), ...(has(c.author) ? { user: { login: c.author } } : {}), ...(has(c.date) ? { created_at: c.date } : {}) })) } : {}),
}));
// OpenProject reads ids from HAL hrefs ending in a number.
const numericIds = items => new Map(items.map((item, index) => [item.cardId, index + 1]));
// Sprints and releases, for the formats with a place for them (GitLab
// iterations and milestones, OpenProject sprints and versions), numbered as
// those APIs number theirs. What the importer reads back is
// models/lib/externalScrumPlanning.js. A cancelled sprint or release has no
// equivalent in either and is left out, with its cards unassigned.
const day = value => (value ? new Date(value).toISOString().slice(0, 10) : undefined);
function planningIndex({ scrumSprints, scrumReleases }) {
const numbered = rows => new Map(list(rows).filter(row => row && row.state !== 'cancelled')
.map((row, index) => [row._id, { ...row, number: index + 1 }]));
return { sprints: numbered(scrumSprints), releases: numbered(scrumReleases) };
}
const GITLAB_ITERATION_STATE = { planned: 1, active: 2, closed: 3 };
const OPENPROJECT_SPRINT_STATUS = { planned: 'in_planning', active: 'active', closed: 'completed' };
const OPENPROJECT_SPRINT_TITLE = { planned: 'In planning', active: 'Active', closed: 'Completed' };
const sprintOf = (planning, item) => (item.scrum && planning.sprints.get(item.scrum.sprintId)) || null;
const releaseOf = (planning, item) => (item.scrum && planning.releases.get(item.scrum.firstReleaseId)) || null;
// Backlog rank as OpenProject's integer position: 1..n in rank order.
function positions(items) {
const ranked = items.filter(i => i.scrum && typeof i.scrum.backlogRank === 'number')
.sort((a, b) => a.scrum.backlogRank - b.scrum.backlogRank);
return new Map(ranked.map((item, index) => [item.cardId, index + 1]));
}
// Kanboard task links, as getAllTaskLinks returns them for each task: `task_id`
// is the OTHER task and `label` the link type read from this task. Kanboard
// keeps every link from both ends, so each parent card and each dependency is
// written twice, the second time with the opposite label; the importer
// (parseKanboard) folds the two back into one. A link to a card that is not in
// the export has no task to point at and is left out.
const KANBOARD_LINK_LABEL = {
'related-to': 'relates to', blocks: 'blocks', 'is-blocked-by': 'is blocked by',
duplicates: 'duplicates', 'is-duplicated-by': 'is duplicated by',
fixes: 'fixes', 'is-fixed-by': 'is fixed by',
};
const KANBOARD_OPPOSITE_LABEL = {
'relates to': 'relates to', blocks: 'is blocked by', 'is blocked by': 'blocks',
duplicates: 'is duplicated by', 'is duplicated by': 'duplicates',
fixes: 'is fixed by', 'is fixed by': 'fixes',
'is a child of': 'is a parent of', 'is a parent of': 'is a child of',
};
function kanboardTaskLinks(items) {
const number = new Map(items.map((item, index) => [item.cardId, index + 1]));
const links = items.map(() => []);
const written = new Set();
let id = 0;
const add = (from, to, label) => {
const key = `${from}>${to}:${label}`;
if (from === to || written.has(key)) return;
written.add(key);
written.add(`${to}>${from}:${KANBOARD_OPPOSITE_LABEL[label]}`);
links[from - 1].push({ id: id += 1, task_id: to, label });
links[to - 1].push({ id: id += 1, task_id: from, label: KANBOARD_OPPOSITE_LABEL[label] });
};
items.forEach((item, index) => {
const self = index + 1;
const parent = number.get(item.parentCardId);
if (parent) add(self, parent, 'is a child of');
list(item.dependencies).forEach(dep => {
const other = dep && number.get(dep.cardId);
if (other) add(self, other, KANBOARD_LINK_LABEL[dep.type] || 'relates to');
});
});
return links;
}
// An attachment's file name in a Trello .zip, the same in board.json and in
// the archive: no path separators, never empty.
export const trelloZipFileName = att => String((att && att.name) || (att && att.id) || 'file').replace(/[\\/\0]/g, '_').slice(0, 200) || 'file';
function trelloDocument(collected, { withAttachments = false } = {}) {
const { board, lists } = collected;
const { items, all, offset } = pagingOf(collected);
// The board's people - card owners, assignees, comment authors - over the
// whole board, as Trello members named by username; the import maps them
// to users by username (client/components/import/trelloMembersMapper.js).
const peopleOf = i => [i.owner, ...list(i.assignees)].filter(has).map(String);
const people = [...new Set(all.flatMap(i => [...peopleOf(i),
...list(i.comments).map(c => c && c.author).filter(has).map(String)]))];
// Custom fields: one Trello field per name the board's cards use, its type
// what every value of it is (checkbox, number, date, else text), and each
// card's values as Trello's customFieldItems (models/trelloCreator.js).
const fieldNames = [...new Set(all.flatMap(i => Object.keys(i.customFields || {})))];
const ISO_DAY = /^\d{4}-\d{2}-\d{2}(T|$)/;
const typeOf = name => {
const values = all.map(i => (i.customFields || {})[name]).filter(has);
if (values.length && values.every(v => typeof v === 'boolean')) return 'checkbox';
if (values.length && values.every(v => typeof v === 'number' && Number.isFinite(v))) return 'number';
if (values.length && values.every(v => typeof v === 'string' && ISO_DAY.test(v) && !Number.isNaN(Date.parse(v)))) return 'date';
return 'text';
};
const fields = fieldNames.map((name, n) => ({ id: `${board._id || 'board'}-field-${n + 1}`, name, type: typeOf(name) }));
const valueOf = (field, raw) => {
if (field.type === 'checkbox') return { checked: raw ? 'true' : 'false' };
if (field.type === 'number') return { number: String(raw) };
if (field.type === 'date') return { date: new Date(raw).toISOString() };
return { text: Array.isArray(raw) ? raw.join(', ') : String(raw) };
};
// What models/trelloCreator.js checks every card for: an ISO date of its
// last activity and a position - without them a Trello export did not
// import into WeKan at all.
const isoOf = value => {
const date = value ? new Date(value) : null;
return date && !Number.isNaN(date.getTime()) ? date.toISOString() : new Date(0).toISOString();
};
const checklistsOf = i => list(i.checklists).map((c, n) => ({
id: `${i.cardId}-checklist-${n + 1}`,
idBoard: String(board._id || ''),
idCard: String(i.cardId),
name: String(c.title || 'Checklist'),
pos: n + 1,
checkItems: list(c.items).map((x, m) => ({
id: `${i.cardId}-checklist-${n + 1}-item-${m + 1}`,
name: String(x.title || ''),
state: x.done ? 'complete' : 'incomplete',
pos: m + 1,
})),
}));
return {
name: board.title,
prefs: { background: 'blue', permissionLevel: 'private' },
members: people.map(username => ({ id: username, username, fullName: username })),
customFields: fields.map((field, n) => ({ id: field.id, idModel: String(board._id || ''), modelType: 'board',
name: field.name, type: field.type, pos: n + 1, display: { cardFront: true } })),
labels: (board.labels || []).map(l => ({ id: l._id, name: String(l.name || ''), color: l.color })),
// Archived lists and cards are Trello's closed ones (the Trello
// export collects them; models/trelloCreator.js reads closed back).
lists: lists.map((l, n) => ({ id: l._id, name: l.title, closed: Boolean(l.archived), pos: n + 1 })),
cards: items.map((i, n) => ({
id: i.cardId,
name: i.title,
desc: String(i.description || ''),
pos: offset + n + 1,
dateLastActivity: isoOf(i.modifiedAt || i.createdAt),
idList: i.listId,
due: i.dueAt || null,
...(has(i.startAt) ? { start: i.startAt } : {}),
dueComplete: Boolean(i.dueComplete),
closed: Boolean(i.archived),
idLabels: list(i.labelIds),
idMembers: [...new Set(peopleOf(i))],
idChecklists: checklistsOf(i).map(c => c.id),
// The Trello .zip: each attachment named as its file in the archive
// (attachments/<id>_<name>), which the Trello .zip import matches by
// fileName (server/routes/importTrelloZip.js).
...(withAttachments ? { attachments: list(i.attachments).map(att => ({ id: att.id, name: trelloZipFileName(att),
fileName: trelloZipFileName(att), bytes: att.size || 0, mimeType: att.type || '', isUpload: true })) } : {}),
customFieldItems: fields.filter(field => has((i.customFields || {})[field.name])).map(field => ({
id: `${i.cardId}-${field.id}`, idCustomField: field.id, idModel: i.cardId, modelType: 'card',
value: valueOf(field, i.customFields[field.name]) })),
})),
checklists: items.flatMap(checklistsOf),
actions: items.flatMap(i => list(i.comments).filter(c => c && has(c.text)).map((c, n) => ({
id: `${i.cardId}-comment-${n + 1}`,
type: 'commentCard',
date: isoOf(c.date || i.createdAt),
idMemberCreator: c.author || null,
memberCreator: c.author ? { username: c.author, fullName: c.author } : null,
data: { text: String(c.text), card: { id: i.cardId, name: i.title }, board: { id: String(board._id || '') } },
}))),
};
}
export const formatters = {
// NextCloud Deck: board with stacks, each stack carrying its cards.
// A card is in the stack of its own list (by id; by title when either has
// none), so two lists of one name do not each carry the other's cards.
deck: ({ board, lists, items }) => ({
title: board.title,
stacks: lists.map(l => ({
title: l.title,
cards: items
.filter(i => (l._id && i.listId ? i.listId === l._id : i.listTitle === l.title))
.map(i => ({
title: i.title,
description: i.description,
duedate: i.dueAt,
...(Object.keys(i.timetracking || {}).length ? { timetracking: i.timetracking } : {}),
labels: i.labels.map(name => ({ title: name })),
...(has(i.createdAt) ? { createdAt: i.createdAt } : {}),
// Deck's done: the end date, or done without one when the due
// date is ticked done (the import reads both).
...(has(i.endAt) ? { done: i.endAt } : i.dueComplete ? { done: true } : {}),
...(has(i.owner) || list(i.assignees).length
? { assignedUsers: [i.owner, ...list(i.assignees)].filter(has).map(uid => ({ participant: { uid } })) } : {}),
...(has(i.creator) ? { owner: { uid: i.creator } } : {}),
...(list(i.comments).length ? { comments: i.comments.map(c => ({
message: c.text, actorId: c.author, creationDateTime: c.date })) } : {}),
})),
})),
}),
// Kanboard: columns, swimlanes and tasks, the shape the Kanboard importer reads.
// Tasks are numbered 1..n; parent cards and dependencies become task links.
kanboard: ({ board, lists, swimlanes, items }) => {
const links = kanboardTaskLinks(items);
return {
board: { name: board.title },
columns: lists.map(l => ({ title: l.title })),
swimlanes: swimlanes.map(s => ({ name: s.title })),
tasks: items.map((i, index) => ({
id: index + 1,
title: i.title,
description: i.description,
column_name: i.listTitle,
swimlane_name: i.swimlaneTitle,
date_due: i.dueAt,
...(has(i.startAt) ? { date_started: i.startAt } : {}),
...(has(i.endAt) ? { date_completed: i.endAt } : {}),
...(has(i.createdAt) ? { date_creation: i.createdAt } : {}),
...(has(i.owner) ? { owner_username: i.owner } : {}),
...(has(i.creator) ? { creator_username: i.creator } : {}),
tags: i.labels,
...(checklistItems(i).length ? { subtasks: checklistItems(i).map(x => ({ title: x.title, status: x.done ? 2 : 0 })) } : {}),
...(list(i.comments).length ? { comments: i.comments.map(c => ({
comment: c.text, username: c.author, date_creation: c.date })) } : {}),
...(links[index].length ? { links: links[index] } : {}),
// What parseKanboard reads back: spent time, recurrence, and the
// estimate, score and reference custom fields.
...(Number(i.spentTime) > 0 ? { time_spent: Number(i.spentTime) } : {}),
...(kanboardColorId(i.color) ? { color_id: kanboardColorId(i.color) } : {}),
...(kanboardRecurrenceOf(i.recurrence) && !has(i.endAt) ? { recurrence_status: 1, recurrence_trigger: 0,
recurrence_factor: kanboardRecurrenceOf(i.recurrence)[0], recurrence_timeframe: kanboardRecurrenceOf(i.recurrence)[1] } : {}),
...(Number((i.customFields || {})[KANBOARD_ESTIMATE_FIELD]) > 0 ? { time_estimated: Number(i.customFields[KANBOARD_ESTIMATE_FIELD]) } : {}),
...(Number((i.customFields || {}).Score) > 0 ? { score: Number(i.customFields.Score) } : {}),
...(has((i.customFields || {}).Reference) ? { reference: String(i.customFields.Reference) } : {}),
})),
};
},
// OpenProject: a work-packages collection with HAL links.
// A page of the board, or all of it (models/lib/exportPaging.js): the
// numbers, ranks and custom field columns are counted over the whole board.
openproject: collected => {
const { items, all } = pagingOf(collected);
const ids = numericIds(all);
const blockers = blockersOf(all);
const planning = planningIndex(collected);
const ranks = positions(all);
const versions = [...planning.releases.values()].map(r => ({ _type: 'Version', id: r.number, name: r.name,
...(has(r.notes) ? { description: { raw: r.notes } } : {}),
...(r.plannedStart ? { startDate: day(r.plannedStart) } : {}), ...(r.plannedEnd ? { endDate: day(r.plannedEnd) } : {}),
status: r.state === 'released' ? 'closed' : 'open' }));
const sprints = [...planning.sprints.values()].map(sp => ({ _type: 'Sprint', id: sp.number, name: sp.name,
...(has(sp.goal) ? { description: { raw: sp.goal } } : {}),
...(sp.plannedStart ? { startDate: day(sp.plannedStart) } : {}), ...(sp.plannedEnd ? { finishDate: day(sp.plannedEnd) } : {}),
_links: { self: { href: `/api/v3/sprints/${sp.number}`, title: sp.name },
status: { href: `urn:openproject-org:api:v3:sprints:status:${OPENPROJECT_SPRINT_STATUS[sp.state] || 'in_planning'}`,
title: OPENPROJECT_SPRINT_TITLE[sp.state] || 'In planning' } } }));
const fieldNames = [...new Set(all.flatMap(i => Object.keys(i.customFields || {})))];
const fieldKey = name => `customField${fieldNames.indexOf(name) + 1}`;
return {
_embedded: {
...(fieldNames.length ? { schemas: [Object.fromEntries(fieldNames.map(name => [fieldKey(name), { name }]))] } : {}),
...(versions.length ? { versions } : {}),
...(sprints.length ? { sprints } : {}),
elements: items.map(i => ({
id: ids.get(i.cardId),
subject: i.title,
description: { raw: i.description },
dueDate: i.dueAt,
...(has(i.startAt) ? { startDate: i.startAt } : {}),
...(has(i.createdAt) ? { createdAt: i.createdAt } : {}),
...(ranks.has(i.cardId) ? { position: ranks.get(i.cardId) } : {}),
// Hours spent as OpenProject's ISO 8601 duration, which parseOpenProject reads back.
...(Number(i.spentTime) > 0 ? { spentTime: `PT${Math.round(Number(i.spentTime) * 100) / 100}H` } : {}),
...Object.fromEntries(Object.entries(i.customFields || {}).map(([name, value]) => [fieldKey(name), value])),
_links: {
status: { title: i.listTitle },
...(releaseOf(planning, i) ? { version: { href: `/api/v3/versions/${releaseOf(planning, i).number}`,
title: releaseOf(planning, i).name } } : {}),
...(sprintOf(planning, i) ? { sprint: { href: `/api/v3/sprints/${sprintOf(planning, i).number}`,
title: sprintOf(planning, i).name } } : {}),
...(has(i.owner) ? { assignee: { title: i.owner } } : {}),
...(list(i.assignees).length ? { responsible: { title: i.assignees[0] } } : {}),
...(has(i.creator) ? { author: { title: i.creator } } : {}),
...(ids.has(i.parentCardId) ? { parent: { href: `/api/v3/work_packages/${ids.get(i.parentCardId)}` } } : {}),
},
// Comments as activities, and what the work package waits for as
// "blocked" relations from it, which the OpenProject import reads.
...(list(i.comments).length || blockers.has(i.cardId) ? { _embedded: {
...(list(i.comments).length ? { activities: i.comments.map(c => ({
_type: 'Activity::Comment', comment: { raw: c.text }, createdAt: c.date,
_links: { user: { title: c.author } } })) } : {}),
...(blockers.has(i.cardId) ? { relations: blockers.get(i.cardId).map(on => ({ _type: 'Relation', type: 'blocked',
_links: { from: { href: `/api/v3/work_packages/${ids.get(i.cardId)}` }, to: { href: `/api/v3/work_packages/${ids.get(on)}` } } })) } : {}),
} } : {}),
})),
},
};
},
// GitHub / Gitea / Forgejo: an issues array.
github: githubLike,
gitea: githubLike,
forgejo: githubLike,
// GitLab: an Issues API v4 array, carrying what parseGitlab reads (#2698):
// every assignee, the author, creation and close dates and comments as
// notes. No iid: a re-import would then add a second "Source:" line.
// Sprints and releases go out as each issue's iteration and milestone.
gitlab: collected => {
const planning = planningIndex(collected);
return collected.items.map(i => ({
title: i.title,
description: i.description,
state: isClosed(i.listTitle) ? 'closed' : 'opened',
labels: i.labels,
due_date: i.dueAt,
// Hours spent, as GitLab's time_stats seconds - what parseGitlab reads back.
...(Number(i.spentTime) > 0 ? { time_stats: { total_time_spent: Math.round(Number(i.spentTime) * 3600) } } : {}),
...(has(i.owner) ? { assignees: [i.owner, ...list(i.assignees)].map(username => ({ username })) } : {}),
...(has(i.creator) ? { author: { username: i.creator } } : {}),
...(has(i.createdAt) ? { created_at: i.createdAt } : {}),
...(isClosed(i.listTitle) && has(i.endAt) ? { closed_at: i.endAt } : {}),
...(list(i.comments).length ? { notes: i.comments.map(c => ({ body: c.text,
author: { username: c.author }, created_at: c.date, system: false })) } : {}),
...(sprintOf(planning, i) ? { iteration: (sp => ({ id: sp.number, iid: sp.number, title: sp.name,
description: sp.goal || '', state: GITLAB_ITERATION_STATE[sp.state] || 1,
start_date: day(sp.plannedStart), due_date: day(sp.plannedEnd) }))(sprintOf(planning, i)) } : {}),
...(releaseOf(planning, i) ? { milestone: (r => ({ id: r.number, iid: r.number, title: r.name,
description: r.notes || '', state: r.state === 'released' ? 'closed' : 'active',
start_date: day(r.plannedStart), due_date: day(r.plannedEnd) }))(releaseOf(planning, i)) } : {}),
}));
},
// Trello board JSON (round-trips with WeKan's Trello import).
// The card's checklists are Trello checklists and its comments commentCard
// actions, the shapes models/trelloCreator.js reads back (checkChecklists,
// parseActions); each card's arrays depend only on the card, so a page
// writes its own (server/lib/renderExternalExport.js JSON_PAGED).
trello: collected => trelloDocument(collected),
// The same, with the cards' attachments, as a .zip beside board.json
// (server/lib/renderExternalExport.js streamTrelloZip).
trellozip: collected => trelloDocument(collected, { withAttachments: true }),
// Jira issues collection (round-trips with WeKan's Jira import).
// The issue keys and custom field names are counted over the whole board,
// whichever page is written (models/lib/exportPaging.js).
jira: collected => {
const { board, jiraEstimateMapping } = collected;
const { items, all } = pagingOf(collected);
const keys = new Map(all.map((item, idx) => [item.cardId, `WEKAN-${idx + 1}`]));
const fieldNames = [...new Set(all.flatMap(i => Object.keys(i.customFields || {})))];
const fieldKey = name => `customfield_${90000 + fieldNames.indexOf(name) + 1}`;
return {
board: { name: board.title },
...(jiraEstimateMapping ? {
wekanScrumMapping: { estimateFieldId: jiraEstimateMapping.estimateFieldId, estimateUnit: jiraEstimateMapping.estimateUnit },
schema: { [jiraEstimateMapping.estimateFieldId]: { type: 'number' } },
} : {}),
...(fieldNames.length ? { names: Object.fromEntries(fieldNames.map(name => [fieldKey(name), name])) } : {}),
issues: items.map(i => ({
key: keys.get(i.cardId),
fields: {
summary: i.title,
description: i.description,
status: { name: i.listTitle, ...(i.jiraScrum?.statusCategory ? { statusCategory: i.jiraScrum.statusCategory } : {}) },
...(i.jiraScrum?.issuetype ? { issuetype: i.jiraScrum.issuetype } : {}),
...(i.jiraScrum?.fixVersions ? { fixVersions: i.jiraScrum.fixVersions } : {}),
...(i.jiraEstimate || {}),
labels: i.labels,
duedate: i.dueAt,
...(Object.keys(i.timetracking || {}).length ? { timetracking: i.timetracking } : {}),
...(has(i.createdAt) ? { created: i.createdAt } : {}),
...(has(i.owner) ? { assignee: { name: i.owner } } : {}),
...(has(i.requestedBy || i.creator) ? { reporter: { displayName: i.requestedBy || i.creator } } : {}),
...(keys.has(i.parentCardId) ? { parent: { key: keys.get(i.parentCardId) } } : {}),
// Card dependencies as Jira issue links, read back by
// models/jiraCreator.js createDependencies: blocks and duplicates
// keep their direction, anything else is Relates.
...(list(i.dependencies).some(dep => keys.has(dep.cardId)) ? { issuelinks: list(i.dependencies)
.filter(dep => keys.has(dep.cardId)).map(dep => {
const key = keys.get(dep.cardId);
const kind = { blocks: ['Blocks', 'outward'], 'is-blocked-by': ['Blocks', 'inward'],
duplicates: ['Duplicate', 'outward'], 'is-duplicated-by': ['Duplicate', 'inward'] }[dep.type] || ['Relates', 'outward'];
return { type: { name: kind[0] }, [kind[1] === 'outward' ? 'outwardIssue' : 'inwardIssue']: { key } };
}) } : {}),
...(checklistItems(i).length ? { subtasks: checklistItems(i).map(x => ({
fields: { summary: x.title, status: { statusCategory: { key: x.done ? 'done' : 'new' } } } })) } : {}),
...(list(i.comments).length ? { comment: { comments: i.comments.map(c => ({
body: c.text, author: { name: c.author }, created: c.date })) } } : {}),
...Object.fromEntries(Object.entries(i.customFields || {}).map(([name, value]) => [fieldKey(name), value])),
},
})),
};
},
// Asana tasks (sections become the board columns).
// A task's dependencies are what it waits for, as the Asana import reads
// them (models/lib/externalParsers.js parseAsana): over the whole board.
asana: collected => { const { items, all } = pagingOf(collected); const blockers = blockersOf(all); return {
data: items.map(i => ({
...(blockers.has(i.cardId) ? { dependencies: blockers.get(i.cardId).map(gid => ({ gid })) } : {}),
gid: i.cardId,
name: i.title,
notes: i.description,
completed: isClosed(i.listTitle),
...(isClosed(i.listTitle) && has(i.endAt) ? { completed_at: i.endAt } : {}),
due_on: i.dueAt,
// Asana's time tracking, in minutes - what parseAsana reads back.
...(Number(i.spentTime) > 0 ? { actual_time_minutes: Math.round(Number(i.spentTime) * 60) } : {}),
...(has(i.startAt) ? { start_on: i.startAt } : {}),
...(has(i.createdAt) ? { created_at: i.createdAt } : {}),
...(has(i.owner) ? { assignee: { name: i.owner } } : {}),
...(has(i.parentCardId) ? { parent: { gid: i.parentCardId } } : {}),
memberships: [{ section: { name: i.listTitle } }],
tags: i.labels.map(name => ({ name })),
...(Object.keys(i.customFields || {}).length ? { custom_fields: Object.entries(i.customFields).map(([name, value]) =>
(typeof value === 'number' ? { name, number_value: value } : { name, text_value: Array.isArray(value) ? value.join(', ') : String(value) })) } : {}),
...(checklistItems(i).length ? { subtasks: checklistItems(i).map(x => ({ name: x.title, completed: Boolean(x.done) })) } : {}),
...(list(i.comments).length ? { stories: i.comments.map(c => ({
resource_subtype: 'comment_added', text: c.text, created_by: { name: c.author }, created_at: c.date })) } : {}),
})),
}; },
// ZenKit-style export (stages + items), the adapter shape the importer reads.
zenkit: ({ board, lists, items }) => ({
title: board.title,
stages: lists.map(l => ({ name: l.title })),
items: items.map(i => ({
id: i.cardId,
title: i.title,
description: i.description,
stage_name: i.listTitle,
due: i.dueAt,
tags: i.labels,
...(has(i.startAt) ? { start: i.startAt } : {}),
...(has(i.createdAt) ? { created_at: i.createdAt } : {}),
...(has(i.parentCardId) ? { parent_id: i.parentCardId } : {}),
...(has(i.owner) || list(i.assignees).length ? { assignees: [i.owner, ...list(i.assignees)].filter(has) } : {}),
...(Object.keys(i.customFields || {}).length ? { fields: i.customFields } : {}),
...(list(i.checklists).length ? { checklists: i.checklists.map(c => ({
name: c.title, items: list(c.items).map(x => ({ text: x.title, checked: Boolean(x.done) })) })) } : {}),
...(list(i.comments).length ? { comments: i.comments.map(c => ({ text: c.text, author: c.author, date: c.date })) } : {}),
})),
}),
// Markdown "task list" kanban - the convention several markdown-kanban tools
// use (Obsidian Kanban and similar): `## List name` headings, `- [ ]`/`- [x]`
// items underneath, indented continuation lines as the item's description.
// Round-trips with parseMarkdownKanban in externalParsers.js. Returns a
// plain string, not an object - the one formatter here that does.
markdown: formatMarkdownKanban,
// The Leo literate editor's .leo outline (XML): lists, cards and checklists
// as nested nodes. Round-trips with parseLeo in leoOutline.js.
leo: formatLeo,
// todo.txt: one task per line; round-trips with parseTodoTxt (todoTxtFormat.js).
todotxt: formatTodoTxt,
// Taskwarrior's `task import` JSON; round-trips with parseTaskwarrior (taskwarriorFormat.js).
taskwarrior: formatTaskwarrior,
// Focalboard's archive text (header line and board.jsonl); round-trips with
// parseFocalboard (focalboardFormat.js).
focalboard: data => formatFocalboard(data),
// A Todoist project template (CSV); round-trips with parseTodoistCsv (todoistCsvFormat.js).
todoist: formatTodoistCsv,
// Microsoft Planner's Excel export: rows that models/export.js writes as .xlsx
// (server/lib/plannerWorkbook.js); round-trips with parsePlannerRows.
planner: formatPlannerRows,
// MeisterTask's CSV import shape; round-trips with parseMeisterTaskCsv.
meistertask: formatMeisterTaskCsv,
// The Obsidian Kanban plugin's board file; round-trips with parseObsidianKanban.
obsidian: formatObsidianKanban,
// Linear's CSV export columns; round-trips with parseLinearCsv.
linear: formatLinearCsv,
// TickTick's backup CSV; round-trips with parseTickTickCsv.
ticktick: formatTickTickCsv,
// ClickUp's workspace export columns; round-trips with parseClickUpCsv.
clickup: formatClickUpCsv,
// A Nullboard .nbx board file; round-trips with parseNullboard.
nullboard: formatNullboard,
// Kanri's single-board JSON export; round-trips with parseKanri (kanriFormat.js).
kanri: formatKanri,
// The stories CSV Pivotal Tracker's import reads; round-trips with parsePivotalCsv.
pivotal: formatPivotalCsv,
// The English CSV Redmine's issue import maps; round-trips with parseRedmineCsv.
redmine: formatRedmineCsv,
// A Tasks.org backup that its Import backup reads; round-trips with parseTasksOrgBackup.
tasksorg: formatTasksOrgBackup,
// monday.com's Excel import table: sheets models/export.js writes as .xlsx
// (server/lib/mondayWorkbook.js); round-trips with parseMondaySheets.
monday: formatMondaySheets,
// Businessmap's Excel import columns: sheets models/export.js writes as .xlsx
// (server/lib/businessmapWorkbook.js); round-trips with parseBusinessmapSheets.
businessmap: formatBusinessmapSheets,
// A Super Productivity backup its "Import from File" reads; round-trips
// with parseSuperProductivity.
superproductivity: collected => formatSuperProductivity(collected),
// A Taiga project dump that Taiga's load_dump reads; round-trips with parseTaiga (taigaFormat.js).
taiga: data => formatTaiga(data),
// Vikunja's data export: projects that models/export.js writes as the .zip
// (vikunjaArchiveFiles, server/lib/vikunjaArchive.js); round-trips with parseVikunjaExport.
vikunja: data => formatVikunja(data),
// Fizzy's account export, which its account import reads: rows here, the
// .zip written by server/lib/renderExternalExport.js (fizzyArchiveFiles).
fizzy: data => formatFizzy(data),
// Wrike's Excel import template: rows models/export.js writes as .xlsx
// (server/lib/wrikeWorkbook.js); round-trips with parseWrikeRows.
wrike: formatWrikeRows,
// The board's lists as a Wrike workflow, in the JSON Wrike's GET /workflows
// returns (models/lib/wrikeWorkflow.js): the workflow the wrike export's
// Workflow and Custom Status cells name.
wrikeworkflow: formatWrikeWorkflow,
// Teamwork.com's Excel task import template: rows models/export.js writes as
// .xlsx (server/lib/teamworkWorkbook.js); round-trips with parseTeamworkSheet.
teamwork: formatTeamworkSheet,
// The CSV Quire's Import CSV reads; round-trips with parseQuireCsv (quireCsvFormat.js).
quire: formatQuireCsv,
// The CSV Notion's CSV import reads; round-trips with parseNotionExport (notionFormat.js).
notion: formatNotionCsv,
// An OPML outline; round-trips with parseOpml (opmlOutline.js, server-only).
opml: formatOpml,
// An Org mode outline; round-trips with parseOrgMode (orgModeFormat.js).
orgmode: formatOrgMode,
// Mail, notes and chat: an .mbox (models/lib/mailFormat.js), an Evernote
// .enex (enexFormat.js) and a Mattermost bulk import file (chatExportFormats.js),
// each read back by WeKan's import of the same format.
mbox: formatMbox,
enex: data => formatEnex(data),
mattermost: formatMattermostBulk,
// The .zip Rocket.Chat's CSV importer reads: rows here, the files written by
// server/lib/renderExternalExport.js (rocketChatCsvFiles).
rocketchat: formatRocketChat,
// Websites (models/lib/websiteFormat.js), each read back by WeKan's import
// of the same format: WordPress's WXR and REST JSON, Ghost, Blogger, and a
// .zip of a Markdown site or of the HTML pages
// (server/lib/renderExternalExport.js zips those two).
wordpress: data => formatWxr(data),
wordpressjson: data => formatWordPressJson(data),
ghost: data => formatGhost(data),
blogger: data => formatBlogger(data),
markdownsite: data => markdownSiteFiles(data),
htmlsite: data => htmlSiteFiles(data),
// Microsoft: the CSV Azure DevOps Boards' and Microsoft Lists' imports read,
// the XML Microsoft Project opens, .eml files for Outlook and OneNote pages
// (both a .zip, server/lib/renderExternalExport.js), and Teams chats as
// Graph chat messages.
azuredevops: formatAzureDevOpsCsv,
mslists: formatMsListsCsv,
msproject: formatMsProjectXml,
outlook: data => formatOutlookEml(data),
onenote: data => formatOnenote(data),
teams: data => formatTeams(data),
// Sandstorm grains of the apps WeKan writes: plain values here, the .zip
// written after the export boundary (server/lib/renderExternalExport.js).
...Object.fromEntries(SANDSTORM_APPS.filter(app => app.export).map(app => [app.key, data => formatSandstormGrain(app.key, data)])),
};
export const EXTERNAL_EXPORT_FORMATS = Object.keys(formatters);