⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.
TypeScript honoissue-managementissue-trackerjira-alternativekanbanlinear-alternativemcpproject-managementreactself-hostedtypescript
feat(import): add Jira as an import source
Andrej1c429603661f
diff --git a/apps/api/src/import/index.ts b/apps/api/src/import/index.tsindex 9fa0f2210..b7436c355 100644--- a/apps/api/src/import/index.ts+++ b/apps/api/src/import/index.ts@@ -42,7 +42,7 @@ const listImportSourceProjectsRoute = createRoute({tags: ["Import"],summary: "List projects in an import source",description:- "Sign in to PLANKA, Plane, Linear, Trello or another Kaneo instance and list the projects that can be imported. The credentials are used only for this request; they are never stored, logged, or returned.",+ "Sign in to PLANKA, Plane, Linear, Jira, Trello or another Kaneo instance and list the projects that can be imported. The credentials are used only for this request; they are never stored, logged, or returned.",middleware: [workspaceAccess.fromBody(),importPermission,diff --git a/apps/api/src/import/schema.ts b/apps/api/src/import/schema.tsindex 105b12653..8ec703945 100644--- a/apps/api/src/import/schema.ts+++ b/apps/api/src/import/schema.ts@@ -2,13 +2,11 @@ import { z } from "../openapi";const NEVER_STORED = "Used only for this import and never stored or logged.";-function sourceUrl(description: string) {- return z- .string()- .trim()- .min(1)- .max(2048)- .openapi({ description, example: "https://planka.example.com" });+function sourceUrl(+ description: string,+ example = "https://planka.example.com",+) {+ return z.string().trim().min(1).max(2048).openapi({ description, example });}function secret(description: string) {@@ -72,6 +70,23 @@ const linearConnection = z}).openapi("LinearImportConnection");+const jiraConnection = z+ .object({+ source: z.literal("jira"),+ url: sourceUrl(+ "Address of the Jira site, e.g. https://your-site.atlassian.net for Jira Cloud, or your own domain for Jira Data Center.",+ "https://your-site.atlassian.net",+ ),+ email: z.string().trim().min(1).max(320).optional().openapi({+ description:+ "Email of the Atlassian account the API token belongs to. Required for Jira Cloud; leave it out for Jira Data Center.",+ }),+ apiToken: secret(+ "A Jira Cloud API token, sent with email, or a Jira Data Center personal access token, sent without email.",+ ),+ })+ .openapi("JiraImportConnection");+const trelloConnection = z.object({source: z.literal("trello"),@@ -96,6 +111,7 @@ export const importConnectionSchema = zplankaConnection,planeConnection,linearConnection,+ jiraConnection,trelloConnection,kaneoConnection,])diff --git a/apps/api/src/import/source/resolve-import-connection.test.ts b/apps/api/src/import/source/resolve-import-connection.test.tsindex 81a0ac340..ca7ca6b8f 100644--- a/apps/api/src/import/source/resolve-import-connection.test.ts+++ b/apps/api/src/import/source/resolve-import-connection.test.ts@@ -61,6 +61,51 @@ describe("resolveImportConnection", () => {).toEqual({ source: "trello", apiKey: "own-key", token: "token-123456" });});+ it("signs in to Jira with or without an email", () => {+ const hint =+ "Check the email and API token, or the personal access token for Jira Data Center.";++ expect(+ resolveImportConnection(+ {+ source: "jira",+ url: "https://acme.atlassian.net",+ email: "[email protected]",+ apiToken: "jira-token-123456",+ },+ {},+ ),+ ).toEqual({+ connection: {+ source: "jira",+ url: "https://acme.atlassian.net",+ email: "[email protected]",+ apiToken: "jira-token-123456",+ },+ secrets: ["jira-token-123456"],+ credentialHint: hint,+ });++ expect(+ resolveImportConnection(+ {+ source: "jira",+ url: "https://jira.example.com",+ apiToken: "pat-123456",+ },+ {},+ ),+ ).toEqual({+ connection: {+ source: "jira",+ url: "https://jira.example.com",+ apiToken: "pat-123456",+ },+ secrets: ["pat-123456"],+ credentialHint: hint,+ });+ });+it("asks for a Trello API key when there is none", () => {expect(() =>resolveImportConnection({ source: "trello", token: "token-123456" }, {}),diff --git a/apps/api/src/import/source/resolve-import-connection.ts b/apps/api/src/import/source/resolve-import-connection.tsindex 1b9b7afd1..2742812e5 100644--- a/apps/api/src/import/source/resolve-import-connection.ts+++ b/apps/api/src/import/source/resolve-import-connection.ts@@ -52,6 +52,13 @@ export function resolveImportConnection(secrets: [input.apiKey],credentialHint: "Check the API key.",};+ case "jira":+ return {+ connection: input,+ secrets: [input.apiToken],+ credentialHint:+ "Check the email and API token, or the personal access token for Jira Data Center.",+ };case "kaneo":return {connection: input,diff --git a/apps/api/src/import/source/source-names.ts b/apps/api/src/import/source/source-names.tsindex 96ea05ca6..52b76af56 100644--- a/apps/api/src/import/source/source-names.ts+++ b/apps/api/src/import/source/source-names.ts@@ -4,6 +4,7 @@ export const IMPORT_SOURCE_NAMES: Record<ImportSourceId, string> = {planka: "PLANKA",plane: "Plane",linear: "Linear",+ jira: "Jira",trello: "Trello",kaneo: "Kaneo",};diff --git a/apps/docs/core/migrations/from-jira.mdx b/apps/docs/core/migrations/from-jira.mdxnew file mode 100644index 000000000..a600fb49c--- /dev/null+++ b/apps/docs/core/migrations/from-jira.mdx@@ -0,0 +1,69 @@+---+title: Import from Jira+description: Move Jira Cloud or Jira Data Center projects into Kaneo, including board columns, issues, priorities, labels, assignees, sub-tasks, issue links, and comments.+---++Each Jira project becomes a Kaneo project. This works with Jira Cloud and Jira Data Center. Read [Import from other tools](/core/migrations) first for the rules that apply to every import.++## Before you start++You need:++- To be an admin of the Kaneo workspace you are importing into.+- Your Jira site URL. Open Jira and copy the address from the browser, for example `https://your-site.atlassian.net`. For Jira Data Center, the address is on your own domain, for example `https://jira.example.com`.+- A way to sign in to Jira:+ - **Jira Cloud**: the email of your Atlassian account and an API token. Open [id.atlassian.com/manage-profile/security/api-tokens](https://id.atlassian.com/manage-profile/security/api-tokens) and create an API token. Copy it right away, because Atlassian only shows it once.+ - **Jira Data Center**: a personal access token. In Jira, open your profile, then **Personal Access Tokens**, and create one. Leave the email empty when you use it.++Invite your team to the Kaneo workspace first. Assignees are matched by email. Jira often hides email addresses, depending on each person's profile settings, so when it does, Kaneo matches by full name instead, ignoring case, and only when exactly one workspace member has that name. Anyone who isn't a member yet will have their issues imported unassigned.++If you run Kaneo yourself and Jira is on a private network, for example a Jira Data Center server on your LAN, the Kaneo server must be able to reach it. The operator must set `KANEO_ALLOW_PRIVATE_WEBHOOK_DESTINATIONS=true` on the Kaneo API. See [Self-hosted instances](/core/migrations#self-hosted-instances).++## Connect++1. In Kaneo, open **Settings → Workspace → Import** and choose **Jira**.+2. Paste your Jira site URL.+3. For Jira Cloud, enter your email and paste your API token. For Jira Data Center, leave the email empty and paste your personal access token.+4. Select the projects to import. Leave comments on, or turn them off.+5. Start the import. You can leave the page while it runs and check **Recent imports** later.++## What carries over++| Jira | Kaneo |+| --- | --- |+| Project | Project |+| Project key, for example `PROJ` | Project key. If another project in the workspace uses it, Kaneo adds a suffix, for example `PROJ-2` |+| Columns of the project's Jira Software board, or its statuses when there is no board Kaneo can read | Columns, in Jira's order. The last board column, and columns that only hold done statuses, become final columns. Issues in a **Backlog** column or status go to the project's **Backlog** instead of the board |+| Issue | Task |+| Issue number, for example `PROJ-123` | Task number, so `PROJ-123` stays `PROJ-123` |+| Description | Task description, converted from Jira's rich text to Markdown |+| Priority | The closest Kaneo priority. Highest, Blocker, and Critical become Urgent. High and Major become High. Medium stays Medium. Low, Lowest, Minor, and Trivial become Low. Other priorities become no priority |+| Due date | Due date |+| Labels | Labels. Jira labels have no colors, so Kaneo picks one for each |+| Assignee | Assignee, matched by email, or by full name when Jira hides the email |+| Sub-tasks, and issues that have a parent issue such as an epic | Subtask relations |+| Issue links | **Blocks** links stay blocks relations. Other links, such as **Relates**, become related relations |+| Comments | Comments, with the original author's name and date |++## What doesn't++- **Attachments.** Download anything you need from Jira before you stop using it.+- **Sprints.**+- **Epics**, other than as parent issues. An epic is imported as a task, with its issues as subtasks.+- **Components and fix versions.**+- **Custom fields.**+- **Worklogs.**+- **Watchers.**+- **Parent and issue links to issues in other projects.** The report says how many were left out.++## Troubleshooting++**The token is rejected**: for Jira Cloud, check that the email belongs to the Atlassian account that created the token, that you copied the whole token, and that it has not expired. For Jira Data Center, leave the email empty and paste a personal access token, not your password.++**A project is missing from the list**: your Jira account can't browse it. Ask a Jira admin for access to the project, or sign in with an account that has it.++**Columns follow statuses instead of the board**: Kaneo could not read the project's board, and the report says so. Check that your account can see the board in Jira, then delete the imported project and import it again.++**A large import is slow**: Jira Cloud limits how many requests Kaneo can make, so large projects take a while. With comments on, Kaneo reads them separately for each issue that has any. You don't need to keep the page open. Check **Recent imports** later. If you don't need the comments, turn them off to finish faster.++**Tasks are unassigned**: the assignee's Jira email, or their full name when Jira hides the email, must match a member of the Kaneo workspace. Invite them or fix the name, delete the imported project, and import it again. You can also assign the tasks by hand.diff --git a/apps/docs/core/migrations/index.mdx b/apps/docs/core/migrations/index.mdxindex fb4067cbf..eb0a5f099 100644--- a/apps/docs/core/migrations/index.mdx+++ b/apps/docs/core/migrations/index.mdx@@ -1,6 +1,6 @@---title: Import from other tools-description: Bring projects from Linear, Trello, Plane, PLANKA, or another Kaneo instance into a Kaneo workspace.+description: Bring projects from Linear, Jira, Trello, Plane, PLANKA, or another Kaneo instance into a Kaneo workspace.---Kaneo can copy projects from another tool into your workspace. You connect a source with a key, choose the projects you want, and Kaneo recreates them as new Kaneo projects. Kaneo only reads from the source; nothing there is changed.@@ -10,6 +10,7 @@ Kaneo can copy projects from another tool into your workspace. You connect a sou| Source | Each of these becomes a Kaneo project | Guide || --- | --- | --- || Linear | Team | [Import from Linear](/core/migrations/from-linear) |+| Jira (Cloud or Data Center) | Project | [Import from Jira](/core/migrations/from-jira) || Trello | Board | [Import from Trello](/core/migrations/from-trello) || Plane (cloud or self-hosted) | Project | [Import from Plane](/core/migrations/from-plane) || PLANKA | Board | [Import from PLANKA](/core/migrations/from-planka) |@@ -56,7 +57,7 @@ Trello boards have no key, so Kaneo makes one from the board name. PLANKA boardsAssignees are matched to workspace members by email. Anyone who isn't a member when you import gets their tasks imported unassigned. [Invite your team](/core/functional/collaborate-with-team) before you start.-Some sources hide email addresses. Trello never shares other people's emails, and PLANKA hides them from accounts that are not admins. In those cases Kaneo matches by full name, ignoring case, and only when exactly one workspace member has that name.+Some sources hide email addresses. Trello never shares other people's emails, Jira often hides them depending on each person's profile settings, and PLANKA hides them from accounts that are not admins. In those cases Kaneo matches by full name, ignoring case, and only when exactly one workspace member has that name.Kaneo has one assignee per task. When an item has several assignees, only the first is kept, and the report says how many items had more than one.diff --git a/apps/docs/openapi.json b/apps/docs/openapi.jsonindex 6d5b0092f..5f9701d4f 100644--- a/apps/docs/openapi.json+++ b/apps/docs/openapi.json@@ -4722,6 +4722,9 @@{"$ref": "#/components/schemas/LinearImportConnection"},+ {+ "$ref": "#/components/schemas/JiraImportConnection"+ },{"$ref": "#/components/schemas/TrelloImportConnection"},@@ -4735,6 +4738,7 @@"planka": "#/components/schemas/PlankaImportConnection","plane": "#/components/schemas/PlaneImportConnection","linear": "#/components/schemas/LinearImportConnection",+ "jira": "#/components/schemas/JiraImportConnection","trello": "#/components/schemas/TrelloImportConnection","kaneo": "#/components/schemas/KaneoImportConnection"}@@ -4837,6 +4841,41 @@"apiKey"]},+ "JiraImportConnection": {+ "type": "object",+ "properties": {+ "source": {+ "type": "string",+ "enum": [+ "jira"+ ]+ },+ "url": {+ "type": "string",+ "minLength": 1,+ "maxLength": 2048,+ "description": "Address of the Jira site, e.g. https://your-site.atlassian.net for Jira Cloud, or your own domain for Jira Data Center.",+ "example": "https://your-site.atlassian.net"+ },+ "email": {+ "type": "string",+ "minLength": 1,+ "maxLength": 320,+ "description": "Email of the Atlassian account the API token belongs to. Required for Jira Cloud; leave it out for Jira Data Center."+ },+ "apiToken": {+ "type": "string",+ "minLength": 1,+ "maxLength": 4096,+ "description": "A Jira Cloud API token, sent with email, or a Jira Data Center personal access token, sent without email. Used only for this import and never stored or logged."+ }+ },+ "required": [+ "source",+ "url",+ "apiToken"+ ]+ },"TrelloImportConnection": {"type": "object","properties": {@@ -4919,6 +4958,7 @@"planka","plane","linear",+ "jira","trello","kaneo"]@@ -22649,7 +22689,7 @@"Import"],"summary": "List projects in an import source",- "description": "Sign in to PLANKA, Plane, Linear, Trello or another Kaneo instance and list the projects that can be imported. The credentials are used only for this request; they are never stored, logged, or returned.",+ "description": "Sign in to PLANKA, Plane, Linear, Jira, Trello or another Kaneo instance and list the projects that can be imported. The credentials are used only for this request; they are never stored, logged, or returned.","requestBody": {"required": true,"content": {diff --git a/apps/web/src/components/import/build-connection.test.ts b/apps/web/src/components/import/build-connection.test.tsindex b6dadb525..6aa10f7a8 100644--- a/apps/web/src/components/import/build-connection.test.ts+++ b/apps/web/src/components/import/build-connection.test.ts@@ -26,6 +26,55 @@ describe("buildConnection", () => {).toEqual({ source: "linear", apiKey: "lin_api_1" });});+ it("needs the Jira URL and token, and sends the email only when typed", () => {+ expect(+ buildConnection(+ "jira",+ values({ token: "jira-token", email: "[email protected]" }),+ withServerKey,+ ),+ ).toBeNull();+ expect(+ buildConnection(+ "jira",+ values({ url: "https://acme.atlassian.net", email: "[email protected]" }),+ withServerKey,+ ),+ ).toBeNull();+ expect(+ buildConnection(+ "jira",+ values({+ url: " https://acme.atlassian.net ",+ email: " [email protected] ",+ token: " jira-token ",+ apiKey: "ignored",+ }),+ withServerKey,+ ),+ ).toEqual({+ source: "jira",+ url: "https://acme.atlassian.net",+ email: "[email protected]",+ apiToken: "jira-token",+ });+ expect(+ buildConnection(+ "jira",+ values({+ url: "https://jira.example.com",+ email: " ",+ token: "pat-token",+ }),+ withServerKey,+ ),+ ).toEqual({+ source: "jira",+ url: "https://jira.example.com",+ apiToken: "pat-token",+ });+ });+it("leaves the Trello key to the server when it has one", () => {expect(buildConnection(diff --git a/apps/web/src/components/import/build-connection.ts b/apps/web/src/components/import/build-connection.tsindex 97f2c8f44..c89d42869 100644--- a/apps/web/src/components/import/build-connection.ts+++ b/apps/web/src/components/import/build-connection.ts@@ -15,10 +15,16 @@ export function buildConnection(const apiKey = values.apiKey.trim();const token = values.token.trim();const username = values.username.trim();+ const email = values.email.trim();switch (source) {case "linear":return apiKey ? { source, apiKey } : null;+ case "jira":+ if (!url || !token) return null;+ return email+ ? { source, url, email, apiToken: token }+ : { source, url, apiToken: token };case "trello":if (!token) return null;if (serverHasTrelloKey) return { source, token };diff --git a/apps/web/src/components/import/connect-forms/connect-form-registry.ts b/apps/web/src/components/import/connect-forms/connect-form-registry.tsindex 33e3229a9..864b3ba3e 100644--- a/apps/web/src/components/import/connect-forms/connect-form-registry.ts+++ b/apps/web/src/components/import/connect-forms/connect-form-registry.ts@@ -1,5 +1,6 @@import type { ComponentType } from "react";import type { ConnectFormProps } from "@/components/import/connect-forms/connect-form-props";+import { JiraConnectForm } from "@/components/import/connect-forms/jira-connect-form";import { KaneoConnectForm } from "@/components/import/connect-forms/kaneo-connect-form";import { LinearConnectForm } from "@/components/import/connect-forms/linear-connect-form";import { PlaneConnectForm } from "@/components/import/connect-forms/plane-connect-form";@@ -12,6 +13,7 @@ export const CONNECT_FORMS: Record<ComponentType<ConnectFormProps>> = {linear: LinearConnectForm,+ jira: JiraConnectForm,trello: TrelloConnectForm,plane: PlaneConnectForm,planka: PlankaConnectForm,diff --git a/apps/web/src/components/import/connect-forms/jira-connect-form.test.tsx b/apps/web/src/components/import/connect-forms/jira-connect-form.test.tsxnew file mode 100644index 000000000..e169c792c--- /dev/null+++ b/apps/web/src/components/import/connect-forms/jira-connect-form.test.tsx@@ -0,0 +1,64 @@+import { cleanup, fireEvent, render, screen } from "@testing-library/react";+import { afterEach, describe, expect, it, vi } from "vite-plus/test";+import { JiraConnectForm } from "@/components/import/connect-forms/jira-connect-form";+import { EMPTY_CONNECT_VALUES } from "@/components/import/connect-values";++vi.mock("react-i18next", () => ({+ useTranslation: () => ({ t: (key: string) => key }),+}));++afterEach(cleanup);++describe("JiraConnectForm", () => {+ it("collects the site URL, email and token", () => {+ const onChange = vi.fn();+ render(+ <JiraConnectForm+ values={EMPTY_CONNECT_VALUES}+ onChange={onChange}+ error={null}+ trelloAuthorizeUrl={null}+ />,+ );++ fireEvent.change(+ screen.getByLabelText("settings:workspaceImport.jira.urlLabel"),+ { target: { value: "https://acme.atlassian.net" } },+ );+ fireEvent.change(+ screen.getByLabelText("settings:workspaceImport.jira.emailLabel"),+ { target: { value: "[email protected]" } },+ );+ const token = screen.getByLabelText(+ "settings:workspaceImport.jira.tokenLabel",+ );+ fireEvent.change(token, { target: { value: "jira-token" } });++ expect(onChange).toHaveBeenCalledWith({+ url: "https://acme.atlassian.net",+ });+ expect(onChange).toHaveBeenCalledWith({ email: "[email protected]" });+ expect(onChange).toHaveBeenCalledWith({ token: "jira-token" });+ expect(token).toHaveAttribute("type", "password");+ });++ it("links to the Atlassian API tokens page", () => {+ render(+ <JiraConnectForm+ values={EMPTY_CONNECT_VALUES}+ onChange={vi.fn()}+ error={null}+ trelloAuthorizeUrl={null}+ />,+ );++ const link = screen.getByRole("link", {+ name: /settings:workspaceImport\.jira\.openSettings/,+ });+ expect(link).toHaveAttribute(+ "href",+ "https://id.atlassian.com/manage-profile/security/api-tokens",+ );+ expect(link).toHaveAttribute("target", "_blank");+ });+});diff --git a/apps/web/src/components/import/connect-forms/jira-connect-form.tsx b/apps/web/src/components/import/connect-forms/jira-connect-form.tsxnew file mode 100644index 000000000..4eefe00d8--- /dev/null+++ b/apps/web/src/components/import/connect-forms/jira-connect-form.tsx@@ -0,0 +1,88 @@+import { Info } from "lucide-react";+import { useTranslation } from "react-i18next";+import { ConnectFieldRow } from "@/components/import/connect-forms/connect-field-row";+import type { ConnectFormProps } from "@/components/import/connect-forms/connect-form-props";+import { ConnectHelpSteps } from "@/components/import/connect-forms/connect-help-steps";+import { fieldDescribedBy } from "@/components/import/connect-forms/field-ids";+import { SecretInput } from "@/components/import/connect-forms/secret-input";+import { Input } from "@/components/ui/input";++const URL_ID = "import-jira-url";+const EMAIL_ID = "import-jira-email";+const TOKEN_ID = "import-jira-token";++export function JiraConnectForm({ values, onChange, error }: ConnectFormProps) {+ const { t } = useTranslation();+ const tokenLabel = t("settings:workspaceImport.jira.tokenLabel");++ return (+ <div className="divide-y divide-border overflow-hidden rounded-xl border border-border bg-card">+ <ConnectFieldRow+ id={URL_ID}+ labelFor={URL_ID}+ label={t("settings:workspaceImport.jira.urlLabel")}+ description={t("settings:workspaceImport.jira.urlDescription")}+ >+ <Input+ id={URL_ID}+ type="url"+ inputMode="url"+ value={values.url}+ onChange={(event) => onChange({ url: event.target.value })}+ placeholder={t("settings:workspaceImport.jira.urlPlaceholder")}+ autoComplete="off"+ autoCapitalize="off"+ spellCheck={false}+ aria-describedby={fieldDescribedBy(URL_ID, false)}+ />+ </ConnectFieldRow>+ <ConnectFieldRow+ id={EMAIL_ID}+ labelFor={EMAIL_ID}+ label={t("settings:workspaceImport.jira.emailLabel")}+ description={t("settings:workspaceImport.jira.emailDescription")}+ >+ <Input+ id={EMAIL_ID}+ type="email"+ inputMode="email"+ value={values.email}+ onChange={(event) => onChange({ email: event.target.value })}+ autoComplete="off"+ autoCapitalize="off"+ spellCheck={false}+ aria-describedby={fieldDescribedBy(EMAIL_ID, false)}+ />+ </ConnectFieldRow>+ <ConnectFieldRow+ id={TOKEN_ID}+ labelFor={TOKEN_ID}+ label={tokenLabel}+ description={t("settings:workspaceImport.jira.tokenDescription")}+ error={error}+ >+ <SecretInput+ id={TOKEN_ID}+ label={tokenLabel}+ value={values.token}+ onValueChange={(token) => onChange({ token })}+ placeholder={t("settings:workspaceImport.jira.tokenPlaceholder")}+ invalid={Boolean(error)}+ />+ </ConnectFieldRow>+ <ConnectHelpSteps+ href="https://id.atlassian.com/manage-profile/security/api-tokens"+ linkLabel={t("settings:workspaceImport.jira.openSettings")}+ steps={[+ t("settings:workspaceImport.jira.stepOpen"),+ t("settings:workspaceImport.jira.stepCreate"),+ t("settings:workspaceImport.jira.stepPaste"),+ ]}+ />+ <div className="flex items-start gap-2.5 bg-info/4 px-4 py-3 text-xs dark:bg-info/8">+ <Info aria-hidden="true" className="mt-px size-4 shrink-0 text-info" />+ <p>{t("settings:workspaceImport.jira.nameMatchTip")}</p>+ </div>+ </div>+ );+}diff --git a/apps/web/src/components/import/connect-values.ts b/apps/web/src/components/import/connect-values.tsindex 7dfae8484..68b81fde9 100644--- a/apps/web/src/components/import/connect-values.ts+++ b/apps/web/src/components/import/connect-values.ts@@ -5,6 +5,7 @@ export type ImportConnectValues = {apiKey: string;token: string;username: string;+ email: string;password: string;plankaSignIn: PlankaSignIn;};@@ -14,6 +15,7 @@ export const EMPTY_CONNECT_VALUES: ImportConnectValues = {apiKey: "",token: "",username: "",+ email: "",password: "",plankaSignIn: "apiKey",};diff --git a/apps/web/src/components/import/import-options-card.tsx b/apps/web/src/components/import/import-options-card.tsxindex e4345498f..48c6b20a9 100644--- a/apps/web/src/components/import/import-options-card.tsx+++ b/apps/web/src/components/import/import-options-card.tsx@@ -54,9 +54,13 @@ export function ImportOptionsCard({? t("settings:workspaceImport.select.membersNoteTrello", {workspace: workspaceName,})- : t("settings:workspaceImport.select.membersNote", {- workspace: workspaceName,- })}+ : sourceId === "jira"+ ? t("settings:workspaceImport.select.membersNoteJira", {+ workspace: workspaceName,+ })+ : t("settings:workspaceImport.select.membersNote", {+ workspace: workspaceName,+ })}</p></div><Buttondiff --git a/apps/web/src/components/import/import-source-definitions.ts b/apps/web/src/components/import/import-source-definitions.tsindex 1dbb06200..9e49a3c24 100644--- a/apps/web/src/components/import/import-source-definitions.ts+++ b/apps/web/src/components/import/import-source-definitions.ts@@ -1,5 +1,6 @@import type { ComponentType } from "react";import type { ImportUnit } from "@/components/import/import-unit-copy";+import { JiraLogo } from "@/components/import/source-logos/jira-logo";import { KaneoLogo } from "@/components/import/source-logos/kaneo-logo";import { LinearLogo } from "@/components/import/source-logos/linear-logo";import { PlaneLogo } from "@/components/import/source-logos/plane-logo";@@ -29,6 +30,14 @@ export const IMPORT_SOURCES: ImportSourceDefinition[] = [introKey: "settings:workspaceImport.sources.linear.intro",unit: "team",},+ {+ id: "jira",+ name: "Jira",+ Logo: JiraLogo,+ descriptionKey: "settings:workspaceImport.sources.jira.description",+ introKey: "settings:workspaceImport.sources.jira.intro",+ unit: "project",+ },{id: "trello",name: "Trello",diff --git a/apps/web/src/components/import/source-logos/jira-logo.tsx b/apps/web/src/components/import/source-logos/jira-logo.tsxnew file mode 100644index 000000000..e006fd4d9--- /dev/null+++ b/apps/web/src/components/import/source-logos/jira-logo.tsx@@ -0,0 +1,16 @@+import type { SourceLogoProps } from "@/components/import/source-logos/source-logo-size";+import { cn } from "@/lib/cn";++export function JiraLogo({ size }: SourceLogoProps) {+ return (+ <svg+ viewBox="0 0 24 24"+ fill="currentColor"+ aria-hidden="true"+ focusable="false"+ className={cn("text-[#2684FF]", size === "sm" ? "size-4" : "size-5")}+ >+ <path d="M11.571 11.513H0a5.218 5.218 0 0 0 5.232 5.215h2.13v2.057A5.215 5.215 0 0 0 12.575 24V12.518a1.005 1.005 0 0 0-1.005-1.005zm5.723-5.756H5.736a5.215 5.215 0 0 0 5.215 5.214h2.129v2.058a5.218 5.218 0 0 0 5.215 5.214V6.758a1.001 1.001 0 0 0-1.001-1.001zM23.013 0H11.455a5.215 5.215 0 0 0 5.215 5.215h2.129v2.057A5.215 5.215 0 0 0 24 12.483V1.005A1.001 1.001 0 0 0 23.013 0Z" />+ </svg>+ );+}diff --git a/i18n/az-AZ.json b/i18n/az-AZ.jsonindex d893e363e..96bd73914 100644--- a/i18n/az-AZ.json+++ b/i18n/az-AZ.json@@ -2079,7 +2079,7 @@},"entry": {"createProjectLink": "Import your projects",- "createProjectPrompt": "Moving from Linear, Trello or Plane?",+ "createProjectPrompt": "Moving from Jira, Linear, Trello or Plane?","projectsEmpty": "Import from another tool"},"history": {@@ -2173,7 +2173,8 @@"inviteMembers": "Invite members","membersNote": "Assignees are matched to members of {{workspace}} by email. Invite your team first so their tasks stay assigned.","membersNoteTrello": "Assignees are matched to members of {{workspace}} by email, or by full name for Trello. Invite your team first so their tasks stay assigned.",- "selectAll": "Select all"+ "selectAll": "Select all",+ "membersNoteJira": "Assignees are matched to members of {{workspace}} by email, or by full name when Jira hides the email. Invite your team first so their tasks stay assigned."},"sources": {"connect": "Connect",@@ -2200,6 +2201,10 @@"trello": {"description": "Boards, lists, cards, checklists and comments. Authorize with one click.","intro": "Each Trello board becomes a project, with its lists as columns."+ },+ "jira": {+ "description": "Projects, issues, sub-tasks, links and comments. Cloud or Data Center.",+ "intro": "Each Jira project becomes a project here, with its workflow as columns."}},"status": {@@ -2293,6 +2298,21 @@"someImported_other": "{{done}} of {{count}} teams imported.","step": "Choose teams"}+ },+ "jira": {+ "emailDescription": "The email of your Atlassian account. Leave it empty for Jira Data Center.",+ "emailLabel": "Email",+ "nameMatchTip": "Jira often hides email addresses, so assignees may be matched to people here by full name.",+ "openSettings": "Open Atlassian API tokens",+ "stepCreate": "Create an API token and copy it.",+ "stepOpen": "Open id.atlassian.com, then Security, then API tokens.",+ "stepPaste": "Paste it with the email you sign in to Jira with.",+ "tokenDescription": "Cloud: create one at id.atlassian.com. Data Center: use a personal access token.",+ "tokenLabel": "API token",+ "tokenPlaceholder": "Paste token",+ "urlDescription": "Copy it from your browser. Data Center works too.",+ "urlLabel": "Jira site URL",+ "urlPlaceholder": "https://your-site.atlassian.net"}}},diff --git a/i18n/de-DE.json b/i18n/de-DE.jsonindex eb01825ed..44d98f5ee 100644--- a/i18n/de-DE.json+++ b/i18n/de-DE.json@@ -2079,7 +2079,7 @@},"entry": {"createProjectLink": "Import your projects",- "createProjectPrompt": "Moving from Linear, Trello or Plane?",+ "createProjectPrompt": "Moving from Jira, Linear, Trello or Plane?","projectsEmpty": "Import from another tool"},"history": {@@ -2173,7 +2173,8 @@"inviteMembers": "Invite members","membersNote": "Assignees are matched to members of {{workspace}} by email. Invite your team first so their tasks stay assigned.","membersNoteTrello": "Assignees are matched to members of {{workspace}} by email, or by full name for Trello. Invite your team first so their tasks stay assigned.",- "selectAll": "Select all"+ "selectAll": "Select all",+ "membersNoteJira": "Assignees are matched to members of {{workspace}} by email, or by full name when Jira hides the email. Invite your team first so their tasks stay assigned."},"sources": {"connect": "Connect",@@ -2200,6 +2201,10 @@"trello": {"description": "Boards, lists, cards, checklists and comments. Authorize with one click.","intro": "Each Trello board becomes a project, with its lists as columns."+ },+ "jira": {+ "description": "Projects, issues, sub-tasks, links and comments. Cloud or Data Center.",+ "intro": "Each Jira project becomes a project here, with its workflow as columns."}},"status": {@@ -2293,6 +2298,21 @@"someImported_other": "{{done}} of {{count}} teams imported.","step": "Choose teams"}+ },+ "jira": {+ "emailDescription": "The email of your Atlassian account. Leave it empty for Jira Data Center.",+ "emailLabel": "Email",+ "nameMatchTip": "Jira often hides email addresses, so assignees may be matched to people here by full name.",+ "openSettings": "Open Atlassian API tokens",+ "stepCreate": "Create an API token and copy it.",+ "stepOpen": "Open id.atlassian.com, then Security, then API tokens.",+ "stepPaste": "Paste it with the email you sign in to Jira with.",+ "tokenDescription": "Cloud: create one at id.atlassian.com. Data Center: use a personal access token.",+ "tokenLabel": "API token",+ "tokenPlaceholder": "Paste token",+ "urlDescription": "Copy it from your browser. Data Center works too.",+ "urlLabel": "Jira site URL",+ "urlPlaceholder": "https://your-site.atlassian.net"}}},diff --git a/i18n/el-GR.json b/i18n/el-GR.jsonindex 0709c2b3d..a0fabb0a6 100644--- a/i18n/el-GR.json+++ b/i18n/el-GR.json@@ -2079,7 +2079,7 @@},"entry": {"createProjectLink": "Import your projects",- "createProjectPrompt": "Moving from Linear, Trello or Plane?",+ "createProjectPrompt": "Moving from Jira, Linear, Trello or Plane?","projectsEmpty": "Import from another tool"},"history": {@@ -2173,7 +2173,8 @@"inviteMembers": "Invite members","membersNote": "Assignees are matched to members of {{workspace}} by email. Invite your team first so their tasks stay assigned.","membersNoteTrello": "Assignees are matched to members of {{workspace}} by email, or by full name for Trello. Invite your team first so their tasks stay assigned.",- "selectAll": "Select all"+ "selectAll": "Select all",+ "membersNoteJira": "Assignees are matched to members of {{workspace}} by email, or by full name when Jira hides the email. Invite your team first so their tasks stay assigned."},"sources": {"connect": "Connect",@@ -2200,6 +2201,10 @@"trello": {"description": "Boards, lists, cards, checklists and comments. Authorize with one click.","intro": "Each Trello board becomes a project, with its lists as columns."+ },+ "jira": {+ "description": "Projects, issues, sub-tasks, links and comments. Cloud or Data Center.",+ "intro": "Each Jira project becomes a project here, with its workflow as columns."}},"status": {@@ -2293,6 +2298,21 @@"someImported_other": "{{done}} of {{count}} teams imported.","step": "Choose teams"}+ },+ "jira": {+ "emailDescription": "The email of your Atlassian account. Leave it empty for Jira Data Center.",+ "emailLabel": "Email",+ "nameMatchTip": "Jira often hides email addresses, so assignees may be matched to people here by full name.",+ "openSettings": "Open Atlassian API tokens",+ "stepCreate": "Create an API token and copy it.",+ "stepOpen": "Open id.atlassian.com, then Security, then API tokens.",+ "stepPaste": "Paste it with the email you sign in to Jira with.",+ "tokenDescription": "Cloud: create one at id.atlassian.com. Data Center: use a personal access token.",+ "tokenLabel": "API token",+ "tokenPlaceholder": "Paste token",+ "urlDescription": "Copy it from your browser. Data Center works too.",+ "urlLabel": "Jira site URL",+ "urlPlaceholder": "https://your-site.atlassian.net"}}},diff --git a/i18n/en-US.json b/i18n/en-US.jsonindex a4ab5e3b6..c7312ffef 100644--- a/i18n/en-US.json+++ b/i18n/en-US.json@@ -1235,6 +1235,10 @@"description": "Teams, issues, labels, sub-issues and comments. Paste a personal API key.","intro": "Each Linear team becomes a project, with its workflow as columns."},+ "jira": {+ "description": "Projects, issues, sub-tasks, links and comments. Cloud or Data Center.",+ "intro": "Each Jira project becomes a project here, with its workflow as columns."+ },"trello": {"description": "Boards, lists, cards, checklists and comments. Authorize with one click.","intro": "Each Trello board becomes a project, with its lists as columns."@@ -1297,6 +1301,21 @@"stepCreate": "Under Personal API keys, create a key with Read access.","stepPaste": "Copy it and paste it above."},+ "jira": {+ "urlLabel": "Jira site URL",+ "urlDescription": "Copy it from your browser. Data Center works too.",+ "urlPlaceholder": "https://your-site.atlassian.net",+ "emailLabel": "Email",+ "emailDescription": "The email of your Atlassian account. Leave it empty for Jira Data Center.",+ "tokenLabel": "API token",+ "tokenDescription": "Cloud: create one at id.atlassian.com. Data Center: use a personal access token.",+ "tokenPlaceholder": "Paste token",+ "openSettings": "Open Atlassian API tokens",+ "stepOpen": "Open id.atlassian.com, then Security, then API tokens.",+ "stepCreate": "Create an API token and copy it.",+ "stepPaste": "Paste it with the email you sign in to Jira with.",+ "nameMatchTip": "Jira often hides email addresses, so assignees may be matched to people here by full name."+ },"trello": {"apiKeyLabel": "API key","apiKeyDescription": "In a Power-Up you own, open the Trello Auth tab and generate an API key (not the OAuth 2.0 tab) at",@@ -1347,6 +1366,7 @@"commentsDescription": "Keeps each comment's original author and date.","membersNote": "Assignees are matched to members of {{workspace}} by email. Invite your team first so their tasks stay assigned.","membersNoteTrello": "Assignees are matched to members of {{workspace}} by email, or by full name for Trello. Invite your team first so their tasks stay assigned.",+ "membersNoteJira": "Assignees are matched to members of {{workspace}} by email, or by full name when Jira hides the email. Invite your team first so their tasks stay assigned.","inviteMembers": "Invite members"},"units": {@@ -1456,7 +1476,7 @@},"entry": {"projectsEmpty": "Import from another tool",- "createProjectPrompt": "Moving from Linear, Trello or Plane?",+ "createProjectPrompt": "Moving from Jira, Linear, Trello or Plane?","createProjectLink": "Import your projects"}},diff --git a/i18n/es-ES.json b/i18n/es-ES.jsonindex b46c23bd4..147b077ca 100644--- a/i18n/es-ES.json+++ b/i18n/es-ES.json@@ -2094,7 +2094,7 @@},"entry": {"createProjectLink": "Import your projects",- "createProjectPrompt": "Moving from Linear, Trello or Plane?",+ "createProjectPrompt": "Moving from Jira, Linear, Trello or Plane?","projectsEmpty": "Import from another tool"},"history": {@@ -2191,7 +2191,8 @@"inviteMembers": "Invite members","membersNote": "Assignees are matched to members of {{workspace}} by email. Invite your team first so their tasks stay assigned.","membersNoteTrello": "Assignees are matched to members of {{workspace}} by email, or by full name for Trello. Invite your team first so their tasks stay assigned.",- "selectAll": "Select all"+ "selectAll": "Select all",+ "membersNoteJira": "Assignees are matched to members of {{workspace}} by email, or by full name when Jira hides the email. Invite your team first so their tasks stay assigned."},"sources": {"connect": "Connect",@@ -2218,6 +2219,10 @@"trello": {"description": "Boards, lists, cards, checklists and comments. Authorize with one click.","intro": "Each Trello board becomes a project, with its lists as columns."+ },+ "jira": {+ "description": "Projects, issues, sub-tasks, links and comments. Cloud or Data Center.",+ "intro": "Each Jira project becomes a project here, with its workflow as columns."}},"status": {@@ -2330,6 +2335,21 @@"someImported_other": "{{done}} of {{count}} teams imported.","step": "Choose teams"}+ },+ "jira": {+ "emailDescription": "The email of your Atlassian account. Leave it empty for Jira Data Center.",+ "emailLabel": "Email",+ "nameMatchTip": "Jira often hides email addresses, so assignees may be matched to people here by full name.",+ "openSettings": "Open Atlassian API tokens",+ "stepCreate": "Create an API token and copy it.",+ "stepOpen": "Open id.atlassian.com, then Security, then API tokens.",+ "stepPaste": "Paste it with the email you sign in to Jira with.",+ "tokenDescription": "Cloud: create one at id.atlassian.com. Data Center: use a personal access token.",+ "tokenLabel": "API token",+ "tokenPlaceholder": "Paste token",+ "urlDescription": "Copy it from your browser. Data Center works too.",+ "urlLabel": "Jira site URL",+ "urlPlaceholder": "https://your-site.atlassian.net"}}},diff --git a/i18n/fr-FR.json b/i18n/fr-FR.jsonindex 412562b10..508deab30 100644--- a/i18n/fr-FR.json+++ b/i18n/fr-FR.json@@ -2094,7 +2094,7 @@},"entry": {"createProjectLink": "Import your projects",- "createProjectPrompt": "Moving from Linear, Trello or Plane?",+ "createProjectPrompt": "Moving from Jira, Linear, Trello or Plane?","projectsEmpty": "Import from another tool"},"history": {@@ -2191,7 +2191,8 @@"inviteMembers": "Invite members","membersNote": "Assignees are matched to members of {{workspace}} by email. Invite your team first so their tasks stay assigned.","membersNoteTrello": "Assignees are matched to members of {{workspace}} by email, or by full name for Trello. Invite your team first so their tasks stay assigned.",- "selectAll": "Select all"+ "selectAll": "Select all",+ "membersNoteJira": "Assignees are matched to members of {{workspace}} by email, or by full name when Jira hides the email. Invite your team first so their tasks stay assigned."},"sources": {"connect": "Connect",@@ -2218,6 +2219,10 @@"trello": {"description": "Boards, lists, cards, checklists and comments. Authorize with one click.","intro": "Each Trello board becomes a project, with its lists as columns."+ },+ "jira": {+ "description": "Projects, issues, sub-tasks, links and comments. Cloud or Data Center.",+ "intro": "Each Jira project becomes a project here, with its workflow as columns."}},"status": {@@ -2330,6 +2335,21 @@"someImported_other": "{{done}} of {{count}} teams imported.","step": "Choose teams"}+ },+ "jira": {+ "emailDescription": "The email of your Atlassian account. Leave it empty for Jira Data Center.",+ "emailLabel": "Email",+ "nameMatchTip": "Jira often hides email addresses, so assignees may be matched to people here by full name.",+ "openSettings": "Open Atlassian API tokens",+ "stepCreate": "Create an API token and copy it.",+ "stepOpen": "Open id.atlassian.com, then Security, then API tokens.",+ "stepPaste": "Paste it with the email you sign in to Jira with.",+ "tokenDescription": "Cloud: create one at id.atlassian.com. Data Center: use a personal access token.",+ "tokenLabel": "API token",+ "tokenPlaceholder": "Paste token",+ "urlDescription": "Copy it from your browser. Data Center works too.",+ "urlLabel": "Jira site URL",+ "urlPlaceholder": "https://your-site.atlassian.net"}}},diff --git a/i18n/hi-IN.json b/i18n/hi-IN.jsonindex 7eb9c6d03..8fbe29530 100644--- a/i18n/hi-IN.json+++ b/i18n/hi-IN.json@@ -2079,7 +2079,7 @@},"entry": {"createProjectLink": "Import your projects",- "createProjectPrompt": "Moving from Linear, Trello or Plane?",+ "createProjectPrompt": "Moving from Jira, Linear, Trello or Plane?","projectsEmpty": "Import from another tool"},"history": {@@ -2173,7 +2173,8 @@"inviteMembers": "Invite members","membersNote": "Assignees are matched to members of {{workspace}} by email. Invite your team first so their tasks stay assigned.","membersNoteTrello": "Assignees are matched to members of {{workspace}} by email, or by full name for Trello. Invite your team first so their tasks stay assigned.",- "selectAll": "Select all"+ "selectAll": "Select all",+ "membersNoteJira": "Assignees are matched to members of {{workspace}} by email, or by full name when Jira hides the email. Invite your team first so their tasks stay assigned."},"sources": {"connect": "Connect",@@ -2200,6 +2201,10 @@"trello": {"description": "Boards, lists, cards, checklists and comments. Authorize with one click.","intro": "Each Trello board becomes a project, with its lists as columns."+ },+ "jira": {+ "description": "Projects, issues, sub-tasks, links and comments. Cloud or Data Center.",+ "intro": "Each Jira project becomes a project here, with its workflow as columns."}},"status": {@@ -2293,6 +2298,21 @@"someImported_other": "{{done}} of {{count}} teams imported.","step": "Choose teams"}+ },+ "jira": {+ "emailDescription": "The email of your Atlassian account. Leave it empty for Jira Data Center.",+ "emailLabel": "Email",+ "nameMatchTip": "Jira often hides email addresses, so assignees may be matched to people here by full name.",+ "openSettings": "Open Atlassian API tokens",+ "stepCreate": "Create an API token and copy it.",+ "stepOpen": "Open id.atlassian.com, then Security, then API tokens.",+ "stepPaste": "Paste it with the email you sign in to Jira with.",+ "tokenDescription": "Cloud: create one at id.atlassian.com. Data Center: use a personal access token.",+ "tokenLabel": "API token",+ "tokenPlaceholder": "Paste token",+ "urlDescription": "Copy it from your browser. Data Center works too.",+ "urlLabel": "Jira site URL",+ "urlPlaceholder": "https://your-site.atlassian.net"}}},diff --git a/i18n/id-ID.json b/i18n/id-ID.jsonindex a6555f684..38c928da1 100644--- a/i18n/id-ID.json+++ b/i18n/id-ID.json@@ -2064,7 +2064,7 @@},"entry": {"createProjectLink": "Import your projects",- "createProjectPrompt": "Moving from Linear, Trello or Plane?",+ "createProjectPrompt": "Moving from Jira, Linear, Trello or Plane?","projectsEmpty": "Import from another tool"},"history": {@@ -2155,7 +2155,8 @@"inviteMembers": "Invite members","membersNote": "Assignees are matched to members of {{workspace}} by email. Invite your team first so their tasks stay assigned.","membersNoteTrello": "Assignees are matched to members of {{workspace}} by email, or by full name for Trello. Invite your team first so their tasks stay assigned.",- "selectAll": "Select all"+ "selectAll": "Select all",+ "membersNoteJira": "Assignees are matched to members of {{workspace}} by email, or by full name when Jira hides the email. Invite your team first so their tasks stay assigned."},"sources": {"connect": "Connect",@@ -2182,6 +2183,10 @@"trello": {"description": "Boards, lists, cards, checklists and comments. Authorize with one click.","intro": "Each Trello board becomes a project, with its lists as columns."+ },+ "jira": {+ "description": "Projects, issues, sub-tasks, links and comments. Cloud or Data Center.",+ "intro": "Each Jira project becomes a project here, with its workflow as columns."}},"status": {@@ -2256,6 +2261,21 @@"someImported_other": "{{done}} of {{count}} teams imported.","step": "Choose teams"}+ },+ "jira": {+ "emailDescription": "The email of your Atlassian account. Leave it empty for Jira Data Center.",+ "emailLabel": "Email",+ "nameMatchTip": "Jira often hides email addresses, so assignees may be matched to people here by full name.",+ "openSettings": "Open Atlassian API tokens",+ "stepCreate": "Create an API token and copy it.",+ "stepOpen": "Open id.atlassian.com, then Security, then API tokens.",+ "stepPaste": "Paste it with the email you sign in to Jira with.",+ "tokenDescription": "Cloud: create one at id.atlassian.com. Data Center: use a personal access token.",+ "tokenLabel": "API token",+ "tokenPlaceholder": "Paste token",+ "urlDescription": "Copy it from your browser. Data Center works too.",+ "urlLabel": "Jira site URL",+ "urlPlaceholder": "https://your-site.atlassian.net"}}},diff --git a/i18n/it-IT.json b/i18n/it-IT.jsonindex 8945e7c0c..9c766b239 100644--- a/i18n/it-IT.json+++ b/i18n/it-IT.json@@ -2094,7 +2094,7 @@},"entry": {"createProjectLink": "Import your projects",- "createProjectPrompt": "Moving from Linear, Trello or Plane?",+ "createProjectPrompt": "Moving from Jira, Linear, Trello or Plane?","projectsEmpty": "Import from another tool"},"history": {@@ -2191,7 +2191,8 @@"inviteMembers": "Invite members","membersNote": "Assignees are matched to members of {{workspace}} by email. Invite your team first so their tasks stay assigned.","membersNoteTrello": "Assignees are matched to members of {{workspace}} by email, or by full name for Trello. Invite your team first so their tasks stay assigned.",- "selectAll": "Select all"+ "selectAll": "Select all",+ "membersNoteJira": "Assignees are matched to members of {{workspace}} by email, or by full name when Jira hides the email. Invite your team first so their tasks stay assigned."},"sources": {"connect": "Connect",@@ -2218,6 +2219,10 @@"trello": {"description": "Boards, lists, cards, checklists and comments. Authorize with one click.","intro": "Each Trello board becomes a project, with its lists as columns."+ },+ "jira": {+ "description": "Projects, issues, sub-tasks, links and comments. Cloud or Data Center.",+ "intro": "Each Jira project becomes a project here, with its workflow as columns."}},"status": {@@ -2330,6 +2335,21 @@"someImported_other": "{{done}} of {{count}} teams imported.","step": "Choose teams"}+ },+ "jira": {+ "emailDescription": "The email of your Atlassian account. Leave it empty for Jira Data Center.",+ "emailLabel": "Email",+ "nameMatchTip": "Jira often hides email addresses, so assignees may be matched to people here by full name.",+ "openSettings": "Open Atlassian API tokens",+ "stepCreate": "Create an API token and copy it.",+ "stepOpen": "Open id.atlassian.com, then Security, then API tokens.",+ "stepPaste": "Paste it with the email you sign in to Jira with.",+ "tokenDescription": "Cloud: create one at id.atlassian.com. Data Center: use a personal access token.",+ "tokenLabel": "API token",+ "tokenPlaceholder": "Paste token",+ "urlDescription": "Copy it from your browser. Data Center works too.",+ "urlLabel": "Jira site URL",+ "urlPlaceholder": "https://your-site.atlassian.net"}}},diff --git a/i18n/ja-JP.json b/i18n/ja-JP.jsonindex bb449a68b..4ec3fc82b 100644--- a/i18n/ja-JP.json+++ b/i18n/ja-JP.json@@ -2064,7 +2064,7 @@},"entry": {"createProjectLink": "Import your projects",- "createProjectPrompt": "Moving from Linear, Trello or Plane?",+ "createProjectPrompt": "Moving from Jira, Linear, Trello or Plane?","projectsEmpty": "Import from another tool"},"history": {@@ -2155,7 +2155,8 @@"inviteMembers": "Invite members","membersNote": "Assignees are matched to members of {{workspace}} by email. Invite your team first so their tasks stay assigned.","membersNoteTrello": "Assignees are matched to members of {{workspace}} by email, or by full name for Trello. Invite your team first so their tasks stay assigned.",- "selectAll": "Select all"+ "selectAll": "Select all",+ "membersNoteJira": "Assignees are matched to members of {{workspace}} by email, or by full name when Jira hides the email. Invite your team first so their tasks stay assigned."},"sources": {"connect": "Connect",@@ -2182,6 +2183,10 @@"trello": {"description": "Boards, lists, cards, checklists and comments. Authorize with one click.","intro": "Each Trello board becomes a project, with its lists as columns."+ },+ "jira": {+ "description": "Projects, issues, sub-tasks, links and comments. Cloud or Data Center.",+ "intro": "Each Jira project becomes a project here, with its workflow as columns."}},"status": {@@ -2256,6 +2261,21 @@"someImported_other": "{{done}} of {{count}} teams imported.","step": "Choose teams"}+ },+ "jira": {+ "emailDescription": "The email of your Atlassian account. Leave it empty for Jira Data Center.",+ "emailLabel": "Email",+ "nameMatchTip": "Jira often hides email addresses, so assignees may be matched to people here by full name.",+ "openSettings": "Open Atlassian API tokens",+ "stepCreate": "Create an API token and copy it.",+ "stepOpen": "Open id.atlassian.com, then Security, then API tokens.",+ "stepPaste": "Paste it with the email you sign in to Jira with.",+ "tokenDescription": "Cloud: create one at id.atlassian.com. Data Center: use a personal access token.",+ "tokenLabel": "API token",+ "tokenPlaceholder": "Paste token",+ "urlDescription": "Copy it from your browser. Data Center works too.",+ "urlLabel": "Jira site URL",+ "urlPlaceholder": "https://your-site.atlassian.net"}}},diff --git a/i18n/ko-KR.json b/i18n/ko-KR.jsonindex e1bb9a092..d9d0804bb 100644--- a/i18n/ko-KR.json+++ b/i18n/ko-KR.json@@ -2064,7 +2064,7 @@},"entry": {"createProjectLink": "Import your projects",- "createProjectPrompt": "Moving from Linear, Trello or Plane?",+ "createProjectPrompt": "Moving from Jira, Linear, Trello or Plane?","projectsEmpty": "Import from another tool"},"history": {@@ -2155,7 +2155,8 @@"inviteMembers": "Invite members","membersNote": "Assignees are matched to members of {{workspace}} by email. Invite your team first so their tasks stay assigned.","membersNoteTrello": "Assignees are matched to members of {{workspace}} by email, or by full name for Trello. Invite your team first so their tasks stay assigned.",- "selectAll": "Select all"+ "selectAll": "Select all",+ "membersNoteJira": "Assignees are matched to members of {{workspace}} by email, or by full name when Jira hides the email. Invite your team first so their tasks stay assigned."},"sources": {"connect": "Connect",@@ -2182,6 +2183,10 @@"trello": {"description": "Boards, lists, cards, checklists and comments. Authorize with one click.","intro": "Each Trello board becomes a project, with its lists as columns."+ },+ "jira": {+ "description": "Projects, issues, sub-tasks, links and comments. Cloud or Data Center.",+ "intro": "Each Jira project becomes a project here, with its workflow as columns."}},"status": {@@ -2256,6 +2261,21 @@"someImported_other": "{{done}} of {{count}} teams imported.","step": "Choose teams"}+ },+ "jira": {+ "emailDescription": "The email of your Atlassian account. Leave it empty for Jira Data Center.",+ "emailLabel": "Email",+ "nameMatchTip": "Jira often hides email addresses, so assignees may be matched to people here by full name.",+ "openSettings": "Open Atlassian API tokens",+ "stepCreate": "Create an API token and copy it.",+ "stepOpen": "Open id.atlassian.com, then Security, then API tokens.",+ "stepPaste": "Paste it with the email you sign in to Jira with.",+ "tokenDescription": "Cloud: create one at id.atlassian.com. Data Center: use a personal access token.",+ "tokenLabel": "API token",+ "tokenPlaceholder": "Paste token",+ "urlDescription": "Copy it from your browser. Data Center works too.",+ "urlLabel": "Jira site URL",+ "urlPlaceholder": "https://your-site.atlassian.net"}}},diff --git a/i18n/mk-MK.json b/i18n/mk-MK.jsonindex 35033174c..82f324c55 100644--- a/i18n/mk-MK.json+++ b/i18n/mk-MK.json@@ -2079,7 +2079,7 @@},"entry": {"createProjectLink": "Import your projects",- "createProjectPrompt": "Moving from Linear, Trello or Plane?",+ "createProjectPrompt": "Moving from Jira, Linear, Trello or Plane?","projectsEmpty": "Import from another tool"},"history": {@@ -2173,7 +2173,8 @@"inviteMembers": "Invite members","membersNote": "Assignees are matched to members of {{workspace}} by email. Invite your team first so their tasks stay assigned.","membersNoteTrello": "Assignees are matched to members of {{workspace}} by email, or by full name for Trello. Invite your team first so their tasks stay assigned.",- "selectAll": "Select all"+ "selectAll": "Select all",+ "membersNoteJira": "Assignees are matched to members of {{workspace}} by email, or by full name when Jira hides the email. Invite your team first so their tasks stay assigned."},"sources": {"connect": "Connect",@@ -2200,6 +2201,10 @@"trello": {"description": "Boards, lists, cards, checklists and comments. Authorize with one click.","intro": "Each Trello board becomes a project, with its lists as columns."+ },+ "jira": {+ "description": "Projects, issues, sub-tasks, links and comments. Cloud or Data Center.",+ "intro": "Each Jira project becomes a project here, with its workflow as columns."}},"status": {@@ -2293,6 +2298,21 @@"someImported_other": "{{done}} of {{count}} teams imported.","step": "Choose teams"}+ },+ "jira": {+ "emailDescription": "The email of your Atlassian account. Leave it empty for Jira Data Center.",+ "emailLabel": "Email",+ "nameMatchTip": "Jira often hides email addresses, so assignees may be matched to people here by full name.",+ "openSettings": "Open Atlassian API tokens",+ "stepCreate": "Create an API token and copy it.",+ "stepOpen": "Open id.atlassian.com, then Security, then API tokens.",+ "stepPaste": "Paste it with the email you sign in to Jira with.",+ "tokenDescription": "Cloud: create one at id.atlassian.com. Data Center: use a personal access token.",+ "tokenLabel": "API token",+ "tokenPlaceholder": "Paste token",+ "urlDescription": "Copy it from your browser. Data Center works too.",+ "urlLabel": "Jira site URL",+ "urlPlaceholder": "https://your-site.atlassian.net"}}},diff --git a/i18n/nl-NL.json b/i18n/nl-NL.jsonindex 206ec33eb..529186112 100644--- a/i18n/nl-NL.json+++ b/i18n/nl-NL.json@@ -2079,7 +2079,7 @@},"entry": {"createProjectLink": "Import your projects",- "createProjectPrompt": "Moving from Linear, Trello or Plane?",+ "createProjectPrompt": "Moving from Jira, Linear, Trello or Plane?","projectsEmpty": "Import from another tool"},"history": {@@ -2173,7 +2173,8 @@"inviteMembers": "Invite members","membersNote": "Assignees are matched to members of {{workspace}} by email. Invite your team first so their tasks stay assigned.","membersNoteTrello": "Assignees are matched to members of {{workspace}} by email, or by full name for Trello. Invite your team first so their tasks stay assigned.",- "selectAll": "Select all"+ "selectAll": "Select all",+ "membersNoteJira": "Assignees are matched to members of {{workspace}} by email, or by full name when Jira hides the email. Invite your team first so their tasks stay assigned."},"sources": {"connect": "Connect",@@ -2200,6 +2201,10 @@"trello": {"description": "Boards, lists, cards, checklists and comments. Authorize with one click.","intro": "Each Trello board becomes a project, with its lists as columns."+ },+ "jira": {+ "description": "Projects, issues, sub-tasks, links and comments. Cloud or Data Center.",+ "intro": "Each Jira project becomes a project here, with its workflow as columns."}},"status": {@@ -2293,6 +2298,21 @@"someImported_other": "{{done}} of {{count}} teams imported.","step": "Choose teams"}+ },+ "jira": {+ "emailDescription": "The email of your Atlassian account. Leave it empty for Jira Data Center.",+ "emailLabel": "Email",+ "nameMatchTip": "Jira often hides email addresses, so assignees may be matched to people here by full name.",+ "openSettings": "Open Atlassian API tokens",+ "stepCreate": "Create an API token and copy it.",+ "stepOpen": "Open id.atlassian.com, then Security, then API tokens.",+ "stepPaste": "Paste it with the email you sign in to Jira with.",+ "tokenDescription": "Cloud: create one at id.atlassian.com. Data Center: use a personal access token.",+ "tokenLabel": "API token",+ "tokenPlaceholder": "Paste token",+ "urlDescription": "Copy it from your browser. Data Center works too.",+ "urlLabel": "Jira site URL",+ "urlPlaceholder": "https://your-site.atlassian.net"}}},diff --git a/i18n/pl-PL.json b/i18n/pl-PL.jsonindex cb071d788..921a72872 100644--- a/i18n/pl-PL.json+++ b/i18n/pl-PL.json@@ -2706,7 +2706,7 @@},"entry": {"createProjectLink": "Import your projects",- "createProjectPrompt": "Moving from Linear, Trello or Plane?",+ "createProjectPrompt": "Moving from Jira, Linear, Trello or Plane?","projectsEmpty": "Import from another tool"},"history": {@@ -2806,7 +2806,8 @@"inviteMembers": "Invite members","membersNote": "Assignees are matched to members of {{workspace}} by email. Invite your team first so their tasks stay assigned.","membersNoteTrello": "Assignees are matched to members of {{workspace}} by email, or by full name for Trello. Invite your team first so their tasks stay assigned.",- "selectAll": "Select all"+ "selectAll": "Select all",+ "membersNoteJira": "Assignees are matched to members of {{workspace}} by email, or by full name when Jira hides the email. Invite your team first so their tasks stay assigned."},"sources": {"connect": "Connect",@@ -2833,6 +2834,10 @@"trello": {"description": "Boards, lists, cards, checklists and comments. Authorize with one click.","intro": "Each Trello board becomes a project, with its lists as columns."+ },+ "jira": {+ "description": "Projects, issues, sub-tasks, links and comments. Cloud or Data Center.",+ "intro": "Each Jira project becomes a project here, with its workflow as columns."}},"status": {@@ -2964,6 +2969,21 @@"someImported_other": "{{done}} of {{count}} teams imported.","step": "Choose teams"}+ },+ "jira": {+ "emailDescription": "The email of your Atlassian account. Leave it empty for Jira Data Center.",+ "emailLabel": "Email",+ "nameMatchTip": "Jira often hides email addresses, so assignees may be matched to people here by full name.",+ "openSettings": "Open Atlassian API tokens",+ "stepCreate": "Create an API token and copy it.",+ "stepOpen": "Open id.atlassian.com, then Security, then API tokens.",+ "stepPaste": "Paste it with the email you sign in to Jira with.",+ "tokenDescription": "Cloud: create one at id.atlassian.com. Data Center: use a personal access token.",+ "tokenLabel": "API token",+ "tokenPlaceholder": "Paste token",+ "urlDescription": "Copy it from your browser. Data Center works too.",+ "urlLabel": "Jira site URL",+ "urlPlaceholder": "https://your-site.atlassian.net"}}},diff --git a/i18n/pt-BR.json b/i18n/pt-BR.jsonindex f5dd7f85e..9e1e16f31 100644--- a/i18n/pt-BR.json+++ b/i18n/pt-BR.json@@ -2094,7 +2094,7 @@},"entry": {"createProjectLink": "Import your projects",- "createProjectPrompt": "Moving from Linear, Trello or Plane?",+ "createProjectPrompt": "Moving from Jira, Linear, Trello or Plane?","projectsEmpty": "Import from another tool"},"history": {@@ -2191,7 +2191,8 @@"inviteMembers": "Invite members","membersNote": "Assignees are matched to members of {{workspace}} by email. Invite your team first so their tasks stay assigned.","membersNoteTrello": "Assignees are matched to members of {{workspace}} by email, or by full name for Trello. Invite your team first so their tasks stay assigned.",- "selectAll": "Select all"+ "selectAll": "Select all",+ "membersNoteJira": "Assignees are matched to members of {{workspace}} by email, or by full name when Jira hides the email. Invite your team first so their tasks stay assigned."},"sources": {"connect": "Connect",@@ -2218,6 +2219,10 @@"trello": {"description": "Boards, lists, cards, checklists and comments. Authorize with one click.","intro": "Each Trello board becomes a project, with its lists as columns."+ },+ "jira": {+ "description": "Projects, issues, sub-tasks, links and comments. Cloud or Data Center.",+ "intro": "Each Jira project becomes a project here, with its workflow as columns."}},"status": {@@ -2330,6 +2335,21 @@"someImported_other": "{{done}} of {{count}} teams imported.","step": "Choose teams"}+ },+ "jira": {+ "emailDescription": "The email of your Atlassian account. Leave it empty for Jira Data Center.",+ "emailLabel": "Email",+ "nameMatchTip": "Jira often hides email addresses, so assignees may be matched to people here by full name.",+ "openSettings": "Open Atlassian API tokens",+ "stepCreate": "Create an API token and copy it.",+ "stepOpen": "Open id.atlassian.com, then Security, then API tokens.",+ "stepPaste": "Paste it with the email you sign in to Jira with.",+ "tokenDescription": "Cloud: create one at id.atlassian.com. Data Center: use a personal access token.",+ "tokenLabel": "API token",+ "tokenPlaceholder": "Paste token",+ "urlDescription": "Copy it from your browser. Data Center works too.",+ "urlLabel": "Jira site URL",+ "urlPlaceholder": "https://your-site.atlassian.net"}}},diff --git a/i18n/ru-RU.json b/i18n/ru-RU.jsonindex 6dac9d21b..84089c31b 100644--- a/i18n/ru-RU.json+++ b/i18n/ru-RU.json@@ -2117,7 +2117,7 @@},"entry": {"createProjectLink": "Import your projects",- "createProjectPrompt": "Moving from Linear, Trello or Plane?",+ "createProjectPrompt": "Moving from Jira, Linear, Trello or Plane?","projectsEmpty": "Import from another tool"},"history": {@@ -2217,7 +2217,8 @@"inviteMembers": "Invite members","membersNote": "Assignees are matched to members of {{workspace}} by email. Invite your team first so their tasks stay assigned.","membersNoteTrello": "Assignees are matched to members of {{workspace}} by email, or by full name for Trello. Invite your team first so their tasks stay assigned.",- "selectAll": "Select all"+ "selectAll": "Select all",+ "membersNoteJira": "Assignees are matched to members of {{workspace}} by email, or by full name when Jira hides the email. Invite your team first so their tasks stay assigned."},"sources": {"connect": "Connect",@@ -2244,6 +2245,10 @@"trello": {"description": "Boards, lists, cards, checklists and comments. Authorize with one click.","intro": "Each Trello board becomes a project, with its lists as columns."+ },+ "jira": {+ "description": "Projects, issues, sub-tasks, links and comments. Cloud or Data Center.",+ "intro": "Each Jira project becomes a project here, with its workflow as columns."}},"status": {@@ -2375,6 +2380,21 @@"someImported_other": "{{done}} of {{count}} teams imported.","step": "Choose teams"}+ },+ "jira": {+ "emailDescription": "The email of your Atlassian account. Leave it empty for Jira Data Center.",+ "emailLabel": "Email",+ "nameMatchTip": "Jira often hides email addresses, so assignees may be matched to people here by full name.",+ "openSettings": "Open Atlassian API tokens",+ "stepCreate": "Create an API token and copy it.",+ "stepOpen": "Open id.atlassian.com, then Security, then API tokens.",+ "stepPaste": "Paste it with the email you sign in to Jira with.",+ "tokenDescription": "Cloud: create one at id.atlassian.com. Data Center: use a personal access token.",+ "tokenLabel": "API token",+ "tokenPlaceholder": "Paste token",+ "urlDescription": "Copy it from your browser. Data Center works too.",+ "urlLabel": "Jira site URL",+ "urlPlaceholder": "https://your-site.atlassian.net"}}},diff --git a/i18n/schema.json b/i18n/schema.jsonindex 11fd91e94..a41c2157a 100644--- a/i18n/schema.json+++ b/i18n/schema.json@@ -4839,6 +4839,19 @@},"required": ["description", "intro"]},+ "jira": {+ "type": "object",+ "additionalProperties": false,+ "properties": {+ "description": {+ "type": "string"+ },+ "intro": {+ "type": "string"+ }+ },+ "required": ["description", "intro"]+ },"trello": {"type": "object","additionalProperties": false,@@ -4901,6 +4914,7 @@"connect","connectTo","linear",+ "jira","trello","plane","planka",@@ -5079,6 +5093,66 @@"stepPaste"]},+ "jira": {+ "type": "object",+ "additionalProperties": false,+ "properties": {+ "urlLabel": {+ "type": "string"+ },+ "urlDescription": {+ "type": "string"+ },+ "urlPlaceholder": {+ "type": "string"+ },+ "emailLabel": {+ "type": "string"+ },+ "emailDescription": {+ "type": "string"+ },+ "tokenLabel": {+ "type": "string"+ },+ "tokenDescription": {+ "type": "string"+ },+ "tokenPlaceholder": {+ "type": "string"+ },+ "openSettings": {+ "type": "string"+ },+ "stepOpen": {+ "type": "string"+ },+ "stepCreate": {+ "type": "string"+ },+ "stepPaste": {+ "type": "string"+ },+ "nameMatchTip": {+ "type": "string"+ }+ },+ "required": [+ "urlLabel",+ "urlDescription",+ "urlPlaceholder",+ "emailLabel",+ "emailDescription",+ "tokenLabel",+ "tokenDescription",+ "tokenPlaceholder",+ "openSettings",+ "stepOpen",+ "stepCreate",+ "stepPaste",+ "nameMatchTip"+ ]+ },"trello": {"type": "object","additionalProperties": false,@@ -5272,6 +5346,9 @@"membersNoteTrello": {"type": "string"},+ "membersNoteJira": {+ "type": "string"+ },"inviteMembers": {"type": "string"}@@ -5284,6 +5361,7 @@"commentsDescription","membersNote","membersNoteTrello",+ "membersNoteJira","inviteMembers"]},@@ -5968,6 +6046,7 @@"back","connect","linear",+ "jira","trello","plane","planka",diff --git a/i18n/tr-TR.json b/i18n/tr-TR.jsonindex bbc84b47a..5502009e4 100644--- a/i18n/tr-TR.json+++ b/i18n/tr-TR.json@@ -2079,7 +2079,7 @@},"entry": {"createProjectLink": "Import your projects",- "createProjectPrompt": "Moving from Linear, Trello or Plane?",+ "createProjectPrompt": "Moving from Jira, Linear, Trello or Plane?","projectsEmpty": "Import from another tool"},"history": {@@ -2173,7 +2173,8 @@"inviteMembers": "Invite members","membersNote": "Assignees are matched to members of {{workspace}} by email. Invite your team first so their tasks stay assigned.","membersNoteTrello": "Assignees are matched to members of {{workspace}} by email, or by full name for Trello. Invite your team first so their tasks stay assigned.",- "selectAll": "Select all"+ "selectAll": "Select all",+ "membersNoteJira": "Assignees are matched to members of {{workspace}} by email, or by full name when Jira hides the email. Invite your team first so their tasks stay assigned."},"sources": {"connect": "Connect",@@ -2200,6 +2201,10 @@"trello": {"description": "Boards, lists, cards, checklists and comments. Authorize with one click.","intro": "Each Trello board becomes a project, with its lists as columns."+ },+ "jira": {+ "description": "Projects, issues, sub-tasks, links and comments. Cloud or Data Center.",+ "intro": "Each Jira project becomes a project here, with its workflow as columns."}},"status": {@@ -2293,6 +2298,21 @@"someImported_other": "{{done}} of {{count}} teams imported.","step": "Choose teams"}+ },+ "jira": {+ "emailDescription": "The email of your Atlassian account. Leave it empty for Jira Data Center.",+ "emailLabel": "Email",+ "nameMatchTip": "Jira often hides email addresses, so assignees may be matched to people here by full name.",+ "openSettings": "Open Atlassian API tokens",+ "stepCreate": "Create an API token and copy it.",+ "stepOpen": "Open id.atlassian.com, then Security, then API tokens.",+ "stepPaste": "Paste it with the email you sign in to Jira with.",+ "tokenDescription": "Cloud: create one at id.atlassian.com. Data Center: use a personal access token.",+ "tokenLabel": "API token",+ "tokenPlaceholder": "Paste token",+ "urlDescription": "Copy it from your browser. Data Center works too.",+ "urlLabel": "Jira site URL",+ "urlPlaceholder": "https://your-site.atlassian.net"}}},diff --git a/i18n/uk-UA.json b/i18n/uk-UA.jsonindex 4391c7773..147277982 100644--- a/i18n/uk-UA.json+++ b/i18n/uk-UA.json@@ -2109,7 +2109,7 @@},"entry": {"createProjectLink": "Import your projects",- "createProjectPrompt": "Moving from Linear, Trello or Plane?",+ "createProjectPrompt": "Moving from Jira, Linear, Trello or Plane?","projectsEmpty": "Import from another tool"},"history": {@@ -2209,7 +2209,8 @@"inviteMembers": "Invite members","membersNote": "Assignees are matched to members of {{workspace}} by email. Invite your team first so their tasks stay assigned.","membersNoteTrello": "Assignees are matched to members of {{workspace}} by email, or by full name for Trello. Invite your team first so their tasks stay assigned.",- "selectAll": "Select all"+ "selectAll": "Select all",+ "membersNoteJira": "Assignees are matched to members of {{workspace}} by email, or by full name when Jira hides the email. Invite your team first so their tasks stay assigned."},"sources": {"connect": "Connect",@@ -2236,6 +2237,10 @@"trello": {"description": "Boards, lists, cards, checklists and comments. Authorize with one click.","intro": "Each Trello board becomes a project, with its lists as columns."+ },+ "jira": {+ "description": "Projects, issues, sub-tasks, links and comments. Cloud or Data Center.",+ "intro": "Each Jira project becomes a project here, with its workflow as columns."}},"status": {@@ -2367,6 +2372,21 @@"someImported_other": "{{done}} of {{count}} teams imported.","step": "Choose teams"}+ },+ "jira": {+ "emailDescription": "The email of your Atlassian account. Leave it empty for Jira Data Center.",+ "emailLabel": "Email",+ "nameMatchTip": "Jira often hides email addresses, so assignees may be matched to people here by full name.",+ "openSettings": "Open Atlassian API tokens",+ "stepCreate": "Create an API token and copy it.",+ "stepOpen": "Open id.atlassian.com, then Security, then API tokens.",+ "stepPaste": "Paste it with the email you sign in to Jira with.",+ "tokenDescription": "Cloud: create one at id.atlassian.com. Data Center: use a personal access token.",+ "tokenLabel": "API token",+ "tokenPlaceholder": "Paste token",+ "urlDescription": "Copy it from your browser. Data Center works too.",+ "urlLabel": "Jira site URL",+ "urlPlaceholder": "https://your-site.atlassian.net"}}},diff --git a/i18n/vi-VN.json b/i18n/vi-VN.jsonindex 0886a2e16..23264a718 100644--- a/i18n/vi-VN.json+++ b/i18n/vi-VN.json@@ -2064,7 +2064,7 @@},"entry": {"createProjectLink": "Import your projects",- "createProjectPrompt": "Moving from Linear, Trello or Plane?",+ "createProjectPrompt": "Moving from Jira, Linear, Trello or Plane?","projectsEmpty": "Import from another tool"},"history": {@@ -2155,7 +2155,8 @@"inviteMembers": "Invite members","membersNote": "Assignees are matched to members of {{workspace}} by email. Invite your team first so their tasks stay assigned.","membersNoteTrello": "Assignees are matched to members of {{workspace}} by email, or by full name for Trello. Invite your team first so their tasks stay assigned.",- "selectAll": "Select all"+ "selectAll": "Select all",+ "membersNoteJira": "Assignees are matched to members of {{workspace}} by email, or by full name when Jira hides the email. Invite your team first so their tasks stay assigned."},"sources": {"connect": "Connect",@@ -2182,6 +2183,10 @@"trello": {"description": "Boards, lists, cards, checklists and comments. Authorize with one click.","intro": "Each Trello board becomes a project, with its lists as columns."+ },+ "jira": {+ "description": "Projects, issues, sub-tasks, links and comments. Cloud or Data Center.",+ "intro": "Each Jira project becomes a project here, with its workflow as columns."}},"status": {@@ -2256,6 +2261,21 @@"someImported_other": "{{done}} of {{count}} teams imported.","step": "Choose teams"}+ },+ "jira": {+ "emailDescription": "The email of your Atlassian account. Leave it empty for Jira Data Center.",+ "emailLabel": "Email",+ "nameMatchTip": "Jira often hides email addresses, so assignees may be matched to people here by full name.",+ "openSettings": "Open Atlassian API tokens",+ "stepCreate": "Create an API token and copy it.",+ "stepOpen": "Open id.atlassian.com, then Security, then API tokens.",+ "stepPaste": "Paste it with the email you sign in to Jira with.",+ "tokenDescription": "Cloud: create one at id.atlassian.com. Data Center: use a personal access token.",+ "tokenLabel": "API token",+ "tokenPlaceholder": "Paste token",+ "urlDescription": "Copy it from your browser. Data Center works too.",+ "urlLabel": "Jira site URL",+ "urlPlaceholder": "https://your-site.atlassian.net"}}},diff --git a/i18n/zh-CN.json b/i18n/zh-CN.jsonindex 09a99ca0c..4b6f428f8 100644--- a/i18n/zh-CN.json+++ b/i18n/zh-CN.json@@ -2064,7 +2064,7 @@},"entry": {"createProjectLink": "Import your projects",- "createProjectPrompt": "Moving from Linear, Trello or Plane?",+ "createProjectPrompt": "Moving from Jira, Linear, Trello or Plane?","projectsEmpty": "Import from another tool"},"history": {@@ -2155,7 +2155,8 @@"inviteMembers": "Invite members","membersNote": "Assignees are matched to members of {{workspace}} by email. Invite your team first so their tasks stay assigned.","membersNoteTrello": "Assignees are matched to members of {{workspace}} by email, or by full name for Trello. Invite your team first so their tasks stay assigned.",- "selectAll": "Select all"+ "selectAll": "Select all",+ "membersNoteJira": "Assignees are matched to members of {{workspace}} by email, or by full name when Jira hides the email. Invite your team first so their tasks stay assigned."},"sources": {"connect": "Connect",@@ -2182,6 +2183,10 @@"trello": {"description": "Boards, lists, cards, checklists and comments. Authorize with one click.","intro": "Each Trello board becomes a project, with its lists as columns."+ },+ "jira": {+ "description": "Projects, issues, sub-tasks, links and comments. Cloud or Data Center.",+ "intro": "Each Jira project becomes a project here, with its workflow as columns."}},"status": {@@ -2256,6 +2261,21 @@"someImported_other": "{{done}} of {{count}} teams imported.","step": "Choose teams"}+ },+ "jira": {+ "emailDescription": "The email of your Atlassian account. Leave it empty for Jira Data Center.",+ "emailLabel": "Email",+ "nameMatchTip": "Jira often hides email addresses, so assignees may be matched to people here by full name.",+ "openSettings": "Open Atlassian API tokens",+ "stepCreate": "Create an API token and copy it.",+ "stepOpen": "Open id.atlassian.com, then Security, then API tokens.",+ "stepPaste": "Paste it with the email you sign in to Jira with.",+ "tokenDescription": "Cloud: create one at id.atlassian.com. Data Center: use a personal access token.",+ "tokenLabel": "API token",+ "tokenPlaceholder": "Paste token",+ "urlDescription": "Copy it from your browser. Data Center works too.",+ "urlLabel": "Jira site URL",+ "urlPlaceholder": "https://your-site.atlassian.net"}}},diff --git a/i18n/zh-TW.json b/i18n/zh-TW.jsonindex ea226935e..d04737fac 100644--- a/i18n/zh-TW.json+++ b/i18n/zh-TW.json@@ -2064,7 +2064,7 @@},"entry": {"createProjectLink": "Import your projects",- "createProjectPrompt": "Moving from Linear, Trello or Plane?",+ "createProjectPrompt": "Moving from Jira, Linear, Trello or Plane?","projectsEmpty": "Import from another tool"},"history": {@@ -2155,7 +2155,8 @@"inviteMembers": "Invite members","membersNote": "Assignees are matched to members of {{workspace}} by email. Invite your team first so their tasks stay assigned.","membersNoteTrello": "Assignees are matched to members of {{workspace}} by email, or by full name for Trello. Invite your team first so their tasks stay assigned.",- "selectAll": "Select all"+ "selectAll": "Select all",+ "membersNoteJira": "Assignees are matched to members of {{workspace}} by email, or by full name when Jira hides the email. Invite your team first so their tasks stay assigned."},"sources": {"connect": "Connect",@@ -2182,6 +2183,10 @@"trello": {"description": "Boards, lists, cards, checklists and comments. Authorize with one click.","intro": "Each Trello board becomes a project, with its lists as columns."+ },+ "jira": {+ "description": "Projects, issues, sub-tasks, links and comments. Cloud or Data Center.",+ "intro": "Each Jira project becomes a project here, with its workflow as columns."}},"status": {@@ -2256,6 +2261,21 @@"someImported_other": "{{done}} of {{count}} teams imported.","step": "Choose teams"}+ },+ "jira": {+ "emailDescription": "The email of your Atlassian account. Leave it empty for Jira Data Center.",+ "emailLabel": "Email",+ "nameMatchTip": "Jira often hides email addresses, so assignees may be matched to people here by full name.",+ "openSettings": "Open Atlassian API tokens",+ "stepCreate": "Create an API token and copy it.",+ "stepOpen": "Open id.atlassian.com, then Security, then API tokens.",+ "stepPaste": "Paste it with the email you sign in to Jira with.",+ "tokenDescription": "Cloud: create one at id.atlassian.com. Data Center: use a personal access token.",+ "tokenLabel": "API token",+ "tokenPlaceholder": "Paste token",+ "urlDescription": "Copy it from your browser. Data Center works too.",+ "urlLabel": "Jira site URL",+ "urlPlaceholder": "https://your-site.atlassian.net"}}},diff --git a/packages/importers/package.json b/packages/importers/package.jsonindex f265dc3f5..c1c4d2acf 100644--- a/packages/importers/package.json+++ b/packages/importers/package.json@@ -2,7 +2,7 @@"name": "@kaneo/importers","version": "0.0.0","private": true,- "description": "Read projects from PLANKA, Plane, Linear, Trello and other Kaneo instances into one import model",+ "description": "Read projects from PLANKA, Plane, Linear, Jira, Trello and other Kaneo instances into one import model","type": "module","main": "./dist/index.js","types": "./dist/index.d.ts",diff --git a/packages/importers/src/index.ts b/packages/importers/src/index.tsindex 828aa9d42..3619b692c 100644--- a/packages/importers/src/index.ts+++ b/packages/importers/src/index.ts@@ -1,3 +1,4 @@+import { connectJira, type JiraCredentials } from "./jira/index.js";import { connectKaneo, type KaneoCredentials } from "./kaneo/index.js";import { connectLinear, type LinearCredentials } from "./linear/index.js";import { connectPlane, type PlaneCredentials } from "./plane/index.js";@@ -6,6 +7,7 @@ import { connectTrello, type TrelloCredentials } from "./trello/index.js";import type { ConnectOptions, ImportSource } from "./types.js";export { normalizeBaseUrl, SourceHttpError } from "./http.js";+export { type JiraSite, parseJiraUrl } from "./jira/index.js";export {SOURCE_PROJECT_KEY_MAX,sanitizeProjectKey,@@ -15,6 +17,7 @@ export {export { trelloAuthorizeUrl } from "./trello/index.js";export type * from "./types.js";export type {+ JiraCredentials,KaneoCredentials,LinearCredentials,PlaneCredentials,@@ -26,6 +29,7 @@ export const IMPORT_SOURCE_IDS = ["planka","plane","linear",+ "jira","trello","kaneo",] as const;@@ -36,6 +40,7 @@ export type ImportCredentials = {planka: PlankaCredentials;plane: PlaneCredentials;linear: LinearCredentials;+ jira: JiraCredentials;trello: TrelloCredentials;kaneo: KaneoCredentials;};@@ -55,6 +60,8 @@ export function connectSource(return connectPlane(connection, options);case "linear":return connectLinear(connection, options);+ case "jira":+ return connectJira(connection, options);case "trello":return connectTrello(connection, options);case "kaneo":diff --git a/packages/importers/src/jira/api-types.ts b/packages/importers/src/jira/api-types.tsnew file mode 100644index 000000000..589afcb53--- /dev/null+++ b/packages/importers/src/jira/api-types.ts@@ -0,0 +1,119 @@+export type JiraUser = {+ accountId?: string | null;+ key?: string | null;+ name?: string | null;+ displayName?: string | null;+ emailAddress?: string | null;+};++export type JiraStatusCategory = {+ key?: string | null;+};++export type JiraStatus = {+ id: string;+ name?: string | null;+ statusCategory?: JiraStatusCategory | null;+};++export type JiraIssueTypeStatuses = {+ id?: string;+ name?: string | null;+ statuses?: JiraStatus[] | null;+};++export type JiraProject = {+ id: string;+ key: string;+ name: string;+ description?: string | null;+ projectTypeKey?: string | null;+};++export type JiraProjectPage = {+ values?: JiraProject[] | null;+ isLast?: boolean | null;+};++export type JiraBoard = {+ id: number;+ name?: string | null;+ type?: string | null;+ location?: { projectKey?: string | null } | null;+};++export type JiraBoardPage = {+ values?: JiraBoard[] | null;+};++export type JiraBoardColumn = {+ name?: string | null;+ statuses?: Array<{ id: string }> | null;+};++export type JiraBoardConfiguration = {+ columnConfig?: { columns?: JiraBoardColumn[] | null } | null;+};++export type JiraLinkedIssue = {+ id: string;+ key?: string | null;+};++export type JiraIssueLink = {+ type?: {+ name?: string | null;+ inward?: string | null;+ outward?: string | null;+ } | null;+ inwardIssue?: JiraLinkedIssue | null;+ outwardIssue?: JiraLinkedIssue | null;+};++export type JiraIssueFields = {+ summary?: string | null;+ description?: unknown;+ status?: JiraStatus | null;+ priority?: { name?: string | null } | null;+ assignee?: JiraUser | null;+ labels?: string[] | null;+ duedate?: string | null;+ created?: string | null;+ parent?: JiraLinkedIssue | null;+ issuelinks?: JiraIssueLink[] | null;+ attachment?: unknown[] | null;+ comment?: { total?: number | null } | null;+};++export type JiraIssue = {+ id: string;+ key: string;+ fields?: JiraIssueFields | null;+ renderedFields?: { description?: string | null } | null;+};++export type JiraCloudSearchPage = {+ issues?: JiraIssue[] | null;+ nextPageToken?: string | null;+ isLast?: boolean | null;+};++export type JiraServerSearchPage = {+ issues?: JiraIssue[] | null;+ startAt?: number | null;+ total?: number | null;+};++export type JiraComment = {+ id?: string;+ author?: JiraUser | null;+ body?: unknown;+ renderedBody?: string | null;+ created?: string | null;+};++export type JiraCommentPage = {+ comments?: JiraComment[] | null;+ startAt?: number | null;+ total?: number | null;+};diff --git a/packages/importers/src/jira/auth.test.ts b/packages/importers/src/jira/auth.test.tsnew file mode 100644index 000000000..713416506--- /dev/null+++ b/packages/importers/src/jira/auth.test.ts@@ -0,0 +1,71 @@+import { describe, expect, it } from "vite-plus/test";+import {+ basicAuthorization,+ CLOUD_REJECTED_MESSAGE,+ MISSING_CLOUD_TOKEN_MESSAGE,+ MISSING_EMAIL_MESSAGE,+ MISSING_SERVER_TOKEN_MESSAGE,+ resolveJiraAuth,+ SERVER_REJECTED_MESSAGE,+} from "./auth.js";++const CLOUD = { baseUrl: "https://acme.atlassian.net", cloud: true };+const SERVER = { baseUrl: "https://jira.example.com", cloud: false };++describe("resolveJiraAuth", () => {+ it("uses Basic auth with the email and API token on Jira Cloud", () => {+ expect(+ resolveJiraAuth(CLOUD, {+ email: " [email protected] ",+ apiToken: " token-1 ",+ }),+ ).toEqual({+ apiVersion: "3",+ authorization: `Basic ${Buffer.from("[email protected]:token-1").toString("base64")}`,+ rejectedMessage: CLOUD_REJECTED_MESSAGE,+ });+ });++ it("needs the Atlassian account email on Jira Cloud", () => {+ expect(() => resolveJiraAuth(CLOUD, { apiToken: "token-1" })).toThrow(+ MISSING_EMAIL_MESSAGE,+ );+ expect(() =>+ resolveJiraAuth(CLOUD, { email: " ", apiToken: "token-1" }),+ ).toThrow(MISSING_EMAIL_MESSAGE);+ });++ it("sends a personal access token as a bearer on Data Center", () => {+ expect(resolveJiraAuth(SERVER, { apiToken: " pat-1 " })).toEqual({+ apiVersion: "2",+ authorization: "Bearer pat-1",+ rejectedMessage: SERVER_REJECTED_MESSAGE,+ });+ });++ it("uses Basic auth on Data Center when an email is given", () => {+ expect(+ resolveJiraAuth(SERVER, { email: "fred", apiToken: "secret" }),+ ).toMatchObject({+ apiVersion: "2",+ authorization: `Basic ${Buffer.from("fred:secret").toString("base64")}`,+ });+ });++ it("asks for a token before anything else", () => {+ expect(() => resolveJiraAuth(CLOUD, { email: "[email protected]" })).toThrow(+ MISSING_CLOUD_TOKEN_MESSAGE,+ );+ expect(() => resolveJiraAuth(SERVER, { apiToken: " " })).toThrow(+ MISSING_SERVER_TOKEN_MESSAGE,+ );+ });+});++describe("basicAuthorization", () => {+ it("encodes non-ASCII credentials as UTF-8", () => {+ expect(basicAuthorization("zoë@example.com", "pässword")).toBe(+ `Basic ${Buffer.from("zoë@example.com:pässword", "utf8").toString("base64")}`,+ );+ });+});diff --git a/packages/importers/src/jira/auth.ts b/packages/importers/src/jira/auth.tsnew file mode 100644index 000000000..a2d425a13--- /dev/null+++ b/packages/importers/src/jira/auth.ts@@ -0,0 +1,62 @@+import type { JiraSite } from "./url.js";++export type JiraApiVersion = "2" | "3";++export type JiraAuth = {+ apiVersion: JiraApiVersion;+ authorization: string;+ rejectedMessage: string;+};++export type JiraAuthInput = {+ email?: string | null;+ apiToken?: string | null;+};++export const MISSING_EMAIL_MESSAGE =+ "Add the email address of your Atlassian account.";++export const MISSING_CLOUD_TOKEN_MESSAGE =+ "Add an Atlassian API token. Create one at id.atlassian.com.";++export const MISSING_SERVER_TOKEN_MESSAGE =+ "Add a Jira personal access token. Create one under your Jira profile > Personal Access Tokens.";++export const CLOUD_REJECTED_MESSAGE =+ "Jira rejected the email and API token. Create an API token at id.atlassian.com and try again.";++export const SERVER_REJECTED_MESSAGE =+ "Jira rejected the personal access token.";++export function resolveJiraAuth(+ site: JiraSite,+ input: JiraAuthInput,+): JiraAuth {+ const token = input.apiToken?.trim();+ const email = input.email?.trim();++ if (site.cloud) {+ if (!token) throw new Error(MISSING_CLOUD_TOKEN_MESSAGE);+ if (!email) throw new Error(MISSING_EMAIL_MESSAGE);+ return {+ apiVersion: "3",+ authorization: basicAuthorization(email, token),+ rejectedMessage: CLOUD_REJECTED_MESSAGE,+ };+ }++ if (!token) throw new Error(MISSING_SERVER_TOKEN_MESSAGE);+ return {+ apiVersion: "2",+ authorization: email ? basicAuthorization(email, token) : `Bearer ${token}`,+ rejectedMessage: SERVER_REJECTED_MESSAGE,+ };+}++export function basicAuthorization(user: string, secret: string): string {+ let binary = "";+ for (const byte of new TextEncoder().encode(`${user}:${secret}`)) {+ binary += String.fromCharCode(byte);+ }+ return `Basic ${btoa(binary)}`;+}diff --git a/packages/importers/src/jira/board.test.ts b/packages/importers/src/jira/board.test.tsnew file mode 100644index 000000000..01705583f--- /dev/null+++ b/packages/importers/src/jira/board.test.ts@@ -0,0 +1,21 @@+import { describe, expect, it } from "vite-plus/test";+import { pickBoard } from "./board.js";++describe("pickBoard", () => {+ it("prefers the board that lives in the project", () => {+ expect(+ pickBoard(+ [+ { id: 1, location: { projectKey: "OPS" } },+ { id: 2, location: { projectKey: "abc" } },+ ],+ "ABC",+ )?.id,+ ).toBe(2);+ });++ it("falls back to the first board and handles no boards", () => {+ expect(pickBoard([{ id: 5 }, { id: 6 }], "ABC")?.id).toBe(5);+ expect(pickBoard([], "ABC")).toBeUndefined();+ });+});diff --git a/packages/importers/src/jira/board.ts b/packages/importers/src/jira/board.tsnew file mode 100644index 000000000..5601755a4--- /dev/null+++ b/packages/importers/src/jira/board.ts@@ -0,0 +1,55 @@+import { SourceHttpError } from "../http.js";+import type { JiraBoard, JiraBoardColumn } from "./api-types.js";+import type { JiraClient } from "./client.js";++export type BoardRead = {+ columns: JiraBoardColumn[] | null;+ unavailable: boolean;+};++const NO_BOARD_ACCESS = new Set([401, 403, 404]);++export async function readBoardColumns(+ client: JiraClient,+ projectKey: string,+): Promise<BoardRead> {+ let boards: JiraBoard[];+ try {+ boards = (await client.boards(projectKey))?.values ?? [];+ } catch (error) {+ const status = deniedStatus(error);+ if (status === undefined) throw error;+ return { columns: null, unavailable: status !== 404 };+ }++ const board = pickBoard(boards, projectKey);+ if (!board) return { columns: null, unavailable: false };++ try {+ const config = await client.boardConfiguration(board.id);+ const columns = config?.columnConfig?.columns;+ return columns?.length+ ? { columns, unavailable: false }+ : { columns: null, unavailable: true };+ } catch (error) {+ if (deniedStatus(error) === undefined) throw error;+ return { columns: null, unavailable: true };+ }+}++export function pickBoard(+ boards: JiraBoard[],+ projectKey: string,+): JiraBoard | undefined {+ const key = projectKey.toUpperCase();+ return (+ boards.find((board) => board.location?.projectKey?.toUpperCase() === key) ??+ boards[0]+ );+}++function deniedStatus(error: unknown): number | undefined {+ return error instanceof SourceHttpError && NO_BOARD_ACCESS.has(error.status)+ ? error.status+ : undefined;+}diff --git a/packages/importers/src/jira/client.ts b/packages/importers/src/jira/client.tsnew file mode 100644index 000000000..fce200cde--- /dev/null+++ b/packages/importers/src/jira/client.ts@@ -0,0 +1,158 @@+import { createJsonClient, type JsonClient } from "../http.js";+import type { FetchLike } from "../types.js";+import type {+ JiraBoardConfiguration,+ JiraBoardPage,+ JiraCloudSearchPage,+ JiraCommentPage,+ JiraIssueTypeStatuses,+ JiraProject,+ JiraProjectPage,+ JiraServerSearchPage,+ JiraUser,+} from "./api-types.js";+import type { JiraAuth } from "./auth.js";+import { toJiraError } from "./errors.js";+import type { JiraSite } from "./url.js";++export const PROJECTS_PAGE_SIZE = 50;+export const SEARCH_PAGE_SIZE = 100;+export const COMMENTS_PAGE_SIZE = 100;++export type JiraClientOptions = {+ site: JiraSite;+ auth: JiraAuth;+ fetch?: FetchLike;+ signal?: AbortSignal;+};++export type SearchQuery = {+ jql: string;+ fields: string[];+};++export class JiraClient {+ readonly cloud: boolean;+ private readonly http: JsonClient;+ private readonly api: string;++ constructor(private readonly options: JiraClientOptions) {+ this.cloud = options.site.cloud;+ this.api = `/rest/api/${options.auth.apiVersion}`;+ this.http = createJsonClient({+ service: "Jira",+ baseUrl: options.site.baseUrl,+ headers: () => ({ Authorization: options.auth.authorization }),+ fetch: options.fetch,+ signal: options.signal,+ });+ }++ withSignal(signal: AbortSignal | undefined): JiraClient {+ if (!signal) return this;+ const current = this.options.signal;+ return new JiraClient({+ ...this.options,+ signal: current ? AbortSignal.any([current, signal]) : signal,+ });+ }++ myself(): Promise<JiraUser | null> {+ return this.request(`${this.api}/myself`);+ }++ async listProjects(): Promise<JiraProject[]> {+ if (!this.cloud) {+ return (+ (await this.request<JiraProject[] | null>(`${this.api}/project`)) ?? []+ );+ }+ const projects: JiraProject[] = [];+ for (;;) {+ const params = new URLSearchParams({+ startAt: String(projects.length),+ maxResults: String(PROJECTS_PAGE_SIZE),+ });+ const page = await this.request<JiraProjectPage | null>(+ `${this.api}/project/search?${params}`,+ );+ const values = page?.values ?? [];+ projects.push(...values);+ if (page?.isLast !== false || values.length === 0) return projects;+ }+ }++ getProject(projectKey: string): Promise<JiraProject> {+ return this.request(+ `${this.api}/project/${encodeURIComponent(projectKey)}`,+ );+ }++ async projectStatuses(projectKey: string): Promise<JiraIssueTypeStatuses[]> {+ return (+ (await this.request<JiraIssueTypeStatuses[] | null>(+ `${this.api}/project/${encodeURIComponent(projectKey)}/statuses`,+ )) ?? []+ );+ }++ boards(projectKey: string): Promise<JiraBoardPage | null> {+ const params = new URLSearchParams({ projectKeyOrId: projectKey });+ return this.request(`/rest/agile/1.0/board?${params}`);+ }++ boardConfiguration(boardId: number): Promise<JiraBoardConfiguration | null> {+ return this.request(+ `/rest/agile/1.0/board/${encodeURIComponent(String(boardId))}/configuration`,+ );+ }++ searchCloud(+ query: SearchQuery,+ nextPageToken: string | undefined,+ ): Promise<JiraCloudSearchPage | null> {+ return this.request(`${this.api}/search/jql`, {+ method: "POST",+ body: JSON.stringify({+ jql: query.jql,+ maxResults: SEARCH_PAGE_SIZE,+ fields: query.fields,+ expand: "renderedFields",+ ...(nextPageToken ? { nextPageToken } : {}),+ }),+ });+ }++ searchServer(+ query: SearchQuery,+ startAt: number,+ ): Promise<JiraServerSearchPage | null> {+ const params = new URLSearchParams({+ jql: query.jql,+ startAt: String(startAt),+ maxResults: String(SEARCH_PAGE_SIZE),+ fields: query.fields.join(","),+ expand: "renderedFields",+ });+ return this.request(`${this.api}/search?${params}`);+ }++ comments(issueId: string, startAt: number): Promise<JiraCommentPage | null> {+ const params = new URLSearchParams({+ startAt: String(startAt),+ maxResults: String(COMMENTS_PAGE_SIZE),+ expand: "renderedBody",+ });+ return this.request(+ `${this.api}/issue/${encodeURIComponent(issueId)}/comment?${params}`,+ );+ }++ private async request<T>(path: string, init?: RequestInit): Promise<T> {+ try {+ return await this.http.request<T>(path, init);+ } catch (error) {+ throw toJiraError(error, this.options.auth.rejectedMessage);+ }+ }+}diff --git a/packages/importers/src/jira/columns.test.ts b/packages/importers/src/jira/columns.test.tsnew file mode 100644index 000000000..76bbca964--- /dev/null+++ b/packages/importers/src/jira/columns.test.ts@@ -0,0 +1,157 @@+import { describe, expect, it } from "vite-plus/test";+import type { JiraStatus } from "./api-types.js";+import {+ collectStatuses,+ planBoardColumns,+ planStatusColumns,+ resolveColumnKey,+ statusCategories,+} from "./columns.js";++function status(id: string, name: string, category?: string): JiraStatus {+ return {+ id,+ name,+ ...(category ? { statusCategory: { key: category } } : {}),+ };+}++const BACKLOG = status("1", "Backlog", "new");+const TODO = status("2", "Selected for Development", "new");+const DOING = status("3", "In Progress", "indeterminate");+const REVIEW = status("4", "In Review", "indeterminate");+const DONE = status("5", "Done", "done");+const WONT = status("6", "Won't Do", "done");+const ARCHIVED = status("7", "Archived", "done");++const CATEGORIES = statusCategories([+ BACKLOG,+ TODO,+ DOING,+ REVIEW,+ DONE,+ WONT,+ ARCHIVED,+]);++function ids(...statuses: JiraStatus[]) {+ return statuses.map((item) => ({ id: item.id }));+}++describe("planBoardColumns", () => {+ it("keeps board columns in order, sends Backlog to the Kaneo backlog and marks final columns", () => {+ const plan = planBoardColumns(+ [+ { name: "Backlog", statuses: ids(BACKLOG) },+ { name: "To Do", statuses: ids(TODO) },+ { name: "Doing", statuses: ids(DOING, REVIEW) },+ { name: "Rejected", statuses: ids(WONT) },+ { name: "Empty", statuses: [] },+ { name: "Shipped", statuses: ids(DONE) },+ ],+ CATEGORIES,+ );++ expect(plan.columns).toEqual([+ { key: "column-2", name: "To Do", isFinal: false },+ { key: "column-3", name: "Doing", isFinal: false },+ { key: "column-4", name: "Rejected", isFinal: true },+ { key: "column-6", name: "Shipped", isFinal: true },+ ]);+ expect(Object.fromEntries(plan.columnKeyByStatus)).toEqual({+ "1": null,+ "2": "column-2",+ "3": "column-3",+ "4": "column-3",+ "5": "column-6",+ "6": "column-4",+ });+ });++ it("treats the last column as final even when its statuses are not done", () => {+ const plan = planBoardColumns(+ [+ { name: "Open", statuses: ids(TODO) },+ { name: " ", statuses: ids(REVIEW) },+ ],+ new Map(),+ );+ expect(plan.columns).toEqual([+ { key: "column-1", name: "Open", isFinal: false },+ { key: "column-2", name: "Untitled", isFinal: true },+ ]);+ });++ it("keeps the first column a status was placed in", () => {+ const plan = planBoardColumns(+ [+ { name: "A", statuses: ids(TODO) },+ { name: "B", statuses: ids(TODO, DONE) },+ ],+ CATEGORIES,+ );+ expect(plan.columnKeyByStatus.get("2")).toBe("column-1");+ });+});++describe("planStatusColumns", () => {+ it("orders statuses by category, keeps first seen order and marks done statuses final", () => {+ const plan = planStatusColumns([+ DONE,+ DOING,+ status("8", "Mystery"),+ TODO,+ BACKLOG,+ WONT,+ ]);++ expect(plan.columns).toEqual([+ { key: "2", name: "Selected for Development", isFinal: false },+ { key: "3", name: "In Progress", isFinal: false },+ { key: "8", name: "Mystery", isFinal: false },+ { key: "5", name: "Done", isFinal: true },+ { key: "6", name: "Won't Do", isFinal: true },+ ]);+ expect(plan.columnKeyByStatus.get("1")).toBeNull();+ });+});++describe("resolveColumnKey", () => {+ const plan = planBoardColumns(+ [+ { name: "Backlog", statuses: ids(BACKLOG) },+ { name: "To Do", statuses: ids(TODO) },+ { name: "Done", statuses: ids(DONE) },+ ],+ CATEGORIES,+ );++ it("uses the mapped column or the backlog", () => {+ expect(resolveColumnKey(plan, "2", CATEGORIES)).toBe("column-2");+ expect(resolveColumnKey(plan, "1", CATEGORIES)).toBeNull();+ expect(resolveColumnKey(plan, undefined, CATEGORIES)).toBeNull();+ });++ it("places statuses missing from the board by category", () => {+ expect(resolveColumnKey(plan, "7", CATEGORIES)).toBe("column-3");+ expect(resolveColumnKey(plan, "4", CATEGORIES)).toBeNull();+ expect(resolveColumnKey(plan, "unknown", CATEGORIES)).toBeNull();+ });+});++describe("collectStatuses", () => {+ it("dedupes statuses across issue types and adds statuses only seen on issues", () => {+ const statuses = collectStatuses(+ [+ { name: "Task", statuses: [TODO, DOING, DONE] },+ { name: "Sub-task", statuses: [TODO, DONE] },+ ],+ [+ { id: "i1", key: "ABC-1", fields: { status: DOING } },+ { id: "i2", key: "ABC-2", fields: { status: ARCHIVED } },+ { id: "i3", key: "ABC-3", fields: null },+ ],+ );+ expect(statuses.map((item) => item.id)).toEqual(["2", "3", "5", "7"]);+ });+});diff --git a/packages/importers/src/jira/columns.ts b/packages/importers/src/jira/columns.tsnew file mode 100644index 000000000..5e07b50d0--- /dev/null+++ b/packages/importers/src/jira/columns.ts@@ -0,0 +1,128 @@+import type { ImportedColumn } from "../types.js";+import type {+ JiraBoardColumn,+ JiraIssue,+ JiraIssueTypeStatuses,+ JiraStatus,+} from "./api-types.js";++export type ColumnPlan = {+ columns: ImportedColumn[];+ columnKeyByStatus: ReadonlyMap<string, string | null>;+};++export type StatusCategories = ReadonlyMap<string, string>;++const DONE_CATEGORY = "done";+const CATEGORY_ORDER = ["new", "indeterminate", DONE_CATEGORY];+const UNKNOWN_CATEGORY_RANK = CATEGORY_ORDER.indexOf("indeterminate");++export function isBacklogName(name: string): boolean {+ return name.trim().toLowerCase() === "backlog";+}++export function collectStatuses(+ groups: JiraIssueTypeStatuses[],+ issues: JiraIssue[],+): JiraStatus[] {+ const byId = new Map<string, JiraStatus>();+ const candidates = [+ ...groups.flatMap((group) => group.statuses ?? []),+ ...issues.flatMap((issue) =>+ issue.fields?.status ? [issue.fields.status] : [],+ ),+ ];+ for (const status of candidates) {+ if (status?.id && !byId.has(status.id)) byId.set(status.id, status);+ }+ return [...byId.values()];+}++export function statusCategories(statuses: JiraStatus[]): StatusCategories {+ const categories = new Map<string, string>();+ for (const status of statuses) {+ const key = status.statusCategory?.key?.trim().toLowerCase();+ if (key) categories.set(status.id, key);+ }+ return categories;+}++export function planBoardColumns(+ boardColumns: JiraBoardColumn[],+ categories: StatusCategories,+): ColumnPlan {+ const columnKeyByStatus = new Map<string, string | null>();+ const kept: Array<{ key: string; name: string; statusIds: string[] }> = [];++ for (const [index, column] of boardColumns.entries()) {+ const statusIds = (column.statuses ?? [])+ .map((status) => status?.id)+ .filter((id): id is string => Boolean(id));+ if (statusIds.length === 0) continue;++ const name = column.name?.trim() || "Untitled";+ const key = isBacklogName(name) ? null : `column-${index + 1}`;+ for (const id of statusIds) {+ if (!columnKeyByStatus.has(id)) columnKeyByStatus.set(id, key);+ }+ if (key) kept.push({ key, name, statusIds });+ }++ const columns = kept.map((column, index) => ({+ key: column.key,+ name: column.name,+ isFinal:+ index === kept.length - 1 ||+ column.statusIds.every((id) => categories.get(id) === DONE_CATEGORY),+ }));+ return { columns, columnKeyByStatus };+}++export function planStatusColumns(statuses: JiraStatus[]): ColumnPlan {+ const columnKeyByStatus = new Map<string, string | null>();+ const columns: ImportedColumn[] = [];++ const ordered = statuses+ .map((status, index) => ({ status, index }))+ .sort(+ (a, b) =>+ categoryRank(a.status) - categoryRank(b.status) || a.index - b.index,+ );++ for (const { status } of ordered) {+ const name = status.name?.trim() || "Untitled";+ if (isBacklogName(name)) {+ columnKeyByStatus.set(status.id, null);+ continue;+ }+ columnKeyByStatus.set(status.id, status.id);+ columns.push({+ key: status.id,+ name,+ isFinal: categoryOf(status) === DONE_CATEGORY,+ });+ }++ return { columns, columnKeyByStatus };+}++export function resolveColumnKey(+ plan: ColumnPlan,+ statusId: string | undefined,+ categories: StatusCategories,+): string | null {+ if (!statusId) return null;+ const mapped = plan.columnKeyByStatus.get(statusId);+ if (mapped !== undefined) return mapped;+ if (categories.get(statusId) !== DONE_CATEGORY) return null;+ return plan.columns.filter((column) => column.isFinal).at(-1)?.key ?? null;+}++function categoryOf(status: JiraStatus): string | undefined {+ return status.statusCategory?.key?.trim().toLowerCase();+}++function categoryRank(status: JiraStatus): number {+ const index = CATEGORY_ORDER.indexOf(categoryOf(status) ?? "");+ return index === -1 ? UNKNOWN_CATEGORY_RANK : index;+}diff --git a/packages/importers/src/jira/comments.test.ts b/packages/importers/src/jira/comments.test.tsnew file mode 100644index 000000000..140d27245--- /dev/null+++ b/packages/importers/src/jira/comments.test.ts@@ -0,0 +1,80 @@+import { describe, expect, it } from "vite-plus/test";+import { mapComments } from "./comments.js";+import { createJiraHtmlToMarkdown } from "./html.js";++const toMarkdown = createJiraHtmlToMarkdown("https://jira.example.com");++describe("mapComments", () => {+ it("orders comments oldest first with Markdown bodies and authors", () => {+ expect(+ mapComments(+ [+ {+ id: "2",+ author: {+ displayName: "Grace Hopper",+ emailAddress: "[email protected]",+ },+ body: { type: "doc" },+ renderedBody: "<p>Second <b>reply</b></p>",+ created: "2024-03-02T09:00:00.000+0000",+ },+ {+ id: "1",+ author: { displayName: "Ada Lovelace" },+ renderedBody: "<p>First</p>",+ created: "2024-03-01T09:00:00.000+0000",+ },+ {+ id: "3",+ author: null,+ body: " Wiki *text* ",+ created: "2024-03-03T09:00:00.000+0000",+ },+ {+ id: "4",+ author: { emailAddress: "[email protected]" },+ renderedBody: "<p></p>",+ created: "2024-03-04T09:00:00.000+0000",+ },+ ],+ toMarkdown,+ ),+ ).toEqual([+ {+ author: { name: "Ada Lovelace" },+ body: "First",+ createdAt: "2024-03-01T09:00:00.000Z",+ },+ {+ author: { name: "Grace Hopper", email: "[email protected]" },+ body: "Second **reply**",+ createdAt: "2024-03-02T09:00:00.000Z",+ },+ {+ author: { name: "Jira user" },+ body: "Wiki *text*",+ createdAt: "2024-03-03T09:00:00.000Z",+ },+ ]);+ });++ it("uses the email as the name when there is no display name", () => {+ expect(+ mapComments(+ [+ {+ author: { emailAddress: "[email protected]" },+ renderedBody: "<p>Hi</p>",+ },+ ],+ toMarkdown,+ ),+ ).toEqual([+ {+ author: { name: "[email protected]", email: "[email protected]" },+ body: "Hi",+ },+ ]);+ });+});diff --git a/packages/importers/src/jira/comments.ts b/packages/importers/src/jira/comments.tsnew file mode 100644index 000000000..af2997b8e--- /dev/null+++ b/packages/importers/src/jira/comments.ts@@ -0,0 +1,41 @@+import { toIsoDate } from "../markdown.js";+import type { ImportedComment } from "../types.js";+import type { JiraComment } from "./api-types.js";+import type { HtmlToMarkdown } from "./html.js";+import { toPerson } from "./people.js";++export const FALLBACK_AUTHOR = "Jira user";++export function mapComments(+ comments: JiraComment[],+ toMarkdown: HtmlToMarkdown,+): ImportedComment[] {+ const mapped: ImportedComment[] = [];+ for (const comment of comments) {+ const body = commentBody(comment, toMarkdown);+ if (!body) continue;+ const person = toPerson(comment.author);+ const createdAt = toIsoDate(comment.created);+ mapped.push({+ author: {+ name: person?.name ?? person?.email ?? FALLBACK_AUTHOR,+ ...(person?.email ? { email: person.email } : {}),+ },+ body,+ ...(createdAt ? { createdAt } : {}),+ });+ }+ return mapped.sort((a, b) => timestamp(a.createdAt) - timestamp(b.createdAt));+}++function commentBody(comment: JiraComment, toMarkdown: HtmlToMarkdown): string {+ if (typeof comment.renderedBody === "string") {+ return toMarkdown(comment.renderedBody);+ }+ return typeof comment.body === "string" ? comment.body.trim() : "";+}++function timestamp(value: string | undefined): number {+ const parsed = value ? Date.parse(value) : Number.NaN;+ return Number.isNaN(parsed) ? 0 : parsed;+}diff --git a/packages/importers/src/jira/emoticons.ts b/packages/importers/src/jira/emoticons.tsnew file mode 100644index 000000000..d750b8432--- /dev/null+++ b/packages/importers/src/jira/emoticons.ts@@ -0,0 +1,30 @@+const EMOTICONS: ReadonlyMap<string, string> = new Map([+ ["smile", "🙂"],+ ["sad", "🙁"],+ ["tongue", "😛"],+ ["biggrin", "😀"],+ ["wink", "😉"],+ ["thumbs_up", "👍"],+ ["thumbs_down", "👎"],+ ["information", "ℹ️"],+ ["check", "✅"],+ ["error", "❌"],+ ["warning", "⚠️"],+ ["add", "➕"],+ ["forbidden", "⛔"],+ ["help_16", "❓"],+ ["lightbulb_on", "💡"],+ ["lightbulb", "💡"],+ ["star_yellow", "⭐"],+ ["star_red", "⭐"],+ ["star_green", "⭐"],+ ["star_blue", "⭐"],+ ["flag", "🚩"],+ ["flag_grey", "🏳️"],+]);++export function emoticonText(src: string, alt: string): string {+ const name = /\/([\w-]+)\.(?:png|gif|svg)(?:[?#].*)?$/i.exec(src)?.[1];+ const emoji = name ? EMOTICONS.get(name.toLowerCase()) : undefined;+ return emoji ?? alt.trim();+}diff --git a/packages/importers/src/jira/errors.test.ts b/packages/importers/src/jira/errors.test.tsnew file mode 100644index 000000000..36f3298fc--- /dev/null+++ b/packages/importers/src/jira/errors.test.ts@@ -0,0 +1,63 @@+import { describe, expect, it } from "vite-plus/test";+import { SourceHttpError } from "../http.js";+import { jiraErrorText, toJiraError } from "./errors.js";++describe("jiraErrorText", () => {+ it("joins error messages and field errors", () => {+ expect(+ jiraErrorText({+ errorMessages: [+ "The value 'XYZ' does not exist for the field 'project'.",+ ],+ errors: { jql: "Bad order" },+ }),+ ).toBe("The value 'XYZ' does not exist for the field 'project'. Bad order");+ expect(jiraErrorText({ message: "Board not found" })).toBe(+ "Board not found",+ );+ });++ it("ignores bodies without messages", () => {+ expect(jiraErrorText({ errorMessages: [], errors: {} })).toBeUndefined();+ expect(jiraErrorText("<html></html>")).toBeUndefined();+ expect(jiraErrorText(null)).toBeUndefined();+ });++ it("shortens long messages", () => {+ const text = jiraErrorText({ errorMessages: ["x".repeat(400)] });+ expect(text).toHaveLength(301);+ });+});++describe("toJiraError", () => {+ it("replaces 401 errors with the credential message and drops the body", () => {+ const error = toJiraError(+ new SourceHttpError("Jira /rest/api/3/myself: HTTP 401", 401, {+ echoed: "secret",+ }),+ "Jira rejected the personal access token.",+ ) as SourceHttpError;+ expect(error).toBeInstanceOf(SourceHttpError);+ expect(error.message).toBe("Jira rejected the personal access token.");+ expect(error.status).toBe(401);+ expect(error.body).toBeNull();+ });++ it("keeps the status and uses the Jira message", () => {+ const error = toJiraError(+ new SourceHttpError("Jira /rest/api/2/search: HTTP 400", 400, {+ errorMessages: ["Field 'Rank' does not exist."],+ }),+ "rejected",+ ) as SourceHttpError;+ expect(error.message).toBe("Jira: Field 'Rank' does not exist.");+ expect(error.status).toBe(400);+ });++ it("passes other errors through", () => {+ const plain = new Error("network down");+ expect(toJiraError(plain, "rejected")).toBe(plain);+ const html = new SourceHttpError("Jira /x: HTTP 502", 502, "<html>");+ expect(toJiraError(html, "rejected")).toBe(html);+ });+});diff --git a/packages/importers/src/jira/errors.ts b/packages/importers/src/jira/errors.tsnew file mode 100644index 000000000..28f489867--- /dev/null+++ b/packages/importers/src/jira/errors.ts@@ -0,0 +1,42 @@+import { SourceHttpError } from "../http.js";++const MAX_MESSAGE_LENGTH = 300;++export function jiraErrorText(body: unknown): string | undefined {+ if (typeof body !== "object" || body === null) return undefined;+ const record = body as Record<string, unknown>;+ const messages = [+ ...strings(record.errorMessages),+ ...strings(+ typeof record.errors === "object" && record.errors !== null+ ? Object.values(record.errors)+ : [],+ ),+ ];+ if (messages.length === 0 && typeof record.message === "string") {+ messages.push(record.message.trim());+ }+ const text = messages.filter(Boolean).join(" ");+ if (!text) return undefined;+ return text.length > MAX_MESSAGE_LENGTH+ ? `${text.slice(0, MAX_MESSAGE_LENGTH)}…`+ : text;+}++export function toJiraError(error: unknown, rejectedMessage: string): unknown {+ if (!(error instanceof SourceHttpError)) return error;+ if (error.status === 401) {+ return new SourceHttpError(rejectedMessage, 401, null);+ }+ const text = jiraErrorText(error.body);+ return text+ ? new SourceHttpError(`Jira: ${text}`, error.status, error.body)+ : error;+}++function strings(value: unknown): string[] {+ if (!Array.isArray(value)) return [];+ return value+ .filter((item): item is string => typeof item === "string")+ .map((item) => item.trim());+}diff --git a/packages/importers/src/jira/html-rules.ts b/packages/importers/src/jira/html-rules.tsnew file mode 100644index 000000000..232d470cd--- /dev/null+++ b/packages/importers/src/jira/html-rules.ts@@ -0,0 +1,192 @@+import type TurndownService from "turndown";+import { emoticonText } from "./emoticons.js";++type Rule = TurndownService.Rule;++const CODE_LANGUAGE = /(?:^|\s)code-([\w+#-]+)/;++export function jiraRules(origin: string): Array<[string, Rule]> {+ return [+ ["jiraParagraph", { filter: "p", replacement: paragraph }],+ ["jiraListItem", { filter: "li", replacement: listItem }],+ ["jiraCodeBlock", { filter: isBareCodeBlock, replacement: codeBlock }],+ ["jiraMonospace", { filter: isMonospace, replacement: monospace }],+ ["jiraPanel", { filter: isPanel, replacement: blockquote }],+ ["jiraIcon", { filter: isIcon, replacement: () => "" }],+ ["jiraImage", { filter: "img", replacement: image }],+ ["jiraLink", { filter: isLink, replacement: link(origin) }],+ ["jiraMention", { filter: isMention, replacement: mention }],+ ["jiraTable", { filter: isHeaderlessTable, replacement: headerlessTable }],+ ];+}++function classes(node: HTMLElement): string[] {+ return (node.getAttribute("class") ?? "").split(/\s+/).filter(Boolean);+}++function paragraph(content: string, node: HTMLElement): string {+ const parent = node.parentNode?.nodeName;+ if (parent === "TH" || parent === "TD") {+ return node.previousElementSibling ? ` ${content}` : content;+ }+ if (parent === "LI" && !node.previousElementSibling) {+ return `\n${content}\n`;+ }+ return `\n\n${content}\n\n`;+}++function listItem(content: string, node: HTMLElement): string {+ const parent = node.parentNode as HTMLElement | null;+ let marker = "- ";+ if (parent?.nodeName === "OL") {+ const start = Number(parent.getAttribute("start") ?? "1");+ const index = Array.prototype.indexOf.call(parent.children, node);+ marker = `${(Number.isFinite(start) ? start : 1) + index}. `;+ }+ const indent = " ".repeat(marker.length);+ const body = content+ .replace(/^\n+/, "")+ .replace(/\n+$/, "")+ .replace(/\n(?=[^\n])/g, `\n${indent}`);+ return `${marker}${body}${node.nextSibling ? "\n" : ""}`;+}++function isBareCodeBlock(node: HTMLElement): boolean {+ return node.nodeName === "PRE" && node.firstChild?.nodeName !== "CODE";+}++function codeBlock(_content: string, node: HTMLElement): string {+ const language = CODE_LANGUAGE.exec(node.getAttribute("class") ?? "")?.[1];+ const code = (node.textContent ?? "").replace(/\n+$/, "");+ const longestRun = Math.max(+ 2,+ ...[...code.matchAll(/`+/g)].map((match) => match[0].length),+ );+ const fence = "`".repeat(longestRun + 1);+ const info = language && language !== "none" ? language : "";+ return `\n\n${fence}${info}\n${code}\n${fence}\n\n`;+}++function isMonospace(node: HTMLElement): boolean {+ return node.nodeName === "TT";+}++function monospace(_content: string, node: HTMLElement): string {+ const text = node.textContent ?? "";+ if (!text) return "";+ const fence = text.includes("`") ? "``" : "`";+ const pad = text.startsWith("`") || text.endsWith("`") ? " " : "";+ return `${fence}${pad}${text}${pad}${fence}`;+}++function isPanel(node: HTMLElement): boolean {+ if (node.nodeName !== "DIV") return false;+ const names = classes(node);+ if (names.includes("aui-message")) return true;+ return (+ names.includes("panel") &&+ !names.includes("code") &&+ !names.includes("preformatted")+ );+}++function blockquote(content: string): string {+ const body = content.replace(/^\n+|\n+$/g, "");+ return body ? `\n\n${body.replace(/^/gm, "> ")}\n\n` : "";+}++function isIcon(node: HTMLElement): boolean {+ return (+ node.nodeName === "SPAN" &&+ classes(node).some((name) => name.startsWith("aui-icon"))+ );+}++function image(_content: string, node: HTMLElement): string {+ const src = (node.getAttribute("src") ?? "").trim();+ const alt = (node.getAttribute("alt") ?? "").replace(/\s+/g, " ").trim();+ if (classes(node).includes("emoticon")) return emoticonText(src, alt);+ if (!/^https?:\/\//i.test(src)) return alt;+ return `![${alt.replace(/[[\]]/g, "\\$&")}](${escapeUrl(src)})`;+}++function isLink(node: HTMLElement): boolean {+ return node.nodeName === "A" && Boolean(node.getAttribute("href"));+}++function link(origin: string) {+ return (content: string, node: HTMLElement): string => {+ const href = resolveHref(node.getAttribute("href") ?? "", origin);+ const text = content.trim();+ if (!href || !text) return text;+ return `[${text}](${escapeUrl(href)})`;+ };+}++function resolveHref(raw: string, origin: string): string | undefined {+ const href = raw.trim();+ if (/^(?:https?:|mailto:)/i.test(href)) return href;+ if (href.startsWith("/") && !href.startsWith("//")) return `${origin}${href}`;+ return undefined;+}++function escapeUrl(url: string): string {+ return url.replace(/[()\s]/g, (char) =>+ char === "(" ? "%28" : char === ")" ? "%29" : "%20",+ );+}++function isMention(node: HTMLElement): boolean {+ if (node.nodeName !== "A") return false;+ if (classes(node).includes("user-hover")) return true;+ if (node.hasAttribute("data-account-id") || node.hasAttribute("accountid")) {+ return true;+ }+ return /ViewProfile\.jspa/i.test(node.getAttribute("href") ?? "");+}++function mention(content: string): string {+ const name = content.trim();+ if (!name) return "";+ return name.startsWith("@") ? name : `@${name}`;+}++function isHeaderlessTable(node: HTMLElement): boolean {+ if (node.nodeName !== "TABLE") return false;+ const first = (node as HTMLTableElement).rows[0];+ return first !== undefined && !isHeadingRow(first);+}++function headerlessTable(content: string, node: HTMLElement): string {+ const lines = content.split("\n").filter((line) => line.trim());+ const first = (node as HTMLTableElement).rows[0];+ const width = first?.cells.length ?? 0;+ if (lines.length === 0 || width === 0) return "";+ const separator = `| ${Array.from({ length: width }, () => "---").join(" | ")} |`;+ return `\n\n${[lines[0], separator, ...lines.slice(1)].join("\n")}\n\n`;+}++function isHeadingRow(row: HTMLTableRowElement): boolean {+ const parent = row.parentNode as HTMLElement | null;+ if (!parent) return false;+ if (parent.nodeName === "THEAD") return true;+ if (parent.firstChild !== row) return false;+ const section =+ parent.nodeName === "TABLE" ||+ (parent.nodeName === "TBODY" && isFirstBody(parent));+ return (+ section &&+ Array.prototype.every.call(+ row.childNodes,+ (cell: Node) => cell.nodeName === "TH",+ )+ );+}++function isFirstBody(body: HTMLElement): boolean {+ const previous = body.previousSibling;+ return (+ !previous ||+ (previous.nodeName === "THEAD" && !(previous.textContent ?? "").trim())+ );+}diff --git a/packages/importers/src/jira/html.test.ts b/packages/importers/src/jira/html.test.tsnew file mode 100644index 000000000..7643e86dc--- /dev/null+++ b/packages/importers/src/jira/html.test.ts@@ -0,0 +1,121 @@+import { describe, expect, it } from "vite-plus/test";+import { createJiraHtmlToMarkdown } from "./html.js";++const toMarkdown = createJiraHtmlToMarkdown("https://jira.example.com/jira");++describe("createJiraHtmlToMarkdown", () => {+ it("treats empty HTML as an empty description", () => {+ expect(toMarkdown(null)).toBe("");+ expect(toMarkdown(undefined)).toBe("");+ expect(toMarkdown(" ")).toBe("");+ expect(toMarkdown("<p></p>")).toBe("");+ });++ it("converts headings, emphasis, strikethrough and rules", () => {+ expect(+ toMarkdown(+ '<h2><a name="Goal"></a>Goal</h2>\n<p>Ship <b>fast</b> and <em>safe</em>, not <del>slow</del>.<br/>\nNext line</p>\n<hr />\n<p>End</p>',+ ),+ ).toBe(+ "## Goal\n\nShip **fast** and _safe_, not ~slow~. \nNext line\n\n---\n\nEnd",+ );+ });++ it("writes tight nested lists", () => {+ expect(+ toMarkdown(+ '<ul class="alternate" type="square">\n\t<li>one\n\t<ul class="alternate" type="square">\n\t\t<li>nested</li>\n\t</ul>\n\t</li>\n\t<li>two</li>\n</ul>\n\n<ol>\n\t<li>first</li>\n\t<li>second</li>\n</ol>',+ ),+ ).toBe("- one\n - nested\n- two\n\n1. first\n2. second");+ });++ it("keeps lists made of paragraphs tight", () => {+ expect(+ toMarkdown(+ "<ul><li><p>one</p><ul><li><p>nested</p></li></ul></li><li><p>two</p></li></ul>",+ ),+ ).toBe("- one\n - nested\n- two");+ });++ it("turns Jira code panels into fenced blocks with their language", () => {+ expect(+ toMarkdown(+ '<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">\n<pre class="code-java"><span class="code-keyword">public</span> <span class="code-keyword">class</span> Foo {\n <span class="code-object">String</span> name = <span class="code-quote">"a_b"</span>;\n}\n</pre>\n</div></div>',+ ),+ ).toBe('```java\npublic class Foo {\n String name = "a_b";\n}\n```');+ });++ it("turns noformat blocks into plain fences and keeps markdown characters", () => {+ expect(+ toMarkdown(+ '<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">\n<pre>raw *text* with ```fences```</pre>\n</div></div>',+ ),+ ).toBe("````\nraw *text* with ```fences```\n````");+ });++ it("keeps inline monospace", () => {+ expect(toMarkdown("<p>Run <tt>pnpm test</tt> and <tt>a`b</tt></p>")).toBe(+ "Run `pnpm test` and ``a`b``",+ );+ });++ it("turns panels and info macros into quotes", () => {+ expect(+ toMarkdown(+ '<div class="panel" style="border-width: 1px;"><div class="panelHeader" style="border-bottom-width: 1px;"><b>Heads up</b></div><div class="panelContent">\n<p>Mind the gap.</p>\n</div></div>',+ ),+ ).toBe("> **Heads up**\n> \n> Mind the gap.");+ expect(+ toMarkdown(+ '<div class="aui-message information shadowed information-macro"><span class="aui-icon icon-info">Icon</span><div class="message-content"><p>Read this first.</p></div></div>',+ ),+ ).toBe("> Read this first.");+ });++ it("converts tables with and without a header row", () => {+ expect(+ toMarkdown(+ "<div class='table-wrap'>\n<table class='confluenceTable'><tbody>\n<tr>\n<th class='confluenceTh'>Name</th>\n<th class='confluenceTh'>Owner</th>\n</tr>\n<tr>\n<td class='confluenceTd'>API</td>\n<td class='confluenceTd'><p>Jane</p><p>Bob</p></td>\n</tr>\n</tbody></table>\n</div>",+ ),+ ).toBe("| Name | Owner |\n| --- | --- |\n| API | Jane Bob |");+ expect(+ toMarkdown(+ "<table class='confluenceTable'><tbody>\n<tr>\n<td class='confluenceTd'>a</td>\n<td class='confluenceTd'>b</td>\n</tr>\n<tr>\n<td class='confluenceTd'>c</td>\n<td class='confluenceTd'>d</td>\n</tr>\n</tbody></table>",+ ),+ ).toBe("| a | b |\n| --- | --- |\n| c | d |");+ });++ it("degrades user mentions to plain text", () => {+ expect(+ toMarkdown(+ '<p>Ping <a href="https://jira.example.com/jira/secure/ViewProfile.jspa?name=fred" class="user-hover" rel="fred">Fred Flintstone</a> and <a href="/jira/secure/ViewProfile.jspa?accountId=5b10" data-account-id="5b10" accountid="5b10">@Ada</a></p>',+ ),+ ).toBe("Ping @Fred Flintstone and @Ada");+ });++ it("keeps absolute links and resolves site relative ones", () => {+ expect(+ toMarkdown(+ '<p>See <a href="https://jira.example.com/jira/browse/ABC-2" title="Fix it" class="issue-link" data-issue-key="ABC-2">ABC-2</a>, <a href="/jira/browse/ABC-3">ABC-3</a>, <a href="#anchor">here</a> and <a href="https://example.com/a (b)" class="external-link" rel="nofollow">docs</a></p>',+ ),+ ).toBe(+ "See [ABC-2](https://jira.example.com/jira/browse/ABC-2), [ABC-3](https://jira.example.com/jira/browse/ABC-3), here and [docs](https://example.com/a%20%28b%29)",+ );+ });++ it("keeps only absolute images and maps emoticons", () => {+ expect(+ toMarkdown(+ '<p>Before <img class="emoticon" src="https://jira.example.com/jira/images/icons/emoticons/check.png" height="16" width="16" align="absmiddle" alt="" border="0"/></p><p><span class="image-wrap" style=""><img src="https://jira.example.com/jira/secure/attachment/10000/shot.png" style="border: 0px solid black" /></span></p><p><img src="/rest/api/3/attachment/content/10001" alt="diagram.png" /></p><p><img src="blob:abc" /></p><p>After</p>',+ ),+ ).toBe(+ "Before ✅\n\n\n\ndiagram.png\n\nAfter",+ );+ });++ it("keeps quotes", () => {+ expect(toMarkdown("<blockquote><p>Quoted</p></blockquote>")).toBe(+ "> Quoted",+ );+ });+});diff --git a/packages/importers/src/jira/html.ts b/packages/importers/src/jira/html.tsnew file mode 100644index 000000000..a577c65e5--- /dev/null+++ b/packages/importers/src/jira/html.ts@@ -0,0 +1,34 @@+import TurndownService from "turndown";+import { gfm } from "turndown-plugin-gfm";+import { jiraRules } from "./html-rules.js";++export type HtmlToMarkdown = (html: string | null | undefined) => string;++export function createJiraHtmlToMarkdown(baseUrl: string): HtmlToMarkdown {+ const service = new TurndownService({+ headingStyle: "atx",+ codeBlockStyle: "fenced",+ bulletListMarker: "-",+ hr: "---",+ });+ service.use(gfm);+ for (const [name, rule] of jiraRules(originOf(baseUrl))) {+ service.addRule(name, rule);+ }++ return (html) => {+ if (!html?.trim()) return "";+ return service+ .turndown(html)+ .replace(/\n{3,}/g, "\n\n")+ .trim();+ };+}++function originOf(baseUrl: string): string {+ try {+ return new URL(baseUrl).origin;+ } catch {+ return "";+ }+}diff --git a/packages/importers/src/jira/index.ts b/packages/importers/src/jira/index.tsnew file mode 100644index 000000000..68370fc80--- /dev/null+++ b/packages/importers/src/jira/index.ts@@ -0,0 +1,2 @@+export { connectJira, type JiraCredentials } from "./source.js";+export { MISSING_URL_MESSAGE, parseJiraUrl, type JiraSite } from "./url.js";diff --git a/packages/importers/src/jira/labels.test.ts b/packages/importers/src/jira/labels.test.tsnew file mode 100644index 000000000..2e2c54947--- /dev/null+++ b/packages/importers/src/jira/labels.test.ts@@ -0,0 +1,53 @@+import { describe, expect, it } from "vite-plus/test";+import type { JiraIssue } from "./api-types.js";+import { issueLabels, LABEL_PALETTE, labelColor, mapLabels } from "./labels.js";++function issue(id: string, labels: string[] | null): JiraIssue {+ return { id, key: `ABC-${id}`, fields: { labels } };+}++describe("labelColor", () => {+ it("picks the same palette color for the same name every time", () => {+ expect(labelColor("frontend")).toBe(labelColor("frontend"));+ expect(LABEL_PALETTE).toContain(labelColor("frontend"));+ expect(labelColor("")).toBe(LABEL_PALETTE[0x811c9dc5 % 8]);+ });++ it("spreads common names over several colors", () => {+ const names = [+ "bug",+ "frontend",+ "backend",+ "ux",+ "tech-debt",+ "security",+ "performance",+ "docs",+ "infra",+ "mobile",+ ];+ expect(new Set(names.map(labelColor)).size).toBeGreaterThan(3);+ });+});++describe("issueLabels", () => {+ it("trims, drops blanks and dedupes", () => {+ expect(issueLabels(issue("1", [" ui ", "ui", "", "api"]))).toEqual([+ "ui",+ "api",+ ]);+ expect(issueLabels(issue("2", null))).toEqual([]);+ });+});++describe("mapLabels", () => {+ it("lists every label used in the project once, sorted by name", () => {+ expect(+ mapLabels([issue("1", ["ux", "Backend"]), issue("2", ["ux", "api"])]),+ ).toEqual([+ { key: "api", name: "api", color: labelColor("api") },+ { key: "Backend", name: "Backend", color: labelColor("Backend") },+ { key: "ux", name: "ux", color: labelColor("ux") },+ ]);+ });+});diff --git a/packages/importers/src/jira/labels.ts b/packages/importers/src/jira/labels.tsnew file mode 100644index 000000000..dbbf4a7cb--- /dev/null+++ b/packages/importers/src/jira/labels.ts@@ -0,0 +1,37 @@+import type { ImportedLabel } from "../types.js";+import type { JiraIssue } from "./api-types.js";++export const LABEL_PALETTE = [+ "#8b5cf6",+ "#059669",+ "#16a34a",+ "#d97706",+ "#ea580c",+ "#e11d48",+ "#dc2626",+ "#64748b",+] as const;++export function labelColor(name: string): string {+ let hash = 0x811c9dc5;+ for (let index = 0; index < name.length; index++) {+ hash ^= name.charCodeAt(index);+ hash = Math.imul(hash, 0x01000193) >>> 0;+ }+ return LABEL_PALETTE[hash % LABEL_PALETTE.length] as string;+}++export function issueLabels(issue: JiraIssue): string[] {+ const labels = (issue.fields?.labels ?? [])+ .filter((label): label is string => typeof label === "string")+ .map((label) => label.trim())+ .filter(Boolean);+ return [...new Set(labels)];+}++export function mapLabels(issues: JiraIssue[]): ImportedLabel[] {+ const names = new Set(issues.flatMap(issueLabels));+ return [...names]+ .sort((a, b) => a.localeCompare(b))+ .map((name) => ({ key: name, name, color: labelColor(name) }));+}diff --git a/packages/importers/src/jira/mapping.test.ts b/packages/importers/src/jira/mapping.test.tsnew file mode 100644index 000000000..dbe01007b--- /dev/null+++ b/packages/importers/src/jira/mapping.test.ts@@ -0,0 +1,135 @@+import { describe, expect, it } from "vite-plus/test";+import type { JiraIssue } from "./api-types.js";+import { createJiraHtmlToMarkdown } from "./html.js";+import {+ issueDescription,+ issueNumber,+ mapIssue,+ mapPriority,+} from "./mapping.js";++const toMarkdown = createJiraHtmlToMarkdown("https://acme.atlassian.net");++describe("mapPriority", () => {+ it.each([+ ["Highest", "urgent"],+ ["Blocker", "urgent"],+ ["critical", "urgent"],+ ["High", "high"],+ ["Major", "high"],+ ["Medium", "medium"],+ ["Low", "low"],+ ["Minor", "low"],+ ["Lowest", "low"],+ [" Trivial ", "low"],+ ["P1", "no-priority"],+ ["constructor", "no-priority"],+ [null, "no-priority"],+ [undefined, "no-priority"],+ ])("maps %j to %s", (name, expected) => {+ expect(mapPriority(name)).toBe(expected);+ });+});++describe("issueNumber", () => {+ it.each([+ ["ABC-123", 123],+ ["MY_PROJ-7", 7],+ ["A1-0", undefined],+ ["ABC", undefined],+ ["", undefined],+ [null, undefined],+ ["ABC-99999999999999999999", undefined],+ ])("reads the number of %j", (key, expected) => {+ expect(issueNumber(key)).toBe(expected);+ });+});++describe("issueDescription", () => {+ it("prefers the rendered HTML and falls back to raw wiki text", () => {+ expect(+ issueDescription(+ {+ id: "1",+ key: "ABC-1",+ fields: { description: { type: "doc" } },+ renderedFields: { description: "<p>Hello <b>you</b></p>" },+ },+ toMarkdown,+ ),+ ).toBe("Hello **you**");+ expect(+ issueDescription(+ { id: "1", key: "ABC-1", fields: { description: " h1. Raw " } },+ toMarkdown,+ ),+ ).toBe("h1. Raw");+ expect(+ issueDescription(+ { id: "1", key: "ABC-1", fields: { description: { type: "doc" } } },+ toMarkdown,+ ),+ ).toBe("");+ });+});++describe("mapIssue", () => {+ const issue: JiraIssue = {+ id: "10042",+ key: "ABC-42",+ fields: {+ summary: " Fix login ",+ status: { id: "3" },+ priority: { name: "High" },+ assignee: {+ accountId: "5b10",+ displayName: "Ada Lovelace",+ emailAddress: null,+ },+ labels: ["auth", "auth", "ux"],+ duedate: "2024-05-01",+ created: "2024-04-01T08:30:00.000+0200",+ },+ renderedFields: { description: "<p>Steps</p>" },+ };++ it("maps the fields Kaneo keeps", () => {+ expect(+ mapIssue(issue, {+ columnKey: "column-2",+ comments: [{ author: { name: "Grace" }, body: "Hi" }],+ toMarkdown,+ }),+ ).toEqual({+ key: "10042",+ number: 42,+ columnKey: "column-2",+ title: "Fix login",+ description: "Steps",+ priority: "high",+ dueDate: "2024-05-01T00:00:00.000Z",+ createdAt: "2024-04-01T06:30:00.000Z",+ assignee: { name: "Ada Lovelace" },+ labelKeys: ["auth", "ux"],+ comments: [{ author: { name: "Grace" }, body: "Hi" }],+ });+ });++ it("falls back to the issue key as title and leaves out empty fields", () => {+ expect(+ mapIssue(+ { id: "1", key: "ABC-1", fields: { summary: " " } },+ { columnKey: null, comments: [], toMarkdown },+ ),+ ).toEqual({+ key: "1",+ number: 1,+ columnKey: null,+ title: "ABC-1",+ description: "",+ priority: "no-priority",+ labelKeys: [],+ comments: [],+ });+ });+});diff --git a/packages/importers/src/jira/mapping.ts b/packages/importers/src/jira/mapping.tsnew file mode 100644index 000000000..bb94faefd--- /dev/null+++ b/packages/importers/src/jira/mapping.ts@@ -0,0 +1,75 @@+import { toIsoDate } from "../markdown.js";+import type {+ ImportedComment,+ ImportedPriority,+ ImportedTask,+} from "../types.js";+import type { JiraIssue } from "./api-types.js";+import type { HtmlToMarkdown } from "./html.js";+import { issueLabels } from "./labels.js";+import { toPerson } from "./people.js";++const PRIORITIES: ReadonlyMap<string, ImportedPriority> = new Map([+ ["highest", "urgent"],+ ["blocker", "urgent"],+ ["critical", "urgent"],+ ["high", "high"],+ ["major", "high"],+ ["medium", "medium"],+ ["low", "low"],+ ["minor", "low"],+ ["lowest", "low"],+ ["trivial", "low"],+]);++export type IssueContext = {+ columnKey: string | null;+ comments: ImportedComment[];+ toMarkdown: HtmlToMarkdown;+};++export function mapPriority(name: string | null | undefined): ImportedPriority {+ return PRIORITIES.get(name?.trim().toLowerCase() ?? "") ?? "no-priority";+}++export function issueNumber(+ key: string | null | undefined,+): number | undefined {+ const digits = /-(\d+)$/.exec(key?.trim() ?? "")?.[1];+ const number = digits ? Number(digits) : Number.NaN;+ return Number.isSafeInteger(number) && number > 0 ? number : undefined;+}++export function issueDescription(+ issue: JiraIssue,+ toMarkdown: HtmlToMarkdown,+): string {+ const rendered = issue.renderedFields?.description;+ if (typeof rendered === "string") return toMarkdown(rendered);+ const raw = issue.fields?.description;+ return typeof raw === "string" ? raw.trim() : "";+}++export function mapIssue(+ issue: JiraIssue,+ context: IssueContext,+): ImportedTask {+ const fields = issue.fields ?? {};+ const number = issueNumber(issue.key);+ const dueDate = toIsoDate(fields.duedate);+ const createdAt = toIsoDate(fields.created);+ const assignee = toPerson(fields.assignee);+ return {+ key: issue.id,+ ...(number !== undefined ? { number } : {}),+ columnKey: context.columnKey,+ title: fields.summary?.trim() || issue.key || "Untitled",+ description: issueDescription(issue, context.toMarkdown),+ priority: mapPriority(fields.priority?.name),+ ...(dueDate ? { dueDate } : {}),+ ...(createdAt ? { createdAt } : {}),+ ...(assignee ? { assignee } : {}),+ labelKeys: issueLabels(issue),+ comments: context.comments,+ };+}diff --git a/packages/importers/src/jira/people.ts b/packages/importers/src/jira/people.tsnew file mode 100644index 000000000..687a71802--- /dev/null+++ b/packages/importers/src/jira/people.ts@@ -0,0 +1,11 @@+import type { ImportedPerson } from "../types.js";+import type { JiraUser } from "./api-types.js";++export function toPerson(+ user: JiraUser | null | undefined,+): ImportedPerson | undefined {+ const name = user?.displayName?.trim();+ const email = user?.emailAddress?.trim();+ if (!name && !email) return undefined;+ return { ...(name ? { name } : {}), ...(email ? { email } : {}) };+}diff --git a/packages/importers/src/jira/project.test.ts b/packages/importers/src/jira/project.test.tsnew file mode 100644index 000000000..472ffc327--- /dev/null+++ b/packages/importers/src/jira/project.test.ts@@ -0,0 +1,162 @@+import { describe, expect, it } from "vite-plus/test";+import type { JiraIssue, JiraStatus } from "./api-types.js";+import { mapJiraProject } from "./project.js";+import { BOARD_UNAVAILABLE_WARNING } from "./warnings.js";++const BACKLOG: JiraStatus = {+ id: "1",+ name: "Backlog",+ statusCategory: { key: "new" },+};+const TODO: JiraStatus = {+ id: "2",+ name: "To Do",+ statusCategory: { key: "new" },+};+const DOING: JiraStatus = {+ id: "3",+ name: "In Progress",+ statusCategory: { key: "indeterminate" },+};+const DONE: JiraStatus = {+ id: "4",+ name: "Done",+ statusCategory: { key: "done" },+};++function issue(+ id: string,+ status: JiraStatus,+ fields: JiraIssue["fields"] = {},+): JiraIssue {+ return {+ id,+ key: `ABC-${id}`,+ fields: { summary: `Issue ${id}`, status, ...fields },+ };+}++const ISSUES = [+ issue("10", DONE, { attachment: [{}], parent: { id: "11" } }),+ issue("11", DOING, { labels: ["ux"] }),+ issue("12", BACKLOG),+ issue("13", TODO, {+ attachment: [],+ issuelinks: [+ { type: { name: "Blocks" }, outwardIssue: { id: "11" } },+ { type: { name: "Relates" }, outwardIssue: { id: "999" } },+ ],+ }),+ issue("14", DOING),+];++function project(+ overrides: Partial<Parameters<typeof mapJiraProject>[0]> = {},+) {+ return mapJiraProject({+ baseUrl: "https://acme.atlassian.net",+ project: { id: "100", key: "ABC", name: " Alpha ", description: " Core " },+ statusGroups: [{ name: "Task", statuses: [BACKLOG, TODO, DOING, DONE] }],+ boardColumns: [+ { name: "Backlog", statuses: [{ id: "1" }] },+ { name: "To Do", statuses: [{ id: "2" }] },+ { name: "In Progress", statuses: [{ id: "3" }] },+ { name: "Done", statuses: [{ id: "4" }] },+ ],+ boardUnavailable: false,+ issues: ISSUES,+ comments: new Map([+ [+ "11",+ [+ {+ author: { displayName: "Ada" },+ renderedBody: "<p>Looks good</p>",+ created: "2024-01-02T00:00:00.000+0000",+ },+ ],+ ],+ ]),+ ...overrides,+ });+}++describe("mapJiraProject", () => {+ it("places issues in board columns, backlog first, keeping rank order", () => {+ const result = project();++ expect(result.name).toBe("Alpha");+ expect(result.key).toBe("ABC");+ expect(result.description).toBe("Core");+ expect(result.columns).toEqual([+ { key: "column-2", name: "To Do", isFinal: false },+ { key: "column-3", name: "In Progress", isFinal: false },+ { key: "column-4", name: "Done", isFinal: true },+ ]);+ expect(result.tasks.map((task) => [task.key, task.columnKey])).toEqual([+ ["12", null],+ ["13", "column-2"],+ ["11", "column-3"],+ ["14", "column-3"],+ ["10", "column-4"],+ ]);+ expect(result.tasks.find((task) => task.key === "11")?.comments).toEqual([+ {+ author: { name: "Ada" },+ body: "Looks good",+ createdAt: "2024-01-02T00:00:00.000Z",+ },+ ]);+ expect(result.labels.map((label) => label.key)).toEqual(["ux"]);+ expect(result.relations).toEqual([+ { sourceKey: "11", targetKey: "10", type: "subtask" },+ { sourceKey: "13", targetKey: "11", type: "blocks" },+ ]);+ expect(result.warnings).toEqual([+ "1 issue has attachments, which are not imported.",+ "1 parent or issue link points to another project, so it was not imported.",+ ]);+ });++ it("falls back to status columns and warns when the board was not shared", () => {+ const result = project({ boardColumns: null, boardUnavailable: true });++ expect(result.columns).toEqual([+ { key: "2", name: "To Do", isFinal: false },+ { key: "3", name: "In Progress", isFinal: false },+ { key: "4", name: "Done", isFinal: true },+ ]);+ expect(result.tasks.map((task) => task.columnKey)).toEqual([+ null,+ "2",+ "3",+ "3",+ "4",+ ]);+ expect(result.warnings).toContain(BOARD_UNAVAILABLE_WARNING);+ });++ it("uses statuses quietly when the project has no board", () => {+ const result = project({ boardColumns: null, issues: [] });+ expect(result.columns.map((column) => column.key)).toEqual(["2", "3", "4"]);+ expect(result.tasks).toEqual([]);+ expect(result.warnings).toEqual([]);+ });++ it("uses statuses when the board has no usable columns", () => {+ const result = project({+ boardColumns: [{ name: "Backlog", statuses: [{ id: "1" }] }],+ issues: [],+ });+ expect(result.columns.map((column) => column.key)).toEqual(["2", "3", "4"]);+ });++ it("falls back to the key when the project has no name", () => {+ const result = project({+ project: { id: "100", key: "ABC", name: " " },+ issues: [],+ });+ expect(result.name).toBe("ABC");+ expect(result).not.toHaveProperty("description");+ });+});diff --git a/packages/importers/src/jira/project.ts b/packages/importers/src/jira/project.tsnew file mode 100644index 000000000..77f73acdc--- /dev/null+++ b/packages/importers/src/jira/project.ts@@ -0,0 +1,108 @@+import type { ImportedProject } from "../types.js";+import type {+ JiraBoardColumn,+ JiraComment,+ JiraIssue,+ JiraIssueTypeStatuses,+ JiraProject,+ JiraStatus,+} from "./api-types.js";+import {+ type ColumnPlan,+ collectStatuses,+ planBoardColumns,+ planStatusColumns,+ resolveColumnKey,+ type StatusCategories,+ statusCategories,+} from "./columns.js";+import { mapComments } from "./comments.js";+import { createJiraHtmlToMarkdown } from "./html.js";+import { mapLabels } from "./labels.js";+import { mapIssue } from "./mapping.js";+import { mapRelations } from "./relations.js";+import { buildWarnings } from "./warnings.js";++export type JiraProjectData = {+ baseUrl: string;+ project: JiraProject;+ statusGroups: JiraIssueTypeStatuses[];+ boardColumns: JiraBoardColumn[] | null;+ boardUnavailable: boolean;+ issues: JiraIssue[];+ comments: ReadonlyMap<string, JiraComment[]>;+};++export function mapJiraProject(data: JiraProjectData): ImportedProject {+ const statuses = collectStatuses(data.statusGroups, data.issues);+ const categories = statusCategories(statuses);+ const plan = choosePlan(data.boardColumns, statuses, categories);+ const toMarkdown = createJiraHtmlToMarkdown(data.baseUrl);+ const placed = sortByColumn(data.issues, plan, categories);+ const { relations, external } = mapRelations(data.issues);+ const description = data.project.description?.trim();++ return {+ name: data.project.name?.trim() || data.project.key,+ key: data.project.key,+ ...(description ? { description } : {}),+ columns: plan.columns,+ labels: mapLabels(data.issues),+ tasks: placed.map(({ issue, columnKey }) =>+ mapIssue(issue, {+ columnKey,+ comments: mapComments(data.comments.get(issue.id) ?? [], toMarkdown),+ toMarkdown,+ }),+ ),+ relations,+ warnings: buildWarnings({+ issuesWithAttachments: data.issues.filter(+ (issue) => (issue.fields?.attachment?.length ?? 0) > 0,+ ).length,+ externalLinks: external,+ boardUnavailable: data.boardUnavailable,+ }),+ };+}++function choosePlan(+ boardColumns: JiraBoardColumn[] | null,+ statuses: JiraStatus[],+ categories: StatusCategories,+): ColumnPlan {+ const board = boardColumns+ ? planBoardColumns(boardColumns, categories)+ : null;+ return board && board.columns.length > 0+ ? board+ : planStatusColumns(statuses);+}++function sortByColumn(+ issues: JiraIssue[],+ plan: ColumnPlan,+ categories: StatusCategories,+): Array<{ issue: JiraIssue; columnKey: string | null }> {+ const rank = new Map(+ plan.columns.map((column, index) => [column.key, index]),+ );+ return issues+ .map((issue, index) => ({+ issue,+ index,+ columnKey: resolveColumnKey(plan, issue.fields?.status?.id, categories),+ }))+ .sort(+ (a, b) =>+ columnRank(a.columnKey, rank) - columnRank(b.columnKey, rank) ||+ a.index - b.index,+ );+}++function columnRank(+ columnKey: string | null,+ rank: ReadonlyMap<string, number>,+): number {+ return columnKey === null ? -1 : (rank.get(columnKey) ?? rank.size);+}diff --git a/packages/importers/src/jira/read-comments.ts b/packages/importers/src/jira/read-comments.tsnew file mode 100644index 000000000..cd03e1522--- /dev/null+++ b/packages/importers/src/jira/read-comments.ts@@ -0,0 +1,62 @@+import { SourceHttpError } from "../http.js";+import type { JiraComment, JiraIssue } from "./api-types.js";+import { COMMENTS_PAGE_SIZE, type JiraClient } from "./client.js";++export const COMMENT_PROGRESS_STEP = 10;++export async function readComments(+ client: JiraClient,+ issues: JiraIssue[],+ onProgress?: (message: string) => void,+): Promise<Map<string, JiraComment[]>> {+ const commented = issues.filter(hasComments);+ const byIssue = new Map<string, JiraComment[]>();++ for (const [index, issue] of commented.entries()) {+ byIssue.set(issue.id, await readIssueComments(client, issue.id));+ const done = index + 1;+ if (done % COMMENT_PROGRESS_STEP === 0 || done === commented.length) {+ onProgress?.(`Reading comments (${done} of ${commented.length})`);+ }+ }++ return byIssue;+}++export function hasComments(issue: JiraIssue): boolean {+ const total = issue.fields?.comment?.total;+ return typeof total !== "number" || total > 0;+}++async function readIssueComments(+ client: JiraClient,+ issueId: string,+): Promise<JiraComment[]> {+ const comments: JiraComment[] = [];+ try {+ for (;;) {+ const page = await client.comments(issueId, comments.length);+ const batch = page?.comments ?? [];+ comments.push(...batch);+ if (isLastPage(batch.length, comments.length, page?.total)) {+ return comments;+ }+ }+ } catch (error) {+ if (!(error instanceof SourceHttpError) || error.status !== 404) {+ throw error;+ }+ return comments;+ }+}++function isLastPage(+ received: number,+ loaded: number,+ total: number | null | undefined,+): boolean {+ if (received === 0) return true;+ return typeof total === "number"+ ? loaded >= total+ : received < COMMENTS_PAGE_SIZE;+}diff --git a/packages/importers/src/jira/read-project.ts b/packages/importers/src/jira/read-project.tsnew file mode 100644index 000000000..fec118bea--- /dev/null+++ b/packages/importers/src/jira/read-project.ts@@ -0,0 +1,59 @@+import { SourceHttpError } from "../http.js";+import type { ImportedProject, ReadProjectOptions } from "../types.js";+import type { JiraComment, JiraProject } from "./api-types.js";+import { readBoardColumns } from "./board.js";+import type { JiraClient } from "./client.js";+import { mapJiraProject } from "./project.js";+import { readComments } from "./read-comments.js";+import { searchProjectIssues } from "./search.js";++export async function readJiraProject(+ client: JiraClient,+ baseUrl: string,+ projectKey: string,+ options: ReadProjectOptions,+): Promise<ImportedProject> {+ const { onProgress } = options;++ onProgress?.("Reading project and board");+ const project = await readProjectDetails(client, projectKey);+ const statusGroups = await client.projectStatuses(project.key);+ const board = await readBoardColumns(client, project.key);++ onProgress?.("Reading issues");+ const issues = await searchProjectIssues(client, project.key, {+ includeComments: options.includeComments,+ onPage: (loaded) => onProgress?.(`Reading issues (${loaded} so far)`),+ });++ let comments = new Map<string, JiraComment[]>();+ if (options.includeComments && issues.length > 0) {+ comments = await readComments(client, issues, onProgress);+ }++ return mapJiraProject({+ baseUrl,+ project,+ statusGroups,+ boardColumns: board.columns,+ boardUnavailable: board.unavailable,+ issues,+ comments,+ });+}++async function readProjectDetails(+ client: JiraClient,+ projectKey: string,+): Promise<JiraProject> {+ try {+ return await client.getProject(projectKey);+ } catch (error) {+ if (error instanceof SourceHttpError && error.status === 404) {+ throw new Error(+ `Jira could not find the project "${projectKey}", or this account cannot browse it.`,+ );+ }+ throw error;+ }+}diff --git a/packages/importers/src/jira/relations.test.ts b/packages/importers/src/jira/relations.test.tsnew file mode 100644index 000000000..156e7cce0--- /dev/null+++ b/packages/importers/src/jira/relations.test.ts@@ -0,0 +1,99 @@+import { describe, expect, it } from "vite-plus/test";+import type { JiraIssue, JiraIssueLink } from "./api-types.js";+import { isBlocksLink, mapRelations } from "./relations.js";++const BLOCKS = { name: "Blocks", inward: "is blocked by", outward: "blocks" };+const RELATES = {+ name: "Relates",+ inward: "relates to",+ outward: "relates to",+};+const DUPLICATE = {+ name: "Duplicate",+ inward: "is duplicated by",+ outward: "duplicates",+};++function issue(+ id: string,+ links: JiraIssueLink[] = [],+ parent?: string,+): JiraIssue {+ return {+ id,+ key: `ABC-${id}`,+ fields: {+ issuelinks: links,+ ...(parent ? { parent: { id: parent } } : {}),+ },+ };+}++describe("mapRelations", () => {+ it("maps parents to subtasks inside the project", () => {+ const result = mapRelations([issue("1"), issue("2", [], "1")]);+ expect(result).toEqual({+ relations: [{ sourceKey: "1", targetKey: "2", type: "subtask" }],+ external: 0,+ });+ });++ it("keeps the blocking direction from both sides and adds it once", () => {+ const result = mapRelations([+ issue("1", [{ type: BLOCKS, outwardIssue: { id: "2" } }]),+ issue("2", [{ type: BLOCKS, inwardIssue: { id: "1" } }]),+ issue("3", [{ type: BLOCKS, inwardIssue: { id: "2" } }]),+ ]);+ expect(result.relations).toEqual([+ { sourceKey: "1", targetKey: "2", type: "blocks" },+ { sourceKey: "2", targetKey: "3", type: "blocks" },+ ]);+ });++ it("turns every other link type into one related link per pair", () => {+ const result = mapRelations([+ issue("1", [+ { type: RELATES, outwardIssue: { id: "2" } },+ { type: DUPLICATE, inwardIssue: { id: "3" } },+ ]),+ issue("2", [{ type: RELATES, inwardIssue: { id: "1" } }]),+ issue("3", [+ { type: DUPLICATE, outwardIssue: { id: "1" } },+ { type: { name: "Cloners" }, outwardIssue: { id: "2" } },+ ]),+ ]);+ expect(result.relations).toEqual([+ { sourceKey: "1", targetKey: "2", type: "related" },+ { sourceKey: "3", targetKey: "1", type: "related" },+ { sourceKey: "3", targetKey: "2", type: "related" },+ ]);+ });++ it("drops and counts parents and links that point outside the project", () => {+ const result = mapRelations([+ issue(+ "1",+ [+ { type: BLOCKS, outwardIssue: { id: "99" } },+ { type: RELATES, inwardIssue: { id: "98" } },+ { type: RELATES, outwardIssue: { id: "98" } },+ ],+ "97",+ ),+ issue("2", [{ type: BLOCKS, outwardIssue: { id: "99" } }]),+ issue("3", [{ type: RELATES, outwardIssue: { id: "3" } }]),+ ]);+ expect(result).toEqual({ relations: [], external: 4 });+ });+});++describe("isBlocksLink", () => {+ it("recognizes renamed blocks links by their outward wording", () => {+ expect(isBlocksLink({ type: BLOCKS })).toBe(true);+ expect(+ isBlocksLink({ type: { name: "Dependency", outward: "Blocks" } }),+ ).toBe(true);+ expect(isBlocksLink({ type: RELATES })).toBe(false);+ expect(isBlocksLink({})).toBe(false);+ });+});diff --git a/packages/importers/src/jira/relations.ts b/packages/importers/src/jira/relations.tsnew file mode 100644index 000000000..4db5f0910--- /dev/null+++ b/packages/importers/src/jira/relations.ts@@ -0,0 +1,55 @@+import type { ImportedRelation, ImportedRelationType } from "../types.js";+import type { JiraIssue, JiraIssueLink } from "./api-types.js";++export type RelationsResult = {+ relations: ImportedRelation[];+ external: number;+};++export function mapRelations(issues: JiraIssue[]): RelationsResult {+ const issueIds = new Set(issues.map((issue) => issue.id));+ const seen = new Set<string>();+ const external = new Set<string>();+ const relations: ImportedRelation[] = [];++ function add(+ sourceKey: string | undefined,+ targetKey: string | undefined,+ type: ImportedRelationType,+ ): void {+ if (!sourceKey || !targetKey || sourceKey === targetKey) return;+ const pair =+ type === "related"+ ? [sourceKey, targetKey].sort().join(":")+ : `${sourceKey}:${targetKey}`;+ const id = `${type}:${pair}`;+ if (!issueIds.has(sourceKey) || !issueIds.has(targetKey)) {+ external.add(id);+ return;+ }+ if (seen.has(id)) return;+ seen.add(id);+ relations.push({ sourceKey, targetKey, type });+ }++ for (const issue of issues) {+ add(issue.fields?.parent?.id, issue.id, "subtask");+ for (const link of issue.fields?.issuelinks ?? []) {+ const blocks = isBlocksLink(link);+ if (link.outwardIssue) {+ add(issue.id, link.outwardIssue.id, blocks ? "blocks" : "related");+ }+ if (link.inwardIssue) {+ add(link.inwardIssue.id, issue.id, blocks ? "blocks" : "related");+ }+ }+ }++ return { relations, external: external.size };+}++export function isBlocksLink(link: JiraIssueLink): boolean {+ const name = link.type?.name?.trim().toLowerCase();+ const outward = link.type?.outward?.trim().toLowerCase();+ return name === "blocks" || outward === "blocks";+}diff --git a/packages/importers/src/jira/search.ts b/packages/importers/src/jira/search.tsnew file mode 100644index 000000000..79bacd56c--- /dev/null+++ b/packages/importers/src/jira/search.ts@@ -0,0 +1,119 @@+import { SourceHttpError } from "../http.js";+import type { JiraIssue } from "./api-types.js";+import {+ type JiraClient,+ SEARCH_PAGE_SIZE,+ type SearchQuery,+} from "./client.js";++export const ISSUE_FIELDS = [+ "summary",+ "description",+ "status",+ "priority",+ "assignee",+ "labels",+ "duedate",+ "created",+ "parent",+ "issuelinks",+ "attachment",+];++export const RANK_ORDER = "ORDER BY Rank ASC";+export const CREATED_ORDER = "ORDER BY created ASC";++export type SearchOptions = {+ includeComments: boolean;+ onPage?: (loaded: number) => void;+};++export async function searchProjectIssues(+ client: JiraClient,+ projectKey: string,+ options: SearchOptions,+): Promise<JiraIssue[]> {+ const scope = `project = ${quoteJql(projectKey)}`;+ const fields = options.includeComments+ ? [...ISSUE_FIELDS, "comment"]+ : ISSUE_FIELDS;+ let loaded = 0;+ const onPage = (count: number) => {+ loaded = count;+ options.onPage?.(count);+ };++ try {+ return await searchAll(+ client,+ { jql: `${scope} ${RANK_ORDER}`, fields },+ onPage,+ );+ } catch (error) {+ if (+ !(error instanceof SourceHttpError) ||+ error.status !== 400 ||+ loaded > 0+ ) {+ throw error;+ }+ }+ return searchAll(+ client,+ { jql: `${scope} ${CREATED_ORDER}`, fields },+ onPage,+ );+}++export function quoteJql(value: string): string {+ return `"${value.replace(/["\\]/g, "\\$&")}"`;+}++function searchAll(+ client: JiraClient,+ query: SearchQuery,+ onPage: (loaded: number) => void,+): Promise<JiraIssue[]> {+ return client.cloud+ ? searchByToken(client, query, onPage)+ : searchByOffset(client, query, onPage);+}++async function searchByToken(+ client: JiraClient,+ query: SearchQuery,+ onPage: (loaded: number) => void,+): Promise<JiraIssue[]> {+ const issues: JiraIssue[] = [];+ const seenTokens = new Set<string>();+ let token: string | undefined;+ for (;;) {+ const page = await client.searchCloud(query, token);+ issues.push(...(page?.issues ?? []));+ onPage(issues.length);+ const next = page?.nextPageToken ?? undefined;+ if (!next || page?.isLast === true || seenTokens.has(next)) return issues;+ seenTokens.add(next);+ token = next;+ }+}++async function searchByOffset(+ client: JiraClient,+ query: SearchQuery,+ onPage: (loaded: number) => void,+): Promise<JiraIssue[]> {+ const issues: JiraIssue[] = [];+ for (;;) {+ const page = await client.searchServer(query, issues.length);+ const batch = page?.issues ?? [];+ issues.push(...batch);+ onPage(issues.length);+ const total = page?.total;+ const done =+ typeof total === "number"+ ? issues.length >= total+ : batch.length < SEARCH_PAGE_SIZE;+ if (batch.length === 0 || done) return issues;+ }+}diff --git a/packages/importers/src/jira/source.test.ts b/packages/importers/src/jira/source.test.tsnew file mode 100644index 000000000..f79023ff1--- /dev/null+++ b/packages/importers/src/jira/source.test.ts@@ -0,0 +1,759 @@+import { describe, expect, it } from "vite-plus/test";+import type { FetchLike } from "../types.js";+import {+ CLOUD_REJECTED_MESSAGE,+ MISSING_EMAIL_MESSAGE,+ SERVER_REJECTED_MESSAGE,+} from "./auth.js";+import { connectJira } from "./index.js";+import { NOT_JIRA_MESSAGE } from "./source.js";+import { BOARD_UNAVAILABLE_WARNING } from "./warnings.js";++const TOKEN = "jira-secret-token";+const CLOUD_URL =+ "https://acme.atlassian.net/jira/software/projects/ABC/boards/7";+const SERVER_URL = "https://example.com/jira/secure/Dashboard.jspa";++type Request = {+ method: string;+ url: URL;+ headers: Headers;+ body: Record<string, unknown> | null;+};+type Handler = (request: Request) => unknown;++class Reply {+ constructor(+ readonly status: number,+ readonly body: unknown = { errorMessages: ["Nope"], errors: {} },+ ) {}+}++function fakeJira(routes: Record<string, Handler | unknown>) {+ const calls: Request[] = [];+ const fetch: FetchLike = async (input, init) => {+ const url = new URL(input);+ const method = init?.method ?? "GET";+ const request: Request = {+ method,+ url,+ headers: new Headers(init?.headers),+ body: init?.body+ ? (JSON.parse(String(init.body)) as Record<string, unknown>)+ : null,+ };+ calls.push(request);+ const route = routes[`${method} ${url.pathname}`];+ const value =+ typeof route === "function" ? (route as Handler)(request) : route;+ if (value === undefined) {+ return json(404, { errorMessages: ["Not found"], errors: {} });+ }+ if (value instanceof Reply) return json(value.status, value.body);+ return json(200, value);+ };+ const paths = (method?: string) =>+ calls+ .filter((call) => !method || call.method === method)+ .map((call) => `${call.method} ${call.url.pathname}`);+ return { fetch, calls, paths };+}++function json(status: number, body: unknown) {+ return new Response(typeof body === "string" ? body : JSON.stringify(body), {+ status,+ headers: { "Content-Type": "application/json" },+ });+}++const STATUSES = {+ backlog: { id: "1", name: "Backlog", statusCategory: { key: "new" } },+ todo: {+ id: "2",+ name: "Selected for Development",+ statusCategory: { key: "new" },+ },+ doing: {+ id: "3",+ name: "In Progress",+ statusCategory: { key: "indeterminate" },+ },+ done: { id: "4", name: "Done", statusCategory: { key: "done" } },+};++const STATUS_GROUPS = [+ {+ id: "10001",+ name: "Task",+ subtask: false,+ statuses: [STATUSES.backlog, STATUSES.todo, STATUSES.doing, STATUSES.done],+ },+ {+ id: "10002",+ name: "Sub-task",+ subtask: true,+ statuses: [STATUSES.todo, STATUSES.done],+ },+];++const BOARD_CONFIG = {+ id: 7,+ name: "ABC board",+ type: "kanban",+ columnConfig: {+ columns: [+ { name: "Backlog", statuses: [{ id: "1" }] },+ { name: "Selected for Development", statuses: [{ id: "2" }] },+ { name: "In Progress", statuses: [{ id: "3" }] },+ { name: "Done", statuses: [{ id: "4" }] },+ ],+ },+};++function issue(+ id: string,+ number: number,+ fields: Record<string, unknown>,+ description = "",+) {+ return {+ id,+ key: `ABC-${number}`,+ fields: {+ summary: `Issue ${number}`,+ status: STATUSES.todo,+ priority: { name: "Medium" },+ labels: [],+ issuelinks: [],+ attachment: [],+ created: "2024-01-01T10:00:00.000+0000",+ ...fields,+ },+ renderedFields: { description },+ };+}++const ISSUE_PAGE_1 = [+ issue(+ "101",+ 1,+ {+ status: STATUSES.doing,+ priority: { name: "Highest" },+ assignee: {+ accountId: "a1",+ displayName: "Ada Lovelace",+ emailAddress: "[email protected]",+ },+ labels: ["frontend"],+ duedate: "2024-06-30",+ issuelinks: [+ {+ type: { name: "Blocks", inward: "is blocked by", outward: "blocks" },+ outwardIssue: { id: "103", key: "ABC-3" },+ },+ ],+ comment: { comments: [], total: 2 },+ },+ '<p>Ship it, cc <a href="/secure/ViewProfile.jspa?accountId=a2" class="user-hover" data-account-id="a2">Grace Hopper</a></p>',+ ),+ issue("102", 2, {+ status: STATUSES.backlog,+ priority: { name: "Low" },+ attachment: [{ id: "a" }],+ comment: { comments: [], total: 0 },+ }),+];++const ISSUE_PAGE_2 = [+ issue("103", 3, {+ status: STATUSES.done,+ parent: { id: "101", key: "ABC-1" },+ issuelinks: [+ {+ type: { name: "Blocks", inward: "is blocked by", outward: "blocks" },+ inwardIssue: { id: "101", key: "ABC-1" },+ },+ {+ type: { name: "Relates", inward: "relates to", outward: "relates to" },+ outwardIssue: { id: "900", key: "OPS-9" },+ },+ ],+ comment: { comments: [], total: 0 },+ }),+];++function cloudRoutes(extra: Record<string, Handler | unknown> = {}) {+ return {+ "GET /rest/api/3/myself": { accountId: "a1", displayName: "Ada Lovelace" },+ "GET /rest/api/3/project/search": (request: Request) =>+ request.url.searchParams.get("startAt") === "0"+ ? {+ values: [+ {+ id: "100",+ key: "ABC",+ name: "Alpha",+ projectTypeKey: "software",+ },+ ],+ isLast: false,+ }+ : {+ values: [+ {+ id: "200",+ key: "OPS",+ name: "Operations",+ projectTypeKey: "business",+ },+ ],+ isLast: true,+ },+ "GET /rest/api/3/project/ABC": {+ id: "100",+ key: "ABC",+ name: "Alpha",+ description: "Core product",+ },+ "GET /rest/api/3/project/ABC/statuses": STATUS_GROUPS,+ "GET /rest/agile/1.0/board": {+ values: [+ { id: 3, type: "scrum", location: { projectKey: "OPS" } },+ { id: 7, type: "kanban", location: { projectKey: "ABC" } },+ ],+ },+ "GET /rest/agile/1.0/board/7/configuration": BOARD_CONFIG,+ "POST /rest/api/3/search/jql": (request: Request) =>+ request.body?.nextPageToken === "page-2"+ ? { issues: ISSUE_PAGE_2, isLast: true }+ : { issues: ISSUE_PAGE_1, nextPageToken: "page-2", isLast: false },+ "GET /rest/api/3/issue/101/comment": (request: Request) =>+ request.url.searchParams.get("startAt") === "0"+ ? {+ startAt: 0,+ maxResults: 1,+ total: 2,+ comments: [+ {+ id: "c2",+ author: { displayName: "Grace Hopper" },+ renderedBody: "<p>Second</p>",+ created: "2024-02-02T10:00:00.000+0000",+ },+ ],+ }+ : {+ startAt: 1,+ maxResults: 1,+ total: 2,+ comments: [+ {+ id: "c1",+ author: {+ displayName: "Ada Lovelace",+ emailAddress: "[email protected]",+ },+ renderedBody: "<p>First <b>note</b></p>",+ created: "2024-02-01T10:00:00.000+0000",+ },+ ],+ },+ ...extra,+ };+}++function serverIssues() {+ return [+ issue("201", 1, { status: STATUSES.todo, comment: { total: 0 } }),+ issue("202", 2, { status: STATUSES.done, comment: { total: 0 } }),+ issue("203", 3, { status: STATUSES.doing, comment: { total: 0 } }),+ ];+}++function serverRoutes(extra: Record<string, Handler | unknown> = {}) {+ return {+ "GET /jira/rest/api/2/myself": {+ key: "JIRAUSER1",+ name: "fred",+ displayName: "Fred",+ },+ "GET /jira/rest/api/2/project": [+ { id: "1", key: "ABC", name: "Alpha", projectTypeKey: "software" },+ { id: "2", key: "LEG", name: "Legacy" },+ ],+ "GET /jira/rest/api/2/project/ABC": { id: "1", key: "ABC", name: "Alpha" },+ "GET /jira/rest/api/2/project/ABC/statuses": STATUS_GROUPS,+ "GET /jira/rest/api/2/search": (request: Request) => {+ const startAt = Number(request.url.searchParams.get("startAt"));+ const issues = serverIssues();+ return {+ startAt,+ maxResults: 2,+ total: issues.length,+ issues: issues.slice(startAt, startAt + 2),+ };+ },+ ...extra,+ };+}++describe("connectJira", () => {+ it("signs in to Jira Cloud with Basic auth and REST API v3", async () => {+ const jira = fakeJira(cloudRoutes());+ await connectJira(+ { url: CLOUD_URL, email: " [email protected] ", apiToken: ` ${TOKEN} ` },+ { fetch: jira.fetch },+ );++ expect(jira.paths()).toEqual(["GET /rest/api/3/myself"]);+ const call = jira.calls[0];+ expect(call?.url.origin).toBe("https://acme.atlassian.net");+ expect(call?.headers.get("authorization")).toBe(+ `Basic ${Buffer.from(`[email protected]:${TOKEN}`).toString("base64")}`,+ );+ expect(call?.url.href).not.toContain(TOKEN);+ });++ it("uses a bearer token and REST API v2 on Data Center", async () => {+ const jira = fakeJira(serverRoutes());+ await connectJira(+ { url: SERVER_URL, apiToken: TOKEN },+ { fetch: jira.fetch },+ );++ expect(jira.calls[0]?.url.href).toBe(+ "https://example.com/jira/rest/api/2/myself",+ );+ expect(jira.calls[0]?.headers.get("authorization")).toBe(`Bearer ${TOKEN}`);+ });++ it("uses Basic auth on Data Center when an email is given", async () => {+ const jira = fakeJira(serverRoutes());+ await connectJira(+ { url: SERVER_URL, email: "[email protected]", apiToken: TOKEN },+ { fetch: jira.fetch },+ );+ expect(jira.calls[0]?.headers.get("authorization")).toBe(+ `Basic ${Buffer.from(`[email protected]:${TOKEN}`).toString("base64")}`,+ );+ });++ it("asks for the account email on Jira Cloud before calling Jira", async () => {+ const jira = fakeJira(cloudRoutes());+ await expect(+ connectJira({ url: CLOUD_URL, apiToken: TOKEN }, { fetch: jira.fetch }),+ ).rejects.toThrow(MISSING_EMAIL_MESSAGE);+ expect(jira.calls).toHaveLength(0);+ });++ it.each([+ [+ CLOUD_URL,+ "[email protected]",+ "GET /rest/api/3/myself",+ CLOUD_REJECTED_MESSAGE,+ ],+ [+ SERVER_URL,+ undefined,+ "GET /jira/rest/api/2/myself",+ SERVER_REJECTED_MESSAGE,+ ],+ ])(+ "explains rejected credentials for %s",+ async (url, email, route, message) => {+ const jira = fakeJira({ [route]: new Reply(401, { message: TOKEN }) });+ const error = await connectJira(+ { url, ...(email ? { email } : {}), apiToken: TOKEN },+ { fetch: jira.fetch },+ ).catch((caught: unknown) => caught as Error);++ expect(error).toBeInstanceOf(Error);+ expect((error as Error).message).toBe(message);+ expect((error as Error).message).not.toContain(TOKEN);+ },+ );++ it("rejects addresses that are not Jira", async () => {+ const missing = fakeJira({});+ await expect(+ connectJira(+ { url: "https://example.org", apiToken: TOKEN },+ { fetch: missing.fetch },+ ),+ ).rejects.toThrow(NOT_JIRA_MESSAGE);++ const html = fakeJira({ "GET /rest/api/2/myself": "<html>Sign in</html>" });+ await expect(+ connectJira(+ { url: "https://example.org", apiToken: TOKEN },+ { fetch: html.fetch },+ ),+ ).rejects.toThrow(NOT_JIRA_MESSAGE);+ });+});++describe("listProjects", () => {+ it("pages through Jira Cloud projects", async () => {+ const jira = fakeJira(cloudRoutes());+ const source = await connectJira(+ { url: CLOUD_URL, email: "[email protected]", apiToken: TOKEN },+ { fetch: jira.fetch },+ );++ expect(await source.listProjects()).toEqual([+ { id: "ABC", name: "Alpha", detail: "ABC · Software" },+ { id: "OPS", name: "Operations", detail: "OPS · Business" },+ ]);+ const pages = jira.calls.filter((call) =>+ call.url.pathname.endsWith("/project/search"),+ );+ expect(pages.map((call) => call.url.searchParams.get("startAt"))).toEqual([+ "0",+ "1",+ ]);+ expect(pages[0]?.url.searchParams.get("maxResults")).toBe("50");+ });++ it("reads the full project list on Data Center", async () => {+ const jira = fakeJira(serverRoutes());+ const source = await connectJira(+ { url: SERVER_URL, apiToken: TOKEN },+ { fetch: jira.fetch },+ );+ expect(await source.listProjects()).toEqual([+ { id: "ABC", name: "Alpha", detail: "ABC · Software" },+ { id: "LEG", name: "Legacy", detail: "LEG" },+ ]);+ });+});++describe("readProject on Jira Cloud", () => {+ it("reads the board, pages issues by token, reads comments and maps the project", async () => {+ const jira = fakeJira(cloudRoutes());+ const source = await connectJira(+ { url: CLOUD_URL, email: "[email protected]", apiToken: TOKEN },+ { fetch: jira.fetch },+ );+ const progress: string[] = [];+ const project = await source.readProject("ABC", {+ includeComments: true,+ onProgress: (message) => progress.push(message),+ });++ const searches = jira.calls.filter((call) =>+ call.url.pathname.endsWith("/search/jql"),+ );+ expect(searches.map((call) => call.body?.nextPageToken)).toEqual([+ undefined,+ "page-2",+ ]);+ expect(searches[0]?.body).toMatchObject({+ jql: 'project = "ABC" ORDER BY Rank ASC',+ maxResults: 100,+ expand: "renderedFields",+ });+ expect(searches[0]?.body?.fields).toEqual(+ expect.arrayContaining([+ "summary",+ "description",+ "status",+ "parent",+ "issuelinks",+ "attachment",+ "comment",+ ]),+ );+ expect(+ jira.calls+ .find((call) => call.url.pathname === "/rest/agile/1.0/board")+ ?.url.searchParams.get("projectKeyOrId"),+ ).toBe("ABC");+ const commentCalls = jira.calls.filter((call) =>+ call.url.pathname.endsWith("/comment"),+ );+ expect(+ commentCalls.map((call) => [+ call.url.pathname,+ call.url.searchParams.get("startAt"),+ ]),+ ).toEqual([+ ["/rest/api/3/issue/101/comment", "0"],+ ["/rest/api/3/issue/101/comment", "1"],+ ]);+ expect(commentCalls[0]?.url.searchParams.get("expand")).toBe(+ "renderedBody",+ );+ expect(commentCalls[0]?.url.searchParams.get("maxResults")).toBe("100");++ expect(progress).toEqual([+ "Reading project and board",+ "Reading issues",+ "Reading issues (2 so far)",+ "Reading issues (3 so far)",+ "Reading comments (1 of 1)",+ ]);++ expect(project.name).toBe("Alpha");+ expect(project.key).toBe("ABC");+ expect(project.description).toBe("Core product");+ expect(project.columns).toEqual([+ { key: "column-2", name: "Selected for Development", isFinal: false },+ { key: "column-3", name: "In Progress", isFinal: false },+ { key: "column-4", name: "Done", isFinal: true },+ ]);+ expect(project.labels).toEqual([+ {+ key: "frontend",+ name: "frontend",+ color: expect.stringMatching(/^#[0-9a-f]{6}$/),+ },+ ]);+ expect(project.tasks).toEqual([+ {+ key: "102",+ number: 2,+ columnKey: null,+ title: "Issue 2",+ description: "",+ priority: "low",+ createdAt: "2024-01-01T10:00:00.000Z",+ labelKeys: [],+ comments: [],+ },+ {+ key: "101",+ number: 1,+ columnKey: "column-3",+ title: "Issue 1",+ description: "Ship it, cc @Grace Hopper",+ priority: "urgent",+ dueDate: "2024-06-30T00:00:00.000Z",+ createdAt: "2024-01-01T10:00:00.000Z",+ assignee: { name: "Ada Lovelace", email: "[email protected]" },+ labelKeys: ["frontend"],+ comments: [+ {+ author: { name: "Ada Lovelace", email: "[email protected]" },+ body: "First **note**",+ createdAt: "2024-02-01T10:00:00.000Z",+ },+ {+ author: { name: "Grace Hopper" },+ body: "Second",+ createdAt: "2024-02-02T10:00:00.000Z",+ },+ ],+ },+ {+ key: "103",+ number: 3,+ columnKey: "column-4",+ title: "Issue 3",+ description: "",+ priority: "medium",+ createdAt: "2024-01-01T10:00:00.000Z",+ labelKeys: [],+ comments: [],+ },+ ]);+ expect(project.relations).toEqual([+ { sourceKey: "101", targetKey: "103", type: "blocks" },+ { sourceKey: "101", targetKey: "103", type: "subtask" },+ ]);+ expect(project.warnings).toEqual([+ "1 issue has attachments, which are not imported.",+ "1 parent or issue link points to another project, so it was not imported.",+ ]);+ });++ it("leaves comments out of the search and skips the comment requests when not asked", async () => {+ const jira = fakeJira(cloudRoutes());+ const source = await connectJira(+ { url: CLOUD_URL, email: "[email protected]", apiToken: TOKEN },+ { fetch: jira.fetch },+ );+ const project = await source.readProject("ABC", { includeComments: false });++ const search = jira.calls.find((call) =>+ call.url.pathname.endsWith("/search/jql"),+ );+ expect(search?.body?.fields).not.toContain("comment");+ expect(jira.paths().some((path) => path.endsWith("/comment"))).toBe(false);+ expect(project.tasks.every((task) => task.comments.length === 0)).toBe(+ true,+ );+ });++ it.each([401, 403, 404])(+ "falls back to statuses when the board configuration answers %i",+ async (status) => {+ const jira = fakeJira(+ cloudRoutes({+ "GET /rest/agile/1.0/board/7/configuration": new Reply(status),+ }),+ );+ const source = await connectJira(+ { url: CLOUD_URL, email: "[email protected]", apiToken: TOKEN },+ { fetch: jira.fetch },+ );+ const project = await source.readProject("ABC", {+ includeComments: false,+ });++ expect(project.columns).toEqual([+ { key: "2", name: "Selected for Development", isFinal: false },+ { key: "3", name: "In Progress", isFinal: false },+ { key: "4", name: "Done", isFinal: true },+ ]);+ expect(project.tasks.map((task) => [task.key, task.columnKey])).toEqual([+ ["102", null],+ ["101", "3"],+ ["103", "4"],+ ]);+ expect(project.warnings).toContain(BOARD_UNAVAILABLE_WARNING);+ },+ );++ it("uses statuses without a warning when the project has no board", async () => {+ const jira = fakeJira(+ cloudRoutes({ "GET /rest/agile/1.0/board": { values: [] } }),+ );+ const source = await connectJira(+ { url: CLOUD_URL, email: "[email protected]", apiToken: TOKEN },+ { fetch: jira.fetch },+ );+ const project = await source.readProject("ABC", { includeComments: false });++ expect(project.columns.map((column) => column.key)).toEqual([+ "2",+ "3",+ "4",+ ]);+ expect(project.warnings).not.toContain(BOARD_UNAVAILABLE_WARNING);+ expect(jira.paths().some((path) => path.endsWith("/configuration"))).toBe(+ false,+ );+ });++ it("explains a project that does not exist", async () => {+ const jira = fakeJira(cloudRoutes());+ const source = await connectJira(+ { url: CLOUD_URL, email: "[email protected]", apiToken: TOKEN },+ { fetch: jira.fetch },+ );+ await expect(+ source.readProject("NOPE", { includeComments: false }),+ ).rejects.toThrow(+ 'Jira could not find the project "NOPE", or this account cannot browse it.',+ );+ });+});++describe("readProject on Data Center", () => {+ it("pages issues by offset and uses statuses when Jira Software is missing", async () => {+ const jira = fakeJira(serverRoutes());+ const source = await connectJira(+ { url: SERVER_URL, apiToken: TOKEN },+ { fetch: jira.fetch },+ );+ const progress: string[] = [];+ const project = await source.readProject("ABC", {+ includeComments: true,+ onProgress: (message) => progress.push(message),+ });++ const searches = jira.calls.filter((call) =>+ call.url.pathname.endsWith("/rest/api/2/search"),+ );+ expect(+ searches.map((call) => call.url.searchParams.get("startAt")),+ ).toEqual(["0", "2"]);+ expect(searches[0]?.url.searchParams.get("jql")).toBe(+ 'project = "ABC" ORDER BY Rank ASC',+ );+ expect(searches[0]?.url.searchParams.get("expand")).toBe("renderedFields");+ expect(searches[0]?.url.searchParams.get("fields")?.split(",")).toContain(+ "comment",+ );+ expect(jira.paths().some((path) => path.endsWith("/comment"))).toBe(false);+ expect(progress).toContain("Reading issues (3 so far)");++ expect(project.columns.map((column) => column.key)).toEqual([+ "2",+ "3",+ "4",+ ]);+ expect(project.tasks.map((task) => [task.key, task.columnKey])).toEqual([+ ["201", "2"],+ ["203", "3"],+ ["202", "4"],+ ]);+ expect(project.warnings).toEqual([]);+ });++ it("orders by creation when the Rank field does not exist", async () => {+ const jira = fakeJira(+ serverRoutes({+ "GET /jira/rest/api/2/search": (request: Request) => {+ const jql = request.url.searchParams.get("jql") ?? "";+ if (jql.includes("Rank")) {+ return new Reply(400, {+ errorMessages: [+ "Field 'Rank' does not exist or you do not have permission to view it.",+ ],+ errors: {},+ });+ }+ return {+ startAt: 0,+ maxResults: 100,+ total: 1,+ issues: serverIssues().slice(0, 1),+ };+ },+ }),+ );+ const source = await connectJira(+ { url: SERVER_URL, apiToken: TOKEN },+ { fetch: jira.fetch },+ );+ const project = await source.readProject("ABC", { includeComments: false });++ expect(+ jira.calls+ .filter((call) => call.url.pathname.endsWith("/search"))+ .map((call) => call.url.searchParams.get("jql")),+ ).toEqual([+ 'project = "ABC" ORDER BY Rank ASC',+ 'project = "ABC" ORDER BY created ASC',+ ]);+ expect(project.tasks.map((task) => task.key)).toEqual(["201"]);+ });++ it("surfaces other search errors with the Jira message", async () => {+ const jira = fakeJira(+ serverRoutes({+ "GET /jira/rest/api/2/search": new Reply(400, {+ errorMessages: [+ "The value 'ABC' does not exist for the field 'project'.",+ ],+ errors: {},+ }),+ }),+ );+ const source = await connectJira(+ { url: SERVER_URL, apiToken: TOKEN },+ { fetch: jira.fetch },+ );+ await expect(+ source.readProject("ABC", { includeComments: false }),+ ).rejects.toThrow(+ "Jira: The value 'ABC' does not exist for the field 'project'.",+ );+ expect(+ jira.paths().filter((path) => path.endsWith("/search")),+ ).toHaveLength(2);+ });+});diff --git a/packages/importers/src/jira/source.ts b/packages/importers/src/jira/source.tsnew file mode 100644index 000000000..ffa64226f--- /dev/null+++ b/packages/importers/src/jira/source.ts@@ -0,0 +1,80 @@+import { SourceHttpError } from "../http.js";+import type { ConnectOptions, ImportSource, SourceProject } from "../types.js";+import type { JiraProject } from "./api-types.js";+import { resolveJiraAuth } from "./auth.js";+import { JiraClient } from "./client.js";+import { readJiraProject } from "./read-project.js";+import { parseJiraUrl } from "./url.js";++export type JiraCredentials = {+ url: string;+ email?: string;+ apiToken: string;+};++export const NOT_JIRA_MESSAGE =+ "This address does not look like a Jira site. Check the site URL.";++const PROJECT_TYPES: ReadonlyMap<string, string> = new Map([+ ["software", "Software"],+ ["business", "Business"],+ ["service_desk", "Service management"],+ ["product_discovery", "Product Discovery"],+]);++export async function connectJira(+ credentials: JiraCredentials,+ options: ConnectOptions = {},+): Promise<ImportSource> {+ const site = parseJiraUrl(credentials.url);+ const auth = resolveJiraAuth(site, credentials);+ const client = new JiraClient({+ site,+ auth,+ fetch: options.fetch,+ signal: options.signal,+ });+ await verifyAccount(client);++ return {+ async listProjects(): Promise<SourceProject[]> {+ const projects = await client.listProjects();+ return projects.map((project) => ({+ id: project.key,+ name: project.name,+ detail: projectDetail(project),+ }));+ },++ readProject(projectKey, readOptions) {+ return readJiraProject(+ client.withSignal(readOptions.signal),+ site.baseUrl,+ projectKey,+ readOptions,+ );+ },+ };+}++export function projectDetail(project: JiraProject): string {+ const type = PROJECT_TYPES.get(project.projectTypeKey ?? "");+ return type ? `${project.key} · ${type}` : project.key;+}++async function verifyAccount(client: JiraClient): Promise<void> {+ let user: Awaited<ReturnType<JiraClient["myself"]>>;+ try {+ user = await client.myself();+ } catch (error) {+ if (error instanceof SourceHttpError && error.status === 404) {+ throw new Error(NOT_JIRA_MESSAGE);+ }+ throw error;+ }+ const identified =+ typeof user === "object" &&+ user !== null &&+ Boolean(user.accountId || user.key || user.name || user.displayName);+ if (!identified) throw new Error(NOT_JIRA_MESSAGE);+}diff --git a/packages/importers/src/jira/url.test.ts b/packages/importers/src/jira/url.test.tsnew file mode 100644index 000000000..008f4f46e--- /dev/null+++ b/packages/importers/src/jira/url.test.ts@@ -0,0 +1,79 @@+import { describe, expect, it } from "vite-plus/test";+import { MISSING_URL_MESSAGE, parseJiraUrl } from "./url.js";++describe("parseJiraUrl", () => {+ it.each([+ "https://acme.atlassian.net/jira/software/projects/ABC/boards/1",+ "acme.atlassian.net",+ " ACME.atlassian.net/ ",+ "https://acme.atlassian.net/browse/ABC-12?focusedCommentId=1#top",+ "http://acme.atlassian.net/jira/your-work",+ "https://acme.atlassian.net/wiki/spaces/ENG",+ ])("reduces the Jira Cloud URL %s to the site", (url) => {+ expect(parseJiraUrl(url)).toEqual({+ baseUrl: url.trim().startsWith("http://")+ ? "http://acme.atlassian.net"+ : "https://acme.atlassian.net",+ cloud: true,+ });+ });++ it.each([+ ["https://jira.example.com/browse/ABC-1", "https://jira.example.com"],+ ["jira.example.com", "https://jira.example.com"],+ [+ "https://jira.example.com/secure/RapidBoard.jspa?rapidView=4",+ "https://jira.example.com",+ ],+ [+ "https://jira.example.com/projects/ABC/issues/ABC-1?filter=all",+ "https://jira.example.com",+ ],+ [+ "https://jira.example.com/issues/?jql=project%3DABC",+ "https://jira.example.com",+ ],+ ["https://jira.example.com/rest/api/2/myself", "https://jira.example.com"],+ [+ "https://jira.example.com/plugins/servlet/desk",+ "https://jira.example.com",+ ],+ ["https://jira.example.com/login.jsp", "https://jira.example.com"],+ ["https://jira.example.com:8443/", "https://jira.example.com:8443"],+ ])("keeps the Data Center origin for %s", (url, baseUrl) => {+ expect(parseJiraUrl(url)).toEqual({ baseUrl, cloud: false });+ });++ it.each([+ [+ "https://example.com/jira/secure/Dashboard.jspa",+ "https://example.com/jira",+ ],+ ["https://example.com/jira/browse/ABC-1", "https://example.com/jira"],+ ["https://example.com/jira/projects/ABC", "https://example.com/jira"],+ ["http://localhost:8080/jira/", "http://localhost:8080/jira"],+ [+ "https://example.com/tools/jira/issues/?jql=",+ "https://example.com/tools/jira",+ ],+ ["https://example.com/jira", "https://example.com/jira"],+ ["https://example.com/jira/login.jsp", "https://example.com/jira"],+ ])("keeps the context path of %s", (url, baseUrl) => {+ expect(parseJiraUrl(url)).toEqual({ baseUrl, cloud: false });+ });++ it("drops Cloud style app paths on other hosts", () => {+ expect(+ parseJiraUrl(+ "https://jira.example.com/jira/software/projects/ABC/boards/1",+ ),+ ).toEqual({ baseUrl: "https://jira.example.com", cloud: false });+ });++ it.each(["", " ", "ftp://jira.example.com", "https://", null, undefined])(+ "asks for a site URL when given %j",+ (url) => {+ expect(() => parseJiraUrl(url)).toThrow(MISSING_URL_MESSAGE);+ },+ );+});diff --git a/packages/importers/src/jira/url.ts b/packages/importers/src/jira/url.tsnew file mode 100644index 000000000..78696371e--- /dev/null+++ b/packages/importers/src/jira/url.ts@@ -0,0 +1,88 @@+export type JiraSite = {+ baseUrl: string;+ cloud: boolean;+};++export const MISSING_URL_MESSAGE =+ "Add your Jira site URL, for example https://your-site.atlassian.net";++const UI_SEGMENTS = new Set([+ "browse",+ "secure",+ "projects",+ "plugins",+ "issues",+ "rest",+ "servicedesk",+]);++const CLOUD_APP_SEGMENTS = new Set([+ "software",+ "core",+ "business",+ "your-work",+ "for-you",+ "dashboards",+ "filters",+ "plans",+ "people",+ "settings",+ "boards",+ "apps",+ "polaris",+ "discovery",+]);++const PAGE_FILE = /\.(?:jspa?|action)$/i;++export function parseJiraUrl(rawUrl: string | null | undefined): JiraSite {+ const url = toUrl(rawUrl?.trim() ?? "");+ if (!url) throw new Error(MISSING_URL_MESSAGE);++ const origin = `${url.protocol}//${url.host}`;+ if (isCloudHost(url.hostname)) return { baseUrl: origin, cloud: true };++ const contextPath = contextSegments(url.pathname).join("/");+ return {+ baseUrl: contextPath ? `${origin}/${contextPath}` : origin,+ cloud: false,+ };+}++function toUrl(value: string): URL | null {+ if (!value) return null;+ const withProtocol = /^[a-z][a-z\d+.-]*:\/\//i.test(value)+ ? value+ : `https://${value.replace(/^\/+/, "")}`;+ try {+ const url = new URL(withProtocol);+ if (url.protocol !== "https:" && url.protocol !== "http:") return null;+ return url.hostname ? url : null;+ } catch {+ return null;+ }+}++function isCloudHost(hostname: string): boolean {+ return hostname.toLowerCase().endsWith(".atlassian.net");+}++function contextSegments(pathname: string): string[] {+ const segments = pathname.split("/").filter(Boolean);+ const kept: string[] = [];+ for (const [index, segment] of segments.entries()) {+ if (isUiSegment(segment, segments[index + 1])) break;+ kept.push(segment);+ }+ return kept;+}++function isUiSegment(segment: string, next: string | undefined): boolean {+ const name = segment.toLowerCase();+ if (UI_SEGMENTS.has(name) || PAGE_FILE.test(name)) return true;+ return (+ name === "jira" &&+ next !== undefined &&+ CLOUD_APP_SEGMENTS.has(next.toLowerCase())+ );+}diff --git a/packages/importers/src/jira/warnings.test.ts b/packages/importers/src/jira/warnings.test.tsnew file mode 100644index 000000000..639793f10--- /dev/null+++ b/packages/importers/src/jira/warnings.test.ts@@ -0,0 +1,38 @@+import { describe, expect, it } from "vite-plus/test";+import { BOARD_UNAVAILABLE_WARNING, buildWarnings } from "./warnings.js";++describe("buildWarnings", () => {+ it("stays quiet when nothing was dropped", () => {+ expect(+ buildWarnings({+ issuesWithAttachments: 0,+ externalLinks: 0,+ boardUnavailable: false,+ }),+ ).toEqual([]);+ });++ it("counts attachments and outside links in singular and plural", () => {+ expect(+ buildWarnings({+ issuesWithAttachments: 1,+ externalLinks: 1,+ boardUnavailable: false,+ }),+ ).toEqual([+ "1 issue has attachments, which are not imported.",+ "1 parent or issue link points to another project, so it was not imported.",+ ]);+ expect(+ buildWarnings({+ issuesWithAttachments: 3,+ externalLinks: 2,+ boardUnavailable: true,+ }),+ ).toEqual([+ "3 issues have attachments, which are not imported.",+ "2 parent or issue links point to other projects, so they were not imported.",+ BOARD_UNAVAILABLE_WARNING,+ ]);+ });+});diff --git a/packages/importers/src/jira/warnings.ts b/packages/importers/src/jira/warnings.tsnew file mode 100644index 000000000..9d6905596--- /dev/null+++ b/packages/importers/src/jira/warnings.ts@@ -0,0 +1,28 @@+export const BOARD_UNAVAILABLE_WARNING =+ "Jira did not share the board for this project, so columns follow its statuses.";++export type WarningCounts = {+ issuesWithAttachments: number;+ externalLinks: number;+ boardUnavailable: boolean;+};++export function buildWarnings(counts: WarningCounts): string[] {+ const warnings: string[] = [];+ if (counts.issuesWithAttachments > 0) {+ warnings.push(+ counts.issuesWithAttachments === 1+ ? "1 issue has attachments, which are not imported."+ : `${counts.issuesWithAttachments} issues have attachments, which are not imported.`,+ );+ }+ if (counts.externalLinks > 0) {+ warnings.push(+ counts.externalLinks === 1+ ? "1 parent or issue link points to another project, so it was not imported."+ : `${counts.externalLinks} parent or issue links point to other projects, so they were not imported.`,+ );+ }+ if (counts.boardUnavailable) warnings.push(BOARD_UNAVAILABLE_WARNING);+ return warnings;+}diff --git a/packages/importers/src/plane/turndown-plugin-gfm.d.ts b/packages/importers/src/turndown-plugin-gfm.d.tssimilarity index 100%rename from packages/importers/src/plane/turndown-plugin-gfm.d.tsrename to packages/importers/src/turndown-plugin-gfm.d.ts