@kaddo/cli 3.87.0 → 3.88.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>admin</title>
8
- <script type="module" crossorigin src="/assets/index-Bey8Xopr.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-D6yaYj2M.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-DNkI-1xG.css">
10
10
  </head>
11
11
  <body>
@@ -1075,6 +1075,7 @@ async function createAdminServer(opts) {
1075
1075
  async (request, reply) => {
1076
1076
  const q = request.query;
1077
1077
  const filters = {};
1078
+ if (q.projects) filters.projects = q.projects.split(",");
1078
1079
  if (q.statuses) filters.statuses = q.statuses.split(",");
1079
1080
  if (q.types) filters.types = q.types.split(",");
1080
1081
  if (q.labels) filters.labels = q.labels.split(",");
@@ -1108,6 +1109,7 @@ async function createAdminServer(opts) {
1108
1109
  async (request, reply) => {
1109
1110
  const q = request.query;
1110
1111
  const filters = {};
1112
+ if (q.projects) filters.projects = q.projects.split(",");
1111
1113
  if (q.statuses) filters.statuses = q.statuses.split(",");
1112
1114
  if (q.types) filters.types = q.types.split(",");
1113
1115
  if (q.labels) filters.labels = q.labels.split(",");
package/dist/core.js CHANGED
@@ -9444,6 +9444,10 @@ function defaultMessageFor(code) {
9444
9444
  function integrationError(code, message) {
9445
9445
  return new IntegrationError(code, message ?? defaultMessageFor(code));
9446
9446
  }
9447
+ function normalizeProviderError(err, fallback = "INTEGRATION_PROVIDER_ERROR") {
9448
+ if (err instanceof IntegrationError) return err;
9449
+ return new IntegrationError(fallback, defaultMessageFor(fallback));
9450
+ }
9447
9451
 
9448
9452
  // ../integrations/src/identity.ts
9449
9453
  function externalIdentityKey(integrationId, externalId) {
@@ -9513,6 +9517,11 @@ function parseFilters(raw) {
9513
9517
  const o = raw;
9514
9518
  const filters = {};
9515
9519
  let hasAny = false;
9520
+ const projects = toStringArray3(o.projects);
9521
+ if (projects?.length) {
9522
+ filters.projects = projects;
9523
+ hasAny = true;
9524
+ }
9516
9525
  const types = toStringArray3(o.types);
9517
9526
  if (types?.length) {
9518
9527
  filters.types = types;
@@ -9686,6 +9695,7 @@ function mergeFilters(base, overlay) {
9686
9695
  if (!base) return { ...overlay };
9687
9696
  if (!overlay) return { ...base };
9688
9697
  return {
9698
+ projects: overlay.projects?.length ? overlay.projects : base.projects,
9689
9699
  types: overlay.types?.length ? overlay.types : base.types,
9690
9700
  statuses: overlay.statuses?.length ? overlay.statuses : base.statuses,
9691
9701
  labels: overlay.labels?.length ? overlay.labels : base.labels,
@@ -10048,10 +10058,259 @@ function createMockAdapter(opts = {}) {
10048
10058
  };
10049
10059
  }
10050
10060
 
10061
+ // ../integrations/src/jira-adapter.ts
10062
+ var JIRA_ADAPTER_ID = "jira";
10063
+ function adfToMarkdown(node) {
10064
+ if (!node) return "";
10065
+ if (node.type === "text") {
10066
+ let t = node.text ?? "";
10067
+ for (const m of node.marks ?? []) {
10068
+ if (m.type === "strong") t = `**${t}**`;
10069
+ else if (m.type === "em") t = `*${t}*`;
10070
+ else if (m.type === "code") t = `\`${t}\``;
10071
+ else if (m.type === "strike") t = `~~${t}~~`;
10072
+ }
10073
+ return t;
10074
+ }
10075
+ const children = (node.content ?? []).map(adfToMarkdown).join("");
10076
+ switch (node.type) {
10077
+ case "doc":
10078
+ return children.trim();
10079
+ case "paragraph":
10080
+ return children + "\n\n";
10081
+ case "heading": {
10082
+ const level = Math.min(Number(node.attrs?.level) || 1, 6);
10083
+ return "#".repeat(level) + " " + children.trim() + "\n\n";
10084
+ }
10085
+ case "bulletList":
10086
+ return children;
10087
+ case "orderedList":
10088
+ return children;
10089
+ case "listItem":
10090
+ return "- " + children.trim() + "\n";
10091
+ case "blockquote":
10092
+ return children.split("\n").filter(Boolean).map((l) => "> " + l).join("\n") + "\n\n";
10093
+ case "codeBlock":
10094
+ return "```\n" + children + "```\n\n";
10095
+ case "rule":
10096
+ return "---\n\n";
10097
+ case "hardBreak":
10098
+ return "\n";
10099
+ case "mediaGroup":
10100
+ case "mediaSingle":
10101
+ case "media":
10102
+ return "";
10103
+ default:
10104
+ return children;
10105
+ }
10106
+ }
10107
+ function normalizeDescription(field) {
10108
+ if (!field) return void 0;
10109
+ if (typeof field === "string") return field || void 0;
10110
+ if (typeof field === "object" && field.type === "doc") {
10111
+ const md = adfToMarkdown(field);
10112
+ return md || void 0;
10113
+ }
10114
+ return void 0;
10115
+ }
10116
+ function escapeJql(value) {
10117
+ return '"' + value.replace(/\\/g, "\\\\").replace(/"/g, '\\"') + '"';
10118
+ }
10119
+ function buildJql(filters) {
10120
+ const clauses = [];
10121
+ if (filters?.projects?.length) clauses.push(`project IN (${filters.projects.map(escapeJql).join(", ")})`);
10122
+ if (filters?.types?.length) clauses.push(`issuetype IN (${filters.types.map(escapeJql).join(", ")})`);
10123
+ if (filters?.statuses?.length) clauses.push(`status IN (${filters.statuses.map(escapeJql).join(", ")})`);
10124
+ if (filters?.labels?.length) clauses.push(`labels IN (${filters.labels.map(escapeJql).join(", ")})`);
10125
+ if (filters?.assignees?.length) clauses.push(`assignee IN (${filters.assignees.map(escapeJql).join(", ")})`);
10126
+ if (filters?.updatedAfter) clauses.push(`updated >= ${escapeJql(filters.updatedAfter)}`);
10127
+ if (filters?.search) clauses.push(`(summary ~ ${escapeJql(filters.search)} OR description ~ ${escapeJql(filters.search)})`);
10128
+ if (filters?.providerQuery) clauses.push(`(${filters.providerQuery})`);
10129
+ return clauses.join(" AND ") || "ORDER BY updated DESC";
10130
+ }
10131
+ function normalizeBaseUrl(raw) {
10132
+ let url = raw.trim();
10133
+ if (url.endsWith("/")) url = url.slice(0, -1);
10134
+ return url;
10135
+ }
10136
+ function authHeader(email, token) {
10137
+ const encoded = typeof Buffer !== "undefined" ? Buffer.from(`${email}:${token}`).toString("base64") : btoa(`${email}:${token}`);
10138
+ return `Basic ${encoded}`;
10139
+ }
10140
+ async function jiraFetch(baseUrl, path4, auth, timeoutMs, params) {
10141
+ const url = new URL(path4, baseUrl + "/");
10142
+ if (params) for (const [k, v] of Object.entries(params)) url.searchParams.set(k, v);
10143
+ const controller = new AbortController();
10144
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
10145
+ try {
10146
+ const res = await fetch(url.toString(), {
10147
+ method: "GET",
10148
+ headers: { Authorization: auth, Accept: "application/json" },
10149
+ signal: controller.signal
10150
+ });
10151
+ if (res.status === 401) throw integrationError("INTEGRATION_UNAUTHORIZED");
10152
+ if (res.status === 403) throw integrationError("INTEGRATION_FORBIDDEN");
10153
+ if (res.status === 404) throw integrationError("INTEGRATION_NOT_FOUND");
10154
+ if (res.status === 429) throw integrationError("INTEGRATION_RATE_LIMITED");
10155
+ if (res.status >= 500) throw integrationError("INTEGRATION_UNAVAILABLE");
10156
+ if (!res.ok) throw integrationError("INTEGRATION_PROVIDER_ERROR", `Jira responded with status ${res.status}.`);
10157
+ return await res.json();
10158
+ } catch (err) {
10159
+ if (err instanceof Error && err.name === "AbortError") throw integrationError("INTEGRATION_TIMEOUT");
10160
+ throw normalizeProviderError(err);
10161
+ } finally {
10162
+ clearTimeout(timer);
10163
+ }
10164
+ }
10165
+ function normalizeIssue(issue, baseUrl, integrationId) {
10166
+ const f = issue.fields;
10167
+ const issueType = f.issuetype;
10168
+ const status = f.status;
10169
+ const assignee = f.assignee;
10170
+ const reporter = f.reporter;
10171
+ const priority = f.priority;
10172
+ const project = f.project;
10173
+ const parent = f.parent;
10174
+ const components = f.components;
10175
+ const labels = f.labels;
10176
+ return {
10177
+ externalId: issue.key,
10178
+ provider: JIRA_ADAPTER_ID,
10179
+ title: f.summary ?? issue.key,
10180
+ description: normalizeDescription(f.description),
10181
+ type: issueType?.name,
10182
+ status: status?.name,
10183
+ url: `${baseUrl}/browse/${issue.key}`,
10184
+ author: reporter ? { name: reporter.displayName, email: reporter.emailAddress, id: reporter.accountId } : void 0,
10185
+ assignees: assignee ? [{ name: assignee.displayName, email: assignee.emailAddress, id: assignee.accountId }] : void 0,
10186
+ labels,
10187
+ createdAt: f.created,
10188
+ updatedAt: f.updated,
10189
+ project: project ? { key: project.key, name: project.name, id: project.id } : void 0,
10190
+ rawMetadata: {
10191
+ ...priority?.name ? { priority: priority.name } : {},
10192
+ ...parent?.key ? { parent: parent.key } : {},
10193
+ ...components?.length ? { components: components.map((c) => c.name).filter(Boolean) } : {}
10194
+ }
10195
+ };
10196
+ }
10197
+ var SEARCH_FIELDS = "summary,description,issuetype,status,assignee,reporter,priority,labels,project,parent,components,created,updated";
10198
+ var DEFAULT_PAGE_SIZE = 50;
10199
+ var metadata = {
10200
+ id: JIRA_ADAPTER_ID,
10201
+ displayName: "Jira",
10202
+ version: "1.0.0",
10203
+ description: "Connect Jira Cloud work items to Kaddo for discovery, import and refinement.",
10204
+ icon: "jira",
10205
+ configSchema: {
10206
+ baseUrl: {
10207
+ type: "url",
10208
+ required: true,
10209
+ label: "Jira Site URL",
10210
+ description: "The URL of the Jira Cloud site.",
10211
+ placeholder: "https://company.atlassian.net"
10212
+ },
10213
+ email: {
10214
+ type: "string",
10215
+ required: true,
10216
+ label: "Email",
10217
+ description: "Email associated with the Jira API token.",
10218
+ placeholder: "user@company.com"
10219
+ }
10220
+ },
10221
+ secretSchema: {
10222
+ apiToken: {
10223
+ type: "password",
10224
+ required: true,
10225
+ label: "API Token",
10226
+ description: "Jira API token for authentication. Generate one at id.atlassian.com."
10227
+ }
10228
+ },
10229
+ filterCapabilities: {
10230
+ projects: { supported: true, multiple: true },
10231
+ types: { supported: true, multiple: true },
10232
+ statuses: { supported: true, multiple: true },
10233
+ labels: { supported: true, multiple: true },
10234
+ assignees: { supported: true, multiple: true },
10235
+ updatedAfter: { supported: true },
10236
+ search: { supported: true },
10237
+ providerQuery: { supported: true, label: "JQL" }
10238
+ }
10239
+ };
10240
+ var capabilities = {
10241
+ workItems: { list: true, read: true, import: true, write: false, statusSync: false, comments: false, webhooks: false }
10242
+ };
10243
+ function resolveConfig(context) {
10244
+ const baseUrl = context.config.baseUrl;
10245
+ const email = context.config.email;
10246
+ const apiToken = context.credentials.apiToken;
10247
+ if (typeof baseUrl !== "string" || !baseUrl) throw integrationError("INTEGRATION_CONFIG_INVALID", "Jira Site URL is required.");
10248
+ if (typeof email !== "string" || !email) throw integrationError("INTEGRATION_CONFIG_INVALID", "Email is required.");
10249
+ if (!apiToken) throw integrationError("INTEGRATION_CONFIG_INVALID", "API Token is required.");
10250
+ return { baseUrl: normalizeBaseUrl(baseUrl), email, apiToken };
10251
+ }
10252
+ function createJiraAdapter() {
10253
+ return {
10254
+ id: JIRA_ADAPTER_ID,
10255
+ metadata,
10256
+ capabilities,
10257
+ async verifyConnection(context) {
10258
+ const checkedAt = (/* @__PURE__ */ new Date()).toISOString();
10259
+ try {
10260
+ const { baseUrl, email, apiToken } = resolveConfig(context);
10261
+ const auth = authHeader(email, apiToken);
10262
+ await jiraFetch(baseUrl, "/rest/api/3/myself", auth, context.timeoutMs);
10263
+ return { status: "available", checkedAt };
10264
+ } catch (err) {
10265
+ const ie = normalizeProviderError(err);
10266
+ if (ie.code === "INTEGRATION_UNAUTHORIZED") return { status: "unauthorized", message: "Check the configured email and API token.", checkedAt };
10267
+ if (ie.code === "INTEGRATION_CONFIG_INVALID") return { status: "invalid-config", message: ie.safeMessage, checkedAt };
10268
+ return { status: "unavailable", message: ie.safeMessage, checkedAt };
10269
+ }
10270
+ },
10271
+ async listWorkItems(request) {
10272
+ const { baseUrl, email, apiToken } = resolveConfig(request.context);
10273
+ const auth = authHeader(email, apiToken);
10274
+ const jql = buildJql(request.filters);
10275
+ const pageSize = Math.min(Math.max(1, request.pageSize ?? DEFAULT_PAGE_SIZE), 100);
10276
+ const startAt = request.cursor ? Math.max(0, Number.parseInt(request.cursor, 10) || 0) : 0;
10277
+ try {
10278
+ const data = await jiraFetch(baseUrl, "/rest/api/3/search", auth, request.context.timeoutMs, {
10279
+ jql: jql.startsWith("ORDER BY") ? jql : jql + " ORDER BY updated DESC",
10280
+ startAt: String(startAt),
10281
+ maxResults: String(pageSize),
10282
+ fields: SEARCH_FIELDS
10283
+ });
10284
+ const items = data.issues.map((issue) => normalizeIssue(issue, baseUrl, request.context.integrationId));
10285
+ const nextStart = data.startAt + data.issues.length;
10286
+ const hasMore = nextStart < data.total;
10287
+ return { items, hasMore, ...hasMore ? { nextCursor: String(nextStart) } : {} };
10288
+ } catch (err) {
10289
+ throw normalizeProviderError(err);
10290
+ }
10291
+ },
10292
+ async getWorkItem(request) {
10293
+ const { baseUrl, email, apiToken } = resolveConfig(request.context);
10294
+ const auth = authHeader(email, apiToken);
10295
+ try {
10296
+ const issue = await jiraFetch(baseUrl, `/rest/api/3/issue/${encodeURIComponent(request.externalId)}`, auth, request.context.timeoutMs, {
10297
+ fields: SEARCH_FIELDS
10298
+ });
10299
+ return normalizeIssue(issue, baseUrl, request.context.integrationId);
10300
+ } catch (err) {
10301
+ const ie = normalizeProviderError(err);
10302
+ if (ie.code === "INTEGRATION_NOT_FOUND") return null;
10303
+ throw ie;
10304
+ }
10305
+ }
10306
+ };
10307
+ }
10308
+
10051
10309
  // ../integrations/src/index.ts
10052
10310
  function createDefaultRegistry() {
10053
10311
  const registry2 = new IntegrationRegistry();
10054
10312
  registry2.register(createMockAdapter());
10313
+ registry2.register(createJiraAdapter());
10055
10314
  return registry2;
10056
10315
  }
10057
10316
 
@@ -10327,6 +10586,10 @@ function updateIntegrationFilters(dir, id, filters) {
10327
10586
  if (idx < 0) throw new IntegrationServiceError("INTEGRATION_NOT_CONFIGURED", `No integration "${id}" is configured.`);
10328
10587
  const clean = {};
10329
10588
  let hasAny = false;
10589
+ if (filters.projects?.length) {
10590
+ clean.projects = filters.projects;
10591
+ hasAny = true;
10592
+ }
10330
10593
  if (filters.types?.length) {
10331
10594
  clean.types = filters.types;
10332
10595
  hasAny = true;
package/dist/index.js CHANGED
@@ -17602,6 +17602,10 @@ function defaultMessageFor(code) {
17602
17602
  function integrationError(code, message) {
17603
17603
  return new IntegrationError(code, message ?? defaultMessageFor(code));
17604
17604
  }
17605
+ function normalizeProviderError(err, fallback = "INTEGRATION_PROVIDER_ERROR") {
17606
+ if (err instanceof IntegrationError) return err;
17607
+ return new IntegrationError(fallback, defaultMessageFor(fallback));
17608
+ }
17605
17609
 
17606
17610
  // ../integrations/src/identity.ts
17607
17611
  function externalIdentityKey(integrationId, externalId) {
@@ -17671,6 +17675,11 @@ function parseFilters(raw) {
17671
17675
  const o = raw;
17672
17676
  const filters = {};
17673
17677
  let hasAny = false;
17678
+ const projects = toStringArray4(o.projects);
17679
+ if (projects?.length) {
17680
+ filters.projects = projects;
17681
+ hasAny = true;
17682
+ }
17674
17683
  const types = toStringArray4(o.types);
17675
17684
  if (types?.length) {
17676
17685
  filters.types = types;
@@ -17765,6 +17774,7 @@ function mergeFilters(base, overlay) {
17765
17774
  if (!base) return { ...overlay };
17766
17775
  if (!overlay) return { ...base };
17767
17776
  return {
17777
+ projects: overlay.projects?.length ? overlay.projects : base.projects,
17768
17778
  types: overlay.types?.length ? overlay.types : base.types,
17769
17779
  statuses: overlay.statuses?.length ? overlay.statuses : base.statuses,
17770
17780
  labels: overlay.labels?.length ? overlay.labels : base.labels,
@@ -18124,10 +18134,259 @@ function createMockAdapter(opts = {}) {
18124
18134
  };
18125
18135
  }
18126
18136
 
18137
+ // ../integrations/src/jira-adapter.ts
18138
+ var JIRA_ADAPTER_ID = "jira";
18139
+ function adfToMarkdown(node) {
18140
+ if (!node) return "";
18141
+ if (node.type === "text") {
18142
+ let t = node.text ?? "";
18143
+ for (const m of node.marks ?? []) {
18144
+ if (m.type === "strong") t = `**${t}**`;
18145
+ else if (m.type === "em") t = `*${t}*`;
18146
+ else if (m.type === "code") t = `\`${t}\``;
18147
+ else if (m.type === "strike") t = `~~${t}~~`;
18148
+ }
18149
+ return t;
18150
+ }
18151
+ const children = (node.content ?? []).map(adfToMarkdown).join("");
18152
+ switch (node.type) {
18153
+ case "doc":
18154
+ return children.trim();
18155
+ case "paragraph":
18156
+ return children + "\n\n";
18157
+ case "heading": {
18158
+ const level = Math.min(Number(node.attrs?.level) || 1, 6);
18159
+ return "#".repeat(level) + " " + children.trim() + "\n\n";
18160
+ }
18161
+ case "bulletList":
18162
+ return children;
18163
+ case "orderedList":
18164
+ return children;
18165
+ case "listItem":
18166
+ return "- " + children.trim() + "\n";
18167
+ case "blockquote":
18168
+ return children.split("\n").filter(Boolean).map((l) => "> " + l).join("\n") + "\n\n";
18169
+ case "codeBlock":
18170
+ return "```\n" + children + "```\n\n";
18171
+ case "rule":
18172
+ return "---\n\n";
18173
+ case "hardBreak":
18174
+ return "\n";
18175
+ case "mediaGroup":
18176
+ case "mediaSingle":
18177
+ case "media":
18178
+ return "";
18179
+ default:
18180
+ return children;
18181
+ }
18182
+ }
18183
+ function normalizeDescription(field) {
18184
+ if (!field) return void 0;
18185
+ if (typeof field === "string") return field || void 0;
18186
+ if (typeof field === "object" && field.type === "doc") {
18187
+ const md = adfToMarkdown(field);
18188
+ return md || void 0;
18189
+ }
18190
+ return void 0;
18191
+ }
18192
+ function escapeJql(value) {
18193
+ return '"' + value.replace(/\\/g, "\\\\").replace(/"/g, '\\"') + '"';
18194
+ }
18195
+ function buildJql(filters) {
18196
+ const clauses = [];
18197
+ if (filters?.projects?.length) clauses.push(`project IN (${filters.projects.map(escapeJql).join(", ")})`);
18198
+ if (filters?.types?.length) clauses.push(`issuetype IN (${filters.types.map(escapeJql).join(", ")})`);
18199
+ if (filters?.statuses?.length) clauses.push(`status IN (${filters.statuses.map(escapeJql).join(", ")})`);
18200
+ if (filters?.labels?.length) clauses.push(`labels IN (${filters.labels.map(escapeJql).join(", ")})`);
18201
+ if (filters?.assignees?.length) clauses.push(`assignee IN (${filters.assignees.map(escapeJql).join(", ")})`);
18202
+ if (filters?.updatedAfter) clauses.push(`updated >= ${escapeJql(filters.updatedAfter)}`);
18203
+ if (filters?.search) clauses.push(`(summary ~ ${escapeJql(filters.search)} OR description ~ ${escapeJql(filters.search)})`);
18204
+ if (filters?.providerQuery) clauses.push(`(${filters.providerQuery})`);
18205
+ return clauses.join(" AND ") || "ORDER BY updated DESC";
18206
+ }
18207
+ function normalizeBaseUrl(raw) {
18208
+ let url = raw.trim();
18209
+ if (url.endsWith("/")) url = url.slice(0, -1);
18210
+ return url;
18211
+ }
18212
+ function authHeader(email, token) {
18213
+ const encoded = typeof Buffer !== "undefined" ? Buffer.from(`${email}:${token}`).toString("base64") : btoa(`${email}:${token}`);
18214
+ return `Basic ${encoded}`;
18215
+ }
18216
+ async function jiraFetch(baseUrl, path11, auth, timeoutMs, params) {
18217
+ const url = new URL(path11, baseUrl + "/");
18218
+ if (params) for (const [k, v] of Object.entries(params)) url.searchParams.set(k, v);
18219
+ const controller = new AbortController();
18220
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
18221
+ try {
18222
+ const res = await fetch(url.toString(), {
18223
+ method: "GET",
18224
+ headers: { Authorization: auth, Accept: "application/json" },
18225
+ signal: controller.signal
18226
+ });
18227
+ if (res.status === 401) throw integrationError("INTEGRATION_UNAUTHORIZED");
18228
+ if (res.status === 403) throw integrationError("INTEGRATION_FORBIDDEN");
18229
+ if (res.status === 404) throw integrationError("INTEGRATION_NOT_FOUND");
18230
+ if (res.status === 429) throw integrationError("INTEGRATION_RATE_LIMITED");
18231
+ if (res.status >= 500) throw integrationError("INTEGRATION_UNAVAILABLE");
18232
+ if (!res.ok) throw integrationError("INTEGRATION_PROVIDER_ERROR", `Jira responded with status ${res.status}.`);
18233
+ return await res.json();
18234
+ } catch (err) {
18235
+ if (err instanceof Error && err.name === "AbortError") throw integrationError("INTEGRATION_TIMEOUT");
18236
+ throw normalizeProviderError(err);
18237
+ } finally {
18238
+ clearTimeout(timer);
18239
+ }
18240
+ }
18241
+ function normalizeIssue(issue, baseUrl, integrationId) {
18242
+ const f = issue.fields;
18243
+ const issueType = f.issuetype;
18244
+ const status = f.status;
18245
+ const assignee = f.assignee;
18246
+ const reporter = f.reporter;
18247
+ const priority = f.priority;
18248
+ const project = f.project;
18249
+ const parent = f.parent;
18250
+ const components = f.components;
18251
+ const labels = f.labels;
18252
+ return {
18253
+ externalId: issue.key,
18254
+ provider: JIRA_ADAPTER_ID,
18255
+ title: f.summary ?? issue.key,
18256
+ description: normalizeDescription(f.description),
18257
+ type: issueType?.name,
18258
+ status: status?.name,
18259
+ url: `${baseUrl}/browse/${issue.key}`,
18260
+ author: reporter ? { name: reporter.displayName, email: reporter.emailAddress, id: reporter.accountId } : void 0,
18261
+ assignees: assignee ? [{ name: assignee.displayName, email: assignee.emailAddress, id: assignee.accountId }] : void 0,
18262
+ labels,
18263
+ createdAt: f.created,
18264
+ updatedAt: f.updated,
18265
+ project: project ? { key: project.key, name: project.name, id: project.id } : void 0,
18266
+ rawMetadata: {
18267
+ ...priority?.name ? { priority: priority.name } : {},
18268
+ ...parent?.key ? { parent: parent.key } : {},
18269
+ ...components?.length ? { components: components.map((c) => c.name).filter(Boolean) } : {}
18270
+ }
18271
+ };
18272
+ }
18273
+ var SEARCH_FIELDS = "summary,description,issuetype,status,assignee,reporter,priority,labels,project,parent,components,created,updated";
18274
+ var DEFAULT_PAGE_SIZE = 50;
18275
+ var metadata = {
18276
+ id: JIRA_ADAPTER_ID,
18277
+ displayName: "Jira",
18278
+ version: "1.0.0",
18279
+ description: "Connect Jira Cloud work items to Kaddo for discovery, import and refinement.",
18280
+ icon: "jira",
18281
+ configSchema: {
18282
+ baseUrl: {
18283
+ type: "url",
18284
+ required: true,
18285
+ label: "Jira Site URL",
18286
+ description: "The URL of the Jira Cloud site.",
18287
+ placeholder: "https://company.atlassian.net"
18288
+ },
18289
+ email: {
18290
+ type: "string",
18291
+ required: true,
18292
+ label: "Email",
18293
+ description: "Email associated with the Jira API token.",
18294
+ placeholder: "user@company.com"
18295
+ }
18296
+ },
18297
+ secretSchema: {
18298
+ apiToken: {
18299
+ type: "password",
18300
+ required: true,
18301
+ label: "API Token",
18302
+ description: "Jira API token for authentication. Generate one at id.atlassian.com."
18303
+ }
18304
+ },
18305
+ filterCapabilities: {
18306
+ projects: { supported: true, multiple: true },
18307
+ types: { supported: true, multiple: true },
18308
+ statuses: { supported: true, multiple: true },
18309
+ labels: { supported: true, multiple: true },
18310
+ assignees: { supported: true, multiple: true },
18311
+ updatedAfter: { supported: true },
18312
+ search: { supported: true },
18313
+ providerQuery: { supported: true, label: "JQL" }
18314
+ }
18315
+ };
18316
+ var capabilities = {
18317
+ workItems: { list: true, read: true, import: true, write: false, statusSync: false, comments: false, webhooks: false }
18318
+ };
18319
+ function resolveConfig(context) {
18320
+ const baseUrl = context.config.baseUrl;
18321
+ const email = context.config.email;
18322
+ const apiToken = context.credentials.apiToken;
18323
+ if (typeof baseUrl !== "string" || !baseUrl) throw integrationError("INTEGRATION_CONFIG_INVALID", "Jira Site URL is required.");
18324
+ if (typeof email !== "string" || !email) throw integrationError("INTEGRATION_CONFIG_INVALID", "Email is required.");
18325
+ if (!apiToken) throw integrationError("INTEGRATION_CONFIG_INVALID", "API Token is required.");
18326
+ return { baseUrl: normalizeBaseUrl(baseUrl), email, apiToken };
18327
+ }
18328
+ function createJiraAdapter() {
18329
+ return {
18330
+ id: JIRA_ADAPTER_ID,
18331
+ metadata,
18332
+ capabilities,
18333
+ async verifyConnection(context) {
18334
+ const checkedAt = (/* @__PURE__ */ new Date()).toISOString();
18335
+ try {
18336
+ const { baseUrl, email, apiToken } = resolveConfig(context);
18337
+ const auth = authHeader(email, apiToken);
18338
+ await jiraFetch(baseUrl, "/rest/api/3/myself", auth, context.timeoutMs);
18339
+ return { status: "available", checkedAt };
18340
+ } catch (err) {
18341
+ const ie = normalizeProviderError(err);
18342
+ if (ie.code === "INTEGRATION_UNAUTHORIZED") return { status: "unauthorized", message: "Check the configured email and API token.", checkedAt };
18343
+ if (ie.code === "INTEGRATION_CONFIG_INVALID") return { status: "invalid-config", message: ie.safeMessage, checkedAt };
18344
+ return { status: "unavailable", message: ie.safeMessage, checkedAt };
18345
+ }
18346
+ },
18347
+ async listWorkItems(request) {
18348
+ const { baseUrl, email, apiToken } = resolveConfig(request.context);
18349
+ const auth = authHeader(email, apiToken);
18350
+ const jql = buildJql(request.filters);
18351
+ const pageSize = Math.min(Math.max(1, request.pageSize ?? DEFAULT_PAGE_SIZE), 100);
18352
+ const startAt = request.cursor ? Math.max(0, Number.parseInt(request.cursor, 10) || 0) : 0;
18353
+ try {
18354
+ const data = await jiraFetch(baseUrl, "/rest/api/3/search", auth, request.context.timeoutMs, {
18355
+ jql: jql.startsWith("ORDER BY") ? jql : jql + " ORDER BY updated DESC",
18356
+ startAt: String(startAt),
18357
+ maxResults: String(pageSize),
18358
+ fields: SEARCH_FIELDS
18359
+ });
18360
+ const items = data.issues.map((issue) => normalizeIssue(issue, baseUrl, request.context.integrationId));
18361
+ const nextStart = data.startAt + data.issues.length;
18362
+ const hasMore = nextStart < data.total;
18363
+ return { items, hasMore, ...hasMore ? { nextCursor: String(nextStart) } : {} };
18364
+ } catch (err) {
18365
+ throw normalizeProviderError(err);
18366
+ }
18367
+ },
18368
+ async getWorkItem(request) {
18369
+ const { baseUrl, email, apiToken } = resolveConfig(request.context);
18370
+ const auth = authHeader(email, apiToken);
18371
+ try {
18372
+ const issue = await jiraFetch(baseUrl, `/rest/api/3/issue/${encodeURIComponent(request.externalId)}`, auth, request.context.timeoutMs, {
18373
+ fields: SEARCH_FIELDS
18374
+ });
18375
+ return normalizeIssue(issue, baseUrl, request.context.integrationId);
18376
+ } catch (err) {
18377
+ const ie = normalizeProviderError(err);
18378
+ if (ie.code === "INTEGRATION_NOT_FOUND") return null;
18379
+ throw ie;
18380
+ }
18381
+ }
18382
+ };
18383
+ }
18384
+
18127
18385
  // ../integrations/src/index.ts
18128
18386
  function createDefaultRegistry() {
18129
18387
  const registry2 = new IntegrationRegistry();
18130
18388
  registry2.register(createMockAdapter());
18389
+ registry2.register(createJiraAdapter());
18131
18390
  return registry2;
18132
18391
  }
18133
18392
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaddo/cli",
3
- "version": "3.87.0",
3
+ "version": "3.88.0",
4
4
  "description": "Knowledge Driven Development toolkit",
5
5
  "license": "MIT",
6
6
  "repository": {